// pkg/webview/messages.go package webview import "time" // --- Queries (read-only) --- // QueryURL gets the current page URL. Result: string // Use: result, _, err := c.QUERY(webview.QueryURL{Window: "editor"}) type QueryURL struct { Window string `json:"window"` } // QueryTitle gets the current page title. Result: string // Use: result, _, err := c.QUERY(webview.QueryTitle{Window: "editor"}) type QueryTitle struct { Window string `json:"window"` } // QueryConsole gets captured console messages. Result: []ConsoleMessage // Use: result, _, err := c.QUERY(webview.QueryConsole{Window: "editor", Level: "error", Limit: 20}) type QueryConsole struct { Window string `json:"window"` Level string `json:"level,omitempty"` // filter by type: "log", "warn", "error", "info", "debug" Limit int `json:"limit,omitempty"` // max messages (0 = all) } // QuerySelector finds a single element. Result: *ElementInfo (nil if not found) // Use: result, _, err := c.QUERY(webview.QuerySelector{Window: "editor", Selector: "#submit"}) type QuerySelector struct { Window string `json:"window"` Selector string `json:"selector"` } // QuerySelectorAll finds all matching elements. Result: []*ElementInfo // Use: result, _, err := c.QUERY(webview.QuerySelectorAll{Window: "editor", Selector: "button"}) type QuerySelectorAll struct { Window string `json:"window"` Selector string `json:"selector"` } // QueryDOMTree gets HTML content. Result: string (outerHTML) // Use: result, _, err := c.QUERY(webview.QueryDOMTree{Window: "editor", Selector: "main"}) type QueryDOMTree struct { Window string `json:"window"` Selector string `json:"selector,omitempty"` // empty = full document } // QueryComputedStyle returns the computed CSS properties for an element. // Use: result, _, err := c.QUERY(webview.QueryComputedStyle{Window: "editor", Selector: "#panel"}) type QueryComputedStyle struct { Window string `json:"window"` Selector string `json:"selector"` } // QueryPerformance returns page performance metrics. // Use: result, _, err := c.QUERY(webview.QueryPerformance{Window: "editor"}) type QueryPerformance struct { Window string `json:"window"` } // QueryResources returns the page's loaded resource entries. // Use: result, _, err := c.QUERY(webview.QueryResources{Window: "editor"}) type QueryResources struct { Window string `json:"window"` } // QueryNetwork returns the captured network log. // Use: result, _, err := c.QUERY(webview.QueryNetwork{Window: "editor", Limit: 50}) type QueryNetwork struct { Window string `json:"window"` Limit int `json:"limit,omitempty"` } // QueryExceptions returns captured JavaScript exceptions. // Use: result, _, err := c.QUERY(webview.QueryExceptions{Window: "editor", Limit: 10}) type QueryExceptions struct { Window string `json:"window"` Limit int `json:"limit,omitempty"` } // --- Tasks (side-effects) --- // TaskEvaluate executes JavaScript. Result: any (JS return value) // Use: _, _, err := c.PERFORM(webview.TaskEvaluate{Window: "editor", Script: "document.title"}) type TaskEvaluate struct { Window string `json:"window"` Script string `json:"script"` } // TaskClick clicks an element. Result: nil // Use: _, _, err := c.PERFORM(webview.TaskClick{Window: "editor", Selector: "#submit"}) type TaskClick struct { Window string `json:"window"` Selector string `json:"selector"` } // TaskType types text into an element. Result: nil // Use: _, _, err := c.PERFORM(webview.TaskType{Window: "editor", Selector: "#search", Text: "core"}) type TaskType struct { Window string `json:"window"` Selector string `json:"selector"` Text string `json:"text"` } // TaskNavigate navigates to a URL. Result: nil // Use: _, _, err := c.PERFORM(webview.TaskNavigate{Window: "editor", URL: "https://example.com"}) type TaskNavigate struct { Window string `json:"window"` URL string `json:"url"` } // TaskScreenshot captures the page as PNG. Result: ScreenshotResult // Use: result, _, err := c.PERFORM(webview.TaskScreenshot{Window: "editor"}) type TaskScreenshot struct { Window string `json:"window"` } // TaskScreenshotElement captures a specific element as PNG. Result: ScreenshotResult // Use: result, _, err := c.PERFORM(webview.TaskScreenshotElement{Window: "editor", Selector: "#panel"}) type TaskScreenshotElement struct { Window string `json:"window"` Selector string `json:"selector"` } // TaskScroll scrolls to an absolute position (window.scrollTo). Result: nil // Use: _, _, err := c.PERFORM(webview.TaskScroll{Window: "editor", X: 0, Y: 600}) type TaskScroll struct { Window string `json:"window"` X int `json:"x"` Y int `json:"y"` } // TaskHover hovers over an element. Result: nil // Use: _, _, err := c.PERFORM(webview.TaskHover{Window: "editor", Selector: "#help"}) type TaskHover struct { Window string `json:"window"` Selector string `json:"selector"` } // TaskSelect selects an option in a