browser-debugger-cli 0.8.0 → 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 (251) hide show
  1. package/README.md +4 -1
  2. package/dist/cdp/schema.d.ts +4 -1
  3. package/dist/cdp/schema.js +48 -7
  4. package/dist/commands/cdp.js +3 -2
  5. package/dist/commands/cleanup.d.ts +11 -0
  6. package/dist/commands/cleanup.js +161 -57
  7. package/dist/commands/console.d.ts +20 -1
  8. package/dist/commands/console.js +57 -17
  9. package/dist/commands/details.js +3 -2
  10. package/dist/commands/dom/DomElementResolver.d.ts +10 -3
  11. package/dist/commands/dom/DomElementResolver.js +35 -17
  12. package/dist/commands/dom/a11y.d.ts +10 -0
  13. package/dist/commands/dom/a11y.js +27 -5
  14. package/dist/commands/dom/eval.d.ts +3 -1
  15. package/dist/commands/dom/eval.js +29 -4
  16. package/dist/commands/dom/form.js +16 -62
  17. package/dist/commands/dom/formInteraction.js +152 -113
  18. package/dist/commands/dom/formSummary.d.ts +49 -0
  19. package/dist/commands/dom/formSummary.js +180 -0
  20. package/dist/commands/dom/frames.d.ts +2 -1
  21. package/dist/commands/dom/frames.js +17 -2
  22. package/dist/commands/dom/get.d.ts +6 -5
  23. package/dist/commands/dom/get.js +92 -82
  24. package/dist/commands/dom/helpers/index.d.ts +1 -1
  25. package/dist/commands/dom/helpers/index.js +1 -1
  26. package/dist/commands/dom/helpers/query.d.ts +44 -17
  27. package/dist/commands/dom/helpers/query.js +244 -97
  28. package/dist/commands/dom/helpers/runElementCommand.d.ts +10 -2
  29. package/dist/commands/dom/helpers/runElementCommand.js +97 -30
  30. package/dist/commands/dom/helpers/screenshot.d.ts +4 -1
  31. package/dist/commands/dom/helpers/screenshot.js +164 -49
  32. package/dist/commands/dom/index.d.ts +3 -1
  33. package/dist/commands/dom/index.js +16 -6
  34. package/dist/commands/dom/layout.d.ts +14 -0
  35. package/dist/commands/dom/layout.js +54 -0
  36. package/dist/commands/dom/listeners.d.ts +5 -1
  37. package/dist/commands/dom/listeners.js +13 -3
  38. package/dist/commands/dom/query.js +2 -3
  39. package/dist/commands/dom/screenshot.d.ts +12 -2
  40. package/dist/commands/dom/screenshot.js +27 -3
  41. package/dist/commands/dom/semanticUtils.d.ts +6 -13
  42. package/dist/commands/dom/semanticUtils.js +15 -19
  43. package/dist/commands/dom/wait.d.ts +13 -0
  44. package/dist/commands/dom/wait.js +83 -0
  45. package/dist/commands/helpJson.js +2 -2
  46. package/dist/commands/network/list.js +4 -11
  47. package/dist/commands/optionBehaviors.js +112 -21
  48. package/dist/commands/page.d.ts +2 -1
  49. package/dist/commands/page.js +41 -5
  50. package/dist/commands/peek.js +4 -11
  51. package/dist/commands/sessions.d.ts +8 -0
  52. package/dist/commands/sessions.js +19 -0
  53. package/dist/commands/shared/CommandRunner.js +4 -4
  54. package/dist/commands/shared/dataFetcher.js +2 -2
  55. package/dist/commands/shared/followMode.d.ts +21 -1
  56. package/dist/commands/shared/followMode.js +29 -2
  57. package/dist/commands/shared/handleValidationError.d.ts +2 -2
  58. package/dist/commands/shared/handleValidationError.js +12 -3
  59. package/dist/commands/shared/optionTypes.d.ts +40 -5
  60. package/dist/commands/shared/startHelpers.js +12 -3
  61. package/dist/commands/shared/validation.d.ts +3 -2
  62. package/dist/commands/shared/validation.js +4 -3
  63. package/dist/commands/start.d.ts +63 -0
  64. package/dist/commands/start.js +115 -15
  65. package/dist/commands/status.js +29 -7
  66. package/dist/commands/stop.js +7 -6
  67. package/dist/commands/tail.js +4 -11
  68. package/dist/commands/types.d.ts +2 -0
  69. package/dist/commands.js +2 -0
  70. package/dist/connection/chromeIdentity.d.ts +65 -0
  71. package/dist/connection/chromeIdentity.js +143 -0
  72. package/dist/connection/launcher/profilePreferences.d.ts +47 -0
  73. package/dist/connection/launcher/profilePreferences.js +151 -0
  74. package/dist/connection/launcher.d.ts +21 -2
  75. package/dist/connection/launcher.js +42 -16
  76. package/dist/connection/portReservation.d.ts +14 -4
  77. package/dist/connection/portReservation.js +21 -6
  78. package/dist/connection/startupExit.d.ts +8 -0
  79. package/dist/connection/startupExit.js +15 -6
  80. package/dist/constants.d.ts +6 -2
  81. package/dist/constants.js +9 -2
  82. package/dist/daemon/SessionController.js +23 -7
  83. package/dist/daemon/errors.d.ts +1 -1
  84. package/dist/daemon/errors.js +1 -1
  85. package/dist/daemon/launcher.d.ts +2 -1
  86. package/dist/daemon/launcher.js +5 -6
  87. package/dist/daemon/server/SocketServer.js +1 -2
  88. package/dist/daemon/session/Session.d.ts +13 -0
  89. package/dist/daemon/session/Session.js +57 -8
  90. package/dist/daemon/session/chromeConnection.d.ts +9 -0
  91. package/dist/daemon/session/chromeConnection.js +45 -8
  92. package/dist/daemon/session/commandRegistry.js +52 -62
  93. package/dist/daemon/session/interactions.d.ts +35 -9
  94. package/dist/daemon/session/interactions.js +36 -9
  95. package/dist/daemon/session/triggeredRequests.d.ts +67 -0
  96. package/dist/daemon/session/triggeredRequests.js +157 -0
  97. package/dist/daemon/session/types.d.ts +5 -1
  98. package/dist/daemon.js +5393 -1600
  99. package/dist/errors/messages.d.ts +387 -24
  100. package/dist/errors/messages.js +761 -67
  101. package/dist/index.js +3976 -1558
  102. package/dist/ipc/client.d.ts +12 -1
  103. package/dist/ipc/client.js +22 -3
  104. package/dist/ipc/protocol/commands.d.ts +89 -4
  105. package/dist/ipc/protocol/commands.js +2 -0
  106. package/dist/ipc/protocol/domTypes.d.ts +258 -7
  107. package/dist/ipc/session/lifecycle.d.ts +8 -1
  108. package/dist/ipc/session/queries.d.ts +5 -1
  109. package/dist/ipc/session/types.d.ts +5 -0
  110. package/dist/ipc/transport/index.d.ts +2 -1
  111. package/dist/ipc/transport/index.js +2 -2
  112. package/dist/runtime/dom/actionEffects.d.ts +106 -0
  113. package/dist/runtime/dom/actionEffects.js +256 -0
  114. package/dist/runtime/dom/actionEffectsScripts.d.ts +52 -0
  115. package/dist/runtime/dom/actionEffectsScripts.js +234 -0
  116. package/dist/runtime/dom/elementGeometry.d.ts +170 -0
  117. package/dist/runtime/dom/elementGeometry.js +553 -0
  118. package/dist/runtime/dom/elementInfo.d.ts +77 -0
  119. package/dist/runtime/dom/elementInfo.js +191 -0
  120. package/dist/runtime/dom/evalHelpers.d.ts +51 -6
  121. package/dist/runtime/dom/evalHelpers.js +136 -26
  122. package/dist/runtime/dom/eventListeners.d.ts +2 -1
  123. package/dist/runtime/dom/eventListeners.js +174 -47
  124. package/dist/runtime/dom/formDiscovery.d.ts +1 -1
  125. package/dist/runtime/dom/formDiscovery.js +116 -16
  126. package/dist/runtime/dom/formFillHelpers/fill.d.ts +10 -0
  127. package/dist/runtime/dom/formFillHelpers/fill.js +125 -10
  128. package/dist/runtime/dom/formFillHelpers/index.d.ts +2 -2
  129. package/dist/runtime/dom/formFillHelpers/index.js +2 -2
  130. package/dist/runtime/dom/formFillHelpers/pressKey.js +14 -3
  131. package/dist/runtime/dom/formFillHelpers/scroll.d.ts +3 -0
  132. package/dist/runtime/dom/formFillHelpers/scroll.js +60 -18
  133. package/dist/runtime/dom/formFillHelpers/shared.d.ts +17 -0
  134. package/dist/runtime/dom/formFillHelpers/shared.js +25 -1
  135. package/dist/runtime/dom/formFillHelpers/stability.d.ts +20 -6
  136. package/dist/runtime/dom/formFillHelpers/stability.js +50 -19
  137. package/dist/runtime/dom/formSubmitHelpers.d.ts +3 -0
  138. package/dist/runtime/dom/formSubmitHelpers.js +89 -15
  139. package/dist/runtime/dom/frameLayout.d.ts +60 -0
  140. package/dist/runtime/dom/frameLayout.js +140 -0
  141. package/dist/runtime/dom/frameOrigin.d.ts +50 -0
  142. package/dist/runtime/dom/frameOrigin.js +62 -0
  143. package/dist/runtime/dom/frameScopedConnection.d.ts +92 -0
  144. package/dist/runtime/dom/frameScopedConnection.js +252 -0
  145. package/dist/runtime/dom/frameSelection.d.ts +1 -1
  146. package/dist/runtime/dom/frameSelection.js +2 -2
  147. package/dist/runtime/dom/frames.d.ts +25 -2
  148. package/dist/runtime/dom/frames.js +202 -63
  149. package/dist/runtime/dom/layout.d.ts +67 -0
  150. package/dist/runtime/dom/layout.js +333 -0
  151. package/dist/runtime/dom/listenerPageScripts.d.ts +66 -0
  152. package/dist/runtime/dom/listenerPageScripts.js +279 -0
  153. package/dist/runtime/dom/listenerSummary.d.ts +132 -11
  154. package/dist/runtime/dom/listenerSummary.js +344 -22
  155. package/dist/runtime/dom/pageActivity.d.ts +41 -0
  156. package/dist/runtime/dom/pageActivity.js +123 -0
  157. package/dist/runtime/dom/reactEventHelpers.d.ts +58 -2
  158. package/dist/runtime/dom/reactEventHelpers.js +212 -41
  159. package/dist/runtime/dom/targetNode.d.ts +80 -27
  160. package/dist/runtime/dom/targetNode.js +249 -33
  161. package/dist/runtime/dom/wait.d.ts +25 -0
  162. package/dist/runtime/dom/wait.js +199 -0
  163. package/dist/runtime/dom/waitCondition.d.ts +71 -0
  164. package/dist/runtime/dom/waitCondition.js +75 -0
  165. package/dist/runtime/page/emulation.d.ts +51 -0
  166. package/dist/runtime/page/emulation.js +80 -0
  167. package/dist/runtime/page/loadingState.d.ts +36 -0
  168. package/dist/runtime/page/loadingState.js +86 -0
  169. package/dist/runtime/page/navigation.d.ts +46 -2
  170. package/dist/runtime/page/navigation.js +69 -33
  171. package/dist/session/QueryCacheManager.d.ts +11 -1
  172. package/dist/session/QueryCacheManager.js +25 -3
  173. package/dist/session/chromeOwners.d.ts +34 -0
  174. package/dist/session/chromeOwners.js +51 -0
  175. package/dist/session/cleanup/staleSession.d.ts +11 -1
  176. package/dist/session/cleanup/staleSession.js +17 -6
  177. package/dist/session/cleanup/userCommands.js +2 -4
  178. package/dist/session/metadata.d.ts +5 -1
  179. package/dist/session/metadata.js +2 -1
  180. package/dist/session/paths.d.ts +77 -3
  181. package/dist/session/paths.js +111 -5
  182. package/dist/session/port.d.ts +31 -7
  183. package/dist/session/port.js +50 -43
  184. package/dist/session/portClaims.d.ts +66 -0
  185. package/dist/session/portClaims.js +284 -0
  186. package/dist/session/sessionList.d.ts +58 -0
  187. package/dist/session/sessionList.js +199 -0
  188. package/dist/session/sessionName.d.ts +46 -0
  189. package/dist/session/sessionName.js +97 -0
  190. package/dist/telemetry/a11y.d.ts +8 -3
  191. package/dist/telemetry/a11y.js +92 -28
  192. package/dist/telemetry/requestKinds.d.ts +32 -0
  193. package/dist/telemetry/requestKinds.js +61 -0
  194. package/dist/telemetry/requestState.d.ts +31 -0
  195. package/dist/telemetry/requestState.js +38 -0
  196. package/dist/types.d.ts +80 -3
  197. package/dist/ui/formatters/a11y.js +3 -0
  198. package/dist/ui/formatters/console/chronological.d.ts +8 -0
  199. package/dist/ui/formatters/console/chronological.js +17 -4
  200. package/dist/ui/formatters/console/json.js +3 -4
  201. package/dist/ui/formatters/console/shared.d.ts +12 -0
  202. package/dist/ui/formatters/console.d.ts +2 -2
  203. package/dist/ui/formatters/console.js +1 -1
  204. package/dist/ui/formatters/details.js +2 -1
  205. package/dist/ui/formatters/dom.d.ts +26 -14
  206. package/dist/ui/formatters/dom.js +65 -52
  207. package/dist/ui/formatters/form.js +29 -18
  208. package/dist/ui/formatters/layout.d.ts +31 -0
  209. package/dist/ui/formatters/layout.js +53 -0
  210. package/dist/ui/formatters/listeners.d.ts +3 -2
  211. package/dist/ui/formatters/listeners.js +73 -9
  212. package/dist/ui/formatters/networkHeaders.js +13 -0
  213. package/dist/ui/formatters/preview.js +2 -1
  214. package/dist/ui/formatters/requestStatus.d.ts +1 -17
  215. package/dist/ui/formatters/requestStatus.js +2 -30
  216. package/dist/ui/formatters/sessions.d.ts +12 -0
  217. package/dist/ui/formatters/sessions.js +40 -0
  218. package/dist/ui/formatters/status.d.ts +21 -2
  219. package/dist/ui/formatters/status.js +47 -10
  220. package/dist/ui/formatters/triggeredRequests.d.ts +36 -0
  221. package/dist/ui/formatters/triggeredRequests.js +65 -0
  222. package/dist/ui/formatting.d.ts +10 -0
  223. package/dist/ui/formatting.js +28 -36
  224. package/dist/ui/messages/chrome.d.ts +9 -0
  225. package/dist/ui/messages/chrome.js +17 -5
  226. package/dist/ui/messages/commands.d.ts +388 -14
  227. package/dist/ui/messages/commands.js +664 -21
  228. package/dist/ui/messages/consoleMessages.d.ts +10 -0
  229. package/dist/ui/messages/consoleMessages.js +17 -0
  230. package/dist/ui/messages/hints.js +2 -1
  231. package/dist/ui/messages/preview.js +5 -4
  232. package/dist/ui/messages/session.d.ts +16 -21
  233. package/dist/ui/messages/session.js +28 -26
  234. package/dist/ui/messages/sessionCommand.d.ts +43 -0
  235. package/dist/ui/messages/sessionCommand.js +52 -0
  236. package/dist/utils/async.d.ts +8 -0
  237. package/dist/utils/async.js +19 -0
  238. package/dist/utils/http.d.ts +22 -1
  239. package/dist/utils/http.js +28 -9
  240. package/dist/utils/selectorFilters.d.ts +36 -8
  241. package/dist/utils/selectorFilters.js +267 -53
  242. package/dist/utils/shellDetection.d.ts +8 -2
  243. package/dist/utils/shellDetection.js +120 -33
  244. package/dist/utils/suggestions.d.ts +26 -0
  245. package/dist/utils/suggestions.js +73 -0
  246. package/dist/utils/taskMappings.js +10 -0
  247. package/dist/utils/url.d.ts +12 -2
  248. package/dist/utils/url.js +69 -7
  249. package/package.json +1 -1
  250. package/dist/ui/formatters/sessionFormatters.d.ts +0 -58
  251. package/dist/ui/formatters/sessionFormatters.js +0 -121
