diff options
Diffstat (limited to 'src/bun.js/bindings')
8 files changed, 217 insertions, 3 deletions
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h index 3c3aa5669..5347e037b 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h @@ -21,7 +21,8 @@ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectStringMatching; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFFI; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFSWatcher; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouter; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouterConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTMLRewriter; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouterConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForH2FrameParser; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForH2FrameParserConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTMLRewriter; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTMLRewriterConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTTPSServer; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForHTTPServer; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForListener; diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h index a521090c0..db9036b98 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h @@ -21,7 +21,8 @@ std::unique_ptr<IsoSubspace> m_subspaceForExpectStringMatching; std::unique_ptr<IsoSubspace> m_subspaceForFFI; std::unique_ptr<IsoSubspace> m_subspaceForFSWatcher; std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouter; -std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouterConstructor;std::unique_ptr<IsoSubspace> m_subspaceForHTMLRewriter; +std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouterConstructor;std::unique_ptr<IsoSubspace> m_subspaceForH2FrameParser; +std::unique_ptr<IsoSubspace> m_subspaceForH2FrameParserConstructor;std::unique_ptr<IsoSubspace> m_subspaceForHTMLRewriter; std::unique_ptr<IsoSubspace> m_subspaceForHTMLRewriterConstructor;std::unique_ptr<IsoSubspace> m_subspaceForHTTPSServer; std::unique_ptr<IsoSubspace> m_subspaceForHTTPServer; std::unique_ptr<IsoSubspace> m_subspaceForListener; diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h index 0596372b4..2dc660f5b 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h @@ -136,6 +136,12 @@ JSC::Structure* JSFileSystemRouterStructure() { return m_JSFileSystemRouter.getI JSC::LazyClassStructure m_JSFileSystemRouter; bool hasJSFileSystemRouterSetterValue { false }; mutable JSC::WriteBarrier<JSC::Unknown> m_JSFileSystemRouterSetterValue; +JSC::Structure* JSH2FrameParserStructure() { return m_JSH2FrameParser.getInitializedOnMainThread(this); } + JSC::JSObject* JSH2FrameParserConstructor() { return m_JSH2FrameParser.constructorInitializedOnMainThread(this); } + JSC::JSValue JSH2FrameParserPrototype() { return m_JSH2FrameParser.prototypeInitializedOnMainThread(this); } + JSC::LazyClassStructure m_JSH2FrameParser; + bool hasJSH2FrameParserSetterValue { false }; + mutable JSC::WriteBarrier<JSC::Unknown> m_JSH2FrameParserSetterValue; JSC::Structure* JSHTMLRewriterStructure() { return m_JSHTMLRewriter.getInitializedOnMainThread(this); } JSC::JSObject* JSHTMLRewriterConstructor() { return m_JSHTMLRewriter.constructorInitializedOnMainThread(this); } JSC::JSValue JSHTMLRewriterPrototype() { return m_JSHTMLRewriter.prototypeInitializedOnMainThread(this); } diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h index 40a473727..1ff623c44 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h @@ -137,6 +137,12 @@ void GlobalObject::initGeneratedLazyClasses() { init.setStructure(WebCore::JSFileSystemRouter::createStructure(init.vm, init.global, init.prototype)); init.setConstructor(WebCore::JSFileSystemRouter::createConstructor(init.vm, init.global, init.prototype)); }); + m_JSH2FrameParser.initLater( + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSH2FrameParser::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSH2FrameParser::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSH2FrameParser::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSHTMLRewriter.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSHTMLRewriter::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); @@ -320,6 +326,7 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor& thisObject->m_JSFFI.visit(visitor); visitor.append(thisObject->m_JSFFISetterValue); thisObject->m_JSFSWatcher.visit(visitor); visitor.append(thisObject->m_JSFSWatcherSetterValue); thisObject->m_JSFileSystemRouter.visit(visitor); visitor.append(thisObject->m_JSFileSystemRouterSetterValue); + thisObject->m_JSH2FrameParser.visit(visitor); visitor.append(thisObject->m_JSH2FrameParserSetterValue); thisObject->m_JSHTMLRewriter.visit(visitor); visitor.append(thisObject->m_JSHTMLRewriterSetterValue); thisObject->m_JSHTTPSServer.visit(visitor); visitor.append(thisObject->m_JSHTTPSServerSetterValue); thisObject->m_JSHTTPServer.visit(visitor); visitor.append(thisObject->m_JSHTTPServerSetterValue); diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp index 376260383..86a1b3366 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.cpp +++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp @@ -11052,14 +11052,30 @@ extern "C" void H2FrameParserClass__finalize(void*); extern "C" EncodedJSValue H2FrameParserPrototype__detach(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(H2FrameParserPrototype__detachCallback); +extern "C" EncodedJSValue H2FrameParserPrototype__goaway(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(H2FrameParserPrototype__goawayCallback); + +extern "C" EncodedJSValue H2FrameParserPrototype__ping(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(H2FrameParserPrototype__pingCallback); + extern "C" EncodedJSValue H2FrameParserPrototype__read(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(H2FrameParserPrototype__readCallback); +extern "C" EncodedJSValue H2FrameParserPrototype__request(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(H2FrameParserPrototype__requestCallback); + +extern "C" EncodedJSValue H2FrameParserPrototype__updateSettings(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(H2FrameParserPrototype__settingsCallback); + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSH2FrameParserPrototype, JSH2FrameParserPrototype::Base); static const HashTableValue JSH2FrameParserPrototypeTableValues[] = { { "detach"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, H2FrameParserPrototype__detachCallback, 0 } }, - { "read"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, H2FrameParserPrototype__readCallback, 1 } } + { "goaway"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, H2FrameParserPrototype__goawayCallback, 3 } }, + { "ping"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, H2FrameParserPrototype__pingCallback, 0 } }, + { "read"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, H2FrameParserPrototype__readCallback, 1 } }, + { "request"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, H2FrameParserPrototype__requestCallback, 2 } }, + { "settings"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, H2FrameParserPrototype__settingsCallback, 1 } } }; const ClassInfo JSH2FrameParserPrototype::s_info = { "H2FrameParser"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSH2FrameParserPrototype) }; @@ -11104,6 +11120,62 @@ JSC_DEFINE_HOST_FUNCTION(H2FrameParserPrototype__detachCallback, (JSGlobalObject return H2FrameParserPrototype__detach(thisObject->wrapped(), lexicalGlobalObject, callFrame); } +JSC_DEFINE_HOST_FUNCTION(H2FrameParserPrototype__goawayCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSH2FrameParser* thisObject = jsDynamicCast<JSH2FrameParser*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof H2FrameParser"_s); + return JSValue::encode({}); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + +#ifdef BUN_DEBUG + /** View the file name of the JS file that called this function + * from a debugger */ + SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); + const char* fileName = sourceOrigin.string().utf8().data(); + static const char* lastFileName = nullptr; + if (lastFileName != fileName) { + lastFileName = fileName; + } +#endif + + return H2FrameParserPrototype__goaway(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + +JSC_DEFINE_HOST_FUNCTION(H2FrameParserPrototype__pingCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSH2FrameParser* thisObject = jsDynamicCast<JSH2FrameParser*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof H2FrameParser"_s); + return JSValue::encode({}); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + +#ifdef BUN_DEBUG + /** View the file name of the JS file that called this function + * from a debugger */ + SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); + const char* fileName = sourceOrigin.string().utf8().data(); + static const char* lastFileName = nullptr; + if (lastFileName != fileName) { + lastFileName = fileName; + } +#endif + + return H2FrameParserPrototype__ping(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + JSC_DEFINE_HOST_FUNCTION(H2FrameParserPrototype__readCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { auto& vm = lexicalGlobalObject->vm(); @@ -11132,6 +11204,62 @@ JSC_DEFINE_HOST_FUNCTION(H2FrameParserPrototype__readCallback, (JSGlobalObject * return H2FrameParserPrototype__read(thisObject->wrapped(), lexicalGlobalObject, callFrame); } +JSC_DEFINE_HOST_FUNCTION(H2FrameParserPrototype__requestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSH2FrameParser* thisObject = jsDynamicCast<JSH2FrameParser*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof H2FrameParser"_s); + return JSValue::encode({}); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + +#ifdef BUN_DEBUG + /** View the file name of the JS file that called this function + * from a debugger */ + SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); + const char* fileName = sourceOrigin.string().utf8().data(); + static const char* lastFileName = nullptr; + if (lastFileName != fileName) { + lastFileName = fileName; + } +#endif + + return H2FrameParserPrototype__request(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + +JSC_DEFINE_HOST_FUNCTION(H2FrameParserPrototype__settingsCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSH2FrameParser* thisObject = jsDynamicCast<JSH2FrameParser*>(callFrame->thisValue()); + + if (UNLIKELY(!thisObject)) { + auto throwScope = DECLARE_THROW_SCOPE(vm); + throwVMTypeError(lexicalGlobalObject, throwScope, "Expected 'this' to be instanceof H2FrameParser"_s); + return JSValue::encode({}); + } + + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + +#ifdef BUN_DEBUG + /** View the file name of the JS file that called this function + * from a debugger */ + SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); + const char* fileName = sourceOrigin.string().utf8().data(); + static const char* lastFileName = nullptr; + if (lastFileName != fileName) { + lastFileName = fileName; + } +#endif + + return H2FrameParserPrototype__updateSettings(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + void JSH2FrameParserPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { Base::finishCreation(vm); diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h index b8b694068..6bfd65a8a 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.h +++ b/src/bun.js/bindings/ZigGeneratedClasses.h @@ -1311,6 +1311,56 @@ public: mutable JSC::WriteBarrier<JSC::Unknown> m_style; }; +class JSH2FrameParser final : public JSC::JSDestructibleObject { +public: + using Base = JSC::JSDestructibleObject; + static JSH2FrameParser* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); + + DECLARE_EXPORT_INFO; + template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<JSH2FrameParser, WebCore::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForH2FrameParser.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForH2FrameParser = std::forward<decltype(space)>(space); }, + [](auto& spaces) { return spaces.m_subspaceForH2FrameParser.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForH2FrameParser = std::forward<decltype(space)>(space); }); + } + + static void destroy(JSC::JSCell*); + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info()); + } + + static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype); + + ~JSH2FrameParser(); + + void* wrapped() const { return m_ctx; } + + void detach() + { + m_ctx = nullptr; + } + + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSH2FrameParser, m_ctx); } + + void* m_ctx { nullptr }; + + JSH2FrameParser(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) + : Base(vm, structure) + { + m_ctx = sinkPtr; + } + + void finishCreation(JSC::VM&); +}; + class JSHTMLRewriter final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 467667953..9af138b9c 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -135,6 +135,7 @@ using namespace Bun; extern "C" JSC::EncodedJSValue Bun__fetch(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); extern "C" JSC::EncodedJSValue Bun__canonicalizeIP(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +extern "C" EncodedJSValue H2FrameParser__getConstructor(Zig::GlobalObject* globalObject); using JSGlobalObject = JSC::JSGlobalObject; @@ -1640,6 +1641,14 @@ static JSC_DEFINE_HOST_FUNCTION(functionLazyLoad, if (string == "events"_s) { return JSValue::encode(WebCore::JSEventEmitter::getConstructor(vm, globalObject)); } + if(string == "internal/http2"_s) { + auto* obj = constructEmptyObject(globalObject); + + obj->putDirect( + vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "H2FrameParser"_s)), JSValue::decode(H2FrameParser__getConstructor(globalObject)), 0); + + return JSValue::encode(obj); + } if (string == "internal/tls"_s) { auto* obj = constructEmptyObject(globalObject); diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig index 7d5571ff3..6f106a1dd 100644 --- a/src/bun.js/bindings/generated_classes.zig +++ b/src/bun.js/bindings/generated_classes.zig @@ -3009,13 +3009,25 @@ pub const JSH2FrameParser = struct { if (@TypeOf(H2FrameParser.detach) != CallbackType) @compileLog("Expected H2FrameParser.detach to be a callback but received " ++ @typeName(@TypeOf(H2FrameParser.detach))); + if (@TypeOf(H2FrameParser.goaway) != CallbackType) + @compileLog("Expected H2FrameParser.goaway to be a callback but received " ++ @typeName(@TypeOf(H2FrameParser.goaway))); + if (@TypeOf(H2FrameParser.ping) != CallbackType) + @compileLog("Expected H2FrameParser.ping to be a callback but received " ++ @typeName(@TypeOf(H2FrameParser.ping))); if (@TypeOf(H2FrameParser.read) != CallbackType) @compileLog("Expected H2FrameParser.read to be a callback but received " ++ @typeName(@TypeOf(H2FrameParser.read))); + if (@TypeOf(H2FrameParser.request) != CallbackType) + @compileLog("Expected H2FrameParser.request to be a callback but received " ++ @typeName(@TypeOf(H2FrameParser.request))); + if (@TypeOf(H2FrameParser.updateSettings) != CallbackType) + @compileLog("Expected H2FrameParser.updateSettings to be a callback but received " ++ @typeName(@TypeOf(H2FrameParser.updateSettings))); if (!JSC.is_bindgen) { @export(H2FrameParser.constructor, .{ .name = "H2FrameParserClass__construct" }); @export(H2FrameParser.detach, .{ .name = "H2FrameParserPrototype__detach" }); @export(H2FrameParser.finalize, .{ .name = "H2FrameParserClass__finalize" }); + @export(H2FrameParser.goaway, .{ .name = "H2FrameParserPrototype__goaway" }); + @export(H2FrameParser.ping, .{ .name = "H2FrameParserPrototype__ping" }); @export(H2FrameParser.read, .{ .name = "H2FrameParserPrototype__read" }); + @export(H2FrameParser.request, .{ .name = "H2FrameParserPrototype__request" }); + @export(H2FrameParser.updateSettings, .{ .name = "H2FrameParserPrototype__updateSettings" }); } } }; |