Documentation
¶
Overview ¶
Package hostui provides the desktop system tray, pairing window and permission guide for a standalone Host process.
Index ¶
- Constants
- Variables
- func AppRevealTarget(executable string) string
- func Available(goos string, getenv func(string) string) bool
- func BindLocale(c *ui.Context)
- func BuildMenu(state MenuState) *mygo.Menu
- func BuildMenuItems(state MenuState) []*mygo.MenuItem
- func DisplayName(product identity.Desktop) string
- func FormatPeerLatency(lang string, online bool, rttMS *uint64) string
- func FormatPeerProtocol(lang string, online bool, route string) string
- func RenderPermissionGuide(c *ui.Context, m *PermissionGuideModel)
- func RenderShareWindow(c *ui.Context, m *ShareWindowModel)
- func Run(ctx context.Context, cfg Options) error
- func Supported(goos string, getenv func(string) string) bool
- func Text(c *ui.Context, key string, args ...any) string
- func TextIn(lang, key string, args ...any) string
- func TrayIconPNG(product identity.Desktop, goos string) ([]byte, bool, error)
- type Autostart
- type AutostartConfig
- type MenuState
- type Options
- type PeerMonitor
- type PeerStatus
- type PermissionController
- func (pc *PermissionController) Counts() (int, int)
- func (pc *PermissionController) Destroy()
- func (pc *PermissionController) Hide()
- func (pc *PermissionController) IsVisible() bool
- func (pc *PermissionController) Refresh() (int, int)
- func (pc *PermissionController) Show(lang string)
- func (pc *PermissionController) Supported() bool
- type PermissionGuideModel
- type PermissionItem
- type PermissionProbe
- type ShareController
- type ShareNodeOption
- type ShareWindowModel
- type WindowsRunStore
Constants ¶
const MinimumFontSize float32 = 14
MinimumFontSize is the floor for every text element in Host desktop windows.
Variables ¶
var SupportedLanguages = []string{"en", "zh-CN", "zh-TW", "ja", "ko", "fr", "de", "es", "pt-BR", "ru"}
SupportedLanguages lists all 10 locales shipped for standalone Host tray and windows.
Functions ¶
func AppRevealTarget ¶
AppRevealTarget returns the enclosing .app bundle on macOS when present, or the executable itself.
func Available ¶
Available reports whether the current OS and environment have a desktop GUI session where a system tray can be presented.
func BindLocale ¶
BindLocale attaches the Host UI catalog to a window frame.
func BuildMenuItems ¶
BuildMenuItems constructs the right-click context menu items for the standalone Host tray.
func DisplayName ¶
DisplayName derives the standalone Host display name from the product identity.
func FormatPeerLatency ¶
FormatPeerLatency formats a peer's live RTT in milliseconds or an em-dash placeholder.
func FormatPeerProtocol ¶
FormatPeerProtocol formats a peer's live route for display.
func RenderPermissionGuide ¶
func RenderPermissionGuide(c *ui.Context, m *PermissionGuideModel)
RenderPermissionGuide draws the Permission Guide Window using >=14px typography, multi-tone vector illustrations, solid borders, and semantic theme tokens.
func RenderShareWindow ¶
func RenderShareWindow(c *ui.Context, m *ShareWindowModel)
RenderShareWindow draws the Share Window using >=14px typography, solid borders, multi-tone vector illustrations, node selection cards, and 32px PIN digit tiles.
func Run ¶
Run starts the standalone Host system tray, Share Window, and automatic Permission Guide Window on the main goroutine, blocking until ctx cancels or the user chooses Quit from the tray menu.
func Supported ¶
Supported reports whether an explicit --tray launch is supported in this environment.
Types ¶
type Autostart ¶
type Autostart struct {
// contains filtered or unexported fields
}
Autostart inspects and toggles OS login startup for the standalone Host.
func NewAutostart ¶
func NewAutostart(cfg AutostartConfig) *Autostart
NewAutostart constructs an Autostart manager using OS defaults for omitted fields.
func (*Autostart) Enabled ¶
Enabled reports whether standalone Host launch-at-login (or an active managed user Host service from service.sh) is enabled.
func (*Autostart) SetEnabled ¶
SetEnabled enables or disables login startup for the standalone Host.
type AutostartConfig ¶
type AutostartConfig struct {
GOOS string
HomeDir string
ConfigHome string
Executable string
Profile string
ExplicitProfile bool
Product identity.Desktop
WindowsRun WindowsRunStore
}
AutostartConfig configures login autostart management for a standalone Host.
type MenuState ¶
type MenuState struct {
Language string
AppName string
Peers []PeerStatus
AutostartEnabled bool
ShowPermissions bool
PermissionsReady int
PermissionsTotal int
OnPermissions func()
OnToggleAutostart func(next bool)
OnRemovePeer func(id protocol.NodeID)
OnQuit func()
IncludeStatusIcons bool
}
MenuState describes the data and callbacks used to build the Host tray context menu.
type Options ¶
type Options struct {
Identity identity.Desktop
Profile string
ExplicitProfile bool
Node *node.Node
PairingOrigin string
}
Options configures the standalone Host desktop tray and companion windows.
type PeerMonitor ¶
type PeerMonitor struct {
// contains filtered or unexported fields
}
PeerMonitor tracks paired peers, live connection routes/RTTs, and host removal.
func NewPeerMonitor ¶
func NewPeerMonitor(parent context.Context, endpoint *link.Link, controller *client.Client, onChange func()) *PeerMonitor
NewPeerMonitor starts watching paired peers and their live connections.
func (*PeerMonitor) Close ¶
func (m *PeerMonitor) Close()
Close stops all background peer watches and waits for workers to exit.
func (*PeerMonitor) Refresh ¶
func (m *PeerMonitor) Refresh()
Refresh triggers an immediate peer discovery pass.
func (*PeerMonitor) RemovePeer ¶
func (m *PeerMonitor) RemovePeer(id protocol.NodeID, done func(error))
RemovePeer revokes trust and disconnects a paired peer using client.RemoveHost and the durable revoke_device identity command.
func (*PeerMonitor) Snapshot ¶
func (m *PeerMonitor) Snapshot() []PeerStatus
Snapshot returns the sorted list of currently paired peers.
type PeerStatus ¶
type PeerStatus struct {
ID protocol.NodeID
Address link.EndpointAddress
Name string
Online bool
// Route is "lan", "p2p", "relay", or "" when disconnected.
Route string
RTTMS *uint64
}
PeerStatus describes one paired peer shown in the Host tray menu.
type PermissionController ¶
type PermissionController struct {
// contains filtered or unexported fields
}
PermissionController manages live permission checks, polling, and the native guide window.
func NewPermissionController ¶
func NewPermissionController(ctx context.Context, appName string, probe PermissionProbe, onChange func(ready, total int), onVisibility func()) *PermissionController
NewPermissionController constructs a PermissionController for standalone Host.
func (*PermissionController) Counts ¶
func (pc *PermissionController) Counts() (int, int)
Counts returns the latest (ready, total) permission counts.
func (*PermissionController) Destroy ¶
func (pc *PermissionController) Destroy()
Destroy closes the Permission Guide Window during Host shutdown.
func (*PermissionController) Hide ¶
func (pc *PermissionController) Hide()
Hide hides the Permission Guide Window and pauses background polling.
func (*PermissionController) IsVisible ¶
func (pc *PermissionController) IsVisible() bool
IsVisible reports whether the Permission Guide Window is currently open and visible.
func (*PermissionController) Refresh ¶
func (pc *PermissionController) Refresh() (int, int)
Refresh checks all permissions off the UI thread and returns (ready, total).
func (*PermissionController) Show ¶
func (pc *PermissionController) Show(lang string)
Show opens or raises the Permission Guide Window on the main UI thread.
func (*PermissionController) Supported ¶
func (pc *PermissionController) Supported() bool
Supported reports whether permission checks apply on the current platform.
type PermissionGuideModel ¶
type PermissionGuideModel struct {
AppName string
Items []PermissionItem
Checking bool
OnAuthorize func(permissionflow.Permission)
OnRevealApp func()
OnRecheck func()
OnClose func()
}
PermissionGuideModel holds the renderable state and actions of the Permission Guide Window.
func (*PermissionGuideModel) AllGranted ¶
func (m *PermissionGuideModel) AllGranted() bool
AllGranted reports whether every required permission is granted.
func (*PermissionGuideModel) Counts ¶
func (m *PermissionGuideModel) Counts() (ready, total int)
Counts returns how many permissions are granted and the total count.
type PermissionItem ¶
type PermissionItem struct {
Permission permissionflow.Permission
TitleKey string
DescKey string
Graphic *ui.SVG
Granted bool
Busy bool
}
PermissionItem represents one required Host execution permission in the guide UI.
func DefaultPermissionItems ¶
func DefaultPermissionItems() []PermissionItem
DefaultPermissionItems returns the 3 core macOS permissions required by standalone Host.
type PermissionProbe ¶
type PermissionProbe struct {
GOOS string
Executable string
Check func(permissionflow.Permission) (permissionflow.Status, error)
Authorize func(context.Context, permissionflow.Permission) (permissionflow.Status, error)
Settings func(permissionflow.Permission) error
RevealApp func(path string) error
}
PermissionProbe abstracts OS permission checks and settings guidance.
func SystemPermissionProbe ¶
func SystemPermissionProbe() PermissionProbe
SystemPermissionProbe returns the live desktop OS permission probe.
func (PermissionProbe) Supported ¶
func (p PermissionProbe) Supported() bool
Supported reports whether this OS uses desktop privacy grants for Host execution.
type ShareController ¶
type ShareController struct {
// contains filtered or unexported fields
}
ShareController manages network route selection, live ShareForRole sessions, and the native Share Window.
func NewShareController ¶
func NewShareController(ctx context.Context, appName string, endpoint *link.Link, controller *client.Client, pairingOrigin string, onPaired func(), onVisibility func()) *ShareController
NewShareController constructs a ShareController for standalone Host.
func (*ShareController) Destroy ¶
func (sc *ShareController) Destroy()
Destroy closes the Share Window during Host shutdown.
func (*ShareController) Hide ¶
func (sc *ShareController) Hide()
Hide hides the Share Window and cancels its active pairing session.
func (*ShareController) IsVisible ¶
func (sc *ShareController) IsVisible() bool
IsVisible reports whether the Share Window is currently open and visible.
func (*ShareController) Show ¶
func (sc *ShareController) Show(lang string)
Show opens or raises the Share Window and starts a live executor pairing session.
type ShareNodeOption ¶
type ShareNodeOption struct {
}
ShareNodeOption describes one selectable network/relay route in the Share Window.
type ShareWindowModel ¶
type ShareWindowModel struct {
}
ShareWindowModel holds the renderable state and callbacks of the Share Window.