A collection of APIs that can be added to a Javy runtime.
APIs are registered by enabling crate features.
``rust
use javy::{quickjs::JSValue, Runtime};
// with
console` feature enabled
use javy_apis::RuntimeExt;
fn main() -> Result<()> { let runtime = Runtime::newwithdefaults()?; let context = runtime.context(); context.eval_global("hello.js", "console.log('hello!');")?; Ok(()) } ```
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.
console
- registers an implementation of the console
APItext_encoding
- registers implementations of TextEncoder
and TextDecoder
stream_io
- registers implementations of Javy.IO.readSync
and Javy.IO.writeSync
QUICKJS_WASM_SYS_WASI_SDK_PATH
environment variable to the absolute path where you installed the wasi-sdk
For example, if you install the wasi-sdk
in /opt/wasi-sdk
, you can run:
bash
export QUICKJS_WASM_SYS_WASI_SDK_PATH=/opt/wasi-sdk
To publish this crate to crates.io, run ./publish.sh
.