browser-debugger-cli 0.13.0 → 0.15.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 (159) hide show
  1. package/.claude/skills/bdg/SKILL.md +101 -187
  2. package/README.md +4 -4
  3. package/dist/commands/cdp.js +1 -0
  4. package/dist/commands/cleanup.js +3 -0
  5. package/dist/commands/console.js +5 -1
  6. package/dist/commands/dom/a11y.d.ts +1 -1
  7. package/dist/commands/dom/a11y.js +20 -20
  8. package/dist/commands/dom/eval.d.ts +3 -1
  9. package/dist/commands/dom/eval.js +8 -5
  10. package/dist/commands/dom/formInteraction.js +1 -1
  11. package/dist/commands/dom/get.js +25 -7
  12. package/dist/commands/dom/helpers/evalResult.d.ts +36 -0
  13. package/dist/commands/dom/helpers/evalResult.js +59 -0
  14. package/dist/commands/dom/index.js +7 -2
  15. package/dist/commands/dom/query.d.ts +2 -1
  16. package/dist/commands/dom/query.js +5 -3
  17. package/dist/commands/dom/screenshot.js +1 -0
  18. package/dist/commands/helpJson.d.ts +1 -1
  19. package/dist/commands/helpJson.js +4 -4
  20. package/dist/commands/helpTopic.js +10 -4
  21. package/dist/commands/network/har.js +18 -14
  22. package/dist/commands/network/list.js +46 -3
  23. package/dist/commands/optionBehaviors.d.ts +25 -2
  24. package/dist/commands/optionBehaviors.js +60 -42
  25. package/dist/commands/peek.js +3 -0
  26. package/dist/commands/shared/CommandRunner.js +13 -13
  27. package/dist/commands/shared/daemonErrorHandler.js +2 -2
  28. package/dist/commands/shared/dataFetcher.d.ts +4 -2
  29. package/dist/commands/shared/dataFetcher.js +11 -3
  30. package/dist/commands/shared/handleValidationError.js +3 -3
  31. package/dist/commands/shared/optionTypes.d.ts +15 -3
  32. package/dist/commands/shared/outputFile.d.ts +2 -1
  33. package/dist/commands/shared/outputFile.js +7 -4
  34. package/dist/commands/shared/startHelpers.js +3 -3
  35. package/dist/commands/status.js +3 -1
  36. package/dist/commands/stop.js +2 -1
  37. package/dist/connection/chromeIdentity.d.ts +8 -2
  38. package/dist/connection/chromeIdentity.js +85 -13
  39. package/dist/connection/launcher/flagsBuilder.d.ts +46 -0
  40. package/dist/connection/launcher/flagsBuilder.js +107 -23
  41. package/dist/connection/launcher.d.ts +1 -1
  42. package/dist/connection/launcher.js +1 -2
  43. package/dist/constants.d.ts +31 -5
  44. package/dist/constants.js +37 -5
  45. package/dist/daemon/SessionController.js +2 -0
  46. package/dist/daemon/launcher.d.ts +17 -3
  47. package/dist/daemon/launcher.js +37 -7
  48. package/dist/daemon/session/Session.d.ts +2 -1
  49. package/dist/daemon/session/Session.js +10 -2
  50. package/dist/daemon/session/TelemetryStore.d.ts +7 -0
  51. package/dist/daemon/session/TelemetryStore.js +6 -0
  52. package/dist/daemon/session/commandRegistry.js +25 -7
  53. package/dist/daemon/session/matchedStylesReset.d.ts +26 -0
  54. package/dist/daemon/session/matchedStylesReset.js +46 -0
  55. package/dist/daemon/session/plugins.js +1 -0
  56. package/dist/daemon/session/triggeredRequests.d.ts +0 -5
  57. package/dist/daemon/session/triggeredRequests.js +13 -7
  58. package/dist/daemon.js +8742 -8315
  59. package/dist/errors/messages.d.ts +31 -0
  60. package/dist/errors/messages.js +96 -6
  61. package/dist/index.js +1129 -548
  62. package/dist/ipc/client.d.ts +6 -1
  63. package/dist/ipc/client.js +11 -2
  64. package/dist/ipc/protocol/commands.d.ts +8 -0
  65. package/dist/ipc/protocol/inspectTypes.d.ts +5 -2
  66. package/dist/ipc/session/types.d.ts +5 -1
  67. package/dist/ipc/transport/index.d.ts +6 -0
  68. package/dist/ipc/transport/index.js +16 -1
  69. package/dist/program.d.ts +14 -0
  70. package/dist/program.js +53 -0
  71. package/dist/runtime/dom/elementGeometry.d.ts +23 -0
  72. package/dist/runtime/dom/elementGeometry.js +17 -15
  73. package/dist/runtime/dom/elementInfo.d.ts +13 -4
  74. package/dist/runtime/dom/elementInfo.js +15 -5
  75. package/dist/runtime/dom/evalHelpers.d.ts +24 -4
  76. package/dist/runtime/dom/evalHelpers.js +40 -12
  77. package/dist/runtime/dom/frameScopedConnection.d.ts +7 -0
  78. package/dist/runtime/dom/frameScopedConnection.js +2 -2
  79. package/dist/runtime/dom/frames.d.ts +2 -1
  80. package/dist/runtime/dom/frames.js +3 -1
  81. package/dist/runtime/dom/inspect.d.ts +17 -3
  82. package/dist/runtime/dom/inspect.js +40 -26
  83. package/dist/runtime/dom/inspectModel.d.ts +3 -3
  84. package/dist/runtime/dom/inspectRules.d.ts +29 -3
  85. package/dist/runtime/dom/inspectRules.js +205 -11
  86. package/dist/runtime/dom/layout.d.ts +0 -2
  87. package/dist/runtime/dom/layout.js +1 -2
  88. package/dist/runtime/dom/reactEventHelpers.d.ts +4 -1
  89. package/dist/runtime/dom/reactEventHelpers.js +9 -2
  90. package/dist/runtime/dom/targetNode.d.ts +10 -6
  91. package/dist/runtime/dom/targetNode.js +15 -8
  92. package/dist/runtime/page/emulation.js +6 -5
  93. package/dist/runtime/page/userAgent.d.ts +86 -2
  94. package/dist/runtime/page/userAgent.js +154 -33
  95. package/dist/session/paths.d.ts +38 -3
  96. package/dist/session/paths.js +154 -7
  97. package/dist/session/portClaims.d.ts +0 -8
  98. package/dist/session/portClaims.js +1 -22
  99. package/dist/session/sessionList.d.ts +5 -1
  100. package/dist/session/sessionList.js +5 -1
  101. package/dist/telemetry/a11y.d.ts +15 -1
  102. package/dist/telemetry/a11y.js +83 -0
  103. package/dist/telemetry/har/builder.d.ts +12 -1
  104. package/dist/telemetry/har/builder.js +11 -3
  105. package/dist/telemetry/har/sanitize.d.ts +24 -0
  106. package/dist/telemetry/har/sanitize.js +138 -0
  107. package/dist/telemetry/har/sanitizeBody.d.ts +38 -0
  108. package/dist/telemetry/har/sanitizeBody.js +168 -0
  109. package/dist/telemetry/network.d.ts +13 -16
  110. package/dist/telemetry/network.js +30 -52
  111. package/dist/telemetry/networkRetention.d.ts +83 -0
  112. package/dist/telemetry/networkRetention.js +117 -0
  113. package/dist/types.d.ts +26 -0
  114. package/dist/ui/OutputBuilder.d.ts +10 -0
  115. package/dist/ui/OutputBuilder.js +12 -0
  116. package/dist/ui/formatters/a11y.d.ts +5 -7
  117. package/dist/ui/formatters/a11y.js +7 -61
  118. package/dist/ui/formatters/console/chronological.js +4 -4
  119. package/dist/ui/formatters/console/follow.d.ts +4 -2
  120. package/dist/ui/formatters/console/follow.js +6 -3
  121. package/dist/ui/formatters/console/json.d.ts +3 -6
  122. package/dist/ui/formatters/console/json.js +9 -13
  123. package/dist/ui/formatters/console/shared.d.ts +17 -2
  124. package/dist/ui/formatters/console/shared.js +17 -0
  125. package/dist/ui/formatters/console/summarize.d.ts +2 -2
  126. package/dist/ui/formatters/console/summarize.js +22 -7
  127. package/dist/ui/formatters/console.d.ts +1 -1
  128. package/dist/ui/formatters/console.js +1 -5
  129. package/dist/ui/formatters/details.js +1 -1
  130. package/dist/ui/formatters/dom.d.ts +13 -4
  131. package/dist/ui/formatters/dom.js +25 -7
  132. package/dist/ui/formatters/layout.js +2 -1
  133. package/dist/ui/formatters/longValues.d.ts +14 -0
  134. package/dist/ui/formatters/longValues.js +23 -0
  135. package/dist/ui/formatters/networkList.d.ts +8 -2
  136. package/dist/ui/formatters/networkList.js +11 -2
  137. package/dist/ui/formatters/preview.d.ts +4 -1
  138. package/dist/ui/formatters/preview.js +55 -13
  139. package/dist/ui/formatters/sessions.d.ts +3 -2
  140. package/dist/ui/formatters/sessions.js +10 -3
  141. package/dist/ui/formatters/status.js +7 -0
  142. package/dist/ui/formatters/triggeredRequests.js +2 -1
  143. package/dist/ui/messages/chrome.d.ts +34 -7
  144. package/dist/ui/messages/chrome.js +81 -15
  145. package/dist/ui/messages/commands.d.ts +29 -8
  146. package/dist/ui/messages/commands.js +36 -8
  147. package/dist/ui/messages/networkMessages.d.ts +50 -0
  148. package/dist/ui/messages/networkMessages.js +66 -0
  149. package/dist/ui/messages/session.d.ts +8 -0
  150. package/dist/ui/messages/session.js +10 -0
  151. package/dist/utils/atomicFile.d.ts +2 -1
  152. package/dist/utils/atomicFile.js +5 -2
  153. package/dist/utils/directories.d.ts +41 -0
  154. package/dist/utils/directories.js +48 -0
  155. package/dist/utils/http.d.ts +9 -2
  156. package/dist/utils/http.js +4 -3
  157. package/dist/utils/strings.d.ts +19 -0
  158. package/dist/utils/strings.js +16 -0
  159. package/package.json +2 -2