@@ -3,9 +3,12 @@
3
3
  *
4
4
  * Centralized location for reusable error messages with consistent formatting.
5
5
  */
6
- import type { DomFrame } from '../ipc/protocol/commands.js';
6
+ import type { DomFrame, PendingRequestInfo } from '../ipc/protocol/commands.js';
7
+ import { type WaitCondition, type WaitSnapshot } from '../runtime/dom/waitCondition.js';
8
+ import type { DocumentRequestState, IndexSource } from '../types.js';
7
9
  /**
8
- * Generate "session already running" error message.
10
+ * Generate "session already running" error message (commands carry
11
+ * `--session` for a named session).
9
12
  *
10
13
  * @param pid - Process ID of running session
11
14
  * @param duration - Session duration in milliseconds
@@ -19,8 +22,19 @@ import type { DomFrame } from '../ipc/protocol/commands.js';
19
22
  * ```
20
23
  */
21
24
  export declare function sessionAlreadyRunningError(pid: number, duration: number, targetUrl?: string): string;
22
- /** What to do when `bdg <url>` finds a session already running */
23
- export declare const ALREADY_RUNNING_SUGGESTION = "Use the running session (bdg status), or stop it first: bdg stop && bdg <url>";
25
+ /**
26
+ * The daemon's one-line answer to `bdg <url>` while its session runs.
27
+ *
28
+ * @param pid - Daemon PID
29
+ * @returns Message
30
+ */
31
+ export declare function sessionAlreadyRunningMessage(pid: number): string;
32
+ /**
33
+ * What to do when `bdg <url>` finds the selected session already running.
34
+ *
35
+ * @returns Suggestion
36
+ */
37
+ export declare function alreadyRunningSuggestion(): string;
24
38
  /**
25
39
  * Human-readable description of a bdg-launched Chrome (as opposed to one
26
40
  * reached via `--chrome-ws-url`). Used in mismatch errors where the active
@@ -157,6 +171,15 @@ export interface ErrorWithSuggestion {
157
171
  * Index out of range error.
158
172
  */
