Skip to main content

lattice_plugin_host/
transient_host.rs

1//! TR.2b — the transient-source guest world.
2//!
3//! A WASM transient source implements the `transient-source-plugin` world: it
4//! exports `id` / `build` and imports `logging` + `project`. This module holds
5//! the `bindgen!` for that world, using the same shared-types trick every seam
6//! before it does — `with:` points `types` + `logging` at the `plugin` world's
7//! generated modules so a crossed value is the SAME Rust type the boundary
8//! round-trips, not a fresh incompatible copy.
9//!
10//! **Async, and on an explicit user action.** `build` is reached by a chord or
11//! an ex-command — never per keystroke, never per frame — and it suspends the
12//! guest stack rather than pinning the caller's thread. The editor parks on it
13//! (`Editor::pending_transient_build`) and seats the menu when it lands.
14//!
15//! Design: `docs/dev/architecture/plugin-transients.md` §5.
16
17pub(crate) mod bindings {
18    wasmtime::component::bindgen!({
19        world: "transient-source-plugin",
20        path: "../lattice-wit/wit",
21        // Building a menu suspends the guest rather than pinning the caller's
22        // thread; it is never on the keystroke path.
23        exports: { default: async },
24        with: {
25            // Reuse the `plugin` world's generated mirrors so a `transient-spec`
26            // crossing here is the same Rust type `WitBoundary` round-trips.
27            "lattice:plugin-host/types": crate::lattice::plugin_host::types,
28            "lattice:plugin-host/logging": crate::lattice::plugin_host::logging,
29        },
30    });
31}