browser-debugger-cli 0.8.0 → 0.9.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 +4 -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 +27 -5
- 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 +152 -113
- 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/query.d.ts +44 -17
- package/dist/commands/dom/helpers/query.js +244 -97
- package/dist/commands/dom/helpers/runElementCommand.d.ts +10 -2
- package/dist/commands/dom/helpers/runElementCommand.js +97 -30
- package/dist/commands/dom/helpers/screenshot.d.ts +4 -1
- package/dist/commands/dom/helpers/screenshot.js +164 -49
- package/dist/commands/dom/index.d.ts +3 -1
- package/dist/commands/dom/index.js +16 -6
- 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 +13 -3
- 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 +6 -13
- package/dist/commands/dom/semanticUtils.js +15 -19
- 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 +4 -11
- package/dist/commands/optionBehaviors.js +112 -21
- package/dist/commands/page.d.ts +2 -1
- package/dist/commands/page.js +41 -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/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 +40 -5
- package/dist/commands/shared/startHelpers.js +12 -3
- package/dist/commands/shared/validation.d.ts +3 -2
- package/dist/commands/shared/validation.js +4 -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 +2 -1
- package/dist/daemon/launcher.js +5 -6
- package/dist/daemon/server/SocketServer.js +1 -2
- package/dist/daemon/session/Session.d.ts +13 -0
- package/dist/daemon/session/Session.js +57 -8
- package/dist/daemon/session/chromeConnection.d.ts +9 -0
- package/dist/daemon/session/chromeConnection.js +45 -8
- package/dist/daemon/session/commandRegistry.js +52 -62
- package/dist/daemon/session/interactions.d.ts +35 -9
- package/dist/daemon/session/interactions.js +36 -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 +5393 -1600
- package/dist/errors/messages.d.ts +387 -24
- package/dist/errors/messages.js +761 -67
- package/dist/index.js +3976 -1558
- package/dist/ipc/client.d.ts +12 -1
- package/dist/ipc/client.js +22 -3
- package/dist/ipc/protocol/commands.d.ts +89 -4
- package/dist/ipc/protocol/commands.js +2 -0
- package/dist/ipc/protocol/domTypes.d.ts +258 -7
- 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 +106 -0
- package/dist/runtime/dom/actionEffects.js +256 -0
- package/dist/runtime/dom/actionEffectsScripts.d.ts +52 -0
- package/dist/runtime/dom/actionEffectsScripts.js +234 -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 +77 -0
- package/dist/runtime/dom/elementInfo.js +191 -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 +174 -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 +10 -0
- package/dist/runtime/dom/formFillHelpers/fill.js +125 -10
- 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 +1 -1
- package/dist/runtime/dom/frameSelection.js +2 -2
- package/dist/runtime/dom/frames.d.ts +25 -2
- package/dist/runtime/dom/frames.js +202 -63
- package/dist/runtime/dom/layout.d.ts +67 -0
- package/dist/runtime/dom/layout.js +333 -0
- package/dist/runtime/dom/listenerPageScripts.d.ts +66 -0
- package/dist/runtime/dom/listenerPageScripts.js +279 -0
- package/dist/runtime/dom/listenerSummary.d.ts +132 -11
- package/dist/runtime/dom/listenerSummary.js +344 -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 +58 -2
- package/dist/runtime/dom/reactEventHelpers.js +212 -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 +51 -0
- package/dist/runtime/page/emulation.js +80 -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 +8 -3
- package/dist/telemetry/a11y.js +92 -28
- 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 +80 -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.js +2 -1
- package/dist/ui/formatters/dom.d.ts +26 -14
- package/dist/ui/formatters/dom.js +65 -52
- package/dist/ui/formatters/form.js +29 -18
- 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.js +13 -0
- 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 +10 -0
- package/dist/ui/formatting.js +28 -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 +388 -14
- package/dist/ui/messages/commands.js +664 -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/preview.js +5 -4
- package/dist/ui/messages/session.d.ts +16 -21
- package/dist/ui/messages/session.js +28 -26
- package/dist/ui/messages/sessionCommand.d.ts +43 -0
- package/dist/ui/messages/sessionCommand.js +52 -0
- package/dist/utils/async.d.ts +8 -0
- package/dist/utils/async.js +19 -0
- package/dist/utils/http.d.ts +22 -1
- package/dist/utils/http.js +28 -9
- package/dist/utils/selectorFilters.d.ts +36 -8
- package/dist/utils/selectorFilters.js +267 -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
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
* - Raw: full HTML, attributes, and classes
|
|
7
7
|
*/
|
|
8
8
|
import type { DomGetCommandOptions } from '../shared/optionTypes.js';
|
|
9
|
+
/** What `bdg dom get` reads without a selector */
|
|
10
|
+
export declare const DOM_GET_DEFAULT_SELECTOR = "body";
|
|
9
11
|
/**
|
|
10
|
-
* Handle `bdg dom get [selectorOrIndex] [--node-id <id>]`.
|
|
12
|
+
* Handle `bdg dom get [selectorOrIndex] [--index <n>] [--node-id <id>]`.
|
|
11
13
|
*
|
|
12
|
-
* `--node-id` reads that node directly (raw output); otherwise
|
|
13
|
-
*
|
|
14
|
-
* numeric index.
|
|
14
|
+
* `--node-id` reads that node directly (raw output); otherwise reads a cached
|
|
15
|
+
* index or a selector's match (`body` without an argument).
|
|
15
16
|
*
|
|
16
|
-
* @param selectorOrIndex - CSS selector or cached index (
|
|
17
|
+
* @param selectorOrIndex - CSS selector or cached index (default: body)
|
|
17
18
|
* @param options - Command options
|
|
18
19
|
*/
|
|
19
20
|
export declare function handleDomGet(selectorOrIndex: string | undefined, options: DomGetCommandOptions): Promise<void>;
|
package/dist/commands/dom/get.js
CHANGED
|
@@ -6,86 +6,93 @@
|
|
|
6
6
|
* - Raw: full HTML, attributes, and classes
|
|
7
7
|
*/
|
|
8
8
|
import { DomElementResolver } from './DomElementResolver.js';
|
|
9
|
-
import { getDOMElements, getDomContext,
|
|
10
|
-
import { formatSemanticNodeWithContext,
|
|
9
|
+
import { getDOMElements, getDomContext, selectMatch, } from './helpers/index.js';
|
|
10
|
+
import { formatSemanticNodeWithContext, resolveNodeWithFallback, } from './semanticUtils.js';
|
|
11
11
|
import { runCommand } from '../shared/CommandRunner.js';
|
|
12
12
|
import { CommandError } from '../../errors/index.js';
|
|
13
|
-
import {
|
|
13
|
+
import { conflictingOptionsMessage, indexWithIndexOptionError, nodeIdNotFoundError, optionRequiresMessage, } from '../../errors/messages.js';
|
|
14
14
|
import { resolveA11yNode } from '../../telemetry/a11y.js';
|
|
15
15
|
import { formatDomGet } from '../../ui/formatters/dom.js';
|
|
16
16
|
import { EXIT_CODES } from '../../utils/exitCodes.js';
|
|
17
17
|
import { filterDefined } from '../../utils/objects.js';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
/** What `bdg dom get` reads without a selector */
|
|
19
|
+
export const DOM_GET_DEFAULT_SELECTOR = 'body';
|
|
20
|
+
/**
|
|
21
|
+
* The element to read: a cached index or a selector match.
|
|
22
|
+
*
|
|
23
|
+
* @param selectorOrIndex - CSS selector or cached index
|
|
24
|
+
* @param index - Which match of the selector (0-based)
|
|
25
|
+
* @returns Backend node id
|
|
26
|
+
* @throws CommandError (83) no match, (81) index out of range, (87) stale cached index
|
|
27
|
+
*/
|
|
28
|
+
async function targetNodeId(selectorOrIndex, index) {
|
|
28
29
|
const resolver = DomElementResolver.getInstance();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const ref = { backendNodeId: targetNode.nodeId };
|
|
32
|
-
const [a11yNode, domContext] = await Promise.all([resolveA11yNode(ref), getDomContext(ref)]);
|
|
33
|
-
const node = resolveNodeWithFallback(a11yNode, domContext, targetNode.nodeId);
|
|
34
|
-
if (!node) {
|
|
35
|
-
const err = elementAtIndexNotFoundError(index, 'cached query');
|
|
36
|
-
throw new CommandError(err.message, { suggestion: err.suggestion }, EXIT_CODES.RESOURCE_NOT_FOUND);
|
|
37
|
-
}
|
|
38
|
-
return { success: true, data: { node, domContext } };
|
|
39
|
-
}, options, formatSemanticNodeWithContext);
|
|
40
|
-
}
|
|
41
|
-
async function handleIndexGet(index, options) {
|
|
42
|
-
if (options.raw) {
|
|
43
|
-
await handleIndexGetRaw(index, options);
|
|
30
|
+
if (resolver.isNumericIndex(selectorOrIndex)) {
|
|
31
|
+
return (await resolver.getNodeIdForIndex(Number(selectorOrIndex))).nodeId;
|
|
44
32
|
}
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
return selectMatch(selectorOrIndex, index ?? 0);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Semantic view of one element: its accessibility node (or one inferred from
|
|
37
|
+
* the DOM) and its DOM context.
|
|
38
|
+
*
|
|
39
|
+
* @param backendNodeId - The element
|
|
40
|
+
* @param full - All of its text instead of the first 500 characters
|
|
41
|
+
* @returns Node and context
|
|
42
|
+
* @throws CommandError (83) when the element is gone
|
|
43
|
+
*/
|
|
44
|
+
async function semanticElement(backendNodeId, full) {
|
|
45
|
+
const ref = { backendNodeId };
|
|
46
|
+
const [a11yNode, domContext] = await Promise.all([
|
|
47
|
+
resolveA11yNode(ref),
|
|
48
|
+
getDomContext(ref, { full }),
|
|
49
|
+
]);
|
|
50
|
+
const node = resolveNodeWithFallback(a11yNode, domContext, backendNodeId);
|
|
51
|
+
if (!node) {
|
|
52
|
+
const err = nodeIdNotFoundError(backendNodeId);
|
|
53
|
+
throw new CommandError(err.message, { suggestion: err.suggestion }, EXIT_CODES.RESOURCE_NOT_FOUND);
|
|
47
54
|
}
|
|
55
|
+
return { node, domContext };
|
|
48
56
|
}
|
|
49
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Raw view: the element(s) with attributes and outer HTML.
|
|
59
|
+
*
|
|
60
|
+
* @param selectorOrIndex - CSS selector or cached index
|
|
61
|
+
* @param options - Command options (`--all`, `--index`)
|
|
62
|
+
*/
|
|
63
|
+
async function handleRawGet(selectorOrIndex, options) {
|
|
50
64
|
await runCommand(async () => {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
const resolver = DomElementResolver.getInstance();
|
|
66
|
+
const getOptions = resolver.isNumericIndex(selectorOrIndex)
|
|
67
|
+
? { nodeId: (await resolver.getNodeIdForIndex(Number(selectorOrIndex))).nodeId }
|
|
68
|
+
: filterDefined({
|
|
69
|
+
selector: selectorOrIndex,
|
|
70
|
+
all: options.all,
|
|
71
|
+
nth: matchIndex(options),
|
|
72
|
+
});
|
|
73
|
+
return { success: true, data: await getDOMElements(getOptions) };
|
|
58
74
|
}, options, formatDomGet);
|
|
59
75
|
}
|
|
60
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Semantic view of the target.
|
|
78
|
+
*
|
|
79
|
+
* @param selectorOrIndex - CSS selector or cached index
|
|
80
|
+
* @param options - Command options (`--index`, `--full`)
|
|
81
|
+
*/
|
|
82
|
+
async function handleSemanticGet(selectorOrIndex, options) {
|
|
61
83
|
await runCommand(async () => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
let nodeId;
|
|
65
|
-
if (a11yNode?.backendDOMNodeId) {
|
|
66
|
-
nodeId = a11yNode.backendDOMNodeId;
|
|
67
|
-
domContext = await getDomContext({ backendNodeId: nodeId });
|
|
68
|
-
}
|
|
69
|
-
else if (!a11yNode) {
|
|
70
|
-
const queryResult = await queryDomContextBySelector(selector);
|
|
71
|
-
nodeId = queryResult.nodeId;
|
|
72
|
-
domContext = queryResult.domContext;
|
|
73
|
-
}
|
|
74
|
-
const node = resolveNodeWithFallback(a11yNode, domContext, nodeId);
|
|
75
|
-
if (!node) {
|
|
76
|
-
const err = noNodesFoundError(selector);
|
|
77
|
-
throw new CommandError(err.message, { suggestion: err.suggestion }, EXIT_CODES.RESOURCE_NOT_FOUND);
|
|
78
|
-
}
|
|
79
|
-
return { success: true, data: { node, domContext } };
|
|
84
|
+
const backendNodeId = await targetNodeId(selectorOrIndex, matchIndex(options));
|
|
85
|
+
return { success: true, data: await semanticElement(backendNodeId, options.full === true) };
|
|
80
86
|
}, options, formatSemanticNodeWithContext);
|
|
81
87
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Which match of the selector to read: `--index`, or its alias `--nth`.
|
|
90
|
+
*
|
|
91
|
+
* @param options - Command options
|
|
92
|
+
* @returns 0-based index, undefined for the first match
|
|
93
|
+
*/
|
|
94
|
+
function matchIndex(options) {
|
|
95
|
+
return options.index ?? options.nth;
|
|
89
96
|
}
|
|
90
97
|
/**
|
|
91
98
|
* Options of `dom get` that cannot be combined (one would be ignored).
|
|
@@ -98,22 +105,26 @@ function getOptionsConflict(selectorOrIndex, options) {
|
|
|
98
105
|
if (options.nodeId !== undefined && selectorOrIndex !== undefined) {
|
|
99
106
|
return conflictingOptionsMessage('--node-id', 'a selector or index');
|
|
100
107
|
}
|
|
101
|
-
if (options.
|
|
102
|
-
return conflictingOptionsMessage('--
|
|
108
|
+
if (options.full && (options.raw || options.nodeId !== undefined)) {
|
|
109
|
+
return conflictingOptionsMessage('--full', options.raw ? '--raw' : '--node-id');
|
|
103
110
|
}
|
|
104
|
-
if (
|
|
105
|
-
return
|
|
111
|
+
if (options.index !== undefined && options.nth !== undefined) {
|
|
112
|
+
return conflictingOptionsMessage('--index', '--nth');
|
|
106
113
|
}
|
|
114
|
+
if (options.all && matchIndex(options) !== undefined) {
|
|
115
|
+
return conflictingOptionsMessage('--all', '--index');
|
|
116
|
+
}
|
|
117
|
+
if (options.all && !options.raw)
|
|
118
|
+
return optionRequiresMessage('--all', '--raw');
|
|
107
119
|
return null;
|
|
108
120
|
}
|
|
109
121
|
/**
|
|
110
|
-
* Handle `bdg dom get [selectorOrIndex] [--node-id <id>]`.
|
|
122
|
+
* Handle `bdg dom get [selectorOrIndex] [--index <n>] [--node-id <id>]`.
|
|
111
123
|
*
|
|
112
|
-
* `--node-id` reads that node directly (raw output); otherwise
|
|
113
|
-
*
|
|
114
|
-
* numeric index.
|
|
124
|
+
* `--node-id` reads that node directly (raw output); otherwise reads a cached
|
|
125
|
+
* index or a selector's match (`body` without an argument).
|
|
115
126
|
*
|
|
116
|
-
* @param selectorOrIndex - CSS selector or cached index (
|
|
127
|
+
* @param selectorOrIndex - CSS selector or cached index (default: body)
|
|
117
128
|
* @param options - Command options
|
|
118
129
|
*/
|
|
119
130
|
export async function handleDomGet(selectorOrIndex, options) {
|
|
@@ -126,16 +137,15 @@ export async function handleDomGet(selectorOrIndex, options) {
|
|
|
126
137
|
await runCommand(async () => ({ success: true, data: await getDOMElements({ nodeId }) }), options, formatDomGet);
|
|
127
138
|
return;
|
|
128
139
|
}
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
const target = selectorOrIndex ?? DOM_GET_DEFAULT_SELECTOR;
|
|
141
|
+
if (DomElementResolver.getInstance().isNumericIndex(target) &&
|
|
142
|
+
matchIndex(options) !== undefined) {
|
|
143
|
+
const err = indexWithIndexOptionError(target, 'get');
|
|
131
144
|
throw new CommandError(err.message, { suggestion: err.suggestion }, EXIT_CODES.INVALID_ARGUMENTS);
|
|
132
145
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
else {
|
|
138
|
-
await handleSelectorGet(selectorOrIndex, options);
|
|
139
|
-
}
|
|
146
|
+
if (options.raw)
|
|
147
|
+
await handleRawGet(target, options);
|
|
148
|
+
else
|
|
149
|
+
await handleSemanticGet(target, options);
|
|
140
150
|
}
|
|
141
151
|
//# sourceMappingURL=get.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - `query.ts` — selector → backend node ids (shadow roots, same-origin iframes), DOM.describeNode
|
|
6
6
|
* - `screenshot.ts` — page / element capture, element bounds, scroll helpers
|
|
7
7
|
*/
|
|
8
|
-
export { queryDOMElements, getDomContext, getDOMElements, resolveSelector, resolveBackendNodeIds,
|
|
8
|
+
export { documentReadyState, noMatchesError, queryDOMElements, getDomContext, getDOMElements, resolveSelector, resolveBackendNodeIds, selectMatch, assertNodeAttached, } from './query.js';
|
|
9
9
|
export { capturePageScreenshot, captureElementScreenshot, getElementBounds, } from './screenshot.js';
|
|
10
10
|
export type { DomQueryResult, DomGetResult, ScreenshotResult, DomGetOptions, ScreenshotOptions, DomContext, ElementBounds, } from '../../../types.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* - `query.ts` — selector → backend node ids (shadow roots, same-origin iframes), DOM.describeNode
|
|
6
6
|
* - `screenshot.ts` — page / element capture, element bounds, scroll helpers
|
|
7
7
|
*/
|
|
8
|
-
export { queryDOMElements, getDomContext, getDOMElements, resolveSelector, resolveBackendNodeIds,
|
|
8
|
+
export { documentReadyState, noMatchesError, queryDOMElements, getDomContext, getDOMElements, resolveSelector, resolveBackendNodeIds, selectMatch, assertNodeAttached, } from './query.js';
|
|
9
9
|
export { capturePageScreenshot, captureElementScreenshot, getElementBounds, } from './screenshot.js';
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -9,15 +9,35 @@
|
|
|
9
9
|
* bdg invocations. Selectors are matched in the page, including open shadow
|
|
10
10
|
* roots and same-origin iframes, like a user sees the page.
|
|
11
11
|
*/
|
|
12
|
-
import
|
|
12
|
+
import { type ErrorWithSuggestion, type NoMatchContext } from '../../../errors/messages.js';
|
|
13
|
+
import type { DomQueryResult, DomGetResult, DomGetOptions, DomContext, IndexSource, NodeRef } from '../../../types.js';
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
15
|
+
* The "no nodes" error for a selector that matched nothing. One more page
|
|
16
|
+
* evaluation, on this failure path only, tells what the page says about it
|
|
17
|
+
* ({@link noMatchContext}).
|
|
16
18
|
*
|
|
17
|
-
* @param
|
|
18
|
-
* @returns
|
|
19
|
+
* @param selector - Selector as given
|
|
20
|
+
* @returns Message and suggestion
|
|
19
21
|
*/
|
|
20
|
-
export declare function
|
|
22
|
+
export declare function noMatchesError(selector: string): Promise<ErrorWithSuggestion>;
|
|
23
|
+
/**
|
|
24
|
+
* What the page says about a selector that matched nothing, in one
|
|
25
|
+
* evaluation: whether it is still loading, how many elements match with the
|
|
26
|
+
* selector's `:visible` filters removed, whether it has cross-origin iframes
|
|
27
|
+
* or embeds (which selectors do not search), and for a selector that is a
|
|
28
|
+
* single id or class, the similar ids or classes on the page.
|
|
29
|
+
*
|
|
30
|
+
* @param selector - Selector as given
|
|
31
|
+
* @returns Context for {@link noNodesFoundError} (empty when the page did not answer)
|
|
32
|
+
*/
|
|
33
|
+
export declare function noMatchContext(selector: string): Promise<NoMatchContext>;
|
|
34
|
+
/**
|
|
35
|
+
* The page's `document.readyState`, read for a failure that may come from a
|
|
36
|
+
* page still loading.
|
|
37
|
+
*
|
|
38
|
+
* @returns The state, or undefined when the page did not answer
|
|
39
|
+
*/
|
|
40
|
+
export declare function documentReadyState(): Promise<string | undefined>;
|
|
21
41
|
/**
|
|
22
42
|
* Query elements by selector for `bdg dom query`.
|
|
23
43
|
*
|
|
@@ -26,12 +46,26 @@ export declare function textPreview(text: string): string;
|
|
|
26
46
|
*/
|
|
27
47
|
export declare function queryDOMElements(selector: string): Promise<DomQueryResult>;
|
|
28
48
|
/**
|
|
29
|
-
* Get DOM context (tag, classes, text preview) for a node
|
|
49
|
+
* Get DOM context (tag, classes, text preview) for a node: a one-line
|
|
50
|
+
* preview, and up to {@link ELEMENT_TEXT_LENGTH} characters of text when it
|
|
51
|
+
* is longer (all of it with `full`).
|
|
30
52
|
*
|
|
31
53
|
* @param ref - Node reference
|
|
54
|
+
* @param options - `full`: the whole text instead of its first 500 characters
|
|
32
55
|
* @returns DOM context, or null if the node does not exist
|
|
33
56
|
*/
|
|
34
|
-
export declare function getDomContext(ref: NodeRef
|
|
57
|
+
export declare function getDomContext(ref: NodeRef, options?: {
|
|
58
|
+
full?: boolean;
|
|
59
|
+
}): Promise<DomContext | null>;
|
|
60
|
+
/**
|
|
61
|
+
* One match of a selector.
|
|
62
|
+
*
|
|
63
|
+
* @param selector - CSS selector
|
|
64
|
+
* @param index - Which match (0-based)
|
|
65
|
+
* @returns Its backend node id
|
|
66
|
+
* @throws CommandError (83) when nothing matches, (81) for an index beyond the matches
|
|
67
|
+
*/
|
|
68
|
+
export declare function selectMatch(selector: string, index?: number): Promise<number>;
|
|
35
69
|
/**
|
|
36
70
|
* Get full details (attributes, outer HTML) for `bdg dom get --raw`.
|
|
37
71
|
*
|
|
@@ -55,13 +89,6 @@ export declare function resolveSelector(selector: string): Promise<NodeRef>;
|
|
|
55
89
|
* @returns Backend node id per selector, or undefined when it matches nothing
|
|
56
90
|
*/
|
|
57
91
|
export declare function resolveBackendNodeIds(selectors: string[]): Promise<(number | undefined)[]>;
|
|
58
|
-
/**
|
|
59
|
-
* Accessibility node of the first element matching a selector.
|
|
60
|
-
*
|
|
61
|
-
* @param selector - CSS selector
|
|
62
|
-
* @returns A11y node, or null when nothing matches or the node is not exposed
|
|
63
|
-
*/
|
|
64
|
-
export declare function resolveA11yNodeForSelector(selector: string): Promise<A11yNode | null>;
|
|
65
92
|
/**
|
|
66
93
|
* Check that a cached element is still part of the current page.
|
|
67
94
|
*
|
|
@@ -71,8 +98,8 @@ export declare function resolveA11yNodeForSelector(selector: string): Promise<A1
|
|
|
71
98
|
* false for removed elements.
|
|
72
99
|
*
|
|
73
100
|
* @param backendNodeId - Backend node id from the query cache
|
|
74
|
-
* @param
|
|
101
|
+
* @param source - Index the user gave and the list it refers to, for the error message
|
|
75
102
|
* @throws CommandError (87) when the element is gone
|
|
76
103
|
*/
|
|
77
|
-
export declare function assertNodeAttached(backendNodeId: number,
|
|
104
|
+
export declare function assertNodeAttached(backendNodeId: number, source?: IndexSource): Promise<void>;
|
|
78
105
|
//# sourceMappingURL=query.d.ts.map
|