Expand description
Configurable JavaScript runtime for WebAssembly.
Example usage:
use anyhow::anyhow;
use javy::{Runtime, from_js_error};
let runtime = Runtime::default();
let context = runtime.context();
context.with(|cx| {
let globals = this.globals();
globals.set(
"print_hello",
Function::new(
this.clone(),
MutFn::new(move |_, _| {
println!("Hello, world!");
}),
)?,
)?;
});
context.with(|cx| {
cx.eval_with_options(Default::default(), "print_hello();")
.map_err(|e| from_js_error(cx.clone(), e))
.map(|_| ())
});§Core concepts
§Features
export_alloc_fns- exportsalloc::canonical_abi_reallocandalloc::canonical_abi_freefrom generated WebAssembly for allocating and freeing memoryjson- functions for converting between [quickjs::JSValueRef] and JSON byte slicesmessagepack- functions for converting between [quickjs::JSValueRef] and MessagePack byte slices
Re-exports§
pub use rquickjs as quickjs;
Modules§
Macros§
- Alias for
Args::hold - Alias for [
Args::hold(cx, args).release()]
Structs§
- A configuration for
Runtime. - A JavaScript Runtime.
Functions§
- Handles a JavaScript error or exception and converts to anyhow::Error.
- Converts an
anyhow::Errorto aJSError. - Converts the JavaScript value to a string, replacing any invalid UTF-8 sequences with the Unicode replacement character (U+FFFD).
- Retrieves the string representation of a JavaScript value.