aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/builtins/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/builtins/cpp')
-rw-r--r--src/bun.js/builtins/cpp/ProcessObjectBuiltins.cpp62
-rw-r--r--src/bun.js/builtins/cpp/ProcessObjectBuiltins.h119
-rw-r--r--src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp134
-rw-r--r--src/bun.js/builtins/cpp/ReadableStreamBuiltins.h27
-rw-r--r--src/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.cpp41
-rw-r--r--src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp73
-rw-r--r--src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.h9
-rw-r--r--src/bun.js/builtins/cpp/WebCoreJSBuiltins.h4
8 files changed, 452 insertions, 17 deletions
diff --git a/src/bun.js/builtins/cpp/ProcessObjectBuiltins.cpp b/src/bun.js/builtins/cpp/ProcessObjectBuiltins.cpp
new file mode 100644
index 000000000..18463bb9d
--- /dev/null
+++ b/src/bun.js/builtins/cpp/ProcessObjectBuiltins.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015 Igalia
+ * Copyright (c) 2015 Igalia S.L.
+ * Copyright (c) 2015 Igalia.
+ * Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
+ * Copyright (c) 2015, 2016, 2017 Canon Inc.
+ * Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
+ * Copyright (c) 2022 Codeblog Corp. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
+// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
+
+#include "config.h"
+#include "ProcessObjectBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/ImplementationVisibility.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().processObjectBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().processObjectBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/bun.js/builtins/cpp/ProcessObjectBuiltins.h b/src/bun.js/builtins/cpp/ProcessObjectBuiltins.h
new file mode 100644
index 000000000..da852b83e
--- /dev/null
+++ b/src/bun.js/builtins/cpp/ProcessObjectBuiltins.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2015 Igalia
+ * Copyright (c) 2015 Igalia S.L.
+ * Copyright (c) 2015 Igalia.
+ * Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
+ * Copyright (c) 2015, 2016, 2017 Canon Inc.
+ * Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
+ * Copyright (c) 2022 Codeblog Corp. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
+// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
+
+#pragma once
+
+#include <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ProcessObject */
+
+#define WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_DATA(macro) \
+
+
+#define WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_CODE(macro) \
+
+#define WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_FUNCTION_NAME(macro) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ProcessObjectBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ProcessObjectBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
+ WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
+#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
+ {
+ }
+
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+ JSC::UnlinkedFunctionExecutable* name##Executable(); \
+ const JSC::SourceCode& name##Source() const { return m_##name##Source; }
+ WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ProcessObjectBuiltinsWrapper::name##Executable() \
+{\
+ if (!m_##name##Executable) {\
+ JSC::Identifier executableName = functionName##PublicName();\
+ if (overriddenName)\
+ executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
+ m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
+ }\
+ return m_##name##Executable.get();\
+}
+WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ProcessObjectBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_PROCESSOBJECT_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp
index 830fbfd51..03dcd26cb 100644
--- a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp
+++ b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp
@@ -211,6 +211,106 @@ const char* const s_readableStreamReadableStreamToBlobCode =
"})\n" \
;
+const JSC::ConstructAbility s_readableStreamReadableStreamToNodeReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamReadableStreamToNodeReadableCodeConstructorKind = JSC::ConstructorKind::None;
+const JSC::ImplementationVisibility s_readableStreamReadableStreamToNodeReadableCodeImplementationVisibility = JSC::ImplementationVisibility::Private;
+const int s_readableStreamReadableStreamToNodeReadableCodeLength = 2476;
+static const JSC::Intrinsic s_readableStreamReadableStreamToNodeReadableCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamReadableStreamToNodeReadableCode =
+ "(function (stream) {\n" \
+ " \"use strict\";\n" \
+ " var {Readable} = @require(\"node:stream\");\n" \
+ "\n" \
+ " var Prototype = class ReadableNodeStream extends Readable {\n" \
+ " #reader;\n" \
+ " #stream;\n" \
+ " #pushed;\n" \
+ " #boundOnData;\n" \
+ " #scheduledRead;\n" \
+ " constructor(stream) {\n" \
+ " super();\n" \
+ " this.#stream = stream;\n" \
+ " this.#reader = @undefined;\n" \
+ " this.#pushed = [];\n" \
+ " this.#boundOnData = (result) => this.#onData(result);\n" \
+ " this.#scheduledRead = false;\n" \
+ " }\n" \
+ "\n" \
+ " _read(size = 0) {\n" \
+ " if (!this.#reader) {\n" \
+ " this.#reader = this.#stream.getReader();\n" \
+ " }\n" \
+ "\n" \
+ " const pushed = this.#pushed;\n" \
+ " const pending = pushed.length;\n" \
+ " for (let i = 0; i < pending; i++) {\n" \
+ " if (!this.push(pushed[i])) {\n" \
+ " pushed.splice(0, i);\n" \
+ " return;\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " this.#scheduleRead();\n" \
+ " }\n" \
+ "\n" \
+ " #handleData(value) {\n" \
+ " var i = 0;\n" \
+ " const expectedCount = this.#pushed.length;\n" \
+ " var pushed = this.#pushed;\n" \
+ " try {\n" \
+ " for (i; i < expectedCount; i++) {\n" \
+ " var item = pushed[i];\n" \
+ " if (!this.push(item)) {\n" \
+ " return false;\n" \
+ " }\n" \
+ " }\n" \
+ " } catch(e) {\n" \
+ " this.error(e);\n" \
+ " return false;\n" \
+ " } finally {\n" \
+ " this.#pushed.splice(0, i);\n" \
+ " if (this.#pushed.length > 0) {\n" \
+ " this.#pushed.push(...value);\n" \
+ " return false;\n" \
+ " }\n" \
+ "\n" \
+ " }\n" \
+ "\n" \
+ " const valueLength = value.length;\n" \
+ " for (i = 0; i < valueLength; i++) {\n" \
+ " if (!this.push(value[i])) {\n" \
+ " this.#pushed.push(...value.slice(i));\n" \
+ " return false;\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " return true;\n" \
+ " }\n" \
+ "\n" \
+ " #onData({done, value}) {\n" \
+ " this.#scheduledRead = false;\n" \
+ "\n" \
+ " if (done) {\n" \
+ " this.destroy(@undefined);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " if (!this.#handleData(value)) {\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " this.#scheduleRead();\n" \
+ " }\n" \
+ "\n" \
+ " #scheduleRead() {\n" \
+ " if (this.#scheduledRead) return;\n" \
+ " this.#scheduledRead = true;\n" \
+ " this.#reader.readMany().@then(this.#onData, this.error);\n" \
+ " }\n" \
+ " };\n" \
+ "})\n" \
+;
+
const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamConsumeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamConsumeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private;
@@ -563,6 +663,40 @@ const char* const s_readableStreamLockedCode =
"})\n" \
;
+const JSC::ConstructAbility s_readableStreamValuesCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamValuesCodeConstructorKind = JSC::ConstructorKind::None;
+const JSC::ImplementationVisibility s_readableStreamValuesCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
+const int s_readableStreamValuesCodeLength = 249;
+static const JSC::Intrinsic s_readableStreamValuesCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamValuesCode =
+ "(function (options) {\n" \
+ " \"use strict\";\n" \
+ " var prototype = this?.constructor?.prototype;\n" \
+ " if (!prototype) {\n" \
+ " return @undefined;\n" \
+ " }\n" \
+ " @readableStreamDefineLazyIterators(prototype);\n" \
+ " return prototype.values.@call(this, options);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamLazyAsyncIteratorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamLazyAsyncIteratorCodeConstructorKind = JSC::ConstructorKind::None;
+const JSC::ImplementationVisibility s_readableStreamLazyAsyncIteratorCodeImplementationVisibility = JSC::ImplementationVisibility::Private;
+const int s_readableStreamLazyAsyncIteratorCodeLength = 259;
+static const JSC::Intrinsic s_readableStreamLazyAsyncIteratorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamLazyAsyncIteratorCode =
+ "(function () {\n" \
+ " \"use strict\";\n" \
+ " var prototype = this?.constructor?.prototype;\n" \
+ " if (!prototype) {\n" \
+ " return @undefined;\n" \
+ " }\n" \
+ " @readableStreamDefineLazyIterators(prototype);\n" \
+ " return prototype[globalThis.Symbol.asyncIterator].@call(this);\n" \
+ "})\n" \
+;
+
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
diff --git a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.h b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.h
index 4a7935e83..503cdfd97 100644
--- a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.h
+++ b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.h
@@ -77,6 +77,11 @@ extern const int s_readableStreamReadableStreamToBlobCodeLength;
extern const JSC::ConstructAbility s_readableStreamReadableStreamToBlobCodeConstructAbility;
extern const JSC::ConstructorKind s_readableStreamReadableStreamToBlobCodeConstructorKind;
extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToBlobCodeImplementationVisibility;
+extern const char* const s_readableStreamReadableStreamToNodeReadableCode;
+extern const int s_readableStreamReadableStreamToNodeReadableCodeLength;
+extern const JSC::ConstructAbility s_readableStreamReadableStreamToNodeReadableCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamReadableStreamToNodeReadableCodeConstructorKind;
+extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToNodeReadableCodeImplementationVisibility;
extern const char* const s_readableStreamConsumeReadableStreamCode;
extern const int s_readableStreamConsumeReadableStreamCodeLength;
extern const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility;
@@ -122,6 +127,16 @@ extern const int s_readableStreamLockedCodeLength;
extern const JSC::ConstructAbility s_readableStreamLockedCodeConstructAbility;
extern const JSC::ConstructorKind s_readableStreamLockedCodeConstructorKind;
extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementationVisibility;
+extern const char* const s_readableStreamValuesCode;
+extern const int s_readableStreamValuesCodeLength;
+extern const JSC::ConstructAbility s_readableStreamValuesCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamValuesCodeConstructorKind;
+extern const JSC::ImplementationVisibility s_readableStreamValuesCodeImplementationVisibility;
+extern const char* const s_readableStreamLazyAsyncIteratorCode;
+extern const int s_readableStreamLazyAsyncIteratorCodeLength;
+extern const JSC::ConstructAbility s_readableStreamLazyAsyncIteratorCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamLazyAsyncIteratorCodeConstructorKind;
+extern const JSC::ImplementationVisibility s_readableStreamLazyAsyncIteratorCodeImplementationVisibility;
#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_DATA(macro) \
macro(initializeReadableStream, readableStreamInitializeReadableStream, 2) \
@@ -130,6 +145,7 @@ extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementat
macro(readableStreamToArrayBuffer, readableStreamReadableStreamToArrayBuffer, 1) \
macro(readableStreamToJSON, readableStreamReadableStreamToJSON, 1) \
macro(readableStreamToBlob, readableStreamReadableStreamToBlob, 1) \
+ macro(readableStreamToNodeReadable, readableStreamReadableStreamToNodeReadable, 1) \
macro(consumeReadableStream, readableStreamConsumeReadableStream, 3) \
macro(createEmptyReadableStream, readableStreamCreateEmptyReadableStream, 0) \
macro(createNativeReadableStream, readableStreamCreateNativeReadableStream, 3) \
@@ -139,6 +155,8 @@ extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementat
macro(pipeTo, readableStreamPipeTo, 1) \
macro(tee, readableStreamTee, 0) \
macro(locked, readableStreamLocked, 0) \
+ macro(values, readableStreamValues, 1) \
+ macro(lazyAsyncIterator, readableStreamLazyAsyncIterator, 0) \
#define WEBCORE_BUILTIN_READABLESTREAM_INITIALIZEREADABLESTREAM 1
#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOARRAY 1
@@ -146,6 +164,7 @@ extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementat
#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOARRAYBUFFER 1
#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOJSON 1
#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOBLOB 1
+#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTONODEREADABLE 1
#define WEBCORE_BUILTIN_READABLESTREAM_CONSUMEREADABLESTREAM 1
#define WEBCORE_BUILTIN_READABLESTREAM_CREATEEMPTYREADABLESTREAM 1
#define WEBCORE_BUILTIN_READABLESTREAM_CREATENATIVEREADABLESTREAM 1
@@ -155,6 +174,8 @@ extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementat
#define WEBCORE_BUILTIN_READABLESTREAM_PIPETO 1
#define WEBCORE_BUILTIN_READABLESTREAM_TEE 1
#define WEBCORE_BUILTIN_READABLESTREAM_LOCKED 1
+#define WEBCORE_BUILTIN_READABLESTREAM_VALUES 1
+#define WEBCORE_BUILTIN_READABLESTREAM_LAZYASYNCITERATOR 1
#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(macro) \
macro(readableStreamInitializeReadableStreamCode, initializeReadableStream, ASCIILiteral(), s_readableStreamInitializeReadableStreamCodeLength) \
@@ -163,6 +184,7 @@ extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementat
macro(readableStreamReadableStreamToArrayBufferCode, readableStreamToArrayBuffer, ASCIILiteral(), s_readableStreamReadableStreamToArrayBufferCodeLength) \
macro(readableStreamReadableStreamToJSONCode, readableStreamToJSON, ASCIILiteral(), s_readableStreamReadableStreamToJSONCodeLength) \
macro(readableStreamReadableStreamToBlobCode, readableStreamToBlob, ASCIILiteral(), s_readableStreamReadableStreamToBlobCodeLength) \
+ macro(readableStreamReadableStreamToNodeReadableCode, readableStreamToNodeReadable, ASCIILiteral(), s_readableStreamReadableStreamToNodeReadableCodeLength) \
macro(readableStreamConsumeReadableStreamCode, consumeReadableStream, ASCIILiteral(), s_readableStreamConsumeReadableStreamCodeLength) \
macro(readableStreamCreateEmptyReadableStreamCode, createEmptyReadableStream, ASCIILiteral(), s_readableStreamCreateEmptyReadableStreamCodeLength) \
macro(readableStreamCreateNativeReadableStreamCode, createNativeReadableStream, ASCIILiteral(), s_readableStreamCreateNativeReadableStreamCodeLength) \
@@ -172,6 +194,8 @@ extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementat
macro(readableStreamPipeToCode, pipeTo, ASCIILiteral(), s_readableStreamPipeToCodeLength) \
macro(readableStreamTeeCode, tee, ASCIILiteral(), s_readableStreamTeeCodeLength) \
macro(readableStreamLockedCode, locked, "get locked"_s, s_readableStreamLockedCodeLength) \
+ macro(readableStreamValuesCode, values, ASCIILiteral(), s_readableStreamValuesCodeLength) \
+ macro(readableStreamLazyAsyncIteratorCode, lazyAsyncIterator, ASCIILiteral(), s_readableStreamLazyAsyncIteratorCodeLength) \
#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(macro) \
macro(cancel) \
@@ -180,6 +204,7 @@ extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementat
macro(createNativeReadableStream) \
macro(getReader) \
macro(initializeReadableStream) \
+ macro(lazyAsyncIterator) \
macro(locked) \
macro(pipeThrough) \
macro(pipeTo) \
@@ -187,8 +212,10 @@ extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementat
macro(readableStreamToArrayBuffer) \
macro(readableStreamToBlob) \
macro(readableStreamToJSON) \
+ macro(readableStreamToNodeReadable) \
macro(readableStreamToText) \
macro(tee) \
+ macro(values) \
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
diff --git a/src/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.cpp
index 436de27e0..b1914d83d 100644
--- a/src/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.cpp
+++ b/src/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.cpp
@@ -93,7 +93,7 @@ const char* const s_readableStreamDefaultReaderCancelCode =
const JSC::ConstructAbility s_readableStreamDefaultReaderReadManyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamDefaultReaderReadManyCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
-const int s_readableStreamDefaultReaderReadManyCodeLength = 3712;
+const int s_readableStreamDefaultReaderReadManyCodeLength = 4130;
static const JSC::Intrinsic s_readableStreamDefaultReaderReadManyCodeIntrinsic = JSC::NoIntrinsic;
const char* const s_readableStreamDefaultReaderReadManyCode =
"(function ()\n" \
@@ -117,25 +117,34 @@ const char* const s_readableStreamDefaultReaderReadManyCode =
"\n" \
" \n" \
" var controller = @getByIdDirectPrivate(stream, \"readableStreamController\");\n" \
+ " var queue = @getByIdDirectPrivate(controller, \"queue\");\n" \
+ " \n" \
+ " if (!queue) {\n" \
+ " return controller.@pull(\n" \
+ " controller\n" \
+ " ).@then(\n" \
+ " ({done, value}) => (done ? { done: true, value: [], size: 0 } : { value: [value], size: 1, done: false }));\n" \
+ " }\n" \
"\n" \
- " const content = @getByIdDirectPrivate(controller, \"queue\").content;\n" \
- " var size = @getByIdDirectPrivate(controller, \"queue\").size;\n" \
+ " const content = queue.content;\n" \
+ " var size = queue.size;\n" \
" var values = content.toArray(false);\n" \
+ " \n" \
" var length = values.length;\n" \
"\n" \
" if (length > 0) {\n" \
- "\n" \
+ " var outValues = @newArrayWithSize(length);\n" \
" if (@isReadableByteStreamController(controller)) {\n" \
- " for (var i = 0; i < value.length; i++) {\n" \
- " const buf = value[i];\n" \
+ " for (var i = 0; i < length; i++) {\n" \
+ " const buf = values[i];\n" \
" if (!(@ArrayBuffer.@isView(buf) || buf instanceof @ArrayBuffer)) {\n" \
- " value[i] = new @Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n" \
+ " @putByValDirect(outValues, i, @Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));\n" \
" }\n" \
" }\n" \
" } else {\n" \
- " values[0] = values[0].value;\n" \
- " for (var i = 1; i < values.length; i++) {\n" \
- " values[i] = values[i].value;\n" \
+ " @putByValDirect(outValues, 0, values[0].value);\n" \
+ " for (var i = 1; i < length; i++) {\n" \
+ " @putByValDirect(outValues, i, values[i].value);\n" \
" }\n" \
" }\n" \
" \n" \
@@ -148,7 +157,7 @@ const char* const s_readableStreamDefaultReaderReadManyCode =
" else if (@isReadableByteStreamController(controller))\n" \
" @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
"\n" \
- " return {value: values, size, done: false};\n" \
+ " return {value: outValues, size, done: false};\n" \
" }\n" \
"\n" \
" var onPullMany = (result) => {\n" \
@@ -159,17 +168,19 @@ const char* const s_readableStreamDefaultReaderReadManyCode =
" \n" \
" var queue = @getByIdDirectPrivate(controller, \"queue\");\n" \
" var value = [result.value].concat(queue.content.toArray(false));\n" \
+ " var length = value.length;\n" \
"\n" \
" if (@isReadableByteStreamController(controller)) {\n" \
- " for (var i = 0; i < value.length; i++) {\n" \
+ " for (var i = 0; i < length; i++) {\n" \
" const buf = value[i];\n" \
" if (!(@ArrayBuffer.@isView(buf) || buf instanceof @ArrayBuffer)) {\n" \
- " value[i] = new @Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n" \
+ " const {buffer, byteOffset, byteLength} = buf;\n" \
+ " @putByValDirect(value, i, new @Uint8Array(buffer, byteOffset, byteLength));\n" \
" }\n" \
" }\n" \
" } else {\n" \
- " for (var i = 1; i < value.length; i++) {\n" \
- " value[i] = value[i].value;\n" \
+ " for (var i = 1; i < length; i++) {\n" \
+ " @putByValDirect(value, i, value[i].value);\n" \
" }\n" \
" }\n" \
" \n" \
diff --git a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp
index 751a2a895..f1cc09349 100644
--- a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp
+++ b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp
@@ -1938,7 +1938,7 @@ const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode
const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
-const int s_readableStreamInternalsReadableStreamCancelCodeLength = 505;
+const int s_readableStreamInternalsReadableStreamCancelCodeLength = 736;
static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic;
const char* const s_readableStreamInternalsReadableStreamCancelCode =
"(function (stream, reason) {\n" \
@@ -1952,7 +1952,17 @@ const char* const s_readableStreamInternalsReadableStreamCancelCode =
" @readableStreamClose(stream);\n" \
"\n" \
" var controller = @getByIdDirectPrivate(stream, \"readableStreamController\");\n" \
- " return controller.@cancel(controller, reason).@then(function () {});\n" \
+ " var cancel = controller.@cancel;\n" \
+ " if (cancel) {\n" \
+ " return cancel(controller, reason).@then(function () {});\n" \
+ " }\n" \
+ "\n" \
+ " var close = controller.close;\n" \
+ " if (close) {\n" \
+ " return @Promise.@resolve(controller.close(reason));\n" \
+ " }\n" \
+ "\n" \
+ " @throwTypeError(\"ReadableStreamController has no cancel or close method\");\n" \
"})\n" \
;
@@ -2555,6 +2565,65 @@ const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode =
"})\n" \
;
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructorKind = JSC::ConstructorKind::None;
+const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
+const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength = 1651;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode =
+ "(function (prototype) {\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " var asyncIterator = globalThis.Symbol.asyncIterator;\n" \
+ "\n" \
+ " var ReadableStreamAsyncIterator = async function* ReadableStreamAsyncIterator(stream, preventCancel) {\n" \
+ " var reader = stream.getReader();\n" \
+ " var deferredError;\n" \
+ " try {\n" \
+ " while (true) {\n" \
+ " var done, value;\n" \
+ " const firstResult = reader.readMany();\n" \
+ " if (@isPromise(firstResult)) {\n" \
+ " const result = await firstResult;\n" \
+ " done = result.done;\n" \
+ " value = result.value;\n" \
+ " } else {\n" \
+ " done = firstResult.done;\n" \
+ " value = firstResult.value;\n" \
+ " }\n" \
+ "\n" \
+ " if (done) {\n" \
+ " return;\n" \
+ " }\n" \
+ " yield* value;\n" \
+ " }\n" \
+ " } catch(e) {\n" \
+ " deferredError = e;\n" \
+ " } finally {\n" \
+ " reader.releaseLock();\n" \
+ "\n" \
+ " if (!preventCancel) {\n" \
+ " stream.cancel(deferredError);\n" \
+ " }\n" \
+ "\n" \
+ " if (deferredError) {\n" \
+ " throw deferredError;\n" \
+ " }\n" \
+ " }\n" \
+ " };\n" \
+ "\n" \
+ " var createAsyncIterator = function asyncIterator() {\n" \
+ " return ReadableStreamAsyncIterator(this, false);\n" \
+ " };\n" \
+ " var createValues = function values({preventCancel = false} = {preventCancel: false}) {\n" \
+ " return ReadableStreamAsyncIterator(this, preventCancel);\n" \
+ " };\n" \
+ " @Object.@defineProperty(prototype, asyncIterator, { value: createAsyncIterator });\n" \
+ " @Object.@defineProperty(prototype, \"values\", { value: createValues });\n" \
+ " return prototype;\n" \
+ "})\n" \
+;
+
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
diff --git a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.h b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.h
index 335637c81..a617260be 100644
--- a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.h
+++ b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.h
@@ -362,6 +362,11 @@ extern const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength;
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility;
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructorKind;
extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility;
+extern const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode;
+extern const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructorKind;
+extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeImplementationVisibility;
#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_DATA(macro) \
macro(readableStreamReaderGenericInitialize, readableStreamInternalsReadableStreamReaderGenericInitialize, 2) \
@@ -427,6 +432,7 @@ extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStre
macro(readableStreamToArrayBufferDirect, readableStreamInternalsReadableStreamToArrayBufferDirect, 2) \
macro(readableStreamToTextDirect, readableStreamInternalsReadableStreamToTextDirect, 2) \
macro(readableStreamToArrayDirect, readableStreamInternalsReadableStreamToArrayDirect, 2) \
+ macro(readableStreamDefineLazyIterators, readableStreamInternalsReadableStreamDefineLazyIterators, 1) \
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICINITIALIZE 1
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PRIVATEINITIALIZEREADABLESTREAMDEFAULTCONTROLLER 1
@@ -491,6 +497,7 @@ extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStre
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTOARRAYBUFFERDIRECT 1
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTOTEXTDIRECT 1
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTOARRAYDIRECT 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFINELAZYITERATORS 1
#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(macro) \
macro(readableStreamInternalsReadableStreamReaderGenericInitializeCode, readableStreamReaderGenericInitialize, ASCIILiteral(), s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength) \
@@ -556,6 +563,7 @@ extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStre
macro(readableStreamInternalsReadableStreamToArrayBufferDirectCode, readableStreamToArrayBufferDirect, ASCIILiteral(), s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength) \
macro(readableStreamInternalsReadableStreamToTextDirectCode, readableStreamToTextDirect, ASCIILiteral(), s_readableStreamInternalsReadableStreamToTextDirectCodeLength) \
macro(readableStreamInternalsReadableStreamToArrayDirectCode, readableStreamToArrayDirect, ASCIILiteral(), s_readableStreamInternalsReadableStreamToArrayDirectCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefineLazyIteratorsCode, readableStreamDefineLazyIterators, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength) \
#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
macro(acquireReadableStreamDefaultReader) \
@@ -604,6 +612,7 @@ extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStre
macro(readableStreamDefaultControllerShouldCallPull) \
macro(readableStreamDefaultControllerStart) \
macro(readableStreamDefaultReaderRead) \
+ macro(readableStreamDefineLazyIterators) \
macro(readableStreamError) \
macro(readableStreamFulfillReadRequest) \
macro(readableStreamIntoArray) \
diff --git a/src/bun.js/builtins/cpp/WebCoreJSBuiltins.h b/src/bun.js/builtins/cpp/WebCoreJSBuiltins.h
index 2e8d8a578..12e9719d3 100644
--- a/src/bun.js/builtins/cpp/WebCoreJSBuiltins.h
+++ b/src/bun.js/builtins/cpp/WebCoreJSBuiltins.h
@@ -40,6 +40,7 @@
#include "ImportMetaObjectBuiltins.h"
#include "JSBufferConstructorBuiltins.h"
#include "JSBufferPrototypeBuiltins.h"
+#include "ProcessObjectBuiltins.h"
#include "ReadableByteStreamControllerBuiltins.h"
#include "ReadableByteStreamInternalsBuiltins.h"
#include "ReadableStreamBYOBReaderBuiltins.h"
@@ -68,6 +69,7 @@ public:
, m_importMetaObjectBuiltins(m_vm)
, m_jsBufferConstructorBuiltins(m_vm)
, m_jsBufferPrototypeBuiltins(m_vm)
+ , m_processObjectBuiltins(m_vm)
, m_readableByteStreamControllerBuiltins(m_vm)
, m_readableByteStreamInternalsBuiltins(m_vm)
, m_readableStreamBuiltins(m_vm)
@@ -96,6 +98,7 @@ public:
ImportMetaObjectBuiltinsWrapper& importMetaObjectBuiltins() { return m_importMetaObjectBuiltins; }
JSBufferConstructorBuiltinsWrapper& jsBufferConstructorBuiltins() { return m_jsBufferConstructorBuiltins; }
JSBufferPrototypeBuiltinsWrapper& jsBufferPrototypeBuiltins() { return m_jsBufferPrototypeBuiltins; }
+ ProcessObjectBuiltinsWrapper& processObjectBuiltins() { return m_processObjectBuiltins; }
ReadableByteStreamControllerBuiltinsWrapper& readableByteStreamControllerBuiltins() { return m_readableByteStreamControllerBuiltins; }
ReadableByteStreamInternalsBuiltinsWrapper& readableByteStreamInternalsBuiltins() { return m_readableByteStreamInternalsBuiltins; }
ReadableStreamBuiltinsWrapper& readableStreamBuiltins() { return m_readableStreamBuiltins; }
@@ -119,6 +122,7 @@ private:
ImportMetaObjectBuiltinsWrapper m_importMetaObjectBuiltins;
JSBufferConstructorBuiltinsWrapper m_jsBufferConstructorBuiltins;
JSBufferPrototypeBuiltinsWrapper m_jsBufferPrototypeBuiltins;
+ ProcessObjectBuiltinsWrapper m_processObjectBuiltins;
ReadableByteStreamControllerBuiltinsWrapper m_readableByteStreamControllerBuiltins;
ReadableByteStreamInternalsBuiltinsWrapper m_readableByteStreamInternalsBuiltins;
ReadableStreamBuiltinsWrapper m_readableStreamBuiltins;