browser-debugger-cli 0.9.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 (133) hide show
  1. package/README.md +4 -1
  2. package/dist/commands/dom/a11y.js +2 -1
  3. package/dist/commands/dom/formInteraction.js +56 -25
  4. package/dist/commands/dom/helpers/keyAttributes.d.ts +20 -0
  5. package/dist/commands/dom/helpers/keyAttributes.js +54 -0
  6. package/dist/commands/dom/helpers/query.d.ts +1 -1
  7. package/dist/commands/dom/helpers/query.js +66 -19
  8. package/dist/commands/dom/helpers/runElementCommand.js +4 -3
  9. package/dist/commands/dom/helpers/screenshot.js +85 -12
  10. package/dist/commands/dom/index.d.ts +1 -0
  11. package/dist/commands/dom/index.js +8 -3
  12. package/dist/commands/dom/inspect.d.ts +15 -0
  13. package/dist/commands/dom/inspect.js +82 -0
  14. package/dist/commands/dom/layout.js +2 -2
  15. package/dist/commands/dom/listeners.js +2 -2
  16. package/dist/commands/dom/semanticUtils.d.ts +14 -1
  17. package/dist/commands/dom/semanticUtils.js +44 -3
  18. package/dist/commands/network/list.js +13 -2
  19. package/dist/commands/optionBehaviors.js +48 -6
  20. package/dist/commands/page.d.ts +1 -1
  21. package/dist/commands/page.js +62 -3
  22. package/dist/commands/shared/commonOptions.d.ts +4 -0
  23. package/dist/commands/shared/commonOptions.js +9 -0
  24. package/dist/commands/shared/optionTypes.d.ts +21 -0
  25. package/dist/commands/shared/startHelpers.d.ts +66 -0
  26. package/dist/commands/shared/startHelpers.js +91 -10
  27. package/dist/commands/shared/validation.d.ts +11 -0
  28. package/dist/commands/shared/validation.js +16 -0
  29. package/dist/daemon/launcher.d.ts +8 -1
  30. package/dist/daemon/launcher.js +3 -1
  31. package/dist/daemon/session/Session.d.ts +7 -0
  32. package/dist/daemon/session/Session.js +23 -1
  33. package/dist/daemon/session/commandRegistry.d.ts +14 -1
  34. package/dist/daemon/session/commandRegistry.js +65 -9
  35. package/dist/daemon/session/interactions.d.ts +18 -5
  36. package/dist/daemon/session/interactions.js +22 -12
  37. package/dist/daemon.js +3565 -329
  38. package/dist/errors/messages.d.ts +69 -0
  39. package/dist/errors/messages.js +102 -1
  40. package/dist/index.js +2416 -1320
  41. package/dist/ipc/client.d.ts +9 -0
  42. package/dist/ipc/client.js +13 -0
  43. package/dist/ipc/protocol/commands.d.ts +56 -1
  44. package/dist/ipc/protocol/commands.js +2 -0
  45. package/dist/ipc/protocol/domTypes.d.ts +35 -2
  46. package/dist/ipc/protocol/inspectTypes.d.ts +388 -0
  47. package/dist/ipc/protocol/inspectTypes.js +10 -0
  48. package/dist/runtime/dom/actionEffects.d.ts +94 -15
  49. package/dist/runtime/dom/actionEffects.js +173 -27
  50. package/dist/runtime/dom/actionEffectsScripts.d.ts +52 -14
  51. package/dist/runtime/dom/actionEffectsScripts.js +224 -32
  52. package/dist/runtime/dom/elementInfo.d.ts +26 -0
  53. package/dist/runtime/dom/elementInfo.js +65 -0
  54. package/dist/runtime/dom/eventListeners.js +14 -4
  55. package/dist/runtime/dom/formFillHelpers/fill.d.ts +3 -4
  56. package/dist/runtime/dom/formFillHelpers/fill.js +77 -28
  57. package/dist/runtime/dom/frameSelection.d.ts +11 -0
  58. package/dist/runtime/dom/frameSelection.js +20 -1
  59. package/dist/runtime/dom/frames.d.ts +38 -5
  60. package/dist/runtime/dom/frames.js +136 -21
  61. package/dist/runtime/dom/inspect.d.ts +28 -0
  62. package/dist/runtime/dom/inspect.js +557 -0
  63. package/dist/runtime/dom/inspectAllStyles.d.ts +62 -0
  64. package/dist/runtime/dom/inspectAllStyles.js +385 -0
  65. package/dist/runtime/dom/inspectCascade.d.ts +94 -0
  66. package/dist/runtime/dom/inspectCascade.js +371 -0
  67. package/dist/runtime/dom/inspectCascadeModel.d.ts +39 -0
  68. package/dist/runtime/dom/inspectCascadeModel.js +232 -0
  69. package/dist/runtime/dom/inspectHints.d.ts +62 -0
  70. package/dist/runtime/dom/inspectHints.js +305 -0
  71. package/dist/runtime/dom/inspectLayoutModel.d.ts +87 -0
  72. package/dist/runtime/dom/inspectLayoutModel.js +346 -0
  73. package/dist/runtime/dom/inspectModel.d.ts +74 -0
  74. package/dist/runtime/dom/inspectModel.js +184 -0
  75. package/dist/runtime/dom/inspectPaintModel.d.ts +157 -0
  76. package/dist/runtime/dom/inspectPaintModel.js +461 -0
  77. package/dist/runtime/dom/inspectRules.d.ts +37 -0
  78. package/dist/runtime/dom/inspectRules.js +101 -0
  79. package/dist/runtime/dom/inspectScripts.d.ts +132 -0
  80. package/dist/runtime/dom/inspectScripts.js +263 -0
  81. package/dist/runtime/dom/inspectTree.d.ts +40 -0
  82. package/dist/runtime/dom/inspectTree.js +134 -0
  83. package/dist/runtime/dom/inspectVariables.d.ts +33 -0
  84. package/dist/runtime/dom/inspectVariables.js +94 -0
  85. package/dist/runtime/dom/inspectWhyModel.d.ts +20 -0
  86. package/dist/runtime/dom/inspectWhyModel.js +134 -0
  87. package/dist/runtime/dom/layout.d.ts +5 -1
  88. package/dist/runtime/dom/layout.js +10 -3
  89. package/dist/runtime/dom/listenerPageScripts.d.ts +11 -5
  90. package/dist/runtime/dom/listenerPageScripts.js +95 -9
  91. package/dist/runtime/dom/listenerSummary.d.ts +4 -0
  92. package/dist/runtime/dom/listenerSummary.js +26 -9
  93. package/dist/runtime/dom/reactEventHelpers.d.ts +5 -0
  94. package/dist/runtime/dom/reactEventHelpers.js +12 -4
  95. package/dist/runtime/page/emulation.d.ts +20 -0
  96. package/dist/runtime/page/emulation.js +37 -0
  97. package/dist/telemetry/a11y.d.ts +10 -0
  98. package/dist/telemetry/a11y.js +78 -1
  99. package/dist/telemetry/console.d.ts +1 -0
  100. package/dist/telemetry/console.js +100 -5
  101. package/dist/telemetry/network.js +3 -1
  102. package/dist/types.d.ts +32 -0
  103. package/dist/ui/formatters/details.d.ts +8 -0
  104. package/dist/ui/formatters/details.js +59 -3
  105. package/dist/ui/formatters/dom.d.ts +2 -1
  106. package/dist/ui/formatters/dom.js +25 -9
  107. package/dist/ui/formatters/inspect.d.ts +39 -0
  108. package/dist/ui/formatters/inspect.js +596 -0
  109. package/dist/ui/formatters/keyAttributes.d.ts +19 -0
  110. package/dist/ui/formatters/keyAttributes.js +84 -0
  111. package/dist/ui/formatters/layout.js +2 -2
  112. package/dist/ui/formatters/networkHeaders.d.ts +13 -0
  113. package/dist/ui/formatters/networkHeaders.js +23 -3
  114. package/dist/ui/formatters/networkList.d.ts +29 -1
  115. package/dist/ui/formatters/networkList.js +86 -20
  116. package/dist/ui/formatters/status.js +1 -1
  117. package/dist/ui/formatting.d.ts +9 -0
  118. package/dist/ui/formatting.js +6 -3
  119. package/dist/ui/messages/commands.d.ts +123 -7
  120. package/dist/ui/messages/commands.js +181 -10
  121. package/dist/ui/messages/networkMessages.d.ts +14 -0
  122. package/dist/ui/messages/networkMessages.js +18 -0
  123. package/dist/ui/messages/session.d.ts +14 -0
  124. package/dist/ui/messages/session.js +20 -0
  125. package/dist/utils/async.d.ts +9 -0
  126. package/dist/utils/async.js +17 -0
  127. package/dist/utils/color.d.ts +84 -0
  128. package/dist/utils/color.js +376 -0
  129. package/dist/utils/cssValues.d.ts +109 -0
  130. package/dist/utils/cssValues.js +236 -0
  131. package/dist/utils/selectorFilters.d.ts +12 -0
  132. package/dist/utils/selectorFilters.js +29 -0
  133. package/package.json +1 -1
