browser-debugger-cli 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/.claude/skills/bdg/SKILL.md +100 -186
  2. package/README.md +4 -4
  3. package/dist/commands/console.js +5 -1
  4. package/dist/commands/dom/a11y.d.ts +1 -1
  5. package/dist/commands/dom/a11y.js +20 -20
  6. package/dist/commands/dom/eval.d.ts +2 -1
  7. package/dist/commands/dom/eval.js +21 -3
  8. package/dist/commands/dom/formInteraction.js +1 -1
  9. package/dist/commands/dom/get.js +25 -7
  10. package/dist/commands/dom/index.js +7 -2
  11. package/dist/commands/dom/query.d.ts +2 -1
  12. package/dist/commands/dom/query.js +5 -3
  13. package/dist/commands/dom/screenshot.js +1 -0
  14. package/dist/commands/helpJson.js +1 -1
  15. package/dist/commands/network/list.js +46 -3
  16. package/dist/commands/optionBehaviors.d.ts +25 -2
  17. package/dist/commands/optionBehaviors.js +55 -42
  18. package/dist/commands/peek.js +3 -0
  19. package/dist/commands/shared/CommandRunner.js +13 -13
  20. package/dist/commands/shared/daemonErrorHandler.js +2 -2
  21. package/dist/commands/shared/dataFetcher.d.ts +4 -2
  22. package/dist/commands/shared/dataFetcher.js +11 -3
  23. package/dist/commands/shared/handleValidationError.js +3 -3
  24. package/dist/commands/shared/optionTypes.d.ts +14 -3
  25. package/dist/commands/shared/startHelpers.js +3 -3
  26. package/dist/connection/chromeIdentity.d.ts +8 -2
  27. package/dist/connection/chromeIdentity.js +85 -13
  28. package/dist/constants.d.ts +29 -1
  29. package/dist/constants.js +35 -1
  30. package/dist/daemon/SessionController.js +2 -0
  31. package/dist/daemon/session/Session.d.ts +2 -1
  32. package/dist/daemon/session/Session.js +10 -2
  33. package/dist/daemon/session/TelemetryStore.d.ts +7 -0
  34. package/dist/daemon/session/TelemetryStore.js +6 -0
  35. package/dist/daemon/session/commandRegistry.js +23 -5
  36. package/dist/daemon/session/matchedStylesReset.d.ts +26 -0
  37. package/dist/daemon/session/matchedStylesReset.js +46 -0
  38. package/dist/daemon/session/plugins.js +1 -0
  39. package/dist/daemon/session/triggeredRequests.d.ts +0 -5
  40. package/dist/daemon/session/triggeredRequests.js +13 -7
  41. package/dist/daemon.js +742 -460
  42. package/dist/errors/messages.d.ts +8 -0
  43. package/dist/errors/messages.js +10 -0
  44. package/dist/index.js +710 -518
  45. package/dist/ipc/protocol/commands.d.ts +4 -0
  46. package/dist/ipc/protocol/inspectTypes.d.ts +5 -2
  47. package/dist/ipc/session/types.d.ts +5 -1
  48. package/dist/program.d.ts +14 -0
  49. package/dist/program.js +53 -0
  50. package/dist/runtime/dom/elementGeometry.d.ts +23 -0
  51. package/dist/runtime/dom/elementGeometry.js +17 -15
  52. package/dist/runtime/dom/elementInfo.d.ts +6 -4
  53. package/dist/runtime/dom/elementInfo.js +7 -4
  54. package/dist/runtime/dom/frameScopedConnection.d.ts +7 -0
  55. package/dist/runtime/dom/frameScopedConnection.js +2 -2
  56. package/dist/runtime/dom/inspect.d.ts +17 -3
  57. package/dist/runtime/dom/inspect.js +40 -26
  58. package/dist/runtime/dom/inspectModel.d.ts +3 -3
  59. package/dist/runtime/dom/inspectRules.d.ts +29 -3
  60. package/dist/runtime/dom/inspectRules.js +205 -11
  61. package/dist/runtime/dom/layout.d.ts +0 -2
  62. package/dist/runtime/dom/layout.js +1 -2
  63. package/dist/runtime/dom/reactEventHelpers.d.ts +4 -1
  64. package/dist/runtime/dom/reactEventHelpers.js +9 -2
  65. package/dist/runtime/dom/targetNode.d.ts +10 -6
  66. package/dist/runtime/dom/targetNode.js +15 -8
  67. package/dist/telemetry/a11y.d.ts +15 -1
  68. package/dist/telemetry/a11y.js +83 -0
  69. package/dist/telemetry/har/builder.js +1 -1
  70. package/dist/telemetry/network.d.ts +13 -16
  71. package/dist/telemetry/network.js +30 -52
  72. package/dist/telemetry/networkRetention.d.ts +83 -0
  73. package/dist/telemetry/networkRetention.js +117 -0
  74. package/dist/types.d.ts +26 -0
  75. package/dist/ui/OutputBuilder.d.ts +10 -0
  76. package/dist/ui/OutputBuilder.js +12 -0
  77. package/dist/ui/formatters/a11y.d.ts +5 -7
  78. package/dist/ui/formatters/a11y.js +7 -61
  79. package/dist/ui/formatters/console/chronological.js +4 -4
  80. package/dist/ui/formatters/console/follow.d.ts +4 -2
  81. package/dist/ui/formatters/console/follow.js +6 -3
  82. package/dist/ui/formatters/console/json.d.ts +3 -6
  83. package/dist/ui/formatters/console/json.js +9 -13
  84. package/dist/ui/formatters/console/shared.d.ts +17 -2
  85. package/dist/ui/formatters/console/shared.js +17 -0
  86. package/dist/ui/formatters/console/summarize.d.ts +2 -2
  87. package/dist/ui/formatters/console/summarize.js +22 -7
  88. package/dist/ui/formatters/console.d.ts +1 -1
  89. package/dist/ui/formatters/console.js +1 -5
  90. package/dist/ui/formatters/details.js +1 -1
  91. package/dist/ui/formatters/dom.d.ts +13 -4
  92. package/dist/ui/formatters/dom.js +25 -7
  93. package/dist/ui/formatters/layout.js +2 -1
  94. package/dist/ui/formatters/longValues.d.ts +14 -0
  95. package/dist/ui/formatters/longValues.js +23 -0
  96. package/dist/ui/formatters/networkList.d.ts +8 -2
  97. package/dist/ui/formatters/networkList.js +11 -2
  98. package/dist/ui/formatters/preview.d.ts +4 -1
  99. package/dist/ui/formatters/preview.js +55 -13
  100. package/dist/ui/formatters/status.js +7 -0
  101. package/dist/ui/formatters/triggeredRequests.js +2 -1
  102. package/dist/ui/messages/chrome.d.ts +20 -1
  103. package/dist/ui/messages/chrome.js +29 -3
  104. package/dist/ui/messages/commands.d.ts +29 -8
  105. package/dist/ui/messages/commands.js +36 -8
  106. package/dist/ui/messages/networkMessages.d.ts +24 -0
  107. package/dist/ui/messages/networkMessages.js +45 -0
  108. package/dist/utils/http.d.ts +9 -2
  109. package/dist/utils/http.js +4 -3
  110. package/dist/utils/strings.d.ts +19 -0
  111. package/dist/utils/strings.js +16 -0
  112. package/package.json +2 -2
