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.
Files changed (304) hide show
  1. package/README.md +7 -1
  2. package/dist/cdp/schema.d.ts +4 -1
  3. package/dist/cdp/schema.js +48 -7
  4. package/dist/commands/cdp.js +3 -2
  5. package/dist/commands/cleanup.d.ts +11 -0
  6. package/dist/commands/cleanup.js +161 -57
  7. package/dist/commands/console.d.ts +20 -1
  8. package/dist/commands/console.js +57 -17
  9. package/dist/commands/details.js +3 -2
  10. package/dist/commands/dom/DomElementResolver.d.ts +10 -3
  11. package/dist/commands/dom/DomElementResolver.js +35 -17
  12. package/dist/commands/dom/a11y.d.ts +10 -0
  13. package/dist/commands/dom/a11y.js +29 -6
  14. package/dist/commands/dom/eval.d.ts +3 -1
  15. package/dist/commands/dom/eval.js +29 -4
  16. package/dist/commands/dom/form.js +16 -62
  17. package/dist/commands/dom/formInteraction.js +189 -119
  18. package/dist/commands/dom/formSummary.d.ts +49 -0
  19. package/dist/commands/dom/formSummary.js +180 -0
  20. package/dist/commands/dom/frames.d.ts +2 -1
  21. package/dist/commands/dom/frames.js +17 -2
  22. package/dist/commands/dom/get.d.ts +6 -5
  23. package/dist/commands/dom/get.js +92 -82
  24. package/dist/commands/dom/helpers/index.d.ts +1 -1
  25. package/dist/commands/dom/helpers/index.js +1 -1
  26. package/dist/commands/dom/helpers/keyAttributes.d.ts +20 -0
  27. package/dist/commands/dom/helpers/keyAttributes.js +54 -0
  28. package/dist/commands/dom/helpers/query.d.ts +44 -17
  29. package/dist/commands/dom/helpers/query.js +300 -106
  30. package/dist/commands/dom/helpers/runElementCommand.d.ts +10 -2
  31. package/dist/commands/dom/helpers/runElementCommand.js +98 -30
  32. package/dist/commands/dom/helpers/screenshot.d.ts +4 -1
  33. package/dist/commands/dom/helpers/screenshot.js +239 -51
  34. package/dist/commands/dom/index.d.ts +4 -1
  35. package/dist/commands/dom/index.js +22 -7
  36. package/dist/commands/dom/inspect.d.ts +15 -0
  37. package/dist/commands/dom/inspect.js +82 -0
  38. package/dist/commands/dom/layout.d.ts +14 -0
  39. package/dist/commands/dom/layout.js +54 -0
  40. package/dist/commands/dom/listeners.d.ts +5 -1
  41. package/dist/commands/dom/listeners.js +15 -5
  42. package/dist/commands/dom/query.js +2 -3
  43. package/dist/commands/dom/screenshot.d.ts +12 -2
  44. package/dist/commands/dom/screenshot.js +27 -3
  45. package/dist/commands/dom/semanticUtils.d.ts +16 -10
  46. package/dist/commands/dom/semanticUtils.js +53 -16
  47. package/dist/commands/dom/wait.d.ts +13 -0
  48. package/dist/commands/dom/wait.js +83 -0
  49. package/dist/commands/helpJson.js +2 -2
  50. package/dist/commands/network/list.js +17 -13
  51. package/dist/commands/optionBehaviors.js +154 -21
  52. package/dist/commands/page.d.ts +3 -2
  53. package/dist/commands/page.js +100 -5
  54. package/dist/commands/peek.js +4 -11
  55. package/dist/commands/sessions.d.ts +8 -0
  56. package/dist/commands/sessions.js +19 -0
  57. package/dist/commands/shared/CommandRunner.js +4 -4
  58. package/dist/commands/shared/commonOptions.d.ts +4 -0
  59. package/dist/commands/shared/commonOptions.js +9 -0
  60. package/dist/commands/shared/dataFetcher.js +2 -2
  61. package/dist/commands/shared/followMode.d.ts +21 -1
  62. package/dist/commands/shared/followMode.js +29 -2
  63. package/dist/commands/shared/handleValidationError.d.ts +2 -2
  64. package/dist/commands/shared/handleValidationError.js +12 -3
  65. package/dist/commands/shared/optionTypes.d.ts +61 -5
  66. package/dist/commands/shared/startHelpers.d.ts +66 -0
  67. package/dist/commands/shared/startHelpers.js +103 -13
  68. package/dist/commands/shared/validation.d.ts +14 -2
  69. package/dist/commands/shared/validation.js +20 -3
  70. package/dist/commands/start.d.ts +63 -0
  71. package/dist/commands/start.js +115 -15
  72. package/dist/commands/status.js +29 -7
  73. package/dist/commands/stop.js +7 -6
  74. package/dist/commands/tail.js +4 -11
  75. package/dist/commands/types.d.ts +2 -0
  76. package/dist/commands.js +2 -0
  77. package/dist/connection/chromeIdentity.d.ts +65 -0
  78. package/dist/connection/chromeIdentity.js +143 -0
  79. package/dist/connection/launcher/profilePreferences.d.ts +47 -0
  80. package/dist/connection/launcher/profilePreferences.js +151 -0
  81. package/dist/connection/launcher.d.ts +21 -2
  82. package/dist/connection/launcher.js +42 -16
  83. package/dist/connection/portReservation.d.ts +14 -4
  84. package/dist/connection/portReservation.js +21 -6
  85. package/dist/connection/startupExit.d.ts +8 -0
  86. package/dist/connection/startupExit.js +15 -6
  87. package/dist/constants.d.ts +6 -2
  88. package/dist/constants.js +9 -2
  89. package/dist/daemon/SessionController.js +23 -7
  90. package/dist/daemon/errors.d.ts +1 -1
  91. package/dist/daemon/errors.js +1 -1
  92. package/dist/daemon/launcher.d.ts +10 -2
  93. package/dist/daemon/launcher.js +8 -7
  94. package/dist/daemon/server/SocketServer.js +1 -2
  95. package/dist/daemon/session/Session.d.ts +20 -0
  96. package/dist/daemon/session/Session.js +80 -9
  97. package/dist/daemon/session/chromeConnection.d.ts +9 -0
  98. package/dist/daemon/session/chromeConnection.js +45 -8
  99. package/dist/daemon/session/commandRegistry.d.ts +14 -1
  100. package/dist/daemon/session/commandRegistry.js +113 -67
  101. package/dist/daemon/session/interactions.d.ts +48 -9
  102. package/dist/daemon/session/interactions.js +46 -9
  103. package/dist/daemon/session/triggeredRequests.d.ts +67 -0
  104. package/dist/daemon/session/triggeredRequests.js +157 -0
  105. package/dist/daemon/session/types.d.ts +5 -1
  106. package/dist/daemon.js +10630 -3601
  107. package/dist/errors/messages.d.ts +456 -24
  108. package/dist/errors/messages.js +862 -67
  109. package/dist/index.js +6915 -3401
  110. package/dist/ipc/client.d.ts +21 -1
  111. package/dist/ipc/client.js +35 -3
  112. package/dist/ipc/protocol/commands.d.ts +145 -5
  113. package/dist/ipc/protocol/commands.js +4 -0
  114. package/dist/ipc/protocol/domTypes.d.ts +291 -7
  115. package/dist/ipc/protocol/inspectTypes.d.ts +388 -0
  116. package/dist/ipc/protocol/inspectTypes.js +10 -0
  117. package/dist/ipc/session/lifecycle.d.ts +8 -1
  118. package/dist/ipc/session/queries.d.ts +5 -1
  119. package/dist/ipc/session/types.d.ts +5 -0
  120. package/dist/ipc/transport/index.d.ts +2 -1
  121. package/dist/ipc/transport/index.js +2 -2
  122. package/dist/runtime/dom/actionEffects.d.ts +185 -0
  123. package/dist/runtime/dom/actionEffects.js +402 -0
  124. package/dist/runtime/dom/actionEffectsScripts.d.ts +90 -0
  125. package/dist/runtime/dom/actionEffectsScripts.js +426 -0
  126. package/dist/runtime/dom/elementGeometry.d.ts +170 -0
  127. package/dist/runtime/dom/elementGeometry.js +553 -0
  128. package/dist/runtime/dom/elementInfo.d.ts +103 -0
  129. package/dist/runtime/dom/elementInfo.js +256 -0
  130. package/dist/runtime/dom/evalHelpers.d.ts +51 -6
  131. package/dist/runtime/dom/evalHelpers.js +136 -26
  132. package/dist/runtime/dom/eventListeners.d.ts +2 -1
  133. package/dist/runtime/dom/eventListeners.js +184 -47
  134. package/dist/runtime/dom/formDiscovery.d.ts +1 -1
  135. package/dist/runtime/dom/formDiscovery.js +116 -16
  136. package/dist/runtime/dom/formFillHelpers/fill.d.ts +9 -0
  137. package/dist/runtime/dom/formFillHelpers/fill.js +178 -14
  138. package/dist/runtime/dom/formFillHelpers/index.d.ts +2 -2
  139. package/dist/runtime/dom/formFillHelpers/index.js +2 -2
  140. package/dist/runtime/dom/formFillHelpers/pressKey.js +14 -3
  141. package/dist/runtime/dom/formFillHelpers/scroll.d.ts +3 -0
  142. package/dist/runtime/dom/formFillHelpers/scroll.js +60 -18
  143. package/dist/runtime/dom/formFillHelpers/shared.d.ts +17 -0
  144. package/dist/runtime/dom/formFillHelpers/shared.js +25 -1
  145. package/dist/runtime/dom/formFillHelpers/stability.d.ts +20 -6
  146. package/dist/runtime/dom/formFillHelpers/stability.js +50 -19
  147. package/dist/runtime/dom/formSubmitHelpers.d.ts +3 -0
  148. package/dist/runtime/dom/formSubmitHelpers.js +89 -15
  149. package/dist/runtime/dom/frameLayout.d.ts +60 -0
  150. package/dist/runtime/dom/frameLayout.js +140 -0
  151. package/dist/runtime/dom/frameOrigin.d.ts +50 -0
  152. package/dist/runtime/dom/frameOrigin.js +62 -0
  153. package/dist/runtime/dom/frameScopedConnection.d.ts +92 -0
  154. package/dist/runtime/dom/frameScopedConnection.js +252 -0
  155. package/dist/runtime/dom/frameSelection.d.ts +12 -1
  156. package/dist/runtime/dom/frameSelection.js +22 -3
  157. package/dist/runtime/dom/frames.d.ts +61 -5
  158. package/dist/runtime/dom/frames.js +329 -75
  159. package/dist/runtime/dom/inspect.d.ts +28 -0
  160. package/dist/runtime/dom/inspect.js +557 -0
  161. package/dist/runtime/dom/inspectAllStyles.d.ts +62 -0
  162. package/dist/runtime/dom/inspectAllStyles.js +385 -0
  163. package/dist/runtime/dom/inspectCascade.d.ts +94 -0
  164. package/dist/runtime/dom/inspectCascade.js +371 -0
  165. package/dist/runtime/dom/inspectCascadeModel.d.ts +39 -0
  166. package/dist/runtime/dom/inspectCascadeModel.js +232 -0
  167. package/dist/runtime/dom/inspectHints.d.ts +62 -0
  168. package/dist/runtime/dom/inspectHints.js +305 -0
  169. package/dist/runtime/dom/inspectLayoutModel.d.ts +87 -0
  170. package/dist/runtime/dom/inspectLayoutModel.js +346 -0
  171. package/dist/runtime/dom/inspectModel.d.ts +74 -0
  172. package/dist/runtime/dom/inspectModel.js +184 -0
  173. package/dist/runtime/dom/inspectPaintModel.d.ts +157 -0
  174. package/dist/runtime/dom/inspectPaintModel.js +461 -0
  175. package/dist/runtime/dom/inspectRules.d.ts +37 -0
  176. package/dist/runtime/dom/inspectRules.js +101 -0
  177. package/dist/runtime/dom/inspectScripts.d.ts +132 -0
  178. package/dist/runtime/dom/inspectScripts.js +263 -0
  179. package/dist/runtime/dom/inspectTree.d.ts +40 -0
  180. package/dist/runtime/dom/inspectTree.js +134 -0
  181. package/dist/runtime/dom/inspectVariables.d.ts +33 -0
  182. package/dist/runtime/dom/inspectVariables.js +94 -0
  183. package/dist/runtime/dom/inspectWhyModel.d.ts +20 -0
  184. package/dist/runtime/dom/inspectWhyModel.js +134 -0
  185. package/dist/runtime/dom/layout.d.ts +71 -0
  186. package/dist/runtime/dom/layout.js +340 -0
  187. package/dist/runtime/dom/listenerPageScripts.d.ts +72 -0
  188. package/dist/runtime/dom/listenerPageScripts.js +365 -0
  189. package/dist/runtime/dom/listenerSummary.d.ts +136 -11
  190. package/dist/runtime/dom/listenerSummary.js +361 -22
  191. package/dist/runtime/dom/pageActivity.d.ts +41 -0
  192. package/dist/runtime/dom/pageActivity.js +123 -0
  193. package/dist/runtime/dom/reactEventHelpers.d.ts +63 -2
  194. package/dist/runtime/dom/reactEventHelpers.js +220 -41
  195. package/dist/runtime/dom/targetNode.d.ts +80 -27
  196. package/dist/runtime/dom/targetNode.js +249 -33
  197. package/dist/runtime/dom/wait.d.ts +25 -0
  198. package/dist/runtime/dom/wait.js +199 -0
  199. package/dist/runtime/dom/waitCondition.d.ts +71 -0
  200. package/dist/runtime/dom/waitCondition.js +75 -0
  201. package/dist/runtime/page/emulation.d.ts +71 -0
  202. package/dist/runtime/page/emulation.js +117 -0
  203. package/dist/runtime/page/loadingState.d.ts +36 -0
  204. package/dist/runtime/page/loadingState.js +86 -0
  205. package/dist/runtime/page/navigation.d.ts +46 -2
  206. package/dist/runtime/page/navigation.js +69 -33
  207. package/dist/session/QueryCacheManager.d.ts +11 -1
  208. package/dist/session/QueryCacheManager.js +25 -3
  209. package/dist/session/chromeOwners.d.ts +34 -0
  210. package/dist/session/chromeOwners.js +51 -0
  211. package/dist/session/cleanup/staleSession.d.ts +11 -1
  212. package/dist/session/cleanup/staleSession.js +17 -6
  213. package/dist/session/cleanup/userCommands.js +2 -4
  214. package/dist/session/metadata.d.ts +5 -1
  215. package/dist/session/metadata.js +2 -1
  216. package/dist/session/paths.d.ts +77 -3
  217. package/dist/session/paths.js +111 -5
  218. package/dist/session/port.d.ts +31 -7
  219. package/dist/session/port.js +50 -43
  220. package/dist/session/portClaims.d.ts +66 -0
  221. package/dist/session/portClaims.js +284 -0
  222. package/dist/session/sessionList.d.ts +58 -0
  223. package/dist/session/sessionList.js +199 -0
  224. package/dist/session/sessionName.d.ts +46 -0
  225. package/dist/session/sessionName.js +97 -0
  226. package/dist/telemetry/a11y.d.ts +18 -3
  227. package/dist/telemetry/a11y.js +170 -29
  228. package/dist/telemetry/console.d.ts +1 -0
  229. package/dist/telemetry/console.js +100 -5
  230. package/dist/telemetry/network.js +3 -1
  231. package/dist/telemetry/requestKinds.d.ts +32 -0
  232. package/dist/telemetry/requestKinds.js +61 -0
  233. package/dist/telemetry/requestState.d.ts +31 -0
  234. package/dist/telemetry/requestState.js +38 -0
  235. package/dist/types.d.ts +112 -3
  236. package/dist/ui/formatters/a11y.js +3 -0
  237. package/dist/ui/formatters/console/chronological.d.ts +8 -0
  238. package/dist/ui/formatters/console/chronological.js +17 -4
  239. package/dist/ui/formatters/console/json.js +3 -4
  240. package/dist/ui/formatters/console/shared.d.ts +12 -0
  241. package/dist/ui/formatters/console.d.ts +2 -2
  242. package/dist/ui/formatters/console.js +1 -1
  243. package/dist/ui/formatters/details.d.ts +8 -0
  244. package/dist/ui/formatters/details.js +61 -4
  245. package/dist/ui/formatters/dom.d.ts +27 -14
  246. package/dist/ui/formatters/dom.js +88 -59
  247. package/dist/ui/formatters/form.js +29 -18
  248. package/dist/ui/formatters/inspect.d.ts +39 -0
  249. package/dist/ui/formatters/inspect.js +596 -0
  250. package/dist/ui/formatters/keyAttributes.d.ts +19 -0
  251. package/dist/ui/formatters/keyAttributes.js +84 -0
  252. package/dist/ui/formatters/layout.d.ts +31 -0
  253. package/dist/ui/formatters/layout.js +53 -0
  254. package/dist/ui/formatters/listeners.d.ts +3 -2
  255. package/dist/ui/formatters/listeners.js +73 -9
  256. package/dist/ui/formatters/networkHeaders.d.ts +13 -0
  257. package/dist/ui/formatters/networkHeaders.js +36 -3
  258. package/dist/ui/formatters/networkList.d.ts +29 -1
  259. package/dist/ui/formatters/networkList.js +86 -20
  260. package/dist/ui/formatters/preview.js +2 -1
  261. package/dist/ui/formatters/requestStatus.d.ts +1 -17
  262. package/dist/ui/formatters/requestStatus.js +2 -30
  263. package/dist/ui/formatters/sessions.d.ts +12 -0
  264. package/dist/ui/formatters/sessions.js +40 -0
  265. package/dist/ui/formatters/status.d.ts +21 -2
  266. package/dist/ui/formatters/status.js +47 -10
  267. package/dist/ui/formatters/triggeredRequests.d.ts +36 -0
  268. package/dist/ui/formatters/triggeredRequests.js +65 -0
  269. package/dist/ui/formatting.d.ts +19 -0
  270. package/dist/ui/formatting.js +31 -36
  271. package/dist/ui/messages/chrome.d.ts +9 -0
  272. package/dist/ui/messages/chrome.js +17 -5
  273. package/dist/ui/messages/commands.d.ts +504 -14
  274. package/dist/ui/messages/commands.js +835 -21
  275. package/dist/ui/messages/consoleMessages.d.ts +10 -0
  276. package/dist/ui/messages/consoleMessages.js +17 -0
  277. package/dist/ui/messages/hints.js +2 -1
  278. package/dist/ui/messages/networkMessages.d.ts +14 -0
  279. package/dist/ui/messages/networkMessages.js +18 -0
  280. package/dist/ui/messages/preview.js +5 -4
  281. package/dist/ui/messages/session.d.ts +30 -21
  282. package/dist/ui/messages/session.js +48 -26
  283. package/dist/ui/messages/sessionCommand.d.ts +43 -0
  284. package/dist/ui/messages/sessionCommand.js +52 -0
  285. package/dist/utils/async.d.ts +17 -0
  286. package/dist/utils/async.js +36 -0
  287. package/dist/utils/color.d.ts +84 -0
  288. package/dist/utils/color.js +376 -0
  289. package/dist/utils/cssValues.d.ts +109 -0
  290. package/dist/utils/cssValues.js +236 -0
  291. package/dist/utils/http.d.ts +22 -1
  292. package/dist/utils/http.js +28 -9
  293. package/dist/utils/selectorFilters.d.ts +48 -8
  294. package/dist/utils/selectorFilters.js +296 -53
  295. package/dist/utils/shellDetection.d.ts +8 -2
  296. package/dist/utils/shellDetection.js +120 -33
  297. package/dist/utils/suggestions.d.ts +26 -0
  298. package/dist/utils/suggestions.js +73 -0
  299. package/dist/utils/taskMappings.js +10 -0
  300. package/dist/utils/url.d.ts +12 -2
  301. package/dist/utils/url.js +69 -7
  302. package/package.json +1 -1
  303. package/dist/ui/formatters/sessionFormatters.d.ts +0 -58
  304. package/dist/ui/formatters/sessionFormatters.js +0 -121
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * User-facing messages for the console command output and formatting.
5
5
  */
