Lepus is a native desktop application toolkit for MoonBit. It combines a WebView runtime, typed MoonBit-to-JavaScript commands, multi-window management, official plugins, and a project CLI.
Lepus is under active development. Check platform support and the plugin matrix before relying on a capability in production.
- Single-window and multi-window native applications
- Inline HTML, local directories, remote URLs, and in-memory ZIP assets
- Single-process and process-per-window execution models
- Typed plugins exposed as
window.lepusApi.<plugin>.<command> - Built-in window controls and cross-window events
- CLI workflows for setup, development, build, doctor, and bundling
- MoonBit toolchain with native target support
- A C toolchain supported by MoonBit
- Native WebView dependencies for the current platform
- Node.js/npm only when using a frontend project with
package.json
Check the local environment:
moon run --target native cli/lepus -- doctorAdd Lepus to a MoonBit module:
moon add lepus-apps/lepusA package using the high-level API imports the root package:
///|
import {
"lepus-apps/lepus",
}The smallest application uses Window and an in-memory HTML source:
///|
async fn main {
@lepus.Window(
title="Hello Lepus",
width=800,
height=600,
source=@lepus.Source::html(
(
#|<!doctype html>
#|<html><body><h1>Hello from MoonBit</h1></body></html>
),
),
).run()
}The construction API used above is checked as part of the package tests:
///|
test "construct a Lepus app" {
let window = @lepus.WindowConfig::new(
label="main",
title="Hello Lepus",
source=@lepus.Source::html("<h1>Hello</h1>"),
)
let app = @lepus.App::new([window])
assert_eq(app.window_count(), 1)
assert_eq(window.label(), "main")
}Run the included example:
moon run --target native examples/helloSource selects what a window loads:
///|
let remote = @lepus.Source::Url("https://example.com")
///|
let local = @lepus.Source::Local("./dist")
///|
let inline = @lepus.Source::html("<h1>Inline HTML</h1>")
///|
let archived = @lepus.Source::zip(zip_bytes)Urlnavigates directly to a URL.Localserves a local directory through a generated custom protocol.Memoryserves an in-memory file set;Source::htmlandSource::zipbuild it.WindowConfig::sourceis required when a window starts.
See Core API for source and configuration details.
For most applications, prefer run_single_process: all windows share one
native application, event loop, and plugin host process.
///|
async fn main {
let main = @lepus.WindowConfig::new(
label="main",
title="Main",
source=@lepus.Source::html("<h1>Main</h1>"),
)
let settings = @lepus.WindowConfig::new(
label="settings",
title="Settings",
hidden=true,
source=@lepus.Source::html("<h1>Settings</h1>"),
)
@lepus.App::new([main, settings]).run_single_process()
}Use App::run only when process isolation per window is required. Window
labels must be unique in both modes.
See Windows and events.
Install plugins on Window or App:
///|
async fn main {
@lepus.Window(
title="Dialog",
source=@lepus.Source::html("<button onclick='showDialog()'>Open</button>"),
plugins=[@lepus_plugin_dialog.plugin()],
).run()
}Frontend commands are promises:
const reply = await window.lepusApi.dialog.confirm({
title: "Confirm",
message: "Continue?",
default_ok: true,
});Every official plugin exports plugin(). The complete command inventory and
implementation status are documented in Plugins and
Plugin Matrix.
moon run --target native cli/lepus -- setup
moon run --target native cli/lepus -- dev
moon run --target native cli/lepus -- build
moon run --target native cli/lepus -- bundleSee CLI reference for all commands and options.
- Getting started
- Core API
- Windows and events
- Plugins
- CLI reference
- Architecture
- Platform support
- Low-level WebView API
- Runnable examples
moon check
moon test --target native
moon info && moon fmtDocumentation site:
npm install
npm run docs:dev
npm run docs:buildRun CLI help with:
moon run --target native cli/lepus -- --help