@visual-check/cli 0.1.2 → 0.2.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 (211) hide show
  1. package/dist/addon-child/image-files.js +1 -1
  2. package/dist/addon-child/image-files.js.map +1 -1
  3. package/dist/agent-skill/skill-files.d.ts +4 -0
  4. package/dist/agent-skill/skill-files.d.ts.map +1 -1
  5. package/dist/agent-skill/skill-files.js +4 -0
  6. package/dist/agent-skill/skill-files.js.map +1 -1
  7. package/dist/baselines/baseline-error.d.ts +15 -2
  8. package/dist/baselines/baseline-error.d.ts.map +1 -1
  9. package/dist/baselines/baseline-error.js +32 -2
  10. package/dist/baselines/baseline-error.js.map +1 -1
  11. package/dist/capture/capture-session.d.ts +161 -30
  12. package/dist/capture/capture-session.d.ts.map +1 -1
  13. package/dist/capture/capture-session.js +263 -70
  14. package/dist/capture/capture-session.js.map +1 -1
  15. package/dist/capture/driver/cdp/cdp-page.d.ts.map +1 -1
  16. package/dist/capture/driver/cdp/cdp-page.js +120 -31
  17. package/dist/capture/driver/cdp/cdp-page.js.map +1 -1
  18. package/dist/capture/driver/cdp/failed-loads.d.ts +16 -0
  19. package/dist/capture/driver/cdp/failed-loads.d.ts.map +1 -0
  20. package/dist/capture/driver/cdp/failed-loads.js +71 -0
  21. package/dist/capture/driver/cdp/failed-loads.js.map +1 -0
  22. package/dist/capture/driver/cdp/launch-arguments.d.ts +7 -1
  23. package/dist/capture/driver/cdp/launch-arguments.d.ts.map +1 -1
  24. package/dist/capture/driver/cdp/launch-arguments.js +8 -1
  25. package/dist/capture/driver/cdp/launch-arguments.js.map +1 -1
  26. package/dist/capture/driver/driver.d.ts +88 -4
  27. package/dist/capture/driver/driver.d.ts.map +1 -1
  28. package/dist/capture/driver/driver.js +33 -0
  29. package/dist/capture/driver/driver.js.map +1 -1
  30. package/dist/capture/page-script.d.ts +7 -6
  31. package/dist/capture/page-script.d.ts.map +1 -1
  32. package/dist/capture/page-script.js +10 -9
  33. package/dist/capture/page-script.js.map +1 -1
  34. package/dist/capture/prepare-capture.d.ts +50 -3
  35. package/dist/capture/prepare-capture.d.ts.map +1 -1
  36. package/dist/capture/prepare-capture.js +157 -16
  37. package/dist/capture/prepare-capture.js.map +1 -1
  38. package/dist/commands/check-storybooks.d.ts +5 -4
  39. package/dist/commands/check-storybooks.d.ts.map +1 -1
  40. package/dist/commands/check-storybooks.js +11 -8
  41. package/dist/commands/check-storybooks.js.map +1 -1
  42. package/dist/commands/consistency-output.d.ts.map +1 -1
  43. package/dist/commands/consistency-output.js +3 -3
  44. package/dist/commands/consistency-output.js.map +1 -1
  45. package/dist/commands/failed-loads-hint.d.ts +7 -0
  46. package/dist/commands/failed-loads-hint.d.ts.map +1 -0
  47. package/dist/commands/failed-loads-hint.js +16 -0
  48. package/dist/commands/failed-loads-hint.js.map +1 -0
  49. package/dist/commands/local-update.d.ts +22 -0
  50. package/dist/commands/local-update.d.ts.map +1 -0
  51. package/dist/commands/local-update.js +39 -0
  52. package/dist/commands/local-update.js.map +1 -0
  53. package/dist/commands/network-warning.d.ts.map +1 -1
  54. package/dist/commands/network-warning.js +2 -18
  55. package/dist/commands/network-warning.js.map +1 -1
  56. package/dist/commands/plan-snapshots.d.ts +23 -8
  57. package/dist/commands/plan-snapshots.d.ts.map +1 -1
  58. package/dist/commands/plan-snapshots.js +15 -9
  59. package/dist/commands/plan-snapshots.js.map +1 -1
  60. package/dist/commands/report-entries.d.ts +5 -2
  61. package/dist/commands/report-entries.d.ts.map +1 -1
  62. package/dist/commands/report-entries.js +63 -15
  63. package/dist/commands/report-entries.js.map +1 -1
  64. package/dist/commands/run-browser.d.ts +5 -5
  65. package/dist/commands/run-browser.d.ts.map +1 -1
  66. package/dist/commands/run-browser.js +1 -0
  67. package/dist/commands/run-browser.js.map +1 -1
  68. package/dist/commands/run-cli.d.ts +16 -5
  69. package/dist/commands/run-cli.d.ts.map +1 -1
  70. package/dist/commands/run-cli.js +74 -54
  71. package/dist/commands/run-cli.js.map +1 -1
  72. package/dist/commands/run-report.d.ts +3 -3
  73. package/dist/commands/run-report.d.ts.map +1 -1
  74. package/dist/commands/run-report.js +4 -2
  75. package/dist/commands/run-report.js.map +1 -1
  76. package/dist/commands/run-snapshots.d.ts +7 -4
  77. package/dist/commands/run-snapshots.d.ts.map +1 -1
  78. package/dist/commands/run-snapshots.js +49 -17
  79. package/dist/commands/run-snapshots.js.map +1 -1
  80. package/dist/commands/snapshot-result.d.ts +66 -9
  81. package/dist/commands/snapshot-result.d.ts.map +1 -1
  82. package/dist/commands/snapshot-result.js +46 -6
  83. package/dist/commands/snapshot-result.js.map +1 -1
  84. package/dist/commands/stop-message.d.ts.map +1 -1
  85. package/dist/commands/stop-message.js +6 -1
  86. package/dist/commands/stop-message.js.map +1 -1
  87. package/dist/commands/stopped-run.d.ts +10 -5
  88. package/dist/commands/stopped-run.d.ts.map +1 -1
  89. package/dist/commands/stopped-run.js +35 -22
  90. package/dist/commands/stopped-run.js.map +1 -1
  91. package/dist/commands/take-snapshot.d.ts +9 -6
  92. package/dist/commands/take-snapshot.d.ts.map +1 -1
  93. package/dist/commands/take-snapshot.js +16 -7
  94. package/dist/commands/take-snapshot.js.map +1 -1
  95. package/dist/commands/test-snapshot.d.ts +2 -2
  96. package/dist/commands/test-snapshot.d.ts.map +1 -1
  97. package/dist/commands/test-snapshot.js.map +1 -1
  98. package/dist/commands/update-baselines.d.ts.map +1 -1
  99. package/dist/commands/update-baselines.js +3 -2
  100. package/dist/commands/update-baselines.js.map +1 -1
  101. package/dist/commands/update-snapshot.d.ts +22 -4
  102. package/dist/commands/update-snapshot.d.ts.map +1 -1
  103. package/dist/commands/update-snapshot.js +79 -18
  104. package/dist/commands/update-snapshot.js.map +1 -1
  105. package/dist/config/checks.d.ts +26 -0
  106. package/dist/config/checks.d.ts.map +1 -1
  107. package/dist/config/checks.js +68 -6
  108. package/dist/config/checks.js.map +1 -1
  109. package/dist/config/define-config.d.ts +38 -2
  110. package/dist/config/define-config.d.ts.map +1 -1
  111. package/dist/config/define-config.js.map +1 -1
  112. package/dist/config/resolve-config.d.ts +15 -2
  113. package/dist/config/resolve-config.d.ts.map +1 -1
  114. package/dist/config/resolve-config.js +6 -0
  115. package/dist/config/resolve-config.js.map +1 -1
  116. package/dist/config/story-options.d.ts +32 -4
  117. package/dist/config/story-options.d.ts.map +1 -1
  118. package/dist/config/story-options.js +38 -7
  119. package/dist/config/story-options.js.map +1 -1
  120. package/dist/config/unrunnable-regexp.d.ts +22 -0
  121. package/dist/config/unrunnable-regexp.d.ts.map +1 -0
  122. package/dist/config/unrunnable-regexp.js +25 -0
  123. package/dist/config/unrunnable-regexp.js.map +1 -0
  124. package/dist/config/validate-config.d.ts.map +1 -1
  125. package/dist/config/validate-config.js +6 -21
  126. package/dist/config/validate-config.js.map +1 -1
  127. package/dist/index.d.ts +3 -3
  128. package/dist/index.d.ts.map +1 -1
  129. package/dist/index.js.map +1 -1
  130. package/dist/init/find-storybooks.d.ts +5 -0
  131. package/dist/init/find-storybooks.d.ts.map +1 -1
  132. package/dist/init/find-storybooks.js +8 -1
  133. package/dist/init/find-storybooks.js.map +1 -1
  134. package/dist/init/ignored-skill.d.ts +50 -0
  135. package/dist/init/ignored-skill.d.ts.map +1 -0
  136. package/dist/init/ignored-skill.js +61 -0
  137. package/dist/init/ignored-skill.js.map +1 -0
  138. package/dist/init/install.d.ts +24 -9
  139. package/dist/init/install.d.ts.map +1 -1
  140. package/dist/init/install.js +66 -26
  141. package/dist/init/install.js.map +1 -1
  142. package/dist/init/package-manager.d.ts +6 -0
  143. package/dist/init/package-manager.d.ts.map +1 -1
  144. package/dist/init/package-manager.js +4 -0
  145. package/dist/init/package-manager.js.map +1 -1
  146. package/dist/init/run-init.d.ts +17 -4
  147. package/dist/init/run-init.d.ts.map +1 -1
  148. package/dist/init/run-init.js +31 -11
  149. package/dist/init/run-init.js.map +1 -1
  150. package/dist/init/workspace.d.ts +2 -0
  151. package/dist/init/workspace.d.ts.map +1 -1
  152. package/dist/init/workspace.js +2 -0
  153. package/dist/init/workspace.js.map +1 -1
  154. package/dist/page-errors/judge-page-errors.d.ts +50 -0
  155. package/dist/page-errors/judge-page-errors.d.ts.map +1 -0
  156. package/dist/page-errors/judge-page-errors.js +39 -0
  157. package/dist/page-errors/judge-page-errors.js.map +1 -0
  158. package/dist/page-errors/page-error-policy.d.ts +36 -0
  159. package/dist/page-errors/page-error-policy.d.ts.map +1 -0
  160. package/dist/page-errors/page-error-policy.js +15 -0
  161. package/dist/page-errors/page-error-policy.js.map +1 -0
  162. package/dist/real-network-requests/judge-real-requests.d.ts +26 -0
  163. package/dist/real-network-requests/judge-real-requests.d.ts.map +1 -0
  164. package/dist/real-network-requests/judge-real-requests.js +17 -0
  165. package/dist/real-network-requests/judge-real-requests.js.map +1 -0
  166. package/dist/real-network-requests/real-request-policy.d.ts +29 -0
  167. package/dist/real-network-requests/real-request-policy.d.ts.map +1 -0
  168. package/dist/real-network-requests/real-request-policy.js +10 -0
  169. package/dist/real-network-requests/real-request-policy.js.map +1 -0
  170. package/dist/real-network-requests/silenced-hosts.d.ts +9 -0
  171. package/dist/real-network-requests/silenced-hosts.d.ts.map +1 -0
  172. package/dist/real-network-requests/silenced-hosts.js +28 -0
  173. package/dist/real-network-requests/silenced-hosts.js.map +1 -0
  174. package/dist/report/report-document.d.ts +154 -9
  175. package/dist/report/report-document.d.ts.map +1 -1
  176. package/dist/report/report-document.js +1 -1
  177. package/dist/report/report-document.js.map +1 -1
  178. package/dist/report/report-folder.d.ts +7 -3
  179. package/dist/report/report-folder.d.ts.map +1 -1
  180. package/dist/report/report-folder.js +5 -5
  181. package/dist/report/report-folder.js.map +1 -1
  182. package/dist/reporter/end-block.d.ts +32 -3
  183. package/dist/reporter/end-block.d.ts.map +1 -1
  184. package/dist/reporter/end-block.js +55 -3
  185. package/dist/reporter/end-block.js.map +1 -1
  186. package/dist/reporter/page-errors-block.d.ts +52 -0
  187. package/dist/reporter/page-errors-block.d.ts.map +1 -0
  188. package/dist/reporter/page-errors-block.js +98 -0
  189. package/dist/reporter/page-errors-block.js.map +1 -0
  190. package/dist/reporter/real-requests-block.d.ts +33 -0
  191. package/dist/reporter/real-requests-block.d.ts.map +1 -0
  192. package/dist/reporter/real-requests-block.js +53 -0
  193. package/dist/reporter/real-requests-block.js.map +1 -0
  194. package/dist/step-summary/step-summary.d.ts +27 -7
  195. package/dist/step-summary/step-summary.d.ts.map +1 -1
  196. package/dist/step-summary/step-summary.js +107 -15
  197. package/dist/step-summary/step-summary.js.map +1 -1
  198. package/dist/storybook/options-encoding.d.ts +18 -5
  199. package/dist/storybook/options-encoding.d.ts.map +1 -1
  200. package/dist/storybook/options-encoding.js +12 -4
  201. package/dist/storybook/options-encoding.js.map +1 -1
  202. package/dist/storybook/options-read.d.ts +3 -2
  203. package/dist/storybook/options-read.d.ts.map +1 -1
  204. package/dist/storybook/options-read.js +17 -0
  205. package/dist/storybook/options-read.js.map +1 -1
  206. package/dist/storybook/read-stories.d.ts +15 -0
  207. package/dist/storybook/read-stories.d.ts.map +1 -1
  208. package/dist/storybook/read-stories.js +60 -14
  209. package/dist/storybook/read-stories.js.map +1 -1
  210. package/package.json +2 -1
  211. package/skill/SKILL.md +25 -7
