@storyshelf/core 0.6.2 → 0.8.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 (727) hide show
  1. package/README.md +49 -32
  2. package/dist/adapter/capture-queue.d.mts +44 -4
  3. package/dist/adapter/capture-runner.d.mts +134 -12
  4. package/dist/adapter/capture-runner.mjs +9 -12
  5. package/dist/adapter/database.d.mts +89 -10
  6. package/dist/adapter/database.mjs +4 -3
  7. package/dist/adapter/database.mjs.map +1 -1
  8. package/dist/adapter/design.d.mts +83 -0
  9. package/dist/adapter/design.mjs +27 -0
  10. package/dist/adapter/design.mjs.map +1 -0
  11. package/dist/adapter/email-sender.d.mts +0 -2
  12. package/dist/adapter/metadata.d.mts +3 -12
  13. package/dist/adapter/notifier.d.mts +6 -3
  14. package/dist/adapter/notifier.mjs +5 -1
  15. package/dist/adapter/oauth.d.mts +50 -0
  16. package/dist/adapter/setup.d.mts +4 -7
  17. package/dist/adapter/setup.mjs +3 -3
  18. package/dist/adapter/setup.mjs.map +1 -1
  19. package/dist/adapter/storage.d.mts +1 -3
  20. package/dist/adapter/webhook-events.d.mts +0 -2
  21. package/dist/adapter/webhook-events.mjs +13 -14
  22. package/dist/adapter/webhook-events.mjs.map +1 -1
  23. package/dist/adapters/capture-target-offers.d.mts +26 -0
  24. package/dist/adapters/capture-target-offers.mjs +57 -0
  25. package/dist/adapters/capture-target-offers.mjs.map +1 -0
  26. package/dist/adapters/capture-target.d.mts +69 -0
  27. package/dist/adapters/capture-target.mjs +75 -0
  28. package/dist/adapters/capture-target.mjs.map +1 -0
  29. package/dist/adapters/notifier/build-comment.d.mts +22 -0
  30. package/dist/adapters/notifier/build-comment.mjs +23 -0
  31. package/dist/adapters/notifier/build-comment.mjs.map +1 -0
  32. package/dist/adapters/notifier/build-state.d.mts +97 -0
  33. package/dist/adapters/notifier/build-state.mjs +217 -0
  34. package/dist/adapters/notifier/build-state.mjs.map +1 -0
  35. package/dist/adapters/notifier/events.d.mts +4 -4
  36. package/dist/adapters/notifier/events.mjs +32 -20
  37. package/dist/adapters/notifier/events.mjs.map +1 -1
  38. package/dist/adapters/notifier/format.d.mts +0 -2
  39. package/dist/adapters/notifier/format.mjs +1 -2
  40. package/dist/adapters/notifier/provider.d.mts +53 -9
  41. package/dist/adapters/notifier/provider.mjs +11 -0
  42. package/dist/adapters/notifier/provider.mjs.map +1 -0
  43. package/dist/adapters/notifier/state.d.mts +22 -0
  44. package/dist/adapters/notifier/state.mjs +65 -0
  45. package/dist/adapters/notifier/state.mjs.map +1 -0
  46. package/dist/adapters/notifier/types.d.mts +51 -4
  47. package/dist/adapters/remote-browser.d.mts +168 -0
  48. package/dist/adapters/remote-browser.mjs +201 -0
  49. package/dist/adapters/remote-browser.mjs.map +1 -0
  50. package/dist/adapters/remote-lease-attempt.mjs +39 -0
  51. package/dist/adapters/remote-lease-attempt.mjs.map +1 -0
  52. package/dist/adapters/remote-lease-error.d.mts +25 -0
  53. package/dist/adapters/remote-lease-error.mjs +54 -0
  54. package/dist/adapters/remote-lease-error.mjs.map +1 -0
  55. package/dist/adapters/remote-lease-held.d.mts +15 -0
  56. package/dist/adapters/remote-lease-held.mjs +86 -0
  57. package/dist/adapters/remote-lease-held.mjs.map +1 -0
  58. package/dist/adapters/remote-lease-shutdown.d.mts +12 -0
  59. package/dist/adapters/remote-lease-shutdown.mjs +32 -0
  60. package/dist/adapters/remote-lease-shutdown.mjs.map +1 -0
  61. package/dist/adapters/remote-lease.d.mts +39 -0
  62. package/dist/adapters/remote-lease.mjs +175 -0
  63. package/dist/adapters/remote-lease.mjs.map +1 -0
  64. package/dist/adapters/remote-limiter.mjs +121 -0
  65. package/dist/adapters/remote-limiter.mjs.map +1 -0
  66. package/dist/adapters/remote-pool.d.mts +56 -0
  67. package/dist/adapters/remote-pool.mjs +195 -0
  68. package/dist/adapters/remote-pool.mjs.map +1 -0
  69. package/dist/adapters/render-runs.d.mts +23 -0
  70. package/dist/adapters/render-runs.mjs +40 -0
  71. package/dist/adapters/render-runs.mjs.map +1 -0
  72. package/dist/adapters/setup-runner.d.mts +0 -2
  73. package/dist/adapters/setup-runner.mjs +3 -6
  74. package/dist/adapters/setup-runner.mjs.map +1 -1
  75. package/dist/adapters/sources.d.mts +10 -0
  76. package/dist/adapters/sources.mjs +19 -0
  77. package/dist/adapters/sources.mjs.map +1 -0
  78. package/dist/adapters/validate.d.mts +0 -2
  79. package/dist/adapters/validate.mjs +27 -20
  80. package/dist/adapters/validate.mjs.map +1 -1
  81. package/dist/ai.d.mts +103 -0
  82. package/dist/ai.mjs +18 -0
  83. package/dist/ai.mjs.map +1 -0
  84. package/dist/auth.d.mts +0 -2
  85. package/dist/auth.mjs +1 -2
  86. package/dist/brand-packs.d.mts +0 -2
  87. package/dist/brand-packs.mjs +0 -1
  88. package/dist/capture/a11y/axe-source.d.mts +16 -0
  89. package/dist/capture/a11y/axe-source.mjs +36 -0
  90. package/dist/capture/a11y/axe-source.mjs.map +1 -0
  91. package/dist/capture/a11y/in-page.d.mts +25 -0
  92. package/dist/capture/a11y/in-page.mjs +59 -0
  93. package/dist/capture/a11y/in-page.mjs.map +1 -0
  94. package/dist/capture/a11y/map.d.mts +22 -0
  95. package/dist/capture/a11y/map.mjs +47 -0
  96. package/dist/capture/a11y/map.mjs.map +1 -0
  97. package/dist/capture/a11y/options.d.mts +21 -0
  98. package/dist/capture/a11y/options.mjs +74 -0
  99. package/dist/capture/a11y/options.mjs.map +1 -0
  100. package/dist/capture/adapter.d.mts +46 -5
  101. package/dist/capture/adapter.mjs +1 -2
  102. package/dist/capture/adapter.mjs.map +1 -1
  103. package/dist/capture/affected.d.mts +2 -2
  104. package/dist/capture/affected.mjs +14 -6
  105. package/dist/capture/affected.mjs.map +1 -1
  106. package/dist/capture/attempt-logger.mjs +83 -0
  107. package/dist/capture/attempt-logger.mjs.map +1 -0
  108. package/dist/capture/browsers.d.mts +33 -0
  109. package/dist/capture/browsers.mjs +66 -0
  110. package/dist/capture/browsers.mjs.map +1 -0
  111. package/dist/capture/build-state/deliver.d.mts +30 -0
  112. package/dist/capture/build-state/deliver.mjs +117 -0
  113. package/dist/capture/build-state/deliver.mjs.map +1 -0
  114. package/dist/capture/build-state/index.d.mts +8 -0
  115. package/dist/capture/build-state/notify-job.d.mts +54 -0
  116. package/dist/capture/build-state/notify-job.mjs +132 -0
  117. package/dist/capture/build-state/notify-job.mjs.map +1 -0
  118. package/dist/capture/build-state/publisher.d.mts +21 -0
  119. package/dist/capture/build-state/publisher.mjs +106 -0
  120. package/dist/capture/build-state/publisher.mjs.map +1 -0
  121. package/dist/capture/build-state/resume.d.mts +7 -0
  122. package/dist/capture/build-state/resume.mjs +46 -0
  123. package/dist/capture/build-state/resume.mjs.map +1 -0
  124. package/dist/capture/build-state/types.d.mts +47 -0
  125. package/dist/capture/catalog/catalogue.d.mts +20 -0
  126. package/dist/capture/catalog/catalogue.mjs +52 -0
  127. package/dist/capture/catalog/catalogue.mjs.map +1 -0
  128. package/dist/capture/catalog/components.d.mts +21 -0
  129. package/dist/capture/catalog/components.mjs +54 -0
  130. package/dist/capture/catalog/components.mjs.map +1 -0
  131. package/dist/capture/catalog/history.d.mts +28 -0
  132. package/dist/capture/catalog/history.mjs +50 -0
  133. package/dist/capture/catalog/history.mjs.map +1 -0
  134. package/dist/capture/catalog/hook.d.mts +12 -0
  135. package/dist/capture/catalog/hook.mjs +18 -0
  136. package/dist/capture/catalog/hook.mjs.map +1 -0
  137. package/dist/capture/catalog/index.d.mts +11 -0
  138. package/dist/capture/catalog/load.d.mts +24 -0
  139. package/dist/capture/catalog/load.mjs +48 -0
  140. package/dist/capture/catalog/load.mjs.map +1 -0
  141. package/dist/capture/catalog/parse.d.mts +13 -0
  142. package/dist/capture/catalog/parse.mjs +55 -0
  143. package/dist/capture/catalog/parse.mjs.map +1 -0
  144. package/dist/capture/catalog/read.d.mts +15 -0
  145. package/dist/capture/catalog/read.mjs +39 -0
  146. package/dist/capture/catalog/read.mjs.map +1 -0
  147. package/dist/capture/catalog/types.d.mts +31 -0
  148. package/dist/capture/comparison-reference.d.mts +27 -0
  149. package/dist/capture/comparison-reference.mjs +75 -0
  150. package/dist/capture/comparison-reference.mjs.map +1 -0
  151. package/dist/capture/consumer/capture-handler.d.mts +56 -0
  152. package/dist/capture/consumer/capture-handler.mjs +117 -0
  153. package/dist/capture/consumer/capture-handler.mjs.map +1 -0
  154. package/dist/capture/consumer/idle.d.mts +15 -0
  155. package/dist/capture/consumer/idle.mjs +24 -0
  156. package/dist/capture/consumer/idle.mjs.map +1 -0
  157. package/dist/capture/consumer/index.d.mts +11 -0
  158. package/dist/capture/consumer/index.mjs +138 -0
  159. package/dist/capture/consumer/index.mjs.map +1 -0
  160. package/dist/capture/consumer/loop.mjs +109 -0
  161. package/dist/capture/consumer/loop.mjs.map +1 -0
  162. package/dist/capture/consumer/metrics.d.mts +39 -0
  163. package/dist/capture/consumer/metrics.mjs +37 -0
  164. package/dist/capture/consumer/metrics.mjs.map +1 -0
  165. package/dist/capture/consumer/retry.d.mts +31 -0
  166. package/dist/capture/consumer/retry.mjs +33 -0
  167. package/dist/capture/consumer/retry.mjs.map +1 -0
  168. package/dist/capture/consumer/run-job.mjs +194 -0
  169. package/dist/capture/consumer/run-job.mjs.map +1 -0
  170. package/dist/capture/consumer/startup.mjs +37 -0
  171. package/dist/capture/consumer/startup.mjs.map +1 -0
  172. package/dist/capture/consumer/types.d.mts +95 -0
  173. package/dist/capture/crash-failure.d.mts +23 -0
  174. package/dist/capture/crash-failure.mjs +69 -0
  175. package/dist/capture/crash-failure.mjs.map +1 -0
  176. package/dist/capture/db-queue/cadence.d.mts +30 -0
  177. package/dist/capture/db-queue/cadence.mjs +37 -0
  178. package/dist/capture/db-queue/cadence.mjs.map +1 -0
  179. package/dist/capture/db-queue/claim.d.mts +7 -0
  180. package/dist/capture/db-queue/claim.mjs +148 -0
  181. package/dist/capture/db-queue/claim.mjs.map +1 -0
  182. package/dist/capture/db-queue/clock.mjs +11 -0
  183. package/dist/capture/db-queue/clock.mjs.map +1 -0
  184. package/dist/capture/db-queue/codec.mjs +75 -0
  185. package/dist/capture/db-queue/codec.mjs.map +1 -0
  186. package/dist/capture/db-queue/index.d.mts +18 -0
  187. package/dist/capture/db-queue/index.mjs +89 -0
  188. package/dist/capture/db-queue/index.mjs.map +1 -0
  189. package/dist/capture/db-queue/keeper.d.mts +34 -0
  190. package/dist/capture/db-queue/keeper.mjs +91 -0
  191. package/dist/capture/db-queue/keeper.mjs.map +1 -0
  192. package/dist/capture/db-queue/lease.mjs +45 -0
  193. package/dist/capture/db-queue/lease.mjs.map +1 -0
  194. package/dist/capture/db-queue/lifecycle.mjs +35 -0
  195. package/dist/capture/db-queue/lifecycle.mjs.map +1 -0
  196. package/dist/capture/db-queue/operations.mjs +93 -0
  197. package/dist/capture/db-queue/operations.mjs.map +1 -0
  198. package/dist/capture/db-queue/poll-loop.d.mts +28 -0
  199. package/dist/capture/db-queue/poll-loop.mjs +88 -0
  200. package/dist/capture/db-queue/poll-loop.mjs.map +1 -0
  201. package/dist/capture/db-queue/poll.d.mts +8 -0
  202. package/dist/capture/db-queue/poll.mjs +68 -0
  203. package/dist/capture/db-queue/poll.mjs.map +1 -0
  204. package/dist/capture/db-queue/timers.d.mts +10 -0
  205. package/dist/capture/db-queue/timers.mjs +36 -0
  206. package/dist/capture/db-queue/timers.mjs.map +1 -0
  207. package/dist/capture/db-queue/types.d.mts +81 -0
  208. package/dist/capture/db-queue/types.mjs +11 -0
  209. package/dist/capture/db-queue/types.mjs.map +1 -0
  210. package/dist/capture/db-queue/wake.mjs +47 -0
  211. package/dist/capture/db-queue/wake.mjs.map +1 -0
  212. package/dist/capture/design.mjs +38 -0
  213. package/dist/capture/design.mjs.map +1 -0
  214. package/dist/capture/diff-record.mjs +24 -5
  215. package/dist/capture/diff-record.mjs.map +1 -1
  216. package/dist/capture/dispatch.d.mts +13 -10
  217. package/dist/capture/dispatch.mjs +102 -111
  218. package/dist/capture/dispatch.mjs.map +1 -1
  219. package/dist/capture/enrich.mjs +59 -0
  220. package/dist/capture/enrich.mjs.map +1 -0
  221. package/dist/capture/failure-sets.mjs +21 -0
  222. package/dist/capture/failure-sets.mjs.map +1 -0
  223. package/dist/capture/fingerprint.d.mts +40 -0
  224. package/dist/capture/fingerprint.mjs +82 -0
  225. package/dist/capture/fingerprint.mjs.map +1 -0
  226. package/dist/capture/forked/channel.d.mts +23 -0
  227. package/dist/capture/forked/child.d.mts +32 -0
  228. package/dist/capture/forked/child.mjs +201 -0
  229. package/dist/capture/forked/child.mjs.map +1 -0
  230. package/dist/capture/forked/crash-tracker.mjs +22 -0
  231. package/dist/capture/forked/crash-tracker.mjs.map +1 -0
  232. package/dist/capture/forked/decision.d.mts +24 -0
  233. package/dist/capture/forked/decision.mjs +26 -0
  234. package/dist/capture/forked/decision.mjs.map +1 -0
  235. package/dist/capture/forked/exit.mjs +11 -0
  236. package/dist/capture/forked/exit.mjs.map +1 -0
  237. package/dist/capture/forked/fork.d.mts +29 -0
  238. package/dist/capture/forked/fork.mjs +92 -0
  239. package/dist/capture/forked/fork.mjs.map +1 -0
  240. package/dist/capture/forked/forked-capture.d.mts +38 -0
  241. package/dist/capture/forked/forked-capture.mjs +239 -0
  242. package/dist/capture/forked/forked-capture.mjs.map +1 -0
  243. package/dist/capture/forked/lease-book.mjs +45 -0
  244. package/dist/capture/forked/lease-book.mjs.map +1 -0
  245. package/dist/capture/forked/protocol.d.mts +36 -0
  246. package/dist/capture/forked/protocol.mjs +24 -0
  247. package/dist/capture/forked/protocol.mjs.map +1 -0
  248. package/dist/capture/forked/runs.mjs +74 -0
  249. package/dist/capture/forked/runs.mjs.map +1 -0
  250. package/dist/capture/guards.mjs +1 -2
  251. package/dist/capture/ignore-regions.d.mts +36 -0
  252. package/dist/capture/ignore-regions.mjs +65 -0
  253. package/dist/capture/ignore-regions.mjs.map +1 -0
  254. package/dist/capture/isolate.mjs +140 -0
  255. package/dist/capture/isolate.mjs.map +1 -0
  256. package/dist/capture/job-lease.d.mts +26 -0
  257. package/dist/capture/job-lease.mjs +56 -0
  258. package/dist/capture/job-lease.mjs.map +1 -0
  259. package/dist/capture/matrix.mjs +298 -0
  260. package/dist/capture/matrix.mjs.map +1 -0
  261. package/dist/capture/modes.d.mts +23 -0
  262. package/dist/capture/modes.mjs +106 -0
  263. package/dist/capture/modes.mjs.map +1 -0
  264. package/dist/capture/orchestrator.d.mts +37 -7
  265. package/dist/capture/orchestrator.mjs +120 -110
  266. package/dist/capture/orchestrator.mjs.map +1 -1
  267. package/dist/capture/pipeline.d.mts +9 -4
  268. package/dist/capture/pipeline.mjs +284 -48
  269. package/dist/capture/pipeline.mjs.map +1 -1
  270. package/dist/capture/progress.d.mts +9 -0
  271. package/dist/capture/progress.mjs +27 -0
  272. package/dist/capture/progress.mjs.map +1 -0
  273. package/dist/capture/publish/accept.d.mts +37 -0
  274. package/dist/capture/publish/accept.mjs +27 -0
  275. package/dist/capture/publish/accept.mjs.map +1 -0
  276. package/dist/capture/publish/complete.d.mts +44 -0
  277. package/dist/capture/publish/complete.mjs +63 -0
  278. package/dist/capture/publish/complete.mjs.map +1 -0
  279. package/dist/capture/publish/extract.d.mts +18 -0
  280. package/dist/capture/publish/extract.mjs +120 -0
  281. package/dist/capture/publish/extract.mjs.map +1 -0
  282. package/dist/capture/publish/handler.d.mts +26 -0
  283. package/dist/capture/publish/handler.mjs +61 -0
  284. package/dist/capture/publish/handler.mjs.map +1 -0
  285. package/dist/capture/publish/index.d.mts +11 -0
  286. package/dist/capture/publish/invalid-zip.d.mts +8 -0
  287. package/dist/capture/publish/invalid-zip.mjs +11 -0
  288. package/dist/capture/publish/invalid-zip.mjs.map +1 -0
  289. package/dist/capture/publish/limits.d.mts +35 -0
  290. package/dist/capture/publish/limits.mjs +38 -0
  291. package/dist/capture/publish/limits.mjs.map +1 -0
  292. package/dist/capture/publish/published.d.mts +13 -0
  293. package/dist/capture/publish/published.mjs +17 -0
  294. package/dist/capture/publish/published.mjs.map +1 -0
  295. package/dist/capture/publish/run.d.mts +31 -0
  296. package/dist/capture/publish/run.mjs +29 -0
  297. package/dist/capture/publish/run.mjs.map +1 -0
  298. package/dist/capture/rediff.d.mts +1 -3
  299. package/dist/capture/rediff.mjs +23 -9
  300. package/dist/capture/rediff.mjs.map +1 -1
  301. package/dist/capture/render.mjs +52 -0
  302. package/dist/capture/render.mjs.map +1 -0
  303. package/dist/capture/scratch.d.mts +42 -0
  304. package/dist/capture/scratch.mjs +136 -0
  305. package/dist/capture/scratch.mjs.map +1 -0
  306. package/dist/capture/shard-plan.mjs +127 -0
  307. package/dist/capture/shard-plan.mjs.map +1 -0
  308. package/dist/capture/shards/context.mjs +51 -0
  309. package/dist/capture/shards/context.mjs.map +1 -0
  310. package/dist/capture/shards/execute.mjs +175 -0
  311. package/dist/capture/shards/execute.mjs.map +1 -0
  312. package/dist/capture/shards/fan-out.mjs +125 -0
  313. package/dist/capture/shards/fan-out.mjs.map +1 -0
  314. package/dist/capture/shards/history.mjs +34 -0
  315. package/dist/capture/shards/history.mjs.map +1 -0
  316. package/dist/capture/shards/reduce.mjs +96 -0
  317. package/dist/capture/shards/reduce.mjs.map +1 -0
  318. package/dist/capture/sizing.d.mts +0 -2
  319. package/dist/capture/sizing.mjs +2 -13
  320. package/dist/capture/sizing.mjs.map +1 -1
  321. package/dist/capture/skip-checks.mjs +3 -67
  322. package/dist/capture/skip-checks.mjs.map +1 -1
  323. package/dist/capture/statics.d.mts +7 -10
  324. package/dist/capture/statics.mjs +26 -74
  325. package/dist/capture/statics.mjs.map +1 -1
  326. package/dist/capture/storybook-urls.d.mts +38 -0
  327. package/dist/capture/storybook-urls.mjs +41 -0
  328. package/dist/capture/storybook-urls.mjs.map +1 -0
  329. package/dist/capture/storybook.d.mts +12 -6
  330. package/dist/capture/storybook.mjs +63 -19
  331. package/dist/capture/storybook.mjs.map +1 -1
  332. package/dist/capture/target.mjs +20 -0
  333. package/dist/capture/target.mjs.map +1 -0
  334. package/dist/capture/targets.d.mts +23 -0
  335. package/dist/capture/targets.mjs +31 -0
  336. package/dist/capture/targets.mjs.map +1 -0
  337. package/dist/capture/tests.d.mts +35 -0
  338. package/dist/capture/tests.mjs +136 -0
  339. package/dist/capture/tests.mjs.map +1 -0
  340. package/dist/capture/token-chunks.mjs +91 -0
  341. package/dist/capture/token-chunks.mjs.map +1 -0
  342. package/dist/capture.d.mts +63 -7
  343. package/dist/capture.mjs +51 -3
  344. package/dist/config.d.mts +136 -14
  345. package/dist/config.mjs +14 -8
  346. package/dist/config.mjs.map +1 -1
  347. package/dist/diff.d.mts +7 -3
  348. package/dist/diff.mjs +15 -3
  349. package/dist/diff.mjs.map +1 -0
  350. package/dist/index.d.mts +3 -3
  351. package/dist/index.mjs +2 -2
  352. package/dist/insights/budget.d.mts +18 -0
  353. package/dist/insights/budget.mjs +32 -0
  354. package/dist/insights/budget.mjs.map +1 -0
  355. package/dist/insights/envelope.d.mts +57 -0
  356. package/dist/insights/envelope.mjs +59 -0
  357. package/dist/insights/envelope.mjs.map +1 -0
  358. package/dist/insights/evidence-health.d.mts +30 -0
  359. package/dist/insights/evidence-health.mjs +27 -0
  360. package/dist/insights/evidence-health.mjs.map +1 -0
  361. package/dist/insights/evidence.d.mts +53 -0
  362. package/dist/insights/evidence.mjs +63 -0
  363. package/dist/insights/evidence.mjs.map +1 -0
  364. package/dist/insights/hash.d.mts +16 -0
  365. package/dist/insights/hash.mjs +20 -0
  366. package/dist/insights/hash.mjs.map +1 -0
  367. package/dist/insights/limits.d.mts +22 -0
  368. package/dist/insights/limits.mjs +23 -0
  369. package/dist/insights/limits.mjs.map +1 -0
  370. package/dist/insights/prompts/v1.d.mts +11 -0
  371. package/dist/insights/prompts/v1.mjs +33 -0
  372. package/dist/insights/prompts/v1.mjs.map +1 -0
  373. package/dist/insights/redact.d.mts +7 -0
  374. package/dist/insights/redact.mjs +23 -0
  375. package/dist/insights/redact.mjs.map +1 -0
  376. package/dist/insights/text.mjs +43 -0
  377. package/dist/insights/text.mjs.map +1 -0
  378. package/dist/insights.d.mts +11 -0
  379. package/dist/insights.mjs +12 -0
  380. package/dist/logger.d.mts +0 -2
  381. package/dist/logger.mjs +18 -3
  382. package/dist/logger.mjs.map +1 -1
  383. package/dist/models/ai-budget-alert.d.mts +21 -0
  384. package/dist/models/ai-budget-alert.mjs +37 -0
  385. package/dist/models/ai-budget-alert.mjs.map +1 -0
  386. package/dist/models/ai-usage.d.mts +38 -0
  387. package/dist/models/ai-usage.mjs +60 -0
  388. package/dist/models/ai-usage.mjs.map +1 -0
  389. package/dist/models/baseline-approval.d.mts +18 -0
  390. package/dist/models/baseline-approval.mjs +41 -0
  391. package/dist/models/baseline-approval.mjs.map +1 -0
  392. package/dist/models/baseline-archive.d.mts +82 -0
  393. package/dist/models/baseline-archive.mjs +105 -0
  394. package/dist/models/baseline-archive.mjs.map +1 -0
  395. package/dist/models/baseline-atomic.mjs +66 -0
  396. package/dist/models/baseline-atomic.mjs.map +1 -0
  397. package/dist/models/baseline-conflict.d.mts +6 -0
  398. package/dist/models/baseline-conflict.mjs +9 -0
  399. package/dist/models/baseline-conflict.mjs.map +1 -0
  400. package/dist/models/baseline-export.d.mts +17 -0
  401. package/dist/models/baseline-export.mjs +135 -0
  402. package/dist/models/baseline-export.mjs.map +1 -0
  403. package/dist/models/baseline-import.mjs +117 -0
  404. package/dist/models/baseline-import.mjs.map +1 -0
  405. package/dist/models/baseline-origin.d.mts +16 -0
  406. package/dist/models/baseline-origin.mjs +35 -0
  407. package/dist/models/baseline-origin.mjs.map +1 -0
  408. package/dist/models/baseline-status.d.mts +0 -2
  409. package/dist/models/baseline-status.mjs +1 -2
  410. package/dist/models/baseline-transfer.d.mts +48 -0
  411. package/dist/models/baseline-transfer.mjs +149 -0
  412. package/dist/models/baseline-transfer.mjs.map +1 -0
  413. package/dist/models/baseline.d.mts +37 -7
  414. package/dist/models/baseline.mjs +152 -28
  415. package/dist/models/baseline.mjs.map +1 -1
  416. package/dist/models/build-component.d.mts +26 -0
  417. package/dist/models/build-component.mjs +54 -0
  418. package/dist/models/build-component.mjs.map +1 -0
  419. package/dist/models/build-review-status.d.mts +27 -0
  420. package/dist/models/build-review-status.mjs +36 -0
  421. package/dist/models/build-review-status.mjs.map +1 -0
  422. package/dist/models/build-review.d.mts +26 -0
  423. package/dist/models/build-review.mjs +53 -0
  424. package/dist/models/build-review.mjs.map +1 -0
  425. package/dist/models/build.d.mts +25 -5
  426. package/dist/models/build.mjs +53 -15
  427. package/dist/models/build.mjs.map +1 -1
  428. package/dist/models/capture-attempt.d.mts +7 -3
  429. package/dist/models/capture-attempt.mjs +30 -6
  430. package/dist/models/capture-attempt.mjs.map +1 -1
  431. package/dist/models/capture-job.d.mts +104 -0
  432. package/dist/models/capture-job.mjs +287 -0
  433. package/dist/models/capture-job.mjs.map +1 -0
  434. package/dist/models/capture-log.d.mts +1 -3
  435. package/dist/models/capture-log.mjs +5 -5
  436. package/dist/models/capture-log.mjs.map +1 -1
  437. package/dist/models/capture-shard.d.mts +60 -0
  438. package/dist/models/capture-shard.mjs +189 -0
  439. package/dist/models/capture-shard.mjs.map +1 -0
  440. package/dist/models/changeset.d.mts +46 -0
  441. package/dist/models/changeset.mjs +80 -0
  442. package/dist/models/changeset.mjs.map +1 -0
  443. package/dist/models/columns.mjs +18 -0
  444. package/dist/models/columns.mjs.map +1 -0
  445. package/dist/models/comment.d.mts +4 -3
  446. package/dist/models/comment.mjs +8 -6
  447. package/dist/models/comment.mjs.map +1 -1
  448. package/dist/models/component.d.mts +41 -0
  449. package/dist/models/component.mjs +59 -0
  450. package/dist/models/component.mjs.map +1 -0
  451. package/dist/models/connections.d.mts +39 -0
  452. package/dist/models/connections.mjs +111 -0
  453. package/dist/models/connections.mjs.map +1 -0
  454. package/dist/models/content-ref.d.mts +1 -3
  455. package/dist/models/content-ref.mjs +2 -3
  456. package/dist/models/content-ref.mjs.map +1 -1
  457. package/dist/models/credentials.d.mts +0 -2
  458. package/dist/models/credentials.mjs +13 -4
  459. package/dist/models/credentials.mjs.map +1 -1
  460. package/dist/models/design-credentials.d.mts +39 -0
  461. package/dist/models/design-credentials.mjs +85 -0
  462. package/dist/models/design-credentials.mjs.map +1 -0
  463. package/dist/models/design-health.d.mts +14 -0
  464. package/dist/models/design-health.mjs +24 -0
  465. package/dist/models/design-health.mjs.map +1 -0
  466. package/dist/models/design-nodes.d.mts +81 -0
  467. package/dist/models/design-nodes.mjs +221 -0
  468. package/dist/models/design-nodes.mjs.map +1 -0
  469. package/dist/models/design-renders.mjs +73 -0
  470. package/dist/models/design-renders.mjs.map +1 -0
  471. package/dist/models/design-resolve.d.mts +27 -0
  472. package/dist/models/design-resolve.mjs +40 -0
  473. package/dist/models/design-resolve.mjs.map +1 -0
  474. package/dist/models/design.d.mts +37 -0
  475. package/dist/models/design.mjs +89 -0
  476. package/dist/models/design.mjs.map +1 -0
  477. package/dist/models/inherited-ratio.d.mts +19 -0
  478. package/dist/models/inherited-ratio.mjs +21 -0
  479. package/dist/models/inherited-ratio.mjs.map +1 -0
  480. package/dist/models/insight.d.mts +68 -0
  481. package/dist/models/insight.mjs +161 -0
  482. package/dist/models/insight.mjs.map +1 -0
  483. package/dist/models/label.d.mts +4 -4
  484. package/dist/models/label.mjs +26 -12
  485. package/dist/models/label.mjs.map +1 -1
  486. package/dist/models/member.d.mts +1 -3
  487. package/dist/models/member.mjs +6 -6
  488. package/dist/models/member.mjs.map +1 -1
  489. package/dist/models/notification-channel.d.mts +37 -5
  490. package/dist/models/notification-channel.mjs +89 -11
  491. package/dist/models/notification-channel.mjs.map +1 -1
  492. package/dist/models/notification-subscription.d.mts +1 -4
  493. package/dist/models/notification-subscription.mjs +8 -11
  494. package/dist/models/notification-subscription.mjs.map +1 -1
  495. package/dist/models/project-group-mapping.d.mts +6 -3
  496. package/dist/models/project-group-mapping.mjs +15 -6
  497. package/dist/models/project-group-mapping.mjs.map +1 -1
  498. package/dist/models/project.d.mts +9 -3
  499. package/dist/models/project.mjs +10 -6
  500. package/dist/models/project.mjs.map +1 -1
  501. package/dist/models/public-origin.d.mts +61 -0
  502. package/dist/models/public-origin.mjs +113 -0
  503. package/dist/models/public-origin.mjs.map +1 -0
  504. package/dist/models/review-switch-off.d.mts +12 -0
  505. package/dist/models/review-switch-off.mjs +25 -0
  506. package/dist/models/review-switch-off.mjs.map +1 -0
  507. package/dist/models/site-settings.d.mts +21 -0
  508. package/dist/models/site-settings.mjs +47 -0
  509. package/dist/models/site-settings.mjs.map +1 -0
  510. package/dist/models/snapshot.d.mts +39 -3
  511. package/dist/models/snapshot.mjs +54 -5
  512. package/dist/models/snapshot.mjs.map +1 -1
  513. package/dist/models/token.d.mts +13 -3
  514. package/dist/models/token.mjs +24 -7
  515. package/dist/models/token.mjs.map +1 -1
  516. package/dist/models/usage.d.mts +74 -0
  517. package/dist/models/usage.mjs +148 -0
  518. package/dist/models/usage.mjs.map +1 -0
  519. package/dist/models/user.d.mts +1 -3
  520. package/dist/models/user.mjs +5 -5
  521. package/dist/models/user.mjs.map +1 -1
  522. package/dist/models/webhook.d.mts +15 -3
  523. package/dist/models/webhook.mjs +34 -6
  524. package/dist/models/webhook.mjs.map +1 -1
  525. package/dist/models.d.mts +30 -4
  526. package/dist/models.mjs +31 -6
  527. package/dist/options.d.mts +16 -0
  528. package/dist/options.mjs +88 -0
  529. package/dist/options.mjs.map +1 -0
  530. package/dist/paths.d.mts +21 -6
  531. package/dist/paths.mjs +57 -12
  532. package/dist/paths.mjs.map +1 -1
  533. package/dist/retention/ai.d.mts +16 -0
  534. package/dist/retention/ai.mjs +22 -0
  535. package/dist/retention/ai.mjs.map +1 -0
  536. package/dist/retention/pending.mjs +46 -0
  537. package/dist/retention/pending.mjs.map +1 -0
  538. package/dist/retention/published-gzip-sweep.mjs +28 -0
  539. package/dist/retention/published-gzip-sweep.mjs.map +1 -0
  540. package/dist/retention/screenshot-sweep.d.mts +49 -0
  541. package/dist/retention/screenshot-sweep.mjs +127 -0
  542. package/dist/retention/screenshot-sweep.mjs.map +1 -0
  543. package/dist/retention.d.mts +16 -4
  544. package/dist/retention.mjs +76 -16
  545. package/dist/retention.mjs.map +1 -1
  546. package/dist/schema/baseline.d.mts +8 -2
  547. package/dist/schema/build-component.d.mts +23 -0
  548. package/dist/schema/build-review.d.mts +15 -0
  549. package/dist/schema/build.d.mts +7 -2
  550. package/dist/schema/capture-attempt.d.mts +0 -2
  551. package/dist/schema/capture-job.d.mts +58 -0
  552. package/dist/schema/capture-shard.d.mts +33 -0
  553. package/dist/schema/comment.d.mts +2 -2
  554. package/dist/schema/connection.d.mts +22 -0
  555. package/dist/schema/content-ref.d.mts +0 -2
  556. package/dist/schema/design.d.mts +56 -0
  557. package/dist/schema/insight.d.mts +52 -0
  558. package/dist/schema/label.d.mts +0 -2
  559. package/dist/schema/member.d.mts +0 -2
  560. package/dist/schema/notification.d.mts +4 -2
  561. package/dist/schema/project-group-mapping.d.mts +0 -2
  562. package/dist/schema/project.d.mts +21 -2
  563. package/dist/schema/site-setting.d.mts +19 -0
  564. package/dist/schema/snapshot.d.mts +17 -2
  565. package/dist/schema/token.d.mts +0 -2
  566. package/dist/schema/usage.d.mts +28 -0
  567. package/dist/schema/user.d.mts +0 -2
  568. package/dist/schema/webhook.d.mts +0 -2
  569. package/dist/schema.d.mts +12 -6
  570. package/dist/serverless.d.mts +19 -0
  571. package/dist/serverless.mjs +36 -0
  572. package/dist/serverless.mjs.map +1 -0
  573. package/dist/test-helpers/build-reference-contract.d.mts +14 -0
  574. package/dist/test-helpers/build-reference-contract.mjs +66 -0
  575. package/dist/test-helpers/build-reference-contract.mjs.map +1 -0
  576. package/dist/test-helpers/create-project.d.mts +1 -3
  577. package/dist/test-helpers/create-project.mjs +1 -2
  578. package/dist/test-helpers/database-contract.d.mts +0 -2
  579. package/dist/test-helpers/database-contract.mjs +37 -2
  580. package/dist/test-helpers/database-contract.mjs.map +1 -1
  581. package/dist/test-helpers/deferred.d.mts +37 -0
  582. package/dist/test-helpers/deferred.mjs +60 -0
  583. package/dist/test-helpers/deferred.mjs.map +1 -0
  584. package/dist/test-helpers/design-contract.d.mts +19 -0
  585. package/dist/test-helpers/design-contract.mjs +39 -0
  586. package/dist/test-helpers/design-contract.mjs.map +1 -0
  587. package/dist/test-helpers/fake-adapters.d.mts +0 -2
  588. package/dist/test-helpers/fake-adapters.mjs +1 -2
  589. package/dist/test-helpers/fake-database.d.mts +0 -2
  590. package/dist/test-helpers/fake-database.mjs +21 -4
  591. package/dist/test-helpers/fake-database.mjs.map +1 -1
  592. package/dist/test-helpers/fake-design.d.mts +41 -0
  593. package/dist/test-helpers/fake-design.mjs +113 -0
  594. package/dist/test-helpers/fake-design.mjs.map +1 -0
  595. package/dist/test-helpers/fake-notifier.d.mts +19 -0
  596. package/dist/test-helpers/fake-notifier.mjs +43 -0
  597. package/dist/test-helpers/fake-notifier.mjs.map +1 -0
  598. package/dist/test-helpers/fake-storage.d.mts +0 -2
  599. package/dist/test-helpers/fake-storage.mjs +1 -2
  600. package/dist/test-helpers/fake-tables.mjs +260 -69
  601. package/dist/test-helpers/fake-tables.mjs.map +1 -1
  602. package/dist/test-helpers/manual-clock.d.mts +25 -0
  603. package/dist/test-helpers/manual-clock.mjs +55 -0
  604. package/dist/test-helpers/manual-clock.mjs.map +1 -0
  605. package/dist/test-helpers/notifier-contract.d.mts +7 -3
  606. package/dist/test-helpers/notifier-contract.mjs +33 -5
  607. package/dist/test-helpers/notifier-contract.mjs.map +1 -1
  608. package/dist/test-helpers/queue-contract.d.mts +16 -4
  609. package/dist/test-helpers/queue-contract.mjs +196 -3
  610. package/dist/test-helpers/queue-contract.mjs.map +1 -1
  611. package/dist/test-helpers/queue-multi-instance.d.mts +18 -0
  612. package/dist/test-helpers/queue-multi-instance.mjs +205 -0
  613. package/dist/test-helpers/queue-multi-instance.mjs.map +1 -0
  614. package/dist/test-helpers/runner-contract.d.mts +0 -2
  615. package/dist/test-helpers/runner-contract.mjs +12 -2
  616. package/dist/test-helpers/runner-contract.mjs.map +1 -1
  617. package/dist/test-helpers/sql-chunks.mjs +25 -2
  618. package/dist/test-helpers/sql-chunks.mjs.map +1 -1
  619. package/dist/test-helpers/storage-contract.d.mts +0 -2
  620. package/dist/test-helpers/storage-contract.mjs +2 -3
  621. package/dist/test-helpers.d.mts +10 -4
  622. package/dist/test-helpers.mjs +9 -3
  623. package/dist/tracing.mjs +36 -6
  624. package/dist/tracing.mjs.map +1 -1
  625. package/dist/types.d.mts +14 -5
  626. package/dist/types.mjs +22 -6
  627. package/dist/types.mjs.map +1 -1
  628. package/dist/urls.d.mts +4 -2
  629. package/dist/urls.mjs +12 -4
  630. package/dist/urls.mjs.map +1 -1
  631. package/dist/utils/adaptive-concurrency.d.mts +64 -0
  632. package/dist/utils/adaptive-concurrency.mjs +148 -0
  633. package/dist/utils/adaptive-concurrency.mjs.map +1 -0
  634. package/dist/utils/connect-retry.d.mts +26 -0
  635. package/dist/utils/connect-retry.mjs +42 -0
  636. package/dist/utils/connect-retry.mjs.map +1 -0
  637. package/dist/utils/encrypt.d.mts +0 -2
  638. package/dist/utils/encrypt.mjs +1 -2
  639. package/dist/utils/environment.d.mts +17 -0
  640. package/dist/utils/environment.mjs +58 -0
  641. package/dist/utils/environment.mjs.map +1 -0
  642. package/dist/utils/hash.d.mts +0 -2
  643. package/dist/utils/hash.mjs +1 -2
  644. package/dist/utils/http.d.mts +29 -3
  645. package/dist/utils/http.mjs +100 -19
  646. package/dist/utils/http.mjs.map +1 -1
  647. package/dist/utils/map-adaptive.d.mts +13 -0
  648. package/dist/utils/map-adaptive.mjs +71 -0
  649. package/dist/utils/map-adaptive.mjs.map +1 -0
  650. package/dist/utils/map-limit.d.mts +8 -0
  651. package/dist/utils/map-limit.mjs +31 -0
  652. package/dist/utils/map-limit.mjs.map +1 -0
  653. package/dist/utils/mime.d.mts +0 -2
  654. package/dist/utils/mime.mjs +1 -2
  655. package/dist/utils/page-limiter.d.mts +35 -0
  656. package/dist/utils/page-limiter.mjs +55 -0
  657. package/dist/utils/page-limiter.mjs.map +1 -0
  658. package/dist/utils/path-security.d.mts +0 -2
  659. package/dist/utils/path-security.mjs +2 -4
  660. package/dist/utils/path-security.mjs.map +1 -1
  661. package/dist/utils/public-origin.d.mts +18 -0
  662. package/dist/utils/public-origin.mjs +74 -0
  663. package/dist/utils/public-origin.mjs.map +1 -0
  664. package/dist/utils/redact.d.mts +0 -2
  665. package/dist/utils/redact.mjs +4 -2
  666. package/dist/utils/redact.mjs.map +1 -1
  667. package/dist/utils/remote-environment.d.mts +76 -0
  668. package/dist/utils/remote-environment.mjs +163 -0
  669. package/dist/utils/remote-environment.mjs.map +1 -0
  670. package/dist/utils/resources.d.mts +62 -0
  671. package/dist/utils/resources.mjs +121 -0
  672. package/dist/utils/resources.mjs.map +1 -0
  673. package/dist/utils/screenshot-store.d.mts +13 -0
  674. package/dist/utils/screenshot-store.mjs +40 -0
  675. package/dist/utils/screenshot-store.mjs.map +1 -0
  676. package/dist/utils/session-gate.d.mts +23 -0
  677. package/dist/utils/session-gate.mjs +69 -0
  678. package/dist/utils/session-gate.mjs.map +1 -0
  679. package/dist/utils/storybook-token.d.mts +89 -0
  680. package/dist/utils/storybook-token.mjs +135 -0
  681. package/dist/utils/storybook-token.mjs.map +1 -0
  682. package/dist/utils/storybook-url.d.mts +13 -0
  683. package/dist/utils/storybook-url.mjs +20 -0
  684. package/dist/utils/storybook-url.mjs.map +1 -0
  685. package/dist/utils/timing.d.mts +0 -2
  686. package/dist/utils/timing.mjs +2 -3
  687. package/dist/utils/timing.mjs.map +1 -1
  688. package/dist/utils/ulid.d.mts +0 -2
  689. package/dist/utils/ulid.mjs +1 -2
  690. package/dist/utils/zip-read.mjs +128 -0
  691. package/dist/utils/zip-read.mjs.map +1 -0
  692. package/dist/utils/zip-write.d.mts +16 -0
  693. package/dist/utils/zip-write.mjs +187 -0
  694. package/dist/utils/zip-write.mjs.map +1 -0
  695. package/dist/utils.d.mts +17 -3
  696. package/dist/utils.mjs +18 -4
  697. package/package.json +35 -26
  698. package/dist/adapter/capture-runner.mjs.map +0 -1
  699. package/dist/adapter/git-host/comments.d.mts +0 -41
  700. package/dist/adapter/git-host/comments.mjs +0 -54
  701. package/dist/adapter/git-host/comments.mjs.map +0 -1
  702. package/dist/adapter/git-host/helpers.d.mts +0 -13
  703. package/dist/adapter/git-host/helpers.mjs +0 -30
  704. package/dist/adapter/git-host/helpers.mjs.map +0 -1
  705. package/dist/adapter/git-host.d.mts +0 -42
  706. package/dist/capture/queue.d.mts +0 -38
  707. package/dist/capture/queue.mjs +0 -98
  708. package/dist/capture/queue.mjs.map +0 -1
  709. package/dist/capture/recovery.d.mts +0 -21
  710. package/dist/capture/recovery.mjs +0 -83
  711. package/dist/capture/recovery.mjs.map +0 -1
  712. package/dist/capture/status-fanout.mjs +0 -72
  713. package/dist/capture/status-fanout.mjs.map +0 -1
  714. package/dist/diff/engine.d.mts +0 -16
  715. package/dist/diff/engine.mjs +0 -87
  716. package/dist/diff/engine.mjs.map +0 -1
  717. package/dist/diff/options.d.mts +0 -42
  718. package/dist/diff/options.mjs +0 -15
  719. package/dist/diff/options.mjs.map +0 -1
  720. package/dist/models/status-config.d.mts +0 -38
  721. package/dist/models/status-config.mjs +0 -63
  722. package/dist/models/status-config.mjs.map +0 -1
  723. package/dist/schema/status-config.d.mts +0 -16
  724. package/dist/test-helpers/git-contract.d.mts +0 -11
  725. package/dist/test-helpers/git-contract.mjs +0 -34
  726. package/dist/test-helpers/git-contract.mjs.map +0 -1
  727. /package/dist/adapter/{git-host.mjs → oauth.mjs} +0 -0
