Files
chandra/wit/host/plasmoids.wit
T
VandClaude Opus 5.5 af774d76fe
CI / test (push) Failing after 16s
Rename the project to Chandra
moon-plasma / moonplasma / MoonPlasma / Moon Plasma become chandra / Chandra
everywhere: the WIT package (chandra:desktop, chandra:host, chandra:wm), the
MoonBit module (chandra/desktop) and generated bindings, the Rust host,
identifiers (ChandraCompositor), the session script (chandra-session) and
desktop entry (chandra.desktop), config and data paths
($XDG_CONFIG_HOME/chandra, share/chandra/modules), env vars (CHANDRA_*),
UI strings, docs and tests. The test fixture components are rebuilt against
the renamed WIT.

Saved panel.edn and state.edn are still read from the old
$XDG_CONFIG_HOME/moon-plasma until the first save writes the new copy.

The remote repository keeps its experiments/moon-plasma name for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hi3L9oVBoRd373Qr4n
2026-11-25 17:12:57 +00:00

101 lines
3.4 KiB
Plaintext

package chandra:host@0.1.0;
/// Panel modules (plasmoids) for a compositor that is itself a component. A component can't embed
/// a second wasm runtime, so the host runs the modules (wasmtime) and the compositor drives them
/// through this interface. It mirrors compositor/wasm: load, draw, events, plus the host data a
/// module may read and the requests it may make.
interface plasmoids {
use chandra:desktop/types@0.1.0.{draw-op, input-event, size};
use chandra:desktop/theme@0.1.0.{tokens};
/// A loaded module. `imports` is its capability grant: the host interfaces its binary imports
/// (besides theme), e.g. ["clock"] or ["windows", "system"].
record loaded {
handle: u32,
id: string,
name: string,
preferred: size,
min-width: u32,
stretch: bool,
imports: list<string>,
}
/// Load the plasmoid component at `path`. The error is a short reason.
load: func(path: string) -> result<loaded, string>;
unload: func(handle: u32);
/// The theme the modules see through `theme.get-tokens` (set before drawing so a swap shows at once).
set-tokens: func(t: tokens);
render: func(handle: u32, box: size) -> list<draw-op>;
record popup-surface {
box: size,
ops: list<draw-op>,
}
popup: func(handle: u32) -> option<popup-surface>;
/// Deliver an event to the module (`on-popup`: to its popup surface). True when it wants a redraw.
on-event: func(handle: u32, on-popup: bool, event: input-event) -> bool;
// ---- host data modules read through their capabilities ----
/// Row tables, as built by compositor/wasm: a LE u32 row count, then per row each field as a LE
/// i32 ('i') or a LE u32 byte length + UTF-8 ('s'). `which`: 0 apps (sssss: id name comment
/// category glyph), 1 windows (isii: id title focused minimized), 2 layouts (s), 3 modules
/// (sssi: id name path loaded), 4 instances (sss: slot module name), 5 wallpapers (s).
publish-table: func(which: u32, rows: list<u8>);
/// Layout mode (0 tiling, 1 monocle, 2 floating) and whether the Interface Explorer is on.
publish-state: func(layout-mode: s32, inspector-on: bool);
/// The wallpaper on the desktop now (an index into the wallpapers table).
publish-wallpaper: func(current: s32);
record system-snapshot {
cpu-permille: u32,
mem-used-kib: u64,
mem-total-kib: u64,
battery-percent: s32,
charging: bool,
uptime-secs: u64,
net-rx-bytes-per-sec: u64,
net-tx-bytes-per-sec: u64,
load-centi: u32,
}
publish-system: func(s: system-snapshot);
record window-entry {
id: u64,
title: string,
app-id: string,
focused: bool,
}
publish-windows: func(wins: list<window-entry>);
// ---- what modules asked of the host ----
variant request {
launch(string),
focus-window(s32),
set-layout(s32),
set-inspector(bool),
load-module(string),
unload-instance(string),
browse,
logout,
set-wallpaper(s32),
}
/// The next pending request, oldest first.
next-request: func() -> option<request>;
/// A window a module asked to focus through `windows.focus` (64-bit id), since the last call.
take-focus-request: func() -> option<u64>;
/// Names of the `*.wasm` files directly in `dir`, sorted.
list-wasm-files: func(dir: string) -> list<string>;
/// A native file-chooser dialog (zenity on the host session) for "Add widget".
variant picker-state {
open,
cancelled,
chosen(string),
}
picker-start: func() -> bool;
picker-poll: func() -> picker-state;
}