aboutsummaryrefslogtreecommitdiff
path: root/src/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'src/javascript')
-rw-r--r--src/javascript/jsc/bindings/ScriptExecutionContext.cpp74
-rw-r--r--src/javascript/jsc/bindings/ScriptExecutionContext.h10
-rw-r--r--src/javascript/jsc/bindings/headers-cpp.h2
-rw-r--r--src/javascript/jsc/bindings/headers-handwritten.h2
-rw-r--r--src/javascript/jsc/bindings/headers-replacements.zig2
-rw-r--r--src/javascript/jsc/bindings/headers.h529
-rw-r--r--src/javascript/jsc/bindings/headers.zig2
-rw-r--r--src/javascript/jsc/bindings/webcore/WebSocket.cpp219
-rw-r--r--src/javascript/jsc/bindings/webcore/WebSocket.h6
-rw-r--r--src/javascript/jsc/event_loop.zig2
10 files changed, 436 insertions, 412 deletions
diff --git a/src/javascript/jsc/bindings/ScriptExecutionContext.cpp b/src/javascript/jsc/bindings/ScriptExecutionContext.cpp
index 9c6735993..73b8b4c01 100644
--- a/src/javascript/jsc/bindings/ScriptExecutionContext.cpp
+++ b/src/javascript/jsc/bindings/ScriptExecutionContext.cpp
@@ -55,73 +55,25 @@ us_socket_context_t* ScriptExecutionContext::webSocketContextNoSSL()
}
template<bool SSL>
-static uWS::WebSocketContext<SSL, false, WebCore::WebSocket*>* registerWebSocketClientContext(ScriptExecutionContext* script, us_socket_context_t* parent)
+static us_socket_context_t* registerWebSocketClientContext(ScriptExecutionContext* script, us_socket_context_t* parent)
{
- uWS::Loop* loop = uWS::Loop::get();
- uWS::WebSocketContext<SSL, false, WebCore::WebSocket*>* ctx = uWS::WebSocketContext<SSL, false, WebCore::WebSocket*>::createClient(loop, parent);
-
- auto* opts = ctx->getExt();
-
- /* Maximum message size we can receive */
- unsigned int maxPayloadLength = 16 * 1024;
- /* 2 minutes timeout is good */
- unsigned short idleTimeout = 120;
- /* 64kb backpressure is probably good */
- unsigned int maxBackpressure = 64 * 1024;
- bool closeOnBackpressureLimit = false;
- /* This one depends on kernel timeouts and is a bad default */
- bool resetIdleTimeoutOnSend = false;
- /* A good default, esp. for newcomers */
- bool sendPingsAutomatically = false;
- /* Maximum socket lifetime in seconds before forced closure (defaults to disabled) */
- unsigned short maxLifetime = 0;
-
- opts->maxPayloadLength = maxPayloadLength;
- opts->maxBackpressure = maxBackpressure;
- opts->closeOnBackpressureLimit = closeOnBackpressureLimit;
- opts->resetIdleTimeoutOnSend = resetIdleTimeoutOnSend;
- opts->sendPingsAutomatically = sendPingsAutomatically;
- // opts->compression = compression;
- // TODO:
- opts->compression = uWS::CompressOptions::DISABLED;
-
- opts->openHandler = [](uWS::WebSocket<SSL, false, WebCore::WebSocket*>* ws) {
- WebCore::WebSocket* webSocket = *ws->getUserData();
- webSocket->didConnect();
- };
-
- opts->messageHandler = [](uWS::WebSocket<SSL, false, WebCore::WebSocket*>* ws, std::string_view input, uWS::OpCode opCode) {
- WebCore::WebSocket* webSocket = *ws->getUserData();
- if (opCode == uWS::OpCode::BINARY) {
- webSocket->didReceiveBinaryData({ const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(input.data())), input.length() });
- } else {
- webSocket->didReceiveMessage(WTF::String::fromUTF8(input.data(), input.length()));
- }
- };
-
- // pts->drainHandler = [](uWS::WebSocket<SSL, false, WebCore::WebSocket>* ws, std::string_view input, uWS::OpCode opCode) {
- // WebCore::WebSocket* webSocket = *ws->getUserData();
- // webSocket->didReceiveData(input.data(), input.length());
- // };
-
- opts->closeHandler = [](uWS::WebSocket<SSL, false, WebCore::WebSocket*>* ws, int code, std::string_view message) {
- WebCore::WebSocket* webSocket = *ws->getUserData();
- webSocket->didClose(
- ws->getBufferedAmount(),
- code,
- WTF::String::fromUTF8(
- message.data(),
- message.length()));
- };
-
- return ctx;
+ us_loop_t* loop = (us_loop_t*)uWS::Loop::get();
+ if constexpr (SSL) {
+ us_socket_context_t* child = us_create_child_socket_context(1, parent, sizeof(size_t));
+ Bun__WebSocketClientTLS__register(script->jsGlobalObject(), loop, child);
+ return child;
+ } else {
+ us_socket_context_t* child = us_create_child_socket_context(0, parent, sizeof(size_t));
+ Bun__WebSocketClient__register(script->jsGlobalObject(), loop, child);
+ return child;
+ }
}
-uWS::WebSocketContext<false, false, WebSocket*>* ScriptExecutionContext::connectedWebSocketKindClient()
+us_socket_context_t* ScriptExecutionContext::connectedWebSocketKindClient()
{
return registerWebSocketClientContext<false>(this, webSocketContextNoSSL());
}
-uWS::WebSocketContext<true, false, WebSocket*>* ScriptExecutionContext::connectedWebSocketKindClientSSL()
+us_socket_context_t* ScriptExecutionContext::connectedWebSocketKindClientSSL()
{
return registerWebSocketClientContext<true>(this, webSocketContextSSL());
}
diff --git a/src/javascript/jsc/bindings/ScriptExecutionContext.h b/src/javascript/jsc/bindings/ScriptExecutionContext.h
index ea8302356..e5644c2fc 100644
--- a/src/javascript/jsc/bindings/ScriptExecutionContext.h
+++ b/src/javascript/jsc/bindings/ScriptExecutionContext.h
@@ -118,18 +118,18 @@ private:
us_socket_context_t* webSocketContextSSL();
us_socket_context_t* webSocketContextNoSSL();
- uWS::WebSocketContext<true, false, WebSocket*>* connectedWebSocketKindClientSSL();
- uWS::WebSocketContext<false, false, WebSocket*>* connectedWebSocketKindClient();
+ us_socket_context_t* connectedWebSocketKindClientSSL();
+ us_socket_context_t* connectedWebSocketKindClient();
us_socket_context_t* m_ssl_client_websockets_ctx = nullptr;
us_socket_context_t* m_client_websockets_ctx = nullptr;
- uWS::WebSocketContext<true, false, WebSocket*>* m_connected_ssl_client_websockets_ctx = nullptr;
- uWS::WebSocketContext<false, false, WebSocket*>* m_connected_client_websockets_ctx = nullptr;
+ us_socket_context_t* m_connected_ssl_client_websockets_ctx = nullptr;
+ us_socket_context_t* m_connected_client_websockets_ctx = nullptr;
public:
template<bool isSSL, bool isServer>
- uWS::WebSocketContext<isSSL, isServer, WebSocket*>* connnectedWebSocketContext()
+ us_socket_context_t* connnectedWebSocketContext()
{
if constexpr (isSSL) {
if (!m_connected_ssl_client_websockets_ctx) {
diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h
index 8d44b538a..ebf00db91 100644
--- a/src/javascript/jsc/bindings/headers-cpp.h
+++ b/src/javascript/jsc/bindings/headers-cpp.h
@@ -1,4 +1,4 @@
-//-- AUTOGENERATED FILE -- 1655526456
+//-- AUTOGENERATED FILE -- 1655637924
// clang-format off
#pragma once
diff --git a/src/javascript/jsc/bindings/headers-handwritten.h b/src/javascript/jsc/bindings/headers-handwritten.h
index 995393b93..3f0bf5327 100644
--- a/src/javascript/jsc/bindings/headers-handwritten.h
+++ b/src/javascript/jsc/bindings/headers-handwritten.h
@@ -189,6 +189,8 @@ typedef struct StringPointer {
typedef void WebSocketHTTPClient;
typedef void WebSocketHTTPSClient;
+typedef void WebSocketClient;
+typedef void WebSocketClientTLS;
#ifdef __cplusplus
diff --git a/src/javascript/jsc/bindings/headers-replacements.zig b/src/javascript/jsc/bindings/headers-replacements.zig
index 80f3dd6dc..712a63454 100644
--- a/src/javascript/jsc/bindings/headers-replacements.zig
+++ b/src/javascript/jsc/bindings/headers-replacements.zig
@@ -68,3 +68,5 @@ pub const ArrayBufferSink = @import("../webcore/streams.zig").ArrayBufferSink;
pub const WebSocketHTTPClient = bindings.WebSocketHTTPClient;
pub const WebSocketHTTPSClient = bindings.WebSocketHTTPSClient;
+pub const WebSocketClient = bindings.WebSocketClient;
+pub const WebSocketClientTLS = bindings.WebSocketClientTLS;
diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h
index 0a23cdd2c..3db8ed275 100644
--- a/src/javascript/jsc/bindings/headers.h
+++ b/src/javascript/jsc/bindings/headers.h
@@ -1,5 +1,5 @@
// clang-format: off
-//-- AUTOGENERATED FILE -- 1655526456
+//-- AUTOGENERATED FILE -- 1655637924
#pragma once
#include <stddef.h>
@@ -7,11 +7,11 @@
#include <stdbool.h>
#ifdef __cplusplus
-#define AUTO_EXTERN_C extern "C"
-#define AUTO_EXTERN_C_ZIG extern "C" __attribute__((weak))
+ #define AUTO_EXTERN_C extern "C"
+ #define AUTO_EXTERN_C_ZIG extern "C" __attribute__((weak))
#else
-#define AUTO_EXTERN_C
-#define AUTO_EXTERN_C_ZIG __attribute__((weak))
+ #define AUTO_EXTERN_C
+ #define AUTO_EXTERN_C_ZIG __attribute__((weak))
#endif
#define ZIG_DECL AUTO_EXTERN_C_ZIG
#define CPP_DECL AUTO_EXTERN_C
@@ -26,287 +26,246 @@ typedef void* JSClassRef;
#include "JavaScriptCore/JSClassRef.h"
#endif
#include "headers-handwritten.h"
-typedef struct bJSC__SourceCode {
- unsigned char bytes[24];
-} bJSC__SourceCode;
-typedef char* bJSC__SourceCode_buf;
-typedef struct bWTF__URL {
- unsigned char bytes[40];
-} bWTF__URL;
-typedef char* bWTF__URL_buf;
-typedef struct bJSC__JSModuleRecord {
- unsigned char bytes[216];
-} bJSC__JSModuleRecord;
-typedef char* bJSC__JSModuleRecord_buf;
-typedef struct bJSC__ThrowScope {
- unsigned char bytes[8];
-} bJSC__ThrowScope;
-typedef char* bJSC__ThrowScope_buf;
-typedef struct bJSC__PropertyName {
- unsigned char bytes[8];
-} bJSC__PropertyName;
-typedef char* bJSC__PropertyName_buf;
-typedef struct bJSC__JSFunction {
- unsigned char bytes[32];
-} bJSC__JSFunction;
-typedef char* bJSC__JSFunction_buf;
-typedef struct bJSC__JSGlobalObject {
- unsigned char bytes[2312];
-} bJSC__JSGlobalObject;
-typedef char* bJSC__JSGlobalObject_buf;
-typedef struct bJSC__JSCell {
- unsigned char bytes[8];
-} bJSC__JSCell;
-typedef char* bJSC__JSCell_buf;
-typedef struct bJSC__CatchScope {
- unsigned char bytes[8];
-} bJSC__CatchScope;
-typedef char* bJSC__CatchScope_buf;
-typedef struct bWTF__String {
- unsigned char bytes[8];
-} bWTF__String;
-typedef char* bWTF__String_buf;
-typedef struct bWTF__StringView {
- unsigned char bytes[16];
-} bWTF__StringView;
-typedef char* bWTF__StringView_buf;
-typedef struct bJSC__JSModuleLoader {
- unsigned char bytes[16];
-} bJSC__JSModuleLoader;
-typedef char* bJSC__JSModuleLoader_buf;
-typedef struct bInspector__ScriptArguments {
- unsigned char bytes[32];
-} bInspector__ScriptArguments;
-typedef char* bInspector__ScriptArguments_buf;
-typedef struct bJSC__Exception {
- unsigned char bytes[40];
-} bJSC__Exception;
-typedef char* bJSC__Exception_buf;
-typedef struct bJSC__VM {
- unsigned char bytes[52168];
-} bJSC__VM;
-typedef char* bJSC__VM_buf;
-typedef struct bJSC__JSString {
- unsigned char bytes[16];
-} bJSC__JSString;
-typedef char* bJSC__JSString_buf;
-typedef struct bJSC__SourceOrigin {
- unsigned char bytes[48];
-} bJSC__SourceOrigin;
-typedef char* bJSC__SourceOrigin_buf;
-typedef struct bWTF__ExternalStringImpl {
- unsigned char bytes[40];
-} bWTF__ExternalStringImpl;
-typedef char* bWTF__ExternalStringImpl_buf;
-typedef struct bJSC__JSInternalPromise {
- unsigned char bytes[32];
-} bJSC__JSInternalPromise;
-typedef char* bJSC__JSInternalPromise_buf;
-typedef struct bWTF__StringImpl {
- unsigned char bytes[24];
-} bWTF__StringImpl;
-typedef char* bWTF__StringImpl_buf;
-typedef struct bJSC__JSPromise {
- unsigned char bytes[32];
-} bJSC__JSPromise;
-typedef char* bJSC__JSPromise_buf;
-typedef struct bJSC__JSObject {
- unsigned char bytes[16];
-} bJSC__JSObject;
-typedef char* bJSC__JSObject_buf;
-typedef struct bJSC__Identifier {
- unsigned char bytes[8];
-} bJSC__Identifier;
-typedef char* bJSC__Identifier_buf;
+ typedef struct bJSC__SourceCode { unsigned char bytes[24]; } bJSC__SourceCode;
+ typedef char* bJSC__SourceCode_buf;
+ typedef struct bWTF__URL { unsigned char bytes[40]; } bWTF__URL;
+ typedef char* bWTF__URL_buf;
+ typedef struct bJSC__JSModuleRecord { unsigned char bytes[216]; } bJSC__JSModuleRecord;
+ typedef char* bJSC__JSModuleRecord_buf;
+ typedef struct bJSC__ThrowScope { unsigned char bytes[8]; } bJSC__ThrowScope;
+ typedef char* bJSC__ThrowScope_buf;
+ typedef struct bJSC__PropertyName { unsigned char bytes[8]; } bJSC__PropertyName;
+ typedef char* bJSC__PropertyName_buf;
+ typedef struct bJSC__JSFunction { unsigned char bytes[32]; } bJSC__JSFunction;
+ typedef char* bJSC__JSFunction_buf;
+ typedef struct bJSC__JSGlobalObject { unsigned char bytes[2312]; } bJSC__JSGlobalObject;
+ typedef char* bJSC__JSGlobalObject_buf;
+ typedef struct bJSC__JSCell { unsigned char bytes[8]; } bJSC__JSCell;
+ typedef char* bJSC__JSCell_buf;
+ typedef struct bJSC__CatchScope { unsigned char bytes[8]; } bJSC__CatchScope;
+ typedef char* bJSC__CatchScope_buf;
+ typedef struct bWTF__String { unsigned char bytes[8]; } bWTF__String;
+ typedef char* bWTF__String_buf;
+ typedef struct bWTF__StringView { unsigned char bytes[16]; } bWTF__StringView;
+ typedef char* bWTF__StringView_buf;
+ typedef struct bJSC__JSModuleLoader { unsigned char bytes[16]; } bJSC__JSModuleLoader;
+ typedef char* bJSC__JSModuleLoader_buf;
+ typedef struct bInspector__ScriptArguments { unsigned char bytes[32]; } bInspector__ScriptArguments;
+ typedef char* bInspector__ScriptArguments_buf;
+ typedef struct bJSC__Exception { unsigned char bytes[40]; } bJSC__Exception;
+ typedef char* bJSC__Exception_buf;
+ typedef struct bJSC__VM { unsigned char bytes[52168]; } bJSC__VM;
+ typedef char* bJSC__VM_buf;
+ typedef struct bJSC__JSString { unsigned char bytes[16]; } bJSC__JSString;
+ typedef char* bJSC__JSString_buf;
+ typedef struct bJSC__SourceOrigin { unsigned char bytes[48]; } bJSC__SourceOrigin;
+ typedef char* bJSC__SourceOrigin_buf;
+ typedef struct bWTF__ExternalStringImpl { unsigned char bytes[40]; } bWTF__ExternalStringImpl;
+ typedef char* bWTF__ExternalStringImpl_buf;
+ typedef struct bJSC__JSInternalPromise { unsigned char bytes[32]; } bJSC__JSInternalPromise;
+ typedef char* bJSC__JSInternalPromise_buf;
+ typedef struct bWTF__StringImpl { unsigned char bytes[24]; } bWTF__StringImpl;
+ typedef char* bWTF__StringImpl_buf;
+ typedef struct bJSC__JSPromise { unsigned char bytes[32]; } bJSC__JSPromise;
+ typedef char* bJSC__JSPromise_buf;
+ typedef struct bJSC__JSObject { unsigned char bytes[16]; } bJSC__JSObject;
+ typedef char* bJSC__JSObject_buf;
+ typedef struct bJSC__Identifier { unsigned char bytes[8]; } bJSC__Identifier;
+ typedef char* bJSC__Identifier_buf;
#ifndef __cplusplus
-typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope
-typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype
-typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype
-typedef ErrorableResolvedSource ErrorableResolvedSource;
-typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype
-typedef ErrorableZigString ErrorableZigString;
-typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName
-typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject
-typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl
-typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype
-typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader
-typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype
-typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype
-typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier
-typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype
-typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback
-typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise
-typedef WebSocketHTTPClient WebSocketHTTPClient;
-typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype
-typedef SystemError SystemError;
-typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell
-typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin
-typedef Bun__Writable Bun__Writable;
-typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord
-typedef bWTF__String WTF__String; // WTF::String
-typedef bWTF__URL WTF__URL; // WTF::URL
-typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype
-typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise
-typedef Bun__Readable Bun__Readable;
-typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype
-typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype
-typedef struct WebCore__FetchHeaders WebCore__FetchHeaders; // WebCore::FetchHeaders
-typedef struct JSC__CallFrame JSC__CallFrame; // JSC::CallFrame
-typedef bWTF__StringView WTF__StringView; // WTF::StringView
-typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope
-typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl
-typedef WebSocketHTTPSClient WebSocketHTTPSClient;
-typedef bJSC__VM JSC__VM; // JSC::VM
-typedef JSClassRef JSClassRef;
-typedef Bun__ArrayBuffer Bun__ArrayBuffer;
-typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject
-typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction
-typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype
-typedef ZigException ZigException;
-typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode
-typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype
-typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype
-typedef ZigString ZigString;
-typedef struct WebCore__DOMURL WebCore__DOMURL; // WebCore::DOMURL
-typedef int64_t JSC__JSValue;
-typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype
-typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments
-typedef bJSC__Exception JSC__Exception; // JSC::Exception
-typedef bJSC__JSString JSC__JSString; // JSC::JSString
-typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype
-typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype
+ typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope
+ typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype
+ typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype
+ typedef ErrorableResolvedSource ErrorableResolvedSource;
+ typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype
+ typedef ErrorableZigString ErrorableZigString;
+ typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName
+ typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject
+ typedef WebSocketClient WebSocketClient;
+ typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl
+ typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype
+ typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader
+ typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype
+ typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype
+ typedef WebSocketClientTLS WebSocketClientTLS;
+ typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier
+ typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype
+ typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback
+ typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise
+ typedef WebSocketHTTPClient WebSocketHTTPClient;
+ typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype
+ typedef SystemError SystemError;
+ typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell
+ typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin
+ typedef Bun__Writable Bun__Writable;
+ typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord
+ typedef bWTF__String WTF__String; // WTF::String
+ typedef bWTF__URL WTF__URL; // WTF::URL
+ typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype
+ typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise
+ typedef Bun__Readable Bun__Readable;
+ typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype
+ typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype
+ typedef struct WebCore__FetchHeaders WebCore__FetchHeaders; // WebCore::FetchHeaders
+ typedef struct JSC__CallFrame JSC__CallFrame; // JSC::CallFrame
+ typedef bWTF__StringView WTF__StringView; // WTF::StringView
+ typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope
+ typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl
+ typedef WebSocketHTTPSClient WebSocketHTTPSClient;
+ typedef bJSC__VM JSC__VM; // JSC::VM
+ typedef JSClassRef JSClassRef;
+ typedef Bun__ArrayBuffer Bun__ArrayBuffer;
+ typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject
+ typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction
+ typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype
+ typedef ZigException ZigException;
+ typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode
+ typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype
+ typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype
+ typedef ZigString ZigString;
+ typedef struct WebCore__DOMURL WebCore__DOMURL; // WebCore::DOMURL
+ typedef int64_t JSC__JSValue;
+ typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype
+ typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments
+ typedef bJSC__Exception JSC__Exception; // JSC::Exception
+ typedef bJSC__JSString JSC__JSString; // JSC::JSString
+ typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype
+ typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype
#endif
#ifdef __cplusplus
-namespace JSC {
-class JSCell;
-class Exception;
-class JSPromisePrototype;
-class StringPrototype;
-class GeneratorFunctionPrototype;
-class ArrayPrototype;
-class JSString;
-class JSObject;
-class AsyncIteratorPrototype;
-class AsyncGeneratorFunctionPrototype;
-class Identifier;
-class JSPromise;
-class RegExpPrototype;
-class AsyncFunctionPrototype;
-class CatchScope;
-class VM;
-class BigIntPrototype;
-class SourceOrigin;
-class ThrowScope;
-class SetIteratorPrototype;
-class AsyncGeneratorPrototype;
-class PropertyName;
-class MapIteratorPrototype;
-class JSModuleRecord;
-class JSInternalPromise;
-class ArrayIteratorPrototype;
-class JSFunction;
-class JSModuleLoader;
-class GeneratorPrototype;
-class JSGlobalObject;
-class SourceCode;
-class FunctionPrototype;
-class IteratorPrototype;
-class CallFrame;
-class ObjectPrototype;
-}
-namespace WTF {
-class URL;
-class StringImpl;
-class String;
-class StringView;
-class ExternalStringImpl;
-}
-namespace Zig {
-class JSMicrotaskCallback;
-}
-namespace WebCore {
-class DOMURL;
-class FetchHeaders;
-}
-namespace Inspector {
-class ScriptArguments;
-}
-
-typedef ErrorableResolvedSource ErrorableResolvedSource;
-typedef ErrorableZigString ErrorableZigString;
-typedef WebSocketHTTPClient WebSocketHTTPClient;
-typedef SystemError SystemError;
-typedef Bun__Writable Bun__Writable;
-typedef Bun__Readable Bun__Readable;
-typedef WebSocketHTTPSClient WebSocketHTTPSClient;
-typedef JSClassRef JSClassRef;
-typedef Bun__ArrayBuffer Bun__ArrayBuffer;
-typedef ZigException ZigException;
-typedef ZigString ZigString;
-typedef int64_t JSC__JSValue;
-using JSC__JSCell = JSC::JSCell;
-using JSC__Exception = JSC::Exception;
-using JSC__JSPromisePrototype = JSC::JSPromisePrototype;
-using JSC__StringPrototype = JSC::StringPrototype;
-using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype;
-using JSC__ArrayPrototype = JSC::ArrayPrototype;
-using JSC__JSString = JSC::JSString;
-using JSC__JSObject = JSC::JSObject;
-using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype;
-using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype;
-using JSC__Identifier = JSC::Identifier;
-using JSC__JSPromise = JSC::JSPromise;
-using JSC__RegExpPrototype = JSC::RegExpPrototype;
-using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype;
-using JSC__CatchScope = JSC::CatchScope;
-using JSC__VM = JSC::VM;
-using JSC__BigIntPrototype = JSC::BigIntPrototype;
-using JSC__SourceOrigin = JSC::SourceOrigin;
-using JSC__ThrowScope = JSC::ThrowScope;
-using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype;
-using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype;
-using JSC__PropertyName = JSC::PropertyName;
-using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype;
-using JSC__JSModuleRecord = JSC::JSModuleRecord;
-using JSC__JSInternalPromise = JSC::JSInternalPromise;
-using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype;
-using JSC__JSFunction = JSC::JSFunction;
-using JSC__JSModuleLoader = JSC::JSModuleLoader;
-using JSC__GeneratorPrototype = JSC::GeneratorPrototype;
-using JSC__JSGlobalObject = JSC::JSGlobalObject;
-using JSC__SourceCode = JSC::SourceCode;
-using JSC__FunctionPrototype = JSC::FunctionPrototype;
-using JSC__IteratorPrototype = JSC::IteratorPrototype;
-using JSC__CallFrame = JSC::CallFrame;
-using JSC__ObjectPrototype = JSC::ObjectPrototype;
-using WTF__URL = WTF::URL;
-using WTF__StringImpl = WTF::StringImpl;
-using WTF__String = WTF::String;
-using WTF__StringView = WTF::StringView;
-using WTF__ExternalStringImpl = WTF::ExternalStringImpl;
-using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback;
-using WebCore__DOMURL = WebCore::DOMURL;
-using WebCore__FetchHeaders = WebCore::FetchHeaders;
-using Inspector__ScriptArguments = Inspector::ScriptArguments;
+ namespace JSC {
+ class JSCell;
+ class Exception;
+ class JSPromisePrototype;
+ class StringPrototype;
+ class GeneratorFunctionPrototype;
+ class ArrayPrototype;
+ class JSString;
+ class JSObject;
+ class AsyncIteratorPrototype;
+ class AsyncGeneratorFunctionPrototype;
+ class Identifier;
+ class JSPromise;
+ class RegExpPrototype;
+ class AsyncFunctionPrototype;
+ class CatchScope;
+ class VM;
+ class BigIntPrototype;
+ class SourceOrigin;
+ class ThrowScope;
+ class SetIteratorPrototype;
+ class AsyncGeneratorPrototype;
+ class PropertyName;
+ class MapIteratorPrototype;
+ class JSModuleRecord;
+ class JSInternalPromise;
+ class ArrayIteratorPrototype;
+ class JSFunction;
+ class JSModuleLoader;
+ class GeneratorPrototype;
+ class JSGlobalObject;
+ class SourceCode;
+ class FunctionPrototype;
+ class IteratorPrototype;
+ class CallFrame;
+ class ObjectPrototype;
+ }
+ namespace WTF {
+ class URL;
+ class StringImpl;
+ class String;
+ class StringView;
+ class ExternalStringImpl;
+ }
+ namespace Zig {
+ class JSMicrotaskCallback;
+ }
+ namespace WebCore {
+ class DOMURL;
+ class FetchHeaders;
+ }
+ namespace Inspector {
+ class ScriptArguments;
+ }
+
+ typedef ErrorableResolvedSource ErrorableResolvedSource;
+ typedef ErrorableZigString ErrorableZigString;
+ typedef WebSocketClient WebSocketClient;
+ typedef WebSocketClientTLS WebSocketClientTLS;
+ typedef WebSocketHTTPClient WebSocketHTTPClient;
+ typedef SystemError SystemError;
+ typedef Bun__Writable Bun__Writable;
+ typedef Bun__Readable Bun__Readable;
+ typedef WebSocketHTTPSClient WebSocketHTTPSClient;
+ typedef JSClassRef JSClassRef;
+ typedef Bun__ArrayBuffer Bun__ArrayBuffer;
+ typedef ZigException ZigException;
+ typedef ZigString ZigString;
+ typedef int64_t JSC__JSValue;
+ using JSC__JSCell = JSC::JSCell;
+ using JSC__Exception = JSC::Exception;
+ using JSC__JSPromisePrototype = JSC::JSPromisePrototype;
+ using JSC__StringPrototype = JSC::StringPrototype;
+ using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype;
+ using JSC__ArrayPrototype = JSC::ArrayPrototype;
+ using JSC__JSString = JSC::JSString;
+ using JSC__JSObject = JSC::JSObject;
+ using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype;
+ using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype;
+ using JSC__Identifier = JSC::Identifier;
+ using JSC__JSPromise = JSC::JSPromise;
+ using JSC__RegExpPrototype = JSC::RegExpPrototype;
+ using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype;
+ using JSC__CatchScope = JSC::CatchScope;
+ using JSC__VM = JSC::VM;
+ using JSC__BigIntPrototype = JSC::BigIntPrototype;
+ using JSC__SourceOrigin = JSC::SourceOrigin;
+ using JSC__ThrowScope = JSC::ThrowScope;
+ using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype;
+ using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype;
+ using JSC__PropertyName = JSC::PropertyName;
+ using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype;
+ using JSC__JSModuleRecord = JSC::JSModuleRecord;
+ using JSC__JSInternalPromise = JSC::JSInternalPromise;
+ using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype;
+ using JSC__JSFunction = JSC::JSFunction;
+ using JSC__JSModuleLoader = JSC::JSModuleLoader;
+ using JSC__GeneratorPrototype = JSC::GeneratorPrototype;
+ using JSC__JSGlobalObject = JSC::JSGlobalObject;
+ using JSC__SourceCode = JSC::SourceCode;
+ using JSC__FunctionPrototype = JSC::FunctionPrototype;
+ using JSC__IteratorPrototype = JSC::IteratorPrototype;
+ using JSC__CallFrame = JSC::CallFrame;
+ using JSC__ObjectPrototype = JSC::ObjectPrototype;
+ using WTF__URL = WTF::URL;
+ using WTF__StringImpl = WTF::StringImpl;
+ using WTF__String = WTF::String;
+ using WTF__StringView = WTF::StringView;
+ using WTF__ExternalStringImpl = WTF::ExternalStringImpl;
+ using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback;
+ using WebCore__DOMURL = WebCore::DOMURL;
+ using WebCore__FetchHeaders = WebCore::FetchHeaders;
+ using Inspector__ScriptArguments = Inspector::ScriptArguments;
#endif
+
#pragma mark - JSC::JSObject
-CPP_DECL JSC__JSValue JSC__JSObject__create(JSC__JSGlobalObject* arg0, size_t arg1, void* arg2, void (*ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2));
+CPP_DECL JSC__JSValue JSC__JSObject__create(JSC__JSGlobalObject* arg0, size_t arg1, void* arg2, void (* ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2));
CPP_DECL size_t JSC__JSObject__getArrayLength(JSC__JSObject* arg0);
CPP_DECL JSC__JSValue JSC__JSObject__getDirect(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, const ZigString* arg2);
CPP_DECL JSC__JSValue JSC__JSObject__getIndex(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, uint32_t arg2);
CPP_DECL void JSC__JSObject__putRecord(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3, size_t arg4);
-CPP_DECL JSC__JSValue ZigString__external(const ZigString* arg0, JSC__JSGlobalObject* arg1, void* arg2, void (*ArgFn3)(void* arg0, void* arg1, size_t arg2));
+CPP_DECL JSC__JSValue ZigString__external(const ZigString* arg0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(void* arg0, void* arg1, size_t arg2));
CPP_DECL JSC__JSValue ZigString__to16BitValue(const ZigString* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL JSC__JSValue ZigString__toErrorInstance(const ZigString* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL JSC__JSValue ZigString__toExternalU16(const uint16_t* arg0, size_t arg1, JSC__JSGlobalObject* arg2);
CPP_DECL JSC__JSValue ZigString__toExternalValue(const ZigString* arg0, JSC__JSGlobalObject* arg1);
-CPP_DECL JSC__JSValue ZigString__toExternalValueWithCallback(const ZigString* arg0, JSC__JSGlobalObject* arg1, void (*ArgFn2)(void* arg0, void* arg1, size_t arg2));
+CPP_DECL JSC__JSValue ZigString__toExternalValueWithCallback(const ZigString* arg0, JSC__JSGlobalObject* arg1, void (* ArgFn2)(void* arg0, void* arg1, size_t arg2));
CPP_DECL JSC__JSValue ZigString__toValue(const ZigString* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL JSC__JSValue ZigString__toValueGC(const ZigString* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL WebCore__DOMURL* WebCore__DOMURL__cast_(JSC__JSValue JSValue0, JSC__VM* arg1);
@@ -503,7 +462,7 @@ CPP_DECL size_t WTF__String__length(WTF__String* arg0);
#pragma mark - JSC::JSValue
-CPP_DECL void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (*ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3), void (*ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3));
+CPP_DECL void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3), void (* ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3));
CPP_DECL bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, Bun__ArrayBuffer* arg2);
CPP_DECL JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0);
CPP_DECL JSC__JSInternalPromise* JSC__JSValue__asInternalPromise(JSC__JSValue JSValue0);
@@ -521,7 +480,7 @@ CPP_DECL JSC__JSValue JSC__JSValue__createTypeError(const ZigString* arg0, const
CPP_DECL JSC__JSValue JSC__JSValue__createUninitializedUint8Array(JSC__JSGlobalObject* arg0, size_t arg1);
CPP_DECL bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell* arg1);
CPP_DECL bool JSC__JSValue__eqlValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1);
-CPP_DECL void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (*ArgFn3)(JSC__VM* arg0, JSC__JSGlobalObject* arg1, void* arg2, JSC__JSValue JSValue3));
+CPP_DECL void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(JSC__VM* arg0, JSC__JSGlobalObject* arg1, void* arg2, JSC__JSValue JSValue3));
CPP_DECL JSC__JSValue JSC__JSValue__fromEntries(JSC__JSGlobalObject* arg0, ZigString* arg1, ZigString* arg2, size_t arg3, bool arg4);
CPP_DECL JSC__JSValue JSC__JSValue__fromInt64NoTruncate(JSC__JSGlobalObject* arg0, int64_t arg1);
CPP_DECL JSC__JSValue JSC__JSValue__fromUInt64NoTruncate(JSC__JSGlobalObject* arg0, uint64_t arg1);
@@ -607,13 +566,13 @@ CPP_DECL JSC__JSValue JSC__Exception__value(JSC__Exception* arg0);
CPP_DECL void JSC__VM__clearExecutionTimeLimit(JSC__VM* arg0);
CPP_DECL JSC__VM* JSC__VM__create(unsigned char HeapType0);
-CPP_DECL void JSC__VM__deferGC(JSC__VM* arg0, void* arg1, void (*ArgFn2)(void* arg0));
+CPP_DECL void JSC__VM__deferGC(JSC__VM* arg0, void* arg1, void (* ArgFn2)(void* arg0));
CPP_DECL void JSC__VM__deinit(JSC__VM* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL void JSC__VM__deleteAllCode(JSC__VM* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL void JSC__VM__doWork(JSC__VM* arg0);
CPP_DECL void JSC__VM__drainMicrotasks(JSC__VM* arg0);
CPP_DECL bool JSC__VM__executionForbidden(JSC__VM* arg0);
-CPP_DECL void JSC__VM__holdAPILock(JSC__VM* arg0, void* arg1, void (*ArgFn2)(void* arg0));
+CPP_DECL void JSC__VM__holdAPILock(JSC__VM* arg0, void* arg1, void (* ArgFn2)(void* arg0));
CPP_DECL bool JSC__VM__isEntered(JSC__VM* arg0);
CPP_DECL bool JSC__VM__isJITEnabled();
CPP_DECL void JSC__VM__releaseWeakRefs(JSC__VM* arg0);
@@ -623,7 +582,7 @@ CPP_DECL void JSC__VM__setExecutionTimeLimit(JSC__VM* arg0, double arg1);
CPP_DECL void JSC__VM__shrinkFootprint(JSC__VM* arg0);
CPP_DECL void JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
CPP_DECL void JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
-CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (*ArgFn1)());
+CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (* ArgFn1)());
#pragma mark - JSC::ThrowScope
@@ -670,7 +629,7 @@ CPP_DECL size_t WTF__StringImpl__length(const WTF__StringImpl* arg0);
CPP_DECL const uint16_t* WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl* arg0);
CPP_DECL const unsigned char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0);
-CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (*ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2));
+CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (* ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2));
CPP_DECL bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl* arg0);
CPP_DECL bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl* arg0);
CPP_DECL bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl* arg0);
@@ -812,6 +771,28 @@ ZIG_DECL void Bun__WebSocketHTTPSClient__register(JSC__JSGlobalObject* arg0, voi
#ifdef __cplusplus
+ZIG_DECL void Bun__WebSocketClient__close(WebSocketClient* arg0, uint16_t arg1, const ZigString* arg2);
+ZIG_DECL void Bun__WebSocketClient__finalize(WebSocketClient* arg0);
+ZIG_DECL void* Bun__WebSocketClient__init(void* arg0, void* arg1, void* arg2, JSC__JSGlobalObject* arg3);
+ZIG_DECL void Bun__WebSocketClient__register(JSC__JSGlobalObject* arg0, void* arg1, void* arg2);
+ZIG_DECL void Bun__WebSocketClient__writeBinaryData(WebSocketClient* arg0, const unsigned char* arg1, size_t arg2);
+ZIG_DECL void Bun__WebSocketClient__writeString(WebSocketClient* arg0, const ZigString* arg1);
+
+#endif
+
+#ifdef __cplusplus
+
+ZIG_DECL void Bun__WebSocketClientTLS__close(WebSocketClientTLS* arg0, uint16_t arg1, const ZigString* arg2);
+ZIG_DECL void Bun__WebSocketClientTLS__finalize(WebSocketClientTLS* arg0);
+ZIG_DECL void* Bun__WebSocketClientTLS__init(void* arg0, void* arg1, void* arg2, JSC__JSGlobalObject* arg3);
+ZIG_DECL void Bun__WebSocketClientTLS__register(JSC__JSGlobalObject* arg0, void* arg1, void* arg2);
+ZIG_DECL void Bun__WebSocketClientTLS__writeBinaryData(WebSocketClientTLS* arg0, const unsigned char* arg1, size_t arg2);
+ZIG_DECL void Bun__WebSocketClientTLS__writeString(WebSocketClientTLS* arg0, const ZigString* arg1);
+
+#endif
+
+#ifdef __cplusplus
+
ZIG_DECL void Bun__Process__exit(JSC__JSGlobalObject* arg0, int32_t arg1);
ZIG_DECL JSC__JSValue Bun__Process__getArgv(JSC__JSGlobalObject* arg0);
ZIG_DECL JSC__JSValue Bun__Process__getCwd(JSC__JSGlobalObject* arg0);
@@ -824,6 +805,7 @@ CPP_DECL ZigException ZigException__fromException(JSC__Exception* arg0);
#pragma mark - Zig::ConsoleClient
+
#ifdef __cplusplus
ZIG_DECL void Zig__ConsoleClient__count(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
@@ -844,6 +826,7 @@ ZIG_DECL void Zig__ConsoleClient__timeStamp(void* arg0, JSC__JSGlobalObject* arg
#pragma mark - Bun__Timer
+
#ifdef __cplusplus
ZIG_DECL JSC__JSValue Bun__Timer__clearInterval(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig
index 4b05ed250..306ee44f2 100644
--- a/src/javascript/jsc/bindings/headers.zig
+++ b/src/javascript/jsc/bindings/headers.zig
@@ -68,6 +68,8 @@ pub const ArrayBufferSink = @import("../webcore/streams.zig").ArrayBufferSink;
pub const WebSocketHTTPClient = bindings.WebSocketHTTPClient;
pub const WebSocketHTTPSClient = bindings.WebSocketHTTPSClient;
+pub const WebSocketClient = bindings.WebSocketClient;
+pub const WebSocketClientTLS = bindings.WebSocketClientTLS;
// GENERATED CODE - DO NOT MODIFY BY HAND
pub const ptrdiff_t = c_long;
diff --git a/src/javascript/jsc/bindings/webcore/WebSocket.cpp b/src/javascript/jsc/bindings/webcore/WebSocket.cpp
index 3c9f3a373..7748f2ae8 100644
--- a/src/javascript/jsc/bindings/webcore/WebSocket.cpp
+++ b/src/javascript/jsc/bindings/webcore/WebSocket.cpp
@@ -176,11 +176,11 @@ WebSocket::~WebSocket()
switch (m_connectedWebSocketKind) {
case ConnectedWebSocketKind::Client: {
- this->m_connectedWebSocket.client->end(None);
+ Bun__WebSocketClient__finalize(this->m_connectedWebSocket.client);
break;
}
case ConnectedWebSocketKind::ClientSSL: {
- this->m_connectedWebSocket.clientSSL->end(None);
+ Bun__WebSocketClientTLS__finalize(this->m_connectedWebSocket.clientSSL);
break;
}
case ConnectedWebSocketKind::Server: {
@@ -408,17 +408,17 @@ ExceptionOr<void> WebSocket::send(const String& message)
LOG(Network, "WebSocket %p send() Sending String '%s'", this, message.utf8().data());
if (m_state == CONNECTING)
return Exception { InvalidStateError };
- auto utf8 = message.utf8(StrictConversionReplacingUnpairedSurrogatesWithFFFD);
// No exception is raised if the connection was once established but has subsequently been closed.
if (m_state == CLOSING || m_state == CLOSED) {
+ auto utf8 = message.utf8(StrictConversionReplacingUnpairedSurrogatesWithFFFD);
size_t payloadSize = utf8.length();
m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize);
m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize));
return {};
}
- if (utf8.length() > 0)
- this->sendWebSocketData<false>(utf8.data(), utf8.length());
+ if (message.length() > 0)
+ this->sendWebSocketString(message);
return {};
}
@@ -437,7 +437,7 @@ ExceptionOr<void> WebSocket::send(ArrayBuffer& binaryData)
char* data = static_cast<char*>(binaryData.data());
size_t length = binaryData.byteLength();
if (length > 0)
- this->sendWebSocketData<true>(data, length);
+ this->sendWebSocketData(data, length);
return {};
}
@@ -458,7 +458,7 @@ ExceptionOr<void> WebSocket::send(ArrayBufferView& arrayBufferView)
char* baseAddress = reinterpret_cast<char*>(buffer->data()) + arrayBufferView.byteOffset();
size_t length = arrayBufferView.byteLength();
if (length > 0)
- this->sendWebSocketData<true>(baseAddress, length);
+ this->sendWebSocketData(baseAddress, length);
return {};
}
@@ -480,48 +480,74 @@ ExceptionOr<void> WebSocket::send(ArrayBufferView& arrayBufferView)
// return {};
// }
-template<bool isBinary>
void WebSocket::sendWebSocketData(const char* baseAddress, size_t length)
{
- uWS::OpCode opCode = uWS::OpCode::TEXT;
+ uWS::OpCode opCode = uWS::OpCode::BINARY;
- if constexpr (isBinary)
- opCode = uWS::OpCode::BINARY;
+ switch (m_connectedWebSocketKind) {
+ case ConnectedWebSocketKind::Client: {
+ Bun__WebSocketClient__writeBinaryData(this->m_connectedWebSocket.client, reinterpret_cast<const unsigned char*>(baseAddress), length);
+ // this->m_connectedWebSocket.client->send({ baseAddress, length }, opCode);
+ // this->m_bufferedAmount = this->m_connectedWebSocket.client->getBufferedAmount();
+ break;
+ }
+ case ConnectedWebSocketKind::ClientSSL: {
+ Bun__WebSocketClientTLS__writeBinaryData(this->m_connectedWebSocket.clientSSL, reinterpret_cast<const unsigned char*>(baseAddress), length);
+ break;
+ }
+ case ConnectedWebSocketKind::Server: {
+ this->m_connectedWebSocket.server->send({ baseAddress, length }, opCode);
+ this->m_bufferedAmount = this->m_connectedWebSocket.server->getBufferedAmount();
+ break;
+ }
+ case ConnectedWebSocketKind::ServerSSL: {
+ this->m_connectedWebSocket.serverSSL->send({ baseAddress, length }, opCode);
+ this->m_bufferedAmount = this->m_connectedWebSocket.serverSSL->getBufferedAmount();
+ break;
+ }
+ default: {
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ }
+}
- this->m_connectedWebSocket.client->cork(
- [&]() {
- switch (m_connectedWebSocketKind) {
- case ConnectedWebSocketKind::Client: {
- this->m_connectedWebSocket.client->send({ baseAddress, length }, opCode);
- this->m_bufferedAmount = this->m_connectedWebSocket.client->getBufferedAmount();
- break;
- }
- case ConnectedWebSocketKind::ClientSSL: {
- this->m_connectedWebSocket.clientSSL->send({ baseAddress, length }, opCode);
- this->m_bufferedAmount = this->m_connectedWebSocket.clientSSL->getBufferedAmount();
- break;
- }
- case ConnectedWebSocketKind::Server: {
- this->m_connectedWebSocket.server->send({ baseAddress, length }, opCode);
- this->m_bufferedAmount = this->m_connectedWebSocket.server->getBufferedAmount();
- break;
- }
- case ConnectedWebSocketKind::ServerSSL: {
- this->m_connectedWebSocket.serverSSL->send({ baseAddress, length }, opCode);
- this->m_bufferedAmount = this->m_connectedWebSocket.serverSSL->getBufferedAmount();
- break;
- }
- default: {
- RELEASE_ASSERT_NOT_REACHED();
- }
- }
- });
+void WebSocket::sendWebSocketString(const String& message)
+{
+
+ switch (m_connectedWebSocketKind) {
+ case ConnectedWebSocketKind::Client: {
+ auto zigStr = Zig::toZigString(message);
+ Bun__WebSocketClient__writeString(this->m_connectedWebSocket.client, &zigStr);
+ // this->m_connectedWebSocket.client->send({ baseAddress, length }, opCode);
+ // this->m_bufferedAmount = this->m_connectedWebSocket.client->getBufferedAmount();
+ break;
+ }
+ case ConnectedWebSocketKind::ClientSSL: {
+ auto zigStr = Zig::toZigString(message);
+ Bun__WebSocketClientTLS__writeString(this->m_connectedWebSocket.clientSSL, &zigStr);
+ break;
+ }
+ case ConnectedWebSocketKind::Server: {
+ auto utf8 = message.utf8(StrictConversionReplacingUnpairedSurrogatesWithFFFD);
+ this->m_connectedWebSocket.server->send({ utf8.data(), utf8.length() }, uWS::OpCode::TEXT);
+ this->m_bufferedAmount = this->m_connectedWebSocket.server->getBufferedAmount();
+ break;
+ }
+ case ConnectedWebSocketKind::ServerSSL: {
+ auto utf8 = message.utf8(StrictConversionReplacingUnpairedSurrogatesWithFFFD);
+ this->m_connectedWebSocket.serverSSL->send({ utf8.data(), utf8.length() }, uWS::OpCode::TEXT);
+ this->m_bufferedAmount = this->m_connectedWebSocket.serverSSL->getBufferedAmount();
+ break;
+ }
+ default: {
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ }
}
ExceptionOr<void> WebSocket::close(std::optional<unsigned short> optionalCode, const String& reason)
{
- CString utf8 = reason.utf8(StrictConversionReplacingUnpairedSurrogatesWithFFFD);
int code = optionalCode ? optionalCode.value() : static_cast<int>(0);
if (code == 0)
LOG(Network, "WebSocket %p close() without code and reason", this);
@@ -529,7 +555,7 @@ ExceptionOr<void> WebSocket::close(std::optional<unsigned short> optionalCode, c
LOG(Network, "WebSocket %p close() code=%d reason='%s'", this, code, reason.utf8().data());
// if (!(code == WebSocketChannel::CloseEventCodeNormalClosure || (WebSocketChannel::CloseEventCodeMinimumUserDefined <= code && code <= WebSocketChannel::CloseEventCodeMaximumUserDefined)))
// return Exception { InvalidAccessError };
- if (utf8.length() > maxReasonSizeInBytes) {
+ if (reason.length() > maxReasonSizeInBytes) {
// scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "WebSocket close message is too long."_s);
return Exception { SyntaxError, "WebSocket close message is too long."_s };
}
@@ -553,23 +579,25 @@ ExceptionOr<void> WebSocket::close(std::optional<unsigned short> optionalCode, c
m_state = CLOSING;
switch (m_connectedWebSocketKind) {
case ConnectedWebSocketKind::Client: {
- this->m_connectedWebSocket.client->end(code, { utf8.data(), utf8.length() });
- this->m_bufferedAmount = this->m_connectedWebSocket.client->getBufferedAmount();
+ ZigString reasonZigStr = Zig::toZigString(reason);
+ Bun__WebSocketClient__close(this->m_connectedWebSocket.client, code, &reasonZigStr);
+ // this->m_bufferedAmount = this->m_connectedWebSocket.client->getBufferedAmount();
break;
}
case ConnectedWebSocketKind::ClientSSL: {
- this->m_connectedWebSocket.clientSSL->end(code, { utf8.data(), utf8.length() });
- this->m_bufferedAmount = this->m_connectedWebSocket.clientSSL->getBufferedAmount();
+ ZigString reasonZigStr = Zig::toZigString(reason);
+ Bun__WebSocketClientTLS__close(this->m_connectedWebSocket.clientSSL, code, &reasonZigStr);
+ // this->m_bufferedAmount = this->m_connectedWebSocket.clientSSL->getBufferedAmount();
break;
}
case ConnectedWebSocketKind::Server: {
- this->m_connectedWebSocket.server->end(code, { utf8.data(), utf8.length() });
- this->m_bufferedAmount = this->m_connectedWebSocket.server->getBufferedAmount();
+ // this->m_connectedWebSocket.server->end(code, { utf8.data(), utf8.length() });
+ // this->m_bufferedAmount = this->m_connectedWebSocket.server->getBufferedAmount();
break;
}
case ConnectedWebSocketKind::ServerSSL: {
- this->m_connectedWebSocket.serverSSL->end(code, { utf8.data(), utf8.length() });
- this->m_bufferedAmount = this->m_connectedWebSocket.serverSSL->getBufferedAmount();
+ // this->m_connectedWebSocket.serverSSL->end(code, { utf8.data(), utf8.length() });
+ // this->m_bufferedAmount = this->m_connectedWebSocket.serverSSL->getBufferedAmount();
break;
}
default: {
@@ -832,26 +860,12 @@ void WebSocket::didConnect(us_socket_t* socket, char* bufferedData, size_t buffe
{
this->m_upgradeClient = nullptr;
if (m_isSecure) {
- /* Adopting a socket invalidates it, do not rely on it directly to carry any data */
- uWS::WebSocket<true, false, WebSocket*>* webSocket = (uWS::WebSocket<true, false, WebSocket*>*)us_socket_context_adopt_socket(1,
- (us_socket_context_t*)this->scriptExecutionContext()->connnectedWebSocketContext<true, false>(), socket, sizeof(uWS::WebSocketData) + sizeof(WebSocket*));
-
- webSocket->AsyncSocket<true>::uncork();
-
- webSocket->init(0, uWS::CompressOptions::DISABLED, uWS::BackPressure());
- *webSocket->getUserData() = this;
- this->m_connectedWebSocket.clientSSL = webSocket;
+ us_socket_context_t* ctx = (us_socket_context_t*)this->scriptExecutionContext()->connnectedWebSocketContext<true, false>();
+ this->m_connectedWebSocket.clientSSL = Bun__WebSocketClientTLS__init(this, socket, ctx, this->scriptExecutionContext()->jsGlobalObject());
this->m_connectedWebSocketKind = ConnectedWebSocketKind::ClientSSL;
} else {
- /* Adopting a socket invalidates it, do not rely on it directly to carry any data */
- uWS::WebSocket<false, false, WebSocket*>* webSocket = (uWS::WebSocket<false, false, WebSocket*>*)us_socket_context_adopt_socket(1,
- (us_socket_context_t*)this->scriptExecutionContext()->connnectedWebSocketContext<false, false>(), socket, sizeof(uWS::WebSocketData) + sizeof(WebSocket*));
-
- webSocket->AsyncSocket<false>::uncork();
-
- webSocket->init(0, uWS::CompressOptions::DISABLED, uWS::BackPressure());
- *webSocket->getUserData() = this;
- this->m_connectedWebSocket.client = webSocket;
+ us_socket_context_t* ctx = (us_socket_context_t*)this->scriptExecutionContext()->connnectedWebSocketContext<false, false>();
+ this->m_connectedWebSocket.client = Bun__WebSocketClient__init(this, socket, ctx, this->scriptExecutionContext()->jsGlobalObject());
this->m_connectedWebSocketKind = ConnectedWebSocketKind::Client;
}
@@ -977,6 +991,61 @@ void WebSocket::didFailWithErrorCode(int32_t code)
didReceiveMessageError(message);
break;
}
+
+ // failed_to_allocate_memory
+ case 18: {
+ auto message = MAKE_STATIC_STRING_IMPL("Failed to allocate memory");
+ didReceiveMessageError(message);
+ break;
+ }
+ // control_frame_is_fragmented
+ case 19: {
+ auto message = MAKE_STATIC_STRING_IMPL("Protocol error - control frame is fragmented");
+ didReceiveMessageError(message);
+ break;
+ }
+ // invalid_control_frame
+ case 20: {
+ auto message = MAKE_STATIC_STRING_IMPL("Protocol error - invalid control frame");
+ didReceiveMessageError(message);
+ break;
+ }
+ // compression_unsupported
+ case 21: {
+ auto message = MAKE_STATIC_STRING_IMPL("Compression not implemented yet");
+ didReceiveMessageError(message);
+ break;
+ }
+ // unexpected_mask_from_server
+ case 22: {
+ auto message = MAKE_STATIC_STRING_IMPL("Protocol error - unexpected mask from server");
+ didReceiveMessageError(message);
+ break;
+ }
+ // expected_control_frame
+ case 23: {
+ auto message = MAKE_STATIC_STRING_IMPL("Protocol error - expected control frame");
+ didReceiveMessageError(message);
+ break;
+ }
+ // unsupported_control_frame
+ case 24: {
+ auto message = MAKE_STATIC_STRING_IMPL("Protocol error - unsupported control frame");
+ didReceiveMessageError(message);
+ break;
+ }
+ // unexpected_opcode
+ case 25: {
+ auto message = MAKE_STATIC_STRING_IMPL("Protocol error - unexpected opcode");
+ didReceiveMessageError(message);
+ break;
+ }
+ // invalid_utf8
+ case 26: {
+ auto message = MAKE_STATIC_STRING_IMPL("Server sent invalid UTF8");
+ didReceiveMessageError(message);
+ break;
+ }
}
}
} // namespace WebCore
@@ -985,7 +1054,21 @@ extern "C" void WebSocket__didConnect(WebCore::WebSocket* webSocket, us_socket_t
{
webSocket->didConnect(socket, bufferedData, len);
}
-extern "C" void WebSocket__didFailWithErrorCode(WebCore::WebSocket* webSocket, int32_t errorCode)
+extern "C" void WebSocket__didCloseWithErrorCode(WebCore::WebSocket* webSocket, int32_t errorCode)
{
webSocket->didFailWithErrorCode(errorCode);
+}
+
+extern "C" void WebSocket__didReceiveText(WebCore::WebSocket* webSocket, bool clone, const ZigString* str)
+{
+ WTF::String wtf_str = Zig::toString(*str);
+ if (clone) {
+ wtf_str = wtf_str.isolatedCopy();
+ }
+
+ webSocket->didReceiveMessage(WTFMove(wtf_str));
+}
+extern "C" void WebSocket__didReceiveBytes(WebCore::WebSocket* webSocket, uint8_t* bytes, size_t len)
+{
+ webSocket->didReceiveBinaryData({ bytes, len });
} \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/webcore/WebSocket.h b/src/javascript/jsc/bindings/webcore/WebSocket.h
index 51b885c3b..03c0d7709 100644
--- a/src/javascript/jsc/bindings/webcore/WebSocket.h
+++ b/src/javascript/jsc/bindings/webcore/WebSocket.h
@@ -105,8 +105,8 @@ public:
private:
typedef union AnyWebSocket {
- uWS::WebSocket<false, false, WebCore::WebSocket*>* client;
- uWS::WebSocket<true, false, WebCore::WebSocket*>* clientSSL;
+ WebSocketClient* client;
+ WebSocketClientTLS* clientSSL;
uWS::WebSocket<false, true, WebCore::WebSocket*>* server;
uWS::WebSocket<true, true, WebCore::WebSocket*>* serverSSL;
} AnyWebSocket;
@@ -138,7 +138,7 @@ private:
void didUpdateBufferedAmount(unsigned bufferedAmount);
void didStartClosingHandshake();
- template<bool isBinary>
+ void sendWebSocketString(const String& message);
void sendWebSocketData(const char* data, size_t length);
void failAsynchronously();
diff --git a/src/javascript/jsc/event_loop.zig b/src/javascript/jsc/event_loop.zig
index 9cc6c835a..fbd14c270 100644
--- a/src/javascript/jsc/event_loop.zig
+++ b/src/javascript/jsc/event_loop.zig
@@ -287,7 +287,7 @@ pub const EventLoop = struct {
concurrent_lock: Lock = Lock.init(),
global: *JSGlobalObject = undefined,
virtual_machine: *VirtualMachine = undefined,
- pub const Queue = std.fifo.LinearFifo(Task, .Dynamic);
+ pub const Queue = bun.LinearFifo(Task, .Dynamic);
pub fn tickWithCount(this: *EventLoop) u32 {
var finished: u32 = 0;