mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
`process.stdout.write(data)`/`process.stderr.write(data)` with a chunk whose type is only known at run time (`any`, or a `string | Uint8Array` union) was refused. Lower the one-argument form to the new `process.stdioWriteDyn` libCall, and factor the existing stdio write method's dispatch into `scr_stdio_write_call` so both share Node's Writable validation: a string or a Uint8Array/Buffer writes its bytes, null throws ERR_STREAM_NULL_VALUES, and any other value throws ERR_INVALID_ARG_TYPE, all before anything is written. `scr_stdio_write_call` keeps its exact statements, so it is only the call sites that change; programs that contain a JS stdio value and link the events unit may differ (their write method's bytes). Corpus: `tests/corpus/process-write-dynamic-chunks.ts` covers strings, Buffer, Uint8Array, a string | Uint8Array union, a JSON field, and the four invalid chunks with their codes and messages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>