WASM/TypeScript consumption surface
State: open/planned · Kind: adapter · Audience: system
Summary
Section titled “Summary”- Each crate a TypeScript consumer needs gets its own wasm-bindgen binding with
generated TypeScript types, browser and Node served by packaging.
yaml-splice-wasmis shipped;solutions/agent-pants/crates/agent-adapt-wasmis the other in-repo example. - There is no markdown WASM crate. TypeScript owns the query plane and the
markdown-contractAPI (D-9WKF-contract-authoring-and-runtime-ownership). - A new binding ships when a TypeScript consumer needs the Rust behaviour.
Statement
Section titled “Statement”The fleet’s TS consumers — polish UI, sdlc tooling, determined apps, doc sites — reach
Rust behaviour through a binding per crate: wasm-bindgen bindings, generated types,
conditional main/browser/exports packaging with an environment-detecting loader —
the shape oxc and biome converged on after abandoning dual wasm+native bindings. Data
crosses as JSON; napi-rs is admitted later only under demonstrated performance need for
large-vault batch work.
What it provides
Section titled “What it provides”yaml-splice-wasm(D-W4SM-yaml-splice-wasm-typescript-binding): WASM artifact and typed wrapper foryaml-splice.- Dual node/browser entry, sync Node init and async browser init.
- Generated
.d.tsfrom the Rust type layer — no hand-maintained type mirrors (the 1709-line lint-rule table is the cautionary example). - Separate wasm packages don’t share binary payload, so each binding is a deliberate cut point, added only on proven consumer demand (the B-MDU7 promotion bar applied to npm).
Underlying implementation
Section titled “Underlying implementation”Shipped: packages/rust/yaml-splice-wasm and solutions/agent-pants/crates/agent-adapt-wasm.
Precedent: markdown-contract PR #249 (WASM spike, GO — 404 KiB brotli, JSON boundary,
sync/async init findings reusable directly). Sequenced by M-F4RZ-wasm-ts-distribution.
Packaging lesson source: oxc’s retrospective on abandoning dual bindings; biome’s
@biomejs/js-api loader shim.