aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-05-17 18:51:50 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-05-17 18:51:50 -0700
commit25447426f19702a0fff808b3d426d66f4d8e558d (patch)
treeaa98cd928a6ee0db015b98bee9041cbf4575167d
parent67f543daa79c142cf6ea1451fa0c5d691b468c40 (diff)
downloadbun-25447426f19702a0fff808b3d426d66f4d8e558d.tar.gz
bun-25447426f19702a0fff808b3d426d66f4d8e558d.tar.zst
bun-25447426f19702a0fff808b3d426d66f4d8e558d.zip
Make `BuildError` and `ResolveError` use C++ instead of JSC C API
Fixes memory leak with private data never being cleared Fixes a case where a ResolveError could actually be a BuildError
-rw-r--r--src/bun.js/BuildMessage.zig171
-rw-r--r--src/bun.js/ResolveMessage.zig174
-rw-r--r--src/bun.js/api/JSTranspiler.zig4
-rw-r--r--src/bun.js/base.zig4
-rw-r--r--src/bun.js/bindings/JSSink.cpp2
-rw-r--r--src/bun.js/bindings/JSSink.h2
-rw-r--r--src/bun.js/bindings/JSSinkLookupTable.h2
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h6
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h6
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h12
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h14
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.cpp1000
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.h119
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp21
-rw-r--r--src/bun.js/bindings/exports.zig23
-rw-r--r--src/bun.js/bindings/generated_classes.zig390
-rw-r--r--src/bun.js/bindings/generated_classes_list.zig2
-rw-r--r--src/bun.js/javascript.zig483
-rw-r--r--src/bun.js/resolve_message.classes.ts94
-rw-r--r--src/bun.js/test/pretty_format.zig23
-rw-r--r--src/js_ast.zig7
-rw-r--r--src/jsc.zig2
-rw-r--r--src/logger.zig21
23 files changed, 2067 insertions, 515 deletions
diff --git a/src/bun.js/BuildMessage.zig b/src/bun.js/BuildMessage.zig
new file mode 100644
index 000000000..74bcce2ba
--- /dev/null
+++ b/src/bun.js/BuildMessage.zig
@@ -0,0 +1,171 @@
+const bun = @import("root").bun;
+const logger = bun.logger;
+const std = @import("std");
+const Fs = bun.fs;
+const string = bun.string;
+const Resolver = @import("../resolver//resolver.zig").Resolver;
+const JSC = bun.JSC;
+const JSGlobalObject = JSC.JSGlobalObject;
+const strings = bun.strings;
+const default_allocator = bun.default_allocator;
+const ZigString = JSC.ZigString;
+const JSValue = JSC.JSValue;
+
+pub const BuildMessage = struct {
+ msg: logger.Msg,
+ // resolve_result: Resolver.Result,
+ allocator: std.mem.Allocator,
+ logged: bool = false,
+
+ pub usingnamespace JSC.Codegen.JSBuildMessage;
+
+ pub fn constructor(
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.CallFrame,
+ ) callconv(.C) ?*BuildMessage {
+ globalThis.throw("BuildMessage is not constructable", .{});
+ return null;
+ }
+
+ pub fn toStringFn(this: *BuildMessage, globalThis: *JSC.JSGlobalObject) JSC.JSValue {
+ var text = std.fmt.allocPrint(default_allocator, "BuildMessage: {s}", .{this.msg.data.text}) catch {
+ globalThis.throwOutOfMemory();
+ return .zero;
+ };
+ var str = ZigString.init(text);
+ str.setOutputEncoding();
+ if (str.isUTF8()) {
+ const out = str.toValueGC(globalThis);
+ default_allocator.free(text);
+ return out;
+ }
+
+ return str.toExternalValue(globalThis);
+ }
+
+ pub fn create(
+ globalThis: *JSC.JSGlobalObject,
+ allocator: std.mem.Allocator,
+ msg: logger.Msg,
+ // resolve_result: *const Resolver.Result,
+ ) JSC.JSValue {
+ var build_error = allocator.create(BuildMessage) catch unreachable;
+ build_error.* = BuildMessage{
+ .msg = msg.clone(allocator) catch unreachable,
+ // .resolve_result = resolve_result.*,
+ .allocator = allocator,
+ };
+
+ return build_error.toJS(globalThis);
+ }
+
+ pub fn toString(
+ this: *BuildMessage,
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ return this.toStringFn(globalThis);
+ }
+
+ pub fn toPrimitive(
+ this: *BuildMessage,
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const args_ = callframe.arguments(1);
+ const args = args_.ptr[0..args_.len];
+ if (args.len > 0) {
+ if (!args[0].isString()) {
+ return JSC.JSValue.jsNull();
+ }
+
+ const str = args[0].getZigString(globalThis);
+ if (str.eqlComptime("default") or str.eqlComptime("string")) {
+ return this.toStringFn(globalThis);
+ }
+ }
+
+ return JSC.JSValue.jsNull();
+ }
+
+ pub fn toJSON(
+ this: *BuildMessage,
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ var object = JSC.JSValue.createEmptyObject(globalThis, 4);
+ object.put(globalThis, ZigString.static("name"), ZigString.init("BuildMessage").toValueGC(globalThis));
+ object.put(globalThis, ZigString.static("position"), this.getPosition(globalThis));
+ object.put(globalThis, ZigString.static("message"), this.getMessage(globalThis));
+ object.put(globalThis, ZigString.static("level"), this.getLevel(globalThis));
+ return object;
+ }
+
+ pub fn generatePositionObject(msg: logger.Msg, globalThis: *JSC.JSGlobalObject) JSC.JSValue {
+ const location = msg.data.location orelse return JSC.JSValue.jsNull();
+ var object = JSC.JSValue.createEmptyObject(globalThis, 7);
+
+ object.put(
+ globalThis,
+ ZigString.static("lineText"),
+ ZigString.init(location.line_text orelse "").toValueGC(globalThis),
+ );
+ object.put(
+ globalThis,
+ ZigString.static("file"),
+ ZigString.init(location.file).toValueGC(globalThis),
+ );
+ object.put(
+ globalThis,
+ ZigString.static("namespace"),
+ ZigString.init(location.namespace).toValueGC(globalThis),
+ );
+ object.put(
+ globalThis,
+ ZigString.static("line"),
+ JSValue.jsNumber(location.line),
+ );
+ object.put(
+ globalThis,
+ ZigString.static("column"),
+ JSValue.jsNumber(location.column),
+ );
+ object.put(
+ globalThis,
+ ZigString.static("length"),
+ JSValue.jsNumber(location.length),
+ );
+ object.put(
+ globalThis,
+ ZigString.static("offset"),
+ JSValue.jsNumber(location.offset),
+ );
+
+ return object;
+ }
+
+ pub fn getPosition(
+ this: *BuildMessage,
+ globalThis: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
+ return BuildMessage.generatePositionObject(this.msg, globalThis);
+ }
+
+ pub fn getMessage(
+ this: *BuildMessage,
+ globalThis: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
+ return ZigString.init(this.msg.data.text).toValueGC(globalThis);
+ }
+
+ pub fn getLevel(
+ this: *BuildMessage,
+ globalThis: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
+ return ZigString.init(this.msg.kind.string()).toValueGC(globalThis);
+ }
+
+ pub fn finalize(this: *BuildMessage) callconv(.C) void {
+ this.msg.deinit(bun.default_allocator);
+ }
+};
diff --git a/src/bun.js/ResolveMessage.zig b/src/bun.js/ResolveMessage.zig
new file mode 100644
index 000000000..b9b2d7b06
--- /dev/null
+++ b/src/bun.js/ResolveMessage.zig
@@ -0,0 +1,174 @@
+const bun = @import("root").bun;
+const logger = bun.logger;
+const std = @import("std");
+const Fs = bun.fs;
+const string = bun.string;
+const Resolver = @import("../resolver//resolver.zig");
+const JSC = bun.JSC;
+const JSGlobalObject = JSC.JSGlobalObject;
+const strings = bun.strings;
+const default_allocator = bun.default_allocator;
+const ZigString = JSC.ZigString;
+
+pub const ResolveMessage = struct {
+ msg: logger.Msg,
+ allocator: std.mem.Allocator,
+ referrer: ?Fs.Path = null,
+ logged: bool = false,
+
+ pub usingnamespace JSC.Codegen.JSResolveMessage;
+
+ pub fn constructor(
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.CallFrame,
+ ) callconv(.C) ?*ResolveMessage {
+ globalThis.throw("ResolveMessage is not constructable", .{});
+ return null;
+ }
+
+ pub fn fmt(allocator: std.mem.Allocator, specifier: string, referrer: string, err: anyerror) !string {
+ switch (err) {
+ error.ModuleNotFound => {
+ if (Resolver.isPackagePath(specifier) and !strings.containsChar(specifier, '/')) {
+ return try std.fmt.allocPrint(allocator, "Cannot find package \"{s}\" from \"{s}\"", .{ specifier, referrer });
+ } else {
+ return try std.fmt.allocPrint(allocator, "Cannot find module \"{s}\" from \"{s}\"", .{ specifier, referrer });
+ }
+ },
+ else => {
+ if (Resolver.isPackagePath(specifier)) {
+ return try std.fmt.allocPrint(allocator, "{s} while resolving package \"{s}\" from \"{s}\"", .{ @errorName(err), specifier, referrer });
+ } else {
+ return try std.fmt.allocPrint(allocator, "{s} while resolving \"{s}\" from \"{s}\"", .{ @errorName(err), specifier, referrer });
+ }
+ },
+ }
+ }
+
+ pub fn toStringFn(this: *ResolveMessage, globalThis: *JSC.JSGlobalObject) JSC.JSValue {
+ var text = std.fmt.allocPrint(default_allocator, "ResolveMessage: {s}", .{this.msg.data.text}) catch {
+ globalThis.throwOutOfMemory();
+ return .zero;
+ };
+ var str = ZigString.init(text);
+ str.setOutputEncoding();
+ if (str.isUTF8()) {
+ const out = str.toValueGC(globalThis);
+ default_allocator.free(text);
+ return out;
+ }
+
+ return str.toExternalValue(globalThis);
+ }
+
+ pub fn toString(
+ // this
+ this: *ResolveMessage,
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ return this.toStringFn(globalThis);
+ }
+
+ pub fn toPrimitive(
+ this: *ResolveMessage,
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ const args_ = callframe.arguments(1);
+ const args = args_.ptr[0..args_.len];
+ if (args.len > 0) {
+ if (!args[0].isString()) {
+ return JSC.JSValue.jsNull();
+ }
+
+ const str = args[0].getZigString(globalThis);
+ if (str.eqlComptime("default") or str.eqlComptime("string")) {
+ return this.toStringFn(globalThis);
+ }
+ }
+
+ return JSC.JSValue.jsNull();
+ }
+
+ pub fn toJSON(
+ this: *ResolveMessage,
+ globalThis: *JSC.JSGlobalObject,
+ _: *JSC.CallFrame,
+ ) callconv(.C) JSC.JSValue {
+ var object = JSC.JSValue.createEmptyObject(globalThis, 7);
+ object.put(globalThis, ZigString.static("name"), ZigString.init("ResolveMessage").toValueGC(globalThis));
+ object.put(globalThis, ZigString.static("position"), this.getPosition(globalThis));
+ object.put(globalThis, ZigString.static("message"), this.getMessage(globalThis));
+ object.put(globalThis, ZigString.static("level"), this.getLevel(globalThis));
+ object.put(globalThis, ZigString.static("specifier"), this.getSpecifier(globalThis));
+ object.put(globalThis, ZigString.static("importKind"), this.getImportKind(globalThis));
+ object.put(globalThis, ZigString.static("referrer"), this.getReferrer(globalThis));
+ return object;
+ }
+
+ pub fn create(
+ globalThis: *JSGlobalObject,
+ allocator: std.mem.Allocator,
+ msg: logger.Msg,
+ referrer: string,
+ ) JSC.JSValue {
+ var resolve_error = allocator.create(ResolveMessage) catch unreachable;
+ resolve_error.* = ResolveMessage{
+ .msg = msg.clone(allocator) catch unreachable,
+ .allocator = allocator,
+ .referrer = Fs.Path.init(referrer),
+ };
+ return resolve_error.toJS(globalThis);
+ }
+
+ pub fn getPosition(
+ this: *ResolveMessage,
+ globalThis: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
+ return JSC.BuildMessage.generatePositionObject(this.msg, globalThis);
+ }
+
+ pub fn getMessage(
+ this: *ResolveMessage,
+ globalThis: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
+ return ZigString.init(this.msg.data.text).toValueGC(globalThis);
+ }
+
+ pub fn getLevel(
+ this: *ResolveMessage,
+ globalThis: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
+ return ZigString.init(this.msg.kind.string()).toValueGC(globalThis);
+ }
+
+ pub fn getSpecifier(
+ this: *ResolveMessage,
+ globalThis: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
+ return ZigString.init(this.msg.metadata.resolve.specifier.slice(this.msg.data.text)).toValueGC(globalThis);
+ }
+
+ pub fn getImportKind(
+ this: *ResolveMessage,
+ globalThis: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
+ return ZigString.init(this.msg.metadata.resolve.import_kind.label()).toValueGC(globalThis);
+ }
+
+ pub fn getReferrer(
+ this: *ResolveMessage,
+ globalThis: *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue {
+ if (this.referrer) |referrer| {
+ return ZigString.init(referrer.text).toValueGC(globalThis);
+ } else {
+ return JSC.JSValue.jsNull();
+ }
+ }
+
+ pub fn finalize(this: *ResolveMessage) callconv(.C) void {
+ this.msg.deinit(bun.default_allocator);
+ }
+};
diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig
index a6d23dbd0..fecce60cd 100644
--- a/src/bun.js/api/JSTranspiler.zig
+++ b/src/bun.js/api/JSTranspiler.zig
@@ -200,13 +200,13 @@ pub const TransformTask = struct {
const error_value: JSValue = brk: {
if (this.err) |err| {
if (!this.log.hasAny()) {
- break :brk JSC.JSValue.fromRef(JSC.BuildMessage.create(
+ break :brk JSC.BuildMessage.create(
this.global,
bun.default_allocator,
logger.Msg{
.data = logger.Data{ .text = bun.asByteSlice(@errorName(err)) },
},
- ));
+ );
}
}
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig
index aab880453..c2196f246 100644
--- a/src/bun.js/base.zig
+++ b/src/bun.js/base.zig
@@ -11,8 +11,6 @@ const stringZ = bun.stringZ;
const default_allocator = bun.default_allocator;
const C = bun.C;
const JavaScript = @import("./javascript.zig");
-const ResolveMessage = JavaScript.ResolveMessage;
-const BuildMessage = JavaScript.BuildMessage;
const JSC = @import("root").bun.JSC;
const WebCore = @import("./webcore.zig");
const Test = @import("./test/jest.zig");
@@ -2200,7 +2198,6 @@ const MD5_SHA1 = JSC.API.Bun.Crypto.MD5_SHA1;
const FFI = JSC.FFI;
pub const JSPrivateDataPtr = TaggedPointerUnion(.{
AttributeIterator,
- BuildMessage,
Comment,
DebugServer,
DebugSSLServer,
@@ -2215,7 +2212,6 @@ pub const JSPrivateDataPtr = TaggedPointerUnion(.{
LazyPropertiesObject,
ModuleNamespace,
- ResolveMessage,
Router,
Server,
diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp
index 2fb03963e..84f69aa31 100644
--- a/src/bun.js/bindings/JSSink.cpp
+++ b/src/bun.js/bindings/JSSink.cpp
@@ -1,6 +1,6 @@
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at 2023-05-14T13:28:43.914Z
+// Generated by 'make generate-sink' at 2023-05-18T01:04:00.447Z
// To regenerate this file, run:
//
// make generate-sink
diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h
index 9726f68e9..5bbfab777 100644
--- a/src/bun.js/bindings/JSSink.h
+++ b/src/bun.js/bindings/JSSink.h
@@ -1,6 +1,6 @@
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at 2023-05-14T13:28:43.910Z
+// Generated by 'make generate-sink' at 2023-05-18T01:04:00.446Z
//
#pragma once
diff --git a/src/bun.js/bindings/JSSinkLookupTable.h b/src/bun.js/bindings/JSSinkLookupTable.h
index e4ed81629..a4ace6dc3 100644
--- a/src/bun.js/bindings/JSSinkLookupTable.h
+++ b/src/bun.js/bindings/JSSinkLookupTable.h
@@ -1,4 +1,4 @@
-// Automatically generated from src/bun.js/bindings/JSSink.cpp using /home/cirospaciari/Repos/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT!
+// Automatically generated from src/bun.js/bindings/JSSink.cpp using /Users/jarred/Code/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT!
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
index 120a135f8..f59e0e855 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
@@ -1,6 +1,7 @@
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlob;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlobConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildArtifact;
-std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasher;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildMessage;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildMessageConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasher;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasherConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirent;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirentConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpect;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectAny;
@@ -11,7 +12,8 @@ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD4Constructor;std::un
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD5Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMatchedRoute;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNodeJSFS;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNodeJSFSConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequest;
-std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequestConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponse;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequestConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResolveMessage;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResolveMessageConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponse;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponseConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA1;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA1Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA224;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA224Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA256;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
index d298b8db4..3e80b933b 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
@@ -1,6 +1,7 @@
std::unique_ptr<IsoSubspace> m_subspaceForBlob;
std::unique_ptr<IsoSubspace> m_subspaceForBlobConstructor;std::unique_ptr<IsoSubspace> m_subspaceForBuildArtifact;
-std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasher;
+std::unique_ptr<IsoSubspace> m_subspaceForBuildMessage;
+std::unique_ptr<IsoSubspace> m_subspaceForBuildMessageConstructor;std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasher;
std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasherConstructor;std::unique_ptr<IsoSubspace> m_subspaceForDirent;
std::unique_ptr<IsoSubspace> m_subspaceForDirentConstructor;std::unique_ptr<IsoSubspace> m_subspaceForExpect;
std::unique_ptr<IsoSubspace> m_subspaceForExpectConstructor;std::unique_ptr<IsoSubspace> m_subspaceForExpectAny;
@@ -11,7 +12,8 @@ std::unique_ptr<IsoSubspace> m_subspaceForMD4Constructor;std::unique_ptr<IsoSubs
std::unique_ptr<IsoSubspace> m_subspaceForMD5Constructor;std::unique_ptr<IsoSubspace> m_subspaceForMatchedRoute;
std::unique_ptr<IsoSubspace> m_subspaceForNodeJSFS;
std::unique_ptr<IsoSubspace> m_subspaceForNodeJSFSConstructor;std::unique_ptr<IsoSubspace> m_subspaceForRequest;
-std::unique_ptr<IsoSubspace> m_subspaceForRequestConstructor;std::unique_ptr<IsoSubspace> m_subspaceForResponse;
+std::unique_ptr<IsoSubspace> m_subspaceForRequestConstructor;std::unique_ptr<IsoSubspace> m_subspaceForResolveMessage;
+std::unique_ptr<IsoSubspace> m_subspaceForResolveMessageConstructor;std::unique_ptr<IsoSubspace> m_subspaceForResponse;
std::unique_ptr<IsoSubspace> m_subspaceForResponseConstructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA1;
std::unique_ptr<IsoSubspace> m_subspaceForSHA1Constructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA224;
std::unique_ptr<IsoSubspace> m_subspaceForSHA224Constructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA256;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
index 2b01818b9..95a787f5e 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
@@ -10,6 +10,12 @@ JSC::Structure* JSBuildArtifactStructure() { return m_JSBuildArtifact.getInitial
JSC::LazyClassStructure m_JSBuildArtifact;
bool hasJSBuildArtifactSetterValue { false };
mutable JSC::WriteBarrier<JSC::Unknown> m_JSBuildArtifactSetterValue;
+JSC::Structure* JSBuildMessageStructure() { return m_JSBuildMessage.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSBuildMessageConstructor() { return m_JSBuildMessage.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSBuildMessagePrototype() { return m_JSBuildMessage.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSBuildMessage;
+ bool hasJSBuildMessageSetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSBuildMessageSetterValue;
JSC::Structure* JSCryptoHasherStructure() { return m_JSCryptoHasher.getInitializedOnMainThread(this); }
JSC::JSObject* JSCryptoHasherConstructor() { return m_JSCryptoHasher.constructorInitializedOnMainThread(this); }
JSC::JSValue JSCryptoHasherPrototype() { return m_JSCryptoHasher.prototypeInitializedOnMainThread(this); }
@@ -76,6 +82,12 @@ JSC::Structure* JSRequestStructure() { return m_JSRequest.getInitializedOnMainTh
JSC::LazyClassStructure m_JSRequest;
bool hasJSRequestSetterValue { false };
mutable JSC::WriteBarrier<JSC::Unknown> m_JSRequestSetterValue;
+JSC::Structure* JSResolveMessageStructure() { return m_JSResolveMessage.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSResolveMessageConstructor() { return m_JSResolveMessage.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSResolveMessagePrototype() { return m_JSResolveMessage.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSResolveMessage;
+ bool hasJSResolveMessageSetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSResolveMessageSetterValue;
JSC::Structure* JSResponseStructure() { return m_JSResponse.getInitializedOnMainThread(this); }
JSC::JSObject* JSResponseConstructor() { return m_JSResponse.constructorInitializedOnMainThread(this); }
JSC::JSValue JSResponsePrototype() { return m_JSResponse.prototypeInitializedOnMainThread(this); }
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
index dc2cbb2cd..8756ed660 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
@@ -11,6 +11,12 @@ void GlobalObject::initGeneratedLazyClasses() {
init.setStructure(WebCore::JSBuildArtifact::createStructure(init.vm, init.global, init.prototype));
});
+ m_JSBuildMessage.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSBuildMessage::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSBuildMessage::createStructure(init.vm, init.global, init.prototype));
+ init.setConstructor(WebCore::JSBuildMessage::createConstructor(init.vm, init.global, init.prototype));
+ });
m_JSCryptoHasher.initLater(
[](LazyClassStructure::Initializer& init) {
init.setPrototype(WebCore::JSCryptoHasher::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
@@ -77,6 +83,12 @@ void GlobalObject::initGeneratedLazyClasses() {
init.setStructure(WebCore::JSRequest::createStructure(init.vm, init.global, init.prototype));
init.setConstructor(WebCore::JSRequest::createConstructor(init.vm, init.global, init.prototype));
});
+ m_JSResolveMessage.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSResolveMessage::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSResolveMessage::createStructure(init.vm, init.global, init.prototype));
+ init.setConstructor(WebCore::JSResolveMessage::createConstructor(init.vm, init.global, init.prototype));
+ });
m_JSResponse.initLater(
[](LazyClassStructure::Initializer& init) {
init.setPrototype(WebCore::JSResponse::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
@@ -173,6 +185,7 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor&
{
thisObject->m_JSBlob.visit(visitor); visitor.append(thisObject->m_JSBlobSetterValue);
thisObject->m_JSBuildArtifact.visit(visitor); visitor.append(thisObject->m_JSBuildArtifactSetterValue);
+ thisObject->m_JSBuildMessage.visit(visitor); visitor.append(thisObject->m_JSBuildMessageSetterValue);
thisObject->m_JSCryptoHasher.visit(visitor); visitor.append(thisObject->m_JSCryptoHasherSetterValue);
thisObject->m_JSDirent.visit(visitor); visitor.append(thisObject->m_JSDirentSetterValue);
thisObject->m_JSExpect.visit(visitor); visitor.append(thisObject->m_JSExpectSetterValue);
@@ -184,6 +197,7 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor&
thisObject->m_JSMatchedRoute.visit(visitor); visitor.append(thisObject->m_JSMatchedRouteSetterValue);
thisObject->m_JSNodeJSFS.visit(visitor); visitor.append(thisObject->m_JSNodeJSFSSetterValue);
thisObject->m_JSRequest.visit(visitor); visitor.append(thisObject->m_JSRequestSetterValue);
+ thisObject->m_JSResolveMessage.visit(visitor); visitor.append(thisObject->m_JSResolveMessageSetterValue);
thisObject->m_JSResponse.visit(visitor); visitor.append(thisObject->m_JSResponseSetterValue);
thisObject->m_JSSHA1.visit(visitor); visitor.append(thisObject->m_JSSHA1SetterValue);
thisObject->m_JSSHA224.visit(visitor); visitor.append(thisObject->m_JSSHA224SetterValue);
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp
index a8ec4c6b5..c8a1b9b2b 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.cpp
+++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp
@@ -1017,6 +1017,450 @@ void JSBuildArtifact::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSBuildArtifact);
+class JSBuildMessagePrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSBuildMessagePrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSBuildMessagePrototype* ptr = new (NotNull, JSC::allocateCell<JSBuildMessagePrototype>(vm)) JSBuildMessagePrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSBuildMessagePrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+class JSBuildMessageConstructor final : public JSC::InternalFunction {
+public:
+ using Base = JSC::InternalFunction;
+ static JSBuildMessageConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBuildMessagePrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSBuildMessageConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForBuildMessageConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBuildMessageConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForBuildMessageConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForBuildMessageConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSBuildMessagePrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSBuildMessageConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSBuildMessagePrototype* prototype);
+};
+
+extern "C" void* BuildMessageClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC_DECLARE_CUSTOM_GETTER(jsBuildMessageConstructor);
+extern "C" void BuildMessageClass__finalize(void*);
+
+extern "C" EncodedJSValue BuildMessagePrototype__toPrimitive(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(BuildMessagePrototype__toPrimitiveCallback);
+
+extern "C" JSC::EncodedJSValue BuildMessagePrototype__getLevel(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(BuildMessagePrototype__levelGetterWrap);
+
+extern "C" JSC::EncodedJSValue BuildMessagePrototype__getMessage(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(BuildMessagePrototype__messageGetterWrap);
+
+extern "C" JSC::EncodedJSValue BuildMessagePrototype__getPosition(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(BuildMessagePrototype__positionGetterWrap);
+
+extern "C" EncodedJSValue BuildMessagePrototype__toJSON(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(BuildMessagePrototype__toJSONCallback);
+
+extern "C" EncodedJSValue BuildMessagePrototype__toString(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(BuildMessagePrototype__toStringCallback);
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBuildMessagePrototype, JSBuildMessagePrototype::Base);
+
+static const HashTableValue JSBuildMessagePrototypeTableValues[] = {
+ { "level"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BuildMessagePrototype__levelGetterWrap, 0 } },
+ { "message"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BuildMessagePrototype__messageGetterWrap, 0 } },
+ { "position"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BuildMessagePrototype__positionGetterWrap, 0 } },
+ { "toJSON"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BuildMessagePrototype__toJSONCallback, 0 } },
+ { "toString"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BuildMessagePrototype__toStringCallback, 0 } }
+};
+
+const ClassInfo JSBuildMessagePrototype::s_info = { "BuildMessage"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBuildMessagePrototype) };
+
+JSC_DEFINE_CUSTOM_GETTER(jsBuildMessageConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto* prototype = jsDynamicCast<JSBuildMessagePrototype*>(JSValue::decode(thisValue));
+
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(globalObject->JSBuildMessageConstructor());
+}
+
+JSC_DEFINE_HOST_FUNCTION(BuildMessagePrototype__toPrimitiveCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSBuildMessage* thisObject = jsDynamicCast<JSBuildMessage*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return BuildMessagePrototype__toPrimitive(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(BuildMessagePrototype__levelGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSBuildMessage* thisObject = jsCast<JSBuildMessage*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_level.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ BuildMessagePrototype__getLevel(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_level.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void BuildMessagePrototype__levelSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSBuildMessage*>(JSValue::decode(thisValue));
+ thisObject->m_level.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue BuildMessagePrototype__levelGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSBuildMessage*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_level.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(BuildMessagePrototype__messageGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSBuildMessage* thisObject = jsCast<JSBuildMessage*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_message.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ BuildMessagePrototype__getMessage(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_message.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void BuildMessagePrototype__messageSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSBuildMessage*>(JSValue::decode(thisValue));
+ thisObject->m_message.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue BuildMessagePrototype__messageGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSBuildMessage*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_message.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(BuildMessagePrototype__positionGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSBuildMessage* thisObject = jsCast<JSBuildMessage*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_position.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ BuildMessagePrototype__getPosition(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_position.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void BuildMessagePrototype__positionSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSBuildMessage*>(JSValue::decode(thisValue));
+ thisObject->m_position.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue BuildMessagePrototype__positionGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSBuildMessage*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_position.get());
+}
+
+JSC_DEFINE_HOST_FUNCTION(BuildMessagePrototype__toJSONCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSBuildMessage* thisObject = jsDynamicCast<JSBuildMessage*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return BuildMessagePrototype__toJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(BuildMessagePrototype__toStringCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSBuildMessage* thisObject = jsDynamicCast<JSBuildMessage*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return BuildMessagePrototype__toString(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+void JSBuildMessagePrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSBuildMessage::info(), JSBuildMessagePrototypeTableValues, *this);
+ this->putDirect(vm, vm.propertyNames->toPrimitiveSymbol, JSFunction::create(vm, globalObject, 1, String("toPrimitive"_s), BuildMessagePrototype__toPrimitiveCallback, ImplementationVisibility::Public), PropertyAttribute::Function | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0);
+ this->putDirect(vm, vm.propertyNames->name, jsString(vm, String("BuildMessage"_s)), PropertyAttribute::ReadOnly | 0);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+void JSBuildMessageConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSBuildMessagePrototype* prototype)
+{
+ Base::finishCreation(vm, 0, "BuildMessage"_s, PropertyAdditionMode::WithoutStructureTransition);
+
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ ASSERT(inherits(info()));
+}
+
+JSBuildMessageConstructor::JSBuildMessageConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
+
+JSBuildMessageConstructor* JSBuildMessageConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBuildMessagePrototype* prototype)
+{
+ JSBuildMessageConstructor* ptr = new (NotNull, JSC::allocateCell<JSBuildMessageConstructor>(vm)) JSBuildMessageConstructor(vm, structure);
+ ptr->finishCreation(vm, globalObject, prototype);
+ return ptr;
+}
+
+JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSBuildMessageConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
+{
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
+ JSObject* newTarget = asObject(callFrame->newTarget());
+ auto* constructor = globalObject->JSBuildMessageConstructor();
+ Structure* structure = globalObject->JSBuildMessageStructure();
+ if (constructor != newTarget) {
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSBuildMessageStructure());
+ }
+
+ void* ptr = BuildMessageClass__construct(globalObject, callFrame);
+
+ if (UNLIKELY(!ptr)) {
+ return JSValue::encode(JSC::jsUndefined());
+ }
+
+ JSBuildMessage* instance = JSBuildMessage::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+void JSBuildMessageConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSBuildMessagePrototype* prototype)
+{
+}
+
+const ClassInfo JSBuildMessageConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBuildMessageConstructor) };
+
+extern "C" EncodedJSValue BuildMessage__getConstructor(Zig::GlobalObject* globalObject)
+{
+ return JSValue::encode(globalObject->JSBuildMessageConstructor());
+}
+
+JSBuildMessage::~JSBuildMessage()
+{
+ if (m_ctx) {
+ BuildMessageClass__finalize(m_ctx);
+ }
+}
+void JSBuildMessage::destroy(JSCell* cell)
+{
+ static_cast<JSBuildMessage*>(cell)->JSBuildMessage::~JSBuildMessage();
+}
+
+const ClassInfo JSBuildMessage::s_info = { "BuildMessage"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBuildMessage) };
+
+void JSBuildMessage::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSBuildMessage* JSBuildMessage::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSBuildMessage* ptr = new (NotNull, JSC::allocateCell<JSBuildMessage>(vm)) JSBuildMessage(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* BuildMessage__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSBuildMessage* object = JSC::jsDynamicCast<JSBuildMessage*>(cell);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool BuildMessage__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSBuildMessage* object = JSC::jsDynamicCast<JSBuildMessage*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t BuildMessage__ptrOffset = JSBuildMessage::offsetOfWrapped();
+
+void JSBuildMessage::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSBuildMessage*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSBuildMessage::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+{
+ return WebCore::JSBuildMessageConstructor::create(vm, globalObject, WebCore::JSBuildMessageConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSBuildMessagePrototype*>(prototype));
+}
+
+JSObject* JSBuildMessage::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSBuildMessagePrototype::create(vm, globalObject, JSBuildMessagePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue BuildMessage__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSBuildMessageStructure();
+ JSBuildMessage* instance = JSBuildMessage::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+template<typename Visitor>
+void JSBuildMessage::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSBuildMessage* thisObject = jsCast<JSBuildMessage*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+
+ visitor.append(thisObject->m_level);
+ visitor.append(thisObject->m_message);
+ visitor.append(thisObject->m_position);
+}
+
+DEFINE_VISIT_CHILDREN(JSBuildMessage);
+
+template<typename Visitor>
+void JSBuildMessage::visitAdditionalChildren(Visitor& visitor)
+{
+ JSBuildMessage* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+
+ visitor.append(thisObject->m_level);
+ visitor.append(thisObject->m_message);
+ visitor.append(thisObject->m_position);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSBuildMessage);
+
+template<typename Visitor>
+void JSBuildMessage::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSBuildMessage* thisObject = jsCast<JSBuildMessage*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSBuildMessage);
class JSCryptoHasherPrototype final : public JSC::JSNonFinalObject {
public:
using Base = JSC::JSNonFinalObject;
@@ -7566,6 +8010,562 @@ void JSRequest::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSRequest);
+class JSResolveMessagePrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSResolveMessagePrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSResolveMessagePrototype* ptr = new (NotNull, JSC::allocateCell<JSResolveMessagePrototype>(vm)) JSResolveMessagePrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSResolveMessagePrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+class JSResolveMessageConstructor final : public JSC::InternalFunction {
+public:
+ using Base = JSC::InternalFunction;
+ static JSResolveMessageConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSResolveMessagePrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSResolveMessageConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForResolveMessageConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResolveMessageConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForResolveMessageConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForResolveMessageConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSResolveMessagePrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSResolveMessageConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSResolveMessagePrototype* prototype);
+};
+
+extern "C" void* ResolveMessageClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC_DECLARE_CUSTOM_GETTER(jsResolveMessageConstructor);
+extern "C" void ResolveMessageClass__finalize(void*);
+
+extern "C" EncodedJSValue ResolveMessagePrototype__toPrimitive(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(ResolveMessagePrototype__toPrimitiveCallback);
+
+extern "C" JSC::EncodedJSValue ResolveMessagePrototype__getImportKind(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(ResolveMessagePrototype__importKindGetterWrap);
+
+extern "C" JSC::EncodedJSValue ResolveMessagePrototype__getLevel(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(ResolveMessagePrototype__levelGetterWrap);
+
+extern "C" JSC::EncodedJSValue ResolveMessagePrototype__getMessage(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(ResolveMessagePrototype__messageGetterWrap);
+
+extern "C" JSC::EncodedJSValue ResolveMessagePrototype__getPosition(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(ResolveMessagePrototype__positionGetterWrap);
+
+extern "C" JSC::EncodedJSValue ResolveMessagePrototype__getReferrer(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(ResolveMessagePrototype__referrerGetterWrap);
+
+extern "C" JSC::EncodedJSValue ResolveMessagePrototype__getSpecifier(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
+JSC_DECLARE_CUSTOM_GETTER(ResolveMessagePrototype__specifierGetterWrap);
+
+extern "C" EncodedJSValue ResolveMessagePrototype__toJSON(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(ResolveMessagePrototype__toJSONCallback);
+
+extern "C" EncodedJSValue ResolveMessagePrototype__toString(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(ResolveMessagePrototype__toStringCallback);
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSResolveMessagePrototype, JSResolveMessagePrototype::Base);
+
+static const HashTableValue JSResolveMessagePrototypeTableValues[] = {
+ { "importKind"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResolveMessagePrototype__importKindGetterWrap, 0 } },
+ { "level"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResolveMessagePrototype__levelGetterWrap, 0 } },
+ { "message"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResolveMessagePrototype__messageGetterWrap, 0 } },
+ { "position"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResolveMessagePrototype__positionGetterWrap, 0 } },
+ { "referrer"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResolveMessagePrototype__referrerGetterWrap, 0 } },
+ { "specifier"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResolveMessagePrototype__specifierGetterWrap, 0 } },
+ { "toJSON"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResolveMessagePrototype__toJSONCallback, 0 } },
+ { "toString"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResolveMessagePrototype__toStringCallback, 0 } }
+};
+
+const ClassInfo JSResolveMessagePrototype::s_info = { "ResolveMessage"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSResolveMessagePrototype) };
+
+JSC_DEFINE_CUSTOM_GETTER(jsResolveMessageConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto* prototype = jsDynamicCast<JSResolveMessagePrototype*>(JSValue::decode(thisValue));
+
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(globalObject->JSResolveMessageConstructor());
+}
+
+JSC_DEFINE_HOST_FUNCTION(ResolveMessagePrototype__toPrimitiveCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSResolveMessage* thisObject = jsDynamicCast<JSResolveMessage*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ResolveMessagePrototype__toPrimitive(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(ResolveMessagePrototype__importKindGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSResolveMessage* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_importKind.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ ResolveMessagePrototype__getImportKind(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_importKind.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void ResolveMessagePrototype__importKindSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ thisObject->m_importKind.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue ResolveMessagePrototype__importKindGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_importKind.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(ResolveMessagePrototype__levelGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSResolveMessage* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_level.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ ResolveMessagePrototype__getLevel(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_level.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void ResolveMessagePrototype__levelSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ thisObject->m_level.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue ResolveMessagePrototype__levelGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_level.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(ResolveMessagePrototype__messageGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSResolveMessage* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_message.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ ResolveMessagePrototype__getMessage(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_message.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void ResolveMessagePrototype__messageSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ thisObject->m_message.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue ResolveMessagePrototype__messageGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_message.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(ResolveMessagePrototype__positionGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSResolveMessage* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_position.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ ResolveMessagePrototype__getPosition(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_position.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void ResolveMessagePrototype__positionSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ thisObject->m_position.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue ResolveMessagePrototype__positionGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_position.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(ResolveMessagePrototype__referrerGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSResolveMessage* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_referrer.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ ResolveMessagePrototype__getReferrer(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_referrer.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void ResolveMessagePrototype__referrerSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ thisObject->m_referrer.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue ResolveMessagePrototype__referrerGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_referrer.get());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(ResolveMessagePrototype__specifierGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ auto& vm = lexicalGlobalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ JSResolveMessage* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ if (JSValue cachedValue = thisObject->m_specifier.get())
+ return JSValue::encode(cachedValue);
+
+ JSC::JSValue result = JSC::JSValue::decode(
+ ResolveMessagePrototype__getSpecifier(thisObject->wrapped(), globalObject));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ thisObject->m_specifier.set(vm, thisObject, result);
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
+}
+
+extern "C" void ResolveMessagePrototype__specifierSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ thisObject->m_specifier.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue ResolveMessagePrototype__specifierGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSResolveMessage*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_specifier.get());
+}
+
+JSC_DEFINE_HOST_FUNCTION(ResolveMessagePrototype__toJSONCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSResolveMessage* thisObject = jsDynamicCast<JSResolveMessage*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ResolveMessagePrototype__toJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(ResolveMessagePrototype__toStringCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSResolveMessage* thisObject = jsDynamicCast<JSResolveMessage*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ResolveMessagePrototype__toString(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+void JSResolveMessagePrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSResolveMessage::info(), JSResolveMessagePrototypeTableValues, *this);
+ this->putDirect(vm, vm.propertyNames->toPrimitiveSymbol, JSFunction::create(vm, globalObject, 1, String("toPrimitive"_s), ResolveMessagePrototype__toPrimitiveCallback, ImplementationVisibility::Public), PropertyAttribute::Function | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0);
+ this->putDirect(vm, Identifier::fromString(vm, "code"_s), jsString(vm, String("ERR_MODULE_NOT_FOUND"_s)), PropertyAttribute::ReadOnly | 0);
+ this->putDirect(vm, vm.propertyNames->name, jsString(vm, String("ResolveMessage"_s)), PropertyAttribute::ReadOnly | 0);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+void JSResolveMessageConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSResolveMessagePrototype* prototype)
+{
+ Base::finishCreation(vm, 0, "ResolveMessage"_s, PropertyAdditionMode::WithoutStructureTransition);
+
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ ASSERT(inherits(info()));
+}
+
+JSResolveMessageConstructor::JSResolveMessageConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
+
+JSResolveMessageConstructor* JSResolveMessageConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSResolveMessagePrototype* prototype)
+{
+ JSResolveMessageConstructor* ptr = new (NotNull, JSC::allocateCell<JSResolveMessageConstructor>(vm)) JSResolveMessageConstructor(vm, structure);
+ ptr->finishCreation(vm, globalObject, prototype);
+ return ptr;
+}
+
+JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSResolveMessageConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
+{
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
+ JSObject* newTarget = asObject(callFrame->newTarget());
+ auto* constructor = globalObject->JSResolveMessageConstructor();
+ Structure* structure = globalObject->JSResolveMessageStructure();
+ if (constructor != newTarget) {
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSResolveMessageStructure());
+ }
+
+ void* ptr = ResolveMessageClass__construct(globalObject, callFrame);
+
+ if (UNLIKELY(!ptr)) {
+ return JSValue::encode(JSC::jsUndefined());
+ }
+
+ JSResolveMessage* instance = JSResolveMessage::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+void JSResolveMessageConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSResolveMessagePrototype* prototype)
+{
+}
+
+const ClassInfo JSResolveMessageConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSResolveMessageConstructor) };
+
+extern "C" EncodedJSValue ResolveMessage__getConstructor(Zig::GlobalObject* globalObject)
+{
+ return JSValue::encode(globalObject->JSResolveMessageConstructor());
+}
+
+JSResolveMessage::~JSResolveMessage()
+{
+ if (m_ctx) {
+ ResolveMessageClass__finalize(m_ctx);
+ }
+}
+void JSResolveMessage::destroy(JSCell* cell)
+{
+ static_cast<JSResolveMessage*>(cell)->JSResolveMessage::~JSResolveMessage();
+}
+
+const ClassInfo JSResolveMessage::s_info = { "ResolveMessage"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSResolveMessage) };
+
+void JSResolveMessage::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSResolveMessage* JSResolveMessage::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSResolveMessage* ptr = new (NotNull, JSC::allocateCell<JSResolveMessage>(vm)) JSResolveMessage(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* ResolveMessage__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSResolveMessage* object = JSC::jsDynamicCast<JSResolveMessage*>(cell);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool ResolveMessage__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSResolveMessage* object = JSC::jsDynamicCast<JSResolveMessage*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t ResolveMessage__ptrOffset = JSResolveMessage::offsetOfWrapped();
+
+void JSResolveMessage::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSResolveMessage*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSResolveMessage::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+{
+ return WebCore::JSResolveMessageConstructor::create(vm, globalObject, WebCore::JSResolveMessageConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSResolveMessagePrototype*>(prototype));
+}
+
+JSObject* JSResolveMessage::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSResolveMessagePrototype::create(vm, globalObject, JSResolveMessagePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue ResolveMessage__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSResolveMessageStructure();
+ JSResolveMessage* instance = JSResolveMessage::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+template<typename Visitor>
+void JSResolveMessage::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSResolveMessage* thisObject = jsCast<JSResolveMessage*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+
+ visitor.append(thisObject->m_importKind);
+ visitor.append(thisObject->m_level);
+ visitor.append(thisObject->m_message);
+ visitor.append(thisObject->m_position);
+ visitor.append(thisObject->m_referrer);
+ visitor.append(thisObject->m_specifier);
+}
+
+DEFINE_VISIT_CHILDREN(JSResolveMessage);
+
+template<typename Visitor>
+void JSResolveMessage::visitAdditionalChildren(Visitor& visitor)
+{
+ JSResolveMessage* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+
+ visitor.append(thisObject->m_importKind);
+ visitor.append(thisObject->m_level);
+ visitor.append(thisObject->m_message);
+ visitor.append(thisObject->m_position);
+ visitor.append(thisObject->m_referrer);
+ visitor.append(thisObject->m_specifier);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSResolveMessage);
+
+template<typename Visitor>
+void JSResolveMessage::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSResolveMessage* thisObject = jsCast<JSResolveMessage*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSResolveMessage);
class JSResponsePrototype final : public JSC::JSNonFinalObject {
public:
using Base = JSC::JSNonFinalObject;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h
index 02fef6d3c..cf5446a1a 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses.h
@@ -132,6 +132,64 @@ public:
mutable JSC::WriteBarrier<JSC::Unknown> m_type;
};
+class JSBuildMessage final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSBuildMessage* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSBuildMessage, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForBuildMessage.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBuildMessage = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForBuildMessage.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForBuildMessage = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSBuildMessage();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSBuildMessage, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSBuildMessage(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_level;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_message;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_position;
+};
+
class JSCryptoHasher final : public JSC::JSDestructibleObject {
public:
using Base = JSC::JSDestructibleObject;
@@ -744,6 +802,67 @@ public:
mutable JSC::WriteBarrier<JSC::Unknown> m_url;
};
+class JSResolveMessage final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSResolveMessage* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSResolveMessage, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForResolveMessage.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResolveMessage = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForResolveMessage.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForResolveMessage = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSResolveMessage();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSResolveMessage, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSResolveMessage(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_importKind;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_level;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_message;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_position;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_referrer;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_specifier;
+};
+
class JSResponse final : public JSC::JSDestructibleObject {
public:
using Base = JSC::JSDestructibleObject;
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index d35132c8b..eeccb6650 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -3021,6 +3021,15 @@ JSC_DEFINE_CUSTOM_GETTER(bunDns_getter, (JSGlobalObject * globalObject, EncodedJ
return JSValue::encode(reinterpret_cast<Zig::GlobalObject*>(globalObject)->dnsObject());
}
+JSC_DEFINE_CUSTOM_GETTER(functionResolveMessageGetter, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName))
+{
+ return JSValue::encode(reinterpret_cast<Zig::GlobalObject*>(globalObject)->JSResolveMessageConstructor());
+}
+JSC_DEFINE_CUSTOM_GETTER(functionBuildMessageGetter, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName))
+{
+ return JSValue::encode(reinterpret_cast<Zig::GlobalObject*>(globalObject)->JSBuildMessageConstructor());
+}
+
EncodedJSValue GlobalObject::assignToStream(JSValue stream, JSValue controller)
{
JSC::VM& vm = this->vm();
@@ -3264,6 +3273,18 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "navigator"_s), JSC::CustomGetterSetter::create(vm, functionLazyNavigatorGetter, nullptr),
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0);
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ResolveError"_s), JSC::CustomGetterSetter::create(vm, functionResolveMessageGetter, nullptr),
+ JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0);
+
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ResolveMessage"_s), JSC::CustomGetterSetter::create(vm, functionResolveMessageGetter, nullptr),
+ JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0);
+
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "BuildError"_s), JSC::CustomGetterSetter::create(vm, functionBuildMessageGetter, nullptr),
+ JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0);
+
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "BuildMessage"_s), JSC::CustomGetterSetter::create(vm, functionBuildMessageGetter, nullptr),
+ JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0);
+
putDirect(vm, builtinNames.requireMapPrivateName(), this->requireMap(),
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0);
diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig
index 1fb5a1029..acbf7944a 100644
--- a/src/bun.js/bindings/exports.zig
+++ b/src/bun.js/bindings/exports.zig
@@ -2159,24 +2159,13 @@ pub const ZigConsoleClient = struct {
}
return;
+ } else if (value.as(JSC.BuildMessage)) |build_log| {
+ build_log.msg.writeFormat(writer_, enable_ansi_colors) catch {};
+ return;
+ } else if (value.as(JSC.ResolveMessage)) |resolve_log| {
+ resolve_log.msg.writeFormat(writer_, enable_ansi_colors) catch {};
+ return;
} else if (jsType != .DOMWrapper) {
- if (CAPI.JSObjectGetPrivate(value.asRef())) |private_data_ptr| {
- const priv_data = JSPrivateDataPtr.from(private_data_ptr);
- switch (priv_data.tag()) {
- .BuildMessage => {
- const build_log = priv_data.as(JS.BuildMessage);
- build_log.msg.writeFormat(writer_, enable_ansi_colors) catch {};
- return;
- },
- .ResolveMessage => {
- const resolve_log = priv_data.as(JS.ResolveMessage);
- resolve_log.msg.writeFormat(writer_, enable_ansi_colors) catch {};
- return;
- },
- else => {},
- }
- }
-
if (value.isCallable(this.globalThis.vm())) {
return this.printAs(.Function, Writer, writer_, value, jsType, enable_ansi_colors);
}
diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig
index 841e65b21..43acdc98b 100644
--- a/src/bun.js/bindings/generated_classes.zig
+++ b/src/bun.js/bindings/generated_classes.zig
@@ -380,6 +380,161 @@ pub const JSBuildArtifact = struct {
}
}
};
+pub const JSBuildMessage = struct {
+ const BuildMessage = Classes.BuildMessage;
+ const GetterType = fn (*BuildMessage, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*BuildMessage, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*BuildMessage, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*BuildMessage, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*BuildMessage, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+
+ /// Return the pointer to the wrapped object.
+ /// If the object does not match the type, return null.
+ pub fn fromJS(value: JSC.JSValue) ?*BuildMessage {
+ JSC.markBinding(@src());
+ return BuildMessage__fromJS(value);
+ }
+
+ extern fn BuildMessagePrototype__levelSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn BuildMessagePrototype__levelGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `BuildMessage.level` setter
+ /// This value will be visited by the garbage collector.
+ pub fn levelSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ BuildMessagePrototype__levelSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `BuildMessage.level` getter
+ /// This value will be visited by the garbage collector.
+ pub fn levelGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = BuildMessagePrototype__levelGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn BuildMessagePrototype__messageSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn BuildMessagePrototype__messageGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `BuildMessage.message` setter
+ /// This value will be visited by the garbage collector.
+ pub fn messageSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ BuildMessagePrototype__messageSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `BuildMessage.message` getter
+ /// This value will be visited by the garbage collector.
+ pub fn messageGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = BuildMessagePrototype__messageGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn BuildMessagePrototype__positionSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn BuildMessagePrototype__positionGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `BuildMessage.position` setter
+ /// This value will be visited by the garbage collector.
+ pub fn positionSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ BuildMessagePrototype__positionSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `BuildMessage.position` getter
+ /// This value will be visited by the garbage collector.
+ pub fn positionGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = BuildMessagePrototype__positionGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ /// Get the BuildMessage constructor value.
+ /// This loads lazily from the global object.
+ pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ return BuildMessage__getConstructor(globalObject);
+ }
+
+ /// Create a new instance of BuildMessage
+ pub fn toJS(this: *BuildMessage, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = BuildMessage__create(globalObject, this);
+ std.debug.assert(value__.as(BuildMessage).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return BuildMessage__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of BuildMessage.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*BuildMessage) bool {
+ JSC.markBinding(@src());
+ return BuildMessage__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *BuildMessage, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(BuildMessage__dangerouslySetPtr(value, null));
+ }
+
+ extern fn BuildMessage__fromJS(JSC.JSValue) ?*BuildMessage;
+ extern fn BuildMessage__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn BuildMessage__create(globalObject: *JSC.JSGlobalObject, ptr: ?*BuildMessage) JSC.JSValue;
+
+ extern fn BuildMessage__dangerouslySetPtr(JSC.JSValue, ?*BuildMessage) bool;
+
+ comptime {
+ if (@TypeOf(BuildMessage.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*BuildMessage)) {
+ @compileLog("BuildMessage.constructor is not a constructor");
+ }
+
+ if (@TypeOf(BuildMessage.finalize) != (fn (*BuildMessage) callconv(.C) void)) {
+ @compileLog("BuildMessage.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(BuildMessage.toPrimitive) != CallbackType)
+ @compileLog("Expected BuildMessage.toPrimitive to be a callback but received " ++ @typeName(@TypeOf(BuildMessage.toPrimitive)));
+ if (@TypeOf(BuildMessage.getLevel) != GetterType)
+ @compileLog("Expected BuildMessage.getLevel to be a getter");
+
+ if (@TypeOf(BuildMessage.getMessage) != GetterType)
+ @compileLog("Expected BuildMessage.getMessage to be a getter");
+
+ if (@TypeOf(BuildMessage.getPosition) != GetterType)
+ @compileLog("Expected BuildMessage.getPosition to be a getter");
+
+ if (@TypeOf(BuildMessage.toJSON) != CallbackType)
+ @compileLog("Expected BuildMessage.toJSON to be a callback but received " ++ @typeName(@TypeOf(BuildMessage.toJSON)));
+ if (@TypeOf(BuildMessage.toString) != CallbackType)
+ @compileLog("Expected BuildMessage.toString to be a callback but received " ++ @typeName(@TypeOf(BuildMessage.toString)));
+ if (!JSC.is_bindgen) {
+ @export(BuildMessage.constructor, .{ .name = "BuildMessageClass__construct" });
+ @export(BuildMessage.finalize, .{ .name = "BuildMessageClass__finalize" });
+ @export(BuildMessage.getLevel, .{ .name = "BuildMessagePrototype__getLevel" });
+ @export(BuildMessage.getMessage, .{ .name = "BuildMessagePrototype__getMessage" });
+ @export(BuildMessage.getPosition, .{ .name = "BuildMessagePrototype__getPosition" });
+ @export(BuildMessage.toJSON, .{ .name = "BuildMessagePrototype__toJSON" });
+ @export(BuildMessage.toPrimitive, .{ .name = "BuildMessagePrototype__toPrimitive" });
+ @export(BuildMessage.toString, .{ .name = "BuildMessagePrototype__toString" });
+ }
+ }
+};
pub const JSCryptoHasher = struct {
const CryptoHasher = Classes.CryptoHasher;
const GetterType = fn (*CryptoHasher, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
@@ -2204,6 +2359,239 @@ pub const JSRequest = struct {
}
}
};
+pub const JSResolveMessage = struct {
+ const ResolveMessage = Classes.ResolveMessage;
+ const GetterType = fn (*ResolveMessage, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*ResolveMessage, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*ResolveMessage, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*ResolveMessage, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*ResolveMessage, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+
+ /// Return the pointer to the wrapped object.
+ /// If the object does not match the type, return null.
+ pub fn fromJS(value: JSC.JSValue) ?*ResolveMessage {
+ JSC.markBinding(@src());
+ return ResolveMessage__fromJS(value);
+ }
+
+ extern fn ResolveMessagePrototype__importKindSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn ResolveMessagePrototype__importKindGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `ResolveMessage.importKind` setter
+ /// This value will be visited by the garbage collector.
+ pub fn importKindSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResolveMessagePrototype__importKindSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `ResolveMessage.importKind` getter
+ /// This value will be visited by the garbage collector.
+ pub fn importKindGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResolveMessagePrototype__importKindGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn ResolveMessagePrototype__levelSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn ResolveMessagePrototype__levelGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `ResolveMessage.level` setter
+ /// This value will be visited by the garbage collector.
+ pub fn levelSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResolveMessagePrototype__levelSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `ResolveMessage.level` getter
+ /// This value will be visited by the garbage collector.
+ pub fn levelGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResolveMessagePrototype__levelGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn ResolveMessagePrototype__messageSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn ResolveMessagePrototype__messageGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `ResolveMessage.message` setter
+ /// This value will be visited by the garbage collector.
+ pub fn messageSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResolveMessagePrototype__messageSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `ResolveMessage.message` getter
+ /// This value will be visited by the garbage collector.
+ pub fn messageGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResolveMessagePrototype__messageGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn ResolveMessagePrototype__positionSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn ResolveMessagePrototype__positionGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `ResolveMessage.position` setter
+ /// This value will be visited by the garbage collector.
+ pub fn positionSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResolveMessagePrototype__positionSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `ResolveMessage.position` getter
+ /// This value will be visited by the garbage collector.
+ pub fn positionGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResolveMessagePrototype__positionGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn ResolveMessagePrototype__referrerSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn ResolveMessagePrototype__referrerGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `ResolveMessage.referrer` setter
+ /// This value will be visited by the garbage collector.
+ pub fn referrerSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResolveMessagePrototype__referrerSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `ResolveMessage.referrer` getter
+ /// This value will be visited by the garbage collector.
+ pub fn referrerGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResolveMessagePrototype__referrerGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn ResolveMessagePrototype__specifierSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn ResolveMessagePrototype__specifierGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `ResolveMessage.specifier` setter
+ /// This value will be visited by the garbage collector.
+ pub fn specifierSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResolveMessagePrototype__specifierSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `ResolveMessage.specifier` getter
+ /// This value will be visited by the garbage collector.
+ pub fn specifierGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResolveMessagePrototype__specifierGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ /// Get the ResolveMessage constructor value.
+ /// This loads lazily from the global object.
+ pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ return ResolveMessage__getConstructor(globalObject);
+ }
+
+ /// Create a new instance of ResolveMessage
+ pub fn toJS(this: *ResolveMessage, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = ResolveMessage__create(globalObject, this);
+ std.debug.assert(value__.as(ResolveMessage).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return ResolveMessage__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of ResolveMessage.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*ResolveMessage) bool {
+ JSC.markBinding(@src());
+ return ResolveMessage__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *ResolveMessage, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(ResolveMessage__dangerouslySetPtr(value, null));
+ }
+
+ extern fn ResolveMessage__fromJS(JSC.JSValue) ?*ResolveMessage;
+ extern fn ResolveMessage__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn ResolveMessage__create(globalObject: *JSC.JSGlobalObject, ptr: ?*ResolveMessage) JSC.JSValue;
+
+ extern fn ResolveMessage__dangerouslySetPtr(JSC.JSValue, ?*ResolveMessage) bool;
+
+ comptime {
+ if (@TypeOf(ResolveMessage.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*ResolveMessage)) {
+ @compileLog("ResolveMessage.constructor is not a constructor");
+ }
+
+ if (@TypeOf(ResolveMessage.finalize) != (fn (*ResolveMessage) callconv(.C) void)) {
+ @compileLog("ResolveMessage.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(ResolveMessage.toPrimitive) != CallbackType)
+ @compileLog("Expected ResolveMessage.toPrimitive to be a callback but received " ++ @typeName(@TypeOf(ResolveMessage.toPrimitive)));
+ if (@TypeOf(ResolveMessage.getImportKind) != GetterType)
+ @compileLog("Expected ResolveMessage.getImportKind to be a getter");
+
+ if (@TypeOf(ResolveMessage.getLevel) != GetterType)
+ @compileLog("Expected ResolveMessage.getLevel to be a getter");
+
+ if (@TypeOf(ResolveMessage.getMessage) != GetterType)
+ @compileLog("Expected ResolveMessage.getMessage to be a getter");
+
+ if (@TypeOf(ResolveMessage.getPosition) != GetterType)
+ @compileLog("Expected ResolveMessage.getPosition to be a getter");
+
+ if (@TypeOf(ResolveMessage.getReferrer) != GetterType)
+ @compileLog("Expected ResolveMessage.getReferrer to be a getter");
+
+ if (@TypeOf(ResolveMessage.getSpecifier) != GetterType)
+ @compileLog("Expected ResolveMessage.getSpecifier to be a getter");
+
+ if (@TypeOf(ResolveMessage.toJSON) != CallbackType)
+ @compileLog("Expected ResolveMessage.toJSON to be a callback but received " ++ @typeName(@TypeOf(ResolveMessage.toJSON)));
+ if (@TypeOf(ResolveMessage.toString) != CallbackType)
+ @compileLog("Expected ResolveMessage.toString to be a callback but received " ++ @typeName(@TypeOf(ResolveMessage.toString)));
+ if (!JSC.is_bindgen) {
+ @export(ResolveMessage.constructor, .{ .name = "ResolveMessageClass__construct" });
+ @export(ResolveMessage.finalize, .{ .name = "ResolveMessageClass__finalize" });
+ @export(ResolveMessage.getImportKind, .{ .name = "ResolveMessagePrototype__getImportKind" });
+ @export(ResolveMessage.getLevel, .{ .name = "ResolveMessagePrototype__getLevel" });
+ @export(ResolveMessage.getMessage, .{ .name = "ResolveMessagePrototype__getMessage" });
+ @export(ResolveMessage.getPosition, .{ .name = "ResolveMessagePrototype__getPosition" });
+ @export(ResolveMessage.getReferrer, .{ .name = "ResolveMessagePrototype__getReferrer" });
+ @export(ResolveMessage.getSpecifier, .{ .name = "ResolveMessagePrototype__getSpecifier" });
+ @export(ResolveMessage.toJSON, .{ .name = "ResolveMessagePrototype__toJSON" });
+ @export(ResolveMessage.toPrimitive, .{ .name = "ResolveMessagePrototype__toPrimitive" });
+ @export(ResolveMessage.toString, .{ .name = "ResolveMessagePrototype__toString" });
+ }
+ }
+};
pub const JSResponse = struct {
const Response = Classes.Response;
const GetterType = fn (*Response, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
@@ -4172,6 +4560,7 @@ pub const JSTranspiler = struct {
comptime {
_ = JSBlob;
_ = JSBuildArtifact;
+ _ = JSBuildMessage;
_ = JSCryptoHasher;
_ = JSDirent;
_ = JSExpect;
@@ -4183,6 +4572,7 @@ comptime {
_ = JSMatchedRoute;
_ = JSNodeJSFS;
_ = JSRequest;
+ _ = JSResolveMessage;
_ = JSResponse;
_ = JSSHA1;
_ = JSSHA224;
diff --git a/src/bun.js/bindings/generated_classes_list.zig b/src/bun.js/bindings/generated_classes_list.zig
index 4e180154b..4acde31e8 100644
--- a/src/bun.js/bindings/generated_classes_list.zig
+++ b/src/bun.js/bindings/generated_classes_list.zig
@@ -32,4 +32,6 @@ pub const Classes = struct {
pub const TextDecoder = JSC.WebCore.TextDecoder;
pub const Timeout = JSC.API.Bun.Timer.TimerObject;
pub const BuildArtifact = JSC.API.BuildArtifact;
+ pub const BuildMessage = JSC.BuildMessage;
+ pub const ResolveMessage = JSC.ResolveMessage;
};
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig
index 34825c3e3..93851f7c0 100644
--- a/src/bun.js/javascript.zig
+++ b/src/bun.js/javascript.zig
@@ -95,8 +95,6 @@ pub const GlobalClasses = [_]type{
Bun.Class,
WebCore.Crypto.Class,
EventListenerMixin.addEventListener(VirtualMachine),
- BuildMessage.Class,
- ResolveMessage.Class,
// Fetch.Class,
js_ast.Macro.JSNode.BunJSXCallbackFunction,
@@ -112,6 +110,8 @@ const Task = JSC.Task;
const Blob = @import("../blob.zig");
pub const Buffer = MarkedArrayBuffer;
const Lock = @import("../lock.zig").Lock;
+const BuildMessage = JSC.BuildMessage;
+const ResolveMessage = JSC.ResolveMessage;
pub const OpaqueCallback = *const fn (current: ?*anyopaque) callconv(.C) void;
pub fn OpaqueWrap(comptime Context: type, comptime Function: fn (this: *Context) void) OpaqueCallback {
@@ -1327,7 +1327,7 @@ pub const VirtualMachine = struct {
};
{
- res.* = ErrorableZigString.err(err, @ptrCast(*anyopaque, ResolveMessage.create(global, VirtualMachine.get().allocator, msg, source.slice())));
+ res.* = ErrorableZigString.err(err, ResolveMessage.create(global, VirtualMachine.get().allocator, msg, source.slice()).asVoid());
}
return;
@@ -1437,7 +1437,7 @@ pub const VirtualMachine = struct {
};
};
{
- ret.* = ErrorableResolvedSource.err(err, @ptrCast(*anyopaque, BuildMessage.create(globalThis, globalThis.allocator(), msg)));
+ ret.* = ErrorableResolvedSource.err(err, BuildMessage.create(globalThis, globalThis.allocator(), msg).asVoid());
}
return;
},
@@ -1445,13 +1445,13 @@ pub const VirtualMachine = struct {
1 => {
const msg = log.msgs.items[0];
ret.* = ErrorableResolvedSource.err(err, switch (msg.metadata) {
- .build => BuildMessage.create(globalThis, globalThis.allocator(), msg).?,
+ .build => BuildMessage.create(globalThis, globalThis.allocator(), msg).asVoid(),
.resolve => ResolveMessage.create(
globalThis,
globalThis.allocator(),
msg,
referrer.slice(),
- ).?,
+ ).asVoid(),
});
return;
},
@@ -1462,13 +1462,13 @@ pub const VirtualMachine = struct {
for (log.msgs.items, 0..) |msg, i| {
errors[i] = switch (msg.metadata) {
- .build => BuildMessage.create(globalThis, globalThis.allocator(), msg).?,
+ .build => BuildMessage.create(globalThis, globalThis.allocator(), msg).asVoid(),
.resolve => ResolveMessage.create(
globalThis,
globalThis.allocator(),
msg,
referrer.slice(),
- ).?,
+ ).asVoid(),
};
}
@@ -1792,21 +1792,8 @@ pub const VirtualMachine = struct {
return;
}
- if (value.isObject()) {
- if (js.JSObjectGetPrivate(value.asRef())) |priv| {
- was_internal = this.printErrorFromMaybePrivateData(
- priv,
- exception_list,
- Writer,
- writer,
- allow_ansi_color,
- );
- return;
- }
- }
-
was_internal = this.printErrorFromMaybePrivateData(
- value.asRef(),
+ value,
exception_list,
Writer,
writer,
@@ -1816,18 +1803,15 @@ pub const VirtualMachine = struct {
pub fn printErrorFromMaybePrivateData(
this: *VirtualMachine,
- value: ?*anyopaque,
+ value: JSC.JSValue,
exception_list: ?*ExceptionList,
comptime Writer: type,
writer: Writer,
comptime allow_ansi_color: bool,
) bool {
- const private_data_ptr = JSPrivateDataPtr.from(value);
-
- switch (private_data_ptr.tag()) {
- .BuildMessage => {
+ if (value.jsType() == .DOMWrapper) {
+ if (value.as(JSC.BuildMessage)) |build_error| {
defer Output.flush();
- var build_error = private_data_ptr.as(BuildMessage);
if (!build_error.logged) {
build_error.msg.writeFormat(writer, allow_ansi_color) catch {};
writer.writeAll("\n") catch {};
@@ -1840,10 +1824,8 @@ pub const VirtualMachine = struct {
) catch {};
}
return true;
- },
- .ResolveMessage => {
+ } else if (value.as(JSC.ResolveMessage)) |resolve_error| {
defer Output.flush();
- var resolve_error = private_data_ptr.as(ResolveMessage);
if (!resolve_error.logged) {
resolve_error.msg.writeFormat(writer, allow_ansi_color) catch {};
resolve_error.logged = true;
@@ -1857,24 +1839,24 @@ pub const VirtualMachine = struct {
) catch {};
}
return true;
- },
- else => {
- this.printErrorInstance(
- @intToEnum(JSValue, @bitCast(JSValue.Type, (@ptrToInt(value)))),
- exception_list,
- Writer,
- writer,
- allow_ansi_color,
- ) catch |err| {
- if (comptime Environment.isDebug) {
- // yo dawg
- Output.printErrorln("Error while printing Error-like object: {s}", .{@errorName(err)});
- Output.flush();
- }
- };
- return false;
- },
+ }
}
+
+ this.printErrorInstance(
+ value,
+ exception_list,
+ Writer,
+ writer,
+ allow_ansi_color,
+ ) catch |err| {
+ if (comptime Environment.isDebug) {
+ // yo dawg
+ Output.printErrorln("Error while printing Error-like object: {s}", .{@errorName(err)});
+ Output.flush();
+ }
+ };
+
+ return false;
}
pub fn reportUncaughtException(globalObject: *JSGlobalObject, exception: *JSC.Exception) JSValue {
@@ -2438,411 +2420,6 @@ pub const EventListenerMixin = struct {
}
};
-pub const ResolveMessage = struct {
- msg: logger.Msg,
- allocator: std.mem.Allocator,
- referrer: ?Fs.Path = null,
- logged: bool = false,
-
- pub fn fmt(allocator: std.mem.Allocator, specifier: string, referrer: string, err: anyerror) !string {
- switch (err) {
- error.ModuleNotFound => {
- if (Resolver.isPackagePath(specifier) and !strings.containsChar(specifier, '/')) {
- return try std.fmt.allocPrint(allocator, "Cannot find package \"{s}\" from \"{s}\"", .{ specifier, referrer });
- } else {
- return try std.fmt.allocPrint(allocator, "Cannot find module \"{s}\" from \"{s}\"", .{ specifier, referrer });
- }
- },
- else => {
- if (Resolver.isPackagePath(specifier)) {
- return try std.fmt.allocPrint(allocator, "{s} while resolving package \"{s}\" from \"{s}\"", .{ @errorName(err), specifier, referrer });
- } else {
- return try std.fmt.allocPrint(allocator, "{s} while resolving \"{s}\" from \"{s}\"", .{ @errorName(err), specifier, referrer });
- }
- },
- }
- }
-
- pub fn toStringFn(this: *ResolveMessage, ctx: js.JSContextRef) js.JSValueRef {
- var text = std.fmt.allocPrint(default_allocator, "ResolveMessage: {s}", .{this.msg.data.text}) catch return null;
- var str = ZigString.init(text);
- str.setOutputEncoding();
- if (str.isUTF8()) {
- const out = str.toValueGC(ctx.ptr());
- default_allocator.free(text);
- return out.asObjectRef();
- }
-
- return str.toExternalValue(ctx.ptr()).asObjectRef();
- }
-
- pub fn toString(
- // this
- this: *ResolveMessage,
- ctx: js.JSContextRef,
- // function
- _: js.JSObjectRef,
- // thisObject
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return this.toStringFn(ctx);
- }
-
- pub fn convertToType(ctx: js.JSContextRef, obj: js.JSObjectRef, kind: js.JSType, _: js.ExceptionRef) callconv(.C) js.JSValueRef {
- switch (kind) {
- js.JSType.kJSTypeString => {
- if (js.JSObjectGetPrivate(obj)) |priv| {
- if (JSPrivateDataPtr.from(priv).is(ResolveMessage)) {
- var this = JSPrivateDataPtr.from(priv).as(ResolveMessage);
- return this.toStringFn(ctx);
- }
- }
- },
- else => {},
- }
-
- return obj;
- }
-
- pub const Class = NewClass(
- ResolveMessage,
- .{
- .name = "ResolveMessage",
- .read_only = true,
- },
- .{
- .toString = .{ .rfn = toString },
- .convertToType = .{ .rfn = &convertToType },
- },
- .{
- .referrer = .{
- .get = getReferrer,
- .ro = true,
- },
- .code = .{
- .get = getCode,
- .ro = true,
- },
- .message = .{
- .get = getMessage,
- .ro = true,
- },
- .name = .{
- .get = getName,
- .ro = true,
- },
- .specifier = .{
- .get = getSpecifier,
- .ro = true,
- },
- .importKind = .{
- .get = getImportKind,
- .ro = true,
- },
- .position = .{
- .get = getPosition,
- .ro = true,
- },
- .level = .{
- .get = getLevel,
- .ro = true,
- },
- },
- );
-
- pub fn create(
- globalThis: *JSGlobalObject,
- allocator: std.mem.Allocator,
- msg: logger.Msg,
- referrer: string,
- ) js.JSObjectRef {
- var resolve_error = allocator.create(ResolveMessage) catch unreachable;
- resolve_error.* = ResolveMessage{
- .msg = msg.clone(allocator) catch unreachable,
- .allocator = allocator,
- .referrer = Fs.Path.init(referrer),
- };
- var ref = Class.make(globalThis, resolve_error);
- js.JSValueProtect(globalThis, ref);
- return ref;
- }
-
- pub fn getCode(
- _: *ResolveMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.static(comptime @as(string, @tagName(JSC.Node.ErrorCode.ERR_MODULE_NOT_FOUND))).toValueGC(ctx).asObjectRef();
- }
-
- pub fn getPosition(
- this: *ResolveMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return BuildMessage.generatePositionObject(this.msg, ctx);
- }
-
- pub fn getMessage(
- this: *ResolveMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.init(this.msg.data.text).toValueGC(ctx.ptr()).asRef();
- }
-
- pub fn getSpecifier(
- this: *ResolveMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.init(this.msg.metadata.resolve.specifier.slice(this.msg.data.text)).toValueGC(ctx.ptr()).asRef();
- }
-
- pub fn getImportKind(
- this: *ResolveMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.init(this.msg.metadata.resolve.import_kind.label()).toValueGC(ctx.ptr()).asRef();
- }
-
- pub fn getReferrer(
- this: *ResolveMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- if (this.referrer) |referrer| {
- return ZigString.init(referrer.text).toValueGC(ctx.ptr()).asRef();
- } else {
- return js.JSValueMakeNull(ctx);
- }
- }
-
- pub fn getName(
- _: *ResolveMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.static("ResolveMessage").toValueGC(ctx.ptr()).asRef();
- }
-
- pub fn getLevel(
- this: *ResolveMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.init(this.msg.kind.string()).toValueGC(ctx.ptr()).asRef();
- }
-
- pub fn finalize(this: *ResolveMessage) void {
- this.msg.deinit(bun.default_allocator);
- }
-};
-
-pub const BuildMessage = struct {
- msg: logger.Msg,
- // resolve_result: Resolver.Result,
- allocator: std.mem.Allocator,
- logged: bool = false,
-
- pub const Class = NewClass(
- BuildMessage,
- .{ .name = "BuildMessage", .read_only = true, .ts = .{
- .class = .{
- .name = "BuildMessage",
- },
- } },
- .{
- .convertToType = .{ .rfn = convertToType },
- .toString = .{ .rfn = toString },
- },
- .{
- .message = .{
- .get = getMessage,
- .ro = true,
- },
- .name = .{
- .get = getName,
- .ro = true,
- },
- // This is called "position" instead of "location" because "location" may be confused with Location.
- .position = .{
- .get = getPosition,
- .ro = true,
- },
- .level = .{
- .get = getLevel,
- .ro = true,
- },
- },
- );
-
- pub fn toStringFn(this: *BuildMessage, ctx: js.JSContextRef) js.JSValueRef {
- var text = std.fmt.allocPrint(default_allocator, "BuildMessage: {s}", .{this.msg.data.text}) catch return null;
- var str = ZigString.init(text);
- str.setOutputEncoding();
- if (str.isUTF8()) {
- const out = str.toValueGC(ctx.ptr());
- default_allocator.free(text);
- return out.asObjectRef();
- }
-
- return str.toExternalValue(ctx.ptr()).asObjectRef();
- }
-
- pub fn toString(
- // this
- this: *BuildMessage,
- ctx: js.JSContextRef,
- // function
- _: js.JSObjectRef,
- // thisObject
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return this.toStringFn(ctx);
- }
-
- pub fn convertToType(ctx: js.JSContextRef, obj: js.JSObjectRef, kind: js.JSType, _: js.ExceptionRef) callconv(.C) js.JSValueRef {
- switch (kind) {
- js.JSType.kJSTypeString => {
- if (js.JSObjectGetPrivate(obj)) |priv| {
- if (JSPrivateDataPtr.from(priv).is(BuildMessage)) {
- var this = JSPrivateDataPtr.from(priv).as(BuildMessage);
- return this.toStringFn(ctx);
- }
- }
- },
- else => {},
- }
-
- return obj;
- }
-
- pub fn create(
- globalThis: *JSGlobalObject,
- allocator: std.mem.Allocator,
- msg: logger.Msg,
- // resolve_result: *const Resolver.Result,
- ) js.JSObjectRef {
- var build_error = allocator.create(BuildMessage) catch unreachable;
- build_error.* = BuildMessage{
- .msg = msg.clone(allocator) catch unreachable,
- // .resolve_result = resolve_result.*,
- .allocator = allocator,
- };
-
- var ref = Class.make(globalThis, build_error);
- js.JSValueProtect(globalThis, ref);
- return ref;
- }
-
- pub fn getPosition(
- this: *BuildMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return generatePositionObject(this.msg, ctx);
- }
-
- pub fn generatePositionObject(msg: logger.Msg, ctx: js.JSContextRef) js.JSValueRef {
- if (msg.data.location) |location| {
- var object = JSC.JSValue.createEmptyObject(ctx, 7);
-
- object.put(
- ctx,
- ZigString.static("lineText"),
- ZigString.init(location.line_text orelse "").toValueGC(ctx),
- );
- object.put(
- ctx,
- ZigString.static("file"),
- ZigString.init(location.file).toValueGC(ctx),
- );
- object.put(
- ctx,
- ZigString.static("namespace"),
- ZigString.init(location.namespace).toValueGC(ctx),
- );
- object.put(
- ctx,
- ZigString.static("line"),
- JSValue.jsNumber(location.line),
- );
- object.put(
- ctx,
- ZigString.static("column"),
- JSValue.jsNumber(location.column),
- );
- object.put(
- ctx,
- ZigString.static("length"),
- JSValue.jsNumber(location.length),
- );
- object.put(
- ctx,
- ZigString.static("offset"),
- JSValue.jsNumber(location.offset),
- );
- return object.asObjectRef();
- }
-
- return js.JSValueMakeNull(ctx);
- }
-
- pub fn getMessage(
- this: *BuildMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.init(this.msg.data.text).toValueGC(ctx.ptr()).asRef();
- }
-
- pub fn getName(
- _: *BuildMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.static("BuildMessage").toValueGC(ctx.ptr()).asRef();
- }
-
- pub fn getLevel(
- this: *BuildMessage,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.init(this.msg.kind.string()).toValueGC(ctx.ptr()).asRef();
- }
-};
-
pub const JSPrivateDataTag = JSPrivateDataPtr.Tag;
pub const HotReloader = NewHotReloader(VirtualMachine, JSC.EventLoop, false);
pub const Watcher = HotReloader.Watcher;
diff --git a/src/bun.js/resolve_message.classes.ts b/src/bun.js/resolve_message.classes.ts
new file mode 100644
index 000000000..734e766ba
--- /dev/null
+++ b/src/bun.js/resolve_message.classes.ts
@@ -0,0 +1,94 @@
+import { define } from "./scripts/class-definitions";
+
+export default [
+ define({
+ name: "ResolveMessage",
+ construct: true,
+ finalize: true,
+ configurable: false,
+ klass: {},
+ JSType: "0b11101110",
+ proto: {
+ message: {
+ getter: "getMessage",
+ cache: true,
+ },
+ name: {
+ value: "ResolveMessage",
+ },
+ level: {
+ getter: "getLevel",
+ cache: true,
+ },
+ referrer: {
+ getter: "getReferrer",
+ cache: true,
+ },
+ specifier: {
+ getter: "getSpecifier",
+ cache: true,
+ },
+ importKind: {
+ getter: "getImportKind",
+ cache: true,
+ },
+ code: {
+ value: "ERR_MODULE_NOT_FOUND",
+ },
+ position: {
+ getter: "getPosition",
+ cache: true,
+ },
+ ["@@toPrimitive"]: {
+ fn: "toPrimitive",
+ length: 1,
+ },
+ ["toString"]: {
+ fn: "toString",
+ length: 0,
+ },
+ ["toJSON"]: {
+ fn: "toJSON",
+ length: 0,
+ },
+ },
+ }),
+
+ define({
+ name: "BuildMessage",
+ construct: true,
+ finalize: true,
+ configurable: false,
+ klass: {},
+ JSType: "0b11101110",
+ proto: {
+ message: {
+ getter: "getMessage",
+ cache: true,
+ },
+ name: {
+ value: "BuildMessage",
+ },
+ level: {
+ getter: "getLevel",
+ cache: true,
+ },
+ position: {
+ getter: "getPosition",
+ cache: true,
+ },
+ ["@@toPrimitive"]: {
+ fn: "toPrimitive",
+ length: 1,
+ },
+ ["toString"]: {
+ fn: "toString",
+ length: 0,
+ },
+ ["toJSON"]: {
+ fn: "toJSON",
+ length: 0,
+ },
+ },
+ }),
+];
diff --git a/src/bun.js/test/pretty_format.zig b/src/bun.js/test/pretty_format.zig
index 355fd7191..ef2a217b9 100644
--- a/src/bun.js/test/pretty_format.zig
+++ b/src/bun.js/test/pretty_format.zig
@@ -1261,24 +1261,13 @@ pub const JestPrettyFormat = struct {
}
return;
+ } else if (value.as(JSC.BuildMessage)) |build_log| {
+ build_log.msg.writeFormat(writer_, enable_ansi_colors) catch {};
+ return;
+ } else if (value.as(JSC.ResolveMessage)) |resolve_log| {
+ resolve_log.msg.writeFormat(writer_, enable_ansi_colors) catch {};
+ return;
} else if (jsType != .DOMWrapper) {
- if (CAPI.JSObjectGetPrivate(value.asRef())) |private_data_ptr| {
- const priv_data = JSPrivateDataPtr.from(private_data_ptr);
- switch (priv_data.tag()) {
- .BuildMessage => {
- const build_log = priv_data.as(JS.BuildMessage);
- build_log.msg.writeFormat(writer_, enable_ansi_colors) catch {};
- return;
- },
- .ResolveMessage => {
- const resolve_log = priv_data.as(JS.ResolveMessage);
- resolve_log.msg.writeFormat(writer_, enable_ansi_colors) catch {};
- return;
- },
- else => {},
- }
- }
-
if (value.isCallable(this.globalThis.vm())) {
return this.printAs(.Function, Writer, writer_, value, jsType, enable_ansi_colors);
}
diff --git a/src/js_ast.zig b/src/js_ast.zig
index cdf7a3ad9..fdd220926 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -9693,6 +9693,9 @@ pub const Macro = struct {
} else if (value.as(JSC.WebCore.Blob)) |resp| {
blob_ = resp.*;
blob_.?.allocator = null;
+ } else if (value.as(JSC.ResolveMessage) != null or value.as(JSC.BuildMessage) != null) {
+ this.macro.vm.runErrorHandler(value, null);
+ return error.MacroFailed;
}
} else {
var private_data = JSCBase.JSPrivateDataPtr.from(JSC.C.JSObjectGetPrivate(value.asObjectRef()).?);
@@ -9705,10 +9708,6 @@ pub const Macro = struct {
node.updateSymbolsMap(Visitor, this.visitor);
return _entry.value_ptr.*;
},
- .ResolveMessage, .BuildMessage => {
- this.macro.vm.runErrorHandler(value, null);
- return error.MacroFailed;
- },
else => {},
}
diff --git a/src/jsc.zig b/src/jsc.zig
index 812d32482..26ad7cc5f 100644
--- a/src/jsc.zig
+++ b/src/jsc.zig
@@ -12,6 +12,8 @@ pub usingnamespace @import("./bun.js/javascript.zig");
pub usingnamespace @import("./bun.js/module_loader.zig");
pub const C = @import("./bun.js/javascript_core_c_api.zig");
pub const WebCore = @import("./bun.js/webcore.zig");
+pub const BuildMessage = @import("./bun.js/BuildMessage.zig").BuildMessage;
+pub const ResolveMessage = @import("./bun.js/ResolveMessage.zig").ResolveMessage;
pub const Cloudflare = struct {
pub const HTMLRewriter = @import("./bun.js/api/html_rewriter.zig").HTMLRewriter;
pub const ContentOptions = @import("./bun.js/api/html_rewriter.zig").ContentOptions;
diff --git a/src/logger.zig b/src/logger.zig
index 4cfa13fb9..ad7a9b333 100644
--- a/src/logger.zig
+++ b/src/logger.zig
@@ -436,8 +436,8 @@ pub const Msg = struct {
pub fn toJS(this: Msg, globalObject: *bun.JSC.JSGlobalObject, allocator: std.mem.Allocator) JSC.JSValue {
return switch (this.metadata) {
- .build => JSC.BuildMessage.create(globalObject, allocator, this).?.value(),
- .resolve => JSC.ResolveMessage.create(globalObject, allocator, this, "").?.value(),
+ .build => JSC.BuildMessage.create(globalObject, allocator, this),
+ .resolve => JSC.ResolveMessage.create(globalObject, allocator, this, ""),
};
}
@@ -720,18 +720,17 @@ pub const Log = struct {
0 => return JSC.JSValue.jsUndefined(),
1 => {
const msg = msgs[0];
- return JSC.JSValue.fromRef(JSC.BuildMessage.create(global, allocator, msg));
+ return switch (msg.metadata) {
+ .build => JSC.BuildMessage.create(global, allocator, msg),
+ .resolve => JSC.ResolveMessage.create(global, allocator, msg, ""),
+ };
},
else => {
for (msgs[0..count], 0..) |msg, i| {
- switch (msg.metadata) {
- .build => {
- errors_stack[i] = JSC.BuildMessage.create(global, allocator, msg).?;
- },
- .resolve => {
- errors_stack[i] = JSC.ResolveMessage.create(global, allocator, msg, "").?;
- },
- }
+ errors_stack[i] = switch (msg.metadata) {
+ .build => JSC.BuildMessage.create(global, allocator, msg).asVoid(),
+ .resolve => JSC.ResolveMessage.create(global, allocator, msg, "").asVoid(),
+ };
}
const out = JSC.ZigString.init(fmt);
const agg = global.createAggregateError(errors_stack[0..count].ptr, count, &out);