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
7.1 KiB
Toolchain: what works today (verified 2026-11-24)
Everything here was run on x86_64 Linux (glibc 2.43 locally; CI uses
node:20-bookworm, glibc 2.36), without root.
Verdict
MoonBit can produce real WebAssembly Components today, via the official
wit-bindgen moonbit backend plus wasm-tools component new. No MoonBit
compiler flag is needed: MoonBit emits a core wasm module (linear-memory
wasm target) that exports the canonical-ABI symbols wit-bindgen generated,
and wasm-tools wraps it into a component.
| Piece | Status | Notes |
|---|---|---|
moon build --target wasm |
works | Used for all components (linear memory, own GC/alloc). |
moon build --target wasm-gc |
not usable for components | The canonical ABI needs linear memory + cabi_realloc; wit-bindgen's MoonBit backend targets wasm only (preferred_target = "wasm" in the generated moon.mod). |
wit-bindgen moonbit (0.63.0) |
works | Generates guest bindings: types, imports, declare pub fn stubs for exports, link.exports config. Handles records, variants, enums, options, results, lists, strings. Resources/async/streams exist in the backend but are not used here. |
wasm-tools component embed/new (1.263.0) |
works | --encoding utf16 (MoonBit strings are UTF-16). |
wasm-tools component targets |
works | Used as a WIT conformance test: asserts each component implements its declared world. |
jco transpile (1.42.0) |
works | Component → JS + core wasm. Used for the M0 host. --instantiation async lets the host pass a per-instance import object, which is how capability grants work. |
wasmtime (51.0.0) |
validates/compiles | wasmtime compile accepts every component. We do not run them under wasmtime yet: a component with host imports needs an embedder (Rust/C-API) to supply them — wasmtime run cannot. That is M4. |
| mooncakes packages | see below | Nothing needed at M0. |
Pipeline
wit/*.wit ──wit-bindgen moonbit──▶ interface/ world/ components/<n>/gen/ (committed)
│ + stub.mbt (hand-written, thin) → lib/* (pure logic, unit-tested)
moon build --target wasm --release ──▶ _build/.../gen.wasm (core module)
wasm-tools component embed wit --world W --encoding utf16 ─▶ wasm-tools component new ─▶ build/components/<n>.wasm
wasm-tools component targets --world W wit <n>.wasm (conformance)
jco transpile --instantiation async ─▶ build/jco/<n>/ (host glue)
Component sizes are 24–33 KB each (release build, no wasm-opt).
Workflow details / gotchas found
wit-bindgen moonbitdoes not write a stub for exported functions in this version; export packages containdeclare pub fn …and you implement them in astub.mbtin the same package. We keepstub.mbtto adapters only; logic lives inlib/*packages somoon testcan cover it.- Using one
--out-dir .with a distinct--gen-dir components/<n>/genper component makes all components share one copy of the imported types (interface/…/types), solib/*helpers work across components. - Generated helper functions are emitted in nondeterministic order, so
scripts/gen-bindings.sh --checkcompares sorted lines, not bytes. moon.mod.jsonis no longer accepted by this moon (0.1.20261119): usemoon.mod.- jco strips the
@versionfrom import keys (chandra:desktop/clock), and maps WITvariant→{tag, val},enum→ string,option→ value/undefined,resultimport returns →{tag:'ok'|'err', val}(or throw). moon testruns on the wasm target throughmoonrun; packages that import the generatedtypespackage are testable (the extern "wasm" helpers are only called at the boundary).- wit-bindgen 0.63 moonbit emits deprecation warnings under newer moon
(
#deprecated pub extend); harmless.
Packages surveyed on mooncakes.io (for later milestones)
| Package | Relevance | Backends / caveat |
|---|---|---|
mizchi/wit 0.4.x |
WIT parser/resolver in MoonBit | could power an in-MoonBit chandra CLI that inspects worlds; not needed at M0 |
moonrockz/wit |
WIT scanner/CST/formatter | same |
mizchi/wite 0.11 |
component-aware analyzer/optimizer (wite can verify a component against WIT, compose WAC) |
candidate replacement for wasm-tools size/verify steps |
moonbitlang/async |
async runtime (native/…); not a component-model async | the component-model async ABI (WASIp3) is in wit-bindgen's backend but out of scope until hosts support it |
moonbitlang/core/json |
JSON | core, all backends — for the settings store (M3) |
The wasm2elf-mb, moonview, webby, curl-wasm, moon-mud and moon-gpui
checkouts on this machine were consulted for conventions only; nothing is
imported from them. (moon-gpui currently contains only a README here — the
docs/PORTING.md referenced in the task is not present in /workspace/moon-gpui.)
Exact setup
# 1. MoonBit (not installed by our scripts)
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash # moon 0.1.20261119
export PATH="$HOME/.moon/bin:$PATH"
# 2. wasm-tools, wit-bindgen, wasmtime → ./.tools/bin (versions in scripts/versions.env)
scripts/setup-toolchain.sh
# 3. jco + playwright-core → host/node_modules (Node ≥ 20)
(cd host && npm ci)
# 4. build every component, then test everything
scripts/build.sh # or: scripts/build.sh clock-binary (one component only)
scripts/test.sh
Pinned versions: moon 0.1.20261119 (moonc 738607b), wasm-tools 1.263.0,
wit-bindgen 0.63.0, wasmtime 51.0.0, jco 1.42.0, Node 20/24.
Hello-world proof (what scripts/build.sh does for clock-digital)
wit-bindgen moonbit wit --world clock-widget --out-dir . \
--gen-dir components/clock-digital/gen --project-name chandra/desktop --ignore-module-file
moon build --target wasm --release
wasm-tools component embed wit _build/wasm/release/build/components/clock-digital/gen/gen.wasm \
--world clock-widget --encoding utf16 -o e.wasm
wasm-tools component new e.wasm -o build/components/clock-digital.wasm
wasm-tools component wit build/components/clock-digital.wasm
# world root { import chandra:desktop/types@0.1.0;
# import chandra:desktop/clock@0.1.0;
# import chandra:desktop/theme@0.1.0;
# export chandra:desktop/plasmoid@0.1.0; }
jco transpile build/components/clock-digital.wasm -o build/jco/clock-digital --instantiation async
node host/src/cli.mjs --time 2026-11-24T14:07:00 # instantiates all components, prints the desktop
Browser screenshots
scripts/screenshot.mjs drives the browser host in headless Chromium through
playwright-core. It needs a Chromium headless shell binary; locally:
export CHROME_PATH=$(ls ~/.cache/ms-playwright/chromium_headless_shell-*/*/chrome-headless-shell)
node scripts/screenshot.mjs docs/screenshots --tag m0
(The full chrome binary under chromium-*/ hung on launch in this sandbox; the headless shell works.)
CI does not take screenshots (no browser in the job image); the Node host tests cover the same code path minus Canvas2D.