browser-debugger-cli 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/README.md +7 -1
  2. package/dist/cdp/schema.d.ts +4 -1
  3. package/dist/cdp/schema.js +48 -7
  4. package/dist/commands/cdp.js +3 -2
  5. package/dist/commands/cleanup.d.ts +11 -0
  6. package/dist/commands/cleanup.js +161 -57
  7. package/dist/commands/console.d.ts +20 -1
  8. package/dist/commands/console.js +57 -17
  9. package/dist/commands/details.js +3 -2
  10. package/dist/commands/dom/DomElementResolver.d.ts +10 -3
  11. package/dist/commands/dom/DomElementResolver.js +35 -17
  12. package/dist/commands/dom/a11y.d.ts +10 -0
  13. package/dist/commands/dom/a11y.js +29 -6
  14. package/dist/commands/dom/eval.d.ts +3 -1
  15. package/dist/commands/dom/eval.js +29 -4
  16. package/dist/commands/dom/form.js +16 -62
  17. package/dist/commands/dom/formInteraction.js +189 -119
  18. package/dist/commands/dom/formSummary.d.ts +49 -0
  19. package/dist/commands/dom/formSummary.js +180 -0
  20. package/dist/commands/dom/frames.d.ts +2 -1
  21. package/dist/commands/dom/frames.js +17 -2
  22. package/dist/commands/dom/get.d.ts +6 -5
  23. package/dist/commands/dom/get.js +92 -82
  24. package/dist/commands/dom/helpers/index.d.ts +1 -1
  25. package/dist/commands/dom/helpers/index.js +1 -1
  26. package/dist/commands/dom/helpers/keyAttributes.d.ts +20 -0
  27. package/dist/commands/dom/helpers/keyAttributes.js +54 -0
  28. package/dist/commands/dom/helpers/query.d.ts +44 -17
  29. package/dist/commands/dom/helpers/query.js +300 -106
  30. package/dist/commands/dom/helpers/runElementCommand.d.ts +10 -2
  31. package/dist/commands/dom/helpers/runElementCommand.js +98 -30
  32. package/dist/commands/dom/helpers/screenshot.d.ts +4 -1
  33. package/dist/commands/dom/helpers/screenshot.js +239 -51
  34. package/dist/commands/dom/index.d.ts +4 -1
  35. package/dist/commands/dom/index.js +22 -7
  36. package/dist/commands/dom/inspect.d.ts +15 -0
  37. package/dist/commands/dom/inspect.js +82 -0
  38. package/dist/commands/dom/layout.d.ts +14 -0
  39. package/dist/commands/dom/layout.js +54 -0
  40. package/dist/commands/dom/listeners.d.ts +5 -1
  41. package/dist/commands/dom/listeners.js +15 -5
  42. package/dist/commands/dom/query.js +2 -3
  43. package/dist/commands/dom/screenshot.d.ts +12 -2
  44. package/dist/commands/dom/screenshot.js +27 -3
  45. package/dist/commands/dom/semanticUtils.d.ts +16 -10
  46. package/dist/commands/dom/semanticUtils.js +53 -16
  47. package/dist/commands/dom/wait.d.ts +13 -0
  48. package/dist/commands/dom/wait.js +83 -0
  49. package/dist/commands/helpJson.js +2 -2
  50. package/dist/commands/network/list.js +17 -13
  51. package/dist/commands/optionBehaviors.js +154 -21
  52. package/dist/commands/page.d.ts +3 -2
  53. package/dist/commands/page.js +100 -5
  54. package/dist/commands/peek.js +4 -11
  55. package/dist/commands/sessions.d.ts +8 -0
  56. package/dist/commands/sessions.js +19 -0
  57. package/dist/commands/shared/CommandRunner.js +4 -4
  58. package/dist/commands/shared/commonOptions.d.ts +4 -0
  59. package/dist/commands/shared/commonOptions.js +9 -0
  60. package/dist/commands/shared/dataFetcher.js +2 -2
  61. package/dist/commands/shared/followMode.d.ts +21 -1
  62. package/dist/commands/shared/followMode.js +29 -2
  63. package/dist/commands/shared/handleValidationError.d.ts +2 -2
  64. package/dist/commands/shared/handleValidationError.js +12 -3
  65. package/dist/commands/shared/optionTypes.d.ts +61 -5
  66. package/dist/commands/shared/startHelpers.d.ts +66 -0
  67. package/dist/commands/shared/startHelpers.js +103 -13
  68. package/dist/commands/shared/validation.d.ts +14 -2
  69. package/dist/commands/shared/validation.js +20 -3
  70. package/dist/commands/start.d.ts +63 -0
  71. package/dist/commands/start.js +115 -15
  72. package/dist/commands/status.js +29 -7
  73. package/dist/commands/stop.js +7 -6
  74. package/dist/commands/tail.js +4 -11
  75. package/dist/commands/types.d.ts +2 -0
  76. package/dist/commands.js +2 -0
  77. package/dist/connection/chromeIdentity.d.ts +65 -0
  78. package/dist/connection/chromeIdentity.js +143 -0
  79. package/dist/connection/launcher/profilePreferences.d.ts +47 -0
  80. package/dist/connection/launcher/profilePreferences.js +151 -0
  81. package/dist/connection/launcher.d.ts +21 -2
  82. package/dist/connection/launcher.js +42 -16
  83. package/dist/connection/portReservation.d.ts +14 -4
  84. package/dist/connection/portReservation.js +21 -6
  85. package/dist/connection/startupExit.d.ts +8 -0
  86. package/dist/connection/startupExit.js +15 -6
  87. package/dist/constants.d.ts +6 -2
  88. package/dist/constants.js +9 -2
  89. package/dist/daemon/SessionController.js +23 -7
  90. package/dist/daemon/errors.d.ts +1 -1
  91. package/dist/daemon/errors.js +1 -1
  92. package/dist/daemon/launcher.d.ts +10 -2
  93. package/dist/daemon/launcher.js +8 -7
  94. package/dist/daemon/server/SocketServer.js +1 -2
  95. package/dist/daemon/session/Session.d.ts +20 -0
  96. package/dist/daemon/session/Session.js +80 -9
  97. package/dist/daemon/session/chromeConnection.d.ts +9 -0
  98. package/dist/daemon/session/chromeConnection.js +45 -8
  99. package/dist/daemon/session/commandRegistry.d.ts +14 -1
  100. package/dist/daemon/session/commandRegistry.js +113 -67
  101. package/dist/daemon/session/interactions.d.ts +48 -9
  102. package/dist/daemon/session/interactions.js +46 -9
  103. package/dist/daemon/session/triggeredRequests.d.ts +67 -0
  104. package/dist/daemon/session/triggeredRequests.js +157 -0
  105. package/dist/daemon/session/types.d.ts +5 -1
  106. package/dist/daemon.js +10630 -3601
  107. package/dist/errors/messages.d.ts +456 -24
  108. package/dist/errors/messages.js +862 -67
  109. package/dist/index.js +6915 -3401
  110. package/dist/ipc/client.d.ts +21 -1
  111. package/dist/ipc/client.js +35 -3
  112. package/dist/ipc/protocol/commands.d.ts +145 -5
  113. package/dist/ipc/protocol/commands.js +4 -0
  114. package/dist/ipc/protocol/domTypes.d.ts +291 -7
  115. package/dist/ipc/protocol/inspectTypes.d.ts +388 -0
  116. package/dist/ipc/protocol/inspectTypes.js +10 -0
  117. package/dist/ipc/session/lifecycle.d.ts +8 -1
  118. package/dist/ipc/session/queries.d.ts +5 -1
  119. package/dist/ipc/session/types.d.ts +5 -0
  120. package/dist/ipc/transport/index.d.ts +2 -1
  121. package/dist/ipc/transport/index.js +2 -2
  122. package/dist/runtime/dom/actionEffects.d.ts +185 -0
  123. package/dist/runtime/dom/actionEffects.js +402 -0
  124. package/dist/runtime/dom/actionEffectsScripts.d.ts +90 -0
  125. package/dist/runtime/dom/actionEffectsScripts.js +426 -0
  126. package/dist/runtime/dom/elementGeometry.d.ts +170 -0
  127. package/dist/runtime/dom/elementGeometry.js +553 -0
  128. package/dist/runtime/dom/elementInfo.d.ts +103 -0
  129. package/dist/runtime/dom/elementInfo.js +256 -0
  130. package/dist/runtime/dom/evalHelpers.d.ts +51 -6
  131. package/dist/runtime/dom/evalHelpers.js +136 -26
  132. package/dist/runtime/dom/eventListeners.d.ts +2 -1
  133. package/dist/runtime/dom/eventListeners.js +184 -47
  134. package/dist/runtime/dom/formDiscovery.d.ts +1 -1
  135. package/dist/runtime/dom/formDiscovery.js +116 -16
  136. package/dist/runtime/dom/formFillHelpers/fill.d.ts +9 -0
  137. package/dist/runtime/dom/formFillHelpers/fill.js +178 -14
  138. package/dist/runtime/dom/formFillHelpers/index.d.ts +2 -2
  139. package/dist/runtime/dom/formFillHelpers/index.js +2 -2
  140. package/dist/runtime/dom/formFillHelpers/pressKey.js +14 -3
  141. package/dist/runtime/dom/formFillHelpers/scroll.d.ts +3 -0
  142. package/dist/runtime/dom/formFillHelpers/scroll.js +60 -18
  143. package/dist/runtime/dom/formFillHelpers/shared.d.ts +17 -0
  144. package/dist/runtime/dom/formFillHelpers/shared.js +25 -1
  145. package/dist/runtime/dom/formFillHelpers/stability.d.ts +20 -6
  146. package/dist/runtime/dom/formFillHelpers/stability.js +50 -19
  147. package/dist/runtime/dom/formSubmitHelpers.d.ts +3 -0
  148. package/dist/runtime/dom/formSubmitHelpers.js +89 -15
  149. package/dist/runtime/dom/frameLayout.d.ts +60 -0
  150. package/dist/runtime/dom/frameLayout.js +140 -0
  151. package/dist/runtime/dom/frameOrigin.d.ts +50 -0
  152. package/dist/runtime/dom/frameOrigin.js +62 -0
  153. package/dist/runtime/dom/frameScopedConnection.d.ts +92 -0
  154. package/dist/runtime/dom/frameScopedConnection.js +252 -0
  155. package/dist/runtime/dom/frameSelection.d.ts +12 -1
  156. package/dist/runtime/dom/frameSelection.js +22 -3
  157. package/dist/runtime/dom/frames.d.ts +61 -5
  158. package/dist/runtime/dom/frames.js +329 -75
  159. package/dist/runtime/dom/inspect.d.ts +28 -0
  160. package/dist/runtime/dom/inspect.js +557 -0
  161. package/dist/runtime/dom/inspectAllStyles.d.ts +62 -0
  162. package/dist/runtime/dom/inspectAllStyles.js +385 -0
  163. package/dist/runtime/dom/inspectCascade.d.ts +94 -0
  164. package/dist/runtime/dom/inspectCascade.js +371 -0
  165. package/dist/runtime/dom/inspectCascadeModel.d.ts +39 -0
  166. package/dist/runtime/dom/inspectCascadeModel.js +232 -0
  167. package/dist/runtime/dom/inspectHints.d.ts +62 -0
  168. package/dist/runtime/dom/inspectHints.js +305 -0
  169. package/dist/runtime/dom/inspectLayoutModel.d.ts +87 -0
  170. package/dist/runtime/dom/inspectLayoutModel.js +346 -0
  171. package/dist/runtime/dom/inspectModel.d.ts +74 -0
  172. package/dist/runtime/dom/inspectModel.js +184 -0
  173. package/dist/runtime/dom/inspectPaintModel.d.ts +157 -0
  174. package/dist/runtime/dom/inspectPaintModel.js +461 -0
  175. package/dist/runtime/dom/inspectRules.d.ts +37 -0
  176. package/dist/runtime/dom/inspectRules.js +101 -0
  177. package/dist/runtime/dom/inspectScripts.d.ts +132 -0
  178. package/dist/runtime/dom/inspectScripts.js +263 -0
  179. package/dist/runtime/dom/inspectTree.d.ts +40 -0
  180. package/dist/runtime/dom/inspectTree.js +134 -0
  181. package/dist/runtime/dom/inspectVariables.d.ts +33 -0
  182. package/dist/runtime/dom/inspectVariables.js +94 -0
  183. package/dist/runtime/dom/inspectWhyModel.d.ts +20 -0
  184. package/dist/runtime/dom/inspectWhyModel.js +134 -0
  185. package/dist/runtime/dom/layout.d.ts +71 -0
  186. package/dist/runtime/dom/layout.js +340 -0
  187. package/dist/runtime/dom/listenerPageScripts.d.ts +72 -0
  188. package/dist/runtime/dom/listenerPageScripts.js +365 -0
  189. package/dist/runtime/dom/listenerSummary.d.ts +136 -11
  190. package/dist/runtime/dom/listenerSummary.js +361 -22
  191. package/dist/runtime/dom/pageActivity.d.ts +41 -0
  192. package/dist/runtime/dom/pageActivity.js +123 -0
  193. package/dist/runtime/dom/reactEventHelpers.d.ts +63 -2
  194. package/dist/runtime/dom/reactEventHelpers.js +220 -41
  195. package/dist/runtime/dom/targetNode.d.ts +80 -27
  196. package/dist/runtime/dom/targetNode.js +249 -33
  197. package/dist/runtime/dom/wait.d.ts +25 -0
  198. package/dist/runtime/dom/wait.js +199 -0
  199. package/dist/runtime/dom/waitCondition.d.ts +71 -0
  200. package/dist/runtime/dom/waitCondition.js +75 -0
  201. package/dist/runtime/page/emulation.d.ts +71 -0
  202. package/dist/runtime/page/emulation.js +117 -0
  203. package/dist/runtime/page/loadingState.d.ts +36 -0
  204. package/dist/runtime/page/loadingState.js +86 -0
  205. package/dist/runtime/page/navigation.d.ts +46 -2
  206. package/dist/runtime/page/navigation.js +69 -33
  207. package/dist/session/QueryCacheManager.d.ts +11 -1
  208. package/dist/session/QueryCacheManager.js +25 -3
  209. package/dist/session/chromeOwners.d.ts +34 -0
  210. package/dist/session/chromeOwners.js +51 -0
  211. package/dist/session/cleanup/staleSession.d.ts +11 -1
  212. package/dist/session/cleanup/staleSession.js +17 -6
  213. package/dist/session/cleanup/userCommands.js +2 -4
  214. package/dist/session/metadata.d.ts +5 -1
  215. package/dist/session/metadata.js +2 -1
  216. package/dist/session/paths.d.ts +77 -3
  217. package/dist/session/paths.js +111 -5
  218. package/dist/session/port.d.ts +31 -7
  219. package/dist/session/port.js +50 -43
  220. package/dist/session/portClaims.d.ts +66 -0
  221. package/dist/session/portClaims.js +284 -0
  222. package/dist/session/sessionList.d.ts +58 -0
  223. package/dist/session/sessionList.js +199 -0
  224. package/dist/session/sessionName.d.ts +46 -0
  225. package/dist/session/sessionName.js +97 -0
  226. package/dist/telemetry/a11y.d.ts +18 -3
  227. package/dist/telemetry/a11y.js +170 -29
  228. package/dist/telemetry/console.d.ts +1 -0
  229. package/dist/telemetry/console.js +100 -5
  230. package/dist/telemetry/network.js +3 -1
  231. package/dist/telemetry/requestKinds.d.ts +32 -0
  232. package/dist/telemetry/requestKinds.js +61 -0
  233. package/dist/telemetry/requestState.d.ts +31 -0
  234. package/dist/telemetry/requestState.js +38 -0
  235. package/dist/types.d.ts +112 -3
  236. package/dist/ui/formatters/a11y.js +3 -0
  237. package/dist/ui/formatters/console/chronological.d.ts +8 -0
  238. package/dist/ui/formatters/console/chronological.js +17 -4
  239. package/dist/ui/formatters/console/json.js +3 -4
  240. package/dist/ui/formatters/console/shared.d.ts +12 -0
  241. package/dist/ui/formatters/console.d.ts +2 -2
  242. package/dist/ui/formatters/console.js +1 -1
  243. package/dist/ui/formatters/details.d.ts +8 -0
  244. package/dist/ui/formatters/details.js +61 -4
  245. package/dist/ui/formatters/dom.d.ts +27 -14
  246. package/dist/ui/formatters/dom.js +88 -59
  247. package/dist/ui/formatters/form.js +29 -18
  248. package/dist/ui/formatters/inspect.d.ts +39 -0
  249. package/dist/ui/formatters/inspect.js +596 -0
  250. package/dist/ui/formatters/keyAttributes.d.ts +19 -0
  251. package/dist/ui/formatters/keyAttributes.js +84 -0
  252. package/dist/ui/formatters/layout.d.ts +31 -0
  253. package/dist/ui/formatters/layout.js +53 -0
  254. package/dist/ui/formatters/listeners.d.ts +3 -2
  255. package/dist/ui/formatters/listeners.js +73 -9
  256. package/dist/ui/formatters/networkHeaders.d.ts +13 -0
  257. package/dist/ui/formatters/networkHeaders.js +36 -3
  258. package/dist/ui/formatters/networkList.d.ts +29 -1
  259. package/dist/ui/formatters/networkList.js +86 -20
  260. package/dist/ui/formatters/preview.js +2 -1
  261. package/dist/ui/formatters/requestStatus.d.ts +1 -17
  262. package/dist/ui/formatters/requestStatus.js +2 -30
  263. package/dist/ui/formatters/sessions.d.ts +12 -0
  264. package/dist/ui/formatters/sessions.js +40 -0
  265. package/dist/ui/formatters/status.d.ts +21 -2
  266. package/dist/ui/formatters/status.js +47 -10
  267. package/dist/ui/formatters/triggeredRequests.d.ts +36 -0
  268. package/dist/ui/formatters/triggeredRequests.js +65 -0
  269. package/dist/ui/formatting.d.ts +19 -0
  270. package/dist/ui/formatting.js +31 -36
  271. package/dist/ui/messages/chrome.d.ts +9 -0
  272. package/dist/ui/messages/chrome.js +17 -5
  273. package/dist/ui/messages/commands.d.ts +504 -14
  274. package/dist/ui/messages/commands.js +835 -21
  275. package/dist/ui/messages/consoleMessages.d.ts +10 -0
  276. package/dist/ui/messages/consoleMessages.js +17 -0
  277. package/dist/ui/messages/hints.js +2 -1
  278. package/dist/ui/messages/networkMessages.d.ts +14 -0
  279. package/dist/ui/messages/networkMessages.js +18 -0
  280. package/dist/ui/messages/preview.js +5 -4
  281. package/dist/ui/messages/session.d.ts +30 -21
  282. package/dist/ui/messages/session.js +48 -26
  283. package/dist/ui/messages/sessionCommand.d.ts +43 -0
  284. package/dist/ui/messages/sessionCommand.js +52 -0
  285. package/dist/utils/async.d.ts +17 -0
  286. package/dist/utils/async.js +36 -0
  287. package/dist/utils/color.d.ts +84 -0
  288. package/dist/utils/color.js +376 -0
  289. package/dist/utils/cssValues.d.ts +109 -0
  290. package/dist/utils/cssValues.js +236 -0
  291. package/dist/utils/http.d.ts +22 -1
  292. package/dist/utils/http.js +28 -9
  293. package/dist/utils/selectorFilters.d.ts +48 -8
  294. package/dist/utils/selectorFilters.js +296 -53
  295. package/dist/utils/shellDetection.d.ts +8 -2
  296. package/dist/utils/shellDetection.js +120 -33
  297. package/dist/utils/suggestions.d.ts +26 -0
  298. package/dist/utils/suggestions.js +73 -0
  299. package/dist/utils/taskMappings.js +10 -0
  300. package/dist/utils/url.d.ts +12 -2
  301. package/dist/utils/url.js +69 -7
  302. package/package.json +1 -1
  303. package/dist/ui/formatters/sessionFormatters.d.ts +0 -58
  304. package/dist/ui/formatters/sessionFormatters.js +0 -121
