| Crates.io | javy-plugin-api |
| lib.rs | javy-plugin-api |
| version | 4.0.0 |
| created_at | 2024-11-12 22:24:52.323831+00 |
| updated_at | 2025-08-29 17:33:39.98147+00 |
| description | APIs for Javy plugins |
| homepage | https://github.com/bytecodealliance/javy/tree/main/crates/plugin-api |
| repository | https://github.com/bytecodealliance/javy/tree/main/crates/plugin-api |
| max_upload_size | |
| id | 1445657 |
| size | 40,011 |
Refer to the crate level documentation to learn more.
Example usage:
use javy_plugin_api::{
javy::{quickjs::prelude::Func, Runtime},
javy_plugin, Config,
};
wit_bindgen::generate!({ world: "my-javy-plugin-v1", generate_all });
fn config() -> Config {
let mut config = Config::default();
config
.text_encoding(true)
.javy_stream_io(true);
config
}
fn modify_runtime(runtime: Runtime) -> Runtime {
runtime.context().with(|ctx| {
ctx.globals().set("plugin", true).unwrap();
});
runtime
}
struct Component;
// Dynamically linked modules will use `my_javy_plugin_v1` as the import
// namespace.
javy_plugin!("my-javy-plugin-v1", Component, config, modify_runtime);
export!(Component);
Please read the extending Javy documentation for the new plugin API details.
To update your plugin:
wit adjacent to the Cargo.toml filewit directory, create a WIT file matching the details in the
extending Javy documentationconfig() -> Config function that will return a Javy configmodify_runtime(runtime: Runtime) -> Runtime function that will
perform whatever modifications to runtime that are necessarywit-bindgen to your cratewit_bindgen::generate! to create the required traits from the WIT fileimport_namespace! and use javy_plugin! instead. Ensure you use a
different value for the import_namespace parameter since the API has
changed. Pass your struct type, your config function, and your
modify_runtime function.export! on your struct type.To publish this crate to crates.io, run ./publish.sh.