hotdrink-wasm
A wrapper library around hotdrink-rs
for compilation to WebAssembly.
Prerequisites
The project uses multiple nightly features, and must be built using nightly Rust.
I recommend using rustup
, which can be downloaded here,
You also need wasm-pack
to compile your project to WebAssembly, which can be downloaded here.
The standard library must be recompiled with atomics enabled to use Web Workers as threads,
which means that we need the standard library source code.
This can be downloaded with rustup component add rust-src
.
Usage
Add the following to your Cargo.toml
:
= "0.1.1"
Single threaded
use ;
use ;
use ;
component_type_wrapper!
}
constraint_system_wrapper!;
After producing a JavaScript module in www/pkg with
you can use the wrapper like this:
let cs = wasm.;
cs.;
cs.;
cs.;
cs.;
Multithreaded
Remember to add the thread
feature flag in your Cargo.toml
.
= { = "0.1.1", = ["thread"] }
To use a multithreaded constraint system, you would create it like this instead:
use ;
use ;
component_type_wrapper!
}
constraint_system_wrapper_threaded!;
To use Web Workers from Rust, the we must compile with --target no-modules
.
This will produce WebAssembly code and JS wrappers in www/pkg, which can then be imported there. See wasm-pack's documentation for more information.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.