#Lepus WebView

    lepus-apps/lepus/webview is a MoonBit-native desktop framework built on top of webview. It provides:

    • Native windows (WebKit / WebView2)
    • Typed JS MoonBit bridge
    • Plugin-style command routing
    • Parent/child process IPC APIs

    #Architecture

    flowchart LR subgraph JS["JavaScript Runtime"] JSAPI["window.lepusBridge / window.lepusApi"] end subgraph MB["MoonBit Runtime"] WV["WebView"] PL["PluginHost + CommandRouter"] WM["WindowManager (IPC)"] APP["Managed App (parent/child)"] end subgraph NATIVE["Native Layer"] STUB["stub.c + binding.mbt"] LIB["webview C library"] end JSAPI <-->|"Command request/response"| PL PL <-->|"Cross-process command/event"| WM APP --> WM PL --> WV WV --> STUB --> LIB

    #API List

    API list below is aligned with pkg.generated.mbti.

    #WebView

    • Lifecycle: destroy, terminate
    • Window/UI: set_title, set_size, set_html, navigate
    • Window controls: minimize, maximize, unmaximize, toggle_maximize, set_fullscreen, toggle_fullscreen, close
    • Window customization: set_window_customization, enable_custom_titlebar_support, enable_transparent_background_support
    • History: back, forward, go, reload, reload_force
    • Handle: get_handle

    #Window (Managed App)

    • Setup: new, install, set_html, navigate
    • Window controls: minimize, maximize, unmaximize, toggle_maximize, set_fullscreen, toggle_fullscreen, close
    • Window customization: set_window_customization
    • History: back, forward, go, reload, reload_force
    • Run: run

    #Plugin / PluginHost / PluginContext

    • Plugin build/install: Plugin::new, PluginInternal::new, PluginHost::new, PluginHost::install, PluginHost::destroy
    • Context handlers: command_async, command_result_async, command_result_bg
    • Bridge access: PluginHost::command_bridge, PluginHost::global_name

    #Process Command IPC

    • Request/response model: ProcessCommandRequest, ProcessCommandResponse
    • Router: ProcessCommandRouter::{new, handle, handle_async, handle_result, handle_result_async, dispatch, serve, plugin}
    • Proxy: ProcessCommandProxy::{new, call, call_plugin, plugin_handler}
    • Plugin router: ProcessPluginRouter::{command, command_async, command_result, command_result_async}

    #Window Manager IPC

    • Process control: init, fork_process, spawn_process, connect_child_process
    • Window control: create_window, create_child_window, run_window, destroy_window, destroy, set_window_customization, minimize_window, maximize_window, unmaximize_window, toggle_maximize_window, set_fullscreen_window, toggle_fullscreen_window, close_window
    • Messaging: send_message, broadcast, request, respond, try_pop_message
    • Process-command serving: serve_process_commands
    • State: is_main_process, is_child_process, wait_child_noblock

    #Window Customization

    Window::new(...) and WebView::new_managed(...) support:

    • frameless : Bool
    • resizable : Bool
    • always_on_top : Bool
    • transparent : Bool
    • title_bar_style : Int (0 default, 1 hidden)
    • title_bar_overlay : Bool

    Constants:

    • @webview.TITLE_BAR_STYLE_DEFAULT
    • @webview.TITLE_BAR_STYLE_HIDDEN

    #Drag Region (-webkit-app-region: drag)

    For custom title bars, Lepus injects drag helpers automatically when one of the following is true:

    • frameless = true
    • title_bar_style = TITLE_BAR_STYLE_HIDDEN
    • title_bar_overlay = true

    You can mark draggable and interactive regions with:

    • draggable: .lepus-drag, .lepus-titlebar, [data-lepus-drag="true"]
    • non-draggable: .lepus-no-drag

    You can also use raw CSS directly:

    .titlebar { -webkit-app-region: drag; } .titlebar button { -webkit-app-region: no-drag; }

    #Example

    Run the included demo:

    moon build --target native example moon run --target native example

    Minimal managed-window example:

    ///|
    fn main {
    let win = @webview.Window(title="Lepus WebView", width=960, height=640)
    win.set_html("<html><body><h1>Hello from MoonBit</h1></body></html>")
    win.run()
    }

    #Build & Test

    moon check moon test --target native moon build --target native

    #License

    Apache-2.0

    ProcessCommandError

    type ProcessCommandError

    CommandBridge

    type CommandBridge[X]

    High-level command bridge using webview_bind.

    JS API:
    • window[global_name].send(name, payload) → calls MoonBit command

    CommandResponse

    pub(all) enum CommandResponse {
    Ok(Json)
    Error(String)
    } derive(Eq)

    Structured response returned from JS → MoonBit commands.

    CommandResponse::equal

    CommandResponse::not_equal

    fn CommandResponse::not_equal(x : CommandResponse, y : CommandResponse) -> Bool

    IpcMessage

    pub struct IpcMessage {
    source_window_id : Int
    target_window_id : Int
    message_type : IpcMessageType
    message_id : Int
    subtype : String
    data : String
    }

    Snapshot of one IPC message copied out of the native queue.

    IpcMessageType

    pub(all) enum IpcMessageType {
    Data
    Command
    Event
    Request
    Response
    } derive(Eq)

    IPC message kind.

    IpcMessageType::equal

    IpcMessageType::int

    fn IpcMessageType::int(self : IpcMessageType) -> Int

    IpcMessageType::not_equal

    fn IpcMessageType::not_equal(x : IpcMessageType, y : IpcMessageType) -> Bool

    Plugin

    pub struct Plugin {
    name : String
    install_scripts : Array[String]
    parent_installers : Array[(ProcessPluginRouter) -> Unit]
    child_installers : Array[(PluginContext[Unit], ProcessCommandProxy) -> Unit]
    direct_installers : Array[(PluginContext[Unit]) -> Unit]
    }

    A plugin definition that can be installed into a PluginHost.

    A plugin is typically exposed from a MoonBit module:

    pub fn plugin() -> @webview.Plugin {
    @webview.Plugin("math", fn(plugin) {
    plugin.command("sum", fn(payload : SumPayload) {
    SumReply{ total: payload.left + payload.right }
    })
    })
    }

    Managed plugins are built once and then used in both:
    • parent process: register real handlers
    • child process: register proxy handlers or direct handlers

    Plugin::Plugin

    #alias(new, deprecated="Use `Plugin()` instead")
    fn Plugin::Plugin(name : String, register : (PluginBuilder) -> Unit) -> Plugin

    Creates a managed plugin whose commands are available from JavaScript without exposing IPC details to user code.

    PluginBuilder

    pub struct PluginBuilder {
    plugin_name : String
    install_scripts : Array[String]
    parent_installers : Array[(ProcessPluginRouter) -> Unit]
    child_installers : Array[(PluginContext[Unit], ProcessCommandProxy) -> Unit]
    direct_installers : Array[(PluginContext[Unit]) -> Unit]
    }

    Registration context used while building a managed Plugin.

    PluginBuilder::command

    fn[Payload :
    FromJson
    + ToJson, Reply :
    FromJson
    + ToJson] PluginBuilder::command(self : PluginBuilder, api_name : String, callback : async (Payload) -> Reply) -> Unit

    Registers a typed async plugin command.

    PluginBuilder::command_result_async

    fn[Payload :
    FromJson
    + ToJson, Reply :
    FromJson
    + ToJson] PluginBuilder::command_result_async(self : PluginBuilder, api_name : String, callback : async (Payload) -> Reply) -> Unit

    Registers a typed async plugin command that can raise explicit command errors.

    PluginBuilder::command_sync

    fn[Payload :
    FromJson
    + ToJson, Reply :
    FromJson
    + ToJson] PluginBuilder::command_sync(self : PluginBuilder, api_name : String, callback : (Payload) -> Reply) -> Unit

    Registers a typed synchronous plugin command.

    PluginBuilder::script

    fn PluginBuilder::script(self : PluginBuilder, script : String) -> Unit

    Registers a JavaScript snippet injected when this plugin is installed.

    PluginContext

    type PluginContext[X]

    Registration context handed to a plugin while it installs its public APIs.

    PluginContext::command_async

    fn[X, Payload :
    FromJson
    , Reply : ToJson] PluginContext::command_async(self : PluginContext[X], api_name : String, callback : async (Payload) -> Reply) -> Unit

    Registers an async typed plugin command.

    The command becomes callable from JavaScript through: window.lepusApi[plugin_name][api_name](...args). The callback is spawned as a background task, non-blocking.

    PluginContext::command_result_async

    fn[X, Payload :
    FromJson
    , Reply : ToJson] PluginContext::command_result_async(self : PluginContext[X], api_name : String, callback : async (Payload) -> Reply) -> Unit

    Registers an async typed plugin command that can return explicit command errors.

    PluginContext::command_result_bg

    fn[X, Payload :
    FromJson
    , Reply : ToJson] PluginContext::command_result_bg(self : PluginContext[X], api_name : String, callback : (Payload) -> Reply raise) -> Unit

    Registers a typed plugin command that performs blocking work on a detached native thread and responds asynchronously to JavaScript.

    PluginContext::command_sync

    fn[X, Payload :
    FromJson
    , Reply : ToJson] PluginContext::command_sync(self : PluginContext[X], api_name : String, callback : (Payload) -> Reply) -> Unit

    Registers a typed synchronous plugin command.

    PluginContext::install_command_api

    fn[X] PluginContext::install_command_api(self : PluginContext[X], api_name : String, register : (String) -> Unit) -> Unit

    PluginContext::name

    fn[X] PluginContext::name(self : PluginContext[X]) -> String

    Returns the plugin name currently being installed.

    PluginContext::register_api

    fn[X] PluginContext::register_api(self : PluginContext[X], api_name : String) -> String

    PluginHost

    type PluginHost[X]

    Plugin host built on top of CommandBridge.

    On the JavaScript side this exposes:
    • window[global_name]["@@call"](plugin_name, api_name, ...args)
    • window[global_name][plugin_name][api_name](...args)

    Argument packing rule:
    • one argument: sent as-is
    • two or more arguments: sent as an array

    PluginHost::PluginHost

    #alias(new, deprecated="Use `PluginHost()` instead")
    fn[X] PluginHost::PluginHost(webview : WebView[X], global_name? : String) -> PluginHost[X]

    Creates a plugin host backed by a CommandBridge.

    global_name controls the JavaScript namespace used for plugin APIs (defaults to window.lepusApi).

    PluginHost::command_bridge

    fn[X] PluginHost::command_bridge(self : PluginHost[X]) -> CommandBridge[X]

    Returns the underlying command bridge used by the plugin host.

    PluginHost::destroy

    fn[X] PluginHost::destroy(self : PluginHost[X]) -> Unit

    Destroys the plugin host and all installed plugins.

    PluginHost::global_name

    fn[X] PluginHost::global_name(self : PluginHost[X]) -> String

    Returns the JavaScript global object name used for plugin APIs.

    PluginHost::install

    fn PluginHost::install(self : PluginHost[Unit], plugin : Plugin, proxy? : ProcessCommandProxy?) -> Unit

    Installs a plugin into the host.

    This aborts if another plugin with the same name has already been installed on this host.

    PluginHost::install_script

    fn[X] PluginHost::install_script(self : PluginHost[X], script : String) -> Unit

    ProcessCommandProxy

    pub struct ProcessCommandProxy {
    wm : WindowManager
    source_window_id : Int
    subtype : String
    }

    ProcessCommandProxy::call

    fn[Payload : ToJson, Reply :
    FromJson
    ] ProcessCommandProxy::call(self : ProcessCommandProxy, name : String, payload : Payload, target_window_id? : Int, timeout_ms? : Int) -> Reply raise ProcessCommandError

    ProcessCommandProxy::call_plugin

    fn[Payload : ToJson, Reply :
    FromJson
    ] ProcessCommandProxy::call_plugin(self : ProcessCommandProxy, plugin_name : String, api_name : String, payload : Payload, target_window_id? : Int, timeout_ms? : Int) -> Reply raise ProcessCommandError

    ProcessCommandProxy::new

    fn ProcessCommandProxy::new(wm : WindowManager, source_window_id : Int, subtype? : String) -> ProcessCommandProxy

    ProcessCommandProxy::plugin_handler

    fn[Payload : ToJson, Reply :
    FromJson
    ] ProcessCommandProxy::plugin_handler(self : ProcessCommandProxy, plugin_name : String, api_name : String, target_window_id? : Int, timeout_ms? : Int) -> ((Payload) -> Reply raise)

    Builds a typed forwarding closure for a plugin command handled by the parent process.

    ProcessCommandReplyForTest

    type ProcessCommandReplyForTest derive(
    FromJson
    )

    ProcessCommandRequest

    pub struct ProcessCommandRequest {
    name : String
    payload : Json
    } derive(ToJson,
    FromJson
    )

    IPC command request exchanged between the child webview process and the parent async dispatcher.

    ProcessCommandRequest::new

    fn[Payload : ToJson] ProcessCommandRequest::new(name : String, payload : Payload) -> ProcessCommandRequest

    ProcessCommandRequest::parse

    ProcessCommandRequest::to_json

    ProcessCommandResponse

    pub(all) enum ProcessCommandResponse {
    Ok(Json)
    Error(String)
    } derive(ToJson,
    FromJson
    )

    IPC command response returned by the parent async dispatcher.

    ProcessCommandResponse::decode_reply

    ProcessCommandResponse::error

    fn ProcessCommandResponse::error(message : String) -> ProcessCommandResponse

    ProcessCommandResponse::ok

    fn[Payload : ToJson] ProcessCommandResponse::ok(payload : Payload) -> ProcessCommandResponse

    ProcessCommandResponse::stringify

    fn ProcessCommandResponse::stringify(self : ProcessCommandResponse) -> String

    ProcessCommandResponse::to_json

    ProcessCommandRouter

    pub struct ProcessCommandRouter {
    handlers : Map[String, async (Json) -> ProcessCommandResponse]
    }

    Parent-process command router for requests coming from a child webview process.

    ProcessCommandRouter::dispatch

    Dispatches a parsed process command through the registered router handlers.

    ProcessCommandRouter::handle

    fn[Payload :
    FromJson
    , Reply : ToJson] ProcessCommandRouter::handle(self : ProcessCommandRouter, name : String, callback : (Payload) -> Reply) -> Unit

    Registers a typed synchronous command on the parent-process router.

    ProcessCommandRouter::handle_async

    fn[Payload :
    FromJson
    , Reply : ToJson] ProcessCommandRouter::handle_async(self : ProcessCommandRouter, name : String, callback : async (Payload) -> Reply) -> Unit

    Registers a typed async command on the parent-process router.

    ProcessCommandRouter::handle_result

    fn[Payload :
    FromJson
    , Reply : ToJson] ProcessCommandRouter::handle_result(self : ProcessCommandRouter, name : String, callback : (Payload) -> Reply raise) -> Unit

    Registers a typed synchronous command that can return explicit errors.

    ProcessCommandRouter::handle_result_async

    fn[Payload :
    FromJson
    , Reply : ToJson] ProcessCommandRouter::handle_result_async(self : ProcessCommandRouter, name : String, callback : async (Payload) -> Reply) -> Unit

    Registers a typed async command that can return explicit errors.

    ProcessCommandRouter::new

    Creates a parent-process command router.

    ProcessCommandRouter::plugin

    fn ProcessCommandRouter::plugin(self : ProcessCommandRouter, plugin_name : String, register : (ProcessPluginRouter) -> Unit) -> Unit

    Registers a plugin namespace on the parent-process router.

    ProcessCommandRouter::serve

    async fn ProcessCommandRouter::serve(self : ProcessCommandRouter, wm : WindowManager, child_pid : Int, subtype? : String) -> Unit

    Serves process commands from a child webview by using the registered router.

    ProcessCommandRouter::serve_many

    async fn ProcessCommandRouter::serve_many(self : ProcessCommandRouter, wm : WindowManager, child_pids : Array[Int], subtype? : String) -> Unit

    Serves process commands from many child webview processes.

    Continues pumping the main-process IPC queue and dispatching requests until every child has exited. Requests are responded via their window_id.

    ProcessCommandRouter::serve_many_dynamic

    async fn ProcessCommandRouter::serve_many_dynamic(self : ProcessCommandRouter, wm : WindowManager, poll_children : () -> Array[Int], subtype? : String) -> Unit

    Serves process commands from a dynamically-changing set of child webview processes.

    poll_children returns the current live child pids on every iteration, so child processes spawned while serving (e.g. a window opened at runtime) are picked up automatically. The loop ends once poll_children reports nothing running.

    ProcessPluginRouter

    pub struct ProcessPluginRouter {
    router : ProcessCommandRouter
    plugin_name : String
    }

    Plugin-scoped registration context for ProcessCommandRouter.

    ProcessPluginRouter::command

    fn[Payload :
    FromJson
    , Reply : ToJson] ProcessPluginRouter::command(self : ProcessPluginRouter, api_name : String, callback : (Payload) -> Reply) -> Unit

    Registers a typed synchronous plugin command on the parent-process router.

    ProcessPluginRouter::command_async

    fn[Payload :
    FromJson
    , Reply : ToJson] ProcessPluginRouter::command_async(self : ProcessPluginRouter, api_name : String, callback : async (Payload) -> Reply) -> Unit

    Registers a typed async plugin command on the parent-process router.

    ProcessPluginRouter::command_result

    fn[Payload :
    FromJson
    , Reply : ToJson] ProcessPluginRouter::command_result(self : ProcessPluginRouter, api_name : String, callback : (Payload) -> Reply raise) -> Unit

    Registers a typed synchronous plugin command that can return explicit errors.

    ProcessPluginRouter::command_result_async

    fn[Payload :
    FromJson
    , Reply : ToJson] ProcessPluginRouter::command_result_async(self : ProcessPluginRouter, api_name : String, callback : async (Payload) -> Reply) -> Unit

    Registers a typed async plugin command that can return explicit errors.

    ProcessType

    pub(all) enum ProcessType {
    Main
    Child
    Unknown
    } derive(Eq)

    Process type returned by native window manager.

    ProcessType::equal

    fn ProcessType::equal(ProcessType, ProcessType) -> Bool

    ProcessType::not_equal

    fn ProcessType::not_equal(x : ProcessType, y : ProcessType) -> Bool

    SizeHint

    pub(all) enum SizeHint {
    None
    Min
    Max
    Fixed
    }

    Window size hints

    TitleBarStyle

    pub(all) enum TitleBarStyle {
    Default
    Hidden
    } derive(Eq,
    Debug
    )

    TitleBarStyle::equal

    TitleBarStyle::not_equal

    fn TitleBarStyle::not_equal(x : TitleBarStyle, y : TitleBarStyle) -> Bool

    WebView

    type WebView[X]

    An instance of a webview window (managed via IPC).

    Example:

    let webview = @webview.WebView::new_managed(task_group)
    webview.set_title("My WebView")
    webview.set_size(800, 600, @webview.SizeHint::None)
    webview.set_html("<html><body><h1>Hello, World!</h1></body></html>")
    webview.terminate()

    WebView::back

    fn[X] WebView::back(self : WebView[X]) -> Unit

    Navigates one step back in browser history.

    WebView::close

    fn[X] WebView::close(self : WebView[X]) -> Unit

    Close native window.

    WebView::destroy

    fn[X] WebView::destroy(self : WebView[X]) -> Unit

    Destroys the webview and closes the window. Safe to call from a background thread.

    WebView::enable_custom_titlebar_support

    fn[X] WebView::enable_custom_titlebar_support(self : WebView[X]) -> Unit

    Injects CSS helper classes for Electron-like drag regions.

    • .lepus-drag: draggable zone (-webkit-app-region: drag)
    • .lepus-titlebar: titlebar draggable zone (-webkit-app-region: drag)
    • [data-lepus-drag="true"]: draggable zone (-webkit-app-region: drag)
    • .lepus-no-drag: interactive zone (-webkit-app-region: no-drag)

    WebView::enable_transparent_background_support

    fn[X] WebView::enable_transparent_background_support(self : WebView[X]) -> Unit

    Injects CSS/JS that keeps page background transparent.

    WebView::eval

    fn[X] WebView::eval(self : WebView[X], js : String) -> Unit

    Evaluates arbitrary JavaScript code.

    WebView::forward

    fn[X] WebView::forward(self : WebView[X]) -> Unit

    Navigates one step forward in browser history.

    WebView::get_handle

    Returns the raw WebView_t handle.

    WebView::go

    fn[X] WebView::go(self : WebView[X], delta : Int) -> Unit

    Navigates to a specific entry in browser history.

    • delta < 0: backward
    • delta > 0: forward
    • delta = 0: reload current entry

    WebView::maximize

    fn[X] WebView::maximize(self : WebView[X]) -> Unit

    Maximize native window.

    WebView::minimize

    fn[X] WebView::minimize(self : WebView[X]) -> Unit

    Minimize native window.

    WebView::navigate

    fn[X] WebView::navigate(self : WebView[X], url : String) -> Unit

    Navigates the webview to the given URL. URL may be a data URI.

    Example:
    let webview = @webview.WebView::new_managed(task_group)
    webview.navigate("https://www.example.com")
    webview.navigate("data:text/html,<h1>Hello</h1>")
    webview.terminate()

    WebView::new_managed

    fn[X] WebView::new_managed(task_group :
    TaskGroup
    [X], title? : String, url? : String, width? : Int, height? : Int, debug? : Int, devtools? : Bool, frameless? : Bool, resizable? : Bool, closeable? : Bool, always_on_top? : Bool, transparent? : Bool, title_bar_style? : TitleBarStyle, title_bar_overlay? : Bool, traffic_light_position? : (Int, Int), position? : (Int, Int), hidden? : Bool, focused? : Bool) -> WebView[X]

    Creates a managed webview window via native WindowManager (IPC-capable).

    Window lifecycle operations (terminate/set_title/set_size/ navigate/set_html/eval/init) will be routed through wm_* APIs.

    WebView::reload

    fn[X] WebView::reload(self : WebView[X]) -> Unit

    Reloads the current page using standard browser cache policy.

    WebView::reload_force

    fn[X] WebView::reload_force(self : WebView[X]) -> Unit

    Reloads the current page and requests a revalidation from server.

    WebView::set_custom_protocol

    fn[X] WebView::set_custom_protocol(self : WebView[X], scheme : String, root_dir : String) -> Unit

    Register a custom scheme backed by a local root directory for this webview.

    WebView::set_devtools

    fn[X] WebView::set_devtools(self : WebView[X], enabled : Bool) -> Unit

    Enable or disable developer tools integration at runtime.

    WebView::set_fullscreen

    fn[X] WebView::set_fullscreen(self : WebView[X], fullscreen : Bool) -> Unit

    Set native fullscreen state.

    WebView::set_html

    fn[X] WebView::set_html(self : WebView[X], html : String) -> Unit

    Loads HTML content into the webview.

    Example:
    let webview = @webview.WebView::new_managed(task_group)
    webview.set_html("<html><body><h1>Hello, World!</h1></body></html>")
    webview.terminate()

    WebView::set_size

    fn[X] WebView::set_size(self : WebView[X], width : Int, height : Int, hints : SizeHint) -> Unit

    Updates the size of the native window.

    Remarks:
    • SizeHint::Max is not supported with GTK 4.
    • GTK 4 can only set a default size early in the window lifecycle.

    WebView::set_title

    fn[X] WebView::set_title(self : WebView[X], title : String) -> Unit

    Updates the title of the native window.

    WebView::set_traffic_light_position

    fn[X] WebView::set_traffic_light_position(self : WebView[X], x : Int, y : Int) -> Unit

    Set macOS traffic-light buttons position.

    WebView::set_window_customization

    fn[X] WebView::set_window_customization(self : WebView[X], frameless : Bool, resizable : Bool, closeable : Bool, always_on_top : Bool, transparent : Bool, title_bar_style : TitleBarStyle, title_bar_overlay : Bool) -> Unit

    Applies native custom-window style flags at runtime.

    WebView::start_drag

    fn[X] WebView::start_drag(self : WebView[X]) -> Unit

    Start native window drag/move gesture.

    WebView::terminate

    fn[X] WebView::terminate(self : WebView[X]) -> Unit

    Stops the main event loop. Safe to call from a background thread.

    WebView::toggle_fullscreen

    fn[X] WebView::toggle_fullscreen(self : WebView[X]) -> Unit

    Toggle native fullscreen state.

    WebView::toggle_maximize

    fn[X] WebView::toggle_maximize(self : WebView[X]) -> Unit

    Toggle native maximize state.

    WebView::unmaximize

    fn[X] WebView::unmaximize(self : WebView[X]) -> Unit

    Restore native window from maximized state.

    WebView::window_id

    fn[X] WebView::window_id(self : WebView[X]) -> Int

    Returns the managed window id.

    Window

    pub struct Window {
    label : String
    title : String
    width : Int
    height : Int
    size_hint : SizeHint
    debug : Int
    devtools : Bool
    child_arg : String
    frameless : Bool
    resizable : Bool
    closeable : Bool
    always_on_top : Bool
    transparent : Bool
    title_bar_style : TitleBarStyle
    title_bar_overlay : Bool
    traffic_light_position : (Int, Int)
    position : (Int, Int)
    hidden : Bool
    focused : Bool
    enable_window_controls_plugin : Bool
    url : String
    html : String
    pending_custom_protocols : Array[(String, String)]
    runtime_window_id : Int
    plugins : Array[Plugin]
    }

    High-level managed app that owns the parent dispatcher and child webview process lifecycle.

    Window::Window

    #alias(new, deprecated="Use `Window()` instead")
    fn Window::Window(label? : String, title? : String, url? : String, width? : Int, height? : Int, size_hint? : SizeHint, debug? : Int, devtools? : Bool, child_arg? : String, frameless? : Bool, resizable? : Bool, closeable? : Bool, always_on_top? : Bool, transparent? : Bool, title_bar_style? : TitleBarStyle, title_bar_overlay? : Bool, traffic_light_position? : (Int, Int), position? : (Int, Int), hidden? : Bool, focused? : Bool, enable_window_controls_plugin? : Bool) -> Window

    Creates a managed app. The library handles the parent dispatcher and child webview process automatically.

    Window::close

    fn Window::close(self : Window) -> Unit

    Close native window.

    Window::eval

    fn Window::eval(self : Window, js : String) -> Unit

    Window::focus

    fn Window::focus(self : Window) -> Unit

    Bring the native window to front and focus it. On macOS this also activates the owning process as the foreground app (Tauri Window::set_focus parity).

    Window::hide

    fn Window::hide(self : Window) -> Unit

    Hide the native window.

    Window::install

    fn Window::install(self : Window, plugin : Plugin) -> Unit

    Installs a managed plugin into the app.

    Window::label

    fn Window::label(self : Window) -> String

    Returns the stable label used for cross-window addressing. Falls back to the title when no explicit label was provided.

    Window::maximize

    fn Window::maximize(self : Window) -> Unit

    Maximize native window.

    Window::minimize

    fn Window::minimize(self : Window) -> Unit

    Minimize native window.

    Window::navigate

    fn Window::navigate(self : Window, url : String) -> Unit

    Window::run

    async fn Window::run(self : Window) -> Unit

    Runs the managed app end-to-end.

    Window::run_child

    async fn Window::run_child(self : Window, window_id_base : Int) -> Unit

    Runs this window in the current (already-spawned, child) process.

    Connects to the main-process IPC server, sets the globally-unique window-id base, then creates and runs the webview. This is the child-side half of Window::run_many.

    Window::run_many

    async fn Window::run_many(labels : Array[String], router : ProcessCommandRouter) -> Unit

    Runs a multi-window app: spawns one child process per window (each with a globally-unique window-id base and stable label), then serves commands from all children until every window closes.

    labels order must match the window order the child sides use to resolve their own configuration via detect_child_window().

    Window::set_custom_protocol

    fn Window::set_custom_protocol(self : Window, scheme : String, root_dir : String) -> Unit

    Register a custom scheme for the child webview before it navigates.

    Window::set_fullscreen

    fn Window::set_fullscreen(self : Window, fullscreen : Bool) -> Unit

    Set native fullscreen state.

    Window::set_html

    fn Window::set_html(self : Window, html : String) -> Unit

    Sets inline HTML content for the child webview.

    Window::set_position

    fn Window::set_position(self : Window, x : Int, y : Int) -> Unit

    Move the native window to an absolute screen position.

    Window::set_size

    fn Window::set_size(self : Window, width : Int, height : Int, hint? : SizeHint) -> Unit

    Resize the native window.

    Window::set_traffic_light_position

    fn Window::set_traffic_light_position(self : Window, x : Int, y : Int) -> Unit

    Set macOS traffic-light buttons position.

    Window::set_window_customization

    fn Window::set_window_customization(self : Window, frameless : Bool, resizable : Bool, closeable : Bool, always_on_top : Bool, transparent : Bool, title_bar_style : TitleBarStyle, title_bar_overlay : Bool) -> Unit

    Applies native custom-window style flags.

    Window::show

    fn Window::show(self : Window) -> Unit

    Show the native window.

    Window::start_drag

    fn Window::start_drag(self : Window) -> Unit

    Start native window drag/move gesture.

    Window::toggle_fullscreen

    fn Window::toggle_fullscreen(self : Window) -> Unit

    Toggle native fullscreen state.

    Window::toggle_maximize

    fn Window::toggle_maximize(self : Window) -> Unit

    Toggle native maximize state.

    Window::unmaximize

    fn Window::unmaximize(self : Window) -> Unit

    Restore native window from maximized state.

    WindowManager

    pub struct WindowManager {
    process_type : ProcessType
    window_ids : Array[Int]
    }

    Thin high-level wrapper over native window manager (stub.c wm_* APIs).

    WindowManager::broadcast

    fn WindowManager::broadcast(self : WindowManager, source_window_id : Int, subtype : String, data : String) -> Int

    Broadcast an event message.

    WindowManager::close_window

    fn WindowManager::close_window(_self : WindowManager, window_id : Int) -> Int

    Close native window.

    WindowManager::connect_child_process

    fn WindowManager::connect_child_process() -> Int

    Connect current process to the main-process IPC server and switch into child mode.

    WindowManager::create_child_window

    fn WindowManager::create_child_window(_self : WindowManager, title : String, url : String, width? : Int, height? : Int, parent_id? : Int) -> Int

    Spawn a child process window. Returns child process pid.

    WindowManager::create_window

    fn WindowManager::create_window(self : WindowManager, title : String, url : String, width? : Int, height? : Int) -> Int

    Create a native window in current process.

    WindowManager::destroy

    fn WindowManager::destroy(self : WindowManager) -> Unit

    Cleanup native WM runtime.

    WindowManager::destroy_window

    fn WindowManager::destroy_window(_self : WindowManager, window_id : Int) -> Int

    Destroy a window.

    WindowManager::focus_window

    fn WindowManager::focus_window(_self : WindowManager, window_id : Int) -> Int

    Bring a window to front and focus it. On macOS this also activates the process as the foreground application (Tauri Window::set_focus parity).

    WindowManager::fork_process

    fn WindowManager::fork_process(_self : WindowManager) -> Int

    Fork the current process. The parent receives the child pid, the child receives 0.

    WindowManager::init

    fn WindowManager::init(is_main? : Bool) -> WindowManager

    Initialize WM runtime for current process.

    • main process: pass true
    • child process: pass false

    WindowManager::install_default_app_menu

    fn WindowManager::install_default_app_menu(_self : WindowManager) -> Int

    Install the standard application main menu (macOS) so keyboard shortcuts work: Cmd+Q (quit app), Cmd+W (close window), Cmd+M (minimize), and the Edit menu (Cmd+Z/X/C/V/A). No-op on other platforms.

    WindowManager::is_child_process

    fn WindowManager::is_child_process(self : WindowManager) -> Bool

    Return true when running in child process.

    WindowManager::is_main_process

    fn WindowManager::is_main_process(self : WindowManager) -> Bool

    Return true when running in main process.

    WindowManager::maximize_window

    fn WindowManager::maximize_window(_self : WindowManager, window_id : Int) -> Int

    Maximize native window.

    WindowManager::minimize_window

    fn WindowManager::minimize_window(_self : WindowManager, window_id : Int) -> Int

    Minimize native window.

    WindowManager::request

    fn WindowManager::request(_self : WindowManager, source_window_id : Int, target_window_id : Int, subtype : String, data : String, timeout_ms? : Int) -> String

    Send an IPC request and wait for the response body.

    WindowManager::respond

    fn WindowManager::respond(_self : WindowManager, source_window_id : Int, target_window_id : Int, request_id : Int, data : String) -> Int

    Send an IPC response for a previously received request.

    WindowManager::run_window

    fn WindowManager::run_window(_self : WindowManager, window_id : Int) -> Int

    Run a window event loop.

    WindowManager::send_message

    fn WindowManager::send_message(_self : WindowManager, source_window_id : Int, target_window_id : Int, message_type : IpcMessageType, subtype : String, data : String) -> Int

    Send an IPC message.

    WindowManager::serve_process_commands

    async fn WindowManager::serve_process_commands(self : WindowManager, child_pid : Int, handler : async (ProcessCommandRequest) -> ProcessCommandResponse, subtype? : String) -> Unit

    WindowManager::set_activation_policy

    fn WindowManager::set_activation_policy(_self : WindowManager, policy : Int) -> Int

    Set the NSApplication activation policy (macOS). No-op on other platforms.

    WindowManager::set_devtools

    fn WindowManager::set_devtools(_self : WindowManager, window_id : Int, enabled : Bool) -> Int

    Enable or disable developer tools integration.

    WindowManager::set_fullscreen_window

    fn WindowManager::set_fullscreen_window(_self : WindowManager, window_id : Int, fullscreen : Bool) -> Int

    Set native fullscreen state.

    WindowManager::set_position

    fn WindowManager::set_position(_self : WindowManager, window_id : Int, x : Int, y : Int) -> Int

    Move native window to an absolute screen position.

    WindowManager::set_size

    fn WindowManager::set_size(_self : WindowManager, window_id : Int, width : Int, height : Int, hints : SizeHint) -> Int

    Resize native window.

    WindowManager::set_traffic_light_position

    fn WindowManager::set_traffic_light_position(_self : WindowManager, window_id : Int, x : Int, y : Int) -> Int

    Set macOS traffic-light buttons position.

    WindowManager::set_visibility

    fn WindowManager::set_visibility(_self : WindowManager, window_id : Int, visible : Bool) -> Int

    Show or hide a native window.

    WindowManager::set_window_customization

    fn WindowManager::set_window_customization(_self : WindowManager, window_id : Int, frameless : Bool, resizable : Bool, closeable : Bool, always_on_top : Bool, transparent : Bool, title_bar_style : TitleBarStyle, title_bar_overlay : Bool) -> Int

    Apply native custom-window style flags.

    WindowManager::set_window_id_base

    fn WindowManager::set_window_id_base(_self : WindowManager, base : Int) -> Int

    Set the current (child) process window-id starting base.

    The main process assigns each child a globally unique base so that windows created in different children never collide on window_id (used for IPC routing). Call before creating any window in the child process.

    WindowManager::spawn_process

    fn WindowManager::spawn_process(_self : WindowManager, program : String, arg1 : String) -> Int

    Spawn a fresh child process by exec-ing the given program path with one extra argument.

    WindowManager::start_drag_window

    fn WindowManager::start_drag_window(_self : WindowManager, window_id : Int) -> Int

    Start native window drag/move gesture.

    WindowManager::toggle_fullscreen_window

    fn WindowManager::toggle_fullscreen_window(_self : WindowManager, window_id : Int) -> Int

    Toggle native fullscreen state.

    WindowManager::toggle_maximize_window

    fn WindowManager::toggle_maximize_window(_self : WindowManager, window_id : Int) -> Int

    Toggle native maximize state.

    WindowManager::try_pop_message

    fn WindowManager::try_pop_message(_self : WindowManager, queue_id : Int) -> IpcMessage?

    Try to pop one queued IPC message for the given queue id.

    WindowManager::unmaximize_window

    fn WindowManager::unmaximize_window(_self : WindowManager, window_id : Int) -> Int

    Restore native window from maximized state.

    WindowManager::wait_child_noblock

    fn WindowManager::wait_child_noblock(_self : WindowManager, pid : Int) -> Int

    Non-blocking child process status check.

    WindowState

    pub(all) enum WindowState {
    Unknown
    Created
    Running
    Hidden
    Closing
    Closed
    } derive(Eq)

    Window state mapped from native window manager.

    WindowState::equal

    fn WindowState::equal(WindowState, WindowState) -> Bool

    WindowState::int

    fn WindowState::int(self : WindowState) -> Int

    WindowState::not_equal

    fn WindowState::not_equal(x : WindowState, y : WindowState) -> Bool

    build_router

    fn build_router(plugins : Array[Plugin]) -> ProcessCommandRouter

    Builds a main-process command router from an App-level plugin list.

    child_arg_for

    fn child_arg_for(base : Int, label : String) -> String

    Encodes a unique child-process marker used to carry a globally-unique window-id base and a stable label across a re-exec`ed child process.

    decode_process_command_response

    fn[Reply :
    FromJson
    ] decode_process_command_response(raw : String) -> Reply raise ProcessCommandError

    detect_child_window

    fn detect_child_window() -> (Int, String)?

    Detects whether the current process was spawned as a Lepus multi-window child.

    Returns (window_id_base, label) when argv carries a --lepus-child:<base>:<label> marker, otherwise None.

    window_controls_plugin

    fn window_controls_plugin(window_id : Int) -> Plugin

    Builds the window_controls plugin bound to window_id, exposing close/minimize/maximize/fullscreen/drag commands to JavaScript.

    wm_set_size

    fn wm_set_size(window_id : Int, width : Int, height : Int, hints : SizeHint) -> Int

    Set managed window size.

    wm_set_window_customization

    fn wm_set_window_customization(window_id : Int, frameless : Int, resizable : Int, closeable : Int, always_on_top : Int, transparent : Int, title_bar_style : TitleBarStyle, title_bar_overlay : Int) -> Int

    Apply native custom-window style flags.