@@ -28,6 +28,7 @@ export declare function connectToDaemon(): Promise<HandshakeResponse>;
28
28
  * Request status information from the daemon.
29
29
  * Returns daemon state, session metadata, and activity metrics.
30
30
  *
31
+ * @param socketPath - Daemon socket to ask (default: the selected session's)
31
32
  * @returns Status response with daemon and session information
32
33
  * @throws Error if connection fails or times out
33
34
  *
@@ -40,7 +41,7 @@ export declare function connectToDaemon(): Promise<HandshakeResponse>;
40
41
  * }
41
42
  * ```
42
43
  */
43
- export declare function getStatus(): Promise<StatusResponse>;
44
+ export declare function getStatus(socketPath?: string): Promise<StatusResponse>;
44
45
  /**
45
46
  * Request preview data from the daemon.
46
47
  * Returns snapshot of collected telemetry without stopping session.
@@ -217,8 +218,27 @@ export declare function domScroll(params: NoType<(typeof COMMANDS)['dom_scroll']
217
218
  * @returns Where the page is now
218
219
  */
219
220
  export declare function pageNavigate(params: NoType<(typeof COMMANDS)['page_navigate']['requestSchema']>): Promise<ClientResponse<'page_navigate'>>;
221
+ /**
222
+ * Change the page emulation (viewport, color scheme) or clear it.
223
+ *
224
+ * @param params - What to set, or reset
225
+ * @returns Emulation and what the page now has
226
+ */
227
+ export declare function pageEmulate(params: NoType<(typeof COMMANDS)['page_emulate']['requestSchema']>): Promise<ClientResponse<'page_emulate'>>;
220
228
  /** Run form discovery and return the raw structured form data. */
221
229
  export declare function domFormDiscover(): Promise<ClientResponse<'dom_form_discover'>>;
222
230
  /** List the event listeners that run for an element. */
223
231
  export declare function domListeners(params: NoType<(typeof COMMANDS)['dom_listeners']['requestSchema']>): Promise<ClientResponse<'dom_listeners'>>;
232
+ /** Positions, sizes and visibility of elements. */
233
+ export declare function domLayout(params: NoType<(typeof COMMANDS)['dom_layout']['requestSchema']>): Promise<ClientResponse<'dom_layout'>>;
234
+ /** What one element looks like: styles, box, layout and child tree. */
235
+ export declare function domInspect(params: NoType<(typeof COMMANDS)['dom_inspect']['requestSchema']>): Promise<ClientResponse<'dom_inspect'>>;
236
+ /**
237
+ * Wait until elements appear, become visible, contain a text or are gone,
238
+ * and/or the page has loaded.
239
+ *
240
+ * @param params - Condition and timeout
241
+ * @returns What the page showed once the condition was met
242
+ */
243
+ export declare function domWait(params: NoType<(typeof COMMANDS)['dom_wait']['requestSchema']>): Promise<ClientResponse<'dom_wait'>>;
224
244
  //# sourceMappingURL=client.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * Public API for communicating with the daemon via Unix socket.
5
5
  * Provides high-level functions for session lifecycle and queries.
6
6
  */
7
- import { getQuickIPCRequestTimeout } from '../constants.js';
7
+ import { getIPCRequestTimeout, getQuickIPCRequestTimeout } from '../constants.js';
8
8
  import { CommandError } from '../errors/index.js';
9
9
  import { EXIT_CODES } from '../utils/exitCodes.js';
10
10
  import { sendRequest } from './transport/index.js';
@@ -42,6 +42,7 @@ async function assertResponsive() {
42
42
  * Request status information from the daemon.
43
43
  * Returns daemon state, session metadata, and activity metrics.
44
44
  *
45
+ * @param socketPath - Daemon socket to ask (default: the selected session's)
45
46
  * @returns Status response with daemon and session information
46
47
  * @throws Error if connection fails or times out
47
48
  *
@@ -54,9 +55,9 @@ async function assertResponsive() {
54
55
  * }
55
56
  * ```
