Documentation
¶
Index ¶
- Variables
- func AllowURLScheme(scheme string)
- func EmitNFCTag(uid string)
- func GetArchInfo() string
- func GetEnvInfo(key string) string
- func Getenv(key string) string
- func MenuSupported() bool
- func NewEmbedFS(e embed.FS, subDir string) (fs.FS, error)
- func NotificationPermissionGranted() bool
- func Notify(title, body string) error
- func OpenURL(rawURL string) error
- func RegisterBLE(b *Bridge)
- func RegisterBackground(b *Bridge)
- func RegisterBattery(b *Bridge)
- func RegisterBuiltins(b *Bridge)
- func RegisterCamera(b *Bridge)
- func RegisterClipboard(b *Bridge)
- func RegisterDesktopFeatures(b *Bridge)
- func RegisterDialogs(b *Bridge)
- func RegisterFS(b *Bridge)
- func RegisterGeolocation(b *Bridge)
- func RegisterMicrophone(b *Bridge)
- func RegisterNFC(b *Bridge)
- func RegisterPush(b *Bridge)
- func RegisterSampleCommands(b *Bridge)
- func RegisterSensors(b *Bridge)
- func RegisterShare(b *Bridge)
- func RegisterStore(b *Bridge)
- func RegisterUpdater(b *Bridge, cfg UpdaterConfig)
- func RegisterVibration(b *Bridge)
- func RegisterWakeLock(b *Bridge)
- func RequestNotificationPermission() string
- func SetBLEProvider(p BLEProvider)
- func SetBackgroundProvider(p BackgroundProvider)
- func SetBatteryProvider(p BatteryProvider)
- func SetCameraProvider(p CameraProvider)
- func SetClipboardProvider(p ClipboardProvider)
- func SetDialogsProvider(p DialogsProvider)
- func SetMicrophoneProvider(p MicrophoneProvider)
- func SetNFCProvider(p NFCProvider)
- func SetNativeNotifier(n NativeNotifier)
- func SetPushProvider(p PushProvider)
- func SetSensorsProvider(p SensorsProvider)
- func SetShareProvider(p ShareProvider)
- func SetVibrationProvider(p VibrationProvider)
- func SetWakeLockProvider(p WakeLockProvider)
- func TraySupported() bool
- func WindowingSupported() bool
- type App
- func (a *App) Bridge() *Bridge
- func (a *App) CloseWindow(id int) error
- func (a *App) Config() Config
- func (a *App) Emit(event string, data any)
- func (a *App) Invoke(name string, fn InvokeHandler)
- func (a *App) JS() *JSRuntime
- func (a *App) ListWindows() ([]int, error)
- func (a *App) On(event string, fn EventHandler)
- func (a *App) OpenWindow(opts WindowOptions) (int, error)
- func (a *App) Quit()
- func (a *App) Run() error
- func (a *App) SetMenu(menu []MenuItem) error
- func (a *App) SetPolicy(p *Policy)
- func (a *App) StartServer() (int, error)
- func (a *App) Stop()
- type BLEDevice
- type BLEProvider
- type BackgroundProvider
- type BatteryInfo
- type BatteryProvider
- type Bridge
- func (b *Bridge) AddFSRoot(dir string)
- func (b *Bridge) Call(method string, args any) (any, error)
- func (b *Bridge) DispatchEvent(event string, data json.RawMessage)
- func (b *Bridge) Emit(event string, data any)
- func (b *Bridge) GrantFSPath(path string)
- func (b *Bridge) Handle(name string, fn InvokeHandler)
- func (b *Bridge) HandleRequest(req InvokeRequest) InvokeResponse
- func (b *Bridge) HandleRequestContext(ctx context.Context, req InvokeRequest) InvokeResponse
- func (b *Bridge) On(event string, fn EventHandler)
- func (b *Bridge) SetFSAppID(appID string)
- func (b *Bridge) SetFSScope(mode FSScope)
- func (b *Bridge) SetPolicy(p *Policy)
- func (b *Bridge) Subscribe() chan EventMessage
- func (b *Bridge) Unsubscribe(ch chan EventMessage)
- type CameraProvider
- type ClipboardProvider
- type Config
- type DialogsProvider
- type EventHandler
- type EventMessage
- type FSScope
- type FileDialogOptions
- type FileFilter
- type Hub
- type InvokeHandler
- type InvokeRequest
- type InvokeResponse
- type JSRuntime
- func (jsr *JSRuntime) Call(ctx context.Context, name string, args ...any) (any, error)
- func (jsr *JSRuntime) CallJSON(ctx context.Context, name string, out any, args ...any) error
- func (jsr *JSRuntime) Has(ctx context.Context, name string) bool
- func (jsr *JSRuntime) Run() error
- func (jsr *JSRuntime) Stop()
- type MenuItem
- type MenuRole
- type MessageBoxOptions
- type MicrophoneProvider
- type NFCMessage
- type NFCProvider
- type NFCRecord
- type NativeNotifier
- type OSInfo
- type PlatformInfo
- type Policy
- type PromptOptions
- type PushProvider
- type SensorsProvider
- type Server
- type ShareData
- type ShareProvider
- type TrayConfig
- type TrayItem
- type UpdaterConfig
- type VibrationProvider
- type WSClient
- type WakeLockProvider
- type WebviewWindow
- func (win *WebviewWindow) Bind(name string, fn any) error
- func (win *WebviewWindow) Destroy()
- func (win *WebviewWindow) Dispatch(f func())
- func (win *WebviewWindow) Eval(js string)
- func (win *WebviewWindow) Init(js string)
- func (win *WebviewWindow) IsValid() bool
- func (win *WebviewWindow) NativeHandle() unsafe.Pointer
- func (win *WebviewWindow) Navigate(url string)
- func (win *WebviewWindow) Run()
- func (win *WebviewWindow) SetSize(width, height int)
- func (win *WebviewWindow) SetTitle(title string)
- func (win *WebviewWindow) Terminate()
- type WindowManager
- type WindowMode
- type WindowOptions
Constants ¶
This section is empty.
Variables ¶
ErrJSUnavailable is returned when the JS runtime is not accepting calls — either no init script defined any functions, or the runtime has been stopped.
Functions ¶
func AllowURLScheme ¶ added in v0.9.0
func AllowURLScheme(scheme string)
AllowURLScheme permits scheme (without "://") in OpenURL, on top of the safe-by-default set. App.Run calls this for Config.URLScheme so an app can always open its own deep links.
func EmitNFCTag ¶
func EmitNFCTag(uid string)
EmitNFCTag lets a native NFC backend (e.g. the gomobile bridge) push a "nfc:tag" event without depending on the Provider interface for it.
func GetArchInfo ¶
func GetArchInfo() string
func GetEnvInfo ¶
func MenuSupported ¶
func MenuSupported() bool
MenuSupported reports whether this platform has a native menu-bar backend (macOS today). Query it (or goleo:capabilities) before offering menu UI.
func NotificationPermissionGranted ¶
func NotificationPermissionGranted() bool
func RegisterBLE ¶
func RegisterBLE(b *Bridge)
func RegisterBackground ¶
func RegisterBackground(b *Bridge)
func RegisterBattery ¶
func RegisterBattery(b *Bridge)
func RegisterBuiltins ¶
func RegisterBuiltins(b *Bridge)
func RegisterCamera ¶
func RegisterCamera(b *Bridge)
func RegisterClipboard ¶
func RegisterClipboard(b *Bridge)
func RegisterDesktopFeatures ¶
func RegisterDesktopFeatures(b *Bridge)
RegisterDesktopFeatures registers all host features that are available on desktop (Windows, macOS, Linux). On mobile this file is excluded at compile time, so no extra permissions are declared.
func RegisterDialogs ¶
func RegisterDialogs(b *Bridge)
func RegisterFS ¶
func RegisterFS(b *Bridge)
func RegisterGeolocation ¶
func RegisterGeolocation(b *Bridge)
RegisterGeolocation declares that this app uses geolocation.
It installs NO bridge command, and that is deliberate — the frontend calls navigator.geolocation directly through @goleo/bridge's getCurrentPosition(). The call still has to exist, because it is what the CLI's manifest scanner detects, and that detection is what declares Android's ACCESS_FINE_LOCATION (plus the android.hardware.location* uses-feature entries) and iOS's NSLocationWhenInUseUsageDescription.
Those declarations are not optional extras for the web path — they are what makes it work. Android's WebView can only grant a navigator.geolocation request if the app itself holds ACCESS_FINE_LOCATION, and WKWebView needs the usage description. So an app that stops calling this loses geolocation entirely, which is exactly the outcome a "this function is empty, delete it" cleanup would produce. TestGeolocationStaysDetectableAsAPureWebFeature guards it.
func RegisterMicrophone ¶ added in v0.10.9
func RegisterMicrophone(b *Bridge)
RegisterMicrophone opts the app in to microphone access.
Recording itself happens in the WebView (getUserMedia + MediaRecorder) and needs no Go code; these two commands exist because the WebView cannot check permission without starting a capture, and on mobile that check is a native API. Registering this is also what puts RECORD_AUDIO in the generated Android manifest, which is why it is separate from RegisterCamera — see the package comment.
func RegisterNFC ¶
func RegisterNFC(b *Bridge)
func RegisterPush ¶
func RegisterPush(b *Bridge)
func RegisterSampleCommands ¶
func RegisterSampleCommands(b *Bridge)
func RegisterSensors ¶
func RegisterSensors(b *Bridge)
func RegisterShare ¶
func RegisterShare(b *Bridge)
func RegisterStore ¶
func RegisterStore(b *Bridge)
RegisterStore exposes the persistent key/value store to the frontend. Unlike device features it needs no build tag or permission and works on every target (the Go backend owns a JSON file in the app data dir); the frontend falls back to localStorage when there is no backend (PWA).
func RegisterUpdater ¶
func RegisterUpdater(b *Bridge, cfg UpdaterConfig)
RegisterUpdater exposes desktop auto-update to the frontend. Mobile/PWA apps update through their store, so this is opt-in and desktop-only. cfg carries the signed-manifest URL, the embedded ed25519 public key (base64), and the running app version.
func RegisterVibration ¶
func RegisterVibration(b *Bridge)
func RegisterWakeLock ¶
func RegisterWakeLock(b *Bridge)
func RequestNotificationPermission ¶
func RequestNotificationPermission() string
func SetBLEProvider ¶
func SetBLEProvider(p BLEProvider)
func SetBackgroundProvider ¶
func SetBackgroundProvider(p BackgroundProvider)
func SetBatteryProvider ¶
func SetBatteryProvider(p BatteryProvider)
func SetCameraProvider ¶
func SetCameraProvider(p CameraProvider)
func SetClipboardProvider ¶
func SetClipboardProvider(p ClipboardProvider)
func SetDialogsProvider ¶
func SetDialogsProvider(p DialogsProvider)
func SetMicrophoneProvider ¶ added in v0.10.9
func SetMicrophoneProvider(p MicrophoneProvider)
func SetNFCProvider ¶
func SetNFCProvider(p NFCProvider)
func SetNativeNotifier ¶
func SetNativeNotifier(n NativeNotifier)
func SetPushProvider ¶
func SetPushProvider(p PushProvider)
func SetSensorsProvider ¶
func SetSensorsProvider(p SensorsProvider)
func SetShareProvider ¶
func SetShareProvider(p ShareProvider)
func SetVibrationProvider ¶
func SetVibrationProvider(p VibrationProvider)
func SetWakeLockProvider ¶
func SetWakeLockProvider(p WakeLockProvider)
func TraySupported ¶
func TraySupported() bool
TraySupported reports whether this platform/build can show a system tray icon. False on mobile and wasm/PWA builds.
func WindowingSupported ¶
func WindowingSupported() bool
WindowingSupported reports whether this platform/build can open additional native windows (see App.OpenWindow). False on mobile and wasm/PWA builds, where the platform hosts a single WebView itself. Developer code can check this before calling windowing APIs; the APIs also guard internally.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) CloseWindow ¶
CloseWindow closes the window with the given id. Guarded like OpenWindow.
func (*App) Invoke ¶
func (a *App) Invoke(name string, fn InvokeHandler)
func (*App) JS ¶ added in v0.12.0
JS returns the app's script runtime, or nil if there is none. Callers should treat a nil return the same as a disabled feature rather than panicking — an app with no init.js is the normal case, not an error.
func (*App) ListWindows ¶
ListWindows returns the ids of open managed windows. On platforms without windowing it returns an errors.ErrUnsupported-wrapped error.
func (*App) On ¶
func (a *App) On(event string, fn EventHandler)
func (*App) OpenWindow ¶
func (a *App) OpenWindow(opts WindowOptions) (int, error)
OpenWindow opens an additional native window (a child process hosting one webview) and returns its id. Guarded: on platforms without native windowing (mobile, wasm/PWA) it returns an errors.ErrUnsupported-wrapped error rather than attempting to run. Available after Run has started the desktop app.
func (*App) Quit ¶
func (a *App) Quit()
Quit triggers a graceful shutdown: it unblocks the run loop, which closes all managed windows (CloseAll), runs OnShutdown, and stops the server. Safe to call from any goroutine — a bridge handler, an OS signal, or an ExitOnClose window closing — and idempotent (context cancellation is).
func (*App) SetMenu ¶
SetMenu installs the application menu bar. Native on all three desktops — NSMenu (macOS), user32 HMENU (Windows), GtkMenuBar/GtkPopoverMenuBar (Linux, GTK3/GTK4) — and returns an errors.ErrUnsupported-wrapped error on mobile and PWA, where MenuSupported() also reports false. Safe to call after Run has started or from Config.Menu at startup.
func (*App) SetPolicy ¶
SetPolicy installs a capability ACL (see Policy) enforced on every invoke. Call before Run. Passing nil (the default) disables enforcement.
func (*App) StartServer ¶
type BLEProvider ¶
BLEProvider and BLEDevice are re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type BackgroundProvider ¶
type BackgroundProvider = background.Provider
BackgroundProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type BatteryInfo ¶
type BatteryInfo = battery.BatteryInfo
type BatteryProvider ¶
BatteryProvider and BatteryInfo are re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
func (*Bridge) AddFSRoot ¶ added in v0.9.0
AddFSRoot adds a directory the fs plugin may reach. App.New adds the app's data directory; Policy.FSRoots are added when a policy is installed.
func (*Bridge) DispatchEvent ¶
func (b *Bridge) DispatchEvent(event string, data json.RawMessage)
func (*Bridge) GrantFSPath ¶ added in v0.9.0
GrantFSPath records a path the user explicitly chose in a native dialog, so the app may then read or write it even though it sits outside the configured roots. This is what keeps the ordinary "user picks a file, app opens it" flow working without any configuration — the same model Tauri uses.
func (*Bridge) Handle ¶
func (b *Bridge) Handle(name string, fn InvokeHandler)
func (*Bridge) HandleRequest ¶
func (b *Bridge) HandleRequest(req InvokeRequest) InvokeResponse
func (*Bridge) HandleRequestContext ¶ added in v0.12.0
func (b *Bridge) HandleRequestContext(ctx context.Context, req InvokeRequest) InvokeResponse
HandleRequestContext is HandleRequest with a caller-supplied context, passed through to the handler.
Added for the JS runtime, and the reason is worth stating because it is not obvious: the embedded engine owns its VM on a single goroutine, so a script calling into Go runs the handler ON that goroutine. If the handler then calls back into JS, the goroutine would be waiting on itself — a deadlock. jsruntime_call.go marks its context so a nested call runs inline instead of queueing, and that marker can only reach the handler if the context does. HandleRequest kept context.Background() and therefore could not carry it.
Every transport that does NOT have that constraint (HTTP, WebSocket, native IPC) should keep calling HandleRequest.
func (*Bridge) On ¶
func (b *Bridge) On(event string, fn EventHandler)
func (*Bridge) SetFSAppID ¶ added in v0.9.0
SetFSAppID names the app whose data directory is always in scope. App.New calls this with Config.AppID (falling back to Title). The directory itself is resolved on first use, not here — see fsScopeState.appID.
func (*Bridge) SetFSScope ¶ added in v0.9.0
SetFSScope selects the confinement mode for the fs plugin. App.New calls this from Config.FSScope; call it directly if you construct a Bridge yourself.
func (*Bridge) SetPolicy ¶
SetPolicy installs a capability ACL enforced on every invoke. Passing nil disables enforcement (the default). See Policy.
A policy's FSRoots are also registered as filesystem roots here — that is what makes them actually confine the fs plugin. Before this, FSRoots was inert.
func (*Bridge) Subscribe ¶
func (b *Bridge) Subscribe() chan EventMessage
func (*Bridge) Unsubscribe ¶
func (b *Bridge) Unsubscribe(ch chan EventMessage)
type CameraProvider ¶
CameraProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type ClipboardProvider ¶
ClipboardProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type Config ¶
type Config struct {
Title string
Width int
Height int
DevMode bool
DevServer string
Port int
WindowMode WindowMode
EmbedFS any
// InProcessWindows opts additional windows into the in-process model instead of
// child processes. On Windows each window gets its own OS-thread message loop
// (inProcWindowManager); macOS and Linux are main-thread-only, so extra windows
// share the primary window's single run loop (mainLoopWindowManager). Ignored
// elsewhere (falls back to multi-process). See spikes/win-multiwindow and
// spikes/glaze-multiwindow.
InProcessWindows bool
// NativeIPC routes the primary window's frontend<->backend calls over the
// webview's in-process message channel (Bind/Eval) instead of the loopback
// WebSocket, when a native webview hosts the UI. The WebSocket/HTTP server
// stays up and remains the transport for child-process windows, browser/PWA,
// and mobile — so the @goleo/bridge auto-detects the native channel and
// falls back transparently. Lower latency and no WS surface for that window.
// See nativeipc.go. Desktop (WindowModeWebview) only.
NativeIPC bool
// SchemeAssets serves the primary window's embedded UI from a portless, secure
// custom origin (AssetScheme://, default "goleo://") instead of the loopback
// HTTP server — so with NativeIPC on, that window opens no TCP port at all
// while keeping a secure context (localStorage/crypto.subtle/getUserMedia).
// Takes effect only in production (embedded FS, not DevMode). Supported on all
// three desktops via glaze: macOS and Linux serve the literal scheme, and Windows
// serves it over a secure https://<scheme>.localhost virtual host, since WebView2
// has no per-scheme secure flag. Elsewhere it transparently falls back to the
// loopback server, which stays up as the fallback transport either way.
SchemeAssets bool
// AssetScheme overrides the custom scheme name used by SchemeAssets
// (default "goleo"). Must be a plain scheme token, no "://".
AssetScheme string
// FSScope selects how strictly the filesystem plugin (RegisterFS) confines
// paths. The zero value, FSScopeStandard, limits it to the app's data
// directory, any Policy.FSRoots, and paths the user picked in a native dialog
// this session. Set FSScopeUnrestricted for a tool that genuinely needs the
// whole disk (or export GOLEO_FS_UNRESTRICTED=1).
//
// Writes and deletes outside the scope are refused. Out-of-scope *reads*
// currently warn instead, for one release, so existing apps keep working —
// they will become errors.
FSScope FSScope
// SingleInstance, when true, allows only one running instance; a second
// launch forwards its args to the running one (emitting app:secondInstance)
// and exits. AppID identifies the app for the lock (defaults to Title).
SingleInstance bool
AppID string
// Background runs the app as a headless controller: no auto primary window
// (open windows on demand via OpenWindow / the tray), and the main thread
// runs the tray (if Tray is set) or blocks until Quit.
Background bool
// Tray adds a system tray icon + menu (used with Background). Desktop only.
Tray *TrayConfig
// OnReady runs (in a goroutine) once the server + window manager are up and
// the port is known — where OpenWindow works. Unlike OnStartup, which runs
// before the server binds.
OnReady func(ctx context.Context)
// URLScheme, if set (e.g. "myapp"), registers a custom URL scheme so
// myapp:// links launch/wake the app. The frontend reads the launch URL via
// goleo:initialURL and listens for app:openURL (forwarded from later launches).
URLScheme string
// InitJS is the path to a JavaScript startup script that controls window
// creation (createWindow/getConfig API). When set, the file must exist.
// When empty, init.js then backend/init.js are tried; if neither exists
// the window is created from this Config directly.
InitJS string
// Menu is the native application menu bar, supported on all three desktops:
// NSMenu on macOS, a user32 HMENU on Windows, and GtkMenuBar (GTK3) or
// GtkPopoverMenuBar (GTK4) on Linux. When empty, macOS installs
// StandardMenu(Title) so webview keyboard shortcuts (Cmd+C/V/X/A/Z) work.
// Unsupported on mobile and PWA, where SetMenu reports errors.ErrUnsupported.
// See runtime/menu.go, App.SetMenu.
Menu []MenuItem
OnStartup func(ctx context.Context)
OnShutdown func(ctx context.Context)
}
type DialogsProvider ¶
DialogsProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
The option types are re-exported for the same reason: Provider's methods take them, so a shell adapter cannot implement the interface without naming them. Without these aliases the generated gomobile package had to import runtime/dialogs directly, which is exactly what "inject without importing the sub-package" is meant to avoid.
type EventHandler ¶
type EventHandler func(ctx context.Context, data json.RawMessage)
type EventMessage ¶
type EventMessage struct {
Event string `json:"event"`
Data json.RawMessage `json:"data,omitempty"`
}
type FSScope ¶ added in v0.9.0
type FSScope int
FSScope selects how strictly the filesystem plugin confines paths.
const ( // FSScopeStandard confines the fs plugin to the app's own data directory, // any Policy.FSRoots, and paths the user picked in a native dialog this // session. This is the zero value, so it is the default. FSScopeStandard FSScope = iota // FSScopeUnrestricted restores the historical behaviour: any absolute path // the OS will allow. Only for development tools and file managers that // genuinely need the whole disk. Also settable with GOLEO_FS_UNRESTRICTED=1. FSScopeUnrestricted )
type FileDialogOptions ¶ added in v0.10.7
type FileDialogOptions = dialogs.FileDialogOptions
DialogsProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
The option types are re-exported for the same reason: Provider's methods take them, so a shell adapter cannot implement the interface without naming them. Without these aliases the generated gomobile package had to import runtime/dialogs directly, which is exactly what "inject without importing the sub-package" is meant to avoid.
type FileFilter ¶ added in v0.10.7
type FileFilter = dialogs.FileFilter
DialogsProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
The option types are re-exported for the same reason: Provider's methods take them, so a shell adapter cannot implement the interface without naming them. Without these aliases the generated gomobile package had to import runtime/dialogs directly, which is exactly what "inject without importing the sub-package" is meant to avoid.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub tracks the WebSocket clients of ONE server.
It used to be a package-level global started from init(), shared by every Server/App in the process and never shut down. Clients were registered with no association to the server that accepted them, so broadcastEvent fanned out to all of them: in a process running two Apps, app A's bridge events were delivered to app B's frontend, and in tests one case's clients leaked into the next.
type InvokeHandler ¶
type InvokeRequest ¶
type InvokeRequest struct {
ID string `json:"id"`
Method string `json:"method"`
Args json.RawMessage `json:"args,omitempty"`
}
type InvokeResponse ¶
type JSRuntime ¶
type JSRuntime struct {
// contains filtered or unexported fields
}
func NewJSRuntime ¶
func (*JSRuntime) Call ¶ added in v0.12.0
Call invokes a global function defined by the init script and returns its result.
Arguments and the return value cross as JSON. That is deliberate: goja's reflective mapping will happily accept a struct and then silently drop fields it cannot represent, which is the same failure the gomobile providers hit (see AGENTS.md — provider methods take JSON strings for exactly this reason). A predictable boundary that rejects loudly beats a clever one that loses data quietly.
A JS exception becomes a Go error; it never panics across the boundary.
total, err := app.JS().Call(ctx, "priceOrder", order)
func (*JSRuntime) CallJSON ¶ added in v0.12.0
CallJSON is Call with the result decoded into out, for when the script returns a shape the caller already models in Go.
func (*JSRuntime) Has ¶ added in v0.12.0
Has reports whether the init script defined a callable global with this name, so a caller can offer a scripted hook without requiring one.
func (*JSRuntime) Run ¶
Run loads and executes the startup script. Resolution:
- Config.InitJS set: that file must exist (embedded or on disk) — an error is returned if it cannot be loaded.
- Config.InitJS empty: init.js, then backend/init.js are tried; if none exists Run returns nil and the app falls back to the built-in Go-driven window setup from Config.
type MenuItem ¶
type MenuItem struct {
Label string
Role MenuRole
Accelerator string // e.g. "cmd+q", "cmd+shift+z" (cmd/ctrl/alt/shift + key)
OnClick func()
Separator bool
}
MenuItem is one entry in a native menu. A top-level MenuItem (with a Submenu) is a menu in the menu bar; nested items are its entries. Exactly one of Role / OnClick / Submenu / Separator is meaningful per item (Role wins over OnClick).
func StandardMenu ¶
StandardMenu returns a conventional macOS menu bar — an App menu (Quit) and an Edit menu (undo/redo/cut/copy/paste/select-all) — so webview keyboard shortcuts work. Installed automatically on macOS when Config.Menu is empty; also a handy base to extend for custom menus.
type MenuRole ¶
type MenuRole string
MenuRole is a standard menu action wired to the platform's native handler (e.g. the responder chain on macOS), so the item works without a Go callback. Roles are what make Cmd+C/V/X/A/Z etc. work in the webview on macOS.
type MessageBoxOptions ¶ added in v0.10.7
type MessageBoxOptions = dialogs.MessageBoxOptions
DialogsProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
The option types are re-exported for the same reason: Provider's methods take them, so a shell adapter cannot implement the interface without naming them. Without these aliases the generated gomobile package had to import runtime/dialogs directly, which is exactly what "inject without importing the sub-package" is meant to avoid.
type MicrophoneProvider ¶ added in v0.10.9
type MicrophoneProvider = microphone.Provider
MicrophoneProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type NFCMessage ¶
type NFCMessage = nfc.NFCMessage
type NFCProvider ¶
NFCProvider, NFCMessage and NFCRecord are re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type NativeNotifier ¶
type OSInfo ¶
type PlatformInfo ¶
type PlatformInfo struct {
Platform string `json:"platform"`
IsMobile bool `json:"isMobile"`
IsDesktop bool `json:"isDesktop"`
IsBrowser bool `json:"isBrowser"`
}
func GetPlatformInfo ¶
func GetPlatformInfo() PlatformInfo
type Policy ¶
type Policy struct {
// Allow lists permitted invoke methods. "goleo:store*" allows the whole
// store plugin; "goleo:fsReadTextFile" allows exactly one command.
// Enforced by allowsMethod via Bridge.HandleRequest.
Allow []string
// FSRoots widens the filesystem plugin's scope to these directories, on top
// of the app's own data directory and any path the user picks in a native
// dialog. Enforced via Bridge.checkFSPath — see fs_scope.go.
FSRoots []string
// HTTPHosts is intended to limit an http plugin to these hosts.
// RESERVED — no http plugin exists yet, so this gates nothing today.
HTTPHosts []string
// ShellPrograms is intended to limit a shell plugin to these program names.
// RESERVED — no shell plugin exists yet, so this gates nothing today.
ShellPrograms []string
}
Policy is a runtime capability ACL. When set on a Bridge (SetPolicy), every invoke is checked centrally before its handler runs: the method must be in Allow (exact match, or a "prefix*" wildcard) or an always-safe core command, otherwise it is denied.
No policy set = no enforcement (legacy-permissive). Setting a policy opts into deny-by-default, matching Tauri's capability model.
FSRoots IS enforced (since the fs-scope change): SetPolicy registers each root with the Bridge's filesystem scope, and every fs handler checks it. HTTPHosts and ShellPrograms are reserved — goleo has no http or shell plugin yet, so there is nothing for them to gate; they are accepted so a policy written today keeps working when those plugins land.
func (*Policy) AllowsFSPath ¶
AllowsFSPath reports whether path is within an allowed root. Empty FSRoots = unconstrained. Uses cleaned paths so "../" traversal cannot escape a root.
NOTE: this is a raw helper for hosts doing their own checks; it is NOT the enforcement path. Enforcement is Bridge.checkFSPath (fs_scope.go), which treats FSRoots as additive to the app data directory and dialog grants, resolves symlinks, and applies a deny-list — none of which this helper does. In particular its "empty means unconstrained" rule is the opposite of the default the fs plugin needs, so do not use it to decide access.
func (*Policy) AllowsHTTPHost ¶
AllowsHTTPHost reports whether host is permitted. Empty HTTPHosts = unconstrained.
func (*Policy) AllowsShellProgram ¶
AllowsShellProgram reports whether program is permitted. Empty = unconstrained.
type PromptOptions ¶ added in v0.10.7
type PromptOptions = dialogs.PromptOptions
DialogsProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
The option types are re-exported for the same reason: Provider's methods take them, so a shell adapter cannot implement the interface without naming them. Without these aliases the generated gomobile package had to import runtime/dialogs directly, which is exactly what "inject without importing the sub-package" is meant to avoid.
type PushProvider ¶
PushProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type SensorsProvider ¶
SensorsProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type ShareProvider ¶
ShareProvider and ShareData are re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package.
type TrayConfig ¶
TrayConfig configures an optional system tray icon + menu. Set Config.Tray (with Config.Background) to run as a tray app. Icon is PNG bytes.
type TrayItem ¶
type TrayItem struct {
Label string
OnClick func()
}
TrayItem is one system-tray menu entry.
type UpdaterConfig ¶
UpdaterConfig is re-exported so apps can configure the updater without importing the sub-package.
type VibrationProvider ¶
VibrationProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type WakeLockProvider ¶
WakeLockProvider is re-exported so shells (e.g. the gomobile bridge) can inject a native backend without importing the sub-package directly.
type WebviewWindow ¶
type WebviewWindow struct {
// contains filtered or unexported fields
}
func NewWebviewWindow ¶
func NewWebviewWindow(cfg windowConfig) WebviewWindow
func (*WebviewWindow) Destroy ¶
func (win *WebviewWindow) Destroy()
func (*WebviewWindow) Dispatch ¶
func (win *WebviewWindow) Dispatch(f func())
func (*WebviewWindow) Eval ¶
func (win *WebviewWindow) Eval(js string)
func (*WebviewWindow) Init ¶
func (win *WebviewWindow) Init(js string)
func (*WebviewWindow) IsValid ¶
func (win *WebviewWindow) IsValid() bool
func (*WebviewWindow) NativeHandle ¶
func (win *WebviewWindow) NativeHandle() unsafe.Pointer
NativeHandle returns the OS window handle — GtkWindow* on Linux, NSWindow* on macOS, HWND on Windows — used by the native menu-bar backend. Nil if the window isn't created.
func (*WebviewWindow) Navigate ¶
func (win *WebviewWindow) Navigate(url string)
func (*WebviewWindow) Run ¶
func (win *WebviewWindow) Run()
func (*WebviewWindow) SetSize ¶
func (win *WebviewWindow) SetSize(width, height int)
func (*WebviewWindow) SetTitle ¶
func (win *WebviewWindow) SetTitle(title string)
func (*WebviewWindow) Terminate ¶
func (win *WebviewWindow) Terminate()
type WindowManager ¶
type WindowManager struct {
// contains filtered or unexported fields
}
WindowManager tracks additional webview windows, each running as a child process of this executable (see window_child.go). The primary window is still hosted in-process by App.runWebview; this manages every window opened after startup via App.OpenWindow / the goleo:window* bridge commands.
func (*WindowManager) Close ¶
func (wm *WindowManager) Close(id int) error
Close terminates the window with the given id. The webview child holds no unsaved state (it is pure UI), so killing the process is safe.
func (*WindowManager) CloseAll ¶
func (wm *WindowManager) CloseAll()
CloseAll terminates every managed window; called during shutdown.
func (*WindowManager) List ¶
func (wm *WindowManager) List() []int
List returns the ids of all currently open managed windows.
func (*WindowManager) Open ¶
func (wm *WindowManager) Open(opts WindowOptions) (int, error)
Open spawns a new window process and returns its id. The child connects to this process's server as an ordinary bridge client, so cross-window state and events flow through the existing hub.
type WindowMode ¶
type WindowMode int
const ( WindowModeBrowser WindowMode = iota WindowModeWebview WindowModeMobile )
type WindowOptions ¶
type WindowOptions struct {
Title string `json:"title"`
Width int `json:"width"`
Height int `json:"height"`
// URL, if set, is loaded verbatim. Otherwise the window loads the app's own
// server root plus Path (e.g. Path "/settings" → "<serverURL>/settings").
URL string `json:"url"`
Path string `json:"path"`
// ExitOnClose quits the whole app when this window closes (via App.Quit).
// Default false: closing just closes the window; the app keeps running.
ExitOnClose bool `json:"exitOnClose"`
}
WindowOptions describes an additional window to open at runtime.
Source Files
¶
- app.go
- background_reexport.go
- battery_reexport.go
- bluetooth_reexport.go
- bridge.go
- camera_reexport.go
- capabilities.go
- capabilities_desktop.go
- clipboard_reexport.go
- compat.go
- desktop.go
- dialogs_reexport.go
- embed.go
- examples.go
- fs_reexport.go
- fs_scope.go
- geolocation_reexport.go
- jsruntime.go
- jsruntime_call.go
- menu.go
- menu_linux.go
- microphone_reexport.go
- nativeipc.go
- nfc_reexport.go
- notify_reexport.go
- platform.go
- policy.go
- push_reexport.go
- scheme_assets.go
- sensors_reexport.go
- server.go
- share_reexport.go
- store_reexport.go
- tray.go
- tray_desktop.go
- updater_reexport.go
- vibration_reexport.go
- wakelock_reexport.go
- websocket.go
- webview_glaze.go
- webview_glaze_permissions_linux.go
- window_child.go
- windowmanager.go
- windowmanager_mainloop.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package autostart registers/unregisters an app to launch on login.
|
Package autostart registers/unregisters an app to launch on login. |
|
Package deeplink registers a custom URL scheme (myapp://) so links launch or wake the app.
|
Package deeplink registers a custom URL scheme (myapp://) so links launch or wake the app. |
|
Package microphone exposes the microphone's PERMISSION state, not audio capture.
|
Package microphone exposes the microphone's PERMISSION state, not audio capture. |
|
Package singleinstance enforces a single running instance of an app and forwards a later launch's args to the primary (e.g.
|
Package singleinstance enforces a single running instance of an app and forwards a later launch's args to the primary (e.g. |
|
Package store is a simple persistent key/value store backed by a JSON file in the app data directory.
|
Package store is a simple persistent key/value store backed by a JSON file in the app data directory. |
|
Package updater is a desktop auto-update client.
|
Package updater is a desktop auto-update client. |