M0: WIT package, MoonBit components, JS host, docs, CI (#1)
CI / test (push) Successful in 19s

This commit was merged in pull request #1.
This commit is contained in:
nandi committed 2026-11-24 23:51:26 +00:00
1 parent e5548fc067
commit 880ecd4102
141 files changed
+9681 -1

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
package moonplasma:desktop@0.1.0;
/// Host-brokered capabilities. A component can only call what its world
/// imports AND what the host grants it in the desktop manifest.
interface clock {
use types.{datetime};
/// Local wall-clock time (the host owns the time zone).
now: func() -> datetime;
}
interface app-catalog {
use types.{app-entry};
/// Installed applications (static list in the PoC; .desktop files later).
list-apps: func() -> list<app-entry>;
}
interface app-launch {
/// Ask the host to start an application by catalog id.
launch: func(id: string) -> result<_, string>;
}
+31
View File
@@ -0,0 +1,31 @@
package moonplasma:desktop@0.1.0;
/// The widget (plasmoid) contract.
interface plasmoid {
use types.{size, draw-op, input-event};
record plasmoid-info {
/// Stable machine id, e.g. "org.moonplasma.clock.digital".
id: string,
name: string,
preferred: size,
min-width: u32,
/// Whether the panel may grow this widget beyond `preferred`.
stretch: bool,
}
record popup-surface {
size: size,
ops: list<draw-op>,
}
enum surface { widget, popup }
info: func() -> plasmoid-info;
/// Draw the widget into a `size` box (local coordinates).
render: func(size: size) -> list<draw-op>;
/// Present when the widget wants a popup surface (e.g. a launcher menu).
popup: func() -> option<popup-surface>;
/// Returns true when the widget's visuals changed and a redraw is needed.
on-event: func(target: surface, event: input-event) -> bool;
}
+37
View File
@@ -0,0 +1,37 @@
package moonplasma:desktop@0.1.0;
/// Panel layout/chrome contract (the plasmashell "containment" analogue).
interface panel-layout {
use types.{size, rect, draw-op};
enum edge { start, end }
record slot {
id: string,
preferred: size,
min-width: u32,
stretch: bool,
/// Which end of the panel the widget packs towards.
align: edge,
}
record placement { id: string, rect: rect }
record layout {
panel: rect,
placements: list<placement>,
}
/// Decide where the panel sits and where each widget goes.
compute-layout: func(screen: size, slots: list<slot>) -> layout;
/// Panel background/frame (drawn beneath the widgets), in screen coords.
render-panel: func(screen: size, panel: rect) -> list<draw-op>;
/// Place a popup of `popup` size for the widget at `anchor`.
popup-position: func(screen: size, panel: rect, anchor: rect, popup: size) -> rect;
}
/// Desktop surface contract (wallpaper / desktop containment).
interface desktop-surface {
use types.{size, draw-op};
render-background: func(screen: size) -> list<draw-op>;
}
+31
View File
@@ -0,0 +1,31 @@
package moonplasma:desktop@0.1.0;
/// Look-and-feel design tokens (Plasma "Look and Feel"/colour scheme analogue).
interface theme {
use types.{color};
record palette {
desktop-top: color,
desktop-bottom: color,
surface: color,
surface-hover: color,
surface-popup: color,
foreground: color,
foreground-muted: color,
accent: color,
accent-foreground: color,
border: color,
}
record tokens {
name: string,
palette: palette,
font-size: u32,
radius: u32,
spacing: u32,
panel-height: u32,
}
/// Read on every render so a theme swap shows up on the next frame.
get-tokens: func() -> tokens;
}
+74
View File
@@ -0,0 +1,74 @@
package moonplasma:desktop@0.1.0;
/// Shared value types. Everything here is plain data (no resources) so that
/// it can cross any component boundary and any host implementation.
interface types {
record size { w: u32, h: u32 }
record point { x: s32, y: s32 }
record rect { x: s32, y: s32, w: u32, h: u32 }
/// Non-premultiplied sRGB, 8 bits per channel.
record color { r: u8, g: u8, b: u8, a: u8 }
enum text-align { left, center, right }
record text-style {
/// Pixel height of the em box.
size: u32,
color: color,
align: text-align,
bold: bool,
}
record fill-rect-op { rect: rect, color: color, radius: u32 }
record stroke-rect-op { rect: rect, color: color, width: u32, radius: u32 }
record line-op { start: point, end: point, color: color, width: u32 }
record circle-op { center: point, radius: u32, color: color, filled: bool }
/// `origin` is the left edge (align=left), centre (center) or right edge
/// (right) of the text, at the vertical *middle* of the line box.
record text-op { origin: point, text: string, style: text-style }
/// The render-list vocabulary. Components never touch pixels: they return
/// a list of these in their own local coordinate space (origin top-left),
/// and the host/compositor translates, clips and rasterises them.
variant draw-op {
fill-rect(fill-rect-op),
stroke-rect(stroke-rect-op),
line(line-op),
circle(circle-op),
text(text-op),
push-clip(rect),
pop-clip,
}
variant input-event {
pointer-move(point),
pointer-down(point),
pointer-up(point),
pointer-leave,
/// Sent to a popup owner when the user clicks outside its popup.
focus-lost,
/// A printable character ("a") or a named key ("Backspace", "Enter", "Escape").
key-down(string),
}
record datetime {
year: u32,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: u8,
/// 0 = Sunday .. 6 = Saturday
weekday: u8,
}
record app-entry {
id: string,
name: string,
comment: string,
category: string,
/// A short glyph (1-2 chars) standing in for an icon until the icon
/// theme interface lands.
glyph: string,
}
}
+30
View File
@@ -0,0 +1,30 @@
package moonplasma:desktop@0.1.0;
/// Minimum every widget gets: theme tokens. Everything else is opt-in.
world widget {
import theme;
export plasmoid;
}
world clock-widget {
include widget;
import clock;
}
world launcher-widget {
include widget;
import app-catalog;
import app-launch;
}
world panel {
import theme;
export panel-layout;
}
/// Reference shell: panel + desktop background in one component.
world shell {
import theme;
export desktop-surface;
export panel-layout;
}