Documentation
¶
Overview ¶
Package bridge embeds the renderer runtime that Golet injects into pages.
bridge.js is built from ../../packages/bridge by `bun run build` and committed, so building a Golet application never requires Bun.
Index ¶
Constants ¶
const FitContentEvent = "golet:fit-content"
FitContentEvent tells the page of a window that takes the size of its content (FitContent) the limits of that size, with a FitContent, when the page's zoom changed them. The bridge configuration tells them at document start.
const LocaleEvent = "golet:locale"
LocaleEvent tells the pages of a window that the language the app shows changed, with a Locale. The bridge configuration tells pages the language at document start; the event is sent as a page loads too, for one that started loading as the language changed, and the bridge tells its listeners only of a language the page did not have.
const PreferencesEvent = "golet:preferences"
PreferencesEvent tells a page the accent color and the accessibility settings of the desktop, as golet.ThemePreferences encodes them. The bridge keeps the latest for golet-runtime's preferences(), the accent in the --golet-accent CSS variable and the text scale in --golet-text-scale.
const TitleBarEvent = "golet:title-bar"
TitleBarEvent tells a page of a window with a hidden title bar the room the window controls take. The bridge keeps it in the --golet-titlebar-* CSS variables.
const WindowActiveEvent = "golet:window-active"
WindowActiveEvent tells a page whether its window is drawn as active, true or false: the bridge keeps it for golet-runtime's windowActive(), and sets the attribute data-golet-window-inactive of <html> while it is not. Pages start active; a page that loads in an inactive window hears it as its DOM is ready.
Variables ¶
This section is empty.
Functions ¶
func PreferencesScript ¶
PreferencesScript delivers PreferencesEvent with the JSON prefs at document start, after the bridge has registered its handler.
Types ¶
type Config ¶
type Config struct {
Platform string `json:"platform"`
WindowID int `json:"windowId"`
Version string `json:"version"`
// Secret prefixes every message the bridge posts.
Secret string `json:"secret"`
// Locale is the language the app shows, e.g. "zh-Hans", and Dir the
// direction it is written in, "ltr" or "rtl", which pages read as
// golet.locale and golet.dir from document start.
Locale string `json:"locale"`
Dir string `json:"dir"`
// Fit is the limits of a window that takes the size of its page's
// content (FitContent), nil for other windows.
Fit *FitContent `json:"fit,omitempty"`
}
Config is passed to the bridge as __GOLET_CONFIG__.
type FitContent ¶ added in v0.1.13
type FitContent struct {
MinWidth float64 `json:"minWidth"`
MinHeight float64 `json:"minHeight"`
MaxWidth float64 `json:"maxWidth"`
MaxHeight float64 `json:"maxHeight"`
}
FitContent is the limits of the size of a window that takes its content's, in CSS pixels; 0 is none. The bridge lays the page's root element out within them.
func NewFitContent ¶ added in v0.1.13
func NewFitContent(minSize, maxSize platform.Size, zoom float64) FitContent
NewFitContent converts the limits of a window's size, in DIPs, to the CSS pixels of a page shown at zoom.