host

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 23 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 host is the hot-reload host process: it owns the canvas windows of an app run by `tan dev` and shows frames rendered by worker processes (each rebuild of the app), forwarding input to the current worker and swapping workers without closing windows. See docs/specs/ui-hotreload.md and package devhost for the protocol.

The host is the app binary itself started with TANGO_DEV_ROLE=host: package uihost calls Main from its init, on the main thread, and exits without running the app's main. It only runs framework code.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ResizeWait is how long CanvasFrame waits for a frame of the new
	// size after a resize, so live resize shows fresh content.
	ResizeWait = 50 * time.Millisecond
	// RequestTimeout re-sends a FrameRequest a worker did not answer.
	RequestTimeout = time.Second
	// SnapshotTimeout bounds waiting for the old worker's state.
	SnapshotTimeout = 2 * time.Second
	// OrphanGrace keeps windows of a replaced worker that the new worker
	// did not reopen (yet) before closing them.
	OrphanGrace = 2 * time.Second
	// NoWindowCommit swaps to a new worker that opened no window at all
	// after this long.
	NoWindowCommit = 5 * time.Second
	// FreezeLimit bounds how long input is held back from the old worker
	// for a new one that does not show a frame.
	FreezeLimit = 10 * time.Second
	// ReclaimWindow is how long after a swap the host takes activation
	// back from the new worker (see Host.lifecycle).
	ReclaimWindow = 2 * time.Second
)

Tunables (variables for tests).

View Source
var NewA11yBridge func(cv platform.Canvas) A11yBridge

NewA11yBridge creates the bridge of a host window's canvas; nil (or a nil result: the canvas cannot expose a tree) leaves the windows without one. Package uihost sets it.

Functions

func Main

func Main() int

Main runs the host until its app quits or tan dev goes away and returns the process exit code. It must run on the main thread.

Types

type A11yBridge

type A11yBridge interface {
	// Active reports whether an assistive technology uses the canvas. It
	// is polled at the start of every CanvasFrame and may itself update
	// the platform (drop its tree when the technology left).
	Active() bool
	// Update hands the platform a new tree; changed as for
	// ui.AccessibilityHost.
	Update(tree *a11y.Tree, changed []a11y.NodeID)
	// Replace gives the platform tree instead of the one it has (another
	// process drew it), dropping the old one with its focus first.
	Replace(tree *a11y.Tree)
	// Reset drops the platform's tree (no tree to show).
	Reset()
	// Close releases the bridge (the window closed).
	Close()
}

A11yBridge is the platform accessibility bridge of one host window's canvas. All methods run on the main thread.

type Host

type Host struct {

	// Token, when set before Serve, is the session token every peer must
	// send in Hello (devhost.EnvToken); others are refused.
	Token string
	// contains filtered or unexported fields
}

Host is the hot-reload host. Its state is owned by the app's main thread unless noted.

func New

func New(app *tango.App) *Host

New returns a host for app. Call Serve once the app runs.

func (*Host) Serve

func (h *Host) Serve(ln net.Listener) error

Serve accepts connections until ln closes.

Jump to

Keyboard shortcuts

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