browser-debugger-cli 0.7.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1172) hide show
  1. package/README.md +17 -6
  2. package/dist/cdp/protocol.d.ts +1 -1
  3. package/dist/cdp/protocol.js +1 -1
  4. package/dist/cdp/schema.d.ts +14 -1
  5. package/dist/cdp/schema.js +61 -7
  6. package/dist/commands/cdp.js +76 -23
  7. package/dist/commands/cleanup.d.ts +11 -0
  8. package/dist/commands/cleanup.js +167 -55
  9. package/dist/commands/console.d.ts +38 -2
  10. package/dist/commands/console.js +147 -62
  11. package/dist/commands/details.js +15 -4
  12. package/dist/commands/dom/DomElementResolver.d.ts +34 -72
  13. package/dist/commands/dom/DomElementResolver.js +93 -166
  14. package/dist/commands/dom/a11y.d.ts +10 -0
  15. package/dist/commands/dom/a11y.js +75 -34
  16. package/dist/commands/dom/eval.d.ts +15 -0
  17. package/dist/commands/dom/eval.js +68 -0
  18. package/dist/commands/dom/form.js +109 -199
  19. package/dist/commands/dom/formInteraction.d.ts +6 -1
  20. package/dist/commands/dom/formInteraction.js +319 -362
  21. package/dist/commands/dom/formSummary.d.ts +49 -0
  22. package/dist/commands/dom/formSummary.js +180 -0
  23. package/dist/commands/dom/frames.d.ts +13 -0
  24. package/dist/commands/dom/frames.js +43 -0
  25. package/dist/commands/dom/get.d.ts +21 -0
  26. package/dist/commands/dom/get.js +151 -0
  27. package/dist/commands/dom/helpers/index.d.ts +11 -0
  28. package/dist/commands/dom/helpers/index.js +10 -0
  29. package/dist/commands/dom/helpers/query.d.ts +105 -0
  30. package/dist/commands/dom/helpers/query.js +604 -0
  31. package/dist/commands/dom/helpers/runElementCommand.d.ts +64 -0
  32. package/dist/commands/dom/helpers/runElementCommand.js +130 -0
  33. package/dist/commands/dom/helpers/screenshot.d.ts +33 -0
  34. package/dist/commands/dom/helpers/screenshot.js +489 -0
  35. package/dist/commands/dom/index.d.ts +17 -3
  36. package/dist/commands/dom/index.js +61 -517
  37. package/dist/commands/dom/layout.d.ts +14 -0
  38. package/dist/commands/dom/layout.js +54 -0
  39. package/dist/commands/dom/listeners.d.ts +20 -0
  40. package/dist/commands/dom/listeners.js +64 -0
  41. package/dist/commands/dom/query.d.ts +14 -0
  42. package/dist/commands/dom/query.js +35 -0
  43. package/dist/commands/dom/screenshot.d.ts +31 -0
  44. package/dist/commands/dom/screenshot.js +272 -0
  45. package/dist/commands/dom/semanticUtils.d.ts +37 -0
  46. package/dist/commands/dom/semanticUtils.js +98 -0
  47. package/dist/commands/dom/wait.d.ts +13 -0
  48. package/dist/commands/dom/wait.js +83 -0
  49. package/dist/commands/helpJson.d.ts +4 -2
  50. package/dist/commands/helpJson.js +12 -32
  51. package/dist/commands/helpTopic.d.ts +32 -0
  52. package/dist/commands/helpTopic.js +58 -0
  53. package/dist/commands/network/har.js +50 -24
  54. package/dist/commands/network/list.js +97 -71
  55. package/dist/commands/network/shared.d.ts +9 -15
  56. package/dist/commands/network/shared.js +30 -51
  57. package/dist/commands/optionBehaviors.d.ts +1 -9
  58. package/dist/commands/optionBehaviors.js +148 -36
  59. package/dist/commands/page.d.ts +12 -0
  60. package/dist/commands/page.js +148 -0
  61. package/dist/commands/peek.js +64 -57
  62. package/dist/commands/sessions.d.ts +8 -0
  63. package/dist/commands/sessions.js +19 -0
  64. package/dist/commands/shared/CommandRunner.d.ts +18 -1
  65. package/dist/commands/shared/CommandRunner.js +83 -26
  66. package/dist/commands/shared/commonOptions.d.ts +10 -0
  67. package/dist/commands/shared/commonOptions.js +12 -0
  68. package/dist/commands/shared/daemonErrorHandler.d.ts +9 -0
  69. package/dist/commands/shared/daemonErrorHandler.js +31 -11
  70. package/dist/commands/shared/dataFetcher.d.ts +33 -10
  71. package/dist/commands/shared/dataFetcher.js +57 -20
  72. package/dist/commands/shared/followMode.d.ts +21 -4
  73. package/dist/commands/shared/followMode.js +34 -12
  74. package/dist/commands/shared/handleValidationError.d.ts +14 -0
  75. package/dist/commands/shared/handleValidationError.js +48 -0
  76. package/dist/commands/shared/optionTypes.d.ts +80 -25
  77. package/dist/commands/shared/outputFile.d.ts +33 -0
  78. package/dist/commands/shared/outputFile.js +78 -0
  79. package/dist/commands/shared/startHelpers.d.ts +5 -8
  80. package/dist/commands/shared/startHelpers.js +235 -37
  81. package/dist/commands/shared/validation.d.ts +43 -0
  82. package/dist/commands/shared/validation.js +102 -22
  83. package/dist/commands/start.d.ts +91 -1
  84. package/dist/commands/start.js +328 -40
  85. package/dist/commands/status.js +76 -17
  86. package/dist/commands/stop.js +21 -30
  87. package/dist/commands/tail.js +22 -44
  88. package/dist/commands/types.d.ts +2 -0
  89. package/dist/commands.js +4 -0
  90. package/dist/connection/cdp.d.ts +12 -6
  91. package/dist/connection/cdp.js +59 -16
  92. package/dist/connection/chromeIdentity.d.ts +65 -0
  93. package/dist/connection/chromeIdentity.js +143 -0
  94. package/dist/connection/diagnostics.d.ts +0 -9
  95. package/dist/connection/diagnostics.js +0 -13
  96. package/dist/connection/errors.d.ts +36 -1
  97. package/dist/connection/errors.js +43 -3
  98. package/dist/connection/handlers.d.ts +5 -5
  99. package/dist/connection/handlers.js +1 -1
  100. package/dist/connection/inFlightRequests.d.ts +33 -0
  101. package/dist/connection/inFlightRequests.js +52 -0
  102. package/dist/connection/launcher/binaryResolver.js +20 -7
  103. package/dist/connection/launcher/flagsBuilder.d.ts +24 -54
  104. package/dist/connection/launcher/flagsBuilder.js +65 -40
  105. package/dist/connection/launcher/preferencesLoader.js +27 -8
  106. package/dist/connection/launcher/profilePreferences.d.ts +47 -0
  107. package/dist/connection/launcher/profilePreferences.js +151 -0
  108. package/dist/connection/launcher.d.ts +22 -1
  109. package/dist/connection/launcher.js +89 -44
  110. package/dist/connection/pageReadiness.d.ts +5 -6
  111. package/dist/connection/pageReadiness.js +63 -120
  112. package/dist/connection/portReservation.d.ts +20 -0
  113. package/dist/connection/portReservation.js +52 -2
  114. package/dist/connection/startupExit.d.ts +45 -0
  115. package/dist/connection/startupExit.js +116 -0
  116. package/dist/connection/typed-cdp.d.ts +8 -6
  117. package/dist/connection/typed-cdp.js +5 -3
  118. package/dist/connection/types.d.ts +3 -0
  119. package/dist/constants.d.ts +27 -24
  120. package/dist/constants.js +37 -27
  121. package/dist/daemon/SessionController.d.ts +125 -0
  122. package/dist/daemon/SessionController.js +488 -0
  123. package/dist/daemon/errors.d.ts +15 -19
  124. package/dist/daemon/errors.js +18 -21
  125. package/dist/daemon/ipcServer.d.ts +44 -30
  126. package/dist/daemon/ipcServer.js +164 -132
  127. package/dist/daemon/launcher.d.ts +14 -21
  128. package/dist/daemon/launcher.js +94 -102
  129. package/dist/daemon/messages.d.ts +29 -0
  130. package/dist/daemon/messages.js +35 -0
  131. package/dist/daemon/patternDefinitions.d.ts +1 -1
  132. package/dist/daemon/patternDefinitions.js +3 -2
  133. package/dist/daemon/patternDetector.d.ts +13 -29
  134. package/dist/daemon/patternDetector.js +26 -47
  135. package/dist/daemon/server/SocketServer.d.ts +56 -2
  136. package/dist/daemon/server/SocketServer.js +130 -30
  137. package/dist/daemon/session/Session.d.ts +150 -0
  138. package/dist/daemon/session/Session.js +337 -0
  139. package/dist/daemon/session/TelemetryStore.d.ts +30 -0
  140. package/dist/daemon/session/TelemetryStore.js +44 -0
  141. package/dist/daemon/session/cdpSetup.d.ts +47 -0
  142. package/dist/daemon/session/cdpSetup.js +94 -0
  143. package/dist/daemon/session/chromeConnection.d.ts +47 -0
  144. package/dist/daemon/session/chromeConnection.js +215 -0
  145. package/dist/daemon/{worker → session}/collectors.d.ts +3 -3
  146. package/dist/daemon/{worker → session}/collectors.js +3 -3
  147. package/dist/daemon/session/commandRegistry.js +435 -0
  148. package/dist/daemon/session/interactions.d.ts +53 -0
  149. package/dist/daemon/session/interactions.js +71 -0
  150. package/dist/daemon/{worker → session}/plugins.d.ts +3 -3
  151. package/dist/daemon/session/plugins.js +219 -0
  152. package/dist/daemon/session/targetMismatch.d.ts +34 -0
  153. package/dist/daemon/session/targetMismatch.js +83 -0
  154. package/dist/daemon/session/teardown.d.ts +27 -0
  155. package/dist/daemon/session/teardown.js +128 -0
  156. package/dist/daemon/session/triggeredRequests.d.ts +67 -0
  157. package/dist/daemon/session/triggeredRequests.js +157 -0
  158. package/dist/daemon/session/types.d.ts +19 -0
  159. package/dist/daemon.d.ts +3 -4
  160. package/dist/daemon.js +19149 -24
  161. package/dist/{ui/errors → errors}/CommandError.js +1 -1
  162. package/dist/{ui/errors → errors}/index.d.ts +2 -0
  163. package/dist/errors/issues.d.ts +16 -0
  164. package/dist/errors/issues.js +11 -0
  165. package/dist/errors/messages.d.ts +908 -0
  166. package/dist/errors/messages.js +1653 -0
  167. package/dist/errors/notices.d.ts +30 -0
  168. package/dist/errors/notices.js +11 -0
  169. package/dist/{ui/errors → errors}/utils.js +1 -1
  170. package/dist/index.js +18828 -168
  171. package/dist/ipc/client.d.ts +56 -9
  172. package/dist/ipc/client.js +115 -19
  173. package/dist/ipc/index.d.ts +2 -2
  174. package/dist/ipc/index.js +2 -2
  175. package/dist/ipc/protocol/commands.d.ts +305 -59
  176. package/dist/ipc/protocol/commands.js +29 -21
  177. package/dist/ipc/protocol/domTypes.d.ts +487 -0
  178. package/dist/ipc/protocol/domTypes.js +10 -0
  179. package/dist/ipc/protocol/guards.d.ts +4 -4
  180. package/dist/ipc/protocol/guards.js +4 -4
  181. package/dist/ipc/protocol/messages.d.ts +9 -33
  182. package/dist/ipc/protocol/messages.js +1 -1
  183. package/dist/ipc/session/errors.d.ts +10 -2
  184. package/dist/ipc/session/errors.js +10 -2
  185. package/dist/ipc/session/lifecycle.d.ts +28 -23
  186. package/dist/ipc/session/queries.d.ts +26 -5
  187. package/dist/ipc/session/types.d.ts +6 -1
  188. package/dist/ipc/session/types.js +1 -1
  189. package/dist/ipc/transport/IPCError.d.ts +3 -3
  190. package/dist/ipc/transport/IPCError.js +3 -3
  191. package/dist/ipc/transport/index.d.ts +8 -1
  192. package/dist/ipc/transport/index.js +8 -3
  193. package/dist/ipc/transport/jsonl.d.ts +28 -2
  194. package/dist/ipc/transport/jsonl.js +57 -10
  195. package/dist/ipc/utils/errors.d.ts +4 -2
  196. package/dist/ipc/utils/errors.js +10 -4
  197. package/dist/ipc/utils/index.d.ts +0 -1
  198. package/dist/ipc/utils/index.js +0 -1
  199. package/dist/ipc/utils/responseValidator.d.ts +5 -1
  200. package/dist/ipc/utils/responseValidator.js +7 -3
  201. package/dist/runtime/dom/actionEffects.d.ts +106 -0
  202. package/dist/runtime/dom/actionEffects.js +256 -0
  203. package/dist/runtime/dom/actionEffectsScripts.d.ts +52 -0
  204. package/dist/runtime/dom/actionEffectsScripts.js +234 -0
  205. package/dist/runtime/dom/elementGeometry.d.ts +170 -0
  206. package/dist/runtime/dom/elementGeometry.js +553 -0
  207. package/dist/runtime/dom/elementInfo.d.ts +77 -0
  208. package/dist/runtime/dom/elementInfo.js +191 -0
  209. package/dist/runtime/dom/evalHelpers.d.ts +121 -0
  210. package/dist/runtime/dom/evalHelpers.js +516 -0
  211. package/dist/runtime/dom/eventListeners.d.ts +24 -0
  212. package/dist/runtime/dom/eventListeners.js +379 -0
  213. package/dist/runtime/dom/formDiscovery.d.ts +26 -0
  214. package/dist/{commands → runtime}/dom/formDiscovery.js +163 -24
  215. package/dist/runtime/dom/formFillHelpers/fill.d.ts +39 -0
  216. package/dist/runtime/dom/formFillHelpers/fill.js +414 -0
  217. package/dist/runtime/dom/formFillHelpers/index.d.ts +17 -0
  218. package/dist/runtime/dom/formFillHelpers/index.js +17 -0
  219. package/dist/runtime/dom/formFillHelpers/pressKey.d.ts +28 -0
  220. package/dist/runtime/dom/formFillHelpers/pressKey.js +206 -0
  221. package/dist/runtime/dom/formFillHelpers/scroll.d.ts +27 -0
  222. package/dist/runtime/dom/formFillHelpers/scroll.js +230 -0
  223. package/dist/runtime/dom/formFillHelpers/shared.d.ts +60 -0
  224. package/dist/runtime/dom/formFillHelpers/shared.js +124 -0
  225. package/dist/runtime/dom/formFillHelpers/stability.d.ts +28 -0
  226. package/dist/runtime/dom/formFillHelpers/stability.js +71 -0
  227. package/dist/runtime/dom/formSubmitHelpers.d.ts +32 -0
  228. package/dist/runtime/dom/formSubmitHelpers.js +326 -0
  229. package/dist/runtime/dom/formTypes.d.ts +8 -0
  230. package/dist/runtime/dom/frameLayout.d.ts +60 -0
  231. package/dist/runtime/dom/frameLayout.js +140 -0
  232. package/dist/runtime/dom/frameOrigin.d.ts +50 -0
  233. package/dist/runtime/dom/frameOrigin.js +62 -0
  234. package/dist/runtime/dom/frameScopedConnection.d.ts +92 -0
  235. package/dist/runtime/dom/frameScopedConnection.js +252 -0
  236. package/dist/runtime/dom/frameSelection.d.ts +27 -0
  237. package/dist/runtime/dom/frameSelection.js +66 -0
  238. package/dist/runtime/dom/frames.d.ts +61 -0
  239. package/dist/runtime/dom/frames.js +444 -0
  240. package/dist/runtime/dom/keyMapping.d.ts +103 -0
  241. package/dist/runtime/dom/keyMapping.js +232 -0
  242. package/dist/runtime/dom/layout.d.ts +67 -0
  243. package/dist/runtime/dom/layout.js +333 -0
  244. package/dist/runtime/dom/listenerPageScripts.d.ts +66 -0
  245. package/dist/runtime/dom/listenerPageScripts.js +279 -0
  246. package/dist/runtime/dom/listenerSummary.d.ts +193 -0
  247. package/dist/runtime/dom/listenerSummary.js +472 -0
  248. package/dist/runtime/dom/pageActivity.d.ts +41 -0
  249. package/dist/runtime/dom/pageActivity.js +123 -0
  250. package/dist/runtime/dom/reactEventHelpers.d.ts +117 -0
  251. package/dist/runtime/dom/reactEventHelpers.js +641 -0
  252. package/dist/runtime/dom/targetNode.d.ts +131 -0
  253. package/dist/runtime/dom/targetNode.js +370 -0
  254. package/dist/runtime/dom/wait.d.ts +25 -0
  255. package/dist/runtime/dom/wait.js +199 -0
  256. package/dist/runtime/dom/waitCondition.d.ts +71 -0
  257. package/dist/runtime/dom/waitCondition.js +75 -0
  258. package/dist/runtime/page/emulation.d.ts +51 -0
  259. package/dist/runtime/page/emulation.js +80 -0
  260. package/dist/runtime/page/loadingState.d.ts +36 -0
  261. package/dist/runtime/page/loadingState.js +86 -0
  262. package/dist/runtime/page/navigation.d.ts +78 -0
  263. package/dist/runtime/page/navigation.js +285 -0
  264. package/dist/session/QueryCacheManager.d.ts +36 -83
  265. package/dist/session/QueryCacheManager.js +63 -133
  266. package/dist/session/chrome.d.ts +21 -16
  267. package/dist/session/chrome.js +28 -44
  268. package/dist/session/chromeOwners.d.ts +34 -0
  269. package/dist/session/chromeOwners.js +51 -0
  270. package/dist/session/cleanup/staleSession.d.ts +59 -0
  271. package/dist/session/cleanup/staleSession.js +135 -0
  272. package/dist/session/cleanup/userCommands.d.ts +36 -0
  273. package/dist/session/cleanup/userCommands.js +93 -0
  274. package/dist/session/daemonSocket.d.ts +25 -0
  275. package/dist/session/daemonSocket.js +40 -0
  276. package/dist/session/lastSession.d.ts +29 -0
  277. package/dist/session/lastSession.js +45 -0
  278. package/dist/session/metadata.d.ts +7 -1
  279. package/dist/session/metadata.js +2 -1
  280. package/dist/session/paths.d.ts +79 -7
  281. package/dist/session/paths.js +113 -9
  282. package/dist/session/pid.d.ts +9 -38
  283. package/dist/session/pid.js +14 -64
  284. package/dist/session/port.d.ts +31 -12
  285. package/dist/session/port.js +56 -59
  286. package/dist/session/portClaims.d.ts +66 -0
  287. package/dist/session/portClaims.js +284 -0
  288. package/dist/session/sessionList.d.ts +58 -0
  289. package/dist/session/sessionList.js +199 -0
  290. package/dist/session/sessionName.d.ts +46 -0
  291. package/dist/session/sessionName.js +97 -0
  292. package/dist/telemetry/a11y.d.ts +31 -20
  293. package/dist/telemetry/a11y.js +304 -107
  294. package/dist/telemetry/attachedTargets.d.ts +36 -0
  295. package/dist/telemetry/attachedTargets.js +163 -0
  296. package/dist/telemetry/console.d.ts +21 -4
  297. package/dist/telemetry/console.js +122 -11
  298. package/dist/telemetry/dialogs.d.ts +4 -2
  299. package/dist/telemetry/dialogs.js +3 -1
  300. package/dist/telemetry/dom.d.ts +1 -11
  301. package/dist/telemetry/dom.js +0 -102
  302. package/dist/telemetry/filterDsl.d.ts +9 -1
  303. package/dist/telemetry/filterDsl.js +101 -31
  304. package/dist/telemetry/filterPresets.js +12 -2
  305. package/dist/telemetry/filters.d.ts +1 -1
  306. package/dist/telemetry/filters.js +38 -3
  307. package/dist/telemetry/har/builder.js +190 -160
  308. package/dist/telemetry/har/types.d.ts +21 -4
  309. package/dist/telemetry/navigation.d.ts +13 -29
  310. package/dist/telemetry/navigation.js +12 -46
  311. package/dist/telemetry/network.d.ts +37 -1
  312. package/dist/telemetry/network.js +343 -130
  313. package/dist/telemetry/networkExtraInfo.d.ts +106 -0
  314. package/dist/telemetry/networkExtraInfo.js +241 -0
  315. package/dist/telemetry/objectExpander.d.ts +14 -5
  316. package/dist/telemetry/objectExpander.js +13 -6
  317. package/dist/telemetry/remoteObject.d.ts +10 -2
  318. package/dist/telemetry/remoteObject.js +59 -2
  319. package/dist/telemetry/remoteObjectUtils.js +22 -3
  320. package/dist/telemetry/requestKinds.d.ts +32 -0
  321. package/dist/telemetry/requestKinds.js +61 -0
  322. package/dist/telemetry/requestState.d.ts +31 -0
  323. package/dist/telemetry/requestState.js +38 -0
  324. package/dist/types.d.ts +143 -46
  325. package/dist/types.js +1 -33
  326. package/dist/ui/OutputBuilder.d.ts +17 -14
  327. package/dist/ui/OutputBuilder.js +18 -87
  328. package/dist/ui/formatters/a11y.js +75 -9
  329. package/dist/ui/formatters/console/chronological.d.ts +22 -0
  330. package/dist/ui/formatters/console/chronological.js +71 -0
  331. package/dist/ui/formatters/console/follow.d.ts +18 -0
  332. package/dist/ui/formatters/console/follow.js +36 -0
  333. package/dist/ui/formatters/console/json.d.ts +21 -0
  334. package/dist/ui/formatters/console/json.js +52 -0
  335. package/dist/ui/formatters/console/shared.d.ts +148 -0
  336. package/dist/ui/formatters/console/shared.js +158 -0
  337. package/dist/ui/formatters/console/summarize.d.ts +10 -0
  338. package/dist/ui/formatters/console/summarize.js +63 -0
  339. package/dist/ui/formatters/console.d.ts +16 -137
  340. package/dist/ui/formatters/console.js +17 -418
  341. package/dist/ui/formatters/cookies.js +3 -3
  342. package/dist/ui/formatters/details.d.ts +5 -2
  343. package/dist/ui/formatters/details.js +184 -24
  344. package/dist/ui/formatters/dom.d.ts +42 -9
  345. package/dist/ui/formatters/dom.js +99 -34
  346. package/dist/ui/formatters/form.js +62 -72
  347. package/dist/ui/formatters/helpFormatters.js +5 -4
  348. package/dist/ui/formatters/layout.d.ts +31 -0
  349. package/dist/ui/formatters/layout.js +53 -0
  350. package/dist/ui/formatters/listeners.d.ts +25 -0
  351. package/dist/ui/formatters/listeners.js +160 -0
  352. package/dist/ui/formatters/networkHeaders.d.ts +3 -3
  353. package/dist/ui/formatters/networkHeaders.js +20 -4
  354. package/dist/ui/formatters/networkList.d.ts +14 -2
  355. package/dist/ui/formatters/networkList.js +80 -35
  356. package/dist/ui/formatters/preview.d.ts +21 -3
  357. package/dist/ui/formatters/preview.js +55 -73
  358. package/dist/ui/formatters/requestStatus.d.ts +18 -0
  359. package/dist/ui/formatters/requestStatus.js +27 -0
  360. package/dist/ui/formatters/semantic.d.ts +1 -1
  361. package/dist/ui/formatters/semantic.js +1 -1
  362. package/dist/ui/formatters/sessions.d.ts +12 -0
  363. package/dist/ui/formatters/sessions.js +40 -0
  364. package/dist/ui/formatters/status.d.ts +44 -7
  365. package/dist/ui/formatters/status.js +89 -28
  366. package/dist/ui/formatters/triggeredRequests.d.ts +36 -0
  367. package/dist/ui/formatters/triggeredRequests.js +65 -0
  368. package/dist/ui/formatting.d.ts +45 -0
  369. package/dist/ui/formatting.js +115 -24
  370. package/dist/ui/logging/logger.d.ts +1 -1
  371. package/dist/ui/messages/chrome.d.ts +41 -97
  372. package/dist/ui/messages/chrome.js +110 -132
  373. package/dist/ui/messages/commands.d.ts +495 -3
  374. package/dist/ui/messages/commands.js +796 -6
  375. package/dist/ui/messages/consoleMessages.d.ts +7 -3
  376. package/dist/ui/messages/consoleMessages.js +13 -4
  377. package/dist/ui/messages/hints.d.ts +9 -15
  378. package/dist/ui/messages/hints.js +18 -16
  379. package/dist/ui/messages/networkMessages.d.ts +0 -6
  380. package/dist/ui/messages/networkMessages.js +0 -8
  381. package/dist/ui/messages/preview.js +5 -4
  382. package/dist/ui/messages/session.d.ts +37 -21
  383. package/dist/ui/messages/session.js +59 -26
  384. package/dist/ui/messages/sessionCommand.d.ts +43 -0
  385. package/dist/ui/messages/sessionCommand.js +52 -0
  386. package/dist/ui/messages/validation.d.ts +15 -26
  387. package/dist/ui/messages/validation.js +33 -38
  388. package/dist/utils/async.d.ts +8 -0
  389. package/dist/utils/async.js +19 -0
  390. package/dist/utils/atomicFile.js +1 -1
  391. package/dist/utils/decisionTrees.js +1 -1
  392. package/dist/utils/errorMapping.js +15 -4
  393. package/dist/utils/errors.d.ts +13 -0
  394. package/dist/utils/errors.js +21 -0
  395. package/dist/utils/exitCodes.d.ts +5 -0
  396. package/dist/utils/exitCodes.js +36 -2
  397. package/dist/utils/http.d.ts +56 -4
  398. package/dist/utils/http.js +78 -6
  399. package/dist/utils/packageRoot.d.ts +12 -0
  400. package/dist/utils/packageRoot.js +33 -0
  401. package/dist/utils/process.d.ts +10 -0
  402. package/dist/utils/process.js +35 -3
  403. package/dist/utils/selectorFilters.d.ts +73 -0
  404. package/dist/utils/selectorFilters.js +438 -0
  405. package/dist/utils/shellDetection.d.ts +8 -2
  406. package/dist/utils/shellDetection.js +120 -33
  407. package/dist/utils/suggestions.d.ts +26 -0
  408. package/dist/utils/suggestions.js +74 -1
  409. package/dist/utils/taskMappings.js +17 -2
  410. package/dist/utils/typeGuards.js +2 -2
  411. package/dist/utils/url.d.ts +23 -5
  412. package/dist/utils/url.js +115 -52
  413. package/dist/utils/validation.d.ts +15 -93
  414. package/dist/utils/validation.js +10 -118
  415. package/dist/utils/version.js +3 -5
  416. package/package.json +39 -30
  417. package/dist/__testfixtures__/cdpMessages.d.ts +0 -43
  418. package/dist/__testfixtures__/cdpMessages.d.ts.map +0 -1
  419. package/dist/__testfixtures__/cdpMessages.js +0 -118
  420. package/dist/__testfixtures__/cdpMessages.js.map +0 -1
  421. package/dist/__testfixtures__/connectionTargets.d.ts +0 -21
  422. package/dist/__testfixtures__/connectionTargets.d.ts.map +0 -1
  423. package/dist/__testfixtures__/connectionTargets.js +0 -59
  424. package/dist/__testfixtures__/connectionTargets.js.map +0 -1
  425. package/dist/__tests__/fixtures/schema-v0.2.1.golden.json +0 -47
  426. package/dist/__tests__/integration/session-files.integration.test.d.ts +0 -2
  427. package/dist/__tests__/integration/session-files.integration.test.d.ts.map +0 -1
  428. package/dist/__tests__/integration/session-files.integration.test.js +0 -66
  429. package/dist/__tests__/integration/session-files.integration.test.js.map +0 -1
  430. package/dist/__tests__/schema.contract.test.d.ts +0 -19
  431. package/dist/__tests__/schema.contract.test.d.ts.map +0 -1
  432. package/dist/__tests__/schema.contract.test.js +0 -236
  433. package/dist/__tests__/schema.contract.test.js.map +0 -1
  434. package/dist/__tests__/smoke/error-handling.smoke.test.d.ts +0 -8
  435. package/dist/__tests__/smoke/error-handling.smoke.test.d.ts.map +0 -1
  436. package/dist/__tests__/smoke/error-handling.smoke.test.js +0 -66
  437. package/dist/__tests__/smoke/error-handling.smoke.test.js.map +0 -1
  438. package/dist/__tests__/smoke/session-lifecycle.smoke.test.d.ts +0 -8
  439. package/dist/__tests__/smoke/session-lifecycle.smoke.test.d.ts.map +0 -1
  440. package/dist/__tests__/smoke/session-lifecycle.smoke.test.js +0 -112
  441. package/dist/__tests__/smoke/session-lifecycle.smoke.test.js.map +0 -1
  442. package/dist/__tests__/telemetry/filterDsl.unit.test.d.ts +0 -12
  443. package/dist/__tests__/telemetry/filterDsl.unit.test.d.ts.map +0 -1
  444. package/dist/__tests__/telemetry/filterDsl.unit.test.js +0 -374
  445. package/dist/__tests__/telemetry/filterDsl.unit.test.js.map +0 -1
  446. package/dist/__tests__/telemetry/filterPresets.unit.test.d.ts +0 -10
  447. package/dist/__tests__/telemetry/filterPresets.unit.test.d.ts.map +0 -1
  448. package/dist/__tests__/telemetry/filterPresets.unit.test.js +0 -89
  449. package/dist/__tests__/telemetry/filterPresets.unit.test.js.map +0 -1
  450. package/dist/__testutils__/FakeClock.d.ts +0 -67
  451. package/dist/__testutils__/FakeClock.d.ts.map +0 -1
  452. package/dist/__testutils__/FakeClock.js +0 -132
  453. package/dist/__testutils__/FakeClock.js.map +0 -1
  454. package/dist/__testutils__/FakeWebSocket.d.ts +0 -106
  455. package/dist/__testutils__/FakeWebSocket.d.ts.map +0 -1
  456. package/dist/__testutils__/FakeWebSocket.js +0 -213
  457. package/dist/__testutils__/FakeWebSocket.js.map +0 -1
  458. package/dist/__testutils__/assertions.d.ts +0 -33
  459. package/dist/__testutils__/assertions.d.ts.map +0 -1
  460. package/dist/__testutils__/assertions.js +0 -57
  461. package/dist/__testutils__/assertions.js.map +0 -1
  462. package/dist/__testutils__/commandRunner.d.ts +0 -45
  463. package/dist/__testutils__/commandRunner.d.ts.map +0 -1
  464. package/dist/__testutils__/commandRunner.js +0 -108
  465. package/dist/__testutils__/commandRunner.js.map +0 -1
  466. package/dist/__testutils__/daemonHelpers.d.ts +0 -93
  467. package/dist/__testutils__/daemonHelpers.d.ts.map +0 -1
  468. package/dist/__testutils__/daemonHelpers.js +0 -255
  469. package/dist/__testutils__/daemonHelpers.js.map +0 -1
  470. package/dist/__testutils__/index.d.ts +0 -16
  471. package/dist/__testutils__/index.d.ts.map +0 -1
  472. package/dist/__testutils__/index.js +0 -16
  473. package/dist/__testutils__/index.js.map +0 -1
  474. package/dist/__testutils__/testCleanup.d.ts +0 -45
  475. package/dist/__testutils__/testCleanup.d.ts.map +0 -1
  476. package/dist/__testutils__/testCleanup.js +0 -87
  477. package/dist/__testutils__/testCleanup.js.map +0 -1
  478. package/dist/__testutils__/testClock.d.ts +0 -28
  479. package/dist/__testutils__/testClock.d.ts.map +0 -1
  480. package/dist/__testutils__/testClock.js +0 -81
  481. package/dist/__testutils__/testClock.js.map +0 -1
  482. package/dist/__testutils__/testFixtures.d.ts +0 -15
  483. package/dist/__testutils__/testFixtures.d.ts.map +0 -1
  484. package/dist/__testutils__/testFixtures.js +0 -23
  485. package/dist/__testutils__/testFixtures.js.map +0 -1
  486. package/dist/__testutils__/testHome.d.ts +0 -26
  487. package/dist/__testutils__/testHome.d.ts.map +0 -1
  488. package/dist/__testutils__/testHome.js +0 -57
  489. package/dist/__testutils__/testHome.js.map +0 -1
  490. package/dist/__testutils__/testProcess.d.ts +0 -46
  491. package/dist/__testutils__/testProcess.d.ts.map +0 -1
  492. package/dist/__testutils__/testProcess.js +0 -85
  493. package/dist/__testutils__/testProcess.js.map +0 -1
  494. package/dist/cdp/protocol.d.ts.map +0 -1
  495. package/dist/cdp/protocol.js.map +0 -1
  496. package/dist/cdp/schema.d.ts.map +0 -1
  497. package/dist/cdp/schema.js.map +0 -1
  498. package/dist/cdp/types.d.ts.map +0 -1
  499. package/dist/cdp/types.js.map +0 -1
  500. package/dist/commands/__tests__/cdp.contract.test.d.ts +0 -24
  501. package/dist/commands/__tests__/cdp.contract.test.d.ts.map +0 -1
  502. package/dist/commands/__tests__/cdp.contract.test.js +0 -466
  503. package/dist/commands/__tests__/cdp.contract.test.js.map +0 -1
  504. package/dist/commands/__tests__/console.contract.test.d.ts +0 -9
  505. package/dist/commands/__tests__/console.contract.test.d.ts.map +0 -1
  506. package/dist/commands/__tests__/console.contract.test.js +0 -118
  507. package/dist/commands/__tests__/console.contract.test.js.map +0 -1
  508. package/dist/commands/__tests__/domEval.contract.test.d.ts +0 -17
  509. package/dist/commands/__tests__/domEval.contract.test.d.ts.map +0 -1
  510. package/dist/commands/__tests__/domEval.contract.test.js +0 -235
  511. package/dist/commands/__tests__/domEval.contract.test.js.map +0 -1
  512. package/dist/commands/__tests__/helpJson.contract.test.d.ts +0 -12
  513. package/dist/commands/__tests__/helpJson.contract.test.d.ts.map +0 -1
  514. package/dist/commands/__tests__/helpJson.contract.test.js +0 -121
  515. package/dist/commands/__tests__/helpJson.contract.test.js.map +0 -1
  516. package/dist/commands/__tests__/machineReadableHelp.contract.test.d.ts +0 -12
  517. package/dist/commands/__tests__/machineReadableHelp.contract.test.d.ts.map +0 -1
  518. package/dist/commands/__tests__/machineReadableHelp.contract.test.js +0 -121
  519. package/dist/commands/__tests__/machineReadableHelp.contract.test.js.map +0 -1
  520. package/dist/commands/cdp.d.ts.map +0 -1
  521. package/dist/commands/cdp.js.map +0 -1
  522. package/dist/commands/cleanup.d.ts.map +0 -1
  523. package/dist/commands/cleanup.js.map +0 -1
  524. package/dist/commands/console.d.ts.map +0 -1
  525. package/dist/commands/console.js.map +0 -1
  526. package/dist/commands/details.d.ts.map +0 -1
  527. package/dist/commands/details.js.map +0 -1
  528. package/dist/commands/dom/DomElementResolver.d.ts.map +0 -1
  529. package/dist/commands/dom/DomElementResolver.js.map +0 -1
  530. package/dist/commands/dom/__tests__/screenshotResize.unit.test.d.ts +0 -2
  531. package/dist/commands/dom/__tests__/screenshotResize.unit.test.d.ts.map +0 -1
  532. package/dist/commands/dom/__tests__/screenshotResize.unit.test.js +0 -184
  533. package/dist/commands/dom/__tests__/screenshotResize.unit.test.js.map +0 -1
  534. package/dist/commands/dom/a11y.d.ts.map +0 -1
  535. package/dist/commands/dom/a11y.js.map +0 -1
  536. package/dist/commands/dom/evalHelpers.d.ts +0 -38
  537. package/dist/commands/dom/evalHelpers.d.ts.map +0 -1
  538. package/dist/commands/dom/evalHelpers.js +0 -121
  539. package/dist/commands/dom/evalHelpers.js.map +0 -1
  540. package/dist/commands/dom/form.d.ts.map +0 -1
  541. package/dist/commands/dom/form.js.map +0 -1
  542. package/dist/commands/dom/formDiscovery.d.ts +0 -26
  543. package/dist/commands/dom/formDiscovery.d.ts.map +0 -1
  544. package/dist/commands/dom/formDiscovery.js.map +0 -1
  545. package/dist/commands/dom/formFillHelpers.d.ts +0 -186
  546. package/dist/commands/dom/formFillHelpers.d.ts.map +0 -1
  547. package/dist/commands/dom/formFillHelpers.js +0 -650
  548. package/dist/commands/dom/formFillHelpers.js.map +0 -1
  549. package/dist/commands/dom/formInteraction.d.ts.map +0 -1
  550. package/dist/commands/dom/formInteraction.js.map +0 -1
  551. package/dist/commands/dom/formSubmitHelpers.d.ts +0 -59
  552. package/dist/commands/dom/formSubmitHelpers.d.ts.map +0 -1
  553. package/dist/commands/dom/formSubmitHelpers.js +0 -163
  554. package/dist/commands/dom/formSubmitHelpers.js.map +0 -1
  555. package/dist/commands/dom/formTypes.d.ts +0 -75
  556. package/dist/commands/dom/formTypes.d.ts.map +0 -1
  557. package/dist/commands/dom/formTypes.js.map +0 -1
  558. package/dist/commands/dom/helpers.d.ts +0 -86
  559. package/dist/commands/dom/helpers.d.ts.map +0 -1
  560. package/dist/commands/dom/helpers.js +0 -656
  561. package/dist/commands/dom/helpers.js.map +0 -1
  562. package/dist/commands/dom/index.d.ts.map +0 -1
  563. package/dist/commands/dom/index.js.map +0 -1
  564. package/dist/commands/dom/keyMapping.d.ts +0 -56
  565. package/dist/commands/dom/keyMapping.d.ts.map +0 -1
  566. package/dist/commands/dom/keyMapping.js +0 -110
  567. package/dist/commands/dom/keyMapping.js.map +0 -1
  568. package/dist/commands/dom/reactEventHelpers.d.ts +0 -79
  569. package/dist/commands/dom/reactEventHelpers.d.ts.map +0 -1
  570. package/dist/commands/dom/reactEventHelpers.js +0 -239
  571. package/dist/commands/dom/reactEventHelpers.js.map +0 -1
  572. package/dist/commands/dom/screenshotResize.d.ts.map +0 -1
  573. package/dist/commands/dom/screenshotResize.js.map +0 -1
  574. package/dist/commands/helpJson.d.ts.map +0 -1
  575. package/dist/commands/helpJson.js.map +0 -1
  576. package/dist/commands/machineReadableHelp.d.ts +0 -165
  577. package/dist/commands/machineReadableHelp.d.ts.map +0 -1
  578. package/dist/commands/machineReadableHelp.js +0 -252
  579. package/dist/commands/machineReadableHelp.js.map +0 -1
  580. package/dist/commands/network/har.d.ts.map +0 -1
  581. package/dist/commands/network/har.js.map +0 -1
  582. package/dist/commands/network/index.d.ts.map +0 -1
  583. package/dist/commands/network/index.js.map +0 -1
  584. package/dist/commands/network/list.d.ts.map +0 -1
  585. package/dist/commands/network/list.js.map +0 -1
  586. package/dist/commands/network/shared.d.ts.map +0 -1
  587. package/dist/commands/network/shared.js.map +0 -1
  588. package/dist/commands/network.d.ts +0 -8
  589. package/dist/commands/network.d.ts.map +0 -1
  590. package/dist/commands/network.js +0 -216
  591. package/dist/commands/network.js.map +0 -1
  592. package/dist/commands/optionBehaviors.d.ts.map +0 -1
  593. package/dist/commands/optionBehaviors.js.map +0 -1
  594. package/dist/commands/peek.d.ts.map +0 -1
  595. package/dist/commands/peek.js.map +0 -1
  596. package/dist/commands/shared/CommandRunner.d.ts.map +0 -1
  597. package/dist/commands/shared/CommandRunner.js.map +0 -1
  598. package/dist/commands/shared/__tests__/validation.unit.test.d.ts +0 -7
  599. package/dist/commands/shared/__tests__/validation.unit.test.d.ts.map +0 -1
  600. package/dist/commands/shared/__tests__/validation.unit.test.js +0 -141
  601. package/dist/commands/shared/__tests__/validation.unit.test.js.map +0 -1
  602. package/dist/commands/shared/commonOptions.d.ts.map +0 -1
  603. package/dist/commands/shared/commonOptions.js.map +0 -1
  604. package/dist/commands/shared/daemonErrorHandler.d.ts.map +0 -1
  605. package/dist/commands/shared/daemonErrorHandler.js.map +0 -1
  606. package/dist/commands/shared/dataFetcher.d.ts.map +0 -1
  607. package/dist/commands/shared/dataFetcher.js.map +0 -1
  608. package/dist/commands/shared/followMode.d.ts.map +0 -1
  609. package/dist/commands/shared/followMode.js.map +0 -1
  610. package/dist/commands/shared/landingPage.d.ts.map +0 -1
  611. package/dist/commands/shared/landingPage.js.map +0 -1
  612. package/dist/commands/shared/optionTypes.d.ts.map +0 -1
  613. package/dist/commands/shared/optionTypes.js.map +0 -1
  614. package/dist/commands/shared/startHelpers.d.ts.map +0 -1
  615. package/dist/commands/shared/startHelpers.js.map +0 -1
  616. package/dist/commands/shared/validation.d.ts.map +0 -1
  617. package/dist/commands/shared/validation.js.map +0 -1
  618. package/dist/commands/start.d.ts.map +0 -1
  619. package/dist/commands/start.js.map +0 -1
  620. package/dist/commands/status.d.ts.map +0 -1
  621. package/dist/commands/status.js.map +0 -1
  622. package/dist/commands/stop.d.ts.map +0 -1
  623. package/dist/commands/stop.js.map +0 -1
  624. package/dist/commands/tail.d.ts.map +0 -1
  625. package/dist/commands/tail.js.map +0 -1
  626. package/dist/commands/types.d.ts.map +0 -1
  627. package/dist/commands/types.js.map +0 -1
  628. package/dist/commands.d.ts.map +0 -1
  629. package/dist/commands.js.map +0 -1
  630. package/dist/connection/__tests__/cdp.contract.test.d.ts +0 -16
  631. package/dist/connection/__tests__/cdp.contract.test.d.ts.map +0 -1
  632. package/dist/connection/__tests__/cdp.contract.test.js +0 -377
  633. package/dist/connection/__tests__/cdp.contract.test.js.map +0 -1
  634. package/dist/connection/__tests__/flagsBuilder.unit.test.d.ts +0 -9
  635. package/dist/connection/__tests__/flagsBuilder.unit.test.d.ts.map +0 -1
  636. package/dist/connection/__tests__/flagsBuilder.unit.test.js +0 -94
  637. package/dist/connection/__tests__/flagsBuilder.unit.test.js.map +0 -1
  638. package/dist/connection/__tests__/handlers.unit.test.d.ts +0 -11
  639. package/dist/connection/__tests__/handlers.unit.test.d.ts.map +0 -1
  640. package/dist/connection/__tests__/handlers.unit.test.js +0 -220
  641. package/dist/connection/__tests__/handlers.unit.test.js.map +0 -1
  642. package/dist/connection/__tests__/pageReadiness.contract.test.d.ts +0 -14
  643. package/dist/connection/__tests__/pageReadiness.contract.test.d.ts.map +0 -1
  644. package/dist/connection/__tests__/pageReadiness.contract.test.js +0 -382
  645. package/dist/connection/__tests__/pageReadiness.contract.test.js.map +0 -1
  646. package/dist/connection/__tests__/portReservation.contract.test.d.ts +0 -14
  647. package/dist/connection/__tests__/portReservation.contract.test.d.ts.map +0 -1
  648. package/dist/connection/__tests__/portReservation.contract.test.js +0 -250
  649. package/dist/connection/__tests__/portReservation.contract.test.js.map +0 -1
  650. package/dist/connection/cdp.d.ts.map +0 -1
  651. package/dist/connection/cdp.js.map +0 -1
  652. package/dist/connection/config.d.ts.map +0 -1
  653. package/dist/connection/config.js.map +0 -1
  654. package/dist/connection/diagnostics.d.ts.map +0 -1
  655. package/dist/connection/diagnostics.js.map +0 -1
  656. package/dist/connection/errors.d.ts.map +0 -1
  657. package/dist/connection/errors.js.map +0 -1
  658. package/dist/connection/events.d.ts.map +0 -1
  659. package/dist/connection/events.js.map +0 -1
  660. package/dist/connection/handlers.d.ts.map +0 -1
  661. package/dist/connection/handlers.js.map +0 -1
  662. package/dist/connection/launcher/binaryResolver.d.ts.map +0 -1
  663. package/dist/connection/launcher/binaryResolver.js.map +0 -1
  664. package/dist/connection/launcher/flagsBuilder.d.ts.map +0 -1
  665. package/dist/connection/launcher/flagsBuilder.js.map +0 -1
  666. package/dist/connection/launcher/preferencesLoader.d.ts.map +0 -1
  667. package/dist/connection/launcher/preferencesLoader.js.map +0 -1
  668. package/dist/connection/launcher.d.ts.map +0 -1
  669. package/dist/connection/launcher.js.map +0 -1
  670. package/dist/connection/pageReadiness.d.ts.map +0 -1
  671. package/dist/connection/pageReadiness.js.map +0 -1
  672. package/dist/connection/portReservation.d.ts.map +0 -1
  673. package/dist/connection/portReservation.js.map +0 -1
  674. package/dist/connection/typed-cdp.d.ts.map +0 -1
  675. package/dist/connection/typed-cdp.js.map +0 -1
  676. package/dist/connection/types.d.ts.map +0 -1
  677. package/dist/connection/types.js.map +0 -1
  678. package/dist/constants.d.ts.map +0 -1
  679. package/dist/constants.js.map +0 -1
  680. package/dist/daemon/__tests__/JsonlParser.unit.test.d.ts +0 -8
  681. package/dist/daemon/__tests__/JsonlParser.unit.test.d.ts.map +0 -1
  682. package/dist/daemon/__tests__/JsonlParser.unit.test.js +0 -140
  683. package/dist/daemon/__tests__/JsonlParser.unit.test.js.map +0 -1
  684. package/dist/daemon/__tests__/PendingRequestManager.unit.test.d.ts +0 -8
  685. package/dist/daemon/__tests__/PendingRequestManager.unit.test.d.ts.map +0 -1
  686. package/dist/daemon/__tests__/PendingRequestManager.unit.test.js +0 -276
  687. package/dist/daemon/__tests__/PendingRequestManager.unit.test.js.map +0 -1
  688. package/dist/daemon/__tests__/TelemetryStore.unit.test.d.ts +0 -8
  689. package/dist/daemon/__tests__/TelemetryStore.unit.test.d.ts.map +0 -1
  690. package/dist/daemon/__tests__/TelemetryStore.unit.test.js +0 -290
  691. package/dist/daemon/__tests__/TelemetryStore.unit.test.js.map +0 -1
  692. package/dist/daemon/__tests__/commandRegistry.contract.test.d.ts +0 -8
  693. package/dist/daemon/__tests__/commandRegistry.contract.test.d.ts.map +0 -1
  694. package/dist/daemon/__tests__/commandRegistry.contract.test.js +0 -647
  695. package/dist/daemon/__tests__/commandRegistry.contract.test.js.map +0 -1
  696. package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.d.ts +0 -19
  697. package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.d.ts.map +0 -1
  698. package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.js +0 -212
  699. package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.js.map +0 -1
  700. package/dist/daemon/__tests__/ipcServer.contract.test.d.ts +0 -23
  701. package/dist/daemon/__tests__/ipcServer.contract.test.d.ts.map +0 -1
  702. package/dist/daemon/__tests__/ipcServer.contract.test.js +0 -416
  703. package/dist/daemon/__tests__/ipcServer.contract.test.js.map +0 -1
  704. package/dist/daemon/__tests__/launcher.unit.test.d.ts +0 -8
  705. package/dist/daemon/__tests__/launcher.unit.test.d.ts.map +0 -1
  706. package/dist/daemon/__tests__/launcher.unit.test.js +0 -20
  707. package/dist/daemon/__tests__/launcher.unit.test.js.map +0 -1
  708. package/dist/daemon/errors.d.ts.map +0 -1
  709. package/dist/daemon/errors.js.map +0 -1
  710. package/dist/daemon/handlers/BaseHandler.d.ts +0 -75
  711. package/dist/daemon/handlers/BaseHandler.d.ts.map +0 -1
  712. package/dist/daemon/handlers/BaseHandler.js +0 -103
  713. package/dist/daemon/handlers/BaseHandler.js.map +0 -1
  714. package/dist/daemon/handlers/CommandHandlers.d.ts +0 -36
  715. package/dist/daemon/handlers/CommandHandlers.d.ts.map +0 -1
  716. package/dist/daemon/handlers/CommandHandlers.js +0 -60
  717. package/dist/daemon/handlers/CommandHandlers.js.map +0 -1
  718. package/dist/daemon/handlers/QueryHandlers.d.ts +0 -37
  719. package/dist/daemon/handlers/QueryHandlers.d.ts.map +0 -1
  720. package/dist/daemon/handlers/QueryHandlers.js +0 -126
  721. package/dist/daemon/handlers/QueryHandlers.js.map +0 -1
  722. package/dist/daemon/handlers/SessionHandlers.d.ts +0 -32
  723. package/dist/daemon/handlers/SessionHandlers.d.ts.map +0 -1
  724. package/dist/daemon/handlers/SessionHandlers.js +0 -213
  725. package/dist/daemon/handlers/SessionHandlers.js.map +0 -1
  726. package/dist/daemon/handlers/pendingRequests.d.ts +0 -50
  727. package/dist/daemon/handlers/pendingRequests.d.ts.map +0 -1
  728. package/dist/daemon/handlers/pendingRequests.js +0 -57
  729. package/dist/daemon/handlers/pendingRequests.js.map +0 -1
  730. package/dist/daemon/handlers/requestHandlers.d.ts +0 -55
  731. package/dist/daemon/handlers/requestHandlers.d.ts.map +0 -1
  732. package/dist/daemon/handlers/requestHandlers.js +0 -66
  733. package/dist/daemon/handlers/requestHandlers.js.map +0 -1
  734. package/dist/daemon/handlers/responseHandler.d.ts +0 -42
  735. package/dist/daemon/handlers/responseHandler.d.ts.map +0 -1
  736. package/dist/daemon/handlers/responseHandler.js +0 -217
  737. package/dist/daemon/handlers/responseHandler.js.map +0 -1
  738. package/dist/daemon/ipcServer.d.ts.map +0 -1
  739. package/dist/daemon/ipcServer.js.map +0 -1
  740. package/dist/daemon/launcher.d.ts.map +0 -1
  741. package/dist/daemon/launcher.js.map +0 -1
  742. package/dist/daemon/lifecycle/cdpSetup.d.ts +0 -24
  743. package/dist/daemon/lifecycle/cdpSetup.d.ts.map +0 -1
  744. package/dist/daemon/lifecycle/cdpSetup.js +0 -55
  745. package/dist/daemon/lifecycle/cdpSetup.js.map +0 -1
  746. package/dist/daemon/lifecycle/chromeConnection.d.ts +0 -17
  747. package/dist/daemon/lifecycle/chromeConnection.d.ts.map +0 -1
  748. package/dist/daemon/lifecycle/chromeConnection.js +0 -79
  749. package/dist/daemon/lifecycle/chromeConnection.js.map +0 -1
  750. package/dist/daemon/lifecycle/signalHandlers.d.ts +0 -14
  751. package/dist/daemon/lifecycle/signalHandlers.d.ts.map +0 -1
  752. package/dist/daemon/lifecycle/signalHandlers.js +0 -48
  753. package/dist/daemon/lifecycle/signalHandlers.js.map +0 -1
  754. package/dist/daemon/lifecycle/workerCleanup.d.ts +0 -27
  755. package/dist/daemon/lifecycle/workerCleanup.d.ts.map +0 -1
  756. package/dist/daemon/lifecycle/workerCleanup.js +0 -143
  757. package/dist/daemon/lifecycle/workerCleanup.js.map +0 -1
  758. package/dist/daemon/lifecycle/workerConfig.d.ts +0 -14
  759. package/dist/daemon/lifecycle/workerConfig.d.ts.map +0 -1
  760. package/dist/daemon/lifecycle/workerConfig.js +0 -69
  761. package/dist/daemon/lifecycle/workerConfig.js.map +0 -1
  762. package/dist/daemon/lifecycle/workerIpc.d.ts +0 -14
  763. package/dist/daemon/lifecycle/workerIpc.d.ts.map +0 -1
  764. package/dist/daemon/lifecycle/workerIpc.js +0 -86
  765. package/dist/daemon/lifecycle/workerIpc.js.map +0 -1
  766. package/dist/daemon/patternDefinitions.d.ts.map +0 -1
  767. package/dist/daemon/patternDefinitions.js.map +0 -1
  768. package/dist/daemon/patternDetector.d.ts.map +0 -1
  769. package/dist/daemon/patternDetector.js.map +0 -1
  770. package/dist/daemon/server/JsonlParser.d.ts +0 -31
  771. package/dist/daemon/server/JsonlParser.d.ts.map +0 -1
  772. package/dist/daemon/server/JsonlParser.js +0 -55
  773. package/dist/daemon/server/JsonlParser.js.map +0 -1
  774. package/dist/daemon/server/SocketServer.d.ts.map +0 -1
  775. package/dist/daemon/server/SocketServer.js.map +0 -1
  776. package/dist/daemon/server/WorkerManager.d.ts +0 -36
  777. package/dist/daemon/server/WorkerManager.d.ts.map +0 -1
  778. package/dist/daemon/server/WorkerManager.js +0 -89
  779. package/dist/daemon/server/WorkerManager.js.map +0 -1
  780. package/dist/daemon/services/SessionService.d.ts +0 -87
  781. package/dist/daemon/services/SessionService.d.ts.map +0 -1
  782. package/dist/daemon/services/SessionService.js +0 -45
  783. package/dist/daemon/services/SessionService.js.map +0 -1
  784. package/dist/daemon/startSession.d.ts +0 -55
  785. package/dist/daemon/startSession.d.ts.map +0 -1
  786. package/dist/daemon/startSession.js +0 -168
  787. package/dist/daemon/startSession.js.map +0 -1
  788. package/dist/daemon/worker/TelemetryStore.d.ts +0 -19
  789. package/dist/daemon/worker/TelemetryStore.d.ts.map +0 -1
  790. package/dist/daemon/worker/TelemetryStore.js +0 -53
  791. package/dist/daemon/worker/TelemetryStore.js.map +0 -1
  792. package/dist/daemon/worker/__tests__/PatternDetector.unit.test.d.ts +0 -11
  793. package/dist/daemon/worker/__tests__/PatternDetector.unit.test.d.ts.map +0 -1
  794. package/dist/daemon/worker/__tests__/PatternDetector.unit.test.js +0 -136
  795. package/dist/daemon/worker/__tests__/PatternDetector.unit.test.js.map +0 -1
  796. package/dist/daemon/worker/collectors.d.ts.map +0 -1
  797. package/dist/daemon/worker/collectors.js.map +0 -1
  798. package/dist/daemon/worker/commandRegistry.d.ts.map +0 -1
  799. package/dist/daemon/worker/commandRegistry.js +0 -236
  800. package/dist/daemon/worker/commandRegistry.js.map +0 -1
  801. package/dist/daemon/worker/plugins.d.ts.map +0 -1
  802. package/dist/daemon/worker/plugins.js +0 -75
  803. package/dist/daemon/worker/plugins.js.map +0 -1
  804. package/dist/daemon/worker/types.d.ts +0 -15
  805. package/dist/daemon/worker/types.d.ts.map +0 -1
  806. package/dist/daemon/worker/types.js.map +0 -1
  807. package/dist/daemon/worker.d.ts +0 -9
  808. package/dist/daemon/worker.d.ts.map +0 -1
  809. package/dist/daemon/worker.js +0 -98
  810. package/dist/daemon/worker.js.map +0 -1
  811. package/dist/daemon/workerIpc.d.ts +0 -33
  812. package/dist/daemon/workerIpc.d.ts.map +0 -1
  813. package/dist/daemon/workerIpc.js +0 -8
  814. package/dist/daemon/workerIpc.js.map +0 -1
  815. package/dist/daemon.d.ts.map +0 -1
  816. package/dist/daemon.js.map +0 -1
  817. package/dist/index.d.ts.map +0 -1
  818. package/dist/index.js.map +0 -1
  819. package/dist/ipc/__tests__/client.contract.test.d.ts +0 -8
  820. package/dist/ipc/__tests__/client.contract.test.d.ts.map +0 -1
  821. package/dist/ipc/__tests__/client.contract.test.js +0 -693
  822. package/dist/ipc/__tests__/client.contract.test.js.map +0 -1
  823. package/dist/ipc/__tests__/errors.unit.test.d.ts +0 -7
  824. package/dist/ipc/__tests__/errors.unit.test.d.ts.map +0 -1
  825. package/dist/ipc/__tests__/errors.unit.test.js +0 -77
  826. package/dist/ipc/__tests__/errors.unit.test.js.map +0 -1
  827. package/dist/ipc/__tests__/guards.unit.test.d.ts +0 -7
  828. package/dist/ipc/__tests__/guards.unit.test.d.ts.map +0 -1
  829. package/dist/ipc/__tests__/guards.unit.test.js +0 -73
  830. package/dist/ipc/__tests__/guards.unit.test.js.map +0 -1
  831. package/dist/ipc/__tests__/jsonl.unit.test.d.ts +0 -7
  832. package/dist/ipc/__tests__/jsonl.unit.test.d.ts.map +0 -1
  833. package/dist/ipc/__tests__/jsonl.unit.test.js +0 -103
  834. package/dist/ipc/__tests__/jsonl.unit.test.js.map +0 -1
  835. package/dist/ipc/__tests__/validation.unit.test.d.ts +0 -7
  836. package/dist/ipc/__tests__/validation.unit.test.d.ts.map +0 -1
  837. package/dist/ipc/__tests__/validation.unit.test.js +0 -60
  838. package/dist/ipc/__tests__/validation.unit.test.js.map +0 -1
  839. package/dist/ipc/client.d.ts.map +0 -1
  840. package/dist/ipc/client.js.map +0 -1
  841. package/dist/ipc/index.d.ts.map +0 -1
  842. package/dist/ipc/index.js.map +0 -1
  843. package/dist/ipc/protocol/commands.d.ts.map +0 -1
  844. package/dist/ipc/protocol/commands.js.map +0 -1
  845. package/dist/ipc/protocol/guards.d.ts.map +0 -1
  846. package/dist/ipc/protocol/guards.js.map +0 -1
  847. package/dist/ipc/protocol/index.d.ts.map +0 -1
  848. package/dist/ipc/protocol/index.js.map +0 -1
  849. package/dist/ipc/protocol/messages.d.ts.map +0 -1
  850. package/dist/ipc/protocol/messages.js.map +0 -1
  851. package/dist/ipc/session/errors.d.ts.map +0 -1
  852. package/dist/ipc/session/errors.js.map +0 -1
  853. package/dist/ipc/session/index.d.ts.map +0 -1
  854. package/dist/ipc/session/index.js.map +0 -1
  855. package/dist/ipc/session/lifecycle.d.ts.map +0 -1
  856. package/dist/ipc/session/lifecycle.js.map +0 -1
  857. package/dist/ipc/session/queries.d.ts.map +0 -1
  858. package/dist/ipc/session/queries.js.map +0 -1
  859. package/dist/ipc/session/types.d.ts.map +0 -1
  860. package/dist/ipc/session/types.js.map +0 -1
  861. package/dist/ipc/transport/IPCError.d.ts.map +0 -1
  862. package/dist/ipc/transport/IPCError.js.map +0 -1
  863. package/dist/ipc/transport/errors.d.ts.map +0 -1
  864. package/dist/ipc/transport/errors.js.map +0 -1
  865. package/dist/ipc/transport/index.d.ts.map +0 -1
  866. package/dist/ipc/transport/index.js.map +0 -1
  867. package/dist/ipc/transport/jsonl.d.ts.map +0 -1
  868. package/dist/ipc/transport/jsonl.js.map +0 -1
  869. package/dist/ipc/transport/socket.d.ts.map +0 -1
  870. package/dist/ipc/transport/socket.js.map +0 -1
  871. package/dist/ipc/transport/validation.d.ts.map +0 -1
  872. package/dist/ipc/transport/validation.js.map +0 -1
  873. package/dist/ipc/utils/errors.d.ts.map +0 -1
  874. package/dist/ipc/utils/errors.js.map +0 -1
  875. package/dist/ipc/utils/index.d.ts.map +0 -1
  876. package/dist/ipc/utils/index.js.map +0 -1
  877. package/dist/ipc/utils/requestId.d.ts +0 -23
  878. package/dist/ipc/utils/requestId.d.ts.map +0 -1
  879. package/dist/ipc/utils/requestId.js +0 -27
  880. package/dist/ipc/utils/requestId.js.map +0 -1
  881. package/dist/ipc/utils/responseValidator.d.ts.map +0 -1
  882. package/dist/ipc/utils/responseValidator.js.map +0 -1
  883. package/dist/ipc/utils/session.d.ts.map +0 -1
  884. package/dist/ipc/utils/session.js.map +0 -1
  885. package/dist/ipc/utils/types.d.ts.map +0 -1
  886. package/dist/ipc/utils/types.js.map +0 -1
  887. package/dist/session/QueryCacheManager.d.ts.map +0 -1
  888. package/dist/session/QueryCacheManager.js.map +0 -1
  889. package/dist/session/__tests__/chrome-cache.contract.test.d.ts +0 -7
  890. package/dist/session/__tests__/chrome-cache.contract.test.d.ts.map +0 -1
  891. package/dist/session/__tests__/chrome-cache.contract.test.js +0 -77
  892. package/dist/session/__tests__/chrome-cache.contract.test.js.map +0 -1
  893. package/dist/session/__tests__/cleanup.contract.test.d.ts +0 -7
  894. package/dist/session/__tests__/cleanup.contract.test.d.ts.map +0 -1
  895. package/dist/session/__tests__/cleanup.contract.test.js +0 -84
  896. package/dist/session/__tests__/cleanup.contract.test.js.map +0 -1
  897. package/dist/session/__tests__/lock.contract.test.d.ts +0 -7
  898. package/dist/session/__tests__/lock.contract.test.d.ts.map +0 -1
  899. package/dist/session/__tests__/lock.contract.test.js +0 -77
  900. package/dist/session/__tests__/lock.contract.test.js.map +0 -1
  901. package/dist/session/__tests__/metadata.contract.test.d.ts +0 -7
  902. package/dist/session/__tests__/metadata.contract.test.d.ts.map +0 -1
  903. package/dist/session/__tests__/metadata.contract.test.js +0 -87
  904. package/dist/session/__tests__/metadata.contract.test.js.map +0 -1
  905. package/dist/session/chrome.d.ts.map +0 -1
  906. package/dist/session/chrome.js.map +0 -1
  907. package/dist/session/cleanup.d.ts +0 -141
  908. package/dist/session/cleanup.d.ts.map +0 -1
  909. package/dist/session/cleanup.js +0 -514
  910. package/dist/session/cleanup.js.map +0 -1
  911. package/dist/session/lock.d.ts +0 -57
  912. package/dist/session/lock.d.ts.map +0 -1
  913. package/dist/session/lock.js +0 -165
  914. package/dist/session/lock.js.map +0 -1
  915. package/dist/session/metadata.d.ts.map +0 -1
  916. package/dist/session/metadata.js.map +0 -1
  917. package/dist/session/output.d.ts +0 -18
  918. package/dist/session/output.d.ts.map +0 -1
  919. package/dist/session/output.js +0 -24
  920. package/dist/session/output.js.map +0 -1
  921. package/dist/session/paths.d.ts.map +0 -1
  922. package/dist/session/paths.js.map +0 -1
  923. package/dist/session/pid.d.ts.map +0 -1
  924. package/dist/session/pid.js.map +0 -1
  925. package/dist/session/port.d.ts.map +0 -1
  926. package/dist/session/port.js.map +0 -1
  927. package/dist/session/process.d.ts +0 -8
  928. package/dist/session/process.d.ts.map +0 -1
  929. package/dist/session/process.js +0 -8
  930. package/dist/session/process.js.map +0 -1
  931. package/dist/session/queryCache.d.ts +0 -46
  932. package/dist/session/queryCache.d.ts.map +0 -1
  933. package/dist/session/queryCache.js +0 -54
  934. package/dist/session/queryCache.js.map +0 -1
  935. package/dist/session/statusData.d.ts.map +0 -1
  936. package/dist/session/statusData.js.map +0 -1
  937. package/dist/telemetry/__tests__/a11y.unit.test.d.ts +0 -10
  938. package/dist/telemetry/__tests__/a11y.unit.test.d.ts.map +0 -1
  939. package/dist/telemetry/__tests__/a11y.unit.test.js +0 -265
  940. package/dist/telemetry/__tests__/a11y.unit.test.js.map +0 -1
  941. package/dist/telemetry/__tests__/filters.unit.test.d.ts +0 -2
  942. package/dist/telemetry/__tests__/filters.unit.test.d.ts.map +0 -1
  943. package/dist/telemetry/__tests__/filters.unit.test.js +0 -357
  944. package/dist/telemetry/__tests__/filters.unit.test.js.map +0 -1
  945. package/dist/telemetry/__tests__/navigation.contract.test.d.ts +0 -8
  946. package/dist/telemetry/__tests__/navigation.contract.test.d.ts.map +0 -1
  947. package/dist/telemetry/__tests__/navigation.contract.test.js +0 -211
  948. package/dist/telemetry/__tests__/navigation.contract.test.js.map +0 -1
  949. package/dist/telemetry/__tests__/network.contract.test.d.ts +0 -8
  950. package/dist/telemetry/__tests__/network.contract.test.d.ts.map +0 -1
  951. package/dist/telemetry/__tests__/network.contract.test.js +0 -623
  952. package/dist/telemetry/__tests__/network.contract.test.js.map +0 -1
  953. package/dist/telemetry/__tests__/remoteObject.unit.test.d.ts +0 -2
  954. package/dist/telemetry/__tests__/remoteObject.unit.test.d.ts.map +0 -1
  955. package/dist/telemetry/__tests__/remoteObject.unit.test.js +0 -261
  956. package/dist/telemetry/__tests__/remoteObject.unit.test.js.map +0 -1
  957. package/dist/telemetry/__tests__/roleInference.unit.test.d.ts +0 -9
  958. package/dist/telemetry/__tests__/roleInference.unit.test.d.ts.map +0 -1
  959. package/dist/telemetry/__tests__/roleInference.unit.test.js +0 -138
  960. package/dist/telemetry/__tests__/roleInference.unit.test.js.map +0 -1
  961. package/dist/telemetry/__tests__/utils.unit.test.d.ts +0 -7
  962. package/dist/telemetry/__tests__/utils.unit.test.d.ts.map +0 -1
  963. package/dist/telemetry/__tests__/utils.unit.test.js +0 -91
  964. package/dist/telemetry/__tests__/utils.unit.test.js.map +0 -1
  965. package/dist/telemetry/a11y.d.ts.map +0 -1
  966. package/dist/telemetry/a11y.js.map +0 -1
  967. package/dist/telemetry/console.d.ts.map +0 -1
  968. package/dist/telemetry/console.js.map +0 -1
  969. package/dist/telemetry/dialogs.d.ts.map +0 -1
  970. package/dist/telemetry/dialogs.js.map +0 -1
  971. package/dist/telemetry/dom.d.ts.map +0 -1
  972. package/dist/telemetry/dom.js.map +0 -1
  973. package/dist/telemetry/filterDsl.d.ts.map +0 -1
  974. package/dist/telemetry/filterDsl.js.map +0 -1
  975. package/dist/telemetry/filterPresets.d.ts.map +0 -1
  976. package/dist/telemetry/filterPresets.js.map +0 -1
  977. package/dist/telemetry/filters.d.ts.map +0 -1
  978. package/dist/telemetry/filters.js.map +0 -1
  979. package/dist/telemetry/har/__tests__/builder.unit.test.d.ts +0 -8
  980. package/dist/telemetry/har/__tests__/builder.unit.test.d.ts.map +0 -1
  981. package/dist/telemetry/har/__tests__/builder.unit.test.js +0 -694
  982. package/dist/telemetry/har/__tests__/builder.unit.test.js.map +0 -1
  983. package/dist/telemetry/har/builder.d.ts.map +0 -1
  984. package/dist/telemetry/har/builder.js.map +0 -1
  985. package/dist/telemetry/har/types.d.ts.map +0 -1
  986. package/dist/telemetry/har/types.js.map +0 -1
  987. package/dist/telemetry/navigation.d.ts.map +0 -1
  988. package/dist/telemetry/navigation.js.map +0 -1
  989. package/dist/telemetry/network.d.ts.map +0 -1
  990. package/dist/telemetry/network.js.map +0 -1
  991. package/dist/telemetry/objectExpander.d.ts.map +0 -1
  992. package/dist/telemetry/objectExpander.js.map +0 -1
  993. package/dist/telemetry/remoteObject.d.ts.map +0 -1
  994. package/dist/telemetry/remoteObject.js.map +0 -1
  995. package/dist/telemetry/remoteObjectUtils.d.ts.map +0 -1
  996. package/dist/telemetry/remoteObjectUtils.js.map +0 -1
  997. package/dist/telemetry/roleInference.d.ts.map +0 -1
  998. package/dist/telemetry/roleInference.js.map +0 -1
  999. package/dist/telemetry/utils.d.ts.map +0 -1
  1000. package/dist/telemetry/utils.js.map +0 -1
  1001. package/dist/types/dom.d.ts +0 -77
  1002. package/dist/types/dom.d.ts.map +0 -1
  1003. package/dist/types/dom.js +0 -8
  1004. package/dist/types/dom.js.map +0 -1
  1005. package/dist/types.d.ts.map +0 -1
  1006. package/dist/types.js.map +0 -1
  1007. package/dist/ui/OutputBuilder.d.ts.map +0 -1
  1008. package/dist/ui/OutputBuilder.js.map +0 -1
  1009. package/dist/ui/errors/CommandError.d.ts.map +0 -1
  1010. package/dist/ui/errors/CommandError.js.map +0 -1
  1011. package/dist/ui/errors/index.d.ts.map +0 -1
  1012. package/dist/ui/errors/index.js.map +0 -1
  1013. package/dist/ui/errors/utils.d.ts.map +0 -1
  1014. package/dist/ui/errors/utils.js.map +0 -1
  1015. package/dist/ui/formatters/__tests__/preview.unit.test.d.ts +0 -13
  1016. package/dist/ui/formatters/__tests__/preview.unit.test.d.ts.map +0 -1
  1017. package/dist/ui/formatters/__tests__/preview.unit.test.js +0 -180
  1018. package/dist/ui/formatters/__tests__/preview.unit.test.js.map +0 -1
  1019. package/dist/ui/formatters/__tests__/semantic.unit.test.d.ts +0 -2
  1020. package/dist/ui/formatters/__tests__/semantic.unit.test.d.ts.map +0 -1
  1021. package/dist/ui/formatters/__tests__/semantic.unit.test.js +0 -111
  1022. package/dist/ui/formatters/__tests__/semantic.unit.test.js.map +0 -1
  1023. package/dist/ui/formatters/a11y.d.ts.map +0 -1
  1024. package/dist/ui/formatters/a11y.js.map +0 -1
  1025. package/dist/ui/formatters/console.d.ts.map +0 -1
  1026. package/dist/ui/formatters/console.js.map +0 -1
  1027. package/dist/ui/formatters/cookies.d.ts.map +0 -1
  1028. package/dist/ui/formatters/cookies.js.map +0 -1
  1029. package/dist/ui/formatters/details.d.ts.map +0 -1
  1030. package/dist/ui/formatters/details.js.map +0 -1
  1031. package/dist/ui/formatters/dom.d.ts.map +0 -1
  1032. package/dist/ui/formatters/dom.js.map +0 -1
  1033. package/dist/ui/formatters/form.d.ts.map +0 -1
  1034. package/dist/ui/formatters/form.js.map +0 -1
  1035. package/dist/ui/formatters/helpFormatters.d.ts.map +0 -1
  1036. package/dist/ui/formatters/helpFormatters.js.map +0 -1
  1037. package/dist/ui/formatters/index.d.ts.map +0 -1
  1038. package/dist/ui/formatters/index.js.map +0 -1
  1039. package/dist/ui/formatters/networkHeaders.d.ts.map +0 -1
  1040. package/dist/ui/formatters/networkHeaders.js.map +0 -1
  1041. package/dist/ui/formatters/networkList.d.ts.map +0 -1
  1042. package/dist/ui/formatters/networkList.js.map +0 -1
  1043. package/dist/ui/formatters/preview.d.ts.map +0 -1
  1044. package/dist/ui/formatters/preview.js.map +0 -1
  1045. package/dist/ui/formatters/semantic.d.ts.map +0 -1
  1046. package/dist/ui/formatters/semantic.js.map +0 -1
  1047. package/dist/ui/formatters/sessionFormatters.d.ts +0 -58
  1048. package/dist/ui/formatters/sessionFormatters.d.ts.map +0 -1
  1049. package/dist/ui/formatters/sessionFormatters.js +0 -118
  1050. package/dist/ui/formatters/sessionFormatters.js.map +0 -1
  1051. package/dist/ui/formatters/status.d.ts.map +0 -1
  1052. package/dist/ui/formatters/status.js.map +0 -1
  1053. package/dist/ui/formatting.d.ts.map +0 -1
  1054. package/dist/ui/formatting.js.map +0 -1
  1055. package/dist/ui/logging/index.d.ts.map +0 -1
  1056. package/dist/ui/logging/index.js.map +0 -1
  1057. package/dist/ui/logging/logger.d.ts.map +0 -1
  1058. package/dist/ui/logging/logger.js.map +0 -1
  1059. package/dist/ui/messages/chrome.d.ts.map +0 -1
  1060. package/dist/ui/messages/chrome.js.map +0 -1
  1061. package/dist/ui/messages/commands.d.ts.map +0 -1
  1062. package/dist/ui/messages/commands.js.map +0 -1
  1063. package/dist/ui/messages/consoleMessages.d.ts.map +0 -1
  1064. package/dist/ui/messages/consoleMessages.js.map +0 -1
  1065. package/dist/ui/messages/debug.d.ts +0 -168
  1066. package/dist/ui/messages/debug.d.ts.map +0 -1
  1067. package/dist/ui/messages/debug.js +0 -219
  1068. package/dist/ui/messages/debug.js.map +0 -1
  1069. package/dist/ui/messages/dom.d.ts +0 -14
  1070. package/dist/ui/messages/dom.d.ts.map +0 -1
  1071. package/dist/ui/messages/dom.js +0 -28
  1072. package/dist/ui/messages/dom.js.map +0 -1
  1073. package/dist/ui/messages/errors.d.ts +0 -233
  1074. package/dist/ui/messages/errors.d.ts.map +0 -1
  1075. package/dist/ui/messages/errors.js +0 -395
  1076. package/dist/ui/messages/errors.js.map +0 -1
  1077. package/dist/ui/messages/hints.d.ts.map +0 -1
  1078. package/dist/ui/messages/hints.js.map +0 -1
  1079. package/dist/ui/messages/internal.d.ts +0 -23
  1080. package/dist/ui/messages/internal.d.ts.map +0 -1
  1081. package/dist/ui/messages/internal.js +0 -27
  1082. package/dist/ui/messages/internal.js.map +0 -1
  1083. package/dist/ui/messages/networkMessages.d.ts.map +0 -1
  1084. package/dist/ui/messages/networkMessages.js.map +0 -1
  1085. package/dist/ui/messages/preview.d.ts.map +0 -1
  1086. package/dist/ui/messages/preview.js.map +0 -1
  1087. package/dist/ui/messages/session.d.ts.map +0 -1
  1088. package/dist/ui/messages/session.js.map +0 -1
  1089. package/dist/ui/messages/validation.d.ts.map +0 -1
  1090. package/dist/ui/messages/validation.js.map +0 -1
  1091. package/dist/utils/__tests__/atomicFile.test.d.ts +0 -2
  1092. package/dist/utils/__tests__/atomicFile.test.d.ts.map +0 -1
  1093. package/dist/utils/__tests__/atomicFile.test.js +0 -43
  1094. package/dist/utils/__tests__/atomicFile.test.js.map +0 -1
  1095. package/dist/utils/__tests__/errors.unit.test.d.ts +0 -12
  1096. package/dist/utils/__tests__/errors.unit.test.d.ts.map +0 -1
  1097. package/dist/utils/__tests__/errors.unit.test.js +0 -255
  1098. package/dist/utils/__tests__/errors.unit.test.js.map +0 -1
  1099. package/dist/utils/__tests__/http.unit.test.d.ts +0 -12
  1100. package/dist/utils/__tests__/http.unit.test.d.ts.map +0 -1
  1101. package/dist/utils/__tests__/http.unit.test.js +0 -218
  1102. package/dist/utils/__tests__/http.unit.test.js.map +0 -1
  1103. package/dist/utils/__tests__/objects.test.d.ts +0 -2
  1104. package/dist/utils/__tests__/objects.test.d.ts.map +0 -1
  1105. package/dist/utils/__tests__/objects.test.js +0 -50
  1106. package/dist/utils/__tests__/objects.test.js.map +0 -1
  1107. package/dist/utils/__tests__/process.unit.test.d.ts +0 -14
  1108. package/dist/utils/__tests__/process.unit.test.d.ts.map +0 -1
  1109. package/dist/utils/__tests__/process.unit.test.js +0 -124
  1110. package/dist/utils/__tests__/process.unit.test.js.map +0 -1
  1111. package/dist/utils/__tests__/session.contract.test.d.ts +0 -2
  1112. package/dist/utils/__tests__/session.contract.test.d.ts.map +0 -1
  1113. package/dist/utils/__tests__/session.contract.test.js +0 -258
  1114. package/dist/utils/__tests__/session.contract.test.js.map +0 -1
  1115. package/dist/utils/__tests__/shellDetection.unit.test.d.ts +0 -12
  1116. package/dist/utils/__tests__/shellDetection.unit.test.d.ts.map +0 -1
  1117. package/dist/utils/__tests__/shellDetection.unit.test.js +0 -220
  1118. package/dist/utils/__tests__/shellDetection.unit.test.js.map +0 -1
  1119. package/dist/utils/__tests__/url.test.d.ts +0 -2
  1120. package/dist/utils/__tests__/url.test.d.ts.map +0 -1
  1121. package/dist/utils/__tests__/url.test.js +0 -42
  1122. package/dist/utils/__tests__/url.test.js.map +0 -1
  1123. package/dist/utils/async.d.ts.map +0 -1
  1124. package/dist/utils/async.js.map +0 -1
  1125. package/dist/utils/atomicFile.d.ts.map +0 -1
  1126. package/dist/utils/atomicFile.js.map +0 -1
  1127. package/dist/utils/concurrency.d.ts.map +0 -1
  1128. package/dist/utils/concurrency.js.map +0 -1
  1129. package/dist/utils/daemonErrors.d.ts +0 -60
  1130. package/dist/utils/daemonErrors.d.ts.map +0 -1
  1131. package/dist/utils/daemonErrors.js +0 -58
  1132. package/dist/utils/daemonErrors.js.map +0 -1
  1133. package/dist/utils/decisionTrees.d.ts.map +0 -1
  1134. package/dist/utils/decisionTrees.js.map +0 -1
  1135. package/dist/utils/errorMapping.d.ts.map +0 -1
  1136. package/dist/utils/errorMapping.js.map +0 -1
  1137. package/dist/utils/errors.d.ts.map +0 -1
  1138. package/dist/utils/errors.js.map +0 -1
  1139. package/dist/utils/exitCodes.d.ts.map +0 -1
  1140. package/dist/utils/exitCodes.js.map +0 -1
  1141. package/dist/utils/file.d.ts.map +0 -1
  1142. package/dist/utils/file.js.map +0 -1
  1143. package/dist/utils/http.d.ts.map +0 -1
  1144. package/dist/utils/http.js.map +0 -1
  1145. package/dist/utils/levenshtein.d.ts.map +0 -1
  1146. package/dist/utils/levenshtein.js.map +0 -1
  1147. package/dist/utils/objects.d.ts.map +0 -1
  1148. package/dist/utils/objects.js.map +0 -1
  1149. package/dist/utils/process.d.ts.map +0 -1
  1150. package/dist/utils/process.js.map +0 -1
  1151. package/dist/utils/shellDetection.d.ts.map +0 -1
  1152. package/dist/utils/shellDetection.js.map +0 -1
  1153. package/dist/utils/strings.d.ts.map +0 -1
  1154. package/dist/utils/strings.js.map +0 -1
  1155. package/dist/utils/suggestions.d.ts.map +0 -1
  1156. package/dist/utils/suggestions.js.map +0 -1
  1157. package/dist/utils/taskMappings.d.ts.map +0 -1
  1158. package/dist/utils/taskMappings.js.map +0 -1
  1159. package/dist/utils/typeGuards.d.ts.map +0 -1
  1160. package/dist/utils/typeGuards.js.map +0 -1
  1161. package/dist/utils/url.d.ts.map +0 -1
  1162. package/dist/utils/url.js.map +0 -1
  1163. package/dist/utils/validation.d.ts.map +0 -1
  1164. package/dist/utils/validation.js.map +0 -1
  1165. package/dist/utils/version.d.ts.map +0 -1
  1166. package/dist/utils/version.js.map +0 -1
  1167. /package/dist/daemon/{worker → session}/commandRegistry.d.ts +0 -0
  1168. /package/dist/daemon/{worker → session}/types.js +0 -0
  1169. /package/dist/{ui/errors → errors}/CommandError.d.ts +0 -0
  1170. /package/dist/{ui/errors → errors}/index.js +0 -0
  1171. /package/dist/{ui/errors → errors}/utils.d.ts +0 -0
  1172. /package/dist/{commands → runtime}/dom/formTypes.js +0 -0
