browser-debugger-cli 0.12.0 → 0.13.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 +4 -4
- package/README.md +1 -0
- package/dist/commands/cdp.d.ts +22 -1
- package/dist/commands/cdp.js +100 -43
- package/dist/commands/console.d.ts +12 -0
- package/dist/commands/console.js +62 -12
- package/dist/commands/dom/DomElementResolver.d.ts +3 -1
- package/dist/commands/dom/DomElementResolver.js +10 -3
- package/dist/commands/dom/a11y.js +3 -2
- package/dist/commands/dom/eval.d.ts +3 -2
- package/dist/commands/dom/eval.js +11 -5
- package/dist/commands/dom/form.js +10 -9
- package/dist/commands/dom/formInteraction.js +8 -7
- package/dist/commands/dom/get.js +8 -8
- package/dist/commands/dom/helpers/index.d.ts +1 -1
- package/dist/commands/dom/helpers/index.js +1 -1
- package/dist/commands/dom/helpers/query.d.ts +27 -3
- package/dist/commands/dom/helpers/query.js +152 -64
- package/dist/commands/dom/helpers/screenshot.js +13 -13
- package/dist/commands/dom/index.js +4 -2
- package/dist/commands/dom/query.d.ts +19 -2
- package/dist/commands/dom/query.js +37 -6
- package/dist/commands/dom/screenshot.js +2 -1
- package/dist/commands/dom/semanticUtils.d.ts +3 -2
- package/dist/commands/dom/semanticUtils.js +40 -9
- package/dist/commands/helpJson.d.ts +82 -19
- package/dist/commands/helpJson.js +111 -40
- package/dist/commands/helpTopic.d.ts +16 -1
- package/dist/commands/helpTopic.js +59 -1
- package/dist/commands/installSkill.d.ts +15 -5
- package/dist/commands/installSkill.js +86 -16
- package/dist/commands/network/list.js +22 -12
- package/dist/commands/optionBehaviors.js +33 -11
- package/dist/commands/shared/daemonErrorHandler.d.ts +5 -2
- package/dist/commands/shared/daemonErrorHandler.js +20 -9
- package/dist/commands/shared/dataFetcher.d.ts +12 -4
- package/dist/commands/shared/dataFetcher.js +12 -4
- package/dist/commands/shared/followMode.d.ts +9 -1
- package/dist/commands/shared/followMode.js +22 -4
- package/dist/commands/shared/optionTypes.d.ts +4 -1
- package/dist/commands/shared/outputFile.js +6 -1
- package/dist/commands/start.d.ts +7 -5
- package/dist/commands/start.js +65 -21
- package/dist/commands/stop.d.ts +11 -0
- package/dist/commands/stop.js +24 -1
- package/dist/commands.js +1 -1
- package/dist/connection/cdp.d.ts +7 -0
- package/dist/connection/cdp.js +9 -0
- package/dist/connection/launcher.js +3 -2
- package/dist/daemon/SessionController.js +6 -1
- package/dist/daemon/launcher.d.ts +3 -2
- package/dist/daemon/launcher.js +47 -3
- package/dist/daemon/session/Session.d.ts +4 -1
- package/dist/daemon/session/Session.js +33 -2
- package/dist/daemon/session/TelemetryStore.d.ts +8 -1
- package/dist/daemon/session/TelemetryStore.js +13 -1
- package/dist/daemon/session/commandRegistry.js +29 -13
- package/dist/daemon/session/interactions.d.ts +2 -1
- package/dist/daemon/session/interactions.js +13 -1
- package/dist/daemon/session/plugins.js +16 -2
- package/dist/daemon/session/teardown.js +1 -1
- package/dist/daemon.js +1622 -748
- package/dist/errors/messages.d.ts +54 -11
- package/dist/errors/messages.js +109 -22
- package/dist/index.js +13733 -8796
- package/dist/ipc/client.d.ts +18 -2
- package/dist/ipc/client.js +26 -5
- package/dist/ipc/protocol/auditTypes.d.ts +8 -2
- package/dist/ipc/protocol/commands.d.ts +12 -0
- package/dist/ipc/protocol/domTypes.d.ts +12 -0
- package/dist/ipc/protocol/inspectTypes.d.ts +2 -0
- package/dist/ipc/session/types.d.ts +2 -0
- package/dist/runtime/dom/actionEffects.d.ts +5 -1
- package/dist/runtime/dom/actionEffects.js +26 -14
- package/dist/runtime/dom/audit.js +3 -2
- package/dist/runtime/dom/auditModel.js +6 -1
- package/dist/runtime/dom/auditScripts.d.ts +9 -3
- package/dist/runtime/dom/auditScripts.js +41 -5
- package/dist/runtime/dom/elementGeometry.d.ts +10 -3
- package/dist/runtime/dom/elementGeometry.js +27 -4
- package/dist/runtime/dom/elementInfo.d.ts +74 -18
- package/dist/runtime/dom/elementInfo.js +187 -40
- package/dist/runtime/dom/evalHelpers.d.ts +12 -2
- package/dist/runtime/dom/evalHelpers.js +67 -7
- package/dist/runtime/dom/formDiscovery.d.ts +6 -2
- package/dist/runtime/dom/formDiscovery.js +20 -3
- package/dist/runtime/dom/formFillHelpers/fill.js +7 -11
- package/dist/runtime/dom/formFillHelpers/pressKey.js +2 -2
- package/dist/runtime/dom/formFillHelpers/shared.d.ts +16 -10
- package/dist/runtime/dom/formFillHelpers/shared.js +19 -52
- package/dist/runtime/dom/formSubmitHelpers.js +4 -3
- package/dist/runtime/dom/frameLayout.js +1 -0
- package/dist/runtime/dom/inspect.js +5 -6
- package/dist/runtime/dom/inspectAllStyles.js +1 -0
- package/dist/runtime/dom/inspectHints.d.ts +1 -1
- package/dist/runtime/dom/inspectModel.d.ts +2 -1
- package/dist/runtime/dom/inspectModel.js +7 -3
- package/dist/runtime/dom/inspectPaintModel.d.ts +2 -0
- package/dist/runtime/dom/inspectPaintModel.js +3 -1
- package/dist/runtime/dom/inspectScripts.d.ts +29 -2
- package/dist/runtime/dom/inspectScripts.js +49 -10
- package/dist/runtime/dom/layout.js +9 -7
- package/dist/runtime/dom/reactEventHelpers.d.ts +14 -4
- package/dist/runtime/dom/reactEventHelpers.js +63 -27
- package/dist/runtime/dom/targetNode.d.ts +18 -5
- package/dist/runtime/dom/targetNode.js +268 -8
- package/dist/runtime/dom/wait.js +2 -1
- package/dist/runtime/page/bdgWorld.d.ts +57 -0
- package/dist/runtime/page/bdgWorld.js +180 -0
- package/dist/runtime/page/replacedBuiltins.d.ts +28 -0
- package/dist/runtime/page/replacedBuiltins.js +136 -0
- package/dist/session/QueryCacheManager.d.ts +4 -1
- package/dist/session/QueryCacheManager.js +5 -2
- package/dist/session/chrome.d.ts +4 -1
- package/dist/session/chrome.js +7 -1
- package/dist/session/cleanup/staleSession.d.ts +21 -4
- package/dist/session/cleanup/staleSession.js +79 -9
- package/dist/session/cleanup/userCommands.d.ts +4 -1
- package/dist/session/cleanup/userCommands.js +10 -5
- package/dist/session/daemonSocket.d.ts +10 -0
- package/dist/session/daemonSocket.js +22 -0
- package/dist/session/lastSession.d.ts +6 -3
- package/dist/session/lastSession.js +11 -5
- package/dist/session/paths.d.ts +3 -1
- package/dist/session/paths.js +5 -5
- package/dist/session/portClaims.js +4 -3
- package/dist/session/sessionList.d.ts +13 -5
- package/dist/session/sessionList.js +31 -7
- package/dist/telemetry/a11y.js +2 -2
- package/dist/telemetry/console.d.ts +2 -1
- package/dist/telemetry/console.js +30 -21
- package/dist/telemetry/pageCrash.d.ts +26 -0
- package/dist/telemetry/pageCrash.js +53 -0
- package/dist/types.d.ts +16 -0
- package/dist/ui/formatters/audit.js +14 -5
- package/dist/ui/formatters/cdp.d.ts +138 -0
- package/dist/ui/formatters/cdp.js +131 -0
- package/dist/ui/formatters/console/chronological.js +3 -1
- package/dist/ui/formatters/console/follow.d.ts +2 -1
- package/dist/ui/formatters/console/follow.js +2 -2
- package/dist/ui/formatters/console/json.d.ts +2 -2
- package/dist/ui/formatters/console/json.js +11 -5
- package/dist/ui/formatters/console/shared.d.ts +30 -0
- package/dist/ui/formatters/console/shared.js +16 -0
- package/dist/ui/formatters/console/summarize.d.ts +9 -2
- package/dist/ui/formatters/console/summarize.js +40 -9
- package/dist/ui/formatters/console.d.ts +2 -1
- package/dist/ui/formatters/console.js +7 -5
- package/dist/ui/formatters/details.js +3 -1
- package/dist/ui/formatters/dom.d.ts +1 -1
- package/dist/ui/formatters/dom.js +5 -6
- package/dist/ui/formatters/helpFormatters.js +1 -1
- package/dist/ui/formatters/inspect.js +9 -3
- package/dist/ui/formatters/installSkill.d.ts +9 -1
- package/dist/ui/formatters/installSkill.js +32 -6
- package/dist/ui/formatters/layout.js +2 -1
- package/dist/ui/formatters/networkList.d.ts +1 -1
- package/dist/ui/formatters/networkList.js +1 -2
- package/dist/ui/formatters/preview.d.ts +2 -0
- package/dist/ui/formatters/preview.js +17 -7
- package/dist/ui/formatters/sessions.d.ts +2 -2
- package/dist/ui/formatters/sessions.js +9 -2
- package/dist/ui/logging/logger.d.ts +1 -1
- package/dist/ui/messages/commands.d.ts +124 -4
- package/dist/ui/messages/commands.js +162 -7
- package/dist/ui/messages/consoleMessages.d.ts +24 -0
- package/dist/ui/messages/consoleMessages.js +32 -0
- package/dist/ui/messages/preview.d.ts +6 -0
- package/dist/ui/messages/preview.js +9 -1
- package/dist/ui/messages/session.d.ts +13 -2
- package/dist/ui/messages/session.js +22 -3
- package/dist/utils/directories.d.ts +34 -0
- package/dist/utils/directories.js +88 -0
- package/dist/utils/display.d.ts +16 -0
- package/dist/utils/display.js +42 -0
- package/dist/utils/exitCodes.d.ts +1 -0
- package/dist/utils/exitCodes.js +6 -0
- package/dist/utils/process.d.ts +12 -0
- package/dist/utils/process.js +25 -0
- package/package.json +1 -1
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { keyAttributeItems } from './keyAttributes.js';
|
|
2
2
|
import { OutputFormatter } from '../formatting.js';
|
|
3
|
-
import { frameLabel,
|
|
4
|
-
/** Matches listed in human output (JSON has all of them) */
|
|
5
|
-
const QUERY_DISPLAY_LIMIT = 50;
|
|
3
|
+
import { frameLabel, framesStillLoadingNote, noFramesMessage, queryMoreMatchesNote, queryViewportCheckedNote, queryNextSteps, screenshotGrownNote, screenshotScaledNote, viewportPositionHint, } from '../messages/commands.js';
|
|
6
4
|
/**
|
|
7
5
|
* Format DOM query results for human-readable output.
|
|
8
6
|
*
|
|
9
7
|
* Displays found nodes with their index, tag, identifying attributes
|
|
10
8
|
* ({@link queryTagAttributes}), classes, and preview text
|
|
11
9
|
* (plus where they are when outside the viewport or hidden, e.g.
|
|
12
|
-
* `(below fold)`),
|
|
10
|
+
* `(below fold)`), as many as `--limit` listed, with a note for the rest (no match is an error, exit 83).
|
|
13
11
|
* One line of next commands follows; they take the match's index, so they
|
|
14
12
|
* work for matches in shadow roots and iframes too.
|
|
15
13
|
*
|
|
@@ -35,7 +33,7 @@ const QUERY_DISPLAY_LIMIT = 50;
|
|
|
35
33
|
export function formatDomQuery(data) {
|
|
36
34
|
const { count, nodes, selector } = data;
|
|
37
35
|
const fmt = new OutputFormatter();
|
|
38
|
-
const nodeLines = nodes.
|
|
36
|
+
const nodeLines = nodes.map((node) => {
|
|
39
37
|
const attributes = queryTagAttributes(node)
|
|
40
38
|
.map((item) => ` ${item}`)
|
|
41
39
|
.join('');
|
|
@@ -49,7 +47,8 @@ export function formatDomQuery(data) {
|
|
|
49
47
|
return fmt
|
|
50
48
|
.text(`Found ${count} node${count === 1 ? '' : 's'} matching "${selector}":`)
|
|
51
49
|
.list(nodeLines)
|
|
52
|
-
.list(
|
|
50
|
+
.list(data.omitted ? [queryMoreMatchesNote(data.omitted, data.indexed)] : [])
|
|
51
|
+
.list(data.viewportChecked ? [queryViewportCheckedNote(data.viewportChecked)] : [])
|
|
53
52
|
.tip(queryNextSteps(exampleIndex))
|
|
54
53
|
.build();
|
|
55
54
|
}
|
|
@@ -17,7 +17,7 @@ import { section } from '../formatting.js';
|
|
|
17
17
|
export function buildAgentDiscoveryHelp() {
|
|
18
18
|
const counts = getProtocolCounts();
|
|
19
19
|
return section('For AI Agents:', [
|
|
20
|
-
'bdg --help --json
|
|
20
|
+
'bdg --help --json Commands, flags, exit codes (bdg <cmd> --help --json: details)',
|
|
21
21
|
`bdg cdp --list List all ${counts.domains} CDP domains`,
|
|
22
22
|
`bdg cdp --search <term> Search ${counts.methods} CDP methods`,
|
|
23
23
|
]);
|
|
@@ -212,6 +212,9 @@ function fontParts(text) {
|
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* A contrast as words, e.g. `contrast 4.47 fail on #fff (faded: opacity 0.4)`.
|
|
215
|
+
* An approximate one gets no pass/fail level, only the estimate and why
|
|
216
|
+
* (`contrast ≈1 on #fff (approximate: img.hero behind)`): what is behind
|
|
217
|
+
* the text is not a known color.
|
|
215
218
|
*
|
|
216
219
|
* @param contrast - Contrast
|
|
217
220
|
* @returns Words, or undefined
|
|
@@ -221,10 +224,9 @@ function contrastText(contrast) {
|
|
|
221
224
|
return undefined;
|
|
222
225
|
return [
|
|
223
226
|
contrast.approximate
|
|
224
|
-
? `contrast ≈${contrast.ratio}
|
|
227
|
+
? `contrast ≈${contrast.ratio}`
|
|
225
228
|
: `contrast ${contrast.ratio} ${contrast.level}`,
|
|
226
229
|
`on ${contrast.background}`,
|
|
227
|
-
contrast.overImage && '(over image)',
|
|
228
230
|
contrast.opacity !== undefined && `(faded: opacity ${contrast.opacity})`,
|
|
229
231
|
contrast.approximate && `(approximate: ${contrast.approximate.join(', ')})`,
|
|
230
232
|
]
|
|
@@ -274,7 +276,7 @@ function fillText(fill) {
|
|
|
274
276
|
.join(' ');
|
|
275
277
|
}
|
|
276
278
|
/**
|
|
277
|
-
* The fill line: backgrounds, opacity and blend mode.
|
|
279
|
+
* The fill line: backgrounds (and that they are clipped to gradient text), opacity and blend mode.
|
|
278
280
|
*
|
|
279
281
|
* @param data - Inspect result
|
|
280
282
|
* @returns Line
|
|
@@ -286,6 +288,10 @@ function fillLine(data) {
|
|
|
286
288
|
paint &&
|
|
287
289
|
`stroke ${paint.stroke}${paint.strokeWidth !== undefined ? ` ${paint.strokeWidth}` : ''}`,
|
|
288
290
|
...(data.fills ?? []).map(fillText),
|
|
291
|
+
data.text?.gradientFill &&
|
|
292
|
+
!data.text.holder &&
|
|
293
|
+
(data.fills ?? []).length > 0 &&
|
|
294
|
+
'clipped to the text',
|
|
289
295
|
data.opacity !== undefined && `opacity ${data.opacity}`,
|
|
290
296
|
data.blend && `blend ${data.blend}`,
|
|
291
297
|
]);
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { InstalledSkill } from '../../types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Format
|
|
3
|
+
* Format the targets the skill was written for, as a failed install lists
|
|
4
|
+
* the ones that succeeded.
|
|
5
|
+
*
|
|
6
|
+
* @param skills - Install results
|
|
7
|
+
* @returns Human-readable lines
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatSkillTargets(skills: InstalledSkill[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* Format where the skill was installed, plus what to do next.
|
|
4
12
|
*
|
|
5
13
|
* @param data - Install results
|
|
6
14
|
* @returns Human-readable summary
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { homedir } from 'os';
|
|
2
2
|
import { OutputFormatter } from '../formatting.js';
|
|
3
|
+
import { skillBackupMessage } from '../messages/commands.js';
|
|
4
|
+
/** Indent of the path column, so a backup line sits under the path it belongs to */
|
|
5
|
+
const PATH_INDENT = ' '.repeat(2 + 6 + 2 + 9 + 2);
|
|
3
6
|
/**
|
|
4
7
|
* Shorten a path under the home directory to `~/...`.
|
|
5
8
|
*
|
|
@@ -11,17 +14,40 @@ function tildePath(path) {
|
|
|
11
14
|
return path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
|
|
12
15
|
}
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
17
|
+
* Add where the skill was installed, one line per agent, plus where a
|
|
18
|
+
* replaced copy was kept.
|
|
19
|
+
*
|
|
20
|
+
* @param fmt - Formatter to add the lines to
|
|
21
|
+
* @param skills - Install results
|
|
22
|
+
* @returns The formatter
|
|
23
|
+
*/
|
|
24
|
+
function addSkillTargets(fmt, skills) {
|
|
25
|
+
fmt.text('bdg skill:');
|
|
26
|
+
for (const skill of skills) {
|
|
27
|
+
fmt.text(` ${skill.target.padEnd(6)} ${skill.status.padEnd(9)} ${tildePath(skill.path)}`);
|
|
28
|
+
if (skill.backup)
|
|
29
|
+
fmt.text(`${PATH_INDENT}${skillBackupMessage(tildePath(skill.backup))}`);
|
|
30
|
+
}
|
|
31
|
+
return fmt;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Format the targets the skill was written for, as a failed install lists
|
|
35
|
+
* the ones that succeeded.
|
|
36
|
+
*
|
|
37
|
+
* @param skills - Install results
|
|
38
|
+
* @returns Human-readable lines
|
|
39
|
+
*/
|
|
40
|
+
export function formatSkillTargets(skills) {
|
|
41
|
+
return addSkillTargets(new OutputFormatter(), skills).build();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Format where the skill was installed, plus what to do next.
|
|
15
45
|
*
|
|
16
46
|
* @param data - Install results
|
|
17
47
|
* @returns Human-readable summary
|
|
18
48
|
*/
|
|
19
49
|
export function formatInstalledSkills(data) {
|
|
20
|
-
|
|
21
|
-
for (const skill of data.skills) {
|
|
22
|
-
fmt.text(` ${skill.target.padEnd(6)} ${skill.status.padEnd(9)} ${tildePath(skill.path)}`);
|
|
23
|
-
}
|
|
24
|
-
return fmt
|
|
50
|
+
return addSkillTargets(new OutputFormatter(), data.skills)
|
|
25
51
|
.hints('Next:', [
|
|
26
52
|
'Start a new agent session to load it (running sessions keep the old list)',
|
|
27
53
|
'After upgrading bdg, run bdg install-skill again',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { indexSourceText } from '../../errors/messages.js';
|
|
5
5
|
import { OutputFormatter } from '../formatting.js';
|
|
6
|
-
import { coverText, indexLayoutHeadline, layoutHeadline, layoutPositionLabel, moreMatchesNote, pageLayoutLine, } from '../messages/commands.js';
|
|
6
|
+
import { coverText, indexLayoutHeadline, layoutHeadline, layoutPositionLabel, maskedText, moreMatchesNote, pageLayoutLine, } from '../messages/commands.js';
|
|
7
7
|
/** Elements listed in human output (JSON has up to 100) */
|
|
8
8
|
const LAYOUT_DISPLAY_LIMIT = 20;
|
|
9
9
|
/**
|
|
@@ -26,6 +26,7 @@ export function layoutLine(element, viewport) {
|
|
|
26
26
|
element.coveredBy && coverText(element.coveredBy, element.coverTransparent),
|
|
27
27
|
element.inert && 'inert',
|
|
28
28
|
element.invisible,
|
|
29
|
+
element.masked && maskedText(element.masked),
|
|
29
30
|
element.context && element.context !== element.clippedBy && `in ${element.context}`,
|
|
30
31
|
]
|
|
31
32
|
.filter(Boolean)
|
|
@@ -41,7 +41,7 @@ export declare function pageStartOf(requests: NetworkRequest[]): PageStart | und
|
|
|
41
41
|
export declare function formatStartOffset(request: NetworkRequest, pageStart: PageStart | undefined): string;
|
|
42
42
|
/**
|
|
43
43
|
* Rows of the network stream: requests that finished since the last poll,
|
|
44
|
-
* with the column header the first time.
|
|
44
|
+
* with the column header the first time (the stream banner is on stderr).
|
|
45
45
|
*
|
|
46
46
|
* @param requests - Newly finished requests
|
|
47
47
|
* @param options - `header` the first time; `verbose` for full URLs; the page start for START
|
|
@@ -170,7 +170,7 @@ function formatNetworkListHuman(requests, options) {
|
|
|
170
170
|
const FOLLOW_ID_WIDTH = 14;
|
|
171
171
|
/**
|
|
172
172
|
* Rows of the network stream: requests that finished since the last poll,
|
|
173
|
-
* with the column header the first time.
|
|
173
|
+
* with the column header the first time (the stream banner is on stderr).
|
|
174
174
|
*
|
|
175
175
|
* @param requests - Newly finished requests
|
|
176
176
|
* @param options - `header` the first time; `verbose` for full URLs; the page start for START
|
|
@@ -180,7 +180,6 @@ export function formatNetworkFollowRows(requests, options = {}) {
|
|
|
180
180
|
const fmt = new OutputFormatter();
|
|
181
181
|
const widths = columnWidths(requests, FOLLOW_ID_WIDTH);
|
|
182
182
|
if (options.header) {
|
|
183
|
-
fmt.text('Streaming network requests... (Ctrl+C to stop)');
|
|
184
183
|
fmt.text(formatColumnHeader(widths));
|
|
185
184
|
fmt.separator('─', SEPARATOR_WIDTH);
|
|
186
185
|
}
|
|
@@ -53,6 +53,8 @@ export interface PreviewJsonData {
|
|
|
53
53
|
target: BdgOutput['target'];
|
|
54
54
|
partial?: boolean;
|
|
55
55
|
totals?: BdgOutput['totals'];
|
|
56
|
+
/** When the page's renderer crashed (epoch ms), while it is not loaded again */
|
|
57
|
+
pageCrashedAt?: number;
|
|
56
58
|
network?: BdgOutput['data']['network'];
|
|
57
59
|
console?: BdgOutput['data']['console'];
|
|
58
60
|
}
|
|
@@ -3,7 +3,9 @@ import { buildSuccessResponse } from '../OutputBuilder.js';
|
|
|
3
3
|
import { formatTimestamp } from './console/shared.js';
|
|
4
4
|
import { failureReason, formatRequestStatus, getRequestState, } from './requestStatus.js';
|
|
5
5
|
import { OutputFormatter, truncateUrl, truncateText } from '../formatting.js';
|
|
6
|
+
import { withPageCrashedNote } from '../messages/commands.js';
|
|
6
7
|
import { PREVIEW_EMPTY_STATES, PREVIEW_HEADERS, compactTipsMessage, verboseCommandsMessage, } from '../messages/preview.js';
|
|
8
|
+
import { consoleDroppedNote } from '../messages/consoleMessages.js';
|
|
7
9
|
import { sessionCommand } from '../messages/sessionCommand.js';
|
|
8
10
|
/**
|
|
9
11
|
* Infer resource type from MIME type when CDP doesn't provide it.
|
|
@@ -69,6 +71,7 @@ export function buildPreviewJsonData(output, options) {
|
|
|
69
71
|
target: output.target,
|
|
70
72
|
...(output.partial !== undefined && { partial: output.partial }),
|
|
71
73
|
...(output.totals && { totals: output.totals }),
|
|
74
|
+
...(output.pageCrashedAt !== undefined && { pageCrashedAt: output.pageCrashedAt }),
|
|
72
75
|
...(pick('network') && output.data.network && { network: last(output.data.network) }),
|
|
73
76
|
...(pick('console') && output.data.console && { console: last(output.data.console) }),
|
|
74
77
|
};
|
|
@@ -78,19 +81,22 @@ export function buildPreviewJsonData(output, options) {
|
|
|
78
81
|
*
|
|
79
82
|
* @param output - Preview output
|
|
80
83
|
* @param options - Preview options
|
|
81
|
-
* @returns
|
|
84
|
+
* @returns `{ version, success, data }` envelope, pretty-printed, or on one
|
|
85
|
+
* line in follow mode (one object per line, NDJSON)
|
|
82
86
|
*/
|
|
83
87
|
function formatPreviewAsJson(output, options) {
|
|
84
|
-
|
|
88
|
+
const envelope = buildSuccessResponse(buildPreviewJsonData(output, options));
|
|
89
|
+
return options.follow ? JSON.stringify(envelope) : JSON.stringify(envelope, null, 2);
|
|
85
90
|
}
|
|
86
91
|
/**
|
|
87
|
-
* Format preview as human-readable output
|
|
92
|
+
* Format preview as human-readable output, after a warning when the page
|
|
93
|
+
* crashed (what is shown was collected before).
|
|
88
94
|
*/
|
|
89
95
|
function formatPreviewHumanReadable(output, options) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return
|
|
96
|
+
const body = options.verbose
|
|
97
|
+
? formatPreviewVerbose(output, options)
|
|
98
|
+
: formatPreviewCompact(output, options);
|
|
99
|
+
return withPageCrashedNote(body, output.pageCrashedAt);
|
|
94
100
|
}
|
|
95
101
|
/**
|
|
96
102
|
* Format preview in compact format (default)
|
|
@@ -145,6 +151,8 @@ function formatPreviewCompact(output, options) {
|
|
|
145
151
|
const totalCount = output.totals?.console ?? output.data.console.length;
|
|
146
152
|
const limitHint = formatLimitHint(showingCount, totalCount);
|
|
147
153
|
fmt.text(`CONSOLE (${showingCount}/${totalCount})${limitHint}:`);
|
|
154
|
+
if (output.totals?.consoleDropped)
|
|
155
|
+
fmt.text(` ${consoleDroppedNote(output.totals.consoleDropped)}`);
|
|
148
156
|
if (messages.length === 0) {
|
|
149
157
|
fmt.text(` ${PREVIEW_EMPTY_STATES.NO_DATA}`);
|
|
150
158
|
}
|
|
@@ -232,6 +240,8 @@ function formatPreviewVerbose(output, options) {
|
|
|
232
240
|
? `Console Messages (all ${messages.length})`
|
|
233
241
|
: `Console Messages (last ${messages.length} of ${output.totals?.console ?? output.data.console.length})`;
|
|
234
242
|
fmt.text(title).separator('━', 50);
|
|
243
|
+
if (output.totals?.consoleDropped)
|
|
244
|
+
fmt.text(consoleDroppedNote(output.totals.consoleDropped));
|
|
235
245
|
if (messages.length === 0) {
|
|
236
246
|
fmt.text(PREVIEW_EMPTY_STATES.NO_CONSOLE_MESSAGES);
|
|
237
247
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RunningSessionInfo } from '../../session/sessionList.js';
|
|
2
2
|
/**
|
|
3
|
-
* Format the sessions as a table, followed by
|
|
4
|
-
* crashed and stale sessions.
|
|
3
|
+
* Format the sessions as a table, followed by why ended sessions ended and
|
|
4
|
+
* the cleanup commands of crashed and stale sessions.
|
|
5
5
|
*
|
|
6
6
|
* @param data - Sessions
|
|
7
7
|
* @returns Human-readable list
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { OutputFormatter } from '../formatting.js';
|
|
2
|
+
import { endedSessionText } from '../messages/session.js';
|
|
2
3
|
/** Label of the default session in the list */
|
|
3
4
|
const DEFAULT_SESSION_LABEL = '(default)';
|
|
4
5
|
/**
|
|
5
|
-
* Format the sessions as a table, followed by
|
|
6
|
-
* crashed and stale sessions.
|
|
6
|
+
* Format the sessions as a table, followed by why ended sessions ended and
|
|
7
|
+
* the cleanup commands of crashed and stale sessions.
|
|
7
8
|
*
|
|
8
9
|
* @param data - Sessions
|
|
9
10
|
* @returns Human-readable list
|
|
@@ -31,6 +32,12 @@ export function formatSessionList(data) {
|
|
|
31
32
|
.join(' ')
|
|
32
33
|
.trimEnd());
|
|
33
34
|
}
|
|
35
|
+
const ended = data.sessions.flatMap(({ name, endReason, endedAt }) => endReason && endedAt !== undefined
|
|
36
|
+
? [endedSessionText(name ?? DEFAULT_SESSION_LABEL, { reason: endReason, endedAt })]
|
|
37
|
+
: []);
|
|
38
|
+
if (ended.length > 0) {
|
|
39
|
+
fmt.blank().section('Ended without bdg stop:', ended);
|
|
40
|
+
}
|
|
34
41
|
const cleanups = data.sessions.flatMap((session) => (session.cleanup ? [session.cleanup] : []));
|
|
35
42
|
if (cleanups.length > 0) {
|
|
36
43
|
fmt.hints('Crashed or stale sessions; clean up with:', cleanups);
|
|
@@ -29,7 +29,7 @@ export type LogLevel = 'info' | 'debug';
|
|
|
29
29
|
* Log contexts for different components.
|
|
30
30
|
* Used to prefix log messages with component name.
|
|
31
31
|
*/
|
|
32
|
-
export type LogContext = 'bdg' | 'launcher' | 'daemon' | 'client' | 'cleanup' | 'session' | 'chrome' | 'cdp' | 'ipc' | 'http' | 'dialogs' | 'navigation' | 'console' | 'dom' | 'network' | 'diagnostics' | 'readiness' | 'atomic-file' | 'object-expander' | 'fetcher' | 'targets';
|
|
32
|
+
export type LogContext = 'bdg' | 'launcher' | 'daemon' | 'client' | 'cleanup' | 'session' | 'chrome' | 'cdp' | 'ipc' | 'http' | 'dialogs' | 'navigation' | 'page-crash' | 'console' | 'dom' | 'network' | 'diagnostics' | 'readiness' | 'atomic-file' | 'object-expander' | 'fetcher' | 'targets';
|
|
33
33
|
/**
|
|
34
34
|
* Logger instance with support for different log levels.
|
|
35
35
|
*/
|
|
@@ -24,6 +24,13 @@ export declare function chromeClosedMessage(pid?: number): string;
|
|
|
24
24
|
* @returns Formatted success message
|
|
25
25
|
*/
|
|
26
26
|
export declare function orphanedDaemonsCleanedMessage(count: number): string;
|
|
27
|
+
/**
|
|
28
|
+
* Where `bdg install-skill` kept the copy it replaced.
|
|
29
|
+
*
|
|
30
|
+
* @param path - Backup path, as the user would type it
|
|
31
|
+
* @returns One line
|
|
32
|
+
*/
|
|
33
|
+
export declare function skillBackupMessage(path: string): string;
|
|
27
34
|
/**
|
|
28
35
|
* Warning shown when a click falls back from mouse events to `el.click()`.
|
|
29
36
|
*
|
|
@@ -135,6 +142,22 @@ export declare const CLICK_NOT_RECEIVED_WARNING = "The click may not have reache
|
|
|
135
142
|
* "... and 8980 more (--json lists the first 100)"
|
|
136
143
|
*/
|
|
137
144
|
export declare function moreMatchesNote(hidden: number, jsonLimit?: number): string;
|
|
145
|
+
/**
|
|
146
|
+
* Note under `dom query` matches cut by `--limit`.
|
|
147
|
+
*
|
|
148
|
+
* @param omitted - Matches not listed
|
|
149
|
+
* @param indexed - Matches usable by index, when not all of them
|
|
150
|
+
* @returns e.g. `... and 49953 more (--limit 0 lists all; indices 0-999 work with other commands)`
|
|
151
|
+
*/
|
|
152
|
+
export declare function queryMoreMatchesNote(omitted: number, indexed?: number): string;
|
|
153
|
+
/**
|
|
154
|
+
* Note under `dom query` matches listed past those whose viewport position
|
|
155
|
+
* was checked.
|
|
156
|
+
*
|
|
157
|
+
* @param checked - First matches checked
|
|
158
|
+
* @returns e.g. `Visibility is checked for the first 100 matches only; bdg dom layout <index> checks any of them`
|
|
159
|
+
*/
|
|
160
|
+
export declare function queryViewportCheckedNote(checked: number): string;
|
|
138
161
|
/**
|
|
139
162
|
* Note under a list of a11y query matches cut by `--limit`.
|
|
140
163
|
*
|
|
@@ -185,6 +208,31 @@ export declare const LAYOUT_REASONS: {
|
|
|
185
208
|
/** Joins an invisible reason to the ancestor causing it */
|
|
186
209
|
readonly on: " on ";
|
|
187
210
|
};
|
|
211
|
+
/** Why an out-of-view text's contrast in `dom audit` is approximate: none of its ancestors paints a background */
|
|
212
|
+
export declare const AUDIT_OUT_OF_VIEW_RISK = "only its ancestors were checked";
|
|
213
|
+
/**
|
|
214
|
+
* `dom audit contrast` note for text that looks below the level but cannot
|
|
215
|
+
* be measured exactly (over an image, blended, under or over another layer).
|
|
216
|
+
*
|
|
217
|
+
* @param count - How many such texts
|
|
218
|
+
* @returns e.g. `(+12 more may be below it but cannot be measured: text over images or blended layers; check them with bdg dom inspect)`
|
|
219
|
+
*/
|
|
220
|
+
export declare function auditUncertainContrastNote(count: number): string;
|
|
221
|
+
/**
|
|
222
|
+
* `dom audit animations` note for canvas elements, whose script-drawn
|
|
223
|
+
* animations it cannot see.
|
|
224
|
+
*
|
|
225
|
+
* @param count - Visible canvas elements
|
|
226
|
+
* @returns e.g. `(+ 2 canvas elements: animations drawn by scripts on them are not listed)`
|
|
227
|
+
*/
|
|
228
|
+
export declare function auditCanvasNote(count: number): string;
|
|
229
|
+
/**
|
|
230
|
+
* A mask over an element, for `dom layout` and `dom inspect`.
|
|
231
|
+
*
|
|
232
|
+
* @param masked - The mask, e.g. `mask-image on div.hero`
|
|
233
|
+
* @returns e.g. `masked by mask-image on div.hero`
|
|
234
|
+
*/
|
|
235
|
+
export declare function maskedText(masked: string): string;
|
|
188
236
|
/**
|
|
189
237
|
* Off-screen reason for an element out of view on a page whose scrolling is
|
|
190
238
|
* locked, naming the visible dialog that likely locked it when there is one.
|
|
@@ -228,16 +276,53 @@ export declare function layoutPositionLabel(element: LabelledLayout, viewport?:
|
|
|
228
276
|
* @returns e.g. `prefers-color-scheme: dark (from the system setting)`
|
|
229
277
|
*/
|
|
230
278
|
export declare function colorSchemeLabel(scheme: string, emulated: boolean): string;
|
|
279
|
+
/**
|
|
280
|
+
* Suggestion for an action that failed on a page that replaced built-ins
|
|
281
|
+
* bdg's page scripts use.
|
|
282
|
+
*
|
|
283
|
+
* @param replaced - Their dotted names (all are named)
|
|
284
|
+
* @returns Suggestion naming them and a way around
|
|
285
|
+
*/
|
|
286
|
+
export declare function brokenByReplacedBuiltinsSuggestion(replaced: readonly string[]): string;
|
|
287
|
+
/**
|
|
288
|
+
* Warning on an action when the page replaced built-ins bdg's page scripts
|
|
289
|
+
* use (polyfills, old frameworks, anti-bot scripts). Names the first four;
|
|
290
|
+
* the action's `replacedBuiltins` (JSON) lists them all.
|
|
291
|
+
*
|
|
292
|
+
* @param replaced - Their dotted names
|
|
293
|
+
* @returns e.g. `the page replaced built-ins bdg's scripts use (Element.prototype.querySelectorAll); bdg found the element in its own world, but the action runs in the page's and may misbehave`
|
|
294
|
+
*/
|
|
295
|
+
export declare function replacedBuiltinsWarning(replaced: readonly string[]): string;
|
|
231
296
|
/**
|
|
232
297
|
* First line of `bdg status` for a running session.
|
|
233
298
|
*
|
|
234
|
-
* @param page - URL and title of the page, when the session reported them
|
|
235
|
-
*
|
|
299
|
+
* @param page - URL and title of the page, when the session reported them,
|
|
300
|
+
* and when it crashed
|
|
301
|
+
* @returns e.g. `Session active: https://example.com/ — Example Domain`, with
|
|
302
|
+
* a crash warning on a second line
|
|
236
303
|
*/
|
|
237
304
|
export declare function sessionActiveLine(page?: {
|
|
238
305
|
url: string;
|
|
239
306
|
title: string;
|
|
307
|
+
crashedAt?: number | undefined;
|
|
240
308
|
}): string;
|
|
309
|
+
/**
|
|
310
|
+
* Warning that the session's page crashed, for `bdg status`, `bdg peek`,
|
|
311
|
+
* `bdg console` and `bdg network list`.
|
|
312
|
+
*
|
|
313
|
+
* @param crashedAt - When it crashed (epoch ms)
|
|
314
|
+
* @returns e.g. `⚠ The page crashed at 18:42:10 (renderer gone); bdg page reload brings it back`
|
|
315
|
+
*/
|
|
316
|
+
export declare function pageCrashedNote(crashedAt: number): string;
|
|
317
|
+
/**
|
|
318
|
+
* Put the page-crashed warning before a view of collected data, when the
|
|
319
|
+
* page crashed (what is shown was collected before).
|
|
320
|
+
*
|
|
321
|
+
* @param body - The view
|
|
322
|
+
* @param crashedAt - When the page crashed (epoch ms), if it did
|
|
323
|
+
* @returns The view, after the warning when the page crashed
|
|
324
|
+
*/
|
|
325
|
+
export declare function withPageCrashedNote(body: string, crashedAt: number | undefined): string;
|
|
241
326
|
/**
|
|
242
327
|
* Page dimensions line of `bdg dom layout`.
|
|
243
328
|
*
|
|
@@ -405,6 +490,16 @@ export declare function dialogConsoleText(dialog: {
|
|
|
405
490
|
type: string;
|
|
406
491
|
message: string;
|
|
407
492
|
}): string;
|
|
493
|
+
/**
|
|
494
|
+
* How far a pointer action scrolled the page to reach its element.
|
|
495
|
+
*
|
|
496
|
+
* @param scrolledBy - Page scroll (CSS px)
|
|
497
|
+
* @returns e.g. `page down 1240px to reach it`, `page right 300px, up 80px to reach it`
|
|
498
|
+
*/
|
|
499
|
+
export declare function pointerScrollText(scrolledBy: {
|
|
500
|
+
x: number;
|
|
501
|
+
y: number;
|
|
502
|
+
}): string;
|
|
408
503
|
/** Headline of each pointer action, e.g. "Element Double-clicked" */
|
|
409
504
|
export declare const POINTER_ACTION_DONE: {
|
|
410
505
|
readonly click: "Clicked";
|
|
@@ -556,9 +651,11 @@ export declare function elementTextLine(text: string): string;
|
|
|
556
651
|
*
|
|
557
652
|
* @param children - First child elements, e.g. `iframe#app`
|
|
558
653
|
* @param count - Number of child elements
|
|
559
|
-
* @
|
|
654
|
+
* @param inShadowRoot - The children are those of its shadow root (`--raw` does not show them)
|
|
655
|
+
* @returns e.g. `No text; holds 1 element: iframe (see its HTML with --raw)`,
|
|
656
|
+
* `No text; its shadow root holds 1 element: button "Close" (see it with bdg dom inspect)`
|
|
560
657
|
*/
|
|
561
|
-
export declare function emptyElementLine(children: string[], count: number): string;
|
|
658
|
+
export declare function emptyElementLine(children: string[], count: number, inShadowRoot?: boolean): string;
|
|
562
659
|
/**
|
|
563
660
|
* Note on a screenshot scaled down to keep its image token cost bounded.
|
|
564
661
|
*
|
|
@@ -600,6 +697,23 @@ export declare function queryNextSteps(index: number): string;
|
|
|
600
697
|
* @returns e.g. `Frame: https://pay.example/`
|
|
601
698
|
*/
|
|
602
699
|
export declare function evalFrameLine(url: string): string;
|
|
700
|
+
/**
|
|
701
|
+
* Warning on a `dom eval` result the browser copied because the page
|
|
702
|
+
* replaced built-ins bdg's own copy uses.
|
|
703
|
+
*
|
|
704
|
+
* @param replaced - Their dotted names (all are named)
|
|
705
|
+
* @returns e.g. `the page replaced Object.keys, so the browser copied the result: undefined, NaN, functions, DOM nodes, dates, maps and sets inside it show as null or {}`
|
|
706
|
+
*/
|
|
707
|
+
export declare function evalCopiedByBrowserWarning(replaced: readonly string[]): string;
|
|
708
|
+
/**
|
|
709
|
+
* Warning on a `dom eval` result shown as its preview: the page replaced
|
|
710
|
+
* built-ins bdg's copy uses and the browser could not copy it either (a
|
|
711
|
+
* cycle or a BigInt inside).
|
|
712
|
+
*
|
|
713
|
+
* @param replaced - Their dotted names (all are named)
|
|
714
|
+
* @returns Warning that the value is a shortened preview
|
|
715
|
+
*/
|
|
716
|
+
export declare function evalPreviewWarning(replaced: readonly string[]): string;
|
|
603
717
|
/**
|
|
604
718
|
* Generate warning message.
|
|
605
719
|
*
|
|
@@ -715,5 +829,11 @@ export declare function inspectMidTransitionNote(): string;
|
|
|
715
829
|
export declare const AUDIT_HELP_EXAMPLES = "\nExamples:\n bdg dom audit All checks\n bdg dom audit contrast --level AAA Text below WCAG AAA, weakest first\n bdg dom audit overflow What scrolls sideways, cut-off text, scaled images\n bdg dom audit layers animations Fixed/sticky elements and running animations\n\nFollow up on a finding with bdg dom inspect <element> (e.g. --why color).";
|
|
716
830
|
/** Examples under `bdg css search --help` */
|
|
717
831
|
export declare const CSS_SEARCH_HELP_EXAMPLES = "\nExamples:\n bdg css search -- --brand Where a custom property is set and used (-- before a text\n that starts with -; options go before it:\n bdg css search --limit 50 -- --brand)\n bdg css search \"oklch(\" Rules that use oklch colors\n bdg css search \".btn-primary\" Rules of a class, in every stylesheet";
|
|
832
|
+
/**
|
|
833
|
+
* `details` field of `bdg --help --json`: where the full help is.
|
|
834
|
+
*
|
|
835
|
+
* @returns Note
|
|
836
|
+
*/
|
|
837
|
+
export declare function helpJsonDetailsNote(): string;
|
|
718
838
|
export {};
|
|
719
839
|
//# sourceMappingURL=commands.d.ts.map
|