MoonBit application framework without a user interface
Umbrella | @lander: batteries-included CLI entry with sane defaults
Hosting | @hosting: bare builder, services, lifecycle, drivers, exit codes
Binding | @config.bind: typed values with source-aware errors and validation
Conventions | @conventions: discovery, workspaces, environments, profiles
Configuration core | @config: sources, file tree, pure load, merge, provenance
Formats | TOML, YAML, JSON5 and Ion; linked set selected by a virtual package| Layer | Package | Status |
|---|---|---|
| Core | moonrockz/moon-lander-core | AppName, EnvPrefix, AbsolutePath, TimeLimit, and shared typed errors on all four targets |
| Configuration core | moonrockz/moon-lander-config | Value tree, key paths, typed file-tree paths, sources (defaults, files, environment, overrides), file tree and pure load, merge with null rules, provenance, merge policies, lazy secrets, redaction, display helpers (show, explain, path_text) and typed errors |
| Formats | formats, parsers/* in moonrockz/moon-lander-config | TOML, YAML with default/strict profiles, JSON/JSON5 and Ion; default and TOML-only linked sets through a virtual package |
| Host adapters | host in moonrockz/moon-lander-config | native and js read files and fill missing variables and the working directory |
| Browser adapter | browser in moonrockz/moon-lander-config | js browser URL mounts with explicit manifests, run inputs, limits, cancellation, and typed boundary errors |
| Conventions & profiles | conventions, profiles in moonrockz/moon-lander-config | Walk-up discovery in three layouts, system and global user directories on every platform, workspaces and member selection, environment files, configuration profiles, local and user overrides, explicit project file, ambiguity, legacy fallback, stop boundary, and isolated mode |
| Binding | moonrockz/moon-lander-config | bind, bind_root, bind_or, bind_with (FromConfig), Sourced[T], Options[T], NamedOptions[T], and Validate with source-aware decode and validation errors |
| Mediator | moonrockz/moon-lander-mediator | Typed senders, publish topics that run every handler and report every failure in one PublishFailed, a middleware pipeline with fixed order and short-circuit, an explicit context value and MediatorError on all four targets |
| Async mediator | moonrockz/moon-lander-mediator/async | Async senders and topics with sequential and concurrent publish, caller cancellation, the timeout middleware, async middleware with a sync finally_, and from_sync on wasm, js and native |
| Logging | moonrockz/moon-lander-logging, logging-hosting-async | Bring-your-own Logger trait, six levels, structured events with Serilog-style message templates, category routing, context enrichment, configuration binding, console and rolling-file sinks, and hosted lifecycle integration |
| Hosting | moonrockz/moon-lander-hosting (@hosting), console, argparse, moonrun | Bare builder, six-hook lifecycle engine, Lifetime, cancellation checks, exit codes and reports, shutdown timeout, moonbitlang/core/argparse integration with priority-700 overrides, native C signal stub and Node/Bun console drivers, embedded wasm/wasm-gc driver, explicit wasm Moonrun driver, enclosing host controls, and Program trait |
| Umbrella | moonrockz/moon-lander (@lander) | Batteries-included @lander.cli with linked formats, app_dirs, standard flags, environment-file discovery, @lander.command, @lander.build, target-selecting @lander.run and @lander.run_app, and pub using re-exports |
| Actors & SignalR hubs | moonrockz/moon-lander-actors, moonrockz/signalr, moonrockz/moon-lander-hubs | Typed actors with runtime events, standalone SignalR protocol/client/server, and hosted SignalR hubs |
| Service plugins | moonrockz/moon-lander-plugins | One contract for a hosted service, with a pure session, plugins in MoonBit code and plugin_service for a host |
| Default | Enabled by @lander.cli | Change or turn off |
|---|---|---|
| Formats | Linked set from moonrockz/moon-lander-config/formats (TOML, YAML, JSON5, Ion) | \|> @lander.formats(["toml", "yaml"]) |
| Conventions | app_dirs(name, prefix~) | \|> @lander.conventions(c => ...) |
| Standard flags | --environment, --config, --isolated, --project | \|> @lander.no_standard_flags() |
| Environment files | Discovery on; loads only when a name is set | \|> @lander.no_environments() |
| Environment variables | <PREFIX>_* at priority 600 | \|> @lander.env_prefix(...), \|> @lander.skip_env_source() |
| Services record | Unit until build | \|> @lander.build(factory) |
| Driver | Console on native/js; embedded on wasm/wasm-gc | \|> @lander.run(command) or \|> @lander.run_app(factory) |
| Shutdown timeout | 30 seconds | \|> @lander.shutdown_timeout(limit) |
///|
fn smallest_program(args : Array[String]) -> Unit raise {
"acme" |> @lander.AppName::parse |> @lander.cli(args) |> @lander.run(_ => ())
}
///|
test "smallest program compiles on all four targets" {
ignore(smallest_program)
}///|
struct DemoServices {
label : String
flushes : Ref[Int32]
}
///|
fn demo_pipeline(
args : Array[String],
flushes : Ref[Int32],
) -> @lander.HostBuilder[DemoServices] raise {
"acme"
|> @lander.AppName::parse
|> @lander.cli(args)
|> @lander.configure(sources => {
sources |> @config.defaults({ "app": { "label": "ready" } })
})
|> @lander.build(b => {
label: @config.get_text(b.config, "app.label"),
flushes,
})
|> @lander.service("telemetry", stopping=ctx => {
ignore(ctx.services.label)
ctx.services.flushes.val += 1
})
|> @lander.shutdown_timeout(@lander.TimeLimit::seconds(5))
}
///|
test "batteries pipeline builds cleanly on all four targets" {
let flushes = Ref(0)
ignore(demo_pipeline([], flushes))
assert_eq(flushes.val, 0)
}///|
test "custom command composes active standard flags" {
let builder = "acme"
|> @lander.AppName::parse
|> @lander.cli(["build", "--environment", "Staging"])
|> @lander.command((name, standard) => {
@hosting_argparse.Command(
name,
options=standard.options(),
flags=standard.flags(),
subcommands=[@hosting_argparse.Command("build")],
)
})
ignore(builder)
}///|
struct DemoApp {
greeting : String
}
///|
impl @lander.Program for DemoApp with fn run(self, ctx) {
ignore((self.greeting, ctx.environment.application_name))
}
///|
fn run_demo_app(args : Array[String]) -> Unit raise {
"acme"
|> @lander.AppName::parse
|> @lander.cli(args)
|> @lander.run_app(_ => { greeting: "hello", })
}
///|
test "run_app compiles on all four targets" {
ignore(run_demo_app)
}| Type | Parse | Rule |
|---|---|---|
| AppName | @lander.AppName::parse("acme") | Starts with an ASCII letter; then only ASCII letters, digits, - and _ |
| ServiceName | @lander.ServiceName::parse("db") | Safe as one file path component: starts with XID_Start, continues with XID_Continue, - or ., no invisible characters, no trailing ., not a Windows device name, at most 128 UTF-8 bytes |
| ExitCode | @lander.ExitCode::from_int(3), ExitCode::success(), ExitCode::failure() | 0 to 255 |
///|
test "explicit starting settings in one lander style" {
let builder = "acme"
|> @lander.AppName::parse
|> @lander.cli(
[],
env_vars={ "ACME_PORT": "8080" },
working_dir=@lander.AbsolutePath::parse("/work"),
environment=@lander.EnvironmentName::parse("Staging"),
)
|> @lander.env_vars(({ "ACME_PORT": 9090, "ACME_DEBUG": true } : Json))
|> @lander.working_dir(@lander.AbsolutePath::parse("/other"))
|> @lander.formats(["toml"])
|> @lander.no_environments()
|> @lander.no_standard_flags()
ignore(builder)
}fn cli(name : AppName, args : Array[String], env_vars? : &IntoEnvVars, working_dir? : AbsolutePath, environment? : EnvironmentName) -> HostBuilder[Unit]fn[S] command(builder : HostBuilder[S], make : (String, StandardFlags) -> Command, mappings? : Array[Mapping]) -> HostBuilder[S]fn[S] configure(builder : HostBuilder[S], sources : (ConfigBuilder) -> ConfigBuilder raise) -> HostBuilder[S]fn[S] conventions(builder : HostBuilder[S], transform : (Conventions) -> Conventions) -> HostBuilder[S]fn[S] error_report(builder : HostBuilder[S], report : async (Error, ExitCode) -> Unit) -> HostBuilder[S]fn map(option : OverrideOption, key : KeyPath, action? : MappingAction, parse? : (String) -> ConfigValue raise) -> Mappingfn[S] service(builder : HostBuilder[S], name : &IntoServiceName, starting? : async (Context[S]) -> Unit, start? : async (Context[S]) -> Unit, started? : async (Context[S]) -> Unit, stopping? : async (Context[S]) -> Unit, stop? : async (Context[S]) -> Unit, stopped? : async (Context[S]) -> Unit) -> HostBuilder[S] raise HostError