diff options
author | 2022-09-05 23:05:22 -0700 | |
---|---|---|
committer | 2022-09-05 23:05:22 -0700 | |
commit | 11aa17a57cc679d34e8e6f6f7aa665f565cb7305 (patch) | |
tree | ccb9a605cb4bcc42c6b2665ddbf8d04af72d94c7 /src/bun.js/modules/EventsModule.h | |
parent | d2397b60e79e4386c6a7b7a9783a6f8e379a5ae0 (diff) | |
download | bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.tar.gz bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.tar.zst bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.zip |
Support async `onLoad` callbacks in `Bun.plugin`
Diffstat (limited to 'src/bun.js/modules/EventsModule.h')
-rw-r--r-- | src/bun.js/modules/EventsModule.h | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/src/bun.js/modules/EventsModule.h b/src/bun.js/modules/EventsModule.h index 5adb19d01..d1e14a2db 100644 --- a/src/bun.js/modules/EventsModule.h +++ b/src/bun.js/modules/EventsModule.h @@ -1,27 +1,36 @@ -#include "../bindings/ZigGlobalObject.h" #include "JavaScriptCore/JSGlobalObject.h" +#include "ZigGlobalObject.h" namespace Zig { +using namespace WebCore; +inline void generateEventsSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, + JSC::Identifier moduleKey, + Vector<JSC::Identifier, 4> &exportNames, + JSC::MarkedArgumentBuffer &exportValues) { + JSC::VM &vm = lexicalGlobalObject->vm(); + GlobalObject *globalObject = + reinterpret_cast<GlobalObject *>(lexicalGlobalObject); -inline void generateEventsSourceCode(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector<JSC::Identifier, 4>& exportNames, JSC::MarkedArgumentBuffer& exportValues) { - JSC::VM& vm = lexicalGlobalObject->vm(); - GlobalObject* globalObject = reinterpret_cast<GlobalObject*>(lexicalGlobalObject); + exportNames.append(JSC::Identifier::fromString(vm, "EventEmitter"_s)); + exportValues.append( + WebCore::JSEventEmitter::getConstructor(vm, globalObject)); - exportNames.append(JSC::Identifier::fromString(vm, "EventEmitter"_s)); - exportValues.append(WebCore::JSEventEmitter::getConstructor(vm, globalObject)); - - exportNames.append(JSC::Identifier::fromString(vm, "getEventListeners"_s)); - exportValues.append(JSC::JSFunction::create(vm, lexicalGlobalObject, 0, - MAKE_STATIC_STRING_IMPL("getEventListeners"), Events_functionGetEventListeners, ImplementationVisibility::Public)); - exportNames.append(JSC::Identifier::fromString(vm, "listenerCount"_s)); - exportValues.append(JSC::JSFunction::create(vm, lexicalGlobalObject, 0, - MAKE_STATIC_STRING_IMPL("listenerCount"), Events_functionListenerCount, ImplementationVisibility::Public)); - exportNames.append(JSC::Identifier::fromString(vm, "once"_s)); - exportValues.append(JSC::JSFunction::create(vm, lexicalGlobalObject, 0, - MAKE_STATIC_STRING_IMPL("once"), Events_functionOnce, ImplementationVisibility::Public)); - exportNames.append(JSC::Identifier::fromString(vm, "on"_s)); - exportValues.append(JSC::JSFunction::create(vm, lexicalGlobalObject, 0, - MAKE_STATIC_STRING_IMPL("on"), Events_functionOn, ImplementationVisibility::Public)); + exportNames.append(JSC::Identifier::fromString(vm, "getEventListeners"_s)); + exportValues.append(JSC::JSFunction::create( + vm, lexicalGlobalObject, 0, MAKE_STATIC_STRING_IMPL("getEventListeners"), + Events_functionGetEventListeners, ImplementationVisibility::Public)); + exportNames.append(JSC::Identifier::fromString(vm, "listenerCount"_s)); + exportValues.append(JSC::JSFunction::create( + vm, lexicalGlobalObject, 0, MAKE_STATIC_STRING_IMPL("listenerCount"), + Events_functionListenerCount, ImplementationVisibility::Public)); + exportNames.append(JSC::Identifier::fromString(vm, "once"_s)); + exportValues.append(JSC::JSFunction::create( + vm, lexicalGlobalObject, 0, MAKE_STATIC_STRING_IMPL("once"), + Events_functionOnce, ImplementationVisibility::Public)); + exportNames.append(JSC::Identifier::fromString(vm, "on"_s)); + exportValues.append(JSC::JSFunction::create( + vm, lexicalGlobalObject, 0, MAKE_STATIC_STRING_IMPL("on"), + Events_functionOn, ImplementationVisibility::Public)); } -} +} // namespace Zig |