jasper-plugin-sdk
SDK for writing Jasper plugins in Rust,
compiled to wasm32-unknown-unknown and run inside the host's wasmi sandbox.
The crate's minor version tracks the plugin API spec version (SDK 0.2.x ⇔
apiVersion = "0.2" in manifest.toml). The full contract lives in
docs/plugin-spec.md.
Quick start
[]
= ["cdylib"]
[]
= "0.2"
use jasper_plugin_sdk as sdk;
use Note;
register!
Build with cargo build --release --target wasm32-unknown-unknown, then zip
manifest.toml + plugin.wasm (+ assets) into a .jplug package.
What you get
register!— wires your code to the wasm ABI (plugin_dispatch); the three slotsbefore_save,storage,commandcan be combined freelyhost— typed wrappers overhost_call:log,now_ms(the sandbox has no clock),settings_get/settings_set(needssettingscapability),http_request(needshost:httpcapability)storage::Storage— implement this trait to provide a storage backend (declared via[[contributes.storage]]in the manifest)sdk::core— re-export ofjasper-coremodel types crossing the ABI
Testing your plugin natively
Plain unit tests just work (cargo test — the ABI exports are wasm-only).
For integration tests that need host APIs, enable the native-host feature
in dev-dependencies: host_call is then served by a local stand-in —
http.request performs real HTTP via ureq, time.now uses the system clock,
and settings live in a thread-local map you can seed with
sdk::native_host::set_setting:
[]
= { = "0.2", = ["native-host"] }
This is a test double, not the sandbox: no capability gating, no fuel/memory limits. It never affects the wasm build.
Gotchas
- Don't pull dependencies that drag in
wasm-bindgen(e.g.chronowith default features) — the sandbox is plain wasm, not a JS environment. The SDK registers agetrandomerror stub sowasm32-unknown-unknownlinks. - Reference plugins live in
plugins-examples/(before-save hook, storage providers, editor command).
License
MIT OR Apache-2.0, at your option.