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
@@ -0,0 +1,388 @@
1
+ /**
2
+ * What `bdg dom inspect` returns: one element's look as a designer reads it,
3
+ * in a schema aligned with Figma's concepts (rect, box, layout with
4
+ * hug/fill/fixed sizing, text, fills, strokes, radius, effects, children), so
5
+ * it can be compared key by key with a design. Lengths are CSS px as numbers
6
+ * (one decimal); other units stay text. Colors are hex (`#rrggbbaa` when
7
+ * translucent).
8
+ */
9
+ import type { ContrastLevel } from '../../utils/color.js';
10
+ import type { CssLength } from '../../utils/cssValues.js';
11
+ /** Border box: page coordinates (iframe offsets and page scroll included) and size */
12
+ export interface InspectRect {
13
+ x: number;
14
+ y: number;
15
+ w: number;
16
+ h: number;
17
+ }
18
+ /** Sides top, right, bottom, left */
19
+ export type Sides = [CssLength, CssLength, CssLength, CssLength];
20
+ /** How a box gets its size along an axis, as Figma's auto layout names it */
21
+ export type SizingMode = 'fixed' | 'hug' | 'fill';
22
+ /** Padding, margin, border widths and the constraints on the box */
23
+ export interface InspectBox {
24
+ padding: Sides;
25
+ margin: Sides;
26
+ border: Sides;
27
+ sizing: string;
28
+ min?: {
29
+ w?: CssLength;
30
+ h?: CssLength;
31
+ };
32
+ max?: {
33
+ w?: CssLength;
34
+ h?: CssLength;
35
+ };
36
+ /** `overflow` when not visible, e.g. `hidden` or `hidden auto` (x y) */
37
+ overflow?: string;
38
+ /** Size of the content when it overflows the box by more than 1px */
39
+ scroll?: {
40
+ w: number;
41
+ h: number;
42
+ };
43
+ }
44
+ /** Flex or grid container properties */
45
+ export interface InspectContainer {
46
+ direction?: string;
47
+ wrap?: string;
48
+ justify?: string;
49
+ align?: string;
50
+ /** Row and column gap (one number when equal) */
51
+ gap?: CssLength | [CssLength, CssLength];
52
+ columns?: string;
53
+ rows?: string;
54
+ }
55
+ /** The parent that lays the element out (display: contents wrappers skipped) */
56
+ export interface InspectParent extends InspectContainer {
57
+ element: string;
58
+ display: string;
59
+ textAlign?: string;
60
+ }
61
+ /** Gaps to the previous and next rendered in-flow siblings, by the side each is on */
62
+ export interface InspectSiblings {
63
+ top?: number;
64
+ bottom?: number;
65
+ left?: number;
66
+ right?: number;
67
+ }
68
+ /** Display, position and the layout the element takes part in */
69
+ export interface InspectLayout extends InspectContainer {
70
+ display: string;
71
+ position?: string;
72
+ inset?: Sides;
73
+ z?: CssLength;
74
+ float?: string;
75
+ valign?: string;
76
+ /** As a flex item: grow shrink basis */
77
+ flex?: string;
78
+ self?: string;
79
+ order?: number;
80
+ /** As a grid item: row-start / column-start / row-end / column-end */
81
+ area?: string;
82
+ sizing?: {
83
+ w: SizingMode;
84
+ h: SizingMode;
85
+ };
86
+ parent?: InspectParent;
87
+ /** Distances from the parent's content box edges */
88
+ inParent?: {
89
+ left: number;
90
+ top: number;
91
+ right: number;
92
+ bottom: number;
93
+ };
94
+ siblings?: InspectSiblings;
95
+ }
96
+ /** Contrast of the text with what is behind it */
97
+ export interface InspectContrast {
98
+ ratio: number;
99
+ level: ContrastLevel;
100
+ /** Effective background (ancestor backgrounds composited) */
101
+ background: string;
102
+ /** The background was taken from an ancestor (or the page canvas) */
103
+ inherited?: boolean;
104
+ /** A background image or gradient is behind the text: the ratio uses the colors only */
105
+ overImage?: boolean;
106
+ /**
107
+ * Opacity of the element and its ancestors (below 1): the text color is
108
+ * faded by it before the ratio is taken (backgrounds inside the faded
109
+ * subtree are not, so the ratio is approximate)
110
+ */
111
+ opacity?: number;
112
+ }
113
+ /** Typography (for containers without text of their own: only what differs from the parent) */
114
+ export interface InspectText {
115
+ family?: string;
116
+ /** Font Chrome rendered the text with, when it is not the first family */
117
+ rendered?: string;
118
+ /** The rendered font is a web font */
119
+ webfont?: boolean;
120
+ weight?: number;
121
+ style?: string;
122
+ size?: number;
123
+ lineHeight?: CssLength;
124
+ color?: string;
125
+ contrast?: InspectContrast;
126
+ align?: string;
127
+ transform?: string;
128
+ tracking?: CssLength;
129
+ decoration?: string;
130
+ whiteSpace?: string;
131
+ overflow?: string;
132
+ clamp?: string;
133
+ shadow?: string;
134
+ features?: string;
135
+ }
136
+ /** A background layer */
137
+ export type InspectFill = {
138
+ type: 'solid';
139
+ color: string;
140
+ } | {
141
+ type: 'gradient';
142
+ value: string;
143
+ } | {
144
+ type: 'image';
145
+ value: string;
146
+ size?: string;
147
+ };
148
+ /** A border side (or all four) */
149
+ export interface InspectStroke {
150
+ side: 'all' | 'top' | 'right' | 'bottom' | 'left';
151
+ width: number;
152
+ style: string;
153
+ color: string;
154
+ }
155
+ /** A shadow layer */
156
+ export interface InspectEffect {
157
+ type: 'shadow' | 'inner-shadow';
158
+ x: number;
159
+ y: number;
160
+ blur: number;
161
+ spread: number;
162
+ color: string;
163
+ }
164
+ /** Visual effects other than shadows */
165
+ export interface InspectFx {
166
+ transform?: string;
167
+ filter?: string;
168
+ backdrop?: string;
169
+ clip?: string;
170
+ mask?: string;
171
+ animation?: string;
172
+ }
173
+ /** Interaction state set by CSS */
174
+ export interface InspectState {
175
+ cursor?: string;
176
+ pointerEvents?: string;
177
+ visibility?: string;
178
+ userSelect?: string;
179
+ appearance?: string;
180
+ }
181
+ /** A generated pseudo-element (`::before`, `::after`) or the placeholder */
182
+ export interface InspectPseudo {
183
+ type: '::before' | '::after' | '::placeholder';
184
+ content?: string;
185
+ display?: string;
186
+ position?: string;
187
+ size?: {
188
+ w: number;
189
+ h: number;
190
+ };
191
+ color?: string;
192
+ fills?: InspectFill[];
193
+ radius?: string;
194
+ effects?: InspectEffect[];
195
+ transform?: string;
196
+ opacity?: number;
197
+ /** `::placeholder`: font style and weight, when not the field's */
198
+ fontStyle?: string;
199
+ fontWeight?: number;
200
+ /** `::placeholder`: contrast of the placeholder text with the field's background */
201
+ contrast?: InspectContrast;
202
+ }
203
+ /** A row of the child tree; identical siblings are one row with a count */
204
+ export interface InspectTreeNode {
205
+ /** `tag.firstClass` */
206
+ element: string;
207
+ /** Position relative to the parent's border box (like Figma's x/y in a frame; a group's first member) */
208
+ x: number;
209
+ y: number;
210
+ w: number;
211
+ h: number;
212
+ /** `flex` or `grid` container */
213
+ layout?: 'flex' | 'grid';
214
+ text?: string;
215
+ /** Identical siblings this row stands for (2 or more) */
216
+ count?: number;
217
+ children?: InspectTreeNode[];
218
+ /** Rendered element children (at the depth limit, where they are not listed) */
219
+ childCount?: number;
220
+ /** Children that are not rendered (not listed) */
221
+ hiddenChildren?: number;
222
+ }
223
+ /** Why the element cannot be seen, or where it is when it is out of view */
224
+ export interface InspectVisibility {
225
+ /** No box: `display: none` on it or an ancestor, or not in the page's layout */
226
+ notRendered?: true;
227
+ /** Rendered but not seen, e.g. `visibility: hidden`, `zero size` */
228
+ hidden?: string;
229
+ /** Out of the viewport: `above`, `below`, `left` or `right` */
230
+ offscreen?: string;
231
+ /** Topmost element at the center of its visible part, when another one */
232
+ coveredBy?: string;
233
+ /** The cover paints nothing there: the element shows, but clicks land on the cover */
234
+ coverTransparent?: true;
235
+ }
236
+ /** A property asked for with `--props` */
237
+ export interface InspectProp {
238
+ /** Computed value as Chrome reports it */
239
+ computed: string;
240
+ /** Normalized: px as numbers, colors as hex */
241
+ value: string;
242
+ }
243
+ /** A declaration that has no effect, and why */
244
+ export interface InspectHint {
245
+ /** `inactive` (has no effect), `unset-variable` (var() of an unset custom property), `not-inherited` (a form control in the browser's font) */
246
+ kind: 'inactive' | 'unset-variable' | 'not-inherited';
247
+ /** Property as written */
248
+ property: string;
249
+ value: string;
250
+ /** e.g. `display is block` */
251
+ reason: string;
252
+ /** e.g. `use display: flex or grid on this element` */
253
+ fix: string;
254
+ /** e.g. `.hero (app.css:12)` */
255
+ source: string;
256
+ }
257
+ /** Which declaration sets a property */
258
+ export interface InspectRule {
259
+ /** Longhand, or the shorthand when one declaration sets all its sides */
260
+ property: string;
261
+ /** Value as written (custom properties visible) */
262
+ value: string;
263
+ /** Computed value, normalized (px as numbers, colors as hex), when the written one has `var()` */
264
+ computed?: string;
265
+ /** e.g. `.btn-primary (bootstrap.min.css:5:52628)`, `style attribute` */
266
+ source: string;
267
+ /** Selectors of the declarations it beats */
268
+ overrides?: string[];
269
+ /** Set on an ancestor this many levels up (inherited) */
270
+ inherited?: number;
271
+ important?: true;
272
+ layer?: string;
273
+ /** Media or container condition of the rule */
274
+ condition?: string;
275
+ }
276
+ /** One declaration in the cascade of a property (`--why`) */
277
+ export interface InspectWhyEntry {
278
+ /** Value as written (a shorthand's whole value) */
279
+ value: string;
280
+ /** Shorthand or logical property it was written as */
281
+ via?: string;
282
+ /** The value with its custom properties substituted, when it has `var()` */
283
+ resolved?: string;
284
+ /** Custom properties it uses that are not set (the declaration is then invalid) */
285
+ unset?: string[];
286
+ source: string;
287
+ /** Specificity of the rule's selector (ids, classes, types) */
288
+ specificity?: [number, number, number];
289
+ /** `applied` (wins), `overridden`, or `inherited` (from an ancestor: the winner, or one it beat there) */
290
+ status: 'applied' | 'overridden' | 'inherited';
291
+ important?: true;
292
+ layer?: string;
293
+ condition?: string;
294
+ }
295
+ /** `--why`: every declaration of one property, winner first */
296
+ export interface InspectWhy {
297
+ property: string;
298
+ /** Computed value, normalized (px as numbers, colors as hex) */
299
+ computed: string;
300
+ chain: InspectWhyEntry[];
301
+ /** Where the custom properties of the winning value are set */
302
+ variables?: InspectVariable[];
303
+ }
304
+ /** A custom property a winning value uses, and where it is set */
305
+ export interface InspectVariable {
306
+ name: string;
307
+ value: string;
308
+ source: string;
309
+ /** Set on an ancestor this many levels up */
310
+ inherited?: number;
311
+ }
312
+ /** `bdg dom inspect` result */
313
+ export interface InspectResult {
314
+ success: true;
315
+ /** Selector the element was found with (for an index: the cached query's) */
316
+ selector: string;
317
+ /** Elements the selector matched */
318
+ count: number;
319
+ /** Which match was inspected (0-based) */
320
+ index: number;
321
+ /**
322
+ * How the match was chosen when no index was given and several matched:
323
+ * the first rendered one (`first-visible`, when earlier ones are not
324
+ * rendered) or the first
325
+ */
326
+ picked?: 'first-visible' | 'first';
327
+ /** `tag#id.c1.c2(+N)` */
328
+ element: string;
329
+ /** Its text (innerText) or form value, at most 30 characters; not for containers */
330
+ content?: string;
331
+ /** Placeholder of an empty field */
332
+ placeholder?: string;
333
+ /** Enclosing iframe(s) and shadow root */
334
+ context?: string;
335
+ /** Absent when not rendered */
336
+ rect?: InspectRect;
337
+ visibility: InspectVisibility;
338
+ /**
339
+ * `dark` when the page renders a dark theme (dark canvas or dark page
340
+ * background) while the session prefers dark; colors are then the dark
341
+ * theme's
342
+ */
343
+ theme?: 'dark';
344
+ /**
345
+ * Running CSS transitions (their property) and animations (their name):
346
+ * the values read are mid-way and will still change
347
+ */
348
+ animating?: string[];
349
+ /** `prefers-color-scheme` the page sees */
350
+ colorScheme?: 'light' | 'dark';
351
+ box?: InspectBox;
352
+ layout?: InspectLayout;
353
+ text?: InspectText;
354
+ fills?: InspectFill[];
355
+ opacity?: number;
356
+ blend?: string;
357
+ strokes?: InspectStroke[];
358
+ /** Corner radii top-left, top-right, bottom-right, bottom-left */
359
+ radius?: Sides;
360
+ outline?: {
361
+ width: number;
362
+ style: string;
363
+ color: string;
364
+ offset?: number;
365
+ };
366
+ effects?: InspectEffect[];
367
+ fx?: InspectFx;
368
+ state?: InspectState;
369
+ pseudo?: InspectPseudo[];
370
+ children?: InspectTreeNode[];
371
+ /** Children not rendered (not listed) */
372
+ hiddenChildren?: number;
373
+ /** Tree rows left out beyond `--tree-limit` */
374
+ moreRows?: number;
375
+ /** `--all`: every longhand that is not a no-op default, collapsed into shorthands */
376
+ all?: Record<string, string>;
377
+ /** `--props`: the properties asked for */
378
+ props?: Record<string, InspectProp>;
379
+ /** Declarations that have no effect (checked by default; empty when none) */
380
+ hints?: InspectHint[];
381
+ /** `--rules`: the declaration that sets each shown property */
382
+ rules?: InspectRule[];
383
+ /** `--why <property>`: one entry, or one per longhand of a shorthand whose sides differ */
384
+ why?: InspectWhy[];
385
+ /** The cascade was not read: Chrome took longer than the time allowed, or failed */
386
+ cascade?: 'timeout' | 'failed';
387
+ }
388
+ //# sourceMappingURL=inspectTypes.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * What `bdg dom inspect` returns: one element's look as a designer reads it,
3
+ * in a schema aligned with Figma's concepts (rect, box, layout with
4
+ * hug/fill/fixed sizing, text, fills, strokes, radius, effects, children), so
5
+ * it can be compared key by key with a design. Lengths are CSS px as numbers
6
+ * (one decimal); other units stay text. Colors are hex (`#rrggbbaa` when
7
+ * translucent).
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=inspectTypes.js.map
@@ -4,7 +4,8 @@
4
4
  * Types for handshake, start session, and stop session operations.
