aboutsummaryrefslogtreecommitdiff
path: root/src/api/schema.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-07-13 10:32:57 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-07-13 10:32:57 -0700
commitfea9faaf4cd110591e9e6f07cd4d17cbc0ea5918 (patch)
treeb59ec68d139ebcb339cd7bd6d1d15eb71a423b4f /src/api/schema.zig
parentb1b459435f375bf5eef7c6aeb7285ac6c2719b62 (diff)
downloadbun-fea9faaf4cd110591e9e6f07cd4d17cbc0ea5918.tar.gz
bun-fea9faaf4cd110591e9e6f07cd4d17cbc0ea5918.tar.zst
bun-fea9faaf4cd110591e9e6f07cd4d17cbc0ea5918.zip
alright
Former-commit-id: ab73c7b323c222e5d1172c07036653ca98aa8e6b
Diffstat (limited to 'src/api/schema.zig')
-rw-r--r--src/api/schema.zig96
1 files changed, 91 insertions, 5 deletions
diff --git a/src/api/schema.zig b/src/api/schema.zig
index 23739441a..02125997e 100644
--- a/src/api/schema.zig
+++ b/src/api/schema.zig
@@ -759,6 +759,82 @@ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
};
+pub const FrameworkConfig = struct {
+/// entry_point
+entry_point: ?[]const u8 = null,
+
+
+pub fn decode(reader: anytype) anyerror!FrameworkConfig {
+ var this = std.mem.zeroes(FrameworkConfig);
+
+ while(true) {
+ switch (try reader.readByte()) {
+ 0 => { return this; },
+
+ 1 => {
+ this.entry_point = try reader.readValue([]const u8);
+},
+ else => {
+ return error.InvalidMessage;
+ },
+ }
+ }
+unreachable;
+}
+
+pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+if (this.entry_point) |entry_point| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(entry_point);
+}
+try writer.endMessage();
+}
+
+};
+
+pub const RouteConfig = struct {
+/// dir
+dir: ?[]const u8 = null,
+
+/// extensions
+extensions: []const []const u8,
+
+
+pub fn decode(reader: anytype) anyerror!RouteConfig {
+ var this = std.mem.zeroes(RouteConfig);
+
+ while(true) {
+ switch (try reader.readByte()) {
+ 0 => { return this; },
+
+ 1 => {
+ this.dir = try reader.readValue([]const u8);
+},
+ 2 => {
+ this.extensions = try reader.readArray([]const u8);
+},
+ else => {
+ return error.InvalidMessage;
+ },
+ }
+ }
+unreachable;
+}
+
+pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+if (this.dir) |dir| {
+ try writer.writeFieldID(1);
+ try writer.writeValue(dir);
+}
+if (this.extensions) |extensions| {
+ try writer.writeFieldID(2);
+ try writer.writeArray([]const u8, extensions);
+}
+try writer.endMessage();
+}
+
+};
+
pub const TransformOptions = struct {
/// jsx
jsx: ?Jsx = null,
@@ -823,8 +899,11 @@ generate_node_module_bundle: ?bool = null,
/// node_modules_bundle_path
node_modules_bundle_path: ?[]const u8 = null,
-/// javascript_framework_file
-javascript_framework_file: ?[]const u8 = null,
+/// framework
+framework: ?FrameworkConfig = null,
+
+/// router
+router: ?RouteConfig = null,
pub fn decode(reader: anytype) anyerror!TransformOptions {
@@ -898,7 +977,10 @@ pub fn decode(reader: anytype) anyerror!TransformOptions {
this.node_modules_bundle_path = try reader.readValue([]const u8);
},
22 => {
- this.javascript_framework_file = try reader.readValue([]const u8);
+ this.framework = try reader.readValue(FrameworkConfig);
+},
+ 23 => {
+ this.router = try reader.readValue(RouteConfig);
},
else => {
return error.InvalidMessage;
@@ -993,9 +1075,13 @@ if (this.node_modules_bundle_path) |node_modules_bundle_path| {
try writer.writeFieldID(21);
try writer.writeValue(node_modules_bundle_path);
}
-if (this.javascript_framework_file) |javascript_framework_file| {
+if (this.framework) |framework| {
try writer.writeFieldID(22);
- try writer.writeValue(javascript_framework_file);
+ try writer.writeValue(framework);
+}
+if (this.router) |router| {
+ try writer.writeFieldID(23);
+ try writer.writeValue(router);
}
try writer.endMessage();
}