6
+ import type { ConsoleSkipped } from '../formatters/console/shared.js';
6
7
  /**
7
8
  * Generate message for following console output.
8
9
  *
@@ -15,4 +16,13 @@ export declare function followingConsoleMessage(): string;
15
16
  * @returns Status message for stderr
16
17
  */
17
18
  export declare function stoppedFollowingConsoleMessage(): string;
19
+ /**
20
+ * Note under a console list whose indices skip messages: the indices are
21
+ * positions in the session's message list (what `bdg details console <n>`
22
+ * takes), and the messages in between were left out by the filters.
23
+ *
24
+ * @param skipped - Messages left out between the first and last listed index
25
+ * @returns e.g. `[n] are positions in the session's message list; not listed in between: 1 message from another page load (-H lists all)`
26
+ */
27
+ export declare function consoleIndexGapNote(skipped: ConsoleSkipped): string;
18
28
  //# sourceMappingURL=consoleMessages.d.ts.map
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * User-facing messages for the console command output and formatting.
5
5
  */
6
+ import { pluralize } from '../formatting.js';
6
7
  /**
7
8
  * Generate message for following console output.
8
9
  *
@@ -19,4 +20,20 @@ export function followingConsoleMessage() {
19
20
  export function stoppedFollowingConsoleMessage() {
20
21
  return 'Stopped streaming console messages';
21
22
  }
23
+ /**
24
+ * Note under a console list whose indices skip messages: the indices are
25
+ * positions in the session's message list (what `bdg details console <n>`
26
+ * takes), and the messages in between were left out by the filters.
27
+ *
28
+ * @param skipped - Messages left out between the first and last listed index
29
+ * @returns e.g. `[n] are positions in the session's message list; not listed in between: 1 message from another page load (-H lists all)`
30
+ */
31
+ export function consoleIndexGapNote(skipped) {
32
+ const reasons = [
33
+ skipped.otherLevels > 0 && `${pluralize(skipped.otherLevels, 'message')} of another level`,
34
+ skipped.otherPages > 0 &&
35
+ `${pluralize(skipped.otherPages, 'message')} from another page load (-H lists all)`,
36
+ ].filter(Boolean);
37
+ return `[n] are positions in the session's message list; not listed in between: ${reasons.join(', ')}`;
38
+ }
22
39
  //# sourceMappingURL=consoleMessages.js.map
