platform

package
v0.0.0-...-76cebe8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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
	MenuItemSubmenu      = caps.MenuItemSubmenu
)

Variables

This section is empty.

Functions

func Probe

func Probe() probe.Info

Probe reports the state of the system webview and display on this machine without opening a window.

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).

func New

func New(opts Options) (App, error)

New creates the WebKitGTK application. Call it from the main goroutine.

type AppPresence

type AppPresence = caps.AppPresence

type Axis

type Axis = caps.Axis

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 Clipboard

type Clipboard = caps.Clipboard

type Dialogs

type Dialogs = caps.Dialogs

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 JumpTask

type JumpTask = caps.JumpTask

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.

func (Memory) Backend

func (m Memory) Backend() (string, map[string]bool)

Backend returns the profile name and feature map in the form the macOS and Windows backends take. An empty profile means "performance" (no levers), and the map is never nil, so a feature is switched off only when Features says so.

type MenuEvent = caps.MenuEvent
type MenuItem = caps.MenuItem
type MenuKind = caps.MenuKind
type Menus = caps.Menus

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 Notifier

type Notifier = caps.Notifier

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 Point

type Point = caps.Point

type Privacy

type Privacy = caps.Privacy

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 Sharer

type Sharer = caps.Sharer

type Shortcuts

type Shortcuts = caps.Shortcuts

type ThumbButton

type ThumbButton = caps.ThumbButton

type TitleBarOverlay

type TitleBarOverlay = caps.TitleBarOverlay

type Tray

type Tray = caps.Tray

type TrayEvent

type TrayEvent = caps.TrayEvent

type TrayIcon

type TrayIcon = caps.TrayIcon

type ViewEvent

type ViewEvent = caps.ViewEvent

type ViewEvents

type ViewEvents = caps.ViewEvents

type ViewInfo

type ViewInfo = caps.ViewInfo

type ViewLookup

type ViewLookup = caps.ViewLookup

type ViewOptions

type ViewOptions = caps.ViewOptions

type ViewRef

type ViewRef = caps.ViewRef

type Window

type Window interface {
	// Navigate loads path on the app origin.
	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 WindowRef

type WindowRef = caps.WindowRef

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL