Documentation
¶
Index ¶
- func ActionError(w io.Writer, msg string, opts OutputOptions) error
- func ActionSuccess(w io.Writer) error
- func ComputedStyles(w io.Writer, styles map[string]string) error
- func ComputedStylesMulti(w io.Writer, elements []ipc.ElementWithStyles) error
- func Console(w io.Writer, entries []ipc.ConsoleEntry, opts OutputOptions) error
- func ConsoleDetail(w io.Writer, e ipc.ConsoleEntry, opts OutputOptions) error
- func Cookies(w io.Writer, cookies []ipc.Cookie, opts OutputOptions) error
- func EvalResult(w io.Writer, data ipc.EvalData) error
- func FilePath(w io.Writer, path string) error
- func FormatElementIdentifier(meta ipc.ElementMeta, index int) string
- func InlineStyles(w io.Writer, elements []ipc.ElementWithStyles) error
- func MatchedRules(w io.Writer, rules []ipc.CSSMatchedRule) error
- func Network(w io.Writer, entries []ipc.NetworkEntry, opts OutputOptions) error
- func PropertyValue(w io.Writer, value string) error
- func SanitizeIdentifier(s string) string
- func Status(w io.Writer, data ipc.StatusData, opts OutputOptions) error
- func Tab(w io.Writer, data ipc.TabData, opts OutputOptions) error
- func TabError(w io.Writer, errorMsg string, sessions []ipc.PageSession, ...) error
- type DetailLevel
- type OutputOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionError ¶
func ActionError(w io.Writer, msg string, opts OutputOptions) error
ActionError outputs "Error: <message>" for failed action commands.
func ActionSuccess ¶
ActionSuccess outputs "OK" for successful action commands.
func ComputedStyles ¶
ComputedStyles outputs computed styles in text format. Format: property: value (one per line)
func ComputedStylesMulti ¶
func ComputedStylesMulti(w io.Writer, elements []ipc.ElementWithStyles) error
ComputedStylesMulti outputs computed styles for multiple elements. Each element is identified by a CSS selector-style identifier (#id, .class:N, or tag:N) printed on a separate line before its styles. Multiple elements are separated by "--".
Format:
#header color: blue font-size: 16px -- .panel:2 background: white
Elements are identified by priority: ID > first class > tag name. Index numbers are 1-based for user readability.
func Console ¶
func Console(w io.Writer, entries []ipc.ConsoleEntry, opts OutputOptions) error
Console renders the indexed console list: one summary line per entry, prefixed with the entry's seq (its drill-down address). The line carries the wall-clock timestamp, the level, the top stack frame, and the first line of the message. The enriched payload (full multi-line text, complete stack, all arguments, and exception or Log-domain detail) is reserved for drill-down (ConsoleDetail).
func ConsoleDetail ¶
func ConsoleDetail(w io.Writer, e ipc.ConsoleEntry, opts OutputOptions) error
ConsoleDetail renders a single console entry in full for drill-down: the summary line, then the complete multi-line message, stack, arguments, and any exception or Log-domain correlation on seven-space subordinate lines, matching the network drill-down layout.
func EvalResult ¶
EvalResult outputs the raw JavaScript return value.
func FormatElementIdentifier ¶
func FormatElementIdentifier(meta ipc.ElementMeta, index int) string
FormatElementIdentifier returns a CSS selector-style identifier for an element. The identifier helps users distinguish between multiple elements in output.
Format:
- #id if element has id attribute
- .class:N if element has class attribute (N is 1-based index)
- tag:N fallback using tag name (N is 1-based index)
The index parameter is 0-based but displayed as 1-based (index+1) for user-friendliness. IDs and classes are sanitized to remove invalid CSS identifier characters. If sanitization results in an empty string, the next priority level is used.
Examples:
- Element with id="header" -> "#header"
- Element with class="panel active" at index 0 -> ".panel:1"
- Element with tag "div" at index 2 -> "div:3"
func InlineStyles ¶
func InlineStyles(w io.Writer, elements []ipc.ElementWithStyles) error
InlineStyles outputs inline style attributes for multiple elements. Each element is identified by a CSS selector-style identifier (#id, .class:N, or tag:N) printed on a separate line before its inline style. Multiple elements are separated by "--". Empty inline styles are displayed as "(empty)".
Format:
#main color: red; margin: 10px; -- .item:1 (empty)
Elements are identified by priority: ID > first class > tag name. Index numbers are 1-based for user readability.
func MatchedRules ¶
func MatchedRules(w io.Writer, rules []ipc.CSSMatchedRule) error
MatchedRules outputs matched CSS rules with -- separators.
func Network ¶
func Network(w io.Writer, entries []ipc.NetworkEntry, opts OutputOptions) error
Network outputs network entries in text format.
Text is a curated human convenience; JSON carries the full NetworkEntry. The captured fields are classified for the text view as follows:
- Method, URL, Status, Duration: shown on the main line (the core request line).
- Failed/Error: shown — a failed entry renders a FAILED token plus its reason.
- Type: shown — short resource category (xhr, document, image, ...).
- Size: shown when > 0 — human-readable response size.
- MimeType: omitted — overlaps Type and the printed body; the exact Content-Type stays in JSON and response headers.
- StatusText: omitted — redundant with the numeric status, which is already shown and colourised; a failure's reason comes from Error, not StatusText.
- RequestHeaders/ResponseHeaders: conditional — high-volume, so kept out of the default view and shown only when opts.ShowHeaders (the --headers flag), letting an agent get headers in compact text form without the full JSON.
- RemoteIPAddress/RemotePort/Protocol/ConnectionID: shown on a subordinate "remote:" line when captured — the endpoint actually contacted, the negotiated wire protocol, and the connection id (conn:N) that exposes HTTP/2 multiplexing and keep-alive reuse across entries.
- SecurityState: shown on the same "remote:" line only when not "secure", so a non-secure posture (insecure, neutral, unknown) stands out as a signal while the common secure case stays silent.
- Timing: shown on a subordinate "timing:" line as integer-millisecond phase durations (dns, connect, tls, send, wait) so a slow request reveals where the time went. Phases under half a millisecond are dropped.
- Initiator: shown on a subordinate "initiator:" line as "type url:line" when a location was captured (parser and script initiators), naming what triggered the request. The bare "other" initiator is omitted as noise.
- FromDiskCache/FromServiceWorker/FromPrefetchCache: shown as a single self-describing main-line token (disk, service-worker, prefetch) naming which cache served the response. The origins are mutually exclusive.
func PropertyValue ¶
PropertyValue outputs a single CSS property value.
func SanitizeIdentifier ¶
SanitizeIdentifier removes invalid CSS identifier characters. Only alphanumeric characters, hyphens, and underscores are retained. Returns an empty string if no valid characters remain.
This function is used to clean id and class attributes before using them in CSS selector notation. Invalid characters are stripped to ensure the resulting identifier is valid CSS.
func Status ¶
func Status(w io.Writer, data ipc.StatusData, opts OutputOptions) error
Status outputs daemon status in text format.
func TabError ¶
func TabError(w io.Writer, errorMsg string, sessions []ipc.PageSession, matches []ipc.PageSession, opts OutputOptions) error
TabError outputs a tab error with session/match information.
Types ¶
type DetailLevel ¶
type DetailLevel int
DetailLevel controls how much of each network entry the text formatter renders.
const ( // DetailSummary renders only the main line per entry (no transport block, no // headers, no bodies). A failed entry still shows its failure reason. DetailSummary DetailLevel = iota // DetailStandard adds the transport detail block (remote, timing, initiator) // and, when ShowHeaders is set, the header blocks. This is the default. DetailStandard // DetailFull adds the request and response bodies, bounded by --max-body-size. DetailFull )
type OutputOptions ¶
type OutputOptions struct {
UseColor bool // Enable ANSI color codes
ShowHeaders bool // Render request/response headers (network text mode)
Detail DetailLevel // Network detail level (summary/standard/full)
}
OutputOptions controls text formatting behavior.
func DefaultOptions ¶
func DefaultOptions() OutputOptions
DefaultOptions returns default output options based on TTY detection. Deprecated: Use NewOutputOptions instead for proper color detection.
func NewOutputOptions ¶
func NewOutputOptions(jsonOutput bool, noColorFlag bool) OutputOptions
NewOutputOptions returns output options based on flags and environment. Priority: jsonOutput > noColorFlag > NO_COLOR env > TTY detection.