Sign in

    #Proton Native

    moonbit-community/proton/native is the direct MoonBit FFI binding for the standalone Proton native dynamic library.

    The public API uses Proton-owned Runtime and Window values. Raw native handles are intentionally not part of the public surface.

    ///|
    test "native ABI is loaded" {
    inspect(abi_version(), content="1")
    let info = runtime_info()
    inspect(info.abi_version, content="1")
    assert_true(info.build_mode == "abi-only" || info.build_mode == "runtime")
    assert_true(info.runtime_available == (info.build_mode == "runtime"))
    assert_true(info.features.contains("event_polling"))
    assert_true(info.features.contains("bridge_polling"))
    }

    Runtime configuration is typed on the MoonBit side and serialized to the stable proton_* C ABI JSON format.

    ///|
    test "typed runtime config JSON" {
    let config = RuntimeConfig::new(
    runtime_root="app-runtime",
    helper_path="cef_process.exe",
    cache_dir="/absolute/path/to/cache",
    )
    let json = config.to_json_string()
    assert_true(json.contains("\"abi_version\":1"))
    assert_true(json.contains("\"runtime_root\":\"app-runtime\""))
    assert_true(json.contains("\"helper_path\":\"cef_process.exe\""))
    assert_true(json.contains("\"cache_dir\":\"/absolute/path/to/cache\""))
    assert_true(json.contains("\"persist_session_cookies\":true"))
    }

    Omitting cache_dir creates an isolated temporary browser profile that is removed after native runtime shutdown. A non-empty cache_dir must be an absolute path owned by one running process; it enables persistent browser state. For persistent profiles, persist_session_cookies defaults to true, so session cookies without an expiry are stored alongside permanent cookies.

    For packaged Proton runtimes, prefer RuntimeConfig::bundled(). It asks proton.dll to use the install layout beside the loaded DLL, including bin/cef_process.exe, instead of requiring application code to hard-code paths.

    ///|
    test "bundled runtime config JSON" {
    let json = RuntimeConfig::bundled(cache_dir="/absolute/path/to/cache").to_json_string()
    assert_true(json.contains("\"use_bundled\":true"))
    assert_true(json.contains("\"cache_dir\":\"/absolute/path/to/cache\""))
    assert_true(json.contains("\"persist_session_cookies\":true"))
    }

    The default no-engine build supports fake runtime/window handles for ABI and binding validation. Real runtime configs that include runtime_root or helper_path, or use RuntimeConfig::bundled(), are treated as engine configs and must pass RuntimeConfig::probe.

    ///|
    test "runtime and window lifecycle" {
    let runtime = Runtime::new()
    let window = Window::new(
    runtime,
    config=WindowConfig::new(
    title="Proton",
    width=320,
    height=240,
    initial_url="about:blank",
    ),
    )
    match runtime.poll_event() {
    Some(event) => inspect(event.event_type(), content="window_created")
    _ => fail("expected window_created")
    }
    window.load_html("<p>Hello Proton</p>", "proton://app/")
    window.destroy()
    runtime.destroy()
    }

    Runtime::wait is a low-level primitive for hosts that own the external message pump. It reports which kinds of work may be ready, and the caller still drains events or bridge requests through the poll APIs. The root facade uses the process-wide host loop instead, which installs directly into the MoonBit async scheduler before application code starts.

    ///|
    test "runtime wait event readiness" {
    let runtime = Runtime::new()
    let empty = runtime.wait(interest_mask=runtime_wait_event, timeout_ms=0)

    inspect(empty.is_timeout(), content="true")
    let window = Window::new(runtime)
    let ready = runtime.wait(interest_mask=runtime_wait_event, timeout_ms=0)

    inspect(ready.has_event(), content="true")
    match runtime.poll_event() {
    Some(event) => inspect(event.event_type(), content="window_created")
    _ => fail("expected window_created")
    }
    window.destroy()
    runtime.destroy()
    }

    Windows can host additional web contents views, following the Electron WebContentsView model: each view is an independent browser positioned with top-left coordinates inside the window's content area and stacked above the window's main browser. Engine support is reported through the web_contents_view runtime feature.

    ///|
    test "web contents view lifecycle" {
    let runtime = Runtime::new()
    let window = Window::new(runtime)
    let view = View::new(
    window,
    ViewConfig::new(
    width=320,
    height=200,
    x=10,
    y=20,
    initial_url="about:blank",
    ),
    )
    view.set_bounds(x=20, y=30, width=300, height=180)
    view.set_z_order(1)
    view.load_url("about:blank")
    let state = view.state()
    inspect(state.width, content="300")
    inspect(state.visible, content="true")
    view.destroy()
    window.destroy()
    runtime.destroy()
    }

    NativeError

    pub(all) suberror NativeError {
    Status(status~ : Int, message~ : String)
    InvalidArgument(message~ : String)
    InvalidPayload(context~ : String, message~ : String)
    } derive(Eq,
    Debug
    )

    Failures at the MoonBit/native runtime boundary.

    NativeError::equal

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

    NativeError::is_invalid_state

    fn NativeError::is_invalid_state(self : NativeError) -> Bool

    Reports whether the native object is closing or has already been destroyed.

    NativeError::is_stale_bridge_response

    fn NativeError::is_stale_bridge_response(self : NativeError) -> Bool

    Reports whether a bridge response lost its renderer request while an asynchronous handler was still completing.

    NativeError::is_stale_browser_request

    fn NativeError::is_stale_browser_request(self : NativeError) -> Bool

    NativeError::is_stale_window_request

    fn NativeError::is_stale_window_request(self : NativeError) -> Bool

    NativeError::is_update_busy

    fn NativeError::is_update_busy(self : NativeError) -> Bool

    NativeError::is_update_revision_mismatch

    fn NativeError::is_update_revision_mismatch(self : NativeError) -> Bool

    NativeError::is_update_rollback

    fn NativeError::is_update_rollback(self : NativeError) -> Bool

    NativeError::message

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

    NativeError::not_equal

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

    NativeError::output

    fn NativeError::output(self : NativeError, logger : &Logger) -> Unit

    NativeError::status

    fn NativeError::status(self : NativeError) -> Int

    NativeError::to_string

    fn NativeError::to_string(self : NativeError) -> String

    AppActivation

    pub(all) struct AppActivation {
    abi_version : Int
    urls : Array[String]
    files : Array[String]
    reopen : Bool
    } derive(Eq, ToJson,
    Debug
    )

    Inputs forwarded by a second operating-system application instance.

    AppActivation::equal

    AppActivation::new

    fn AppActivation::new(urls? : Array[String], files? : Array[String], reopen? : Bool) -> AppActivation

    AppActivation::not_equal

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

    AppActivation::to_json

    AppInstance

    type AppInstance

    AppInstance::acquire

    fn AppInstance::acquire(identifier : String, activation : AppActivation) -> AppInstanceAcquire raise NativeError

    Claims one operating-system application identity. A secondary process forwards its activation before returning Forwarded.

    AppInstance::attach_runtime

    fn AppInstance::attach_runtime(self : AppInstance, runtime : Runtime) -> Unit raise NativeError

    Attaches the primary instance listener to a runtime's existing wake source.

    AppInstance::destroy

    fn AppInstance::destroy(self : AppInstance) -> Unit raise NativeError

    AppInstanceAcquire

    pub enum AppInstanceAcquire {
    Primary(AppInstance)
    Forwarded
    }

    Result of claiming an operating-system application identity.

    BridgeConfig

    pub(all) struct BridgeConfig {
    raw_json : String?
    max_payload_bytes : Int
    grants : Array[BridgeGrantConfig]
    } derive(Eq,
    Debug
    )

    BridgeConfig::equal

    BridgeConfig::new

    fn BridgeConfig::new(grants~ : Array[BridgeGrantConfig], max_payload_bytes? : Int) -> BridgeConfig

    BridgeConfig::not_equal

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

    BridgeConfig::to_json_string

    fn BridgeConfig::to_json_string(self : BridgeConfig) -> String

    BridgeConfig::unsafe_from_json

    fn BridgeConfig::unsafe_from_json(raw_json : String) -> BridgeConfig

    BridgeDiagnostic

    pub(all) struct BridgeDiagnostic {
    abi_version : Int
    stage : String
    code : String
    message : String
    page_instance : String
    url : String
    owner : String?
    source_url : String?
    source_line : String?
    line : Int?
    column : Int?
    stack : String?
    additional_failure_count : Int?
    details_truncated : Bool
    } derive(Eq,
    Debug
    ,
    FromJson
    )

    BridgeDiagnostic::equal

    BridgeDiagnostic::not_equal

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

    BridgeExtensionConfig

    pub(all) struct BridgeExtensionConfig {
    js_namespace : String
    apis : Array[String]
    } derive(Eq,
    Debug
    )

    One JavaScript namespace installed by the renderer bootstrap.

    BridgeExtensionConfig::equal

    BridgeExtensionConfig::new

    fn BridgeExtensionConfig::new(js_namespace : String, apis~ : Array[String]) -> BridgeExtensionConfig

    BridgeExtensionConfig::not_equal

    BridgeGrantConfig

    pub(all) struct BridgeGrantConfig {
    source_origin : String
    ops : Array[String]
    extensions : Array[BridgeExtensionConfig]
    initialization_units : Array[BridgeInitializationUnit]
    } derive(Eq,
    Debug
    )

    Renderer capabilities granted to one canonical source in one window.

    BridgeGrantConfig::equal

    BridgeGrantConfig::new

    fn BridgeGrantConfig::new(source_origin : String, ops~ : Array[String], extensions? : Array[BridgeExtensionConfig], initialization_units? : Array[BridgeInitializationUnit]) -> BridgeGrantConfig

    BridgeGrantConfig::not_equal

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

    BridgeInitializationUnit

    pub(all) struct BridgeInitializationUnit {
    owner : String
    name : String
    source : String
    } derive(Eq,
    Debug
    )

    One ordered JavaScript initialization unit owned by an extension.

    BridgeInitializationUnit::equal

    BridgeInitializationUnit::new

    fn BridgeInitializationUnit::new(owner : String, name : String, source : String) -> BridgeInitializationUnit

    BridgeInitializationUnit::not_equal

    BridgeLifecycleState

    pub(all) struct BridgeLifecycleState {
    abi_version : Int
    revision : String
    outcome : String
    page_instance : String
    url : String
    failure_pending : Bool
    } derive(Eq,
    Debug
    ,
    FromJson
    )

    BridgeRequest

    pub(all) struct BridgeRequest {
    request_id : Int64
    window : Int64
    op : String
    payload : Json
    page_instance : String?
    source_origin : String
    } derive(
    Debug
    )

    BridgeRequest::op

    fn BridgeRequest::op(self : BridgeRequest) -> String

    BridgeRequest::page_instance

    fn BridgeRequest::page_instance(self : BridgeRequest) -> String?

    BridgeRequest::payload

    fn BridgeRequest::payload(self : BridgeRequest) -> Json

    BridgeRequest::request_id

    fn BridgeRequest::request_id(self : BridgeRequest) -> Int64

    BridgeRequest::source_origin

    fn BridgeRequest::source_origin(self : BridgeRequest) -> String

    BridgeRequest::window

    fn BridgeRequest::window(self : BridgeRequest) -> Int64

    BridgeResponse

    pub(all) enum BridgeResponse {
    Ok(request_id~ : Int64, payload~ : Json)
    Err(request_id~ : Int64, code~ : String, message~ : String)
    } derive(
    Debug
    )

    BridgeResponse::to_json_string

    fn BridgeResponse::to_json_string(self : BridgeResponse) -> String

    BrowserPolicy

    pub(all) struct BrowserPolicy {
    navigation : BrowserPolicyMode
    popup : BrowserPolicyMode
    download : BrowserPolicyMode
    certificate : BrowserPolicyMode
    media : BrowserPolicyMode
    devtools : Bool
    } derive(Eq,
    Debug
    )

    BrowserPolicy::equal

    BrowserPolicy::new

    fn BrowserPolicy::new(navigation? : BrowserPolicyMode, popup? : BrowserPolicyMode, download? : BrowserPolicyMode, certificate? : BrowserPolicyMode, media? : BrowserPolicyMode, devtools? : Bool) -> BrowserPolicy

    BrowserPolicy::not_equal

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

    BrowserPolicyMode

    pub(all) enum BrowserPolicyMode {
    Allow
    Deny
    Ask
    } derive(Eq,
    Debug
    )

    BrowserPolicyMode::equal

    BrowserPolicyMode::not_equal

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

    DialogLevel

    pub(all) enum DialogLevel {
    Info
    Warning
    Error
    } derive(Eq,
    Debug
    )

    DialogLevel::equal

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

    DialogLevel::not_equal

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

    DialogPollResult

    pub(all) enum DialogPollResult {
    Pending
    Ready(String)
    } derive(Eq,
    Debug
    )

    DialogPollResult::equal

    DialogPollResult::not_equal

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

    A top-level native menu and its items.
    fn Menu::equal(Menu, Menu) -> Bool

    fn Menu::new(label : String, items~ : Array[MenuItem]) -> Menu

    Creates a top-level menu.
    fn Menu::not_equal(x : Menu, y : Menu) -> Bool

    fn Menu::role(role : MenuRole, label? : String, items? : Array[MenuItem]) -> Menu

    Creates a standard top-level menu. Omitted items select the role defaults; an explicit item array replaces those defaults exactly.

    An application-level native menu bar.
    fn MenuBar::equal(MenuBar, MenuBar) -> Bool

    fn MenuBar::new(menus~ : Array[Menu]) -> MenuBar

    Creates an application-level menu bar.
    fn MenuBar::not_equal(x : MenuBar, y : MenuBar) -> Bool

    fn MenuBar::to_json_string(self : MenuBar) -> String

    Encodes this menu bar for the native ABI.

    type MenuItem derive(Eq,
    Debug
    )

    A command, separator, or platform role in a native menu.
    fn MenuItem::command(id : String, label : String, key? : String) -> MenuItem

    Creates an app command item. Activating it emits menu_command.
    fn MenuItem::equal(MenuItem, MenuItem) -> Bool

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

    fn MenuItem::role(role : MenuItemRole, label? : String, key? : String) -> MenuItem

    Creates an item backed by a platform menu role such as close or quit.
    fn MenuItem::separator() -> MenuItem

    Creates a menu separator.

    pub(all) enum MenuItemRole {
    Quit
    Hide
    HideOthers
    ShowAll
    Close
    Minimize
    Zoom
    Undo
    Redo
    Cut
    Copy
    Paste
    SelectAll
    } derive(Eq,
    Debug
    )

    A standard native menu action.

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

    pub(all) enum MenuRole {
    Application
    File
    Edit
    View
    Window
    Help
    } derive(Eq,
    Debug
    )

    A standard top-level application menu role.
    fn MenuRole::equal(MenuRole, MenuRole) -> Bool

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

    NativeBrowserRequest

    pub(all) enum NativeBrowserRequest {
    Navigation(request_id~ : Int64, url~ : String, http_method~ : String, user_gesture~ : Bool, redirect~ : Bool)
    Popup(request_id~ : Int64, url~ : String, disposition~ : Int, user_gesture~ : Bool)
    Download(request_id~ : Int64, download_id~ : Int, url~ : String, suggested_name~ : String)
    Certificate(request_id~ : Int64, url~ : String, error_code~ : Int)
    Media(request_id~ : Int64, origin~ : String, permissions~ : Int)
    } derive(Eq,
    Debug
    )

    NativeBrowserRequest::equal

    NativeBrowserRequest::not_equal

    NativeDownloadUpdate

    pub(all) struct NativeDownloadUpdate {
    download_id : Int
    state : String
    received_bytes : Int64
    total_bytes : Int64
    percent : Int
    } derive(Eq,
    Debug
    )

    NativeDownloadUpdate::equal

    NativeDownloadUpdate::not_equal

    NativeImage

    type NativeImage

    NativeImage::add_bitmap

    fn NativeImage::add_bitmap(self : NativeImage, data : Bytes, width : Int, height : Int, scale_factor? : Double) -> Unit raise NativeError

    Adds a raw RGBA bitmap representation at scale_factor (1.0 = 100%). data must be at least width * height * 4 bytes in 32-bit RGBA format.

    NativeImage::add_jpeg

    fn NativeImage::add_jpeg(self : NativeImage, data : Bytes, scale_factor? : Double) -> Unit raise NativeError

    Adds a JPEG representation at scale_factor (1.0 = 100%). JPEG does not support transparency; the alpha channel is discarded.

    NativeImage::add_png

    fn NativeImage::add_png(self : NativeImage, data : Bytes, scale_factor? : Double) -> Unit raise NativeError

    Adds a PNG representation at scale_factor (1.0 = 100%). PNG transparency is preserved.

    NativeImage::create_empty

    fn NativeImage::create_empty() -> NativeImage raise NativeError

    Creates an empty native image. Use add_png, add_jpeg, or add_bitmap to add a representation at a given scale factor, then query with is_empty or size, and export with to_png, to_jpeg, or to_bitmap.

    Raises UnsupportedNativeFeature when the native engine is not available.

    NativeImage::destroy

    fn NativeImage::destroy(self : NativeImage) -> Unit raise NativeError

    Releases the native image handle. Safe to call multiple times; subsequent calls are no-ops.

    NativeImage::is_empty

    fn NativeImage::is_empty(self : NativeImage) -> Bool raise NativeError

    Returns true if the image has no representations.

    NativeImage::size

    fn NativeImage::size(self : NativeImage) -> (Int, Int) raise NativeError

    Returns the image size in density-independent pixels as (width, height).

    NativeImage::to_bitmap

    fn NativeImage::to_bitmap(self : NativeImage, scale_factor? : Double) -> (Bytes, Int, Int) raise NativeError

    Exports the representation closest to scale_factor as raw RGBA bitmap bytes (32-bit RGBA). Returns (bitmap_bytes, pixel_width, pixel_height).

    NativeImage::to_jpeg

    fn NativeImage::to_jpeg(self : NativeImage, scale_factor? : Double, quality? : Int) -> (Bytes, Int, Int) raise NativeError

    Exports the representation closest to scale_factor as JPEG bytes. quality is 0-100 (0=lowest, 100=highest). Returns (jpeg_bytes, pixel_width, pixel_height).

    NativeImage::to_png

    fn NativeImage::to_png(self : NativeImage, scale_factor? : Double, with_transparency? : Bool) -> (Bytes, Int, Int) raise NativeError

    Exports the representation closest to scale_factor as PNG bytes. When with_transparency is true, alpha transparency is preserved. Returns (png_bytes, pixel_width, pixel_height).

    NativeNotificationClick

    pub(all) struct NativeNotificationClick {
    payload : String?
    } derive(Eq,
    Debug
    )

    A native notification activation, optionally carrying its application payload.

    NativeNotificationClick::equal

    NativeNotificationClick::not_equal

    NativeNotificationResult

    pub(all) enum NativeNotificationResult {
    Delivered
    Failed(String)
    } derive(Eq,
    Debug
    )

    NativeNotificationResult::equal

    NativeNotificationResult::not_equal

    ProcessResult

    pub(all) enum ProcessResult {
    MainProcess
    SubprocessHandled(Int)
    } derive(Eq,
    Debug
    )

    ProcessResult::equal

    ProcessResult::not_equal

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

    Runtime

    type Runtime

    Runtime::activate_wakeup_source

    fn Runtime::activate_wakeup_source(self : Runtime) -> Unit raise NativeError

    Activates a prepared wakeup source after its reader is connected.

    Runtime::begin_message_dialog

    fn Runtime::begin_message_dialog(self : Runtime, title : String?, message : String, level : DialogLevel) -> Int64 raise NativeError

    Runtime::destroy

    fn Runtime::destroy(self : Runtime) -> Unit raise NativeError

    Runtime::do_message_loop_work

    fn Runtime::do_message_loop_work(self : Runtime) -> Unit raise NativeError

    Advances one external-message-pump iteration for a low-level host.

    Runtime::new

    fn Runtime::new(config? : RuntimeConfig) -> Runtime raise NativeError

    Runtime::next_wakeup_delay_ms

    fn Runtime::next_wakeup_delay_ms(self : Runtime) -> Int? raise NativeError

    Returns the delay until CEF next needs its external message pump serviced, or None when no delayed pump is scheduled.

    Runtime::poll_bridge_request

    fn Runtime::poll_bridge_request(self : Runtime) -> BridgeRequest? raise NativeError

    Runtime::poll_bridge_request_json

    fn Runtime::poll_bridge_request_json(self : Runtime) -> String? raise NativeError

    Runtime::poll_event

    fn Runtime::poll_event(self : Runtime) -> RuntimeEvent? raise NativeError

    Runtime::poll_event_json

    fn Runtime::poll_event_json(self : Runtime) -> String? raise NativeError

    Runtime::poll_message_dialog

    fn Runtime::poll_message_dialog(self : Runtime, dialog : Int64) -> Bool raise NativeError

    Runtime::prepare_wakeup_source

    fn Runtime::prepare_wakeup_source(self : Runtime) -> String raise NativeError

    Prepares a platform-owned wakeup source and returns its locator.

    Call activate_wakeup_source after opening the locator for reading.

    Runtime::respond_bridge_request

    fn Runtime::respond_bridge_request(self : Runtime, response : BridgeResponse) -> Unit raise NativeError

    Runtime::set_menu

    fn Runtime::set_menu(self : Runtime, menu : MenuBar) -> Unit raise NativeError

    Replaces the application-level native menu bar for this runtime.

    Runtime::set_wakeup_fd

    fn Runtime::set_wakeup_fd(self : Runtime, wakeup_fd : Int) -> Unit raise NativeError

    Installs the write end of a non-blocking pipe used to wake the host async runtime. The native runtime duplicates the descriptor and does not borrow the caller's ownership.

    Runtime::wait

    fn Runtime::wait(self : Runtime, interest_mask~ : Int, timeout_ms? : Int) -> RuntimeWaitReady raise NativeError

    Waits for low-level external-pump work.

    RuntimeConfig

    type RuntimeConfig derive(Eq,
    Debug
    )

    RuntimeConfig::bundled

    fn RuntimeConfig::bundled(helper_path? : String, cache_dir? : String, locale? :
    Locale
    , accept_languages? : Array[
    Locale
    ], remote_debugging_port? : Int, headless? : Bool, persist_session_cookies? : Bool) -> RuntimeConfig

    helper_path, when set, overrides the subprocess executable the bundled runtime discovers. Packaged macOS applications automatically use their nested base Helper app. Set headless to enable CEF off-screen rendering for every window. Omit cache_dir for an isolated temporary browser profile, or provide an absolute, process-exclusive path for persistence.

    RuntimeConfig::equal

    RuntimeConfig::new

    fn RuntimeConfig::new(runtime_root? : String, helper_path? : String, resources_dir? : String, locales_dir? : String, cache_dir? : String, locale? :
    Locale
    , accept_languages? : Array[
    Locale
    ], remote_debugging_port? : Int, headless? : Bool, persist_session_cookies? : Bool) -> RuntimeConfig

    Builds an explicit native runtime configuration.

    Set headless to enable CEF off-screen rendering for every window created by this runtime. Remote debugging remains independently configurable. Omit cache_dir for an isolated temporary browser profile, or provide an absolute, process-exclusive path for persistent browser state.

    RuntimeConfig::not_equal

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

    RuntimeConfig::probe

    fn RuntimeConfig::probe(self : RuntimeConfig) -> Unit raise NativeError

    RuntimeConfig::to_json_string

    fn RuntimeConfig::to_json_string(self : RuntimeConfig) -> String

    RuntimeConfig::unsafe_from_json

    fn RuntimeConfig::unsafe_from_json(raw_json : String) -> RuntimeConfig

    Builds a runtime configuration from unchecked ABI JSON.

    This bypasses typed locale and schema construction and is intended only for low-level compatibility tests and native integration code.

    RuntimeEvent

    type RuntimeEvent derive(Eq,
    Debug
    )

    RuntimeEvent::bridge_request_cancellation

    fn RuntimeEvent::bridge_request_cancellation(self : RuntimeEvent) -> Int64?

    RuntimeEvent::browser_download_update

    fn RuntimeEvent::browser_download_update(self : RuntimeEvent) -> NativeDownloadUpdate?

    RuntimeEvent::browser_request

    fn RuntimeEvent::browser_request(self : RuntimeEvent) -> NativeBrowserRequest?

    RuntimeEvent::equal

    RuntimeEvent::event_type

    fn RuntimeEvent::event_type(self : RuntimeEvent) -> String

    RuntimeEvent::has_window

    fn RuntimeEvent::has_window(self : RuntimeEvent) -> Bool

    RuntimeEvent::is_bridge_lifecycle_changed

    fn RuntimeEvent::is_bridge_lifecycle_changed(self : RuntimeEvent) -> Bool

    RuntimeEvent::is_window_closed

    fn RuntimeEvent::is_window_closed(self : RuntimeEvent) -> Bool

    RuntimeEvent::is_window_created

    fn RuntimeEvent::is_window_created(self : RuntimeEvent) -> Bool

    RuntimeEvent::launch_input

    fn RuntimeEvent::launch_input(self : RuntimeEvent) -> RuntimeLaunchInput?

    Returns the typed application launch input carried by this event.

    RuntimeEvent::menu_command_id

    fn RuntimeEvent::menu_command_id(self : RuntimeEvent) -> String?

    The command id for an app-menu command item click, or None for every other event kind.

    RuntimeEvent::not_equal

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

    RuntimeEvent::notification_result

    fn RuntimeEvent::notification_result(self : RuntimeEvent) -> NativeNotificationResult?

    RuntimeEvent::view_event

    fn RuntimeEvent::view_event(self : RuntimeEvent) -> ViewEventInfo?

    Returns the view event payload when this event carries one.

    RuntimeEvent::view_id

    fn RuntimeEvent::view_id(self : RuntimeEvent) -> Int64?

    Returns the web contents view associated with this event when one exists.

    RuntimeEvent::window_close_request

    fn RuntimeEvent::window_close_request(self : RuntimeEvent) -> Int64?

    RuntimeEvent::window_id

    fn RuntimeEvent::window_id(self : RuntimeEvent) -> Int64?

    Returns the window associated with this event when one exists. For an app menu command this is the focused window at click time.

    RuntimeEvent::window_state_change

    fn RuntimeEvent::window_state_change(self : RuntimeEvent) -> WindowState?

    RuntimeInfo

    pub(all) struct RuntimeInfo {
    abi_version : Int
    runtime_available : Bool
    build_mode : String
    platform : String
    platform_id : String
    features : Array[String]
    } derive(Eq,
    Debug
    ,
    FromJson
    )

    RuntimeInfo::equal

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

    RuntimeInfo::not_equal

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

    RuntimeLaunchInput

    pub(all) enum RuntimeLaunchInput {
    OpenUrls(Array[String])
    OpenFiles(Array[String])
    Reopen
    } derive(Eq,
    Debug
    )

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

    RuntimeLaunchInput::equal

    RuntimeLaunchInput::not_equal

    RuntimeWaitReady

    pub(all) struct RuntimeWaitReady {
    mask : Int
    } derive(Eq,
    Debug
    )

    RuntimeWaitReady::equal

    RuntimeWaitReady::has_bridge

    fn RuntimeWaitReady::has_bridge(self : RuntimeWaitReady) -> Bool

    RuntimeWaitReady::has_event

    fn RuntimeWaitReady::has_event(self : RuntimeWaitReady) -> Bool

    RuntimeWaitReady::has_platform

    fn RuntimeWaitReady::has_platform(self : RuntimeWaitReady) -> Bool

    RuntimeWaitReady::is_timeout

    fn RuntimeWaitReady::is_timeout(self : RuntimeWaitReady) -> Bool

    RuntimeWaitReady::mask

    fn RuntimeWaitReady::mask(self : RuntimeWaitReady) -> Int

    RuntimeWaitReady::not_equal

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

    ScreenInfo

    pub(all) struct ScreenInfo {
    id : Int
    x : Int
    y : Int
    width : Int
    height : Int
    work_x : Int
    work_y : Int
    work_width : Int
    work_height : Int
    scale_factor_percent : Int
    is_primary : Bool
    } derive(Eq,
    Debug
    ,
    FromJson
    )

    Information about a single connected display.

    ScreenInfo::equal

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

    ScreenInfo::not_equal

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

    TitlebarStyle

    pub(all) enum TitlebarStyle {
    Default
    Overlay
    } derive(Eq,
    Debug
    )

    TitlebarStyle::equal

    TitlebarStyle::not_equal

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

    UpdateInstallOutcome

    pub enum UpdateInstallOutcome {
    Installed
    AlreadyInstalled
    } derive(Eq,
    Debug
    )

    What consuming an authenticated update stage changed.

    UpdateInstallOutcome::equal

    UpdateInstallOutcome::not_equal

    UpdateStage

    type UpdateStage

    A private native file that receives one artifact stream while it is checked.

    The file path is deliberately not exposed. The native updater owns it from creation through expansion, which keeps verification and installation tied to the same bytes.

    UpdateStage::abort

    fn UpdateStage::abort(self : UpdateStage) -> Unit raise NativeError

    Discards an unfinished stage and all bytes written to it.

    UpdateStage::install

    Consumes a complete stage and installs the application it contains.

    UpdateStage::write

    fn UpdateStage::write(self : UpdateStage, chunk : Bytes) -> Unit raise NativeError

    Appends one downloaded chunk to a private update stage.

    View

    type View

    An owned native web contents view hosted inside a window's content area.

    View::as_ref

    fn View::as_ref(self : View) -> ViewRef

    Borrows this view handle for APIs that must not destroy it.

    View::browser_command

    fn View::browser_command(self : View, command : String, download_id? : Int) -> Unit raise NativeError

    Sends a browser control command to the view: back, forward, reload, reload_ignore_cache, stop, open_devtools, or close_devtools.

    View::destroy

    fn View::destroy(self : View) -> Unit raise NativeError

    View::eval

    fn View::eval(self : View, script : String) -> Unit raise NativeError

    Executes JavaScript in the view's main frame without awaiting a result.

    View::id

    fn View::id(self : View) -> Int64

    Returns the stable native handle used to correlate native calls.

    View::load_html

    fn View::load_html(self : View, html : String, base_url : String) -> Unit raise NativeError

    Loads inline HTML into the view, served from base_url on the proton:// scheme, mirroring Window::load_html.

    View::load_url

    fn View::load_url(self : View, url : String) -> Unit raise NativeError

    View::new

    fn View::new(window : Window, config : ViewConfig) -> View raise NativeError

    Creates a web contents view inside window. The view renders above the window's main browser content; use set_z_order to stack multiple views. Requires the web_contents_view native runtime feature.

    View::set_bounds

    fn View::set_bounds(self : View, x~ : Int, y~ : Int, width~ : Int, height~ : Int) -> Unit raise NativeError

    Moves and resizes the view. x/y use a top-left origin in the owning window's content coordinate space, matching Electron's setBounds.

    View::set_visible

    fn View::set_visible(self : View, visible : Bool) -> Unit raise NativeError

    View::set_z_order

    fn View::set_z_order(self : View, z_order : Int) -> Unit raise NativeError

    Stacks the view relative to the window's other views; higher z_order renders above lower values, and views always render above the window's main browser content.

    View::state

    fn View::state(self : View) -> ViewState raise NativeError

    Reads the current view state from the native runtime.

    ViewConfig

    type ViewConfig derive(Eq,
    Debug
    )

    Native configuration for one web contents view. width and height are required because the native browser needs an initial rectangle; x/y default to 0, visible to true, z_order to 0, and initial_url to about:blank. Views stack above the window's main browser, ordered by ascending z_order.

    ViewConfig::equal

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

    ViewConfig::new

    fn ViewConfig::new(width~ : Int, height~ : Int, x? : Int, y? : Int, visible? : Bool, z_order? : Int, initial_url? : String, background_color? : String) -> ViewConfig

    ViewConfig::not_equal

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

    ViewConfig::to_json_string

    fn ViewConfig::to_json_string(self : ViewConfig) -> String

    ViewConfig::unsafe_from_json

    fn ViewConfig::unsafe_from_json(raw_json : String) -> ViewConfig

    Creates a view config from unchecked native ABI JSON.

    ViewEventInfo

    pub(all) struct ViewEventInfo {
    url : String?
    title : String?
    is_loading : Bool?
    error_code : Int?
    error_text : String?
    } derive(Eq,
    Debug
    )

    The payload of a web contents view lifecycle event.

    ViewEventInfo::equal

    ViewEventInfo::not_equal

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

    ViewRef

    A borrowed view handle for APIs that must not destroy the view.

    ViewRef::equal

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

    ViewRef::not_equal

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

    ViewRef::to_repr

    ViewRef::unsafe_from_handle

    fn ViewRef::unsafe_from_handle(handle : Int64) -> ViewRef

    ViewState

    pub(all) struct ViewState {
    x : Int
    y : Int
    width : Int
    height : Int
    visible : Bool
    z_order : Int
    } derive(Eq,
    Debug
    ,
    FromJson
    )

    A point-in-time web contents view state snapshot. Bounds use a top-left origin in the owning window's content coordinate space.

    ViewState::equal

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

    ViewState::not_equal

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

    Window

    type Window

    Window::as_ref

    fn Window::as_ref(self : Window) -> WindowRef

    Borrows this owning window handle for APIs that must not destroy it.

    Window::bridge_lifecycle_state

    fn Window::bridge_lifecycle_state(self : Window) -> BridgeLifecycleState raise NativeError

    Window::browser_command

    fn Window::browser_command(self : Window, command : String, download_id? : Int) -> Unit raise NativeError

    Window::clear_cache

    fn Window::clear_cache(self : Window) -> Unit raise NativeError

    Clears the HTTP cache for the window's request context. Fire-and-forget.

    Window::close

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

    Window::cookie_begin_get

    fn Window::cookie_begin_get(self : Window, url : String?, include_http_only : Bool) -> Unit raise NativeError

    Begins retrieving cookies for the window's session. If url is None, all cookies are retrieved; otherwise only cookies matching the URL are returned. When include_http_only is true, HTTP-only cookies are included. Returns immediately; call cookie_poll_get on each message loop iteration until it returns Some(json).

    Window::cookie_delete

    fn Window::cookie_delete(self : Window, url : String?, name : String?) -> Unit raise NativeError

    Deletes cookies. If url is None, all cookies are deleted. If name is Some, only cookies with that name matching the URL are deleted. Fire-and-forget.

    Window::cookie_flush

    fn Window::cookie_flush(self : Window) -> Unit raise NativeError

    Flushes the cookie store to disk. Fire-and-forget.

    Window::cookie_poll_get

    fn Window::cookie_poll_get(self : Window) -> String? raise NativeError

    Polls for the result of a cookie get operation. Returns None if the operation is still in progress, or Some(json) with a JSON array of cookie objects when complete.

    Window::cookie_set

    fn Window::cookie_set(self : Window, cookie_json : String) -> Unit raise NativeError

    Sets a cookie from a JSON object. The JSON must contain "url", "name", and "value", and may contain "domain", "path", "secure", "http_only", "same_site", "expires". Fire-and-forget.

    Window::destroy

    fn Window::destroy(self : Window) -> Unit raise NativeError

    Window::emit_bridge_event_json

    fn Window::emit_bridge_event_json(self : Window, event_json : String) -> Unit raise NativeError

    Window::eval

    fn Window::eval(self : Window, script : String) -> Unit raise NativeError

    Window::focus

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

    Window::hide

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

    Window::id

    fn Window::id(self : Window) -> Int64

    Returns the stable native handle used to correlate runtime events.

    Window::load_asset

    fn Window::load_asset(self : Window, html : String, document_url : String, asset_root : String) -> Unit raise NativeError

    Load an HTML document whose relative URLs resolve inside asset_root.

    Window::load_html

    fn Window::load_html(self : Window, html : String, base_url : String) -> Unit raise NativeError

    Window::load_url

    fn Window::load_url(self : Window, url : String) -> Unit raise NativeError

    Window::maximize

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

    Window::minimize

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

    Window::new

    fn Window::new(runtime : Runtime, config? : WindowConfig) -> Window raise NativeError

    Window::respond_browser_request

    fn Window::respond_browser_request(self : Window, request_id : Int64, action : String, path? : String) -> Unit raise NativeError

    Window::respond_close_request

    fn Window::respond_close_request(self : Window, request_id : Int64, allow : Bool) -> Unit raise NativeError

    Window::restore

    fn Window::restore(self : Window) -> Unit raise NativeError

    Window::set_always_on_top

    fn Window::set_always_on_top(self : Window, always_on_top : Bool) -> Unit raise NativeError

    Window::set_close_interception

    fn Window::set_close_interception(self : Window, enabled : Bool) -> Unit raise NativeError

    Window::set_fullscreen

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

    Window::set_position

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

    Window::set_size

    fn Window::set_size(self : Window, width : Int, height : Int) -> Unit raise NativeError

    Window::set_title

    fn Window::set_title(self : Window, title : String) -> Unit raise NativeError

    Window::set_zoom_percent

    fn Window::set_zoom_percent(self : Window, zoom_percent : Int) -> Unit raise NativeError

    Window::show

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

    Window::state

    fn Window::state(self : Window) -> WindowState raise NativeError

    Window::take_bridge_failure

    fn Window::take_bridge_failure(self : Window) -> BridgeDiagnostic? raise NativeError

    WindowConfig

    type WindowConfig derive(Eq,
    Debug
    )

    WindowConfig::equal

    WindowConfig::new

    fn WindowConfig::new(title? : String, width? : Int, height? : Int, initial_url? : String, size_hint? : WindowSizeHint, titlebar_style? : TitlebarStyle, browser? : BrowserPolicy, bridge? : BridgeConfig) -> WindowConfig

    WindowConfig::not_equal

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

    WindowConfig::to_json_string

    fn WindowConfig::to_json_string(self : WindowConfig) -> String

    WindowConfig::unsafe_from_json

    fn WindowConfig::unsafe_from_json(raw_json : String) -> WindowConfig

    WindowMonitor

    pub(all) struct WindowMonitor {
    x : Int
    y : Int
    width : Int
    height : Int
    work_x : Int
    work_y : Int
    work_width : Int
    work_height : Int
    scale_factor_percent : Int
    } derive(Eq,
    Debug
    ,
    FromJson
    )

    Geometry and scaling information for the monitor containing a window.

    WindowMonitor::equal

    WindowMonitor::not_equal

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

    WindowRef

    type WindowRef derive(Eq,
    Debug
    )

    WindowRef::begin_choose_directory_dialog

    fn WindowRef::begin_choose_directory_dialog(self : WindowRef, title : String?, path : String?) -> Int64 raise NativeError

    WindowRef::begin_confirm_dialog

    fn WindowRef::begin_confirm_dialog(self : WindowRef, title : String?, message : String, level : DialogLevel) -> Int64 raise NativeError

    WindowRef::begin_message_dialog

    fn WindowRef::begin_message_dialog(self : WindowRef, title : String?, message : String, level : DialogLevel) -> Int64 raise NativeError

    WindowRef::begin_open_file_dialog

    fn WindowRef::begin_open_file_dialog(self : WindowRef, title : String?, path : String?) -> Int64 raise NativeError

    WindowRef::begin_save_file_dialog

    fn WindowRef::begin_save_file_dialog(self : WindowRef, title : String?, path : String?) -> Int64 raise NativeError

    WindowRef::equal

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

    WindowRef::not_equal

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

    WindowRef::poll_dialog_result

    fn WindowRef::poll_dialog_result(self : WindowRef, dialog : Int64) -> DialogPollResult raise NativeError

    WindowRef::unsafe_from_handle

    fn WindowRef::unsafe_from_handle(handle : Int64) -> WindowRef

    WindowSizeHint

    pub(all) enum WindowSizeHint {
    Unconstrained
    Fixed
    Min
    Max
    } derive(Eq,
    Debug
    )

    Controls how the configured width and height constrain native resizing.

    WindowSizeHint::equal

    WindowSizeHint::not_equal

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

    WindowState

    pub(all) struct WindowState {
    x : Int
    y : Int
    width : Int
    height : Int
    monitor : WindowMonitor
    zoom_percent : Int
    visible : Bool
    focused : Bool
    minimized : Bool
    maximized : Bool
    fullscreen : Bool
    always_on_top : Bool
    theme : String
    } derive(Eq,
    Debug
    ,
    FromJson
    )

    A point-in-time native window state snapshot.

    WindowState::equal

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

    WindowState::not_equal

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

    abi_version

    fn abi_version() -> Int

    bridge_permission_grants_supported

    fn bridge_permission_grants_supported() -> Bool

    execute_process

    fn execute_process(config? : RuntimeConfig) -> ProcessResult raise NativeError

    host_loop_begin

    fn host_loop_begin() -> Unit raise NativeError

    Takes over the calling thread's event loop. The loop belongs to the thread rather than to a runtime: it starts before the first runtime exists and outlives the last one, so a host can run async work while it is still deciding what runtime to build.

    Must be called on the process's main thread.

    host_loop_end

    fn host_loop_end() -> Unit

    Releases the host loop. Safe to call when no loop is running.

    host_loop_poll

    fn host_loop_poll(timeout_ms? : Int) -> RuntimeWaitReady raise NativeError

    Runs one iteration of the host loop: block until work arrives or the timeout expires, then advance the platform toolkit. Pass no timeout_ms to wait indefinitely.

    This is the only thing that drives the platform while the host loop owns the thread, so a host must keep calling it. The returned mask says which kinds of work became ready; it is empty when nothing happened.

    last_error_message

    fn last_error_message() -> String

    notification_cleanup

    fn notification_cleanup() -> Unit raise NativeError

    Releases process-level notification hooks installed by Proton.

    notification_poll_click

    fn notification_poll_click() -> NativeNotificationClick? raise NativeError

    Removes and returns the oldest pending notification activation.

    notification_show

    fn notification_show(title : String, body : String, payload? : String) -> Unit raise NativeError

    Schedules a native notification with an optional activation payload.

    notification_supported

    fn notification_supported() -> Bool raise NativeError

    Reports whether native notifications are available in the current process.

    probe_runtime

    fn probe_runtime(config? : RuntimeConfig) -> Unit raise NativeError

    runtime_info

    fn runtime_info() -> RuntimeInfo raise NativeError

    runtime_info_json

    fn runtime_info_json() -> String raise NativeError

    runtime_wait_all

    let runtime_wait_all : Int

    runtime_wait_bridge

    let runtime_wait_bridge : Int

    runtime_wait_event

    let runtime_wait_event : Int

    runtime_wait_none

    let runtime_wait_none : Int

    runtime_wait_platform

    let runtime_wait_platform : Int

    screens

    fn screens() -> Array[ScreenInfo] raise NativeError

    Enumerates all connected displays.

    Returns an array of ScreenInfo describing each monitor's bounds, work area, scale factor, and primary flag. The first entry is always the primary display. Raises UnsupportedNativeFeature when the native engine is not available.

    signal_wakeup

    fn signal_wakeup() -> Unit

    Wakes a blocked Runtime::wait or host_loop_poll, or makes the next one return immediately when none is blocked yet. A lost wakeup deadlocks the host, so the two cases behave the same.

    Takes no runtime and is safe from any thread, touching only atomics and the platform run loop. That is what lets a thread outside the runtime call it: handles validate thread ownership and such a thread owns none.

    system_preferred_language_tags

    fn system_preferred_language_tags() -> Array[String] raise NativeError

    Returns the operating system's preferred language tags in preference order.

    Platform adapters may return platform-native locale syntax. The public facade owns validation and canonicalization into Locale values.

    update_cleanup_previous

    fn update_cleanup_previous() -> Unit raise NativeError

    Removes older bundles retained by completed application updates.

    Call this only after the replacement has completed application startup. Native code restricts deletion to Proton-reserved sibling names with the same signing identity and an older update revision.

    update_current_revision

    fn update_current_revision() -> UInt64 raise NativeError

    Reads the installed application's monotonic update revision.

    This is an optimistic check for process-local coordination. Installation repeats it while holding the native cross-process commit lock.

    update_install

    fn update_install(archive : Bytes, parent_dir : String) -> Unit raise NativeError

    Installs an authenticated update archive over the running application.

    Expansion, bundle signature validation, and replacement form one native transaction. The expanded bundle path never crosses the FFI boundary, so another task cannot replace the validated bundle before installation.

    update_relaunch

    fn update_relaunch() -> Unit raise NativeError

    Starts the replaced application.

    The caller is expected to exit afterwards: two copies of the same application running against the same state is worse than a moment with none.

    update_stage_begin

    fn update_stage_begin(parent_dir : String, expected_size : Int64, target_revision : UInt64) -> UpdateStage raise NativeError

    Starts a private update staging transaction in an explicit directory.

    Application updates should use update_stage_begin_for_current_app so the stage and installed bundle are guaranteed to be on the same filesystem.

    update_stage_begin_for_current_app

    fn update_stage_begin_for_current_app(expected_size : Int64, target_revision : UInt64) -> UpdateStage raise NativeError

    Starts a private update stage beside the running application bundle.

    Keeping the stage on the installed application's filesystem makes the final bundle replacement an atomic rename even when the application runs from an external volume.

    web_contents_view_supported

    fn web_contents_view_supported() -> Bool

    Returns true when the loaded native runtime supports web contents views.