5
5
  */
6
6
  import type { IPCErrorCode } from './errors.js';
7
- import type { TelemetryType } from '../../types.js';
7
+ import type { PageLoadingState } from '../protocol/commands.js';
8
+ import type { ColorScheme, TelemetryType, ViewportSize } from '../../types.js';
8
9
  /**
9
10
  * Base message interface with type and session ID.
10
11
  */
@@ -53,6 +54,10 @@ export interface SessionOptions {
53
54
  chromeWsUrl?: string;
54
55
  /** Custom Chrome flags (e.g., ['--ignore-certificate-errors']). */
55
56
  chromeFlags?: string[];
57
+ /** Viewport size the page is emulated at (`--viewport`). */
58
+ viewport?: ViewportSize;
59
+ /** `prefers-color-scheme` the page is emulated with (`--color-scheme`). */
60
+ colorScheme?: ColorScheme;
56
61
  }
57
62
  /**
58
63
  * Start session request (client → daemon).
@@ -81,6 +86,8 @@ export interface StartSessionResponseData {
81
86
  targetTitle?: string;
82
87
  /** HTTP status of the page's main document, when known. */
83
88
  documentStatus?: number;
89
+ /** The page had not finished loading when the start returned. */
90
+ loading?: PageLoadingState;
84
91
  /** True if a stale session was auto-recovered before this one started. */