@@ -117,11 +117,17 @@ const headlessSwitches = [
117
117
  ];
118
118
  /**
119
119
  * Builds the arguments Chromium is launched with: Playwright's switches for a headless launch, `--no-sandbox` when the
120
- * sandbox is off, `--disable-skia-runtime-opts`, the proxy when one is given, then the profile folder and the CDP pipe.
120
+ * sandbox is off, `--disable-skia-runtime-opts` and `--disable-partial-raster`, the proxy when one is given, then the
121
+ * profile folder and the CDP pipe.
121
122
  *
122
123
  * `--disable-skia-runtime-opts` is visual-check's own: it turns off Skia's code paths picked by CPU at run time, so
123
124
  * gradients come out the same under Rosetta as on real amd64 runners.
124
125
  *
126
+ * `--disable-partial-raster` is visual-check's own too: a tile the page changed is rastered whole, not only inside the
127
+ * change's rectangle. Chromium's rectangle for text leaves out the fringe of LCD antialiasing, so with partial raster a
128
+ * text that gets shorter can leave a pixel of the old text's fringe behind, and now and then Chromium rasters the tile
129
+ * whole anyway, so the same story gave one capture or the other.
130
+ *
125
131
  * The proxy is `--proxy-server` with `--proxy-bypass-list=<-loopback>`, which removes Chromium's implicit bypass of
126
132
  * loopback addresses, so a Storybook on `localhost` is reached through the proxy too.
127
133
  */
