Files
scriptc/tests/fixtures/opentui/native.ts
Chris Tate be1426a5cb feat(compiler): advance static OpenTUI support
- Extend native FFI with additional scalar widths and writable byte spans.
- Compile stored text codecs and supported bundled module patterns without a JavaScript engine.
- Document supported limits.
2026-09-27 21:49:40 -05:00

20 lines
996 B
TypeScript

declare function nativeCreate(): number;
declare function nativeDestroy(handle: number): void;
declare function nativeAppend(handle: number, text: string): void;
declare function nativeRead(handle: number, target: Uint8Array): number;
declare function nativeRender(text: string, target: Uint8Array): number;
const handle = nativeCreate();
if (handle === 0) throw new Error("OpenTUI text buffer creation failed");
// Temporary strings exercise the adapter's retained copies.
nativeAppend(handle, ["Hello", ", "].join(""));
nativeAppend(handle, ["scriptc!", " café 🎉"].join(""));
const output = new Uint8Array(128);
const written = nativeRead(handle, output.subarray(3));
console.log(new TextDecoder().decode(output.subarray(3, 3 + written)));
console.log(output[0], output[1], output[2]);
nativeDestroy(handle);
const frame = new Uint8Array(256);
const frameLength = nativeRender("Hello, static OpenTUI!", frame);
console.log(new TextDecoder().decode(frame.subarray(0, frameLength)).trim());