Documentation
¶
Overview ¶
Package platform is the thin, cgo-free window and webview layer: WebKitGTK on Linux (purego), WKWebView on macOS (purego objc) and WebView2 on Windows (COM over syscall).
Every method on App and Window may be called from any goroutine; the implementation marshals the call onto the platform's main thread.
Index ¶
- Constants
- func Probe() probe.Info
- type Accelerator
- type App
- type AppPresence
- type Axis
- type CaptureChooser
- type CaptureSource
- type CaptureSources
- type ChromeEvent
- type ChromeEvents
- type ChromeOptions
- type ChromeState
- type Clipboard
- type Dialogs
- type Features
- type FileDialogMode
- type FileDialogOptions
- type FileFilter
- type JumpLister
- type JumpTask
- type LayoutNode
- type Memory
- type MenuEvent
- type MenuItem
- type MenuKind
- type Menus
- type MessageDialogOptions
- type MessageKind
- type Notification
- type NotificationAction
- type NotificationCloser
- type Notifier
- type NotifyEvent
- type Options
- type PermissionHandler
- type PermissionKind
- type PermissionRequest
- type PermissionRequests
- type Point
- type Privacy
- type PrivacyStatus
- type ProcessInfo
- type ProcessRef
- type ShareItems
- type Sharer
- type Shortcuts
- type ThumbButton
- type TitleBarOverlay
- type Tray
- type TrayEvent
- type TrayIcon
- type ViewEvent
- type ViewEvents
- type ViewInfo
- type ViewLookup
- type ViewOptions
- type ViewRef
- type Window
- type WindowChrome
- type WindowControls
- type WindowDocument
- type WindowEvent
- type WindowEventKind
- type WindowEvents
- type WindowOptions
- type WindowRef
- type WindowSheets
- type WindowState
- type WindowTabs
- type WindowThumbBar
- type WindowViews
- type XEmbedTray
Constants ¶
const ( Horizontal = caps.Horizontal Vertical = caps.Vertical WindowCloseRequested = caps.WindowCloseRequested WindowClosed = caps.WindowClosed WindowFocused = caps.WindowFocused WindowBlurred = caps.WindowBlurred WindowReleased = caps.WindowReleased WindowRestored = caps.WindowRestored OpenFile = caps.OpenFile SaveFile = caps.SaveFile OpenFolder = caps.OpenFolder MessageInfo = caps.MessageInfo MessageWarning = caps.MessageWarning MessageError = caps.MessageError MessageQuestion = caps.MessageQuestion MenuItemNormal = caps.MenuItemNormal MenuItemCheck = caps.MenuItemCheck MenuItemRadio = caps.MenuItemRadio MenuItemSeparator = caps.MenuItemSeparator )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Accelerator ¶
type Accelerator = caps.Accelerator
type App ¶
type App interface {
// Run starts the platform event loop and blocks until Quit. onReady runs
// on the main thread once the loop is running.
Run(onReady func()) error
// Dispatch runs fn on the main thread and returns without waiting.
Dispatch(fn func())
// NewWindow opens a window on the app origin.
NewWindow(opts WindowOptions) (Window, error)
// Origin is the app origin, "krate://app" or "https://app.localhost".
Origin() string
// Quit stops the event loop; Run returns.
Quit()
}
App is the running application. New must be called on the main goroutine (the one that runs main, locked with runtime.LockOSThread in an init).
type AppPresence ¶
type AppPresence = caps.AppPresence
type CaptureChooser ¶
type CaptureChooser = caps.CaptureChooser
type CaptureSource ¶
type CaptureSource = caps.CaptureSource
type CaptureSources ¶
type CaptureSources = caps.CaptureSources
type ChromeEvent ¶
type ChromeEvent = caps.ChromeEvent
type ChromeEvents ¶
type ChromeEvents = caps.ChromeEvents
type ChromeOptions ¶
type ChromeOptions = caps.ChromeOptions
type ChromeState ¶
type ChromeState = caps.ChromeState
type Features ¶
type Features struct {
Media, WebAudio, WebGL, WebRTC, SpellCheck bool
}
Features are the optional webview features an app uses.
type FileDialogMode ¶
type FileDialogMode = caps.FileDialogMode
type FileDialogOptions ¶
type FileDialogOptions = caps.FileDialogOptions
type FileFilter ¶
type FileFilter = caps.FileFilter
type JumpLister ¶
type JumpLister = caps.JumpLister
type LayoutNode ¶
type LayoutNode = caps.LayoutNode
type Memory ¶
type Memory struct {
// Profile is "balanced", "minimal" or "performance"; empty means
// "performance" (no levers).
Profile string
// Features says which optional engine features the app uses; the
// profiles other than "performance" switch the others off.
Features Features
}
Memory configures the webview's memory use.
type MessageDialogOptions ¶
type MessageDialogOptions = caps.MessageDialogOptions
type MessageKind ¶
type MessageKind = caps.MessageKind
type Notification ¶
type Notification = caps.Notification
type NotificationAction ¶
type NotificationAction = caps.NotificationAction
type NotificationCloser ¶
type NotificationCloser = caps.NotificationCloser
type NotifyEvent ¶
type NotifyEvent = caps.NotifyEvent
type Options ¶
type Options struct {
// AppID is the reverse-DNS application id, e.g. "com.acme.app".
AppID string
// AppName is the display name of the app (the product name). The Windows
// backend shows it on toast notifications. Empty means AppID.
AppName string
// IconPath is an optional PNG or ICO file the Windows backend uses as the
// default toast icon.
IconPath string
// Icon is the app icon as PNG bytes, nil for the default. Windows and
// Linux (X11) show it on every window unless the Windows executable
// carries an icon resource; macOS sets it as the dock icon unless the
// app runs from a bundle with an icon of its own.
Icon []byte
// Handler serves every request on the app origin. Responses must be
// streamed to the webview as they are written (Flush is honored).
Handler http.Handler
// Debug enables the webview's developer tools.
Debug bool
// Memory selects the memory profile of the webview. The zero value is
// the engine defaults.
Memory Memory
// KeepAlive keeps the app running when its last window closes. The last
// live window is then released (hidden, webview destroyed) rather than
// destroyed, and Show brings it back; see caps.WindowRelease.
KeepAlive bool
// Agent makes the app a menu-bar-only agent at launch: no dock icon and
// no application menu (macOS NSApplicationActivationPolicyAccessory,
// like LSUIElement in Info.plist). Other platforms ignore it.
Agent bool
// Remote asks the engine for a remote debugging endpoint (see
// caps.Automation). The shell sets it only in dev runs and for apps
// built with native.debug.
Remote caps.RemoteDebug
// Extensions prepares the engine for browser extensions; WebView2 must
// know when it creates its environment. See caps.Extensions.
Extensions bool
}
Options configures the application.
type PermissionHandler ¶
type PermissionHandler = caps.PermissionHandler
type PermissionKind ¶
type PermissionKind = caps.PermissionKind
type PermissionRequest ¶
type PermissionRequest = caps.PermissionRequest
type PermissionRequests ¶
type PermissionRequests = caps.PermissionRequests
type PrivacyStatus ¶
type PrivacyStatus = caps.PrivacyStatus
type ProcessInfo ¶
type ProcessInfo = caps.ProcessInfo
type ProcessRef ¶
type ProcessRef = caps.ProcessRef
type ShareItems ¶
type ShareItems = caps.ShareItems
type ThumbButton ¶
type ThumbButton = caps.ThumbButton
type TitleBarOverlay ¶
type TitleBarOverlay = caps.TitleBarOverlay
type ViewEvents ¶
type ViewEvents = caps.ViewEvents
type ViewLookup ¶
type ViewLookup = caps.ViewLookup
type ViewOptions ¶
type ViewOptions = caps.ViewOptions
type Window ¶
type Window interface {
Navigate(path string)
// Eval runs JavaScript in the page without waiting for a result.
Eval(js string)
SetTitle(title string)
SetSize(width, height int)
Close()
}
Window is one top-level window with one webview.
type WindowChrome ¶
type WindowChrome = caps.WindowChrome
type WindowControls ¶
type WindowControls = caps.WindowControls
type WindowDocument ¶
type WindowDocument = caps.WindowDocument
type WindowEvent ¶
type WindowEvent = caps.WindowEvent
type WindowEventKind ¶
type WindowEventKind = caps.WindowEventKind
type WindowEvents ¶
type WindowEvents = caps.WindowEvents
type WindowOptions ¶
type WindowOptions struct {
Title string
Width int
Height int
Resizable bool
// Path is the route to open, relative to the app origin ("/" by default).
Path string
// Chrome is the window chrome the window is created with (title bar
// style, transparency, backdrop and so on). The zero value is a native
// window. Platforms apply what they can and ignore the rest.
Chrome ChromeOptions
// Offscreen opens a window that is never shown on screen: its page renders
// and can be captured with caps.ViewSnapshots. Only Apps that implement
// caps.OffscreenWindows honor it; the others open a normal window.
Offscreen bool
}
WindowOptions configures one window.
type WindowSheets ¶
type WindowSheets = caps.WindowSheets
type WindowState ¶
type WindowState = caps.WindowState
type WindowTabs ¶
type WindowTabs = caps.WindowTabs
type WindowThumbBar ¶
type WindowThumbBar = caps.WindowThumbBar
type WindowViews ¶
type WindowViews = caps.WindowViews
type XEmbedTray ¶
type XEmbedTray = caps.XEmbedTray
Directories
¶
| Path | Synopsis |
|---|---|
|
Package caps defines the optional capability interfaces of the platform layer.
|
Package caps defines the optional capability interfaces of the platform layer. |
|
Package darwin implements the macOS window and webview layer with AppKit and WKWebView, reached through purego (no cgo).
|
Package darwin implements the macOS window and webview layer with AppKit and WKWebView, reached through purego (no cgo). |
|
Package linux implements the desktop platform layer on Linux with WebKitGTK, loaded at run time through purego (no cgo).
|
Package linux implements the desktop platform layer on Linux with WebKitGTK, loaded at run time through purego (no cgo). |
|
Package probe holds the result type of the platform webview probe, shared by the per-OS platform packages and krate-shell --doctor.
|
Package probe holds the result type of the platform webview probe, shared by the per-OS platform packages and krate-shell --doctor. |
|
Package windows is the Windows implementation of the Krate desktop platform layer: Win32 windows hosting WebView2 through hand-written COM bindings over syscall, with no cgo and no WebView2Loader.dll requirement.
|
Package windows is the Windows implementation of the Krate desktop platform layer: Win32 windows hosting WebView2 through hand-written COM bindings over syscall, with no cgo and no WebView2Loader.dll requirement. |