javy-apis
A collection of APIs that can be added to a Javy runtime.
APIs are registered by enabling crate features.
Example usage
use ;
// with `console` feature enabled
use RuntimeExt;
If you want to customize the runtime or the APIs, you can use the Runtime::new_with_apis method instead to provide a javy::Config for the underlying Runtime or an APIConfig for the APIs.
Features
console- Registers an implementation of theconsoleAPI.text_encoding- Registers implementations ofTextEncoderandTextDecoder.random- Overrides the implementation ofMath.randomto one that seeds the RNG on first call toMath.random. This is helpful to enable when using Wizer to snapshot a Javy Runtime so that the output ofMath.randomrelies on the WASI context used at runtime and not the WASI context used when Wizening. Enabling this feature will increase the size of the Wasm module that includes the Javy Runtime and will introduce an additional hostcall invocation whenMath.randomis invoked for the first time.stream_io- Registers implementations ofJavy.IO.readSyncandJavy.IO.writeSync.
Publishing to crates.io
To publish this crate to crates.io, run ./publish.sh.
Using a custom WASI SDK
This crate can be compiled using a custom WASI SDK. When building this crate, set the QUICKJS_WASM_SYS_WASI_SDK_PATH environment variable to the absolute path where you installed the SDK.