@caputchin/replay-wasm
v0.3.0
Published
Generic host glue for a Caputchin headless WASM replay artifact: precompiled-module instantiation, linear-memory marshalling over the cap_alloc/cap_run C-ABI, and gzip+base64 inline decode.
Maintainers
Readme
@caputchin/replay-wasm
Generic host glue for a Caputchin headless WASM replay artifact. A game whose
sim compiles to WASM (the strongest determinism path - the same .wasm runs in
the browser and on the server) uses this kit to turn the module into the one
conforming run(seed, config, trace) the platform replays.
It pairs with the caputchin-replay-rs authoring crate (which
emits the cap_alloc / cap_run C-ABI this kit marshals into) and the
@caputchin/replay-contract types.
What it provides
runWithModule(module, seed, configInts, trace)- instantiate a precompiledWebAssembly.Module, marshal the seed / config / trace across thecap_alloc/cap_runlinear-memory C-ABI, and read back theVerdict. A game'srunis typically one line over this.inflateWasm(...)- decode a gzip + base64 INLINE wasm payload. A replayable artifact often inlines its.wasm(the replay isolate forbids runtime byte-compilation and network fetch), and this inflates it for instantiation.toBytes(...)- the byte-marshalling helper the above share.- Re-exports the contract types (
Seed,Verdict,RunFn) for one import site.
Usage
import { runWithModule } from '@caputchin/replay-wasm';
import type { RunFn } from '@caputchin/replay-contract';
import wasmModule from './sim.wasm'; // precompiled module (loader/build provides it)
export const run: RunFn = (seed, config, trace) =>
runWithModule(wasmModule, seed, configToInts(config), trace);The WASM module must export the cap_alloc / cap_run C-ABI (the
caputchin-replay-rs crate generates it from a deterministic Rust sim).
