mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-26 06:34:20 +08:00
- Route explicit TypeScript globalThis escapes through the dynamic island. - Initialize Node globals on first escaped access and cover C and LLVM parity. - Document the island capabilities that remain conditional. Fixes #34 Co-authored-by: ryoppippi <1560508+ryoppippi@users.noreply.github.com>
18 lines
709 B
TypeScript
18 lines
709 B
TypeScript
// @dynamic
|
|
// An explicitly any-typed globalThis binding reaches the island's actual
|
|
// globals, including Node shims even when this program embeds no npm module.
|
|
const host: any = globalThis;
|
|
console.log(typeof host.process, host === (globalThis as any), host.global === host);
|
|
console.log(typeof host.Buffer, host.process === (globalThis as any).process);
|
|
|
|
const decoder: any = new (globalThis as any).TextDecoder("utf-8");
|
|
console.log(`${decoder.decode(new Uint8Array([72, 105]))}`);
|
|
host.process.stdout.write("host write\n");
|
|
console.log(host.__scriptc_absent__ === undefined);
|
|
|
|
function localGlobal(): string {
|
|
const local: any = globalThis;
|
|
return typeof local.Array;
|
|
}
|
|
console.log(localGlobal());
|