Files
scriptc/packages/compiler/ambient/node-fallback/stream-web.d.ts
T
Chris Tate 9ca9c7af9d Run JavaScript web streams on a native ReadableStream
In JavaScript sources, ReadableStream, ReadableStreamDefaultReader,
ReadableStreamDefaultController, CountQueuingStrategy and
ByteLengthQueuingStrategy (globals and node:stream/web exports) are class
values over a new runtime unit, scr_webstreams.c, which follows Node 24's
webstreams step by step: underlying sources, queuing strategies, default
readers, tee, ReadableStream.from and async iteration settle their promises
in Node's order. scr_dyn_handle_class.c gives a dyn handle tag a
constructor value with a prototype, brand checks and Node's constructor
errors. Stream state carries cycle headers, so the collector reclaims
streams whose callbacks close over their controllers.

Promise steps run as native promise reactions, a variant of scr_async.c
that only programs with web streams link; every other program links the
default object. TypeScript sources keep their static web stream lowerings.
Byte streams, BYOB readers, pipeTo and pipeThrough throw SC2020.

node24-web-stream-readers and node24-web-stream-readable-lifecycle now
match Node.
2026-10-27 06:53:26 -05:00

37 lines
2.4 KiB
TypeScript

/* node:stream/web — the module exports the web stream globals themselves
* (require("stream/web").ReadableStream === globalThis.ReadableStream). */
declare module "stream/web" {
export const ReadableStream: typeof globalThis.ReadableStream;
export type ReadableStream<T = unknown> = globalThis.ReadableStream<T>;
export const ReadableStreamDefaultReader: typeof globalThis.ReadableStreamDefaultReader;
export type ReadableStreamDefaultReader<T = unknown> = globalThis.ReadableStreamDefaultReader<T>;
export const ReadableStreamDefaultController: typeof globalThis.ReadableStreamDefaultController;
export type ReadableStreamDefaultController<T = unknown> =
globalThis.ReadableStreamDefaultController<T>;
export const WritableStream: typeof globalThis.WritableStream;
export type WritableStream<W = unknown> = globalThis.WritableStream<W>;
export const WritableStreamDefaultWriter: typeof globalThis.WritableStreamDefaultWriter;
export type WritableStreamDefaultWriter<W = unknown> = globalThis.WritableStreamDefaultWriter<W>;
export const WritableStreamDefaultController: typeof globalThis.WritableStreamDefaultController;
export type WritableStreamDefaultController = globalThis.WritableStreamDefaultController;
export const TransformStream: typeof globalThis.TransformStream;
export type TransformStream<I = unknown, O = unknown> = globalThis.TransformStream<I, O>;
export const TransformStreamDefaultController: typeof globalThis.TransformStreamDefaultController;
export type TransformStreamDefaultController<O = unknown> =
globalThis.TransformStreamDefaultController<O>;
export const CountQueuingStrategy: typeof globalThis.CountQueuingStrategy;
export type CountQueuingStrategy = globalThis.CountQueuingStrategy;
export const ByteLengthQueuingStrategy: typeof globalThis.ByteLengthQueuingStrategy;
export type ByteLengthQueuingStrategy = globalThis.ByteLengthQueuingStrategy;
export const TextEncoderStream: typeof globalThis.TextEncoderStream;
export type TextEncoderStream = globalThis.TextEncoderStream;
export const TextDecoderStream: typeof globalThis.TextDecoderStream;
export type TextDecoderStream = globalThis.TextDecoderStream;
export type UnderlyingSource<T = unknown> = globalThis.UnderlyingSource<T>;
export type QueuingStrategy<T = unknown> = globalThis.QueuingStrategy<T>;
}
declare module "node:stream/web" {
export * from "stream/web";
}