browserwire

package
v0.94.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 1 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 browserwire is the wire between the backend and lich-browser, the process that holds every page (docs/lich-browser.md): one JSON object per line each way. Both sides import it, so a field moves in one place.

Index

Constants

View Source
const (
	Hello     = "hello"
	Window    = "window"
	Open      = "open"
	Close     = "close"
	NewTab    = "newTab"
	SelectTab = "selectTab"
	CloseTab  = "closeTab"
	Navigate  = "navigate"
	Reload    = "reload"
	Back      = "back"
	Forward   = "forward"
	Eval      = "eval"
	Mouse     = "mouse"
	Key       = "key"
	Text      = "text"
	Snapshot  = "snapshot"
	Zoom      = "zoom"
	Size      = "size"
	Dialog    = "dialog"
	Files     = "files"
	Inspect   = "inspect"
	Clock     = "clock"
	PopOut    = "popOut"
	PopIn     = "popIn"
	Raise     = "raise"
	Draw      = "draw"
	// Screencast and StopScreencast start and stop a page's frames, where
	// HelloResult.Frames says pages draw off screen.
	Screencast     = "screencast"
	StopScreencast = "stopScreencast"
)

Requests.

View Source
const (
	EventTabs     = "tabs"
	EventLoad     = "load"
	EventRequest  = "request"
	EventConsole  = "console"
	EventDialog   = "dialog"
	EventFiles    = "files"
	EventDownload = "download"
	EventCrashed  = "crashed"
	EventClosed   = "closed"
	EventFrame    = "frame"
)

Events.

View Source
const (
	MouseMove  = "move"
	MouseDown  = "down"
	MouseUp    = "up"
	MouseWheel = "wheel"
)

Mouse kinds.

View Source
const (
	KeyDown = "down"
	KeyUp   = "up"
)

Key kinds.

View Source
const (
	LoadStarted   = "started"
	LoadCommitted = "committed"
	LoadFinished  = "finished"
	LoadFailed    = "failed"
)

Load steps.

View Source
const (
	RequestFetch      = "fetch"
	RequestXHR        = "xhr"
	RequestDocument   = "document"
	RequestScript     = "script"
	RequestStylesheet = "stylesheet"
	RequestImage      = "image"
	RequestFont       = "font"
	RequestMedia      = "media"
	RequestOther      = "other"
)

Request types.

View Source
const (
	DialogAlert        = "alert"
	DialogConfirm      = "confirm"
	DialogPrompt       = "prompt"
	DialogBeforeUnload = "beforeunload"
)

Dialog types.

View Source
const (
	DownloadInProgress = "inProgress"
	DownloadCompleted  = "completed"
	DownloadCanceled   = "canceled"
)

Download states.

View Source
const LayerID = "lich-note-rings"

LayerID is the id of the element the window's draw scripts draw its layer in, which a bare snapshot hides.

View Source
const Version = 2

Version is what hello answers; a lich-browser answering another one was built from another commit and the backend does not start it.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClockResult

type ClockResult struct {
	NS int64 `json:"ns"`
}

type ConsoleEvent

type ConsoleEvent struct {
	Page string `json:"page"`
	Text string `json:"text"`
}

type DialogEvent

type DialogEvent struct {
	Page   string    `json:"page"`
	Dialog *JSDialog `json:"dialog"`
}

DialogEvent's Dialog is nil once the dialog closed.

type DialogParams

type DialogParams struct {
	Page   string `json:"page"`
	Accept bool   `json:"accept"`
	Text   string `json:"text,omitempty"`
}

type DownloadEvent

type DownloadEvent struct {
	Page     string `json:"page"`
	GUID     string `json:"guid"`
	URL      string `json:"url"`
	Name     string `json:"name"`
	Path     string `json:"path,omitempty"`
	State    string `json:"state"`
	Received int64  `json:"received"`
	Total    int64  `json:"total"`
}

type DrawParams

type DrawParams struct {
	Page   string `json:"page"`
	Script string `json:"script"`
}

DrawParams is a script drawing the window's layer over the front tab.

type EvalParams

type EvalParams struct {
	Page   string `json:"page"`
	Script string `json:"script"`
}

type EvalResult

type EvalResult struct {
	JSON string `json:"json"`
}

EvalResult's JSON is empty for undefined.

type FilesEvent

type FilesEvent struct {
	Page     string `json:"page"`
	Multiple bool   `json:"multiple"`
}

type FilesParams

type FilesParams struct {
	Page  string   `json:"page"`
	Paths []string `json:"paths"`
}

type FrameEvent

type FrameEvent struct {
	Page string `json:"page"`
	Tab  string `json:"tab"`
	Data string `json:"data"`
}

FrameEvent is what the shown tab drew: Data is a base64 JPEG at the page's scale, as api.BrowserFrame carries it on.

type HelloResult

type HelloResult struct {
	Version int `json:"version"`
	// Frames: pages draw off screen, with no surface for the window to
	// show, so the window draws their frames and sends them its input.
	Frames bool `json:"frames,omitempty"`
}

type JSDialog

type JSDialog struct {
	Type    string `json:"type"`
	Message string `json:"message"`
	Default string `json:"default,omitempty"`
}

