mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
Under the general stream representation, NodeJS.ReadableStream and NodeJS.WritableStream compile as the runtime Readable and Writable classes, so a JavaScript stream object (a constructor-function stream, a plain object with on/pipe, a stream from bundled npm code) passed through a TypeScript function typed with them took the checked unwrap and threw. A program that moves an untyped value into a runtime stream class slot, or passes an untyped pipe() destination or pipeline stage, now lowers once more with checked-dynamic stream slots: the two interfaces (and intersections over them) map to dyn. A native stream rides its typed capsule and keeps its identity; any other value is the JavaScript object itself. Member calls dispatch per value: stream.dynNative tests for a boxed native stream, which takes the ordinary class-method lowering; other values call their own member through dynInvoke. pipe() into a JavaScript destination follows Node's Readable.prototype.pipe listener protocol (stream.pipeDyn). for await and pipeline stages keep the not-supported error for values that are not native streams. The runtime code lives in scr_stream_dyn.c behind a new streamDyn feature, so programs without these libCalls link the same objects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>