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

    proton

    MoonBit bindings for the Proton native desktop runtime.

    proton
    gui
    web
    desktop-app
    Download zip
    Author
    Version
    0.1.13
    License
    Apache-2.0
    Last updated
    3 months ago
    Downloads
    328

    justjavac/proton does not have a README file

    AppEntry

    Declarative entry content loaded into a Proton application window.

    BridgeDiagnostic

    BridgeLifecycleState

    CommandContext

    using @justjavac/proton/core { type AppCommandRequestContext as CommandContext }

    Request-scoped context supplied to typed application command handlers.

    Lifecycle-owned task and event capabilities are added by the application runner; the registrar keeps handlers independent from transport details.

    CommandRegistrar

    Startup-only capability for binding typed command descriptors to handlers.

    A top-level native menu and its items.

    An application-level native menu bar.

    A command, separator, or platform role in a native menu.

    NativeError

    Failures at the MoonBit/native runtime boundary.

    ProcessResult

    RuntimeConfig

    RuntimeEvent

    RuntimeInfo

    RuntimeLaunchInput

    A macOS application activation delivered by Launch Services or the Dock.

    TitlebarStyle

    WindowConfig

    WindowSizeHint

    Controls how the configured width and height constrain native resizing.

    AppCleanupError

    A failure from one stage of best-effort application teardown.

    AppCleanupError::message

    fn AppCleanupError::message(self : AppCleanupError) -> String

    AppConfigurationError

    pub(all) suberror AppConfigurationError {
    InvalidSetting(name~ : String, message~ : String)
    Bootstrap(
    BootstrapError
    )
    ExtensionDependencyCycle(extension_id~ : String)
    ExtensionUnavailable(extension_id~ : String, requested_by~ : String?, state~ : String)
    ExtensionAdaptationFailed(extension_id~ : String, error~ :
    ExtensionAdapterError
    )
    InvalidJavaScriptNamespace(js_namespace~ : String)
    InvalidJavaScriptApi(js_namespace~ : String, api_name~ : String)
    InvalidDevelopmentUrl(url~ : String, reason~ : String)
    } derive(
    Debug
    )

    Failures while resolving and validating an application's configuration.

    AppConfigurationError::message

    fn AppConfigurationError::message(self : AppConfigurationError) -> String

    AppEntryError

    pub(all) suberror AppEntryError {
    ReadFailed(path~ : String, detail~ : String)
    NativeLoad(action~ : String, error~ :
    NativeError
    )
    ClosedDuringStartup
    } derive(
    Debug
    )

    Failures while loading the application's initial document.

    AppEntryError::message

    fn AppEntryError::message(self : AppEntryError) -> String

    AppPathError

    pub(all) suberror AppPathError {
    InvalidIdentifier(identifier~ : String)
    MissingHomeDirectory(platform~ : String)
    PlatformProbe(
    NativeError
    )
    } derive(Eq,
    Debug
    )

    Failures while resolving framework-owned application paths.

    AppPathError::message

    fn AppPathError::message(self : AppPathError) -> String

    AppRunError

    pub(all) suberror AppRunError {
    RunnerError(String)
    ConfigurationError(AppConfigurationError)
    NativeRuntimeError(action~ : String, error~ :
    NativeError
    )
    RuntimeWakeupError(RuntimeWakeupError)
    CommandExtensionLifecycleError(CommandExtensionLifecycleError)
    LifecycleHookError(LifecycleHookError)
    EntryLoadError(AppEntryError)
    BridgeStartupError(
    BridgeDiagnostic
    )
    BridgeRuntimeError(
    BridgeDiagnostic
    )
    CleanupFailed(primary~ : String?, failures~ : Array[AppCleanupError])
    UnexpectedTaskFailure(detail~ : String)
    } derive(
    Debug
    )

    Failures produced while configuring, starting, or running an application.

    AppRunError::message

    fn AppRunError::message(self : AppRunError) -> String

    CommandExtensionLifecycleError

    pub(all) suberror CommandExtensionLifecycleError {
    ApplicationRegistrationFailed(detail~ : String)
    RegistrationFailed(extension_id~ : String, detail~ : String)
    DestroyFailed(extension_id~ : String, detail~ : String)
    } derive(
    Debug
    )

    Failures while starting or stopping command extensions.

    CommandExtensionLifecycleError::message

    LifecycleHookError

    pub(all) suberror LifecycleHookError {
    ApplicationStart(index~ : Int, detail~ : String)
    ApplicationShutdown(index~ : Int, detail~ : String)
    WindowReady(index~ : Int, detail~ : String)
    WindowClose(index~ : Int, detail~ : String)
    } derive(
    Debug
    )

    Failures produced by application or window lifecycle hooks.

    LifecycleHookError::message

    fn LifecycleHookError::message(self : LifecycleHookError) -> String

    NotificationDeliveryError

    pub(all) suberror NotificationDeliveryError {
    Native(
    NativeError
    )
    WaitInterrupted(detail~ : String)
    } derive(Eq,
    Debug
    )

    Failures while starting or waiting for native notification delivery.

    NotificationDeliveryError::message

    RuntimeWakeupError

    pub(all) suberror RuntimeWakeupError {
    UnsupportedFeature(feature~ : String)
    PipeCreateFailed(detail~ : String)
    SourceOpenFailed(source~ : String, detail~ : String)
    SourceClosed
    MissingNotification
    } derive(
    Debug
    )

    Failures in the MoonBit-side runtime wakeup source.

    RuntimeWakeupError::message

    fn RuntimeWakeupError::message(self : RuntimeWakeupError) -> String

    App

    type App

    High-level application facade for ordinary Proton apps.

    App::add_window

    fn App::add_window(self : App, id : String, title : String, entry :
    AppEntry
    , width? : Int, height? : Int, size_hint? :
    WindowSizeHint
    , titlebar_style? :
    TitlebarStyle
    ) -> App

    Adds a secondary window owned by the standard application lifecycle.

    App::app_lifecycle

    fn[State] App::app_lifecycle(self : App, on_start~ : async (ApplicationContext) -> State, on_shutdown~ : async (State) -> Unit) -> App

    Adds a paired application lifecycle hook.

    The startup state is passed to shutdown. Completed hooks shut down in reverse order, including when a later startup hook fails.

    App::bridge_startup_timeout_ms

    fn App::bridge_startup_timeout_ms(self : App, timeout_ms : Int) -> App

    Sets the maximum time allowed for the native bridge to become ready.

    App::commands

    fn App::commands(self : App, register : (
    CommandRegistrar
    ) -> Unit raise) -> App

    Adds one package registrar for typed application commands.

    Registration runs before any window is created and is sealed before the renderer bridge starts accepting requests.

    App::debug

    fn App::debug(self : App, enabled? : Bool) -> App

    Enables or disables runtime debug mode.

    App::debug_level

    fn App::debug_level(self : App, debug : Int) -> App

    Sets the runtime debug level.

    App::entry_asset

    fn App::entry_asset(self : App, path : String) -> App

    Overrides the primary app entry with an asset path.

    App::entry_file

    fn App::entry_file(self : App, path : String) -> App

    Overrides the primary app entry with a file path.

    App::entry_html

    fn App::entry_html(self : App, html : String) -> App

    Overrides the primary app entry with inline HTML.

    App::entry_url

    fn App::entry_url(self : App, url : String) -> App

    Overrides the primary app entry with a URL.

    App::extension

    fn App::extension(self : App, extension :
    Extension
    , options? : Json) -> App

    Registers one extension setting with the app facade.

    The native DLL route exposes command extensions through window.__MoonBit__.core.invokeOp(...) and generated high-level proxies. The renderer installs the bridge before the page's first script executes.

    App::extensions

    fn App::extensions(self : App, extensions :
    Extensions
    ) -> App

    Registers a set of extension settings with the app facade.

    App::headless

    fn App::headless(self : App, enabled? : Bool) -> App

    Enables or disables off-screen headless rendering for the application.

    Headless mode does not create a native top-level window. Set PROTON_HEADLESS=1 to force this mode for automated test runs.

    App::menu

    Sets the app-level native menu bar.

    App::on_launch_input

    fn App::on_launch_input(self : App, handler : async (
    RuntimeLaunchInput
    ) -> Unit noraise) -> App

    Registers an application-level handler for URL, file, and reopen inputs.

    App::run

    async fn App::run(self : App) -> Unit raise AppRunError

    Runs the configured app through the native Proton runtime.

    App::run_or_abort

    async fn App::run_or_abort(self : App) -> Unit

    Runs the configured app and aborts with the error message on failure.

    App::size

    fn App::size(self : App, width~ : Int, height~ : Int) -> App

    Sets the primary window size.

    App::title

    fn App::title(self : App, title : String) -> App

    Sets the primary window title.

    App::titlebar_style

    fn App::titlebar_style(self : App, style :
    TitlebarStyle
    ) -> App

    Sets whether web content remains below or extends beneath the native titlebar. Overlay rendering is currently implemented on macOS and Windows.

    App::window_lifecycle

    fn[State] App::window_lifecycle(self : App, on_ready~ : async (WindowContext) -> State, on_close~ : async (State) -> Unit) -> App

    Adds a paired primary-window lifecycle hook.

    The ready state is passed to close. Completed hooks close in reverse order, including when a later ready hook fails.

    ApplicationContext

    pub struct ApplicationContext {
    tasks :
    TaskGroup
    [Unit]
    }

    Application-lifetime capabilities supplied to startup hooks.

    ApplicationContext::task_group

    Returns the structured task group owned by this application.

    WindowContext

    pub struct WindowContext {
    id : String
    window :
    WindowRef

    tasks :
    TaskGroup
    [Unit]
    events : WindowEventEmitter
    }

    Window-lifetime capabilities supplied to window startup hooks.

    WindowContext::events

    Returns an event emitter bound to this window's active page.

    WindowContext::id

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

    Returns the declarative id of this window. The primary window uses "main".

    WindowContext::task_group

    Returns the structured task group owned by this window.

    WindowContext::window

    Returns a non-owning reference to this window.

    WindowEventEmitter

    pub struct WindowEventEmitter {
    emit_event : async (
    ContractRoute
    , String, Json) -> Unit noraise
    }

    A typed event destination bound to one explicit window.

    WindowEventEmitter::emit

    async fn[Payload : ToJson] WindowEventEmitter::emit(self : WindowEventEmitter, event :
    Event
    [Payload], payload : Payload) -> Unit

    Emits a typed event to this emitter's window.

    abi_version

    fn abi_version() -> Int

    app

    fn app() -> App

    Creates an application from PROTON_CONFIG_PATH, moon.proton in the current working directory, or code-only defaults.

    app_data_dir

    fn app_data_dir(identifier : String) -> String raise AppPathError

    Resolves the stable per-application directory for native persistent data.

    The identifier should match the packaged bundle/application identifier. This function resolves the path but does not create the directory.

    asset

    fn asset(title : String, path : String, width? : Int, height? : Int, debug? : Bool, resizable? : Bool) -> App

    Creates an inline asset application.

    config

    fn config(path : String) -> App

    Creates an application backed by a moon.proton config file.

    The default moon.proton path honors PROTON_CONFIG_PATH and packaged config discovery. Other paths are used exactly as provided.

    file

    fn file(title : String, path : String, width? : Int, height? : Int, debug? : Bool, resizable? : Bool) -> App

    Creates an inline file application.

    html

    fn html(title : String, html : String, width? : Int, height? : Int, debug? : Bool, resizable? : Bool) -> App

    Creates an inline HTML application.

    last_error_message

    fn last_error_message() -> String

    run

    fn run(main : async () -> Unit) -> Unit

    Runs a Proton application with the platform UI loop on the process main thread and MoonBit async work on Proton's application thread.

    Call this once from a synchronous main.

    runtime_info_json

    fn runtime_info_json() -> String raise
    NativeError

    url

    fn url(title : String, url : String, width? : Int, height? : Int, debug? : Bool, resizable? : Bool) -> App

    Creates an inline URL application.