type KeyParams

type KeyParams struct {
	Page string `json:"page"`
	Kind string `json:"kind"`
	Key  string `json:"key"`
	Code string `json:"code,omitempty"`
	Mods Mods   `json:"mods,omitempty"`
}

KeyParams names a key the DOM way: Key is KeyboardEvent.key, Code is KeyboardEvent.code.

type LoadEvent

type LoadEvent struct {
	Page string `json:"page"`
	Tab  string `json:"tab"`
	Step string `json:"step"`
	URL  string `json:"url"`
	At   int64  `json:"at"`
	// Error is WebKit's text for a failed load.
	Error string `json:"error,omitempty"`
	// Download is a navigation that turned into a download.
	Download bool `json:"download,omitempty"`
}

type Message

type Message struct {
	ID     int64           `json:"id,omitempty"`
	Result json.RawMessage `json:"result,omitempty"`
	Error  string          `json:"error,omitempty"`
	Event  string          `json:"event,omitempty"`
	Params json.RawMessage `json:"params,omitempty"`
}

Message is a line from lich-browser: a Response when ID is set, otherwise an Event.

type Mods

type Mods uint8

Mods is a bit set of the modifiers held.

const (
	ModShift Mods = 1 << iota
	ModCtrl
	ModAlt
	ModMeta
)

type MouseParams

type MouseParams struct {
	Page string  `json:"page"`
	Kind string  `json:"kind"`
	X    float64 `json:"x"`
	Y    float64 `json:"y"`
	// Button is the DOM's: 0 left, 1 middle, 2 right.
	Button int     `json:"button,omitempty"`
	Clicks int     `json:"clicks,omitempty"`
	Mods   Mods    `json:"mods,omitempty"`
	DX     float64 `json:"dx,omitempty"`
	DY     float64 `json:"dy,omitempty"`
}
type NavigateParams struct {
	Page string `json:"page"`
	URL  string `json:"url"`
}

type OpenParams

type OpenParams struct {
	Page  string  `json:"page"`
	URL   string  `json:"url"`
	Scale float64 `json:"scale"`
	W     int     `json:"w"`
	H     int     `json:"h"`
	// Downloads is the directory the page's downloads land in.
	Downloads string `json:"downloads"`
}

type PageParams

type PageParams struct {
	Page string `json:"page"`
}

PageParams names the page a request acts on, at its front tab.

type Request

type Request struct {
	ID     int64           `json:"id"`
	Method string          `json:"method"`
	Params json.RawMessage `json:"params,omitempty"`
}

Request is one call from the backend; ID pairs it with its Response.

type RequestEvent

type RequestEvent struct {
	Page     string `json:"page"`
	Tab      string `json:"tab"`
	ID       string `json:"id"`
	Type     string `json:"type"`
	Started  bool   `json:"started,omitempty"`
	Finished bool   `json:"finished,omitempty"`
	At       int64  `json:"at"`
}

RequestEvent is a request of the front tab starting, or finishing however it ended: Finished names the ID that started.

type ScreencastParams

type ScreencastParams struct {
	Page  string  `json:"page"`
	W     int     `json:"w"`
	H     int     `json:"h"`
	Scale float64 `json:"scale"`
}

ScreencastParams lays the page out at W x H CSS pixels, drawn at Scale, and sends its front tab's frames from then on.

type SizeParams

type SizeParams struct {
	Page string `json:"page"`
	W    int    `json:"w"`
	H    int    `json:"h"`
}

type SnapshotParams

type SnapshotParams struct {
	Page string `json:"page"`
	Bare bool   `json:"bare,omitempty"`
}

SnapshotParams' Bare leaves the window's layer out of the shot.

type SnapshotResult

type SnapshotResult struct {
	PNG []byte `json:"png"`
	W   int    `json:"w"`
	H   int    `json:"h"`
}

type Tab

type Tab struct {
	ID      string `json:"id"`
	URL     string `json:"url"`
	Title   string `json:"title"`
	Loading bool   `json:"loading"`
	Front   bool   `json:"front"`
	// XID is the tab's native surface: an X window on Linux, an HWND on
	// Windows, a CAContext id on macOS.
	XID uint64 `json:"xid,omitempty"`
	// Icon is the tab's favicon, PNG.
	Icon []byte `json:"icon,omitempty"`
	// DevTools is WebKit's inspector of the tab before it, Front while the
	// pane shows it in that tab's place; requests still act on that tab.
	DevTools bool `json:"devtools,omitempty"`
}

type TabParams

type TabParams struct {
	Page string `json:"page"`
	Tab  string `json:"tab"`
}

type TabsEvent

type TabsEvent struct {
	Page string `json:"page"`
	Tabs []Tab  `json:"tabs"`
}

type TextParams

type TextParams struct {
	Page string `json:"page"`
	Text string `json:"text"`
}

type WindowParams

type WindowParams struct {
	XID uint64 `json:"xid"`
}

type ZoomParams

type ZoomParams struct {
	Page  string  `json:"page"`
	Scale float64 `json:"scale"`
}

Jump to

Keyboard shortcuts

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