@@ -0,0 +1,46 @@
1
+ /**
2
+ * `dom inspect` keeps slow matched-rules answers for a few seconds, but page
3
+ * state such as `:checked`, `:hover` or `:focus` changes without any CDP
4
+ * event. Every daemon command that may change the page drops them, before
5
+ * and after it runs. Hooking the commands rather than the CDP methods they
6
+ * send keeps `dom inspect`'s own page scripts from clearing its answers, and
7
+ * listing the read-only commands makes a new command reset by default.
8
+ */
9
+ import { resetMatchedStyles } from '../../runtime/dom/inspectRules.js';
10
+ /**
11
+ * Commands that leave the page as it is: they read it, or only the telemetry.
12
+ * Any command not listed (new ones included) resets by default.
13
+ */
14
+ export const KEEPS_MATCHED_STYLES = new Set([
15
+ 'session_peek',
16
+ 'session_details',
17
+ 'session_status',
18
+ 'session_har_data',
19
+ 'session_network_headers',
20
+ 'dom_frames',
21
+ 'dom_form_discover',
22
+ 'dom_listeners',
23
+ 'dom_layout',
24
+ 'dom_audit',
25
+ 'css_search',
26
+ 'dom_inspect',
27
+ ]);
28
+ /**
29
+ * Run a command, dropping the kept matched rules before and after it unless
30
+ * it leaves the page as it is.
31
+ *
32
+ * @param cdp - CDP connection
33
+ * @param name - Command name
34
+ * @param run - The command
35
+ * @returns Its result
36
+ */
37
+ export function withMatchedStylesReset(cdp, name, run) {
38
+ if (KEEPS_MATCHED_STYLES.has(name))
39
+ return run();
40
+ const reset = () => resetMatchedStyles(cdp);
41
+ reset();
42
+ const result = run();
43
+ void result.then(reset, reset);
44
+ return result;
45
+ }
46
+ //# sourceMappingURL=matchedStylesReset.js.map
@@ -137,6 +137,7 @@ export function createDefaultTelemetryPlugins() {
137
137
  fetchAllBodies: config.includeAll ?? false,
138
138
  getCurrentNavigationId: store.getCurrentNavigationId ?? undefined,
139
139
  pendingRequests: store.pendingNetworkRequests,
140
+ evictions: store.networkEvictions,
140
141
  ...filterDefined({
141
142
  maxBodySize: config.maxBodySize,
142
143
  }),
@@ -5,11 +5,6 @@
5
5
  import type { TelemetryStore } from './TelemetryStore.js';
6
6
  import type { TriggeredRequest } from '../../ipc/protocol/domTypes.js';
7
7
  import type { NetworkRequest } from '../../types.js';
8
- /**
9
- * Requests listed in a result (a click that loads a page triggers its whole
10
- * load); notable ones ({@link isNotableRequest}) are kept before assets
11
- */
12
- export declare const MAX_TRIGGERED_REQUESTS = 50;
13
8
  /** Requests started since the watch began: the first ones, and how many more there were */
14
9
  export interface CollectedRequests {
15
10
  triggeredRequests: TriggeredRequest[];
@@ -2,15 +2,11 @@
2
2
  * Network requests an interaction triggered, read from the session's network
3
3
  * telemetry (no CDP listeners of its own).
4
4
  */
5
+ import { MAX_TRIGGERED_REQUESTS } from '../../constants.js';
5
6
  import { isNotableRequest } from '../../telemetry/requestKinds.js';
6
7
  import { failureReason, getRequestState } from '../../telemetry/requestState.js';
7
8
  /** URLs that never reach the network (inline data, in-page objects) */
8
9
  const LOCAL_URL_PATTERN = /^(data|blob):/i;
9
- /**
10
- * Requests listed in a result (a click that loads a page triggers its whole
11
- * load); notable ones ({@link isNotableRequest}) are kept before assets
12
- */
13
- export const MAX_TRIGGERED_REQUESTS = 50;
14
10
  /**
15
11
  * Start attributing requests to an interaction.
16
12
  *
@@ -28,11 +24,12 @@ export function watchTriggeredRequests(store) {
28
24
  if (!store.activeTelemetry.includes('network'))
29
25
  return () => undefined;
30
26
  const startedAt = Date.now();
31
- const firstFinished = store.networkRequests.length;
27
+ const firstFinished = requestsFinished(store);
32
28
  const firstWebSocket = store.websocketConnections.length;
33
29
  return () => {
30
+ const firstKept = Math.max(0, firstFinished - store.networkEvictions.requestsDropped);
34
31
  const started = [
35
- ...store.networkRequests.slice(firstFinished).map((request) => ({ request })),
32
+ ...store.networkRequests.slice(firstKept).map((request) => ({ request })),
36
33
  ...[...store.pendingNetworkRequests.values()].map((pending) => ({
37
34
  request: pending.request,
38
35
  inFlight: true,
@@ -52,6 +49,15 @@ export function watchTriggeredRequests(store) {
52
49
  };
53
50
  };
54
51
  }
52
+ /**
53
+ * Requests the session has finished, dropped ones included.
54
+ *
55
+ * @param store - Session store
56
+ * @returns Count that only grows
57
+ */
58
+ function requestsFinished(store) {
59
+ return store.networkEvictions.requestsDropped + store.networkRequests.length;
60
+ }
55
61
  /**
56
62
  * At most `limit` requests, notable ones first (pages, API calls, sockets,
57
63
  * failures), then assets, still in start order.