@@ -6,6 +6,7 @@
6
6
  * session stays free of UI imports.
7
7
  */
8
8
  import { joinLines } from '../formatting.js';
9
+ import { sessionCommand } from './sessionCommand.js';
9
10
  /**
10
11
  * Format a structured hint into a user-facing string.
11
12
  *
@@ -19,7 +20,7 @@ export function formatHint(hint) {
19
20
  case 'PATTERN_HINT': {
20
21
  const alternative = ctx['alternative'];
21
22
  const cdpMethods = ctx['cdpMethods'] ?? [];
22
- return joinLines('', `Hint: Consider using '${alternative}' instead of ${cdpMethods.join(' or ')}`, '');
23
+ return joinLines('', `Hint: Consider using '${sessionCommand(alternative)}' instead of ${cdpMethods.join(' or ')}`, '');
23
24
  }
24
25
  }
25
26
  }
@@ -15,4 +15,18 @@ export declare function followingNetworkMessage(): string;
15
15
  * @returns Status message for stderr
16
16
  */
17
17
  export declare function stoppedFollowingNetworkMessage(): string;
18
+ /**
19
+ * Note after a header value the server sent more than once.
20
+ *
21
+ * @param count - Times it was sent
22
+ * @returns e.g. `(sent 2 times)`
23
+ */
24
+ export declare function headerRepeatedNote(count: number): string;
25
+ /**
26
+ * Note after a loopback remote address of a request to another host and
27
+ * port: Chrome probably connected to a proxy on this machine, not the server.
28
+ *
29
+ * @returns Note text
30
+ */
31
+ export declare function localProxyNote(): string;
18
32
  //# sourceMappingURL=networkMessages.d.ts.map
