{"modulePath":"github.com/lichdotdev/lich","version":"v0.94.0-rc.5","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package browserwire\n\nPackage 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.\n\n## Constants\n\n```go\nconst (\n\tHello     = \"hello\"\n\tWindow    = \"window\"\n\tOpen      = \"open\"\n\tClose     = \"close\"\n\tNewTab    = \"newTab\"\n\tSelectTab = \"selectTab\"\n\tCloseTab  = \"closeTab\"\n\tNavigate  = \"navigate\"\n\tReload    = \"reload\"\n\tBack      = \"back\"\n\tForward   = \"forward\"\n\tEval      = \"eval\"\n\tMouse     = \"mouse\"\n\tKey       = \"key\"\n\tText      = \"text\"\n\tSnapshot  = \"snapshot\"\n\tZoom      = \"zoom\"\n\tSize      = \"size\"\n\tDialog    = \"dialog\"\n\tFiles     = \"files\"\n\tInspect   = \"inspect\"\n\tClock     = \"clock\"\n\tPopOut    = \"popOut\"\n\tPopIn     = \"popIn\"\n\tRaise     = \"raise\"\n\tDraw      = \"draw\"\n\t// Screencast and StopScreencast start and stop a page's frames, where\n\t// HelloResult.Frames says pages draw off screen.\n\tScreencast     = \"screencast\"\n\tStopScreencast = \"stopScreencast\"\n)\n```\nRequests.\n\n```go\nconst (\n\tEventTabs     = \"tabs\"\n\tEventLoad     = \"load\"\n\tEventRequest  = \"request\"\n\tEventConsole  = \"console\"\n\tEventDialog   = \"dialog\"\n\tEventFiles    = \"files\"\n\tEventDownload = \"download\"\n\tEventCrashed  = \"crashed\"\n\tEventClosed   = \"closed\"\n\tEventFrame    = \"frame\"\n)\n```\nEvents.\n\n```go\nconst (\n\tMouseMove  = \"move\"\n\tMouseDown  = \"down\"\n\tMouseUp    = \"up\"\n\tMouseWheel = \"wheel\"\n)\n```\nMouse kinds.\n\n```go\nconst (\n\tKeyDown = \"down\"\n\tKeyUp   = \"up\"\n)\n```\nKey kinds.\n\n```go\nconst (\n\tLoadStarted   = \"started\"\n\tLoadCommitted = \"committed\"\n\tLoadFinished  = \"finished\"\n\tLoadFailed    = \"failed\"\n)\n```\nLoad steps.\n\n```go\nconst (\n\tRequestFetch      = \"fetch\"\n\tRequestXHR        = \"xhr\"\n\tRequestDocument   = \"document\"\n\tRequestScript     = \"script\"\n\tRequestStylesheet = \"stylesheet\"\n\tRequestImage      = \"image\"\n\tRequestFont       = \"font\"\n\tRequestMedia      = \"media\"\n\tRequestOther      = \"other\"\n)\n```\nRequest types.\n\n```go\nconst (\n\tDialogAlert        = \"alert\"\n\tDialogConfirm      = \"confirm\"\n\tDialogPrompt       = \"prompt\"\n\tDialogBeforeUnload = \"beforeunload\"\n)\n```\nDialog types.\n\n```go\nconst (\n\tDownloadInProgress = \"inProgress\"\n\tDownloadCompleted  = \"completed\"\n\tDownloadCanceled   = \"canceled\"\n)\n```\nDownload states.\n\n```go\nconst LayerID = \"lich-note-rings\"\n```\nLayerID is the id of the element the window's draw scripts draw its layer in, which a bare snapshot hides.\n\n```go\nconst Version = 2\n```\nVersion is what hello answers; a lich-browser answering another one was built from another commit and the backend does not start it.\n\n## Types\n\n```go\ntype ClockResult struct {\n\tNS int64 `json:\"ns\"`\n}\n```\n\n```go\ntype ConsoleEvent struct {\n\tPage string `json:\"page\"`\n\tText string `json:\"text\"`\n}\n```\n\n```go\ntype DialogEvent struct {\n\tPage   string    `json:\"page\"`\n\tDialog *JSDialog `json:\"dialog\"`\n}\n```\nDialogEvent's Dialog is nil once the dialog closed.\n\n```go\ntype DialogParams struct {\n\tPage   string `json:\"page\"`\n\tAccept bool   `json:\"accept\"`\n\tText   string `json:\"text,omitempty\"`\n}\n```\n\n```go\ntype DownloadEvent struct {\n\tPage     string `json:\"page\"`\n\tGUID     string `json:\"guid\"`\n\tURL      string `json:\"url\"`\n\tName     string `json:\"name\"`\n\tPath     string `json:\"path,omitempty\"`\n\tState    string `json:\"state\"`\n\tReceived int64  `json:\"received\"`\n\tTotal    int64  `json:\"total\"`\n}\n```\n\n```go\ntype DrawParams struct {\n\tPage   string `json:\"page\"`\n\tScript string `json:\"script\"`\n}\n```\nDrawParams is a script drawing the window's layer over the front tab.\n\n```go\ntype EvalParams struct {\n\tPage   string `json:\"page\"`\n\tScript string `json:\"script\"`\n}\n```\n\n```go\ntype EvalResult struct {\n\tJSON string `json:\"json\"`\n}\n```\nEvalResult's JSON is empty for undefined.\n\n```go\ntype FilesEvent struct {\n\tPage     string `json:\"page\"`\n\tMultiple bool   `json:\"multiple\"`\n}\n```\n\n```go\ntype FilesParams struct {\n\tPage  string   `json:\"page\"`\n\tPaths []string `json:\"paths\"`\n}\n```\n\n```go\ntype FrameEvent struct {\n\tPage string `json:\"page\"`\n\tTab  string `json:\"tab\"`\n\tData string `json:\"data\"`\n}\n```\nFrameEvent is what the shown tab drew: Data is a base64 JPEG at the page's scale, as api.BrowserFrame carries it on.\n\n```go\ntype HelloResult struct {\n\tVersion int `json:\"version\"`\n\t// Frames: pages draw off screen, with no surface for the window to\n\t// show, so the window draws their frames and sends them its input.\n\tFrames bool `json:\"frames,omitempty\"`\n}\n```\n\n```go\ntype JSDialog struct {\n\tType    string `json:\"type\"`\n\tMessage string `json:\"message\"`\n\tDefault string `json:\"default,omitempty\"`\n}\n```\n\n```go\ntype KeyParams struct {\n\tPage string `json:\"page\"`\n\tKind string `json:\"kind\"`\n\tKey  string `json:\"key\"`\n\tCode string `json:\"code,omitempty\"`\n\tMods Mods   `json:\"mods,omitempty\"`\n}\n```\nKeyParams names a key the DOM way: Key is KeyboardEvent.key, Code is KeyboardEvent.code.\n\n```go\ntype LoadEvent struct {\n\tPage string `json:\"page\"`\n\tTab  string `json:\"tab\"`\n\tStep string `json:\"step\"`\n\tURL  string `json:\"url\"`\n\tAt   int64  `json:\"at\"`\n\t// Error is WebKit's text for a failed load.\n\tError string `json:\"error,omitempty\"`\n\t// Download is a navigation that turned into a download.\n\tDownload bool `json:\"download,omitempty\"`\n}\n```\n\n```go\ntype Message struct {\n\tID     int64           `json:\"id,omitempty\"`\n\tResult json.RawMessage `json:\"result,omitempty\"`\n\tError  string          `json:\"error,omitempty\"`\n\tEvent  string          `json:\"event,omitempty\"`\n\tParams json.RawMessage `json:\"params,omitempty\"`\n}\n```\nMessage is a line from lich-browser: a Response when ID is set, otherwise an Event.\n\n```go\ntype Mods uint8\n```\nMods is a bit set of the modifiers held.\n\n```go\nconst (\n\tModShift Mods = 1 \u003c\u003c iota\n\tModCtrl\n\tModAlt\n\tModMeta\n)\n```\n\n```go\ntype MouseParams struct {\n\tPage string  `json:\"page\"`\n\tKind string  `json:\"kind\"`\n\tX    float64 `json:\"x\"`\n\tY    float64 `json:\"y\"`\n\t// Button is the DOM's: 0 left, 1 middle, 2 right.\n\tButton int     `json:\"button,omitempty\"`\n\tClicks int     `json:\"clicks,omitempty\"`\n\tMods   Mods    `json:\"mods,omitempty\"`\n\tDX     float64 `json:\"dx,omitempty\"`\n\tDY     float64 `json:\"dy,omitempty\"`\n}\n```\n\n```go\ntype NavigateParams struct {\n\tPage string `json:\"page\"`\n\tURL  string `json:\"url\"`\n}\n```\n\n```go\ntype OpenParams struct {\n\tPage  string  `json:\"page\"`\n\tURL   string  `json:\"url\"`\n\tScale float64 `json:\"scale\"`\n\tW     int     `json:\"w\"`\n\tH     int     `json:\"h\"`\n\t// Downloads is the directory the page's downloads land in.\n\tDownloads string `json:\"downloads\"`\n}\n```\n\n```go\ntype PageParams struct {\n\tPage string `json:\"page\"`\n}\n```\nPageParams names the page a request acts on, at its front tab.\n\n```go\ntype Request struct {\n\tID     int64           `json:\"id\"`\n\tMethod string          `json:\"method\"`\n\tParams json.RawMessage `json:\"params,omitempty\"`\n}\n```\nRequest is one call from the backend; ID pairs it with its Response.\n\n```go\ntype RequestEvent struct {\n\tPage     string `json:\"page\"`\n\tTab      string `json:\"tab\"`\n\tID       string `json:\"id\"`\n\tType     string `json:\"type\"`\n\tStarted  bool   `json:\"started,omitempty\"`\n\tFinished bool   `json:\"finished,omitempty\"`\n\tAt       int64  `json:\"at\"`\n}\n```\nRequestEvent is a request of the front tab starting, or finishing however it ended: Finished names the ID that started.\n\n```go\ntype ScreencastParams struct {\n\tPage  string  `json:\"page\"`\n\tW     int     `json:\"w\"`\n\tH     int     `json:\"h\"`\n\tScale float64 `json:\"scale\"`\n}\n```\nScreencastParams lays the page out at W x H CSS pixels, drawn at Scale, and sends its front tab's frames from then on.\n\n```go\ntype SizeParams struct {\n\tPage string `json:\"page\"`\n\tW    int    `json:\"w\"`\n\tH    int    `json:\"h\"`\n}\n```\n\n```go\ntype SnapshotParams struct {\n\tPage string `json:\"page\"`\n\tBare bool   `json:\"bare,omitempty\"`\n}\n```\nSnapshotParams' Bare leaves the window's layer out of the shot.\n\n```go\ntype SnapshotResult struct {\n\tPNG []byte `json:\"png\"`\n\tW   int    `json:\"w\"`\n\tH   int    `json:\"h\"`\n}\n```\n\n```go\ntype Tab struct {\n\tID      string `json:\"id\"`\n\tURL     string `json:\"url\"`\n\tTitle   string `json:\"title\"`\n\tLoading bool   `json:\"loading\"`\n\tFront   bool   `json:\"front\"`\n\t// XID is the tab's native surface: an X window on Linux, an HWND on\n\t// Windows, a CAContext id on macOS.\n\tXID uint64 `json:\"xid,omitempty\"`\n\t// Icon is the tab's favicon, PNG.\n\tIcon []byte `json:\"icon,omitempty\"`\n\t// DevTools is WebKit's inspector of the tab before it, Front while the\n\t// pane shows it in that tab's place; requests still act on that tab.\n\tDevTools bool `json:\"devtools,omitempty\"`\n}\n```\n\n```go\ntype TabParams struct {\n\tPage string `json:\"page\"`\n\tTab  string `json:\"tab\"`\n}\n```\n\n```go\ntype TabsEvent struct {\n\tPage string `json:\"page\"`\n\tTabs []Tab  `json:\"tabs\"`\n}\n```\n\n```go\ntype TextParams struct {\n\tPage string `json:\"page\"`\n\tText string `json:\"text\"`\n}\n```\n\n```go\ntype WindowParams struct {\n\tXID uint64 `json:\"xid\"`\n}\n```\n\n```go\ntype ZoomParams struct {\n\tPage  string  `json:\"page\"`\n\tScale float64 `json:\"scale\"`\n}\n```\n\n","path":"github.com/lichdotdev/lich/browserwire","name":"browserwire","synopsis":"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.","isRedistributable":true}
