diff options
author | 2023-06-07 19:03:11 -0700 | |
---|---|---|
committer | 2023-06-07 19:03:11 -0700 | |
commit | 7a443f72b525f5e80ecccb581fc02eadd1d4c6a9 (patch) | |
tree | cb0f4c1beb99635ca4e528c17068f2a0d10eff05 | |
parent | 4f2095d1c64467f190ac4f35209ff663bf34f39a (diff) | |
download | bun-7a443f72b525f5e80ecccb581fc02eadd1d4c6a9.tar.gz bun-7a443f72b525f5e80ecccb581fc02eadd1d4c6a9.tar.zst bun-7a443f72b525f5e80ecccb581fc02eadd1d4c6a9.zip |
Attempt to add plugindataplugin/plugindata
-rw-r--r-- | packages/bun-types/bun.d.ts | 8 | ||||
-rw-r--r-- | src/bun.js/api/JSBundler.zig | 34 | ||||
-rw-r--r-- | src/bun.js/api/server.zig | 1 | ||||
-rw-r--r-- | src/bun.js/bindings/JSBundlerPlugin.cpp | 5 | ||||
-rw-r--r-- | src/bundler/bundle_v2.zig | 23 | ||||
-rw-r--r-- | src/js/builtins/BundlerPlugin.ts | 18 | ||||
-rw-r--r-- | src/js/out/WebCoreJSBuiltins.cpp | 8 | ||||
-rw-r--r-- | src/js/out/WebCoreJSBuiltins.h | 2 |
8 files changed, 58 insertions, 41 deletions
diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 633570909..19c1abb25 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -2913,6 +2913,10 @@ declare module "bun" { * The default loader for this file extension */ loader: Loader; + /** + * Contextual data passed down from the `onResolve` callback that resolved this module + */ + pluginData: any; } type OnLoadResult = OnLoadResultSourceCode | OnLoadResultObject; @@ -2959,6 +2963,10 @@ declare module "bun" { */ namespace?: string; external?: boolean; + /** + * Data to pass to the `onLoad` callback + */ + pluginData?: any; } type OnResolveCallback = ( diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig index 21003eabf..4ddb46f7f 100644 --- a/src/bun.js/api/JSBundler.zig +++ b/src/bun.js/api/JSBundler.zig @@ -598,10 +598,12 @@ pub const JSBundler = struct { path: []const u8 = "", namespace: []const u8 = "", external: bool = false, + plugin_data: JSValue = JSC.JSValue.jsUndefined(), pub fn deinit(this: *@This()) void { bun.default_allocator.destroy(this.path); bun.default_allocator.destroy(this.namespace); + // bun.default_allocator.destroy(this.plugin_data); } }, no_match: void, @@ -679,6 +681,7 @@ pub const JSBundler = struct { path_value: JSValue, namespace_value: JSValue, external_value: JSValue, + plugin_data_value: JSValue, ) void { var completion = this.completion orelse { this.deinit(); @@ -689,11 +692,14 @@ pub const JSBundler = struct { } else { const path = path_value.toSliceCloneWithAllocator(completion.globalThis, bun.default_allocator) orelse @panic("Unexpected: path is not a string"); const namespace = namespace_value.toSliceCloneWithAllocator(completion.globalThis, bun.default_allocator) orelse @panic("Unexpected: namespace is not a string"); + std.debug.print("got plugin data", .{}); + const plugin_data = plugin_data_value; //.toObject(completion.globalThis).*; // orelse @panic("Unexpected: plugin_data is not an object"); this.value = .{ .success = .{ .path = path.slice(), .namespace = namespace.slice(), .external = external_value.to(bool), + .plugin_data = plugin_data, }, }; } @@ -711,6 +717,7 @@ pub const JSBundler = struct { default_loader: options.Loader, path: []const u8 = "", namespace: []const u8 = "", + plugin_data: JSValue = JSC.JSValue.jsUndefined(), /// Null means the task was aborted. completion: ?*bun.BundleV2.JSBundleCompletionTask = null, @@ -723,12 +730,7 @@ pub const JSBundler = struct { /// Faster path: skip the extra threadpool dispatch when the file is not found was_file: bool = false, - pub fn create( - completion: *bun.BundleV2.JSBundleCompletionTask, - source_index: Index, - default_loader: options.Loader, - path: Fs.Path, - ) Load { + pub fn create(completion: *bun.BundleV2.JSBundleCompletionTask, source_index: Index, default_loader: options.Loader, path: Fs.Path, plugin_data: ?JSValue) Load { completion.ref(); return Load{ .source_index = source_index, @@ -737,6 +739,7 @@ pub const JSBundler = struct { .value = .{ .pending = {} }, .path = path.text, .namespace = path.namespace, + .plugin_data = plugin_data orelse JSValue.undefined, }; } @@ -772,6 +775,11 @@ pub const JSBundler = struct { pub fn deinit(this: *Load) void { this.value.deinit(); + // seems like a reasonable place to free idk + // if (this.plugin_data != JSValue.undefined) { + // bun.default_allocator.free(this.plugin_data); + // } + if (this.completion) |completion| completion.deref(); } @@ -790,6 +798,7 @@ pub const JSBundler = struct { this.namespace, this, this.default_loader, + this.plugin_data, ); } @@ -876,14 +885,7 @@ pub const JSBundler = struct { bool, ) bool; - extern fn JSBundlerPlugin__matchOnLoad( - *JSC.JSGlobalObject, - *Plugin, - namespaceString: *const ZigString, - path: *const ZigString, - context: *anyopaque, - u8, - ) void; + extern fn JSBundlerPlugin__matchOnLoad(*JSC.JSGlobalObject, *Plugin, namespaceString: *const ZigString, path: *const ZigString, context: *anyopaque, u8, pluginData: *const JSValue) void; extern fn JSBundlerPlugin__matchOnResolve( *JSC.JSGlobalObject, @@ -920,6 +922,7 @@ pub const JSBundler = struct { namespace: []const u8, context: *anyopaque, default_loader: options.Loader, + plugin_data: JSValue, ) void { JSC.markBinding(@src()); const tracer = bun.tracy.traceNamed(@src(), "JSBundler.matchOnLoad"); @@ -929,7 +932,8 @@ pub const JSBundler = struct { else ZigString.fromUTF8(namespace); const path_string = ZigString.fromUTF8(path); - JSBundlerPlugin__matchOnLoad(globalThis, this, &namespace_string, &path_string, context, @enumToInt(default_loader)); + std.debug.print("matchonload\n", .{}); + JSBundlerPlugin__matchOnLoad(globalThis, this, &namespace_string, &path_string, context, @enumToInt(default_loader), &plugin_data); } pub fn matchOnResolve( diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 30889964d..1554ee886 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -5224,6 +5224,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { } pub fn listen(this: *ThisServer) void { + JSC.markBinding(@src()); httplog("listen", .{}); if (ssl_enabled) { BoringSSL.load(); diff --git a/src/bun.js/bindings/JSBundlerPlugin.cpp b/src/bun.js/bindings/JSBundlerPlugin.cpp index de936ab05..7bb4b0478 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.cpp +++ b/src/bun.js/bindings/JSBundlerPlugin.cpp @@ -279,10 +279,12 @@ extern "C" bool JSBundlerPlugin__anyMatches(Bun::JSBundlerPlugin* pluginObject, return pluginObject->plugin.anyMatchesCrossThread(pluginObject->vm(), namespaceString, path, isOnLoad); } -extern "C" void JSBundlerPlugin__matchOnLoad(JSC::JSGlobalObject* globalObject, Bun::JSBundlerPlugin* plugin, const ZigString* namespaceString, const ZigString* path, void* context, uint8_t defaultLoaderId) +extern "C" void JSBundlerPlugin__matchOnLoad(JSC::JSGlobalObject* globalObject, Bun::JSBundlerPlugin* plugin, const ZigString* namespaceString, const ZigString* path, void* context, uint8_t defaultLoaderId, JSValue* pluginData) { WTF::String namespaceStringStr = namespaceString ? Zig::toStringCopy(*namespaceString) : WTF::String(); WTF::String pathStr = path ? Zig::toStringCopy(*path) : WTF::String(); + // get value from pointer + JSValue pluginDataValue = *pluginData; JSFunction* function = plugin->onLoadFunction.get(plugin); if (UNLIKELY(!function)) @@ -299,6 +301,7 @@ extern "C" void JSBundlerPlugin__matchOnLoad(JSC::JSGlobalObject* globalObject, arguments.append(JSC::jsString(plugin->vm(), pathStr)); arguments.append(JSC::jsString(plugin->vm(), namespaceStringStr)); arguments.append(JSC::jsNumber(defaultLoaderId)); + arguments.append(pluginDataValue); auto result = call(globalObject, function, callData, plugin, arguments); diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index c62be6153..5c33ca9db 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -603,7 +603,7 @@ pub const BundleV2 = struct { _ = @atomicRmw(usize, &this.graph.parse_pending, .Add, 1, .Monotonic); // Handle onLoad plugins - if (!this.enqueueOnLoadPluginIfNeeded(task)) { + if (!this.enqueueOnLoadPluginIfNeeded(task, bun.JSC.JSValue.jsUndefined())) { if (loader.shouldCopyForBundling()) { var additional_files: *BabyList(AdditionalFile) = &this.graph.input_files.items(.additional_files)[source_index.get()]; additional_files.push(this.graph.allocator, .{ .source_index = task.source_index.get() }) catch unreachable; @@ -670,7 +670,7 @@ pub const BundleV2 = struct { task.tree_shaking = this.linker.options.tree_shaking; // Handle onLoad plugins as entry points - if (!this.enqueueOnLoadPluginIfNeeded(task)) { + if (!this.enqueueOnLoadPluginIfNeeded(task, bun.JSC.JSValue.jsUndefined())) { if (loader.shouldCopyForBundling()) { var additional_files: *BabyList(AdditionalFile) = &this.graph.input_files.items(.additional_files)[source_index.get()]; additional_files.push(this.graph.allocator, .{ .source_index = task.source_index.get() }) catch unreachable; @@ -1476,7 +1476,8 @@ pub const BundleV2 = struct { _ = @atomicRmw(usize, &this.graph.parse_pending, .Add, 1, .Monotonic); // Handle onLoad plugins - if (!this.enqueueOnLoadPluginIfNeeded(task)) { + std.debug.print("enqueueOnLoadPluginIfNeeded", .{}); + if (!this.enqueueOnLoadPluginIfNeeded(task, result.plugin_data)) { if (loader.shouldCopyForBundling()) { var additional_files: *BabyList(AdditionalFile) = &this.graph.input_files.items(.additional_files)[source_index.get()]; additional_files.push(this.graph.allocator, .{ .source_index = task.source_index.get() }) catch unreachable; @@ -1774,7 +1775,11 @@ pub const BundleV2 = struct { return false; } - pub fn enqueueOnLoadPluginIfNeeded(this: *BundleV2, parse: *ParseTask) bool { + pub fn enqueueOnLoadPluginIfNeeded( + this: *BundleV2, + parse: *ParseTask, + plugin_data: JSC.JSValue, + ) bool { if (this.plugins) |plugins| { if (plugins.hasAnyMatches(&parse.path, true)) { // This is where onLoad plugins are enqueued @@ -1783,12 +1788,8 @@ pub const BundleV2 = struct { parse.path.text, }); var load = bun.default_allocator.create(JSC.API.JSBundler.Load) catch unreachable; - load.* = JSC.API.JSBundler.Load.create( - this.completion.?, - parse.source_index, - parse.path.loader(&this.bundler.options.loaders) orelse options.Loader.js, - parse.path, - ); + std.debug.print("Load.create", .{}); + load.* = JSC.API.JSBundler.Load.create(this.completion.?, parse.source_index, parse.path.loader(&this.bundler.options.loaders) orelse options.Loader.js, parse.path, plugin_data); load.parse_task = parse; load.dispatch(); return true; @@ -2164,7 +2165,7 @@ pub const BundleV2 = struct { graph.ast.append(bun.default_allocator, JSAst.empty) catch unreachable; diff += 1; - if (this.enqueueOnLoadPluginIfNeeded(new_task)) { + if (this.enqueueOnLoadPluginIfNeeded(new_task, bun.JSC.JSValue.jsUndefined())) { continue; } diff --git a/src/js/builtins/BundlerPlugin.ts b/src/js/builtins/BundlerPlugin.ts index 36dfba61b..8f25c1e57 100644 --- a/src/js/builtins/BundlerPlugin.ts +++ b/src/js/builtins/BundlerPlugin.ts @@ -21,7 +21,7 @@ interface BundlerPlugin { sourceCode: string | Uint8Array | ArrayBuffer | DataView | null, loaderKey: number | null, ): void; - onResolveAsync(internalID, a, b, c): void; + onResolveAsync(internalID, a, b, c, d): void; addError(internalID, error, number): void; addFilter(filter, namespace, number): void; } @@ -205,7 +205,7 @@ export function runOnResolvePlugins( var { onResolve, onLoad } = this; var results = onResolve.$get(inputNamespace); if (!results) { - this.onResolveAsync(internalID, null, null, null); + this.onResolveAsync(internalID, null, null, null, null); return null; } @@ -236,7 +236,7 @@ export function runOnResolvePlugins( continue; } - var { path, namespace: userNamespace = inputNamespace, external } = result; + var { path, namespace: userNamespace = inputNamespace, external, pluginData } = result; if (!(typeof path === "string")) { throw new TypeError("onResolve: expected 'path' to be a string"); } @@ -276,12 +276,12 @@ export function runOnResolvePlugins( throw new TypeError(`Expected onLoad plugin for namespace ${userNamespace} to exist`); } } - this.onResolveAsync(internalID, path, userNamespace, external); + this.onResolveAsync(internalID, path, userNamespace, external, pluginData); return null; } } - this.onResolveAsync(internalID, null, null, null); + this.onResolveAsync(internalID, null, null, null, null); return null; })(specifier, inputNamespace, importer, kind, resolveDir); @@ -303,11 +303,11 @@ export function runOnResolvePlugins( } } -export function runOnLoadPlugins(this: BundlerPlugin, internalID, path, namespace, defaultLoaderId) { +export function runOnLoadPlugins(this: BundlerPlugin, internalID, path, namespace, defaultLoaderId, pluginData) { const LOADERS_MAP = $LoaderLabelToId; const loaderName = $LoaderIdToLabel[defaultLoaderId]; - var promiseResult = (async (internalID, path, namespace, defaultLoader) => { + var promiseResult = (async (internalID, path, namespace, defaultLoader, pluginData) => { var results = this.onLoad.$get(namespace); if (!results) { this.onLoadAsync(internalID, null, null); @@ -320,7 +320,7 @@ export function runOnLoadPlugins(this: BundlerPlugin, internalID, path, namespac path, namespace, // suffix - // pluginData + pluginData, loader: defaultLoader, }); @@ -364,7 +364,7 @@ export function runOnLoadPlugins(this: BundlerPlugin, internalID, path, namespac this.onLoadAsync(internalID, null, null); return null; - })(internalID, path, namespace, loaderName); + })(internalID, path, namespace, loaderName, pluginData); while ( promiseResult && diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index 4a35b04ee..b3bc96e1c 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -22,17 +22,17 @@ const char* const s_bundlerPluginRunSetupFunctionCode = "(function (_,E){\"use s const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_bundlerPluginRunOnResolvePluginsCodeLength = 1732; +const int s_bundlerPluginRunOnResolvePluginsCodeLength = 1757; static const JSC::Intrinsic s_bundlerPluginRunOnResolvePluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (_,g,y,F,j,q){\"use strict\";const w=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][j];var z=(async(A,B,C,E,G)=>{var{onResolve:H,onLoad:J}=this,K=H.@get(B);if(!K)return this.onResolveAsync(F,null,null,null),null;for(let[T,U]of K)if(T.test(A)){var M=U({path:A,importer:C,namespace:B,resolveDir:G,kind:E});while(M&&@isPromise(M)&&(@getPromiseInternalField(M,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)M=@getPromiseInternalField(M,@promiseFieldReactionsOrResult);if(M&&@isPromise(M))M=await M;if(!M||!@isObject(M))continue;var{path:O,namespace:Q=B,external:S}=M;if(typeof O!==\"string\")@throwTypeError(\"onResolve: expected 'path' to be a string\");if(typeof Q!==\"string\")@throwTypeError(\"onResolve: expected 'namespace' to be a string\");if(!O)continue;if(!Q)Q=B;if(typeof S!==\"boolean\"&&!@isUndefinedOrNull(S))@throwTypeError(\"onResolve: expected 'external' to be boolean\");if(!S){if(Q===\"file\"){if(darwin!==\"win32\"){if(O[0]!==\"/\"||O.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(Q===\"dataurl\"){if(!O.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(Q&&Q!==\"file\"&&(!J||!J.@has(Q)))@throwTypeError(`Expected onLoad plugin for namespace ${Q} to exist`)}return this.onResolveAsync(F,O,Q,S),null}return this.onResolveAsync(F,null,null,null),null})(_,g,y,w,q);while(z&&@isPromise(z)&&(@getPromiseInternalField(z,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)z=@getPromiseInternalField(z,@promiseFieldReactionsOrResult);if(z&&@isPromise(z))z.then(()=>{},(A)=>{this.addError(F,A,0)})})\n"; +const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (_,y,w,j,q,z){\"use strict\";const A=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][q];var B=(async(C,E,F,G,H)=>{var{onResolve:J,onLoad:K}=this,M=J.@get(E);if(!M)return this.onResolveAsync(j,null,null,null,null),null;for(let[V,W]of M)if(V.test(C)){var O=W({path:C,importer:F,namespace:E,resolveDir:H,kind:G});while(O&&@isPromise(O)&&(@getPromiseInternalField(O,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)O=@getPromiseInternalField(O,@promiseFieldReactionsOrResult);if(O&&@isPromise(O))O=await O;if(!O||!@isObject(O))continue;var{path:Q,namespace:S=E,external:T,pluginData:U}=O;if(typeof Q!==\"string\")@throwTypeError(\"onResolve: expected 'path' to be a string\");if(typeof S!==\"string\")@throwTypeError(\"onResolve: expected 'namespace' to be a string\");if(!Q)continue;if(!S)S=E;if(typeof T!==\"boolean\"&&!@isUndefinedOrNull(T))@throwTypeError(\"onResolve: expected 'external' to be boolean\");if(!T){if(S===\"file\"){if(darwin!==\"win32\"){if(Q[0]!==\"/\"||Q.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(S===\"dataurl\"){if(!Q.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(S&&S!==\"file\"&&(!K||!K.@has(S)))@throwTypeError(`Expected onLoad plugin for namespace ${S} to exist`)}return this.onResolveAsync(j,Q,S,T,U),null}return this.onResolveAsync(j,null,null,null,null),null})(_,y,w,A,z);while(B&&@isPromise(B)&&(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)B=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);if(B&&@isPromise(B))B.then(()=>{},(C)=>{this.addError(j,C,0)})})\n"; // runOnLoadPlugins const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; +const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1344; static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (w,y,_,g){\"use strict\";const j={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},q=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][g];var v=(async(x,z,B,C)=>{var F=this.onLoad.@get(B);if(!F)return this.onLoadAsync(x,null,null),null;for(let[K,P]of F)if(K.test(z)){var G=P({path:z,namespace:B,loader:C});while(G&&@isPromise(G)&&(@getPromiseInternalField(G,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)G=@getPromiseInternalField(G,@promiseFieldReactionsOrResult);if(G&&@isPromise(G))G=await G;if(!G||!@isObject(G))continue;var{contents:H,loader:J=C}=G;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const Q=j[J];if(Q===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(x,H,Q),null}return this.onLoadAsync(x,null,null),null})(w,y,_,q);while(v&&@isPromise(v)&&(@getPromiseInternalField(v,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)v=@getPromiseInternalField(v,@promiseFieldReactionsOrResult);if(v&&@isPromise(v))v.then(()=>{},(x)=>{this.addError(w,x,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (j,T,_,b,q){\"use strict\";const v={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},w=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][b];var x=(async(y,z,B,C,F)=>{var G=this.onLoad.@get(B);if(!G)return this.onLoadAsync(y,null,null),null;for(let[P,Q]of G)if(P.test(z)){var H=Q({path:z,namespace:B,pluginData:F,loader:C});while(H&&@isPromise(H)&&(@getPromiseInternalField(H,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)H=@getPromiseInternalField(H,@promiseFieldReactionsOrResult);if(H&&@isPromise(H))H=await H;if(!H||!@isObject(H))continue;var{contents:J,loader:K=C}=H;if(typeof J!==\"string\"&&!@isTypedArrayView(J))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof K!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const S=v[K];if(S===@undefined)@throwTypeError(`Loader ${K} is not supported.`);return this.onLoadAsync(y,J,S),null}return this.onLoadAsync(y,null,null),null})(j,T,_,w,q);while(x&&@isPromise(x)&&(@getPromiseInternalField(x,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)x=@getPromiseInternalField(x,@promiseFieldReactionsOrResult);if(x&&@isPromise(x))x.then(()=>{},(y)=>{this.addError(j,y,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/src/js/out/WebCoreJSBuiltins.h b/src/js/out/WebCoreJSBuiltins.h index d40c09922..70ae72ed8 100644 --- a/src/js/out/WebCoreJSBuiltins.h +++ b/src/js/out/WebCoreJSBuiltins.h @@ -43,7 +43,7 @@ extern const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeIm #define WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_DATA(macro) \ macro(runSetupFunction, bundlerPluginRunSetupFunction, 2) \ macro(runOnResolvePlugins, bundlerPluginRunOnResolvePlugins, 7) \ - macro(runOnLoadPlugins, bundlerPluginRunOnLoadPlugins, 4) \ + macro(runOnLoadPlugins, bundlerPluginRunOnLoadPlugins, 5) \ #define WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_CODE(macro) \ macro(bundlerPluginRunSetupFunctionCode, runSetupFunction, ASCIILiteral(), s_bundlerPluginRunSetupFunctionCodeLength) \ |