@@ -131,6 +137,7 @@ export function launchArguments(options) {
131
137
  ...headlessSwitches,
132
138
  ...(options.sandbox ? [] : ['--no-sandbox']),
133
139
  '--disable-skia-runtime-opts',
140
+ '--disable-partial-raster',
134
141
  ...(options.proxyServer === undefined
135
142
  ? []
136
143
  : [`--proxy-server=${options.proxyServer}`, '--proxy-bypass-list=<-loopback>']),
@@ -1 +1 @@
1
- {"version":3,"file":"launch-arguments.js","sourceRoot":"","sources":["../../../../src/capture/driver/cdp/launch-arguments.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,qHAAqH;AACrH,4FAA4F;AAC5F,wHAAwH;AACxH,gHAAgH;AAChH,iHAAiH;AACjH,8DAA8D;AAE9D;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,uDAAuD;IACvD,uCAAuC;IACvC,8BAA8B;IAC9B,0EAA0E;IAC1E,uDAAuD;IACvD,eAAe;IACf,kCAAkC;IAClC,uEAAuE;IACvE,aAAa;IACb,6DAA6D;IAC7D,aAAa;IACb,yGAAyG;IACzG,cAAc;IACd,wFAAwF;IACxF,+BAA+B;IAC/B,sGAAsG;IACtG,uDAAuD;IACvD,qCAAqC;IACrC,6GAA6G;IAC7G,yBAAyB;IACzB,+GAA+G;IAC/G,mGAAmG;IACnG,mBAAmB;IACnB,4BAA4B;IAC5B,YAAY;IACZ,oBAAoB;IACpB,0FAA0F;IAC1F,sBAAsB;IACtB,4CAA4C;CAC7C,CAAA;AAED;;GAEG;AACH,MAAM,eAAe,GAAG;IACtB,kFAAkF;IAClF,yBAAyB;IACzB,mEAAmE;IACnE,iGAAiG;IACjG,oCAAoC;C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C5C,6BAA6B;QAC7B,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS;YACnC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,CAAC,kBAAkB,OAAO,CAAC,WAAW,EAAE,EAAE,iCAAiC,CAAC,CAAC;QACjF,mBAAmB,OAAO,CAAC,UAAU,EAAE;QACvC,yBAAyB;QACzB,qBAAqB;KACtB,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"launch-arguments.js","sourceRoot":"","sources":["../../../../src/capture/driver/cdp/launch-arguments.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,qHAAqH;AACrH,4FAA4F;AAC5F,wHAAwH;AACxH,gHAAgH;AAChH,iHAAiH;AACjH,8DAA8D;AAE9D;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,uDAAuD;IACvD,uCAAuC;IACvC,8BAA8B;IAC9B,0EAA0E;IAC1E,uDAAuD;IACvD,eAAe;IACf,kCAAkC;IAClC,uEAAuE;IACvE,aAAa;IACb,6DAA6D;IAC7D,aAAa;IACb,yGAAyG;IACzG,cAAc;IACd,wFAAwF;IACxF,+BAA+B;IAC/B,sGAAsG;IACtG,uDAAuD;IACvD,qCAAqC;IACrC,6GAA6G;IAC7G,yBAAyB;IACzB,+GAA+G;IAC/G,mGAAmG;IACnG,mBAAmB;IACnB,4BAA4B;IAC5B,YAAY;IACZ,oBAAoB;IACpB,0FAA0F;IAC1F,sBAAsB;IACtB,4CAA4C;CAC7C,CAAA;AAED;;GAEG;AACH,MAAM,eAAe,GAAG;IACtB,kFAAkF;IAClF,yBAAyB;IACzB,mEAAmE;IACnE,iGAAiG;IACjG,oCAAoC;CACrC,CAAA;AAED;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,8EAA8E;IAC9E,wFAAwF;IACxF,8BAA8B;IAC9B,iCAAiC;IACjC,uCAAuC;IACvC,0CAA0C;IAC1C,iGAAiG;IACjG,8BAA8B;IAC9B,oBAAoB;IACpB,sDAAsD;IACtD,wC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B,OAAO,CAAC,UAAU,EAAE;QACvC,yBAAyB;QACzB,qBAAqB;KACtB,CAAA;AACH,CAAC"}
@@ -110,9 +110,10 @@ export interface PageSetup {
110
110
  */
111
111
  initScript: string;
112
112
  /**
113
- * Whether the page watches the real network requests it makes, for `requestHosts`. Only `update` turns it on, since
114
- * watching has a cost: the browser reports every request, and the page attaches to the service workers of its
115
- * browser context. A page that doesn't watch turns on no request reporting and attaches to no service worker.
113
+ * Whether the page watches the real network requests it makes, for `requestHosts`. `update` turns it on for every
114
+ * page, and `test` only for the snapshots that check real network requests, since watching has a cost: the browser
115
+ * reports every request, and the page attaches to the service workers of its browser context. A page that doesn't
116
+ * watch turns on no request reporting and attaches to no service worker.
116
117
  */
117
118
  watchRequests: boolean;
118
119
  }
@@ -214,6 +215,60 @@ export interface ConsoleMessage {
214
215
  * @public
215
216
  */
216
217
  export declare function readConsoleMessage(payload: string): ConsoleMessage | undefined;
218
+ /**
219
+ * How many page errors a page keeps: the first ones.
220
+ */
221
+ export declare const keptPageErrors = 50;
222
+ /**
223
+ * A page error: a `console.error`, an uncaught error or an unhandled rejection a page raised, or a load of a file from
224
+ * its document's origin that failed at the network level or got an HTTP error status. See GLOSSARY.md.
225
+ *
226
+ * @public
227
+ */
228
+ export interface PageError {
229
+ /**
230
+ * `console.error`, an uncaught error (`error`), an unhandled rejection (`unhandledrejection`), or a load of a file
231
+ * (`load`).
232
+ */
233
+ kind: 'console.error' | 'error' | 'unhandledrejection' | 'load';
234
+ /**
235
+ * The message, up to 500 characters, or a load's full URL. A `console.error`'s arguments are joined by spaces, and an
236
+ * error, thrown, rejected or logged, is described by its stack, whose first line is `Name: message`. Expected page
237
+ * errors are matched against it.
238
+ */
239
+ text: string;
240
+ /**
241
+ * A load's network error, such as `net::ERR_EMPTY_RESPONSE`, or its HTTP status, such as `HTTP 404`. Only on a load.
242
+ */
243
+ loadError?: string;
244
+ }
245
+ /**
246
+ * Gives the page error a console message or error is, the same kind and text, or undefined for a message that's none:
247
+ * a `console.debug`, `console.info`, `console.log` or `console.warn`.
248
+ */
249
+ export declare function pageErrorOf(message: ConsoleMessage): PageError | undefined;
250
+ /**
251
+ * Gives the page errors of every list, each once, in the order first seen: a page error the same as one before it, in
252
+ * its kind, text and load error, is left out.
253
+ *
254
+ * @public
255
+ */
256
+ export declare function eachPageErrorOnce(...lists: readonly (readonly PageError[])[]): PageError[];
257
+ /**
258
+ * A load of a file that failed at the network level on a page.
259
+ *
260
+ * @public
261
+ */
262
+ export interface FailedLoad {
263
+ /**
264
+ * The file's full URL.
265
+ */
266
+ url: string;
267
+ /**
268
+ * The browser's network error, such as `net::ERR_EMPTY_RESPONSE`.
269
+ */
270
+ error: string;
271
+ }
217
272
  /**
218
273
  * A page in a browser context of its own, set up once, that stories are loaded and captured in. It emulates
219
274
  * `prefers-reduced-motion: no-preference` and keeps focus as if its window were focused.
@@ -253,12 +308,22 @@ export declare function readConsoleMessage(payload: string): ConsoleMessage | un
253
308
  * MSW's mocks are, doesn't count, and fonts, stylesheets, images and scripts never do. A page that doesn't watch turns
254
309
  * on no request reporting and attaches to no service worker, so it costs nothing.
255
310
  *
311
+ * Every page keeps its page errors, which `pageErrors` gives, and the loads of its document's origin that failed at the
312
+ * network level, which `failedLoads` gives. Both read loads from the browser's log, which reports only problems, so
313
+ * watching it costs a page nothing, unlike watching requests: no page turns on request reporting for them. The log
314
+ * reports an error status a service worker's own response gives just as it reports a server's, so an error response
315
+ * MSW mocks is a page error. Probed on 2026-11-28 with Chromium 157.0.8103.78's headless shell: a 404 or 500 response
316
+ * a worker built, to a `fetch` and to an `<img>`, is logged once, at the `error` level, with the full URL, as
317
+ * `Failed to load resource: the server responded with a status of 404 ()`, with no status text where a server's
318
+ * response gives one, such as `(Not Found)`.
319
+ *
256
320
  * @public
257
321
  */
258
322
  export interface Page {
259
323
  /**
260
324
  * Sets the size the page lays out and renders at, and turns touch and mobile emulation on or off as the viewport
261
- * says. Fails with a `PageTimeoutError` when the browser doesn't answer within the driver's own fixed limit.
325
+ * says. Setting a viewport again on a loaded page, with the same touch, keeps the page's hover and pointer media.
326
+ * Fails with a `PageTimeoutError` when the browser doesn't answer within the driver's own fixed limit.
262
327
  */
263
328
  setViewport: (viewport: PageViewport) => Promise<void>;
264
329
  /**
@@ -324,6 +389,25 @@ export interface Page {
324
389
  * reads them once a call failed, before it closes the page. Never fails.
325
390
  */
326
391
  consoleMessages: () => ConsoleMessage[];
392
+ /**
393
+ * Gives the loads that failed at the network level since the last `goto` started, such as a dropped or refused
394
+ * connection, each of the origin of the document the main frame showed when it failed: that `goto`'s, or one the page
395
+ * went to since. The first 10 of them, each URL once, in order: a failure of another origin, such as a CDN's, is never
396
+ * kept, so it never crowds out one of the story's own. A cancellation and an HTTP error status don't count. They are
397
+ * kept after the page can no longer be used too, so a caller reads them once a call failed. Never fails.
398
+ */
399
+ failedLoads: () => FailedLoad[];
400
+ /**
401
+ * Gives the first 50 page errors the page raised since the last `goto` started, or since the page opened before any,
402
+ * each once, in order: the same kind, text and load error count once. The `console.error`, `error` and
403
+ * `unhandledrejection` messages count as `consoleMessages` takes them in, from the main frame's main world, but in a
404
+ * list of their own, so no number of other console messages ever crowds one out. A load counts when it failed at
405
+ * the network level, a cancellation (`net::ERR_ABORTED`) aside, or got an HTTP status of 400 or over, a response a
406
+ * service worker built included, and was of the origin of the document the main frame showed then, as for
407
+ * `failedLoads`: a load of another origin never counts. They are kept after the page can no longer be used too, so a
408
+ * caller reads them once a call failed, before it closes the page. Never fails.
409
+ */
410
+ pageErrors: () => PageError[];
327
411
  /**
328
412
  * Closes the page and its browser context. Every call in flight and every later call fails. Calling it again returns
329
413
  * the same promise.
@@ -1 +1 @@
1
- {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../../src/capture/driver/driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAElE;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAE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
62
  return { kind, text: text.slice(0, keptConsoleMessageCharacters) };
63
63
  }
64
+ /**
65
+ * How many page errors a page keeps: the first ones.
66
+ */
67
+ export const keptPageErrors = 50;
68
+ /**
69
+ * Gives the page error a console message or error is, the same kind and text, or undefined for a message that's none:
70
+ * a `console.debug`, `console.info`, `console.log` or `console.warn`.
71
+ */
72
+ export function pageErrorOf(message) {
73
+ const { kind, text } = message;
74
+ return kind === 'console.error' || kind === 'error' || kind === 'unhandledrejection' ? { kind, text } : undefined;
75
+ }
76
+ /**
77
+ * Says whether two page errors are the same one: the same kind, text and load error.
78
+ */
79
+ function isSamePageError(one, other) {
80
+ return one.kind === other.kind && one.text === other.text && one.loadError === other.loadError;
81
+ }
82
+ /**
83
+ * Gives the page errors of every list, each once, in the order first seen: a page error the same as one before it, in
84
+ * its kind, text and load error, is left out.
85
+ *
86
+ * @public
87
+ */
88
+ export function eachPageErrorOnce(...lists) {
89
+ const once = [];
90
+ for (const error of lists.flat()) {
91
+ if (!once.some((kept) => isSamePageError(kept, error))) {
92
+ once.push(error);
93
+ }
94
+ }
95
+ return once;
96
+ }
64
97
  /**
65
98
  * Says how the browser's process ended, and when: that it couldn't start and why, or its exit code, or the signal that
66
99
  * ended it, such as "The browser exited with code 1 while in use."
@@ -1 +1 @@
1
- {"version":3,"file":"driver.js","sourceRoot":"","sources":["../../../src/capture/driver/driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAA;AAqLlE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAAsB,CAAA;AAE5D;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAErC;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAA;AA0B/C;;GAEG;AACH,MAAM,mBAAmB,GAAsC;IAC7D,eAAe;IACf,cAAc;IACd,aAAa;IACb,cAAc;IACd,eAAe;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AAM,CAAS;IAExB;;;OAGG;IACM,cAAc,CAAS;IAEhC;;;OAGG;IACH,YAAY,OAAe,EAAE,MAAyB,EAAE,OAAsD;QAC5G,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,KAAK,CAAA;IACvD,CAAC;CACF"}
@@ -30,9 +30,10 @@ import { type CapturePrepRequest } from './prepare-capture.js';
30
30
  * decoded again. Then it forces layout, so the fonts the layout needs start loading, and waits for
31
31
  * `document.fonts.ready`. One time limit covers both. A page without an API it uses, such as `document.fonts`, has
32
32
  * nothing to wait for there;
33
- * - gives `letFramesPass`, which the frames expression calls once the viewport grew, so the page reacts to the new
34
- * size before anything goes on: an `IntersectionObserver`, a `ResizeObserver` or a `resize` listener calls back,
35
- * and the render it causes is done. It lets the frames pass as `framesFunction` says, within a time limit;
33
+ * - gives `letFramesPass`, which the frames expression calls once the viewport grew, and once it was set again after
34
+ * the wait hook, so the page reacts to the new size before anything goes on: an `IntersectionObserver`, a
35
+ * `ResizeObserver` or a `resize` listener calls back, and the render it causes is done. It lets the frames pass as
36
+ * `framesFunction` says, within a time limit;
36
37
  * - gives `bringToEndState`, which the end state expression calls at capture. It brings every animation in the
37
38
  * document and in every shadow root to its end state, then freezes their videos, SVGs, inline or as CSS images, and
38
39
  * GIFs, then brings the animations that freezing them started to their end state too, as `endStateFunction` says,
@@ -121,9 +122,9 @@ export type FramesPassed = {
121
122
  outcome: 'script-missing';
122
123
  };
123
124
  /**
124
- * Builds the expression that lets two frames pass in the page once the viewport grew, so the page reacts to the new
125
- * size, or gives up once `timeoutMs` passes, rounded up to whole ms. Its value is the page's answer, which
126
- * `readFramesPassed` reads.
125
+ * Builds the expression that lets two frames pass in the page once the viewport grew, or was set again after the wait
126
+ * hook, so the page reacts to the new size, or gives up once `timeoutMs` passes, rounded up to whole ms. Its value is
127
+ * the page's answer, which `readFramesPassed` reads.
127
128
  */
128
129
  export declare function framesAfterGrowthExpression(timeoutMs: number): string;
129
130
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"page-script.d.ts","sourceRoot":"","sources":["../../src/capture/page-script.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,sBAAsB,CAAA;AAQtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,eAAO,MAAM,cAAc,QA2SrB,CAAA;AAEN;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB;IACE;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;CACjB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAA;IACd;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;;OAGG;IACH,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAEL;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAO/D;AAQD;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB;IACE;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAA;CAClB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,WAAW,CAAA;CACrB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAEL;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOrE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAQ7D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAS/F;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CA8BnE"}
1
+ {"version":3,"file":"page-script.d.ts","sourceRoot":"","sources":["../../src/capture/page-script.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,sBAAsB,CAAA;AAQtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,cAAc,QA2SrB,CAAA;AAEN;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB;IACE;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;CACjB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAA;IACd;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;;OAGG;IACH,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAEL;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAO/D;AAQD;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB;IACE;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAA;CAClB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,WAAW,CAAA;CACrB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAEL;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOrE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAQ7D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAS/F;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CA8BnE"}
@@ -39,9 +39,10 @@ const stateGlobal = '__visualCheck';
39
39
  * decoded again. Then it forces layout, so the fonts the layout needs start loading, and waits for
40
40
  * `document.fonts.ready`. One time limit covers both. A page without an API it uses, such as `document.fonts`, has
41
41
  * nothing to wait for there;
42
- * - gives `letFramesPass`, which the frames expression calls once the viewport grew, so the page reacts to the new
43
- * size before anything goes on: an `IntersectionObserver`, a `ResizeObserver` or a `resize` listener calls back,
44
- * and the render it causes is done. It lets the frames pass as `framesFunction` says, within a time limit;
42
+ * - gives `letFramesPass`, which the frames expression calls once the viewport grew, and once it was set again after
43
+ * the wait hook, so the page reacts to the new size before anything goes on: an `IntersectionObserver`, a
44
+ * `ResizeObserver` or a `resize` listener calls back, and the render it causes is done. It lets the frames pass as
45
+ * `framesFunction` says, within a time limit;
45
46
  * - gives `bringToEndState`, which the end state expression calls at capture. It brings every animation in the
46
47
  * document and in every shadow root to its end state, then freezes their videos, SVGs, inline or as CSS images, and
47
48
  * GIFs, then brings the animations that freezing them started to their end state too, as `endStateFunction` says,
@@ -296,7 +297,7 @@ ${storybookPageScript};
296
297
  }
297
298
  }
298
299
 
299
- // Letting frames pass, so the page reacts to a viewport that grew.
300
+ // Letting frames pass, so the page reacts to a viewport that grew or was set again.
300
301
 
301
302
  const framesPassedBefore = (${framesFunction})({ setTimer, requestFrame })
302
303
 
@@ -374,14 +375,14 @@ export function assetsReadyExpression(timeoutMs) {
374
375
  })()`;
375
376
  }
376
377
  /**
377
- * How many frames pass once the viewport grew: the first runs the rendering update that calls the page's observers
378
- * back, the second paints what their render changed.
378
+ * How many frames pass once the viewport grew, or was set again after the wait hook: the first runs the rendering
379
+ * update that calls the page's observers back, the second paints what their render changed.
379
380
  */
380
381
  const framesAfterGrowth = 2;
381
382
  /**
382
- * Builds the expression that lets two frames pass in the page once the viewport grew, so the page reacts to the new
383
- * size, or gives up once `timeoutMs` passes, rounded up to whole ms. Its value is the page's answer, which
384
- * `readFramesPassed` reads.
383
+ * Builds the expression that lets two frames pass in the page once the viewport grew, or was set again after the wait
384
+ * hook, so the page reacts to the new size, or gives up once `timeoutMs` passes, rounded up to whole ms. Its value is
385
+ * the page's answer, which `readFramesPassed` reads.
385
386
  */
386
387
  export function framesAfterGrowthExpression(timeoutMs) {
387
388
  const limit = Math.max(0, Math.ceil(timeoutMs));
@@ -1 +1 @@
1
- {"version":3,"file":"page-script.js","sourceRoot":"","sources":["../../src/capture/page-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAC7F,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC9G,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAA2B,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D;;GAEG;AACH,MAAM,WAAW,GAAG,eAAe,CAAA;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,CAAC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as the capture preparation measures it: how far content the capture would cut reaches
89
+ * past each side of the capture, in CSS pixels, each rounded up, 0 on a side where nothing counts.
90
+ */
91
+ export interface PageOverflow {
92
+ /**
93
+ * How far the element reaches past the page's top edge, in CSS pixels.
94
+ */
95
+ top: number;
96
+ /**
97
+ * How far content reaches past the capture's right edge, in CSS pixels: the full page's content past the viewport's
98
+ * right edge, or the element's content past its border box's.
99
+ */
100
+ right: number;
101
+ /**
102
+ * How far the element's content spills past its border box's bottom edge, in CSS pixels.
103
+ */
104
+ bottom: number;
105
+ /**
106
+ * How far the element reaches past the page's left edge, in CSS pixels.
107
+ */
108
+ left: number;
109
+ }
87
110
  /**
88
111
  * The source of a function, evaluated in the page as part of the page script, that creates the capture preparation.
89
112
  * It takes what the page script kept at document start: `shadowRoots`, `findRemoteContent`, the remote content search,
@@ -100,7 +123,26 @@ export interface PageGrid {
100
123
  * whole pixels and cut at the page's edge: the left and top edges rounded down and kept at 0 or more, the right and
101
124
  * bottom edges kept within the document's scrollable area, read from its root element's `scrollWidth` and
102
125
  * `scrollHeight`, and rounded up. When that size can't be read, the right and bottom edges aren't cut. A box of zero
103
- * width or height, before or after that, or one that can't be read, gives `found: 'zero-size'`.
126
+ * width or height, before or after that, or one that can't be read, gives `found: 'zero-size'`. Then it measures
127
+ * the overflow, content the capture would cut, as how far it reaches past each side, in CSS pixels. For the full
128
+ * page, that's the right side only: the root element's `scrollWidth` less its `clientWidth`, unless the root
129
+ * element or `body` has a computed `overflow-x` of `hidden` or `clip`, as the page cuts that itself. The capture
130
+ * takes the content's full height, and content left of the page's edge can't be scrolled to. For the element, the
131
+ * left and top sides are how far its border box, with the page's scroll, reaches past the page's left and top
132
+ * edges, where its box is cut. The right side is how far its content spills past its border box's right edge,
133
+ * only when its computed `overflow-x` is `visible` and its `direction` is `ltr`, as a right-to-left element's
134
+ * `scrollWidth` counts content spilling left: the content's right edge is its border box's left edge, with the
135
+ * page's scroll, plus its `clientLeft` and its `scrollWidth`. Those are lengths of the element's own layout, so when
136
+ * its border box is drawn a whole pixel or more wider or narrower than its `offsetWidth`, as a transform or zoom
137
+ * draws it, they're scaled by the drawn width over `offsetWidth`. Both edges are kept within the document's
138
+ * scrollable area when its size can be read. The bottom side is the same with `overflow-y`, `clientTop`,
139
+ * `scrollHeight` and `offsetHeight`, whatever the direction. Chrome's `scrollWidth` and `scrollHeight` of an element that doesn't clip cover descendants
140
+ * spilling right or down, transformed or absolutely positioned ones included, but not `position: fixed` ones, the
141
+ * top layer or a `box-shadow`, and scrollable overflow never reaches left or up, so content spilling left or up
142
+ * from an element isn't measured. A side counts when it's at least one whole CSS pixel, as Chrome rounds
143
+ * `scrollWidth` and `clientWidth` to whole pixels, and is rounded up. A side whose values can't be read, or aren't
144
+ * finite, doesn't count, nor does the full page's when the root element's or `body`'s style can't be read. When the
145
+ * element is missing or a selector is invalid, there's no overflow.
104
146
  * 2. Finds the masks' boxes. A selector mask covers each element of the top document that matches it and has an
105
147
  * area, by its border box, with the page's scroll, not rounded. A selector that throws gives
106
148
  * `{ outcome: 'invalid-selector', of: 'mask', name, message }`. Then the remote content search runs once, with the
@@ -131,7 +173,8 @@ export interface PageGrid {
131
173
  * `findRemote` is true and the search answered, it adds `remote`, the remote content found, maybe none: each item's
132
174
  * `host`, with its port when the URL has one, and its box, `x`, `y`, `width` and `height`, in CSS pixels of the top
133
175
  * document, as the search gives them. Without `remote`, the remote content is unknown. When the top document shows a
134
- * grid, it adds `grid`, the widest grid's width and the tallest grid's height. When the element is missing, a
176
+ * grid, it adds `grid`, the widest grid's width and the tallest grid's height. When at least one side of the overflow
177
+ * counts, it adds `overflow`, `{ top, right, bottom, left }`, 0 on a side that doesn't. When the element is missing, a
135
178
  * selector is invalid or the search for a host mask timed out, it paints nothing and hides no caret. It never throws. A
136
179
  * mask must never fail open: when finding the masks' boxes or painting them throws, as when the search for a host mask
137
180
  * rejects or an element can't be created, it answers `{ outcome: 'paint-failed', message }` and hides no caret, with
@@ -139,7 +182,7 @@ export interface PageGrid {
139
182
  * be shown as a popover takes the highest `z-index`, as said above. Hiding the caret is best effort: a root that can't
140
183
  * adopt the sheet is left out, and it still answers `ready`.
141
184
  */
142
- export declare const prepareCaptureFunction = "(context) => {\n const { shadowRoots, findRemoteContent, stateGlobal } = context\n const { elementsOf, rootsOf, read, isObject, scrollOf, recordedRootsOf } = (() => {\n const read = (getter, fallback) => {\n try {\n return getter()\n } catch {\n return fallback\n }\n }\n\n const isObject = (value) => typeof value === 'object' && value !== null\n\n const scrollOf = (view, axis) => {\n const scroll = read(() => view[axis], 0)\n return Number.isFinite(scroll) ? scroll : 0\n }\n\n const elementsOf = (root, selector) => {\n try {\n return Array.from(root.querySelectorAll(selector))\n } catch {\n return []\n }\n }\n\n const openShadowRootOf = (element) => {\n const root = read(() => element.shadowRoot, undefined)\n return isObject(root) ? root : undefined\n }\n\n const rootsOf = (rootDocument, recordedRoots) => {\n const roots = new Set([rootDocument, ...recordedRoots])\n // A Set's iteration visits the roots added during it, so the open roots inside open roots are walked too.\n for (const root of roots) {\n for (const element of elementsOf(root, '*')) {\n const openRoot = openShadowRootOf(element)\n if (openRoot !== undefined) {\n roots.add(openRoot)\n }\n }\n }\n return roots\n }\n\n const recordedRootsOf = (frame, stateGlobal) => {\n const recorded = read(() => frame.contentWindow[stateGlobal].shadowRoots, undefined)\n return Array.isArray(recorded) ? recorded : []\n }\n\n return { elementsOf, rootsOf, read, isObject, scrollOf, recordedRootsOf }\n})()\n\n // The tag name of the element that holds the painted masks. An unknown name with a hyphen gives an HTMLElement.\n const masksTagName = 'visual-check-masks'\n\n // The attribute @visual-check/storybook's grid puts on its element, gridAttribute there. The CLI can't import that\n // package, so it's repeated here.\n const gridSelector = '[data-visual-check-grid]'\n\n // The highest z-index, for a host that couldn't go in the top layer.\n const topZIndex = 2147483647\n\n // The rule that hides the text caret on every element of a root.\n const caretRule = '*, *::before, *::after { caret-color: transparent !important; }'\n\n // The message of what a selector threw.\n const messageOf = (error) =>\n read(() => (isObject(error) && typeof error.message === 'string' ? error.message : String(error)), 'It threw.')\n\n // How far the top document is scrolled, 0 along an axis that can't be read.\n const pageScrollOf = () => {\n const view = read(() => document.defaultView, undefined)\n return { x: scrollOf(view, 'scrollX'), y: scrollOf(view, 'scrollY') }\n }\n\n // The widest grid's border-box width and the tallest grid's height, in CSS pixels, or undefined when the top document\n // shows no grid whose box can be read.\n const gridOf = () => {\n let grid\n for (const element of read(() => Array.from(document.querySelectorAll(gridSelector)), [])) {\n const rect = read(() => element.getBoundingClientRect(), undefined)\n const sides = read(() => [rect.width, rect.height], [])\n if (sides.length === 2 && sides.every((side) => Number.isFinite(side) && side >= 0)) {\n const [width, height] = sides\n grid =\n grid === undefined\n ? { width, height }\n : { width: Math.max(grid.width, width), height: Math.max(grid.height, height) }\n }\n }\n return grid\n }\n\n // The size of the top document's scrollable area, or undefined when it can't be read.\n const documentSizeOf = () => {\n const width = read(() => document.documentElement.scrollWidth, undefined)\n const height = read(() => document.documentElement.scrollHeight, undefined)\n const valid = (side) => typeof side === 'number' && Number.isFinite(side) && side >= 0\n return valid(width) && valid(height) ? { width, height } : undefined\n }\n\n // An element's border box, with the page's scroll, or undefined when it has no area or can't be read.\n const documentBoxOf = (element, scroll) => {\n const rect = read(() => element.getBoundingClientRect(), undefined)\n const sides = read(() => [rect.left, rect.top, rect.right, rect.bottom, rect.width, rect.height], [])\n if (sides.length === 0 || !sides.every(Number.isFinite) || rect.width <= 0 || rect.height <= 0) {\n return undefined\n }\n return {\n left: rect.left + scroll.x,\n top: rect.top + scroll.y,\n right: rect.right + scroll.x,\n bottom: rect.bottom + scroll.y,\n }\n }\n\n // The box of the element the selector matches first, out to whole pixels, or why there's none.\n const elementBoxOf = (selector, scroll) => {\n let element\n try {\n element = document.querySelector(selector)\n } catch (error) {\n return { outcome: 'invalid-selector', of: 'element', message: messageOf(error) }\n }\n if (!isObject(element)) {\n return { outcome: 'element-missing', found: 'nothing' }\n }\n const box = documentBoxOf(element, scroll)\n if (box === undefined) {\n return { outcome: 'element-missing', found: 'zero-size' }\n }\n const size = documentSizeOf()\n const x = Math.max(0, Math.floor(box.left))\n const y = Math.max(0, Math.floor(box.top))\n const right = Math.ceil(size === undefined ? box.right : Math.min(box.right, size.width))\n const bottom = Math.ceil(size === undefined ? box.bottom : Math.min(box.bottom, size.height))\n const width = right - x\n const height = bottom - y\n if (width <= 0 || height <= 0) {\n return { outcome: 'element-missing', found: 'zero-size' }\n }\n return { box: { x, y, width, height } }\n }\n\n // The boxes of the elements a selector mask covers, or why there are none.\n const selectorBoxesOf = (mask, scroll) => {\n let elements\n try {\n elements = Array.from(document.querySelectorAll(mask.selector))\n } catch (error) {\n return { outcome: 'invalid-selector', of: 'mask', name: mask.name, message: messageOf(error) }\n }\n return { boxes: elements.map((element) => documentBoxOf(element, scroll)).filter((box) => box !== undefined) }\n }\n\n // Runs the remote content search once, when a host mask or the request needs it, or gives undefined when neither\n // does. A search that rejects fails the host masks, as a mask must never fail open, and with no host mask leaves the\n // remote content unknown.\n const searchOnce = async (hostMasks, findRemote, timeoutMs) => {\n if (hostMasks.length === 0 && !findRemote) {\n return undefined\n }\n try {\n return await findRemoteContent(timeoutMs)\n } catch (error) {\n if (hostMasks.length > 0) {\n throw error\n }\n return undefined\n }\n }\n\n // The boxes of the remote content the host masks cover, or why there are none.\n const hostBoxesOf = (hostMasks, search) => {\n if (hostMasks.length === 0) {\n return { boxes: [] }\n }\n if (search.outcome === 'timed-out') {\n return { outcome: 'timed-out' }\n }\n const boxes = []\n for (const mask of hostMasks) {\n const host = mask.host.toLowerCase()\n for (const item of search.items) {\n if (item.host === host || item.hostname === host) {\n boxes.push({ left: item.x, top: item.y, right: item.x + item.width, bottom: item.y + item.height })\n }\n }\n }\n return { boxes }\n }\n\n // The remote content a search found, each item by its host and box, or undefined when it's unknown: no search ran,\n // it rejected or it timed out.\n const remoteOf = (search) => {\n if (search === undefined || search.outcome !== 'found') {\n return undefined\n }\n return search.items.map((item) => ({\n host: item.host,\n x: item.x,\n y: item.y,\n width: item.width,\n height: item.height,\n }))\n }\n\n // The boxes of every mask, selector masks first, with the remote content found when the request asks for it, or why\n // there are none.\n const maskBoxesOf = async (masks, scroll, findRemote, timeoutMs) => {\n const boxes = []\n for (const mask of masks) {\n if (typeof mask.selector === 'string') {\n const found = selectorBoxesOf(mask, scroll)\n if (found.outcome !== undefined) {\n return found\n }\n boxes.push(...found.boxes)\n }\n }\n const hostMasks = masks.filter((mask) => typeof mask.host === 'string')\n const search = await searchOnce(hostMasks, findRemote, timeoutMs)\n const found = hostBoxesOf(hostMasks, search)\n if (found.outcome !== undefined) {\n return found\n }\n return { boxes: [...boxes, ...found.boxes], remote: findRemote ? remoteOf(search) : undefined }\n }\n\n // The inline style of the element that holds the masks: a box at the document's origin, the size of its scrollable\n // area, clipping what's past it, or an empty box clipping nothing when that size can't be read.\n const hostStyleOf = (size) =>\n [\n 'all: initial !important',\n 'display: block !important',\n 'position: absolute !important',\n 'left: 0 !important',\n 'top: 0 !important',\n 'width: ' + (size === undefined ? 0 : size.width) + 'px !important',\n 'height: ' + (size === undefined ? 0 : size.height) + 'px !important',\n 'margin: 0 !important',\n 'padding: 0 !important',\n 'border: 0 !important',\n 'overflow: ' + (size === undefined ? 'visible' : 'clip') + ' !important',\n 'background: transparent !important',\n 'pointer-events: none !important',\n ].join('; ')\n\n // The inline style of a painted box.\n const maskStyleOf = (box, maskColor) =>\n [\n 'all: initial !important',\n 'display: block !important',\n 'position: absolute !important',\n 'left: ' + box.left + 'px !important',\n 'top: ' + box.top + 'px !important',\n 'width: ' + (box.right - box.left) + 'px !important',\n 'height: ' + (box.bottom - box.top) + 'px !important',\n 'background: ' + maskColor + ' !important',\n ].join('; ')\n\n // Paints the boxes in a manual popover, so they sit in the top layer, or over the page by z-index when it can't.\n const paint = (boxes, maskColor) => {\n if (boxes.length === 0) {\n return\n }\n const hostStyle = hostStyleOf(documentSizeOf())\n const host = document.createElement(masksTagName)\n host.setAttribute('popover', 'manual')\n host.style.cssText = hostStyle\n for (const box of boxes) {\n const mask = document.createElement('div')\n mask.style.cssText = maskStyleOf(box, maskColor)\n host.appendChild(mask)\n }\n document.documentElement.appendChild(host)\n try {\n host.showPopover()\n } catch {\n host.style.cssText = hostStyle + '; z-index: ' + topZIndex + ' !important'\n }\n }\n\n // Finds the masks' boxes and paints them, giving the remote content found when that's done, or why it couldn't be.\n // A mask unpainted would leave its content in the capture, so anything thrown here fails the preparation.\n const paintMasks = async (masks, maskColor, scroll, findRemote, timeoutMs) => {\n try {\n const found = await maskBoxesOf(masks, scroll, findRemote, timeoutMs)\n if (found.outcome !== undefined) {\n return found\n }\n paint(found.boxes, maskColor)\n return { remote: found.remote }\n } catch (error) {\n return { outcome: 'paint-failed', message: messageOf(error) }\n }\n }\n\n // Hides the caret in a document's roots with a sheet its own window made, then in the documents of its frames.\n const hideCaretIn = (hidden, recordedRoots) => {\n let sheet\n try {\n sheet = new hidden.defaultView.CSSStyleSheet()\n sheet.replaceSync(caretRule)\n } catch {\n return\n }\n for (const root of rootsOf(hidden, recordedRoots)) {\n try {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet]\n } catch {}\n for (const frame of elementsOf(root, 'iframe, frame')) {\n const frameDocument = read(() => frame.contentDocument, null)\n if (isObject(frameDocument)) {\n hideCaretIn(frameDocument, recordedRootsOf(frame, stateGlobal))\n }\n }\n }\n }\n\n return async (request, timeoutMs) => {\n const { element, masks, maskColor, findRemote } = request\n const scroll = pageScrollOf()\n const grid = gridOf()\n const measured = element === null ? { box: null } : elementBoxOf(element, scroll)\n if (measured.outcome !== undefined) {\n return measured\n }\n const painted = await paintMasks(masks, maskColor, scroll, findRemote, timeoutMs)\n if (painted.outcome !== undefined) {\n return painted\n }\n try {\n hideCaretIn(document, shadowRoots)\n } catch {}\n const ready = { outcome: 'ready', box: measured.box }\n return {\n ...ready,\n ...(painted.remote === undefined ? {} : { remote: painted.remote }),\n ...(grid === undefined ? {} : { grid }),\n }\n }\n}";
185
+ export declare const prepareCaptureFunction = "(context) => {\n const { shadowRoots, findRemoteContent, stateGlobal } = context\n const { elementsOf, rootsOf, read, isObject, scrollOf, recordedRootsOf } = (() => {\n const read = (getter, fallback) => {\n try {\n return getter()\n } catch {\n return fallback\n }\n }\n\n const isObject = (value) => typeof value === 'object' && value !== null\n\n const scrollOf = (view, axis) => {\n const scroll = read(() => view[axis], 0)\n return Number.isFinite(scroll) ? scroll : 0\n }\n\n const elementsOf = (root, selector) => {\n try {\n return Array.from(root.querySelectorAll(selector))\n } catch {\n return []\n }\n }\n\n const openShadowRootOf = (element) => {\n const root = read(() => element.shadowRoot, undefined)\n return isObject(root) ? root : undefined\n }\n\n const rootsOf = (rootDocument, recordedRoots) => {\n const roots = new Set([rootDocument, ...recordedRoots])\n // A Set's iteration visits the roots added during it, so the open roots inside open roots are walked too.\n for (const root of roots) {\n for (const element of elementsOf(root, '*')) {\n const openRoot = openShadowRootOf(element)\n if (openRoot !== undefined) {\n roots.add(openRoot)\n }\n }\n }\n return roots\n }\n\n const recordedRootsOf = (frame, stateGlobal) => {\n const recorded = read(() => frame.contentWindow[stateGlobal].shadowRoots, undefined)\n return Array.isArray(recorded) ? recorded : []\n }\n\n return { elementsOf, rootsOf, read, isObject, scrollOf, recordedRootsOf }\n})()\n\n // The tag name of the element that holds the painted masks. An unknown name with a hyphen gives an HTMLElement.\n const masksTagName = 'visual-check-masks'\n\n // The attribute @visual-check/storybook's grid puts on its element, gridAttribute there. The CLI can't import that\n // package, so it's repeated here.\n const gridSelector = '[data-visual-check-grid]'\n\n // The highest z-index, for a host that couldn't go in the top layer.\n const topZIndex = 2147483647\n\n // The rule that hides the text caret on every element of a root.\n const caretRule = '*, *::before, *::after { caret-color: transparent !important; }'\n\n // The message of what a selector threw.\n const messageOf = (error) =>\n read(() => (isObject(error) && typeof error.message === 'string' ? error.message : String(error)), 'It threw.')\n\n // How far the top document is scrolled, 0 along an axis that can't be read.\n const pageScrollOf = () => {\n const view = read(() => document.defaultView, undefined)\n return { x: scrollOf(view, 'scrollX'), y: scrollOf(view, 'scrollY') }\n }\n\n // The widest grid's border-box width and the tallest grid's height, in CSS pixels, or undefined when the top document\n // shows no grid whose box can be read.\n const gridOf = () => {\n let grid\n for (const element of read(() => Array.from(document.querySelectorAll(gridSelector)), [])) {\n const rect = read(() => element.getBoundingClientRect(), undefined)\n const sides = read(() => [rect.width, rect.height], [])\n if (sides.length === 2 && sides.every((side) => Number.isFinite(side) && side >= 0)) {\n const [width, height] = sides\n grid =\n grid === undefined\n ? { width, height }\n : { width: Math.max(grid.width, width), height: Math.max(grid.height, height) }\n }\n }\n return grid\n }\n\n // The size of the top document's scrollable area, or undefined when it can't be read.\n const documentSizeOf = () => {\n const width = read(() => document.documentElement.scrollWidth, undefined)\n const height = read(() => document.documentElement.scrollHeight, undefined)\n const valid = (side) => typeof side === 'number' && Number.isFinite(side) && side >= 0\n return valid(width) && valid(height) ? { width, height } : undefined\n }\n\n // A number a getter reads, or undefined when it can't be read or isn't a finite number.\n const numberOf = (getter) => {\n const value = read(getter, undefined)\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined\n }\n\n // The computed value of a CSS property of an element of the top document, or undefined when it can't be read.\n const computedOf = (element, property) => {\n const value = read(() => document.defaultView.getComputedStyle(element).getPropertyValue(property), undefined)\n return typeof value === 'string' ? value : undefined\n }\n\n // How far content reaches past a side of the capture, in CSS pixels: rounded up when it's at least one whole pixel,\n // and 0 when it's less or unknown, as Chrome rounds scrollWidth and clientWidth to whole pixels.\n const excessOf = (excess) =>\n typeof excess === 'number' && Number.isFinite(excess) && excess >= 1 ? Math.ceil(excess) : 0\n\n // The overflow on each side, or undefined when no side counts.\n const overflowOf = ({ top, right, bottom, left }) => {\n const overflow = { top: excessOf(top), right: excessOf(right), bottom: excessOf(bottom), left: excessOf(left) }\n return Object.values(overflow).some((side) => side > 0) ? overflow : undefined\n }\n\n // The full page's overflow: how far its content reaches past the viewport's right edge, or undefined when nothing\n // does, the root element or body clips it with overflow-x hidden or clip, or that can't be read.\n const pageOverflowOf = () => {\n const root = read(() => document.documentElement, undefined)\n const body = read(() => document.body, undefined)\n const clips = (element) => {\n const value = computedOf(element, 'overflow-x')\n return value === undefined || value === 'hidden' || value === 'clip'\n }\n if (!isObject(root) || [root, body].filter(isObject).some(clips)) {\n return undefined\n }\n const scrollWidth = numberOf(() => root.scrollWidth)\n const clientWidth = numberOf(() => root.clientWidth)\n if (scrollWidth === undefined || clientWidth === undefined) {\n return undefined\n }\n return overflowOf({ top: 0, right: scrollWidth - clientWidth, bottom: 0, left: 0 })\n }\n\n // Whether an element lets its content spill along an axis: its computed overflow on that axis is visible, and, along\n // x, its direction is ltr, as a right-to-left element's scrollWidth counts content spilling left.\n const spillsOn = (element, axis) =>\n computedOf(element, axis === 'x' ? 'overflow-x' : 'overflow-y') === 'visible' &&\n (axis === 'y' || computedOf(element, 'direction') === 'ltr')\n\n // How a length in an element's own layout maps to the document along an axis: its border box's drawn extent over its\n // layout size, offsetWidth or offsetHeight, when they differ by a whole pixel or more, as a transform or zoom makes\n // them, and 1 otherwise, as the layout size is rounded to whole pixels. Undefined when the layout size can't be read.\n const scaleOf = (element, axis, extent) => {\n const layout = numberOf(() => (axis === 'x' ? element.offsetWidth : element.offsetHeight))\n if (layout === undefined || layout <= 0) {\n return undefined\n }\n return Math.abs(extent - layout) < 1 ? 1 : extent / layout\n }\n\n // How far an element's content spills past its border box's far edge along an axis, from its border box's near and\n // far edges in document coordinates, or undefined when the element doesn't let it spill or it can't be read. The\n // content's end is clientLeft and scrollWidth past the near edge, or clientTop and scrollHeight, lengths of the\n // element's own layout, scaled to the document, so a transform or zoom neither makes a spill nor hides one. Both\n // ends are kept within the document's scrollable area, limit, when it's known.\n const spillOf = (element, axis, near, far, limit) => {\n if (!spillsOn(element, axis)) {\n return undefined\n }\n const border = numberOf(() => (axis === 'x' ? element.clientLeft : element.clientTop))\n const content = numberOf(() => (axis === 'x' ? element.scrollWidth : element.scrollHeight))\n const scale = scaleOf(element, axis, far - near)\n if (border === undefined || content === undefined || scale === undefined) {\n return undefined\n }\n const within = (end) => (limit === undefined ? end : Math.min(end, limit))\n return within(near + (border + content) * scale) - within(far)\n }\n\n // An element's overflow, from its border box in document coordinates, or undefined when no side counts.\n const elementOverflowOf = (element, box, size) =>\n overflowOf({\n top: -box.top,\n right: spillOf(element, 'x', box.left, box.right, size === undefined ? undefined : size.width),\n bottom: spillOf(element, 'y', box.top, box.bottom, size === undefined ? undefined : size.height),\n left: -box.left,\n })\n\n // An element's border box, with the page's scroll, or undefined when it has no area or can't be read.\n const documentBoxOf = (element, scroll) => {\n const rect = read(() => element.getBoundingClientRect(), undefined)\n const sides = read(() => [rect.left, rect.top, rect.right, rect.bottom, rect.width, rect.height], [])\n if (sides.length === 0 || !sides.every(Number.isFinite) || rect.width <= 0 || rect.height <= 0) {\n return undefined\n }\n return {\n left: rect.left + scroll.x,\n top: rect.top + scroll.y,\n right: rect.right + scroll.x,\n bottom: rect.bottom + scroll.y,\n }\n }\n\n // The box of the element the selector matches first, out to whole pixels, with its overflow when a side counts, or\n // why there's none.\n const elementBoxOf = (selector, scroll) => {\n let element\n try {\n element = document.querySelector(selector)\n } catch (error) {\n return { outcome: 'invalid-selector', of: 'element', message: messageOf(error) }\n }\n if (!isObject(element)) {\n return { outcome: 'element-missing', found: 'nothing' }\n }\n const box = documentBoxOf(element, scroll)\n if (box === undefined) {\n return { outcome: 'element-missing', found: 'zero-size' }\n }\n const size = documentSizeOf()\n const x = Math.max(0, Math.floor(box.left))\n const y = Math.max(0, Math.floor(box.top))\n const right = Math.ceil(size === undefined ? box.right : Math.min(box.right, size.width))\n const bottom = Math.ceil(size === undefined ? box.bottom : Math.min(box.bottom, size.height))\n const width = right - x\n const height = bottom - y\n if (width <= 0 || height <= 0) {\n return { outcome: 'element-missing', found: 'zero-size' }\n }\n return { box: { x, y, width, height }, overflow: elementOverflowOf(element, box, size) }\n }\n\n // The boxes of the elements a selector mask covers, or why there are none.\n const selectorBoxesOf = (mask, scroll) => {\n let elements\n try {\n elements = Array.from(document.querySelectorAll(mask.selector))\n } catch (error) {\n return { outcome: 'invalid-selector', of: 'mask', name: mask.name, message: messageOf(error) }\n }\n return { boxes: elements.map((element) => documentBoxOf(element, scroll)).filter((box) => box !== undefined) }\n }\n\n // Runs the remote content search once, when a host mask or the request needs it, or gives undefined when neither\n // does. A search that rejects fails the host masks, as a mask must never fail open, and with no host mask leaves the\n // remote content unknown.\n const searchOnce = async (hostMasks, findRemote, timeoutMs) => {\n if (hostMasks.length === 0 && !findRemote) {\n return undefined\n }\n try {\n return await findRemoteContent(timeoutMs)\n } catch (error) {\n if (hostMasks.length > 0) {\n throw error\n }\n return undefined\n }\n }\n\n // The boxes of the remote content the host masks cover, or why there are none.\n const hostBoxesOf = (hostMasks, search) => {\n if (hostMasks.length === 0) {\n return { boxes: [] }\n }\n if (search.outcome === 'timed-out') {\n return { outcome: 'timed-out' }\n }\n const boxes = []\n for (const mask of hostMasks) {\n const host = mask.host.toLowerCase()\n for (const item of search.items) {\n if (item.host === host || item.hostname === host) {\n boxes.push({ left: item.x, top: item.y, right: item.x + item.width, bottom: item.y + item.height })\n }\n }\n }\n return { boxes }\n }\n\n // The remote content a search found, each item by its host and box, or undefined when it's unknown: no search ran,\n // it rejected or it timed out.\n const remoteOf = (search) => {\n if (search === undefined || search.outcome !== 'found') {\n return undefined\n }\n return search.items.map((item) => ({\n host: item.host,\n x: item.x,\n y: item.y,\n width: item.width,\n height: item.height,\n }))\n }\n\n // The boxes of every mask, selector masks first, with the remote content found when the request asks for it, or why\n // there are none.\n const maskBoxesOf = async (masks, scroll, findRemote, timeoutMs) => {\n const boxes = []\n for (const mask of masks) {\n if (typeof mask.selector === 'string') {\n const found = selectorBoxesOf(mask, scroll)\n if (found.outcome !== undefined) {\n return found\n }\n boxes.push(...found.boxes)\n }\n }\n const hostMasks = masks.filter((mask) => typeof mask.host === 'string')\n const search = await searchOnce(hostMasks, findRemote, timeoutMs)\n const found = hostBoxesOf(hostMasks, search)\n if (found.outcome !== undefined) {\n return found\n }\n return { boxes: [...boxes, ...found.boxes], remote: findRemote ? remoteOf(search) : undefined }\n }\n\n // The inline style of the element that holds the masks: a box at the document's origin, the size of its scrollable\n // area, clipping what's past it, or an empty box clipping nothing when that size can't be read.\n const hostStyleOf = (size) =>\n [\n 'all: initial !important',\n 'display: block !important',\n 'position: absolute !important',\n 'left: 0 !important',\n 'top: 0 !important',\n 'width: ' + (size === undefined ? 0 : size.width) + 'px !important',\n 'height: ' + (size === undefined ? 0 : size.height) + 'px !important',\n 'margin: 0 !important',\n 'padding: 0 !important',\n 'border: 0 !important',\n 'overflow: ' + (size === undefined ? 'visible' : 'clip') + ' !important',\n 'background: transparent !important',\n 'pointer-events: none !important',\n ].join('; ')\n\n // The inline style of a painted box.\n const maskStyleOf = (box, maskColor) =>\n [\n 'all: initial !important',\n 'display: block !important',\n 'position: absolute !important',\n 'left: ' + box.left + 'px !important',\n 'top: ' + box.top + 'px !important',\n 'width: ' + (box.right - box.left) + 'px !important',\n 'height: ' + (box.bottom - box.top) + 'px !important',\n 'background: ' + maskColor + ' !important',\n ].join('; ')\n\n // Paints the boxes in a manual popover, so they sit in the top layer, or over the page by z-index when it can't.\n const paint = (boxes, maskColor) => {\n if (boxes.length === 0) {\n return\n }\n const hostStyle = hostStyleOf(documentSizeOf())\n const host = document.createElement(masksTagName)\n host.setAttribute('popover', 'manual')\n host.style.cssText = hostStyle\n for (const box of boxes) {\n const mask = document.createElement('div')\n mask.style.cssText = maskStyleOf(box, maskColor)\n host.appendChild(mask)\n }\n document.documentElement.appendChild(host)\n try {\n host.showPopover()\n } catch {\n host.style.cssText = hostStyle + '; z-index: ' + topZIndex + ' !important'\n }\n }\n\n // Finds the masks' boxes and paints them, giving the remote content found when that's done, or why it couldn't be.\n // A mask unpainted would leave its content in the capture, so anything thrown here fails the preparation.\n const paintMasks = async (masks, maskColor, scroll, findRemote, timeoutMs) => {\n try {\n const found = await maskBoxesOf(masks, scroll, findRemote, timeoutMs)\n if (found.outcome !== undefined) {\n return found\n }\n paint(found.boxes, maskColor)\n return { remote: found.remote }\n } catch (error) {\n return { outcome: 'paint-failed', message: messageOf(error) }\n }\n }\n\n // Hides the caret in a document's roots with a sheet its own window made, then in the documents of its frames.\n const hideCaretIn = (hidden, recordedRoots) => {\n let sheet\n try {\n sheet = new hidden.defaultView.CSSStyleSheet()\n sheet.replaceSync(caretRule)\n } catch {\n return\n }\n for (const root of rootsOf(hidden, recordedRoots)) {\n try {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet]\n } catch {}\n for (const frame of elementsOf(root, 'iframe, frame')) {\n const frameDocument = read(() => frame.contentDocument, null)\n if (isObject(frameDocument)) {\n hideCaretIn(frameDocument, recordedRootsOf(frame, stateGlobal))\n }\n }\n }\n }\n\n return async (request, timeoutMs) => {\n const { element, masks, maskColor, findRemote } = request\n const scroll = pageScrollOf()\n const grid = gridOf()\n const measured = element === null ? { box: null, overflow: pageOverflowOf() } : elementBoxOf(element, scroll)\n if (measured.outcome !== undefined) {\n return measured\n }\n const painted = await paintMasks(masks, maskColor, scroll, findRemote, timeoutMs)\n if (painted.outcome !== undefined) {\n return painted\n }\n try {\n hideCaretIn(document, shadowRoots)\n } catch {}\n const ready = { outcome: 'ready', box: measured.box }\n return {\n ...ready,\n ...(painted.remote === undefined ? {} : { remote: painted.remote }),\n ...(grid === undefined ? {} : { grid }),\n ...(measured.overflow === undefined ? {} : { overflow: measured.overflow }),\n }\n }\n}";
143
186
  /**
144
187
  * What preparing the page for its capture found.
145
188
  */
@@ -161,6 +204,10 @@ export type CapturePrep = {
161
204
  * The grids the page shows, when it shows any: the widest grid's width and the tallest grid's height.
162
205
  */
163
206
  grid?: PageGrid;
207
+ /**
208
+ * The content the capture would cut, when at least one side counts: how far it reaches past each side.
209
+ */
210
+ overflow?: PageOverflow;
164
211
  } | {
165
212
  /**
166
213
  * The element selector matched no element with an area.
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-capture.d.ts","sourceRoot":"","sources":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,iBAAiB,EAAE,CAAA;IAC5B;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,iBAAiB,CAAA;IAC1B;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,WAAW,CAAA;CAC/B,GACD;IACE;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAA;IAC3B;;OAEG;IACH,EAAE,EAAE,SAAS,CAAA;IACb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAA;IAC3B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,WAAW,CAAA;CACrB,GACD;IACE;;OAEG;IACH,OAAO,EAAE,gBAAgB,CAAA;CAC1B,GACD;IACE;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAoJL;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAW3D"}
1
+ {"version":3,"file":"prepare-capture.d.ts","sourceRoot":"","sources":["../../src/capture/prepare-capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAGpD;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB;IACE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB,GACD;IACE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAEL;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,E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