browser-debugger-cli 0.8.0 → 0.10.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/README.md +7 -1
- package/dist/cdp/schema.d.ts +4 -1
- package/dist/cdp/schema.js +48 -7
- package/dist/commands/cdp.js +3 -2
- package/dist/commands/cleanup.d.ts +11 -0
- package/dist/commands/cleanup.js +161 -57
- package/dist/commands/console.d.ts +20 -1
- package/dist/commands/console.js +57 -17
- package/dist/commands/details.js +3 -2
- package/dist/commands/dom/DomElementResolver.d.ts +10 -3
- package/dist/commands/dom/DomElementResolver.js +35 -17
- package/dist/commands/dom/a11y.d.ts +10 -0
- package/dist/commands/dom/a11y.js +29 -6
- package/dist/commands/dom/eval.d.ts +3 -1
- package/dist/commands/dom/eval.js +29 -4
- package/dist/commands/dom/form.js +16 -62
- package/dist/commands/dom/formInteraction.js +189 -119
- package/dist/commands/dom/formSummary.d.ts +49 -0
- package/dist/commands/dom/formSummary.js +180 -0
- package/dist/commands/dom/frames.d.ts +2 -1
- package/dist/commands/dom/frames.js +17 -2
- package/dist/commands/dom/get.d.ts +6 -5
- package/dist/commands/dom/get.js +92 -82
- package/dist/commands/dom/helpers/index.d.ts +1 -1
- package/dist/commands/dom/helpers/index.js +1 -1
- package/dist/commands/dom/helpers/keyAttributes.d.ts +20 -0
- package/dist/commands/dom/helpers/keyAttributes.js +54 -0
- package/dist/commands/dom/helpers/query.d.ts +44 -17
- package/dist/commands/dom/helpers/query.js +300 -106
- package/dist/commands/dom/helpers/runElementCommand.d.ts +10 -2
- package/dist/commands/dom/helpers/runElementCommand.js +98 -30
- package/dist/commands/dom/helpers/screenshot.d.ts +4 -1
- package/dist/commands/dom/helpers/screenshot.js +239 -51
- package/dist/commands/dom/index.d.ts +4 -1
- package/dist/commands/dom/index.js +22 -7
- package/dist/commands/dom/inspect.d.ts +15 -0
- package/dist/commands/dom/inspect.js +82 -0
- package/dist/commands/dom/layout.d.ts +14 -0
- package/dist/commands/dom/layout.js +54 -0
- package/dist/commands/dom/listeners.d.ts +5 -1
- package/dist/commands/dom/listeners.js +15 -5
- package/dist/commands/dom/query.js +2 -3
- package/dist/commands/dom/screenshot.d.ts +12 -2
- package/dist/commands/dom/screenshot.js +27 -3
- package/dist/commands/dom/semanticUtils.d.ts +16 -10
- package/dist/commands/dom/semanticUtils.js +53 -16
- package/dist/commands/dom/wait.d.ts +13 -0
- package/dist/commands/dom/wait.js +83 -0
- package/dist/commands/helpJson.js +2 -2
- package/dist/commands/network/list.js +17 -13
- package/dist/commands/optionBehaviors.js +154 -21
- package/dist/commands/page.d.ts +3 -2
- package/dist/commands/page.js +100 -5
- package/dist/commands/peek.js +4 -11
- package/dist/commands/sessions.d.ts +8 -0
- package/dist/commands/sessions.js +19 -0
- package/dist/commands/shared/CommandRunner.js +4 -4
- package/dist/commands/shared/commonOptions.d.ts +4 -0
- package/dist/commands/shared/commonOptions.js +9 -0
- package/dist/commands/shared/dataFetcher.js +2 -2
- package/dist/commands/shared/followMode.d.ts +21 -1
- package/dist/commands/shared/followMode.js +29 -2
- package/dist/commands/shared/handleValidationError.d.ts +2 -2
- package/dist/commands/shared/handleValidationError.js +12 -3
- package/dist/commands/shared/optionTypes.d.ts +61 -5
- package/dist/commands/shared/startHelpers.d.ts +66 -0
- package/dist/commands/shared/startHelpers.js +103 -13
- package/dist/commands/shared/validation.d.ts +14 -2
- package/dist/commands/shared/validation.js +20 -3
- package/dist/commands/start.d.ts +63 -0
- package/dist/commands/start.js +115 -15
- package/dist/commands/status.js +29 -7
- package/dist/commands/stop.js +7 -6
- package/dist/commands/tail.js +4 -11
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands.js +2 -0
- package/dist/connection/chromeIdentity.d.ts +65 -0
- package/dist/connection/chromeIdentity.js +143 -0
- package/dist/connection/launcher/profilePreferences.d.ts +47 -0
- package/dist/connection/launcher/profilePreferences.js +151 -0
- package/dist/connection/launcher.d.ts +21 -2
- package/dist/connection/launcher.js +42 -16
- package/dist/connection/portReservation.d.ts +14 -4
- package/dist/connection/portReservation.js +21 -6
- package/dist/connection/startupExit.d.ts +8 -0
- package/dist/connection/startupExit.js +15 -6
- package/dist/constants.d.ts +6 -2
- package/dist/constants.js +9 -2
- package/dist/daemon/SessionController.js +23 -7
- package/dist/daemon/errors.d.ts +1 -1
- package/dist/daemon/errors.js +1 -1
- package/dist/daemon/launcher.d.ts +10 -2
- package/dist/daemon/launcher.js +8 -7
- package/dist/daemon/server/SocketServer.js +1 -2
- package/dist/daemon/session/Session.d.ts +20 -0
- package/dist/daemon/session/Session.js +80 -9
- package/dist/daemon/session/chromeConnection.d.ts +9 -0
- package/dist/daemon/session/chromeConnection.js +45 -8
- package/dist/daemon/session/commandRegistry.d.ts +14 -1
- package/dist/daemon/session/commandRegistry.js +113 -67
- package/dist/daemon/session/interactions.d.ts +48 -9
- package/dist/daemon/session/interactions.js +46 -9
- package/dist/daemon/session/triggeredRequests.d.ts +67 -0
- package/dist/daemon/session/triggeredRequests.js +157 -0
- package/dist/daemon/session/types.d.ts +5 -1
- package/dist/daemon.js +10630 -3601
- package/dist/errors/messages.d.ts +456 -24
- package/dist/errors/messages.js +862 -67
- package/dist/index.js +6915 -3401
- package/dist/ipc/client.d.ts +21 -1
- package/dist/ipc/client.js +35 -3
- package/dist/ipc/protocol/commands.d.ts +145 -5
- package/dist/ipc/protocol/commands.js +4 -0
- package/dist/ipc/protocol/domTypes.d.ts +291 -7
- package/dist/ipc/protocol/inspectTypes.d.ts +388 -0
- package/dist/ipc/protocol/inspectTypes.js +10 -0
- package/dist/ipc/session/lifecycle.d.ts +8 -1
- package/dist/ipc/session/queries.d.ts +5 -1
- package/dist/ipc/session/types.d.ts +5 -0
- package/dist/ipc/transport/index.d.ts +2 -1
- package/dist/ipc/transport/index.js +2 -2
- package/dist/runtime/dom/actionEffects.d.ts +185 -0
- package/dist/runtime/dom/actionEffects.js +402 -0
- package/dist/runtime/dom/actionEffectsScripts.d.ts +90 -0
- package/dist/runtime/dom/actionEffectsScripts.js +426 -0
- package/dist/runtime/dom/elementGeometry.d.ts +170 -0
- package/dist/runtime/dom/elementGeometry.js +553 -0
- package/dist/runtime/dom/elementInfo.d.ts +103 -0
- package/dist/runtime/dom/elementInfo.js +256 -0
- package/dist/runtime/dom/evalHelpers.d.ts +51 -6
- package/dist/runtime/dom/evalHelpers.js +136 -26
- package/dist/runtime/dom/eventListeners.d.ts +2 -1
- package/dist/runtime/dom/eventListeners.js +184 -47
- package/dist/runtime/dom/formDiscovery.d.ts +1 -1
- package/dist/runtime/dom/formDiscovery.js +116 -16
- package/dist/runtime/dom/formFillHelpers/fill.d.ts +9 -0
- package/dist/runtime/dom/formFillHelpers/fill.js +178 -14
- package/dist/runtime/dom/formFillHelpers/index.d.ts +2 -2
- package/dist/runtime/dom/formFillHelpers/index.js +2 -2
- package/dist/runtime/dom/formFillHelpers/pressKey.js +14 -3
- package/dist/runtime/dom/formFillHelpers/scroll.d.ts +3 -0
- package/dist/runtime/dom/formFillHelpers/scroll.js +60 -18
- package/dist/runtime/dom/formFillHelpers/shared.d.ts +17 -0
- package/dist/runtime/dom/formFillHelpers/shared.js +25 -1
- package/dist/runtime/dom/formFillHelpers/stability.d.ts +20 -6
- package/dist/runtime/dom/formFillHelpers/stability.js +50 -19
- package/dist/runtime/dom/formSubmitHelpers.d.ts +3 -0
- package/dist/runtime/dom/formSubmitHelpers.js +89 -15
- package/dist/runtime/dom/frameLayout.d.ts +60 -0
- package/dist/runtime/dom/frameLayout.js +140 -0
- package/dist/runtime/dom/frameOrigin.d.ts +50 -0
- package/dist/runtime/dom/frameOrigin.js +62 -0
- package/dist/runtime/dom/frameScopedConnection.d.ts +92 -0
- package/dist/runtime/dom/frameScopedConnection.js +252 -0
- package/dist/runtime/dom/frameSelection.d.ts +12 -1
- package/dist/runtime/dom/frameSelection.js +22 -3
- package/dist/runtime/dom/frames.d.ts +61 -5
- package/dist/runtime/dom/frames.js +329 -75
- package/dist/runtime/dom/inspect.d.ts +28 -0
- package/dist/runtime/dom/inspect.js +557 -0
- package/dist/runtime/dom/inspectAllStyles.d.ts +62 -0
- package/dist/runtime/dom/inspectAllStyles.js +385 -0
- package/dist/runtime/dom/inspectCascade.d.ts +94 -0
- package/dist/runtime/dom/inspectCascade.js +371 -0
- package/dist/runtime/dom/inspectCascadeModel.d.ts +39 -0
- package/dist/runtime/dom/inspectCascadeModel.js +232 -0
- package/dist/runtime/dom/inspectHints.d.ts +62 -0
- package/dist/runtime/dom/inspectHints.js +305 -0
- package/dist/runtime/dom/inspectLayoutModel.d.ts +87 -0
- package/dist/runtime/dom/inspectLayoutModel.js +346 -0
- package/dist/runtime/dom/inspectModel.d.ts +74 -0
- package/dist/runtime/dom/inspectModel.js +184 -0
- package/dist/runtime/dom/inspectPaintModel.d.ts +157 -0
- package/dist/runtime/dom/inspectPaintModel.js +461 -0
- package/dist/runtime/dom/inspectRules.d.ts +37 -0
- package/dist/runtime/dom/inspectRules.js +101 -0
- package/dist/runtime/dom/inspectScripts.d.ts +132 -0
- package/dist/runtime/dom/inspectScripts.js +263 -0
- package/dist/runtime/dom/inspectTree.d.ts +40 -0
- package/dist/runtime/dom/inspectTree.js +134 -0
- package/dist/runtime/dom/inspectVariables.d.ts +33 -0
- package/dist/runtime/dom/inspectVariables.js +94 -0
- package/dist/runtime/dom/inspectWhyModel.d.ts +20 -0
- package/dist/runtime/dom/inspectWhyModel.js +134 -0
- package/dist/runtime/dom/layout.d.ts +71 -0
- package/dist/runtime/dom/layout.js +340 -0
- package/dist/runtime/dom/listenerPageScripts.d.ts +72 -0
- package/dist/runtime/dom/listenerPageScripts.js +365 -0
- package/dist/runtime/dom/listenerSummary.d.ts +136 -11
- package/dist/runtime/dom/listenerSummary.js +361 -22
- package/dist/runtime/dom/pageActivity.d.ts +41 -0
- package/dist/runtime/dom/pageActivity.js +123 -0
- package/dist/runtime/dom/reactEventHelpers.d.ts +63 -2
- package/dist/runtime/dom/reactEventHelpers.js +220 -41
- package/dist/runtime/dom/targetNode.d.ts +80 -27
- package/dist/runtime/dom/targetNode.js +249 -33
- package/dist/runtime/dom/wait.d.ts +25 -0
- package/dist/runtime/dom/wait.js +199 -0
- package/dist/runtime/dom/waitCondition.d.ts +71 -0
- package/dist/runtime/dom/waitCondition.js +75 -0
- package/dist/runtime/page/emulation.d.ts +71 -0
- package/dist/runtime/page/emulation.js +117 -0
- package/dist/runtime/page/loadingState.d.ts +36 -0
- package/dist/runtime/page/loadingState.js +86 -0
- package/dist/runtime/page/navigation.d.ts +46 -2
- package/dist/runtime/page/navigation.js +69 -33
- package/dist/session/QueryCacheManager.d.ts +11 -1
- package/dist/session/QueryCacheManager.js +25 -3
- package/dist/session/chromeOwners.d.ts +34 -0
- package/dist/session/chromeOwners.js +51 -0
- package/dist/session/cleanup/staleSession.d.ts +11 -1
- package/dist/session/cleanup/staleSession.js +17 -6
- package/dist/session/cleanup/userCommands.js +2 -4
- package/dist/session/metadata.d.ts +5 -1
- package/dist/session/metadata.js +2 -1
- package/dist/session/paths.d.ts +77 -3
- package/dist/session/paths.js +111 -5
- package/dist/session/port.d.ts +31 -7
- package/dist/session/port.js +50 -43
- package/dist/session/portClaims.d.ts +66 -0
- package/dist/session/portClaims.js +284 -0
- package/dist/session/sessionList.d.ts +58 -0
- package/dist/session/sessionList.js +199 -0
- package/dist/session/sessionName.d.ts +46 -0
- package/dist/session/sessionName.js +97 -0
- package/dist/telemetry/a11y.d.ts +18 -3
- package/dist/telemetry/a11y.js +170 -29
- package/dist/telemetry/console.d.ts +1 -0
- package/dist/telemetry/console.js +100 -5
- package/dist/telemetry/network.js +3 -1
- package/dist/telemetry/requestKinds.d.ts +32 -0
- package/dist/telemetry/requestKinds.js +61 -0
- package/dist/telemetry/requestState.d.ts +31 -0
- package/dist/telemetry/requestState.js +38 -0
- package/dist/types.d.ts +112 -3
- package/dist/ui/formatters/a11y.js +3 -0
- package/dist/ui/formatters/console/chronological.d.ts +8 -0
- package/dist/ui/formatters/console/chronological.js +17 -4
- package/dist/ui/formatters/console/json.js +3 -4
- package/dist/ui/formatters/console/shared.d.ts +12 -0
- package/dist/ui/formatters/console.d.ts +2 -2
- package/dist/ui/formatters/console.js +1 -1
- package/dist/ui/formatters/details.d.ts +8 -0
- package/dist/ui/formatters/details.js +61 -4
- package/dist/ui/formatters/dom.d.ts +27 -14
- package/dist/ui/formatters/dom.js +88 -59
- package/dist/ui/formatters/form.js +29 -18
- package/dist/ui/formatters/inspect.d.ts +39 -0
- package/dist/ui/formatters/inspect.js +596 -0
- package/dist/ui/formatters/keyAttributes.d.ts +19 -0
- package/dist/ui/formatters/keyAttributes.js +84 -0
- package/dist/ui/formatters/layout.d.ts +31 -0
- package/dist/ui/formatters/layout.js +53 -0
- package/dist/ui/formatters/listeners.d.ts +3 -2
- package/dist/ui/formatters/listeners.js +73 -9
- package/dist/ui/formatters/networkHeaders.d.ts +13 -0
- package/dist/ui/formatters/networkHeaders.js +36 -3
- package/dist/ui/formatters/networkList.d.ts +29 -1
- package/dist/ui/formatters/networkList.js +86 -20
- package/dist/ui/formatters/preview.js +2 -1
- package/dist/ui/formatters/requestStatus.d.ts +1 -17
- package/dist/ui/formatters/requestStatus.js +2 -30
- package/dist/ui/formatters/sessions.d.ts +12 -0
- package/dist/ui/formatters/sessions.js +40 -0
- package/dist/ui/formatters/status.d.ts +21 -2
- package/dist/ui/formatters/status.js +47 -10
- package/dist/ui/formatters/triggeredRequests.d.ts +36 -0
- package/dist/ui/formatters/triggeredRequests.js +65 -0
- package/dist/ui/formatting.d.ts +19 -0
- package/dist/ui/formatting.js +31 -36
- package/dist/ui/messages/chrome.d.ts +9 -0
- package/dist/ui/messages/chrome.js +17 -5
- package/dist/ui/messages/commands.d.ts +504 -14
- package/dist/ui/messages/commands.js +835 -21
- package/dist/ui/messages/consoleMessages.d.ts +10 -0
- package/dist/ui/messages/consoleMessages.js +17 -0
- package/dist/ui/messages/hints.js +2 -1
- package/dist/ui/messages/networkMessages.d.ts +14 -0
- package/dist/ui/messages/networkMessages.js +18 -0
- package/dist/ui/messages/preview.js +5 -4
- package/dist/ui/messages/session.d.ts +30 -21
- package/dist/ui/messages/session.js +48 -26
- package/dist/ui/messages/sessionCommand.d.ts +43 -0
- package/dist/ui/messages/sessionCommand.js +52 -0
- package/dist/utils/async.d.ts +17 -0
- package/dist/utils/async.js +36 -0
- package/dist/utils/color.d.ts +84 -0
- package/dist/utils/color.js +376 -0
- package/dist/utils/cssValues.d.ts +109 -0
- package/dist/utils/cssValues.js +236 -0
- package/dist/utils/http.d.ts +22 -1
- package/dist/utils/http.js +28 -9
- package/dist/utils/selectorFilters.d.ts +48 -8
- package/dist/utils/selectorFilters.js +296 -53
- package/dist/utils/shellDetection.d.ts +8 -2
- package/dist/utils/shellDetection.js +120 -33
- package/dist/utils/suggestions.d.ts +26 -0
- package/dist/utils/suggestions.js +73 -0
- package/dist/utils/taskMappings.js +10 -0
- package/dist/utils/url.d.ts +12 -2
- package/dist/utils/url.js +69 -7
- package/package.json +1 -1
- package/dist/ui/formatters/sessionFormatters.d.ts +0 -58
- package/dist/ui/formatters/sessionFormatters.js +0 -121
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle state of captured network requests.
|
|
3
|
+
*
|
|
4
|
+
* A request is pending until it completes or fails. Status 0 means it failed
|
|
5
|
+
* without any response (DNS, refused, aborted, blocked); a request that got a
|
|
6
|
+
* response keeps its HTTP status even if loading failed afterwards.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Classify a request.
|
|
10
|
+
*
|
|
11
|
+
* @param request - Captured request
|
|
12
|
+
* @returns Its lifecycle state
|
|
13
|
+
*/
|
|
14
|
+
export function getRequestState(request) {
|
|
15
|
+
if (request.status === undefined)
|
|
16
|
+
return 'pending';
|
|
17
|
+
return request.status === 0 ? 'failed' : 'complete';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Why a request failed, leaving out Chrome stopping an unneeded body after a
|
|
21
|
+
* complete response (204/304 report `net::ERR_ABORTED` that way).
|
|
22
|
+
*
|
|
23
|
+
* @param request - Captured request
|
|
24
|
+
* @returns Reason, or undefined when there is none worth showing
|
|
25
|
+
*/
|
|
26
|
+
export function failureReason(request) {
|
|
27
|
+
if (!request.errorText)
|
|
28
|
+
return undefined;
|
|
29
|
+
return getRequestState(request) === 'complete' && request.errorText === BODY_ABORTED
|
|
30
|
+
? undefined
|
|
31
|
+
: request.errorText;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Error Chrome reports when it stops reading a response body nobody needs
|
|
35
|
+
* (the response itself arrived; not a failure of the request).
|
|
36
|
+
*/
|
|
37
|
+
export const BODY_ABORTED = 'net::ERR_ABORTED';
|
|
38
|
+
//# sourceMappingURL=requestState.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -137,7 +137,10 @@ export interface NetworkRequest {
|
|
|
137
137
|
redirectURL?: string;
|
|
138
138
|
encodedDataLength?: number;
|
|
139
139
|
decodedBodyLength?: number;
|
|
140
|
+
/** Address Chrome connected to: the server's, or a proxy's (CDP `remoteIPAddress`) */
|
|
140
141
|
serverIPAddress?: string;
|
|
142
|
+
/** Port Chrome connected to (CDP `remotePort`) */
|
|
143
|
+
serverPort?: number;
|
|
141
144
|
connection?: string;
|
|
142
145
|
/** Status text sent by the server (empty for HTTP/2) */
|
|
143
146
|
statusText?: string;
|
|
@@ -301,10 +304,12 @@ export interface A11yQueryPattern {
|
|
|
301
304
|
* Result from A11y query operation.
|
|
302
305
|
*/
|
|
303
306
|
export interface A11yQueryResult {
|
|
304
|
-
/** Matching nodes */
|
|
307
|
+
/** Matching nodes (the first `--limit` of them) */
|
|
305
308
|
nodes: A11yNode[];
|
|
306
309
|
/** Total matches found */
|
|
307
310
|
count: number;
|
|
311
|
+
/** Matches not listed because of `--limit` (their indices still work) */
|
|
312
|
+
omitted?: number;
|
|
308
313
|
/** Query pattern used */
|
|
309
314
|
pattern: A11yQueryPattern;
|
|
310
315
|
}
|
|
@@ -316,7 +321,40 @@ export interface DomContext {
|
|
|
316
321
|
tag: string;
|
|
317
322
|
classes?: string[];
|
|
318
323
|
preview?: string;
|
|
324
|
+
/** Up to 500 characters of text, when it is longer than the preview */
|
|
325
|
+
text?: string;
|
|
326
|
+
/** First child elements (`tag#id.class`), for an element without text */
|
|
327
|
+
children?: string[];
|
|
328
|
+
/** Number of child elements, for an element without text */
|
|
329
|
+
childCount?: number;
|
|
330
|
+
/** Attributes that identify it by its type (see {@link KeyAttributes}) */
|
|
331
|
+
attributes?: KeyAttributes;
|
|
332
|
+
/** A field holding a secret (password, card, one-time code): its value is shown masked */
|
|
333
|
+
sensitive?: boolean;
|
|
319
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Live state of a form control read in the page: an input's type and value
|
|
337
|
+
* (`checked` for checkboxes and radios), a textarea's value, the labels of a
|
|
338
|
+
* select's selected options, the type of a button in a form.
|
|
339
|
+
*/
|
|
340
|
+
export interface ElementState {
|
|
341
|
+
type?: string;
|
|
342
|
+
/** Masked in the page for sensitive fields; never read for hidden inputs */
|
|
343
|
+
value?: string;
|
|
344
|
+
checked?: boolean;
|
|
345
|
+
selected?: string;
|
|
346
|
+
/** A field holding a secret (its value and selected option are masked) */
|
|
347
|
+
sensitive?: boolean;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* The attributes that identify an element by its type, with full values:
|
|
351
|
+
* img `src`, `alt`; a `href`; input `type`, `name`, `placeholder`, `value`
|
|
352
|
+
* (current value, masked for passwords; for checkboxes and radios their
|
|
353
|
+
* `value` attribute) and `checked`; textarea `name`,
|
|
354
|
+
* `placeholder`, `value`; button `type` (`submit` by default in a form), `name`; select `name`, `selected`
|
|
355
|
+
* (labels of the selected options); iframe `src`; form `action`, `method`.
|
|
356
|
+
*/
|
|
357
|
+
export type KeyAttributes = Record<string, string | boolean>;
|
|
320
358
|
/**
|
|
321
359
|
* Reference to a DOM node for CDP calls: a per-connection `nodeId` (valid only
|
|
322
360
|
* within one command) or a `backendNodeId` (valid while the node exists).
|
|
@@ -326,6 +364,47 @@ export type NodeRef = {
|
|
|
326
364
|
} | {
|
|
327
365
|
backendNodeId: number;
|
|
328
366
|
};
|
|
367
|
+
/** `prefers-color-scheme` value a session emulates (`--color-scheme`) */
|
|
368
|
+
export type ColorScheme = 'light' | 'dark';
|
|
369
|
+
/** Viewport size in CSS px (`--viewport`) */
|
|
370
|
+
export interface ViewportSize {
|
|
371
|
+
width: number;
|
|
372
|
+
height: number;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* The page (document) request an action sent, as far as it got: still
|
|
376
|
+
* pending, answered with a status, or failed.
|
|
377
|
+
*/
|
|
378
|
+
export interface DocumentRequestState {
|
|
379
|
+
method: string;
|
|
380
|
+
url: string;
|
|
381
|
+
/** How long it has been running (pending requests) */
|
|
382
|
+
pendingMs?: number;
|
|
383
|
+
/** HTTP status of the response, once answered */
|
|
384
|
+
status?: number;
|
|
385
|
+
statusText?: string;
|
|
386
|
+
/** Network error, when it failed */
|
|
387
|
+
errorText?: string;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* The list a numeric index refers to: the results of the last
|
|
391
|
+
* `bdg dom query`, `bdg dom form` or `bdg dom a11y query` (one cache holds
|
|
392
|
+
* the last of them).
|
|
393
|
+
*/
|
|
394
|
+
export interface IndexSource {
|
|
395
|
+
/** The index the user gave (0-based) */
|
|
396
|
+
index: number;
|
|
397
|
+
/** Command whose results are cached */
|
|
398
|
+
command: 'dom query' | 'dom form' | 'dom a11y query';
|
|
399
|
+
/** The query's selector or a11y pattern (not for `dom form`) */
|
|
400
|
+
query?: string;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Where an element is relative to the top-level viewport: fully `visible`,
|
|
404
|
+
* `partly` visible, outside it in one direction, or `hidden` (not rendered,
|
|
405
|
+
* `visibility: hidden`, zero size, inert, or clipped away).
|
|
406
|
+
*/
|
|
407
|
+
export type ViewportPosition = 'visible' | 'partly' | 'above' | 'below' | 'left' | 'right' | 'hidden';
|
|
329
408
|
/**
|
|
330
409
|
* Result of a DOM query operation.
|
|
331
410
|
*/
|
|
@@ -341,11 +420,19 @@ export interface DomQueryResult {
|
|
|
341
420
|
id?: string;
|
|
342
421
|
name?: string;
|
|
343
422
|
type?: string;
|
|
423
|
+
/** `value` attribute of an `<option>` */
|
|
424
|
+
value?: string;
|
|
425
|
+
/** Attributes that identify it by its type (see {@link KeyAttributes}) */
|
|
426
|
+
attributes?: KeyAttributes;
|
|
344
427
|
classes?: string[];
|
|
345
428
|
/** Text content preview (display only, never used for targeting) */
|
|
346
429
|
preview?: string;
|
|
347
430
|
/** Enclosing iframe(s) and shadow root, e.g. "iframe#pay > shadow root of <x-card>" */
|
|
348
431
|
context?: string;
|
|
432
|
+
/** Where the element is relative to the viewport when queried (first 100 matches) */
|
|
433
|
+
inViewport?: ViewportPosition;
|
|
434
|
+
/** Ancestor or iframe cutting it off, e.g. a scrolled list */
|
|
435
|
+
clippedBy?: string;
|
|
349
436
|
/** Unique selector for this node (set by form discovery) */
|
|
350
437
|
selector?: string;
|
|
351
438
|
}>;
|
|
@@ -389,7 +476,13 @@ export interface ScreenshotResult {
|
|
|
389
476
|
element?: {
|
|
390
477
|
selector?: string;
|
|
391
478
|
index?: number;
|
|
479
|
+
/** Border box of the element (page coordinates for element captures) */
|
|
392
480
|
bounds: ElementBounds;
|
|
481
|
+
/**
|
|
482
|
+
* Area captured, when content overflowing the element (floats, positioned
|
|
483
|
+
* descendants) made it larger than the border box
|
|
484
|
+
*/
|
|
485
|
+
captured?: ElementBounds;
|
|
393
486
|
};
|
|
394
487
|
/** Capture mode used */
|
|
395
488
|
captureMode?: 'full_page' | 'viewport';
|
|
@@ -473,6 +566,8 @@ export interface FormField {
|
|
|
473
566
|
name: string | null;
|
|
474
567
|
placeholder?: string | undefined;
|
|
475
568
|
required: boolean;
|
|
569
|
+
/** Name of the radio/checkbox group the field belongs to (counted once in the summary) */
|
|
570
|
+
groupLabel?: string | undefined;
|
|
476
571
|
disabled: boolean;
|
|
477
572
|
readOnly: boolean;
|
|
478
573
|
hidden: boolean;
|
|
@@ -509,7 +604,9 @@ export interface FormBlocker {
|
|
|
509
604
|
command: string;
|
|
510
605
|
}
|
|
511
606
|
/**
|
|
512
|
-
* Summary statistics for a form.
|
|
607
|
+
* Summary statistics for a form. Counts cover the visible, editable fields;
|
|
608
|
+
* a radio or checkbox group (same name) counts once, filled when any of its
|
|
609
|
+
* options is checked.
|
|
513
610
|
*/
|
|
514
611
|
export interface FormSummary {
|
|
515
612
|
totalFields: number;
|
|
@@ -520,6 +617,12 @@ export interface FormSummary {
|
|
|
520
617
|
requiredTotal: number;
|
|
521
618
|
requiredFilled: number;
|
|
522
619
|
requiredRemaining: number;
|
|
620
|
+
/** Labels of the fields (choice groups once) left empty, required or not */
|
|
621
|
+
emptyFieldLabels: string[];
|
|
622
|
+
/**
|
|
623
|
+
* Every required field is filled, nothing is invalid, the submit button is
|
|
624
|
+
* enabled, and at least one field is filled (or the form has none)
|
|
625
|
+
*/
|
|
523
626
|
readyToSubmit: boolean;
|
|
524
627
|
blockers: FormBlocker[];
|
|
525
628
|
}
|
|
@@ -540,6 +643,10 @@ export interface DiscoveredForm {
|
|
|
540
643
|
method: string;
|
|
541
644
|
step?: FormStep | undefined;
|
|
542
645
|
relevanceScore: number;
|
|
646
|
+
/** Not visible (not rendered, visibility-hidden, or all its fields are) */
|
|
647
|
+
hidden: boolean;
|
|
648
|
+
/** Shown inside an open dialog: listed first, like visible forms before hidden ones */
|
|
649
|
+
inDialog: boolean;
|
|
543
650
|
fields: FormField[];
|
|
544
651
|
buttons: FormButton[];
|
|
545
652
|
summary: FormSummary;
|
|
@@ -551,11 +658,13 @@ export interface FormDiscoveryResult {
|
|
|
551
658
|
formCount: number;
|
|
552
659
|
selectedForm: number;
|
|
553
660
|
forms: DiscoveredForm[];
|
|
554
|
-
/** The forms not shown (without `--all`): name and number of visible fields */
|
|
661
|
+
/** The forms not shown (without `--all`): name and number of visible fields (all fields of a hidden form) */
|
|
555
662
|
otherForms?: Array<{
|
|
556
663
|
index: number;
|
|
557
664
|
name: string | null;
|
|
558
665
|
fieldCount: number;
|
|
666
|
+
hidden: boolean;
|
|
667
|
+
inDialog: boolean;
|
|
559
668
|
}>;
|
|
560
669
|
brief?: boolean | undefined;
|
|
561
670
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { OutputFormatter, areHintsHidden } from '../formatting.js';
|
|
2
|
+
import { a11yMoreMatchesNote } from '../messages/commands.js';
|
|
2
3
|
/**
|
|
3
4
|
* Maximum number of nodes to display in tree output before truncating.
|
|
4
5
|
* Prevents overwhelming terminal output for large accessibility trees.
|
|
@@ -111,6 +112,8 @@ export function formatA11yQueryResult(result) {
|
|
|
111
112
|
const index = node.index !== undefined ? `[${node.index}] ` : '';
|
|
112
113
|
fmt.text(index + formatA11yNodeOneLine(node)).blank();
|
|
113
114
|
}
|
|
115
|
+
if (result.omitted)
|
|
116
|
+
fmt.text(a11yMoreMatchesNote(result.omitted)).blank();
|
|
114
117
|
const first = result.nodes[0];
|
|
115
118
|
if (first?.index !== undefined && !areHintsHidden()) {
|
|
116
119
|
const fillable = FILLABLE_ROLES.has(first.role.toLowerCase());
|
|
@@ -11,4 +11,12 @@ import { type ConsoleFormatOptions } from './shared.js';
|
|
|
11
11
|
* navigation markers when page reloads are detected.
|
|
12
12
|
*/
|
|
13
13
|
export declare function formatConsoleChronological(messages: ConsoleMessage[], options: ConsoleFormatOptions): string;
|
|
14
|
+
/**
|
|
15
|
+
* The messages `--last` selects: the last N (all for 0 or none).
|
|
16
|
+
*
|
|
17
|
+
* @param messages - Messages after the page and level filters
|
|
18
|
+
* @param last - `--last` value
|
|
19
|
+
* @returns The messages to list
|
|
20
|
+
*/
|
|
21
|
+
export declare function lastMessages(messages: ConsoleMessage[], last: number | undefined): ConsoleMessage[];
|
|
14
22
|
//# sourceMappingURL=chronological.d.ts.map
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* level prefixes, and navigation reload markers.
|
|
4
4
|
*/
|
|
5
5
|
import { OutputFormatter } from '../../formatting.js';
|
|
6
|
+
import { consoleIndexGapNote } from '../../messages/consoleMessages.js';
|
|
6
7
|
import { truncateByLength } from '../../../utils/strings.js';
|
|
7
8
|
import { formatSourceLocation, formatTimestamp } from './shared.js';
|
|
8
9
|
const MAX_LIST_TEXT_LENGTH = 200;
|
|
@@ -14,10 +15,7 @@ const MAX_LIST_TEXT_LENGTH = 200;
|
|
|
14
15
|
*/
|
|
15
16
|
export function formatConsoleChronological(messages, options) {
|
|
16
17
|
const fmt = new OutputFormatter();
|
|
17
|
-
|
|
18
|
-
if (options.last && options.last > 0) {
|
|
19
|
-
displayMessages = messages.slice(-options.last);
|
|
20
|
-
}
|
|
18
|
+
const displayMessages = lastMessages(messages, options.last);
|
|
21
19
|
const headerSuffix = options.history ? ' (all navigations)' : '';
|
|
22
20
|
const header = displayMessages.length === messages.length
|
|
23
21
|
? `Console Messages (${messages.length} total)${headerSuffix}`
|
|
@@ -53,6 +51,21 @@ export function formatConsoleChronological(messages, options) {
|
|
|
53
51
|
fmt.text(`${sourceIndent}→ ${source}`);
|
|
54
52
|
}
|
|
55
53
|
}
|
|
54
|
+
const { skipped } = options;
|
|
55
|
+
if (skipped && skipped.otherPages + skipped.otherLevels > 0) {
|
|
56
|
+
fmt.blank();
|
|
57
|
+
fmt.text(consoleIndexGapNote(skipped));
|
|
58
|
+
}
|
|
56
59
|
return fmt.build();
|
|
57
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* The messages `--last` selects: the last N (all for 0 or none).
|
|
63
|
+
*
|
|
64
|
+
* @param messages - Messages after the page and level filters
|
|
65
|
+
* @param last - `--last` value
|
|
66
|
+
* @returns The messages to list
|
|
67
|
+
*/
|
|
68
|
+
export function lastMessages(messages, last) {
|
|
69
|
+
return last && last > 0 ? messages.slice(-last) : messages;
|
|
70
|
+
}
|
|
58
71
|
//# sourceMappingURL=chronological.js.map
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* deduplicated errors/warnings; full message list is included only when
|
|
4
4
|
* --list is set.
|
|
5
5
|
*/
|
|
6
|
+
import { lastMessages } from './chronological.js';
|
|
6
7
|
import { analyzeMessages, } from './shared.js';
|
|
7
8
|
function toJsonError(dedup, includeStackTrace) {
|
|
8
9
|
const source = dedup.message.stackTrace?.[0];
|
|
@@ -37,10 +38,8 @@ export function buildConsoleJsonOutput(messages, options) {
|
|
|
37
38
|
errors: grouped.errors.map((d) => toJsonError(d, true)),
|
|
38
39
|
warnings: grouped.warnings.map((d) => toJsonError(d, false)),
|
|
39
40
|
};
|
|
40
|
-
if (options.list)
|
|
41
|
-
|
|
42
|
-
output.messages = displayMessages;
|
|
43
|
-
}
|
|
41
|
+
if (options.list)
|
|
42
|
+
output.messages = lastMessages(messages, options.last);
|
|
44
43
|
return output;
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
@@ -55,6 +55,18 @@ export interface ConsoleFormatOptions {
|
|
|
55
55
|
history?: boolean | undefined;
|
|
56
56
|
/** Filter by level (error, warning, info, debug) */
|
|
57
57
|
level?: ConsoleLevel | undefined;
|
|
58
|
+
/** Messages between the first and last listed index that the filters left out */
|
|
59
|
+
skipped?: ConsoleSkipped | undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Messages the page and level filters left out between the first and last
|
|
63
|
+
* listed index (session indices then skip numbers).
|
|
64
|
+
*/
|
|
65
|
+
export interface ConsoleSkipped {
|
|
66
|
+
/** Logged by another page load (`--history` lists them) */
|
|
67
|
+
otherPages: number;
|
|
68
|
+
/** Of another level (`--level`) */
|
|
69
|
+
otherLevels: number;
|
|
58
70
|
}
|
|
59
71
|
/**
|
|
60
72
|
* JSON error/warning entry structure.
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { ConsoleMessage } from '../../types.js';
|
|
9
9
|
import { type ConsoleFormatOptions } from './console/shared.js';
|
|
10
|
-
export type { ConsoleFormatOptions, ConsoleJsonOutput, ConsoleLevel, ConsoleSummary, DeduplicatedMessage, } from './console/shared.js';
|
|
10
|
+
export type { ConsoleFormatOptions, ConsoleJsonOutput, ConsoleLevel, ConsoleSkipped, ConsoleSummary, DeduplicatedMessage, } from './console/shared.js';
|
|
11
11
|
export { LEVEL_MAP } from './console/shared.js';
|
|
12
|
-
export { formatConsoleChronological } from './console/chronological.js';
|
|
12
|
+
export { formatConsoleChronological, lastMessages } from './console/chronological.js';
|
|
13
13
|
export { formatConsoleFollowLines } from './console/follow.js';
|
|
14
14
|
export { buildConsoleJsonOutput, formatConsoleJson } from './console/json.js';
|
|
15
15
|
export { formatConsoleSummary } from './console/summarize.js';
|
|
@@ -9,7 +9,7 @@ import { formatConsoleChronological } from './console/chronological.js';
|
|
|
9
9
|
import { formatConsoleJson } from './console/json.js';
|
|
10
10
|
import { formatConsoleSummary } from './console/summarize.js';
|
|
11
11
|
export { LEVEL_MAP } from './console/shared.js';
|
|
12
|
-
export { formatConsoleChronological } from './console/chronological.js';
|
|
12
|
+
export { formatConsoleChronological, lastMessages } from './console/chronological.js';
|
|
13
13
|
export { formatConsoleFollowLines } from './console/follow.js';
|
|
14
14
|
export { buildConsoleJsonOutput, formatConsoleJson } from './console/json.js';
|
|
15
15
|
export { formatConsoleSummary } from './console/summarize.js';
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { NetworkRequest, ConsoleMessage } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The address Chrome connected to, with its port, noting when it looks like
|
|
4
|
+
* a proxy on this machine ({@link looksLikeLocalProxy}).
|
|
5
|
+
*
|
|
6
|
+
* @param request - Request with `serverIPAddress`
|
|
7
|
+
* @returns e.g. `93.184.215.14:443`, `[2606:4700::1]:443`, `127.0.0.1:9000 (loopback; likely a local proxy)`
|
|
8
|
+
*/
|
|
9
|
+
export declare function remoteAddress(request: NetworkRequest): string;
|
|
2
10
|
/**
|
|
3
11
|
* Format network request details for human-readable output.
|
|
4
12
|
*
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { skippedBodyReason } from '../../telemetry/network.js';
|
|
2
2
|
import { formatFramePosition, formatTimestamp } from './console/shared.js';
|
|
3
|
+
import { headerValueLines } from './networkHeaders.js';
|
|
3
4
|
import { formatRequestStatus } from './requestStatus.js';
|
|
4
5
|
import { OutputFormatter } from '../formatting.js';
|
|
6
|
+
import { localProxyNote } from '../messages/networkMessages.js';
|
|
7
|
+
import { sessionCommand } from '../messages/sessionCommand.js';
|
|
5
8
|
import { truncateByLength } from '../../utils/strings.js';
|
|
9
|
+
import { safeParseUrl } from '../../utils/url.js';
|
|
6
10
|
/** Characters of each WebSocket message shown in human output (`--json` has all) */
|
|
7
11
|
const MESSAGE_PREVIEW_LENGTH = 200;
|
|
8
12
|
/** WebSocket opcode of binary messages */
|
|
@@ -94,6 +98,58 @@ function formatBytes(bytes) {
|
|
|
94
98
|
? `${(bytes / 1024).toFixed(1)} KB`
|
|
95
99
|
: `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
96
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether an IP address is a loopback address (`127.0.0.0/8`, `::1`).
|
|
103
|
+
*
|
|
104
|
+
* @param ip - Address as CDP reports it (IPv6 may come in brackets)
|
|
105
|
+
* @returns True for loopback
|
|
106
|
+
*/
|
|
107
|
+
function isLoopback(ip) {
|
|
108
|
+
const bare = ip.replace(/^\[|\]$/g, '').toLowerCase();
|
|
109
|
+
return /^(::ffff:)?127\./.test(bare) || bare === '::1';
|
|
110
|
+
}
|
|
111
|
+
/** Ports of URLs without one */
|
|
112
|
+
const DEFAULT_PORTS = {
|
|
113
|
+
'http:': '80',
|
|
114
|
+
'https:': '443',
|
|
115
|
+
'ws:': '80',
|
|
116
|
+
'wss:': '443',
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Whether a request probably went through a proxy on this machine: Chrome
|
|
120
|
+
* connected to a loopback address on another port than the URL's (given or
|
|
121
|
+
* the scheme's default), for a host that is not this machine. A loopback
|
|
122
|
+
* host from `/etc/hosts` (`myapp.test`) is connected to on the URL's port,
|
|
123
|
+
* so it is not taken for a proxy. CDP has no proxy flag; this is a guess.
|
|
124
|
+
*
|
|
125
|
+
* @param request - Request with `serverIPAddress` and `serverPort`
|
|
126
|
+
* @returns True when the connection looks like a local proxy
|
|
127
|
+
*/
|
|
128
|
+
function looksLikeLocalProxy(request) {
|
|
129
|
+
const url = safeParseUrl(request.url);
|
|
130
|
+
if (!url || request.serverPort === undefined || !isLoopback(request.serverIPAddress ?? '')) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
const hostname = url.hostname.toLowerCase();
|
|
134
|
+
if (hostname === 'localhost' || hostname.endsWith('.localhost') || isLoopback(hostname)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const urlPort = url.port || DEFAULT_PORTS[url.protocol];
|
|
138
|
+
return urlPort !== undefined && String(request.serverPort) !== urlPort;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The address Chrome connected to, with its port, noting when it looks like
|
|
142
|
+
* a proxy on this machine ({@link looksLikeLocalProxy}).
|
|
143
|
+
*
|
|
144
|
+
* @param request - Request with `serverIPAddress`
|
|
145
|
+
* @returns e.g. `93.184.215.14:443`, `[2606:4700::1]:443`, `127.0.0.1:9000 (loopback; likely a local proxy)`
|
|
146
|
+
*/
|
|
147
|
+
export function remoteAddress(request) {
|
|
148
|
+
const ip = request.serverIPAddress ?? '';
|
|
149
|
+
const host = ip.includes(':') && !ip.startsWith('[') ? `[${ip}]` : ip;
|
|
150
|
+
const address = request.serverPort ? `${host}:${request.serverPort}` : host;
|
|
151
|
+
return looksLikeLocalProxy(request) ? `${address} ${localProxyNote()}` : address;
|
|
152
|
+
}
|
|
97
153
|
/**
|
|
98
154
|
* Summary rows of a request: identity, outcome, timing and size.
|
|
99
155
|
*
|
|
@@ -121,13 +177,14 @@ function requestSummaryRows(request) {
|
|
|
121
177
|
if (request.fromCache)
|
|
122
178
|
rows.push(['From Cache', 'yes']);
|
|
123
179
|
if (request.serverIPAddress)
|
|
124
|
-
rows.push(['Remote Address', request
|
|
180
|
+
rows.push(['Remote Address', remoteAddress(request)]);
|
|
125
181
|
if (request.blockedReason)
|
|
126
182
|
rows.push(['Blocked', request.blockedReason]);
|
|
127
183
|
return rows;
|
|
128
184
|
}
|
|
129
185
|
/**
|
|
130
|
-
* Add a header block
|
|
186
|
+
* Add a header block, a header sent several times one value per line
|
|
187
|
+
* ({@link headerValueLines}).
|
|
131
188
|
*
|
|
132
189
|
* @param fmt - Formatter
|
|
133
190
|
* @param title - Block title
|
|
@@ -135,7 +192,7 @@ function requestSummaryRows(request) {
|
|
|
135
192
|
*/
|
|
136
193
|
function addHeaders(fmt, title, headers) {
|
|
137
194
|
fmt.text(title).separator('━', 70);
|
|
138
|
-
Object.entries(headers).forEach(([key, value]) => fmt.text(` ${key}: ${
|
|
195
|
+
Object.entries(headers).forEach(([key, value]) => headerValueLines(key, value).forEach((line) => fmt.text(` ${key}: ${line}`)));
|
|
139
196
|
fmt.blank();
|
|
140
197
|
}
|
|
141
198
|
/**
|
|
@@ -155,7 +212,7 @@ function describeResponseBody(request) {
|
|
|
155
212
|
const body = request.responseBody;
|
|
156
213
|
if (body.length <= BODY_PREVIEW_LENGTH)
|
|
157
214
|
return body;
|
|
158
|
-
return `${body.slice(0, BODY_PREVIEW_LENGTH)}\n… ${body.length - BODY_PREVIEW_LENGTH} more characters (full body: bdg details network ${request.requestId} --json)`;
|
|
215
|
+
return `${body.slice(0, BODY_PREVIEW_LENGTH)}\n… ${body.length - BODY_PREVIEW_LENGTH} more characters (full body: ${sessionCommand(`bdg details network ${request.requestId} --json`)})`;
|
|
159
216
|
}
|
|
160
217
|
/**
|
|
161
218
|
* Format network request details for human-readable output.
|
|
@@ -3,10 +3,12 @@ import type { DomQueryResult, DomGetResult, ScreenshotResult } from '../../types
|
|
|
3
3
|
/**
|
|
4
4
|
* Format DOM query results for human-readable output.
|
|
5
5
|
*
|
|
6
|
-
* Displays found nodes with their index, tag,
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Displays found nodes with their index, tag, identifying attributes
|
|
7
|
+
* ({@link queryTagAttributes}), classes, and preview text
|
|
8
|
+
* (plus where they are when outside the viewport or hidden, e.g.
|
|
9
|
+
* `(below fold)`), up to {@link QUERY_DISPLAY_LIMIT} of them (no match is an error, exit 83).
|
|
10
|
+
* One line of next commands follows; they take the match's index, so they
|
|
11
|
+
* work for matches in shadow roots and iframes too.
|
|
10
12
|
*
|
|
11
13
|
* @param data - DOM query result containing selector, count, and matching nodes
|
|
12
14
|
* @returns Formatted output string
|
|
@@ -61,18 +63,23 @@ export declare function formatDomGet(data: DomGetResult): string;
|
|
|
61
63
|
/**
|
|
62
64
|
* Format DOM eval results for human-readable output.
|
|
63
65
|
*
|
|
64
|
-
*
|
|
65
|
-
* `
|
|
66
|
+
* A string result is printed as is (not JSON-quoted), so text reads and
|
|
67
|
+
* pipes like `echo`, unless that would read as another value (empty,
|
|
68
|
+
* `undefined`, or valid JSON such as `42` or `[1,2]`): then it stays
|
|
69
|
+
* JSON-quoted. Other values are formatted JSON, and values Chrome only
|
|
70
|
+
* describes (functions, DOM nodes) their description. The iframe it ran in
|
|
71
|
+
* (`--frame`) is reported on stderr, so stdout stays the bare value. `--json`
|
|
72
|
+
* output is unchanged (the value in `data.result`).
|
|
66
73
|
*
|
|
67
|
-
* @param data - DOM eval result containing the evaluated value
|
|
68
|
-
* @returns
|
|
74
|
+
* @param data - DOM eval result containing the evaluated value
|
|
75
|
+
* @returns The string, or formatted JSON
|
|
69
76
|
*
|
|
70
77
|
* @example
|
|
71
78
|
* ```typescript
|
|
72
|
-
* formatDomEval({ result: 'My Page Title' });
|
|
73
|
-
* // Output:
|
|
79
|
+
* formatDomEval({ result: 'My Page Title', type: 'string' });
|
|
80
|
+
* // Output: My Page Title
|
|
74
81
|
*
|
|
75
|
-
* formatDomEval({ result: { url: 'https://example.com', title: 'Example' } });
|
|
82
|
+
* formatDomEval({ result: { url: 'https://example.com', title: 'Example' }, type: 'object' });
|
|
76
83
|
* // Output:
|
|
77
84
|
* // {
|
|
78
85
|
* // "url": "https://example.com",
|
|
@@ -83,22 +90,25 @@ export declare function formatDomGet(data: DomGetResult): string;
|
|
|
83
90
|
export declare function formatDomEval(data: {
|
|
84
91
|
result: unknown;
|
|
85
92
|
type?: string;
|
|
86
|
-
frame?: string;
|
|
87
93
|
}): string;
|
|
88
94
|
/**
|
|
89
|
-
* Format the page's iframes, one per line
|
|
95
|
+
* Format the page's iframes, one per line, nested frames indented below
|
|
96
|
+
* their parent. While the page is still loading (`readyState` set), the list
|
|
97
|
+
* may be incomplete, and says so.
|
|
90
98
|
*
|
|
91
|
-
* @param data - Frames from `bdg dom frames
|
|
99
|
+
* @param data - Frames from `bdg dom frames`, with the readyState of a page still loading
|
|
92
100
|
* @returns Formatted list
|
|
93
101
|
*
|
|
94
102
|
* @example
|
|
95
103
|
* ```
|
|
96
104
|
* [0] http://localhost:3000/widget name=widget same-origin
|
|
97
105
|
* [1] https://pay.example/ #checkout cross-origin, out-of-process
|
|
106
|
+
* [2] about:blank same-origin
|
|
98
107
|
* ```
|
|
99
108
|
*/
|
|
100
109
|
export declare function formatDomFrames(data: {
|
|
101
110
|
frames: DomFrame[];
|
|
111
|
+
readyState?: string;
|
|
102
112
|
}): string;
|
|
103
113
|
/**
|
|
104
114
|
* Format screenshot capture result for human-readable display.
|
|
@@ -115,6 +125,9 @@ export declare function formatDomFrames(data: {
|
|
|
115
125
|
*
|
|
116
126
|
* formatDomScreenshot({ path: './page.png', fullPageSkipped: { reason: 'page_too_tall', ... } });
|
|
117
127
|
* // Output: Screenshot saved to ./page.png (viewport only - page too tall)
|
|
128
|
+
*
|
|
129
|
+
* // An element whose floated children overflow it
|
|
130
|
+
* // Output: Screenshot saved to ./el.png (grown from 940×37 to 940×285 to include content overflowing the element)
|
|
118
131
|
* ```
|
|
119
132
|
*/
|
|
120
133
|
export declare function formatDomScreenshot(data: ScreenshotResult): string;
|