159
173
  export declare function indexOutOfRangeError(index: number, max: number): ErrorWithSuggestion;
174
+ /** Finding elements by accessible name, quoted for the shell (the name may contain spaces and colons). */
175
+ export declare const A11Y_NAME_QUERY_EXAMPLE = "bdg dom a11y query 'name=\u2026'";
176
+ /**
177
+ * Empty (or blank) selector: the browser rejects it, so it is caught before
178
+ * any page script runs.
179
+ *
180
+ * @returns Message and suggestion
181
+ */
182
+ export declare function emptySelectorError(): ErrorWithSuggestion;
160
183
  /**
161
184
  * CSS selector rejected by the browser. Playwright-only syntax (`:text()`,
162
185
  * `>>`, `text=`) gets the filters bdg supports instead.
@@ -167,14 +190,59 @@ export declare function indexOutOfRangeError(index: number, max: number): ErrorW
167
190
  */
168
191
  export declare function invalidSelectorError(selector: string, detail?: string): ErrorWithSuggestion;
169
192
  /**
170
- * A text or visibility filter (`:has-text()`, `:text-is()`, `:visible`) that
171
- * is not at the end of a selector.
193
+ * A text or visibility filter (`:has-text()`, `:text-is()`, `:visible`)
194
+ * inside a pseudo-class other than `:has()`, e.g. `:not(:visible)`.
172
195
  *
173
196
  * @param selector - Selector as given
174
197
  * @param filter - The misplaced filter as written
175
198
  * @returns Message and suggestion
176
199
  */
