diff options
author | 2021-10-24 16:48:47 -0700 | |
---|---|---|
committer | 2021-10-24 16:48:47 -0700 | |
commit | 2dcb465d50ad3512471692fc34c1993a7f197c67 (patch) | |
tree | b76394849488545cdefd11949fb9f4b8c9d3de36 /src/api/schema.zig | |
parent | c93655c7174c95c594893d38903a47813079ac18 (diff) | |
download | bun-2dcb465d50ad3512471692fc34c1993a7f197c67.tar.gz bun-2dcb465d50ad3512471692fc34c1993a7f197c67.tar.zst bun-2dcb465d50ad3512471692fc34c1993a7f197c67.zip |
Upgrade to latest peechy
Diffstat (limited to 'src/api/schema.zig')
-rw-r--r-- | src/api/schema.zig | 4219 |
1 files changed, 1977 insertions, 2242 deletions
diff --git a/src/api/schema.zig b/src/api/schema.zig index 7b60bf346..45589a431 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -1,4 +1,3 @@ - const std = @import("std"); pub const Reader = struct { @@ -18,7 +17,7 @@ pub const Reader = struct { } pub fn read(this: *Self, count: usize) ![]u8 { - const read_count = std.math.min(count, this.remain.len); + const read_count = @minimum(count, this.remain.len); if (read_count < count) { return error.EOF; } @@ -30,7 +29,7 @@ pub const Reader = struct { return slice; } - pub fn readAs(this: *Self, comptime T: type) !T { + pub inline fn readAs(this: *Self, comptime T: type) !T { if (!std.meta.trait.hasUniqueRepresentation(T)) { @compileError(@typeName(T) ++ " must have unique representation."); } @@ -38,7 +37,7 @@ pub const Reader = struct { return std.mem.bytesAsValue(T, try this.read(@sizeOf(T))); } - pub fn readByte(this: *Self) !u8 { + pub inline fn readByte(this: *Self) !u8 { return (try this.read(1))[0]; } @@ -59,29 +58,29 @@ pub const Reader = struct { return E.InvalidValue; } - pub fn readArray(this: *Self, comptime T: type) ![]const T { + pub inline fn readArray(this: *Self, comptime T: type) ![]const T { const length = try this.readInt(u32); if (length == 0) { return &([_]T{}); } - switch (T) { + switch (comptime T) { u8 => { return try this.read(length); }, u16, u32, i8, i16, i32 => { return std.mem.readIntSliceNative(T, this.read(length * @sizeOf(T))); }, - []const u8 => { + [:0]const u8, []const u8 => { var i: u32 = 0; - var array = try this.allocator.alloc([]const u8, length); + var array = try this.allocator.alloc(T, length); while (i < length) : (i += 1) { array[i] = try this.readArray(u8); } return array; }, else => { - switch (@typeInfo(T)) { + switch (comptime @typeInfo(T)) { .Struct => |Struct| { switch (Struct.layout) { .Packed => { @@ -110,48 +109,48 @@ pub const Reader = struct { } } - pub fn readByteArray(this: *Self) ![]u8 { + pub inline fn readByteArray(this: *Self) ![]u8 { const length = try this.readInt(u32); if (length == 0) { return &([_]u8{}); } - return try this.read(@intCast(usize, length)); + return try this.read(@as(usize, length)); } - pub fn readInt(this: *Self, comptime T: type) !T { + pub inline fn readInt(this: *Self, comptime T: type) !T { var slice = try this.read(@sizeOf(T)); return std.mem.readIntSliceNative(T, slice); } - pub fn readBool(this: *Self) !bool { + pub inline fn readBool(this: *Self) !bool { return (try this.readByte()) > 0; } - pub fn readValue(this: *Self, comptime T: type) !T { - switch (T) { + pub inline fn readValue(this: *Self, comptime T: type) !T { + switch (comptime T) { bool => { return try this.readBool(); }, u8 => { return try this.readByte(); }, - []const u8 => { + [*:0]const u8, [:0]const u8, []const u8 => { return try this.readArray(u8); }, - []const []const u8 => { + []const [:0]const u8, []const [*:0]const u8, []const []const u8 => { return try this.readArray([]const u8); }, - []u8 => { + []u8, [:0]u8, [*:0]u8 => { return try this.readArray([]u8); }, u16, u32, i8, i16, i32 => { return std.mem.readIntSliceNative(T, try this.read(@sizeOf(T))); }, else => { - switch (@typeInfo(T)) { + switch (comptime @typeInfo(T)) { .Struct => |Struct| { switch (Struct.layout) { .Packed => { @@ -185,28 +184,28 @@ pub fn Writer(comptime WritableStream: type) type { return Self{ .writable = writable }; } - pub fn write(this: *Self, bytes: anytype) !void { + pub inline fn write(this: *Self, bytes: anytype) !void { _ = try this.writable.write(bytes); } - pub fn writeByte(this: *Self, byte: u8) !void { + pub inline fn writeByte(this: *Self, byte: u8) !void { _ = try this.writable.write(&[1]u8{byte}); } - pub fn writeInt(this: *Self, int: anytype) !void { + pub inline fn writeInt(this: *Self, int: anytype) !void { try this.write(std.mem.asBytes(&int)); } - pub fn writeFieldID(this: *Self, comptime id: comptime_int) !void { + pub inline fn writeFieldID(this: *Self, comptime id: comptime_int) !void { try this.writeByte(id); } - pub fn writeEnum(this: *Self, val: anytype) !void { + pub inline fn writeEnum(this: *Self, val: anytype) !void { try this.writeInt(@enumToInt(val)); } - pub fn writeValue(this: *Self, slice: anytype) !void { - switch (@TypeOf(slice)) { + pub fn writeValue(this: *Self, comptime SliceType: type, slice: SliceType) !void { + switch (SliceType) { []u16, []u32, []i16, @@ -217,11 +216,37 @@ pub fn Writer(comptime WritableStream: type) type { []const i16, []const i32, []const i8, + [:0]u16, + [:0]u32, + [:0]i16, + [:0]i32, + [:0]i8, + [:0]const u16, + [:0]const u32, + [:0]const i16, + [:0]const i32, + [:0]const i8, + [*:0]u16, + [*:0]u32, + [*:0]i16, + [*:0]i32, + [*:0]i8, + [*:0]const u16, + [*:0]const u32, + [*:0]const i16, + [*:0]const i32, + [*:0]const i8, => { - try this.writeArray(@TypeOf(slice), slice); + try this.writeArray(SliceType, slice); }, - []u8, []const u8 => { + []u8, + []const u8, + [:0]u8, + [:0]const u8, + [*:0]u8, + [*:0]const u8, + => { try this.writeArray(u8, slice); }, @@ -238,7 +263,7 @@ pub fn Writer(comptime WritableStream: type) type { } } - pub fn writeArray(this: *Self, comptime T: type, slice: anytype) !void { + pub inline fn writeArray(this: *Self, comptime T: type, slice: anytype) !void { try this.writeInt(@truncate(u32, slice.len)); switch (T) { @@ -248,6 +273,7 @@ pub fn Writer(comptime WritableStream: type) type { u16, u32, i16, i32, i8 => { try this.write(std.mem.asBytes(slice)); }, + [:0]u8, []u8, []u16, []u32, @@ -255,11 +281,32 @@ pub fn Writer(comptime WritableStream: type) type { []i32, []i8, []const u8, + [:0]const u8, []const u16, []const u32, []const i16, []const i32, []const i8, + [:0]u16, + [:0]u32, + [:0]i16, + [:0]i32, + [:0]i8, + [:0]const u16, + [:0]const u32, + [:0]const i16, + [:0]const i32, + [:0]const i8, + [*:0]u16, + [*:0]u32, + [*:0]i16, + [*:0]i32, + [*:0]i8, + [*:0]const u16, + [*:0]const u32, + [*:0]const i16, + [*:0]const i32, + [*:0]const i8, => { for (slice) |num_slice| { try this.writeArray(std.meta.Child(@TypeOf(num_slice)), num_slice); @@ -273,7 +320,7 @@ pub fn Writer(comptime WritableStream: type) type { } } - pub fn endMessage(this: *Self) !void { + pub inline fn endMessage(this: *Self) !void { try this.writeByte(0); } }; @@ -282,2680 +329,2368 @@ pub fn Writer(comptime WritableStream: type) type { pub const ByteWriter = Writer(*std.io.FixedBufferStream([]u8)); pub const FileWriter = Writer(std.fs.File); +pub const Api = struct { + pub const Loader = enum(u8) { + _none, + /// jsx + jsx, + /// js + js, + /// ts + ts, -pub const Api = struct { - -pub const Loader = enum(u8) { + /// tsx + tsx, -_none, - /// jsx - jsx, + /// css + css, - /// js - js, + /// file + file, - /// ts - ts, + /// json + json, - /// tsx - tsx, - - /// css - css, - - /// file - file, - - /// json - json, - -_, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - - -}; - -pub const FrameworkEntryPointType = enum(u8) { - -_none, - /// client - client, - - /// server - server, - - /// fallback - fallback, - -_, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - - -}; + _, -pub const StackFrameScope = enum(u8) { - -_none, - /// Eval - eval, - - /// Module - module, - - /// Function - function, - - /// Global - global, - - /// Wasm - wasm, - - /// Constructor - constructor, - -_, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - - -}; + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -pub const StackFrame = struct { -/// function_name -function_name: []const u8, + pub const FrameworkEntryPointType = enum(u8) { + _none, + /// client + client, -/// file -file: []const u8, + /// server + server, -/// position -position: StackFramePosition, + /// fallback + fallback, -/// scope -scope: StackFrameScope, + _, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -pub fn decode(reader: anytype) anyerror!StackFrame { - var this = std.mem.zeroes(StackFrame); + pub const StackFrameScope = enum(u8) { + _none, + /// Eval + eval, - this.function_name = try reader.readValue([]const u8); - this.file = try reader.readValue([]const u8); - this.position = try reader.readValue(StackFramePosition); - this.scope = try reader.readValue(StackFrameScope); - return this; -} + /// Module + module, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.function_name); - try writer.writeValue(this.file); - try writer.writeValue(this.position); - try writer.writeEnum(this.scope); -} + /// Function + function, -}; - -pub const StackFramePosition = packed struct { -/// source_offset -source_offset: i32 = 0, + /// Global + global, -/// line -line: i32 = 0, + /// Wasm + wasm, -/// line_start -line_start: i32 = 0, + /// Constructor + constructor, -/// line_stop -line_stop: i32 = 0, + _, -/// column_start -column_start: i32 = 0, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -/// column_stop -column_stop: i32 = 0, + pub const StackFrame = struct { + /// function_name + function_name: []const u8, -/// expression_start -expression_start: i32 = 0, + /// file + file: []const u8, -/// expression_stop -expression_stop: i32 = 0, + /// position + position: StackFramePosition, + /// scope + scope: StackFrameScope, -pub fn decode(reader: anytype) anyerror!StackFramePosition { - var this = std.mem.zeroes(StackFramePosition); + pub fn decode(reader: anytype) anyerror!StackFrame { + var this = std.mem.zeroes(StackFrame); - this.source_offset = try reader.readValue(i32); - this.line = try reader.readValue(i32); - this.line_start = try reader.readValue(i32); - this.line_stop = try reader.readValue(i32); - this.column_start = try reader.readValue(i32); - this.column_stop = try reader.readValue(i32); - this.expression_start = try reader.readValue(i32); - this.expression_stop = try reader.readValue(i32); - return this; -} + this.function_name = try reader.readValue([]const u8); + this.file = try reader.readValue([]const u8); + this.position = try reader.readValue(StackFramePosition); + this.scope = try reader.readValue(StackFrameScope); + return this; + } -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.source_offset); - try writer.writeInt(this.line); - try writer.writeInt(this.line_start); - try writer.writeInt(this.line_stop); - try writer.writeInt(this.column_start); - try writer.writeInt(this.column_stop); - try writer.writeInt(this.expression_start); - try writer.writeInt(this.expression_stop); -} + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.function_name), this.function_name); + try writer.writeValue(@TypeOf(this.file), this.file); + try writer.writeValue(@TypeOf(this.position), this.position); + try writer.writeEnum(this.scope); + } + }; -}; + pub const StackFramePosition = packed struct { + /// source_offset + source_offset: i32 = 0, -pub const SourceLine = struct { -/// line -line: i32 = 0, + /// line + line: i32 = 0, -/// text -text: []const u8, + /// line_start + line_start: i32 = 0, + /// line_stop + line_stop: i32 = 0, -pub fn decode(reader: anytype) anyerror!SourceLine { - var this = std.mem.zeroes(SourceLine); + /// column_start + column_start: i32 = 0, - this.line = try reader.readValue(i32); - this.text = try reader.readValue([]const u8); - return this; -} + /// column_stop + column_stop: i32 = 0, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.line); - try writer.writeValue(this.text); -} + /// expression_start + expression_start: i32 = 0, -}; + /// expression_stop + expression_stop: i32 = 0, -pub const StackTrace = struct { -/// source_lines -source_lines: []const SourceLine, + pub fn decode(reader: anytype) anyerror!StackFramePosition { + var this = std.mem.zeroes(StackFramePosition); -/// frames -frames: []const StackFrame, + this.source_offset = try reader.readValue(i32); + this.line = try reader.readValue(i32); + this.line_start = try reader.readValue(i32); + this.line_stop = try reader.readValue(i32); + this.column_start = try reader.readValue(i32); + this.column_stop = try reader.readValue(i32); + this.expression_start = try reader.readValue(i32); + this.expression_stop = try reader.readValue(i32); + return this; + } + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.source_offset); + try writer.writeInt(this.line); + try writer.writeInt(this.line_start); + try writer.writeInt(this.line_stop); + try writer.writeInt(this.column_start); + try writer.writeInt(this.column_stop); + try writer.writeInt(this.expression_start); + try writer.writeInt(this.expression_stop); + } + }; -pub fn decode(reader: anytype) anyerror!StackTrace { - var this = std.mem.zeroes(StackTrace); + pub const SourceLine = struct { + /// line + line: i32 = 0, - this.source_lines = try reader.readArray(SourceLine); - this.frames = try reader.readArray(StackFrame); - return this; -} + /// text + text: []const u8, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(SourceLine, this.source_lines); - try writer.writeArray(StackFrame, this.frames); -} + pub fn decode(reader: anytype) anyerror!SourceLine { + var this = std.mem.zeroes(SourceLine); -}; + this.line = try reader.readValue(i32); + this.text = try reader.readValue([]const u8); + return this; + } -pub const JsException = struct { -/// name -name: ?[]const u8 = null, - -/// message -message: ?[]const u8 = null, - -/// runtime_type -runtime_type: ?u16 = null, - -/// code -code: ?u8 = null, - -/// stack -stack: ?StackTrace = null, - - -pub fn decode(reader: anytype) anyerror!JsException { - var this = std.mem.zeroes(JsException); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.name = try reader.readValue([]const u8); -}, - 2 => { - this.message = try reader.readValue([]const u8); -}, - 3 => { - this.runtime_type = try reader.readValue(u16); -}, - 4 => { - this.code = try reader.readValue(u8); -}, - 5 => { - this.stack = try reader.readValue(StackTrace); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.line); + try writer.writeValue(@TypeOf(this.text), this.text); + } + }; -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.name) |name| { - try writer.writeFieldID(1); - try writer.writeValue(name); -} -if (this.message) |message| { - try writer.writeFieldID(2); - try writer.writeValue(message); -} -if (this.runtime_type) |runtime_type| { - try writer.writeFieldID(3); - try writer.writeInt(runtime_type); -} -if (this.code) |code| { - try writer.writeFieldID(4); - try writer.writeInt(code); -} -if (this.stack) |stack| { - try writer.writeFieldID(5); - try writer.writeValue(stack); -} -try writer.endMessage(); -} + pub const StackTrace = struct { + /// source_lines + source_lines: []const SourceLine, -}; + /// frames + frames: []const StackFrame, -pub const FallbackStep = enum(u8) { + pub fn decode(reader: anytype) anyerror!StackTrace { + var this = std.mem.zeroes(StackTrace); -_none, - /// ssr_disabled - ssr_disabled, + this.source_lines = try reader.readArray(SourceLine); + this.frames = try reader.readArray(StackFrame); + return this; + } - /// create_vm - create_vm, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeArray(SourceLine, this.source_lines); + try writer.writeArray(StackFrame, this.frames); + } + }; - /// configure_router - configure_router, + pub const JsException = struct { + /// name + name: ?[]const u8 = null, - /// configure_defines - configure_defines, + /// message + message: ?[]const u8 = null, - /// resolve_entry_point - resolve_entry_point, + /// runtime_type + runtime_type: ?u16 = null, - /// load_entry_point - load_entry_point, + /// code + code: ?u8 = null, - /// eval_entry_point - eval_entry_point, + /// stack + stack: ?StackTrace = null, - /// fetch_event_handler - fetch_event_handler, + pub fn decode(reader: anytype) anyerror!JsException { + var this = std.mem.zeroes(JsException); -_, + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + 1 => { + this.name = try reader.readValue([]const u8); + }, + 2 => { + this.message = try reader.readValue([]const u8); + }, + 3 => { + this.runtime_type = try reader.readValue(u16); + }, + 4 => { + this.code = try reader.readValue(u8); + }, + 5 => { + this.stack = try reader.readValue(StackTrace); + }, + else => { + return error.InvalidMessage; + }, } + } + unreachable; + } - -}; - -pub const Problems = struct { -/// code -code: u16 = 0, - -/// name -name: []const u8, - -/// exceptions -exceptions: []const JsException, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.name) |name| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(name), name); + } + if (this.message) |message| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(message), message); + } + if (this.runtime_type) |runtime_type| { + try writer.writeFieldID(3); + try writer.writeInt(runtime_type); + } + if (this.code) |code| { + try writer.writeFieldID(4); + try writer.writeInt(code); + } + if (this.stack) |stack| { + try writer.writeFieldID(5); + try writer.writeValue(@TypeOf(stack), stack); + } + try writer.endMessage(); + } + }; -/// build -build: Log, + pub const FallbackStep = enum(u8) { + _none, + /// ssr_disabled + ssr_disabled, + /// create_vm + create_vm, -pub fn decode(reader: anytype) anyerror!Problems { - var this = std.mem.zeroes(Problems); + /// configure_router + configure_router, - this.code = try reader.readValue(u16); - this.name = try reader.readValue([]const u8); - this.exceptions = try reader.readArray(JsException); - this.build = try reader.readValue(Log); - return this; -} + /// configure_defines + configure_defines, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.code); - try writer.writeValue(this.name); - try writer.writeArray(JsException, this.exceptions); - try writer.writeValue(this.build); -} + /// resolve_entry_point + resolve_entry_point, -}; + /// load_entry_point + load_entry_point, -pub const Router = struct { -/// routes -routes: StringMap, + /// eval_entry_point + eval_entry_point, -/// route -route: i32 = 0, + /// fetch_event_handler + fetch_event_handler, -/// params -params: StringMap, + _, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -pub fn decode(reader: anytype) anyerror!Router { - var this = std.mem.zeroes(Router); + pub const Problems = struct { + /// code + code: u16 = 0, - this.routes = try reader.readValue(StringMap); - this.route = try reader.readValue(i32); - this.params = try reader.readValue(StringMap); - return this; -} + /// name + name: []const u8, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.routes); - try writer.writeInt(this.route); - try writer.writeValue(this.params); -} + /// exceptions + exceptions: []const JsException, -}; + /// build + build: Log, -pub const FallbackMessageContainer = struct { -/// message -message: ?[]const u8 = null, - -/// router -router: ?Router = null, - -/// reason -reason: ?FallbackStep = null, - -/// problems -problems: ?Problems = null, - -/// cwd -cwd: ?[]const u8 = null, - - -pub fn decode(reader: anytype) anyerror!FallbackMessageContainer { - var this = std.mem.zeroes(FallbackMessageContainer); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.message = try reader.readValue([]const u8); -}, - 2 => { - this.router = try reader.readValue(Router); -}, - 3 => { - this.reason = try reader.readValue(FallbackStep); -}, - 4 => { - this.problems = try reader.readValue(Problems); -}, - 5 => { - this.cwd = try reader.readValue([]const u8); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + pub fn decode(reader: anytype) anyerror!Problems { + var this = std.mem.zeroes(Problems); -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.message) |message| { - try writer.writeFieldID(1); - try writer.writeValue(message); -} -if (this.router) |router| { - try writer.writeFieldID(2); - try writer.writeValue(router); -} -if (this.reason) |reason| { - try writer.writeFieldID(3); - try writer.writeEnum(reason); -} -if (this.problems) |problems| { - try writer.writeFieldID(4); - try writer.writeValue(problems); -} -if (this.cwd) |cwd| { - try writer.writeFieldID(5); - try writer.writeValue(cwd); -} -try writer.endMessage(); -} + this.code = try reader.readValue(u16); + this.name = try reader.readValue([]const u8); + this.exceptions = try reader.readArray(JsException); + this.build = try reader.readValue(Log); + return this; + } -}; + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.code); + try writer.writeValue(@TypeOf(this.name), this.name); + try writer.writeArray(JsException, this.exceptions); + try writer.writeValue(@TypeOf(this.build), this.build); + } + }; -pub const ResolveMode = enum(u8) { + pub const Router = struct { + /// routes + routes: StringMap, -_none, - /// disable - disable, + /// route + route: i32 = 0, - /// lazy - lazy, + /// params + params: StringMap, - /// dev - dev, + pub fn decode(reader: anytype) anyerror!Router { + var this = std.mem.zeroes(Router); - /// bundle - bundle, + this.routes = try reader.readValue(StringMap); + this.route = try reader.readValue(i32); + this.params = try reader.readValue(StringMap); + return this; + } -_, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.routes), this.routes); + try writer.writeInt(this.route); + try writer.writeValue(@TypeOf(this.params), this.params); + } + }; - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } + pub const FallbackMessageContainer = struct { + /// message + message: ?[]const u8 = null, - -}; + /// router + router: ?Router = null, -pub const Platform = enum(u8) { + /// reason + reason: ?FallbackStep = null, -_none, - /// browser - browser, + /// problems + problems: ?Problems = null, - /// node - node, + /// cwd + cwd: ?[]const u8 = null, - /// bun - bun, + pub fn decode(reader: anytype) anyerror!FallbackMessageContainer { + var this = std.mem.zeroes(FallbackMessageContainer); -_, + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + 1 => { + this.message = try reader.readValue([]const u8); + }, + 2 => { + this.router = try reader.readValue(Router); + }, + 3 => { + this.reason = try reader.readValue(FallbackStep); + }, + 4 => { + this.problems = try reader.readValue(Problems); + }, + 5 => { + this.cwd = try reader.readValue([]const u8); + }, + else => { + return error.InvalidMessage; + }, } + } + unreachable; + } - -}; - -pub const CssInJsBehavior = enum(u8) { - -_none, - /// facade - facade, - - /// facade_onimportcss - facade_onimportcss, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.message) |message| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(message), message); + } + if (this.router) |router| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(router), router); + } + if (this.reason) |reason| { + try writer.writeFieldID(3); + try writer.writeEnum(reason); + } + if (this.problems) |problems| { + try writer.writeFieldID(4); + try writer.writeValue(@TypeOf(problems), problems); + } + if (this.cwd) |cwd| { + try writer.writeFieldID(5); + try writer.writeValue(@TypeOf(cwd), cwd); + } + try writer.endMessage(); + } + }; - /// auto_onimportcss - auto_onimportcss, + pub const ResolveMode = enum(u8) { + _none, + /// disable + disable, -_, + /// lazy + lazy, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } + /// dev + dev, - -}; + /// bundle + bundle, -pub const JsxRuntime = enum(u8) { + _, -_none, - /// automatic - automatic, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; - /// classic - classic, + pub const Platform = enum(u8) { + _none, + /// browser + browser, -_, + /// node + node, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } + /// bun + bun, - -}; + _, -pub const Jsx = struct { -/// factory -factory: []const u8, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -/// runtime -runtime: JsxRuntime, + pub const CssInJsBehavior = enum(u8) { + _none, + /// facade + facade, -/// fragment -fragment: []const u8, + /// facade_onimportcss + facade_onimportcss, -/// development -development: bool = false, + /// auto_onimportcss + auto_onimportcss, -/// import_source -import_source: []const u8, + _, -/// react_fast_refresh -react_fast_refresh: bool = false, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; + pub const JsxRuntime = enum(u8) { + _none, + /// automatic + automatic, -pub fn decode(reader: anytype) anyerror!Jsx { - var this = std.mem.zeroes(Jsx); + /// classic + classic, - this.factory = try reader.readValue([]const u8); - this.runtime = try reader.readValue(JsxRuntime); - this.fragment = try reader.readValue([]const u8); - this.development = try reader.readValue(bool); - this.import_source = try reader.readValue([]const u8); - this.react_fast_refresh = try reader.readValue(bool); - return this; -} + _, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.factory); - try writer.writeEnum(this.runtime); - try writer.writeValue(this.fragment); - try writer.writeInt(@intCast(u8, @boolToInt(this.development))); - try writer.writeValue(this.import_source); - try writer.writeInt(@intCast(u8, @boolToInt(this.react_fast_refresh))); -} + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -}; + pub const Jsx = struct { + /// factory + factory: []const u8, -pub const StringPointer = packed struct { -/// offset -offset: u32 = 0, + /// runtime + runtime: JsxRuntime, -/// length -length: u32 = 0, + /// fragment + fragment: []const u8, + /// development + development: bool = false, -pub fn decode(reader: anytype) anyerror!StringPointer { - var this = std.mem.zeroes(StringPointer); + /// import_source + import_source: []const u8, - this.offset = try reader.readValue(u32); - this.length = try reader.readValue(u32); - return this; -} + /// react_fast_refresh + react_fast_refresh: bool = false, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.offset); - try writer.writeInt(this.length); -} + pub fn decode(reader: anytype) anyerror!Jsx { + var this = std.mem.zeroes(Jsx); -}; + this.factory = try reader.readValue([]const u8); + this.runtime = try reader.readValue(JsxRuntime); + this.fragment = try reader.readValue([]const u8); + this.development = try reader.readValue(bool); + this.import_source = try reader.readValue([]const u8); + this.react_fast_refresh = try reader.readValue(bool); + return this; + } -pub const JavascriptBundledModule = struct { -/// path -path: StringPointer, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.factory), this.factory); + try writer.writeEnum(this.runtime); + try writer.writeValue(@TypeOf(this.fragment), this.fragment); + try writer.writeInt(@as(u8, @boolToInt(this.development))); + try writer.writeValue(@TypeOf(this.import_source), this.import_source); + try writer.writeInt(@as(u8, @boolToInt(this.react_fast_refresh))); + } + }; -/// code -code: StringPointer, + pub const StringPointer = packed struct { + /// offset + offset: u32 = 0, -/// package_id -package_id: u32 = 0, + /// length + length: u32 = 0, -/// id -id: u32 = 0, + pub fn decode(reader: anytype) anyerror!StringPointer { + var this = std.mem.zeroes(StringPointer); -/// path_extname_length -path_extname_length: u8 = 0, + this.offset = try reader.readValue(u32); + this.length = try reader.readValue(u32); + return this; + } + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.offset); + try writer.writeInt(this.length); + } + }; -pub fn decode(reader: anytype) anyerror!JavascriptBundledModule { - var this = std.mem.zeroes(JavascriptBundledModule); + pub const JavascriptBundledModule = struct { + /// path + path: StringPointer, - this.path = try reader.readValue(StringPointer); - this.code = try reader.readValue(StringPointer); - this.package_id = try reader.readValue(u32); - this.id = try reader.readValue(u32); - this.path_extname_length = try reader.readValue(u8); - return this; -} + /// code + code: StringPointer, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.path); - try writer.writeValue(this.code); - try writer.writeInt(this.package_id); - try writer.writeInt(this.id); - try writer.writeInt(this.path_extname_length); -} + /// package_id + package_id: u32 = 0, -}; + /// id + id: u32 = 0, -pub const JavascriptBundledPackage = struct { -/// name -name: StringPointer, + /// path_extname_length + path_extname_length: u8 = 0, -/// version -version: StringPointer, + pub fn decode(reader: anytype) anyerror!JavascriptBundledModule { + var this = std.mem.zeroes(JavascriptBundledModule); -/// hash -hash: u32 = 0, + this.path = try reader.readValue(StringPointer); + this.code = try reader.readValue(StringPointer); + this.package_id = try reader.readValue(u32); + this.id = try reader.readValue(u32); + this.path_extname_length = try reader.readValue(u8); + return this; + } -/// modules_offset -modules_offset: u32 = 0, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.path), this.path); + try writer.writeValue(@TypeOf(this.code), this.code); + try writer.writeInt(this.package_id); + try writer.writeInt(this.id); + try writer.writeInt(this.path_extname_length); + } + }; -/// modules_length -modules_length: u32 = 0, + pub const JavascriptBundledPackage = struct { + /// name + name: StringPointer, + /// version + version: StringPointer, -pub fn decode(reader: anytype) anyerror!JavascriptBundledPackage { - var this = std.mem.zeroes(JavascriptBundledPackage); + /// hash + hash: u32 = 0, - this.name = try reader.readValue(StringPointer); - this.version = try reader.readValue(StringPointer); - this.hash = try reader.readValue(u32); - this.modules_offset = try reader.readValue(u32); - this.modules_length = try reader.readValue(u32); - return this; -} + /// modules_offset + modules_offset: u32 = 0, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.name); - try writer.writeValue(this.version); - try writer.writeInt(this.hash); - try writer.writeInt(this.modules_offset); - try writer.writeInt(this.modules_length); -} + /// modules_length + modules_length: u32 = 0, -}; + pub fn decode(reader: anytype) anyerror!JavascriptBundledPackage { + var this = std.mem.zeroes(JavascriptBundledPackage); -pub const JavascriptBundle = struct { -/// modules -modules: []const JavascriptBundledModule, + this.name = try reader.readValue(StringPointer); + this.version = try reader.readValue(StringPointer); + this.hash = try reader.readValue(u32); + this.modules_offset = try reader.readValue(u32); + this.modules_length = try reader.readValue(u32); + return this; + } -/// packages -packages: []const JavascriptBundledPackage, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.name), this.name); + try writer.writeValue(@TypeOf(this.version), this.version); + try writer.writeInt(this.hash); + try writer.writeInt(this.modules_offset); + try writer.writeInt(this.modules_length); + } + }; -/// etag -etag: []const u8, + pub const JavascriptBundle = struct { + /// modules + modules: []const JavascriptBundledModule, -/// generated_at -generated_at: u32 = 0, + /// packages + packages: []const JavascriptBundledPackage, -/// app_package_json_dependencies_hash -app_package_json_dependencies_hash: []const u8, + /// etag + etag: []const u8, -/// import_from_name -import_from_name: []const u8, + /// generated_at + generated_at: u32 = 0, -/// manifest_string -manifest_string: []const u8, + /// app_package_json_dependencies_hash + app_package_json_dependencies_hash: []const u8, + /// import_from_name + import_from_name: []const u8, -pub fn decode(reader: anytype) anyerror!JavascriptBundle { - var this = std.mem.zeroes(JavascriptBundle); + /// manifest_string + manifest_string: []const u8, - this.modules = try reader.readArray(JavascriptBundledModule); - this.packages = try reader.readArray(JavascriptBundledPackage); - this.etag = try reader.readArray(u8); - this.generated_at = try reader.readValue(u32); - this.app_package_json_dependencies_hash = try reader.readArray(u8); - this.import_from_name = try reader.readArray(u8); - this.manifest_string = try reader.readArray(u8); - return this; -} + pub fn decode(reader: anytype) anyerror!JavascriptBundle { + var this = std.mem.zeroes(JavascriptBundle); -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(JavascriptBundledModule, this.modules); - try writer.writeArray(JavascriptBundledPackage, this.packages); - try writer.writeArray(u8, this.etag); - try writer.writeInt(this.generated_at); - try writer.writeArray(u8, this.app_package_json_dependencies_hash); - try writer.writeArray(u8, this.import_from_name); - try writer.writeArray(u8, this.manifest_string); -} + this.modules = try reader.readArray(JavascriptBundledModule); + this.packages = try reader.readArray(JavascriptBundledPackage); + this.etag = try reader.readArray(u8); + this.generated_at = try reader.readValue(u32); + this.app_package_json_dependencies_hash = try reader.readArray(u8); + this.import_from_name = try reader.readArray(u8); + this.manifest_string = try reader.readArray(u8); + return this; + } -}; + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeArray(JavascriptBundledModule, this.modules); + try writer.writeArray(JavascriptBundledPackage, this.packages); + try writer.writeArray(u8, this.etag); + try writer.writeInt(this.generated_at); + try writer.writeArray(u8, this.app_package_json_dependencies_hash); + try writer.writeArray(u8, this.import_from_name); + try writer.writeArray(u8, this.manifest_string); + } + }; -pub const JavascriptBundleContainer = struct { -/// bundle_format_version -bundle_format_version: ?u32 = null, - -/// routes -routes: ?LoadedRouteConfig = null, - -/// framework -framework: ?LoadedFramework = null, - -/// bundle -bundle: ?JavascriptBundle = null, - -/// code_length -code_length: ?u32 = null, - - -pub fn decode(reader: anytype) anyerror!JavascriptBundleContainer { - var this = std.mem.zeroes(JavascriptBundleContainer); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.bundle_format_version = try reader.readValue(u32); -}, - 2 => { - this.routes = try reader.readValue(LoadedRouteConfig); -}, - 3 => { - this.framework = try reader.readValue(LoadedFramework); -}, - 4 => { - this.bundle = try reader.readValue(JavascriptBundle); -}, - 5 => { - this.code_length = try reader.readValue(u32); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + pub const JavascriptBundleContainer = struct { + /// bundle_format_version + bundle_format_version: ?u32 = null, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.bundle_format_version) |bundle_format_version| { - try writer.writeFieldID(1); - try writer.writeInt(bundle_format_version); -} -if (this.routes) |routes| { - try writer.writeFieldID(2); - try writer.writeValue(routes); -} -if (this.framework) |framework| { - try writer.writeFieldID(3); - try writer.writeValue(framework); -} -if (this.bundle) |bundle| { - try writer.writeFieldID(4); - try writer.writeValue(bundle); -} -if (this.code_length) |code_length| { - try writer.writeFieldID(5); - try writer.writeInt(code_length); -} -try writer.endMessage(); -} + /// routes + routes: ?LoadedRouteConfig = null, -}; + /// framework + framework: ?LoadedFramework = null, -pub const ScanDependencyMode = enum(u8) { + /// bundle + bundle: ?JavascriptBundle = null, -_none, - /// app - app, + /// code_length + code_length: ?u32 = null, - /// all - all, + pub fn decode(reader: anytype) anyerror!JavascriptBundleContainer { + var this = std.mem.zeroes(JavascriptBundleContainer); -_, + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + 1 => { + this.bundle_format_version = try reader.readValue(u32); + }, + 2 => { + this.routes = try reader.readValue(LoadedRouteConfig); + }, + 3 => { + this.framework = try reader.readValue(LoadedFramework); + }, + 4 => { + this.bundle = try reader.readValue(JavascriptBundle); + }, + 5 => { + this.code_length = try reader.readValue(u32); + }, + else => { + return error.InvalidMessage; + }, } + } + unreachable; + } - -}; - -pub const ModuleImportType = enum(u8) { - -_none, - /// import - import, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.bundle_format_version) |bundle_format_version| { + try writer.writeFieldID(1); + try writer.writeInt(bundle_format_version); + } + if (this.routes) |routes| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(routes), routes); + } + if (this.framework) |framework| { + try writer.writeFieldID(3); + try writer.writeValue(@TypeOf(framework), framework); + } + if (this.bundle) |bundle| { + try writer.writeFieldID(4); + try writer.writeValue(@TypeOf(bundle), bundle); + } + if (this.code_length) |code_length| { + try writer.writeFieldID(5); + try writer.writeInt(code_length); + } + try writer.endMessage(); + } + }; - /// require - require, + pub const ScanDependencyMode = enum(u8) { + _none, + /// app + app, -_, + /// all + all, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } + _, - -}; + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -pub const ModuleImportRecord = struct { -/// kind -kind: ModuleImportType, + pub const ModuleImportType = enum(u8) { + _none, + /// import + import, -/// path -path: []const u8, + /// require + require, -/// dynamic -dynamic: bool = false, + _, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -pub fn decode(reader: anytype) anyerror!ModuleImportRecord { - var this = std.mem.zeroes(ModuleImportRecord); + pub const ModuleImportRecord = struct { + /// kind + kind: ModuleImportType, - this.kind = try reader.readValue(ModuleImportType); - this.path = try reader.readValue([]const u8); - this.dynamic = try reader.readValue(bool); - return this; -} + /// path + path: []const u8, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.kind); - try writer.writeValue(this.path); - try writer.writeInt(@intCast(u8, @boolToInt(this.dynamic))); -} + /// dynamic + dynamic: bool = false, -}; + pub fn decode(reader: anytype) anyerror!ModuleImportRecord { + var this = std.mem.zeroes(ModuleImportRecord); -pub const Module = struct { -/// path -path: []const u8, + this.kind = try reader.readValue(ModuleImportType); + this.path = try reader.readValue([]const u8); + this.dynamic = try reader.readValue(bool); + return this; + } -/// imports -imports: []const ModuleImportRecord, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeEnum(this.kind); + try writer.writeValue(@TypeOf(this.path), this.path); + try writer.writeInt(@as(u8, @boolToInt(this.dynamic))); + } + }; + pub const Module = struct { + /// path + path: []const u8, -pub fn decode(reader: anytype) anyerror!Module { - var this = std.mem.zeroes(Module); + /// imports + imports: []const ModuleImportRecord, - this.path = try reader.readValue([]const u8); - this.imports = try reader.readArray(ModuleImportRecord); - return this; -} + pub fn decode(reader: anytype) anyerror!Module { + var this = std.mem.zeroes(Module); -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.path); - try writer.writeArray(ModuleImportRecord, this.imports); -} + this.path = try reader.readValue([]const u8); + this.imports = try reader.readArray(ModuleImportRecord); + return this; + } -}; + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.path), this.path); + try writer.writeArray(ModuleImportRecord, this.imports); + } + }; -pub const StringMap = struct { -/// keys -keys: []const []const u8, + pub const StringMap = struct { + /// keys + keys: []const []const u8, -/// values -values: []const []const u8, + /// values + values: []const []const u8, + pub fn decode(reader: anytype) anyerror!StringMap { + var this = std.mem.zeroes(StringMap); -pub fn decode(reader: anytype) anyerror!StringMap { - var this = std.mem.zeroes(StringMap); + this.keys = try reader.readArray([]const u8); + this.values = try reader.readArray([]const u8); + return this; + } - this.keys = try reader.readArray([]const u8); - this.values = try reader.readArray([]const u8); - return this; -} + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeArray([]const u8, this.keys); + try writer.writeArray([]const u8, this.values); + } + }; -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray([]const u8, this.keys); - try writer.writeArray([]const u8, this.values); -} + pub const LoaderMap = struct { + /// extensions + extensions: []const []const u8, -}; + /// loaders + loaders: []const Loader, -pub const LoaderMap = struct { -/// extensions -extensions: []const []const u8, + pub fn decode(reader: anytype) anyerror!LoaderMap { + var this = std.mem.zeroes(LoaderMap); -/// loaders -loaders: []const Loader, + this.extensions = try reader.readArray([]const u8); + this.loaders = try reader.readArray(Loader); + return this; + } + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeArray([]const u8, this.extensions); + try writer.writeArray(Loader, this.loaders); + } + }; -pub fn decode(reader: anytype) anyerror!LoaderMap { - var this = std.mem.zeroes(LoaderMap); + pub const DotEnvBehavior = enum(u32) { + _none, + /// disable + disable, - this.extensions = try reader.readArray([]const u8); - this.loaders = try reader.readArray(Loader); - return this; -} + /// prefix + prefix, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray([]const u8, this.extensions); - try writer.writeArray(Loader, this.loaders); -} + /// load_all + load_all, -}; + _, -pub const DotEnvBehavior = enum(u32) { + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -_none, - /// disable - disable, + pub const EnvConfig = struct { + /// prefix + prefix: ?[]const u8 = null, - /// prefix - prefix, + /// defaults + defaults: ?StringMap = null, - /// load_all - load_all, + pub fn decode(reader: anytype) anyerror!EnvConfig { + var this = std.mem.zeroes(EnvConfig); -_, + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + 1 => { + this.prefix = try reader.readValue([]const u8); + }, + 2 => { + this.defaults = try reader.readValue(StringMap); + }, + else => { + return error.InvalidMessage; + }, } + } + unreachable; + } - -}; - -pub const EnvConfig = struct { -/// prefix -prefix: ?[]const u8 = null, - -/// defaults -defaults: ?StringMap = null, - - -pub fn decode(reader: anytype) anyerror!EnvConfig { - var this = std.mem.zeroes(EnvConfig); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.prefix = try reader.readValue([]const u8); -}, - 2 => { - this.defaults = try reader.readValue(StringMap); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} - -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.prefix) |prefix| { - try writer.writeFieldID(1); - try writer.writeValue(prefix); -} -if (this.defaults) |defaults| { - try writer.writeFieldID(2); - try writer.writeValue(defaults); -} -try writer.endMessage(); -} - -}; - -pub const LoadedEnvConfig = struct { -/// dotenv -dotenv: DotEnvBehavior, - -/// defaults -defaults: StringMap, - -/// prefix -prefix: []const u8, - - -pub fn decode(reader: anytype) anyerror!LoadedEnvConfig { - var this = std.mem.zeroes(LoadedEnvConfig); + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.prefix) |prefix| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(prefix), prefix); + } + if (this.defaults) |defaults| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(defaults), defaults); + } + try writer.endMessage(); + } + }; - this.dotenv = try reader.readValue(DotEnvBehavior); - this.defaults = try reader.readValue(StringMap); - this.prefix = try reader.readValue([]const u8); - return this; -} + pub const LoadedEnvConfig = struct { + /// dotenv + dotenv: DotEnvBehavior, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.dotenv); - try writer.writeValue(this.defaults); - try writer.writeValue(this.prefix); -} + /// defaults + defaults: StringMap, -}; + /// prefix + prefix: []const u8, -pub const FrameworkConfig = struct { -/// package -package: ?[]const u8 = null, - -/// client -client: ?FrameworkEntryPointMessage = null, - -/// server -server: ?FrameworkEntryPointMessage = null, - -/// fallback -fallback: ?FrameworkEntryPointMessage = null, - -/// development -development: ?bool = null, - -/// client_css_in_js -client_css_in_js: ?CssInJsBehavior = null, - -/// display_name -display_name: ?[]const u8 = null, - -/// overrideModules -override_modules: ?StringMap = 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.package = try reader.readValue([]const u8); -}, - 2 => { - this.client = try reader.readValue(FrameworkEntryPointMessage); -}, - 3 => { - this.server = try reader.readValue(FrameworkEntryPointMessage); -}, - 4 => { - this.fallback = try reader.readValue(FrameworkEntryPointMessage); -}, - 5 => { - this.development = try reader.readValue(bool); -}, - 6 => { - this.client_css_in_js = try reader.readValue(CssInJsBehavior); -}, - 7 => { - this.display_name = try reader.readValue([]const u8); -}, - 8 => { - this.override_modules = try reader.readValue(StringMap); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + pub fn decode(reader: anytype) anyerror!LoadedEnvConfig { + var this = std.mem.zeroes(LoadedEnvConfig); -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.package) |package| { - try writer.writeFieldID(1); - try writer.writeValue(package); -} -if (this.client) |client| { - try writer.writeFieldID(2); - try writer.writeValue(client); -} -if (this.server) |server| { - try writer.writeFieldID(3); - try writer.writeValue(server); -} -if (this.fallback) |fallback| { - try writer.writeFieldID(4); - try writer.writeValue(fallback); -} -if (this.development) |development| { - try writer.writeFieldID(5); - try writer.writeInt(@intCast(u8, @boolToInt(development))); -} -if (this.client_css_in_js) |client_css_in_js| { - try writer.writeFieldID(6); - try writer.writeEnum(client_css_in_js); -} -if (this.display_name) |display_name| { - try writer.writeFieldID(7); - try writer.writeValue(display_name); -} -if (this.override_modules) |override_modules| { - try writer.writeFieldID(8); - try writer.writeValue(override_modules); -} -try writer.endMessage(); -} - -}; + this.dotenv = try reader.readValue(DotEnvBehavior); + this.defaults = try reader.readValue(StringMap); + this.prefix = try reader.readValue([]const u8); + return this; + } -pub const FrameworkEntryPoint = struct { -/// kind -kind: FrameworkEntryPointType, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeEnum(this.dotenv); + try writer.writeValue(@TypeOf(this.defaults), this.defaults); + try writer.writeValue(@TypeOf(this.prefix), this.prefix); + } + }; -/// path -path: []const u8, + pub const FrameworkConfig = struct { + /// package + package: ?[]const u8 = null, -/// env -env: LoadedEnvConfig, + /// client + client: ?FrameworkEntryPointMessage = null, + /// server + server: ?FrameworkEntryPointMessage = null, -pub fn decode(reader: anytype) anyerror!FrameworkEntryPoint { - var this = std.mem.zeroes(FrameworkEntryPoint); + /// fallback + fallback: ?FrameworkEntryPointMessage = null, - this.kind = try reader.readValue(FrameworkEntryPointType); - this.path = try reader.readValue([]const u8); - this.env = try reader.readValue(LoadedEnvConfig); - return this; -} + /// development + development: ?bool = null, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.kind); - try writer.writeValue(this.path); - try writer.writeValue(this.env); -} + /// client_css_in_js + client_css_in_js: ?CssInJsBehavior = null, -}; + /// display_name + display_name: ?[]const u8 = null, -pub const FrameworkEntryPointMap = struct { -/// client -client: ?FrameworkEntryPoint = null, - -/// server -server: ?FrameworkEntryPoint = null, - -/// fallback -fallback: ?FrameworkEntryPoint = null, - - -pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMap { - var this = std.mem.zeroes(FrameworkEntryPointMap); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.client = try reader.readValue(FrameworkEntryPoint); -}, - 2 => { - this.server = try reader.readValue(FrameworkEntryPoint); -}, - 3 => { - this.fallback = try reader.readValue(FrameworkEntryPoint); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + /// overrideModules + override_modules: ?StringMap = null, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.client) |client| { - try writer.writeFieldID(1); - try writer.writeValue(client); -} -if (this.server) |server| { - try writer.writeFieldID(2); - try writer.writeValue(server); -} -if (this.fallback) |fallback| { - try writer.writeFieldID(3); - try writer.writeValue(fallback); -} -try writer.endMessage(); -} + pub fn decode(reader: anytype) anyerror!FrameworkConfig { + var this = std.mem.zeroes(FrameworkConfig); -}; + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, -pub const FrameworkEntryPointMessage = struct { -/// path -path: ?[]const u8 = null, - -/// env -env: ?EnvConfig = null, - - -pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMessage { - var this = std.mem.zeroes(FrameworkEntryPointMessage); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.path = try reader.readValue([]const u8); -}, - 2 => { - this.env = try reader.readValue(EnvConfig); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + 1 => { + this.package = try reader.readValue([]const u8); + }, + 2 => { + this.client = try reader.readValue(FrameworkEntryPointMessage); + }, + 3 => { + this.server = try reader.readValue(FrameworkEntryPointMessage); + }, + 4 => { + this.fallback = try reader.readValue(FrameworkEntryPointMessage); + }, + 5 => { + this.development = try reader.readValue(bool); + }, + 6 => { + this.client_css_in_js = try reader.readValue(CssInJsBehavior); + }, + 7 => { + this.display_name = try reader.readValue([]const u8); + }, + 8 => { + this.override_modules = try reader.readValue(StringMap); + }, + else => { + return error.InvalidMessage; + }, + } + } + unreachable; + } -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.path) |path| { - try writer.writeFieldID(1); - try writer.writeValue(path); -} -if (this.env) |env| { - try writer.writeFieldID(2); - try writer.writeValue(env); -} -try writer.endMessage(); -} + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.package) |package| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(package), package); + } + if (this.client) |client| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(client), client); + } + if (this.server) |server| { + try writer.writeFieldID(3); + try writer.writeValue(@TypeOf(server), server); + } + if (this.fallback) |fallback| { + try writer.writeFieldID(4); + try writer.writeValue(@TypeOf(fallback), fallback); + } + if (this.development) |development| { + try writer.writeFieldID(5); + try writer.writeInt(@as(u8, @boolToInt(development))); + } + if (this.client_css_in_js) |client_css_in_js| { + try writer.writeFieldID(6); + try writer.writeEnum(client_css_in_js); + } + if (this.display_name) |display_name| { + try writer.writeFieldID(7); + try writer.writeValue(@TypeOf(display_name), display_name); + } + if (this.override_modules) |override_modules| { + try writer.writeFieldID(8); + try writer.writeValue(@TypeOf(override_modules), override_modules); + } + try writer.endMessage(); + } + }; -}; + pub const FrameworkEntryPoint = struct { + /// kind + kind: FrameworkEntryPointType, -pub const LoadedFramework = struct { -/// package -package: []const u8, + /// path + path: []const u8, -/// display_name -display_name: []const u8, + /// env + env: LoadedEnvConfig, -/// development -development: bool = false, + pub fn decode(reader: anytype) anyerror!FrameworkEntryPoint { + var this = std.mem.zeroes(FrameworkEntryPoint); -/// entry_points -entry_points: FrameworkEntryPointMap, + this.kind = try reader.readValue(FrameworkEntryPointType); + this.path = try reader.readValue([]const u8); + this.env = try reader.readValue(LoadedEnvConfig); + return this; + } -/// client_css_in_js -client_css_in_js: CssInJsBehavior, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeEnum(this.kind); + try writer.writeValue(@TypeOf(this.path), this.path); + try writer.writeValue(@TypeOf(this.env), this.env); + } + }; -/// overrideModules -override_modules: StringMap, + pub const FrameworkEntryPointMap = struct { + /// client + client: ?FrameworkEntryPoint = null, + /// server + server: ?FrameworkEntryPoint = null, -pub fn decode(reader: anytype) anyerror!LoadedFramework { - var this = std.mem.zeroes(LoadedFramework); + /// fallback + fallback: ?FrameworkEntryPoint = null, - this.package = try reader.readValue([]const u8); - this.display_name = try reader.readValue([]const u8); - this.development = try reader.readValue(bool); - this.entry_points = try reader.readValue(FrameworkEntryPointMap); - this.client_css_in_js = try reader.readValue(CssInJsBehavior); - this.override_modules = try reader.readValue(StringMap); - return this; -} + pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMap { + var this = std.mem.zeroes(FrameworkEntryPointMap); -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.package); - try writer.writeValue(this.display_name); - try writer.writeInt(@intCast(u8, @boolToInt(this.development))); - try writer.writeValue(this.entry_points); - try writer.writeEnum(this.client_css_in_js); - try writer.writeValue(this.override_modules); -} + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, -}; + 1 => { + this.client = try reader.readValue(FrameworkEntryPoint); + }, + 2 => { + this.server = try reader.readValue(FrameworkEntryPoint); + }, + 3 => { + this.fallback = try reader.readValue(FrameworkEntryPoint); + }, + else => { + return error.InvalidMessage; + }, + } + } + unreachable; + } -pub const LoadedRouteConfig = struct { -/// dir -dir: []const u8, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.client) |client| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(client), client); + } + if (this.server) |server| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(server), server); + } + if (this.fallback) |fallback| { + try writer.writeFieldID(3); + try writer.writeValue(@TypeOf(fallback), fallback); + } + try writer.endMessage(); + } + }; -/// extensions -extensions: []const []const u8, + pub const FrameworkEntryPointMessage = struct { + /// path + path: ?[]const u8 = null, -/// static_dir -static_dir: []const u8, + /// env + env: ?EnvConfig = null, -/// asset_prefix -asset_prefix: []const u8, + pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMessage { + var this = std.mem.zeroes(FrameworkEntryPointMessage); + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, -pub fn decode(reader: anytype) anyerror!LoadedRouteConfig { - var this = std.mem.zeroes(LoadedRouteConfig); + 1 => { + this.path = try reader.readValue([]const u8); + }, + 2 => { + this.env = try reader.readValue(EnvConfig); + }, + else => { + return error.InvalidMessage; + }, + } + } + unreachable; + } - this.dir = try reader.readValue([]const u8); - this.extensions = try reader.readArray([]const u8); - this.static_dir = try reader.readValue([]const u8); - this.asset_prefix = try reader.readValue([]const u8); - return this; -} + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.path) |path| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(path), path); + } + if (this.env) |env| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(env), env); + } + try writer.endMessage(); + } + }; -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.dir); - try writer.writeArray([]const u8, this.extensions); - try writer.writeValue(this.static_dir); - try writer.writeValue(this.asset_prefix); -} + pub const LoadedFramework = struct { + /// package + package: []const u8, -}; + /// display_name + display_name: []const u8, -pub const RouteConfig = struct { -/// dir -dir: []const []const u8, - -/// extensions -extensions: []const []const u8, - -/// static_dir -static_dir: ?[]const u8 = null, - -/// asset_prefix -asset_prefix: ?[]const u8 = null, - - -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.readArray([]const u8); -}, - 2 => { - this.extensions = try reader.readArray([]const u8); -}, - 3 => { - this.static_dir = try reader.readValue([]const u8); -}, - 4 => { - this.asset_prefix = try reader.readValue([]const u8); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + /// development + development: bool = false, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.dir) |dir| { - try writer.writeFieldID(1); - try writer.writeArray([]const u8, dir); -} -if (this.extensions) |extensions| { - try writer.writeFieldID(2); - try writer.writeArray([]const u8, extensions); -} -if (this.static_dir) |static_dir| { - try writer.writeFieldID(3); - try writer.writeValue(static_dir); -} -if (this.asset_prefix) |asset_prefix| { - try writer.writeFieldID(4); - try writer.writeValue(asset_prefix); -} -try writer.endMessage(); -} + /// entry_points + entry_points: FrameworkEntryPointMap, -}; + /// client_css_in_js + client_css_in_js: CssInJsBehavior, -pub const TransformOptions = struct { -/// jsx -jsx: ?Jsx = null, + /// overrideModules + override_modules: StringMap, -/// tsconfig_override -tsconfig_override: ?[]const u8 = null, + pub fn decode(reader: anytype) anyerror!LoadedFramework { + var this = std.mem.zeroes(LoadedFramework); -/// resolve -resolve: ?ResolveMode = null, + this.package = try reader.readValue([]const u8); + this.display_name = try reader.readValue([]const u8); + this.development = try reader.readValue(bool); + this.entry_points = try reader.readValue(FrameworkEntryPointMap); + this.client_css_in_js = try reader.readValue(CssInJsBehavior); + this.override_modules = try reader.readValue(StringMap); + return this; + } -/// origin -origin: ?[]const u8 = null, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.package), this.package); + try writer.writeValue(@TypeOf(this.display_name), this.display_name); + try writer.writeInt(@as(u8, @boolToInt(this.development))); + try writer.writeValue(@TypeOf(this.entry_points), this.entry_points); + try writer.writeEnum(this.client_css_in_js); + try writer.writeValue(@TypeOf(this.override_modules), this.override_modules); + } + }; -/// absolute_working_dir -absolute_working_dir: ?[]const u8 = null, + pub const LoadedRouteConfig = struct { + /// dir + dir: []const u8, -/// define -define: ?StringMap = null, - -/// preserve_symlinks -preserve_symlinks: ?bool = null, - -/// entry_points -entry_points: []const []const u8, - -/// write -write: ?bool = null, - -/// inject -inject: []const []const u8, - -/// output_dir -output_dir: ?[]const u8 = null, - -/// external -external: []const []const u8, - -/// loaders -loaders: ?LoaderMap = null, - -/// main_fields -main_fields: []const []const u8, - -/// platform -platform: ?Platform = null, - -/// serve -serve: ?bool = null, - -/// extension_order -extension_order: []const []const u8, - -/// generate_node_module_bundle -generate_node_module_bundle: ?bool = null, - -/// node_modules_bundle_path -node_modules_bundle_path: ?[]const u8 = null, - -/// node_modules_bundle_path_server -node_modules_bundle_path_server: ?[]const u8 = null, - -/// framework -framework: ?FrameworkConfig = null, - -/// router -router: ?RouteConfig = null, - -/// no_summary -no_summary: ?bool = null, - -/// disable_hmr -disable_hmr: ?bool = null, - -/// port -port: ?u16 = null, - - -pub fn decode(reader: anytype) anyerror!TransformOptions { - var this = std.mem.zeroes(TransformOptions); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.jsx = try reader.readValue(Jsx); -}, - 2 => { - this.tsconfig_override = try reader.readValue([]const u8); -}, - 3 => { - this.resolve = try reader.readValue(ResolveMode); -}, - 4 => { - this.origin = try reader.readValue([]const u8); -}, - 5 => { - this.absolute_working_dir = try reader.readValue([]const u8); -}, - 6 => { - this.define = try reader.readValue(StringMap); -}, - 7 => { - this.preserve_symlinks = try reader.readValue(bool); -}, - 8 => { - this.entry_points = try reader.readArray([]const u8); -}, - 9 => { - this.write = try reader.readValue(bool); -}, - 10 => { - this.inject = try reader.readArray([]const u8); -}, - 11 => { - this.output_dir = try reader.readValue([]const u8); -}, - 12 => { - this.external = try reader.readArray([]const u8); -}, - 13 => { - this.loaders = try reader.readValue(LoaderMap); -}, - 14 => { - this.main_fields = try reader.readArray([]const u8); -}, - 15 => { - this.platform = try reader.readValue(Platform); -}, - 16 => { - this.serve = try reader.readValue(bool); -}, - 17 => { - this.extension_order = try reader.readArray([]const u8); -}, - 18 => { - this.generate_node_module_bundle = try reader.readValue(bool); -}, - 19 => { - this.node_modules_bundle_path = try reader.readValue([]const u8); -}, - 20 => { - this.node_modules_bundle_path_server = try reader.readValue([]const u8); -}, - 21 => { - this.framework = try reader.readValue(FrameworkConfig); -}, - 22 => { - this.router = try reader.readValue(RouteConfig); -}, - 23 => { - this.no_summary = try reader.readValue(bool); -}, - 24 => { - this.disable_hmr = try reader.readValue(bool); -}, - 25 => { - this.port = try reader.readValue(u16); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + /// extensions + extensions: []const []const u8, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.jsx) |jsx| { - try writer.writeFieldID(1); - try writer.writeValue(jsx); -} -if (this.tsconfig_override) |tsconfig_override| { - try writer.writeFieldID(2); - try writer.writeValue(tsconfig_override); -} -if (this.resolve) |resolve| { - try writer.writeFieldID(3); - try writer.writeEnum(resolve); -} -if (this.origin) |origin| { - try writer.writeFieldID(4); - try writer.writeValue(origin); -} -if (this.absolute_working_dir) |absolute_working_dir| { - try writer.writeFieldID(5); - try writer.writeValue(absolute_working_dir); -} -if (this.define) |define| { - try writer.writeFieldID(6); - try writer.writeValue(define); -} -if (this.preserve_symlinks) |preserve_symlinks| { - try writer.writeFieldID(7); - try writer.writeInt(@intCast(u8, @boolToInt(preserve_symlinks))); -} -if (this.entry_points) |entry_points| { - try writer.writeFieldID(8); - try writer.writeArray([]const u8, entry_points); -} -if (this.write) |write| { - try writer.writeFieldID(9); - try writer.writeInt(@intCast(u8, @boolToInt(write))); -} -if (this.inject) |inject| { - try writer.writeFieldID(10); - try writer.writeArray([]const u8, inject); -} -if (this.output_dir) |output_dir| { - try writer.writeFieldID(11); - try writer.writeValue(output_dir); -} -if (this.external) |external| { - try writer.writeFieldID(12); - try writer.writeArray([]const u8, external); -} -if (this.loaders) |loaders| { - try writer.writeFieldID(13); - try writer.writeValue(loaders); -} -if (this.main_fields) |main_fields| { - try writer.writeFieldID(14); - try writer.writeArray([]const u8, main_fields); -} -if (this.platform) |platform| { - try writer.writeFieldID(15); - try writer.writeEnum(platform); -} -if (this.serve) |serve| { - try writer.writeFieldID(16); - try writer.writeInt(@intCast(u8, @boolToInt(serve))); -} -if (this.extension_order) |extension_order| { - try writer.writeFieldID(17); - try writer.writeArray([]const u8, extension_order); -} -if (this.generate_node_module_bundle) |generate_node_module_bundle| { - try writer.writeFieldID(18); - try writer.writeInt(@intCast(u8, @boolToInt(generate_node_module_bundle))); -} -if (this.node_modules_bundle_path) |node_modules_bundle_path| { - try writer.writeFieldID(19); - try writer.writeValue(node_modules_bundle_path); -} -if (this.node_modules_bundle_path_server) |node_modules_bundle_path_server| { - try writer.writeFieldID(20); - try writer.writeValue(node_modules_bundle_path_server); -} -if (this.framework) |framework| { - try writer.writeFieldID(21); - try writer.writeValue(framework); -} -if (this.router) |router| { - try writer.writeFieldID(22); - try writer.writeValue(router); -} -if (this.no_summary) |no_summary| { - try writer.writeFieldID(23); - try writer.writeInt(@intCast(u8, @boolToInt(no_summary))); -} -if (this.disable_hmr) |disable_hmr| { - try writer.writeFieldID(24); - try writer.writeInt(@intCast(u8, @boolToInt(disable_hmr))); -} -if (this.port) |port| { - try writer.writeFieldID(25); - try writer.writeInt(port); -} -try writer.endMessage(); -} + /// static_dir + static_dir: []const u8, -}; + /// asset_prefix + asset_prefix: []const u8, -pub const FileHandle = struct { -/// path -path: []const u8, + pub fn decode(reader: anytype) anyerror!LoadedRouteConfig { + var this = std.mem.zeroes(LoadedRouteConfig); -/// size -size: u32 = 0, + this.dir = try reader.readValue([]const u8); + this.extensions = try reader.readArray([]const u8); + this.static_dir = try reader.readValue([]const u8); + this.asset_prefix = try reader.readValue([]const u8); + return this; + } -/// fd -fd: u32 = 0, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.dir), this.dir); + try writer.writeArray([]const u8, this.extensions); + try writer.writeValue(@TypeOf(this.static_dir), this.static_dir); + try writer.writeValue(@TypeOf(this.asset_prefix), this.asset_prefix); + } + }; + pub const RouteConfig = struct { + /// dir + dir: []const []const u8, -pub fn decode(reader: anytype) anyerror!FileHandle { - var this = std.mem.zeroes(FileHandle); + /// extensions + extensions: []const []const u8, - this.path = try reader.readValue([]const u8); - this.size = try reader.readValue(u32); - this.fd = try reader.readValue(u32); - return this; -} + /// static_dir + static_dir: ?[]const u8 = null, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.path); - try writer.writeInt(this.size); - try writer.writeInt(this.fd); -} + /// asset_prefix + asset_prefix: ?[]const u8 = null, -}; + pub fn decode(reader: anytype) anyerror!RouteConfig { + var this = std.mem.zeroes(RouteConfig); -pub const Transform = struct { -/// handle -handle: ?FileHandle = null, - -/// path -path: ?[]const u8 = null, - -/// contents -contents: []const u8, - -/// loader -loader: ?Loader = null, - -/// options -options: ?TransformOptions = null, - - -pub fn decode(reader: anytype) anyerror!Transform { - var this = std.mem.zeroes(Transform); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.handle = try reader.readValue(FileHandle); -}, - 2 => { - this.path = try reader.readValue([]const u8); -}, - 3 => { - this.contents = try reader.readArray(u8); -}, - 4 => { - this.loader = try reader.readValue(Loader); -}, - 5 => { - this.options = try reader.readValue(TransformOptions); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.handle) |handle| { - try writer.writeFieldID(1); - try writer.writeValue(handle); -} -if (this.path) |path| { - try writer.writeFieldID(2); - try writer.writeValue(path); -} -if (this.contents) |contents| { - try writer.writeFieldID(3); - try writer.writeArray(u8, contents); -} -if (this.loader) |loader| { - try writer.writeFieldID(4); - try writer.writeEnum(loader); -} -if (this.options) |options| { - try writer.writeFieldID(5); - try writer.writeValue(options); -} -try writer.endMessage(); -} + 1 => { + this.dir = try reader.readArray([]const u8); + }, + 2 => { + this.extensions = try reader.readArray([]const u8); + }, + 3 => { + this.static_dir = try reader.readValue([]const u8); + }, + 4 => { + this.asset_prefix = try reader.readValue([]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.writeArray([]const u8, dir); + } + if (this.extensions) |extensions| { + try writer.writeFieldID(2); + try writer.writeArray([]const u8, extensions); + } + if (this.static_dir) |static_dir| { + try writer.writeFieldID(3); + try writer.writeValue(@TypeOf(static_dir), static_dir); + } + if (this.asset_prefix) |asset_prefix| { + try writer.writeFieldID(4); + try writer.writeValue(@TypeOf(asset_prefix), asset_prefix); + } + try writer.endMessage(); + } + }; -pub const TransformResponseStatus = enum(u32) { + pub const TransformOptions = struct { + /// jsx + jsx: ?Jsx = null, -_none, - /// success - success, + /// tsconfig_override + tsconfig_override: ?[]const u8 = null, - /// fail - fail, + /// resolve + resolve: ?ResolveMode = null, -_, + /// origin + origin: ?[]const u8 = null, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } + /// absolute_working_dir + absolute_working_dir: ?[]const u8 = null, - -}; + /// define + define: ?StringMap = null, -pub const OutputFile = struct { -/// data -data: []const u8, + /// preserve_symlinks + preserve_symlinks: ?bool = null, -/// path -path: []const u8, + /// entry_points + entry_points: []const []const u8, + /// write + write: ?bool = null, -pub fn decode(reader: anytype) anyerror!OutputFile { - var this = std.mem.zeroes(OutputFile); + /// inject + inject: []const []const u8, - this.data = try reader.readArray(u8); - this.path = try reader.readValue([]const u8); - return this; -} + /// output_dir + output_dir: ?[]const u8 = null, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(u8, this.data); - try writer.writeValue(this.path); -} + /// external + external: []const []const u8, -}; + /// loaders + loaders: ?LoaderMap = null, -pub const TransformResponse = struct { -/// status -status: TransformResponseStatus, + /// main_fields + main_fields: []const []const u8, -/// files -files: []const OutputFile, + /// platform + platform: ?Platform = null, -/// errors -errors: []const Message, + /// serve + serve: ?bool = null, + /// extension_order + extension_order: []const []const u8, -pub fn decode(reader: anytype) anyerror!TransformResponse { - var this = std.mem.zeroes(TransformResponse); + /// generate_node_module_bundle + generate_node_module_bundle: ?bool = null, - this.status = try reader.readValue(TransformResponseStatus); - this.files = try reader.readArray(OutputFile); - this.errors = try reader.readArray(Message); - return this; -} + /// node_modules_bundle_path + node_modules_bundle_path: ?[]const u8 = null, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.status); - try writer.writeArray(OutputFile, this.files); - try writer.writeArray(Message, this.errors); -} + /// node_modules_bundle_path_server + node_modules_bundle_path_server: ?[]const u8 = null, -}; + /// framework + framework: ?FrameworkConfig = null, -pub const MessageLevel = enum(u32) { + /// router + router: ?RouteConfig = null, -_none, - /// err - err, + /// no_summary + no_summary: ?bool = null, - /// warn - warn, + /// disable_hmr + disable_hmr: ?bool = null, - /// note - note, + /// port + port: ?u16 = null, - /// debug - debug, + pub fn decode(reader: anytype) anyerror!TransformOptions { + var this = std.mem.zeroes(TransformOptions); -_, + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + 1 => { + this.jsx = try reader.readValue(Jsx); + }, + 2 => { + this.tsconfig_override = try reader.readValue([]const u8); + }, + 3 => { + this.resolve = try reader.readValue(ResolveMode); + }, + 4 => { + this.origin = try reader.readValue([]const u8); + }, + 5 => { + this.absolute_working_dir = try reader.readValue([]const u8); + }, + 6 => { + this.define = try reader.readValue(StringMap); + }, + 7 => { + this.preserve_symlinks = try reader.readValue(bool); + }, + 8 => { + this.entry_points = try reader.readArray([]const u8); + }, + 9 => { + this.write = try reader.readValue(bool); + }, + 10 => { + this.inject = try reader.readArray([]const u8); + }, + 11 => { + this.output_dir = try reader.readValue([]const u8); + }, + 12 => { + this.external = try reader.readArray([]const u8); + }, + 13 => { + this.loaders = try reader.readValue(LoaderMap); + }, + 14 => { + this.main_fields = try reader.readArray([]const u8); + }, + 15 => { + this.platform = try reader.readValue(Platform); + }, + 16 => { + this.serve = try reader.readValue(bool); + }, + 17 => { + this.extension_order = try reader.readArray([]const u8); + }, + 18 => { + this.generate_node_module_bundle = try reader.readValue(bool); + }, + 19 => { + this.node_modules_bundle_path = try reader.readValue([]const u8); + }, + 20 => { + this.node_modules_bundle_path_server = try reader.readValue([]const u8); + }, + 21 => { + this.framework = try reader.readValue(FrameworkConfig); + }, + 22 => { + this.router = try reader.readValue(RouteConfig); + }, + 23 => { + this.no_summary = try reader.readValue(bool); + }, + 24 => { + this.disable_hmr = try reader.readValue(bool); + }, + 25 => { + this.port = try reader.readValue(u16); + }, + else => { + return error.InvalidMessage; + }, } + } + unreachable; + } - -}; + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.jsx) |jsx| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(jsx), jsx); + } + if (this.tsconfig_override) |tsconfig_override| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(tsconfig_override), tsconfig_override); + } + if (this.resolve) |resolve| { + try writer.writeFieldID(3); + try writer.writeEnum(resolve); + } + if (this.origin) |origin| { + try writer.writeFieldID(4); + try writer.writeValue(@TypeOf(origin), origin); + } + if (this.absolute_working_dir) |absolute_working_dir| { + try writer.writeFieldID(5); + try writer.writeValue(@TypeOf(absolute_working_dir), absolute_working_dir); + } + if (this.define) |define| { + try writer.writeFieldID(6); + try writer.writeValue(@TypeOf(define), define); + } + if (this.preserve_symlinks) |preserve_symlinks| { + try writer.writeFieldID(7); + try writer.writeInt(@as(u8, @boolToInt(preserve_symlinks))); + } + if (this.entry_points) |entry_points| { + try writer.writeFieldID(8); + try writer.writeArray([]const u8, entry_points); + } + if (this.write) |write| { + try writer.writeFieldID(9); + try writer.writeInt(@as(u8, @boolToInt(write))); + } + if (this.inject) |inject| { + try writer.writeFieldID(10); + try writer.writeArray([]const u8, inject); + } + if (this.output_dir) |output_dir| { + try writer.writeFieldID(11); + try writer.writeValue(@TypeOf(output_dir), output_dir); + } + if (this.external) |external| { + try writer.writeFieldID(12); + try writer.writeArray([]const u8, external); + } + if (this.loaders) |loaders| { + try writer.writeFieldID(13); + try writer.writeValue(@TypeOf(loaders), loaders); + } + if (this.main_fields) |main_fields| { + try writer.writeFieldID(14); + try writer.writeArray([]const u8, main_fields); + } + if (this.platform) |platform| { + try writer.writeFieldID(15); + try writer.writeEnum(platform); + } + if (this.serve) |serve| { + try writer.writeFieldID(16); + try writer.writeInt(@as(u8, @boolToInt(serve))); + } + if (this.extension_order) |extension_order| { + try writer.writeFieldID(17); + try writer.writeArray([]const u8, extension_order); + } + if (this.generate_node_module_bundle) |generate_node_module_bundle| { + try writer.writeFieldID(18); + try writer.writeInt(@as(u8, @boolToInt(generate_node_module_bundle))); + } + if (this.node_modules_bundle_path) |node_modules_bundle_path| { + try writer.writeFieldID(19); + try writer.writeValue(@TypeOf(node_modules_bundle_path), node_modules_bundle_path); + } + if (this.node_modules_bundle_path_server) |node_modules_bundle_path_server| { + try writer.writeFieldID(20); + try writer.writeValue(@TypeOf(node_modules_bundle_path_server), node_modules_bundle_path_server); + } + if (this.framework) |framework| { + try writer.writeFieldID(21); + try writer.writeValue(@TypeOf(framework), framework); + } + if (this.router) |router| { + try writer.writeFieldID(22); + try writer.writeValue(@TypeOf(router), router); + } + if (this.no_summary) |no_summary| { + try writer.writeFieldID(23); + try writer.writeInt(@as(u8, @boolToInt(no_summary))); + } + if (this.disable_hmr) |disable_hmr| { + try writer.writeFieldID(24); + try writer.writeInt(@as(u8, @boolToInt(disable_hmr))); + } + if (this.port) |port| { + try writer.writeFieldID(25); + try writer.writeInt(port); + } + try writer.endMessage(); + } + }; -pub const Location = struct { -/// file -file: []const u8, + pub const FileHandle = struct { + /// path + path: []const u8, -/// namespace -namespace: []const u8, + /// size + size: u32 = 0, -/// line -line: i32 = 0, + /// fd + fd: u32 = 0, -/// column -column: i32 = 0, + pub fn decode(reader: anytype) anyerror!FileHandle { + var this = std.mem.zeroes(FileHandle); -/// line_text -line_text: []const u8, + this.path = try reader.readValue([]const u8); + this.size = try reader.readValue(u32); + this.fd = try reader.readValue(u32); + return this; + } -/// suggestion -suggestion: []const u8, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.path), this.path); + try writer.writeInt(this.size); + try writer.writeInt(this.fd); + } + }; -/// offset -offset: u32 = 0, + pub const Transform = struct { + /// handle + handle: ?FileHandle = null, + /// path + path: ?[]const u8 = null, -pub fn decode(reader: anytype) anyerror!Location { - var this = std.mem.zeroes(Location); + /// contents + contents: []const u8, - this.file = try reader.readValue([]const u8); - this.namespace = try reader.readValue([]const u8); - this.line = try reader.readValue(i32); - this.column = try reader.readValue(i32); - this.line_text = try reader.readValue([]const u8); - this.suggestion = try reader.readValue([]const u8); - this.offset = try reader.readValue(u32); - return this; -} + /// loader + loader: ?Loader = null, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(this.file); - try writer.writeValue(this.namespace); - try writer.writeInt(this.line); - try writer.writeInt(this.column); - try writer.writeValue(this.line_text); - try writer.writeValue(this.suggestion); - try writer.writeInt(this.offset); -} + /// options + options: ?TransformOptions = null, -}; + pub fn decode(reader: anytype) anyerror!Transform { + var this = std.mem.zeroes(Transform); -pub const MessageData = struct { -/// text -text: ?[]const u8 = null, - -/// location -location: ?Location = null, - - -pub fn decode(reader: anytype) anyerror!MessageData { - var this = std.mem.zeroes(MessageData); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.text = try reader.readValue([]const u8); -}, - 2 => { - this.location = try reader.readValue(Location); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.text) |text| { - try writer.writeFieldID(1); - try writer.writeValue(text); -} -if (this.location) |location| { - try writer.writeFieldID(2); - try writer.writeValue(location); -} -try writer.endMessage(); -} + 1 => { + this.handle = try reader.readValue(FileHandle); + }, + 2 => { + this.path = try reader.readValue([]const u8); + }, + 3 => { + this.contents = try reader.readArray(u8); + }, + 4 => { + this.loader = try reader.readValue(Loader); + }, + 5 => { + this.options = try reader.readValue(TransformOptions); + }, + else => { + return error.InvalidMessage; + }, + } + } + unreachable; + } -}; + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.handle) |handle| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(handle), handle); + } + if (this.path) |path| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(path), path); + } + if (this.contents) |contents| { + try writer.writeFieldID(3); + try writer.writeArray(u8, contents); + } + if (this.loader) |loader| { + try writer.writeFieldID(4); + try writer.writeEnum(loader); + } + if (this.options) |options| { + try writer.writeFieldID(5); + try writer.writeValue(@TypeOf(options), options); + } + try writer.endMessage(); + } + }; -pub const MessageMeta = struct { -/// resolve -resolve: ?[]const u8 = null, - -/// build -build: ?bool = null, - - -pub fn decode(reader: anytype) anyerror!MessageMeta { - var this = std.mem.zeroes(MessageMeta); - - while(true) { - switch (try reader.readByte()) { - 0 => { return this; }, - - 1 => { - this.resolve = try reader.readValue([]const u8); -}, - 2 => { - this.build = try reader.readValue(bool); -}, - else => { - return error.InvalidMessage; - }, - } - } -unreachable; -} + pub const TransformResponseStatus = enum(u32) { + _none, + /// success + success, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { -if (this.resolve) |resolve| { - try writer.writeFieldID(1); - try writer.writeValue(resolve); -} -if (this.build) |build| { - try writer.writeFieldID(2); - try writer.writeInt(@intCast(u8, @boolToInt(build))); -} -try writer.endMessage(); -} + /// fail + fail, -}; + _, -pub const Message = struct { -/// level -level: MessageLevel, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -/// data -data: MessageData, + pub const OutputFile = struct { + /// data + data: []const u8, -/// notes -notes: []const MessageData, + /// path + path: []const u8, -/// on -on: MessageMeta, + pub fn decode(reader: anytype) anyerror!OutputFile { + var this = std.mem.zeroes(OutputFile); + this.data = try reader.readArray(u8); + this.path = try reader.readValue([]const u8); + return this; + } -pub fn decode(reader: anytype) anyerror!Message { - var this = std.mem.zeroes(Message); + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeArray(u8, this.data); + try writer.writeValue(@TypeOf(this.path), this.path); + } + }; - this.level = try reader.readValue(MessageLevel); - this.data = try reader.readValue(MessageData); - this.notes = try reader.readArray(MessageData); - this.on = try reader.readValue(MessageMeta); - return this; -} + pub const TransformResponse = struct { + /// status + status: TransformResponseStatus, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.level); - try writer.writeValue(this.data); - try writer.writeArray(MessageData, this.notes); - try writer.writeValue(this.on); -} + /// files + files: []const OutputFile, -}; + /// errors + errors: []const Message, -pub const Log = struct { -/// warnings -warnings: u32 = 0, + pub fn decode(reader: anytype) anyerror!TransformResponse { + var this = std.mem.zeroes(TransformResponse); -/// errors -errors: u32 = 0, + this.status = try reader.readValue(TransformResponseStatus); + this.files = try reader.readArray(OutputFile); + this.errors = try reader.readArray(Message); + return this; + } -/// msgs -msgs: []const Message, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeEnum(this.status); + try writer.writeArray(OutputFile, this.files); + try writer.writeArray(Message, this.errors); + } + }; + pub const MessageLevel = enum(u32) { + _none, + /// err + err, -pub fn decode(reader: anytype) anyerror!Log { - var this = std.mem.zeroes(Log); + /// warn + warn, - this.warnings = try reader.readValue(u32); - this.errors = try reader.readValue(u32); - this.msgs = try reader.readArray(Message); - return this; -} + /// note + note, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.warnings); - try writer.writeInt(this.errors); - try writer.writeArray(Message, this.msgs); -} + /// debug + debug, -}; + _, -pub const Reloader = enum(u8) { + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -_none, - /// disable - disable, + pub const Location = struct { + /// file + file: []const u8, - /// live - live, + /// namespace + namespace: []const u8, - /// fast_refresh - fast_refresh, + /// line + line: i32 = 0, -_, + /// column + column: i32 = 0, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } + /// line_text + line_text: []const u8, - -}; + /// suggestion + suggestion: []const u8, -pub const WebsocketMessageKind = enum(u8) { + /// offset + offset: u32 = 0, -_none, - /// welcome - welcome, + pub fn decode(reader: anytype) anyerror!Location { + var this = std.mem.zeroes(Location); - /// file_change_notification - file_change_notification, + this.file = try reader.readValue([]const u8); + this.namespace = try reader.readValue([]const u8); + this.line = try reader.readValue(i32); + this.column = try reader.readValue(i32); + this.line_text = try reader.readValue([]const u8); + this.suggestion = try reader.readValue([]const u8); + this.offset = try reader.readValue(u32); + return this; + } - /// build_success - build_success, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeValue(@TypeOf(this.file), this.file); + try writer.writeValue(@TypeOf(this.namespace), this.namespace); + try writer.writeInt(this.line); + try writer.writeInt(this.column); + try writer.writeValue(@TypeOf(this.line_text), this.line_text); + try writer.writeValue(@TypeOf(this.suggestion), this.suggestion); + try writer.writeInt(this.offset); + } + }; - /// build_fail - build_fail, + pub const MessageData = struct { + /// text + text: ?[]const u8 = null, - /// manifest_success - manifest_success, + /// location + location: ?Location = null, - /// manifest_fail - manifest_fail, + pub fn decode(reader: anytype) anyerror!MessageData { + var this = std.mem.zeroes(MessageData); -_, + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + 1 => { + this.text = try reader.readValue([]const u8); + }, + 2 => { + this.location = try reader.readValue(Location); + }, + else => { + return error.InvalidMessage; + }, } + } + unreachable; + } - -}; + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.text) |text| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(text), text); + } + if (this.location) |location| { + try writer.writeFieldID(2); + try writer.writeValue(@TypeOf(location), location); + } + try writer.endMessage(); + } + }; -pub const WebsocketCommandKind = enum(u8) { + pub const MessageMeta = struct { + /// resolve + resolve: ?[]const u8 = null, -_none, - /// build - build, + /// build + build: ?bool = null, - /// manifest - manifest, + pub fn decode(reader: anytype) anyerror!MessageMeta { + var this = std.mem.zeroes(MessageMeta); -_, + while (true) { + switch (try reader.readByte()) { + 0 => { + return this; + }, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + 1 => { + this.resolve = try reader.readValue([]const u8); + }, + 2 => { + this.build = try reader.readValue(bool); + }, + else => { + return error.InvalidMessage; + }, } + } + unreachable; + } - -}; - -pub const WebsocketMessage = struct { -/// timestamp -timestamp: u32 = 0, - -/// kind -kind: WebsocketMessageKind, - - -pub fn decode(reader: anytype) anyerror!WebsocketMessage { - var this = std.mem.zeroes(WebsocketMessage); - - this.timestamp = try reader.readValue(u32); - this.kind = try reader.readValue(WebsocketMessageKind); - return this; -} - -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.timestamp); - try writer.writeEnum(this.kind); -} - -}; - -pub const WebsocketMessageWelcome = struct { -/// epoch -epoch: u32 = 0, - -/// javascriptReloader -javascript_reloader: Reloader, - -/// cwd -cwd: []const u8, - - -pub fn decode(reader: anytype) anyerror!WebsocketMessageWelcome { - var this = std.mem.zeroes(WebsocketMessageWelcome); - - this.epoch = try reader.readValue(u32); - this.javascript_reloader = try reader.readValue(Reloader); - this.cwd = try reader.readValue([]const u8); - return this; -} - -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.epoch); - try writer.writeEnum(this.javascript_reloader); - try writer.writeValue(this.cwd); -} - -}; - -pub const WebsocketMessageFileChangeNotification = struct { -/// id -id: u32 = 0, - -/// loader -loader: Loader, - - -pub fn decode(reader: anytype) anyerror!WebsocketMessageFileChangeNotification { - var this = std.mem.zeroes(WebsocketMessageFileChangeNotification); + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + if (this.resolve) |resolve| { + try writer.writeFieldID(1); + try writer.writeValue(@TypeOf(resolve), resolve); + } + if (this.build) |build| { + try writer.writeFieldID(2); + try writer.writeInt(@as(u8, @boolToInt(build))); + } + try writer.endMessage(); + } + }; - this.id = try reader.readValue(u32); - this.loader = try reader.readValue(Loader); - return this; -} + pub const Message = struct { + /// level + level: MessageLevel, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - try writer.writeEnum(this.loader); -} + /// data + data: MessageData, -}; + /// notes + notes: []const MessageData, -pub const WebsocketCommand = struct { -/// kind -kind: WebsocketCommandKind, + /// on + on: MessageMeta, -/// timestamp -timestamp: u32 = 0, + pub fn decode(reader: anytype) anyerror!Message { + var this = std.mem.zeroes(Message); + this.level = try reader.readValue(MessageLevel); + this.data = try reader.readValue(MessageData); + this.notes = try reader.readArray(MessageData); + this.on = try reader.readValue(MessageMeta); + return this; + } -pub fn decode(reader: anytype) anyerror!WebsocketCommand { - var this = std.mem.zeroes(WebsocketCommand); + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeEnum(this.level); + try writer.writeValue(@TypeOf(this.data), this.data); + try writer.writeArray(MessageData, this.notes); + try writer.writeValue(@TypeOf(this.on), this.on); + } + }; - this.kind = try reader.readValue(WebsocketCommandKind); - this.timestamp = try reader.readValue(u32); - return this; -} + pub const Log = struct { + /// warnings + warnings: u32 = 0, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.kind); - try writer.writeInt(this.timestamp); -} + /// errors + errors: u32 = 0, -}; + /// msgs + msgs: []const Message, -pub const WebsocketCommandBuild = packed struct { -/// id -id: u32 = 0, + pub fn decode(reader: anytype) anyerror!Log { + var this = std.mem.zeroes(Log); + this.warnings = try reader.readValue(u32); + this.errors = try reader.readValue(u32); + this.msgs = try reader.readArray(Message); + return this; + } -pub fn decode(reader: anytype) anyerror!WebsocketCommandBuild { - var this = std.mem.zeroes(WebsocketCommandBuild); + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.warnings); + try writer.writeInt(this.errors); + try writer.writeArray(Message, this.msgs); + } + }; - this.id = try reader.readValue(u32); - return this; -} + pub const Reloader = enum(u8) { + _none, + /// disable + disable, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); -} + /// live + live, -}; + /// fast_refresh + fast_refresh, -pub const WebsocketCommandManifest = packed struct { -/// id -id: u32 = 0, + _, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -pub fn decode(reader: anytype) anyerror!WebsocketCommandManifest { - var this = std.mem.zeroes(WebsocketCommandManifest); + pub const WebsocketMessageKind = enum(u8) { + _none, + /// welcome + welcome, - this.id = try reader.readValue(u32); - return this; -} + /// file_change_notification + file_change_notification, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); -} + /// build_success + build_success, -}; + /// build_fail + build_fail, -pub const WebsocketMessageBuildSuccess = struct { -/// id -id: u32 = 0, + /// manifest_success + manifest_success, -/// from_timestamp -from_timestamp: u32 = 0, + /// manifest_fail + manifest_fail, -/// loader -loader: Loader, + _, -/// module_path -module_path: []const u8, + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -/// blob_length -blob_length: u32 = 0, + pub const WebsocketCommandKind = enum(u8) { + _none, + /// build + build, + /// manifest + manifest, -pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildSuccess { - var this = std.mem.zeroes(WebsocketMessageBuildSuccess); + _, - this.id = try reader.readValue(u32); - this.from_timestamp = try reader.readValue(u32); - this.loader = try reader.readValue(Loader); - this.module_path = try reader.readValue([]const u8); - this.blob_length = try reader.readValue(u32); - return this; -} + pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { + return try std.json.stringify(@tagName(self), opts, o); + } + }; -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - try writer.writeInt(this.from_timestamp); - try writer.writeEnum(this.loader); - try writer.writeValue(this.module_path); - try writer.writeInt(this.blob_length); -} + pub const WebsocketMessage = struct { + /// timestamp + timestamp: u32 = 0, -}; + /// kind + kind: WebsocketMessageKind, -pub const WebsocketMessageBuildFailure = struct { -/// id -id: u32 = 0, + pub fn decode(reader: anytype) anyerror!WebsocketMessage { + var this = std.mem.zeroes(WebsocketMessage); -/// from_timestamp -from_timestamp: u32 = 0, + this.timestamp = try reader.readValue(u32); + this.kind = try reader.readValue(WebsocketMessageKind); + return this; + } -/// loader -loader: Loader, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.timestamp); + try writer.writeEnum(this.kind); + } + }; -/// module_path -module_path: []const u8, + pub const WebsocketMessageWelcome = struct { + /// epoch + epoch: u32 = 0, -/// log -log: Log, + /// javascriptReloader + javascript_reloader: Reloader, + /// cwd + cwd: []const u8, -pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildFailure { - var this = std.mem.zeroes(WebsocketMessageBuildFailure); + pub fn decode(reader: anytype) anyerror!WebsocketMessageWelcome { + var this = std.mem.zeroes(WebsocketMessageWelcome); - this.id = try reader.readValue(u32); - this.from_timestamp = try reader.readValue(u32); - this.loader = try reader.readValue(Loader); - this.module_path = try reader.readValue([]const u8); - this.log = try reader.readValue(Log); - return this; -} + this.epoch = try reader.readValue(u32); + this.javascript_reloader = try reader.readValue(Reloader); + this.cwd = try reader.readValue([]const u8); + return this; + } -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - try writer.writeInt(this.from_timestamp); - try writer.writeEnum(this.loader); - try writer.writeValue(this.module_path); - try writer.writeValue(this.log); -} + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.epoch); + try writer.writeEnum(this.javascript_reloader); + try writer.writeValue(@TypeOf(this.cwd), this.cwd); + } + }; -}; + pub const WebsocketMessageFileChangeNotification = struct { + /// id + id: u32 = 0, -pub const DependencyManifest = struct { -/// ids -ids: []const u32, + /// loader + loader: Loader, + pub fn decode(reader: anytype) anyerror!WebsocketMessageFileChangeNotification { + var this = std.mem.zeroes(WebsocketMessageFileChangeNotification); -pub fn decode(reader: anytype) anyerror!DependencyManifest { - var this = std.mem.zeroes(DependencyManifest); + this.id = try reader.readValue(u32); + this.loader = try reader.readValue(Loader); + return this; + } - this.ids = try reader.readArray(u32); - return this; -} + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.id); + try writer.writeEnum(this.loader); + } + }; -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(u32, this.ids); -} + pub const WebsocketCommand = struct { + /// kind + kind: WebsocketCommandKind, -}; + /// timestamp + timestamp: u32 = 0, -pub const FileList = struct { -/// ptrs -ptrs: []const StringPointer, + pub fn decode(reader: anytype) anyerror!WebsocketCommand { + var this = std.mem.zeroes(WebsocketCommand); -/// files -files: []const u8, + this.kind = try reader.readValue(WebsocketCommandKind); + this.timestamp = try reader.readValue(u32); + return this; + } + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeEnum(this.kind); + try writer.writeInt(this.timestamp); + } + }; -pub fn decode(reader: anytype) anyerror!FileList { - var this = std.mem.zeroes(FileList); + pub const WebsocketCommandBuild = packed struct { + /// id + id: u32 = 0, - this.ptrs = try reader.readArray(StringPointer); - this.files = try reader.readValue([]const u8); - return this; -} + pub fn decode(reader: anytype) anyerror!WebsocketCommandBuild { + var this = std.mem.zeroes(WebsocketCommandBuild); -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(StringPointer, this.ptrs); - try writer.writeValue(this.files); -} + this.id = try reader.readValue(u32); + return this; + } -}; + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.id); + } + }; -pub const WebsocketMessageResolveIDs = struct { -/// id -id: []const u32, + pub const WebsocketCommandManifest = packed struct { + /// id + id: u32 = 0, -/// list -list: FileList, + pub fn decode(reader: anytype) anyerror!WebsocketCommandManifest { + var this = std.mem.zeroes(WebsocketCommandManifest); + this.id = try reader.readValue(u32); + return this; + } -pub fn decode(reader: anytype) anyerror!WebsocketMessageResolveIDs { - var this = std.mem.zeroes(WebsocketMessageResolveIDs); + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.id); + } + }; - this.id = try reader.readArray(u32); - this.list = try reader.readValue(FileList); - return this; -} + pub const WebsocketMessageBuildSuccess = struct { + /// id + id: u32 = 0, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(u32, this.id); - try writer.writeValue(this.list); -} + /// from_timestamp + from_timestamp: u32 = 0, -}; + /// loader + loader: Loader, -pub const WebsocketCommandResolveIDs = struct { -/// ptrs -ptrs: []const StringPointer, + /// module_path + module_path: []const u8, -/// files -files: []const u8, + /// blob_length + blob_length: u32 = 0, + pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildSuccess { + var this = std.mem.zeroes(WebsocketMessageBuildSuccess); -pub fn decode(reader: anytype) anyerror!WebsocketCommandResolveIDs { - var this = std.mem.zeroes(WebsocketCommandResolveIDs); + this.id = try reader.readValue(u32); + this.from_timestamp = try reader.readValue(u32); + this.loader = try reader.readValue(Loader); + this.module_path = try reader.readValue([]const u8); + this.blob_length = try reader.readValue(u32); + return this; + } - this.ptrs = try reader.readArray(StringPointer); - this.files = try reader.readValue([]const u8); - return this; -} + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.id); + try writer.writeInt(this.from_timestamp); + try writer.writeEnum(this.loader); + try writer.writeValue(@TypeOf(this.module_path), this.module_path); + try writer.writeInt(this.blob_length); + } + }; -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(StringPointer, this.ptrs); - try writer.writeValue(this.files); -} + pub const WebsocketMessageBuildFailure = struct { + /// id + id: u32 = 0, -}; + /// from_timestamp + from_timestamp: u32 = 0, -pub const WebsocketMessageManifestSuccess = struct { -/// id -id: u32 = 0, + /// loader + loader: Loader, -/// module_path -module_path: []const u8, + /// module_path + module_path: []const u8, -/// loader -loader: Loader, + /// log + log: Log, -/// manifest -manifest: DependencyManifest, + pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildFailure { + var this = std.mem.zeroes(WebsocketMessageBuildFailure); + this.id = try reader.readValue(u32); + this.from_timestamp = try reader.readValue(u32); + this.loader = try reader.readValue(Loader); + this.module_path = try reader.readValue([]const u8); + this.log = try reader.readValue(Log); + return this; + } -pub fn decode(reader: anytype) anyerror!WebsocketMessageManifestSuccess { - var this = std.mem.zeroes(WebsocketMessageManifestSuccess); + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.id); + try writer.writeInt(this.from_timestamp); + try writer.writeEnum(this.loader); + try writer.writeValue(@TypeOf(this.module_path), this.module_path); + try writer.writeValue(@TypeOf(this.log), this.log); + } + }; - this.id = try reader.readValue(u32); - this.module_path = try reader.readValue([]const u8); - this.loader = try reader.readValue(Loader); - this.manifest = try reader.readValue(DependencyManifest); - return this; -} + pub const DependencyManifest = struct { + /// ids + ids: []const u32, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - try writer.writeValue(this.module_path); - try writer.writeEnum(this.loader); - try writer.writeValue(this.manifest); -} + pub fn decode(reader: anytype) anyerror!DependencyManifest { + var this = std.mem.zeroes(DependencyManifest); -}; + this.ids = try reader.readArray(u32); + return this; + } -pub const WebsocketMessageManifestFailure = struct { -/// id -id: u32 = 0, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeArray(u32, this.ids); + } + }; -/// from_timestamp -from_timestamp: u32 = 0, + pub const FileList = struct { + /// ptrs + ptrs: []const StringPointer, -/// loader -loader: Loader, + /// files + files: []const u8, -/// log -log: Log, + pub fn decode(reader: anytype) anyerror!FileList { + var this = std.mem.zeroes(FileList); + this.ptrs = try reader.readArray(StringPointer); + this.files = try reader.readValue([]const u8); + return this; + } -pub fn decode(reader: anytype) anyerror!WebsocketMessageManifestFailure { - var this = std.mem.zeroes(WebsocketMessageManifestFailure); + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeArray(StringPointer, this.ptrs); + try writer.writeValue(@TypeOf(this.files), this.files); + } + }; - this.id = try reader.readValue(u32); - this.from_timestamp = try reader.readValue(u32); - this.loader = try reader.readValue(Loader); - this.log = try reader.readValue(Log); - return this; -} + pub const WebsocketMessageResolveIDs = struct { + /// id + id: []const u32, -pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - try writer.writeInt(this.from_timestamp); - try writer.writeEnum(this.loader); - try writer.writeValue(this.log); -} + /// list + list: FileList, -}; + pub fn decode(reader: anytype) anyerror!WebsocketMessageResolveIDs { + var this = std.mem.zeroes(WebsocketMessageResolveIDs); + this.id = try reader.readArray(u32); + this.list = try reader.readValue(FileList); + return this; + } -}; + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeArray(u32, this.id); + try writer.writeValue(@TypeOf(this.list), this.list); + } + }; + pub const WebsocketCommandResolveIDs = struct { + /// ptrs + ptrs: []const StringPointer, -const ExamplePackedStruct = packed struct { - len: u32 = 0, - offset: u32 = 0, + /// files + files: []const u8, - pub fn encode(this: *const ExamplePackedStruct, writer: anytype) !void { - try writer.write(std.mem.asBytes(this)); - } + pub fn decode(reader: anytype) anyerror!WebsocketCommandResolveIDs { + var this = std.mem.zeroes(WebsocketCommandResolveIDs); - pub fn decode(reader: anytype) !ExamplePackedStruct { - return try reader.readAs(ExamplePackedStruct); - } -}; + this.ptrs = try reader.readArray(StringPointer); + this.files = try reader.readValue([]const u8); + return this; + } -const ExampleStruct = struct { - name: []const u8 = "", - age: u32 = 0, + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeArray(StringPointer, this.ptrs); + try writer.writeValue(@TypeOf(this.files), this.files); + } + }; - pub fn encode(this: *const ExampleStruct, writer: anytype) !void { - try writer.writeArray(u8, this.name); - try writer.writeInt(this.age); - } + pub const WebsocketMessageManifestSuccess = struct { + /// id + id: u32 = 0, - pub fn decode(reader: anytype) !ExampleStruct { - var this = std.mem.zeroes(ExampleStruct); - this.name = try reader.readArray(u8); - this.age = try reader.readInt(u32); + /// module_path + module_path: []const u8, - return this; - } -}; + /// loader + loader: Loader, -const EnumValue = enum(u8) { hey, hi, heyopoo }; + /// manifest + manifest: DependencyManifest, -const ExampleMessage = struct { - examples: ?[]ExampleStruct = &([_]ExampleStruct{}), - pack: ?[]ExamplePackedStruct = &([_]ExamplePackedStruct{}), - hey: ?u8 = 0, - hey16: ?u16 = 0, - hey32: ?u16 = 0, - heyi32: ?i32 = 0, - heyi16: ?i16 = 0, - heyi8: ?i8 = 0, - boolean: ?bool = null, - heyooo: ?EnumValue = null, + pub fn decode(reader: anytype) anyerror!WebsocketMessageManifestSuccess { + var this = std.mem.zeroes(WebsocketMessageManifestSuccess); - pub fn encode(this: *const ExampleMessage, writer: anytype) !void { - if (this.examples) |examples| { - try writer.writeFieldID(1); - try writer.writeArray(ExampleStruct, examples); + this.id = try reader.readValue(u32); + this.module_path = try reader.readValue([]const u8); + this.loader = try reader.readValue(Loader); + this.manifest = try reader.readValue(DependencyManifest); + return this; } - if (this.pack) |pack| { - try writer.writeFieldID(2); - try writer.writeArray(ExamplePackedStruct, pack); + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.id); + try writer.writeValue(@TypeOf(this.module_path), this.module_path); + try writer.writeEnum(this.loader); + try writer.writeValue(@TypeOf(this.manifest), this.manifest); } + }; - if (this.hey) |hey| { - try writer.writeFieldID(3); - try writer.writeInt(hey); - } - if (this.hey16) |hey16| { - try writer.writeFieldID(4); - try writer.writeInt(hey16); - } - if (this.hey32) |hey32| { - try writer.writeFieldID(5); - try writer.writeInt(hey32); - } - if (this.heyi32) |heyi32| { - try writer.writeFieldID(6); - try writer.writeInt(heyi32); - } - if (this.heyi16) |heyi16| { - try writer.writeFieldID(7); - try writer.writeInt(heyi16); - } - if (this.heyi8) |heyi8| { - try writer.writeFieldID(8); - try writer.writeInt(heyi8); - } - if (this.boolean) |boolean| { - try writer.writeFieldID(9); - try writer.writeInt(boolean); - } + pub const WebsocketMessageManifestFailure = struct { + /// id + id: u32 = 0, - if (this.heyooo) |heyoo| { - try writer.writeFieldID(10); - try writer.writeEnum(heyoo); - } + /// from_timestamp + from_timestamp: u32 = 0, - try writer.endMessage(); - } + /// loader + loader: Loader, - pub fn decode(reader: anytype) !ExampleMessage { - var this = std.mem.zeroes(ExampleMessage); - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, + /// log + log: Log, - 1 => { - this.examples = try reader.readArray(std.meta.Child(@TypeOf(this.examples.?))); - }, - 2 => { - this.pack = try reader.readArray(std.meta.Child(@TypeOf(this.pack.?))); - }, - 3 => { - this.hey = try reader.readValue(@TypeOf(this.hey.?)); - }, - 4 => { - this.hey16 = try reader.readValue(@TypeOf(this.hey16.?)); - }, - 5 => { - this.hey32 = try reader.readValue(@TypeOf(this.hey32.?)); - }, - 6 => { - this.heyi32 = try reader.readValue(@TypeOf(this.heyi32.?)); - }, - 7 => { - this.heyi16 = try reader.readValue(@TypeOf(this.heyi16.?)); - }, - 8 => { - this.heyi8 = try reader.readValue(@TypeOf(this.heyi8.?)); - }, - 9 => { - this.boolean = try reader.readValue(@TypeOf(this.boolean.?)); - }, - 10 => { - this.heyooo = try reader.readValue(@TypeOf(this.heyooo.?)); - }, - else => { - return error.InvalidValue; - }, - } + pub fn decode(reader: anytype) anyerror!WebsocketMessageManifestFailure { + var this = std.mem.zeroes(WebsocketMessageManifestFailure); + + this.id = try reader.readValue(u32); + this.from_timestamp = try reader.readValue(u32); + this.loader = try reader.readValue(Loader); + this.log = try reader.readValue(Log); + return this; } - return this; - } + pub fn encode(this: *const @This(), writer: anytype) anyerror!void { + try writer.writeInt(this.id); + try writer.writeInt(this.from_timestamp); + try writer.writeEnum(this.loader); + try writer.writeValue(@TypeOf(this.log), this.log); + } + }; }; - -test "ExampleMessage" { - var base = std.mem.zeroes(ExampleMessage); - base.hey = 1; - var buf: [4096]u8 = undefined; - var writable = std.io.fixedBufferStream(&buf); - var writer = ByteWriter.init(writable); - var examples = [_]ExamplePackedStruct{ - .{ .len = 2, .offset = 5 }, - .{ .len = 0, .offset = 10 }, - }; - - var more_examples = [_]ExampleStruct{ - .{ .name = "bacon", .age = 10 }, - .{ .name = "slime", .age = 300 }, - }; - base.examples = &more_examples; - base.pack = &examples; - base.heyooo = EnumValue.hey; - try base.encode(&writer); - var reader = Reader.init(&buf, std.heap.c_allocator); - var compare = try ExampleMessage.decode(&reader); - try std.testing.expectEqual(base.hey orelse 255, 1); - - const cmp_pack = compare.pack.?; - for (cmp_pack) |item, id| { - try std.testing.expectEqual(item, examples[id]); - } - - const cmp_ex = compare.examples.?; - for (cmp_ex) |item, id| { - try std.testing.expectEqualStrings(item.name, more_examples[id].name); - try std.testing.expectEqual(item.age, more_examples[id].age); - } - - try std.testing.expectEqual(cmp_pack[0].len, examples[0].len); - try std.testing.expectEqual(base.heyooo, compare.heyooo); -} |