aboutsummaryrefslogtreecommitdiff
path: root/src/api/schema.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/schema.zig')
-rw-r--r--src/api/schema.zig1833
1 files changed, 988 insertions, 845 deletions
diff --git a/src/api/schema.zig b/src/api/schema.zig
index 319bc9b6f..106815345 100644
--- a/src/api/schema.zig
+++ b/src/api/schema.zig
@@ -1,4 +1,3 @@
-
const std = @import("std");
pub const Reader = struct {
@@ -280,1057 +279,1201 @@ 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 {
+ /// tsx
+ tsx,
-pub const Loader = enum(u8) {
+ /// css
+ css,
-_none,
- /// jsx
- jsx,
+ /// file
+ file,
- /// js
- js,
+ /// json
+ json,
- /// ts
- ts,
+ _,
- /// tsx
- tsx,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
- /// css
- css,
+ pub const ResolveMode = enum(u8) {
+ _none,
+ /// disable
+ disable,
- /// file
- file,
+ /// lazy
+ lazy,
- /// json
- json,
+ /// dev
+ dev,
-_,
+ /// 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 ResolveMode = enum(u8) {
+ pub const Platform = enum(u8) {
+ _none,
+ /// browser
+ browser,
-_none,
- /// disable
- disable,
+ /// node
+ node,
- /// lazy
- lazy,
+ _,
- /// dev
- dev,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
- /// bundle
- bundle,
+ pub const JsxRuntime = enum(u8) {
+ _none,
+ /// automatic
+ automatic,
-_,
+ /// 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 Platform = enum(u8) {
+ pub const Jsx = struct {
+ /// factory
+ factory: []const u8,
-_none,
- /// browser
- browser,
+ /// runtime
+ runtime: JsxRuntime,
- /// node
- node,
+ /// fragment
+ fragment: []const u8,
-_,
+ /// development
+ development: bool = false,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ /// import_source
+ import_source: []const u8,
-
-};
+ /// react_fast_refresh
+ react_fast_refresh: bool = false,
-pub const JsxRuntime = enum(u8) {
+ pub fn decode(reader: anytype) anyerror!Jsx {
+ var this = std.mem.zeroes(Jsx);
-_none,
- /// automatic
- automatic,
+ 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;
+ }
- /// classic
- classic,
+ 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 const StringPointer = packed struct {
+ /// offset
+ offset: u32 = 0,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ /// length
+ length: u32 = 0,
-
-};
+ pub fn decode(reader: anytype) anyerror!StringPointer {
+ var this = std.mem.zeroes(StringPointer);
-pub const Jsx = struct {
-/// factory
-factory: []const u8,
+ this.offset = try reader.readValue(u32);
+ this.length = try reader.readValue(u32);
+ return this;
+ }
-/// runtime
-runtime: JsxRuntime,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.offset);
+ try writer.writeInt(this.length);
+ }
+ };
-/// fragment
-fragment: []const u8,
+ pub const JavascriptBundledModule = struct {
+ /// path
+ path: StringPointer,
-/// development
-development: bool = false,
+ /// code
+ code: StringPointer,
-/// import_source
-import_source: []const u8,
+ /// package_id
+ package_id: u32 = 0,
-/// react_fast_refresh
-react_fast_refresh: bool = false,
+ /// id
+ id: u32 = 0,
+ /// path_extname_length
+ path_extname_length: u8 = 0,
-pub fn decode(reader: anytype) anyerror!Jsx {
- var this = std.mem.zeroes(Jsx);
+ pub fn decode(reader: anytype) anyerror!JavascriptBundledModule {
+ var this = std.mem.zeroes(JavascriptBundledModule);
- 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;
-}
+ 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;
+ }
-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 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);
+ }
+ };
-};
+ pub const JavascriptBundledPackage = struct {
+ /// name
+ name: StringPointer,
-pub const StringPointer = packed struct {
-/// offset
-offset: u32 = 0,
+ /// version
+ version: StringPointer,
-/// length
-length: u32 = 0,
+ /// hash
+ hash: u32 = 0,
+ /// modules_offset
+ modules_offset: u32 = 0,
-pub fn decode(reader: anytype) anyerror!StringPointer {
- var this = std.mem.zeroes(StringPointer);
+ /// modules_length
+ modules_length: u32 = 0,
- this.offset = try reader.readValue(u32);
- this.length = try reader.readValue(u32);
- return this;
-}
+ pub fn decode(reader: anytype) anyerror!JavascriptBundledPackage {
+ var this = std.mem.zeroes(JavascriptBundledPackage);
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeInt(this.offset);
- try writer.writeInt(this.length);
-}
+ 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 const JavascriptBundledModule = struct {
-/// path
-path: StringPointer,
+ pub const JavascriptBundle = struct {
+ /// modules
+ modules: []const JavascriptBundledModule,
-/// code
-code: StringPointer,
+ /// packages
+ packages: []const JavascriptBundledPackage,
-/// package_id
-package_id: u32 = 0,
+ /// etag
+ etag: []const u8,
-/// id
-id: u32 = 0,
+ /// generated_at
+ generated_at: u32 = 0,
-/// path_extname_length
-path_extname_length: u8 = 0,
+ /// 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!JavascriptBundledModule {
- var this = std.mem.zeroes(JavascriptBundledModule);
+ /// manifest_string
+ manifest_string: []const u8,
- 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;
-}
+ 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.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);
-}
+ 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 JavascriptBundledPackage = struct {
-/// name
-name: StringPointer,
+ pub const JavascriptBundleContainer = struct {
+ /// bundle_format_version
+ bundle_format_version: ?u32 = null,
-/// version
-version: StringPointer,
+ /// bundle
+ bundle: ?JavascriptBundle = null,
-/// hash
-hash: u32 = 0,
+ /// code_length
+ code_length: ?u32 = null,
-/// modules_offset
-modules_offset: u32 = 0,
+ pub fn decode(reader: anytype) anyerror!JavascriptBundleContainer {
+ var this = std.mem.zeroes(JavascriptBundleContainer);
-/// modules_length
-modules_length: u32 = 0,
+ 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;
+ }
-pub fn decode(reader: anytype) anyerror!JavascriptBundledPackage {
- var this = std.mem.zeroes(JavascriptBundledPackage);
+ 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();
+ }
+ };
- 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 const ScanDependencyMode = enum(u8) {
+ _none,
+ /// app
+ app,
-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);
-}
+ /// all
+ all,
-};
+ _,
-pub const JavascriptBundle = struct {
-/// modules
-modules: []const JavascriptBundledModule,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-/// packages
-packages: []const JavascriptBundledPackage,
+ pub const ModuleImportType = enum(u8) {
+ _none,
+ /// import
+ import,
-/// etag
-etag: []const u8,
+ /// require
+ require,
-/// generated_at
-generated_at: u32 = 0,
+ _,
-/// app_package_json_dependencies_hash
-app_package_json_dependencies_hash: []const u8,
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
-/// import_from_name
-import_from_name: []const u8,
+ pub const ModuleImportRecord = struct {
+ /// kind
+ kind: ModuleImportType,
-/// manifest_string
-manifest_string: []const u8,
+ /// path
+ path: []const u8,
+ /// dynamic
+ dynamic: bool = false,
-pub fn decode(reader: anytype) anyerror!JavascriptBundle {
- var this = std.mem.zeroes(JavascriptBundle);
+ pub fn decode(reader: anytype) anyerror!ModuleImportRecord {
+ var this = std.mem.zeroes(ModuleImportRecord);
- 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.kind = try reader.readValue(ModuleImportType);
+ this.path = try reader.readValue([]const u8);
+ this.dynamic = try reader.readValue(bool);
+ 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.writeEnum(this.kind);
+ try writer.writeValue(this.path);
+ try writer.writeInt(@intCast(u8, @boolToInt(this.dynamic)));
+ }
+ };
-};
+ pub const Module = struct {
+ /// path
+ path: []const u8,
-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;
-}
+ /// imports
+ imports: []const ModuleImportRecord,
-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 decode(reader: anytype) anyerror!Module {
+ var this = std.mem.zeroes(Module);
-};
+ this.path = try reader.readValue([]const u8);
+ this.imports = try reader.readArray(ModuleImportRecord);
+ return this;
+ }
-pub const ScanDependencyMode = enum(u8) {
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeValue(this.path);
+ try writer.writeArray(ModuleImportRecord, this.imports);
+ }
+ };
-_none,
- /// app
- app,
+ pub const StringMap = struct {
+ /// keys
+ keys: []const []const u8,
- /// all
- all,
+ /// values
+ values: []const []const u8,
-_,
+ pub fn decode(reader: anytype) anyerror!StringMap {
+ var this = std.mem.zeroes(StringMap);
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
- }
+ 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 const LoaderMap = struct {
+ /// extensions
+ extensions: []const []const u8,
+
+ /// loaders
+ loaders: []const Loader,
+
+ pub fn decode(reader: anytype) anyerror!LoaderMap {
+ var this = std.mem.zeroes(LoaderMap);
+
+ 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 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,
-pub const ModuleImportType = enum(u8) {
+ /// inject
+ inject: []const []const u8,
-_none,
- /// import
- import,
+ /// output_dir
+ output_dir: ?[]const u8 = null,
- /// require
- require,
+ /// external
+ external: []const []const u8,
-_,
+ /// loaders
+ loaders: ?LoaderMap = null,
- pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
- return try std.json.stringify(@tagName(self), opts, o);
+ /// 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 ModuleImportRecord = struct {
-/// kind
-kind: ModuleImportType,
+ pub const FileHandle = struct {
+ /// path
+ path: []const u8,
-/// path
-path: []const u8,
+ /// size
+ size: u32 = 0,
-/// dynamic
-dynamic: bool = false,
+ /// fd
+ fd: u32 = 0,
+ pub fn decode(reader: anytype) anyerror!FileHandle {
+ var this = std.mem.zeroes(FileHandle);
-pub fn decode(reader: anytype) anyerror!ModuleImportRecord {
- var this = std.mem.zeroes(ModuleImportRecord);
+ this.path = try reader.readValue([]const u8);
+ this.size = try reader.readValue(u32);
+ this.fd = try reader.readValue(u32);
+ return this;
+ }
- this.kind = try reader.readValue(ModuleImportType);
- this.path = try reader.readValue([]const u8);
- this.dynamic = try reader.readValue(bool);
- 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.writeEnum(this.kind);
- try writer.writeValue(this.path);
- try writer.writeInt(@intCast(u8, @boolToInt(this.dynamic)));
-}
+ pub const Transform = struct {
+ /// handle
+ handle: ?FileHandle = null,
-};
+ /// path
+ path: ?[]const u8 = null,
-pub const Module = struct {
-/// path
-path: []const u8,
+ /// contents
+ contents: []const u8,
-/// imports
-imports: []const ModuleImportRecord,
+ /// loader
+ loader: ?Loader = null,
+ /// options
+ options: ?TransformOptions = null,
-pub fn decode(reader: anytype) anyerror!Module {
- var this = std.mem.zeroes(Module);
+ pub fn decode(reader: anytype) anyerror!Transform {
+ var this = std.mem.zeroes(Transform);
- this.path = try reader.readValue([]const u8);
- this.imports = try reader.readArray(ModuleImportRecord);
- return this;
-}
+ while (true) {
+ switch (try reader.readByte()) {
+ 0 => {
+ return this;
+ },
-pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
- try writer.writeValue(this.path);
- try writer.writeArray(ModuleImportRecord, this.imports);
-}
+ 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(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 StringMap = struct {
-/// keys
-keys: []const []const u8,
+ pub const TransformResponseStatus = enum(u32) {
+ _none,
+ /// success
+ success,
-/// values
-values: []const []const u8,
+ /// fail
+ fail,
+ _,
-pub fn decode(reader: anytype) anyerror!StringMap {
- var this = std.mem.zeroes(StringMap);
+ pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
+ return try std.json.stringify(@tagName(self), opts, o);
+ }
+ };
- this.keys = try reader.readArray([]const u8);
- this.values = try reader.readArray([]const u8);
- return this;
-}
+ pub const OutputFile = struct {
+ /// data
+ data: []const u8,
-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,
-};
+ pub fn decode(reader: anytype) anyerror!OutputFile {
+ var this = std.mem.zeroes(OutputFile);
-pub const LoaderMap = struct {
-/// extensions
-extensions: []const []const u8,
+ this.data = try reader.readArray(u8);
+ this.path = try reader.readValue([]const u8);
+ return this;
+ }
-/// loaders
-loaders: []const Loader,
+ 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 fn decode(reader: anytype) anyerror!LoaderMap {
- var this = std.mem.zeroes(LoaderMap);
+ /// files
+ files: []const OutputFile,
- this.extensions = try reader.readArray([]const u8);
- this.loaders = try reader.readArray(Loader);
- return this;
-}
+ /// errors
+ errors: []const Message,
-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!TransformResponse {
+ var this = std.mem.zeroes(TransformResponse);
-};
+ this.status = try reader.readValue(TransformResponseStatus);
+ this.files = try reader.readArray(OutputFile);
+ this.errors = try reader.readArray(Message);
+ return this;
+ }
-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 {
+ try writer.writeEnum(this.status);
+ try writer.writeArray(OutputFile, this.files);
+ try writer.writeArray(Message, this.errors);
+ }
+ };
-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 MessageKind = enum(u32) {
+ _none,
+ /// err
+ err,
-};
+ /// warn
+ warn,
-pub const FileHandle = struct {
-/// path
-path: []const u8,
+ /// note
+ note,
-/// size
-size: u32 = 0,
+ /// debug
+ debug,
-/// fd
-fd: 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!FileHandle {
- var this = std.mem.zeroes(FileHandle);
+ pub const Location = struct {
+ /// file
+ file: []const u8,
- this.path = try reader.readValue([]const u8);
- this.size = try reader.readValue(u32);
- this.fd = try reader.readValue(u32);
- return this;
-}
+ /// namespace
+ namespace: []const u8,
-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);
-}
+ /// line
+ line: i32 = 0,
-};
+ /// column
+ column: i32 = 0,
-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;
-}
+ /// line_text
+ line_text: []const u8,
-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();
-}
+ /// suggestion
+ suggestion: []const u8,
-};
+ /// offset
+ offset: u32 = 0,
+
+ 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 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 TransformResponseStatus = enum(u32) {
+ pub const MessageData = struct {
+ /// text
+ text: ?[]const u8 = null,
-_none,
- /// success
- success,
+ /// location
+ location: ?Location = null,
- /// fail
- 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(text);
+ }
+ if (this.location) |location| {
+ try writer.writeFieldID(2);
+ try writer.writeValue(location);
+ }
+ try writer.endMessage();
+ }
+ };
-pub const OutputFile = struct {
-/// data
-data: []const u8,
+ pub const Message = struct {
+ /// kind
+ kind: MessageKind,
-/// path
-path: []const u8,
+ /// data
+ data: MessageData,
+ /// notes
+ notes: []const MessageData,
-pub fn decode(reader: anytype) anyerror!OutputFile {
- var this = std.mem.zeroes(OutputFile);
+ pub fn decode(reader: anytype) anyerror!Message {
+ var this = std.mem.zeroes(Message);
- this.data = try reader.readArray(u8);
- this.path = try reader.readValue([]const u8);
- return this;
-}
+ 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.writeArray(u8, this.data);
- try writer.writeValue(this.path);
-}
+ 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,
-pub const TransformResponse = struct {
-/// status
-status: TransformResponseStatus,
+ /// errors
+ errors: u32 = 0,
-/// files
-files: []const OutputFile,
+ /// msgs
+ msgs: []const Message,
-/// errors
-errors: []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 decode(reader: anytype) anyerror!TransformResponse {
- var this = std.mem.zeroes(TransformResponse);
+ 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.status = try reader.readValue(TransformResponseStatus);
- this.files = try reader.readArray(OutputFile);
- this.errors = try reader.readArray(Message);
- return this;
-}
+ pub const WebsocketMessageKind = enum(u8) {
+ _none,
+ /// welcome
+ welcome,
-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);
-}
+ /// file_change_notification
+ file_change_notification,
-};
+ /// build_success
+ build_success,
-pub const MessageKind = enum(u32) {
+ /// build_fail
+ build_fail,
-_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,
+ pub const WebsocketCommandKind = enum(u8) {
+ _none,
+ /// build
+ build,
- /// debug
- debug,
+ _,
-_,
+ 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 WebsocketMessage = struct {
+ /// timestamp
+ timestamp: u32 = 0,
-
-};
+ /// kind
+ kind: WebsocketMessageKind,
-pub const Location = struct {
-/// file
-file: []const u8,
+ pub fn decode(reader: anytype) anyerror!WebsocketMessage {
+ var this = std.mem.zeroes(WebsocketMessage);
-/// namespace
-namespace: []const u8,
+ this.timestamp = try reader.readValue(u32);
+ this.kind = try reader.readValue(WebsocketMessageKind);
+ return this;
+ }
-/// line
-line: i32 = 0,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.timestamp);
+ try writer.writeEnum(this.kind);
+ }
+ };
-/// column
-column: i32 = 0,
+ pub const WebsocketMessageWelcome = packed struct {
+ /// epoch
+ epoch: u32 = 0,
-/// line_text
-line_text: []const u8,
+ pub fn decode(reader: anytype) anyerror!WebsocketMessageWelcome {
+ var this = std.mem.zeroes(WebsocketMessageWelcome);
-/// suggestion
-suggestion: []const u8,
+ this.epoch = try reader.readValue(u32);
+ return this;
+ }
-/// offset
-offset: u32 = 0,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.epoch);
+ }
+ };
+ pub const WebsocketMessageFileChangeNotification = struct {
+ /// id
+ id: u32 = 0,
-pub fn decode(reader: anytype) anyerror!Location {
- var this = std.mem.zeroes(Location);
+ /// loader
+ loader: Loader,
- 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!WebsocketMessageFileChangeNotification {
+ var this = std.mem.zeroes(WebsocketMessageFileChangeNotification);
-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.id = try reader.readValue(u32);
+ this.loader = try reader.readValue(Loader);
+ return this;
+ }
-};
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.id);
+ try writer.writeEnum(this.loader);
+ }
+ };
-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 const WebsocketCommand = struct {
+ /// kind
+ kind: WebsocketCommandKind,
-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();
-}
+ /// timestamp
+ timestamp: u32 = 0,
-};
+ pub fn decode(reader: anytype) anyerror!WebsocketCommand {
+ var this = std.mem.zeroes(WebsocketCommand);
-pub const Message = struct {
-/// kind
-kind: MessageKind,
+ this.kind = try reader.readValue(WebsocketCommandKind);
+ this.timestamp = try reader.readValue(u32);
+ return this;
+ }
-/// data
-data: MessageData,
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeEnum(this.kind);
+ try writer.writeInt(this.timestamp);
+ }
+ };
-/// notes
-notes: []const MessageData,
+ pub const WebsocketCommandBuild = packed struct {
+ /// id
+ id: u32 = 0,
+ pub fn decode(reader: anytype) anyerror!WebsocketCommandBuild {
+ var this = std.mem.zeroes(WebsocketCommandBuild);
-pub fn decode(reader: anytype) anyerror!Message {
- var this = std.mem.zeroes(Message);
+ this.id = try reader.readValue(u32);
+ return this;
+ }
- 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.writeInt(this.id);
+ }
+ };
-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 WebsocketMessageBuildSuccess = struct {
+ /// id
+ id: u32 = 0,
-};
+ /// from_timestamp
+ from_timestamp: u32 = 0,
-pub const Log = struct {
-/// warnings
-warnings: u32 = 0,
+ /// loader
+ loader: Loader,
-/// errors
-errors: u32 = 0,
+ /// module_path
+ module_path: []const u8,
-/// msgs
-msgs: []const Message,
+ /// log
+ log: Log,
+ /// bytes
+ bytes: []const u8,
-pub fn decode(reader: anytype) anyerror!Log {
- var this = std.mem.zeroes(Log);
+ pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildSuccess {
+ var this = std.mem.zeroes(WebsocketMessageBuildSuccess);
- this.warnings = try reader.readValue(u32);
- this.errors = try reader.readValue(u32);
- this.msgs = try reader.readArray(Message);
- return this;
-}
+ 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);
+ this.bytes = try reader.readArray(u8);
+ 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);
-}
+ 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);
+ try writer.writeArray(u8, this.bytes);
+ }
+ };
-};
+ pub const WebsocketMessageBuildFailure = struct {
+ /// id
+ id: u32 = 0,
+ /// from_timestamp
+ from_timestamp: u32 = 0,
-};
+ /// loader
+ loader: Loader,
+
+ /// module_path
+ module_path: []const u8,
+
+ /// log
+ log: Log,
+ 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 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);
+ }
+ };
+};
const ExamplePackedStruct = packed struct {
len: u32 = 0,