Repository navigation
feat(std): add WinterTC polyfills for WASI 0.3 components - #2613
Open
MendyBerger wants to merge 4 commits into
Open
MendyBerger wants to merge 4 commits into
MendyBerger wants to merge 4 commits into
Conversation
Polyfill the WinterTC Minimum Common API for engines that lack it, as spec-shaped ES module exports that call WASI 0.3 directly, typed by jco guest-types. URL, URLPattern, compression, legacy decoding and Web Crypto run in composed wasm32-wasip3 components whose WIT ships in wit/wintertc-0.1.0. Pin jco-std to TypeScript 6 for typescript-eslint.
MendyBerger
requested review from
andreiltd and
vados-cosmonic
as code owners
December 3, 2026 23:08
This branch has not been deployed
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.
Adds polyfills for the WinterTC Minimum Common API (ECMA-429) to jco-std, for JavaScript engines in WASI 0.3 components that don't have these APIs built in, such as QuickJS in
jco componentize --backend quickjs.What's included
@bytecodealliance/jco-std/wintertc): spec-shaped ES module exports. They don't install globals yet. Covers events and abort, streams, fetch (Headers,Request,Response,fetch,FormData,Blob/File), encoding,URL/URLSearchParams/URLPattern, compression, Web Crypto, timers,console,performance,MessageChannel,atob/btoa,queueMicrotaskandreportError.wasi:clocks,wasi:random,wasi:cli,wasi:http), typed by the declarationsjco guest-typesgenerates, so any toolchain that follows those types can use them. The places where componentize-qjs differs from the generated types are handled insrc/wintertc/internal/wit.ts:stream<u8>is passed asUint8Arraychunksjco:wintertc/*interfaces, which you compose with your component. These are large pure algorithms that already have mature, spec-conformant implementations: Servo'surl, Deno'surlpattern, Firefox'sencoding_rs, and audited constant-time RustCrypto code. Reusing those beats reimplementing them in JavaScript, which would be slower on QuickJS, and for Web Crypto it keeps key material out of the JS heap. They're built from Rust crates inpackages/jco-std/cratesforwasm32-wasip3, and import only WASI 0.3.prepackbuilds them intowasm/, and their WIT ships inwit/wintertc-0.1.0/.structuredCloneandWebAssembly, which have to come from the engine.MessagePort.postMessage()throwsDataCloneErrorwithout the engine'sstructuredClone.flushOutput(): WASI 0.3 stdout is an async stream andwasmtime runexits whenrunreturns.errorTarget(): there's no global object to fireerrorevents at.disposeCryptoKey(): frees key material early, before garbage collection.User docs:
docs/src/wasi/wintertc.md. Contributor notes:packages/jco-std/src/wintertc/README.md.Testing
All tests run inside real componentize-qjs components under wasmtime, composed with the Rust components:
fetchfrom awasi:httphandler, and WPT.engine:(for example, nostructuredClone) orrunner:.test-jco-std-wintertc. It setsWINTERTC_REQUIRE_TOOLS=1, so a missing tool fails the job instead of skipping tests.Review notes
crates/Cargo.lock, and five small Rust crates. The generated type declarations are gitignored and regenerated bybuild:tsandcheck:wintertc.url/idna) and BSD-3-Clause code (encoding_rs, the dalek crates). Details are on the docs page.release.ymlinstalls the Rust toolchain pinned incrates/rust-toolchain.tomlwhen packing jco-std, soprepackcan build the components. This path hasn't run yet.🤖 Generated with Claude Code