reflow_rt_wasm
Browser-WASM distribution of the Reflow runtime. Wraps reflow_graph,
reflow_actor, and reflow_network for wasm32-unknown-unknown via
wasm-bindgen. Building this crate produces a .wasm + JS-glue
bundle that ships to npm as
@offbit-ai/reflow-wasm.
Building
# from the repo root
--target web produces an ES module + .wasm ready for native
<script type="module"> use; switch to --target bundler if you
prefer a Vite/webpack pipeline.
The repo's .cargo/config.toml sets the
getrandom_backend="wasm_js" rustflag automatically.
Quickstart (JS)
import init from "@offbit-ai/reflow-wasm";
await ; // loads + instantiates the .wasm
console.log; // "0.2.0"
const g = ;
g.;
g.;
g.;
const net = ;
net.;
net.;
Scope
Currently exposes:
Graphand the full Tier-1 + Tier-2 graph API (mutators + queries)GraphNetworkfor runtime execution of JS actors registered viaregister_actor_js(name, class)bindInputEvents(network, target)for routing browser DOM events (keyboard, mouse, touch, wheel, resize) into input actors
The bundled component catalog (reflow_components) is not part
of this crate yet. Two unrelated reasons:
rquickjsC library — embedded QuickJS doesn't compile towasm32-unknown-unknown. Gated to native; the wasm side uses ajs_sys::Functionshim that calls into the host browser engine instead.- Actor framework
Sendbounds — the#[actor(...)]macro wraps each actor's future asPin<Box<dyn Future + Send>>. Browser-only types are typically!Send:wgpu::WebQueue,reqwest'sAbortGuard, andweb_sys::WebSocketall hold raw JS handles (*mut u8). On wasm the runtime is single-threaded andSendis moot, but the macro doesn't yet drop the bound ontarget_arch = "wasm32". Once that lands, wgpu (which does have a WebGPU backend), browser fetch via reqwest, and websockets all become available to wasm-side actors.
Author actors as JS classes and load them via register_actor_js
in the meantime, or load WASM-compiled actor packs via the browser
pack loader (see docs/pack-format.md).
Versioning
Tracks the workspace minor version. Patch bumps are tagged
wasm-vX.Y.Z on the main branch and cut by the
publish-wasm.yml workflow.