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,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `bdg dom inspect <selector|index>` - what one element looks like, without a
|
|
3
|
+
* screenshot: its box, layout (and its place in the parent), typography with
|
|
4
|
+
* the rendered font and contrast, fills, borders, effects, CSS state,
|
|
5
|
+
* pseudo-elements and a compact child tree, as grouped lines (`--json`:
|
|
6
|
+
* Figma-aligned fields).
|
|
7
|
+
*/
|
|
8
|
+
import { type Command } from 'commander';
|
|
9
|
+
/**
|
|
10
|
+
* Register `bdg dom inspect`.
|
|
11
|
+
*
|
|
12
|
+
* @param dom - The `dom` command group
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerInspectCommand(dom: Command): void;
|
|
15
|
+
//# sourceMappingURL=inspect.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `bdg dom inspect <selector|index>` - what one element looks like, without a
|
|
3
|
+
* screenshot: its box, layout (and its place in the parent), typography with
|
|
4
|
+
* the rendered font and contrast, fills, borders, effects, CSS state,
|
|
5
|
+
* pseudo-elements and a compact child tree, as grouped lines (`--json`:
|
|
6
|
+
* Figma-aligned fields).
|
|
7
|
+
*/
|
|
8
|
+
import { Option } from 'commander';
|
|
9
|
+
import { runElementCommand } from './helpers/runElementCommand.js';
|
|
10
|
+
import { runCommand } from '../shared/CommandRunner.js';
|
|
11
|
+
import { jsonOption, SELECTOR_OR_INDEX_ARGUMENT } from '../shared/commonOptions.js';
|
|
12
|
+
import { cssPropertiesOption, integerOption } from '../shared/validation.js';
|
|
13
|
+
import { domInspect } from '../../ipc/client.js';
|
|
14
|
+
import { DEFAULT_TREE_DEPTH, DEFAULT_TREE_LIMIT } from '../../runtime/dom/inspectTree.js';
|
|
15
|
+
import { formatInspect } from '../../ui/formatters/inspect.js';
|
|
16
|
+
import { INSPECT_OUTPUT_LEGEND } from '../../ui/messages/commands.js';
|
|
17
|
+
import { filterDefined } from '../../utils/objects.js';
|
|
18
|
+
/**
|
|
19
|
+
* Register `bdg dom inspect`.
|
|
20
|
+
*
|
|
21
|
+
* @param dom - The `dom` command group
|
|
22
|
+
*/
|
|
23
|
+
export function registerInspectCommand(dom) {
|
|
24
|
+
dom
|
|
25
|
+
.command('inspect')
|
|
26
|
+
.description('What one element looks like without a screenshot: box, layout, font (rendered, contrast), colors, borders, effects, pseudo-elements and child tree')
|
|
27
|
+
.argument('<selectorOrIndex>', SELECTOR_OR_INDEX_ARGUMENT)
|
|
28
|
+
.option('--index <n>', 'Which match to inspect (0-based; default: the first rendered one)', integerOption(0))
|
|
29
|
+
.option('--tree <depth>', `Child tree depth (default ${DEFAULT_TREE_DEPTH}; 0 for none)`, integerOption(0, 10))
|
|
30
|
+
.option('--tree-limit <n>', `Child tree rows at most (default ${DEFAULT_TREE_LIMIT})`, integerOption(1, 500))
|
|
31
|
+
.addOption(new Option('--all', 'Every computed property that is not its default, collapsed into shorthands, instead of the groups').conflicts('props'))
|
|
32
|
+
.addHelpText('after', INSPECT_OUTPUT_LEGEND)
|
|
33
|
+
.option('--props <names>', "Only these properties, computed and normalized (comma-separated, e.g. padding,color,--brand; '--*' or '--bs-btn-*' lists custom properties)", cssPropertiesOption)
|
|
34
|
+
.addOption(new Option('--rules', 'Also show which CSS rule sets each shown property (selector, file:line, what it overrides); with --props, those properties').conflicts('all'))
|
|
35
|
+
.addOption(new Option('--why <property>', 'Every declaration of one property: the one that applies and those it overrides (e.g. --why color)')
|
|
36
|
+
.conflicts('all')
|
|
37
|
+
.argParser(propertyOption))
|
|
38
|
+
.option('--no-hints', 'Skip the check for declarations that have no effect')
|
|
39
|
+
.addOption(jsonOption())
|
|
40
|
+
.action(async (selectorOrIndex, options) => {
|
|
41
|
+
await runCommand(() => inspectTarget(selectorOrIndex, options), options, formatInspect);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parse `--why`: a property name, lowercased (custom properties as given).
|
|
46
|
+
*
|
|
47
|
+
* @param value - Property name
|
|
48
|
+
* @returns Name
|
|
49
|
+
*/
|
|
50
|
+
function propertyOption(value) {
|
|
51
|
+
return value.startsWith('--') ? value.trim() : value.trim().toLowerCase();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Resolve the target and ask the daemon to inspect it.
|
|
55
|
+
*
|
|
56
|
+
* @param selectorOrIndex - CSS selector or cached query index
|
|
57
|
+
* @param options - Command options
|
|
58
|
+
* @returns Command result
|
|
59
|
+
*/
|
|
60
|
+
async function inspectTarget(selectorOrIndex, options) {
|
|
61
|
+
return runElementCommand({
|
|
62
|
+
selectorOrIndex,
|
|
63
|
+
index: options.index,
|
|
64
|
+
buildRequest: (target) => ({
|
|
65
|
+
...target,
|
|
66
|
+
...filterDefined({
|
|
67
|
+
tree: options.tree,
|
|
68
|
+
treeLimit: options.treeLimit,
|
|
69
|
+
all: options.all,
|
|
70
|
+
props: options.props,
|
|
71
|
+
rules: options.rules,
|
|
72
|
+
why: options.why,
|
|
73
|
+
...(options.hints === false && { hints: false }),
|
|
74
|
+
}),
|
|
75
|
+
}),
|
|
76
|
+
call: domInspect,
|
|
77
|
+
command: 'inspect',
|
|
78
|
+
action: 'inspect the element',
|
|
79
|
+
failureSuggestion: 'Verify the selector matches an element: bdg dom query "<selector>"',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=inspect.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `bdg dom layout <selector|index>` - where elements are on the page and
|
|
3
|
+
* whether a user can see them, without a screenshot: page and viewport
|
|
4
|
+
* coordinates, size, viewport position (visible, partly, above/below the
|
|
5
|
+
* fold, hidden), what covers them and the styles that decide how they show.
|
|
6
|
+
*/
|
|
7
|
+
import type { Command } from 'commander';
|
|
8
|
+
/**
|
|
9
|
+
* Register `bdg dom layout`.
|
|
10
|
+
*
|
|
11
|
+
* @param dom - The `dom` command group
|
|
12
|
+
*/
|
|
13
|
+
export declare function registerLayoutCommand(dom: Command): void;
|
|
14
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `bdg dom layout <selector|index>` - where elements are on the page and
|
|
3
|
+
* whether a user can see them, without a screenshot: page and viewport
|
|
4
|
+
* coordinates, size, viewport position (visible, partly, above/below the
|
|
5
|
+
* fold, hidden), what covers them and the styles that decide how they show.
|
|
6
|
+
*/
|
|
7
|
+
import { DomElementResolver } from './DomElementResolver.js';
|
|
8
|
+
import { runElementCommand } from './helpers/runElementCommand.js';
|
|
9
|
+
import { runCommand } from '../shared/CommandRunner.js';
|
|
10
|
+
import { jsonOption, SELECTOR_OR_INDEX_ARGUMENT } from '../shared/commonOptions.js';
|
|
11
|
+
import { integerOption } from '../shared/validation.js';
|
|
12
|
+
import { domLayout } from '../../ipc/client.js';
|
|
13
|
+
import { formatLayout } from '../../ui/formatters/layout.js';
|
|
14
|
+
/**
|
|
15
|
+
* Register `bdg dom layout`.
|
|
16
|
+
*
|
|
17
|
+
* @param dom - The `dom` command group
|
|
18
|
+
*/
|
|
19
|
+
export function registerLayoutCommand(dom) {
|
|
20
|
+
dom
|
|
21
|
+
.command('layout')
|
|
22
|
+
.description('Positions, sizes and visibility of elements (above/below the fold, hidden, covered) without a screenshot')
|
|
23
|
+
.argument('<selectorOrIndex>', SELECTOR_OR_INDEX_ARGUMENT)
|
|
24
|
+
.option('--index <n>', 'Only this match of the selector (0-based)', integerOption(0))
|
|
25
|
+
.addOption(jsonOption())
|
|
26
|
+
.action(async (selectorOrIndex, options) => {
|
|
27
|
+
await runCommand(() => measureLayout(selectorOrIndex, options), options, formatLayout);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the target and ask the daemon to measure it.
|
|
32
|
+
*
|
|
33
|
+
* @param selectorOrIndex - CSS selector or cached query index
|
|
34
|
+
* @param options - Command options
|
|
35
|
+
* @returns Command result; an index argument is reported as the element's `index`
|
|
36
|
+
*/
|
|
37
|
+
async function measureLayout(selectorOrIndex, options) {
|
|
38
|
+
const result = await runElementCommand({
|
|
39
|
+
selectorOrIndex,
|
|
40
|
+
index: options.index,
|
|
41
|
+
buildRequest: (target) => target,
|
|
42
|
+
call: domLayout,
|
|
43
|
+
command: 'layout',
|
|
44
|
+
action: 'measure the layout',
|
|
45
|
+
failureSuggestion: 'Verify the selector matches an element: bdg dom query "<selector>"',
|
|
46
|
+
});
|
|
47
|
+
if (!result.data || !DomElementResolver.getInstance().isNumericIndex(selectorOrIndex)) {
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
const index = Number(selectorOrIndex);
|
|
51
|
+
const elements = result.data.elements.map((element) => ({ ...element, index }));
|
|
52
|
+
return { ...result, data: { ...result.data, elements } };
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* The daemon collects them with `DOMDebugger.getEventListeners`; listeners on
|
|
6
6
|
* ancestors matter because frameworks (React, jQuery) attach their handlers
|
|
7
|
-
* to a root container or the document and dispatch from there.
|
|
7
|
+
* to a root container or the document and dispatch from there. jQuery's
|
|
8
|
+
* dispatcher is replaced by the jQuery handlers it runs for the element,
|
|
9
|
+
* React's `on…` props of the element and its ancestors are listed, and
|
|
10
|
+
* framework roots (React's root container) are summarised per node unless
|
|
11
|
+
* `--all` is given.
|
|
8
12
|
*/
|
|
9
13
|
import type { Command } from 'commander';
|
|
10
14
|
/**
|
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
*
|
|
5
5
|
* The daemon collects them with `DOMDebugger.getEventListeners`; listeners on
|
|
6
6
|
* ancestors matter because frameworks (React, jQuery) attach their handlers
|
|
7
|
-
* to a root container or the document and dispatch from there.
|
|
7
|
+
* to a root container or the document and dispatch from there. jQuery's
|
|
8
|
+
* dispatcher is replaced by the jQuery handlers it runs for the element,
|
|
9
|
+
* React's `on…` props of the element and its ancestors are listed, and
|
|
10
|
+
* framework roots (React's root container) are summarised per node unless
|
|
11
|
+
* `--all` is given.
|
|
8
12
|
*/
|
|
9
13
|
import { DomElementResolver } from './DomElementResolver.js';
|
|
10
14
|
import { runElementCommand } from './helpers/runElementCommand.js';
|
|
11
15
|
import { runCommand } from '../shared/CommandRunner.js';
|
|
12
|
-
import { jsonOption } from '../shared/commonOptions.js';
|
|
16
|
+
import { jsonOption, SELECTOR_OR_INDEX_ARGUMENT } from '../shared/commonOptions.js';
|
|
13
17
|
import { eventTypesOption, integerOption } from '../shared/validation.js';
|
|
14
18
|
import { domListeners } from '../../ipc/client.js';
|
|
15
19
|
import { formatListeners } from '../../ui/formatters/listeners.js';
|
|
@@ -22,9 +26,10 @@ export function registerListenersCommand(dom) {
|
|
|
22
26
|
dom
|
|
23
27
|
.command('listeners')
|
|
24
28
|
.description('List event listeners that run for an element (incl. delegated ones on ancestors)')
|
|
25
|
-
.argument('<selectorOrIndex>',
|
|
29
|
+
.argument('<selectorOrIndex>', SELECTOR_OR_INDEX_ARGUMENT)
|
|
26
30
|
.option('--index <n>', 'Element index if selector matches multiple (0-based)', integerOption(0))
|
|
27
|
-
.option('--type <types>', 'Only these event types (comma-separated, e.g. click,keydown)', eventTypesOption)
|
|
31
|
+
.option('--type <types>', 'Only these event types (comma-separated, e.g. click,keydown; repeatable)', eventTypesOption)
|
|
32
|
+
.option('--all', 'List every listener of framework roots (React) instead of one line per node')
|
|
28
33
|
.addOption(jsonOption())
|
|
29
34
|
.action(async (selectorOrIndex, options) => {
|
|
30
35
|
await runCommand(() => listElementListeners(selectorOrIndex, options), options, (data) => formatListeners(data, options.type));
|
|
@@ -41,8 +46,13 @@ async function listElementListeners(selectorOrIndex, options) {
|
|
|
41
46
|
const result = await runElementCommand({
|
|
42
47
|
selectorOrIndex,
|
|
43
48
|
index: options.index,
|
|
44
|
-
buildRequest: (target) => ({
|
|
49
|
+
buildRequest: (target) => ({
|
|
50
|
+
...target,
|
|
51
|
+
...(options.type && { types: options.type }),
|
|
52
|
+
...(options.all && { all: true }),
|
|
53
|
+
}),
|
|
45
54
|
call: domListeners,
|
|
55
|
+
command: 'listeners',
|
|
46
56
|
action: 'list event listeners',
|
|
47
57
|
failureSuggestion: 'Verify the selector matches an element: bdg dom query "<selector>"',
|
|
48
58
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `bdg dom query` — find elements by CSS selector and populate the query cache.
|
|
3
3
|
*/
|
|
4
|
-
import { queryDOMElements } from './helpers/index.js';
|
|
4
|
+
import { noMatchesError, queryDOMElements } from './helpers/index.js';
|
|
5
5
|
import { runCommand } from '../shared/CommandRunner.js';
|
|
6
|
-
import { noNodesFoundError } from '../../errors/messages.js';
|
|
7
6
|
import { QueryCacheManager } from '../../session/QueryCacheManager.js';
|
|
8
7
|
import { formatDomQuery } from '../../ui/formatters/dom.js';
|
|
9
8
|
import { EXIT_CODES } from '../../utils/exitCodes.js';
|
|
@@ -21,7 +20,7 @@ export async function handleDomQuery(selector, options) {
|
|
|
21
20
|
const cache = QueryCacheManager.getInstance();
|
|
22
21
|
if (result.count === 0) {
|
|
23
22
|
await cache.clear();
|
|
24
|
-
const err =
|
|
23
|
+
const err = await noMatchesError(selector);
|
|
25
24
|
return {
|
|
26
25
|
success: false,
|
|
27
26
|
error: err.message,
|
|
@@ -13,9 +13,19 @@ import type { DomScreenshotCommandOptions } from '../shared/optionTypes.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function resolveImageFormat(outputPath: string, requested?: 'png' | 'jpeg'): 'png' | 'jpeg';
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Fold the optional positional target (`bdg dom screenshot out.png "#sel"`,
|
|
17
|
+
* or an index from a query) into `--selector` / `--index`.
|
|
18
|
+
*
|
|
19
|
+
* @param target - Positional selector or index, if given
|
|
20
|
+
* @param options - Command options
|
|
21
|
+
* @returns Options with the target as `selector` or `index`
|
|
22
|
+
* @throws CommandError (81) when the option names a different element
|
|
23
|
+
*/
|
|
24
|
+
export declare function withPositionalTarget(target: string | undefined, options: DomScreenshotCommandOptions): DomScreenshotCommandOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Handle `bdg dom screenshot <path> [selector|index]`.
|
|
17
27
|
*
|
|
18
28
|
* Dispatches to page, element, or sequence capture based on flags.
|
|
19
29
|
*/
|
|
20
|
-
export declare function handleDomScreenshot(outputPath: string,
|
|
30
|
+
export declare function handleDomScreenshot(outputPath: string, target: string | undefined, commandOptions: DomScreenshotCommandOptions): Promise<void>;
|
|
21
31
|
//# sourceMappingURL=screenshot.d.ts.map
|
|
@@ -8,7 +8,7 @@ import { runCommand } from '../shared/CommandRunner.js';
|
|
|
8
8
|
import { assertFilePath, outputPathError } from '../shared/outputFile.js';
|
|
9
9
|
import { positiveIntRule } from '../shared/validation.js';
|
|
10
10
|
import { CommandError } from '../../errors/index.js';
|
|
11
|
-
import { conflictingOptionsMessage, genericError } from '../../errors/messages.js';
|
|
11
|
+
import { conflictingOptionsMessage, conflictingTargetError, genericError, } from '../../errors/messages.js';
|
|
12
12
|
import { missingArgumentError } from '../../errors/messages.js';
|
|
13
13
|
import { OutputBuilder, buildSuccessResponse } from '../../ui/OutputBuilder.js';
|
|
14
14
|
import { formatDomScreenshot } from '../../ui/formatters/dom.js';
|
|
@@ -90,6 +90,7 @@ function addElementInfo(result, options) {
|
|
|
90
90
|
...(options.selector !== undefined && { selector: options.selector }),
|
|
91
91
|
...(options.index !== undefined && { index: options.index }),
|
|
92
92
|
bounds,
|
|
93
|
+
...(result.element?.captured && { captured: result.element.captured }),
|
|
93
94
|
},
|
|
94
95
|
};
|
|
95
96
|
}
|
|
@@ -227,11 +228,34 @@ function assertScreenshotOptions(outputPath, options) {
|
|
|
227
228
|
throw new CommandError(message, {}, EXIT_CODES.INVALID_ARGUMENTS);
|
|
228
229
|
}
|
|
229
230
|
/**
|
|
230
|
-
*
|
|
231
|
+
* Fold the optional positional target (`bdg dom screenshot out.png "#sel"`,
|
|
232
|
+
* or an index from a query) into `--selector` / `--index`.
|
|
233
|
+
*
|
|
234
|
+
* @param target - Positional selector or index, if given
|
|
235
|
+
* @param options - Command options
|
|
236
|
+
* @returns Options with the target as `selector` or `index`
|
|
237
|
+
* @throws CommandError (81) when the option names a different element
|
|
238
|
+
*/
|
|
239
|
+
export function withPositionalTarget(target, options) {
|
|
240
|
+
if (target === undefined)
|
|
241
|
+
return options;
|
|
242
|
+
const isIndex = /^\d+$/.test(target);
|
|
243
|
+
const key = isIndex ? 'index' : 'selector';
|
|
244
|
+
const value = isIndex ? Number(target) : target;
|
|
245
|
+
const given = options[key];
|
|
246
|
+
if (given !== undefined && given !== value) {
|
|
247
|
+
const err = conflictingTargetError(`--${key} ${String(given)}`, target);
|
|
248
|
+
throw new CommandError(err.message, { suggestion: err.suggestion }, EXIT_CODES.INVALID_ARGUMENTS);
|
|
249
|
+
}
|
|
250
|
+
return { ...options, [key]: value };
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Handle `bdg dom screenshot <path> [selector|index]`.
|
|
231
254
|
*
|
|
232
255
|
* Dispatches to page, element, or sequence capture based on flags.
|
|
233
256
|
*/
|
|
234
|
-
export async function handleDomScreenshot(outputPath,
|
|
257
|
+
export async function handleDomScreenshot(outputPath, target, commandOptions) {
|
|
258
|
+
const options = withPositionalTarget(target, commandOptions);
|
|
235
259
|
assertScreenshotOptions(outputPath, options);
|
|
236
260
|
if (options.follow) {
|
|
237
261
|
await handleSequenceCapture(outputPath, options);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* their surrounding DOM context and to fall back gracefully when only one
|
|
6
6
|
* of the two data sources is available.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import type { DomContext } from './helpers/index.js';
|
|
9
9
|
import type { A11yNode } from '../../types.js';
|
|
10
10
|
/**
|
|
11
11
|
* Accessibility node paired with its surrounding DOM context for display.
|
|
@@ -17,8 +17,14 @@ export interface SemanticNodeWithContext {
|
|
|
17
17
|
/**
|
|
18
18
|
* Format a semantic node together with DOM context for human-readable output.
|
|
19
19
|
*
|
|
20
|
+
* The role line names the element's key attributes (an image's file name, a
|
|
21
|
+
* link's href, a field's type and name), like `dom query` does, and is
|
|
22
|
+
* followed by up to 500 characters of the element's text
|
|
23
|
+
* (all of it with `dom get --full`) when it is longer than the one-line
|
|
24
|
+
* preview, or, for an element without text or name, what it holds.
|
|
25
|
+
*
|
|
20
26
|
* @param data - Accessibility node and optional DOM context
|
|
21
|
-
* @returns
|
|
27
|
+
* @returns Role line, plus a text line for elements with longer text
|
|
22
28
|
*/
|
|
23
29
|
export declare function formatSemanticNodeWithContext(data: SemanticNodeWithContext): string;
|
|
24
30
|
/**
|
|
@@ -31,14 +37,14 @@ export declare function formatSemanticNodeWithContext(data: SemanticNodeWithCont
|
|
|
31
37
|
*/
|
|
32
38
|
export declare function resolveNodeWithFallback(a11yNode: A11yNode | null, domContext: DomContext | null, nodeId: number | undefined): A11yNode | null;
|
|
33
39
|
/**
|
|
34
|
-
*
|
|
40
|
+
* The accessibility node with its value masked when the element holds a
|
|
41
|
+
* secret (`domContext.sensitive`): Chrome reports a password field's value
|
|
42
|
+
* as one bullet per character, and a field switched to text by a "show
|
|
43
|
+
* password" button in clear.
|
|
35
44
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
45
|
+
* @param node - Accessibility node
|
|
46
|
+
* @param domContext - DOM context of the same element
|
|
47
|
+
* @returns The node, with {@link MASKED_VALUE} as its value for a secret
|
|
39
48
|
*/
|
|
40
|
-
export declare function
|
|
41
|
-
nodeId: number | undefined;
|
|
42
|
-
domContext: DomContext | null;
|
|
43
|
-
}>;
|
|
49
|
+
export declare function withSecretMasked(node: A11yNode, domContext: DomContext | null): A11yNode;
|
|
44
50
|
//# sourceMappingURL=semanticUtils.d.ts.map
|
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
* their surrounding DOM context and to fall back gracefully when only one
|
|
6
6
|
* of the two data sources is available.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { MASKED_VALUE } from '../../runtime/dom/elementInfo.js';
|
|
9
9
|
import { synthesizeA11yNode } from '../../telemetry/roleInference.js';
|
|
10
|
+
import { keyAttributeItems } from '../../ui/formatters/keyAttributes.js';
|
|
11
|
+
import { joinLines } from '../../ui/formatting.js';
|
|
12
|
+
import { elementTextLine, emptyElementLine } from '../../ui/messages/commands.js';
|
|
10
13
|
function capitalize(str) {
|
|
11
14
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
12
15
|
}
|
|
@@ -29,11 +32,32 @@ function buildContextText(node, domContext) {
|
|
|
29
32
|
const classPart = domContext.classes && domContext.classes.length > 0
|
|
30
33
|
? `.${domContext.classes.slice(0, 3).join('.')}`
|
|
31
34
|
: '';
|
|
32
|
-
const previewPart = domContext.preview ? ` "${domContext.preview}"` : '';
|
|
35
|
+
const previewPart = domContext.preview && !domContext.text ? ` "${domContext.preview}"` : '';
|
|
33
36
|
return ` ${tagPart}${classPart}>${previewPart}`;
|
|
34
37
|
}
|
|
35
38
|
return '';
|
|
36
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Key attributes of the element (src, href, a field's type and name, ...),
|
|
42
|
+
* leaving out what the role line already shows: values equal to the
|
|
43
|
+
* accessible name (an image's alt, a field's placeholder) and the value
|
|
44
|
+
* when the accessibility node has one.
|
|
45
|
+
*
|
|
46
|
+
* @param node - Accessibility node
|
|
47
|
+
* @param domContext - DOM context with the key attributes
|
|
48
|
+
* @returns ` src="…/logo.png"`-style text, or empty
|
|
49
|
+
*/
|
|
50
|
+
function buildKeyAttributesText(node, domContext) {
|
|
51
|
+
if (!domContext?.attributes)
|
|
52
|
+
return '';
|
|
53
|
+
const shown = Object.entries(domContext.attributes)
|
|
54
|
+
.filter(([, value]) => Boolean(node.name) && value === node.name)
|
|
55
|
+
.map(([name]) => name);
|
|
56
|
+
if (node.value !== undefined && node.value !== '')
|
|
57
|
+
shown.push('value');
|
|
58
|
+
const items = keyAttributeItems(domContext.tag, domContext.attributes, new Set(shown));
|
|
59
|
+
return items.length > 0 ? ` ${items.join(' ')}` : '';
|
|
60
|
+
}
|
|
37
61
|
function buildPropertiesText(node) {
|
|
38
62
|
const props = [];
|
|
39
63
|
if (node.value !== undefined && node.value !== '')
|
|
@@ -58,16 +82,29 @@ function buildPropertiesText(node) {
|
|
|
58
82
|
/**
|
|
59
83
|
* Format a semantic node together with DOM context for human-readable output.
|
|
60
84
|
*
|
|
85
|
+
* The role line names the element's key attributes (an image's file name, a
|
|
86
|
+
* link's href, a field's type and name), like `dom query` does, and is
|
|
87
|
+
* followed by up to 500 characters of the element's text
|
|
88
|
+
* (all of it with `dom get --full`) when it is longer than the one-line
|
|
89
|
+
* preview, or, for an element without text or name, what it holds.
|
|
90
|
+
*
|
|
61
91
|
* @param data - Accessibility node and optional DOM context
|
|
62
|
-
* @returns
|
|
92
|
+
* @returns Role line, plus a text line for elements with longer text
|
|
63
93
|
*/
|
|
64
94
|
export function formatSemanticNodeWithContext(data) {
|
|
65
95
|
const { node, domContext } = data;
|
|
66
96
|
const roleText = buildRoleText(node);
|
|
67
97
|
const contextText = buildContextText(node, domContext);
|
|
98
|
+
const keysText = buildKeyAttributesText(node, domContext);
|
|
68
99
|
const propsText = buildPropertiesText(node);
|
|
69
100
|
const inferredText = node.inferred ? ' (inferred from DOM)' : '';
|
|
70
|
-
|
|
101
|
+
const line = `${roleText}${contextText}${keysText}${propsText}${inferredText}`;
|
|
102
|
+
if (domContext?.text)
|
|
103
|
+
return joinLines(line, elementTextLine(domContext.text));
|
|
104
|
+
if (domContext?.childCount !== undefined && !node.name) {
|
|
105
|
+
return joinLines(line, emptyElementLine(domContext.children ?? [], domContext.childCount));
|
|
106
|
+
}
|
|
107
|
+
return line;
|
|
71
108
|
}
|
|
72
109
|
/**
|
|
73
110
|
* Resolve an a11y node, falling back to a DOM-synthesized one when only
|
|
@@ -79,24 +116,24 @@ export function formatSemanticNodeWithContext(data) {
|
|
|
79
116
|
*/
|
|
80
117
|
export function resolveNodeWithFallback(a11yNode, domContext, nodeId) {
|
|
81
118
|
if (a11yNode)
|
|
82
|
-
return a11yNode;
|
|
119
|
+
return withSecretMasked(a11yNode, domContext);
|
|
83
120
|
if (domContext && nodeId)
|
|
84
121
|
return synthesizeA11yNode(domContext, nodeId);
|
|
85
122
|
return null;
|
|
86
123
|
}
|
|
87
124
|
/**
|
|
88
|
-
*
|
|
125
|
+
* The accessibility node with its value masked when the element holds a
|
|
126
|
+
* secret (`domContext.sensitive`): Chrome reports a password field's value
|
|
127
|
+
* as one bullet per character, and a field switched to text by a "show
|
|
128
|
+
* password" button in clear.
|
|
89
129
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
130
|
+
* @param node - Accessibility node
|
|
131
|
+
* @param domContext - DOM context of the same element
|
|
132
|
+
* @returns The node, with {@link MASKED_VALUE} as its value for a secret
|
|
93
133
|
*/
|
|
94
|
-
export
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
const domContext = await getDomContext({ backendNodeId });
|
|
100
|
-
return { nodeId: backendNodeId, domContext };
|
|
134
|
+
export function withSecretMasked(node, domContext) {
|
|
135
|
+
if (!domContext?.sensitive || !node.value)
|
|
136
|
+
return node;
|
|
137
|
+
return { ...node, value: MASKED_VALUE };
|
|
101
138
|
}
|
|
102
139
|
//# sourceMappingURL=semanticUtils.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `bdg dom wait [selector]` - wait until elements appear, become visible,
|
|
3
|
+
* contain a text or are gone, and/or the page has loaded, instead of
|
|
4
|
+
* polling with `sleep` and `dom eval`.
|
|
5
|
+
*/
|
|
6
|
+
import type { Command } from 'commander';
|
|
7
|
+
/**
|
|
8
|
+
* Register `bdg dom wait`.
|
|
9
|
+
*
|
|
10
|
+
* @param dom - The `dom` command group
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerWaitCommand(dom: Command): void;
|
|
13
|
+
//# sourceMappingURL=wait.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `bdg dom wait [selector]` - wait until elements appear, become visible,
|
|
3
|
+
* contain a text or are gone, and/or the page has loaded, instead of
|
|
4
|
+
* polling with `sleep` and `dom eval`.
|
|
5
|
+
*/
|
|
6
|
+
import { runCommand } from '../shared/CommandRunner.js';
|
|
7
|
+
import { jsonOption } from '../shared/commonOptions.js';
|
|
8
|
+
import { integerOption } from '../shared/validation.js';
|
|
9
|
+
import { waitTargetRequiredError } from '../../errors/messages.js';
|
|
10
|
+
import { domWait } from '../../ipc/client.js';
|
|
11
|
+
import { WAIT_HELP_EXAMPLES, waitMetMessage } from '../../ui/messages/commands.js';
|
|
12
|
+
import { EXIT_CODES } from '../../utils/exitCodes.js';
|
|
13
|
+
import { filterDefined } from '../../utils/objects.js';
|
|
14
|
+
/** Default --timeout */
|
|
15
|
+
const DEFAULT_WAIT_TIMEOUT_MS = 10_000;
|
|
16
|
+
/** Longest --timeout (10 minutes) */
|
|
17
|
+
const MAX_WAIT_TIMEOUT_MS = 600_000;
|
|
18
|
+
/**
|
|
19
|
+
* Register `bdg dom wait`.
|
|
20
|
+
*
|
|
21
|
+
* @param dom - The `dom` command group
|
|
22
|
+
*/
|
|
23
|
+
export function registerWaitCommand(dom) {
|
|
24
|
+
dom
|
|
25
|
+
.command('wait')
|
|
26
|
+
.description('Wait until elements appear, become visible, contain a text or are gone (or the page loads)')
|
|
27
|
+
.argument('[selector]', 'CSS selector (:has-text, :visible allowed; shadow DOM and same-origin iframes searched); optional with --load')
|
|
28
|
+
.option('--text <text>', 'A match must contain this text (case-insensitive)')
|
|
29
|
+
.option('--visible', 'Only count visible matches')
|
|
30
|
+
.option('--gone', 'Wait until no element matches (none visible, with --visible)')
|
|
31
|
+
.option('--load', 'Also wait for the page to finish loading (document.readyState complete)')
|
|
32
|
+
.option('--timeout <ms>', 'Give up after this many milliseconds (exit 102)', integerOption(1, MAX_WAIT_TIMEOUT_MS), DEFAULT_WAIT_TIMEOUT_MS)
|
|
33
|
+
.addOption(jsonOption())
|
|
34
|
+
.addHelpText('after', WAIT_HELP_EXAMPLES)
|
|
35
|
+
.action(async (selector, options) => {
|
|
36
|
+
await runCommand(() => waitFor(selector, options), options, formatWait);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Validate the options and ask the daemon to wait.
|
|
41
|
+
*
|
|
42
|
+
* @param selector - Selector, if given
|
|
43
|
+
* @param options - Command options
|
|
44
|
+
* @returns Command result
|
|
45
|
+
*/
|
|
46
|
+
async function waitFor(selector, options) {
|
|
47
|
+
const needsSelector = options.text !== undefined || options.gone === true || !options.load;
|
|
48
|
+
if (selector === undefined && needsSelector) {
|
|
49
|
+
const err = waitTargetRequiredError();
|
|
50
|
+
return {
|
|
51
|
+
success: false,
|
|
52
|
+
error: err.message,
|
|
53
|
+
exitCode: EXIT_CODES.INVALID_ARGUMENTS,
|
|
54
|
+
errorContext: { suggestion: err.suggestion },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const response = await domWait({
|
|
58
|
+
...filterDefined({ selector, text: options.text }),
|
|
59
|
+
...(options.gone && { gone: true }),
|
|
60
|
+
...(options.visible && { visible: true }),
|
|
61
|
+
...(options.load && { load: true }),
|
|
62
|
+
timeout: options.timeout,
|
|
63
|
+
});
|
|
64
|
+
if (response.status === 'error' || !response.data) {
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
error: response.error ?? 'Failed to wait',
|
|
68
|
+
exitCode: response.exitCode ?? EXIT_CODES.CDP_CONNECTION_FAILURE,
|
|
69
|
+
...(response.suggestion && { errorContext: { suggestion: response.suggestion } }),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return { success: true, data: response.data };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* One line for human output.
|
|
76
|
+
*
|
|
77
|
+
* @param data - What the page showed when the condition was met
|
|
78
|
+
* @returns e.g. `✓ #finish visible after 5.1s`
|
|
79
|
+
*/
|
|
80
|
+
function formatWait(data) {
|
|
81
|
+
return waitMetMessage(data, data.elapsedMs);
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=wait.js.map
|
|
@@ -97,8 +97,8 @@ function convertCommand(command) {
|
|
|
97
97
|
function generateRuntimeState() {
|
|
98
98
|
const sessionActive = readLiveDaemonPid() !== null;
|
|
99
99
|
const availableCommands = sessionActive
|
|
100
|
-
? ['peek', 'tail', 'details', 'dom', 'network', 'console', 'cdp', 'status', 'stop']
|
|
101
|
-
: ['bdg <url>', 'cleanup', '--help', '--version'];
|
|
100
|
+
? ['peek', 'tail', 'details', 'dom', 'network', 'console', 'cdp', 'status', 'sessions', 'stop']
|
|
101
|
+
: ['bdg <url>', 'sessions', 'cleanup', '--help', '--version'];
|
|
102
102
|
return {
|
|
103
103
|
sessionActive,
|
|
104
104
|
daemonRunning: sessionActive,
|