Add optional WHATWG Streams polyfill - #208
Open
matthargett wants to merge 5 commits into
Open
matthargett wants to merge 5 commits into
matthargett wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new optional Web Streams polyfill module to JsRuntimeHost, embedding the ES5 web-streams-polyfill ponyfill at build time and initializing it only when required, plus adds unit coverage for core Streams behaviors.
Changes:
- Introduces a new
Streamspolyfill library that embeds and evaluates a pinnedweb-streams-polyfillponyfill bundle. - Adds a new CMake option (
JSRUNTIMEHOST_POLYFILL_STREAMS) and wires the Streams target into the build and unit tests. - Adds C++ and TypeScript unit tests covering constructor presence and selected Streams semantics (queueing, tee, backpressure, BYOB, subclassing, invalid enqueues).
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/UnitTests/Shared/Shared.cpp | Initializes Streams polyfill in the JS test runtime and adds a C++ idempotence/constructor-preservation test. |
| Tests/UnitTests/Scripts/tests.ts | Adds focused Web Streams behavior tests adapted from WPT and browser regressions. |
| Tests/UnitTests/CMakeLists.txt | Links the new Streams polyfill library into the UnitTests target. |
| Polyfills/Streams/ThirdParty/web-streams-polyfill/ponyfill.es5.js | Vendors the pinned ES5 ponyfill bundle. |
| Polyfills/Streams/ThirdParty/web-streams-polyfill/LICENSE | Adds upstream MIT license text. |
| Polyfills/Streams/Source/StreamsScripts.h.in | Generates embedded JS source storage with compile-time concatenation. |
| Polyfills/Streams/Source/Streams.cpp | Implements Streams::Initialize to conditionally evaluate and install globals. |
| Polyfills/Streams/README.md | Documents the Streams polyfill scope and pinned upstream revisions. |
| Polyfills/Streams/Include/Babylon/Polyfills/Streams.h | Public header exposing Streams::Initialize. |
| Polyfills/Streams/CMakeLists.txt | Adds Streams library build rules and embeds the JS ponyfill at configure time. |
| Polyfills/CMakeLists.txt | Conditionally adds the Streams subdirectory based on the new option. |
| CMakeLists.txt | Adds JSRUNTIMEHOST_POLYFILL_STREAMS option. |
Files not reviewed (1)
- Polyfills/Streams/ThirdParty/web-streams-polyfill/ponyfill.es5.js: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jul 22, 2026
Vendor the ES5 web-streams-polyfill 4.3.0 ponyfill and expose an idempotent Streams initializer that preserves constructors supplied by the selected JavaScript engine. Cover readable, writable, transform, BYOB, error, tee, subclassing, and host-constructor behavior with focused ports from WPT plus Firefox and Chromium regression tests. Validate the implementation on JavaScriptCore under ASan/UBSan and QuickJS Release.
Replace a partial or null host Streams surface as a complete constructor suite so stream products retain compatible instanceof relationships. Preserve a complete suite on repeated initialization.\n\nHarden the native initialization test so N-API failures complete the test promise instead of hanging, and cover partial host replacement plus null handling and cross-constructor compatibility.
matthargett
force-pushed
the
web-streams-polyfill
branch
from
September 13, 2026 07:12
67b25cc to
54c2d6e
Compare
matthargett
force-pushed
the
web-streams-polyfill
branch
from
September 13, 2026 07:58
abb49db to
18412cb
Compare
…nto the Android test host MSVC caps a single string literal at 16,380 bytes (C2026) and a concatenated one at 65,535; the 71 KB bundle was emitted as two 60,000/11,188-byte raw strings, so every Windows and UWP job failed at "Build Solution". CMake now emits consecutive parts of at most 16,000 bytes, abutting with no separator (the split stays byte-transparent), and a variadic consteval Join reassembles them into the same std::array as before. The desktop UnitTests target links Streams for the Shared.cpp coverage but the Android UnitTestsJNI host did not, so the Android build failed on the include.
matthargett
force-pushed
the
web-streams-polyfill
branch
from
September 13, 2026 07:58
18412cb to
9b273a4
Compare
This was referenced Sep 26, 2026
…abylonJS#257) The Streams suite moves from the monolithic tests.ts to Source/Scripts/tests.streams.ts, the native idempotency test to Source/Tests.Streams.cpp, and the JavaScript suite initializes Streams before Blob/File (Blob.stream() and Response bodies build on it) in Source/Tests.JavaScript.cpp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optional WHATWG Streams polyfill:
ReadableStream,WritableStream,TransformStream, BYOB, controllers, readers/writers and queuing strategies.web-streams-polyfill4.3.0 ponyfill (based on the WHATWG reference implementation) and only fills constructors the selected engine does not supply.Blob.stream,Responseand decompression support, and browser-targeted Babylon.js apps become more likely to just work.Tests
tests.streams.tsandTests.Streams.cpp; validated on JavaScriptCore under ASan/UBSan and on QuickJS Release.Stack
First of the polyfill series: this → #211 Compression and #209 Blob streaming → #210 Headers/Response → #212
data:fetch → #258 Worker. Current withmain@ 62818ee (#257's per-feature test layout).