| Crates.io | wasm-mumu |
| lib.rs | wasm-mumu |
| version | 0.1.1 |
| created_at | 2025-09-04 16:05:13.641722+00 |
| updated_at | 2025-09-04 16:10:49.70127+00 |
| description | WASM wrapper for the MuMu/Lava interpreter |
| homepage | https://lava.nu11.uk |
| repository | https://gitlab.com/tofo/wasm-mumu |
| max_upload_size | |
| id | 1824471 |
| size | 96,741 |
Minimal WebAssembly wrapper for the MuMu/Lava interpreter. It compiles the Rust interpreter to WebAssembly and exposes a tiny JS API.
extend(…), no filesystem).WasmMumu with:
new(verbose: boolean)exec(code: string) → result objectpoll() to progress iterator printing{ ok, value, value_string, value_type, prints }.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.
web/ (see example below).web/pkg:wasm-pack build --release --target web --out-dir web/pkg
cd web
python3 -m http.server 8080
# open http://localhost:8080
web/index.html<!doctype html>
<meta charset="utf-8"/>
<title>MuMu WASM demo</title>
<div>
<textarea id="code" rows="8" cols="80">slog( 1 + 2 * 3 )</textarea><br/>
<button id="run">Run</button>
</div>
<pre id="out"></pre>
<script type="module">
import init, { WasmMumu } from "./pkg/wasm_mumu.js";
const out = document.getElementById('out');
const code = document.getElementById('code');
const runBtn = document.getElementById('run');
await init();
const vm = new WasmMumu(false);
runBtn.onclick = () => {
const res = vm.exec(code.value);
out.textContent = JSON.stringify(res, null, 2);
// drive iterator printing (if any)
let ticks = 0;
const id = setInterval(() => {
const n = vm.poll();
ticks += 1;
if (n === 0 || ticks > 100) clearInterval(id);
}, 16);
};
</script>
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.
extend(...) (native/dlopen) and include(...) (filesystem). These can be added later via WASM Components (for plugins) and fetch-backed includes.slog/sput still populate prints in the result; prefer reading that buffer for UI output.Cargo.toml.MIT or Apache-2.0, at your option.