mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 13:22:07 +00:00
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Ben Grant <ben@bun.sh> Co-authored-by: 190n <7763597+190n@users.noreply.github.com>
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
#include "root.h"
|
|
|
|
#include "JavaScriptCore/CallData.h"
|
|
#include <JavaScriptCore/ObjectConstructor.h>
|
|
#include "InternalModuleRegistry.h"
|
|
#include "ModuleLoader.h"
|
|
#include "ZigGlobalObject.h"
|
|
#include <JavaScriptCore/JSInternalPromise.h>
|
|
|
|
namespace Bun {
|
|
using namespace JSC;
|
|
extern "C" JSInternalPromise* Bun__loadHTMLEntryPoint(Zig::GlobalObject* globalObject)
|
|
{
|
|
auto& vm = globalObject->vm();
|
|
auto scope = DECLARE_THROW_SCOPE(vm);
|
|
JSInternalPromise* promise = JSInternalPromise::create(vm, globalObject->internalPromiseStructure());
|
|
|
|
JSValue htmlModule = globalObject->internalModuleRegistry()->requireId(globalObject, vm, InternalModuleRegistry::InternalHtml);
|
|
if (scope.exception()) [[unlikely]] {
|
|
return promise->rejectWithCaughtException(globalObject, scope);
|
|
}
|
|
|
|
JSObject* htmlModuleObject = htmlModule.getObject();
|
|
if (!htmlModuleObject) [[unlikely]] {
|
|
BUN_PANIC("Failed to load HTML entry point");
|
|
}
|
|
|
|
MarkedArgumentBuffer args;
|
|
JSValue result = JSC::call(globalObject, htmlModuleObject, args, "Failed to load HTML entry point"_s);
|
|
if (scope.exception()) [[unlikely]] {
|
|
return promise->rejectWithCaughtException(globalObject, scope);
|
|
}
|
|
|
|
promise = jsDynamicCast<JSInternalPromise*>(result);
|
|
if (!promise) [[unlikely]] {
|
|
BUN_PANIC("Failed to load HTML entry point");
|
|
}
|
|
return promise;
|
|
}
|
|
|
|
}
|