@@ -0,0 +1,36 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { createRequire } from "node:module";
5
+ import { readFile } from "node:fs/promises";
6
+ // src/capture/a11y/axe-source.ts
7
+ /** Lazy, cached loader for the axe-core browser bundle. */
8
+ let cached;
9
+ /**
10
+ * Read `axe.min.js` (~550 KB) once per process, on first use. Lazy on purpose: servers that never run
11
+ * accessibility checks do not touch the file at boot. A failed read is not cached.
12
+ */
13
+ async function loadAxeSource() {
14
+ cached ??= readAxeSource();
15
+ try {
16
+ return await cached;
17
+ } catch (error) {
18
+ cached = void 0;
19
+ throw error;
20
+ }
21
+ }
22
+ /**
23
+ * Wrap the axe source so evaluating it twice in one document is a no-op. Evaluate it as a string
24
+ * (CDP `Runtime.evaluate`: not bound by the page's CSP and works over remote browsers, since the
25
+ * source travels over the wire instead of a file path).
26
+ */
27
+ function axeInjectionScript(source) {
28
+ return `(function(){if(typeof globalThis.axe!=="undefined")return;\n${source}\n})()`;
29
+ }
30
+ async function readAxeSource() {
31
+ const path = createRequire(import.meta.url).resolve("axe-core/axe.min.js");
32
+ return await readFile(path, "utf8");
33
+ }
34
+ export { axeInjectionScript, loadAxeSource };
35
+
36
+ //# sourceMappingURL=axe-source.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axe-source.mjs","names":[],"sources":["../../../src/capture/a11y/axe-source.ts"],"sourcesContent":["/** Lazy, cached loader for the axe-core browser bundle. */\n\nimport { readFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\n\nlet cached: Promise<string> | undefined;\n\n/**\n * Read `axe.min.js` (~550 KB) once per process, on first use. Lazy on purpose: servers that never run\n * accessibility checks do not touch the file at boot. A failed read is not cached.\n */\nexport async function loadAxeSource(): Promise<string> {\n cached ??= readAxeSource();\n try {\n return await cached;\n } catch (error) {\n cached = undefined;\n throw error;\n }\n}\n\n/**\n * Wrap the axe source so evaluating it twice in one document is a no-op. Evaluate it as a string\n * (CDP `Runtime.evaluate`: not bound by the page's CSP and works over remote browsers, since the\n * source travels over the wire instead of a file path).\n */\nexport function axeInjectionScript(source: string): string {\n return `(function(){if(typeof globalThis.axe!==\"undefined\")return;\\n${source}\\n})()`;\n}\n\n/** Drop the cached source (tests). */\nexport function resetAxeSourceCache(): void {\n cached = undefined;\n}\n\nasync function readAxeSource(): Promise<string> {\n const path = createRequire(import.meta.url).resolve(\"axe-core/axe.min.js\");\n return await readFile(path, \"utf8\");\n}\n"],"mappings":";;;;;;;AAKA,IAAI;;;;;AAMJ,eAAsB,gBAAiC;CACrD,WAAW,cAAc;CACzB,IAAI;EACF,OAAO,MAAM;CACf,SAAS,OAAO;EACd,SAAS,KAAA;EACT,MAAM;CACR;AACF;;;;;;AAOA,SAAgB,mBAAmB,QAAwB;CACzD,OAAO,+DAA+D,OAAO;AAC/E;AAOA,eAAe,gBAAiC;CAC9C,MAAM,OAAO,cAAc,YAAY,GAAG,CAAC,CAAC,QAAQ,qBAAqB;CACzE,OAAO,MAAM,SAAS,MAAM,MAAM;AACpC"}
@@ -0,0 +1,25 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import { SlimViolation } from "./map.mjs";
4
+ import { A11yRunPlan } from "./options.mjs";
5
+ /** What {@link inPageReadA11yParameters} found: the plain-data `parameters.a11y` and what was dropped. */
6
+ interface A11yParametersRead {
7
+ params: unknown;
8
+ /** Function, symbol and undefined values left out because a page cannot hand them over. */
9
+ dropped: number;
10
+ }
11
+ /**
12
+ * Read the current story's `parameters.a11y` from the running Storybook preview as plain data.
13
+ * Functions (`config.rules[].matches`, custom checks) cannot cross into the runner, so they are
14
+ * dropped, and an object or array item that held nothing else goes with them (an emptied rule item
15
+ * would otherwise reset to axe's default). Returns undefined when there is no `a11y` parameter or it
16
+ * cannot be read at all (cyclic).
17
+ */
18
+ declare function inPageReadA11yParameters(): A11yParametersRead | undefined;
19
+ /**
20
+ * Run the injected axe over the plan's context and return only slim fields (id, impact, help, first
21
+ * target, node count). Throws when axe is not present in the page.
22
+ */
23
+ declare function inPageRunAxe(plan: A11yRunPlan): Promise<SlimViolation[]>;
24
+ export { A11yParametersRead, inPageReadA11yParameters, inPageRunAxe };
25
+ //# sourceMappingURL=in-page.d.mts.map
@@ -0,0 +1,59 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ // src/capture/a11y/in-page.ts
5
+ /**
6
+ * Read the current story's `parameters.a11y` from the running Storybook preview as plain data.
7
+ * Functions (`config.rules[].matches`, custom checks) cannot cross into the runner, so they are
8
+ * dropped, and an object or array item that held nothing else goes with them (an emptied rule item
9
+ * would otherwise reset to axe's default). Returns undefined when there is no `a11y` parameter or it
10
+ * cannot be read at all (cyclic).
11
+ */
12
+ function inPageReadA11yParameters() {
13
+ const a11y = globalThis.__STORYBOOK_PREVIEW__?.currentRender?.story?.parameters?.a11y;
14
+ if (a11y === void 0) return void 0;
15
+ const state = { dropped: 0 };
16
+ const DROP = Symbol("drop");
17
+ const clean = (value, depth) => {
18
+ if (depth > 32) throw new Error("too deep");
19
+ if (typeof value === "function" || typeof value === "symbol" || value === void 0) {
20
+ state.dropped += 1;
21
+ return DROP;
22
+ }
23
+ if (value === null || typeof value !== "object") return value;
24
+ const before = state.dropped;
25
+ const entries = Array.isArray(value) ? value.map((item, index) => [String(index), item]) : Object.entries(value);
26
+ const kept = entries.map(([key, item]) => [key, clean(item, depth + 1)]).filter(([, item]) => item !== DROP);
27
+ if (kept.length === 0 && entries.length > 0 && state.dropped > before) return DROP;
28
+ return Array.isArray(value) ? kept.map(([, item]) => item) : Object.fromEntries(kept);
29
+ };
30
+ try {
31
+ const params = clean(a11y, 0);
32
+ return {
33
+ params: params === DROP ? void 0 : params,
34
+ dropped: state.dropped
35
+ };
36
+ } catch {
37
+ return;
38
+ }
39
+ }
40
+ /**
41
+ * Run the injected axe over the plan's context and return only slim fields (id, impact, help, first
42
+ * target, node count). Throws when axe is not present in the page.
43
+ */
44
+ async function inPageRunAxe(plan) {
45
+ const win = globalThis;
46
+ if (!win.axe) throw new Error("axe is not loaded in the page");
47
+ if (typeof plan.context === "string" && !win.document.querySelector(plan.context)) return [];
48
+ if (Object.keys(plan.config).length > 0) win.axe.configure(plan.config);
49
+ return (await win.axe.run(plan.context, plan.options)).violations.map((v) => ({
50
+ id: v.id,
51
+ impact: v.impact ?? null,
52
+ help: v.help,
53
+ target: (v.nodes[0]?.target ?? []).flat(Infinity).join(" "),
54
+ count: v.nodes.length
55
+ }));
56
+ }
57
+ export { inPageReadA11yParameters, inPageRunAxe };
58
+
59
+ //# sourceMappingURL=in-page.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-page.mjs","names":["win"],"sources":["../../../src/capture/a11y/in-page.ts"],"sourcesContent":["/**\n * Functions evaluated inside the story page. Playwright and Puppeteer serialise only a function's\n * source, so each must stay ONE self-contained function: no imports, helpers or module bindings\n * (`in-page.test.ts` rebuilds them from source in a bare scope to guard that).\n */\n\nimport type { SlimViolation } from \"./map.ts\";\nimport type { A11yRunPlan } from \"./options.ts\";\n\n/** What {@link inPageReadA11yParameters} found: the plain-data `parameters.a11y` and what was dropped. */\nexport interface A11yParametersRead {\n params: unknown;\n /** Function, symbol and undefined values left out because a page cannot hand them over. */\n dropped: number;\n}\n\n/**\n * Read the current story's `parameters.a11y` from the running Storybook preview as plain data.\n * Functions (`config.rules[].matches`, custom checks) cannot cross into the runner, so they are\n * dropped, and an object or array item that held nothing else goes with them (an emptied rule item\n * would otherwise reset to axe's default). Returns undefined when there is no `a11y` parameter or it\n * cannot be read at all (cyclic).\n */\n// oxlint-disable-next-line eslint/max-statements -- must stay one self-contained function (see above)\nexport function inPageReadA11yParameters(): A11yParametersRead | undefined {\n const win = globalThis as unknown as {\n // oxlint-disable-next-line eslint/no-underscore-dangle -- Storybook global\n __STORYBOOK_PREVIEW__?: {\n currentRender?: { story?: { parameters?: { a11y?: unknown } } };\n };\n };\n // oxlint-disable-next-line eslint/no-underscore-dangle -- Storybook global\n const a11y = win.__STORYBOOK_PREVIEW__?.currentRender?.story?.parameters?.a11y;\n if (a11y === undefined) return undefined;\n const state = { dropped: 0 };\n const DROP = Symbol(\"drop\");\n const clean = (value: unknown, depth: number): unknown => {\n if (depth > 32) throw new Error(\"too deep\");\n if (typeof value === \"function\" || typeof value === \"symbol\" || value === undefined) {\n state.dropped += 1;\n return DROP;\n }\n if (value === null || typeof value !== \"object\") return value;\n const before = state.dropped;\n const entries: [string, unknown][] = Array.isArray(value)\n ? value.map((item, index): [string, unknown] => [String(index), item])\n : Object.entries(value);\n const kept = entries\n .map(([key, item]): [string, unknown] => [key, clean(item, depth + 1)])\n .filter(([, item]) => item !== DROP);\n if (kept.length === 0 && entries.length > 0 && state.dropped > before) return DROP;\n return Array.isArray(value) ? kept.map(([, item]) => item) : Object.fromEntries(kept);\n };\n try {\n const params = clean(a11y, 0);\n return { params: params === DROP ? undefined : params, dropped: state.dropped };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Run the injected axe over the plan's context and return only slim fields (id, impact, help, first\n * target, node count). Throws when axe is not present in the page.\n */\n// oxlint-disable-next-line eslint/max-statements, eslint/max-lines-per-function -- must stay one self-contained function (see above)\nexport async function inPageRunAxe(plan: A11yRunPlan): Promise<SlimViolation[]> {\n const win = globalThis as unknown as {\n axe?: {\n configure: (config: unknown) => void;\n run: (context: unknown, options: unknown) => Promise<{ violations: AxeViolation[] }>;\n };\n document: { querySelector: (selector: string) => unknown };\n };\n interface AxeViolation {\n id: string;\n impact?: string | null;\n help: string;\n nodes: { target: unknown[] }[];\n }\n if (!win.axe) throw new Error(\"axe is not loaded in the page\");\n if (typeof plan.context === \"string\" && !win.document.querySelector(plan.context)) return [];\n if (Object.keys(plan.config).length > 0) win.axe.configure(plan.config);\n const results = await win.axe.run(plan.context, plan.options);\n return results.violations.map((v) => ({\n id: v.id,\n impact: v.impact ?? null,\n help: v.help,\n target: (v.nodes[0]?.target ?? []).flat(Infinity).join(\" \"),\n count: v.nodes.length,\n }));\n}\n"],"mappings":";;;;;;;;;;;AAwBA,SAAgB,2BAA2D;CAQzE,MAAM,OAAOA,WAAI,uBAAuB,eAAe,OAAO,YAAY;CAC1E,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,MAAM,QAAQ,EAAE,SAAS,EAAE;CAC3B,MAAM,OAAO,OAAO,MAAM;CAC1B,MAAM,SAAS,OAAgB,UAA2B;EACxD,IAAI,QAAQ,IAAI,MAAM,IAAI,MAAM,UAAU;EAC1C,IAAI,OAAO,UAAU,cAAc,OAAO,UAAU,YAAY,UAAU,KAAA,GAAW;GACnF,MAAM,WAAW;GACjB,OAAO;EACT;EACA,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU,OAAO;EACxD,MAAM,SAAS,MAAM;EACrB,MAAM,UAA+B,MAAM,QAAQ,KAAK,IACpD,MAAM,KAAK,MAAM,UAA6B,CAAC,OAAO,KAAK,GAAG,IAAI,CAAC,IACnE,OAAO,QAAQ,KAAK;EACxB,MAAM,OAAO,QACV,KAAK,CAAC,KAAK,UAA6B,CAAC,KAAK,MAAM,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC,CACtE,QAAQ,GAAG,UAAU,SAAS,IAAI;EACrC,IAAI,KAAK,WAAW,KAAK,QAAQ,SAAS,KAAK,MAAM,UAAU,QAAQ,OAAO;EAC9E,OAAO,MAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,GAAG,UAAU,IAAI,IAAI,OAAO,YAAY,IAAI;CACtF;CACA,IAAI;EACF,MAAM,SAAS,MAAM,MAAM,CAAC;EAC5B,OAAO;GAAE,QAAQ,WAAW,OAAO,KAAA,IAAY;GAAQ,SAAS,MAAM;EAAQ;CAChF,QAAQ;EACN;CACF;AACF;;;;;AAOA,eAAsB,aAAa,MAA6C;CAC9E,MAAM,MAAM;CAaZ,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,+BAA+B;CAC7D,IAAI,OAAO,KAAK,YAAY,YAAY,CAAC,IAAI,SAAS,cAAc,KAAK,OAAO,GAAG,OAAO,CAAC;CAC3F,IAAI,OAAO,KAAK,KAAK,MAAM,CAAC,CAAC,SAAS,GAAG,IAAI,IAAI,UAAU,KAAK,MAAM;CAEtE,QAAO,MADe,IAAI,IAAI,IAAI,KAAK,SAAS,KAAK,OAAO,EAAA,CAC7C,WAAW,KAAK,OAAO;EACpC,IAAI,EAAE;EACN,QAAQ,EAAE,UAAU;EACpB,MAAM,EAAE;EACR,SAAS,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,EAAA,CAAG,KAAK,QAAQ,CAAC,CAAC,KAAK,GAAG;EAC1D,OAAO,EAAE,MAAM;CACjB,EAAE;AACJ"}
@@ -0,0 +1,22 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ /** Map slim in-page axe results to `a11y:` violation strings. */
4
+ /** Most violations reported per snapshot; the rest collapse into "…and N more". */
5
+ declare const MAX_REPORTED_VIOLATIONS = 10;
6
+ /** The only per-violation fields that leave the page (raw axe nodes carry large html payloads). */
7
+ interface SlimViolation {
8
+ id: string;
9
+ impact: string | null;
10
+ help: string;
11
+ /** Selector of the first affected node. */
12
+ target: string;
13
+ /** Number of affected nodes. */
14
+ count: number;
15
+ }
16
+ /**
17
+ * One string per violation: rule id, impact, help text, short target and node count, worst impact
18
+ * first. `;` is reserved (the pipeline joins annotations with it), so it never appears in a string.
19
+ */
20
+ declare function mapAxeViolations(violations: readonly SlimViolation[]): string[];
21
+ export { MAX_REPORTED_VIOLATIONS, SlimViolation, mapAxeViolations };
22
+ //# sourceMappingURL=map.d.mts.map
@@ -0,0 +1,47 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ // src/capture/a11y/map.ts
5
+ /** Map slim in-page axe results to `a11y:` violation strings. */
6
+ /** Most violations reported per snapshot; the rest collapse into "…and N more". */
7
+ const MAX_REPORTED_VIOLATIONS = 10;
8
+ const MAX_SELECTOR_LENGTH = 60;
9
+ const MAX_HELP_LENGTH = 90;
10
+ const IMPACT_ORDER = [
11
+ "critical",
12
+ "serious",
13
+ "moderate",
14
+ "minor"
15
+ ];
16
+ /**
17
+ * One string per violation: rule id, impact, help text, short target and node count, worst impact
18
+ * first. `;` is reserved (the pipeline joins annotations with it), so it never appears in a string.
19
+ */
20
+ function mapAxeViolations(violations) {
21
+ const sorted = violations.toSorted(compareViolations);
22
+ const lines = sorted.slice(0, 10).map((violation) => formatViolation(violation));
23
+ const more = sorted.length - lines.length;
24
+ if (more > 0) lines.push(`…and ${more} more`);
25
+ return lines;
26
+ }
27
+ function formatViolation(v) {
28
+ const nodes = `${v.count} node${v.count === 1 ? "" : "s"}`;
29
+ const target = truncate(v.target, MAX_SELECTOR_LENGTH);
30
+ return clean(`${v.id} (${v.impact ?? "unknown"}): ${truncate(v.help, MAX_HELP_LENGTH)} [${target}] ${nodes}`);
31
+ }
32
+ function compareViolations(a, b) {
33
+ return rank(a.impact) - rank(b.impact) || a.id.localeCompare(b.id);
34
+ }
35
+ function rank(impact) {
36
+ const index = IMPACT_ORDER.indexOf(impact ?? "");
37
+ return index === -1 ? IMPACT_ORDER.length : index;
38
+ }
39
+ function truncate(text, max) {
40
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
41
+ }
42
+ function clean(text) {
43
+ return text.replaceAll(/\s+/gu, " ").replaceAll(";", ",");
44
+ }
45
+ export { MAX_REPORTED_VIOLATIONS, mapAxeViolations };
46
+
47
+ //# sourceMappingURL=map.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.mjs","names":[],"sources":["../../../src/capture/a11y/map.ts"],"sourcesContent":["/** Map slim in-page axe results to `a11y:` violation strings. */\n\n/** Most violations reported per snapshot; the rest collapse into \"…and N more\". */\nexport const MAX_REPORTED_VIOLATIONS = 10;\nconst MAX_SELECTOR_LENGTH = 60;\nconst MAX_HELP_LENGTH = 90;\nconst IMPACT_ORDER = [\"critical\", \"serious\", \"moderate\", \"minor\"];\n\n/** The only per-violation fields that leave the page (raw axe nodes carry large html payloads). */\nexport interface SlimViolation {\n id: string;\n impact: string | null;\n help: string;\n /** Selector of the first affected node. */\n target: string;\n /** Number of affected nodes. */\n count: number;\n}\n\n/**\n * One string per violation: rule id, impact, help text, short target and node count, worst impact\n * first. `;` is reserved (the pipeline joins annotations with it), so it never appears in a string.\n */\nexport function mapAxeViolations(violations: readonly SlimViolation[]): string[] {\n const sorted = violations.toSorted(compareViolations);\n const lines = sorted\n .slice(0, MAX_REPORTED_VIOLATIONS)\n .map((violation) => formatViolation(violation));\n const more = sorted.length - lines.length;\n if (more > 0) lines.push(`…and ${more} more`);\n return lines;\n}\n\nfunction formatViolation(v: SlimViolation): string {\n const nodes = `${v.count} node${v.count === 1 ? \"\" : \"s\"}`;\n const target = truncate(v.target, MAX_SELECTOR_LENGTH);\n return clean(\n `${v.id} (${v.impact ?? \"unknown\"}): ${truncate(v.help, MAX_HELP_LENGTH)} [${target}] ${nodes}`,\n );\n}\n\nfunction compareViolations(a: SlimViolation, b: SlimViolation): number {\n return rank(a.impact) - rank(b.impact) || a.id.localeCompare(b.id);\n}\n\nfunction rank(impact: string | null): number {\n const index = IMPACT_ORDER.indexOf(impact ?? \"\");\n return index === -1 ? IMPACT_ORDER.length : index;\n}\n\nfunction truncate(text: string, max: number): string {\n return text.length > max ? `${text.slice(0, max - 1)}…` : text;\n}\n\nfunction clean(text: string): string {\n return text.replaceAll(/\\s+/gu, \" \").replaceAll(\";\", \",\");\n}\n"],"mappings":";;;;;;AAGA,MAAa,0BAA0B;AACvC,MAAM,sBAAsB;AAC5B,MAAM,kBAAkB;AACxB,MAAM,eAAe;CAAC;CAAY;CAAW;CAAY;AAAO;;;;;AAiBhE,SAAgB,iBAAiB,YAAgD;CAC/E,MAAM,SAAS,WAAW,SAAS,iBAAiB;CACpD,MAAM,QAAQ,OACX,MAAM,GAAA,EAA0B,CAAC,CACjC,KAAK,cAAc,gBAAgB,SAAS,CAAC;CAChD,MAAM,OAAO,OAAO,SAAS,MAAM;CACnC,IAAI,OAAO,GAAG,MAAM,KAAK,QAAQ,KAAK,MAAM;CAC5C,OAAO;AACT;AAEA,SAAS,gBAAgB,GAA0B;CACjD,MAAM,QAAQ,GAAG,EAAE,MAAM,OAAO,EAAE,UAAU,IAAI,KAAK;CACrD,MAAM,SAAS,SAAS,EAAE,QAAQ,mBAAmB;CACrD,OAAO,MACL,GAAG,EAAE,GAAG,IAAI,EAAE,UAAU,UAAU,KAAK,SAAS,EAAE,MAAM,eAAe,EAAE,IAAI,OAAO,IAAI,OAC1F;AACF;AAEA,SAAS,kBAAkB,GAAkB,GAA0B;CACrE,OAAO,KAAK,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,KAAK,EAAE,GAAG,cAAc,EAAE,EAAE;AACnE;AAEA,SAAS,KAAK,QAA+B;CAC3C,MAAM,QAAQ,aAAa,QAAQ,UAAU,EAAE;CAC/C,OAAO,UAAU,KAAK,aAAa,SAAS;AAC9C;AAEA,SAAS,SAAS,MAAc,KAAqB;CACnD,OAAO,KAAK,SAAS,MAAM,GAAG,KAAK,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK;AAC5D;AAEA,SAAS,MAAM,MAAsB;CACnC,OAAO,KAAK,WAAW,SAAS,GAAG,CAAC,CAAC,WAAW,KAAK,GAAG;AAC1D"}
@@ -0,0 +1,21 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ /** Turn Storybook's `parameters.a11y` into an axe run plan. */
4
+ /** The story root axe scans unless `parameters.a11y.element`/`context` says otherwise. */
5
+ declare const A11Y_ROOT_SELECTOR = "#storybook-root";
6
+ /** What to hand to `axe.configure` / `axe.run` in the page (JSON-serialisable). */
7
+ interface A11yRunPlan {
8
+ /** Why the story is skipped (`disable`, `test: "off"`); undefined when axe should run. */
9
+ skip?: string;
10
+ config: Record<string, unknown>;
11
+ options: Record<string, unknown>;
12
+ context: unknown;
13
+ }
14
+ /**
15
+ * Resolve the run plan from the JSON-serialisable subset of `parameters.a11y` (functions cannot be
16
+ * read from the page). `disable: true` and `test: "off"` skip the story; `test: "todo" | "error"`
17
+ * still only annotate, results never fail a build.
18
+ */
19
+ declare function resolveA11yRun(raw: unknown): A11yRunPlan;
20
+ export { A11Y_ROOT_SELECTOR, A11yRunPlan, resolveA11yRun };
21
+ //# sourceMappingURL=options.d.mts.map
@@ -0,0 +1,74 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ // src/capture/a11y/options.ts
5
+ /** Turn Storybook's `parameters.a11y` into an axe run plan. */
6
+ /** The story root axe scans unless `parameters.a11y.element`/`context` says otherwise. */
7
+ const A11Y_ROOT_SELECTOR = "#storybook-root";
8
+ /**
9
+ * Rule tags scanned by default: WCAG A/AA plus axe's `best-practice` rules; `parameters.a11y.options.runOnly`
10
+ * replaces them. The page-level best-practice rules (`region`, `landmark-one-main`,
11
+ * `page-has-heading-one`) need the whole document in scope and so stay silent for the default
12
+ * scan of `#storybook-root`; no rule is switched off by default (checked in a real browser).
13
+ */
14
+ const DEFAULT_RUN_ONLY = {
15
+ type: "tag",
16
+ values: [
17
+ "wcag2a",
18
+ "wcag2aa",
19
+ "wcag21a",
20
+ "wcag21aa",
21
+ "wcag22aa",
22
+ "best-practice"
23
+ ]
24
+ };
25
+ /**
26
+ * Resolve the run plan from the JSON-serialisable subset of `parameters.a11y` (functions cannot be
27
+ * read from the page). `disable: true` and `test: "off"` skip the story; `test: "todo" | "error"`
28
+ * still only annotate, results never fail a build.
29
+ */
30
+ function resolveA11yRun(raw) {
31
+ const params = asRecord(raw) ?? {};
32
+ const skip = skipReason(params);
33
+ const config = asRecord(params["config"]) ?? {};
34
+ const userOptions = asRecord(params["options"]);
35
+ const rules = {
36
+ ...disabledByConfig(config),
37
+ ...asRecord(userOptions?.["rules"])
38
+ };
39
+ const options = {
40
+ runOnly: DEFAULT_RUN_ONLY,
41
+ ...userOptions,
42
+ rules
43
+ };
44
+ const context = params["element"] ?? params["context"] ?? "#storybook-root";
45
+ return {
46
+ ...skip ? { skip } : {},
47
+ config,
48
+ options,
49
+ context
50
+ };
51
+ }
52
+ /**
53
+ * `axe.configure({ rules: [{ id, enabled: false }] })` is ignored under a tag-based `runOnly`, so
54
+ * mirror those switches into the run options where they are honoured.
55
+ */
56
+ function disabledByConfig(config) {
57
+ const out = {};
58
+ const rules = Array.isArray(config["rules"]) ? config["rules"] : [];
59
+ for (const rule of rules) {
60
+ const entry = asRecord(rule);
61
+ if (entry?.["enabled"] === false && typeof entry["id"] === "string") out[entry["id"]] = { enabled: false };
62
+ }
63
+ return out;
64
+ }
65
+ function skipReason(params) {
66
+ if (params["disable"] === true) return "parameters.a11y.disable";
67
+ if (params["test"] === "off") return "parameters.a11y.test is \"off\"";
68
+ }
69
+ function asRecord(value) {
70
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
71
+ }
72
+ export { A11Y_ROOT_SELECTOR, resolveA11yRun };
73
+
74
+ //# sourceMappingURL=options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.mjs","names":[],"sources":["../../../src/capture/a11y/options.ts"],"sourcesContent":["/** Turn Storybook's `parameters.a11y` into an axe run plan. */\n\n/** The story root axe scans unless `parameters.a11y.element`/`context` says otherwise. */\nexport const A11Y_ROOT_SELECTOR = \"#storybook-root\";\n\n/**\n * Rule tags scanned by default: WCAG A/AA plus axe's `best-practice` rules; `parameters.a11y.options.runOnly`\n * replaces them. The page-level best-practice rules (`region`, `landmark-one-main`,\n * `page-has-heading-one`) need the whole document in scope and so stay silent for the default\n * scan of `#storybook-root`; no rule is switched off by default (checked in a real browser).\n */\nconst DEFAULT_RUN_ONLY = {\n type: \"tag\",\n values: [\"wcag2a\", \"wcag2aa\", \"wcag21a\", \"wcag21aa\", \"wcag22aa\", \"best-practice\"],\n};\n\n/** What to hand to `axe.configure` / `axe.run` in the page (JSON-serialisable). */\nexport interface A11yRunPlan {\n /** Why the story is skipped (`disable`, `test: \"off\"`); undefined when axe should run. */\n skip?: string;\n config: Record<string, unknown>;\n options: Record<string, unknown>;\n context: unknown;\n}\n\n/**\n * Resolve the run plan from the JSON-serialisable subset of `parameters.a11y` (functions cannot be\n * read from the page). `disable: true` and `test: \"off\"` skip the story; `test: \"todo\" | \"error\"`\n * still only annotate, results never fail a build.\n */\nexport function resolveA11yRun(raw: unknown): A11yRunPlan {\n const params = asRecord(raw) ?? {};\n const skip = skipReason(params);\n const config = asRecord(params[\"config\"]) ?? {};\n const userOptions = asRecord(params[\"options\"]);\n const rules = { ...disabledByConfig(config), ...asRecord(userOptions?.[\"rules\"]) };\n const options = { runOnly: DEFAULT_RUN_ONLY, ...userOptions, rules };\n const context = params[\"element\"] ?? params[\"context\"] ?? A11Y_ROOT_SELECTOR;\n return { ...(skip ? { skip } : {}), config, options, context };\n}\n\n/**\n * `axe.configure({ rules: [{ id, enabled: false }] })` is ignored under a tag-based `runOnly`, so\n * mirror those switches into the run options where they are honoured.\n */\nfunction disabledByConfig(config: Record<string, unknown>): Record<string, { enabled: false }> {\n const out: Record<string, { enabled: false }> = {};\n const rules = Array.isArray(config[\"rules\"]) ? (config[\"rules\"] as unknown[]) : [];\n for (const rule of rules) {\n const entry = asRecord(rule);\n if (entry?.[\"enabled\"] === false && typeof entry[\"id\"] === \"string\")\n out[entry[\"id\"]] = { enabled: false };\n }\n return out;\n}\n\nfunction skipReason(params: Record<string, unknown>): string | undefined {\n if (params[\"disable\"] === true) return \"parameters.a11y.disable\";\n if (params[\"test\"] === \"off\") return 'parameters.a11y.test is \"off\"';\n return undefined;\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n"],"mappings":";;;;;;AAGA,MAAa,qBAAqB;;;;;;;AAQlC,MAAM,mBAAmB;CACvB,MAAM;CACN,QAAQ;EAAC;EAAU;EAAW;EAAW;EAAY;EAAY;CAAe;AAClF;;;;;;AAgBA,SAAgB,eAAe,KAA2B;CACxD,MAAM,SAAS,SAAS,GAAG,KAAK,CAAC;CACjC,MAAM,OAAO,WAAW,MAAM;CAC9B,MAAM,SAAS,SAAS,OAAO,SAAS,KAAK,CAAC;CAC9C,MAAM,cAAc,SAAS,OAAO,UAAU;CAC9C,MAAM,QAAQ;EAAE,GAAG,iBAAiB,MAAM;EAAG,GAAG,SAAS,cAAc,QAAQ;CAAE;CACjF,MAAM,UAAU;EAAE,SAAS;EAAkB,GAAG;EAAa;CAAM;CACnE,MAAM,UAAU,OAAO,cAAc,OAAO,cAAA;CAC5C,OAAO;EAAE,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EAAI;EAAQ;EAAS;CAAQ;AAC/D;;;;;AAMA,SAAS,iBAAiB,QAAqE;CAC7F,MAAM,MAA0C,CAAC;CACjD,MAAM,QAAQ,MAAM,QAAQ,OAAO,QAAQ,IAAK,OAAO,WAAyB,CAAC;CACjF,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,SAAS,IAAI;EAC3B,IAAI,QAAQ,eAAe,SAAS,OAAO,MAAM,UAAU,UACzD,IAAI,MAAM,SAAS,EAAE,SAAS,MAAM;CACxC;CACA,OAAO;AACT;AAEA,SAAS,WAAW,QAAqD;CACvE,IAAI,OAAO,eAAe,MAAM,OAAO;CACvC,IAAI,OAAO,YAAY,OAAO,OAAO;AAEvC;AAEA,SAAS,SAAS,OAAqD;CACrE,OAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IACrE,QACD,KAAA;AACN"}
@@ -1,7 +1,6 @@
1
1
  import __tsdown_shims_path from 'node:path';
