This version of the module is deprecated: This package is deprecated. moonbit-community/proton should be preferred.

    #proton/runtime

    justjavac/proton/runtime owns app and window lifecycle on top of justjavac/proton/core.

    Use this package when you need lower-level App or AppWindow control. For ordinary applications, prefer the root justjavac/proton facade.

    #Responsibilities

    • create and run app windows
    • apply runtime manifests
    • install explicitly provided extension specs
    • keep AppEntry::Asset as a tooling distinction while loading it as a local file

    • justjavac/proton/core: bridge, ops runtime, and extension host
    • justjavac/proton/bootstrap: moon.proton loading
    • justjavac/proton: ergonomic app composition

    App

    pub struct App {
    main_window : AppWindow
    config : AppConfig
    windows : Array[AppWindow]
    installed_extensions : Array[InstalledExtension]
    installed_extension_ids : Map[String, Bool]
    installed_extension_namespaces : Map[String, Bool]
    ipc_backends : Array[AppIpcBackend]
    }

    High-level application runtime built on top of one or more @webview.Webview instances. The first window is the main window that enters the event loop.

    App::config

    fn App::config(self : App) -> AppConfig

    Returns the app configuration used at construction time. The returned value reflects the original app-level settings rather than any later runtime mutation.

    App::create_window

    fn App::create_window(self : App, config : AppWindowConfig) -> AppWindow

    Creates and registers an additional window before the app runtime loop starts. The returned window participates in future extension installs and app-wide event broadcasts.

    App::destroy

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

    Destroys every registered window and releases the app runtime. After this returns, the app should be treated as no longer owning any live native window resources.

    App::emit_extension

    fn[Payload : ToJson] App::emit_extension(self : App, extension_namespace : String, event_name : String, payload : Payload) -> Unit

    Emits one extension event across every current app window. Every currently registered window receives the same extension namespace, event name, and serialized payload.

    App::install_extension

    fn App::install_extension(self : App, extension :
    Extension
    ) -> Unit

    Installs one extension across every current app window. The extension is also tracked so later windows created through create_window receive the same install automatically.

    App::install_extension_spec

    fn App::install_extension_spec(self : App, spec :
    ExtensionSpec
    , context :
    ExtensionBuildContext
    ) -> Result[Unit, String]

    Builds and installs one extension spec across every current app window. A fresh runtime extension is built per window so stateful extensions do not accidentally share per-window handles or cleanup state.

    App::install_ipc_bridge

    fn App::install_ipc_bridge(self : App, bridge_script : String, op_names : Array[String], extensions? : Array[
    IpcExtensionDescriptor
    ]) -> Unit

    Installs a generic IPC bridge across every current and future app window.

    The runtime does not own sockets, files, or child-process state here. It only installs the bridge script generated by the selected IPC implementation.

    App::main_window

    fn App::main_window(self : App) -> AppWindow

    Returns the main app window that owns the runtime loop. This is a cheap accessor for code that needs stable access to the primary window wrapper.

    App::new

    fn App::new(config : AppConfig) -> App

    Creates an application and applies its initial window configuration. The main window is created immediately and any additional configured windows are registered before the runtime loop starts.

    App::run

    fn App::run(self : App) -> Unit

    Runs the main window loop after loading every configured window entry. Each registered window has its configured entry loaded before control is handed off to the main window's event loop. Once the event loop returns, every registered window is destroyed and runtime resources are released.

    App::webview

    Returns the underlying low-level webview of the main window. Use this when low-level bindings or native integrations must target the primary window directly.

    App::window

    fn App::window(self : App, id : String) -> AppWindow?

    Returns a window by its app-level identifier. None is returned when no registered window currently matches the provided id.

    App::windows

    fn App::windows(self : App) -> Array[AppWindow]

    Returns the currently registered windows, including the main window. The array order always starts with the primary window followed by additional windows in registration order.

    AppConfig

    pub struct AppConfig {
    window : WindowConfig
    entry : AppEntry
    windows : Array[AppWindowConfig]
    debug : Int
    }

    Application-level settings for the runtime core.

    AppConfig::new

    fn AppConfig::new(window : WindowConfig, entry : AppEntry, debug? : Int, windows? : Array[AppWindowConfig]) -> AppConfig

    Builds a runtime-core application configuration. Additional windows are registered up front, while their entries are only loaded once App::run starts the runtime loop.

    AppEntry

    pub(all) enum AppEntry {
    Html(String)
    Url(String)
    File(String)
    Asset(String)
    }

    Entry content loaded by an App.

    AppIpcBackend

    type AppIpcBackend

    App-level IPC bridge shared by all app windows.

    AppWindow

    pub struct AppWindow {
    id : String
    webview :
    Webview

    config : WindowConfig
    entry : AppEntry
    }

    Window runtime owned by an App.

    AppWindow::config

    fn AppWindow::config(self : AppWindow) -> WindowConfig

    Returns the window configuration. The returned value matches the declarative settings used when this runtime window was created.

    AppWindow::entry

    fn AppWindow::entry(self : AppWindow) -> AppEntry

    Returns the entry associated with this window. This is the app entry that will be or has been loaded into the window.

    AppWindow::id

    fn AppWindow::id(self : AppWindow) -> String

    Returns the application-level window identifier. This id is the stable lookup key used by App::window.

    AppWindow::webview

    Returns the underlying low-level webview. Use this when a feature needs to drop down to raw webview APIs for a specific registered window.

    AppWindowConfig

    pub struct AppWindowConfig {
    id : String
    window : WindowConfig
    entry : AppEntry
    }

    Additional window registered on an App before the runtime loop starts.

    AppWindowConfig::new

    fn AppWindowConfig::new(id : String, window : WindowConfig, entry : AppEntry) -> AppWindowConfig

    Describes a secondary app window. The id must be unique within the owning app and is used for later window lookup and replacement operations.

    InstalledExtension

    type InstalledExtension

    Describes an extension that can be built separately for each app window.

    WindowConfig

    pub struct WindowConfig {
    title : String
    width : Int
    height : Int
    size_hint :
    SizeHint

    } derive(
    Debug
    )

    Window settings used when creating an App.

    WindowConfig::new

    fn WindowConfig::new(title : String, width : Int, height : Int, size_hint? :
    SizeHint
    ) -> WindowConfig

    Builds a window configuration. Use size_hint to communicate fixed, minimum, or maximum sizing behavior to the underlying native window backend.