moonbit-libyue

    libyue 的 MoonBit 封装:统一跨平台 GUI API,平台差异由库内部吸收,消费方无感

    gui
    desktop
    native
    cross-platform
    libyue
    Download zip
    Author
    Version
    0.5.10
    License
    MIT
    Last updated
    3 days ago
    Downloads
    59

    #moonbit-libyue CI

    Thanks to Cheng Zhao (zcbenz) and his Yue framework, and to MoonBit. As it happens, both of these programming tools carry the character for "moon" — and I have grown fond of them both. About me and libyue

    A native cross-platform desktop GUI library for the MoonBit ecosystem — a full binding of libyue (C++): one MoonBit codebase runs native windows on Windows ✅ / Linux ✅ / macOS 🟡, zero-config right after moon add.

    English | 简体中文

    Component showcase

    Live demo on Linux (XFCE) Live demo on Windows

    Left: Linux (XFCE) · Right: Windows — one MoonBit codebase

    #Core highlights

    🎨 Modern theme — visually consistent across platforms; follows the system accent color and light/dark mode by default, and theme_apply reskins in one line:

    @yue.theme_apply({ ..@yue.theme_from_system(), primary: "#1E4FA3" })

    📝 Declarative — describe the UI as a node tree:

    let window = @yue.mount_window(
    [
    @yue.label("Hello, MoonBit + libyue!", style=[("margin", 20.0)]),
    @yue.button("Quit", on_click=fn() { @yue.quit() }),
    ],
    title="Hello", size=Some((420.0, 160.0)), center=true, on_close=fn(_w) { @yue.quit() },
    )

    ⚡ Signal reactivity — keep state in Signal / Store; bound spots refresh automatically:

    let clicks = @yue.Signal::new(0)
    let text = @yue.Signal::computed(fn() { "Clicked \{clicks.get()} times" }) // dependencies auto-collected

    @yue.button("Click me", on_click=fn() { clicks.update(fn(n) { n + 1 }) }),
    @yue.bind(text, fn(s) { s }),

    🖥 Desktop-grade system integration — system tray · notifications · global shortcuts · clipboard · native menu bar · file dialogs · drag & drop · multiple monitors:

    match @yue.Tray::new("icon.png") {
    Ok(t) => t.on_click(fn() { window.show() })
    Err(_e) => ()
    }

    let n = @yue.Notification::new()
    n.set_title("Build finished")
    n.show()

    📊 Flagship app — Linux process manager & hardware monitor:

    Processes

    moon run examples/sysmonitor

    55 native widgets fully bound · 57 themed self-drawn components · wrapper overhead startup on par with C++, memory +0.8MB · three-platform CI · published on mooncakes

    #Quick start

    Don't know MoonBit? The five-minute tutorial takes you from moon new to your first window.

    Prerequisite: the MoonBit native toolchain, moonc ≥ 0.10.14 (moon version --all to verify).

    Prebuilt demos — unzip and run:

    PlatformPackage
    Windows 10/11 x64bin-windows-x64.zip
    Linux x64 (GTK3, on Ubuntu by default)bin-linux-x64.zip
    macOS (Apple Silicon) 🟡 no real-machine testbin-macos-arm64.zip

    Upgrading to 0.5.0: the Browser binding moved to a standalone package. Add "NoahLiu/moonbit-libyue/yue/browser" to your imports (@yue.Browser → @browser.Browser, API unchanged). Apps that don't import it are no longer linked against WebKit/WebView2.

    #Documentation index

    DocumentContent
    tutorial.mdFive-minute quick start: from moon new to a running window, avoiding the three newcomer pitfalls
    declarative.mdDeclarative Node/mount render tree + Store reactive bindings
    layout.mdLayout style key quick reference: all style keys + common-combination examples
    components-ui.mdThemed component library quick reference: per-API signatures + parameter tables, including theme customization / light-dark switching
    components.mdWidget API quick reference: both the classic setter and X::make props styles
    Troubleshooting & topicsPlatform adaptation notes · Linux tray · native-layer relink (three standalone documents)

    #Platform support

    Ubuntu 24.04 (XFCE / GNOME / KDE) ✅ · Deepin 23 / 25 ✅ · Windows 10/11 ✅ · macOS 🟡 builds pass (CI, no real machine)

    Exes built on Windows run as a GUI subsystem — no console window on double-click.

    #Contributing

    Everyone is welcome: reporting platform-compatibility issues, adding widgets, improving docs — macOS real-machine testing is especially appreciated. A few basic requirements:

    • Commit gate: moon check && moon test zero errors and zero warnings repo-wide
    • Experience on record: write field-tested pitfalls together with their fixes into adaptation.md — not only in commit messages
    • Small batches: one cohesive change per commit, short commit messages

    The full process for adding widgets, native-layer releases, and more is in AGENTS.md.

    #License

    moonbit-libyue is released under the MIT License. It wraps libyue, whose upstream code is licensed LGPL-2.1 with bundled third-party components under Apache-2.0 / MIT / BSD-3-Clause — the complete notice ships in vendor/libyue/LICENSE. All libyue patches used here are maintained as separate commits in the lb091188/yue fork, and the prebuilt static libraries distributed with the package are built from the fork's tagged sources by GitHub Actions (vendor-* tags), so the corresponding source stays retrievable from the repository.

    #References