@@ -218,12 +218,21 @@ export declare function domScroll(params: NoType<(typeof COMMANDS)['dom_scroll']
218
218
  * @returns Where the page is now
219
219
  */
220
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'>>;
221
228
  /** Run form discovery and return the raw structured form data. */
222
229
  export declare function domFormDiscover(): Promise<ClientResponse<'dom_form_discover'>>;
223
230
  /** List the event listeners that run for an element. */
224
231
  export declare function domListeners(params: NoType<(typeof COMMANDS)['dom_listeners']['requestSchema']>): Promise<ClientResponse<'dom_listeners'>>;
225
232
  /** Positions, sizes and visibility of elements. */
226
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'>>;
227
236
  /**
228
237
  * Wait until elements appear, become visible, contain a text or are gone,
229
238
  * and/or the page has loaded.
@@ -313,6 +313,15 @@ export async function domScroll(params) {
313
313
  export async function pageNavigate(params) {
314
314
  return sendCommand('page_navigate', params);
315
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
+ }
316
325
  /** Run form discovery and return the raw structured form data. */
317
326
  export async function domFormDiscover() {
318
327
  return sendCommand('dom_form_discover', {});
@@ -325,6 +334,10 @@ export async function domListeners(params) {
325
334
  export async function domLayout(params) {
326
335
  return sendCommand('dom_layout', params);
327
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
+ }
328
341
  /** Time the client gives `dom wait` beyond its --timeout (the daemon reports the timeout first) */
329
342
  const WAIT_IPC_MARGIN_MS = 10_000;
330
343
  /**
@@ -6,8 +6,9 @@
6
6
  */
7
7
  import type { HintDetails } from '../../errors/notices.js';
8
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;
@@ -234,6 +239,8 @@ export interface DomClickCommand {
234
239
  wait?: boolean;
235
240
  /** Double or right click, or only hover (default: click) */
236
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;
237
244
  }
238
245
  export type DomClickData = ClickResult;
239
246
  /**
@@ -305,6 +312,31 @@ export interface DomLayoutCommand {
305
312
  backendNodeId?: number;
306
313
  }
307
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;
308
340
  /**
309
341
  * dom_form_discover: run the form discovery script and return raw form data.
310
342
  */
@@ -337,8 +369,10 @@ export type RegistryShape = {
337
369
  dom_form_discover: CommandDef<DomFormDiscoverCommand, DomFormDiscoverData>;
338
370
  dom_listeners: CommandDef<DomListenersCommand, DomListenersData>;
339
371
  dom_layout: CommandDef<DomLayoutCommand, DomLayoutData>;
372
+ dom_inspect: CommandDef<DomInspectCommand, DomInspectData>;
340
373
  dom_wait: CommandDef<DomWaitCommand, DomWaitData>;
341
374
  page_navigate: CommandDef<PageNavigateCommand, PageNavigationResult>;
375
+ page_emulate: CommandDef<PageEmulateCommand, PageEmulationResult>;
342
376
  };
343
377
  /** What `bdg page` does */
344
378
  export type PageAction = 'navigate' | 'reload' | 'back' | 'forward';
@@ -421,6 +455,27 @@ export interface PageNavigateCommand {
421
455
  /** Wait for the page to load (default: true) */
422
456
  wait?: boolean;
423
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
+ }
424
479
  /**
425
480
  * Central registry of all session commands.
426
481
  * Maps command names to their request/response schemas.
@@ -31,9 +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(),
36
37
  dom_layout: defineCommand(),
38
+ dom_inspect: defineCommand(),
37
39
  dom_wait: defineCommand(),
38
40
  };
39
41
  //# sourceMappingURL=commands.js.map
@@ -60,14 +60,40 @@ export interface NewMessage {
60
60
  /** The element showing it, e.g. `div#flash.flash.error` */
61
61
  element: string;
62
62
  }
63
+ /** An element a hover or key press showed (added, or made visible) */
64
+ export interface ShownElement {
65
+ /** Its visible text, at most 120 characters */
66
+ text: string;
67
+ /** The element, e.g. `div.figcaption` */
68
+ element: string;
69
+ }
70
+ /** What the page was still working on when an action returned */
71
+ export interface PendingChanges {
72
+ /** Content requests (documents, fetch/XHR, scripts) the action started that were still running */
73
+ requests?: number;
74
+ /** A new document was still loading */
75
+ navigation?: true;
76
+ /** A loading indicator that appeared during the action and was still shown, e.g. `div#loading` */
77
+ loading?: string;
78
+ /** The DOM was still changing (several bursts of changes, the last one under 150 ms ago) */
79
+ domChanging?: true;
80
+ /** The page did not answer within 250 ms (a long-running script) */
81
+ busy?: true;
82
+ }
63
83
  /** What an action changed on the page, besides its triggered requests */
64
84
  export interface ActionEffects {
65
85
  /** The page navigated or changed its URL (absent when it did not) */
66
86
  navigation?: PageNavigation;
67
87
  /** Messages that appeared or changed (at most 3; absent when none did) */
68
88
  messages?: NewMessage[];
89
+ /** Elements a hover or key press showed (at most 3, outermost first; absent when none) */
90
+ shown?: ShownElement[];
69
91
  /** "none" when the action had no visible effect: no DOM change, request or navigation */
70
92
  effect?: 'none';
93
+ /** False when the page was still changing as the action returned (absent otherwise) */
94
+ settled?: false;
95
+ /** What the page was still working on (with `settled: false`) */
96
+ pending?: PendingChanges;
71
97
  }
72
98
  /** A filled field's value differing from the one given */
73
99
  export interface FillValueMismatch {
@@ -270,9 +296,10 @@ export interface ElementListener {
270
296
  /**
271
297
  * Registered through this framework; `handler` is the real handler, not
272
298
  * the framework's dispatcher. React handlers are `on…` props of the node
273
- * (`reactProp`), run by React's dispatchers on its root container.
299
+ * (`reactProp`), run by React's dispatchers on its root container;
300
+ * Preact handlers are run by Preact's event proxy on the node itself.
274
301
  */
275
- framework?: 'jQuery' | 'React';
302
+ framework?: 'jQuery' | 'Preact' | 'React';
276
303
  /** React prop the handler is set as, e.g. `onClick`, `onClickCapture` */
277
304
  reactProp?: string;
278
305
  /** jQuery delegate selector (`.on(type, selector, fn)`) the element matched */
@@ -382,6 +409,12 @@ export interface ElementLayout {
382
409
  offScreenReason?: string;
383
410
  /** Topmost element at the center of its visible part, when that is another element */
384
411
  coveredBy?: string;
412
+ /**
413
+ * The covering element paints nothing at that point (no background, image,
414
+ * shadow or text of its own): the element still shows, but clicks land on
415
+ * the cover
416
+ */
417
+ coverTransparent?: true;
385
418
  /**
386
419
  * Why it cannot be seen although it is rendered: `opacity: 0` on it or an
387
420
  * ancestor, or a `clip-path`/`clip` that cuts it away entirely, e.g.
@@ -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