diff options
-rw-r--r-- | src/bun.js/bindings/ZigGlobalObject.cpp | 7 | ||||
-rw-r--r-- | src/bun.js/builtins/BunBuiltinNames.h | 1 | ||||
-rw-r--r-- | src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp | 12 | ||||
-rw-r--r-- | src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp | 14 | ||||
-rw-r--r-- | src/bun.js/builtins/js/ReadableStream.js | 6 | ||||
-rw-r--r-- | src/bun.js/builtins/js/ReadableStreamInternals.js | 8 |
6 files changed, 26 insertions, 22 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index bfc8e2ad4..03cee0bb4 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -2052,7 +2052,7 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm auto& builtinNames = clientData->builtinNames(); JSC__JSValue const* constructors = Zig__getAPIConstructors(&constructor_count, this); WTF::Vector<GlobalPropertyInfo> extraStaticGlobals; - extraStaticGlobals.reserveCapacity((size_t)count + constructor_count + 3 + 1); + extraStaticGlobals.reserveCapacity((size_t)count + constructor_count + 3 + 1 + 1); int i = 0; for (; i < constructor_count; i++) { auto* object = JSC::jsDynamicCast<JSC::JSCallbackConstructor*>(JSC::JSValue::decode(constructors[i]).asCell()->getObject()); @@ -2145,7 +2145,10 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm } extraStaticGlobals.uncheckedAppend( - GlobalPropertyInfo { JSC::Identifier::fromString(vm, jsClass->className()), + GlobalPropertyInfo { builtinNames.BunPublicName(), + JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 }); + extraStaticGlobals.uncheckedAppend( + GlobalPropertyInfo { builtinNames.BunPrivateName(), JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 }); } diff --git a/src/bun.js/builtins/BunBuiltinNames.h b/src/bun.js/builtins/BunBuiltinNames.h index 8cc0369b4..cd350f999 100644 --- a/src/bun.js/builtins/BunBuiltinNames.h +++ b/src/bun.js/builtins/BunBuiltinNames.h @@ -24,6 +24,7 @@ using namespace JSC; #define BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \ macro(AbortSignal) \ + macro(Bun) \ macro(ReadableByteStreamController) \ macro(ReadableStream) \ macro(ReadableStreamBYOBReader) \ diff --git a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp index 6dfba3a1d..541ac3df2 100644 --- a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp +++ b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp @@ -168,7 +168,7 @@ const char* const s_readableStreamReadableStreamToTextCode = const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamReadableStreamToArrayBufferCodeLength = 354; +const int s_readableStreamReadableStreamToArrayBufferCodeLength = 334; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (stream) {\n" \ @@ -181,32 +181,32 @@ const char* const s_readableStreamReadableStreamToArrayBufferCode = " return @readableStreamToArrayBufferDirect(stream, underlyingSource);\n" \ " }\n" \ "\n" \ - " return globalThis.Bun.readableStreamToArray(stream).@then(globalThis.Bun.concatArrayBuffers);\n" \ + " return @Bun.readableStreamToArray(stream).@then(@Bun.concatArrayBuffers);\n" \ "})\n" \ ; const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_readableStreamReadableStreamToJSONCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_readableStreamReadableStreamToJSONCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamReadableStreamToJSONCodeLength = 128; +const int s_readableStreamReadableStreamToJSONCodeLength = 118; static const JSC::Intrinsic s_readableStreamReadableStreamToJSONCodeIntrinsic = JSC::NoIntrinsic; const char* const s_readableStreamReadableStreamToJSONCode = "(function (stream) {\n" \ " \"use strict\";\n" \ "\n" \ - " return globalThis.Bun.readableStreamToText(stream).@then(globalThis.JSON.parse);\n" \ + " return @Bun.readableStreamToText(stream).@then(globalThis.JSON.parse);\n" \ "})\n" \ ; const JSC::ConstructAbility s_readableStreamReadableStreamToBlobCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_readableStreamReadableStreamToBlobCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_readableStreamReadableStreamToBlobCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamReadableStreamToBlobCodeLength = 149; +const int s_readableStreamReadableStreamToBlobCodeLength = 139; static const JSC::Intrinsic s_readableStreamReadableStreamToBlobCodeIntrinsic = JSC::NoIntrinsic; const char* const s_readableStreamReadableStreamToBlobCode = "(function (stream) {\n" \ " \"use strict\";\n" \ - " return @Promise.resolve(globalThis.Bun.readableStreamToArray(stream)).@then(array => new Blob(array));\n" \ + " return @Promise.resolve(@Bun.readableStreamToArray(stream)).@then(array => new Blob(array));\n" \ "})\n" \ ; diff --git a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp index 205b87774..ab10bdeea 100644 --- a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp +++ b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp @@ -1488,7 +1488,7 @@ const char* const s_readableStreamInternalsOnFlushDirectStreamCode = const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_readableStreamInternalsCreateTextStreamCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_readableStreamInternalsCreateTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsCreateTextStreamCodeLength = 2393; +const int s_readableStreamInternalsCreateTextStreamCodeLength = 2373; static const JSC::Intrinsic s_readableStreamInternalsCreateTextStreamCodeIntrinsic = JSC::NoIntrinsic; const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (highWaterMark) {\n" \ @@ -1569,13 +1569,13 @@ const char* const s_readableStreamInternalsCreateTextStreamCode = "\n" \ " if (hasBuffer && !hasString) {\n" \ " return new globalThis.TextDecoder().decode(\n" \ - " globalThis.Bun.concatArrayBuffers(array)\n" \ + " @Bun.concatArrayBuffers(array)\n" \ " );\n" \ " }\n" \ "\n" \ " //\n" \ "\n" \ - " var arrayBufferSink = new globalThis.Bun.ArrayBufferSink();\n" \ + " var arrayBufferSink = new @Bun.ArrayBufferSink();\n" \ " arrayBufferSink.start({\n" \ " highWaterMark: estimatedLength,\n" \ " asUint8Array: true,\n" \ @@ -1714,7 +1714,7 @@ const char* const s_readableStreamInternalsInitializeArrayStreamCode = const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayBufferStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsInitializeArrayBufferStreamCodeLength = 1005; +const int s_readableStreamInternalsInitializeArrayBufferStreamCodeLength = 995; static const JSC::Intrinsic s_readableStreamInternalsInitializeArrayBufferStreamCodeIntrinsic = JSC::NoIntrinsic; const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = "(function (underlyingSource, highWaterMark) {\n" \ @@ -1728,7 +1728,7 @@ const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = " highWaterMark && typeof highWaterMark === \"number\"\n" \ " ? { highWaterMark, stream: true, asUint8Array: true }\n" \ " : { stream: true, asUint8Array: true };\n" \ - " var sink = new globalThis.Bun.ArrayBufferSink();\n" \ + " var sink = new @Bun.ArrayBufferSink();\n" \ " sink.start(opts);\n" \ "\n" \ " var controller = {\n" \ @@ -2408,13 +2408,13 @@ const char* const s_readableStreamInternalsReadableStreamIntoTextCode = const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength = 1543; +const int s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength = 1533; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeIntrinsic = JSC::NoIntrinsic; const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (stream, underlyingSource) {\n" \ " \"use strict\";\n" \ "\n" \ - " var sink = new globalThis.Bun.ArrayBufferSink();\n" \ + " var sink = new @Bun.ArrayBufferSink();\n" \ " @putByIdDirectPrivate(stream, \"underlyingSource\", @undefined);\n" \ " var highWaterMark = @getByIdDirectPrivate(stream, \"highWaterMark\");\n" \ " sink.start(highWaterMark ? { highWaterMark } : {});\n" \ diff --git a/src/bun.js/builtins/js/ReadableStream.js b/src/bun.js/builtins/js/ReadableStream.js index fbd8148ba..a8aa5d8f3 100644 --- a/src/bun.js/builtins/js/ReadableStream.js +++ b/src/bun.js/builtins/js/ReadableStream.js @@ -135,20 +135,20 @@ function readableStreamToArrayBuffer(stream) { return @readableStreamToArrayBufferDirect(stream, underlyingSource); } - return globalThis.Bun.readableStreamToArray(stream).@then(globalThis.Bun.concatArrayBuffers); + return @Bun.readableStreamToArray(stream).@then(@Bun.concatArrayBuffers); } @globalPrivate function readableStreamToJSON(stream) { "use strict"; - return globalThis.Bun.readableStreamToText(stream).@then(globalThis.JSON.parse); + return @Bun.readableStreamToText(stream).@then(globalThis.JSON.parse); } @globalPrivate function readableStreamToBlob(stream) { "use strict"; - return @Promise.resolve(globalThis.Bun.readableStreamToArray(stream)).@then(array => new Blob(array)); + return @Promise.resolve(@Bun.readableStreamToArray(stream)).@then(array => new Blob(array)); } @globalPrivate diff --git a/src/bun.js/builtins/js/ReadableStreamInternals.js b/src/bun.js/builtins/js/ReadableStreamInternals.js index 0f5871fa1..3a02669dc 100644 --- a/src/bun.js/builtins/js/ReadableStreamInternals.js +++ b/src/bun.js/builtins/js/ReadableStreamInternals.js @@ -1302,13 +1302,13 @@ function createTextStream(highWaterMark) { if (hasBuffer && !hasString) { return new globalThis.TextDecoder().decode( - globalThis.Bun.concatArrayBuffers(array) + @Bun.concatArrayBuffers(array) ); } // worst case: mixed content - var arrayBufferSink = new globalThis.Bun.ArrayBufferSink(); + var arrayBufferSink = new @Bun.ArrayBufferSink(); arrayBufferSink.start({ highWaterMark: estimatedLength, asUint8Array: true, @@ -1440,7 +1440,7 @@ function initializeArrayBufferStream(underlyingSource, highWaterMark) { highWaterMark && typeof highWaterMark === "number" ? { highWaterMark, stream: true, asUint8Array: true } : { stream: true, asUint8Array: true }; - var sink = new globalThis.Bun.ArrayBufferSink(); + var sink = new @Bun.ArrayBufferSink(); sink.start(opts); var controller = { @@ -1972,7 +1972,7 @@ function readableStreamIntoText(stream) { function readableStreamToArrayBufferDirect(stream, underlyingSource) { "use strict"; - var sink = new globalThis.Bun.ArrayBufferSink(); + var sink = new @Bun.ArrayBufferSink(); @putByIdDirectPrivate(stream, "underlyingSource", @undefined); var highWaterMark = @getByIdDirectPrivate(stream, "highWaterMark"); sink.start(highWaterMark ? { highWaterMark } : {}); |