Expand description
A crate for creating Javy plugins
Example usage:
use javy_plugin_api::import_namespace;
use javy_plugin_api::javy::Config;
// Dynamically linked modules will use `my_javy_plugin_v1` as the import
// namespace.
import_namespace!("my_javy_plugin_v1");
#[export_name = "initialize_runtime"]
pub extern "C" fn initialize_runtime() {
let mut config = Config::default();
config
.text_encoding(true)
.javy_stream_io(true);
javy_plugin_api::initialize_runtime(config, |runtime| runtime).unwrap();
}
The crate will automatically add exports for a number of Wasm functions in your crate that Javy needs to work.
§Core concepts
javy
- a re-export of thejavy
crate.import_namespace
- required to provide an import namespace when the plugin is used to generate dynamically linked modules.initialize_runtime
- used to configure the QuickJS runtime with ajavy::Config
and to add behavior to the createdjavy::Runtime
.
§Features
experimental_event_loop
- enables the JS event loop. A number of important things are not yet supported so be careful when enabling.json
- enables thejson
feature in thejavy
crate.
Re-exports§
pub use javy;
Macros§
- Create a custom section named
import_namespace
with the contents of the string argument.
Functions§
- Compiles JS source code to QuickJS bytecode.
- Initializes the Javy runtime.
- Evaluates QuickJS bytecode and optionally invokes exported JS function with name.
- Evaluate the given bytecode.