desktop module
Guides: Architecture · Platform APIs. Available as @import("desktop") in desktop scaffolds.
Window
| Export | Signature |
|---|---|
Window.init | (allocator, WindowOptions) !Window |
WindowOptions | { title, width = 1024, height = 768, devtools = false, scheme = "verve", initial_path = "index.html", assets: []const AssetEntry, dev_assets: ?DevAssetsConfig, install_default_menu = true, on_message/on_url_open/on_drag_drop/on_resize/on_focus/on_close (+ctx ptrs) } |
| Methods | run deinit setTitle loadUrl loadHtml evalJs setMessageHandler openChildWindow cookies() clipboard() print printWithOptions snapshot deliverUrl setColorSchemeHandler setUrlOpenHandler |
Handlers: MessageHandler (ctx, payload) · UrlOpenHandler · DragDropHandler (paths) · ResizeHandler (w, h) · FocusHandler
(bool) · CloseHandler → bool (return true to allow close).
IPC
Router(Ctx, Routes) — comptime route table; each pub const route =
struct { Args, Reply, handle(ctx, alloc, args) !Reply }. JS: window.verve.request({type, …}) / .send(json) / .onMessage(fn).
Assets
AssetEntry{ path, bytes, content_type } · asset_router.resolve(entries, path) · resolveWithFallback(alloc, io, entries, path, dev_dir) — dev disk overrides embedded; path traversal rejected.
Capability modules
| Module | Key API | Platform notes |
|---|---|---|
tray | init(alloc, window, TrayOptions) !Tray; setTooltip/setIcon/setMenu, click + menu handlers | Linux needs libayatana-appindicator3; GTK4 unsupported |
notifications | show(alloc, .{ .title, .body }) | macOS needs signed bundle |
hotkeys | init(alloc, cb, ctx) !Manager; register(id, Modifiers, keycode) | Wayland unsupported; Linux fires off worker thread |
deep_link | forwardToRunningInstance startListener registerScheme | macOS warm-launch is system-handled |
single_instance | acquire(alloc, name) !Lock (error.AlreadyRunning) | flock / CreateMutexW |
clipboard | via window.clipboard(): text/HTML/PNG read+write | Linux text-only |
cookies | via window.cookies(): get/set/delete/clear with Cookie{ same_site, http_only, … } | |
fswatch | init(alloc, path, cb, ctx) !Watcher | macOS recursive ~1s batches; Windows recursive worker-thread; Linux non-recursive |
autostart | enable/disable/isEnabled(alloc, io, environ, …) | LaunchAgents / HKCU Run / .desktop |
updates | checkForUpdate(alloc, feed_url, version) !?UpdateInfo; applyUpdate (sha256-verified) | Linux unsupported |
power | batteryPercent() ?u32 isCharging() bool | |
displays | list(alloc) ![]Display{ x, y, width, height, scale, primary } |
Dialogs & output
FileDialogOptions (open/save/multi/directory), AlertOptions{ buttons, style: informational|warning|critical }, PrintOptions{ kind: default|browser|system, copies, pages, printer_name }, window snapshot (GTK4 unsupported).
All modules use explicit error sets with error.Unsupported where a platform can't deliver — no silent fallbacks.