Files
bun.sh/src/bun.js/bindings/HTMLEntryPoint.cpp
Jarred Sumner 69be630aea WebKit Upgrade (#19839)
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>
2025-05-22 21:12:43 -07:00

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;
}
}