mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-22 05:59:31 +08:00
- 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.
25 lines
608 B
TypeScript
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");
|
|
}
|