wasm-mumu
Minimal WebAssembly wrapper for the MuMu/Lava interpreter. It compiles the Rust interpreter to WebAssembly and exposes a tiny JS API.
What’s included
- Browser-safe interpreter surface (no dynamic
extend(…), no filesystem). - WASM class
WasmMumuwith:new(verbose: boolean)exec(code: string)→ result objectpoll()to progress iterator printing
- Result object shape:
{ ok, value, value_string, value_type, prints }.
Build
You’ll need wasm-pack:
cargo install wasm-pack
wasm-pack build --release --target web
This produces pkg/wasm_mumu.js and pkg/wasm_mumu_bg.wasm.
Quick test (no bundler)
- Create a simple demo page under
web/(see example below). - Build assets directly into
web/pkg:
wasm-pack build --release --target web --out-dir web/pkg
- Serve the folder with any static server and open it in a browser:
cd web
python3 -m http.server 8080
# open http://localhost:8080
Example: web/index.html
<!doctype html>
MuMu WASM demo
slog( 1 + 2 * 3 )
Run
JS API
-
new WasmMumu(verbose: boolean): create an interpreter instance. -
exec(source: string): executes MuMu/Lava code and returns:{ "ok": true, "value": { "...": "JSON view of the final Value" }, "value_string": "pretty printed value", "value_type": "short type name", "prints": ["... lines produced by slog/sput ..."] } -
poll(): run non-blocking iterator printers once; returns number of items printed this tick.
Notes
- Not available in the browser (initially):
extend(...)(native/dlopen) andinclude(...)(filesystem). These can be added later via WASM Components (for plugins) andfetch-backed includes. slog/sputstill populateprintsin the result; prefer reading that buffer for UI output.- If your core engine crate path differs, update the dependency path in
Cargo.toml.
MIT or Apache-2.0, at your option.