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
- type ClockResult
- type ConsoleEvent
- type DialogEvent
- type DialogParams
- type DownloadEvent
- type DrawParams
- type EvalParams
- type EvalResult
- type FilesEvent
- type FilesParams
- type HelloResult
- type JSDialog
- type KeyParams
- type LoadEvent
- type Message
- type Mods
- type MouseParams
- type NavigateParams
- type OpenParams
- type PageParams
- type Request
- type RequestEvent
- type SizeParams
- type SnapshotParams
- type SnapshotResult
- type Tab
- type TabParams
- type TabsEvent
- type TextParams
- type WindowParams
- type ZoomParams
Constants ¶
const ( Hello = "hello" Window = "window" Open = "open" Close = "close" NewTab = "newTab" SelectTab = "selectTab" CloseTab = "closeTab" 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" )
Requests.
const ( EventTabs = "tabs" EventLoad = "load" EventRequest = "request" EventConsole = "console" EventDialog = "dialog" EventFiles = "files" EventDownload = "download" EventCrashed = "crashed" EventClosed = "closed" )
Events.
const ( MouseMove = "move" MouseDown = "down" MouseUp = "up" MouseWheel = "wheel" )
Mouse kinds.
const ( KeyDown = "down" KeyUp = "up" )
Key kinds.
const ( LoadStarted = "started" LoadCommitted = "committed" LoadFinished = "finished" LoadFailed = "failed" )
Load steps.
const ( RequestFetch = "fetch" RequestXHR = "xhr" RequestDocument = "document" RequestScript = "script" RequestStylesheet = "stylesheet" RequestImage = "image" RequestFont = "font" RequestMedia = "media" RequestOther = "other" )
Request types.
const ( DialogAlert = "alert" DialogConfirm = "confirm" DialogPrompt = "prompt" DialogBeforeUnload = "beforeunload" )
Dialog types.
const ( DownloadInProgress = "inProgress" DownloadCompleted = "completed" DownloadCanceled = "canceled" )
Download states.
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.
const Version = 1
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 DialogEvent ¶
DialogEvent's Dialog is nil once the dialog closed.
type DialogParams ¶
type DownloadEvent ¶
type DrawParams ¶
DrawParams is a script drawing the window's layer over the front tab.
type EvalParams ¶
type EvalResult ¶
type EvalResult struct {
JSON string `json:"json"`
}
EvalResult's JSON is empty for undefined.
type FilesEvent ¶
type FilesParams ¶
type HelloResult ¶
type HelloResult struct {
Version int `json:"version"`
}
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 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 ¶
type NavigateParams struct {
}
type OpenParams ¶
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 SizeParams ¶
type SnapshotParams ¶
SnapshotParams' Bare leaves the window's layer out of the shot.
type SnapshotResult ¶
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 X window, the one the window reparents into its own.
XID uint64 `json:"xid,omitempty"`
// Icon is the tab's favicon, PNG.
Icon []byte `json:"icon,omitempty"`
}
type TextParams ¶
type WindowParams ¶
type WindowParams struct {
XID uint64 `json:"xid"`
}