177
200
  export declare function misplacedSelectorFilterError(selector: string, filter: string): ErrorWithSuggestion;
201
+ /**
202
+ * A sibling combinator (`+`, `~`) after a filtered compound: the rest of the
203
+ * selector is matched under the filtered element, so only descendant and
204
+ * child combinators can follow it.
205
+ *
206
+ * @param selector - Selector as given
207
+ * @param combinator - The combinator found
208
+ * @returns Message and suggestion
209
+ */
210
+ export declare function siblingAfterFilterError(selector: string, combinator: string): ErrorWithSuggestion;
211
+ /**
212
+ * A `:has()` with filters whose selector starts with a sibling combinator
213
+ * (`:has(+ a:visible)`): its matches are searched under the element, where
214
+ * siblings are not.
215
+ *
216
+ * @param selector - Selector as given
217
+ * @param combinator - `+` or `~`
218
+ * @returns Message and suggestion
219
+ */
220
+ export declare function siblingInHasError(selector: string, combinator: string): ErrorWithSuggestion;
221
+ /** How a selector with filters is malformed (before the browser sees it). */
222
+ declare const MALFORMED_SELECTOR_DETAILS: {
223
+ readonly 'empty-in-list': () => string;
224
+ readonly 'leading-combinator': (combinator: string) => string;
225
+ readonly 'trailing-combinator': () => string;
226
+ readonly 'empty-has': () => string;
227
+ readonly 'scope-in-has': () => string;
228
+ };
229
+ /**
230
+ * A selector with filters that is malformed in a way bdg detects while
231
+ * splitting it (so the error shows the selector as given, not rewritten CSS).
232
+ *
233
+ * @param selector - Selector as given
234
+ * @param problem - What is wrong
235
+ * @param combinator - The combinator, for `leading-combinator`
236
+ * @returns Message and suggestion
237
+ */
238
+ export declare function malformedSelectorError(selector: string, problem: keyof typeof MALFORMED_SELECTOR_DETAILS, combinator?: string): ErrorWithSuggestion;
239
+ /**
240
+ * `:has-text()` with empty text, which every element would match.
241
+ *
242
+ * @param selector - Selector as given
243
+ * @returns Message and suggestion
244
+ */
245
+ export declare function emptyTextFilterError(selector: string): ErrorWithSuggestion;
178
246
  /**
179
247
  * A text filter without its text, e.g. `:has-text` or `:text-is("x"`.
180
248
  *
@@ -214,6 +282,21 @@ export declare function emptyOutputPathError(extension?: string): ErrorWithSugge
214
282
  * Start options given without the URL to open.
215
283
  */