56
57
  */
57
- export async function getStatus() {
58
+ export async function getStatus(socketPath) {
58
59
  const request = withSession({ type: 'status_request' });
59
- return sendRequest(request, 'status', 'status_response', getQuickIPCRequestTimeout());
60
+ return sendRequest(request, 'status', 'status_response', getQuickIPCRequestTimeout(), socketPath);
60
61
  }
61
62
  /**
62
63
  * Request preview data from the daemon.
@@ -145,6 +146,8 @@ export async function startSession(url, options) {
145
146
  headless: options.headless,
146
147
  chromeWsUrl: options.chromeWsUrl,
147
148
  chromeFlags: options.chromeFlags,
149
+ viewport: options.viewport,
150
+ colorScheme: options.colorScheme,
148
151
  }),
149
152
  });
150
153
  await assertResponsive();
@@ -310,6 +313,15 @@ export async function domScroll(params) {
310
313
  export async function pageNavigate(params) {
311
314
  return sendCommand('page_navigate', params);
312
315
  }
316
+ /**
317
+ * Change the page emulation (viewport, color scheme) or clear it.
318
+ *
319
+ * @param params - What to set, or reset
320
+ * @returns Emulation and what the page now has
321
+ */
322
+ export async function pageEmulate(params) {
323
+ return sendCommand('page_emulate', params);
324
+ }
313
325
  /** Run form discovery and return the raw structured form data. */
314
326
  export async function domFormDiscover() {
315
327
  return sendCommand('dom_form_discover', {});
@@ -318,4 +330,24 @@ export async function domFormDiscover() {
318
330
  export async function domListeners(params) {
319
331
  return sendCommand('dom_listeners', params);
320
332
  }
333
+ /** Positions, sizes and visibility of elements. */
334
+ export async function domLayout(params) {
335
+ return sendCommand('dom_layout', params);
336
+ }
337
+ /** What one element looks like: styles, box, layout and child tree. */
338
+ export async function domInspect(params) {
339
+ return sendCommand('dom_inspect', params);
340
+ }
341
+ /** Time the client gives `dom wait` beyond its --timeout (the daemon reports the timeout first) */
342
+ const WAIT_IPC_MARGIN_MS = 10_000;
343
+ /**
344
+ * Wait until elements appear, become visible, contain a text or are gone,
345
+ * and/or the page has loaded.
346
+ *
347
+ * @param params - Condition and timeout
348
+ * @returns What the page showed once the condition was met
349
+ */
350
+ export async function domWait(params) {
351
+ return sendCommand('dom_wait', params, Math.max(getIPCRequestTimeout(), params.timeout + WAIT_IPC_MARGIN_MS));
352
+ }
321
353
  //# sourceMappingURL=client.js.map
@@ -5,9 +5,10 @@
5
5
  * Each command has a request schema (input) and response data schema (output).
6
6
  */
7
7
  import type { HintDetails } from '../../errors/notices.js';
8
- import type { ClickResult, FillResult, ListenersResult, PressKeyResult, RawFormData, ScrollResult, SubmitResult } from './domTypes.js';
8
+ import type { ClickResult, FillResult, LayoutResult, ListenersResult, PressKeyResult, RawFormData, ScrollResult, SubmitResult } from './domTypes.js';
9
+ import type { InspectResult } from './inspectTypes.js';
9
10
  import type { PageState, SessionActivity } from '../session/types.js';
10
- import type { NetworkRequest } from '../../types.js';
11
+ import type { ColorScheme, NetworkRequest, ViewportSize } from '../../types.js';
11
12
  /**
12
13
  * Session peek command request schema.
13
14
  */
@@ -38,6 +39,10 @@ export interface SessionPeekData {
38
39
  network: Array<{
39
40
  requestId: string;
40
41
  timestamp: number;
42
+ /** Chrome's monotonic time (seconds) when the request was sent */
43
+ sentTime?: number;
44
+ /** Main-frame navigation (page load) the request belongs to */
45
+ navigationId?: number;
41
46
  method: string;
42
47
  url: string;
43
48
  status?: number;
@@ -147,6 +152,14 @@ export interface SessionNetworkHeadersData {
147
152
  url: string;
148
153
  /** Request ID for correlation with peek output. */
149
154
  requestId: string;
155
+ /** HTTP method. */
156
+ method?: string;
157
+ /** HTTP status (0: failed without a response; missing while pending). */
158
+ status?: number;
159
+ /** Status text sent by the server (empty for HTTP/2). */
160
+ statusText?: string;
161
+ /** Why loading failed, when it did. */
162
+ errorText?: string;
150
163
  /** Request headers. */
151
164
  requestHeaders: Record<string, string>;
152
165
  /** Response headers. */
@@ -167,7 +180,7 @@ export interface DomEvalData {
167
180
  type: string;
168
181
  /** Object subtype (node, date, array, ...) */
169
182
  subtype?: string;
170
- /** URL of the iframe the script ran in (with `frame`) */
183
+ /** URL of the iframe the script ran in (with `frame`; empty when it has none) */
171
184
  frame?: string;
172
185
  }
173
186
  /** An iframe of the page, as listed by `bdg dom frames` */
@@ -180,12 +193,18 @@ export interface DomFrame {
180
193
  name?: string;
181
194
  /** `id` attribute of the iframe element */
182
195
  id?: string;
183
- /** Security origin */
196
+ /**
197
+ * Origin the frame's scripts run with: inherited from the parent for
198
+ * srcdoc and about:blank, `"null"` (opaque) for data: URLs and sandboxes
199
+ * without allow-same-origin
200
+ */
184
201
  origin: string;
185
- /** Origin differs from the page's */
202
+ /** The page cannot reach its document: the origin differs from the page's, or is opaque */
186
203
  crossOrigin: boolean;
187
204
  /** Runs in its own renderer process (site isolation) */
188
205
  outOfProcess: boolean;
206
+ /** Index of the frame it is nested in (missing for frames of the page itself) */
207
+ parentIndex?: number;
189
208
  }
190
209
  /**
191
210
  * dom_frames: list the page's iframes (including nested and out-of-process ones).
@@ -220,6 +239,8 @@ export interface DomClickCommand {
220
239
  wait?: boolean;
221
240
  /** Double or right click, or only hover (default: click) */
222
241
  action?: 'click' | 'double' | 'right' | 'hover';
242
+ /** Refuse (exit 90) instead of falling back to DOM events when a real mouse can't reach it */
243
+ strict?: boolean;
223
244
  }
224
245
  export type DomClickData = ClickResult;
225
246
  /**
@@ -276,8 +297,46 @@ export interface DomListenersCommand {
276
297
  backendNodeId?: number;
277
298
  /** Only these event types (default: all) */
278
299
  types?: string[];
300
+ /** List every listener of framework roots instead of one summary per node */
301
+ all?: boolean;
279
302
  }
280
303
  export type DomListenersData = ListenersResult;
304
+ /**
305
+ * dom_layout: positions, sizes and visibility of elements.
306
+ */
307
+ export interface DomLayoutCommand {
308
+ selector: string;
309
+ /** Only this match (default: every match) */
310
+ index?: number;
311
+ /** Exact element from the query cache (overrides selector/index) */
312
+ backendNodeId?: number;
313
+ }
314
+ export type DomLayoutData = LayoutResult;
315
+ /**
316
+ * dom_inspect: what one element looks like (styles, box, layout, child tree).
317
+ */
318
+ export interface DomInspectCommand {
319
+ selector: string;
320
+ /** Which match (default: the first rendered one, else the first) */
321
+ index?: number;
322
+ /** Exact element from the query cache (overrides selector/index) */
323
+ backendNodeId?: number;
324
+ /** Child tree depth (default 2; 0 for none) */
325
+ tree?: number;
326
+ /** Child tree rows at most (default 20) */
327
+ treeLimit?: number;
328
+ /** Every non-default longhand instead of the groups */
329
+ all?: boolean;
330
+ /** Only these properties (lowercase names) */
331
+ props?: string[];
332
+ /** Check for declarations that have no effect (default true) */
333
+ hints?: boolean;
334
+ /** Report which declaration sets each shown property */
335
+ rules?: boolean;
336
+ /** Report every declaration of this property */
337
+ why?: string;
338
+ }
339
+ export type DomInspectData = InspectResult;
281
340
  /**
282
341
  * dom_form_discover: run the form discovery script and return raw form data.
283
342
  */
@@ -309,7 +368,11 @@ export type RegistryShape = {
309
368
  dom_scroll: CommandDef<DomScrollCommand, DomScrollData>;
310
369
  dom_form_discover: CommandDef<DomFormDiscoverCommand, DomFormDiscoverData>;
311
370
  dom_listeners: CommandDef<DomListenersCommand, DomListenersData>;
371
+ dom_layout: CommandDef<DomLayoutCommand, DomLayoutData>;
372
+ dom_inspect: CommandDef<DomInspectCommand, DomInspectData>;
373
+ dom_wait: CommandDef<DomWaitCommand, DomWaitData>;
312
374
  page_navigate: CommandDef<PageNavigateCommand, PageNavigationResult>;
375
+ page_emulate: CommandDef<PageEmulateCommand, PageEmulationResult>;
313
376
  };
314
377
  /** What `bdg page` does */
315
378
  export type PageAction = 'navigate' | 'reload' | 'back' | 'forward';
@@ -325,6 +388,62 @@ export interface PageNavigationResult {
325
388
  status?: number;
326
389
  /** Something worth knowing: an HTTP error, a download, a page still loading */
327
390
  warning?: string;
391
+ /** The new document had not finished loading within the wait (absent once complete) */
392
+ loading?: PageLoadingState;
393
+ }
394
+ /** A request the page is still waiting for */
395
+ export interface PendingRequestInfo {
396
+ method: string;
397
+ url: string;
398
+ /** CDP resource type (Script, Stylesheet, Image, ...) when known */
399
+ resourceType?: string;
400
+ /** How long it has been running */
401
+ pendingMs: number;
402
+ }
403
+ /** A document that has not finished loading (`document.readyState` is not `complete`) */
404
+ export interface PageLoadingState {
405
+ /** `loading` or `interactive` */
406
+ readyState: string;
407
+ /** The longest-running requests, load-blocking ones (scripts, styles, images, frames) first */
408
+ pending: PendingRequestInfo[];
409
+ /** All requests still running (more than `pending` lists when there are many) */
410
+ pendingCount: number;
411
+ }
412
+ /**
413
+ * dom_wait: wait until elements matching a selector appear, become visible,
414
+ * contain a text or are gone, and/or the page has loaded.
415
+ */
416
+ export interface DomWaitCommand {
417
+ /** Selector (filters like :has-text and :visible allowed); optional with `load` */
418
+ selector?: string;
419
+ /** Text one of the matches must contain (case-insensitive) */
420
+ text?: string;
421
+ /** Wait for the matches (or visible matches with `visible`) to be gone */
422
+ gone?: boolean;
423
+ /** Only count visible matches */
424
+ visible?: boolean;
425
+ /** Also wait for `document.readyState` to be `complete` */
426
+ load?: boolean;
427
+ /** Give up after this many milliseconds */
428
+ timeout: number;
429
+ }
430
+ /** What the page showed when a `dom wait` condition was met */
431
+ export interface DomWaitData {
432
+ selector?: string;
433
+ text?: string;
434
+ gone?: boolean;
435
+ visible?: boolean;
436
+ load?: boolean;
437
+ /** Time from the start of the wait until the condition was met */
438
+ elapsedMs: number;
439
+ /** Elements matching the selector */
440
+ count: number;
441
+ /** Of those, the ones containing `text` (with `text` only) */
442
+ textCount?: number;
443
+ /** Of those (or of the text matches), the visible ones */
444
+ visibleCount: number;
445
+ /** `document.readyState` of the page */
446
+ readyState: string;
328
447
  }
329
448
  /**
330
449
  * page_navigate: navigate, reload, or go back/forward, then wait for the page.
@@ -336,6 +455,27 @@ export interface PageNavigateCommand {
336
455
  /** Wait for the page to load (default: true) */
337
456
  wait?: boolean;
338
457
  }
458
+ /**
459
+ * page_emulate: change the viewport or color scheme mid-session, or clear both.
460
+ */
461
+ export interface PageEmulateCommand {
462
+ viewport?: ViewportSize;
463
+ colorScheme?: ColorScheme;
464
+ /** Clear both: back to the browser window and the system setting */
465
+ reset?: boolean;
466
+ }
467
+ /** The page after `page emulate` */
468
+ export interface PageEmulationResult {
469
+ /** What bdg emulates now (empty after a reset) */
470
+ emulated: {
471
+ viewport?: ViewportSize;
472
+ colorScheme?: ColorScheme;
473
+ };
474
+ /** Layout viewport the page has, without scrollbars */
475
+ viewport?: ViewportSize;
476
+ /** `prefers-color-scheme` the page sees */
477
+ colorScheme?: ColorScheme;
478
+ }
339
479
  /**
340
480
  * Central registry of all session commands.
341
481
  * Maps command names to their request/response schemas.
@@ -31,7 +31,11 @@ export const COMMANDS = {
31
31
  dom_press_key: defineCommand(),
32
32
  dom_scroll: defineCommand(),
33
33
  page_navigate: defineCommand(),
34
+ page_emulate: defineCommand(),
34
35
  dom_form_discover: defineCommand(),
35
36
  dom_listeners: defineCommand(),
37
+ dom_layout: defineCommand(),
38
+ dom_inspect: defineCommand(),
39
+ dom_wait: defineCommand(),
36
40
  };
37
41
  //# sourceMappingURL=commands.js.map