Add the module-manager panel module (source, bindings)
CI / test (push) Failing after 15s

components.txt listed it but no source existed, so just modules skipped it and the
picker said 'Module manager not found'. Panel button + popup: loaded instances
(click to unload), available modules (click to load), Browse...

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-24 23:42:50 -08:00
1 parent 8724805a72
commit 200b02d0f1
15 files changed
+892

No files matched your search

@@ -0,0 +1,2 @@
Hot-swap of the system's own wasm modules. A module with this capability
is a module manager: it decides what is loaded into the panel.
@@ -0,0 +1,44 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
fn wasmImportAvailable(p0 : Int) = "moonplasma:desktop/modules@0.1.0" "available"
///|
fn wasmImportLoaded(p0 : Int) = "moonplasma:desktop/modules@0.1.0" "loaded"
///|
fn wasmImportLoadModule(p0 : Int, p1 : Int) = "moonplasma:desktop/modules@0.1.0" "load-module"
///|
fn wasmImportUnloadInstance(p0 : Int, p1 : Int) = "moonplasma:desktop/modules@0.1.0" "unload-instance"
///|
fn wasmImportBrowse() = "moonplasma:desktop/modules@0.1.0" "browse"
///|
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)
///|
#owned(str)
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
#|(func (param i32) (result i32) local.get 0)
@@ -0,0 +1 @@
warnings = "-44"
@@ -0,0 +1,85 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
/// A loadable module found on the module search path.
pub(all) struct ModuleInfo {
id : String; name : String; path : String; loaded : UInt
}
///|
/// A module instance currently loaded in the panel, in panel order.
pub(all) struct InstanceInfo {
slot : String; module_ : String; name : String
}
///|
pub fn available() -> Array[ModuleInfo] {
let return_area = mbt_ffi_malloc(8)
wasmImportAvailable(return_area);
let array : Array[ModuleInfo] = [];
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 28)
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))
array.push(ModuleInfo::{id : result, name : result0, path : result1, loaded : (mbt_ffi_load32((iter_base) + 24)).reinterpret_as_uint()})
}
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
let ret = array
mbt_ffi_free(return_area)
return ret
}
///|
pub fn loaded() -> Array[InstanceInfo] {
let return_area = mbt_ffi_malloc(8)
wasmImportLoaded(return_area);
let array : Array[InstanceInfo] = [];
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 24)
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))
array.push(InstanceInfo::{slot : result, module_ : result0, name : result1})
}
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
let ret = array
mbt_ffi_free(return_area)
return ret
}
///|
/// Load the module file at `path` into the panel (any number of instances).
pub fn load_module(path : String) -> Unit {
let ptr = mbt_ffi_str2ptr(path)
wasmImportLoadModule(ptr, path.length());
mbt_ffi_free(ptr)
}
///|
/// Unload one loaded instance, freeing its panel space.
pub fn unload_instance(slot : String) -> Unit {
let ptr = mbt_ffi_str2ptr(slot)
wasmImportUnloadInstance(ptr, slot.length());
mbt_ffi_free(ptr)
}
///|
/// Ask the host to show its native file chooser for a .wasm elsewhere on disk.
pub fn browse() -> Unit {
wasmImportBrowse();
}