Sign in

    gpui

    An independent MoonBit implementation of the GPUI programming model.

    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    12 hours ago
    Downloads
    3

    #gpui.mbt

    Build GPUI-style user interfaces in MoonBit.

    gpui.mbt gives MoonBit programs a deterministic application/entity model, flex layout and element trees, input routing, scene snapshots, and experimental native/browser hosts. Portable UI state, layout, events, and scene data stay in MoonBit; native backends call platform APIs directly and do not carry a Rust GPUI runtime.

    #What you can use today

    • Application state — App, typed Entity[T], scoped updates, subscriptions, explicit notifications, deterministic queued work, and manually advanced timers.
    • Layout and interaction — deterministic row/column flex layout, recursive layout trees, hit testing, capture/bubble pointer dispatch, stop-propagation, focus state, and portable scroll state and drag gestures.
    • Scene data — ordered quads and bounded plain-text items, rectangle clip chains, affine transforms, opacity, and canonical SceneSnapshot data. The browser uses its system font; experimental Ubuntu, Windows, and macOS renderers draw documented grayscale subsets. macOS uses CoreText system sans for bounded single-line text; this does not add an editor or IME.
    • Linux text — merged PR #27 provides copied PangoFT2 measurement, caret, and hit-test geometry; Ubuntu's GLES host now also presents supported plain-text items through grayscale masks. This is not text input, an editor, or a general Linux support claim; see the Linux text guide.
    • Semantic capabilities — one typed operation can be bound to GUI actions, direct MoonBit calls, and optional MCP dispatch with shared domain validation. A checked JavaScript stdio fixture exercises the pinned stateless MCP wire adapter.
    • macOS — an AppKit + Metal native host with windows, input, clipboard/cursors, scale/resize events, quad and bounded single-line grayscale text presentation, CoreText measurement, and an experimental renderer-recovery path.
    • Ubuntu / Wayland — a Wayland + EGL/OpenGL ES 2 native host with window lifecycle, input, clipboard/cursor services, scale handling, quad presentation, and bounded grayscale text frames.
    • Windows — an experimental one-window Win32/D3D11 hardware-or-WARP slice with basic input, quad presentation, bounded grayscale text, and a focused single-line text field. The private IMM32 text-session ingress is opt-in and default-off; real Japanese IME qualification remains open. Prior hosted Windows runs cover earlier slices and do not establish a Windows support tier or production claim; see the Windows native guide.
    • Browser — Weekboard, a small website-launch task board using the shared MoonBit app/layout/event/scene model and a Canvas 2D host, plus the retained interaction lab for service and lifecycle proofs.
    • Headless testing — portable model, layout, event, focus, and scene behavior can be exercised without a window system.

    The native and browser hosts are development slices rather than production support. See status, limits, and roadmap for the current boundary.

    #Try it

    #Headless MoonBit model

    moon test examples/headless

    The example in examples/headless/example.mbt updates an entity and notifies its subscribers through the framework-owned update path.

    #macOS

    On macOS 13+ with Xcode command-line tools:

    ./script/build_and_run.sh

    The demo opens an AppKit window and renders with Metal. Click the quad or press Space to change it. See the macOS guide for build, smoke, and native-test commands.

    #Ubuntu / Wayland

    After installing the system packages listed in the Ubuntu guide, including PangoFT2 and Fontconfig development packages for the native text renderer:

    sh scripts/prepare_ubuntu.sh moon run examples/ubuntu --target native

    The demo opens a Wayland window and presents the shared scene model through EGL/OpenGL ES 2.

    #Headless Linux text geometry

    Install the native development libraries and fixture fonts listed in the Linux text guide, then run:

    sh scripts/test_linux_text.sh

    This is a separate headless test from the Wayland window/backend smoke. It covers measurement and the private grayscale-mask raster oracle, not GPU text-frame presentation.

    #Browser

    With Vite+ and a supported Node.js release available:

    vp install --frozen-lockfile vp dev

    Open the URL printed by Vite+ to use Weekboard: 12 initial tasks across Backlog, In progress, and Done. Search, add tasks, move cards between lanes by drag or buttons, undo changes, and scroll each lane. Narrow viewports show one lane with lane selectors and scroll buttons. Data stays in the current page session; reloading starts again with the sample tasks.

    The board's state, filtering, history, layout, hit testing, scrolling, drag gestures, and scene data live in the portable task-board package. The browser hosts the canvas, ordinary HTML search/add controls, and visible-card focus proxies. This is bounded text presentation and a demo-specific accessibility projection, not a complete text editor or general accessibility adapter.

    The original interaction lab remains at /proof.html, linked from Weekboard. It retains the GUI/direct/MCP counter, clipboard, committed-input, legacy-island, and renderer-restoration proofs. Use vp build for both pages in _build/browser-site. See the browser guide for limits and separate test commands.

    #MCP stdio adapter

    Run the compiled MoonBit reference server and its endpoint/drift checks with:

    sh scripts/run_mcp_stdio.sh sh scripts/test_mcp_stdio.sh

    See the MCP adapter guide for the supported wire surface and lifecycle limits.

    #MoonBit programming model

    The headless API can be used independently of a native window backend. This is the same entity update used by the checked example:

    pub fn increment(
    app : @core.App,
    entity : @core.Entity[Int],
    ) -> Result[Unit, @diagnostics.FrameworkError] {
    app.update(entity, context => {
    match context.get() {
    Err(error) => Err(error)
    Ok(value) =>
    match context.set(value + 1) {
    Err(error) => Err(error)
    Ok(_) => context.notify()
    }
    }
    })
    }

    Subscriptions are explicitly canceled with unsubscribe. Deterministic timer tests use App::advance_time_by. Generic entity payloads should use immutable or copy-on-write values; the ownership caveat is documented in status and limits.

    #Packages

    PackageWhat it provides
    core/Application lifetime, entities, scoped contexts, subscriptions, scheduler and timers
    primitives/Shared geometry, colors, input values, and portable primitives
    text/UTF-16 documents, strict UTF-8 scalar-offset conversion, directional selections, and immutable composition values; no host IME or rendering
    text_layout/Portable intrinsic text-measurement contract and copied layout/caret/hit values; depends only on text/ and primitives/
    platform/linux_text/Linux-only PangoFT2 implementation of copied measurement geometry and a private grayscale-mask raster boundary; native handles stay behind the FFI boundary
    layout/Deterministic flex layout and recursive layout trees
    element/Element trees, hit testing, event routing, focus, scroll state, drag gestures, and element-to-scene bridging
    scene/Quad paint commands, bounded text snapshot items, validation, canonical snapshots, transforms, opacity, and clips
    platform/Portable backend/window/event contracts plus the macOS backend
    ubuntu/Ubuntu Wayland/EGL/GLES2 native backend
    windows/Experimental Win32/D3D11 WARP backend slice
    capability/Typed semantic capabilities, validation, schema projection, and registry
    mcp/Optional modern MCP inventory, schema projection, stateless wire router, and in-process dispatch adapter
    migration/host_services/Bounded portable service requests/completions and default-deny host-service policy
    examples/Headless, macOS, Ubuntu, Windows, browser, and MCP stdio fixtures

    #Documentation

    #Relationship to GPUI

    gpui.mbt is an independent MoonBit implementation of GPUI-style programming concepts. GPUI is developed by Zed Industries; this project is not affiliated with or endorsed by Zed Industries. Compatibility is behavioral and conceptual rather than Rust source or binary compatibility. The pinned comparison target and source-provenance rules are documented in compatibility and provenance.