@@ -19,4 +19,22 @@ export function followingNetworkMessage() {
19
19
  export function stoppedFollowingNetworkMessage() {
20
20
  return '\nStopped following network requests.';
21
21
  }
22
+ /**
23
+ * Note after a header value the server sent more than once.
24
+ *
25
+ * @param count - Times it was sent
26
+ * @returns e.g. `(sent 2 times)`
27
+ */
28
+ export function headerRepeatedNote(count) {
29
+ return `(sent ${count} times)`;
30
+ }
31
+ /**
32
+ * Note after a loopback remote address of a request to another host and
33
+ * port: Chrome probably connected to a proxy on this machine, not the server.
34
+ *
35
+ * @returns Note text
36
+ */
37
+ export function localProxyNote() {
38
+ return '(loopback; likely a local proxy)';
39
+ }
22
40
  //# sourceMappingURL=networkMessages.js.map
@@ -4,6 +4,7 @@
4
4
  * User-facing messages for the peek command, including empty states,
5
5
  * tips, and interactive command suggestions.
6
6
  * */
7
+ import { sessionCommand } from './sessionCommand.js';
7
8
  export const PREVIEW_EMPTY_STATES = {
8
9
  NO_DATA: '(none)',
9
10
  NO_NETWORK_REQUESTS: 'No network requests yet',
@@ -18,7 +19,7 @@ export const PREVIEW_HEADERS = {
18
19
  * @returns Single-line tip for basic peek usage
19
20
  */
20
21
  export function compactTipsMessage() {
21
- return 'Tip: bdg peek --last 50 | bdg peek --verbose';
22
+ return `Tip: ${sessionCommand('bdg peek --last 50')} | ${sessionCommand('bdg peek --verbose')}`;
22
23
  }
23
24
  /**
24
25
  * Generate verbose mode commands section.
@@ -28,9 +29,9 @@ export function compactTipsMessage() {
28
29
  export function verboseCommandsMessage() {
29
30
  return [
30
31
  'Commands:',
31
- ' Full preview: bdg peek --last 50',
32
- ' Watch live: bdg tail',
33
- ' End session: bdg stop',
32
+ ` Full preview: ${sessionCommand('bdg peek --last 50')}`,
33
+ ` Watch live: ${sessionCommand('bdg tail')}`,
34
+ ` End session: ${sessionCommand('bdg stop')}`,
34
35
  ].join('\n');
35
36
  }
36
37
  /**
@@ -4,6 +4,7 @@
4
4
  * Centralized location for all session UI text including landing pages,
5
5
  * status displays, and session management messages.
6
6
  */
7
+ import type { PageLoadingState } from '../../ipc/protocol/commands.js';
7
8
  /**
8
9
  * Options for the landing page display.
9
10
  */
@@ -12,41 +13,37 @@ export interface LandingPageOptions {
12
13
  url: string;
13
14
  /** HTTP status of the main document (a warning is shown for 4xx/5xx) */
14
15
  documentStatus?: number;
16
+ /** The page had not finished loading (a warning names what it waits on) */
17
+ loading?: PageLoadingState;
15
18
  /** When `--timeout` will stop the session */
16
19
  autoStopAt?: Date;
20
+ /** Name of a named session (`--session`) */
21
+ session?: string;
17
22
  }
18
23
  /**
19
24
  * Lines shown under the target in both the full and the quiet start output:
20
- * an HTTP error of the page, and when the session stops by itself.
25
+ * the session name, an HTTP error of the page, a page still loading, and
26
+ * when the session stops by itself.
21
27
  *
22
28
  * @param options - Landing page options
23
29
  * @returns Lines (empty when there is nothing to say)
24
30
  */
25
31
  export declare function startNotices(options: LandingPageOptions): string[];
26
32
  /**
27
- * Generate the landing page display for session start.
28
- *
29
- * Shows a clean, organized overview of available commands grouped by priority.
30
- * High-level commands are presented first to guide agents toward token-efficient
31
- * wrappers before falling back to verbose CDP commands.
32
- *
33
- * Section order optimized for agent discoverability:
34
- * 1. Common tasks with token savings estimates
35
- * 2. Comprehensive domain command coverage (12+ commands)
36
- * 3. Live monitoring capabilities
37
- * 4. Session management
38
- * 5. Advanced CDP access (positioned as fallback)
39
- * 6. Discovery resources for agents
33
+ * Generate the start output: the target, the notices of {@link startNotices},
34
+ * one line of next commands and where to find the rest. Kept to a few lines
35
+ * because agents read it on every start; `bdg --help` lists everything.
40
36
  *
41
37
  * @param options - Landing page options
42
- * @returns Formatted landing page string
38
+ * @returns Formatted start output
43
39
  *
44
40
  * @example
45
41
  * ```typescript
46
- * const message = landingPage({
47
- * url: 'http://localhost:3000'
48
- * });
49
- * console.log(message);
42
+ * landingPage({ url: 'http://localhost:3000' });
43
+ * // Session Started
44
+ * // Target: http://localhost:3000
45
+ * // Next: bdg dom layout <selector>, bdg dom query <selector>, ...
46
+ * // More: bdg --help (bdg --help --json for agents)
50
47
  * ```
51
48
  */
52
49
  export declare function landingPage(options: LandingPageOptions): string;
@@ -61,9 +58,7 @@ export declare function sessionStopped(): string;
61
58
  */
62
59
  export declare const STOP_MESSAGES: {
63
60
  readonly SUCCESS: "Session stopped successfully";
64
- readonly NO_SESSION: "No active session found";
65
61
  readonly FAILED: "Failed to stop session";
66
- readonly DAEMON_NOT_RUNNING: "No active session";
67
62
  };
68
63
  /**
69
64
  * Generate stop session failed error message.
@@ -82,4 +77,18 @@ export declare function lastSessionEndText(end: {
82
77
  reason: string;
83
78
  endedAt: number;
84
79
  }): string;
80
+ /**
81
+ * Note after a failed start whose daemon had not exited when bdg stopped waiting.
82
+ *
83
+ * @param pid - Daemon PID, when known
84
+ * @param waitedMs - How long bdg waited
85
+ * @returns Note
86
+ */
87
+ export declare function daemonStillExitingHint(pid: number | undefined, waitedMs: number): string;
88
+ /**
89
+ * What to do about a daemon still shutting down after a failed start.
90
+ *
91
+ * @returns Suggestion
92
+ */
93
+ export declare function daemonStillExitingSuggestion(): string;
85
94
  //# sourceMappingURL=session.d.ts.map
@@ -4,54 +4,59 @@
4
4
  * Centralized location for all session UI text including landing pages,
5
5
  * status displays, and session management messages.
6
6
  */
7
- import { buildCommonTasksSection, buildDomainCommandsSection, buildLiveMonitoringSection, buildSessionManagementSection, buildCdpSection, buildDiscoverySection, } from '../formatters/sessionFormatters.js';
8
7
  import { joinLines } from '../formatting.js';
8
+ import { pageLoadingWarning } from './commands.js';
9
+ import { sessionCommand } from './sessionCommand.js';
9
10
  /**
10
11
  * Lines shown under the target in both the full and the quiet start output:
11
- * an HTTP error of the page, and when the session stops by itself.
12
+ * the session name, an HTTP error of the page, a page still loading, and
13
+ * when the session stops by itself.
12
14
  *
13
15
  * @param options - Landing page options
14
16
  * @returns Lines (empty when there is nothing to say)
15
17
  */
16
18
  export function startNotices(options) {
17
- const { documentStatus, autoStopAt } = options;
19
+ const { documentStatus, loading, autoStopAt, session } = options;
18
20
  return [
21
+ ...(session
22
+ ? [
23
+ `Session: ${session} (pass --session ${session} or set BDG_SESSION=${session} on every command)`,
24
+ ]
25
+ : []),
19
26
  ...(documentStatus !== undefined && documentStatus >= 400
20
27
  ? [`⚠ The page responded with HTTP ${documentStatus}`]
21
28
  : []),
29
+ ...(loading ? [`⚠ ${pageLoadingWarning(loading)}`] : []),
22
30
  ...(autoStopAt ? [`Auto-stop: at ${autoStopAt.toLocaleTimeString()} (--timeout)`] : []),
23
31
  ];
24
32
  }
33
+ /** Most useful commands after a start, cheapest first (screenshots cost the most tokens) */
34
+ const START_NEXT_COMMANDS = [
35
+ 'bdg dom layout <selector>',
36
+ 'bdg dom query <selector>',
37
+ 'bdg dom form',
38
+ 'bdg peek',
39
+ 'bdg dom screenshot out.png',
40
+ ];
25
41
  /**
26
- * Generate the landing page display for session start.
27
- *
28
- * Shows a clean, organized overview of available commands grouped by priority.
29
- * High-level commands are presented first to guide agents toward token-efficient
30
- * wrappers before falling back to verbose CDP commands.
31
- *
32
- * Section order optimized for agent discoverability:
33
- * 1. Common tasks with token savings estimates
34
- * 2. Comprehensive domain command coverage (12+ commands)
35
- * 3. Live monitoring capabilities
36
- * 4. Session management
37
- * 5. Advanced CDP access (positioned as fallback)
38
- * 6. Discovery resources for agents
42
+ * Generate the start output: the target, the notices of {@link startNotices},
43
+ * one line of next commands and where to find the rest. Kept to a few lines
44
+ * because agents read it on every start; `bdg --help` lists everything.
39
45
  *
40
46
  * @param options - Landing page options
41
- * @returns Formatted landing page string
47
+ * @returns Formatted start output
42
48
  *
43
49
  * @example
44
50
  * ```typescript
45
- * const message = landingPage({
46
- * url: 'http://localhost:3000'
47
- * });
48
- * console.log(message);
51
+ * landingPage({ url: 'http://localhost:3000' });
52
+ * // Session Started
53
+ * // Target: http://localhost:3000
54
+ * // Next: bdg dom layout <selector>, bdg dom query <selector>, ...
55
+ * // More: bdg --help (bdg --help --json for agents)
49
56
  * ```
50
57
  */
51
58
  export function landingPage(options) {
52
- const { url } = options;
53
- const notices = startNotices(options);
54
- return joinLines('', 'Session Started', '', `Target: ${url}`, '', ...(notices.length > 0 ? [...notices, ''] : []), buildCommonTasksSection(), '', buildDomainCommandsSection(), '', buildLiveMonitoringSection(), '', buildSessionManagementSection(), '', buildCdpSection(), '', buildDiscoverySection(), '');
59
+ return joinLines('Session Started', `Target: ${options.url}`, ...startNotices(options), `Next: ${START_NEXT_COMMANDS.join(', ')}`, 'More: bdg --help (bdg --help --json for agents)');
55
60
  }
56
61
  /**
57
62
  * Generate "session stopped" success message.
@@ -66,9 +71,7 @@ export function sessionStopped() {
66
71
  */
67
72
  export const STOP_MESSAGES = {
68
73
  SUCCESS: 'Session stopped successfully',
69
- NO_SESSION: 'No active session found',
70
74
  FAILED: 'Failed to stop session',
71
- DAEMON_NOT_RUNNING: 'No active session',
72
75
  };
73
76
  /**
74
77
  * Generate stop session failed error message.
@@ -94,4 +97,23 @@ export function lastSessionEndText(end) {
94
97
  const at = new Date(end.endedAt).toLocaleTimeString();
95
98
  return `The last session ended at ${at}: ${why[end.reason] ?? end.reason}`;
96
99
  }
100
+ /**
101
+ * Note after a failed start whose daemon had not exited when bdg stopped waiting.
102
+ *
103
+ * @param pid - Daemon PID, when known
104
+ * @param waitedMs - How long bdg waited
105
+ * @returns Note
106
+ */
107
+ export function daemonStillExitingHint(pid, waitedMs) {
108
+ const daemon = pid === undefined ? 'The daemon' : `The daemon (PID ${pid})`;
109
+ return `${daemon} was still shutting down after ${waitedMs / 1000}s`;
110
+ }
111
+ /**
112
+ * What to do about a daemon still shutting down after a failed start.
113
+ *
114
+ * @returns Suggestion
115
+ */
116
+ export function daemonStillExitingSuggestion() {
117
+ return `check with bdg sessions, or end it with ${sessionCommand('bdg cleanup --force')}`;
118
+ }
97
119
  //# sourceMappingURL=session.js.map
@@ -0,0 +1,43 @@
1
+ /**
2
+ * bdg command lines and wording for the selected session.
3
+ *
4
+ * Every hint, suggestion and error that tells the user to run a bdg command
5
+ * goes through {@link sessionCommand}, so a named session's hints carry
6
+ * `--session <name>` and following them never acts on the default session.
7
+ */
8
+ /**
9
+ * A bdg command for the selected session: ` --session <name>` is appended
10
+ * when a named session is selected.
11
+ *
12
+ * @param command - Command line, e.g. `bdg stop`
13
+ * @param session - Session name (defaults to the selected one; null for the default session)
14
+ * @returns The command, scoped to the session
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * sessionCommand('bdg stop'); // 'bdg stop' (default session)
19
+ * sessionCommand('bdg stop', 'agent-1'); // 'bdg stop --session agent-1'
20
+ * ```
21
+ */
22
+ export declare function sessionCommand(command: string, session?: string | null): string;
23
+ /**
24
+ * "No active session", naming a named session.
25
+ *
26
+ * @param session - Session name (defaults to the selected one; null for the default session)
27
+ * @returns `No active session` or `No active session "<name>"`
28
+ */
29
+ export declare function noActiveSessionMessage(session?: string | null): string;
30
+ /**
31
+ * Shell command that deletes a directory by hand (single-quoted).
32
+ *
33
+ * @param dir - Directory
34
+ * @returns Command line
35
+ */
36
+ export declare function removeDirCommand(dir: string): string;
37
+ /**
38
+ * How to start the selected session.
39
+ *
40
+ * @returns Suggestion
41
+ */
42
+ export declare function startSessionSuggestion(): string;
43
+ //# sourceMappingURL=sessionCommand.d.ts.map
@@ -0,0 +1,52 @@
1
+ /**
2
+ * bdg command lines and wording for the selected session.
3
+ *
4
+ * Every hint, suggestion and error that tells the user to run a bdg command
5
+ * goes through {@link sessionCommand}, so a named session's hints carry
6
+ * `--session <name>` and following them never acts on the default session.
7
+ */
8
+ import { getSessionName } from '../../session/paths.js';
9
+ /**
10
+ * A bdg command for the selected session: ` --session <name>` is appended
11
+ * when a named session is selected.
12
+ *
13
+ * @param command - Command line, e.g. `bdg stop`
14
+ * @param session - Session name (defaults to the selected one; null for the default session)
15
+ * @returns The command, scoped to the session
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * sessionCommand('bdg stop'); // 'bdg stop' (default session)
20
+ * sessionCommand('bdg stop', 'agent-1'); // 'bdg stop --session agent-1'
21
+ * ```
22
+ */
23
+ export function sessionCommand(command, session = getSessionName()) {
24
+ return session === null ? command : `${command} --session ${session}`;
25
+ }
26
+ /**
27
+ * "No active session", naming a named session.
28
+ *
29
+ * @param session - Session name (defaults to the selected one; null for the default session)
30
+ * @returns `No active session` or `No active session "<name>"`
31
+ */
32
+ export function noActiveSessionMessage(session = getSessionName()) {
33
+ return session === null ? 'No active session' : `No active session "${session}"`;
34
+ }
35
+ /**
36
+ * Shell command that deletes a directory by hand (single-quoted).
37
+ *
38
+ * @param dir - Directory
39
+ * @returns Command line
40
+ */
41
+ export function removeDirCommand(dir) {
42
+ return `rm -rf '${dir.replaceAll("'", "'\\''")}'`;
43
+ }
44
+ /**
45
+ * How to start the selected session.
46
+ *
47
+ * @returns Suggestion
48
+ */
49
+ export function startSessionSuggestion() {
50
+ return `Start a session with: ${sessionCommand('bdg <url>')}`;
51
+ }
52
+ //# sourceMappingURL=sessionCommand.js.map
@@ -7,4 +7,21 @@
7
7
  * @param ms - Milliseconds to delay
8
8
  */
9
9
  export declare function delay(ms: number): Promise<void>;
10
+ /**
11
+ * Wait for a promise, giving up after a time; the timer is cleared either way.
12
+ *
13
+ * @param promise - Work to wait for
14
+ * @param ms - Milliseconds to wait at most
15
+ * @returns The promise's result, or undefined when the time ran out first
16
+ */
17
+ export declare function raceTimeout<T>(promise: Promise<T>, ms: number): Promise<T | undefined>;
18
+ /**
19
+ * Poll a condition until it holds or a time runs out.
20
+ *
21
+ * @param condition - Checked first right away, then every `pollMs`
22
+ * @param timeoutMs - Milliseconds to wait at most
23
+ * @param pollMs - Milliseconds between checks
24
+ * @returns True when the condition held, false when the time ran out
25
+ */
26
+ export declare function waitUntil(condition: () => boolean, timeoutMs: number, pollMs?: number): Promise<boolean>;
10
27
  //# sourceMappingURL=async.d.ts.map
@@ -9,4 +9,40 @@
9
9
  export function delay(ms) {
10
10
  return new Promise((resolve) => setTimeout(resolve, ms));
11
11
  }
12
+ /**
13
+ * Wait for a promise, giving up after a time; the timer is cleared either way.
14
+ *
15
+ * @param promise - Work to wait for
16
+ * @param ms - Milliseconds to wait at most
17
+ * @returns The promise's result, or undefined when the time ran out first
18
+ */
19
+ export async function raceTimeout(promise, ms) {
20
+ let timer;
21
+ const timeout = new Promise((resolve) => {
22
+ timer = setTimeout(() => resolve(undefined), ms);
23
+ });
24
+ try {
25
+ return await Promise.race([promise, timeout]);
26
+ }
27
+ finally {
28
+ clearTimeout(timer);
29
+ }
30
+ }
31
+ /**
32
+ * Poll a condition until it holds or a time runs out.
33
+ *
34
+ * @param condition - Checked first right away, then every `pollMs`
35
+ * @param timeoutMs - Milliseconds to wait at most
36
+ * @param pollMs - Milliseconds between checks
37
+ * @returns True when the condition held, false when the time ran out
38
+ */
39
+ export async function waitUntil(condition, timeoutMs, pollMs = 25) {
40
+ const deadline = Date.now() + timeoutMs;
41
+ while (!condition()) {
42
+ if (Date.now() >= deadline)
43
+ return false;
44
+ await delay(Math.min(pollMs, Math.max(0, deadline - Date.now())));
45
+ }
46
+ return true;
47
+ }
12
48
  //# sourceMappingURL=async.js.map
@@ -0,0 +1,84 @@
1
+ /**
2
+ * CSS colors as `bdg dom inspect` reports them: parsed from the computed
3
+ * values Chrome returns (`rgb()`/`rgba()`, and `lab()`, `lch()`, `oklab()`,
4
+ * `oklch()` and `color()` as Tailwind v4 and other modern CSS leave them),
5
+ * converted to sRGB the way Chrome paints them on an sRGB screen (channels
6
+ * outside the gamut are clipped), and printed as short hex. Also the WCAG
7
+ * contrast math over alpha-composited backgrounds.
8
+ *
9
+ * Conversions follow the CSS Color 4 sample code (Bradford D50 → D65, the
10
+ * OKLab matrices of Björn Ottosson).
11
+ */
12
+ /** A color in sRGB: channels 0-1 (unclipped until printed), alpha 0-1 */
13
+ export interface Rgba {
14
+ r: number;
15
+ g: number;
16
+ b: number;
17
+ a: number;
18
+ }
19
+ /**
20
+ * Parse a CSS color as Chrome computes it.
21
+ *
22
+ * @param value - e.g. `rgba(0, 0, 0, 0.2)`, `oklch(0.373 0.034 259.733)`, `#fff`, `transparent`
23
+ * @returns The color in sRGB, or null for anything else (`currentcolor`, keywords, gradients)
24
+ */
25
+ export declare function parseColor(value: string): Rgba | null;
26
+ /**
27
+ * A color as short hex: `#rgb` when every channel's digits repeat, else
28
+ * `#rrggbb`; `#rrggbbaa` when translucent; `transparent` at alpha 0.
29
+ *
30
+ * @param color - Color in sRGB
31
+ * @returns e.g. `#fff`, `#364153`, `#00000033`
32
+ */
33
+ export declare function toHex(color: Rgba): string;
34
+ /**
35
+ * A computed color as short hex ({@link toHex}).
36
+ *
37
+ * @param value - Computed color
38
+ * @returns Hex, or the value unchanged when it is not a color
39
+ */
40
+ export declare function hexColor(value: string): string;
41
+ /**
42
+ * Replace every color inside a value with its hex ({@link toHex}).
43
+ *
44
+ * @param value - e.g. `rgba(0, 0, 0, 0.2) 0px 1px 2px 0px`
45
+ * @returns e.g. `#00000033 0px 1px 2px 0px`
46
+ */
47
+ export declare function hexColorsIn(value: string): string;
48
+ /**
49
+ * Paint a color over another (source-over alpha compositing).
50
+ *
51
+ * @param top - Color on top
52
+ * @param bottom - Color below
53
+ * @returns The color a user sees
54
+ */
55
+ export declare function composite(top: Rgba, bottom: Rgba): Rgba;
56
+ /**
57
+ * WCAG relative luminance of an opaque color (clipped to sRGB).
58
+ *
59
+ * @param color - Color
60
+ * @returns Luminance 0-1
61
+ */
62
+ export declare function relativeLuminance(color: Rgba): number;
63
+ /**
64
+ * WCAG contrast ratio of text over an opaque background; translucent text
65
+ * is composited over the background first.
66
+ *
67
+ * @param text - Text color
68
+ * @param background - Opaque background color
69
+ * @returns Ratio 1-21
70
+ */
71
+ export declare function contrastRatio(text: Rgba, background: Rgba): number;
72
+ /** WCAG 2 conformance of a contrast ratio */
73
+ export type ContrastLevel = 'AAA' | 'AA' | 'AA large' | 'fail';
74
+ /**
75
+ * WCAG 2 level a contrast ratio reaches. Large text (24px, or 18.66px bold)
76
+ * needs 4.5 for AAA and 3 for AA; other text 7 and 4.5.
77
+ *
78
+ * @param ratio - Contrast ratio
79
+ * @param fontSize - Font size in px
80
+ * @param fontWeight - Font weight
81
+ * @returns Level reached
82
+ */
83
+ export declare function contrastLevel(ratio: number, fontSize: number, fontWeight: number): ContrastLevel;
84
+ //# sourceMappingURL=color.d.ts.map