aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-06-09 13:26:30 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-06-09 13:26:30 -0700
commitecda693e3844511644a177a0bcb146bda07effb9 (patch)
treee032597bdae3e8229a88042d1ae2b978ef63e056 /src/api
parent6a4712f4c90ef7f1bb858ea81fe3d11ea60b036e (diff)
downloadbun-ecda693e3844511644a177a0bcb146bda07effb9.tar.gz
bun-ecda693e3844511644a177a0bcb146bda07effb9.tar.zst
bun-ecda693e3844511644a177a0bcb146bda07effb9.zip
lots
Former-commit-id: 7346cdaa5a32ade26821ed97ef07f7c9ae87c0c2
Diffstat (limited to 'src/api')
-rw-r--r--src/api/schema.d.ts22
-rw-r--r--src/api/schema.js220
-rw-r--r--src/api/schema.peechy47
-rw-r--r--src/api/schema.zig1648
4 files changed, 1060 insertions, 877 deletions
diff --git a/src/api/schema.d.ts b/src/api/schema.d.ts
index 2162d6901..8d8ae010e 100644
--- a/src/api/schema.d.ts
+++ b/src/api/schema.d.ts
@@ -137,6 +137,7 @@ type uint32 = number;
path: StringPointer;
code: StringPointer;
package_id: uint32;
+ path_extname_length: byte;
}
export interface JavascriptBundledPackage {
@@ -174,22 +175,30 @@ type uint32 = number;
imports: ModuleImportRecord[];
}
+ export interface StringMap {
+ keys: string[];
+ values: string[];
+ }
+
+ export interface LoaderMap {
+ extensions: string[];
+ loaders: Loader[];
+ }
+
export interface TransformOptions {
jsx?: JSX;
tsconfig_override?: string;
resolve?: ResolveMode;
public_url?: string;
absolute_working_dir?: string;
- define_keys?: string[];
- define_values?: string[];
+ define?: StringMap;
preserve_symlinks?: boolean;
entry_points?: string[];
write?: boolean;
inject?: string[];
output_dir?: string;
external?: string[];
- loader_keys?: string[];
- loader_values?: Loader[];
+ loaders?: LoaderMap;
main_fields?: string[];
platform?: Platform;
serve?: boolean;
@@ -197,6 +206,7 @@ type uint32 = number;
public_dir?: string;
only_scan_dependencies?: ScanDependencyMode;
generate_node_module_bundle?: boolean;
+ node_modules_bundle_path?: string;
}
export interface FileHandle {
@@ -267,6 +277,10 @@ type uint32 = number;
export declare function decodeModuleImportRecord(buffer: ByteBuffer): ModuleImportRecord;
export declare function encodeModule(message: Module, bb: ByteBuffer): void;
export declare function decodeModule(buffer: ByteBuffer): Module;
+ export declare function encodeStringMap(message: StringMap, bb: ByteBuffer): void;
+ export declare function decodeStringMap(buffer: ByteBuffer): StringMap;
+ export declare function encodeLoaderMap(message: LoaderMap, bb: ByteBuffer): void;
+ export declare function decodeLoaderMap(buffer: ByteBuffer): LoaderMap;
export declare function encodeTransformOptions(message: TransformOptions, bb: ByteBuffer): void;
export declare function decodeTransformOptions(buffer: ByteBuffer): TransformOptions;
export declare function encodeFileHandle(message: FileHandle, bb: ByteBuffer): void;
diff --git a/src/api/schema.js b/src/api/schema.js
index 96d3b54fd..3f0bb8179 100644
--- a/src/api/schema.js
+++ b/src/api/schema.js
@@ -167,6 +167,7 @@ function decodeJavascriptBundledModule(bb) {
result["path"] = decodeStringPointer(bb);
result["code"] = decodeStringPointer(bb);
result["package_id"] = bb.readUint32();
+ result["path_extname_length"] = bb.readByte();
return result;
}
@@ -193,6 +194,13 @@ function encodeJavascriptBundledModule(message, bb) {
throw new Error("Missing required field \"package_id\"");
}
+ var value = message["path_extname_length"];
+ if (value != null) {
+ bb.writeByte(value);
+ } else {
+ throw new Error("Missing required field \"path_extname_length\"");
+ }
+
}
function decodeJavascriptBundledPackage(bb) {
@@ -467,6 +475,88 @@ function encodeModule(message, bb) {
}
+function decodeStringMap(bb) {
+ var result = {};
+
+ var length = bb.readVarUint();
+ var values = result["keys"] = Array(length);
+ for (var i = 0; i < length; i++) values[i] = bb.readString();
+ var length = bb.readVarUint();
+ var values = result["values"] = Array(length);
+ for (var i = 0; i < length; i++) values[i] = bb.readString();
+ return result;
+}
+
+function encodeStringMap(message, bb) {
+
+ var value = message["keys"];
+ if (value != null) {
+ var values = value, n = values.length;
+ bb.writeVarUint(n);
+ for (var i = 0; i < n; i++) {
+ value = values[i];
+ bb.writeString(value);
+ }
+ } else {
+ throw new Error("Missing required field \"keys\"");
+ }
+
+ var value = message["values"];
+ if (value != null) {
+ var values = value, n = values.length;
+ bb.writeVarUint(n);
+ for (var i = 0; i < n; i++) {
+ value = values[i];
+ bb.writeString(value);
+ }
+ } else {
+ throw new Error("Missing required field \"values\"");
+ }
+
+}
+
+function decodeLoaderMap(bb) {
+ var result = {};
+
+ var length = bb.readVarUint();
+ var values = result["extensions"] = Array(length);
+ for (var i = 0; i < length; i++) values[i] = bb.readString();
+ var length = bb.readVarUint();
+ var values = result["loaders"] = Array(length);
+ for (var i = 0; i < length; i++) values[i] = Loader[bb.readByte()];
+ return result;
+}
+
+function encodeLoaderMap(message, bb) {
+
+ var value = message["extensions"];
+ if (value != null) {
+ var values = value, n = values.length;
+ bb.writeVarUint(n);
+ for (var i = 0; i < n; i++) {
+ value = values[i];
+ bb.writeString(value);
+ }
+ } else {
+ throw new Error("Missing required field \"extensions\"");
+ }
+
+ var value = message["loaders"];
+ if (value != null) {
+ var values = value, n = values.length;
+ bb.writeVarUint(n);
+ for (var i = 0; i < n; i++) {
+ value = values[i];
+ var encoded = Loader[value];
+if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + " for enum \"Loader\"");
+bb.writeByte(encoded);
+ }
+ } else {
+ throw new Error("Missing required field \"loaders\"");
+ }
+
+}
+
function decodeTransformOptions(bb) {
var result = {};
@@ -496,91 +586,79 @@ function decodeTransformOptions(bb) {
break;
case 6:
- var length = bb.readVarUint();
- var values = result["define_keys"] = Array(length);
- for (var i = 0; i < length; i++) values[i] = bb.readString();
+ result["define"] = decodeStringMap(bb);
break;
case 7:
- var length = bb.readVarUint();
- var values = result["define_values"] = Array(length);
- for (var i = 0; i < length; i++) values[i] = bb.readString();
- break;
-
- case 8:
result["preserve_symlinks"] = !!bb.readByte();
break;
- case 9:
+ case 8:
var length = bb.readVarUint();
var values = result["entry_points"] = Array(length);
for (var i = 0; i < length; i++) values[i] = bb.readString();
break;
- case 10:
+ case 9:
result["write"] = !!bb.readByte();
break;
- case 11:
+ case 10:
var length = bb.readVarUint();
var values = result["inject"] = Array(length);
for (var i = 0; i < length; i++) values[i] = bb.readString();
break;
- case 12:
+ case 11:
result["output_dir"] = bb.readString();
break;
- case 13:
+ case 12:
var length = bb.readVarUint();
var values = result["external"] = Array(length);
for (var i = 0; i < length; i++) values[i] = bb.readString();
break;
- case 14:
- var length = bb.readVarUint();
- var values = result["loader_keys"] = Array(length);
- for (var i = 0; i < length; i++) values[i] = bb.readString();
- break;
-
- case 15:
- var length = bb.readVarUint();
- var values = result["loader_values"] = Array(length);
- for (var i = 0; i < length; i++) values[i] = Loader[bb.readByte()];
+ case 13:
+ result["loaders"] = decodeLoaderMap(bb);
break;
- case 16:
+ case 14:
var length = bb.readVarUint();
var values = result["main_fields"] = Array(length);
for (var i = 0; i < length; i++) values[i] = bb.readString();
break;
- case 17:
+ case 15:
result["platform"] = Platform[bb.readByte()];
break;
- case 18:
+ case 16:
result["serve"] = !!bb.readByte();
break;
- case 19:
+ case 17:
var length = bb.readVarUint();
var values = result["extension_order"] = Array(length);
for (var i = 0; i < length; i++) values[i] = bb.readString();
break;
- case 20:
+ case 18:
result["public_dir"] = bb.readString();
break;
- case 21:
+ case 19:
result["only_scan_dependencies"] = ScanDependencyMode[bb.readByte()];
break;
- case 22:
+ case 20:
result["generate_node_module_bundle"] = !!bb.readByte();
break;
+ case 21:
+ result["node_modules_bundle_path"] = bb.readString();
+ break;
+
default:
throw new Error("Attempted to parse invalid message");
}
@@ -621,37 +699,21 @@ bb.writeByte(encoded);
bb.writeString(value);
}
- var value = message["define_keys"];
+ var value = message["define"];
if (value != null) {
bb.writeByte(6);
- var values = value, n = values.length;
- bb.writeVarUint(n);
- for (var i = 0; i < n; i++) {
- value = values[i];
- bb.writeString(value);
- }
- }
-
- var value = message["define_values"];
- if (value != null) {
- bb.writeByte(7);
- var values = value, n = values.length;
- bb.writeVarUint(n);
- for (var i = 0; i < n; i++) {
- value = values[i];
- bb.writeString(value);
- }
+ encodeStringMap(value, bb);
}
var value = message["preserve_symlinks"];
if (value != null) {
- bb.writeByte(8);
+ bb.writeByte(7);
bb.writeByte(value);
}
var value = message["entry_points"];
if (value != null) {
- bb.writeByte(9);
+ bb.writeByte(8);
var values = value, n = values.length;
bb.writeVarUint(n);
for (var i = 0; i < n; i++) {
@@ -662,13 +724,13 @@ bb.writeByte(encoded);
var value = message["write"];
if (value != null) {
- bb.writeByte(10);
+ bb.writeByte(9);
bb.writeByte(value);
}
var value = message["inject"];
if (value != null) {
- bb.writeByte(11);
+ bb.writeByte(10);
var values = value, n = values.length;
bb.writeVarUint(n);
for (var i = 0; i < n; i++) {
@@ -679,24 +741,13 @@ bb.writeByte(encoded);
var value = message["output_dir"];
if (value != null) {
- bb.writeByte(12);
+ bb.writeByte(11);
bb.writeString(value);
}
var value = message["external"];
if (value != null) {
- bb.writeByte(13);
- var values = value, n = values.length;
- bb.writeVarUint(n);
- for (var i = 0; i < n; i++) {
- value = values[i];
- bb.writeString(value);
- }
- }
-
- var value = message["loader_keys"];
- if (value != null) {
- bb.writeByte(14);
+ bb.writeByte(12);
var values = value, n = values.length;
bb.writeVarUint(n);
for (var i = 0; i < n; i++) {
@@ -705,22 +756,15 @@ bb.writeByte(encoded);
}
}
- var value = message["loader_values"];
+ var value = message["loaders"];
if (value != null) {
- bb.writeByte(15);
- var values = value, n = values.length;
- bb.writeVarUint(n);
- for (var i = 0; i < n; i++) {
- value = values[i];
- var encoded = Loader[value];
-if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + " for enum \"Loader\"");
-bb.writeByte(encoded);
- }
+ bb.writeByte(13);
+ encodeLoaderMap(value, bb);
}
var value = message["main_fields"];
if (value != null) {
- bb.writeByte(16);
+ bb.writeByte(14);
var values = value, n = values.length;
bb.writeVarUint(n);
for (var i = 0; i < n; i++) {
@@ -731,7 +775,7 @@ bb.writeByte(encoded);
var value = message["platform"];
if (value != null) {
- bb.writeByte(17);
+ bb.writeByte(15);
var encoded = Platform[value];
if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + " for enum \"Platform\"");
bb.writeByte(encoded);
@@ -739,13 +783,13 @@ bb.writeByte(encoded);
var value = message["serve"];
if (value != null) {
- bb.writeByte(18);
+ bb.writeByte(16);
bb.writeByte(value);
}
var value = message["extension_order"];
if (value != null) {
- bb.writeByte(19);
+ bb.writeByte(17);
var values = value, n = values.length;
bb.writeVarUint(n);
for (var i = 0; i < n; i++) {
@@ -756,13 +800,13 @@ bb.writeByte(encoded);
var value = message["public_dir"];
if (value != null) {
- bb.writeByte(20);
+ bb.writeByte(18);
bb.writeString(value);
}
var value = message["only_scan_dependencies"];
if (value != null) {
- bb.writeByte(21);
+ bb.writeByte(19);
var encoded = ScanDependencyMode[value];
if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + " for enum \"ScanDependencyMode\"");
bb.writeByte(encoded);
@@ -770,9 +814,15 @@ bb.writeByte(encoded);
var value = message["generate_node_module_bundle"];
if (value != null) {
- bb.writeByte(22);
+ bb.writeByte(20);
bb.writeByte(value);
}
+
+ var value = message["node_modules_bundle_path"];
+ if (value != null) {
+ bb.writeByte(21);
+ bb.writeString(value);
+ }
bb.writeByte(0);
}
@@ -1207,6 +1257,10 @@ export { decodeModuleImportRecord }
export { encodeModuleImportRecord }
export { decodeModule }
export { encodeModule }
+export { decodeStringMap }
+export { encodeStringMap }
+export { decodeLoaderMap }
+export { encodeLoaderMap }
export { decodeTransformOptions }
export { encodeTransformOptions }
export { decodeFileHandle }
diff --git a/src/api/schema.peechy b/src/api/schema.peechy
index 1c21c7d5e..f893c525b 100644
--- a/src/api/schema.peechy
+++ b/src/api/schema.peechy
@@ -49,7 +49,9 @@ struct JavascriptBundledModule {
StringPointer path;
StringPointer code;
uint32 package_id;
-
+ // This lets us efficiently compare strings ignoring the extension
+ // If we instead omit the extension
+ byte path_extname_length;
}
struct JavascriptBundledPackage {
@@ -105,6 +107,16 @@ struct Module {
ModuleImportRecord[] imports;
}
+struct StringMap {
+ string[] keys;
+ string[] values;
+}
+
+struct LoaderMap {
+ string[] extensions;
+ Loader[] loaders;
+}
+
message TransformOptions {
JSX jsx = 1;
string tsconfig_override = 2;
@@ -113,35 +125,34 @@ message TransformOptions {
string public_url = 4;
string absolute_working_dir = 5;
+ StringMap define = 6;
- string[] define_keys = 6;
- string[] define_values = 7;
+ bool preserve_symlinks = 7;
- bool preserve_symlinks = 8;
+ string[] entry_points = 8;
+ bool write = 9;
- string[] entry_points = 9;
- bool write = 10;
+ string[] inject = 10;
+ string output_dir = 11;
- string[] inject = 11;
- string output_dir = 12;
+ string[] external = 12;
- string[] external = 13;
+ LoaderMap loaders = 13;
- string[] loader_keys = 14;
- Loader[] loader_values = 15;
+ string[] main_fields = 14;
+ Platform platform = 15;
- string[] main_fields = 16;
- Platform platform = 17;
+ bool serve = 16;
- bool serve = 18;
+ string[] extension_order = 17;
- string[] extension_order = 19;
+ string public_dir = 18;
- string public_dir = 20;
+ ScanDependencyMode only_scan_dependencies = 19;
- ScanDependencyMode only_scan_dependencies = 21;
+ bool generate_node_module_bundle = 20;
- bool generate_node_module_bundle = 22;
+ string node_modules_bundle_path = 21;
}
struct FileHandle {
diff --git a/src/api/schema.zig b/src/api/schema.zig
index 0e7cb6fcc..4a2e44f9b 100644
--- a/src/api/schema.zig
+++ b/src/api/schema.zig
@@ -1,3 +1,4 @@
+
const std = @import("std");
pub const Reader = struct {
@@ -58,7 +59,7 @@ pub const Reader = struct {
return E.InvalidValue;
}
- pub fn readArray(this: *Self, comptime T: type) ![]T {
+ pub fn readArray(this: *Self, comptime T: type) ![]const T {
const length = try this.readInt(u32);
if (length == 0) {
return &([_]T{});
@@ -92,7 +93,8 @@ pub const Reader = struct {
}
},
.Enum => |type_info| {
- return std.meta.cast([]T, std.mem.readIntSliceNative(type_info.tag_type, try this.read(length * @sizeOf(type_info.tag_type))));
+ const enum_values = try this.read(length * @sizeOf(type_info.tag_type));
+ return @ptrCast([*]T, enum_values.ptr)[0..length];
},
else => {},
}
@@ -136,6 +138,10 @@ pub const Reader = struct {
return try this.readByte();
},
[]const u8 => {
+ return try this.readArray(u8);
+ },
+
+ []const []const u8 => {
return try this.readArray([]const u8);
},
[]u8 => {
@@ -274,955 +280,1053 @@ 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,
- /// tsx
- tsx,
+pub const Api = struct {
- /// css
- css,
+pub const Loader = enum(u8) {
- /// file
- file,
+_none,
+ /// jsx
+ jsx,
- /// json
- json,
+ /// js
+ js,
- _,
+ /// ts
+ ts,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
- };
+ /// tsx
+ tsx,
- pub const ResolveMode = enum(u8) {
- _none,
- /// disable
- disable,
+ /// css
+ css,
- /// lazy
- lazy,
+ /// file
+ file,
- /// dev
- dev,
+ /// json
+ json,
- /// bundle
- bundle,
+_,
- _,
+ 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 Platform = enum(u8) {
- _none,
- /// browser
- browser,
+pub const ResolveMode = enum(u8) {
- /// node
- node,
+_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,
- pub const JsxRuntime = enum(u8) {
- _none,
- /// automatic
- automatic,
+ /// bundle
+ bundle,
- /// classic
- classic,
+_,
- _,
+ 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 Jsx = struct {
- /// factory
- factory: []const u8,
+pub const Platform = enum(u8) {
- /// runtime
- runtime: JsxRuntime,
+_none,
+ /// browser
+ browser,
- /// fragment
- fragment: []const u8,
+ /// node
+ node,
- /// development
- development: bool = false,
+_,
- /// import_source
- import_source: []const u8,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
- /// react_fast_refresh
- react_fast_refresh: bool = false,
+
+};
- pub fn decode(reader: anytype) anyerror!Jsx {
- var this = std.mem.zeroes(Jsx);
+pub const JsxRuntime = enum(u8) {
- 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;
- }
+_none,
+ /// automatic
+ automatic,
- 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)));
- }
- };
+ /// classic
+ classic,
- pub const StringPointer = packed struct {
- /// offset
- offset: u32 = 0,
+_,
- /// length
- length: 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!StringPointer {
- var this = std.mem.zeroes(StringPointer);
+
+};
- this.offset = try reader.readValue(u32);
- this.length = try reader.readValue(u32);
- return this;
- }
+pub const Jsx = struct {
+/// factory
+factory: []const u8,
- pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.offset);
- try writer.writeInt(this.length);
- }
- };
+/// runtime
+runtime: JsxRuntime,
- pub const JavascriptBundledModule = struct {
- /// path
- path: StringPointer,
+/// fragment
+fragment: []const u8,
- /// code
- code: StringPointer,
+/// development
+development: bool = false,
- /// package_id
- package_id: u32 = 0,
+/// import_source
+import_source: []const u8,
- pub fn decode(reader: anytype) anyerror!JavascriptBundledModule {
- var this = std.mem.zeroes(JavascriptBundledModule);
+/// react_fast_refresh
+react_fast_refresh: bool = false,
- this.path = try reader.readValue(StringPointer);
- this.code = try reader.readValue(StringPointer);
- this.package_id = try reader.readValue(u32);
- return this;
- }
- 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);
- }
- };
+pub fn decode(reader: anytype) anyerror!Jsx {
+ var this = std.mem.zeroes(Jsx);
- pub const JavascriptBundledPackage = struct {
- /// name
- name: StringPointer,
+ 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;
+}
- /// version
- version: StringPointer,
+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)));
+}
- /// hash
- hash: u32 = 0,
+};
- /// modules_offset
- modules_offset: u32 = 0,
+pub const StringPointer = packed struct {
+/// offset
+offset: u32 = 0,
- /// modules_length
- modules_length: u32 = 0,
+/// length
+length: u32 = 0,
- pub fn decode(reader: anytype) anyerror!JavascriptBundledPackage {
- var this = std.mem.zeroes(JavascriptBundledPackage);
- 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;
- }
+pub fn decode(reader: anytype) anyerror!StringPointer {
+ var this = std.mem.zeroes(StringPointer);
- 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);
- }
- };
+ this.offset = try reader.readValue(u32);
+ this.length = try reader.readValue(u32);
+ return this;
+}
- pub const JavascriptBundle = struct {
- /// modules
- modules: []JavascriptBundledModule,
+pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.offset);
+ try writer.writeInt(this.length);
+}
- /// packages
- packages: []JavascriptBundledPackage,
+};
- /// etag
- etag: []const u8,
+pub const JavascriptBundledModule = struct {
+/// path
+path: StringPointer,
- /// generated_at
- generated_at: u32 = 0,
+/// code
+code: StringPointer,
- /// app_package_json_dependencies_hash
- app_package_json_dependencies_hash: []const u8,
+/// package_id
+package_id: u32 = 0,
- /// import_from_name
- import_from_name: []const u8,
+/// path_extname_length
+path_extname_length: u8 = 0,
- /// manifest_string
- manifest_string: []const u8,
- pub fn decode(reader: anytype) anyerror!JavascriptBundle {
- var this = std.mem.zeroes(JavascriptBundle);
+pub fn decode(reader: anytype) anyerror!JavascriptBundledModule {
+ var this = std.mem.zeroes(JavascriptBundledModule);
- 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;
- }
+ this.path = try reader.readValue(StringPointer);
+ this.code = try reader.readValue(StringPointer);
+ this.package_id = try reader.readValue(u32);
+ this.path_extname_length = try reader.readValue(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 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.path_extname_length);
+}
- pub const JavascriptBundleContainer = struct {
- /// bundle_format_version
- bundle_format_version: ?u32 = null,
+};
- /// bundle
- bundle: ?JavascriptBundle = null,
+pub const JavascriptBundledPackage = struct {
+/// name
+name: StringPointer,
- /// code_length
- code_length: ?u32 = null,
+/// version
+version: StringPointer,
- pub fn decode(reader: anytype) anyerror!JavascriptBundleContainer {
- var this = std.mem.zeroes(JavascriptBundleContainer);
+/// hash
+hash: u32 = 0,
- while (true) {
- switch (try reader.readByte()) {
- 0 => {
- return this;
- },
+/// modules_offset
+modules_offset: u32 = 0,
- 1 => {
- this.bundle_format_version = try reader.readValue(u32);
- },
- 2 => {
- this.bundle = try reader.readValue(JavascriptBundle);
- },
- 3 => {
- this.code_length = try reader.readValue(u32);
- },
- else => {
- return error.InvalidMessage;
- },
- }
- }
- unreachable;
- }
+/// modules_length
+modules_length: u32 = 0,
- 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.bundle) |bundle| {
- try writer.writeFieldID(2);
- try writer.writeValue(bundle);
- }
- if (this.code_length) |code_length| {
- try writer.writeFieldID(3);
- try writer.writeInt(code_length);
- }
- try writer.endMessage();
- }
- };
- pub const ScanDependencyMode = enum(u8) {
- _none,
- /// app
- app,
+pub fn decode(reader: anytype) anyerror!JavascriptBundledPackage {
+ var this = std.mem.zeroes(JavascriptBundledPackage);
- /// all
- all,
+ 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;
+}
- _,
+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);
+}
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
- };
+};
- pub const ModuleImportType = enum(u8) {
- _none,
- /// import
- import,
+pub const JavascriptBundle = struct {
+/// modules
+modules: []const JavascriptBundledModule,
- /// require
- require,
+/// packages
+packages: []const JavascriptBundledPackage,
- _,
+/// etag
+etag: []const u8,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
- };
+/// generated_at
+generated_at: u32 = 0,
- pub const ModuleImportRecord = struct {
- /// kind
- kind: ModuleImportType,
+/// app_package_json_dependencies_hash
+app_package_json_dependencies_hash: []const u8,
- /// path
- path: []const u8,
+/// import_from_name
+import_from_name: []const u8,
- /// dynamic
- dynamic: bool = false,
+/// manifest_string
+manifest_string: []const u8,
- pub fn decode(reader: anytype) anyerror!ModuleImportRecord {
- var this = std.mem.zeroes(ModuleImportRecord);
- this.kind = try reader.readValue(ModuleImportType);
- this.path = try reader.readValue([]const u8);
- this.dynamic = try reader.readValue(bool);
- 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.writeEnum(this.kind);
- try writer.writeValue(this.path);
- try writer.writeInt(@intCast(u8, @boolToInt(this.dynamic)));
- }
- };
+ 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 const Module = struct {
- /// path
- path: []const u8,
+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);
+}
- /// imports
- imports: []ModuleImportRecord,
+};
- pub fn decode(reader: anytype) anyerror!Module {
- var this = std.mem.zeroes(Module);
+pub const JavascriptBundleContainer = struct {
+/// bundle_format_version
+bundle_format_version: ?u32 = 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.bundle = try reader.readValue(JavascriptBundle);
+},
+ 3 => {
+ this.code_length = try reader.readValue(u32);
+},
+ else => {
+ return error.InvalidMessage;
+ },
+ }
+ }
+unreachable;
+}
- 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 {
+if (this.bundle_format_version) |bundle_format_version| {
+ try writer.writeFieldID(1);
+ try writer.writeInt(bundle_format_version);
+}
+if (this.bundle) |bundle| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(bundle);
+}
+if (this.code_length) |code_length| {
+ try writer.writeFieldID(3);
+ try writer.writeInt(code_length);
+}
+try writer.endMessage();
+}
- pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.path);
- try writer.writeArray(ModuleImportRecord, this.imports);
- }
- };
+};
- pub const TransformOptions = struct {
- /// jsx
- jsx: ?Jsx = null,
+pub const ScanDependencyMode = enum(u8) {
- /// tsconfig_override
- tsconfig_override: ?[]const u8 = null,
+_none,
+ /// app
+ app,
- /// resolve
- resolve: ?ResolveMode = null,
+ /// all
+ all,
- /// public_url
- public_url: ?[]const u8 = null,
+_,
- /// absolute_working_dir
- absolute_working_dir: ?[]const u8 = null,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
- /// define_keys
- define_keys: []const []const u8,
+
+};
- /// define_values
- define_values: []const []const u8,
+pub const ModuleImportType = enum(u8) {
- /// preserve_symlinks
- preserve_symlinks: ?bool = null,
+_none,
+ /// import
+ import,
- /// entry_points
- entry_points: []const []const u8,
+ /// require
+ require,
- /// write
- write: ?bool = null,
+_,
- /// inject
- inject: []const []const u8,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
- /// output_dir
- output_dir: ?[]const u8 = null,
+
+};
- /// external
- external: []const []const u8,
+pub const ModuleImportRecord = struct {
+/// kind
+kind: ModuleImportType,
- /// loader_keys
- loader_keys: []const []const u8,
+/// path
+path: []const u8,
- /// loader_values
- loader_values: []const Loader,
+/// dynamic
+dynamic: bool = false,
- /// main_fields
- main_fields: []const []const u8,
- /// platform
- platform: ?Platform = null,
+pub fn decode(reader: anytype) anyerror!ModuleImportRecord {
+ var this = std.mem.zeroes(ModuleImportRecord);
- /// serve
- serve: ?bool = null,
+ this.kind = try reader.readValue(ModuleImportType);
+ this.path = try reader.readValue([]const u8);
+ this.dynamic = try reader.readValue(bool);
+ return this;
+}
- /// extension_order
- extension_order: []const []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)));
+}
- /// public_dir
- public_dir: ?[]const u8 = null,
+};
- /// only_scan_dependencies
- only_scan_dependencies: ?ScanDependencyMode = null,
+pub const Module = struct {
+/// path
+path: []const u8,
- /// generate_node_module_bundle
- generate_node_module_bundle: ?bool = null,
+/// imports
+imports: []const ModuleImportRecord,
- pub fn decode(reader: anytype) anyerror!TransformOptions {
- var this = std.mem.zeroes(TransformOptions);
- while (true) {
- switch (try reader.readByte()) {
- 0 => {
- return this;
- },
+pub fn decode(reader: anytype) anyerror!Module {
+ var this = std.mem.zeroes(Module);
- 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.public_url = try reader.readValue([]const u8);
- },
- 5 => {
- this.absolute_working_dir = try reader.readValue([]const u8);
- },
- 6 => {
- this.define_keys = try reader.readArray([]const u8);
- },
- 7 => {
- this.define_values = try reader.readArray([]const u8);
- },
- 8 => {
- this.preserve_symlinks = try reader.readValue(bool);
- },
- 9 => {
- this.entry_points = try reader.readArray([]const u8);
- },
- 10 => {
- this.write = try reader.readValue(bool);
- },
- 11 => {
- this.inject = try reader.readArray([]const u8);
- },
- 12 => {
- this.output_dir = try reader.readValue([]const u8);
- },
- 13 => {
- this.external = try reader.readArray([]const u8);
- },
- 14 => {
- this.loader_keys = try reader.readArray([]const u8);
- },
- 15 => {
- this.loader_values = try reader.readArray(Loader);
- },
- 16 => {
- this.main_fields = try reader.readArray([]const u8);
- },
- 17 => {
- this.platform = try reader.readValue(Platform);
- },
- 18 => {
- this.serve = try reader.readValue(bool);
- },
- 19 => {
- this.extension_order = try reader.readArray([]const u8);
- },
- 20 => {
- this.public_dir = try reader.readValue([]const u8);
- },
- 21 => {
- this.only_scan_dependencies = try reader.readValue(ScanDependencyMode);
- },
- 22 => {
- this.generate_node_module_bundle = try reader.readValue(bool);
- },
- else => {
- return error.InvalidMessage;
- },
- }
- }
- unreachable;
- }
+ 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 {
- 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.public_url) |public_url| {
- try writer.writeFieldID(4);
- try writer.writeValue(public_url);
- }
- if (this.absolute_working_dir) |absolute_working_dir| {
- try writer.writeFieldID(5);
- try writer.writeValue(absolute_working_dir);
- }
- if (this.define_keys) |define_keys| {
- try writer.writeFieldID(6);
- try writer.writeArray([]const u8, define_keys);
- }
- if (this.define_values) |define_values| {
- try writer.writeFieldID(7);
- try writer.writeArray([]const u8, define_values);
- }
- if (this.preserve_symlinks) |preserve_symlinks| {
- try writer.writeFieldID(8);
- try writer.writeInt(@intCast(u8, @boolToInt(preserve_symlinks)));
- }
- if (this.entry_points) |entry_points| {
- try writer.writeFieldID(9);
- try writer.writeArray([]const u8, entry_points);
- }
- if (this.write) |write| {
- try writer.writeFieldID(10);
- try writer.writeInt(@intCast(u8, @boolToInt(write)));
- }
- if (this.inject) |inject| {
- try writer.writeFieldID(11);
- try writer.writeArray([]const u8, inject);
- }
- if (this.output_dir) |output_dir| {
- try writer.writeFieldID(12);
- try writer.writeValue(output_dir);
- }
- if (this.external) |external| {
- try writer.writeFieldID(13);
- try writer.writeArray([]const u8, external);
- }
- if (this.loader_keys) |loader_keys| {
- try writer.writeFieldID(14);
- try writer.writeArray([]const u8, loader_keys);
- }
- if (this.loader_values) |loader_values| {
- try writer.writeFieldID(15);
- try writer.writeArray(Loader, loader_values);
- }
- if (this.main_fields) |main_fields| {
- try writer.writeFieldID(16);
- try writer.writeArray([]const u8, main_fields);
- }
- if (this.platform) |platform| {
- try writer.writeFieldID(17);
- try writer.writeEnum(platform);
- }
- if (this.serve) |serve| {
- try writer.writeFieldID(18);
- try writer.writeInt(@intCast(u8, @boolToInt(serve)));
- }
- if (this.extension_order) |extension_order| {
- try writer.writeFieldID(19);
- try writer.writeArray([]const u8, extension_order);
- }
- if (this.public_dir) |public_dir| {
- try writer.writeFieldID(20);
- try writer.writeValue(public_dir);
- }
- if (this.only_scan_dependencies) |only_scan_dependencies| {
- try writer.writeFieldID(21);
- try writer.writeEnum(only_scan_dependencies);
- }
- if (this.generate_node_module_bundle) |generate_node_module_bundle| {
- try writer.writeFieldID(22);
- try writer.writeInt(@intCast(u8, @boolToInt(generate_node_module_bundle)));
- }
- try writer.endMessage();
- }
- };
+pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.path);
+ try writer.writeArray(ModuleImportRecord, this.imports);
+}
- pub const FileHandle = struct {
- /// path
- path: []const u8,
+};
- /// size
- size: u32 = 0,
+pub const StringMap = struct {
+/// keys
+keys: []const []const u8,
- /// fd
- fd: u32 = 0,
+/// values
+values: []const []const u8,
- pub fn decode(reader: anytype) anyerror!FileHandle {
- var this = std.mem.zeroes(FileHandle);
- this.path = try reader.readValue([]const u8);
- this.size = try reader.readValue(u32);
- this.fd = try reader.readValue(u32);
- return this;
- }
+pub fn decode(reader: anytype) anyerror!StringMap {
+ var this = std.mem.zeroes(StringMap);
- 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);
- }
- };
+ this.keys = try reader.readArray([]const u8);
+ this.values = try reader.readArray([]const u8);
+ return this;
+}
- pub const Transform = struct {
- /// handle
- handle: ?FileHandle = null,
+pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray([]const u8, this.keys);
+ try writer.writeArray([]const u8, this.values);
+}
- /// path
- path: ?[]const u8 = null,
+};
- /// contents
- contents: []const u8,
+pub const LoaderMap = struct {
+/// extensions
+extensions: []const []const u8,
- /// loader
- loader: ?Loader = null,
+/// loaders
+loaders: []const Loader,
- /// options
- options: ?TransformOptions = null,
- pub fn decode(reader: anytype) anyerror!Transform {
- var this = std.mem.zeroes(Transform);
+pub fn decode(reader: anytype) anyerror!LoaderMap {
+ var this = std.mem.zeroes(LoaderMap);
- while (true) {
- switch (try reader.readByte()) {
- 0 => {
- return this;
- },
+ this.extensions = try reader.readArray([]const u8);
+ this.loaders = try reader.readArray(Loader);
+ 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;
- }
+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 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();
- }
- };
+};
+
+pub const TransformOptions = struct {
+/// jsx
+jsx: ?Jsx = null,
+
+/// tsconfig_override
+tsconfig_override: ?[]const u8 = null,
+
+/// resolve
+resolve: ?ResolveMode = null,
+
+/// public_url
+public_url: ?[]const u8 = null,
+
+/// absolute_working_dir
+absolute_working_dir: ?[]const u8 = null,
+
+/// 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,
+
+/// public_dir
+public_dir: ?[]const u8 = null,
+
+/// only_scan_dependencies
+only_scan_dependencies: ?ScanDependencyMode = null,
+
+/// generate_node_module_bundle
+generate_node_module_bundle: ?bool = null,
+
+/// node_modules_bundle_path
+node_modules_bundle_path: ?[]const u8 = 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.public_url = 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.public_dir = try reader.readValue([]const u8);
+},
+ 19 => {
+ this.only_scan_dependencies = try reader.readValue(ScanDependencyMode);
+},
+ 20 => {
+ this.generate_node_module_bundle = try reader.readValue(bool);
+},
+ 21 => {
+ this.node_modules_bundle_path = try reader.readValue([]const u8);
+},
+ 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(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.public_url) |public_url| {
+ try writer.writeFieldID(4);
+ try writer.writeValue(public_url);
+}
+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.public_dir) |public_dir| {
+ try writer.writeFieldID(18);
+ try writer.writeValue(public_dir);
+}
+if (this.only_scan_dependencies) |only_scan_dependencies| {
+ try writer.writeFieldID(19);
+ try writer.writeEnum(only_scan_dependencies);
+}
+if (this.generate_node_module_bundle) |generate_node_module_bundle| {
+ try writer.writeFieldID(20);
+ try writer.writeInt(@intCast(u8, @boolToInt(generate_node_module_bundle)));
+}
+if (this.node_modules_bundle_path) |node_modules_bundle_path| {
+ try writer.writeFieldID(21);
+ try writer.writeValue(node_modules_bundle_path);
+}
+try writer.endMessage();
+}
- pub const TransformResponseStatus = enum(u32) {
- _none,
- /// success
- success,
+};
- /// fail
- fail,
+pub const FileHandle = struct {
+/// path
+path: []const u8,
- _,
+/// size
+size: u32 = 0,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
- };
+/// fd
+fd: u32 = 0,
- pub const OutputFile = struct {
- /// data
- data: []const u8,
- /// path
- path: []const u8,
+pub fn decode(reader: anytype) anyerror!FileHandle {
+ var this = std.mem.zeroes(FileHandle);
- pub fn decode(reader: anytype) anyerror!OutputFile {
- var this = std.mem.zeroes(OutputFile);
+ this.path = try reader.readValue([]const u8);
+ this.size = try reader.readValue(u32);
+ this.fd = try reader.readValue(u32);
+ return this;
+}
- this.data = try reader.readArray(u8);
- this.path = try reader.readValue([]const u8);
- return this;
- }
+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);
+}
- pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeArray(u8, this.data);
- try writer.writeValue(this.path);
- }
- };
+};
- pub const TransformResponse = struct {
- /// status
- status: TransformResponseStatus,
+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;
+}
- /// files
- files: []OutputFile,
+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();
+}
- /// errors
- errors: []Message,
+};
- pub fn decode(reader: anytype) anyerror!TransformResponse {
- var this = std.mem.zeroes(TransformResponse);
+pub const TransformResponseStatus = enum(u32) {
- this.status = try reader.readValue(TransformResponseStatus);
- this.files = try reader.readArray(OutputFile);
- this.errors = try reader.readArray(Message);
- return this;
- }
+_none,
+ /// success
+ success,
- 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);
- }
- };
+ /// fail
+ fail,
- pub const MessageKind = enum(u32) {
- _none,
- /// err
- err,
+_,
- /// warn
- warn,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
- /// note
- note,
+
+};
- /// debug
- debug,
+pub const OutputFile = struct {
+/// data
+data: []const u8,
- _,
+/// path
+path: []const u8,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
- };
- pub const Location = struct {
- /// file
- file: []const u8,
+pub fn decode(reader: anytype) anyerror!OutputFile {
+ var this = std.mem.zeroes(OutputFile);
- /// namespace
- namespace: []const u8,
+ this.data = try reader.readArray(u8);
+ this.path = try reader.readValue([]const u8);
+ return this;
+}
- /// line
- line: i32 = 0,
+pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeArray(u8, this.data);
+ try writer.writeValue(this.path);
+}
- /// column
- column: i32 = 0,
+};
- /// line_text
- line_text: []const u8,
+pub const TransformResponse = struct {
+/// status
+status: TransformResponseStatus,
- /// suggestion
- suggestion: []const u8,
+/// files
+files: []const OutputFile,
- /// offset
- offset: u32 = 0,
+/// errors
+errors: []const Message,
- pub fn decode(reader: anytype) anyerror!Location {
- var this = std.mem.zeroes(Location);
- 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;
- }
+pub fn decode(reader: anytype) anyerror!TransformResponse {
+ var this = std.mem.zeroes(TransformResponse);
- 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);
- }
- };
+ this.status = try reader.readValue(TransformResponseStatus);
+ this.files = try reader.readArray(OutputFile);
+ this.errors = try reader.readArray(Message);
+ return this;
+}
- pub const MessageData = struct {
- /// text
- text: ?[]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);
+}
- /// location
- location: ?Location = null,
+};
- pub fn decode(reader: anytype) anyerror!MessageData {
- var this = std.mem.zeroes(MessageData);
+pub const MessageKind = enum(u32) {
- while (true) {
- switch (try reader.readByte()) {
- 0 => {
- return this;
- },
+_none,
+ /// err
+ err,
- 1 => {
- this.text = try reader.readValue([]const u8);
- },
- 2 => {
- this.location = try reader.readValue(Location);
- },
- else => {
- return error.InvalidMessage;
- },
+ /// warn
+ warn,
+
+ /// note
+ note,
+
+ /// debug
+ debug,
+
+_,
+
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
}
- }
- unreachable;
- }
- 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();
- }
- };
+
+};
- pub const Message = struct {
- /// kind
- kind: MessageKind,
+pub const Location = struct {
+/// file
+file: []const u8,
- /// data
- data: MessageData,
+/// namespace
+namespace: []const u8,
- /// notes
- notes: []MessageData,
+/// line
+line: i32 = 0,
- pub fn decode(reader: anytype) anyerror!Message {
- var this = std.mem.zeroes(Message);
+/// column
+column: i32 = 0,
- this.kind = try reader.readValue(MessageKind);
- this.data = try reader.readValue(MessageData);
- this.notes = try reader.readArray(MessageData);
- return this;
- }
+/// line_text
+line_text: []const u8,
- pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeEnum(this.kind);
- try writer.writeValue(this.data);
- try writer.writeArray(MessageData, this.notes);
- }
- };
+/// suggestion
+suggestion: []const u8,
- pub const Log = struct {
- /// warnings
- warnings: u32 = 0,
+/// offset
+offset: u32 = 0,
- /// errors
- errors: u32 = 0,
- /// msgs
- msgs: []Message,
+pub fn decode(reader: anytype) anyerror!Location {
+ var this = std.mem.zeroes(Location);
- pub fn decode(reader: anytype) anyerror!Log {
- var this = std.mem.zeroes(Log);
+ 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;
+}
- this.warnings = try reader.readValue(u32);
- this.errors = try reader.readValue(u32);
- this.msgs = try reader.readArray(Message);
- return this;
- }
+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);
+}
+
+};
+
+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;
+}
+
+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();
+}
- 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);
- }
- };
};
+pub const Message = struct {
+/// kind
+kind: MessageKind,
+
+/// data
+data: MessageData,
+
+/// notes
+notes: []const MessageData,
+
+
+pub fn decode(reader: anytype) anyerror!Message {
+ var this = std.mem.zeroes(Message);
+
+ this.kind = try reader.readValue(MessageKind);
+ this.data = try reader.readValue(MessageData);
+ this.notes = try reader.readArray(MessageData);
+ return this;
+}
+
+pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeEnum(this.kind);
+ try writer.writeValue(this.data);
+ try writer.writeArray(MessageData, this.notes);
+}
+
+};
+
+pub const Log = struct {
+/// warnings
+warnings: u32 = 0,
+
+/// errors
+errors: u32 = 0,
+
+/// msgs
+msgs: []const Message,
+
+
+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 encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.warnings);
+ try writer.writeInt(this.errors);
+ try writer.writeArray(Message, this.msgs);
+}
+
+};
+
+
+};
+
+
const ExamplePackedStruct = packed struct {
len: u32 = 0,
offset: u32 = 0,