browser-debugger-cli 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/bdg/SKILL.md +100 -186
- package/README.md +4 -4
- package/dist/commands/console.js +5 -1
- package/dist/commands/dom/a11y.d.ts +1 -1
- package/dist/commands/dom/a11y.js +20 -20
- package/dist/commands/dom/eval.d.ts +2 -1
- package/dist/commands/dom/eval.js +21 -3
- package/dist/commands/dom/formInteraction.js +1 -1
- package/dist/commands/dom/get.js +25 -7
- package/dist/commands/dom/index.js +7 -2
- package/dist/commands/dom/query.d.ts +2 -1
- package/dist/commands/dom/query.js +5 -3
- package/dist/commands/dom/screenshot.js +1 -0
- package/dist/commands/helpJson.js +1 -1
- package/dist/commands/network/list.js +46 -3
- package/dist/commands/optionBehaviors.d.ts +25 -2
- package/dist/commands/optionBehaviors.js +55 -42
- package/dist/commands/peek.js +3 -0
- package/dist/commands/shared/CommandRunner.js +13 -13
- package/dist/commands/shared/daemonErrorHandler.js +2 -2
- package/dist/commands/shared/dataFetcher.d.ts +4 -2
- package/dist/commands/shared/dataFetcher.js +11 -3
- package/dist/commands/shared/handleValidationError.js +3 -3
- package/dist/commands/shared/optionTypes.d.ts +14 -3
- package/dist/commands/shared/startHelpers.js +3 -3
- package/dist/connection/chromeIdentity.d.ts +8 -2
- package/dist/connection/chromeIdentity.js +85 -13
- package/dist/constants.d.ts +29 -1
- package/dist/constants.js +35 -1
- package/dist/daemon/SessionController.js +2 -0
- package/dist/daemon/session/Session.d.ts +2 -1
- package/dist/daemon/session/Session.js +10 -2
- package/dist/daemon/session/TelemetryStore.d.ts +7 -0
- package/dist/daemon/session/TelemetryStore.js +6 -0
- package/dist/daemon/session/commandRegistry.js +23 -5
- package/dist/daemon/session/matchedStylesReset.d.ts +26 -0
- package/dist/daemon/session/matchedStylesReset.js +46 -0
- package/dist/daemon/session/plugins.js +1 -0
- package/dist/daemon/session/triggeredRequests.d.ts +0 -5
- package/dist/daemon/session/triggeredRequests.js +13 -7
- package/dist/daemon.js +742 -460
- package/dist/errors/messages.d.ts +8 -0
- package/dist/errors/messages.js +10 -0
- package/dist/index.js +710 -518
- package/dist/ipc/protocol/commands.d.ts +4 -0
- package/dist/ipc/protocol/inspectTypes.d.ts +5 -2
- package/dist/ipc/session/types.d.ts +5 -1
- package/dist/program.d.ts +14 -0
- package/dist/program.js +53 -0
- package/dist/runtime/dom/elementGeometry.d.ts +23 -0
- package/dist/runtime/dom/elementGeometry.js +17 -15
- package/dist/runtime/dom/elementInfo.d.ts +6 -4
- package/dist/runtime/dom/elementInfo.js +7 -4
- package/dist/runtime/dom/frameScopedConnection.d.ts +7 -0
- package/dist/runtime/dom/frameScopedConnection.js +2 -2
- package/dist/runtime/dom/inspect.d.ts +17 -3
- package/dist/runtime/dom/inspect.js +40 -26
- package/dist/runtime/dom/inspectModel.d.ts +3 -3
- package/dist/runtime/dom/inspectRules.d.ts +29 -3
- package/dist/runtime/dom/inspectRules.js +205 -11
- package/dist/runtime/dom/layout.d.ts +0 -2
- package/dist/runtime/dom/layout.js +1 -2
- package/dist/runtime/dom/reactEventHelpers.d.ts +4 -1
- package/dist/runtime/dom/reactEventHelpers.js +9 -2
- package/dist/runtime/dom/targetNode.d.ts +10 -6
- package/dist/runtime/dom/targetNode.js +15 -8
- package/dist/telemetry/a11y.d.ts +15 -1
- package/dist/telemetry/a11y.js +83 -0
- package/dist/telemetry/har/builder.js +1 -1
- package/dist/telemetry/network.d.ts +13 -16
- package/dist/telemetry/network.js +30 -52
- package/dist/telemetry/networkRetention.d.ts +83 -0
- package/dist/telemetry/networkRetention.js +117 -0
- package/dist/types.d.ts +26 -0
- package/dist/ui/OutputBuilder.d.ts +10 -0
- package/dist/ui/OutputBuilder.js +12 -0
- package/dist/ui/formatters/a11y.d.ts +5 -7
- package/dist/ui/formatters/a11y.js +7 -61
- package/dist/ui/formatters/console/chronological.js +4 -4
- package/dist/ui/formatters/console/follow.d.ts +4 -2
- package/dist/ui/formatters/console/follow.js +6 -3
- package/dist/ui/formatters/console/json.d.ts +3 -6
- package/dist/ui/formatters/console/json.js +9 -13
- package/dist/ui/formatters/console/shared.d.ts +17 -2
- package/dist/ui/formatters/console/shared.js +17 -0
- package/dist/ui/formatters/console/summarize.d.ts +2 -2
- package/dist/ui/formatters/console/summarize.js +22 -7
- package/dist/ui/formatters/console.d.ts +1 -1
- package/dist/ui/formatters/console.js +1 -5
- package/dist/ui/formatters/details.js +1 -1
- package/dist/ui/formatters/dom.d.ts +13 -4
- package/dist/ui/formatters/dom.js +25 -7
- package/dist/ui/formatters/layout.js +2 -1
- package/dist/ui/formatters/longValues.d.ts +14 -0
- package/dist/ui/formatters/longValues.js +23 -0
- package/dist/ui/formatters/networkList.d.ts +8 -2
- package/dist/ui/formatters/networkList.js +11 -2
- package/dist/ui/formatters/preview.d.ts +4 -1
- package/dist/ui/formatters/preview.js +55 -13
- package/dist/ui/formatters/status.js +7 -0
- package/dist/ui/formatters/triggeredRequests.js +2 -1
- package/dist/ui/messages/chrome.d.ts +20 -1
- package/dist/ui/messages/chrome.js +29 -3
- package/dist/ui/messages/commands.d.ts +29 -8
- package/dist/ui/messages/commands.js +36 -8
- package/dist/ui/messages/networkMessages.d.ts +24 -0
- package/dist/ui/messages/networkMessages.js +45 -0
- package/dist/utils/http.d.ts +9 -2
- package/dist/utils/http.js +4 -3
- package/dist/utils/strings.d.ts +19 -0
- package/dist/utils/strings.js +16 -0
- package/package.json +2 -2
|
@@ -7,15 +7,12 @@ import type { ConsoleMessage } from '../../../types.js';
|
|
|
7
7
|
import { type ConsoleFormatOptions, type ConsoleJsonOutput } from './shared.js';
|
|
8
8
|
/**
|
|
9
9
|
* Build the rich JSON output shape (summary + the newest deduped
|
|
10
|
-
* errors/warnings, plus the message list when --list is requested).
|
|
10
|
+
* errors/warnings, plus the message list when --list is requested). Texts
|
|
11
|
+
* longer than 10000 characters are cut with
|
|
12
|
+
* `truncatedFrom`, unless `--full`.
|
|
11
13
|
*
|
|
12
14
|
* Returns a plain object so callers (e.g. runCommand's JSON envelope) can
|
|
13
15
|
* embed it without re-parsing a stringified payload.
|
|
14
16
|
*/
|
|
15
17
|
export declare function buildConsoleJsonOutput(messages: ConsoleMessage[], options: ConsoleFormatOptions): ConsoleJsonOutput;
|
|
16
|
-
/**
|
|
17
|
-
* Format console output as a JSON string. Thin wrapper around
|
|
18
|
-
* buildConsoleJsonOutput for callers that want a serialized payload.
|
|
19
|
-
*/
|
|
20
|
-
export declare function formatConsoleJson(messages: ConsoleMessage[], options: ConsoleFormatOptions): string;
|
|
21
18
|
//# sourceMappingURL=json.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* --list is set.
|
|
5
5
|
*/
|
|
6
6
|
import { lastMessages } from './chronological.js';
|
|
7
|
-
import { analyzeMessages, newestGroups, } from './shared.js';
|
|
7
|
+
import { analyzeMessages, capMessageText, newestGroups, } from './shared.js';
|
|
8
8
|
function toJsonError(dedup, includeStackTrace) {
|
|
9
9
|
const source = dedup.message.stackTrace?.[0];
|
|
10
10
|
return {
|
|
@@ -26,7 +26,9 @@ function toJsonError(dedup, includeStackTrace) {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Build the rich JSON output shape (summary + the newest deduped
|
|
29
|
-
* errors/warnings, plus the message list when --list is requested).
|
|
29
|
+
* errors/warnings, plus the message list when --list is requested). Texts
|
|
30
|
+
* longer than 10000 characters are cut with
|
|
31
|
+
* `truncatedFrom`, unless `--full`.
|
|
30
32
|
*
|
|
31
33
|
* Returns a plain object so callers (e.g. runCommand's JSON envelope) can
|
|
32
34
|
* embed it without re-parsing a stringified payload.
|
|
@@ -37,22 +39,16 @@ export function buildConsoleJsonOutput(messages, options) {
|
|
|
37
39
|
const warnings = newestGroups(grouped.warnings, options.groupLimit);
|
|
38
40
|
const output = {
|
|
39
41
|
summary,
|
|
40
|
-
errors: errors.shown.map((d) => toJsonError(d, true)),
|
|
41
|
-
warnings: warnings.shown.map((d) => toJsonError(d, false)),
|
|
42
|
+
errors: errors.shown.map((d) => capMessageText(toJsonError(d, true), options.full)),
|
|
43
|
+
warnings: warnings.shown.map((d) => capMessageText(toJsonError(d, false), options.full)),
|
|
42
44
|
...(errors.more > 0 && { moreErrors: errors.more }),
|
|
43
45
|
...(warnings.more > 0 && { moreWarnings: warnings.more }),
|
|
44
46
|
...(options.dropped && { dropped: options.dropped }),
|
|
45
47
|
...(options.pageCrashedAt !== undefined && { pageCrashedAt: options.pageCrashedAt }),
|
|
46
48
|
};
|
|
47
|
-
if (options.list)
|
|
48
|
-
output.messages = lastMessages(messages, options.last);
|
|
49
|
+
if (options.list) {
|
|
50
|
+
output.messages = lastMessages(messages, options.last).map((message) => capMessageText(message, options.full));
|
|
51
|
+
}
|
|
49
52
|
return output;
|
|
50
53
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Format console output as a JSON string. Thin wrapper around
|
|
53
|
-
* buildConsoleJsonOutput for callers that want a serialized payload.
|
|
54
|
-
*/
|
|
55
|
-
export function formatConsoleJson(messages, options) {
|
|
56
|
-
return JSON.stringify(buildConsoleJsonOutput(messages, options), null, 2);
|
|
57
|
-
}
|
|
58
54
|
//# sourceMappingURL=json.js.map
|
|
@@ -43,8 +43,6 @@ export interface ConsoleSummary {
|
|
|
43
43
|
* Options for console formatting.
|
|
44
44
|
*/
|
|
45
45
|
export interface ConsoleFormatOptions {
|
|
46
|
-
/** Output as JSON */
|
|
47
|
-
json?: boolean | undefined;
|
|
48
46
|
/** List all messages chronologically (--list flag) */
|
|
49
47
|
list?: boolean | undefined;
|
|
50
48
|
/** Follow mode (live streaming) */
|
|
@@ -63,6 +61,8 @@ export interface ConsoleFormatOptions {
|
|
|
63
61
|
dropped?: number | undefined;
|
|
64
62
|
/** When the page crashed (epoch ms), while it is not loaded again */
|
|
65
63
|
pageCrashedAt?: number | undefined;
|
|
64
|
+
/** Print message texts whole (`--full`) */
|
|
65
|
+
full?: boolean | undefined;
|
|
66
66
|
}
|
|
67
67
|
/** Distinct errors and warnings the summary lists without `--last` */
|
|
68
68
|
export declare const DEFAULT_GROUP_LIMIT = 50;
|
|
@@ -95,6 +95,8 @@ export interface JsonErrorEntry {
|
|
|
95
95
|
count: number;
|
|
96
96
|
level: string;
|
|
97
97
|
text: string;
|
|
98
|
+
/** Original length of `text` when it was cut (`--full` keeps it whole) */
|
|
99
|
+
truncatedFrom?: number;
|
|
98
100
|
/** Position in the session's message list (what `details console <n>` takes) */
|
|
99
101
|
index?: number;
|
|
100
102
|
/** Where it came from; no line/column for a resource URL (e.g. a failed load) */
|
|
@@ -175,4 +177,17 @@ export declare function formatSectionHeader(label: string, unique: number, total
|
|
|
175
177
|
* @returns Location text
|
|
176
178
|
*/
|
|
177
179
|
export declare function formatFramePosition(frame: StackFrame): string;
|
|
180
|
+
/**
|
|
181
|
+
* A console message (or error entry) for JSON output: its text cut to
|
|
182
|
+
* {@link MAX_CONSOLE_JSON_TEXT_LENGTH} characters with `truncatedFrom`, or
|
|
183
|
+
* whole with `--full`.
|
|
184
|
+
*
|
|
185
|
+
* @param message - Message with a text
|
|
186
|
+
* @param full - `--full`: keep the text whole
|
|
187
|
+
* @returns The message, with the text cut when too long
|
|
188
|
+
*/
|
|
189
|
+
export declare function capMessageText<T extends {
|
|
190
|
+
text: string;
|
|
191
|
+
truncatedFrom?: number;
|
|
192
|
+
}>(message: T, full: boolean | undefined): T;
|
|
178
193
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared types, constants, and helpers used by every console formatter.
|
|
3
3
|
*/
|
|
4
|
+
import { MAX_CONSOLE_JSON_TEXT_LENGTH } from '../../../constants.js';
|
|
5
|
+
import { capLength } from '../../../utils/strings.js';
|
|
4
6
|
/** Distinct errors and warnings the summary lists without `--last` */
|
|
5
7
|
export const DEFAULT_GROUP_LIMIT = 50;
|
|
6
8
|
/**
|
|
@@ -171,4 +173,19 @@ export function formatFramePosition(frame) {
|
|
|
171
173
|
? frame.url
|
|
172
174
|
: `${frame.url}:${frame.lineNumber + 1}:${frame.columnNumber + 1}`;
|
|
173
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* A console message (or error entry) for JSON output: its text cut to
|
|
178
|
+
* {@link MAX_CONSOLE_JSON_TEXT_LENGTH} characters with `truncatedFrom`, or
|
|
179
|
+
* whole with `--full`.
|
|
180
|
+
*
|
|
181
|
+
* @param message - Message with a text
|
|
182
|
+
* @param full - `--full`: keep the text whole
|
|
183
|
+
* @returns The message, with the text cut when too long
|
|
184
|
+
*/
|
|
185
|
+
export function capMessageText(message, full) {
|
|
186
|
+
if (full)
|
|
187
|
+
return message;
|
|
188
|
+
const { text, truncatedFrom } = capLength(message.text, MAX_CONSOLE_JSON_TEXT_LENGTH);
|
|
189
|
+
return truncatedFrom === undefined ? message : { ...message, text, truncatedFrom };
|
|
190
|
+
}
|
|
174
191
|
//# sourceMappingURL=shared.js.map
|
|
@@ -10,8 +10,8 @@ import { type ConsoleFormatOptions } from './shared.js';
|
|
|
10
10
|
* dropped its oldest messages.
|
|
11
11
|
*
|
|
12
12
|
* @param messages - Messages to summarise
|
|
13
|
-
* @param options - Distinct messages listed
|
|
13
|
+
* @param options - Distinct messages listed, messages dropped and `--full`
|
|
14
14
|
* @returns Summary
|
|
15
15
|
*/
|
|
16
|
-
export declare function formatConsoleSummary(messages: ConsoleMessage[], options?: Pick<ConsoleFormatOptions, 'groupLimit' | 'dropped'>): string;
|
|
16
|
+
export declare function formatConsoleSummary(messages: ConsoleMessage[], options?: Pick<ConsoleFormatOptions, 'groupLimit' | 'dropped' | 'full'>): string;
|
|
17
17
|
//# sourceMappingURL=summarize.d.ts.map
|
|
@@ -2,9 +2,21 @@
|
|
|
2
2
|
* Smart summary view: prioritises errors and warnings with deduplication
|
|
3
3
|
* and shows info/debug/other as count-only footer entries.
|
|
4
4
|
*/
|
|
5
|
+
import { MAX_CONSOLE_TEXT_LENGTH } from '../../../constants.js';
|
|
6
|
+
import { capForDisplay } from '../longValues.js';
|
|
5
7
|
import { OutputFormatter, pluralize } from '../../formatting.js';
|
|
6
8
|
import { consoleDroppedNote, consoleMoreGroupsNote } from '../../messages/consoleMessages.js';
|
|
7
9
|
import { analyzeMessages, formatCountPrefix, formatSectionHeader, formatSourceLocation, newestGroups, } from './shared.js';
|
|
10
|
+
/**
|
|
11
|
+
* A message's text cut like `console --list` cuts it, or whole with `--full`.
|
|
12
|
+
*
|
|
13
|
+
* @param message - Message
|
|
14
|
+
* @param full - `--full`
|
|
15
|
+
* @returns Text to print
|
|
16
|
+
*/
|
|
17
|
+
function messageText(message, full) {
|
|
18
|
+
return capForDisplay(message.text, MAX_CONSOLE_TEXT_LENGTH, full);
|
|
19
|
+
}
|
|
8
20
|
/**
|
|
9
21
|
* The errors: the newest distinct ones, with a note for the earlier ones.
|
|
10
22
|
*
|
|
@@ -12,8 +24,9 @@ import { analyzeMessages, formatCountPrefix, formatSectionHeader, formatSourceLo
|
|
|
12
24
|
* @param errors - Distinct errors in order of first appearance
|
|
13
25
|
* @param total - Errors logged
|
|
14
26
|
* @param limit - Distinct errors listed (0 = all)
|
|
27
|
+
* @param full - Print the texts whole (`--full`)
|
|
15
28
|
*/
|
|
16
|
-
function renderErrorSection(fmt, errors, total, limit) {
|
|
29
|
+
function renderErrorSection(fmt, errors, total, limit, full) {
|
|
17
30
|
if (errors.length === 0)
|
|
18
31
|
return;
|
|
19
32
|
const { shown, more } = newestGroups(errors, limit);
|
|
@@ -22,7 +35,7 @@ function renderErrorSection(fmt, errors, total, limit) {
|
|
|
22
35
|
if (more > 0)
|
|
23
36
|
fmt.text(consoleMoreGroupsNote(more, 'error')).blank();
|
|
24
37
|
for (const { message, count } of shown) {
|
|
25
|
-
fmt.text(`${formatCountPrefix(count)}${message
|
|
38
|
+
fmt.text(`${formatCountPrefix(count)}${messageText(message, full)}`);
|
|
26
39
|
const source = formatSourceLocation(message.stackTrace);
|
|
27
40
|
if (source) {
|
|
28
41
|
fmt.text(` → ${source}`);
|
|
@@ -37,8 +50,9 @@ function renderErrorSection(fmt, errors, total, limit) {
|
|
|
37
50
|
* @param warnings - Distinct warnings in order of first appearance
|
|
38
51
|
* @param total - Warnings logged
|
|
39
52
|
* @param limit - Distinct warnings listed (0 = all)
|
|
53
|
+
* @param full - Print the texts whole (`--full`)
|
|
40
54
|
*/
|
|
41
|
-
function renderWarningSection(fmt, warnings, total, limit) {
|
|
55
|
+
function renderWarningSection(fmt, warnings, total, limit, full) {
|
|
42
56
|
if (warnings.length === 0)
|
|
43
57
|
return;
|
|
44
58
|
const { shown, more } = newestGroups(warnings, limit);
|
|
@@ -47,7 +61,7 @@ function renderWarningSection(fmt, warnings, total, limit) {
|
|
|
47
61
|
if (more > 0)
|
|
48
62
|
fmt.text(consoleMoreGroupsNote(more, 'warning'));
|
|
49
63
|
for (const { message, count } of shown) {
|
|
50
|
-
fmt.text(`• ${formatCountPrefix(count)}${message
|
|
64
|
+
fmt.text(`• ${formatCountPrefix(count)}${messageText(message, full)}`);
|
|
51
65
|
const source = formatSourceLocation(message.stackTrace);
|
|
52
66
|
if (source)
|
|
53
67
|
fmt.text(` → ${source}`);
|
|
@@ -71,7 +85,7 @@ function renderOtherSummary(fmt, summary) {
|
|
|
71
85
|
* dropped its oldest messages.
|
|
72
86
|
*
|
|
73
87
|
* @param messages - Messages to summarise
|
|
74
|
-
* @param options - Distinct messages listed
|
|
88
|
+
* @param options - Distinct messages listed, messages dropped and `--full`
|
|
75
89
|
* @returns Summary
|
|
76
90
|
*/
|
|
77
91
|
export function formatConsoleSummary(messages, options = {}) {
|
|
@@ -82,8 +96,9 @@ export function formatConsoleSummary(messages, options = {}) {
|
|
|
82
96
|
if (options.dropped)
|
|
83
97
|
fmt.text(consoleDroppedNote(options.dropped));
|
|
84
98
|
fmt.blank();
|
|
85
|
-
|
|
86
|
-
|
|
99
|
+
const { groupLimit, full } = options;
|
|
100
|
+
renderErrorSection(fmt, grouped.errors, summary.errors.total, groupLimit, full);
|
|
101
|
+
renderWarningSection(fmt, grouped.warnings, summary.warnings.total, groupLimit, full);
|
|
87
102
|
if (grouped.errors.length === 0 && grouped.warnings.length === 0) {
|
|
88
103
|
fmt.text('No errors or warnings found');
|
|
89
104
|
fmt.blank();
|
|
@@ -11,7 +11,7 @@ export type { ConsoleFormatOptions, ConsoleJsonOutput, ConsoleLevel, ConsoleSkip
|
|
|
11
11
|
export { LEVEL_MAP } from './console/shared.js';
|
|
12
12
|
export { formatConsoleChronological, lastMessages } from './console/chronological.js';
|
|
13
13
|
export { formatConsoleFollowLines } from './console/follow.js';
|
|
14
|
-
export { buildConsoleJsonOutput
|
|
14
|
+
export { buildConsoleJsonOutput } from './console/json.js';
|
|
15
15
|
export { formatConsoleSummary } from './console/summarize.js';
|
|
16
16
|
/**
|
|
17
17
|
* Format console output based on options. Routes to the per-mode formatter:
|
|
@@ -7,12 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { withPageCrashedNote } from '../messages/commands.js';
|
|
9
9
|
import { formatConsoleChronological } from './console/chronological.js';
|
|
10
|
-
import { formatConsoleJson } from './console/json.js';
|
|
11
10
|
import { formatConsoleSummary } from './console/summarize.js';
|
|
12
11
|
export { LEVEL_MAP } from './console/shared.js';
|
|
13
12
|
export { formatConsoleChronological, lastMessages } from './console/chronological.js';
|
|
14
13
|
export { formatConsoleFollowLines } from './console/follow.js';
|
|
15
|
-
export { buildConsoleJsonOutput
|
|
14
|
+
export { buildConsoleJsonOutput } from './console/json.js';
|
|
16
15
|
export { formatConsoleSummary } from './console/summarize.js';
|
|
17
16
|
/**
|
|
18
17
|
* Format console output based on options. Routes to the per-mode formatter:
|
|
@@ -21,9 +20,6 @@ export { formatConsoleSummary } from './console/summarize.js';
|
|
|
21
20
|
* starts with a warning when the page crashed.
|
|
22
21
|
*/
|
|
23
22
|
export function formatConsole(messages, options) {
|
|
24
|
-
if (options.json) {
|
|
25
|
-
return formatConsoleJson(messages, options);
|
|
26
|
-
}
|
|
27
23
|
const body = options.list || options.level
|
|
28
24
|
? formatConsoleChronological(messages, options)
|
|
29
25
|
: formatConsoleSummary(messages, options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { skippedBodyReason } from '../../telemetry/
|
|
1
|
+
import { skippedBodyReason } from '../../telemetry/networkRetention.js';
|
|
2
2
|
import { formatFramePosition, formatTimestamp } from './console/shared.js';
|
|
3
3
|
import { headerValueLines } from './networkHeaders.js';
|
|
4
4
|
import { formatRequestStatus } from './requestStatus.js';
|
|
@@ -33,10 +33,13 @@ export declare function formatDomQuery(data: DomQueryResult): string;
|
|
|
33
33
|
/**
|
|
34
34
|
* Format DOM get results for human-readable output.
|
|
35
35
|
*
|
|
36
|
-
* Displays
|
|
37
|
-
*
|
|
36
|
+
* Displays the outerHTML of matched elements, each cut to its first
|
|
37
|
+
* {@link MAX_VALUE_LENGTH} characters with a pointer naming `--full`. For
|
|
38
|
+
* single elements, shows HTML directly. For multiple elements, shows
|
|
39
|
+
* numbered list with HTML for each.
|
|
38
40
|
*
|
|
39
41
|
* @param data - DOM get result containing array of nodes with outerHTML
|
|
42
|
+
* @param options - `full` to print the HTML whole
|
|
40
43
|
* @returns Formatted output string
|
|
41
44
|
*
|
|
42
45
|
* @example
|
|
@@ -59,7 +62,9 @@ export declare function formatDomQuery(data: DomQueryResult): string;
|
|
|
59
62
|
* // [1] <span class="error">Error 2</span>
|
|
60
63
|
* ```
|
|
61
64
|
*/
|
|
62
|
-
export declare function formatDomGet(data: DomGetResult
|
|
65
|
+
export declare function formatDomGet(data: DomGetResult, options?: {
|
|
66
|
+
full?: boolean | undefined;
|
|
67
|
+
}): string;
|
|
63
68
|
/**
|
|
64
69
|
* Format DOM eval results for human-readable output.
|
|
65
70
|
*
|
|
@@ -69,9 +74,11 @@ export declare function formatDomGet(data: DomGetResult): string;
|
|
|
69
74
|
* JSON-quoted. Other values are formatted JSON, and values Chrome only
|
|
70
75
|
* describes (functions, DOM nodes) their description. The iframe it ran in
|
|
71
76
|
* (`--frame`) is reported on stderr, so stdout stays the bare value. `--json`
|
|
72
|
-
* output is unchanged (the value in `data.result`).
|
|
77
|
+
* output is unchanged (the value in `data.result`). The text is cut to its
|
|
78
|
+
* first {@link MAX_VALUE_LENGTH} characters with a pointer naming `--full`.
|
|
73
79
|
*
|
|
74
80
|
* @param data - DOM eval result containing the evaluated value
|
|
81
|
+
* @param options - `full` to print the value whole
|
|
75
82
|
* @returns The string, or formatted JSON
|
|
76
83
|
*
|
|
77
84
|
* @example
|
|
@@ -90,6 +97,8 @@ export declare function formatDomGet(data: DomGetResult): string;
|
|
|
90
97
|
export declare function formatDomEval(data: {
|
|
91
98
|
result: unknown;
|
|
92
99
|
type?: string;
|
|
100
|
+
}, options?: {
|
|
101
|
+
full?: boolean | undefined;
|
|
93
102
|
}): string;
|
|
94
103
|
/**
|
|
95
104
|
* Format the page's iframes, one per line, nested frames indented below
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { MAX_VALUE_LENGTH } from '../../constants.js';
|
|
1
2
|
import { keyAttributeItems } from './keyAttributes.js';
|
|
3
|
+
import { capForDisplay } from './longValues.js';
|
|
2
4
|
import { OutputFormatter } from '../formatting.js';
|
|
3
5
|
import { frameLabel, framesStillLoadingNote, noFramesMessage, queryMoreMatchesNote, queryViewportCheckedNote, queryNextSteps, screenshotGrownNote, screenshotScaledNote, viewportPositionHint, } from '../messages/commands.js';
|
|
4
6
|
/**
|
|
@@ -75,10 +77,13 @@ function queryTagAttributes(node) {
|
|
|
75
77
|
/**
|
|
76
78
|
* Format DOM get results for human-readable output.
|
|
77
79
|
*
|
|
78
|
-
* Displays
|
|
79
|
-
*
|
|
80
|
+
* Displays the outerHTML of matched elements, each cut to its first
|
|
81
|
+
* {@link MAX_VALUE_LENGTH} characters with a pointer naming `--full`. For
|
|
82
|
+
* single elements, shows HTML directly. For multiple elements, shows
|
|
83
|
+
* numbered list with HTML for each.
|
|
80
84
|
*
|
|
81
85
|
* @param data - DOM get result containing array of nodes with outerHTML
|
|
86
|
+
* @param options - `full` to print the HTML whole
|
|
82
87
|
* @returns Formatted output string
|
|
83
88
|
*
|
|
84
89
|
* @example
|
|
@@ -101,15 +106,16 @@ function queryTagAttributes(node) {
|
|
|
101
106
|
* // [1] <span class="error">Error 2</span>
|
|
102
107
|
* ```
|
|
103
108
|
*/
|
|
104
|
-
export function formatDomGet(data) {
|
|
109
|
+
export function formatDomGet(data, options = {}) {
|
|
105
110
|
const { nodes } = data;
|
|
111
|
+
const html = (node) => capForDisplay(node.outerHTML ?? '', MAX_VALUE_LENGTH, options.full);
|
|
106
112
|
if (nodes.length === 1) {
|
|
107
113
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
108
|
-
return nodes[0]
|
|
114
|
+
return html(nodes[0]);
|
|
109
115
|
}
|
|
110
116
|
const fmt = new OutputFormatter();
|
|
111
117
|
nodes.forEach((node, i) => {
|
|
112
|
-
fmt.text(`[${i}] ${node
|
|
118
|
+
fmt.text(`[${i}] ${html(node)}`);
|
|
113
119
|
});
|
|
114
120
|
return fmt.build();
|
|
115
121
|
}
|
|
@@ -122,9 +128,11 @@ export function formatDomGet(data) {
|
|
|
122
128
|
* JSON-quoted. Other values are formatted JSON, and values Chrome only
|
|
123
129
|
* describes (functions, DOM nodes) their description. The iframe it ran in
|
|
124
130
|
* (`--frame`) is reported on stderr, so stdout stays the bare value. `--json`
|
|
125
|
-
* output is unchanged (the value in `data.result`).
|
|
131
|
+
* output is unchanged (the value in `data.result`). The text is cut to its
|
|
132
|
+
* first {@link MAX_VALUE_LENGTH} characters with a pointer naming `--full`.
|
|
126
133
|
*
|
|
127
134
|
* @param data - DOM eval result containing the evaluated value
|
|
135
|
+
* @param options - `full` to print the value whole
|
|
128
136
|
* @returns The string, or formatted JSON
|
|
129
137
|
*
|
|
130
138
|
* @example
|
|
@@ -140,7 +148,17 @@ export function formatDomGet(data) {
|
|
|
140
148
|
* // }
|
|
141
149
|
* ```
|
|
142
150
|
*/
|
|
143
|
-
export function formatDomEval(data) {
|
|
151
|
+
export function formatDomEval(data, options = {}) {
|
|
152
|
+
return capForDisplay(evalResultText(data), MAX_VALUE_LENGTH, options.full);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* An eval result as text: a string as is unless it would read as another
|
|
156
|
+
* value, else formatted JSON.
|
|
157
|
+
*
|
|
158
|
+
* @param data - DOM eval result
|
|
159
|
+
* @returns Text of the value
|
|
160
|
+
*/
|
|
161
|
+
function evalResultText(data) {
|
|
144
162
|
if (data.type === 'undefined')
|
|
145
163
|
return 'undefined';
|
|
146
164
|
const { result } = data;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Human-readable output of `bdg dom layout`.
|
|
3
3
|
*/
|
|
4
|
+
import { LAYOUT_ELEMENT_LIMIT } from '../../constants.js';
|
|
4
5
|
import { indexSourceText } from '../../errors/messages.js';
|
|
5
6
|
import { OutputFormatter } from '../formatting.js';
|
|
6
7
|
import { coverText, indexLayoutHeadline, layoutHeadline, layoutPositionLabel, maskedText, moreMatchesNote, pageLayoutLine, } from '../messages/commands.js';
|
|
@@ -48,7 +49,7 @@ export function formatLayout(data) {
|
|
|
48
49
|
? indexLayoutHeadline(indexSourceText(data.indexSource))
|
|
49
50
|
: layoutHeadline(data.count, data.elements.length + (data.omitted ?? 0), data.selector))
|
|
50
51
|
.list(shown.map((element) => layoutLine(element, data.page.viewport)))
|
|
51
|
-
.list(more > 0 ? [moreMatchesNote(more,
|
|
52
|
+
.list(more > 0 ? [moreMatchesNote(more, LAYOUT_ELEMENT_LIMIT)] : [])
|
|
52
53
|
.build();
|
|
53
54
|
}
|
|
54
55
|
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Long values in human output: cut, with a pointer naming `--full`.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* A value for human output: its first `maxLength` characters followed by
|
|
6
|
+
* how many more there are, or all of it with `--full`.
|
|
7
|
+
*
|
|
8
|
+
* @param text - Value
|
|
9
|
+
* @param maxLength - Characters printed
|
|
10
|
+
* @param full - `--full`: print it whole
|
|
11
|
+
* @returns Text to print
|
|
12
|
+
*/
|
|
13
|
+
export declare function capForDisplay(text: string, maxLength: number, full?: boolean): string;
|
|
14
|
+
//# sourceMappingURL=longValues.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Long values in human output: cut, with a pointer naming `--full`.
|
|
3
|
+
*/
|
|
4
|
+
import { moreCharsNote } from '../messages/commands.js';
|
|
5
|
+
import { capLength } from '../../utils/strings.js';
|
|
6
|
+
/**
|
|
7
|
+
* A value for human output: its first `maxLength` characters followed by
|
|
8
|
+
* how many more there are, or all of it with `--full`.
|
|
9
|
+
*
|
|
10
|
+
* @param text - Value
|
|
11
|
+
* @param maxLength - Characters printed
|
|
12
|
+
* @param full - `--full`: print it whole
|
|
13
|
+
* @returns Text to print
|
|
14
|
+
*/
|
|
15
|
+
export function capForDisplay(text, maxLength, full) {
|
|
16
|
+
if (full)
|
|
17
|
+
return text;
|
|
18
|
+
const capped = capLength(text, maxLength);
|
|
19
|
+
return capped.truncatedFrom === undefined
|
|
20
|
+
? text
|
|
21
|
+
: `${capped.text}${moreCharsNote(capped.truncatedFrom - capped.text.length)}`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=longValues.js.map
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* with support for filtering results display.
|
|
6
6
|
*/
|
|
7
7
|
import type { NetworkRequest } from '../../types.js';
|
|
8
|
+
import { type NetworkEvictionCounts } from '../messages/networkMessages.js';
|
|
8
9
|
export interface NetworkListOptions {
|
|
9
10
|
verbose?: boolean;
|
|
10
11
|
/** Start of the current page, which the START column counts from ({@link pageStartOf}) */
|
|
@@ -13,6 +14,8 @@ export interface NetworkListOptions {
|
|
|
13
14
|
totalCount?: number;
|
|
14
15
|
/** Requests matching the filters, before --last (defaults to totalCount) */
|
|
15
16
|
filteredCount?: number;
|
|
17
|
+
/** Requests dropped and bodies evicted at the session's capture limits */
|
|
18
|
+
evictions?: NetworkEvictionCounts;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
21
|
* When the current page started loading: the request of its document, in
|
|
@@ -41,16 +44,19 @@ export declare function pageStartOf(requests: NetworkRequest[]): PageStart | und
|
|
|
41
44
|
export declare function formatStartOffset(request: NetworkRequest, pageStart: PageStart | undefined): string;
|
|
42
45
|
/**
|
|
43
46
|
* Rows of the network stream: requests that finished since the last poll,
|
|
44
|
-
* with the column header the first time (the stream banner is on stderr)
|
|
47
|
+
* with the column header the first time (the stream banner is on stderr),
|
|
48
|
+
* after the dropped/evicted note when the counts changed.
|
|
45
49
|
*
|
|
46
50
|
* @param requests - Newly finished requests
|
|
47
|
-
* @param options - `header` the first time; `verbose` for full URLs; the page start for
|
|
51
|
+
* @param options - `header` the first time; `verbose` for full URLs; the page start for
|
|
52
|
+
* START; `evictions` only when the session's counts changed since the last poll
|
|
48
53
|
* @returns Text to print (empty when there is nothing new)
|
|
49
54
|
*/
|
|
50
55
|
export declare function formatNetworkFollowRows(requests: NetworkRequest[], options?: {
|
|
51
56
|
header?: boolean;
|
|
52
57
|
verbose?: boolean;
|
|
53
58
|
pageStart?: PageStart;
|
|
59
|
+
evictions?: NetworkEvictionCounts;
|
|
54
60
|
}): string;
|
|
55
61
|
/**
|
|
56
62
|
* Format network requests for display.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { getResourceTypeAbbr } from './preview.js';
|
|
8
8
|
import { getRequestState } from './requestStatus.js';
|
|
9
9
|
import { OutputFormatter, truncateUrl } from '../formatting.js';
|
|
10
|
+
import { networkEvictedNote } from '../messages/networkMessages.js';
|
|
10
11
|
const SIZE_UNITS = ['B', 'KB', 'MB', 'GB'];
|
|
11
12
|
const SEPARATOR_WIDTH = 80;
|
|
12
13
|
function formatSize(bytes) {
|
|
@@ -154,6 +155,9 @@ function formatNetworkListHuman(requests, options) {
|
|
|
154
155
|
const header = buildHeader(requests.length, options.filteredCount ?? totalCount, totalCount);
|
|
155
156
|
fmt.text(header);
|
|
156
157
|
fmt.separator('─', SEPARATOR_WIDTH);
|
|
158
|
+
const evictedNote = options.evictions && networkEvictedNote(options.evictions);
|
|
159
|
+
if (evictedNote)
|
|
160
|
+
fmt.text(evictedNote);
|
|
157
161
|
if (requests.length === 0) {
|
|
158
162
|
fmt.text('No matching requests found.');
|
|
159
163
|
return fmt.build();
|
|
@@ -170,15 +174,20 @@ function formatNetworkListHuman(requests, options) {
|
|
|
170
174
|
const FOLLOW_ID_WIDTH = 14;
|
|
171
175
|
/**
|
|
172
176
|
* Rows of the network stream: requests that finished since the last poll,
|
|
173
|
-
* with the column header the first time (the stream banner is on stderr)
|
|
177
|
+
* with the column header the first time (the stream banner is on stderr),
|
|
178
|
+
* after the dropped/evicted note when the counts changed.
|
|
174
179
|
*
|
|
175
180
|
* @param requests - Newly finished requests
|
|
176
|
-
* @param options - `header` the first time; `verbose` for full URLs; the page start for
|
|
181
|
+
* @param options - `header` the first time; `verbose` for full URLs; the page start for
|
|
182
|
+
* START; `evictions` only when the session's counts changed since the last poll
|
|
177
183
|
* @returns Text to print (empty when there is nothing new)
|
|
178
184
|
*/
|
|
179
185
|
export function formatNetworkFollowRows(requests, options = {}) {
|
|
180
186
|
const fmt = new OutputFormatter();
|
|
181
187
|
const widths = columnWidths(requests, FOLLOW_ID_WIDTH);
|
|
188
|
+
const evictedNote = options.evictions && networkEvictedNote(options.evictions);
|
|
189
|
+
if (evictedNote)
|
|
190
|
+
fmt.text(evictedNote);
|
|
182
191
|
if (options.header) {
|
|
183
192
|
fmt.text(formatColumnHeader(widths));
|
|
184
193
|
fmt.separator('─', SEPARATOR_WIDTH);
|
|
@@ -39,6 +39,8 @@ export interface PreviewOptions {
|
|
|
39
39
|
filteredTypes?: string[] | undefined;
|
|
40
40
|
/** Total network requests before filtering (for showing feedback when no matches). */
|
|
41
41
|
unfilteredNetworkCount?: number | undefined;
|
|
42
|
+
/** Console message texts whole instead of cut (`--full`). */
|
|
43
|
+
full?: boolean | undefined;
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
44
46
|
* Format preview output (peek command)
|
|
@@ -59,7 +61,8 @@ export interface PreviewJsonData {
|
|
|
59
61
|
console?: BdgOutput['data']['console'];
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
|
-
* Build the JSON payload for a preview, honoring the section and `--last`
|
|
64
|
+
* Build the JSON payload for a preview, honoring the section and `--last`
|
|
65
|
+
* filters; console texts are cut with `truncatedFrom` unless `--full`.
|
|
63
66
|
*
|
|
64
67
|
* @param output - Preview output from the daemon
|
|
65
68
|
* @param options - Preview options (section filters, last N)
|