standard-plugin-sdk 0.1.1

Write Standard Code plugins in Rust: wasm components against standard:plugin@2.0.0
Documentation

standard-plugin-sdk

Write Standard Code plugins in Rust. A plugin is a WebAssembly component against the WIT package standard:plugin@2.0.0, built for wasm32-wasip2:

  • UI plugins run in every viewer, sandboxed, and paint surfaces (sidebar cards, pane footers and headers, stages) in the cell model or the graphics model through a shared double-buffered buffer the viewer samples on its paced frame cadence.
  • Daemon plugins and companions run inside standardd with an async run loop, and do the work a UI plugin must not repeat in every viewer.

The crate's library is named standard_plugin. UI plugins are #![no_std] (the std library would import the WASI CLI world, which a viewer does not offer); alloc is available and the default runtime feature supplies the allocator and panic handler.

Start

rustup target add wasm32-wasip2
cargo install standard-plugin-cli --locked
standard-plugin new my-card --kind ui
cd my-card
standard-plugin build     # cargo build for wasm32-wasip2, into bundle/
standard-plugin check     # manifest, grants, imports against the world
standard-plugin pack      # a deterministic tarball and its SHA-256

Every example in the documentation is a compiled file in examples/ (cargo build --examples --target wasm32-wasip2):

Example Shows
clock_card.rs A cell-model sidebar card that wakes once a second
shapes_stage.rs The shape helpers on a graphics-model stage
together_ui.rs A UI plugin that reads values, listens to events, and asks its companion once (driving viewer, claims)
together_companion.rs The companion daemon: run loop, calls, values, events
heartbeat_daemon.rs A daemon plugin: a run loop with a timer and a spawned event task
daemon_http.rs A daemon using WASI HTTP (--features wasi)

standard_plugin::testing runs a plugin against an in-process host in ordinary cargo test (see tests/testing_harness.rs).

The guides ship with this crate, in docs/: getting started, the manifest, grants, rendering, input, working together, daemon plugins, testing, publishing, and a guide for coding agents. They are also the standard_plugin::guide pages of the API documentation, and standard-plugin guide lists or prints them for the SDK version a plugin's Cargo.lock resolves:

standard-plugin guide                 # the list
standard-plugin guide agent-guide     # one guide

A plugin depends on this crate from crates.io:

[dependencies]
standard-plugin-sdk = "0.1"                                     # UI plugins
# standard-plugin-sdk = { version = "0.1", features = ["wasi"] } # daemon plugins

Features

Feature Default For
runtime yes The allocator, panic handler and memory functions of a no_std component
std no Daemon plugins that use the standard library (WASI files, sockets, clocks)
wasi no std plus the wasip2 bindings: daemon::wasi, daemon::io, daemon::http

Versions and license

The SDK, standard-plugin-macros, standard-plugin-manifest and standard-plugin-cli are released together with one version, independent of the Standard Code product version. wit/plugin.wit is the WIT package itself: the viewer and daemon hosts and the CLI read this file.

Licensed under the MIT license (LICENSE).