bridge

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 3 Imported by: 0 modules, 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 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

View Source
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.

View Source
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.

View Source
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.

Variables

This section is empty.

Functions

func PreferencesScript

func PreferencesScript(prefs []byte) string

PreferencesScript delivers PreferencesEvent with the JSON prefs at document start, after the bridge has registered its handler.

func Script

func Script(cfg Config) string

Script returns the bridge source configured for one window.

func TitleBarScript

func TitleBarScript(tb platform.TitleBar, zoom float64) string

TitleBarScript delivers TitleBarEvent at document start, after the bridge, so that a page lays out around the window controls before it first paints.

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"`
}

Config is passed to the bridge as __GOLET_CONFIG__.

type Locale

type Locale struct {
	Locale string `json:"locale"`
	Dir    string `json:"dir"`
}

Locale is the payload of LocaleEvent.

type TitleBar

type TitleBar struct {
	Height float64 `json:"height"`
	Left   float64 `json:"left"`
	Right  float64 `json:"right"`
}

TitleBar is the payload of TitleBarEvent, in CSS pixels.

func NewTitleBar

func NewTitleBar(tb platform.TitleBar, zoom float64) TitleBar

NewTitleBar converts the room of the window controls to the CSS pixels of a page shown at zoom.

Jump to

Keyboard shortcuts

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