Crate javy_plugin_api

Source
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

§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 the json feature in the javy crate.

Re-exports§

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.