MoonBit bindings for the Proton native desktop runtime.
Dependencies
async fn main {
@proton.html("Hello", "<h1>Hello</h1>")
.identifier("dev.proton.hello")
.run_or_abort()
}| Proton | Electron | Behavior |
|---|---|---|
| has_single_instance_lock() | app.hasSingleInstanceLock() | true while this process holds the identity; false without App::single_instance and after a release |
| release_single_instance_lock() | app.releaseSingleInstanceLock() | Releases the identity so the next launch acquires it instead of forwarding; the releasing process keeps running and stops receiving activations |
app_lifecycle(
on_start=context => {
println(context.has_single_instance_lock().to_string())
context.release_single_instance_lock() catch { _ => () }
context
},
on_shutdown=fn(_) { () },
)| Field | Meaning |
|---|---|
| task_id | Task identity, stable for its lifetime; not an OS PID |
| task_type | AppTaskType classification of the task |
| process_cpu_percent | Hosting process CPU usage since the previous sample; 100% is one fully used core |
| process_memory_bytes | Hosting process private footprint in bytes; -1 before measurement |
| name | Task name, empty when unavailable |
for metric in context.task_metrics() {
println(metric.task_type.to_repr())
println(metric.process_cpu_percent)
println(metric.process_memory_bytes)
}let mut save_pending = true
@proton.html("Quit chain", page)
.identifier("com.example.quit-chain")
.on_before_quit(fn(_context) {
if save_pending {
@proton.ApplicationQuitDecision::Prevent
} else {
@proton.ApplicationQuitDecision::Allow
}
})
.on_will_quit(fn(context) {
context.relaunch() catch { _ => () }
@proton.ApplicationQuitDecision::Allow
})
.on_quit(fn(_context, exit_code) {
println("quitting with " + exit_code.to_string())
})
.run_or_abort()| Proton | Electron | Behavior |
|---|---|---|
| focus(steal=...) | app.focus([options]) | macOS activates the application and steal decides whether another frontmost application may be displaced; Windows and Linux focus the first visible window |
| hide() | app.hide() macOS | Hides every window without minimizing it |
| show() | app.show() macOS | Shows hidden windows without focusing them |
| is_active() | app.isActive() macOS | Reports whether the application is the active app |
| is_hidden() | app.isHidden() macOS | Reports whether the application and its windows are hidden |
| Proton | Electron | Payload |
|---|---|---|
| App::on_window_created(...) | browser-window-created | WindowHandle |
| App::on_web_contents_created(...) | web-contents-created | WebContentsHandle: Browser for a window's main page, View for a web contents view |
| App::on_render_process_gone(...) | render-process-gone | WebContentsHandle and RenderProcessGoneDetails { reason, exit_code } |
| App::on_session_created(...) | session-created | ApplicationSession { partition, data_path } |
| Proton | Electron | Behavior |
|---|---|---|
| navigation_history() | navigationHistory.getAllEntries() | Chromium's entries in order plus active_index |
| NavigationHistory::length() | navigationHistory.length() | Number of entries in the snapshot |
| NavigationHistory::entry_at(index) | navigationHistory.getEntryAtIndex(index) | One entry, or None outside the snapshot |
| NavigationHistory::active_entry() | navigationHistory.getActiveIndex() lookup | The entry the browser currently shows |
| NavigationHistory::can_go_back() / can_go_forward() | navigationHistory.canGoBack() / canGoForward() | Whether an entry exists on either side |
| NavigationEntry::url, display_url, original_url, title | NavigationEntry.url and title | Chromium's URL, display URL, pre-redirect URL, and page title |
| NavigationEntry::transition | transitionType | Chromium page-transition type: link, typed, auto-bookmark, auto-subframe, manual-subframe, generated, auto-toplevel, form-submit, reload, keyword, keyword-generated, or other(code) |
| NavigationEntry::transition_qualifiers | transitionQualifiers | client-redirect, server-redirect, forward-back, or from-address-bar |
| NavigationEntry::has_post_data, http_status_code | NavigationEntry.hasPostData and the status code | POST state and the last successful navigation status |
let key = browser.insert_css("body { background: #101418; }")
browser.remove_inserted_css(key)| Electron | Why it is absent |
|---|---|
| capturePage() | CEF exposes no page-snapshot API: only off-screen paint callbacks, which a windowed browser never runs. Use the desktop_capturer extension for screen or window thumbnails. |
| savePage() | CEF has no page-save entry point. |
| setUserAgent() and getUserAgent() | A user agent override is a process-wide CEF setting, not a per-webContents property, and CEF cannot report the effective agent. |
| isCurrentlyAudible() | CEF reports audio capture rather than playback, so Chromium's audible state is not observable. |
| setBackgroundThrottling(), setVisualZoomLevelLimits(), setImageAnimationPolicy() | CEF exposes none of these preferences. |
| getOSProcessId(), getProcessId(), getProcessMemoryInfo() | CEF hides operating-system pids. ApplicationContext::task_metrics() reports hosting-process usage per task, without PID or grouping; values cannot be summed. |
| startDrag() | Drag start lives on CEF's render handler, which only runs for off-screen rendering. |
@proton.html("Commands", html)
.identifier("dev.proton.commands")
.commands(fn(registrar) raise { registrar.bind(ping_command, ping) })
.run_or_abort()const reply = await window.__MoonBit__.core.invokeOp("ext:app/ping", {
name: "proton",
});
window.__MoonBit__.events.on("app.tick", (event) => console.log(event.payload));@proton.html("Main", main_html)
.add_window(
"settings",
"Settings",
@proton.AppEntry::Html(settings_html),
width=420,
height=320,
)window.set_progress_bar(0.4) // determinate
window.set_progress_bar(0.4, mode=@proton.ProgressBarMode::Paused) // paused
window.set_progress_bar(-1.0, mode=@proton.ProgressBarMode::Cleared) // clearedlet overlay = @proton.native_image()
overlay.add_png(png_bytes, 16, 16)
window.set_overlay_icon(Some(overlay), "unread messages")
window.set_overlay_icon(None, "")let previous = @proton.native_image()
previous.add_png(previous_png, 16, 16)
let applied = window.set_thumbar_buttons([
@proton.ThumbarButton::{
id: "previous",
icon: previous,
tooltip: "Previous",
flags: [],
},
@proton.ThumbarButton::{
id: "play",
icon: play,
tooltip: "Play or pause",
flags: [@proton.ThumbarButtonFlag::NoBackground],
},
])@proton.html("Player", player_html)
.on_thumbar_button_click(fn(window, button_id) noraise {
match button_id {
"previous" => play_previous(window)
"next" => play_next(window)
_ => toggle_playback(window)
}
})
.run_or_abort()let result = @proton.set_jump_list(Some([
@proton.JumpListCategory::{
kind: @proton.JumpListCategoryKind::Tasks,
name: "",
items: [
@proton.JumpListItem::{
kind: @proton.JumpListItemKind::Task,
path: executable,
arguments: "--play",
title: "Play or pause",
description: "Starts playback in a new instance",
icon_path: executable,
icon_index: 0,
working_directory: "",
},
// A separator is only allowed in the Tasks category.
@proton.JumpListItem::{
kind: @proton.JumpListItemKind::Separator,
path: "",
arguments: "",
title: "",
description: "",
icon_path: "",
icon_index: 0,
working_directory: "",
},
],
},
@proton.JumpListCategory::{
kind: @proton.JumpListCategoryKind::Custom,
name: "Recent sessions",
items: [...],
},
])) catch {
error => abort(error.message())
}@proton.html("Accessible", "<main><h1>Hello</h1></main>")
.identifier("dev.proton.accessible")
.accessibility(@proton.AccessibilityMode::AlwaysEnabled)
.run_or_abort()let appearance = @proton.system_appearance() catch {
error => abort(error.message())
}
let dark = appearance.color_scheme == @proton.ColorScheme::Dark
let high_contrast = appearance.high_contrast@proton.html("Theme aware", "<main><h1>Hello</h1></main>")
.on_system_appearance_change(fn(appearance) noraise {
// Apply appearance.color_scheme and appearance.high_contrast to custom UI.
})
.run_or_abort()let accent = @proton.system_accent_color()
let animation = @proton.system_animation_settings()
let microphone = @proton.system_media_access_status(
@proton.MediaAccessKind::Microphone,
)
let trusted = @proton.system_is_trusted_accessibility_client(false)pub(all) suberror AppCleanupError {
CommandExtension(CommandExtensionLifecycleError)
LifecycleHook(LifecycleHookError)
WindowDestroy(status~ : Int, detail~ : String)
RuntimeDestroy(status~ : Int, detail~ : String)
} derive(Debug)pub(all) suberror AppConfigurationError {
InvalidSetting(name~ : String, message~ : String)
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)
InvalidEntryUrl(url~ : String, reason~ : String)
InvalidRendererCapability(detail~ : String)
} derive(Debug)pub(all) suberror AppEntryError {
ReadFailed(path~ : String, detail~ : String)
PlatformLoad(action~ : String, status~ : Int, detail~ : String)
ClosedDuringStartup
} derive(Debug)pub(all) suberror AppPathError {
MissingApplicationIdentifier
InvalidIdentifier(identifier~ : String)
MissingHomeDirectory(platform~ : String)
MissingEnvironmentPath(name~ : String, platform~ : String)
MissingExecutablePath
UnsupportedPath(kind~ : String, platform~ : String)
InvalidPathOverride(kind~ : String, path~ : String, reason~ : String)
SystemPath(kind~ : String, status~ : Int, detail~ : String)
PlatformProbe(status~ : Int, detail~ : String)
} derive(Eq, Debug)pub(all) suberror AppRunError {
EventLoopError(String)
ConfigurationError(AppConfigurationError)
LoggingInitializationFailed(detail~ : String)
UnsupportedNativeFeature(feature~ : String)
RuntimeOperationFailed(action~ : String, status~ : Int, detail~ : String)
CommandExtensionLifecycleError(CommandExtensionLifecycleError)
LifecycleHookError(LifecycleHookError)
EntryLoadError(AppEntryError)
BridgeStartupError(BridgeDiagnostic)
BridgeRuntimeError(BridgeDiagnostic)
CleanupFailed(primary~ : String?, failures~ : Array[AppCleanupError])
UnexpectedTaskFailure(detail~ : String)
} derive(Debug)pub(all) suberror CommandExtensionLifecycleError {
ApplicationRegistrationFailed(detail~ : String)
RegistrationFailed(extension_id~ : String, detail~ : String)
EventSourceStartFailed(extension_id~ : String, detail~ : String)
DestroyFailed(extension_id~ : String, detail~ : String)
} derive(Debug)fn CommandExtensionLifecycleError::output(self : CommandExtensionLifecycleError, logger : &Logger) -> Unitpub(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)fn NotificationDeliveryError::not_equal(x : NotificationDeliveryError, y : NotificationDeliveryError) -> Boolpub(all) suberror SystemAppearanceError {
SystemAppearanceUnavailable(status~ : Int, detail~ : String)
}fn SystemPreferencesError::not_equal(x : SystemPreferencesError, y : SystemPreferencesError) -> Boolpub(all) suberror WindowSessionError {
UnknownWindow(id~ : String)
AlreadyOpen(id~ : String)
ApplicationQuitting
StaleWindow(id~ : String)
UnknownView(id~ : String)
AlreadyExists(id~ : String)
StaleView(id~ : String)
Cancelled
OperationFailed(action~ : String, status~ : Int, detail~ : String)
StartupFailed(id~ : String, error~ : AppRunError)
} derive(Debug)type Appfn App::add_window(self : App, id : String, title : String, entry : AppEntry, width? : Int, height? : Int, size_hint? : WindowSizeHint, titlebar_style? : TitlebarStyle, theme? : WindowThemePreference, traffic_light_position? : WindowButtonPosition, open_on_start? : Bool) -> Appfn[State] App::app_lifecycle(self : App, on_start~ : async (ApplicationContext) -> State, on_shutdown~ : async (State) -> Unit) -> Appfn App::capability(self : App, capability : RendererCapability, targets? : Array[RendererTarget]) -> Appfn App::commands(self : App, register : (CommandRegistrar) -> Unit raise, targets? : Array[RendererTarget]) -> Appfn App::on_before_quit(self : App, handler : async (ApplicationContext) -> ApplicationQuitDecision noraise) -> Appfn App::on_browser_event(self : App, handler : async (BrowserHandle, BrowserEvent) -> Unit noraise) -> Appfn App::on_certificate_error(self : App, handler : async (BrowserHandle, CertificateError) -> BrowserPermissionDecision noraise) -> Appfn App::on_download_event(self : App, handler : async (BrowserHandle, DownloadEvent) -> Unit noraise) -> Appfn App::on_download_request(self : App, handler : async (BrowserHandle, DownloadRequest) -> DownloadDecision noraise) -> Appfn App::on_launch_input(self : App, handler : async (ApplicationContext, RuntimeLaunchInput) -> Unit noraise) -> Appfn App::on_media_permission_request(self : App, handler : async (BrowserHandle, MediaPermissionRequest) -> BrowserPermissionDecision noraise) -> Appfn App::on_navigation_request(self : App, handler : async (BrowserHandle, NavigationRequest) -> NavigationDecision noraise) -> Appfn App::on_new_window_request(self : App, handler : async (BrowserHandle, NewWindowRequest) -> NewWindowDecision noraise) -> Appfn App::on_permission_request(self : App, handler : async (BrowserHandle, PermissionRequest) -> BrowserPermissionDecision noraise) -> Appfn App::on_render_process_gone(self : App, handler : async (WebContentsHandle, RenderProcessGoneDetails) -> Unit noraise) -> Appfn App::on_system_appearance_change(self : App, handler : async (SystemAppearance) -> Unit noraise) -> Appfn App::on_thumbar_button_click(self : App, handler : async (WindowHandle, String) -> Unit noraise) -> Appfn App::on_web_contents_created(self : App, handler : async (WebContentsHandle) -> Unit noraise) -> Appfn App::on_will_quit(self : App, handler : async (ApplicationContext) -> ApplicationQuitDecision noraise) -> Appfn App::on_window_close_request(self : App, handler : async (WindowHandle) -> WindowCloseDecision noraise) -> Appfn App::on_window_event(self : App, handler : async (WindowHandle, WindowEvent) -> Unit noraise) -> Appfn[State] App::window_lifecycle(self : App, on_ready~ : async (WindowContext) -> State, on_close~ : async (State) -> Unit) -> Apppub(all) struct AppTaskMetric {
task_id : Int64
task_type : AppTaskType
process_cpu_percent : Double
process_memory_bytes : Int64
name : String
} derive(Eq, Debug)pub struct ApplicationContext {
tasks : TaskGroup[Unit]
windows : WindowManager
locale_preferences : LocalePreferences
request_quit : (Int) -> Unit
request_exit : (Int) -> Unit
has_single_instance_lock : () -> Bool
release_single_instance_lock : () -> Unit raise AppControlError
application_identifier : String
application_executable : String
application_arguments : Array[String]
url_schemes : Array[String]
// private fields
}fn ApplicationContext::focus(self : ApplicationContext, steal? : Bool) -> Unit raise AppControlErrorfn ApplicationContext::is_default_protocol_client(self : ApplicationContext, scheme : String, executable? : String, arguments? : Array[String]) -> Bool raise AppControlErrorfn ApplicationContext::relaunch(self : ApplicationContext, options? : RelaunchOptions) -> Unit raise AppControlErrorfn ApplicationContext::release_single_instance_lock(self : ApplicationContext) -> Unit raise AppControlErrorfn ApplicationContext::remove_default_protocol_client(self : ApplicationContext, scheme : String, executable? : String, arguments? : Array[String]) -> Bool raise AppControlErrorfn ApplicationContext::set_as_default_protocol_client(self : ApplicationContext, scheme : String, executable? : String, arguments? : Array[String]) -> Bool raise AppControlErrorfn ApplicationContext::task_metrics(self : ApplicationContext) -> Array[AppTaskMetric] raise AppControlErrorfn ApplicationQuitDecision::not_equal(x : ApplicationQuitDecision, y : ApplicationQuitDecision) -> Boolpub(all) enum BrowserEvent {
BridgeFailed(diagnostic~ : BridgeDiagnostic)
LoadingChanged(is_loading~ : Bool)
DidStartLoading
DidFinishLoad
Navigated(url~ : String)
TitleUpdated(title~ : String)
LoadFailed(url~ : String, error_code~ : Int, error_text~ : String)
FoundInPage(result~ : FindInPageResult)
PdfPrinted(result~ : PdfPrintResult)
ResourceResponse(url~ : String, status_code~ : Int)
ResourceCompleted(url~ : String, status~ : Int, received_bytes~ : Int64)
ResourceRequested(url~ : String, request_method~ : String, will_cancel~ : Bool)
RendererProcessTerminated(url~ : String, status~ : Int, error_code~ : Int, detail~ : String)
} derive(Eq, Debug)pub struct BrowserHandle {
id : String
native_id : Int64
load_browser_url : (String) -> Unit raise WindowSessionError
load_browser_html : (String, String) -> Unit raise WindowSessionError
eval_browser_script : (String) -> Unit raise WindowSessionError
focus_browser : () -> Unit raise WindowSessionError
send_browser_command : (String, Int?) -> Unit raise WindowSessionError
download_browser_url : (String) -> Unit raise WindowSessionError
print_browser : () -> Unit raise WindowSessionError
print_browser_to_pdf : (String, PdfPrintOptions) -> Int raise WindowSessionError
find_browser_in_page : (String, Bool, Bool, Bool) -> Int raise WindowSessionError
stop_browser_find : (Bool) -> Unit raise WindowSessionError
set_browser_zoom_percent : (Int) -> Unit raise WindowSessionError
read_browser_zoom_percent : () -> Int raise WindowSessionError
set_browser_audio_muted : (Bool) -> Unit raise WindowSessionError
read_browser_audio_muted : () -> Bool raise WindowSessionError
read_browser_navigation_state : () -> (Bool, Bool) raise WindowSessionError
read_browser_focused : () -> Bool raise WindowSessionError
read_browser_devtools_opened : () -> Bool raise WindowSessionError
read_browser_state : () -> BrowserState raise WindowSessionError
read_browser_navigation_history : () -> NavigationHistory raise WindowSessionError
insert_browser_page_css : (String) -> Int64 raise WindowSessionError
remove_browser_page_css : (Int64) -> Unit raise WindowSessionError
session_handle : SessionHandle
}fn BrowserHandle::cancel_download(self : BrowserHandle, download_id : Int) -> Unit raise WindowSessionErrorfn BrowserHandle::find_in_page(self : BrowserHandle, text : String, forward? : Bool, match_case? : Bool, find_next? : Bool) -> Int raise WindowSessionErrorfn BrowserHandle::load_html(self : BrowserHandle, html : String, base_url : String) -> Unit raise WindowSessionErrorfn BrowserHandle::navigation_history(self : BrowserHandle) -> NavigationHistory raise WindowSessionErrorfn BrowserHandle::print_to_pdf(self : BrowserHandle, path : String, options? : PdfPrintOptions) -> Int raise WindowSessionErrorfn BrowserHandle::reload(self : BrowserHandle, ignore_cache? : Bool) -> Unit raise WindowSessionErrorfn BrowserHandle::remove_inserted_css(self : BrowserHandle, key : Int64) -> Unit raise WindowSessionErrorfn BrowserHandle::set_audio_muted(self : BrowserHandle, muted : Bool) -> Unit raise WindowSessionErrorfn BrowserHandle::set_zoom_percent(self : BrowserHandle, zoom_percent : Int) -> Unit raise WindowSessionErrorfn BrowserHandle::stop_find_in_page(self : BrowserHandle, clear_selection? : Bool) -> Unit raise WindowSessionErrorfn BrowserPermissionDecision::not_equal(x : BrowserPermissionDecision, y : BrowserPermissionDecision) -> Boolpub(all) struct Cookie {
name : String
value : String
domain : String
path : String
secure : Bool
http_only : Bool
same_site : CookieSameSite
expiration_date : Double?
} derive(Eq, Debug)pub(all) struct JumpListCategory {
kind : JumpListCategoryKind
name : String
items : Array[JumpListItem]
}pub(all) struct JumpListItem {
kind : JumpListItemKind
path : String
arguments : String
title : String
description : String
icon_path : String
icon_index : Int
working_directory : String
}fn LastWindowClosedPolicy::not_equal(x : LastWindowClosedPolicy, y : LastWindowClosedPolicy) -> Boolfn MediaPermissionRequest::not_equal(x : MediaPermissionRequest, y : MediaPermissionRequest) -> Boolfn Menu::popup(self : Menu, window : WindowHandle, x : Int, y : Int) -> Unit raise WindowSessionErrorpub struct MenuItem {
kind : Int
id : String?
label : String?
key : String?
role : MenuItemRole?
submenu : Menu?
enabled : Bool
visible : Bool
checked : Bool?
}fn NativeImage::add_bitmap(self : NativeImage, data : Bytes, width : Int, height : Int, scale_factor? : Double) -> Unit raise NativeImageErrorfn NativeImage::add_jpeg(self : NativeImage, data : Bytes, scale_factor? : Double) -> Unit raise NativeImageErrorfn NativeImage::add_png(self : NativeImage, data : Bytes, scale_factor? : Double) -> Unit raise NativeImageErrorfn NativeImage::to_bitmap(self : NativeImage, scale_factor? : Double) -> (Bytes, Int, Int) raise NativeImageErrorfn NativeImage::to_jpeg(self : NativeImage, scale_factor? : Double, quality? : Int) -> (Bytes, Int, Int) raise NativeImageErrorfn NativeImage::to_png(self : NativeImage, scale_factor? : Double, with_transparency? : Bool) -> (Bytes, Int, Int) raise NativeImageErrorpub(all) struct NavigationEntry {
url : String
display_url : String
original_url : String
title : String
transition : NavigationTransition
transition_qualifiers : Array[NavigationTransitionQualifier]
has_post_data : Bool
http_status_code : Int
} derive(Eq, Debug)pub(all) struct NavigationHistory {
entries : Array[NavigationEntry]
active_index : Int
} derive(Eq, Debug)fn NavigationTransitionQualifier::equal(NavigationTransitionQualifier, NavigationTransitionQualifier) -> Boolfn NavigationTransitionQualifier::not_equal(x : NavigationTransitionQualifier, y : NavigationTransitionQualifier) -> Boolpub(all) struct PdfPrintOptions {
landscape : Bool
print_background : Bool
scale : Double
paper_width : Double
paper_height : Double
prefer_css_page_size : Bool
margins : PdfPrintMargins
page_ranges : String
display_header_footer : Bool
header_template : String
footer_template : String
generate_tagged_pdf : Bool
generate_document_outline : Bool
} derive(Eq, Debug)fn PdfPrintOptions::PdfPrintOptions(landscape? : Bool, print_background? : Bool, scale? : Double, paper_width? : Double, paper_height? : Double, prefer_css_page_size? : Bool, margins? : PdfPrintMargins, page_ranges? : String, display_header_footer? : Bool, header_template? : String, footer_template? : String, generate_tagged_pdf? : Bool, generate_document_outline? : Bool) -> PdfPrintOptionspub struct PendingUpdate {
version : String
revision : UInt64
notes_url : String?
size : Int64
channel : UpdateChannel
offer : AvailableUpdate
}async fn PendingUpdate::install(self : PendingUpdate, on_progress? : async (Int64) -> Unit noraise) -> UpdateInstallOutcomepub(all) enum PermissionRequest {
Certificate(CertificateError)
Media(MediaPermissionRequest)
} derive(Eq, Debug)fn RelaunchOptions::RelaunchOptions(executable? : String, arguments? : Array[String]) -> RelaunchOptionspub(all) struct RenderProcessGoneDetails {
reason : RenderProcessGoneReason
exit_code : Int
} derive(Eq, Debug)fn RenderProcessGoneDetails::not_equal(x : RenderProcessGoneDetails, y : RenderProcessGoneDetails) -> Boolfn RenderProcessGoneReason::not_equal(x : RenderProcessGoneReason, y : RenderProcessGoneReason) -> Boolpub struct RendererTarget {
window : String
bundled : Bool
}pub struct SessionHandle {
id : String
native_id : Int64
read_cookies : async (String?, Bool) -> Array[Cookie]
write_cookie : (String, String, String, String?, String?, Bool, Bool, CookieSameSite) -> Unit raise WindowSessionError
remove_cookies : (String?, String?) -> Unit raise WindowSessionError
flush_cookie_store : () -> Unit raise WindowSessionError
clear_http_cache : () -> Unit raise WindowSessionError
clear_http_auth_cache : () -> Unit raise WindowSessionError
clear_certificate_exceptions : () -> Unit raise WindowSessionError
close_all_connections : () -> Unit raise WindowSessionError
clear_storage_data : (StorageDataKind) -> Unit raise WindowSessionError
}fn SessionHandle::clear_certificate_exceptions(self : SessionHandle) -> Unit raise WindowSessionErrorfn SessionHandle::clear_storage_data(self : SessionHandle, kind : StorageDataKind) -> Unit raise WindowSessionErrorfn SessionHandle::delete_cookies(self : SessionHandle, url? : String, name? : String) -> Unit raise WindowSessionErrorasync fn SessionHandle::get_cookies(self : SessionHandle, url? : String, include_http_only? : Bool) -> Array[Cookie]fn SessionHandle::set_cookie(self : SessionHandle, url : String, name : String, value : String, domain? : String, path? : String, secure? : Bool, http_only? : Bool, same_site? : CookieSameSite) -> Unit raise WindowSessionErrorpub(all) struct SystemAppearance {
color_scheme : ColorScheme
high_contrast : Bool
} derive(Eq, Debug)pub(all) struct ThumbarButton {
id : String
icon : NativeImage
tooltip : String
flags : Array[ThumbarButtonFlag]
}pub struct ViewConfig {
x : Int
y : Int
width : Int
height : Int
visible : Bool
z_order : Int
initial_url : String
background_color : String?
}fn ViewConfig::ViewConfig(width~ : Int, height~ : Int, x? : Int, y? : Int, visible? : Bool, z_order? : Int, initial_url? : String, background_color? : String) -> ViewConfigpub(all) enum ViewEvent {
LoadingChanged(is_loading~ : Bool)
DidStartLoading
DidFinishLoad
Navigated(url~ : String)
TitleUpdated(title~ : String)
LoadFailed(url~ : String, error_code~ : Int, error_text~ : String)
RendererProcessTerminated(url~ : String, status~ : Int, error_code~ : Int, detail~ : String)
FoundInPage(result~ : FindInPageResult)
Closed
} derive(Eq, Debug)pub struct ViewHandle {
id : String
native_id : Int64
window_id : String
set_view_bounds : (Int, Int, Int, Int) -> Unit raise WindowSessionError
set_view_visible : (Bool) -> Unit raise WindowSessionError
set_view_z_order : (Int) -> Unit raise WindowSessionError
set_view_zoom_percent : (Int) -> Unit raise WindowSessionError
read_view_zoom_percent : () -> Int raise WindowSessionError
set_view_audio_muted : (Bool) -> Unit raise WindowSessionError
read_view_audio_muted : () -> Bool raise WindowSessionError
load_view_url : (String) -> Unit raise WindowSessionError
load_view_html : (String, String) -> Unit raise WindowSessionError
eval_view_script : (String) -> Unit raise WindowSessionError
focus_view : () -> Unit raise WindowSessionError
send_view_command : (String, Int?) -> Unit raise WindowSessionError
find_view_in_page : (String, Bool, Bool, Bool) -> Int raise WindowSessionError
stop_view_find : (Bool) -> Unit raise WindowSessionError
read_view_navigation_state : () -> (Bool, Bool) raise WindowSessionError
read_view_focused : () -> Bool raise WindowSessionError
read_view_devtools_opened : () -> Bool raise WindowSessionError
read_view_state : () -> ViewState raise WindowSessionError
read_view_navigation_history : () -> NavigationHistory raise WindowSessionError
insert_view_page_css : (String) -> Int64 raise WindowSessionError
remove_view_page_css : (Int64) -> Unit raise WindowSessionError
close_view : () -> Unit raise WindowSessionError
}fn ViewHandle::find_in_page(self : ViewHandle, text : String, forward? : Bool, match_case? : Bool, find_next? : Bool) -> Int raise WindowSessionErrorfn ViewHandle::load_html(self : ViewHandle, html : String, base_url : String) -> Unit raise WindowSessionErrorfn ViewHandle::set_bounds(self : ViewHandle, x~ : Int, y~ : Int, width~ : Int, height~ : Int) -> Unit raise WindowSessionErrorfn ViewHandle::set_zoom_percent(self : ViewHandle, zoom_percent : Int) -> Unit raise WindowSessionErrorfn ViewHandle::stop_find_in_page(self : ViewHandle, clear_selection? : Bool) -> Unit raise WindowSessionErrorpub struct WindowContext {
id : String
handle : WindowHandle
windows : WindowManager
tasks : TaskGroup[Unit]
events : WindowEventEmitter
locale_preferences : LocalePreferences
}pub(all) enum WindowEvent {
StateChanged(WindowState)
Closed
ReadyToShow
Moved
Resized
Show
Hide
Focus
Blur
Minimize
Restore
Maximize
Unmaximize
EnterFullScreen
LeaveFullScreen
} derive(Eq, Debug)async fn[Payload : ToJson] WindowEventEmitter::emit(self : WindowEventEmitter, event : Event[Payload], payload : Payload) -> Unitpub struct WindowHandle {
id : String
native_id : Int64
show_window : () -> Unit raise WindowSessionError
show_window_inactive : () -> Unit raise WindowSessionError
hide_window : () -> Unit raise WindowSessionError
close_window : () -> Unit raise WindowSessionError
focus_window : () -> Unit raise WindowSessionError
set_window_title : (String) -> Unit raise WindowSessionError
set_window_icon : (String) -> Unit raise WindowSessionError
set_window_parent : (WindowHandle?, Bool) -> Unit raise WindowSessionError
set_window_size : (Int, Int) -> Unit raise WindowSessionError
set_window_content_size : (Int, Int) -> Unit raise WindowSessionError
read_window_content_size : () -> (Int, Int) raise WindowSessionError
minimize_window : () -> Unit raise WindowSessionError
maximize_window : () -> Unit raise WindowSessionError
restore_window : () -> Unit raise WindowSessionError
set_window_fullscreen : (Bool) -> Unit raise WindowSessionError
set_window_kiosk : (Bool) -> Unit raise WindowSessionError
set_window_position : (Int, Int) -> Unit raise WindowSessionError
set_window_always_on_top : (Bool) -> Unit raise WindowSessionError
set_window_resizable : (Bool) -> Unit raise WindowSessionError
set_window_minimum_size : (Int, Int) -> Unit raise WindowSessionError
set_window_maximum_size : (Int, Int) -> Unit raise WindowSessionError
set_window_aspect_ratio : (Double) -> Unit raise WindowSessionError
set_window_movable : (Bool) -> Unit raise WindowSessionError
set_window_opacity : (Double) -> Unit raise WindowSessionError
set_window_skip_taskbar : (Bool) -> Unit raise WindowSessionError
set_window_content_protection : (Bool) -> Unit raise WindowSessionError
set_window_minimizable : (Bool) -> Unit raise WindowSessionError
set_window_maximizable : (Bool) -> Unit raise WindowSessionError
set_window_closable : (Bool) -> Unit raise WindowSessionError
set_window_button_visibility : (Bool) -> Unit raise WindowSessionError
write_window_button_position : (WindowButtonPosition?) -> Unit raise WindowSessionError
read_window_button_position : () -> WindowButtonPosition? raise WindowSessionError
set_window_focusable : (Bool) -> Unit raise WindowSessionError
set_window_fullscreenable : (Bool) -> Unit raise WindowSessionError
set_window_has_shadow : (Bool) -> Unit raise WindowSessionError
set_window_ignore_mouse_events : (Bool, Bool) -> Unit raise WindowSessionError
set_window_background_color : (String) -> Unit raise WindowSessionError
set_window_theme : (WindowThemePreference) -> Unit raise WindowSessionError
set_window_visible_on_all_workspaces : (Bool) -> Unit raise WindowSessionError
set_window_enabled : (Bool) -> Unit raise WindowSessionError
set_window_menu : (MenuBar?) -> Unit raise WindowSessionError
set_window_zoom_percent : (Int) -> Unit raise WindowSessionError
set_window_progress_bar : (Double, ProgressBarMode) -> Unit raise WindowSessionError
set_window_overlay_icon : (NativeImage?, String) -> Unit raise WindowSessionError
set_window_thumbnail_tooltip : (String) -> Unit raise WindowSessionError
set_window_thumbar_buttons : (Array[ThumbarButton]) -> Bool raise WindowSessionError
flash_window_frame : (Bool) -> Unit raise WindowSessionError
popup_window_menu : (Menu, Int, Int) -> Unit raise WindowSessionError
read_window_state : () -> WindowState raise WindowSessionError
browser : BrowserHandle
add_view : (String, ViewConfig) -> ViewHandle raise WindowSessionError
remove_view : (String) -> Unit raise WindowSessionError
list_views : () -> Array[ViewHandle]
find_view : (String) -> ViewHandle?
}fn WindowHandle::add_view(self : WindowHandle, id : String, config : ViewConfig) -> ViewHandle raise WindowSessionErrorfn WindowHandle::set_always_on_top(self : WindowHandle, always_on_top : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_aspect_ratio(self : WindowHandle, aspect_ratio : Double) -> Unit raise WindowSessionErrorfn WindowHandle::set_background_color(self : WindowHandle, color : String) -> Unit raise WindowSessionErrorfn WindowHandle::set_bounds(self : WindowHandle, x~ : Int, y~ : Int, width~ : Int, height~ : Int) -> Unit raise WindowSessionErrorfn WindowHandle::set_closable(self : WindowHandle, closable : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_content_protection(self : WindowHandle, enabled : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_content_size(self : WindowHandle, width : Int, height : Int) -> Unit raise WindowSessionErrorfn WindowHandle::set_focusable(self : WindowHandle, focusable : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_fullscreen(self : WindowHandle, fullscreen : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_fullscreenable(self : WindowHandle, fullscreenable : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_has_shadow(self : WindowHandle, has_shadow : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_ignore_mouse_events(self : WindowHandle, ignore : Bool, forward : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_maximizable(self : WindowHandle, maximizable : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_maximum_size(self : WindowHandle, width : Int, height : Int) -> Unit raise WindowSessionErrorfn WindowHandle::set_minimizable(self : WindowHandle, minimizable : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_minimum_size(self : WindowHandle, width : Int, height : Int) -> Unit raise WindowSessionErrorfn WindowHandle::set_opacity(self : WindowHandle, opacity : Double) -> Unit raise WindowSessionErrorfn WindowHandle::set_overlay_icon(self : WindowHandle, overlay : NativeImage?, description : String) -> Unit raise WindowSessionErrorfn WindowHandle::set_parent(self : WindowHandle, parent : WindowHandle?, modal? : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_position(self : WindowHandle, x : Int, y : Int) -> Unit raise WindowSessionErrorfn WindowHandle::set_progress_bar(self : WindowHandle, progress : Double, mode? : ProgressBarMode) -> Unit raise WindowSessionErrorfn WindowHandle::set_resizable(self : WindowHandle, resizable : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_size(self : WindowHandle, width : Int, height : Int) -> Unit raise WindowSessionErrorfn WindowHandle::set_skip_taskbar(self : WindowHandle, skip : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_theme(self : WindowHandle, theme : WindowThemePreference) -> Unit raise WindowSessionErrorfn WindowHandle::set_thumbar_buttons(self : WindowHandle, buttons : Array[ThumbarButton]) -> Bool raise WindowSessionErrorfn WindowHandle::set_thumbnail_tooltip(self : WindowHandle, tooltip : String) -> Unit raise WindowSessionErrorfn WindowHandle::set_visible_on_all_workspaces(self : WindowHandle, visible : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_window_button_position(self : WindowHandle, position : WindowButtonPosition?) -> Unit raise WindowSessionErrorfn WindowHandle::set_window_button_visibility(self : WindowHandle, visible : Bool) -> Unit raise WindowSessionErrorfn WindowHandle::set_zoom_percent(self : WindowHandle, zoom_percent : Int) -> Unit raise WindowSessionErrorfn WindowHandle::window_button_position(self : WindowHandle) -> WindowButtonPosition? raise WindowSessionErrorpub struct WindowManager {
open_window : async (String) -> WindowHandle
find_window : (String) -> WindowHandle?
}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 : WindowTheme
} derive(Eq, Debug)fn app_path() -> Stringfn asset(title : String, path : String, width? : Int, height? : Int, debug? : Bool, resizable? : Bool) -> Appfn file(title : String, path : String, width? : Int, height? : Int, debug? : Bool, resizable? : Bool) -> Appfn html(title : String, html : String, width? : Int, height? : Int, debug? : Bool, resizable? : Bool) -> Appfn is_packaged() -> Boolfn is_ready() -> Boolfn resource_dir() -> Stringfn system_media_access_status(kind : MediaAccessKind) -> MediaAccessStatus raise SystemPreferencesErrorfn url(title : String, url : String, width? : Int, height? : Int, debug? : Bool, resizable? : Bool) -> Appfn view(url : String, width~ : Int, height~ : Int, x? : Int, y? : Int, visible? : Bool, z_order? : Int, background_color? : String) -> ViewConfigInstall
Download zipMoonBit bindings for the Proton native desktop runtime.
Dependencies