Files
chandra/wit/host/plasmoids.wit
T
nandiandClaude Sonnet 5.5 0ba975da67
CI / test (push) Failing after 28s
Logout button for the session, and a dev install that symlinks into the checkout
- New 'session' capability (wit/capabilities.wit) and 'logout' panel module: a button whose popup
  asks 'Log out | Cancel' (Enter confirms, Escape cancels). Confirming makes the compositor exit,
  which ends the login session; works in the wasm host and the native build. In the default panel.
- session/install.py --link (just install-session-dev): symlink the host, component, modules,
  fonts and config into this checkout, so after one root install a rebuild is just
  'just compositor-wasm host-wasm modules' for the next login. Plain installs still copy.
- Tests: host runtime test for the module, native end-to-end test (click, cancel, confirm).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 02:44:44 -08:00

98 lines
3.3 KiB
Plaintext

package moonplasma: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 moonplasma:desktop/types@0.1.0.{draw-op, input-event, size};
use moonplasma: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).
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);
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,
}
/// 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;
}