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

@@ -0,0 +1,27 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
fn wasmImportListApps(p0 : Int) = "moonplasma:desktop/app-catalog@0.1.0" "list-apps"
///|
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
#|(func (param i32) (result i32) (local i32)
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
#| local.tee 1 i32.const 0 call $moonbit.init_array8
#| local.get 1)
///|
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load)
///|
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
#|(func (param i32) (param i32) (result i32)
#| local.get 0
#| local.get 1 call $moonbit.init_array16
#| local.get 0)
///|
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
@@ -0,0 +1,5 @@
import {
"moonplasma/desktop/interface/moonplasma/desktop/types" @types,
}
warnings = "-44"
@@ -0,0 +1,17 @@
// Generated using `moon info`, DON'T EDIT IT
package "moonplasma/desktop/interface/moonplasma/desktop/app-catalog"
import {
"moonplasma/desktop/interface/moonplasma/desktop/types",
}
// Values
pub fn list_apps() -> Array[@types.AppEntry]
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,31 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
/// Installed applications (static list in the PoC; .desktop files later).
pub fn list_apps() -> Array[@types.AppEntry] {
let return_area = mbt_ffi_malloc(8)
wasmImportListApps(return_area);
let array : Array[@types.AppEntry] = [];
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 40)
let result = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 0), mbt_ffi_load32((iter_base) + 4))
let result0 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 8), mbt_ffi_load32((iter_base) + 12))
let result1 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 16), mbt_ffi_load32((iter_base) + 20))
let result2 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 24), mbt_ffi_load32((iter_base) + 28))
let result3 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 32), mbt_ffi_load32((iter_base) + 36))
array.push(@types.AppEntry::{id : result, name : result0, comment : result1, category : result2, glyph : result3})
}
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
let ret = array
mbt_ffi_free(return_area)
return ret
}
@@ -0,0 +1,36 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
fn wasmImportLaunch(p0 : Int, p1 : Int, p2 : Int) = "moonplasma:desktop/app-launch@0.1.0" "launch"
///|
#owned(str)
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
#|(func (param i32) (result i32) local.get 0)
///|
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load)
///|
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
///|
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
#|(func (param i32) (result i32) (local i32)
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
#| local.tee 1 i32.const 0 call $moonbit.init_array8
#| local.get 1)
///|
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
#|(func (param i32) (param i32) (result i32)
#| local.get 0
#| local.get 1 call $moonbit.init_array16
#| local.get 0)
///|
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
@@ -0,0 +1 @@
warnings = "-44"
@@ -0,0 +1,13 @@
// Generated using `moon info`, DON'T EDIT IT
package "moonplasma/desktop/interface/moonplasma/desktop/app-launch"
// Values
pub fn launch(String) -> Result[Unit, String]
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,29 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
/// Ask the host to start an application by catalog id.
pub fn launch(id : String) -> Result[Unit, String] {
let ptr = mbt_ffi_str2ptr(id)
let return_area = mbt_ffi_malloc(12)
wasmImportLaunch(ptr, id.length(), return_area);
let lifted = match (mbt_ffi_load8_u((return_area) + 0)) {
0 => {
Result::Ok(())
}
1 => {
let result = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 4), mbt_ffi_load32((return_area) + 8))
Result::Err(result)
}
_ => panic()
}
let ret = lifted
mbt_ffi_free(ptr)
mbt_ffi_free(return_area)
return ret
}
@@ -0,0 +1,2 @@
Host-brokered capabilities. A component can only call what its world
imports AND what the host grants it in the desktop manifest.
@@ -0,0 +1,24 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
fn wasmImportNow(p0 : Int) = "moonplasma:desktop/clock@0.1.0" "now"
///|
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
///|
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
///|
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
#|(func (param i32) (result i32) (local i32)
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
#| local.tee 1 i32.const 0 call $moonbit.init_array8
#| local.get 1)
///|
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load)
@@ -0,0 +1,5 @@
import {
"moonplasma/desktop/interface/moonplasma/desktop/types" @types,
}
warnings = "-44"
@@ -0,0 +1,17 @@
// Generated using `moon info`, DON'T EDIT IT
package "moonplasma/desktop/interface/moonplasma/desktop/clock"
import {
"moonplasma/desktop/interface/moonplasma/desktop/types",
}
// Values
pub fn now() -> @types.Datetime
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,13 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
/// Local wall-clock time (the host owns the time zone).
pub fn now() -> @types.Datetime {
let return_area = mbt_ffi_malloc(12)
wasmImportNow(return_area);
let ret = @types.Datetime::{year : (mbt_ffi_load32((return_area) + 0)).reinterpret_as_uint(), month : (mbt_ffi_load8_u((return_area) + 4)).to_byte(), day : (mbt_ffi_load8_u((return_area) + 5)).to_byte(), hour : (mbt_ffi_load8_u((return_area) + 6)).to_byte(), minute : (mbt_ffi_load8_u((return_area) + 7)).to_byte(), second : (mbt_ffi_load8_u((return_area) + 8)).to_byte(), weekday : (mbt_ffi_load8_u((return_area) + 9)).to_byte()}
mbt_ffi_free(return_area)
return ret
}
@@ -0,0 +1 @@
Look-and-feel design tokens (Plasma "Look and Feel"/colour scheme analogue).
@@ -0,0 +1,31 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
fn wasmImportGetTokens(p0 : Int) = "moonplasma:desktop/theme@0.1.0" "get-tokens"
///|
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load)
///|
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
///|
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
///|
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
#|(func (param i32) (result i32) (local i32)
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
#| local.tee 1 i32.const 0 call $moonbit.init_array8
#| local.get 1)
///|
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
#|(func (param i32) (param i32) (result i32)
#| local.get 0
#| local.get 1 call $moonbit.init_array16
#| local.get 0)
@@ -0,0 +1,5 @@
import {
"moonplasma/desktop/interface/moonplasma/desktop/types" @types,
}
warnings = "-44"
@@ -0,0 +1,38 @@
// Generated using `moon info`, DON'T EDIT IT
package "moonplasma/desktop/interface/moonplasma/desktop/theme"
import {
"moonplasma/desktop/interface/moonplasma/desktop/types",
}
// Values
pub fn get_tokens() -> Tokens
// Errors
// Types and methods
pub(all) struct Palette {
desktop_top : @types.Color
desktop_bottom : @types.Color
surface : @types.Color
surface_hover : @types.Color
surface_popup : @types.Color
foreground : @types.Color
foreground_muted : @types.Color
accent : @types.Color
accent_foreground : @types.Color
border : @types.Color
}
pub(all) struct Tokens {
name : String
palette : Palette
font_size : UInt32
radius : UInt32
spacing : UInt32
panel_height : UInt32
}
// Type aliases
// Traits
@@ -0,0 +1,23 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
pub(all) struct Palette {
desktop_top : @types.Color; desktop_bottom : @types.Color; surface : @types.Color; surface_hover : @types.Color; surface_popup : @types.Color; foreground : @types.Color; foreground_muted : @types.Color; accent : @types.Color; accent_foreground : @types.Color; border : @types.Color
}
///|
pub(all) struct Tokens {
name : String; palette : Palette; font_size : UInt; radius : UInt; spacing : UInt; panel_height : UInt
}
///|
/// Read on every render so a theme swap shows up on the next frame.
pub fn get_tokens() -> Tokens {
let return_area = mbt_ffi_malloc(64)
wasmImportGetTokens(return_area);
let result = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 0), mbt_ffi_load32((return_area) + 4))
let ret = Tokens::{name : result, palette : Palette::{desktop_top : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 8)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 9)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 10)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 11)).to_byte()}, desktop_bottom : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 12)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 13)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 14)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 15)).to_byte()}, surface : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 16)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 17)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 18)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 19)).to_byte()}, surface_hover : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 20)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 21)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 22)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 23)).to_byte()}, surface_popup : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 24)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 25)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 26)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 27)).to_byte()}, foreground : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 28)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 29)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 30)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 31)).to_byte()}, foreground_muted : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 32)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 33)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 34)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 35)).to_byte()}, accent : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 36)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 37)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 38)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 39)).to_byte()}, accent_foreground : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 40)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 41)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 42)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 43)).to_byte()}, border : @types.Color::{r : (mbt_ffi_load8_u((return_area) + 44)).to_byte(), g : (mbt_ffi_load8_u((return_area) + 45)).to_byte(), b : (mbt_ffi_load8_u((return_area) + 46)).to_byte(), a : (mbt_ffi_load8_u((return_area) + 47)).to_byte()}}, font_size : (mbt_ffi_load32((return_area) + 48)).reinterpret_as_uint(), radius : (mbt_ffi_load32((return_area) + 52)).reinterpret_as_uint(), spacing : (mbt_ffi_load32((return_area) + 56)).reinterpret_as_uint(), panel_height : (mbt_ffi_load32((return_area) + 60)).reinterpret_as_uint()}
mbt_ffi_free(return_area)
return ret
}
@@ -0,0 +1,2 @@
Shared value types. Everything here is plain data (no resources) so that
it can cross any component boundary and any host implementation.
@@ -0,0 +1,2 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
@@ -0,0 +1 @@
warnings = "-44"
@@ -0,0 +1,120 @@
// Generated using `moon info`, DON'T EDIT IT
package "moonplasma/desktop/interface/moonplasma/desktop/types"
// Values
// Errors
// Types and methods
pub(all) struct AppEntry {
id : String
name : String
comment : String
category : String
glyph : String
}
pub(all) struct CircleOp {
center : Point
radius : UInt32
color : Color
filled : Bool
}
pub(all) struct Color {
r : Byte
g : Byte
b : Byte
a : Byte
}
pub(all) struct Datetime {
year : UInt32
month : Byte
day : Byte
hour : Byte
minute : Byte
second : Byte
weekday : Byte
}
pub(all) enum DrawOp {
FillRect(FillRectOp)
StrokeRect(StrokeRectOp)
Line(LineOp)
Circle(CircleOp)
Text(TextOp)
PushClip(Rect)
PopClip
}
pub(all) struct FillRectOp {
rect : Rect
color : Color
radius : UInt32
}
pub(all) enum InputEvent {
PointerMove(Point)
PointerDown(Point)
PointerUp(Point)
PointerLeave
FocusLost
KeyDown(String)
}
pub(all) struct LineOp {
start : Point
end : Point
color : Color
width : UInt32
}
pub(all) struct Point {
x : Int32
y : Int32
}
pub(all) struct Rect {
x : Int32
y : Int32
w : UInt32
h : UInt32
}
pub(all) struct Size {
w : UInt32
h : UInt32
}
pub(all) struct StrokeRectOp {
rect : Rect
color : Color
width : UInt32
radius : UInt32
}
pub(all) enum TextAlign {
LEFT
CENTER
RIGHT
}
pub fn TextAlign::from(Int32) -> Self
pub fn TextAlign::ordinal(Self) -> Int32
pub(all) struct TextOp {
origin : Point
text : String
style : TextStyle
}
pub(all) struct TextStyle {
size : UInt32
color : Color
align : TextAlign
bold : Bool
}
// Type aliases
// Traits
@@ -0,0 +1,98 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
pub(all) struct Size {
w : UInt; h : UInt
}
///|
pub(all) struct Point {
x : Int; y : Int
}
///|
pub(all) struct Rect {
x : Int; y : Int; w : UInt; h : UInt
}
///|
/// Non-premultiplied sRGB, 8 bits per channel.
pub(all) struct Color {
r : Byte; g : Byte; b : Byte; a : Byte
}
///|
pub(all) enum TextAlign {
LEFT; CENTER; RIGHT
} derive()
///|
pub fn TextAlign::ordinal(self : TextAlign) -> Int {
match self {
LEFT => 0
CENTER => 1
RIGHT => 2
}
}
///|
pub fn TextAlign::from(self : Int) -> TextAlign {
match self {
0 => LEFT
1 => CENTER
2 => RIGHT
_ => panic()
}
}
///|
pub(all) struct TextStyle {
size : UInt; color : Color; align : TextAlign; bold : Bool
}
///|
pub(all) struct FillRectOp {
rect : Rect; color : Color; radius : UInt
}
///|
pub(all) struct StrokeRectOp {
rect : Rect; color : Color; width : UInt; radius : UInt
}
///|
pub(all) struct LineOp {
start : Point; end : Point; color : Color; width : UInt
}
///|
pub(all) struct CircleOp {
center : Point; radius : UInt; 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.
pub(all) struct TextOp {
origin : Point; text : String; style : TextStyle
}
///|
/// 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.
pub(all) enum DrawOp {
FillRect(FillRectOp)
StrokeRect(StrokeRectOp)
Line(LineOp)
Circle(CircleOp)
Text(TextOp)
PushClip(Rect)
PopClip
}
///|
pub(all) enum InputEvent {
PointerMove(Point)
PointerDown(Point)
PointerUp(Point)
PointerLeave
FocusLost
KeyDown(String)
}
///|
pub(all) struct Datetime {
year : UInt; month : Byte; day : Byte; hour : Byte; minute : Byte; second : Byte; weekday : Byte
}
///|
pub(all) struct AppEntry {
id : String; name : String; comment : String; category : String; glyph : String
}