2
2
  import __tsdown_shims_url from 'node:url';
3
3
  import { DepGraph } from "@storyshelf/affected";
4
- //#region src/capture/adapter.d.ts
5
4
  /** A custom viewport registered on a story via `parameters.viewport`. */
6
5
  interface StoryViewportDefinition {
7
6
  name?: string;
@@ -15,6 +14,23 @@ interface StoryViewportConfig {
15
14
  defaultViewport?: string;
16
15
  viewports?: Record<string, StoryViewportDefinition>;
17
16
  }
17
+ /** Viewport a mode captures at: a width, a Storybook viewport name, or explicit dimensions. */
18
+ type ModeViewportValue = number | string | {
19
+ width: number;
20
+ height: number;
21
+ };
22
+ /**
23
+ * One entry of `parameters.{chromatic,storyshelf}.modes`. `viewport` sizes the
24
+ * page, `disable` removes an inherited mode, every other key is a Storybook
25
+ * global (theme, locale, backgrounds, …) applied through the `globals` URL arg.
26
+ */
27
+ interface ModeDefinition {
28
+ viewport?: ModeViewportValue;
29
+ disable?: boolean;
30
+ [global: string]: unknown;
31
+ }
32
+ /** Named modes keyed by display name (the slug of the name is the baseline identity). */
33
+ type ModeMap = Record<string, ModeDefinition>;
18
34
  /** Per-story capture parameters from the Storybook index. */
19
35
  interface StoryParameters {
20
36
  disableSnapshot?: boolean;
@@ -39,6 +55,13 @@ interface StoryParameters {
39
55
  waitForFonts?: boolean;
40
56
  /** Storybook viewport config; adds the story's default viewport to the project list at capture time. */
41
57
  viewport?: StoryViewportConfig;
58
+ /**
59
+ * CSS selectors hidden (`visibility: hidden`) before the screenshot. `storyshelf` replaces
60
+ * `chromatic`; `[data-storyshelf-ignore]` and the Chromatic markers always apply.
61
+ */
62
+ ignoreSelectors?: string[];
63
+ /** Named modes: extra captures of this story under different globals/viewports. */
64
+ modes?: ModeMap;
42
65
  }
43
66
  /** Return whether a story is marked flaky (failures stay non-blocking). */
44
67
  declare function isFlakyStory(entry: Pick<StoryEntry, "tags" | "parameters">): boolean;
@@ -52,18 +75,35 @@ interface StoryEntry {
52
75
  importPath?: string;
53
76
  tags?: string[];
54
77
  type: "story" | "docs";
78
+ /**
79
+ * Set on a Storybook 10 `.test()` entry (index `subtype: "test"`): the id of the story it is
80
+ * written under. Test entries are never captured; a project that runs tests runs them in the
81
+ * iframe (ADR 0004, decision 10).
82
+ */
83
+ parentId?: string;
55
84
  parameters?: StoryParameters;
85
+ /** Figma URL declared via `parameters.design` / `parameters.storyshelf.figma`. */
86
+ designUrl?: string;
87
+ /** Declared design value that is not a usable Figma URL (ignored; logged at capture). */
88
+ designInvalid?: string;
56
89
  }
57
90
  /** Minimal structural page handle handed to `StorySourceAdapter.waitForReady`. */
58
91
  interface CapturePage {
59
92
  evaluate(pageFunction: string | ((...args: unknown[]) => unknown), arg?: unknown): Promise<unknown>;
60
93
  waitForSelector(selector: string, options?: Record<string, unknown>): Promise<unknown>;
61
94
  }
95
+ /** Optional discovery inputs. */
96
+ interface DiscoverOptions {
97
+ /** Validates declared design links (`design` / `storyshelf.figma`); without it none are extracted. */
98
+ parseDesignUrl?: (raw: string) => {
99
+ url: string;
100
+ } | null;
101
+ }
62
102
  /** Adapter that discovers and renders stories from a Storybook build. */
63
103
  interface StorySourceAdapter {
64
104
  name: string;
65
- discover(source: string): Promise<StoryEntry[]>;
66
- buildUrl(baseUrl: string, storyId: string): string;
105
+ discover(source: string, options?: DiscoverOptions): Promise<StoryEntry[]>;
106
+ buildUrl(baseUrl: string, storyId: string, globals?: Record<string, unknown>): string;
67
107
  screenshotSelector?: string;
68
108
  /**
69
109
  * Optional hook loading the module dependency graph of an extracted build,
@@ -85,9 +125,10 @@ interface Viewport {
85
125
  name: string;
86
126
  width: number;
87
127
  height: number;
128
+ /** Storybook globals applied for this capture (set for modes only). */
129
+ globals?: Record<string, unknown>;
88
130
  }
89
131
  /** Default viewport used when none is configured. */
90
132
  declare const DEFAULT_VIEWPORTS: Viewport[];
91
- //#endregion
92
- export { CapturePage, DEFAULT_VIEWPORTS, StoryEntry, StoryParameters, StorySourceAdapter, StoryViewportConfig, StoryViewportDefinition, Viewport, isDisabledStory, isFlakyStory };
133
+ export { CapturePage, DEFAULT_VIEWPORTS, DiscoverOptions, ModeDefinition, ModeMap, ModeViewportValue, StoryEntry, StoryParameters, StorySourceAdapter, StoryViewportConfig, StoryViewportDefinition, Viewport, isDisabledStory, isFlakyStory };
93
134
  //# sourceMappingURL=adapter.d.mts.map
@@ -1,7 +1,7 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
- //#region src/capture/adapter.ts
4
+ // src/capture/adapter.ts
5
5
  /** Return whether a story is marked flaky (failures stay non-blocking). */
6
6
  function isFlakyStory(entry) {
7
7
  if (entry.parameters?.flakyTest) return true;
@@ -25,7 +25,6 @@ const DEFAULT_VIEWPORTS = [{
25
25
  width: 1280,
26
26
  height: 720
27
27
  }];
28
- //#endregion
29
28
  export { DEFAULT_VIEWPORTS, isDisabledStory, isFlakyStory };
30
29
 
31
30
  //# sourceMappingURL=adapter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.mjs","names":[],"sources":["../../src/capture/adapter.ts"],"sourcesContent":["import type { DepGraph } from \"@storyshelf/affected\";\n\n/** A custom viewport registered on a story via `parameters.viewport`. */\nexport interface StoryViewportDefinition {\n name?: string;\n styles?: {\n width?: string | number;\n height?: string | number;\n };\n}\n\n/** Storybook `parameters.viewport` config; carried through discovery for per-story viewport capture. */\nexport interface StoryViewportConfig {\n defaultViewport?: string;\n viewports?: Record<string, StoryViewportDefinition>;\n}\n\n/** Per-story capture parameters from the Storybook index. */\nexport interface StoryParameters {\n disableSnapshot?: boolean;\n delay?: number;\n diffThreshold?: number;\n pauseAnimationAtEnd?: boolean;\n flakyTest?: boolean;\n /** Force auto-crop (true) or full viewport (false) for this story; undefined uses 60% whitespace rule. */\n autoCrop?: boolean;\n /** Whitespace fraction (0..1) above which we crop; default 0.6. */\n autoCropThreshold?: number;\n /** Whether overflow should trigger fullPage; default true. */\n fullPageOnOverflow?: boolean;\n /** Min dimensions for the final PNG (clamp after padding). */\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n /** Burst count for steady capture (1 = single shot, 3 = burst 100ms); default 1. */\n burst?: number;\n /** Whether to wait for fonts.ready before screenshot; default true when burst >1. */\n waitForFonts?: boolean;\n /** Storybook viewport config; adds the story's default viewport to the project list at capture time. */\n viewport?: StoryViewportConfig;\n}\n\n/** Return whether a story is marked flaky (failures stay non-blocking). */\nexport function isFlakyStory(entry: Pick<StoryEntry, \"tags\" | \"parameters\">): boolean {\n if (entry.parameters?.flakyTest) return true;\n const tags = entry.tags ?? [];\n for (const t of tags) {\n if (t.toLowerCase() === \"flaky-test\") return true;\n }\n return false;\n}\n\n/** Return whether a story is excluded from snapshot capture. */\nexport function isDisabledStory(entry: Pick<StoryEntry, \"tags\" | \"parameters\">): boolean {\n if (entry.parameters?.disableSnapshot) return true;\n const tags = entry.tags ?? [];\n for (const t of tags) {\n const lower = t.toLowerCase();\n if (lower === \"skip\" || lower === \"disable\" || lower === \"disable-snapshot\") return true;\n }\n return false;\n}\n\n/** A single discoverable story or docs entry within a Storybook. */\nexport interface StoryEntry {\n id: string;\n title: string;\n name: string;\n importPath?: string;\n tags?: string[];\n type: \"story\" | \"docs\";\n parameters?: StoryParameters;\n}\n\n/** Minimal structural page handle handed to `StorySourceAdapter.waitForReady`. */\nexport interface CapturePage {\n evaluate(\n pageFunction: string | ((...args: unknown[]) => unknown),\n arg?: unknown,\n ): Promise<unknown>;\n waitForSelector(selector: string, options?: Record<string, unknown>): Promise<unknown>;\n}\n\n/** Adapter that discovers and renders stories from a Storybook build. */\nexport interface StorySourceAdapter {\n name: string;\n discover(source: string): Promise<StoryEntry[]>;\n buildUrl(baseUrl: string, storyId: string): string;\n screenshotSelector?: string;\n /**\n * Optional hook loading the module dependency graph of an extracted build,\n * enabling affected capture (render only stories downstream of a change).\n * Absent (or resolving `null`) means the source cannot be traced, so the\n * orchestrator renders every story.\n */\n loadDependencyGraph?(sourceDir: string): Promise<DepGraph | null>;\n /**\n * Optional hook invoked after navigation and before the screenshot sequence,\n * letting a custom source wait until it is ready to capture. The built-in\n * Storybook adapter leaves this undefined (rendered via iframe). See\n * ADR 0005.\n */\n waitForReady?(page: CapturePage): Promise<void>;\n}\n\n/** A viewport size at which stories are captured. */\nexport interface Viewport {\n name: string;\n width: number;\n height: number;\n}\n\n/** Default viewport used when none is configured. */\nexport const DEFAULT_VIEWPORTS: Viewport[] = [{ name: \"desktop\", width: 1280, height: 720 }];\n"],"mappings":";;;;;AA4CA,SAAgB,aAAa,OAAyD;CACpF,IAAI,MAAM,YAAY,WAAW,OAAO;CACxC,MAAM,OAAO,MAAM,QAAQ,CAAC;CAC5B,KAAK,MAAM,KAAK,MACd,IAAI,EAAE,YAAY,MAAM,cAAc,OAAO;CAE/C,OAAO;AACT;;AAGA,SAAgB,gBAAgB,OAAyD;CACvF,IAAI,MAAM,YAAY,iBAAiB,OAAO;CAC9C,MAAM,OAAO,MAAM,QAAQ,CAAC;CAC5B,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,QAAQ,EAAE,YAAY;EAC5B,IAAI,UAAU,UAAU,UAAU,aAAa,UAAU,oBAAoB,OAAO;CACtF;CACA,OAAO;AACT;;AAoDA,MAAa,oBAAgC,CAAC;CAAE,MAAM;CAAW,OAAO;CAAM,QAAQ;AAAI,CAAC"}
1
+ {"version":3,"file":"adapter.mjs","names":[],"sources":["../../src/capture/adapter.ts"],"sourcesContent":["import type { DepGraph } from \"@storyshelf/affected\";\n\n/** A custom viewport registered on a story via `parameters.viewport`. */\nexport interface StoryViewportDefinition {\n name?: string;\n styles?: {\n width?: string | number;\n height?: string | number;\n };\n}\n\n/** Storybook `parameters.viewport` config; carried through discovery for per-story viewport capture. */\nexport interface StoryViewportConfig {\n defaultViewport?: string;\n viewports?: Record<string, StoryViewportDefinition>;\n}\n\n/** Viewport a mode captures at: a width, a Storybook viewport name, or explicit dimensions. */\nexport type ModeViewportValue = number | string | { width: number; height: number };\n\n/**\n * One entry of `parameters.{chromatic,storyshelf}.modes`. `viewport` sizes the\n * page, `disable` removes an inherited mode, every other key is a Storybook\n * global (theme, locale, backgrounds, …) applied through the `globals` URL arg.\n */\nexport interface ModeDefinition {\n viewport?: ModeViewportValue;\n disable?: boolean;\n [global: string]: unknown;\n}\n\n/** Named modes keyed by display name (the slug of the name is the baseline identity). */\nexport type ModeMap = Record<string, ModeDefinition>;\n\n/** Per-story capture parameters from the Storybook index. */\nexport interface StoryParameters {\n disableSnapshot?: boolean;\n delay?: number;\n diffThreshold?: number;\n pauseAnimationAtEnd?: boolean;\n flakyTest?: boolean;\n /** Force auto-crop (true) or full viewport (false) for this story; undefined uses 60% whitespace rule. */\n autoCrop?: boolean;\n /** Whitespace fraction (0..1) above which we crop; default 0.6. */\n autoCropThreshold?: number;\n /** Whether overflow should trigger fullPage; default true. */\n fullPageOnOverflow?: boolean;\n /** Min dimensions for the final PNG (clamp after padding). */\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n /** Burst count for steady capture (1 = single shot, 3 = burst 100ms); default 1. */\n burst?: number;\n /** Whether to wait for fonts.ready before screenshot; default true when burst >1. */\n waitForFonts?: boolean;\n /** Storybook viewport config; adds the story's default viewport to the project list at capture time. */\n viewport?: StoryViewportConfig;\n /**\n * CSS selectors hidden (`visibility: hidden`) before the screenshot. `storyshelf` replaces\n * `chromatic`; `[data-storyshelf-ignore]` and the Chromatic markers always apply.\n */\n ignoreSelectors?: string[];\n /** Named modes: extra captures of this story under different globals/viewports. */\n modes?: ModeMap;\n}\n\n/** Return whether a story is marked flaky (failures stay non-blocking). */\nexport function isFlakyStory(entry: Pick<StoryEntry, \"tags\" | \"parameters\">): boolean {\n if (entry.parameters?.flakyTest) return true;\n const tags = entry.tags ?? [];\n for (const t of tags) {\n if (t.toLowerCase() === \"flaky-test\") return true;\n }\n return false;\n}\n\n/** Return whether a story is excluded from snapshot capture. */\nexport function isDisabledStory(entry: Pick<StoryEntry, \"tags\" | \"parameters\">): boolean {\n if (entry.parameters?.disableSnapshot) return true;\n const tags = entry.tags ?? [];\n for (const t of tags) {\n const lower = t.toLowerCase();\n if (lower === \"skip\" || lower === \"disable\" || lower === \"disable-snapshot\") return true;\n }\n return false;\n}\n\n/** A single discoverable story or docs entry within a Storybook. */\nexport interface StoryEntry {\n id: string;\n title: string;\n name: string;\n importPath?: string;\n tags?: string[];\n type: \"story\" | \"docs\";\n /**\n * Set on a Storybook 10 `.test()` entry (index `subtype: \"test\"`): the id of the story it is\n * written under. Test entries are never captured; a project that runs tests runs them in the\n * iframe (ADR 0004, decision 10).\n */\n parentId?: string;\n parameters?: StoryParameters;\n /** Figma URL declared via `parameters.design` / `parameters.storyshelf.figma`. */\n designUrl?: string;\n /** Declared design value that is not a usable Figma URL (ignored; logged at capture). */\n designInvalid?: string;\n}\n\n/** Minimal structural page handle handed to `StorySourceAdapter.waitForReady`. */\nexport interface CapturePage {\n evaluate(\n pageFunction: string | ((...args: unknown[]) => unknown),\n arg?: unknown,\n ): Promise<unknown>;\n waitForSelector(selector: string, options?: Record<string, unknown>): Promise<unknown>;\n}\n\n/** Optional discovery inputs. */\nexport interface DiscoverOptions {\n /** Validates declared design links (`design` / `storyshelf.figma`); without it none are extracted. */\n parseDesignUrl?: (raw: string) => { url: string } | null;\n}\n\n/** Adapter that discovers and renders stories from a Storybook build. */\nexport interface StorySourceAdapter {\n name: string;\n discover(source: string, options?: DiscoverOptions): Promise<StoryEntry[]>;\n buildUrl(baseUrl: string, storyId: string, globals?: Record<string, unknown>): string;\n screenshotSelector?: string;\n /**\n * Optional hook loading the module dependency graph of an extracted build,\n * enabling affected capture (render only stories downstream of a change).\n * Absent (or resolving `null`) means the source cannot be traced, so the\n * orchestrator renders every story.\n */\n loadDependencyGraph?(sourceDir: string): Promise<DepGraph | null>;\n /**\n * Optional hook invoked after navigation and before the screenshot sequence,\n * letting a custom source wait until it is ready to capture. The built-in\n * Storybook adapter leaves this undefined (rendered via iframe). See\n * ADR 0005.\n */\n waitForReady?(page: CapturePage): Promise<void>;\n}\n\n/** A viewport size at which stories are captured. */\nexport interface Viewport {\n name: string;\n width: number;\n height: number;\n /** Storybook globals applied for this capture (set for modes only). */\n globals?: Record<string, unknown>;\n}\n\n/** Default viewport used when none is configured. */\nexport const DEFAULT_VIEWPORTS: Viewport[] = [{ name: \"desktop\", width: 1280, height: 720 }];\n"],"mappings":";;;;;AAoEA,SAAgB,aAAa,OAAyD;CACpF,IAAI,MAAM,YAAY,WAAW,OAAO;CACxC,MAAM,OAAO,MAAM,QAAQ,CAAC;CAC5B,KAAK,MAAM,KAAK,MACd,IAAI,EAAE,YAAY,MAAM,cAAc,OAAO;CAE/C,OAAO;AACT;;AAGA,SAAgB,gBAAgB,OAAyD;CACvF,IAAI,MAAM,YAAY,iBAAiB,OAAO;CAC9C,MAAM,OAAO,MAAM,QAAQ,CAAC;CAC5B,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,QAAQ,EAAE,YAAY;EAC5B,IAAI,UAAU,UAAU,UAAU,aAAa,UAAU,oBAAoB,OAAO;CACtF;CACA,OAAO;AACT;;AAsEA,MAAa,oBAAgC,CAAC;CAAE,MAAM;CAAW,OAAO;CAAM,QAAQ;AAAI,CAAC"}
@@ -4,13 +4,13 @@ import { StoryEntry, Viewport } from "./adapter.mjs";
4
4
  import "../adapter/database.mjs";
5
5
  import { Baseline } from "../schema/baseline.mjs";
6
6
  import "../models/baseline.mjs";
7
- //#region src/capture/affected.d.ts
8
7
  /** An inherit candidate paired with the baseline it reuses. */
9
8
  interface InheritedStory {
10
9
  story: StoryEntry;
11
10
  viewport: Viewport;
12
11
  baseline: Baseline;
12
+ /** Engine whose baseline is reused (chromium when absent). */
13
+ browser?: string;
13
14
  }
14
- //#endregion
15
15
  export { InheritedStory };
16
16
  //# sourceMappingURL=affected.d.mts.map
@@ -1,10 +1,18 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
- import { BaselineModel } from "../models/baseline.mjs";
5
4
  import { resolveStoryViewports } from "./storybook.mjs";
5
+ import { BuildModel } from "../models/build.mjs";
6
+ import { BaselineModel } from "../models/baseline.mjs";
6
7
  import { selectAffectedStories } from "@storyshelf/affected";
7
- //#region src/capture/affected.ts
8
+ // src/capture/affected.ts
9
+ /**
10
+ * Resolve the affected import paths for a build, or `null` for full capture (affected capture
11
+ * disabled, or no computation was posted). The one rule for the whole and the sharded path alike.
12
+ */
13
+ function affectedPathsFor(build) {
14
+ return build.affectedOnly ? BuildModel.affectedPaths(build) : null;
15
+ }
8
16
  /** Split one inherit candidate by per-viewport baseline availability. */
9
17
  async function splitStory(baselines, input, story) {
10
18
  const render = [];
@@ -12,12 +20,13 @@ async function splitStory(baselines, input, story) {
12
20
  const viewports = resolveStoryViewports(story, input.viewports);
13
21
  const settled = await Promise.all(viewports.map(async (viewport) => ({
14
22
  viewport,
15
- baseline: await baselines.resolve(input.projectId, story.id, viewport.name, input.branch, input.defaultBranch)
23
+ baseline: await baselines.resolve(input.projectId, story.id, viewport.name, input.branch, input.defaultBranch, input.browser)
16
24
  })));
17
25
  for (const { viewport, baseline } of settled) if (baseline) inherited.push({
18
26
  story,
19
27
  viewport,
20
- baseline
28
+ baseline,
29
+ ...input.browser ? { browser: input.browser } : {}
21
30
  });
22
31
  else if (!render.includes(story)) render.push(story);
23
32
  return {
@@ -58,7 +67,6 @@ async function partitionAffectedStories(input) {
58
67
  inherited: merged.inherited
59
68
  };
60
69
  }
61
- //#endregion
62
- export { partitionAffectedStories };
70
+ export { affectedPathsFor, partitionAffectedStories };
63
71
 
64
72
  //# sourceMappingURL=affected.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"affected.mjs","names":[],"sources":["../../src/capture/affected.ts"],"sourcesContent":["import { selectAffectedStories } from \"@storyshelf/affected\";\nimport type { DatabaseAdapter } from \"../adapters/database.ts\";\nimport { BaselineModel, type BaselineTables } from \"../models/baseline.ts\";\nimport type { Baseline } from \"../schema/baseline.ts\";\nimport type { StoryEntry, Viewport } from \"./adapter.ts\";\nimport { resolveStoryViewports } from \"./storybook.ts\";\n\n/** An inherit candidate paired with the baseline it reuses. */\nexport interface InheritedStory {\n story: StoryEntry;\n viewport: Viewport;\n baseline: Baseline;\n}\n\n/** Stories split into capture-now versus inherit-from-baseline sets. */\nexport interface AffectedPartition {\n render: StoryEntry[];\n inherited: InheritedStory[];\n}\n\n/** Inputs for partitioning a build's stories by affected status. */\nexport interface PartitionInput {\n db: DatabaseAdapter;\n tables: BaselineTables;\n projectId: string;\n branch: string;\n defaultBranch: string;\n stories: StoryEntry[];\n viewports: Viewport[];\n /** Affected import paths, or `null` to render everything. */\n affectedPaths: string[] | null;\n}\n\n/** Split one inherit candidate by per-viewport baseline availability. */\nasync function splitStory(\n baselines: BaselineModel,\n input: PartitionInput,\n story: StoryEntry,\n): Promise<AffectedPartition> {\n const render: StoryEntry[] = [];\n const inherited: InheritedStory[] = [];\n const viewports = resolveStoryViewports(story, input.viewports);\n const settled = await Promise.all(\n viewports.map(async (viewport) => ({\n viewport,\n baseline: await baselines.resolve(\n input.projectId,\n story.id,\n viewport.name,\n input.branch,\n input.defaultBranch,\n ),\n })),\n );\n for (const { viewport, baseline } of settled) {\n if (baseline) {\n inherited.push({ story, viewport, baseline });\n } else if (!render.includes(story)) {\n render.push(story);\n }\n }\n return { render, inherited };\n}\n\n/** Merge per-story partitions into a single render/inherit split. */\nfunction mergePartitions(partitions: AffectedPartition[]): AffectedPartition {\n const render: StoryEntry[] = [];\n const inherited: InheritedStory[] = [];\n for (const partition of partitions) {\n render.push(...partition.render);\n inherited.push(...partition.inherited);\n }\n return { render, inherited };\n}\n\n/**\n * Partition discovered stories into render versus inherit sets.\n *\n * Stories outside the affected set inherit their baseline without rendering,\n * except when no baseline exists (new stories always render). A `null`\n * affected set renders everything.\n */\nexport async function partitionAffectedStories(input: PartitionInput): Promise<AffectedPartition> {\n const selected = selectAffectedStories(input.stories, input.affectedPaths);\n if (selected.inherit.length === 0) {\n return { render: selected.render, inherited: [] };\n }\n const baselines = new BaselineModel(input.db, input.tables);\n const partitions = await Promise.all(\n selected.inherit.map(async (story) => await splitStory(baselines, input, story)),\n );\n const merged = mergePartitions(partitions);\n return { render: [...selected.render, ...merged.render], inherited: merged.inherited };\n}\n"],"mappings":";;;;;;;;AAkCA,eAAe,WACb,WACA,OACA,OAC4B;CAC5B,MAAM,SAAuB,CAAC;CAC9B,MAAM,YAA8B,CAAC;CACrC,MAAM,YAAY,sBAAsB,OAAO,MAAM,SAAS;CAC9D,MAAM,UAAU,MAAM,QAAQ,IAC5B,UAAU,IAAI,OAAO,cAAc;EACjC;EACA,UAAU,MAAM,UAAU,QACxB,MAAM,WACN,MAAM,IACN,SAAS,MACT,MAAM,QACN,MAAM,aACR;CACF,EAAE,CACJ;CACA,KAAK,MAAM,EAAE,UAAU,cAAc,SACnC,IAAI,UACF,UAAU,KAAK;EAAE;EAAO;EAAU;CAAS,CAAC;MACvC,IAAI,CAAC,OAAO,SAAS,KAAK,GAC/B,OAAO,KAAK,KAAK;CAGrB,OAAO;EAAE;EAAQ;CAAU;AAC7B;;AAGA,SAAS,gBAAgB,YAAoD;CAC3E,MAAM,SAAuB,CAAC;CAC9B,MAAM,YAA8B,CAAC;CACrC,KAAK,MAAM,aAAa,YAAY;EAClC,OAAO,KAAK,GAAG,UAAU,MAAM;EAC/B,UAAU,KAAK,GAAG,UAAU,SAAS;CACvC;CACA,OAAO;EAAE;EAAQ;CAAU;AAC7B;;;;;;;;AASA,eAAsB,yBAAyB,OAAmD;CAChG,MAAM,WAAW,sBAAsB,MAAM,SAAS,MAAM,aAAa;CACzE,IAAI,SAAS,QAAQ,WAAW,GAC9B,OAAO;EAAE,QAAQ,SAAS;EAAQ,WAAW,CAAC;CAAE;CAElD,MAAM,YAAY,IAAI,cAAc,MAAM,IAAI,MAAM,MAAM;CAI1D,MAAM,SAAS,gBAAgB,MAHN,QAAQ,IAC/B,SAAS,QAAQ,IAAI,OAAO,UAAU,MAAM,WAAW,WAAW,OAAO,KAAK,CAAC,CACjF,CACyC;CACzC,OAAO;EAAE,QAAQ,CAAC,GAAG,SAAS,QAAQ,GAAG,OAAO,MAAM;EAAG,WAAW,OAAO;CAAU;AACvF"}
1
+ {"version":3,"file":"affected.mjs","names":[],"sources":["../../src/capture/affected.ts"],"sourcesContent":["import { selectAffectedStories } from \"@storyshelf/affected\";\nimport type { DatabaseAdapter } from \"../adapters/database.ts\";\nimport { BaselineModel, type BaselineTables } from \"../models/baseline.ts\";\nimport { BuildModel } from \"../models/build.ts\";\nimport type { Baseline } from \"../schema/baseline.ts\";\nimport type { Build } from \"../schema/build.ts\";\nimport type { StoryEntry, Viewport } from \"./adapter.ts\";\nimport { resolveStoryViewports } from \"./storybook.ts\";\n\n/**\n * Resolve the affected import paths for a build, or `null` for full capture (affected capture\n * disabled, or no computation was posted). The one rule for the whole and the sharded path alike.\n */\nexport function affectedPathsFor(\n build: Pick<Build, \"affectedOnly\" | \"affectedImportPaths\">,\n): string[] | null {\n return build.affectedOnly ? BuildModel.affectedPaths(build) : null;\n}\n\n/** An inherit candidate paired with the baseline it reuses. */\nexport interface InheritedStory {\n story: StoryEntry;\n viewport: Viewport;\n baseline: Baseline;\n /** Engine whose baseline is reused (chromium when absent). */\n browser?: string;\n}\n\n/** Stories split into capture-now versus inherit-from-baseline sets. */\nexport interface AffectedPartition {\n render: StoryEntry[];\n inherited: InheritedStory[];\n}\n\n/** Inputs for partitioning a build's stories by affected status. */\nexport interface PartitionInput {\n db: DatabaseAdapter;\n tables: BaselineTables;\n projectId: string;\n branch: string;\n defaultBranch: string;\n stories: StoryEntry[];\n viewports: Viewport[];\n /** Engine to resolve baselines for (default chromium). */\n browser?: string;\n /** Affected import paths, or `null` to render everything. */\n affectedPaths: string[] | null;\n}\n\n/** Split one inherit candidate by per-viewport baseline availability. */\nasync function splitStory(\n baselines: BaselineModel,\n input: PartitionInput,\n story: StoryEntry,\n): Promise<AffectedPartition> {\n const render: StoryEntry[] = [];\n const inherited: InheritedStory[] = [];\n const viewports = resolveStoryViewports(story, input.viewports);\n const settled = await Promise.all(\n viewports.map(async (viewport) => ({\n viewport,\n baseline: await baselines.resolve(\n input.projectId,\n story.id,\n viewport.name,\n input.branch,\n input.defaultBranch,\n input.browser,\n ),\n })),\n );\n for (const { viewport, baseline } of settled) {\n if (baseline) {\n inherited.push({\n story,\n viewport,\n baseline,\n ...(input.browser ? { browser: input.browser } : {}),\n });\n } else if (!render.includes(story)) {\n render.push(story);\n }\n }\n return { render, inherited };\n}\n\n/** Merge per-story partitions into a single render/inherit split. */\nfunction mergePartitions(partitions: AffectedPartition[]): AffectedPartition {\n const render: StoryEntry[] = [];\n const inherited: InheritedStory[] = [];\n for (const partition of partitions) {\n render.push(...partition.render);\n inherited.push(...partition.inherited);\n }\n return { render, inherited };\n}\n\n/**\n * Partition discovered stories into render versus inherit sets.\n *\n * Stories outside the affected set inherit their baseline without rendering,\n * except when no baseline exists (new stories always render). A `null`\n * affected set renders everything.\n */\nexport async function partitionAffectedStories(input: PartitionInput): Promise<AffectedPartition> {\n const selected = selectAffectedStories(input.stories, input.affectedPaths);\n if (selected.inherit.length === 0) {\n return { render: selected.render, inherited: [] };\n }\n const baselines = new BaselineModel(input.db, input.tables);\n const partitions = await Promise.all(\n selected.inherit.map(async (story) => await splitStory(baselines, input, story)),\n );\n const merged = mergePartitions(partitions);\n return { render: [...selected.render, ...merged.render], inherited: merged.inherited };\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,iBACd,OACiB;CACjB,OAAO,MAAM,eAAe,WAAW,cAAc,KAAK,IAAI;AAChE;;AAiCA,eAAe,WACb,WACA,OACA,OAC4B;CAC5B,MAAM,SAAuB,CAAC;CAC9B,MAAM,YAA8B,CAAC;CACrC,MAAM,YAAY,sBAAsB,OAAO,MAAM,SAAS;CAC9D,MAAM,UAAU,MAAM,QAAQ,IAC5B,UAAU,IAAI,OAAO,cAAc;EACjC;EACA,UAAU,MAAM,UAAU,QACxB,MAAM,WACN,MAAM,IACN,SAAS,MACT,MAAM,QACN,MAAM,eACN,MAAM,OACR;CACF,EAAE,CACJ;CACA,KAAK,MAAM,EAAE,UAAU,cAAc,SACnC,IAAI,UACF,UAAU,KAAK;EACb;EACA;EACA;EACA,GAAI,MAAM,UAAU,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;CACpD,CAAC;MACI,IAAI,CAAC,OAAO,SAAS,KAAK,GAC/B,OAAO,KAAK,KAAK;CAGrB,OAAO;EAAE;EAAQ;CAAU;AAC7B;;AAGA,SAAS,gBAAgB,YAAoD;CAC3E,MAAM,SAAuB,CAAC;CAC9B,MAAM,YAA8B,CAAC;CACrC,KAAK,MAAM,aAAa,YAAY;EAClC,OAAO,KAAK,GAAG,UAAU,MAAM;EAC/B,UAAU,KAAK,GAAG,UAAU,SAAS;CACvC;CACA,OAAO;EAAE;EAAQ;CAAU;AAC7B;;;;;;;;AASA,eAAsB,yBAAyB,OAAmD;CAChG,MAAM,WAAW,sBAAsB,MAAM,SAAS,MAAM,aAAa;CACzE,IAAI,SAAS,QAAQ,WAAW,GAC9B,OAAO;EAAE,QAAQ,SAAS;EAAQ,WAAW,CAAC;CAAE;CAElD,MAAM,YAAY,IAAI,cAAc,MAAM,IAAI,MAAM,MAAM;CAI1D,MAAM,SAAS,gBAAgB,MAHN,QAAQ,IAC/B,SAAS,QAAQ,IAAI,OAAO,UAAU,MAAM,WAAW,WAAW,OAAO,KAAK,CAAC,CACjF,CACyC;CACzC,OAAO;EAAE,QAAQ,CAAC,GAAG,SAAS,QAAQ,GAAG,OAAO,MAAM;EAAG,WAAW,OAAO;CAAU;AACvF"}