216
284
  export declare function missingStartUrlError(): ErrorWithSuggestion;
285
+ /**
286
+ * `--viewport` given something that is not a width and height.
287
+ *
288
+ * @param value - What was given
289
+ * @param max - Largest side accepted
290
+ */
291
+ export declare function invalidViewportError(value: string, max: number): ErrorWithSuggestion;
292
+ /**
293
+ * `--color-scheme` given another value than the ones it takes.
294
+ *
295
+ * @param value - What was given
296
+ * @param similar - Close matches
297
+ * @param schemes - Accepted values
298
+ */
299
+ export declare function invalidColorSchemeError(value: string, similar: string[], schemes: readonly string[]): ErrorWithSuggestion;
217
300
  /**
218
301
  * `-u` / `--user-data-dir` given something that is not a directory path.
219
302
  *
@@ -221,6 +304,34 @@ export declare function missingStartUrlError(): ErrorWithSuggestion;
221
304
  * @param reason - Why it cannot be used
222
305
  */
223
306
  export declare function invalidUserDataDirError(value: string, reason: string): ErrorWithSuggestion;
307
+ /**
308
+ * A `--session` / `BDG_SESSION` name bdg cannot use as a directory name.
309
+ *
310
+ * @param name - The rejected name
311
+ * @param maxLength - Longest allowed name
312
+ */
313
+ export declare function invalidSessionNameError(name: string, maxLength: number): ErrorWithSuggestion;
314
+ /**
315
+ * A session name whose daemon socket path would exceed the OS limit.
316
+ *
317
+ * @param name - Session name
318
+ * @param socketPath - Resulting socket path
319
+ * @param max - Longest socket path in bytes
320
+ */
321
+ export declare function sessionNameSocketTooLongError(name: string, socketPath: string, max: number): ErrorWithSuggestion;
322
+ /**
323
+ * `bdg cleanup --purge` without a named session (the default session's
324
+ * directory holds the named sessions).
325
+ */
326
+ export declare function purgeNeedsNamedSessionError(): ErrorWithSuggestion;
327
+ /**
328
+ * `bdg cleanup --purge` found the session still holding its directory after
329
+ * cleaning up, so the directory is kept.
330
+ *
331
+ * @param dir - Session directory
332
+ * @param reason - What still holds it
333
+ */
334
+ export declare function purgeRefusedError(dir: string, reason: string): ErrorWithSuggestion;
224
335
  /**
225
336
  * The session directory exists but is not a directory.
226
337
  *
@@ -248,6 +359,27 @@ export declare function socketPathTooLongError(socketPath: string, max: number):
248
359
  * @param secure - Whether a wss: URL was given
249
360
  */
250
361
  export declare function externalChromeUnreachableError(endpoint: string, secure: boolean): ErrorWithSuggestion;
362
+ /**
363
+ * Something answers on the `--chrome-ws-url` endpoint, but it is not Chrome's
364
+ * DevTools HTTP endpoint (e.g. a web server on that port).
365
+ *
366
+ * @param endpoint - e.g. http://127.0.0.1:3000
367
+ */
368
+ export declare function notDevToolsEndpointError(endpoint: string): ErrorWithSuggestion;
369
+ /**
370
+ * Another running bdg session uses the Chrome (or tab) `--chrome-ws-url`
371
+ * points to.
372
+ *
373
+ * @param endpoint - e.g. http://127.0.0.1:9222
374
+ * @param owner - The other session: name (null for a default session),
375
+ * directory, base directory and whether it launched that Chrome
376
+ */
377
+ export declare function chromeInUseBySessionError(endpoint: string, owner: {
378
+ name: string | null;
379
+ dir: string;
380
+ baseDir: string;
381
+ launched: boolean;
382
+ }): ErrorWithSuggestion;
251
383
  /**
252
384
  * The page id of a `--chrome-ws-url` page URL does not exist.
253
385
  *
@@ -272,8 +404,9 @@ export declare function chromeWsUrlConflictError(options: string[]): ErrorWithSu
272
404
  * A numeric index given together with `--index`.
273
405
  *
274
406
  * @param index - The index argument
407
+ * @param command - The `bdg dom` subcommand it was given to, e.g. "layout"
275
408
  */
276
- export declare function indexWithIndexOptionError(index: string): ErrorWithSuggestion;
409
+ export declare function indexWithIndexOptionError(index: string, command: string): ErrorWithSuggestion;
277
410
  /** Problems with `bdg dom scroll` options, and how to fix each */
