MoonBit-native desktop application framework research and implementation.
Dependencies
MoonBit app code
-> Rabbita-style Lepusa app syntax
-> typed command + event IPC
-> capability-scoped platform plugins
-> system WebView runtime
-> platform bundles for macOS, Windows, and Linux///|
fn main {
let (emit, cell) = @lepusa.cell_with_emit(model=init_model(), update~, view=(
emit,
model,
) => render_app(emit, model))
let app = @lepusa.new(cell)
.with_startup(load_initial_state(emit))
.on_shutdown(persist_state(emit))
.window(title="Hello Lepusa", width=1000, height=720)
match app.launch_plan() {
Ok(plan) => boot_native_runtime(plan)
Err(problems) => fail_fast(problems)
}
}///|
fn render_app(emit, model) {
@ui.main_([
@ui.h1([@ui.text("Counter")]),
@ui.p([@ui.text("Count: \{model.count}")], attrs=[@ui.class_name("metric")]),
@ui.p([@ui.text("Starting")], attrs=[@ui.id("status")]),
@ui.button("Increment", attrs=[@ui.on_click("counter.increment")]),
@ui.text_listener("ready", "#status"),
])
}///|
let runtime = app.runtime_plan(config=@lepusa.RuntimeConfig::system_webview())
///|
let bundle = @lepusa.BundleConfig::new(
@lepusa.AppMetadata::new(
identifier="dev.example.app",
product_name="Example App",
version="0.1.0",
),
)///|
let project = @desktop.DesktopProject::new(metadata, root)
.window(title="Desk", source=@lepusa.Source::html("<main></main>"))
.with_sync_plugins()
///|
let host = project.runtime_host().unwrap()
///|
let bundle = project.bundle_plan(target=@lepusa.MacOS).unwrap()///|
let manifest = @lepusa.ProjectManifest::new(metadata)
.with_window(
@lepusa.WindowConfig::new(source=@lepusa.Source::packaged("dist")),
)
.with_plugin(@lepusa.Plugin::new("core").command_sync("invoke"))
.with_capability(
@lepusa.Capability::new("main").window("main").command("core.invoke"),
)
///|
let runtime = manifest.runtime_plan(root)
///|
let bundle = manifest.bundle_plan(root, target=@lepusa.MacOS)///|
match @project.ProjectConfig::load("lepusa.json") {
Ok(project) =>
project.manifest().runtime_plan(project.root())
Err(problems) =>
fail_fast(problems)
}moon run cmd/main --target native -- doctor linux
moon run cmd/main --target native -- plan
moon run cmd/main --target native -- manifest
moon run cmd/main --target native -- native-plan macos
moon run cmd/main --target native -- launch-session linux
moon run cmd/main --target native -- launch-session linux --async-bridge
moon run cmd/main --target native -- run linux --project examples/gateway/lepusa.json
moon run cmd/main --target native -- run linux --json --project examples/gateway/lepusa.json
moon run cmd/main --target native -- verify linux --project examples/static/lepusa.json
moon run cmd/main --target native -- verify linux --strict --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- run macos --launch --project examples/static/lepusa.json
moon run cmd/main --target native -- bridge
moon run cmd/main --target native -- dev
moon run cmd/main --target native -- init _build/lepusa-app
moon run cmd/main --target native -- init _build/lepusa-app --workspace /Users/kq/Workspace/lepusa
moon run cmd/main --target native -- plan --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- manifest --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- native-plan linux --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- launch-session linux --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- dev --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- asset lepusa://rabbita/main/index.html --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- lifecycle app-will-exit --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- bridge-task main log.write '{"message":"ready"}' --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- bridge-handoff main log.write '{"message":"ready"}' --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- bridge-complete main fs.readText '{"scope":"data","path":"note.txt"}' --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- bridge-dispatch main log.write '{"message":"ready"}' --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- bridge-loop main fs.readText '{"scope":"data","path":"note.txt"}' --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- bridge-drain main fs.readText '{"scope":"data","path":"note.txt"}' --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- plugin new file-dialog _build/lepusa-plugin-file-dialog
moon run cmd/main --target native -- plugin new file-dialog _build/lepusa-plugin-file-dialog --workspace /Users/kq/Workspace/lepusa
moon run cmd/main --target native -- bundle-plan macos
moon run cmd/main --target native -- bundle-plan macos --json
moon run cmd/main --target native -- bundle-write linux _build/lepusa-bundle --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- bundle-inspect _build/lepusa-bundle/lepusa-app/lepusa/distribution.json
moon run cmd/main --target native -- bundle-release-plan _build/lepusa-bundle/lepusa-app/lepusa/distribution.json --json
moon run cmd/main --target native -- bundle-release-write _build/lepusa-bundle/lepusa-app/lepusa/distribution.json _build/lepusa-release
moon run cmd/main --target native -- bundle-package-plan _build/lepusa-bundle/lepusa-app/lepusa/distribution.json --json
moon run cmd/main --target native -- bundle-package-write _build/lepusa-bundle/lepusa-app/lepusa/distribution.json _build/lepusa-package
moon run cmd/main --target native -- bundle-install-smoke-plan _build/lepusa-bundle/lepusa-app/lepusa/distribution.json /Applications
moon run cmd/main --target native -- bundle-install-smoke-write _build/lepusa-bundle/lepusa-app/lepusa/distribution.json _build/lepusa-install-smoke /Applications
moon run cmd/main --target native -- publish-plan linux --project examples/static/lepusa.json
moon run cmd/main --target native -- publish-plan linux --project examples/static/lepusa.json --json
moon run cmd/runtime --target native -- --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- run --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- launch --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- bootstrap --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- launch-session --async-bridge --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- asset lepusa://packaged/main/index.html --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- lifecycle app-started --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- bridge-task main log.write '{"message":"ready"}' --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- bridge-handoff main log.write '{"message":"ready"}' --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- bridge-complete main fs.readText '{"scope":"data","path":"note.txt"}' --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- bridge-dispatch main log.write '{"message":"ready"}' --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- bridge-loop main fs.readText '{"scope":"data","path":"note.txt"}' --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- bridge-drain main fs.readText '{"scope":"data","path":"note.txt"}' --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/runtime --target native -- invoke main log.write '{"message":"ready"}' --manifest _build/lepusa-bundle/lepusa-app/lepusa/runtime.json
moon run cmd/main --target native -- build macos _build/lepusa-build --project _build/lepusa-app/lepusa.json
moon run cmd/main --target native -- bundle windows _build/lepusa-bundle-winmoon run cmd/main --target native -- init _build/lepusa-app --workspace /Users/kq/Workspace/lepusamoon run cmd/main --target native -- plugin new file-dialog _build/lepusa-plugin-file-dialog --workspace /Users/kq/Workspace/lepusa{
"bundleResources": [
{ "source": "public", "path": "public" },
{
"source": "_build/native/release/build/cmd/server/server.exe",
"path": "local-server",
"executable": true
}
]
}{
"bundleResources": [
{ "source": "public", "path": "public" },
{
"source": "_build/native/release/build/cmd/server/server.exe",
"path": "local-server",
"executable": true
}
]
}///|
let buffer = @log.LogBuffer::new()
///|
let registry = @log.registry(buffer~)
///|
let app = @lepusa.new(root)
.with_plugin(@log.plugin())
.with_capability(@log.capability_for_window("main")){
"runtimeDependencies": [
{ "name": "WebView2Loader.dll", "source": "vendor/WebView2Loader.dll" }
]
}pub struct App {
root : Cell
windows : Array[WindowConfig]
plugins : Array[Plugin]
capabilities : Array[Capability]
startup : Cmd
lifecycle_hooks : Array[LifecycleHook]
} derive(Eq, Debug)fn App::manager(self : App, config? : RuntimeConfig, registry? : CommandRegistry) -> Result[AppManager, Array[String]]fn App::window(self : App, label? : String, title? : String, width? : Int, height? : Int, resizable? : Bool, title_bar? : TitleBarStyle, source? : Source) -> Apppub struct AppManager {
plan : RuntimePlan
registry : CommandRegistry
resources : ResourceTable
channels : ChannelTable
events : EventBus
state : AppStateStore
}fn AppManager::close_resource_handle(self : AppManager, handle : ResourceHandle) -> Result[ResourceEntry, String]fn AppManager::drain_channel(self : AppManager, id : String) -> Result[Array[ChannelMessage], String]fn AppManager::emit(self : AppManager, event : Event, target? : EventTarget) -> Result[Array[EventDelivery], Array[String]]fn AppManager::fail_channel(self : AppManager, id : String, message : String) -> Result[ChannelMessage, String]fn AppManager::listen(self : AppManager, name : String, target? : EventTarget, once? : Bool) -> Result[EventListener, Array[String]]fn AppManager::manage_state(self : AppManager, key : String, kind? : String, value? : String) -> Result[AppStateEntry, Array[String]]fn AppManager::once(self : AppManager, name : String, target? : EventTarget) -> Result[EventListener, Array[String]]fn AppManager::open_channel(self : AppManager, owner? : String, name? : String, metadata? : String) -> Result[Channel, Array[String]]fn AppManager::open_resource(self : AppManager, descriptor : ResourceDescriptor) -> Result[ResourceEntry, Array[String]]fn AppManager::resource_handles_by_owner(self : AppManager, owner : String) -> Array[ResourceHandle]fn AppManager::send_channel(self : AppManager, id : String, payload : String) -> Result[ChannelMessage, String]fn AppStateStore::put(self : AppStateStore, entry : AppStateEntry) -> Result[AppStateEntry, Array[String]]fn AppStateStore::set(self : AppStateStore, key : String, kind? : String, value? : String) -> Result[AppStateEntry, Array[String]]pub struct BackpressurePolicy {
max_pending : Int
overflow : BackpressureOverflow
} derive(Eq, Debug)fn BackpressurePolicy::bounded(max_pending~ : Int, overflow? : BackpressureOverflow) -> BackpressurePolicyfn BackpressurePolicy::new(max_pending? : Int, overflow? : BackpressureOverflow) -> BackpressurePolicyfn BridgeConfig::new(global_name? : String, native_hook? : String, event_dispatch_hook? : String, window_label? : String) -> BridgeConfigpub struct BundleArtifact {
kind : BundleArtifactKind
path : String
description : String
} derive(Eq, Debug)fn BundleArtifact::new(kind~ : BundleArtifactKind, path~ : String, description~ : String) -> BundleArtifactpub struct BundleConfig {
metadata : AppMetadata
target : BundleTarget
icon_path : String?
resource_sources : Array[BundleResourceSource]
runtime_dependency_sources : Array[BundleRuntimeDependencySource]
signing : SigningConfig
} derive(Eq, Debug)fn BundleConfig::new(metadata : AppMetadata, target? : BundleTarget, icon_path? : String, resource_sources? : Array[BundleResourceSource], runtime_dependency_sources? : Array[BundleRuntimeDependencySource], signing? : SigningConfig) -> BundleConfigfn BundleConfig::plan(self : BundleConfig, runtime : RuntimePlan, registered_routes? : Array[String]) -> Result[BundlePlan, Array[String]]pub struct BundlePlan {
metadata : AppMetadata
target : BundleTarget
runtime : RuntimePlan
registered_routes : Array[String]
executable_name : String
bundle_name : String
icon_path : String?
resource_sources : Array[BundleResourceSource]
runtime_dependency_sources : Array[BundleRuntimeDependencySource]
signing : SigningConfig
} derive(Eq, Debug)fn BundlePlan::release_readiness(self : BundlePlan) -> Result[ReleaseReadinessReport, Array[String]]fn BundlePlan::runtime_dependency_sources(self : BundlePlan) -> Array[BundleRuntimeDependencySource]fn BundlePlan::update_manifest(self : BundlePlan, base_url~ : String, channel? : String, public_key? : String, artifact_trust? : Array[UpdateArtifactTrust]) -> Result[UpdateManifest, Array[String]]fn BundlePlan::update_manifest_json(self : BundlePlan, base_url~ : String, channel? : String, public_key? : String, artifact_trust? : Array[UpdateArtifactTrust]) -> Result[String, Array[String]]pub struct BundleResource {
kind : BundleResourceKind
source_path : String
path : String
} derive(Eq, Debug)fn BundleResource::new(kind~ : BundleResourceKind, source_path~ : String, path~ : String) -> BundleResourcefn BundleResourceSource::new(source_path~ : String, path~ : String, executable? : Bool) -> BundleResourceSourcepub struct BundleRuntimeDependency {
kind : BundleRuntimeDependencyKind
name : String
path : String?
source_path : String?
required : Bool
description : String
} derive(Eq, Debug)fn BundleRuntimeDependency::new(kind~ : BundleRuntimeDependencyKind, name~ : String, path? : String, source_path? : String, required? : Bool, description~ : String) -> BundleRuntimeDependencyfn BundleRuntimeDependencySource::new(name~ : String, source_path~ : String) -> BundleRuntimeDependencySourcepub struct Capability {
name : String
windows : Array[String]
origins : Array[String]
platforms : Array[String]
permissions : Array[Permission]
operation_scopes : Array[OperationScope]
} derive(Eq, Debug)fn Capability::allows(self : Capability, window_label~ : String, permission~ : Permission, origin? : String, platform? : String) -> Boolfn Capability::allows_operation(self : Capability, window_label~ : String, permission~ : Permission, scope~ : OperationScope, origin? : String, platform? : String) -> Boolfn Capability::operation_scopes_by_kind(self : Capability, kind : OperationScopeKind) -> Array[OperationScope]fn Capability::with_file_system_scopes(self : Capability, scopes : Array[FileSystemScope]) -> Capabilitypub struct CapabilityCompileIssue {
severity : CapabilityIssueSeverity
code : String
message : String
plugin : String
route : String
permission : String
capability : String
window_label : String
} derive(Eq, Debug)pub struct CapabilityCompileReport {
plugin_contracts : Array[PluginContract]
command_manifest : CommandManifest
permission_manifest : PermissionManifest
issues : Array[CapabilityCompileIssue]
} derive(Eq, Debug)fn CapabilityCompileReport::from_plugins(plugins~ : Array[Plugin], capabilities~ : Array[Capability], windows~ : Array[ResolvedWindow]) -> CapabilityCompileReportfn CapabilityCompileReport::permission_manifest(self : CapabilityCompileReport) -> PermissionManifestfn CapabilityCompileReport::plugin_contracts(self : CapabilityCompileReport) -> Array[PluginContract]fn CapabilityCompileReport::warnings(self : CapabilityCompileReport) -> Array[CapabilityCompileIssue]pub struct CapabilityDecision {
allowed : Bool
window_label : String
origin : String
platform : String
permission : Permission
capability : String
reason : String
} derive(Eq, Debug)fn CapabilityPolicy::allowed_origins(self : CapabilityPolicy, window_label~ : String, permission~ : Permission, platform? : String) -> Array[String]fn CapabilityPolicy::allows(self : CapabilityPolicy, window_label~ : String, permission~ : Permission, origin? : String, platform? : String) -> Boolfn CapabilityPolicy::allows_operation(self : CapabilityPolicy, window_label~ : String, permission~ : Permission, scope~ : OperationScope, origin? : String, platform? : String) -> Boolfn CapabilityPolicy::allows_window(self : CapabilityPolicy, window_label~ : String, permission~ : Permission, platform? : String) -> Boolfn CapabilityPolicy::evaluate(self : CapabilityPolicy, window_label~ : String, permission~ : Permission, origin? : String, platform? : String) -> CapabilityDecisionfn CapabilityPolicy::evaluate_operation(self : CapabilityPolicy, window_label~ : String, permission~ : Permission, scope~ : OperationScope, origin? : String, platform? : String) -> CapabilityDecisionpub struct Channel {
resource : ResourceEntry
next_sequence : Int
messages : Array[ChannelMessage]
closed : Bool
cancelled : Bool
} derive(Eq, Debug)pub struct ChannelMessage {
channel_id : String
sequence : Int
kind : ChannelMessageKind
payload : String
} derive(Eq, Debug)pub struct ChannelTable {
resources : ResourceTable
channels : Map[String, Channel]
order : Array[String]
}fn ChannelTable::fail(self : ChannelTable, id : String, message : String) -> Result[ChannelMessage, String]fn ChannelTable::open(self : ChannelTable, owner? : String, name? : String, metadata? : String) -> Result[Channel, Array[String]]fn ChannelTable::send(self : ChannelTable, id : String, payload : String) -> Result[ChannelMessage, String]fn CommandManifest::allows(self : CommandManifest, route : String, window_label~ : String, origin? : String, platform? : String) -> Boolfn CommandManifest::from_plugins(plugins~ : Array[Plugin], capabilities~ : Array[Capability], windows~ : Array[ResolvedWindow], platform? : String) -> CommandManifestfn CommandManifest::routes_by_affinity(self : CommandManifest, affinity : CommandExecutionAffinity) -> Array[String]pub struct CommandManifestEntry {
plugin : String
command : String
route : String
mode : CommandMode
affinity : CommandExecutionAffinity
permission : Permission
request_schema : IpcSchema
response_schema : IpcSchema
allowed_windows : Array[String]
allowed_origins : Array[String]
allowed_platforms : Array[String]
} derive(Eq, Debug)fn CommandManifestEntry::allowed_in_window(self : CommandManifestEntry, window_label : String) -> Boolfn CommandManifestEntry::allowed_on_platform(self : CommandManifestEntry, platform : String) -> Boolpub struct CommandRegistry {
commands : Map[String, RegisteredCommand]
duplicate_routes : Array[String]
}fn CommandRegistry::dispatch(self : CommandRegistry, request : InvokeRequest, capabilities? : Array[Capability]) -> InvokeResponseasync fn CommandRegistry::dispatch_async(self : CommandRegistry, request : InvokeRequest, capabilities? : Array[Capability]) -> InvokeResponsefn CommandRegistry::dispatch_with_permission(self : CommandRegistry, request : InvokeRequest, permission~ : Permission, capabilities? : Array[Capability]) -> InvokeResponseasync fn CommandRegistry::dispatch_with_permission_async(self : CommandRegistry, request : InvokeRequest, permission~ : Permission, capabilities? : Array[Capability]) -> InvokeResponsefn CommandRegistry::dispatch_with_profile(self : CommandRegistry, profile : SecurityProfile, request : InvokeRequest) -> InvokeResponseasync fn CommandRegistry::dispatch_with_profile_async(self : CommandRegistry, profile : SecurityProfile, request : InvokeRequest) -> InvokeResponsefn CommandRegistry::invoke_contract(self : CommandRegistry, profile : SecurityProfile, route : String) -> InvokeContract?fn CommandRegistry::invoke_contract_report(self : CommandRegistry, profile : SecurityProfile) -> InvokeContractReportfn CommandRegistry::invoke_contracts(self : CommandRegistry, profile : SecurityProfile) -> Array[InvokeContract]fn CommandRegistry::register(self : CommandRegistry, command : RegisteredCommand) -> CommandRegistryfn CommandRegistry::register_async_fn(self : CommandRegistry, route : String, permission? : Permission, operation_scope? : (InvokeRequest) -> Result[OperationScope, String], handler~ : async (String) -> Result[String, String]) -> CommandRegistryfn CommandRegistry::register_fn(self : CommandRegistry, route : String, permission? : Permission, operation_scope? : (InvokeRequest) -> Result[OperationScope, String], handler~ : (String) -> Result[String, String]) -> CommandRegistryfn CommandRegistry::register_stream_fn(self : CommandRegistry, route : String, permission? : Permission, operation_scope? : (InvokeRequest) -> Result[OperationScope, String], handler~ : (String, StreamSink) -> Result[Unit, String]) -> CommandRegistrypub struct CommandSpec {
name : String
mode : CommandMode
affinity : CommandExecutionAffinity
permission : Permission
request_schema : IpcSchema
response_schema : IpcSchema
} derive(Eq, Debug)fn CommandSpec::new(name : String, mode? : CommandMode, affinity? : CommandExecutionAffinity, permission? : Permission, request? : IpcSchema, response? : IpcSchema) -> CommandSpecfn CommandSpec::with_affinity(self : CommandSpec, affinity : CommandExecutionAffinity) -> CommandSpecfn CommandSpec::with_schema(self : CommandSpec, request? : IpcSchema, response? : IpcSchema) -> CommandSpecpub struct EventBus {
next_listener_sequence : Int
listeners : Map[String, EventListener]
order : Array[String]
} derive(Eq, Debug)fn EventBus::emit(self : EventBus, event : Event, target? : EventTarget) -> Result[Array[EventDelivery], Array[String]]fn EventBus::listen(self : EventBus, name : String, target? : EventTarget, once? : Bool) -> Result[EventListener, Array[String]]fn EventBus::listeners_for(self : EventBus, name : String, target? : EventTarget) -> Array[EventListener]fn EventBus::once(self : EventBus, name : String, target? : EventTarget) -> Result[EventListener, Array[String]]pub struct EventDelivery {
listener_id : String
target : EventTarget
event : Event
} derive(Eq, Debug)pub struct EventListener {
id : String
name : String
target : EventTarget
once : Bool
} derive(Eq, Debug)fn FrontendEventDispatch::new(window_label~ : String, hook? : String, event~ : Event) -> FrontendEventDispatchpub struct InvokeContract {
route : String
plugin : String
command : String
mode : CommandMode
affinity : CommandExecutionAffinity
permission : Permission
request_schema : IpcSchema
response_schema : IpcSchema
allowed_windows : Array[String]
allowed_origins : Array[String]
requires_registered_handler : Bool
registered : Bool
registered_mode : CommandMode?
registered_permission : Permission?
exposed : Bool
operation_scope_configured : Bool
operation_scope_required : Bool
problems : Array[String]
} derive(Eq, Debug)pub struct InvokeFailure {
kind : InvokeErrorKind
message : String
route : String
} derive(Eq, Debug)fn InvokeRequest::new(id~ : String, window_label~ : String, plugin~ : String, command~ : String, payload? : String, origin? : String, callback_id? : String, error_id? : String) -> InvokeRequestpub(all) enum InvokeResponse {
InvokeOk(String, String)
InvokeError(String, InvokeFailure)
} derive(Eq, Debug)pub struct LaunchPlan {
root : Cell
windows : Array[WindowConfig]
plugins : Array[Plugin]
capabilities : Array[Capability]
startup : Cmd
lifecycle_hooks : Array[LifecycleHook]
} derive(Eq, Debug)fn LocalService::new(name~ : String, command~ : Array[String], readiness_url~ : String) -> LocalServicepub(all) enum LocalServiceSupervisorAction {
StartLocalService(LocalService)
WaitLocalServiceReady(LocalService)
StopLocalService(LocalService)
} derive(Eq, Debug)pub struct LocalServiceSupervisorPlan {
services : Array[LocalService]
startup_services : Array[LocalService]
startup_actions : Array[LocalServiceSupervisorAction]
shutdown_actions : Array[LocalServiceSupervisorAction]
} derive(Eq, Debug)fn LocalServiceSupervisorPlan::new(services? : Array[LocalService], startup_services? : Array[LocalService]) -> LocalServiceSupervisorPlanfn LocalServiceSupervisorPlan::shutdown_actions(self : LocalServiceSupervisorPlan) -> Array[LocalServiceSupervisorAction]fn LocalServiceSupervisorPlan::startup_actions(self : LocalServiceSupervisorPlan) -> Array[LocalServiceSupervisorAction]fn LocalServiceSupervisorPlan::startup_services(self : LocalServiceSupervisorPlan) -> Array[LocalService]fn LocalhostSource::new(port~ : Int, host? : String, path? : String, readiness_path? : String, command? : Array[String]) -> LocalhostSourcepub struct OperationScope {
kind : OperationScopeKind
value : String
writable : Bool
} derive(Eq, Debug)pub(all) enum Permission {
App
FileSystemRead
FileSystemWrite
FileDialog
Network
Localhost
DeepLink
SingleInstance
Menu
Tray
AutoLaunch
Window
WindowState
Updater
ServiceDiscovery
Shell
Opener
Dialog
Clipboard
Notification
ProcessInfo
ProcessEnvironment
ProcessControl
Custom(String)
} derive(Eq, Debug)pub struct PermissionManifest {
permissions : Array[PermissionManifestPermission]
} derive(Eq, Debug)fn PermissionManifest::from_command_manifest(manifest : CommandManifest, capabilities~ : Array[Capability]) -> PermissionManifestfn PermissionManifest::from_plugins(plugins~ : Array[Plugin], capabilities~ : Array[Capability], windows~ : Array[ResolvedWindow], platform? : String) -> PermissionManifestfn PermissionManifest::new(permissions? : Array[PermissionManifestPermission]) -> PermissionManifestfn PermissionManifest::permission(self : PermissionManifest, name : String) -> PermissionManifestPermission?fn PermissionManifest::permissions(self : PermissionManifest) -> Array[PermissionManifestPermission]pub struct PermissionManifestCommand {
plugin : String
command : String
route : String
mode : CommandMode
affinity : CommandExecutionAffinity
allowed_windows : Array[String]
allowed_origins : Array[String]
allowed_platforms : Array[String]
} derive(Eq, Debug)fn PermissionManifestCommand::affinity(self : PermissionManifestCommand) -> CommandExecutionAffinityfn PermissionManifestGrant::operation_scopes(self : PermissionManifestGrant) -> Array[OperationScope]pub struct PermissionManifestPermission {
name : String
commands : Array[PermissionManifestCommand]
grants : Array[PermissionManifestGrant]
allowed_windows : Array[String]
allowed_origins : Array[String]
allowed_platforms : Array[String]
denied_routes : Array[String]
} derive(Eq, Debug)fn PermissionManifestPermission::allowed_origins(self : PermissionManifestPermission) -> Array[String]fn PermissionManifestPermission::allowed_platforms(self : PermissionManifestPermission) -> Array[String]fn PermissionManifestPermission::allowed_windows(self : PermissionManifestPermission) -> Array[String]fn PermissionManifestPermission::commands(self : PermissionManifestPermission) -> Array[PermissionManifestCommand]fn PermissionManifestPermission::denied_routes(self : PermissionManifestPermission) -> Array[String]fn PermissionManifestPermission::grants(self : PermissionManifestPermission) -> Array[PermissionManifestGrant]pub struct Plugin {
name : String
commands : Array[CommandSpec]
lifecycle_hooks : Array[LifecycleHook]
} derive(Eq, Debug)fn Plugin::command(self : Plugin, name : String, mode? : CommandMode, affinity? : CommandExecutionAffinity, permission? : Permission, request? : IpcSchema, response? : IpcSchema) -> Pluginfn Plugin::command_async(self : Plugin, name : String, permission? : Permission, request? : IpcSchema, response? : IpcSchema, affinity? : CommandExecutionAffinity) -> Pluginfn Plugin::command_event(self : Plugin, name : String, permission? : Permission, request? : IpcSchema, response? : IpcSchema, affinity? : CommandExecutionAffinity) -> Pluginfn Plugin::command_stream(self : Plugin, name : String, permission? : Permission, request? : IpcSchema, response? : IpcSchema, affinity? : CommandExecutionAffinity) -> Pluginfn Plugin::command_sync(self : Plugin, name : String, permission? : Permission, request? : IpcSchema, response? : IpcSchema, affinity? : CommandExecutionAffinity) -> Pluginpub struct PluginCommandContract {
plugin : String
name : String
route : String
mode : CommandMode
affinity : CommandExecutionAffinity
permission : Permission
request_schema : IpcSchema
response_schema : IpcSchema
} derive(Eq, Debug)fn PluginCommandContract::from_command(plugin_name~ : String, command : CommandSpec) -> PluginCommandContractpub struct PluginContract {
name : String
commands : Array[PluginCommandContract]
lifecycle_hooks : Array[PluginLifecycleContract]
permissions : Array[String]
problems : Array[String]
} derive(Eq, Debug)fn PluginContract::command_count_by_affinity(self : PluginContract, affinity : CommandExecutionAffinity) -> Intpub struct ProjectManifest {
metadata : AppMetadata
windows : Array[WindowConfig]
plugins : Array[Plugin]
capabilities : Array[Capability]
filesystem_scopes : Array[FileSystemScope]
startup : Cmd
lifecycle_hooks : Array[LifecycleHook]
runtime : RuntimeConfig
icon_path : String?
resource_sources : Array[BundleResourceSource]
runtime_dependency_sources : Array[BundleRuntimeDependencySource]
signing : SigningConfig
} derive(Eq, Debug)fn ProjectManifest::bundle_plan(self : ProjectManifest, root : Cell, target? : BundleTarget, registered_routes? : Array[String]) -> Result[BundlePlan, Array[String]]fn ProjectManifest::launch_plan(self : ProjectManifest, root : Cell) -> Result[LaunchPlan, Array[String]]fn ProjectManifest::new(metadata : AppMetadata, windows? : Array[WindowConfig], plugins? : Array[Plugin], capabilities? : Array[Capability], filesystem_scopes? : Array[FileSystemScope], startup? : Cmd, lifecycle_hooks? : Array[LifecycleHook], runtime? : RuntimeConfig, icon_path? : String, resource_sources? : Array[BundleResourceSource], runtime_dependency_sources? : Array[BundleRuntimeDependencySource], signing? : SigningConfig) -> ProjectManifestfn ProjectManifest::runtime_dependency_sources(self : ProjectManifest) -> Array[BundleRuntimeDependencySource]fn ProjectManifest::runtime_plan(self : ProjectManifest, root : Cell) -> Result[RuntimePlan, Array[String]]fn ProjectManifest::with_capability(self : ProjectManifest, capability : Capability) -> ProjectManifestfn ProjectManifest::with_file_system_scope(self : ProjectManifest, scope : FileSystemScope) -> ProjectManifestfn ProjectManifest::with_lifecycle(self : ProjectManifest, event : LifecycleEvent, command : Cmd) -> ProjectManifestfn ProjectManifest::with_resource_source(self : ProjectManifest, source : BundleResourceSource) -> ProjectManifestfn ProjectManifest::with_runtime(self : ProjectManifest, runtime : RuntimeConfig) -> ProjectManifestfn ProjectManifest::with_runtime_dependency_source(self : ProjectManifest, source : BundleRuntimeDependencySource) -> ProjectManifestfn ProjectManifest::with_signing(self : ProjectManifest, signing : SigningConfig) -> ProjectManifestpub struct RegisteredCommand {
route : String
permission : Permission
operation_scope : (InvokeRequest) -> Result[OperationScope, String]?
handler : RegisteredCommandHandler
}fn RegisteredCommand::new(route : String, permission? : Permission, operation_scope? : (InvokeRequest) -> Result[OperationScope, String], handler~ : (String) -> Result[String, String]) -> RegisteredCommandfn RegisteredCommand::new_async(route : String, permission? : Permission, operation_scope? : (InvokeRequest) -> Result[OperationScope, String], handler~ : async (String) -> Result[String, String]) -> RegisteredCommandfn RegisteredCommand::new_stream(route : String, permission? : Permission, operation_scope? : (InvokeRequest) -> Result[OperationScope, String], handler~ : (String, StreamSink) -> Result[Unit, String]) -> RegisteredCommandfn RegisteredCommand::resolve_operation_scope(self : RegisteredCommand, request : InvokeRequest) -> Result[OperationScope?, String]pub struct ReleaseReadinessReport {
target : BundleTarget
files : Int
resources : Int
artifacts : Int
runtime_dependencies : Int
required_runtime_dependencies : Int
signing_configured : Bool
signing_prerequisites : Int
signing_steps : Int
runtime_webviews : Int
command_routes : Int
registered_routes : Int
native_launch_session_ready : Bool
native_launch_session_issue : String
issues : Array[String]
} derive(Eq, Debug)pub struct ResolvedSource {
kind : ResolvedSourceKind
url : String
protocol_mappings : Array[ProtocolMapping]
virtual_files : Array[VirtualFile]
local_services : Array[LocalService]
} derive(Eq, Debug)pub struct ResolvedWindow {
label : String
title : String
width : Int
height : Int
resizable : Bool
title_bar : TitleBarStyle
source : ResolvedSource
} derive(Eq, Debug)pub struct ResourceCleanupReport {
closed : Array[ResourceEntry]
remaining : Array[ResourceEntry]
} derive(Eq, Debug)fn ResourceCleanupReport::new(closed? : Array[ResourceEntry], remaining? : Array[ResourceEntry]) -> ResourceCleanupReportfn ResourceDescriptor::new(kind~ : String, owner? : String, name? : String, metadata? : String) -> ResourceDescriptorfn ResourceHandle::new(id~ : String, kind~ : String, owner? : String, name? : String) -> ResourceHandlepub struct ResourceTable {
next_sequence : Int
id_prefix : String
entries : Map[String, ResourceEntry]
order : Array[String]
}fn ResourceTable::close_handle(self : ResourceTable, handle : ResourceHandle) -> Result[ResourceEntry, String]fn ResourceTable::open(self : ResourceTable, descriptor : ResourceDescriptor) -> Result[ResourceEntry, Array[String]]pub struct RunReport {
target : String
backend : String
engine : String
status : RunStatus
webviews : Int
first_window_title : String
first_window_url : String
load_url : String
bridge_url : String
local_services : Int
service_supervisor : Bool
service_start_order : Array[String]
startup_operations : Int
lifecycle_steps : Int
executable_operations : Int
executed_operations : Int
skipped_operations : Int
failed_operations : Int
first_execution_failure : String
bridge_sync_routes : Int
bridge_async_routes : Int
target_can_launch : Bool
target_launch_blocker : String
} derive(Eq, Debug)fn RunReport::new(target~ : String, backend~ : String, engine~ : String, status~ : RunStatus, webviews~ : Int, first_window_title? : String, first_window_url? : String, load_url? : String, bridge_url? : String, local_services? : Int, service_supervisor? : Bool, service_start_order? : Array[String], startup_operations? : Int, lifecycle_steps? : Int, executable_operations? : Int, executed_operations? : Int, skipped_operations? : Int, failed_operations? : Int, first_execution_failure? : String, bridge_sync_routes? : Int, bridge_async_routes? : Int, target_can_launch? : Bool, target_launch_blocker? : String) -> RunReportpub(all) enum RuntimeAction {
RuntimeEffect(String)
RuntimeEmit(EventTarget, Event)
RuntimeNavigate(String, ResolvedSource)
} derive(Eq, Debug)pub struct RuntimeAudit {
command_manifest : CommandManifest
permission_manifest : PermissionManifest
registered_routes : Array[String]
route_exposures : Array[RuntimeRouteExposure]
findings : Array[RuntimeAuditFinding]
} derive(Eq, Debug)fn RuntimeAudit::findings_by_severity(self : RuntimeAudit, severity : RuntimeAuditSeverity) -> Array[RuntimeAuditFinding]fn RuntimeAudit::from_registered_routes(plan : RuntimePlan, registered_routes : Array[String]) -> RuntimeAuditpub struct RuntimeAuditFinding {
severity : RuntimeAuditSeverity
kind : RuntimeAuditKind
route : String
message : String
} derive(Eq, Debug)fn RuntimeAuditFinding::new(severity~ : RuntimeAuditSeverity, kind~ : RuntimeAuditKind, route~ : String, message~ : String) -> RuntimeAuditFindingpub struct RuntimeConfig {
backend : RuntimeBackend
devtools : Bool
asset_protocol : String
platform : String
} derive(Eq, Debug)fn RuntimeConfig::system_webview(devtools? : Bool, asset_protocol? : String, platform? : String) -> RuntimeConfigpub struct RuntimeInvokeAuthorization {
kind : RuntimeInvokeAuthorizationKind
route : String
window_label : String
origin : String
platform : String
permission : Permission?
registered : Bool
capability : String
reason : String
} derive(Eq, Debug)fn RuntimeInvokeAuthorization::kind(self : RuntimeInvokeAuthorization) -> RuntimeInvokeAuthorizationKindfn RuntimeInvokeAuthorization::to_response(self : RuntimeInvokeAuthorization, id : String) -> InvokeResponsepub struct RuntimeLaunchAsset {
url : String
mime_type : String
body : RuntimeLaunchAssetBody
} derive(Eq, Debug)pub struct RuntimeLaunchManifest {
backend : String
platform : String
asset_protocol : String
devtools : Bool
bridge_url : String
webviews : Array[RuntimeWebViewBoot]
protocol_mappings : Array[RuntimeProtocolBinding]
virtual_files : Array[RuntimeVirtualAsset]
local_services : Array[LocalService]
filesystem_scopes : Array[FileSystemScope]
capabilities : Array[RuntimeCapabilityGrant]
startup_actions : Array[RuntimeAction]
lifecycle_hooks : Array[RuntimeLifecycleHook]
command_manifest : CommandManifest
permission_manifest : PermissionManifest
declared_routes : Array[String]
command_routes : Array[String]
registered_routes : Array[String]
} derive(Eq, Debug)fn RuntimeLaunchManifest::capabilities(self : RuntimeLaunchManifest) -> Array[RuntimeCapabilityGrant]fn RuntimeLaunchManifest::file_system_scopes(self : RuntimeLaunchManifest) -> Array[FileSystemScope]fn RuntimeLaunchManifest::lifecycle_hooks(self : RuntimeLaunchManifest) -> Array[RuntimeLifecycleHook]fn RuntimeLaunchManifest::protocol_mappings(self : RuntimeLaunchManifest) -> Array[RuntimeProtocolBinding]fn RuntimeLaunchManifest::resolve_asset(self : RuntimeLaunchManifest, url : String) -> Result[RuntimeLaunchAsset, String]pub struct RuntimeLifecycleHook {
event : LifecycleEvent
actions : Array[RuntimeAction]
} derive(Eq, Debug)fn RuntimeLifecycleHook::new(event : LifecycleEvent, actions : Array[RuntimeAction]) -> RuntimeLifecycleHookpub struct RuntimePlan {
app_metadata : AppMetadata?
launch : LaunchPlan
backend : RuntimeBackend
devtools : Bool
asset_protocol : String
platform : String
command_routes : Array[String]
windows : Array[ResolvedWindow]
filesystem_scopes : Array[FileSystemScope]
} derive(Eq, Debug)fn RuntimePlan::actions(self : RuntimePlan, command : Cmd) -> Result[Array[RuntimeAction], Array[String]]fn RuntimePlan::audit_with_registered_routes(self : RuntimePlan, registered_routes : Array[String]) -> RuntimeAuditfn RuntimePlan::authorize_invoke(self : RuntimePlan, request : InvokeRequest, registered_routes? : Array[String], check_registered? : Bool) -> RuntimeInvokeAuthorizationfn RuntimePlan::bridge_script(self : RuntimePlan, config? : BridgeConfig) -> Result[BridgeScript, Array[String]]fn RuntimePlan::launch_manifest(self : RuntimePlan, registered_routes? : Array[String], restrict_registered? : Bool) -> Result[RuntimeLaunchManifest, Array[String]]fn RuntimePlan::lifecycle_actions(self : RuntimePlan, event : LifecycleEvent) -> Result[Array[RuntimeAction], Array[String]]fn RuntimePlan::lifecycle_hooks(self : RuntimePlan) -> Result[Array[RuntimeLifecycleHook], Array[String]]fn RuntimePlan::security_profile(self : RuntimePlan, registered_routes? : Array[String], check_handlers? : Bool) -> SecurityProfilepub struct RuntimeRouteExposure {
route : String
mode : CommandMode
registered : Bool
exposed : Bool
windows : Array[String]
reasons : Array[String]
} derive(Eq, Debug)pub struct RuntimeWebViewBoot {
label : String
title : String
url : String
width : Int
height : Int
resizable : Bool
title_bar : TitleBarStyle
devtools : Bool
asset_protocol : String
bridge_global_name : String
native_hook : String
event_dispatch_hook : String
allowed_routes : Array[String]
initialization_scripts : Array[String]
} derive(Eq, Debug)pub struct SecurityProfile {
command_manifest : CommandManifest
permission_manifest : PermissionManifest
capability_policy : CapabilityPolicy
capability_report : CapabilityCompileReport
runtime_audit : RuntimeAudit
registered_routes : Array[String]
check_handlers : Bool
platform : String
} derive(Eq, Debug)fn SecurityProfile::allowed_origins(self : SecurityProfile, window_label~ : String, permission~ : Permission) -> Array[String]fn SecurityProfile::allows(self : SecurityProfile, window_label~ : String, permission~ : Permission, origin? : String) -> Boolfn SecurityProfile::allows_operation(self : SecurityProfile, window_label~ : String, permission~ : Permission, scope~ : OperationScope, origin? : String) -> Boolfn SecurityProfile::authorize_invoke(self : SecurityProfile, request : InvokeRequest) -> RuntimeInvokeAuthorizationfn SecurityProfile::authorize_operation(self : SecurityProfile, request : InvokeRequest, scope : OperationScope) -> RuntimeInvokeAuthorizationfn SecurityProfile::evaluate(self : SecurityProfile, window_label~ : String, permission~ : Permission, origin? : String) -> CapabilityDecisionfn SecurityProfile::evaluate_operation(self : SecurityProfile, window_label~ : String, permission~ : Permission, scope~ : OperationScope, origin? : String) -> CapabilityDecisionfn SecurityProfile::from_plan(plan : RuntimePlan, registered_routes? : Array[String], check_handlers? : Bool) -> SecurityProfilefn SigningConfig::new(identity? : String, team_id? : String, entitlements_path? : String, notarization_profile? : String, timestamp_url? : String) -> SigningConfigpub struct SigningPrerequisite {
kind : SigningPrerequisiteKind
name : String
description : String
} derive(Eq, Debug)fn SigningPrerequisite::new(kind~ : SigningPrerequisiteKind, name~ : String, description~ : String) -> SigningPrerequisitefn SigningStep::new(name~ : String, tool~ : String, arguments~ : Array[String], description~ : String) -> SigningSteppub(all) enum Source {
InlineHtml(String)
LocalPath(String)
PackagedAssets(String)
RemoteUrl(String)
Localhost(LocalhostSource)
RabbitaCell(Cell)
} derive(Eq, Debug)fn Source::resolve(self : Source, window_label~ : String, asset_protocol? : String) -> Result[ResolvedSource, String]fn UpdateArtifactTrust::new(path~ : String, sha256~ : String, signature? : String) -> UpdateArtifactTrustpub struct UpdateManifest {
identifier : String
product_name : String
version : String
channel : String
public_key : String?
artifacts : Array[UpdateManifestArtifact]
} derive(Eq, Debug)fn UpdateManifest::new(identifier~ : String, product_name~ : String, version~ : String, channel? : String, public_key? : String, artifacts~ : Array[UpdateManifestArtifact]) -> UpdateManifestpub struct UpdateManifestArtifact {
target : BundleTarget
kind : BundleArtifactKind
path : String
url : String
sha256 : String
signature : String?
} derive(Eq, Debug)fn UpdateManifestArtifact::new(target~ : BundleTarget, kind~ : BundleArtifactKind, path~ : String, url~ : String, sha256~ : String, signature? : String) -> UpdateManifestArtifactfn UpdateManifestArtifact::validate(self : UpdateManifestArtifact, signature_required? : Bool) -> Array[String]pub struct WindowConfig {
label : String
title : String
width : Int
height : Int
resizable : Bool
title_bar : TitleBarStyle
source : Source?
} derive(Eq, Debug)fn WindowConfig::new(label? : String, title? : String, width? : Int, height? : Int, resizable? : Bool, title_bar? : TitleBarStyle, source? : Source) -> WindowConfigfn WindowConfig::resolve(self : WindowConfig, asset_protocol? : String) -> Result[ResolvedWindow, Array[String]]fn capabilities_with_file_system_scopes(capabilities~ : Array[Capability], scopes~ : Array[FileSystemScope]) -> Array[Capability]fn moonsuite_product_runtime_path_for_workspace_root(root : String) -> Stringfn moonsuite_product_service_path_for_workspace_root(root : String) -> Stringfn moonsuite_product_state_path_for_workspace_root(root : String) -> Stringfn moonsuite_product_tmp_path_for_workspace_root(root : String) -> Stringfn moonsuite_product_update_metadata_path_for_workspace_root(root : String) -> StringMoonBit-native desktop application framework research and implementation.
Dependencies