85
92
  recovered?: boolean;
86
93
  /** Target URL or ws URL of the stale session that was recovered, if recorded. */
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import type { IPCMessage } from './lifecycle.js';
7
7
  import type { PageState, SessionActivity } from './types.js';
8
- import type { NetworkRequest, TelemetryType } from '../../types.js';
8
+ import type { ColorScheme, NetworkRequest, TelemetryType, ViewportSize } from '../../types.js';
9
9
  /**
10
10
  * Status request (client → daemon).
11
11
  */
@@ -35,6 +35,10 @@ export interface StatusResponseData {
35
35
  activeTelemetry?: TelemetryType[];
36
36
  /** When `--timeout` stops the session (epoch ms) */
37
37
  autoStopAt?: number;
38
+ /** Viewport the page is emulated at (`--viewport`) */
39
+ viewport?: ViewportSize;
40
+ /** `prefers-color-scheme` the page is emulated with (`--color-scheme`) */
41
+ colorScheme?: ColorScheme;
38
42
  };
39
43
  /** Session activity metrics. */
40
44
  activity?: SessionActivity;
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Common types used across session messages and session commands.
5
5
  */
6
+ import type { ColorScheme, ViewportSize } from '../../types.js';
6
7
  /**
7
8
  * Session activity metrics.
8
9
  */
