hammer-plugin-kit 0.8.0

Write plugins for the Hammer editor in Rust: Hammer's imports, typed operations, and the export, action, and text check types.
Documentation

hammer-plugin-kit

The Rust kit for writing plugins for Hammer, the novel writing app. A plugin is a WebAssembly module that Hammer runs in a sandbox; this crate gives it Hammer's imports, a typed function for each of Hammer's operations (hammer::ops), and the types for exports, actions, and text checks.

[lib]
crate-type = ["cdylib"]

[dependencies]
hammer-plugin-kit = "0.8"
use hammer::ops;

let scene = ops::scene::read(&project, id)?;
for image_id in hammer::images::find_ids(&scene.markdown) {
    let image = ops::image::get(&project, image_id)?;
    hammer::log::info(&format!("{}.{}: {} bytes", image.name, image.extension, image.content.len()));
}

hammer::images reads the hammer://image/<id> references Hammer writes for a project's images, and hammer::export::Archive writes the reply of an exporter whose files Hammer zips.

hammer::server sends a request to a service on the user's own sync server, such as languagetool, as the signed-in user, for a plugin whose manifest names it under permissions.hammerServer. hammer::server::languagetool has typed check and languages for that service.

Build for wasm32-unknown-unknown. The Rust template is a working plugin to start from, and the SDK has the recipes and the Kotlin and C kits.