aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/ZigGlobalObject.h
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-05 23:05:22 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-05 23:05:22 -0700
commit11aa17a57cc679d34e8e6f6f7aa665f565cb7305 (patch)
treeccb9a605cb4bcc42c6b2665ddbf8d04af72d94c7 /src/bun.js/bindings/ZigGlobalObject.h
parentd2397b60e79e4386c6a7b7a9783a6f8e379a5ae0 (diff)
downloadbun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.tar.gz
bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.tar.zst
bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.zip
Support async `onLoad` callbacks in `Bun.plugin`
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.h')
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h
index 6c5c23b3a..160aef714 100644
--- a/src/bun.js/bindings/ZigGlobalObject.h
+++ b/src/bun.js/bindings/ZigGlobalObject.h
@@ -35,7 +35,9 @@ class EventLoopTask;
#include "BunPlugin.h"
extern "C" void Bun__reportError(JSC__JSGlobalObject*, JSC__JSValue);
-
+// defined in ModuleLoader.cpp
+extern "C" JSC::EncodedJSValue jsFunctionOnLoadObjectResultResolve(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame);
+extern "C" JSC::EncodedJSValue jsFunctionOnLoadObjectResultReject(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame);
// #include "EventTarget.h"
// namespace WebCore {
@@ -239,7 +241,10 @@ public:
Bun__HTTPRequestContextDebugTLS__onResolve,
Bun__HTTPRequestContextDebugTLS__onResolveStream,
+ jsFunctionOnLoadObjectResultResolve,
+ jsFunctionOnLoadObjectResultReject,
};
+ static constexpr size_t promiseFunctionsSize = 18;
static PromiseFunctions promiseHandlerID(EncodedJSValue (*handler)(JSC__JSGlobalObject* arg0, JSC__CallFrame* arg1))
{
@@ -275,6 +280,14 @@ public:
return PromiseFunctions::Bun__HTTPRequestContextDebugTLS__onResolve;
} else if (handler == Bun__HTTPRequestContextDebugTLS__onResolveStream) {
return PromiseFunctions::Bun__HTTPRequestContextDebugTLS__onResolveStream;
+ } else if (handler == Bun__HTTPRequestContextDebugTLS__onResolveStream) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebugTLS__onResolveStream;
+ } else if (handler == Bun__HTTPRequestContextDebugTLS__onResolveStream) {
+ return PromiseFunctions::Bun__HTTPRequestContextDebugTLS__onResolveStream;
+ } else if (handler == jsFunctionOnLoadObjectResultResolve) {
+ return PromiseFunctions::jsFunctionOnLoadObjectResultResolve;
+ } else if (handler == jsFunctionOnLoadObjectResultReject) {
+ return PromiseFunctions::jsFunctionOnLoadObjectResultReject;
} else {
RELEASE_ASSERT_NOT_REACHED();
}
@@ -300,7 +313,7 @@ public:
mutable WriteBarrier<JSFunction> m_readableStreamToJSON;
mutable WriteBarrier<JSFunction> m_readableStreamToArrayBuffer;
mutable WriteBarrier<JSFunction> m_assignToStream;
- mutable WriteBarrier<JSFunction> m_thenables[16];
+ mutable WriteBarrier<JSFunction> m_thenables[promiseFunctionsSize + 1];
void trackFFIFunction(JSC::JSFunction* function)
{
@@ -311,6 +324,8 @@ public:
BunPlugin::OnResolve onResolvePlugins[BunPluginTargetMax + 1] {};
BunPluginTarget defaultBunPluginTarget = BunPluginTargetBun;
+ JSC::Structure* pendingVirtualModuleResultStructure() { return m_pendingVirtualModuleResultStructure.get(this); }
+
// When a napi module initializes on dlopen, we need to know what the value is
JSValue pendingNapiModule = JSValue {};
@@ -344,6 +359,8 @@ private:
LazyProperty<JSGlobalObject, JSMap> m_requireMap;
LazyProperty<JSGlobalObject, JSObject> m_performanceObject;
+ LazyProperty<JSGlobalObject, JSC::Structure> m_pendingVirtualModuleResultStructure;
+
LazyProperty<JSGlobalObject, JSObject> m_encodeIntoObjectPrototype;
// LazyProperty<JSGlobalObject, WebCore::JSEventTarget> m_eventTarget;