Files
scriptc/tests/library-mode/wasm/lib.ts
Chris Tate c7b11a9242 Compile embeddable Wasm modules with host imports
- Emit callable Wasm reactors with explicit exports, host callbacks, and independent instance memory.
- Compile three.js scene and geometry workloads into Wasm without an embedded JavaScript engine.
- Document initialization, memory ownership, and external browser hosting.
2026-09-30 01:09:15 -05:00

25 lines
608 B
TypeScript

declare function adjust(value: number): number;
declare function report(message: string, data: Uint8Array, flag: boolean): void;
let total = 7;
export function step(value: number): number {
total += adjust(value);
return total;
}
export function echo(value: string): string {
return "wasm:" + value;
}
export function bytes(value: Uint8Array): Uint8Array {
const output = new Uint8Array(value.length);
for (let i = 0; i < value.length; i++) output[i] = value[i] + 1;
report("hello λ", output, true);
return output;
}
export function fail(): void {
throw new Error("reactor failure");
}