@@ -24,5 +25,9 @@ export interface PageState {
24
25
  url: string;
25
26
  /** Current page title. */
26
27
  title: string;
28
+ /** Layout viewport without scrollbars (left out when the page did not answer in time). */
29
+ viewport?: ViewportSize;
30
+ /** `prefers-color-scheme` the page sees (left out when the page did not answer in time). */
31
+ colorScheme?: ColorScheme;
27
32
  }
28
33
  //# sourceMappingURL=types.d.ts.map
@@ -16,7 +16,8 @@ type WithTypeAndSession = {
16
16
  * @param requestName - Name used in errors and logs
17
17
  * @param expectedType - Response type to validate, if any
18
18
  * @param timeoutMs - How long to wait for the response (default: IPC timeout)
19
+ * @param socketPath - Daemon socket (default: the selected session's)
19
20
  * @returns The daemon's response
20
21
  */
21
- export declare function sendRequest<TRequest extends WithTypeAndSession, TResponse extends WithTypeAndSession>(request: TRequest, requestName: string, expectedType?: string, timeoutMs?: number): Promise<TResponse>;
22
+ export declare function sendRequest<TRequest extends WithTypeAndSession, TResponse extends WithTypeAndSession>(request: TRequest, requestName: string, expectedType?: string, timeoutMs?: number, socketPath?: string): Promise<TResponse>;
22
23
  //# sourceMappingURL=index.d.ts.map
@@ -20,10 +20,10 @@ const log = createLogger('client');
20
20
  * @param requestName - Name used in errors and logs
21
21
  * @param expectedType - Response type to validate, if any
22
22
  * @param timeoutMs - How long to wait for the response (default: IPC timeout)
23
+ * @param socketPath - Daemon socket (default: the selected session's)
23
24
  * @returns The daemon's response
24
25
  */
25
- export async function sendRequest(request, requestName, expectedType, timeoutMs = getIPCRequestTimeout()) {
26
- const socketPath = getDaemonSocketPath();
26
+ export async function sendRequest(request, requestName, expectedType, timeoutMs = getIPCRequestTimeout(), socketPath = getDaemonSocketPath()) {
27
27
  return new Promise((resolve, reject) => {
28
28
  const buffer = new JSONLBuffer();
29
29
  let resolved = false;
@@ -0,0 +1,185 @@
1
+ /**
2
+ * What a DOM action changed on the page: whether it navigated (to a new
3
+ * document or within the same one), which messages and elements appeared,
4
+ * whether it had no visible effect at all, and whether the page was still
5
+ * working on the result. Costs one page script sent before the action (not
6
+ * waited for: CDP runs it before the action's own scripts) and one read
7
+ * after it, plus a second look 300 ms later when nothing seemed to happen.
8
+ * Worst case, when the page does not answer (a navigation is pending, or a
9
+ * long script runs), the snapshot is given up after {@link START_TIMEOUT_MS}
10
+ * and each read after {@link READ_TIMEOUT_MS}.
11
+ */
12
+ import type { CDPConnection } from '../../connection/cdp.js';
13
+ import type { ActionEffects, NewMessage, PageNavigation, PendingChanges, ShownElement, TriggeredRequest } from '../../ipc/protocol/domTypes.js';
14
+ import { type NavigationEvents } from './pageActivity.js';
15
+ /** A message element as a page snapshot lists it */
16
+ export interface SeenMessage {
17
+ /** Number of the element, stable within its document */
18
+ id: number;
19
+ text: string;
20
+ element: string;
21
+ }
22
+ export type { NavigationEvents };
23
+ /** Signs that the page was still working at a read (same document only) */
24
+ export interface SettleSignals {
25
+ /** How long ago each recent burst of structural DOM changes was (ms, newest last) */
26
+ burstAges: number[];
27
+ /** A loading indicator shown since the action began, described */
28
+ loading: string | null;
29
+ }
30
+ /** The page after the action */
31
+ export interface ReadSnapshot {
32
+ href: string;
33
+ /** The snapshot was gone: a new document */
34
+ fresh: boolean;
35
+ /** DOM changes counted since the start (same document only) */
36
+ changes?: number;
37
+ /** Why "no effect" can't be claimed even without changes */
38
+ uncertain?: string;
39
+ messages: SeenMessage[];
40
+ /** Whether the page was still working (same document only) */
41
+ settle?: SettleSignals;
42
+ /** Elements the action showed (when asked for) */
43
+ shown?: ShownElement[];
44
+ }
45
+ /** What collecting saw of the page's work, for {@link pendingChanges} */
46
+ export interface PageWork {
47
+ /** Signals of the last read, when there was one in the same document */
48
+ settle?: SettleSignals;
49
+ /** The DOM kept changing in bursts over a second look ({@link domLooksBusy}) */
50
+ domChanging: boolean;
51
+ /** A read got no answer within its time (a long script) */
52
+ unresponsive: boolean;
53
+ /** A main-frame load was still pending */
54
+ navigating: boolean;
55
+ }
56
+ /** Effects, plus the page's work for deciding whether it had settled */
57
+ export interface CollectedEffects extends ActionEffects {
58
+ work?: PageWork;
59
+ }
60
+ /** What the action did besides changing the page, for the "no effect" decision */
61
+ export interface OtherActivity {
62
+ /** Requests started during the action */
63
+ requests: number;
64
+ /** Dialogs opened during the action */
65
+ dialogs: number;
66
+ /** A window, tab or download was opened */
67
+ opened: boolean;
68
+ }
69
+ /**
70
+ * Messages that are new after the action: all of them after a new document
71
+ * loaded; otherwise those whose text is shown more often than before (a
72
+ * re-rendered message with the same text is not new) and those whose
73
+ * element changed its text. Texts that tick on their own
74
+ * ({@link TICKING_TEXT}: clocks, counters) are left out; other elements
75
+ * that change on their own (a rotating banner) are not recognised. Each text
76
+ * is reported once, at most {@link MAX_NEW_MESSAGES}, cut to
77
+ * {@link MAX_MESSAGE_LENGTH} characters.
78
+ *
79
+ * @param before - Messages before the action
80
+ * @param after - Messages after the action
81
+ * @param newDocument - Whether a new document loaded
82
+ * @returns New messages
83
+ */
84
+ export declare function newMessages(before: SeenMessage[], after: SeenMessage[], newDocument: boolean): NewMessage[];
85
+ /**
86
+ * Elements to report as shown: those whose text is not already reported as
87
+ * a new message, at most {@link MAX_SHOWN_ELEMENTS}, texts cut to
88
+ * {@link MAX_MESSAGE_LENGTH} characters.
89
+ *
90
+ * @param shown - Elements the page found shown by the action
91
+ * @param messages - New messages being reported
92
+ * @returns Elements to report
93
+ */
94
+ export declare function shownElements(shown: ShownElement[], messages: NewMessage[]): ShownElement[];
95
+ /**
96
+ * Whether a read's DOM looks busy, worth a second look: at least
97
+ * {@link BUSY_BURSTS} bursts of structural changes within
98
+ * {@link BUSY_WINDOW_MS}, the last within {@link BUSY_RECENT_MS}. Text-only
99
+ * changes (clocks) and style changes (animations) are not bursts.
100
+ *
101
+ * @param settle - Signals of the read
102
+ * @returns True when the DOM may still be changing
103
+ */
104
+ export declare function domLooksBusy(settle: SettleSignals | undefined): boolean;
105
+ /**
106
+ * Whether the DOM kept changing during the second look: at least
107
+ * {@link BUSY_BURSTS} new bursts within the time since the first read (a
108
+ * render that ends in two commits, or a poller updating once a second, does
109
+ * not count).
110
+ *
111
+ * @param settle - Signals of the second read
112
+ * @param sinceMs - Time since the first read
113
+ * @returns True when the DOM is still changing
114
+ */
115
+ export declare function domKeptChanging(settle: SettleSignals | undefined, sinceMs: number): boolean;
116
+ /**
117
+ * What the page was still working on when the action returned, or undefined
118
+ * when it looked settled: content requests (documents, fetch/XHR, scripts)
119
+ * still pending, a new document still loading, a loading indicator that
120
+ * appeared, a DOM still changing ({@link domKeptChanging}), or a page that
121
+ * did not answer (a long script). A result a timer renders later, with no
122
+ * DOM change before it, is not seen.
123
+ *
124
+ * @param work - What collecting saw
125
+ * @param requests - Requests the action triggered (with pending ones)
126
+ * @returns Pending work, or undefined
127
+ */
128
+ export declare function pendingChanges(work: PageWork, requests?: TriggeredRequest[]): PendingChanges | undefined;
129
+ /**
130
+ * How the page's location changed: a new document committed in the main
131
+ * frame (also when it has the URL it had, as after a form POST that
132
+ * redirects back), or a same-document URL change (history API, hash).
133
+ *
134
+ * Without the URL before the action, a same-document change is reported
135
+ * only when Chrome announced one.
136
+ *
137
+ * @param startHref - URL before the action (undefined when not read)
138
+ * @param read - Page read after the action (undefined when not read)
139
+ * @param events - Main-frame navigation events
140
+ * @returns Navigation, or undefined when the location did not change
141
+ */
142
+ export declare function pageNavigation(startHref: string | undefined, read: ReadSnapshot | undefined, events: NavigationEvents): PageNavigation | undefined;
143
+ /**
144
+ * Whether an action had no visible effect: the page was read before and
145
+ * after in the same document, it counted no DOM change, nothing made the
146
+ * check uncertain, and no navigation, message, shown element, request,
147
+ * dialog or new window happened.
148
+ *
149
+ * @param read - Page read after the action
150
+ * @param effects - Navigation and messages found
151
+ * @param activity - Requests, dialogs and windows during the action
152
+ * @returns True to report `effect: "none"`
153
+ */
154
+ export declare function hadNoEffect(read: ReadSnapshot | undefined, effects: ActionEffects, activity: OtherActivity): boolean;
155
+ /** What collecting looks at besides navigation and messages */
156
+ export interface CollectOptions {
157
+ /** Dialogs the action opened */
158
+ dialogs: number;
159
+ /** Decide "no effect" (with a second look when nothing seemed to happen) */
160
+ detectNoEffect: boolean;
161
+ /** List the elements the action showed */
162
+ reportShown?: boolean;
163
+ /** Take a second look when the DOM looks busy, to tell whether it is still changing */
164
+ detectUnsettled?: boolean;
165
+ }
166
+ /** Collects what changed, once the action and its wait are done */
167
+ export interface ActionEffectsWatch {
168
+ /**
169
+ * @param options - Dialogs, and what to decide and list
170
+ * @returns What changed, and the page's work at the end
171
+ */
172
+ collect(options: CollectOptions): Promise<CollectedEffects>;
173
+ /** Stop listening and stop the page's watch (always call) */
174
+ dispose(): void;
175
+ }
176
+ /**
177
+ * Start watching an action's effects: listen for main-frame navigations,
178
+ * document statuses, requests and new windows, and send the page snapshot
179
+ * without waiting for it.
180
+ *
181
+ * @param cdp - CDP connection
182
+ * @returns Watch to collect from after the action
183
+ */
184
+ export declare function watchActionEffects(cdp: CDPConnection): ActionEffectsWatch;
185
+ //# sourceMappingURL=actionEffects.d.ts.map