Add the pure MoonBit core: grid, gestures, updater, vdom, app

grid: packing, pinning, resize steps (port of Layout.js and app.py's grid logic).
gesture: pointer state machine (tap, long press, drag, release, swipe).
updater: release/version parsing and the update decision.
vdom: pure virtual DOM with an HTML-text renderer for tests.
app: Elm-style Model/Msg/update/view with effects as data, persistence (JSON
layout, import of the old WebView build's localStorage), drawer/search, menus,
drag and resize. 60 headless tests drive it through pointer input.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Sonnet 5.5 committed 2026-11-23 00:55:16 +00:00
1 parent 66e8e90da1
commit 28e0284d9b
28 files changed
+4278

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
///|
/// Small accessors over `Json`, so decoding code reads as lookups with defaults.
///|
pub fn get(j : Json, key : String) -> Json? {
match j {
Object(o) => o.get(key)
_ => None
}
}
///|
pub fn str(j : Json, key : String, default? : String = "") -> String {
match get(j, key) {
Some(String(s)) => s
_ => default
}
}
///|
pub fn int(j : Json, key : String, default? : Int = 0) -> Int {
match get(j, key) {
Some(Number(n, ..)) => n.to_int()
Some(True) => 1
_ => default
}
}
///|
pub fn bool(j : Json, key : String, default? : Bool = false) -> Bool {
match get(j, key) {
Some(True) => true
Some(False) => false
Some(Number(n, ..)) => n != 0.0
_ => default
}
}
///|
pub fn arr(j : Json, key : String) -> Array[Json] {
match get(j, key) {
Some(Array(a)) => a
_ => []
}
}
///|
pub fn parse(text : String) -> Json? {
try Some(@json.parse(text)) catch {
_ => None
}
}
+13
View File
@@ -0,0 +1,13 @@
///|
test "accessors with defaults" {
let j = parse("{\"a\":\"x\",\"n\":3,\"b\":true,\"l\":[1,2],\"o\":{}}").unwrap()
assert_eq(str(j, "a"), "x")
assert_eq(str(j, "zz", default="d"), "d")
assert_eq(int(j, "n"), 3)
assert_eq(int(j, "b"), 1)
assert_eq(int(j, "a", default=-1), -1)
assert_true(bool(j, "b"))
assert_eq(arr(j, "l").length(), 2)
assert_eq(arr(j, "o").length(), 0)
assert_true(parse("{") is None)
}
+3
View File
@@ -0,0 +1,3 @@
import {
"moonbitlang/core/json",
}
+27
View File
@@ -0,0 +1,27 @@
// Generated using `moon info`, DON'T EDIT IT
package "experiments/launcher/jsonx"
import {
"moonbitlang/core/json",
}
// Values
pub fn arr(@json.Json, String) -> Array[@json.Json]
pub fn bool(@json.Json, String, default? : Bool) -> Bool
pub fn get(@json.Json, String) -> @json.Json?
pub fn int(@json.Json, String, default? : Int32) -> Int32
pub fn parse(String) -> @json.Json?
pub fn str(@json.Json, String, default? : String) -> String
// Errors
// Types and methods
// Type aliases
// Traits