diff options
author | 2021-05-21 17:55:42 -0700 | |
---|---|---|
committer | 2021-05-21 17:55:42 -0700 | |
commit | c3d3d70ced281a1d7863b2f08f036b3bc83537b9 (patch) | |
tree | 706f2387e81b255a393962daeeebad4e675d8e3b /src/api/schema.zig | |
parent | 8b75f56577abc3ad2479b87fc59b7243add6a29a (diff) | |
download | bun-c3d3d70ced281a1d7863b2f08f036b3bc83537b9.tar.gz bun-c3d3d70ced281a1d7863b2f08f036b3bc83537b9.tar.zst bun-c3d3d70ced281a1d7863b2f08f036b3bc83537b9.zip |
wip
Former-commit-id: 63e622f2f366a30d4432835b1e190191fd04f6df
Diffstat (limited to 'src/api/schema.zig')
-rw-r--r-- | src/api/schema.zig | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/api/schema.zig b/src/api/schema.zig index bba5a3c94..262c0d01c 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -200,12 +200,15 @@ pub const Api = struct { /// platform platform: ?Platform = null, - /// watch - watch: ?bool = null, + /// serve + serve: ?bool = null, /// extension_order extension_order: []const []const u8, + /// public_dir + public_dir: ?[]const u8 = null, + pub fn decode(allocator: *std.mem.Allocator, reader: anytype) anyerror!TransformOptions { var obj = std.mem.zeroes(TransformOptions); try update(&obj, allocator, reader); @@ -381,7 +384,7 @@ pub const Api = struct { result.platform = try reader.readEnum(Platform, .Little); }, 18 => { - result.watch = (try reader.readByte()) == @as(u8, 1); + result.serve = (try reader.readByte()) == @as(u8, 1); }, 19 => { { @@ -398,6 +401,13 @@ pub const Api = struct { } } }, + 20 => { + length = try reader.readIntNative(u32); + if ((result.public_dir orelse &([_]u8{})).len != length) { + result.public_dir = try allocator.alloc(u8, length); + } + _ = try reader.readAll(result.public_dir.?); + }, else => { return error.InvalidMessage; }, @@ -559,9 +569,9 @@ pub const Api = struct { try writer.writeIntNative(@TypeOf(@enumToInt(result.platform orelse unreachable)), @enumToInt(result.platform orelse unreachable)); } - if (result.watch) |watch| { + if (result.serve) |serve| { try writer.writeByte(18); - try writer.writeByte(@boolToInt(watch)); + try writer.writeByte(@boolToInt(serve)); } if (result.extension_order) |extension_order| { @@ -576,6 +586,12 @@ pub const Api = struct { } } } + + if (result.public_dir) |public_dir| { + try writer.writeByte(20); + try writer.writeIntNative(u32, @intCast(u32, public_dir.len)); + try writer.writeAll(std.mem.sliceAsBytes(public_dir)); + } try writer.writeByte(0); return; } |