A web client running the Rust engine as WebAssembly
Context and problem
Early on day 2, a web client joined the roadmap, built alongside online play. Under 0001 every platform writes its own rules, so a browser game would normally mean a fourth copy, in TypeScript, held to the same spec.
Options considered
- A fourth copy of the rules in TypeScript. The Reflex pattern applied once more. Writing the rules a fourth time didn’t appeal.
- The Rust rules engine compiled to WebAssembly, with a small React app that sends it the same commands as the command-line tools.
Decision
We chose option 2 (decided 19 November 2026, #35): React and Vite over the Rust core compiled to WebAssembly.
rust/canasta-wasm(wasm-bindgen) wraps the same code pathcanasta-cliuses, so the browser speaks the CLI protocol (spec/protocol/cli.md) line for line (#40).- The crate reads no files, clock or OS randomness: rule sets come in as JSON and seeds come from the caller.
web/is the React app: the table, solo play, saved games and online play.
Consequences
Good
- No fourth copy of the rules to write and keep in step.
- The same behaviour tests that drive the Swift, Kotlin and Rust tools drive the WebAssembly build directly (#42). One test that only makes sense for an operating-system process is skipped, and the Wasm build gets its own check instead: the module may not import any network functions.
- Playwright plays full hands in a real browser, with an accessibility scan that caught two real problems (#46).
Bad
- The web is not an independent check of the rules. It runs the Rust engine, so a bug in
canasta-rulesshows up on the server and the web at once, and only Swift and Kotlin can disagree with it. - The engine is heavy for a web page:
canasta_wasm_bg.wasmis about 818 kB (234 kB gzipped) on/canasta, which is why it loads only on game pages (0008). - Building the web game needs a Rust toolchain, the
wasm32-unknown-unknowntarget and awasm-bindgen-clithat matchesCargo.lock, on every machine and on Vercel. - The web is the one platform that breaks the “own copy per platform” rule, so it is an exception to explain to anyone who reads 0001.