@@ -0,0 +1,1653 @@
1
+ /**
2
+ * Common error messages and patterns.
3
+ *
4
+ * Centralized location for reusable error messages with consistent formatting.
5
+ */
6
+ import * as path from 'path';
7
+ import { countedMatches, } from '../runtime/dom/waitCondition.js';
8
+ import { getSessionBaseDir, getSessionName } from '../session/paths.js';
9
+ import { escapeControlChars, formatDuration, joinLines } from '../ui/formatting.js';
10
+ import { documentRequestText, frameLabel, frameUrlLabel, pendingRequestsText, waitSnapshotSummary, waitTargetLabel, } from '../ui/messages/commands.js';
11
+ import { noActiveSessionMessage, sessionCommand, startSessionSuggestion, } from '../ui/messages/sessionCommand.js';
12
+ import { detectSelectorQuoteDamage, detectScriptQuoteDamage, hasAttributeSelector, } from '../utils/shellDetection.js';
13
+ /**
14
+ * Generate "session already running" error message (commands carry
15
+ * `--session` for a named session).
16
+ *
17
+ * @param pid - Process ID of running session
18
+ * @param duration - Session duration in milliseconds
19
+ * @param targetUrl - Optional target URL to show
20
+ * @returns Formatted error message
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const message = sessionAlreadyRunningError(12345, 60000, 'http://localhost:3000');
25
+ * console.error(message);
26
+ * ```
27
+ */
28
+ export function sessionAlreadyRunningError(pid, duration, targetUrl) {
29
+ return joinLines('', `Error: ${sessionLabel()} already running`, '', ` PID: ${pid}`, targetUrl && ` Target: ${targetUrl}`, ` Duration: ${formatDuration(duration)}`, '', 'Suggestions:', ` View session: ${sessionCommand('bdg status')}`, ` Stop and restart: ${stopAndRestartCommand()}`, '');
30
+ }
31
+ /**
32
+ * The daemon's one-line answer to `bdg <url>` while its session runs.
33
+ *
34
+ * @param pid - Daemon PID
35
+ * @returns Message
36
+ */
37
+ export function sessionAlreadyRunningMessage(pid) {
38
+ return `${sessionLabel()} already running (PID ${pid}). Stop it first with: ${sessionCommand('bdg stop')}`;
39
+ }
40
+ /**
41
+ * "Session" or `Session "<name>"` for the selected session.
42
+ *
43
+ * @returns Label
44
+ */
45
+ function sessionLabel() {
46
+ const name = getSessionName();
47
+ return name === null ? 'Session' : `Session "${name}"`;
48
+ }
49
+ /**
50
+ * Stop the selected session and start it again.
51
+ *
52
+ * @returns Command line
53
+ */
54
+ function stopAndRestartCommand() {
55
+ return `${sessionCommand('bdg stop')} && ${sessionCommand('bdg <url>')}`;
56
+ }
57
+ /**
58
+ * What to do when `bdg <url>` finds the selected session already running.
59
+ *
60
+ * @returns Suggestion
61
+ */
62
+ export function alreadyRunningSuggestion() {
63
+ return `Use the running session (${sessionCommand('bdg status')}), or stop it first: ${stopAndRestartCommand()}`;
64
+ }
65
+ /**
66
+ * Human-readable description of a bdg-launched Chrome (as opposed to one
67
+ * reached via `--chrome-ws-url`). Used in mismatch errors where the active
68
+ * session or the caller's intent is launched-mode.
69
+ */
70
+ export const LAUNCHED_CHROME_DESCRIPTION = 'launched Chrome (bdg-managed)';
71
+ /**
72
+ * Generate "session target mismatch" error message.
73
+ *
74
+ * Raised when a new start-session request names a different Chrome target
75
+ * (or switches between launched and attached modes) while an active session
76
+ * is healthy. Distinct from `sessionAlreadyRunningError` so agents can react
77
+ * programmatically via exit code + IPC error code.
78
+ *
79
+ * @param currentTarget - Target URL / ws URL / description of the active session
80
+ * @param requestedTarget - The ws URL / description of what the caller asked for
81
+ * @returns Formatted error message
82
+ */
83
+ export function sessionTargetMismatchError(currentTarget, requestedTarget) {
84
+ return joinLines('', 'Error: Active session is attached to a different Chrome target', '', ` Current: ${currentTarget ?? '(unknown)'}`, ` Requested: ${requestedTarget ?? '(unknown)'}`, '', `Run '${sessionCommand('bdg stop')}' before attaching to a different target.`, '');
85
+ }
86
+ /**
87
+ * The daemon accepted the connection but did not answer in time (frozen or
88
+ * overloaded).
89
+ *
90
+ * @param seconds - How long the command waited
91
+ * @returns Message and suggestion
92
+ */
93
+ export function sessionNotRespondingError(seconds) {
94
+ return {
95
+ message: `The session did not respond within ${seconds}s`,
96
+ suggestion: `Retry in a moment; if it stays unresponsive, end it with: ${sessionCommand('bdg cleanup --force')} (stops the daemon and its Chrome)`,
97
+ };
98
+ }
99
+ /**
100
+ * The daemon answered, but the command did not finish in time (slow or
101
+ * frozen page work).
102
+ *
103
+ * @param seconds - Timeout in seconds
104
+ */
105
+ export function commandTimedOutError(seconds) {
106
+ return {
107
+ message: `The command did not finish within ${seconds}s (the page may be busy or frozen)`,
108
+ suggestion: `Check the session with: ${sessionCommand('bdg status')}; if the page stays frozen, end it with: ${sessionCommand('bdg cleanup --force')}`,
109
+ };
110
+ }
111
+ /**
112
+ * What to do when a command finds no session to work with.
113
+ *
114
+ * @param exitCode - 85 while a start is in progress, otherwise 83
115
+ * @returns Suggestion
116
+ */
117
+ export function sessionUnavailableSuggestion(exitCode) {
118
+ return exitCode === 85
119
+ ? `Wait until "${sessionCommand('bdg <url>')}" returns, then retry`
120
+ : startSessionSuggestion();
121
+ }
122
+ /**
123
+ * Generate unified "daemon not running" error message with context.
124
+ *
125
+ * This replaces the three previous variants:
126
+ * - daemonNotRunningError()
127
+ * - daemonConnectionFailedError()
128
+ * - daemonNotRunningWithCleanup()
129
+ *
130
+ * @param context - Optional context about the error
131
+ * @returns Formatted error message with suggestions
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * // Basic usage
136
+ * console.error(daemonNotRunningError());
137
+ *
138
+ * // With stale cleanup
139
+ * console.error(daemonNotRunningError({ staleCleanedUp: true }));
140
+ *
141
+ * // With status suggestion
142
+ * console.error(daemonNotRunningError({ suggestStatus: true }));
143
+ * ```
144
+ */
145
+ export function daemonNotRunningError(context) {
146
+ return joinLines(`Error: ${noActiveSessionMessage()}`, context?.staleCleanedUp && '(Stale daemon files were cleaned up)', context?.lastError && `Last error: ${context.lastError}`, startSessionSuggestion(), context?.suggestStatus && '', context?.suggestStatus && 'Or check daemon status:', context?.suggestStatus && ` ${sessionCommand('bdg status')}`, context?.suggestRetry && '', context?.suggestRetry && 'Or try the command again if this was transient');
147
+ }
148
+ /**
149
+ * Generate generic error message with optional context.
150
+ *
151
+ * @param message - Error message
152
+ * @param context - Optional additional context
153
+ * @returns Formatted error message
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * console.error(genericError('Operation failed', 'Network timeout'));
158
+ * ```
159
+ */
160
+ export function genericError(message, context) {
161
+ const text = message.startsWith('Error:') ? message : `Error: ${message}`;
162
+ return escapeControlChars(context ? `${text}\n${context}` : text);
163
+ }
164
+ /**
165
+ * Generate "unknown error" message.
166
+ *
167
+ * @returns Formatted error message
168
+ */
169
+ export function unknownError() {
170
+ return 'Error: Unknown error';
171
+ }
172
+ /**
173
+ * Generate "invalid response" error message.
174
+ *
175
+ * @param reason - Reason for invalid response
176
+ * @returns Formatted error message
177
+ */
178
+ export function invalidResponseError(reason) {
179
+ return `[bdg] Invalid response from daemon: ${reason}`;
180
+ }
181
+ /**
182
+ * Generate element not found error with shell quote detection and CDP fallback.
183
+ *
184
+ * Provides guidance for when high-level DOM commands fail to find elements.
185
+ * Detects shell quote damage for attribute selectors and provides specific
186
+ * recovery suggestions including the two-step query-then-inspect pattern.
187
+ *
188
+ * @param selector - CSS selector that failed (as received by the command)
189
+ * @returns Message and context-aware suggestion
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * // Simple selector - standard suggestions
194
+ * elementNotFoundError('#missing-element')
195
+ *
196
+ * // Attribute selector with shell damage detected
197
+ * elementNotFoundError('[data-test-id=value]')
198
+ * // Suggestion: "Shell quote handling detected: ..."
199
+ * ```
200
+ */
201
+ export function elementNotFoundError(selector) {
202
+ const message = `Element not found: ${selector}`;
203
+ const discovery = [
204
+ 'Discovery path:',
205
+ ` 1. Query first: ${sessionCommand(`bdg dom query '${selector}'`)}`,
206
+ ` 2. Then inspect: ${sessionCommand('bdg dom a11y describe 0')}`,
207
+ ];
208
+ const quoteCheck = detectSelectorQuoteDamage(selector);
209
+ if (quoteCheck.damaged) {
210
+ return {
211
+ message,
212
+ suggestion: joinLines('Shell quote handling detected: the selector arrived without its quotes.', quoteCheck.details && ` ${quoteCheck.details}`, ...discovery),
213
+ };
214
+ }
215
+ if (hasAttributeSelector(selector)) {
216
+ return {
217
+ message,
218
+ suggestion: joinLines('Attribute selector: check that the shell kept its quotes.', ...discovery, 'Or see the page structure: bdg dom a11y tree'),
219
+ };
220
+ }
221
+ return {
222
+ message,
223
+ suggestion: joinLines(`Check the selector syntax, or wait for the element to load (${sessionCommand('bdg peek')} shows the page state)`, unreachableElementsNote(selector)),
224
+ };
225
+ }
226
+ /**
227
+ * Index out of range error.
228
+ */
229
+ export function indexOutOfRangeError(index, max) {
230
+ return {
231
+ message: `Index ${index} out of range (found ${max + 1} nodes)`,
232
+ suggestion: `Use an index between 0 and ${max}`,
233
+ };
234
+ }
235
+ /** Finding elements by accessible name, quoted for the shell (the name may contain spaces and colons). */
236
+ export const A11Y_NAME_QUERY_EXAMPLE = "bdg dom a11y query 'name=…'";
237
+ /** Where text filters can go, for selector errors. */
238
+ const SCOPED_FILTER_EXAMPLES = 'Put the filter on the element it tests, e.g. li:has-text("Buy milk") .toggle (the .toggle in that row) or label:has-text("Name") input, or test what an element contains with :has(), e.g. li:has(label:text-is("Buy milk"))';
239
+ /** Playwright selector syntax bdg does not support (`:text()`, `>>` chains, `text=` engines, layout pseudo-classes). */
240
+ const PLAYWRIGHT_ONLY_SYNTAX = /:(?:text|text-matches|nth-match|left-of|right-of|above|below|near)\(|>>|^\s*(?:text|css|xpath|role|id|data-testid|internal:\w+)=/i;
241
+ /**
242
+ * Empty (or blank) selector: the browser rejects it, so it is caught before
243
+ * any page script runs.
244
+ *
245
+ * @returns Message and suggestion
246
+ */
247
+ export function emptySelectorError() {
248
+ return {
249
+ message: 'Invalid CSS selector: The provided selector is empty',
250
+ suggestion: 'Pass a selector, e.g. bdg dom query "button.primary"',
251
+ };
252
+ }
253
+ /**
254
+ * CSS selector rejected by the browser. Playwright-only syntax (`:text()`,
255
+ * `>>`, `text=`) gets the filters bdg supports instead.
256
+ *
257
+ * @param selector - Selector as given
258
+ * @param detail - Browser error, if any
259
+ * @returns Message and suggestion
260
+ */
261
+ export function invalidSelectorError(selector, detail) {
262
+ return {
263
+ message: `Invalid CSS selector: ${selector}${detail ? ` (${detail})` : ''}`,
264
+ suggestion: PLAYWRIGHT_ONLY_SYNTAX.test(selector)
265
+ ? `Playwright-only syntax is not CSS. bdg supports :has-text("…"), :text-is("…") and :visible, e.g. button:has-text("Save"), or scoped to a row or label: li:has-text("Buy milk") .toggle; or find elements by accessible name: ${A11Y_NAME_QUERY_EXAMPLE}`
266
+ : 'Check the selector syntax, e.g. bdg dom query "button.primary"',
267
+ };
268
+ }
269
+ /**
270
+ * A text or visibility filter (`:has-text()`, `:text-is()`, `:visible`)
271
+ * inside a pseudo-class other than `:has()`, e.g. `:not(:visible)`.
272
+ *
273
+ * @param selector - Selector as given
274
+ * @param filter - The misplaced filter as written
275
+ * @returns Message and suggestion
276
+ */
277
+ export function misplacedSelectorFilterError(selector, filter) {
278
+ return {
279
+ message: `${filter} can only be used on an element of the selector or inside :has(), not inside other pseudo-classes: ${selector}`,
280
+ suggestion: `${SCOPED_FILTER_EXAMPLES}; or find elements by accessible name: ${A11Y_NAME_QUERY_EXAMPLE}`,
281
+ };
282
+ }
283
+ /**
284
+ * A sibling combinator (`+`, `~`) after a filtered compound: the rest of the
285
+ * selector is matched under the filtered element, so only descendant and
286
+ * child combinators can follow it.
287
+ *
288
+ * @param selector - Selector as given
289
+ * @param combinator - The combinator found
290
+ * @returns Message and suggestion
291
+ */
292
+ export function siblingAfterFilterError(selector, combinator) {
293
+ return {
294
+ message: `Only a descendant (space) or child (>) combinator can follow a text or visibility filter, not "${combinator}": ${selector}`,
295
+ suggestion: `Put the filter on the element to match, e.g. h2 + p:has-text("x"), or scope by a common ancestor: section:has-text("x") p`,
296
+ };
297
+ }
298
+ /**
299
+ * A `:has()` with filters whose selector starts with a sibling combinator
300
+ * (`:has(+ a:visible)`): its matches are searched under the element, where
301
+ * siblings are not.
302
+ *
303
+ * @param selector - Selector as given
304
+ * @param combinator - `+` or `~`
305
+ * @returns Message and suggestion
306
+ */
307
+ export function siblingInHasError(selector, combinator) {
308
+ return {
309
+ message: `:has() with text or visibility filters can only look inside an element, not at its siblings ("${combinator}"): ${selector}`,
310
+ suggestion: 'Use a descendant or child: li:has(a:visible), li:has(> a:visible); for a sibling, put the filter on it: li + a:visible',
311
+ };
312
+ }
313
+ /** How a selector with filters is malformed (before the browser sees it). */
314
+ const MALFORMED_SELECTOR_DETAILS = {
315
+ 'empty-in-list': () => 'a selector in the list is empty',
316
+ 'leading-combinator': (combinator) => `it starts with the combinator "${combinator}"`,
317
+ 'trailing-combinator': () => 'it ends with a combinator',
318
+ 'empty-has': () => ':has() has an empty selector',
319
+ 'scope-in-has': () => ':has() with filters is already relative to the element; write :has(> a:visible) instead of :has(:scope > a:visible)',
320
+ };
321
+ /**
322
+ * A selector with filters that is malformed in a way bdg detects while
323
+ * splitting it (so the error shows the selector as given, not rewritten CSS).
324
+ *
325
+ * @param selector - Selector as given
326
+ * @param problem - What is wrong
327
+ * @param combinator - The combinator, for `leading-combinator`
328
+ * @returns Message and suggestion
329
+ */
330
+ export function malformedSelectorError(selector, problem, combinator = '') {
331
+ return invalidSelectorError(selector, MALFORMED_SELECTOR_DETAILS[problem](combinator));
332
+ }
333
+ /**
334
+ * `:has-text()` with empty text, which every element would match.
335
+ *
336
+ * @param selector - Selector as given
337
+ * @returns Message and suggestion
338
+ */
339
+ export function emptyTextFilterError(selector) {
340
+ return {
341
+ message: `:has-text() needs the text to look for (empty text matches every element): ${selector}`,
342
+ suggestion: 'Give the text, e.g. button:has-text("Save"); use :text-is("") for elements without text',
343
+ };
344
+ }
345
+ /**
346
+ * A text filter without its text, e.g. `:has-text` or `:text-is("x"`.
347
+ *
348
+ * @param selector - Selector as given
349
+ * @param filter - Filter name, e.g. ":has-text"
350
+ * @returns Message and suggestion
351
+ */
352
+ export function invalidSelectorFilterError(selector, filter) {
353
+ return {
354
+ message: `${filter} needs its text in closed parentheses: ${selector}`,
355
+ suggestion: `Quote the text, e.g. button${filter}("Save"); escape quotes inside it with a backslash`,
356
+ };
357
+ }
358
+ /**
359
+ * `bdg help <topic>` for a command that does not exist.
360
+ *
361
+ * @param topic - Command path as typed, e.g. "dom quer"
362
+ * @param closest - Most similar existing command path, if any
363
+ */
364
+ export function unknownHelpTopicError(topic, closest) {
365
+ const parent = topic.split(' ').slice(0, -1).join(' ');
366
+ return {
367
+ message: `Unknown command: "${topic}"`,
368
+ suggestion: closest
369
+ ? `Did you mean: bdg help ${closest}?`
370
+ : `Run "bdg ${parent ? `${parent} ` : ''}--help" for commands`,
371
+ };
372
+ }
373
+ /**
374
+ * Chrome rejected a CDP method or its parameters.
375
+ *
376
+ * @param detail - Chrome's error message
377
+ */
378
+ export function cdpRequestRejectedError(detail) {
379
+ return {
380
+ message: detail,
381
+ suggestion: 'Check the method and its parameters: bdg cdp <Method> --describe',
382
+ };
383
+ }
384
+ /**
385
+ * A file the user asked for (screenshot, HAR) cannot be written.
386
+ *
387
+ * @param filePath - Path as given
388
+ * @param reason - What is wrong with it
389
+ * @param extension - Extension of the file kind, for the example (default .png)
390
+ */
391
+ export function outputFileError(filePath, reason, extension = '.png') {
392
+ const example = `output${path.extname(filePath) || extension}`;
393
+ return {
394
+ message: `Cannot write ${filePath}: ${reason}`,
395
+ suggestion: `Choose a writable file path, e.g. ./${example} or /tmp/${example}`,
396
+ };
397
+ }
398
+ /**
399
+ * An empty output path.
400
+ *
401
+ * @param extension - Extension of the file kind, for the example
402
+ */
403
+ export function emptyOutputPathError(extension = '.png') {
404
+ return {
405
+ message: 'The output path is empty',
406
+ suggestion: `Give a file name, e.g. output${extension}`,
407
+ };
408
+ }
409
+ /**
410
+ * Start options given without the URL to open.
411
+ */
412
+ export function missingStartUrlError() {
413
+ return {
414
+ message: 'Missing URL to open',
415
+ suggestion: 'Put the URL first, e.g. bdg localhost:3000 --port 9333',
416
+ };
417
+ }
418
+ /**
419
+ * `--viewport` given something that is not a width and height.
420
+ *
421
+ * @param value - What was given
422
+ * @param max - Largest side accepted
423
+ */
424
+ export function invalidViewportError(value, max) {
425
+ return {
426
+ message: `Invalid --viewport: "${value}"`,
427
+ suggestion: `Give width x height in CSS px (1-${max} each), e.g. --viewport 1280x800`,
428
+ };
429
+ }
430
+ /**
431
+ * `--color-scheme` given another value than the ones it takes.
432
+ *
433
+ * @param value - What was given
434
+ * @param similar - Close matches
435
+ * @param schemes - Accepted values
436
+ */
437
+ export function invalidColorSchemeError(value, similar, schemes) {
438
+ return {
439
+ message: `Unknown --color-scheme: "${value}"`,
440
+ suggestion: similar[0] ? `Did you mean: ${similar[0]}?` : `Available: ${schemes.join(', ')}`,
441
+ };
442
+ }
443
+ /**
444
+ * `-u` / `--user-data-dir` given something that is not a directory path.
445
+ *
446
+ * @param value - What was given
447
+ * @param reason - Why it cannot be used
448
+ */
449
+ export function invalidUserDataDirError(value, reason) {
450
+ return {
451
+ message: `Invalid --user-data-dir "${value}": ${reason}`,
452
+ suggestion: 'Give a directory for the Chrome profile, e.g. -u ./profile (it is created if missing)',
453
+ };
454
+ }
455
+ /**
456
+ * A `--session` / `BDG_SESSION` name bdg cannot use as a directory name.
457
+ *
458
+ * @param name - The rejected name
459
+ * @param maxLength - Longest allowed name
460
+ */
461
+ export function invalidSessionNameError(name, maxLength) {
462
+ return {
463
+ message: `Invalid session name "${name}"`,
464
+ suggestion: `Use 1-${maxLength} letters, digits, "-" or "_", starting with a letter or digit, e.g. --session agent-1`,
465
+ };
466
+ }
467
+ /**
468
+ * A session name whose daemon socket path would exceed the OS limit.
469
+ *
470
+ * @param name - Session name
471
+ * @param socketPath - Resulting socket path
472
+ * @param max - Longest socket path in bytes
473
+ */
474
+ export function sessionNameSocketTooLongError(name, socketPath, max) {
475
+ return {
476
+ message: `Session name "${name}" makes the daemon socket path too long (${Buffer.byteLength(socketPath)} bytes, at most ${max}): ${socketPath}`,
477
+ suggestion: 'Use a shorter session name, or a shorter BDG_SESSION_DIR (e.g. /tmp/bdg)',
478
+ };
479
+ }
480
+ /**
481
+ * `bdg cleanup --purge` without a named session (the default session's
482
+ * directory holds the named sessions).
483
+ */
484
+ export function purgeNeedsNamedSessionError() {
485
+ return {
486
+ message: "--purge deletes a named session's directory and needs --session <name>",
487
+ suggestion: 'Name the session: bdg cleanup --session <name> --purge (see bdg sessions)',
488
+ };
489
+ }
490
+ /**
491
+ * `bdg cleanup --purge` found the session still holding its directory after
492
+ * cleaning up, so the directory is kept.
493
+ *
494
+ * @param dir - Session directory
495
+ * @param reason - What still holds it
496
+ */
497
+ export function purgeRefusedError(dir, reason) {
498
+ return {
499
+ message: `Not deleting ${dir}: ${reason}`,
500
+ suggestion: `End the session first (${sessionCommand('bdg cleanup --force')}), then retry: ${sessionCommand('bdg cleanup --purge')}`,
501
+ };
502
+ }
503
+ /** Fix for an unusable session directory */
504
+ const SESSION_DIR_SUGGESTION = 'Set BDG_SESSION_DIR to a short, writable directory, e.g. BDG_SESSION_DIR=/tmp/bdg';
505
+ /**
506
+ * The session directory exists but is not a directory.
507
+ *
508
+ * @param dir - Session directory
509
+ */
510
+ export function sessionDirIsFileError(dir) {
511
+ return { message: `Session directory ${dir} is a file`, suggestion: SESSION_DIR_SUGGESTION };
512
+ }
513
+ /**
514
+ * The session directory cannot be created or written.
515
+ *
516
+ * @param dir - Session directory
517
+ * @param reason - File-system error
518
+ */
519
+ export function sessionDirNotWritableError(dir, reason) {
520
+ return {
521
+ message: `Session directory ${dir} is not writable (${reason})`,
522
+ suggestion: SESSION_DIR_SUGGESTION,
523
+ };
524
+ }
525
+ /**
526
+ * The daemon socket path exceeds the OS limit for Unix sockets.
527
+ *
528
+ * @param socketPath - Socket path
529
+ * @param max - Longest path the OS accepts
530
+ */
531
+ export function socketPathTooLongError(socketPath, max) {
532
+ return {
533
+ message: `Session directory path is too long for the daemon socket (${Buffer.byteLength(socketPath)} bytes, at most ${max}): ${socketPath}`,
534
+ suggestion: SESSION_DIR_SUGGESTION,
535
+ };
536
+ }
537
+ /**
538
+ * The Chrome of `--chrome-ws-url` does not answer on its HTTP endpoint.
539
+ *
540
+ * @param endpoint - e.g. http://127.0.0.1:9222
541
+ * @param secure - Whether a wss: URL was given
542
+ */
543
+ export function externalChromeUnreachableError(endpoint, secure) {
544
+ return {
545
+ message: `Cannot reach the Chrome DevTools endpoint at ${endpoint}`,
546
+ suggestion: secure
547
+ ? 'Chrome itself serves ws:// only; use ws://host:port/... unless a TLS proxy is in front of it'
548
+ : 'Check that Chrome runs with --remote-debugging-port and is reachable from here',
549
+ };
550
+ }
551
+ /**
552
+ * Something answers on the `--chrome-ws-url` endpoint, but it is not Chrome's
553
+ * DevTools HTTP endpoint (e.g. a web server on that port).
554
+ *
555
+ * @param endpoint - e.g. http://127.0.0.1:3000
556
+ */
557
+ export function notDevToolsEndpointError(endpoint) {
558
+ return {
559
+ message: `${endpoint} answers, but it is not a Chrome DevTools endpoint (no /json/version)`,
560
+ suggestion: "Give Chrome's debugging port (the --remote-debugging-port it was started with), not the page's port",
561
+ };
562
+ }
563
+ /**
564
+ * Another running bdg session uses the Chrome (or tab) `--chrome-ws-url`
565
+ * points to.
566
+ *
567
+ * @param endpoint - e.g. http://127.0.0.1:9222
568
+ * @param owner - The other session: name (null for a default session),
569
+ * directory, base directory and whether it launched that Chrome
570
+ */
571
+ export function chromeInUseBySessionError(endpoint, owner) {
572
+ const label = owner.name === null ? 'the default bdg session' : `bdg session "${owner.name}"`;
573
+ const what = owner.launched ? 'was launched by' : 'has its tab driven by';
574
+ const envPrefix = owner.baseDir === getSessionBaseDir() ? '' : `BDG_SESSION_DIR=${owner.baseDir} `;
575
+ const ownerCommand = (command) => envPrefix + sessionCommand(command, owner.name);
576
+ return {
577
+ message: `The Chrome at ${endpoint} ${what} ${label} (${owner.dir}); attaching would take it over`,
578
+ suggestion: `Use that session (${ownerCommand('bdg status')}), stop it first (${ownerCommand('bdg stop')}), or attach to another Chrome or tab (a page URL from ${endpoint}/json/list)`,
579
+ };
580
+ }
581
+ /**
582
+ * The page id of a `--chrome-ws-url` page URL does not exist.
583
+ *
584
+ * @param id - Page id from the URL
585
+ * @param endpoint - e.g. http://127.0.0.1:9222
586
+ */
587
+ export function externalPageNotFoundError(id, endpoint) {
588
+ return {
589
+ message: `No page with id ${id} in the Chrome at ${endpoint}`,
590
+ suggestion: `List its pages: curl -s ${endpoint}/json/list`,
591
+ };
592
+ }
593
+ /**
594
+ * The browser id of a `--chrome-ws-url` browser URL is not this Chrome's.
595
+ *
596
+ * @param endpoint - e.g. http://127.0.0.1:9222
597
+ * @param actual - The Chrome's browser WebSocket URL
598
+ */
599
+ export function externalBrowserIdMismatchError(endpoint, actual) {
600
+ return {
601
+ message: `The Chrome at ${endpoint} has a different browser id (it was restarted, or the URL is from another Chrome)`,
602
+ suggestion: `Use its current URL: ${sessionCommand(`bdg <url> --chrome-ws-url ${actual}`)}`,
603
+ };
604
+ }
605
+ /**
606
+ * Options that only apply when bdg launches Chrome, given with `--chrome-ws-url`.
607
+ *
608
+ * @param options - The conflicting options, e.g. ["--port", "-u"]
609
+ */
610
+ export function chromeWsUrlConflictError(options) {
611
+ return {
612
+ message: `${options.join(' and ')} cannot be used with --chrome-ws-url (the running Chrome already has its port, profile and window mode)`,
613
+ suggestion: 'Drop them, or let bdg launch Chrome without --chrome-ws-url',
614
+ };
615
+ }
616
+ /**
617
+ * A numeric index given together with `--index`.
618
+ *
619
+ * @param index - The index argument
620
+ * @param command - The `bdg dom` subcommand it was given to, e.g. "layout"
621
+ */
622
+ export function indexWithIndexOptionError(index, command) {
623
+ return {
624
+ message: `--index applies to a selector, but "${index}" is already an index from the last query`,
625
+ suggestion: `Use one: bdg dom ${command} ${index}, or bdg dom ${command} "<selector>" --index <n>`,
626
+ };
627
+ }
628
+ /** Problems with `bdg dom scroll` options, and how to fix each */
629
+ const SCROLL_PROBLEMS = {
630
+ 'index-without-selector': [
631
+ '--index requires a selector',
632
+ 'Use: bdg dom scroll "selector" --index 2',
633
+ ],
634
+ vertical: [
635
+ 'Conflicting scroll directions: --up/--down/--top/--bottom',
636
+ 'Use one vertical direction',
637
+ ],
638
+ horizontal: ['Conflicting scroll directions: --left and --right', 'Use either --left or --right'],
639
+ 'selector-with-offset': [
640
+ 'A selector cannot be combined with --up/--down/--left/--right/--top/--bottom',
641
+ 'Scroll to the element (bdg dom scroll "footer"), or by an offset (bdg dom scroll --down 500)',
642
+ ],
643
+ 'no-target': [
644
+ 'No scroll target specified',
645
+ 'Provide a selector (bdg dom scroll "footer") or offset (--down 500, --bottom)',
646
+ ],
647
+ };
648
+ /**
649
+ * Invalid `bdg dom scroll` options.
650
+ *
651
+ * @param problem - Which rule was broken
652
+ */
653
+ export function scrollOptionsError(problem) {
654
+ const [message, suggestion] = SCROLL_PROBLEMS[problem];
655
+ return { message, suggestion };
656
+ }
657
+ /**
658
+ * A key name `dom pressKey` does not know.
659
+ *
660
+ * @param keyName - Key as given
661
+ * @param similar - Similar key names
662
+ */
663
+ export function unknownKeyError(keyName, similar) {
664
+ return {
665
+ message: `Unknown key: "${keyName}"`,
666
+ suggestion: similar.length
667
+ ? `Did you mean: ${similar.join(', ')}?`
668
+ : 'Keys: Enter, Tab, Escape, Space, Backspace, Delete, ArrowUp/Down/Left/Right, Home, End, PageUp, PageDown, F1-F12, a-z, A-Z, 0-9, !@#$%^&*()',
669
+ };
670
+ }
671
+ /**
672
+ * `dom screenshot` given an element both as an argument and as an option,
673
+ * and they differ.
674
+ *
675
+ * @param option - The option and its value, e.g. `--selector #a`
676
+ * @param positional - The element argument
677
+ * @returns Message and suggestion
678
+ */
679
+ export function conflictingTargetError(option, positional) {
680
+ return {
681
+ message: `${option} and the element argument "${positional}" name different elements`,
682
+ suggestion: 'Name the element once: bdg dom screenshot <path> <selector|index>',
683
+ };
684
+ }
685
+ /**
686
+ * Two options given together where one would be ignored.
687
+ *
688
+ * @param first - First option
689
+ * @param second - Option it conflicts with
690
+ * @returns Message
691
+ */
692
+ export function conflictingOptionsMessage(first, second) {
693
+ return `${first} cannot be combined with ${second}; use one of them`;
694
+ }
695
+ /**
696
+ * A Chrome flag bdg cannot pass on.
697
+ *
698
+ * @param flag - The flag
699
+ */
700
+ export function invalidChromeFlagError(flag) {
701
+ return flag.startsWith('--remote-debugging')
702
+ ? {
703
+ message: `${flag} cannot be passed in --chrome-flags: bdg sets the debugging port`,
704
+ suggestion: 'Use --port <number> instead',
705
+ }
706
+ : {
707
+ message: `--chrome-flags got "${flag}", which is a bdg option`,
708
+ suggestion: 'Give Chrome flags as one quoted value: --chrome-flags="--lang=pl --disable-gpu"',
709
+ };
710
+ }
711
+ /**
712
+ * The session (its browser or daemon) went away while a command was running.
713
+ */
714
+ export function sessionEndedDuringCommandError() {
715
+ return {
716
+ message: 'The session ended while the command was running',
717
+ suggestion: `Start a new session with: ${sessionCommand('bdg <url>')}`,
718
+ };
719
+ }
720
+ /**
721
+ * An option that only takes effect together with another one.
722
+ *
723
+ * @param option - Option given
724
+ * @param required - Option it needs
725
+ * @returns Message
726
+ */
727
+ export function optionRequiresMessage(option, required) {
728
+ return `${option} only works with ${required}; add ${required} or drop ${option}`;
729
+ }
730
+ /**
731
+ * `bdg page navigate javascript:…`: scripts run with dom eval.
732
+ */
733
+ export function javascriptNavigationError() {
734
+ return {
735
+ message: 'page navigate opens pages; it does not run javascript: URLs',
736
+ suggestion: `Run the script in the page instead: bdg dom eval '...'`,
737
+ };
738
+ }
739
+ /**
740
+ * A bare word given where a URL is expected, most likely a mistyped command.
741
+ *
742
+ * @param word - The argument
743
+ * @param similar - Similar command names
744
+ */
745
+ export function unknownCommandError(word, similar) {
746
+ const [closest] = similar;
747
+ return {
748
+ message: `Unknown command: "${word}"`,
749
+ suggestion: closest
750
+ ? `Did you mean: bdg ${closest}?`
751
+ : `Run "bdg --help" for commands. To open a host named "${word}", use a full URL: bdg http://${word}/`,
752
+ };
753
+ }
754
+ /**
755
+ * The browser could not load the start URL at all.
756
+ *
757
+ * @param url - URL that failed
758
+ * @param errorText - Chrome network error (e.g. net::ERR_NAME_NOT_RESOLVED)
759
+ */
760
+ export function navigationFailedError(url, errorText) {
761
+ return {
762
+ message: `Could not load ${url}: ${errorText}`,
763
+ suggestion: 'Check the URL and that the server is running and reachable from this machine',
764
+ };
765
+ }
766
+ /**
767
+ * `bdg page back/forward` at the end of the page's history.
768
+ *
769
+ * @param direction - back or forward
770
+ */
771
+ export function noHistoryEntryError(direction) {
772
+ return {
773
+ message: `There is no page to go ${direction} to`,
774
+ suggestion: 'Open a page with: bdg page navigate <url>',
775
+ };
776
+ }
777
+ /**
778
+ * What to do about a submit that timed out waiting for a navigation, by how
779
+ * far its page request got: without one the form probably submits via fetch.
780
+ *
781
+ * @param document - The page request, if one was sent
782
+ * @returns Suggestion
783
+ */
784
+ function submitNavigationSuggestion(document) {
785
+ if (document === undefined) {
786
+ return 'The form sent no page request, so it may not navigate (e.g. it submits via fetch); retry without --wait-navigation';
787
+ }
788
+ const details = `see it with ${sessionCommand('bdg network list --last 10')}`;
789
+ if (document.errorText !== undefined)
790
+ return `The page request failed; ${details}`;
791
+ if (document.status !== undefined && document.status >= 400) {
792
+ return `The server answered with an error; ${details}`;
793
+ }
794
+ if (document.status !== undefined) {
795
+ return 'The server answered without a new page; retry without --wait-navigation';
796
+ }
797
+ return 'The server has not answered the page request yet; retry with a larger --timeout';
798
+ }
799
+ /**
800
+ * What a timed-out submit was waiting on, in words: its page request when a
801
+ * navigation was awaited or the request had not loaded a page, otherwise the
802
+ * requests still running.
803
+ *
804
+ * @param waitNavigation - Whether a navigation was awaited
805
+ * @param blockers - The page request and the requests still running
806
+ * @returns e.g. `POST …/authenticate pending for 10s`; undefined when nothing is known
807
+ */
808
+ function submitWaitDetail(waitNavigation, blockers) {
809
+ const { document, pending = [] } = blockers;
810
+ const loadedPage = document?.status !== undefined && document.status < 400 && document.errorText === undefined;
811
+ if (document && (waitNavigation || !loadedPage))
812
+ return documentRequestText(document);
813
+ if (pending.length === 0)
814
+ return undefined;
815
+ return `waiting on ${pendingRequestsText(pending, blockers.pendingCount ?? pending.length)}`;
816
+ }
817
+ /**
818
+ * The form was submitted but the wait for its result timed out. The message
819
+ * names what it was waiting on: the page request the submit sent (pending,
820
+ * answered with an error, failed; waiting for a navigation, also one that
821
+ * answered), or else the requests still running.
822
+ *
823
+ * @param timeout - Timeout in ms
824
+ * @param waitNavigation - Whether a navigation was awaited
825
+ * @param blockers - The page request and the requests still running
826
+ * @returns e.g. `Form submitted, but timed out after 10000ms waiting for navigation: POST …/authenticate pending for 10s`
827
+ */
828
+ export function submitTimeoutError(timeout, waitNavigation, blockers = {}) {
829
+ const detail = submitWaitDetail(waitNavigation, blockers);
830
+ const message = `Form submitted, but timed out after ${timeout}ms waiting for ${waitNavigation ? 'navigation' : 'network idle'}${detail ? `: ${detail}` : ''}`;
831
+ if (!waitNavigation) {
832
+ return {
833
+ message,
834
+ suggestion: 'Increase --timeout, or use --wait-network 0 to return right after submitting',
835
+ };
836
+ }
837
+ return { message, suggestion: submitNavigationSuggestion(blockers.document) };
838
+ }
839
+ /**
840
+ * Warning of a submit whose navigation happened but whose network was still
841
+ * busy when the wait ran out (the new page is there; a slow script or
842
+ * tracker kept loading).
843
+ *
844
+ * @param timeout - Timeout in ms
845
+ * @param pending - Requests still in flight
846
+ * @returns Warning text
847
+ */
848
+ export function submitNetworkBusyWarning(timeout, pending) {
849
+ const requests = pending === 1 ? '1 request' : `${pending} requests`;
850
+ return `The new page loaded, but ${requests} still had not finished after ${timeout}ms`;
851
+ }
852
+ /**
853
+ * No element has the given node id.
854
+ *
855
+ * @param nodeId - Backend node id given with --node-id
856
+ */
857
+ export function nodeIdNotFoundError(nodeId) {
858
+ return {
859
+ message: `No element with node id ${nodeId} in the page`,
860
+ suggestion: 'Get current node ids with "bdg dom query <selector>" or "bdg dom get <selector> --raw"',
861
+ };
862
+ }
863
+ /**
864
+ * The list an index refers to, in words.
865
+ *
866
+ * @param source - Where the index comes from
867
+ * @returns e.g. `index 0 of the last dom query "h3"`, `index 2 of the last dom form`
868
+ */
869
+ export function indexSourceText(source) {
870
+ return `index ${source.index} of ${cachedListText(source)}`;
871
+ }
872
+ /**
873
+ * The cached list an index refers to, in words.
874
+ *
875
+ * @param source - Where the index comes from
876
+ * @returns e.g. `the last dom query "h3"`
877
+ */
878
+ function cachedListText(source) {
879
+ const query = source.query === undefined ? '' : ` "${source.query}"`;
880
+ return `the last ${source.command}${query}`;
881
+ }
882
+ /**
883
+ * The command that refreshes the list an index refers to.
884
+ *
885
+ * @param source - Where the index comes from
886
+ * @returns e.g. `bdg dom query 'h3'`
887
+ */
888
+ function refreshCommand(source) {
889
+ if (source.query === undefined)
890
+ return sessionCommand(`bdg ${source.command}`);
891
+ return sessionCommand(`bdg ${source.command} ${shellQuote(source.query)}`);
892
+ }
893
+ /**
894
+ * An element of a cross-origin iframe (from an a11y query) whose iframe
895
+ * could not be placed in the top-level viewport, so a mouse event or layout
896
+ * would land in the wrong place.
897
+ *
898
+ * @param problem - The iframe or element has no box, is rotated or skewed, or could not be read
899
+ * @param detail - Underlying error, if any
900
+ * @returns Message and suggestion
901
+ */
902
+ export function frameMappingError(problem, detail) {
903
+ const reasons = {
904
+ 'no-box': 'neither the element nor its iframe document has a box (hidden or removed)',
905
+ rotated: 'the iframe is rotated or skewed, which bdg cannot map',
906
+ unreadable: `it could not be measured${detail ? ` (${detail})` : ''}`,
907
+ };
908
+ return {
909
+ message: `Cannot place the element's cross-origin iframe in the page: ${reasons[problem]}`,
910
+ suggestion: `Act inside the frame instead: ${sessionCommand('bdg dom frames')}, then ${sessionCommand('bdg dom eval --frame <n> \'document.querySelector("…").click()\'')}`,
911
+ };
912
+ }
913
+ /**
914
+ * A cached node is gone (page navigated or the element was removed).
915
+ *
916
+ * @param index - Index the user gave, if any
917
+ * @param source - The list the index refers to, when known
918
+ * @returns Message and suggestion
919
+ */
920
+ export function staleNodeError(index, source) {
921
+ if (source) {
922
+ return {
923
+ message: `The element at ${indexSourceText(source)} is no longer in the page (it was removed or the page navigated)`,
924
+ suggestion: `Re-run "${refreshCommand(source)}" to get fresh indices`,
925
+ };
926
+ }
927
+ const element = index === undefined ? 'The element' : `The element at index ${index}`;
928
+ return {
929
+ message: `${element} is no longer in the page (it was removed or the page navigated)`,
930
+ suggestion: 'Re-run "bdg dom query <selector>" (or "bdg dom form") to get fresh indices',
931
+ };
932
+ }
933
+ /**
934
+ * An index beyond the cached results.
935
+ *
936
+ * @param source - The index and the list it refers to
937
+ * @param count - Number of cached results
938
+ * @returns Message and suggestion
939
+ */
940
+ export function cachedIndexOutOfRangeError(source, count) {
941
+ const results = count === 1 ? '1 result' : `${count} results`;
942
+ return {
943
+ message: `Index ${source.index} is out of range for ${cachedListText(source)} (${results})`,
944
+ suggestion: count > 0
945
+ ? `Use an index between 0 and ${count - 1}, or re-run "${refreshCommand(source)}"`
946
+ : `Re-run "${refreshCommand(source)}"`,
947
+ };
948
+ }
949
+ /**
950
+ * Note for a form command (fill, submit) whose index refers to results of
951
+ * another command and hit an element it cannot act on.
952
+ *
953
+ * @param source - The index and the list it refers to
954
+ * @param preview - What the cached element is, e.g. `h3 "Welcome"`
955
+ * @returns e.g. `index 0 refers to the last dom query results ("h3": h3 "Welcome"); run bdg dom form to target form fields by index`
956
+ */
957
+ export function otherIndexSourceNote(source, preview) {
958
+ const query = source.query === undefined ? '' : `"${source.query}"`;
959
+ const what = [query, preview].filter(Boolean).join(': ');
960
+ return `index ${source.index} refers to the last ${source.command} results${what ? ` (${what})` : ''}; run ${sessionCommand('bdg dom form')} to target form fields by index`;
961
+ }
962
+ /**
963
+ * Where selectors do not reach (open shadow roots and same-origin iframes are
964
+ * searched), and how to reach an element in a cross-origin iframe instead.
965
+ * When the page was checked, only what it has is named (nothing when it has
966
+ * neither cross-origin iframes nor embeds; closed shadow roots cannot be
967
+ * detected).
968
+ *
969
+ * @param selector - Selector that matched nothing
970
+ * @param unsearched - What the page holds, when it was checked
971
+ * @returns Note for "not found" suggestions (empty when nothing applies)
972
+ */
973
+ export function unreachableElementsNote(selector, unsearched) {
974
+ const script = `document.querySelector(${JSON.stringify(selector)})`.replaceAll("'", `'\\''`);
975
+ const framesHelp = `For an element in a cross-origin iframe: ${sessionCommand('bdg dom frames')}, then ${sessionCommand(`bdg dom eval --frame <n> '${script}'`)}`;
976
+ if (!unsearched) {
977
+ return joinLines('Closed shadow roots, cross-origin iframes and <object>/<embed> documents are not searched.', framesHelp);
978
+ }
979
+ const places = [
980
+ unsearched.crossOriginFrames && 'cross-origin iframes',
981
+ unsearched.embeds && '<object>/<embed> documents',
982
+ ].filter(Boolean);
983
+ if (places.length === 0)
984
+ return '';
985
+ return joinLines(`The page has ${places.join(' and ')}, which are not searched.`, unsearched.crossOriginFrames ? framesHelp : undefined);
986
+ }
987
+ /**
988
+ * "Did you mean" for a selector that is a single id or class.
989
+ *
990
+ * @param kind - Id or class
991
+ * @param names - Similar names on the page
992
+ * @returns e.g. `Did you mean #remove-backpack? (similar id on the page)`; empty without names
993
+ */
994
+ export function similarSelectorsLine(kind, names) {
995
+ if (names.length === 0)
996
+ return '';
997
+ const sigil = kind === 'id' ? '#' : '.';
998
+ const what = kind === 'id' ? 'id' : 'class';
999
+ const plural = names.length === 1 ? what : kind === 'id' ? 'ids' : 'classes';
1000
+ return `Did you mean ${names.map((name) => sigil + name).join(', ')}? (similar ${plural} on the page)`;
1001
+ }
1002
+ /**
1003
+ * No nodes found for selector.
1004
+ *
1005
+ * @param selector - Selector as given
1006
+ * @param context - What the page says about it (hidden matches, readyState, unsearched content, similar names)
1007
+ */
1008
+ export function noNodesFoundError(selector, context = {}) {
1009
+ const hiddenMatches = context.hidden ?? 0;
1010
+ const hidden = hiddenMatches > 0
1011
+ ? hiddenMatches === 1
1012
+ ? '1 element matches without :visible but is hidden (check with bdg dom layout). '
1013
+ : `${hiddenMatches} elements match without :visible but are hidden (check with bdg dom layout). `
1014
+ : '';
1015
+ const note = unreachableElementsNote(selector, context.unsearched);
1016
+ return {
1017
+ message: `No nodes found matching "${selector}"`,
1018
+ suggestion: withLoadingHint(joinLines(context.similar, `${hidden}Verify the CSS selector is correct.`, note ? note : undefined), context.readyState, selector),
1019
+ };
1020
+ }
1021
+ /**
1022
+ * Quote a value for a POSIX shell command line.
1023
+ *
1024
+ * @param value - Value
1025
+ * @returns The value in single quotes
1026
+ */
1027
+ function shellQuote(value) {
1028
+ return `'${value.split("'").join(`'\\''`)}'`;
1029
+ }
1030
+ /** Edge of the page in each direction */
1031
+ const SCROLL_EDGES = { up: 'top', down: 'bottom', left: 'left edge', right: 'right edge' };
1032
+ /**
1033
+ * Warning of `bdg dom scroll` when the page did not move, with the
1034
+ * still-loading hint while the document is not complete (it may grow).
1035
+ *
1036
+ * @param effect - Why nothing scrolled
1037
+ * @returns e.g. `Nothing to scroll: the document is no taller than the viewport (993px)`
1038
+ */
1039
+ export function scrollNoEffectWarning(effect) {
1040
+ const vertical = effect.direction === 'up' || effect.direction === 'down';
1041
+ const reasons = {
1042
+ 'too-small': `Nothing to scroll: the document is no ${vertical ? 'taller' : 'wider'} than the viewport (${effect.viewport}px)`,
1043
+ 'at-edge': `Nothing scrolled: the page is already at the ${SCROLL_EDGES[effect.direction]}`,
1044
+ locked: 'Nothing scrolled although the page is larger than the viewport; its scrolling may be locked (e.g. overflow: hidden while a dialog is open)',
1045
+ };
1046
+ const loading = effect.readyState === 'complete' ? undefined : pageStillLoadingHint(effect.readyState);
1047
+ return [reasons[effect.reason], loading].filter(Boolean).join('. ');
1048
+ }
1049
+ /**
1050
+ * Hint for something not found while the page has not finished loading.
1051
+ *
1052
+ * @param readyState - The page's `document.readyState` (not `complete`)
1053
+ * @param selector - Selector that matched nothing, if any
1054
+ * @returns e.g. `The page is still loading (document.readyState: loading); wait for the element with: bdg dom wait '#login'`
1055
+ */
1056
+ export function pageStillLoadingHint(readyState, selector) {
1057
+ const wait = selector !== undefined && selector.trim() !== ''
1058
+ ? `wait for the element with: ${sessionCommand(`bdg dom wait ${shellQuote(selector)}`)}`
1059
+ : `wait for it with: ${sessionCommand('bdg dom wait --load')}`;
1060
+ return `The page is still loading (document.readyState: ${readyState}); ${wait}`;
1061
+ }
1062
+ /**
1063
+ * Put the still-loading hint before a "not found" suggestion when the page
1064
+ * has not finished loading.
1065
+ *
1066
+ * @param suggestion - Suggestion of the error
1067
+ * @param readyState - The page's `document.readyState`, if known
1068
+ * @param selector - Selector that matched nothing, if any
1069
+ * @returns The suggestion, with the hint first while the page loads
1070
+ */
1071
+ export function withLoadingHint(suggestion, readyState, selector) {
1072
+ if (readyState === undefined || readyState === 'complete')
1073
+ return suggestion;
1074
+ return joinLines(pageStillLoadingHint(readyState, selector), suggestion || undefined);
1075
+ }
1076
+ /**
1077
+ * `bdg dom wait` without a selector or --load, or with --text/--gone but no selector.
1078
+ *
1079
+ * @returns Message and suggestion
1080
+ */
1081
+ export function waitTargetRequiredError() {
1082
+ return {
1083
+ message: 'dom wait needs a selector (--text and --gone apply to its matches), or --load',
1084
+ suggestion: `e.g. ${sessionCommand("bdg dom wait '#result' --visible")}, ${sessionCommand("bdg dom wait body --text 'Welcome'")} or ${sessionCommand('bdg dom wait --load')}`,
1085
+ };
1086
+ }
1087
+ /**
1088
+ * `bdg dom wait` that ran out of time: what it waited for and what the page
1089
+ * showed last, with a next step that fits.
1090
+ *
1091
+ * @param condition - What was waited for
1092
+ * @param snapshot - Last thing the page reported (none when it never answered)
1093
+ * @param timeoutMs - The --timeout
1094
+ * @returns Message and suggestion
1095
+ */
1096
+ export function waitTimeoutError(condition, snapshot, timeoutMs) {
1097
+ const seen = snapshot
1098
+ ? `last seen: ${waitSnapshotSummary(snapshot, condition)}`
1099
+ : 'the page did not answer';
1100
+ return {
1101
+ message: `Timed out after ${formatDuration(timeoutMs)} waiting for ${waitGoal(condition)} (${seen})`,
1102
+ suggestion: waitTimeoutSuggestion(condition, snapshot),
1103
+ };
1104
+ }
1105
+ /**
1106
+ * What `bdg dom wait` waits for, as a phrase.
1107
+ *
1108
+ * @param condition - What is waited for
1109
+ * @returns e.g. `#finish to be visible` or `the page to load`
1110
+ */
1111
+ function waitGoal(condition) {
1112
+ if (condition.selector === undefined)
1113
+ return 'the page to load';
1114
+ const state = condition.gone
1115
+ ? condition.visible
1116
+ ? 'to be hidden'
1117
+ : 'to be gone'
1118
+ : condition.visible
1119
+ ? 'to be visible'
1120
+ : 'to appear';
1121
+ return `${waitTargetLabel(condition)} ${state}${condition.load ? ' and the page to load' : ''}`;
1122
+ }
1123
+ /**
1124
+ * Next step after a `bdg dom wait` timeout.
1125
+ *
1126
+ * @param condition - What was waited for
1127
+ * @param snapshot - Last thing the page reported
1128
+ * @returns Suggestion
1129
+ */
1130
+ function waitTimeoutSuggestion(condition, snapshot) {
1131
+ const more = 'allow more time with --timeout <ms>';
1132
+ const selector = condition.selector;
1133
+ if (snapshot && snapshot.readyState !== 'complete') {
1134
+ return `The page is still loading; see the requests it waits on with ${sessionCommand('bdg peek')}, or ${more}`;
1135
+ }
1136
+ if (!snapshot ||
1137
+ selector === undefined ||
1138
+ condition.gone ||
1139
+ countedMatches(snapshot, condition) > 0) {
1140
+ return `Check the page with ${sessionCommand('bdg peek')}, or ${more}`;
1141
+ }
1142
+ if (snapshot.count === 0) {
1143
+ return `Check the selector with ${sessionCommand(`bdg dom query ${shellQuote(selector)}`)}, or ${more}`;
1144
+ }
1145
+ if (snapshot.textCount === 0) {
1146
+ return `The matches do not contain the text; see what they say with ${sessionCommand(`bdg dom query ${shellQuote(selector)}`)}`;
1147
+ }
1148
+ return `The matches are hidden; see why with ${sessionCommand(`bdg dom layout ${shellQuote(selector)}`)}, or ${more}`;
1149
+ }
1150
+ /**
1151
+ * Element not visible/rendered.
1152
+ */
1153
+ export function elementNotVisibleError() {
1154
+ return {
1155
+ message: 'Element is not rendered (e.g. display: none), so it has no area to capture',
1156
+ suggestion: 'Make it visible first, or capture a visible ancestor',
1157
+ };
1158
+ }
1159
+ /**
1160
+ * Element has zero dimensions.
1161
+ */
1162
+ export function elementZeroDimensionsError() {
1163
+ return {
1164
+ message: 'Element has zero width or height, so there is nothing to capture',
1165
+ suggestion: 'It may be collapsed or empty; capture a visible ancestor instead',
1166
+ };
1167
+ }
1168
+ /**
1169
+ * Missing required argument.
1170
+ */
1171
+ export function missingArgumentError(usage) {
1172
+ return {
1173
+ message: 'Missing required argument or flag',
1174
+ suggestion: usage,
1175
+ };
1176
+ }
1177
+ /**
1178
+ * Either/or argument required.
1179
+ */
1180
+ export function eitherArgumentRequiredError(arg1, arg2, example) {
1181
+ return {
1182
+ message: `Either ${arg1} or ${arg2} must be provided`,
1183
+ suggestion: example,
1184
+ };
1185
+ }
1186
+ /**
1187
+ * Invalid query pattern.
1188
+ */
1189
+ export function invalidQueryPatternError(pattern) {
1190
+ return {
1191
+ message: 'Query pattern must specify at least one field',
1192
+ suggestion: `Received: "${pattern}". Try: bdg dom a11y query role=button, or ${A11Y_NAME_QUERY_EXAMPLE}`,
1193
+ };
1194
+ }
1195
+ /**
1196
+ * A file to upload does not exist.
1197
+ *
1198
+ * @param file - Path that was not found
1199
+ */
1200
+ export function fileNotFoundError(file) {
1201
+ return {
1202
+ message: `File not found: ${file}`,
1203
+ suggestion: 'Relative paths are resolved against the directory you run bdg in; separate several files with commas',
1204
+ };
1205
+ }
1206
+ /**
1207
+ * A directory given for a file input.
1208
+ *
1209
+ * @param file - Resolved path
1210
+ */
1211
+ export function uploadDirectoryError(file) {
1212
+ return {
1213
+ message: `Not a file: ${file} is a directory`,
1214
+ suggestion: 'Give the path of a file inside it',
1215
+ };
1216
+ }
1217
+ /**
1218
+ * Several files given for a file input that accepts one.
1219
+ *
1220
+ * @param count - Number of files given
1221
+ */
1222
+ export function singleFileInputError(count) {
1223
+ return {
1224
+ message: `This file input accepts a single file (${count} given)`,
1225
+ suggestion: 'Pass one path; only inputs with the "multiple" attribute take a comma-separated list',
1226
+ };
1227
+ }
1228
+ /**
1229
+ * Unknown field in an a11y query pattern.
1230
+ *
1231
+ * @param field - The unrecognized key
1232
+ * @param similar - A known field it looks like a typo of
1233
+ * @param value - The `name=…`/`description=…` field that absorbed it
1234
+ */
1235
+ export function unknownQueryFieldError(field, similar, value) {
1236
+ const usage = "Use role, name or description, e.g. bdg dom a11y query 'role=button name=Sign in'. Quote the whole pattern for the shell; a name with spaces or colons goes last ('name=E-mail address:') or in inner quotes ('name=\"Role: admin\" role=textbox')";
1237
+ if (!similar)
1238
+ return { message: `Unknown query field: "${field}"`, suggestion: usage };
1239
+ const [key = '', ...text] = (value ?? '').split('=');
1240
+ return {
1241
+ message: `Unknown query field: "${field}" (did you mean "${similar}"?)`,
1242
+ suggestion: `Fix the field name, e.g. ${similar}=…; if the ${key} really contains "${field}:", put it in inner quotes: '${key}="${text.join('=')}"'`,
1243
+ };
1244
+ }
1245
+ /**
1246
+ * No a11y nodes matching pattern.
1247
+ */
1248
+ export function noA11yNodesFoundError(pattern) {
1249
+ return {
1250
+ message: 'No nodes found matching pattern',
1251
+ suggestion: `Pattern: ${pattern}. Try a broader query or use "bdg dom a11y tree" to see all elements`,
1252
+ };
1253
+ }
1254
+ /**
1255
+ * An element that exists but has no node in the accessibility tree.
1256
+ *
1257
+ * @param target - Selector or index the user gave
1258
+ * @param reasons - Why Chrome leaves it out
1259
+ */
1260
+ export function notInAccessibilityTreeError(target, reasons) {
1261
+ return {
1262
+ message: `${target} exists but is not in the accessibility tree${reasons.length ? ` (${reasons.join('; ')})` : ''}`,
1263
+ suggestion: `Screen readers skip it. Inspect its HTML instead: bdg dom get ${/^\d+$/.test(target) ? target : `'${target}'`}`,
1264
+ };
1265
+ }
1266
+ /**
1267
+ * Fillable element not found.
1268
+ */
1269
+ export function fillableElementNotFoundError(selector) {
1270
+ return {
1271
+ message: `Element not found: ${selector}`,
1272
+ suggestion: 'Verify the selector matches a fillable element (input, textarea, select)',
1273
+ };
1274
+ }
1275
+ /** Appended to the element type when an action went to a label's control. */
1276
+ export const VIA_LABEL_SUFFIX = ' (via label)';
1277
+ /** Placeholder for the shell-quoted `name=…` field in {@link LABEL_WITHOUT_CONTROL}. */
1278
+ export const NAME_QUERY_PLACEHOLDER = '{nameQuery}';
1279
+ /**
1280
+ * Filling a `<label>` that has no form control (used by the page script,
1281
+ * which puts the label's quoted `name=<text>` in place of
1282
+ * {@link NAME_QUERY_PLACEHOLDER}).
1283
+ */
1284
+ export const LABEL_WITHOUT_CONTROL = {
1285
+ message: 'Element is not fillable (a <label> not associated with a form control)',
1286
+ suggestion: `Find the field by its accessible name: bdg dom a11y query ${NAME_QUERY_PLACEHOLDER}, or list the form fields: bdg dom form`,
1287
+ };
1288
+ /**
1289
+ * Why `dom fill` refused an element (used by the page script, which adds the
1290
+ * cause in parentheses, e.g. `The element is read-only (contenteditable="false")`).
1291
+ * All are invalid targets (exit 81), like any element that is not fillable.
1292
+ */
1293
+ export const FILL_REFUSALS = {
1294
+ disabled: {
1295
+ message: 'The element is disabled',
1296
+ suggestion: 'Enable the field first (it may depend on another input)',
1297
+ },
1298
+ readOnly: {
1299
+ message: 'The element is read-only',
1300
+ suggestion: 'A user cannot change it either; the page has to make it editable first',
1301
+ },
1302
+ inert: {
1303
+ message: 'The element is inert',
1304
+ suggestion: 'The page made it non-interactive (often behind a dialog); close what covers it first',
1305
+ },
1306
+ notFillable: {
1307
+ message: 'Element is not fillable',
1308
+ suggestion: 'Only input, textarea, select, and contenteditable elements can be filled',
1309
+ },
1310
+ };
1311
+ /**
1312
+ * Clickable element not found.
1313
+ */
1314
+ export function clickableElementNotFoundError(selector) {
1315
+ return {
1316
+ message: `Element not found: ${selector}`,
1317
+ suggestion: 'Verify the selector matches a clickable element',
1318
+ };
1319
+ }
1320
+ /**
1321
+ * Click target disappeared between locating and clicking it.
1322
+ */
1323
+ export function clickTargetDetachedError(selector) {
1324
+ return {
1325
+ message: `Element was removed before it could be clicked: ${selector}`,
1326
+ suggestion: 'The page changed during the click; wait for it to settle and retry',
1327
+ };
1328
+ }
1329
+ /**
1330
+ * Key press failed.
1331
+ */
1332
+ export function keyPressFailedError(details) {
1333
+ return {
1334
+ message: 'Failed to press key',
1335
+ suggestion: details,
1336
+ };
1337
+ }
1338
+ /**
1339
+ * A `bdg dom eval` script ran too long and was terminated.
1340
+ *
1341
+ * @param timeoutMs - Time limit in ms
1342
+ * @returns Error with suggestion
1343
+ */
1344
+ export function scriptTimeoutError(timeoutMs) {
1345
+ return {
1346
+ message: `Script did not finish within ${Math.round(timeoutMs / 1000)}s and was terminated`,
1347
+ suggestion: 'Check for endless loops or long-running work; the page is usable again',
1348
+ };
1349
+ }
1350
+ /**
1351
+ * The page (or an iframe) was kept busy by a script (e.g. a loop started
1352
+ * from a timer) and bdg terminated it.
1353
+ *
1354
+ * @param timeoutMs - Time waited
1355
+ * @param scope - What was busy: the page, or the iframe a command ran in
1356
+ */
1357
+ export function pageBusyError(timeoutMs, scope = 'page', recovered = true) {
1358
+ const busy = `The ${scope} was busy for ${Math.round(timeoutMs / 1000)}s (a script kept it running)`;
1359
+ if (!recovered) {
1360
+ return {
1361
+ message: `${busy} and its scripts could not be stopped`,
1362
+ suggestion: 'Retry in a moment; if it stays busy, reload the page: bdg page reload',
1363
+ };
1364
+ }
1365
+ return {
1366
+ message: `${busy}, so its scripts were terminated`,
1367
+ suggestion: `The ${scope} is usable again; re-run the command`,
1368
+ };
1369
+ }
1370
+ /**
1371
+ * The page did not answer because a navigation is still waiting for the
1372
+ * server (Chrome holds commands for the page until the new document arrives).
1373
+ *
1374
+ * @param url - URL being loaded
1375
+ */
1376
+ export function navigationPendingError(url) {
1377
+ return {
1378
+ message: `The page is not answering: it is still waiting for the server to respond to ${url}`,
1379
+ suggestion: 'Wait for the page to load, or load another one: bdg page navigate <url>',
1380
+ };
1381
+ }
1382
+ /**
1383
+ * `dom eval` given an empty script (often a shell variable that was not set).
1384
+ */
1385
+ export function emptyScriptError() {
1386
+ return {
1387
+ message: 'The script is empty',
1388
+ suggestion: `Pass an expression, e.g. bdg dom eval 'document.title'`,
1389
+ };
1390
+ }
1391
+ /**
1392
+ * A promise returned by `dom eval` that did not settle in time.
1393
+ *
1394
+ * @param timeoutMs - Time waited
1395
+ */
1396
+ export function promiseTimeoutError(timeoutMs) {
1397
+ return {
1398
+ message: `The awaited promise did not settle within ${Math.round(timeoutMs / 1000)}s`,
1399
+ suggestion: 'Nothing was busy; check that the promise resolves or rejects, or race it with a timeout in the script',
1400
+ };
1401
+ }
1402
+ /** How to see the frames `--frame` accepts */
1403
+ const LIST_FRAMES_HINT = 'List frames: bdg dom frames';
1404
+ /**
1405
+ * `dom eval --frame` given an empty frame.
1406
+ */
1407
+ export function emptyFrameError() {
1408
+ return {
1409
+ message: 'The frame is empty',
1410
+ suggestion: `Pass an index, a name/id attribute, or part of the name, id or URL. ${LIST_FRAMES_HINT}`,
1411
+ };
1412
+ }
1413
+ /**
1414
+ * `dom eval --frame` matching no iframe.
1415
+ *
1416
+ * @param query - Requested frame
1417
+ * @param frames - Frames of the page
1418
+ */
1419
+ export function frameNotFoundError(query, frames) {
1420
+ if (frames.length === 0) {
1421
+ return { message: `Frame not found: ${query}`, suggestion: 'The page has no iframes' };
1422
+ }
1423
+ return {
1424
+ message: `Frame not found: ${query}`,
1425
+ suggestion: joinLines('Available frames:', ...frames.map((frame) => ` ${frameLabel(frame)}`)),
1426
+ };
1427
+ }
1428
+ /**
1429
+ * `dom eval --frame` matching more than one iframe.
1430
+ *
1431
+ * @param query - Requested frame
1432
+ * @param candidates - Matching frames
1433
+ */
1434
+ export function ambiguousFrameError(query, candidates) {
1435
+ return {
1436
+ message: `Frame "${query}" matches ${candidates.length} frames`,
1437
+ suggestion: joinLines('Pick one by index, or a longer part of the name, id or URL:', ...candidates.map((frame) => ` ${frameLabel(frame)}`)),
1438
+ };
1439
+ }
1440
+ /**
1441
+ * An iframe without a JavaScript context (still loading, or gone).
1442
+ *
1443
+ * @param url - Frame URL
1444
+ */
1445
+ export function frameNotReadyError(url) {
1446
+ return {
1447
+ message: `The frame has no JavaScript context: ${frameUrlLabel(url)}`,
1448
+ suggestion: `Wait for it to load and retry, or re-run bdg dom frames: the frame may no longer exist`,
1449
+ };
1450
+ }
1451
+ /**
1452
+ * The iframe a `dom eval --frame` script ran in navigated before it finished.
1453
+ *
1454
+ * @param url - Frame URL when the script started
1455
+ */
1456
+ export function frameNavigatedDuringEvalError(url) {
1457
+ return {
1458
+ message: `The frame navigated while the script ran: ${frameUrlLabel(url)}`,
1459
+ suggestion: 'The result was lost with the old document; re-run the script once the frame has loaded. List frames: bdg dom frames',
1460
+ };
1461
+ }
1462
+ /**
1463
+ * The iframe a `dom eval --frame` script ran in was removed (or vanished
1464
+ * before it started).
1465
+ *
1466
+ * @param url - Frame URL when the script started
1467
+ */
1468
+ export function frameRemovedDuringEvalError(url) {
1469
+ return {
1470
+ message: `The frame was removed before the script finished: ${frameUrlLabel(url)}`,
1471
+ suggestion: 'The frame no longer exists; re-run bdg dom frames to see the current ones',
1472
+ };
1473
+ }
1474
+ /**
1475
+ * The page (its tab) was closed while a `dom eval` script ran.
1476
+ */
1477
+ export function pageClosedDuringEvalError() {
1478
+ return {
1479
+ message: 'The page was closed while the script ran',
1480
+ suggestion: 'Its tab is gone; start a new session with: bdg <url>',
1481
+ };
1482
+ }
1483
+ /**
1484
+ * The iframe a `dom eval --frame` script ran in went away, and bdg could not
1485
+ * tell whether it navigated or was removed.
1486
+ *
1487
+ * @param url - Frame URL when the script started
1488
+ */
1489
+ export function frameLostDuringEvalError(url) {
1490
+ return {
1491
+ message: `The frame navigated or was removed while the script ran: ${frameUrlLabel(url)}`,
1492
+ suggestion: 'Re-run bdg dom frames to see the current frames, then the script',
1493
+ };
1494
+ }
1495
+ /**
1496
+ * The page navigated while a `dom eval` script ran (e.g. it set
1497
+ * `location.href` and then awaited).
1498
+ */
1499
+ export function pageNavigatedDuringEvalError() {
1500
+ return {
1501
+ message: 'The page navigated while the script ran',
1502
+ suggestion: 'The result was lost with the old document; re-run the script on the new page (navigate with: bdg page navigate <url>)',
1503
+ };
1504
+ }
1505
+ /** `Identifier 'x' has already been declared` */
1506
+ const REDECLARED_PATTERN = /^SyntaxError: Identifier '([\w$]+)' has already been declared/;
1507
+ /**
1508
+ * Tip for a top-level `const`/`let` whose name the page or the script itself
1509
+ * already declares (`dom eval` runs like the console: names persist between
1510
+ * calls, and a page's own top-level `let`/`const`/`class` cannot be declared again).
1511
+ *
1512
+ * @param name - The redeclared identifier
1513
+ * @returns Tip
1514
+ */
1515
+ function redeclarationTip(name) {
1516
+ return [
1517
+ `'${name}' is already declared at the top level, by the page or earlier in this script.`,
1518
+ `Rename it, or wrap the script in a block so its names stay local: ${sessionCommand(`bdg dom eval '{ const ${name} = ...; ${name} }'`)}`,
1519
+ ].join('\n');
1520
+ }
1521
+ /**
1522
+ * Script execution error with shell quote detection.
1523
+ *
1524
+ * Shows the script as received to help diagnose shell quote stripping issues.
1525
+ * Detects common patterns like `querySelector(input)` that indicate shell damage.
1526
+ *
1527
+ * @param errorMessage - The JavaScript error message
1528
+ * @param receivedScript - The script as received by the command (optional for backwards compat)
1529
+ * @returns Error with context-aware suggestions
1530
+ */
1531
+ export function scriptExecutionError(errorMessage, receivedScript) {
1532
+ if (!receivedScript) {
1533
+ return {
1534
+ message: errorMessage,
1535
+ suggestion: 'Check JavaScript syntax and ensure the expression is valid',
1536
+ };
1537
+ }
1538
+ const quoteCheck = detectScriptQuoteDamage(receivedScript, errorMessage);
1539
+ const redeclared = REDECLARED_PATTERN.exec(errorMessage)?.[1];
1540
+ const truncatedScript = receivedScript.length > 100 ? receivedScript.slice(0, 100) + '...' : receivedScript;
1541
+ const lines = [];
1542
+ lines.push(`Script received: ${truncatedScript}`);
1543
+ if (quoteCheck.damaged) {
1544
+ lines.push('');
1545
+ lines.push('Shell quote damage detected:');
1546
+ if (quoteCheck.details) {
1547
+ lines.push(` ${quoteCheck.details}`);
1548
+ }
1549
+ if (quoteCheck.suggestion) {
1550
+ lines.push('');
1551
+ lines.push(quoteCheck.suggestion);
1552
+ }
1553
+ }
1554
+ else if (redeclared) {
1555
+ lines.push('');
1556
+ lines.push(redeclarationTip(redeclared));
1557
+ }
1558
+ else if (/^SyntaxError\b/.test(errorMessage)) {
1559
+ lines.push('');
1560
+ lines.push('Tips:');
1561
+ lines.push(" - Use single quotes around script: bdg dom eval '...'");
1562
+ lines.push(' - For complex scripts, read them from a file: bdg dom eval "$(cat script.js)"');
1563
+ lines.push(' - Escape inner quotes: \\" or use opposite quote style');
1564
+ }
1565
+ return {
1566
+ message: errorMessage,
1567
+ suggestion: lines.join('\n'),
1568
+ };
1569
+ }
1570
+ /**
1571
+ * Unexpected CDP response format.
1572
+ */
1573
+ export function unexpectedResponseFormatError(context) {
1574
+ return {
1575
+ message: 'Unexpected response format',
1576
+ suggestion: `CDP response missing result.value or invalid ${context} structure`,
1577
+ };
1578
+ }
1579
+ /**
1580
+ * Generic operation failure with dynamic error message.
1581
+ */
1582
+ export function operationFailedError(operation, errorMessage) {
1583
+ return {
1584
+ message: `Failed to ${operation}`,
1585
+ suggestion: errorMessage,
1586
+ };
1587
+ }
1588
+ /**
1589
+ * The browser does not offer `DOMDebugger.getEventListeners` (non-Chrome
1590
+ * targets, or browsers that disable the DOMDebugger domain).
1591
+ *
1592
+ * @param detail - Chrome's error
1593
+ * @returns Message and suggestion
1594
+ */
1595
+ export function eventListenersUnavailableError(detail) {
1596
+ return {
1597
+ message: `This browser cannot list event listeners (DOMDebugger.getEventListeners: ${detail})`,
1598
+ suggestion: 'Use a Chromium-based browser (Chrome, Edge) that supports the DOMDebugger domain',
1599
+ };
1600
+ }
1601
+ /**
1602
+ * Internal error (should not happen in normal usage).
1603
+ */
1604
+ export function internalError(context) {
1605
+ return {
1606
+ message: context,
1607
+ suggestion: 'This is an internal error - please report this issue',
1608
+ };
1609
+ }
1610
+ /**
1611
+ * No forms found on page.
1612
+ */
1613
+ export function noFormsFoundError(readyState) {
1614
+ const check = 'Check if forms exist with: bdg dom query "form, input, [role=textbox]" or inspect the page manually';
1615
+ if (readyState === undefined || readyState === 'complete') {
1616
+ return { message: 'No forms discovered on the page', suggestion: check };
1617
+ }
1618
+ return {
1619
+ message: 'No forms discovered on the page yet; it is still loading',
1620
+ suggestion: joinLines(pageStillLoadingHint(readyState), check),
1621
+ };
1622
+ }
1623
+ /**
1624
+ * The form discovery script threw.
1625
+ *
1626
+ * @param detail - What it threw, e.g. `TypeError: Cannot read properties of null`
1627
+ * @param readyState - The page's `document.readyState`, when known
1628
+ * @returns Message and suggestion (the still-loading hint while the page loads)
1629
+ */
1630
+ export function formDiscoveryFailedError(detail, readyState) {
1631
+ if (readyState !== undefined && readyState !== 'complete') {
1632
+ return {
1633
+ message: `Form discovery failed while the page is still loading (${detail})`,
1634
+ suggestion: pageStillLoadingHint(readyState),
1635
+ };
1636
+ }
1637
+ return {
1638
+ message: `Form discovery failed: ${detail}`,
1639
+ suggestion: `The page changed or threw while it was read; retry, or look at the fields with ${sessionCommand('bdg dom query "form, input, select, textarea"')}`,
1640
+ };
1641
+ }
1642
+ /**
1643
+ * Form in iframe (cross-origin or same-origin).
1644
+ */
1645
+ export function formInIframeError(iframeUrl, crossOrigin) {
1646
+ return {
1647
+ message: `${crossOrigin ? 'The form may be' : 'The form is'} inside an iframe: ${iframeUrl}`,
1648
+ suggestion: crossOrigin
1649
+ ? 'Cross-origin iframes cannot be read or controlled; open the iframe URL directly: bdg <iframe url>'
1650
+ : 'dom form lists forms of the main document only; its fields are reachable directly: bdg dom query "input, select, textarea", then bdg dom fill <index> <value>',
1651
+ };
1652
+ }
1653
+ //# sourceMappingURL=messages.js.map