flow-wasm
Skill1 starsChanged 3 months agoMITView on GitHub
Compile a Flow program to WebAssembly and run it in a browser. Use for web demos, shareable graphics, embedding a simulation in a page, or any request to put Flow output online.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- flow-audioSkill
- flow-autodiffSkill
- flow-basicsSkill
- flow-compiler-devSkill
- flow-debugSkill
- flow-dynamicsSkill
- flow-effectsSkill
- flow-graphicsSkill
- flow-perfSkill
- flow-setupSkill
- flow-stdlibSkill
- flow-verifySkill
The file
Files
WebAssembly
Flow compiles to WebAssembly through the C backend and emits a runnable page alongside the module.
Requires FLOW_HOST=python and Emscripten on the path.
Build
FLOW_HOST=python flow wasm program.flow --backend=c --out build/wasm| Flag | Does |
--backend=c|mlir | Codegen path; C is the default |
--out DIR | Where the module and page land |
--preload DIR@/MOUNT | Bake a directory into the virtual filesystem |
--link PATH | Extra object or library to link |
--threads | Enable threading |
--fs memfs|idbfs | Filesystem backend; idbfs persists in the browser |
Serve the output directory over HTTP. Opening the page from file:// fails on
module fetch.
cd build/wasm && python3 -m http.server 8000Graphics in the browser
stdlib/gfx.flow targets canvas on the web, so a gfx program builds for the
browser without changes. gfx_time_ms becomes performance.now() and
gfx_wait_frame becomes a no-op, because gfx_present already waits on
requestAnimationFrame. Pace the loop with gfx_wait_frame anyway so the same
source behaves correctly in a native window.
Read first
ls examples/wasm/
ls scripts/ | grep wasm
cat docs/demos/wasm.mdscripts/build_wasm.sh, scripts/build_all_wasm.sh, and
scripts/build_wasm_gallery.py are the pipelines the project uses for the
published gallery. Follow them rather than inventing a build.
Verify
A WebAssembly build is only done when the page runs. Check:
- the module loads with no console error;
- the program produces the same output it produced natively, for at least one input;
- the frame loop advances rather than rendering once and stopping.
scripts/verify_browser_interp.py exists for this. Say which check you ran. Do
not report a working demo you have not loaded.
Pitfalls
- Emscripten missing produces a confusing failure early. Check
emcc --versionfirst. - Files a program opens must be preloaded with
--preload; there is no host filesystem. - Threads need cross-origin isolation headers, which a plain
http.serverdoes not send. - Size grows quickly with linked runtimes. Report the module size.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