278
411
  declare const SCROLL_PROBLEMS: {
279
412
  readonly 'index-without-selector': readonly ["--index requires a selector", "Use: bdg dom scroll \"selector\" --index 2"];
@@ -295,8 +428,15 @@ export declare function scrollOptionsError(problem: keyof typeof SCROLL_PROBLEMS
295
428
  * @param similar - Similar key names
296
429
  */
297
430
  export declare function unknownKeyError(keyName: string, similar: string[]): ErrorWithSuggestion;
298
- /** Where selectors cannot look, for "not found" errors */
299
- export declare const UNREACHABLE_ELEMENTS_HINT = "elements in closed shadow roots and cross-origin iframes cannot be reached";
431
+ /**
432
+ * `dom screenshot` given an element both as an argument and as an option,
433
+ * and they differ.
434
+ *
435
+ * @param option - The option and its value, e.g. `--selector #a`
436
+ * @param positional - The element argument
437
+ * @returns Message and suggestion
438
+ */
439
+ export declare function conflictingTargetError(option: string, positional: string): ErrorWithSuggestion;
300
440
  /**
301
441
  * Two options given together where one would be ignored.
302
442
  *
@@ -347,35 +487,185 @@ export declare function navigationFailedError(url: string, errorText: string): E
347
487
  * @param direction - back or forward
348
488
  */
349
489
  export declare function noHistoryEntryError(direction: 'back' | 'forward'): ErrorWithSuggestion;
490
+ /** What a submit was still waiting for when its wait ran out */
491
+ export interface SubmitBlockers {
492
+ /** The page request the submit sent, if any */
493
+ document?: DocumentRequestState | undefined;
494
+ /** Requests still running (the longest-running first) */
495
+ pending?: PendingRequestInfo[] | undefined;
496
+ /** All requests still running */
497
+ pendingCount?: number | undefined;
498
+ }
350
499
  /**
351
- * The form was submitted but the wait for its result timed out.
500
+ * The form was submitted but the wait for its result timed out. The message
501
+ * names what it was waiting on: the page request the submit sent (pending,
502
+ * answered with an error, failed; waiting for a navigation, also one that
503
+ * answered), or else the requests still running.
352
504
  *
353
505
  * @param timeout - Timeout in ms
354
506
  * @param waitNavigation - Whether a navigation was awaited
507
+ * @param blockers - The page request and the requests still running
508
+ * @returns e.g. `Form submitted, but timed out after 10000ms waiting for navigation: POST …/authenticate pending for 10s`
509
+ */
510
+ export declare function submitTimeoutError(timeout: number, waitNavigation: boolean, blockers?: SubmitBlockers): ErrorWithSuggestion;
511
+ /**
512
+ * Warning of a submit whose navigation happened but whose network was still
513
+ * busy when the wait ran out (the new page is there; a slow script or
514
+ * tracker kept loading).
515
+ *
516
+ * @param timeout - Timeout in ms
517
+ * @param pending - Requests still in flight
518
+ * @returns Warning text
355
519
  */
356
- export declare function submitTimeoutError(timeout: number, waitNavigation: boolean): ErrorWithSuggestion;
520
+ export declare function submitNetworkBusyWarning(timeout: number, pending: number): string;
357
521
  /**
358
522
  * No element has the given node id.
359
523
  *
360
524
  * @param nodeId - Backend node id given with --node-id
361
525
  */
362
526
  export declare function nodeIdNotFoundError(nodeId: number): ErrorWithSuggestion;
527
+ /**
528
+ * The list an index refers to, in words.
529
+ *
530
+ * @param source - Where the index comes from
531
+ * @returns e.g. `index 0 of the last dom query "h3"`, `index 2 of the last dom form`
532
+ */
533
+ export declare function indexSourceText(source: IndexSource): string;
534
+ /** Why an element's cross-origin iframe could not be placed in the page */
535
+ export type FrameMappingProblem = 'no-box' | 'rotated' | 'unreadable';
536
+ /**
537
+ * An element of a cross-origin iframe (from an a11y query) whose iframe
538
+ * could not be placed in the top-level viewport, so a mouse event or layout
539
+ * would land in the wrong place.
540
+ *
541
+ * @param problem - The iframe or element has no box, is rotated or skewed, or could not be read
542
+ * @param detail - Underlying error, if any
543
+ * @returns Message and suggestion
544
+ */
545
+ export declare function frameMappingError(problem: FrameMappingProblem, detail?: string): ErrorWithSuggestion;
363
546
  /**
364
547
  * A cached node is gone (page navigated or the element was removed).
365
548
  *
366
- * @param index - Index the user gave (query or form results), if any
549
+ * @param index - Index the user gave, if any
550
+ * @param source - The list the index refers to, when known
551
+ * @returns Message and suggestion
552
+ */
553
+ export declare function staleNodeError(index?: number, source?: IndexSource): ErrorWithSuggestion;
554
+ /**
555
+ * An index beyond the cached results.
556
+ *
557
+ * @param source - The index and the list it refers to
558
+ * @param count - Number of cached results
559
+ * @returns Message and suggestion
367
560
  */
368
- export declare function staleNodeError(index?: number): ErrorWithSuggestion;
561
+ export declare function cachedIndexOutOfRangeError(source: IndexSource, count: number): ErrorWithSuggestion;
369
562
  /**
370
- * Element at index not found (stale cache).
563
+ * Note for a form command (fill, submit) whose index refers to results of
564
+ * another command and hit an element it cannot act on.
565
+ *
566
+ * @param source - The index and the list it refers to
567
+ * @param preview - What the cached element is, e.g. `h3 "Welcome"`
568
+ * @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`
371
569
  */
372
- export declare function elementAtIndexNotFoundError(index: number, selector: string): ErrorWithSuggestion;
373
- /** Where selectors do not reach (open shadow roots and same-origin iframes are searched) */
374
- export declare const CROSS_ORIGIN_FRAMES_NOTE = "Elements inside cross-origin iframes and closed shadow roots are not searched";
570
+ export declare function otherIndexSourceNote(source: IndexSource, preview?: string): string;
571
+ /** What a page holds that selectors cannot search (a cheap page check) */
572
+ export interface UnsearchedContent {
573
+ /** Iframes whose document the page cannot read (cross-origin) */
574
+ crossOriginFrames: boolean;
575
+ /** `<object>`/`<embed>` elements */
576
+ embeds: boolean;
577
+ }
578
+ /**
579
+ * Where selectors do not reach (open shadow roots and same-origin iframes are
580
+ * searched), and how to reach an element in a cross-origin iframe instead.
581
+ * When the page was checked, only what it has is named (nothing when it has
582
+ * neither cross-origin iframes nor embeds; closed shadow roots cannot be
583
+ * detected).
584
+ *
585
+ * @param selector - Selector that matched nothing
586
+ * @param unsearched - What the page holds, when it was checked
587
+ * @returns Note for "not found" suggestions (empty when nothing applies)
588
+ */
589
+ export declare function unreachableElementsNote(selector: string, unsearched?: UnsearchedContent): string;
590
+ /**
591
+ * "Did you mean" for a selector that is a single id or class.
592
+ *
593
+ * @param kind - Id or class
594
+ * @param names - Similar names on the page
595
+ * @returns e.g. `Did you mean #remove-backpack? (similar id on the page)`; empty without names
596
+ */
597
+ export declare function similarSelectorsLine(kind: 'id' | 'class', names: string[]): string;
598
+ /** What the page says about a selector that matched nothing */
599
+ export interface NoMatchContext {
600
+ /** Elements only its `:visible` filters excluded */
601
+ hidden?: number;
602
+ /** The page's `document.readyState`, when known (a hint is added while it loads) */
603
+ readyState?: string;
604
+ /** What the page holds that selectors cannot search, when checked */
605
+ unsearched?: UnsearchedContent;
606
+ /** "Did you mean" line for a single id or class ({@link similarSelectorsLine}) */
607
+ similar?: string;
608
+ }
375
609
  /**
376
610
  * No nodes found for selector.
611
+ *
612
+ * @param selector - Selector as given
613
+ * @param context - What the page says about it (hidden matches, readyState, unsearched content, similar names)
614
+ */
615
+ export declare function noNodesFoundError(selector: string, context?: NoMatchContext): ErrorWithSuggestion;
616
+ /** Why a page scroll moved nothing */
617
+ export interface ScrollNoEffect {
618
+ /** Direction asked for */
619
+ direction: 'up' | 'down' | 'left' | 'right';
620
+ /** The document is no larger than the viewport, the page was at its edge already, or it did not move although it could */
621
+ reason: 'too-small' | 'at-edge' | 'locked';
622
+ /** Viewport size along the axis (px) */
623
+ viewport: number;
624
+ /** The page's `document.readyState` */
625
+ readyState: string;
626
+ }
627
+ /**
628
+ * Warning of `bdg dom scroll` when the page did not move, with the
629
+ * still-loading hint while the document is not complete (it may grow).
630
+ *
631
+ * @param effect - Why nothing scrolled
632
+ * @returns e.g. `Nothing to scroll: the document is no taller than the viewport (993px)`
633
+ */
634
+ export declare function scrollNoEffectWarning(effect: ScrollNoEffect): string;
635
+ /**
636
+ * Hint for something not found while the page has not finished loading.
637
+ *
638
+ * @param readyState - The page's `document.readyState` (not `complete`)
639
+ * @param selector - Selector that matched nothing, if any
640
+ * @returns e.g. `The page is still loading (document.readyState: loading); wait for the element with: bdg dom wait '#login'`
641
+ */
642
+ export declare function pageStillLoadingHint(readyState: string, selector?: string): string;
643
+ /**
644
+ * Put the still-loading hint before a "not found" suggestion when the page
645
+ * has not finished loading.
646
+ *
647
+ * @param suggestion - Suggestion of the error
648
+ * @param readyState - The page's `document.readyState`, if known
649
+ * @param selector - Selector that matched nothing, if any
650
+ * @returns The suggestion, with the hint first while the page loads
377
651
  */
378
- export declare function noNodesFoundError(selector: string): ErrorWithSuggestion;
652
+ export declare function withLoadingHint(suggestion: string, readyState: string | undefined, selector?: string): string;
653
+ /**
654
+ * `bdg dom wait` without a selector or --load, or with --text/--gone but no selector.
655
+ *
656
+ * @returns Message and suggestion
657
+ */
658
+ export declare function waitTargetRequiredError(): ErrorWithSuggestion;
659
+ /**
660
+ * `bdg dom wait` that ran out of time: what it waited for and what the page
661
+ * showed last, with a next step that fits.
662
+ *
663
+ * @param condition - What was waited for
664
+ * @param snapshot - Last thing the page reported (none when it never answered)
665
+ * @param timeoutMs - The --timeout
666
+ * @returns Message and suggestion
667
+ */
668
+ export declare function waitTimeoutError(condition: WaitCondition, snapshot: WaitSnapshot | undefined, timeoutMs: number): ErrorWithSuggestion;
379
669
  /**
380
670
  * Element not visible/rendered.
381
671
  */
@@ -418,8 +708,10 @@ export declare function singleFileInputError(count: number): ErrorWithSuggestion
418
708
  * Unknown field in an a11y query pattern.
419
709
  *
420
710
  * @param field - The unrecognized key
711
+ * @param similar - A known field it looks like a typo of
712
+ * @param value - The `name=…`/`description=…` field that absorbed it
421
713
  */
422
- export declare function unknownQueryFieldError(field: string): ErrorWithSuggestion;
714
+ export declare function unknownQueryFieldError(field: string, similar?: string, value?: string): ErrorWithSuggestion;
423
715
  /**
424
716
  * No a11y nodes matching pattern.
425
717
  */
@@ -435,6 +727,39 @@ export declare function notInAccessibilityTreeError(target: string, reasons: str
435
727
  * Fillable element not found.
436
728
  */
437
729
  export declare function fillableElementNotFoundError(selector: string): ErrorWithSuggestion;
730
+ /** Appended to the element type when an action went to a label's control. */
731
+ export declare const VIA_LABEL_SUFFIX = " (via label)";
732
+ /** Placeholder for the shell-quoted `name=…` field in {@link LABEL_WITHOUT_CONTROL}. */
733
+ export declare const NAME_QUERY_PLACEHOLDER = "{nameQuery}";
734
+ /**
735
+ * Filling a `<label>` that has no form control (used by the page script,
736
+ * which puts the label's quoted `name=<text>` in place of
737
+ * {@link NAME_QUERY_PLACEHOLDER}).
738
+ */
739
+ export declare const LABEL_WITHOUT_CONTROL: ErrorWithSuggestion;
740
+ /**
741
+ * Why `dom fill` refused an element (used by the page script, which adds the
742
+ * cause in parentheses, e.g. `The element is read-only (contenteditable="false")`).
743
+ * All are invalid targets (exit 81), like any element that is not fillable.
744
+ */
745
+ export declare const FILL_REFUSALS: {
746
+ readonly disabled: {
747
+ readonly message: "The element is disabled";
748
+ readonly suggestion: "Enable the field first (it may depend on another input)";
749
+ };
750
+ readonly readOnly: {
751
+ readonly message: "The element is read-only";
752
+ readonly suggestion: "A user cannot change it either; the page has to make it editable first";
753
+ };
754
+ readonly inert: {
755
+ readonly message: "The element is inert";
756
+ readonly suggestion: "The page made it non-interactive (often behind a dialog); close what covers it first";
757
+ };
758
+ readonly notFillable: {
759
+ readonly message: "Element is not fillable";
760
+ readonly suggestion: "Only input, textarea, select, and contenteditable elements can be filled";
761
+ };
762
+ };
438
763
  /**
439
764
  * Clickable element not found.
440
765
  */
@@ -455,12 +780,13 @@ export declare function keyPressFailedError(details: string): ErrorWithSuggestio
455
780
  */
456
781
  export declare function scriptTimeoutError(timeoutMs: number): ErrorWithSuggestion;
457
782
  /**
458
- * The page was kept busy by a script (e.g. a loop started from a timer) and
459
- * bdg terminated it.
783
+ * The page (or an iframe) was kept busy by a script (e.g. a loop started
784
+ * from a timer) and bdg terminated it.
460
785
  *
461
786
  * @param timeoutMs - Time waited
787
+ * @param scope - What was busy: the page, or the iframe a command ran in
462
788
  */
463
- export declare function pageBusyError(timeoutMs: number): ErrorWithSuggestion;
789
+ export declare function pageBusyError(timeoutMs: number, scope?: 'page' | 'frame', recovered?: boolean): ErrorWithSuggestion;
464
790
  /**
465
791
  * The page did not answer because a navigation is still waiting for the
466
792
  * server (Chrome holds commands for the page until the new document arrives).
@@ -497,11 +823,40 @@ export declare function frameNotFoundError(query: string, frames: DomFrame[]): E
497
823
  */
498
824
  export declare function ambiguousFrameError(query: string, candidates: DomFrame[]): ErrorWithSuggestion;
499
825
  /**
500
- * An iframe without a JavaScript context (still loading, or sandboxed without scripts).
826
+ * An iframe without a JavaScript context (still loading, or gone).
501
827
  *
502
828
  * @param url - Frame URL
503
829
  */
504
830
  export declare function frameNotReadyError(url: string): ErrorWithSuggestion;
831
+ /**
832
+ * The iframe a `dom eval --frame` script ran in navigated before it finished.
833
+ *
834
+ * @param url - Frame URL when the script started
835
+ */
836
+ export declare function frameNavigatedDuringEvalError(url: string): ErrorWithSuggestion;
837
+ /**
838
+ * The iframe a `dom eval --frame` script ran in was removed (or vanished
839
+ * before it started).
840
+ *
841
+ * @param url - Frame URL when the script started
842
+ */
843
+ export declare function frameRemovedDuringEvalError(url: string): ErrorWithSuggestion;
844
+ /**
845
+ * The page (its tab) was closed while a `dom eval` script ran.
846
+ */
847
+ export declare function pageClosedDuringEvalError(): ErrorWithSuggestion;
848
+ /**
849
+ * The iframe a `dom eval --frame` script ran in went away, and bdg could not
850
+ * tell whether it navigated or was removed.
851
+ *
852
+ * @param url - Frame URL when the script started
853
+ */
854
+ export declare function frameLostDuringEvalError(url: string): ErrorWithSuggestion;
855
+ /**
856
+ * The page navigated while a `dom eval` script ran (e.g. it set
857
+ * `location.href` and then awaited).
858
+ */
859
+ export declare function pageNavigatedDuringEvalError(): ErrorWithSuggestion;
505
860
  /**
506
861
  * Script execution error with shell quote detection.
507
862
  *
@@ -536,7 +891,15 @@ export declare function internalError(context: string): ErrorWithSuggestion;
536
891
  /**
537
892
  * No forms found on page.
538
893
  */
539
- export declare function noFormsFoundError(): ErrorWithSuggestion;
894
+ export declare function noFormsFoundError(readyState?: string): ErrorWithSuggestion;
895
+ /**
896
+ * The form discovery script threw.
897
+ *
898
+ * @param detail - What it threw, e.g. `TypeError: Cannot read properties of null`
899
+ * @param readyState - The page's `document.readyState`, when known
900
+ * @returns Message and suggestion (the still-loading hint while the page loads)
901
+ */
902
+ export declare function formDiscoveryFailedError(detail: string, readyState?: string): ErrorWithSuggestion;
540
903
  /**
541
904
  * Form in iframe (cross-origin or same-origin).
542
905
  */