@polyphony-chat/polyproto
v0.1.0
Published
WebAssembly bindings for polyproto
Readme
polyproto-wasm
The polyproto-wasm crate wraps the Rust implementation of polyproto. It is, sort of, a facade, exposing the Rust implementation in a manner that is compatible with wasm-bindgen/JavaScript.
Architectural Concerns
The idea behind choosing something resembling the facade pattern to expose the polyproto Rust SDK to JavaScript has been a result of the following constraints:
- I (ava) am the sole active maintainer of this crate and most of the polyproto ecosystem. I am limited by resources such as time and (emotional) energy. Because of these constraints, I cannot "afford" to write a JavaScript implementation of polyproto from scratch. Reusing what we already have is a smart idea for this.
- A polyproto library for JavaScript is needed for many reasons. Most notably:
sonataaims to ship a small prototype with some interactivity, so that individuals have something to try polyproto out with. This could be done in Rust too, throughyew,dioxus,leptosor another Rust-based frontend framework, but, ultimately, JavaScript is the standard for interactive web applications, and it would be rather pointless to save a little work now (by staying completely in Rust land), only to still have to provide a JavaScript implementation of the polyproto SDK in the near future, for purposes of building a client, as well as creating an actual developer ecosystem around polyproto. - For reasons outlined in 1., there was the need for some sort of abstraction that is easy to maintain. Even when some implementation details change in the Rust implementation, it should be easy to port them over to WASM. A facade fulfills this by latching onto the public API of polyproto-rs (which, public APIs should change/break only rarely), and, by polyproto-wasm being in the same worktree as polyproto-rs, changes in polyproto-rs can be propagated instantly to polyproto-wasm, and breaking changes always get noticed, as both crates are part of the same CI pipeline.