@@ -11,8 +11,10 @@ import { connectCDP, navigateToTarget } from './cdpSetup.js';
11
11
  import { externalChromePort, findPageTarget, setupChromeConnection, } from './chromeConnection.js';
12
12
  import { startTelemetryCollectors } from './collectors.js';
13
13
  import { createCommandRegistry } from './commandRegistry.js';
14
+ import { withMatchedStylesReset } from './matchedStylesReset.js';
14
15
  import { teardownSession } from './teardown.js';
15
16
  import { CommandError } from '../../errors/index.js';
17
+ import { unknownSessionCommandMessage } from '../../errors/messages.js';
16
18
  import { applySessionEmulation } from '../../runtime/page/emulation.js';
17
19
  import { readPageLoadingState } from '../../runtime/page/loadingState.js';
18
20
  import { reapOrphanedChrome, removeSessionFiles } from '../../session/cleanup/staleSession.js';
@@ -151,7 +153,8 @@ export class Session {
151
153
  * Execute a registered command against this session. After a renderer
152
154
  * crash only {@link RUN_ON_CRASHED_PAGE} commands run (`bdg cdp` only for
153
155
  * {@link CRASH_SAFE_CDP} methods); others fail with exit 107 instead of
154
- * waiting for a page that cannot answer.
156
+ * waiting for a page that cannot answer. Commands that may change the page
157
+ * drop `dom inspect`'s kept matched rules ({@link withMatchedStylesReset}).
155
158
  *
156
159
  * @param name - Command name
157
160
  * @param params - Command parameters
@@ -168,7 +171,12 @@ export class Session {
168
171
  if (crashedAt !== undefined && needsPage) {
169
172
  return Promise.reject(pageCrashedCommandError(crashedAt));
170
173
  }
171
- return this.registry[name](this.cdp, params);
174
+ if (!Object.hasOwn(this.registry, name)) {
175
+ return Promise.reject(new CommandError(unknownSessionCommandMessage(name), {}, EXIT_CODES.INVALID_ARGUMENTS));
176
+ }
177
+ const handler = this.registry[name];
178
+ const cdp = this.cdp;
179
+ return withMatchedStylesReset(cdp, name, () => handler(cdp, params));
172
180
  }
173
181
  /**
174
182
  * Summary of this session for start responses.
@@ -1,9 +1,16 @@
1
1
  import type { DialogInfo } from '../../ipc/protocol/domTypes.js';
2
2
  import type { NavigationEvent } from '../../telemetry/navigation.js';
3
3
  import type { PendingRequest } from '../../telemetry/network.js';
4
+ import type { NetworkEvictions } from '../../telemetry/networkRetention.js';
4
5
  import type { CDPTarget, ConsoleMessage, NetworkRequest, TelemetryType, WebSocketConnection } from '../../types.js';
5
6
  export declare class TelemetryStore {
7
+ /**
8
+ * Finished requests, oldest first: the newest are kept, so the session's
9
+ * `networkEvictions.requestsDropped` oldest ones are gone
10
+ */
6
11
  readonly networkRequests: NetworkRequest[];
12
+ /** Requests dropped and response bodies evicted at the capture limits */
13
+ readonly networkEvictions: NetworkEvictions;
7
14
  /** Requests still in flight, keyed by CDP requestId */
8
15
  readonly pendingNetworkRequests: Map<string, PendingRequest>;
9
16
  readonly consoleMessages: ConsoleMessage[];
@@ -1,7 +1,13 @@
1
1
  import { MAX_CONSOLE_MESSAGES } from '../../constants.js';
2
2
  import { dialogConsoleText } from '../../ui/messages/commands.js';
3
3
  export class TelemetryStore {
4
+ /**
5
+ * Finished requests, oldest first: the newest are kept, so the session's
6
+ * `networkEvictions.requestsDropped` oldest ones are gone
7
+ */
4
8
  networkRequests = [];
9
+ /** Requests dropped and response bodies evicted at the capture limits */
10
+ networkEvictions = { requestsDropped: 0, bodiesEvicted: 0 };
5
11
  /** Requests still in flight, keyed by CDP requestId */
6
12
  pendingNetworkRequests = new Map();
7
13
  consoleMessages = [];
@@ -21,7 +21,7 @@ import { evaluateInBdgWorld, sendForBdgScript } from '../../runtime/page/bdgWorl
21
21
  import { emulatePage, pageAppearance } from '../../runtime/page/emulation.js';
22
22
  import { readDocumentReadyState } from '../../runtime/page/loadingState.js';
23
23
  import { navigatePage } from '../../runtime/page/navigation.js';
24
- import { skippedBodyReason } from '../../telemetry/network.js';
24
+ import { skippedBodyReason } from '../../telemetry/networkRetention.js';
25
25
  import { consoleMessageDroppedError } from '../../ui/messages/consoleMessages.js';
26
26
  import { sessionCommand } from '../../ui/messages/sessionCommand.js';
27
27
  import { EXIT_CODES } from '../../utils/exitCodes.js';
@@ -140,6 +140,20 @@ function webSocketAsRequest(connection) {
140
140
  webSocket: { frames: connection.frames, ...(closedTime !== undefined && { closedTime }) },
141
141
  };
142
142
  }
143
+ /**
144
+ * Status activity counts of what the network capture let go at its limits,
145
+ * left out when nothing was.
146
+ *
147
+ * @param store - Telemetry store
148
+ * @returns `networkRequestsDropped` and `networkBodiesEvicted` when non-zero
149
+ */
150
+ function networkEvictionActivity(store) {
151
+ const { requestsDropped, bodiesEvicted } = store.networkEvictions;
152
+ return {
153
+ ...(requestsDropped > 0 && { networkRequestsDropped: requestsDropped }),
154
+ ...(bodiesEvicted > 0 && { networkBodiesEvicted: bodiesEvicted }),
155
+ };
156
+ }
143
157
  /**
144
158
  * All captured network activity: finished and in-flight requests and
145
159
  * WebSocket connections, in start order.
@@ -319,6 +333,7 @@ export function createCommandRegistry(store, emulation) {
319
333
  const totalNetwork = allNetwork.length;
320
334
  const totalConsole = store.consoleMessages.length;
321
335
  const dropped = store.consoleDropped;
336
+ const { requestsDropped, bodiesEvicted } = store.networkEvictions;
322
337
  const networkBounds = calculateSliceBounds(totalNetwork, lastN, offset);
323
338
  const consoleBounds = calculateSliceBounds(totalConsole, lastN, offset);
324
339
  const recentNetwork = params.only === 'console'
@@ -347,6 +362,8 @@ export function createCommandRegistry(store, emulation) {
347
362
  totalNetwork,
348
363
  totalConsole,
349
364
  ...(dropped > 0 && { droppedConsole: dropped }),
365
+ ...(requestsDropped > 0 && { droppedNetwork: requestsDropped }),
366
+ ...(bodiesEvicted > 0 && { evictedNetworkBodies: bodiesEvicted }),
350
367
  hasMoreNetwork: networkBounds.start > 0,
351
368
  hasMoreConsole: consoleBounds.start > 0,
352
369
  });
@@ -377,12 +394,13 @@ export function createCommandRegistry(store, emulation) {
377
394
  : { crashedAt: store.pageCrashedAt }),
378
395
  },
379
396
  activeTelemetry: store.activeTelemetry,
380
- activity: filterDefined({
397
+ activity: {
381
398
  networkRequestsCaptured: store.networkRequests.length,
382
399
  consoleMessagesCaptured: store.consoleMessages.length,
383
- lastNetworkRequestAt: lastNetworkRequest?.timestamp,
384
- lastConsoleMessageAt: lastConsoleMessage?.timestamp,
385
- }),
400
+ ...(lastNetworkRequest && { lastNetworkRequestAt: lastNetworkRequest.timestamp }),
401
+ ...(lastConsoleMessage && { lastConsoleMessageAt: lastConsoleMessage.timestamp }),
402
+ ...networkEvictionActivity(store),
403
+ },
386
404
  navigationId: store.getCurrentNavigationId?.() ?? 0,
387
405
  };
388
406
  return result;
@@ -434,8 +452,8 @@ export function createCommandRegistry(store, emulation) {
434
452
  return { result, ...(hint !== undefined && { hint }) };
435
453
  },
436
454
  dom_eval: async (cdp, params) => params.frame === undefined
437
- ? evaluateScript(cdp, params.script)
438
- : evaluateInFrame(cdp, pageWebSocketUrl(store), params.script, params.frame, listedFrameIds),
455
+ ? evaluateScript(cdp, params.script, { full: params.full ?? false })
456
+ : evaluateInFrame(cdp, pageWebSocketUrl(store), params.script, params.frame, listedFrameIds, params.full ?? false),
439
457
  dom_frames: async (cdp) => {
440
458
  const { frames, frameIds } = await listFrames(cdp, pageWebSocketUrl(store));
441
459
  listedFrameIds = frameIds;
@@ -0,0 +1,26 @@
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 type { CDPConnection } from '../../connection/cdp.js';
10
+ import type { CommandName } from '../../ipc/index.js';
11
+ /**
12
+ * Commands that leave the page as it is: they read it, or only the telemetry.
13
+ * Any command not listed (new ones included) resets by default.
14
+ */
15
+ export declare const KEEPS_MATCHED_STYLES: ReadonlySet<CommandName>;
16
+ /**
17
+ * Run a command, dropping the kept matched rules before and after it unless
18
+ * it leaves the page as it is.
19
+ *
20
+ * @param cdp - CDP connection
21
+ * @param name - Command name
22
+ * @param run - The command
23
+ * @returns Its result
24
+ */
25
+ export declare function withMatchedStylesReset<T>(cdp: CDPConnection, name: CommandName, run: () => Promise<T>): Promise<T>;
26
+ //# sourceMappingURL=matchedStylesReset.d.ts.map
@@ -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.