@reqvire-org/ads 0.4.7 → 0.5.1

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 (751) hide show
  1. package/README.md +268 -420
  2. package/dist/accessibility-declarations.mjs +43 -0
  3. package/dist/active-clock.d.mts +30 -0
  4. package/dist/active-clock.mjs +26 -17
  5. package/dist/ads-errors.mjs +3684 -0
  6. package/dist/ads-view-choices.mjs +17 -0
  7. package/dist/ads-views.mjs +12 -0
  8. package/dist/analysis/captured-content.mjs +16 -0
  9. package/dist/analysis/compiler-options.mjs +3 -7
  10. package/dist/analysis/context.mjs +14 -20
  11. package/dist/analysis/controller-gates.mjs +119 -0
  12. package/dist/analysis/design-usage.mjs +142 -0
  13. package/dist/analysis/file-tree.mjs +44 -29
  14. package/dist/analysis/framework-imports.mjs +62 -0
  15. package/dist/analysis/glyph-macros.mjs +103 -0
  16. package/dist/analysis/helpers.mjs +119 -91
  17. package/dist/analysis/impact.mjs +25 -12
  18. package/dist/analysis/inputs.mjs +19 -13
  19. package/dist/analysis/mock-check.mjs +99 -0
  20. package/dist/analysis/module-graph.mjs +156 -0
  21. package/dist/analysis/module-resolvers.mjs +30 -28
  22. package/dist/analysis/native-adapter.mjs +139 -146
  23. package/dist/analysis/native-boundary.mjs +52 -0
  24. package/dist/analysis/native-project.mjs +331 -231
  25. package/dist/analysis/native-session.mjs +20 -0
  26. package/dist/analysis/owner-accessibility.mjs +74 -0
  27. package/dist/analysis/owner-analysis-cache.mjs +125 -0
  28. package/dist/analysis/owner-analysis-key.mjs +114 -0
  29. package/dist/analysis/owner-choices.mjs +896 -0
  30. package/dist/analysis/owner-composition.mjs +636 -0
  31. package/dist/analysis/owner-controls.mjs +27 -0
  32. package/dist/analysis/owner-discovery.mjs +164 -0
  33. package/dist/analysis/owner-failures.mjs +19 -0
  34. package/dist/analysis/owner-outcomes.mjs +42 -0
  35. package/dist/analysis/owner-reuse.mjs +100 -0
  36. package/dist/analysis/owner-source.mjs +1555 -0
  37. package/dist/analysis/prose-owners.mjs +57 -0
  38. package/dist/analysis/public-imports.mjs +31 -0
  39. package/dist/analysis/queries.mjs +72 -54
  40. package/dist/analysis/runtime-setters.mjs +114 -0
  41. package/dist/analysis/scenario-keys.mjs +151 -0
  42. package/dist/analysis/service.mjs +111 -70
  43. package/dist/analysis/standalone.mjs +40 -37
  44. package/dist/analysis/styling-ownership.mjs +298 -0
  45. package/dist/analysis/svg-attributes.mjs +199 -0
  46. package/dist/analysis/syntax.mjs +82 -78
  47. package/dist/analysis/visual-bindings.mjs +68 -0
  48. package/dist/analysis/worker-protocol.mjs +302 -0
  49. package/dist/analysis/worker.mjs +234 -166
  50. package/dist/api-signature.mjs +53 -0
  51. package/dist/app-icon-checks.mjs +298 -0
  52. package/dist/app-icon-declaration.d.mts +53 -0
  53. package/dist/app-icon-declaration.mjs +66 -0
  54. package/dist/asset-binding.mjs +35 -0
  55. package/dist/asset-catalog.mjs +83 -0
  56. package/dist/asset-declaration.d.mts +42 -0
  57. package/dist/asset-declaration.mjs +108 -0
  58. package/dist/asset-macro.d.mts +63 -0
  59. package/dist/asset-macro.mjs +22 -0
  60. package/dist/asset-model.mjs +74 -0
  61. package/dist/asset-usage.mjs +14 -0
  62. package/dist/asset-view-facts.mjs +41 -0
  63. package/dist/authoring-macro.d.mts +11 -0
  64. package/dist/authoring-macro.mjs +21 -0
  65. package/dist/autocomplete-hints.mjs +31 -0
  66. package/dist/availability.mjs +9 -0
  67. package/dist/behavior-macro.d.mts +31 -0
  68. package/dist/behavior-macro.mjs +3 -0
  69. package/dist/behavior-registry.mjs +358 -0
  70. package/dist/boundaries.mjs +50 -212
  71. package/dist/browser-runtime.mjs +73 -0
  72. package/dist/browser-test.d.mts +3 -0
  73. package/dist/browser-test.mjs +2 -0
  74. package/dist/bun-bundler.mjs +10 -0
  75. package/dist/bun-compiler.mjs +30 -18
  76. package/dist/bun-runtime.mjs +4 -0
  77. package/dist/bun-worker.mjs +10 -4
  78. package/dist/capture/request.mjs +81 -0
  79. package/dist/capture/worker.mjs +69 -40
  80. package/dist/capture/worker.page.mjs +6 -0
  81. package/dist/capture-store.mjs +159 -75
  82. package/dist/capture.mjs +232 -95
  83. package/dist/check-service.mjs +27 -33
  84. package/dist/check.mjs +206 -904
  85. package/dist/cli-arguments.mjs +278 -0
  86. package/dist/cli.mjs +374 -304
  87. package/dist/color-values.mjs +294 -242
  88. package/dist/composed-contrast.mjs +648 -0
  89. package/dist/composed-keyline.mjs +107 -0
  90. package/dist/config.mjs +162 -468
  91. package/dist/construction-output.mjs +345 -0
  92. package/dist/construction-spec.d.mts +915 -0
  93. package/dist/construction-spec.mjs +1178 -0
  94. package/dist/corner-overpaint.mjs +53 -0
  95. package/dist/css-length.mjs +80 -0
  96. package/dist/css-quantity.mjs +173 -0
  97. package/dist/deletion-model.mjs +56 -0
  98. package/dist/deletion-plan.mjs +364 -0
  99. package/dist/dependency-manifest.mjs +56 -0
  100. package/dist/design-context-model.d.mts +61 -0
  101. package/dist/design-context-model.mjs +79 -0
  102. package/dist/design-contexts.mjs +105 -0
  103. package/dist/design-foundation.mjs +532 -0
  104. package/dist/design-inputs.mjs +156 -0
  105. package/dist/design-modules.mjs +27 -0
  106. package/dist/design-rejection.d.mts +23 -0
  107. package/dist/design-rejection.mjs +29 -0
  108. package/dist/design-system-closure.mjs +108 -0
  109. package/dist/design-usage.mjs +54 -0
  110. package/dist/development-modules.mjs +2 -0
  111. package/dist/development-runtime.mjs +0 -7
  112. package/dist/digest.mjs +2 -0
  113. package/dist/draft-boundary.mjs +1 -27
  114. package/dist/draft-workspace.mjs +11 -5
  115. package/dist/emit/accept.mjs +33 -0
  116. package/dist/emit/app-icon-emission.mjs +124 -0
  117. package/dist/emit/app-icon-render.mjs +126 -0
  118. package/dist/emit/asset-imports.mjs +18 -0
  119. package/dist/emit/cli-report.mjs +97 -0
  120. package/dist/emit/contract.mjs +136 -0
  121. package/dist/emit/emission.mjs +182 -0
  122. package/dist/emit/font-emission.mjs +111 -0
  123. package/dist/emit/foundation-sheet.mjs +56 -0
  124. package/dist/emit/icon-containers.mjs +46 -0
  125. package/dist/emit/integrity.mjs +61 -0
  126. package/dist/emit/lock.mjs +66 -0
  127. package/dist/emit/namespace.mjs +79 -0
  128. package/dist/emit/operation-reply.mjs +3 -0
  129. package/dist/emit/operation.mjs +36 -0
  130. package/dist/emit/output-location.mjs +20 -0
  131. package/dist/emit/output-package.mjs +7 -0
  132. package/dist/emit/owner-emission-cache.mjs +52 -0
  133. package/dist/emit/palette-module.mjs +19 -0
  134. package/dist/emit/palette-refresh.mjs +77 -0
  135. package/dist/emit/preview-emitter.mjs +110 -0
  136. package/dist/emit/preview-tree.mjs +174 -0
  137. package/dist/emit/scheduler.mjs +75 -0
  138. package/dist/emit/service.mjs +249 -0
  139. package/dist/emit/sync.mjs +38 -0
  140. package/dist/emit/watch.mjs +74 -0
  141. package/dist/emit/writer.mjs +102 -0
  142. package/dist/evidence.mjs +6 -8
  143. package/dist/example-babel.mjs +7 -0
  144. package/dist/example-literals.mjs +88 -0
  145. package/dist/finding-rules.mjs +78 -77
  146. package/dist/focus-checks.mjs +93 -0
  147. package/dist/font-checks.mjs +185 -0
  148. package/dist/font-declaration.d.mts +64 -0
  149. package/dist/font-declaration.mjs +99 -0
  150. package/dist/font-fallback.d.mts +37 -0
  151. package/dist/font-fallback.mjs +25 -0
  152. package/dist/font-macro.d.mts +42 -0
  153. package/dist/font-macro.mjs +6 -0
  154. package/dist/font-metrics.d.mts +34 -0
  155. package/dist/font-metrics.mjs +314 -0
  156. package/dist/font-model.mjs +63 -0
  157. package/dist/form-states.mjs +82 -0
  158. package/dist/foundation-macro.d.mts +108 -0
  159. package/dist/foundation-macro.mjs +6 -0
  160. package/dist/frame-regions.mjs +253 -0
  161. package/dist/glyph-set-declaration.d.mts +27 -0
  162. package/dist/glyph-set-declaration.mjs +36 -0
  163. package/dist/grid-checks.mjs +94 -0
  164. package/dist/grid-facts.mjs +148 -0
  165. package/dist/grid-lowering.mjs +263 -0
  166. package/dist/guard/cli.mjs +51 -0
  167. package/dist/guard/config.mjs +67 -0
  168. package/dist/guard/files.mjs +31 -0
  169. package/dist/guard/index.mjs +3 -0
  170. package/dist/guard/run.mjs +56 -0
  171. package/dist/guard/tsconfig.declarations.json +13 -0
  172. package/dist/index.mjs +2 -7
  173. package/dist/init-project.mjs +134 -0
  174. package/dist/init.mjs +217 -264
  175. package/dist/input-digests.mjs +109 -163
  176. package/dist/input-scope.mjs +18 -41
  177. package/dist/inspected-svg.d.mts +28 -0
  178. package/dist/inspected-svg.mjs +40 -0
  179. package/dist/inventories.mjs +149 -0
  180. package/dist/inventory-query.mjs +15 -0
  181. package/dist/investigations.mjs +177 -99
  182. package/dist/json.d.mts +10 -0
  183. package/dist/json.mjs +36 -0
  184. package/dist/linaria/atomic-processor.json +96 -0
  185. package/dist/linaria/atomic-processor.mjs +2452 -0
  186. package/dist/linaria/backend-identity.mjs +26 -0
  187. package/dist/linaria/compatibility.json +61 -0
  188. package/dist/linaria/css-shape.mjs +94 -0
  189. package/dist/linaria/custom-property-css.mjs +56 -0
  190. package/dist/linaria/delivery.mjs +111 -0
  191. package/dist/linaria/direct-extract.mjs +43 -0
  192. package/dist/linaria/extraction-cache.mjs +31 -0
  193. package/dist/linaria/extraction-model.mjs +5 -0
  194. package/dist/linaria/fingerprint.mjs +183 -0
  195. package/dist/linaria/pair-manifest.json +2315 -0
  196. package/dist/linaria/persisted-extraction-cache.mjs +352 -0
  197. package/dist/linaria/preservation.mjs +13 -0
  198. package/dist/linaria/priority-emitted-rank.mjs +40 -0
  199. package/dist/linaria/priority-manifest.mjs +87 -0
  200. package/dist/linaria/priority-table.mjs +47 -0
  201. package/dist/linaria/priority-tiers.mjs +27 -0
  202. package/dist/linaria/processor-host.mjs +42 -0
  203. package/dist/linaria/processor-runtime.mjs +36 -0
  204. package/dist/linaria-processor-NOTICES.md +147 -0
  205. package/dist/lowering-components.mjs +14 -0
  206. package/dist/lowering-effects.mjs +38 -0
  207. package/dist/lowering-emitter.mjs +29 -0
  208. package/dist/lowering-enter.mjs +31 -0
  209. package/dist/lowering-hidden.mjs +30 -0
  210. package/dist/lowering-layer.mjs +141 -0
  211. package/dist/lowering-motion.mjs +37 -0
  212. package/dist/lowering-normalize.mjs +194 -0
  213. package/dist/lowering-overlaps.mjs +328 -0
  214. package/dist/lowering-paint.mjs +32 -0
  215. package/dist/lowering-properties.mjs +165 -0
  216. package/dist/lowering-region-layout.mjs +225 -0
  217. package/dist/lowering-sequence.mjs +89 -0
  218. package/dist/lowering-serialize.mjs +40 -0
  219. package/dist/lowering-session.mjs +137 -0
  220. package/dist/lowering-tiers.mjs +23 -0
  221. package/dist/lowering-transitions.mjs +53 -0
  222. package/dist/mcp/ads-mcp.mjs +423 -0
  223. package/dist/mcp/apps.mjs +3 -25
  224. package/dist/mcp/behavior-pages.mjs +58 -51
  225. package/dist/mcp/build-status.mjs +233 -267
  226. package/dist/mcp/catalog.mjs +21 -128
  227. package/dist/mcp/compiler-channel.mjs +218 -83
  228. package/dist/mcp/context.mjs +50 -40
  229. package/dist/mcp/deletions.mjs +147 -0
  230. package/dist/mcp/draft-discovery.mjs +43 -38
  231. package/dist/mcp/drafts.mjs +635 -691
  232. package/dist/mcp/execution-context.mjs +33 -22
  233. package/dist/mcp/execution-coordinator.mjs +367 -354
  234. package/dist/mcp/execution-results.mjs +440 -173
  235. package/dist/mcp/mutation-limits.mjs +1 -2
  236. package/dist/mcp/mutations.mjs +515 -553
  237. package/dist/mcp/patch.mjs +117 -75
  238. package/dist/mcp/preview-http.bundle.js +3 -7
  239. package/dist/mcp/preview-http.mjs +220 -107
  240. package/dist/mcp/preview-owner-guard.mjs +81 -43
  241. package/dist/mcp/preview-watch.mjs +428 -365
  242. package/dist/mcp/preview-widget.bundle.js +42 -46
  243. package/dist/mcp/preview-work.mjs +25 -13
  244. package/dist/mcp/prompts.mjs +22 -16
  245. package/dist/mcp/resource-loader.js +1 -1
  246. package/dist/mcp/result-pages.mjs +94 -54
  247. package/dist/mcp/sandbox-host.mjs +41 -19
  248. package/dist/mcp/server-discovery.mjs +96 -0
  249. package/dist/mcp/server-guides.mjs +43 -0
  250. package/dist/mcp/server-host.mjs +203 -0
  251. package/dist/mcp/server-observation.mjs +225 -0
  252. package/dist/mcp/server-project.mjs +371 -0
  253. package/dist/mcp/server-resources.mjs +466 -0
  254. package/dist/mcp/server-shared.mjs +79 -0
  255. package/dist/mcp/server-tools.mjs +791 -0
  256. package/dist/mcp/server.mjs +2 -2813
  257. package/dist/mcp/showcase-host.mjs +209 -135
  258. package/dist/mcp/showcase-http.mjs +50 -28
  259. package/dist/mcp/skills.mjs +32 -36
  260. package/dist/mcp/text-diff.mjs +18 -36
  261. package/dist/measured-geometry.mjs +157 -0
  262. package/dist/motion-model.mjs +52 -0
  263. package/dist/non-text-contrast.mjs +118 -0
  264. package/dist/owner-analysis-check.mjs +711 -0
  265. package/dist/owner-design.mjs +15 -0
  266. package/dist/owner-errors.mjs +216 -0
  267. package/dist/owner-lowering.mjs +206 -0
  268. package/dist/owner-scenarios.mjs +854 -0
  269. package/dist/ownership-model.d.mts +6 -0
  270. package/dist/ownership-model.mjs +143 -0
  271. package/dist/package-declarations.mjs +34 -0
  272. package/dist/paint-contrast.mjs +186 -0
  273. package/dist/palette-generated.mjs +101 -116
  274. package/dist/pictogram-model.mjs +13 -51
  275. package/dist/placeholder-contrast.mjs +35 -0
  276. package/dist/platform-features.mjs +401 -0
  277. package/dist/press-scale.mjs +26 -0
  278. package/dist/preview-bun.mjs +334 -404
  279. package/dist/preview-compile-inputs.mjs +78 -0
  280. package/dist/preview-contexts.mjs +7 -0
  281. package/dist/preview-controls.mjs +35 -0
  282. package/dist/preview-failure.mjs +20 -10
  283. package/dist/preview-files.mjs +18 -36
  284. package/dist/preview-imports.mjs +76 -70
  285. package/dist/preview-incremental.mjs +322 -222
  286. package/dist/preview-inputs.mjs +26 -26
  287. package/dist/preview-manifest-update.mjs +67 -49
  288. package/dist/preview-requests.mjs +10 -17
  289. package/dist/preview-resources.mjs +275 -323
  290. package/dist/preview-scope.mjs +15 -17
  291. package/dist/preview-source.mjs +182 -0
  292. package/dist/preview-spatial.mjs +27 -0
  293. package/dist/profile-macro.d.mts +56 -0
  294. package/dist/profile-macro.mjs +6 -0
  295. package/dist/profile-model.d.mts +65 -0
  296. package/dist/profile-model.mjs +213 -0
  297. package/dist/profile-view-facts.mjs +93 -0
  298. package/dist/program-cache.mjs +9 -7
  299. package/dist/project-boundary.mjs +8 -13
  300. package/dist/project-documents.mjs +25 -29
  301. package/dist/property-registrations.mjs +44 -35
  302. package/dist/prose-model.d.mts +81 -0
  303. package/dist/prose-model.mjs +101 -0
  304. package/dist/public-catalog.mjs +76 -0
  305. package/dist/recipe-defaults.mjs +117 -0
  306. package/dist/recipe-macro.d.mts +502 -0
  307. package/dist/recipe-macro.mjs +23 -0
  308. package/dist/recipe-model.d.mts +26 -0
  309. package/dist/recipe-model.mjs +214 -0
  310. package/dist/region-lowering.mjs +723 -0
  311. package/dist/registration-css.mjs +41 -0
  312. package/dist/registration-roles.mjs +35 -0
  313. package/dist/render-audit/axe-run.page.mjs +28 -0
  314. package/dist/render-audit/corner-overpaint.page.mjs +54 -0
  315. package/dist/render-audit/first-render.page.mjs +35 -0
  316. package/dist/render-audit/image-shape.page.mjs +42 -0
  317. package/dist/render-audit/layout-overflow.page.mjs +240 -0
  318. package/dist/render-audit/layout-shift.page.mjs +36 -0
  319. package/dist/render-audit/non-text-contrast.page.mjs +138 -0
  320. package/dist/render-audit/render-states.mjs +66 -293
  321. package/dist/render-audit/render-states.page.mjs +177 -0
  322. package/dist/render-audit/text-scale.mjs +42 -0
  323. package/dist/render-audit/text-scale.page.mjs +25 -0
  324. package/dist/render-audit/worker.mjs +130 -112
  325. package/dist/render-audit/worker.page.mjs +21 -0
  326. package/dist/render-audit.mjs +490 -500
  327. package/dist/resource-limits.mjs +174 -223
  328. package/dist/result.d.mts +34 -0
  329. package/dist/result.mjs +60 -0
  330. package/dist/role-vocabulary.d.mts +260 -0
  331. package/dist/role-vocabulary.mjs +258 -0
  332. package/dist/runtime-paint-contrast.mjs +97 -0
  333. package/dist/runtime-paint.mjs +42 -0
  334. package/dist/runtime-requirements.mjs +10 -11
  335. package/dist/runtime-style.mjs +21 -0
  336. package/dist/scenario-groups.mjs +42 -33
  337. package/dist/scenario-inspector.mjs +4 -4
  338. package/dist/scenario-kit.d.mts +85 -0
  339. package/dist/scenario-kit.mjs +18 -0
  340. package/dist/scenario-registry-model.mjs +2 -0
  341. package/dist/scenario-registry.mjs +89 -108
  342. package/dist/scenarios-compiler.mjs +875 -662
  343. package/dist/scheme-switch.d.mts +8 -0
  344. package/dist/scheme-switch.mjs +1 -0
  345. package/dist/showcase/ads-views.mjs +166 -0
  346. package/dist/showcase/assets-view.mjs +252 -0
  347. package/dist/showcase/client.bundle.js +211 -48
  348. package/dist/showcase/guide-controls.d.mts +28 -0
  349. package/dist/showcase/guide-controls.mjs +31 -0
  350. package/dist/showcase/http-client.bundle.js +172 -9
  351. package/dist/showcase/index.html +1 -1
  352. package/dist/showcase/preview-frame.css +18 -0
  353. package/dist/showcase/preview-frame.d.mts +5 -0
  354. package/dist/showcase/preview-frame.mjs +4 -0
  355. package/dist/showcase/preview-root.d.mts +2 -0
  356. package/dist/showcase/preview-root.mjs +9 -0
  357. package/dist/showcase/profiles-view.mjs +321 -0
  358. package/dist/showcase/project-rules.mjs +9 -0
  359. package/dist/showcase/sandbox.bundle.js +1 -1
  360. package/dist/showcase/scenario-page.d.mts +49 -0
  361. package/dist/showcase/scenario-page.mjs +105 -0
  362. package/dist/showcase/style.css +2 -0
  363. package/dist/showcase/token-sample.mjs +89 -0
  364. package/dist/showcase/tokens-view.mjs +233 -0
  365. package/dist/showcase/ui/apple-touch-icon-9zwv3w79.png +0 -0
  366. package/dist/showcase/{favicon.ico → ui/favicon-c2c9kvtf.ico} +0 -0
  367. package/dist/showcase/ui/icon-192-t5zh7mxx.png +0 -0
  368. package/dist/showcase/ui/icon-512-ed6yz0n0.png +0 -0
  369. package/dist/showcase/ui/ui.css +1 -1353
  370. package/dist/showcase/ui/ui.js +165 -1064
  371. package/dist/showcase-http-routes.mjs +28 -21
  372. package/dist/skills/README.md +28 -28
  373. package/dist/skills/ads-designer/README.md +1 -1
  374. package/dist/skills/ads-designer/SKILL.md +313 -551
  375. package/dist/skills/ads-designer/references/accessibility.md +162 -114
  376. package/dist/skills/ads-designer/references/atomic-styles.md +72 -277
  377. package/dist/skills/ads-designer/references/behaviors.md +144 -280
  378. package/dist/skills/ads-designer/references/branding.md +137 -222
  379. package/dist/skills/ads-designer/references/captures.md +13 -7
  380. package/dist/skills/ads-designer/references/cli.md +80 -63
  381. package/dist/skills/ads-designer/references/contracts.md +225 -286
  382. package/dist/skills/ads-designer/references/design-craft.md +2 -2
  383. package/dist/skills/ads-designer/references/design-data.md +299 -323
  384. package/dist/skills/ads-designer/references/drafts.md +83 -22
  385. package/dist/skills/ads-designer/references/evidence.md +2 -1
  386. package/dist/skills/ads-designer/references/forms.md +199 -0
  387. package/dist/skills/ads-designer/references/guarded-editing.md +37 -48
  388. package/dist/skills/ads-designer/references/layers.md +64 -76
  389. package/dist/skills/ads-designer/references/layout.md +224 -330
  390. package/dist/skills/ads-designer/references/mobile.md +2 -2
  391. package/dist/skills/ads-designer/references/motion.md +66 -25
  392. package/dist/skills/ads-designer/references/performance.md +55 -50
  393. package/dist/skills/ads-designer/references/pictograms.md +62 -127
  394. package/dist/skills/ads-designer/references/recipes.md +368 -0
  395. package/dist/skills/ads-designer/references/review.md +51 -95
  396. package/dist/skills/ads-designer/references/runtimes.md +34 -33
  397. package/dist/skills/ads-designer/references/scenarios.md +256 -216
  398. package/dist/skills/ads-designer/references/stress-test.md +13 -5
  399. package/dist/skills/ads-designer/references/validation.md +28 -21
  400. package/dist/skills/ads-designer/references/workflows.md +7 -5
  401. package/dist/skills/ads-import/SKILL.md +29 -29
  402. package/dist/skills/ads-import/references/atomic-styles.md +72 -277
  403. package/dist/skills/ads-import/references/behaviors.md +144 -280
  404. package/dist/skills/ads-import/references/branding.md +24 -41
  405. package/dist/skills/ads-import/references/captures.md +13 -7
  406. package/dist/skills/ads-import/references/cli.md +80 -63
  407. package/dist/skills/ads-import/references/compatibility.md +3 -3
  408. package/dist/skills/ads-import/references/contracts.md +225 -286
  409. package/dist/skills/ads-import/references/design-data.md +299 -323
  410. package/dist/skills/ads-import/references/drafts.md +83 -22
  411. package/dist/skills/ads-import/references/evidence.md +2 -1
  412. package/dist/skills/ads-import/references/forms.md +199 -0
  413. package/dist/skills/ads-import/references/guarded-editing.md +37 -48
  414. package/dist/skills/ads-import/references/implementation.md +20 -20
  415. package/dist/skills/ads-import/references/layers.md +64 -76
  416. package/dist/skills/ads-import/references/layout.md +224 -330
  417. package/dist/skills/ads-import/references/recipes.md +368 -0
  418. package/dist/skills/ads-import/references/review.md +51 -95
  419. package/dist/skills/ads-import/references/runtimes.md +34 -33
  420. package/dist/skills/ads-import/references/scenarios.md +256 -216
  421. package/dist/skills/ads-import/references/tokens.md +26 -17
  422. package/dist/skills/ads-import/references/validation.md +28 -21
  423. package/dist/skills/ads-import/references/workflows.md +7 -5
  424. package/dist/skills/ads-migrate/SKILL.md +20 -5
  425. package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +6 -0
  426. package/dist/skills/ads-migrate/references/0.4.7-to-0.5.0-boundary.md +71 -0
  427. package/dist/skills/ads-migrate/references/0.4.7-to-0.5.0-grid.md +204 -0
  428. package/dist/skills/ads-migrate/references/0.4.7-to-0.5.0.md +727 -0
  429. package/dist/skills/ads-migrate/references/0.5.0-to-0.5.1.md +239 -0
  430. package/dist/skills/ads-port/SKILL.md +27 -28
  431. package/dist/skills/ads-port/references/atomic-styles.md +72 -277
  432. package/dist/skills/ads-port/references/behaviors.md +144 -280
  433. package/dist/skills/ads-port/references/captures.md +13 -7
  434. package/dist/skills/ads-port/references/cli.md +80 -63
  435. package/dist/skills/ads-port/references/contracts.md +225 -286
  436. package/dist/skills/ads-port/references/design-data.md +299 -323
  437. package/dist/skills/ads-port/references/drafts.md +83 -22
  438. package/dist/skills/ads-port/references/evidence.md +2 -1
  439. package/dist/skills/ads-port/references/forms.md +199 -0
  440. package/dist/skills/ads-port/references/guarded-editing.md +37 -48
  441. package/dist/skills/ads-port/references/layers.md +64 -76
  442. package/dist/skills/ads-port/references/layout.md +224 -330
  443. package/dist/skills/ads-port/references/lint-and-docs.md +2 -3
  444. package/dist/skills/ads-port/references/native-implementation.md +23 -33
  445. package/dist/skills/ads-port/references/recipes.md +368 -0
  446. package/dist/skills/ads-port/references/review.md +51 -95
  447. package/dist/skills/ads-port/references/runtimes.md +34 -33
  448. package/dist/skills/ads-port/references/scenarios.md +256 -216
  449. package/dist/skills/ads-port/references/validation.md +28 -21
  450. package/dist/skills/ads-port/references/workflows.md +7 -5
  451. package/dist/source-inventory.mjs +33 -0
  452. package/dist/source-values.mjs +272 -262
  453. package/dist/spatial-css.mjs +403 -0
  454. package/dist/spatial-metadata.mjs +11 -11
  455. package/dist/spatial-model.mjs +438 -0
  456. package/dist/spatial-reading.mjs +127 -0
  457. package/dist/stage-timing.mjs +27 -0
  458. package/dist/state-conditions.d.mts +80 -0
  459. package/dist/state-conditions.mjs +107 -0
  460. package/dist/static-values.mjs +94 -0
  461. package/dist/surface-contrast.mjs +252 -0
  462. package/dist/surface-effects.mjs +98 -0
  463. package/dist/target-size.mjs +177 -0
  464. package/dist/task-cache.mjs +142 -136
  465. package/dist/task-worker.mjs +18 -18
  466. package/dist/test-boundaries.mjs +50 -189
  467. package/dist/token-checks.mjs +21 -0
  468. package/dist/token-dtcg.mjs +136 -0
  469. package/dist/token-expression.mjs +19 -0
  470. package/dist/token-inventory.mjs +146 -0
  471. package/dist/token-operations.mjs +37 -0
  472. package/dist/token-overlap.mjs +29 -0
  473. package/dist/token-provenance.mjs +260 -0
  474. package/dist/token-references.mjs +71 -0
  475. package/dist/token-registrations.mjs +116 -0
  476. package/dist/token-resolution.mjs +38 -0
  477. package/dist/token-sections.mjs +123 -0
  478. package/dist/token-shapes.mjs +121 -0
  479. package/dist/token-sheet-check.mjs +54 -0
  480. package/dist/token-type-check.mjs +89 -0
  481. package/dist/token-view-facts.mjs +111 -0
  482. package/dist/tsconfig.declarations.json +24 -0
  483. package/dist/types/css-tree.d.ts +45 -0
  484. package/dist/ui-framework.mjs +34 -34
  485. package/dist/units.mjs +186 -226
  486. package/dist/unknown.d.mts +9 -0
  487. package/dist/unknown.mjs +13 -0
  488. package/dist/unreached-sources.mjs +5 -0
  489. package/dist/validation-checks.mjs +62 -71
  490. package/dist/validation-inputs.mjs +209 -279
  491. package/dist/validation.mjs +132 -159
  492. package/dist/verification/browser.d.mts +21 -25
  493. package/dist/verification/browser.mjs +281 -124
  494. package/dist/verification/browser.page.d.mts +22 -0
  495. package/dist/verification/browser.page.mjs +19 -0
  496. package/dist/verification/paint-audit.page.d.mts +55 -0
  497. package/dist/verification/paint-audit.page.mjs +144 -0
  498. package/dist/verification/playwright-reporter.mjs +160 -0
  499. package/dist/verification/preview-startup.d.mts +51 -0
  500. package/dist/verification/preview-startup.mjs +76 -0
  501. package/dist/verification/request.d.mts +28 -0
  502. package/dist/verification/request.mjs +30 -0
  503. package/dist/verification/unit-preload.mjs +37 -0
  504. package/dist/verification.mjs +574 -607
  505. package/docs/ADS.md +585 -565
  506. package/docs/ARCHITECTURE.md +2002 -1384
  507. package/docs/ASSETS.md +487 -0
  508. package/docs/BEHAVIORS.md +339 -370
  509. package/docs/CACHING.md +365 -154
  510. package/docs/CHANGELOG.md +462 -21
  511. package/docs/COMPARISON.md +21 -26
  512. package/docs/DESIGN-REFERENCES.md +40 -27
  513. package/docs/GUIDE.md +2473 -1292
  514. package/docs/LANGUAGE.md +1159 -0
  515. package/docs/LOWERING.md +180 -0
  516. package/docs/MCP.md +1461 -1179
  517. package/docs/MOTION.md +491 -0
  518. package/docs/PROFILE-KINDS.md +544 -0
  519. package/docs/PROFILES.md +176 -0
  520. package/docs/RULES.md +590 -0
  521. package/docs/TOKEN-ROLES.md +377 -0
  522. package/docs/benchmarks/README.md +26 -27
  523. package/package.json +59 -45
  524. package/dist/a11y.mjs +0 -187
  525. package/dist/assets.mjs +0 -159
  526. package/dist/atomic-composition.mjs +0 -337
  527. package/dist/atomic-trace.mjs +0 -162
  528. package/dist/behavior-libraries.mjs +0 -174
  529. package/dist/behaviors.mjs +0 -306
  530. package/dist/brand-assets.mjs +0 -458
  531. package/dist/brands.mjs +0 -141
  532. package/dist/component-contrast.mjs +0 -256
  533. package/dist/construction-styles.cjs +0 -10
  534. package/dist/contracts/foundation.json +0 -211
  535. package/dist/contracts/tokens.json +0 -52
  536. package/dist/contracts.d.mts +0 -30
  537. package/dist/contrast-composition.mjs +0 -80
  538. package/dist/contrast-styles.mjs +0 -88
  539. package/dist/control-padding.mjs +0 -113
  540. package/dist/css-values.mjs +0 -27
  541. package/dist/declarative-flow.mjs +0 -244
  542. package/dist/design-values.mjs +0 -173
  543. package/dist/font-rules.mjs +0 -108
  544. package/dist/fonts-generated.mjs +0 -112
  545. package/dist/foundation-views.mjs +0 -242
  546. package/dist/foundation.mjs +0 -154
  547. package/dist/generated-entries.mjs +0 -198
  548. package/dist/html.mjs +0 -30
  549. package/dist/icons.mjs +0 -154
  550. package/dist/image-attributes.mjs +0 -187
  551. package/dist/image-size.mjs +0 -28
  552. package/dist/layers.mjs +0 -461
  553. package/dist/layout-widths.mjs +0 -332
  554. package/dist/linaria/atomic-css.cjs +0 -2
  555. package/dist/linaria/atomic-styled.cjs +0 -2
  556. package/dist/linaria/preserve-values.cjs +0 -58
  557. package/dist/linaria/spatial-inputs.cjs +0 -56
  558. package/dist/linaria.d.mts +0 -1
  559. package/dist/linaria.mjs +0 -9
  560. package/dist/lockup-composition.mjs +0 -44
  561. package/dist/lockup-model.cjs +0 -64
  562. package/dist/paint-contracts.mjs +0 -216
  563. package/dist/pictograms.mjs +0 -52
  564. package/dist/public-api.mjs +0 -121
  565. package/dist/public-props.mjs +0 -91
  566. package/dist/render-audit/axe-run.mjs +0 -17
  567. package/dist/render-audit/first-render.mjs +0 -40
  568. package/dist/render-audit/image-shape.mjs +0 -46
  569. package/dist/render-audit/layout-overflow.mjs +0 -167
  570. package/dist/render-audit/layout-shift.mjs +0 -32
  571. package/dist/render-audit/non-text-contrast.mjs +0 -151
  572. package/dist/render-audit/pictograms.mjs +0 -88
  573. package/dist/render-color-probe.mjs +0 -202
  574. package/dist/render-composition.mjs +0 -186
  575. package/dist/runtime-contracts.mjs +0 -506
  576. package/dist/scenario-program.mjs +0 -19
  577. package/dist/scenario-selectors.mjs +0 -237
  578. package/dist/scenario-slots.mjs +0 -217
  579. package/dist/scenario-trace.mjs +0 -314
  580. package/dist/scenarios-vite.d.mts +0 -2
  581. package/dist/scenarios-vite.mjs +0 -2
  582. package/dist/scenarios.mjs +0 -616
  583. package/dist/selector-match.mjs +0 -94
  584. package/dist/showcase/comparison.js +0 -48
  585. package/dist/showcase/connection.js +0 -10
  586. package/dist/showcase/draft-navigation.js +0 -59
  587. package/dist/showcase/foundation-view.css +0 -58
  588. package/dist/showcase/foundation-view.mjs +0 -255
  589. package/dist/showcase/guide-controls.ads.review.mjs +0 -32
  590. package/dist/showcase/http-connection.js +0 -86
  591. package/dist/showcase/http-preview.js +0 -81
  592. package/dist/showcase/icons.js +0 -2
  593. package/dist/showcase/navigation.js +0 -13
  594. package/dist/showcase/pictogram-view.mjs +0 -53
  595. package/dist/showcase/preview-frame.ads.review.css +0 -46
  596. package/dist/showcase/preview-frame.ads.review.d.mts +0 -11
  597. package/dist/showcase/preview-frame.ads.review.mjs +0 -22
  598. package/dist/showcase/preview-state.js +0 -11
  599. package/dist/showcase/refresh-scheduler.js +0 -23
  600. package/dist/showcase/resource-reader.js +0 -37
  601. package/dist/showcase-coverage.mjs +0 -139
  602. package/dist/source-symbols.mjs +0 -4
  603. package/dist/spatial-composition.mjs +0 -322
  604. package/dist/spatial-contexts.cjs +0 -56
  605. package/dist/spatial-css.cjs +0 -351
  606. package/dist/spatial-inputs.cjs +0 -80
  607. package/dist/spatial-model.cjs +0 -322
  608. package/dist/spatial.mjs +0 -21
  609. package/dist/stage-timing.cjs +0 -21
  610. package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +0 -105
  611. package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +0 -275
  612. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +0 -7
  613. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +0 -10
  614. package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +0 -8
  615. package/dist/starters/preact/ds.config.json +0 -37
  616. package/dist/starters/preact/package.json +0 -35
  617. package/dist/starters/preact/src/vite-env.d.ts +0 -7
  618. package/dist/starters/preact/tsconfig.json +0 -35
  619. package/dist/starters/preact/vite.config.ts +0 -23
  620. package/dist/starters/react/ADS.md +0 -286
  621. package/dist/starters/react/README.md +0 -184
  622. package/dist/starters/react/biome.css.json +0 -21
  623. package/dist/starters/react/design-system/assets/brand/README.md +0 -41
  624. package/dist/starters/react/design-system/assets/brand/app-icon.svg +0 -4
  625. package/dist/starters/react/design-system/assets/brand/logo.dark.svg +0 -6
  626. package/dist/starters/react/design-system/assets/brand/logo.svg +0 -6
  627. package/dist/starters/react/design-system/assets/glyphs/README.md +0 -15
  628. package/dist/starters/react/design-system/assets/glyphs/aliases.json +0 -1
  629. package/dist/starters/react/design-system/assets/glyphs/check.svg +0 -1
  630. package/dist/starters/react/design-system/assets/glyphs/chevron-down.svg +0 -1
  631. package/dist/starters/react/design-system/assets/glyphs/chevron-right.svg +0 -1
  632. package/dist/starters/react/design-system/assets/glyphs/close.svg +0 -1
  633. package/dist/starters/react/design-system/assets/glyphs/external-link.svg +0 -1
  634. package/dist/starters/react/design-system/assets/glyphs/info.svg +0 -1
  635. package/dist/starters/react/design-system/assets/glyphs/menu.svg +0 -1
  636. package/dist/starters/react/design-system/assets/glyphs/plus.svg +0 -1
  637. package/dist/starters/react/design-system/assets/glyphs/search.svg +0 -1
  638. package/dist/starters/react/design-system/assets/glyphs/warning.svg +0 -1
  639. package/dist/starters/react/design-system/assets/pictograms/catalog.ads.json +0 -13
  640. package/dist/starters/react/design-system/assets/pictograms/journey.dark.svg +0 -7
  641. package/dist/starters/react/design-system/assets/pictograms/journey.svg +0 -7
  642. package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +0 -1
  643. package/dist/starters/react/design-system/components/Actions/Button/Button.ads.fixture.ts +0 -1
  644. package/dist/starters/react/design-system/components/Actions/Button/Button.ads.scenario.tsx +0 -13
  645. package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +0 -56
  646. package/dist/starters/react/design-system/components/Actions/Button/README.md +0 -12
  647. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +0 -1
  648. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.fixture.ts +0 -9
  649. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.scenario.tsx +0 -16
  650. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +0 -60
  651. package/dist/starters/react/design-system/components/Actions/IconButton/README.md +0 -17
  652. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +0 -1
  653. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +0 -6
  654. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +0 -16
  655. package/dist/starters/react/design-system/components/Content/Icon/Icon.tsx +0 -42
  656. package/dist/starters/react/design-system/components/Content/Icon/README.md +0 -17
  657. package/dist/starters/react/design-system/components/Content/Icon/glyphs.ts +0 -17
  658. package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +0 -1
  659. package/dist/starters/react/design-system/components/Content/Image/Image.ads.fixture.ts +0 -2
  660. package/dist/starters/react/design-system/components/Content/Image/Image.ads.scenario.tsx +0 -13
  661. package/dist/starters/react/design-system/components/Content/Image/Image.tsx +0 -51
  662. package/dist/starters/react/design-system/components/Content/Image/README.md +0 -20
  663. package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +0 -1
  664. package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.fixture.ts +0 -1
  665. package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.scenario.tsx +0 -12
  666. package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +0 -35
  667. package/dist/starters/react/design-system/components/Content/Logo/README.md +0 -12
  668. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.exports.ts +0 -1
  669. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.fixture.ts +0 -1
  670. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.scenario.tsx +0 -7
  671. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.tsx +0 -26
  672. package/dist/starters/react/design-system/components/Forms/TextField/README.md +0 -14
  673. package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +0 -1
  674. package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.fixture.ts +0 -6
  675. package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.scenario.tsx +0 -13
  676. package/dist/starters/react/design-system/components/Forms/TextField/TextField.tsx +0 -61
  677. package/dist/starters/react/design-system/composition/Search/SearchPage/README.md +0 -4
  678. package/dist/starters/react/design-system/composition/Search/SearchPage/SearchPage.ads.fixture.ts +0 -7
  679. package/dist/starters/react/design-system/composition/Search/SearchPage/SearchPage.ads.scenario.tsx +0 -16
  680. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +0 -5
  681. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +0 -13
  682. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +0 -22
  683. package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +0 -1
  684. package/dist/starters/react/design-system/controllers/Palette/Palette.ts +0 -164
  685. package/dist/starters/react/design-system/index.ts +0 -12
  686. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +0 -1
  687. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +0 -7
  688. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +0 -15
  689. package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +0 -105
  690. package/dist/starters/react/design-system/patterns/Conversation/README.md +0 -9
  691. package/dist/starters/react/design-system/patterns/Search/SearchBar/README.md +0 -12
  692. package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +0 -1
  693. package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.fixture.ts +0 -1
  694. package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.scenario.tsx +0 -11
  695. package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.tsx +0 -41
  696. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +0 -5
  697. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +0 -21
  698. package/dist/starters/react/design-system/patterns/Shell/README.md +0 -43
  699. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +0 -1
  700. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +0 -5
  701. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +0 -21
  702. package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +0 -274
  703. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +0 -1
  704. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +0 -7
  705. package/dist/starters/react/design-system/review/index.ads.review.ts +0 -4
  706. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +0 -1
  707. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +0 -6
  708. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +0 -1
  709. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +0 -10
  710. package/dist/starters/react/design-system/showcase/mcp/main.ads.mount.tsx +0 -10
  711. package/dist/starters/react/design-system/styles.css +0 -7
  712. package/dist/starters/react/design-system/tokens/base.css +0 -36
  713. package/dist/starters/react/design-system/tokens/catalog.ads.json +0 -1221
  714. package/dist/starters/react/design-system/tokens/colors.css +0 -215
  715. package/dist/starters/react/design-system/tokens/elevation.css +0 -53
  716. package/dist/starters/react/design-system/tokens/spacing.css +0 -87
  717. package/dist/starters/react/design-system/tokens/spatial.ads.json +0 -70
  718. package/dist/starters/react/design-system/tokens/themes.generated.css +0 -142
  719. package/dist/starters/react/design-system/tokens/themes.generated.ts +0 -402
  720. package/dist/starters/react/design-system/tokens/typography.css +0 -31
  721. package/dist/starters/react/ds.config.json +0 -37
  722. package/dist/starters/react/gitignore.template +0 -8
  723. package/dist/starters/react/package.json +0 -39
  724. package/dist/starters/react/scripts/build-mcp-previews.mjs +0 -3
  725. package/dist/starters/react/src/vite-env.d.ts +0 -7
  726. package/dist/starters/react/tsconfig.build.json +0 -20
  727. package/dist/starters/react/tsconfig.json +0 -34
  728. package/dist/starters/react/vite.config.ts +0 -23
  729. package/dist/style-boundaries.mjs +0 -106
  730. package/dist/style-token-rules.mjs +0 -51
  731. package/dist/themes-generated.mjs +0 -161
  732. package/dist/themes-watch.mjs +0 -83
  733. package/dist/themes.mjs +0 -360
  734. package/dist/token-export.mjs +0 -94
  735. package/dist/token-origins.mjs +0 -24
  736. package/dist/token-policy.mjs +0 -26
  737. package/dist/token-quality.mjs +0 -149
  738. package/dist/token-samples.mjs +0 -19
  739. package/dist/tokens.mjs +0 -194
  740. package/dist/unit-contracts.mjs +0 -396
  741. package/dist/usage.mjs +0 -184
  742. package/dist/verification/playwright-reporter.cjs +0 -87
  743. package/docs/CONTRACTS.md +0 -285
  744. package/docs/HTTP-SHOWCASE-POC.md +0 -397
  745. package/docs/SPATIAL-CHECKS.md +0 -69
  746. package/docs/benchmarks/http-showcase-optimized.json +0 -1879
  747. package/docs/benchmarks/http-showcase-profile.json +0 -308
  748. package/docs/benchmarks/http-showcase.json +0 -3069
  749. /package/dist/{starters/react/design-system/assets/fonts/.gitkeep → analysis/semantic.mjs} +0 -0
  750. /package/dist/{starters/react/design-system/controllers/.gitkeep → lowering-model.mjs} +0 -0
  751. /package/dist/showcase/{favicon.svg → ui/favicon-scavmehf.svg} +0 -0
@@ -1,90 +1,47 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { analyze } from "./analysis/service.mjs";
3
3
  import { createRequire } from "node:module";
4
+ import { adsPlaywright, browserInstallCommand, ensureBrowser } from "./browser-runtime.mjs";
4
5
  import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
5
6
  import path from "node:path";
6
7
  import { fileURLToPath } from "node:url";
7
8
  import { loadConfig } from "./config.mjs";
8
-
9
- import { executeDevelopmentCommand } from "./verification.mjs";
9
+ import { designContextsOrThrow } from "./design-contexts.mjs";
10
+ import { executeDevelopmentCommand, affectedScenarios } from "./verification.mjs";
10
11
  import { findingSeverity, routeFindings } from "./finding-rules.mjs";
11
- import { inspectScenarios } from "./scenarios.mjs";
12
+ import { discoverScenarioRegistry, parseScenarioRegistry } from "./scenario-registry.mjs";
12
13
  import { inspectUnits } from "./units.mjs";
13
- import { globMatcher } from "./layout-widths.mjs";
14
- import { affectedScenarios } from "./verification.mjs";
15
- import { pictogramFindings } from "./render-audit/pictograms.mjs";
16
-
17
- // Render audit: axe-core (Deque, MPL-2.0, an unmodified ADS dependency
18
- // injected at run time, never bundled) runs inside each rendered scenario document, once per
19
- // declared brand and theme, followed by ADS's own non-text contrast check (WCAG 1.4.11),
20
- // which axe does not cover, and its layout-overflow check, which resizes the same page. Only the scenario's #root is audited; the preview status chrome is excluded.
21
- // Findings are errors: they fail `ads audit`, ads_validate (which audits everything its change set
22
- // reaches) and draft acceptance (the draft owners' scenarios, unless acceptance.audit is false).
23
- // Automated rules catch a subset of WCAG failures; passing proves nothing more.
24
-
25
- export const AUDIT_RULE = "a11y-axe";
26
- /** What axe could not decide on its own, such as contrast over a gradient: to check by hand. */
27
- export const INCOMPLETE_RULE = "a11y-incomplete";
28
- /** ADS's own rendered check: WCAG 1.4.11 non-text contrast of control boundaries and icons (axe does not check it). */
29
- export const NON_TEXT_RULE = "a11y-non-text-contrast";
30
- /** ADS's own rendered layout check: horizontal overflow at each of overflowWidths. */
31
- export const OVERFLOW_RULE = "layout-overflow";
32
- export const NARROW_RULE = "layout-overflow-narrow";
33
- /** ADS's own rendered check: a scenario's layout shift above the Core Web Vitals 0.1 threshold. */
34
- export const SHIFT_RULE = "layout-shift";
14
+ import { notAvailable } from "./availability.mjs";
15
+ import { reportedDeclarations } from "./accessibility-declarations.mjs";
16
+ import { isRecord } from "./unknown.mjs";
17
+ export const AUDIT_RULE = "a11y-axe", INCOMPLETE_RULE = "a11y-incomplete", NON_TEXT_RULE = "a11y-non-text-contrast", DECLARED_BOUNDARY_RULE = "a11y-boundary-declared", OVERFLOW_RULE = "layout-overflow", NARROW_RULE = "layout-overflow-narrow", TEXT_SCALE_RULE = "a11y-text-scale", TEXT_SPACING_RULE = "a11y-text-spacing-override", REFLOW_RULE = "a11y-reflow", textWidths = Object.freeze({ reflow: 320, zoom: 640 }), SHIFT_RULE = "layout-shift";
35
18
  const shiftLimit = 0.1;
36
- /** WCAG A/AA rule tags. Best-practice and page-level rules (landmarks, one h1) don't fit isolated scenarios. */
37
19
  export const auditTags = Object.freeze(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]);
38
20
  const viewport = { width: 1280, height: 800 };
39
- /** Viewport widths layout-overflow renders every scenario at: phone, tablet and desktop. */
40
- export const overflowWidths = Object.freeze([390, 768, 1280]);
41
- export const auditedKinds = Object.freeze(["components", "patterns", "composition"]);
42
- /** The width layout-overflow also renders scenarios of these kinds at, inside the widest viewport
43
- * and in the first theme, since layout does not follow color: a narrow side pane. A composition is
44
- * a whole screen, and is never hosted in one. */
45
- export const containerWidth = 240;
46
- export const containerKinds = Object.freeze(["components", "patterns"]);
47
- /** Attempts for one render, against a dropped preview connection or a slow preview. */
48
- export const auditAttempts = 3;
49
- /** overlays and controls bound what each render opens and hovers: distinct ones, in document order. */
50
- const limits = { scenarios: 500, nodes: 5, findings: 2000, reportBytes: 8 * 1024 * 1024, overlays: 3, controls: 6, contentQuietMs: 500, contentLimitMs: 5000 };
51
-
52
- /** WCAG success criteria named by axe tags such as wcag143 or wcag1412. */
21
+ export const overflowWidths = Object.freeze([390, 768, 1280]), auditedKinds = Object.freeze(["components", "patterns"]), containerWidth = 240, containerKinds = Object.freeze(["components", "patterns"]), auditAttempts = 3;
22
+ const limits = { scenarios: 500, nodes: 5, findings: 2000, reportBytes: 8388608, overlays: 3, controls: 6, contentQuietMs: 500, contentLimitMs: 5000 }, fileMap = (scenarios) => new Map(scenarios.map((scenario) => [scenario.id, scenario.file])), addOnce = (list, value) => {
23
+ if (value !== void 0 && !list.includes(value))
24
+ list.push(value);
25
+ }, where = (themes, brands) => `[${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]`;
53
26
  export function wcagCriteria(tags) {
54
27
  return [
55
- ...new Set(
56
- tags
57
- .map((tag) => tag.match(/^wcag(\d)(\d)(\d{1,2})$/))
58
- .filter(Boolean)
59
- .map(([, a, b, c]) => `${a}.${b}.${c}`),
60
- ),
28
+ ...new Set(tags.flatMap((tag) => {
29
+ const match = tag.match(/^wcag(\d)(\d)(\d{1,2})$/);
30
+ return match ? [`${match[1]}.${match[2]}.${match[3]}`] : [];
31
+ }))
61
32
  ];
62
33
  }
63
-
64
- /** Collapse per-brand, per-theme axe violations into ADS errors: one per scenario, rule and failing element set. */
65
34
  export function auditFindings(runs, scenarios) {
66
- const files = new Map(scenarios.map((scenario) => [scenario.id, scenario.file])),
67
- groups = new Map();
68
- const add = (list, value) => {
69
- if (value !== undefined && !list.includes(value)) list.push(value);
70
- };
35
+ const files = fileMap(scenarios), groups = new Map;
71
36
  for (const run of runs)
72
- for (const violation of run.violations) {
73
- const selectors = violation.nodes.map((node) => node.selector);
74
- const key = JSON.stringify([run.scenario, violation.id, [...selectors].sort()]);
75
- const group = groups.get(key) ?? { scenario: run.scenario, themes: [], brands: [], violation };
37
+ for (const violation of run.violations ?? []) {
38
+ const selectors = violation.nodes.map((node) => node.selector), key = JSON.stringify([run.scenario, violation.id, [...selectors].sort()]), group = groups.get(key) ?? { scenario: run.scenario, themes: [], brands: [], violation };
76
39
  groups.set(key, group);
77
- add(group.themes, run.theme);
78
- add(group.brands, run.brand);
40
+ addOnce(group.themes, run.theme);
41
+ addOnce(group.brands, run.brand);
79
42
  }
80
43
  return [...groups.values()].slice(0, limits.findings).map(({ scenario, themes, brands, violation }) => {
81
- const wcag = wcagCriteria(violation.tags),
82
- contrast = violation.id === "color-contrast";
83
- const where =
84
- violation.nodes
85
- .map((node) => node.selector)
86
- .slice(0, 3)
87
- .join(", ") + (violation.nodeCount > 3 ? ` and ${violation.nodeCount - 3} more` : "");
44
+ const wcag = wcagCriteria(violation.tags), contrast = violation.id === "color-contrast", elements = violation.nodes.map((node) => node.selector).slice(0, 3).join(", ") + (violation.nodeCount > 3 ? ` and ${violation.nodeCount - 3} more` : "");
88
45
  return {
89
46
  rule: AUDIT_RULE,
90
47
  severity: findingSeverity(AUDIT_RULE),
@@ -98,38 +55,27 @@ export function auditFindings(runs, scenarios) {
98
55
  tags: violation.tags,
99
56
  scenario,
100
57
  themes,
101
- ...(brands.length ? { brands } : {}),
58
+ ...brands.length ? { brands } : {},
102
59
  nodes: violation.nodes,
103
60
  nodeCount: violation.nodeCount,
104
61
  helpUrl: violation.helpUrl,
105
62
  guidanceUri: "ads://guides/accessibility",
106
- ...(contrast ? { overlaps: "token-contrast" } : {}),
107
- message: `${contrast ? "Rendered contrast (render audit; token-contrast checks declared token pairs statically): " : ""}axe ${violation.id}${violation.impact ? ` (${violation.impact})` : ""}${wcag.length ? `, WCAG ${wcag.join("/")}` : ""} in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${violation.help}. ${violation.nodeCount} element${violation.nodeCount === 1 ? "" : "s"}: ${where}. ${violation.helpUrl}`,
63
+ ...contrast ? { overlaps: ["surface-contrast", "component-contrast"] } : {},
64
+ message: `${contrast ? "Rendered contrast (render audit; surface-contrast checks surface profiles' paint pairs and component-contrast composed pairs statically): " : ""}axe ${violation.id}${violation.impact ? ` (${violation.impact})` : ""}${wcag.length ? `, WCAG ${wcag.join("/")}` : ""} in ${scenario} ${where(themes, brands)}: ${violation.help}. ${violation.nodeCount} element${violation.nodeCount === 1 ? "" : "s"}: ${elements}. ${violation.helpUrl}`
108
65
  };
109
66
  });
110
67
  }
111
-
112
- /** One info item per scenario, axe rule and element set, across brands and themes. */
113
68
  export function incompleteFindings(runs, scenarios) {
114
- const files = new Map(scenarios.map((scenario) => [scenario.id, scenario.file])),
115
- groups = new Map();
116
- const add = (list, value) => {
117
- if (value !== undefined && !list.includes(value)) list.push(value);
118
- };
69
+ const files = fileMap(scenarios), groups = new Map;
119
70
  for (const run of runs)
120
71
  for (const item of run.incomplete ?? []) {
121
- const key = JSON.stringify([run.scenario, item.id, item.nodes.map((node) => node.selector).sort()]);
122
- const group = groups.get(key) ?? { scenario: run.scenario, themes: [], brands: [], item };
72
+ const key = JSON.stringify([run.scenario, item.id, item.nodes.map((node) => node.selector).sort()]), group = groups.get(key) ?? { scenario: run.scenario, themes: [], brands: [], item };
123
73
  groups.set(key, group);
124
- add(group.themes, run.theme);
125
- add(group.brands, run.brand);
74
+ addOnce(group.themes, run.theme);
75
+ addOnce(group.brands, run.brand);
126
76
  }
127
77
  return [...groups.values()].slice(0, limits.findings).map(({ scenario, themes, brands, item }) => {
128
- const where =
129
- item.nodes
130
- .slice(0, 3)
131
- .map((node) => `${node.selector}${node.reason ? ` (${node.reason})` : ""}`)
132
- .join(", ") + (item.nodeCount > 3 ? ` and ${item.nodeCount - 3} more` : "");
78
+ const elements = item.nodes.slice(0, 3).map((node) => `${node.selector}${node.reason ? ` (${node.reason})` : ""}`).join(", ") + (item.nodeCount > 3 ? ` and ${item.nodeCount - 3} more` : "");
133
79
  return {
134
80
  rule: INCOMPLETE_RULE,
135
81
  severity: findingSeverity(INCOMPLETE_RULE),
@@ -141,66 +87,96 @@ export function incompleteFindings(runs, scenarios) {
141
87
  impact: item.impact ?? null,
142
88
  scenario,
143
89
  themes,
144
- ...(brands.length ? { brands } : {}),
90
+ ...brands.length ? { brands } : {},
145
91
  nodes: item.nodes,
146
92
  nodeCount: item.nodeCount,
147
93
  helpUrl: item.helpUrl,
148
94
  guidanceUri: "ads://guides/accessibility",
149
- message: `axe could not decide ${item.id} in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: check it by hand. ${item.help}. ${item.nodeCount} element${item.nodeCount === 1 ? "" : "s"}: ${where}. ${item.helpUrl}`,
95
+ message: `axe could not decide ${item.id} in ${scenario} ${where(themes, brands)}: check it by hand. ${item.help}. ${item.nodeCount} element${item.nodeCount === 1 ? "" : "s"}: ${elements}. ${item.helpUrl}`
150
96
  };
151
97
  });
152
98
  }
153
-
154
99
  const nonTextKinds = {
155
100
  border: {
156
- what: (count) => (count === 1 ? "control's border is its only boundary and has" : "controls' borders are their only boundary and have"),
101
+ what: (count) => count === 1 ? "control's border is its only boundary and has" : "controls' borders are their only boundary and have",
157
102
  against: "the background around it",
158
- fix: "Give the boundary a border token with 3:1 against the surface it sits on, such as --border-strong, or a background with 3:1 against it.",
103
+ fix: "Give the boundary a border token with 3:1 against the surface it sits on, such as --border-strong, or a background with 3:1 against it."
159
104
  },
160
105
  icon: {
161
- what: (count) => (count === 1 ? "icon-only control's icon has" : "icon-only controls' icons have"),
106
+ what: (count) => count === 1 ? "icon-only control's icon has" : "icon-only controls' icons have",
162
107
  against: "its control's background",
163
- fix: "Paint the icon with a text or foreground token that has 3:1 against the control's background.",
108
+ fix: "Paint the icon with a text or foreground token that has 3:1 against the control's background."
164
109
  },
165
110
  focus: {
166
- what: (count) => (count === 1 ? "control's focus outline has" : "controls' focus outlines have"),
111
+ what: (count) => count === 1 ? "control's focus outline has" : "controls' focus outlines have",
167
112
  against: "the background around it",
168
- fix: "Paint the focus outline with --border-focus or a token with 3:1 against the surface it sits on.",
169
- },
113
+ fix: "Paint the focus outline with --border-focus or a token with 3:1 against the surface it sits on."
114
+ }
170
115
  };
171
-
172
- /** Collapse per-brand, per-theme non-text contrast issues into ADS errors: one per scenario, kind
173
- * and failing element set, keeping each element's lowest ratio. */
116
+ export const declaredControls = (report) => reportedDeclarations(report).map(({ file, selector, boundary }) => ({ file, selector, boundary }));
117
+ export function declaredBoundaryFindings(runs, scenarios, root) {
118
+ const files = fileMap(scenarios), groups = new Map;
119
+ for (const run of runs)
120
+ for (const hit of run.nonText?.declared ?? []) {
121
+ const key = JSON.stringify([run.scenario, hit.file, hit.part, hit.selector]), group = groups.get(key) ?? { scenario: run.scenario, hit, themes: [], brands: [], ratio: hit.ratio, evidence: [], unlabelled: [] };
122
+ groups.set(key, group);
123
+ addOnce(group.themes, run.theme);
124
+ addOnce(group.brands, run.brand);
125
+ group.ratio = Math.min(group.ratio, hit.ratio);
126
+ for (const file of hit.evidence ?? [])
127
+ group.evidence.push(path.relative(root, file).split(path.sep).join("/"));
128
+ if (hit.labelled === !1)
129
+ addOnce(group.unlabelled, `${run.theme}${run.brand ? `/${run.brand}` : ""}`);
130
+ }
131
+ return [...groups.values()].slice(0, limits.findings).flatMap(({ scenario, hit, themes, brands, ratio, evidence, unlabelled }) => {
132
+ const common = { file: files.get(scenario) ?? scenario, line: 1, column: 1, source: "ads", scenario, themes, ...brands.length ? { brands } : {}, ratio, guidanceUri: "ads://guides/accessibility" }, kind = hit.boundary === "visible-label" ? "its visible label" : "a boundary shown on hover and focus", listed = {
133
+ ...common,
134
+ rule: DECLARED_BOUNDARY_RULE,
135
+ severity: findingSeverity(DECLARED_BOUNDARY_RULE),
136
+ kind: "declared",
137
+ wcag: ["1.4.11"],
138
+ nodes: [{ selector: hit.selector, ratio, owner: hit.file, part: hit.part, boundary: hit.boundary }],
139
+ nodeCount: 1,
140
+ ...evidence.length ? { evidence } : {},
141
+ message: `Declared boundary in ${scenario} ${where(themes, brands)}: ${hit.selector} (${hit.part} of ${hit.file}) has a boundary below 3:1 (${ratio.toFixed(2)}:1) and is declared identified by ${kind}. A person approved this; check the screenshots${evidence.length ? ` (${evidence.length} files under .ds/audit-evidence)` : ""} still match the reason.`
142
+ };
143
+ if (!unlabelled.length)
144
+ return [listed];
145
+ return [
146
+ listed,
147
+ {
148
+ ...common,
149
+ rule: NON_TEXT_RULE,
150
+ severity: findingSeverity(NON_TEXT_RULE),
151
+ kind: "declaration-unmet",
152
+ wcag: ["1.4.11", "1.3.1"],
153
+ nodes: [{ selector: hit.selector, ratio, owner: hit.file, part: hit.part, boundary: hit.boundary }],
154
+ nodeCount: 1,
155
+ message: `Declared boundary not met in ${scenario} [${unlabelled.join(", ")}]: ${hit.selector} (${hit.part} of ${hit.file}) declares "visible-label" but has no rendered, associated label (<label for>, a wrapping <label> or aria-labelledby to visible text). Show its label, or remove the declaration and give the field a 3:1 boundary.`
156
+ }
157
+ ];
158
+ });
159
+ }
174
160
  export function nonTextContrastFindings(runs, scenarios) {
175
- const files = new Map(scenarios.map((scenario) => [scenario.id, scenario.file])),
176
- groups = new Map();
177
- const add = (list, value) => {
178
- if (value !== undefined && !list.includes(value)) list.push(value);
179
- };
161
+ const files = fileMap(scenarios), groups = new Map;
180
162
  for (const run of runs)
181
163
  for (const kind of Object.keys(nonTextKinds)) {
182
164
  const issues = (run.nonText?.issues ?? []).filter((issue) => issue.kind === kind);
183
- if (!issues.length) continue;
184
- const key = JSON.stringify([run.scenario, kind, issues.map((issue) => issue.selector).sort()]);
185
- const group = groups.get(key) ?? { scenario: run.scenario, kind, themes: [], brands: [], nodes: new Map(), nodeCount: 0 };
165
+ if (!issues.length)
166
+ continue;
167
+ const key = JSON.stringify([run.scenario, kind, issues.map((issue) => issue.selector).sort()]), group = groups.get(key) ?? { scenario: run.scenario, kind, themes: [], brands: [], nodes: new Map, nodeCount: 0 };
186
168
  groups.set(key, group);
187
- add(group.themes, run.theme);
188
- add(group.brands, run.brand);
189
- group.nodeCount = Math.max(group.nodeCount, run.nonText.counts?.[kind] ?? issues.length);
169
+ addOnce(group.themes, run.theme);
170
+ addOnce(group.brands, run.brand);
171
+ group.nodeCount = Math.max(group.nodeCount, run.nonText?.counts[kind] ?? issues.length);
190
172
  for (const issue of issues) {
191
- const previous = group.nodes.get(issue.selector);
192
- if (!previous || issue.ratio < previous.ratio)
193
- group.nodes.set(issue.selector, { ...issue, theme: run.theme, ...(run.brand ? { brand: run.brand } : {}) });
173
+ const ratio = issue.ratio ?? 0, previous = group.nodes.get(issue.selector);
174
+ if (!previous || ratio < previous.ratio)
175
+ group.nodes.set(issue.selector, { ...issue, ratio, theme: run.theme, ...run.brand ? { brand: run.brand } : {} });
194
176
  }
195
177
  }
196
178
  return [...groups.values()].slice(0, limits.findings).map(({ scenario, kind, themes, brands, nodes, nodeCount }) => {
197
- const list = [...nodes.values()],
198
- ratio = Math.min(...list.map((node) => node.ratio));
199
- const where =
200
- list
201
- .slice(0, 3)
202
- .map((node) => `${node.selector} (${node.ratio.toFixed(2)}:1, ${node.foreground} on ${node.background})`)
203
- .join(", ") + (nodeCount > 3 ? ` and ${nodeCount - 3} more` : "");
179
+ const list = [...nodes.values()], ratio = Math.min(...list.map((node) => node.ratio)), elements = list.slice(0, 3).map((node) => `${node.selector} (${node.ratio.toFixed(2)}:1, ${node.foreground} on ${node.background})`).join(", ") + (nodeCount > 3 ? ` and ${nodeCount - 3} more` : "");
204
180
  return {
205
181
  rule: NON_TEXT_RULE,
206
182
  severity: findingSeverity(NON_TEXT_RULE),
@@ -212,16 +188,15 @@ export function nonTextContrastFindings(runs, scenarios) {
212
188
  wcag: ["1.4.11"],
213
189
  scenario,
214
190
  themes,
215
- ...(brands.length ? { brands } : {}),
191
+ ...brands.length ? { brands } : {},
216
192
  ratio,
217
193
  nodes: list,
218
194
  nodeCount,
219
195
  guidanceUri: "ads://guides/accessibility",
220
- message: `Non-text contrast (WCAG 1.4.11) in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${nodeCount} ${nonTextKinds[kind].what(nodeCount)} less than 3:1 against ${nonTextKinds[kind].against}: ${where}. ${nonTextKinds[kind].fix}`,
196
+ message: `Non-text contrast (WCAG 1.4.11) in ${scenario} ${where(themes, brands)}: ${nodeCount} ${nonTextKinds[kind].what(nodeCount)} less than 3:1 against ${nonTextKinds[kind].against}: ${elements}. ${nonTextKinds[kind].fix}`
221
197
  };
222
198
  });
223
199
  }
224
-
225
200
  const skipReasons = {
226
201
  "overlay-did-not-open": "a control with aria-haspopup opened nothing with a dialog, menu or listbox role",
227
202
  "overlay-trigger-gone": "a trigger left the page before its turn",
@@ -236,92 +211,135 @@ const skipReasons = {
236
211
  "control-failed": "measuring a control failed",
237
212
  "control-cap": "the limit of 6 controls per render was reached and no other scenario has them",
238
213
  "content-still-changing": "the page kept changing past 5 s, so what it measured may be mid-change",
239
- "focus-not-reachable": "a control a keyboard cannot reach (aria-hidden, inert, or tabindex -1 outside a roving widget): hover measured, focus not",
240
- };
241
-
242
- const overflowKinds = {
214
+ "focus-not-reachable": "a control a keyboard cannot reach (aria-hidden, inert, or tabindex -1 outside a roving widget): hover measured, focus not"
215
+ }, overflowKinds = {
243
216
  document: {
244
217
  what: "the page scrolls horizontally",
245
- fix: "Find the element wider than its container; use fluid widths, min-width: 0 on flex and grid children, and let long text wrap.",
218
+ fix: "Find the element wider than its container; use fluid widths, min-width: 0 on flex and grid children, and let long text wrap."
246
219
  },
247
220
  viewport: {
248
221
  what: "content reaches past the viewport",
249
- fix: "Make the element fluid (%, fr, a --grid-span-N token in a container query), wrap it, or put it in an overflow-x: auto scroller.",
222
+ fix: "Make the element fluid (%, fr, or a span of its owner's grid tracks instead of a fixed width; a container-context grid where it must follow its region), wrap it, or put it in an overflow-x: auto scroller."
250
223
  },
251
224
  container: {
252
225
  what: "content reaches past its container",
253
- fix: "Make the element fluid (%, fr, min(100%, ...)), wrap it, or put it in an overflow-x: auto scroller. A width that truly stays this wide only fits an overlay: list its owner in layout.fixedWidthUnits.",
226
+ fix: "Make the element fluid (%, fr, min(100%, ...)), wrap it, or put it in an overflow-x: auto scroller."
254
227
  },
255
228
  clipped: {
256
- what: "content is cut off by overflow hidden or clip",
257
- fix: "Make the content fit, truncate it with text-overflow: ellipsis, or use overflow-x: auto if it should scroll.",
229
+ what: "text or a control is cut off by overflow hidden or clip (cropped images, artwork and decorative layers do not count)",
230
+ fix: "Make the content fit, truncate it with text-overflow: ellipsis, or use overflow-x: auto if it should scroll."
231
+ },
232
+ "block-clipped": {
233
+ what: "text or a control is cut off by overflow hidden or clip on the block axis",
234
+ fix: "Let the box grow with its text: drop the fixed block size or use min-block-size, or scroll it with overflow-y: auto."
235
+ },
236
+ spilled: {
237
+ what: "content spills past a box whose block size does not grow with its text",
238
+ fix: "Replace the fixed height or max-height with min-block-size, or size it in rem or lh so it follows the text."
258
239
  },
240
+ overlap: {
241
+ what: "items overlap, grown past the track or line reserved for them",
242
+ fix: "Size the reserved track or row with auto, min-content or minmax(<size>, auto) instead of a fixed length, so it grows with its text."
243
+ },
244
+ "focus-clipped": {
245
+ what: "a control or its focus outline is cut off by a clipping ancestor",
246
+ fix: "Leave room for the outline (padding at least the focus width plus offset) or move overflow hidden off the control's ancestor; let the clipping box grow."
247
+ }
259
248
  };
260
-
261
- /** Collapse overflow issues into ADS errors: one per scenario, kind and failing element set, with
262
- * the widths, themes and brands it fails in. */
263
- export function layoutOverflowFindings(runs, scenarios) {
264
- const files = new Map(scenarios.map((scenario) => [scenario.id, scenario.file])),
265
- groups = new Map();
266
- const add = (list, value) => {
267
- if (value !== undefined && !list.includes(value)) list.push(value);
268
- };
269
- for (const run of runs)
270
- for (const { width, container = false, issues = [], counts = {} } of run.layout ?? [])
271
- for (const kind of Object.keys(overflowKinds)) {
272
- const found = issues.filter((issue) => issue.kind === kind);
273
- if (!found.length) continue;
274
- const key = JSON.stringify([run.scenario, kind, container, found.map((issue) => issue.selector).sort()]);
275
- const group = groups.get(key) ?? { scenario: run.scenario, kind, container, widths: [], themes: [], brands: [], nodes: new Map(), nodeCount: 0 };
276
- groups.set(key, group);
277
- add(group.widths, width);
278
- add(group.themes, run.theme);
279
- add(group.brands, run.brand);
280
- group.nodeCount = Math.max(group.nodeCount, counts[kind] ?? found.length);
281
- for (const issue of found) if (!(group.nodes.get(issue.selector)?.overflow >= issue.overflow)) group.nodes.set(issue.selector, { ...issue, width });
249
+ function groupLayout(entries) {
250
+ const groups = new Map;
251
+ for (const { run, tag, width, result } of entries)
252
+ for (const kind of Object.keys(overflowKinds)) {
253
+ const found = result.issues.filter((issue) => issue.kind === kind);
254
+ if (!found.length)
255
+ continue;
256
+ const key = JSON.stringify([run.scenario, tag, kind, found.map((issue) => issue.selector).sort()]), group = groups.get(key) ?? { scenario: run.scenario, tag, kind, widths: [], themes: [], brands: [], nodes: new Map, nodeCount: 0 };
257
+ groups.set(key, group);
258
+ addOnce(group.widths, width);
259
+ addOnce(group.themes, run.theme);
260
+ addOnce(group.brands, run.brand);
261
+ group.nodeCount = Math.max(group.nodeCount, result.counts[kind] ?? found.length);
262
+ for (const issue of found) {
263
+ const previous = group.nodes.get(issue.selector);
264
+ if (!(previous && previous.overflow >= issue.overflow))
265
+ group.nodes.set(issue.selector, { ...issue, width });
282
266
  }
283
- return [...groups.values()].slice(0, limits.findings).map(({ scenario, kind, container, widths, themes, brands, nodes, nodeCount }) => {
284
- const list = [...nodes.values()],
285
- sorted = [...widths].sort((a, b) => a - b);
286
- const where =
287
- list
288
- .slice(0, 3)
289
- .map((node) => `${node.selector} (${node.overflow}px at ${node.width}px)`)
290
- .join(", ") + (nodeCount > 3 ? ` and ${nodeCount - 3} more` : "");
267
+ }
268
+ return [...groups.values()].slice(0, limits.findings);
269
+ }
270
+ const layoutElements = ({ nodes, nodeCount }) => [...nodes.values()].slice(0, 3).map((node) => `${node.selector} (${node.overflow}px at ${node.width}px${node.cut ? `, cutting ${node.cut.content === "text" ? "text" : "a control"} at ${node.cut.selector}` : ""})`).join(", ") + (nodeCount > 3 ? ` and ${nodeCount - 3} more` : "");
271
+ export function layoutOverflowFindings(runs, scenarios) {
272
+ const files = fileMap(scenarios), entries = runs.flatMap((run) => (run.layout ?? []).map(({ width, container = !1, issues = [], counts = {} }) => ({
273
+ run,
274
+ tag: container ? NARROW_RULE : OVERFLOW_RULE,
275
+ width,
276
+ result: { issues, counts }
277
+ })));
278
+ return groupLayout(entries).map((group) => {
279
+ const { scenario, tag: rule, kind, widths, themes, brands, nodes, nodeCount } = group, container = rule === NARROW_RULE, sorted = [...widths].sort((a, b) => a - b);
291
280
  return {
292
- rule: container ? NARROW_RULE : OVERFLOW_RULE,
293
- severity: findingSeverity(container ? NARROW_RULE : OVERFLOW_RULE),
281
+ rule,
282
+ severity: findingSeverity(rule),
294
283
  file: files.get(scenario) ?? scenario,
295
284
  line: 1,
296
285
  column: 1,
297
286
  source: "ads",
298
287
  kind,
299
- ...(container ? { container: sorted[0] } : { widths: sorted }),
288
+ ...container ? { container: sorted[0] } : { widths: sorted },
300
289
  scenario,
301
290
  themes,
302
- ...(brands.length ? { brands } : {}),
303
- nodes: list,
291
+ ...brands.length ? { brands } : {},
292
+ nodes: [...nodes.values()],
304
293
  nodeCount,
305
294
  guidanceUri: "ads://guides/tokens",
306
- message: `Layout overflow in ${scenario} ${container ? `in a ${sorted[0]} px container` : `at ${sorted.join(", ")} px wide`} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${overflowKinds[kind].what}: ${where}. ${overflowKinds[kind].fix}`,
295
+ message: `Layout overflow in ${scenario} ${container ? `in a ${sorted[0]} px container` : `at ${sorted.join(", ")} px wide`} ${where(themes, brands)}: ${overflowKinds[kind].what}: ${layoutElements(group)}. ${overflowKinds[kind].fix}`
296
+ };
297
+ });
298
+ }
299
+ const textPasses = {
300
+ font: { rule: TEXT_SCALE_RULE, wcag: "1.4.4", title: "Text resize", setting: (width) => `with text at 200% at ${width} px wide` },
301
+ zoom: { rule: TEXT_SCALE_RULE, wcag: "1.4.4", title: "Zoom", setting: (width) => `zoomed to 200% (a ${width} px viewport)` },
302
+ spacing: {
303
+ rule: TEXT_SPACING_RULE,
304
+ wcag: "1.4.12",
305
+ title: "Text spacing",
306
+ setting: (width) => `with line height 1.5, letter spacing 0.12em, word spacing 0.16em and 2em after paragraphs at ${width} px wide`
307
+ },
308
+ reflow: { rule: REFLOW_RULE, wcag: "1.4.10", title: "Reflow", setting: (width) => `at ${width} px wide` }
309
+ };
310
+ export function textScaleFindings(runs, scenarios) {
311
+ const files = fileMap(scenarios), entries = runs.flatMap((run) => (run.textScale ?? []).map(({ pass, width, issues, counts }) => ({ run, tag: pass, width, result: { issues, counts } })));
312
+ return groupLayout(entries).map((group) => {
313
+ const { scenario, tag: pass, kind, widths, themes, brands, nodes, nodeCount } = group, { rule, wcag, title, setting } = textPasses[pass], sorted = [...widths].sort((a, b) => a - b);
314
+ return {
315
+ rule,
316
+ severity: findingSeverity(rule),
317
+ file: files.get(scenario) ?? scenario,
318
+ line: 1,
319
+ column: 1,
320
+ source: "ads",
321
+ pass,
322
+ kind,
323
+ wcag: [wcag],
324
+ widths: sorted,
325
+ scenario,
326
+ themes,
327
+ ...brands.length ? { brands } : {},
328
+ nodes: [...nodes.values()],
329
+ nodeCount,
330
+ guidanceUri: "ads://guides/accessibility",
331
+ message: `${title} (WCAG ${wcag}) in ${scenario} ${setting(sorted.join(", "))} ${where(themes, brands)}: ${overflowKinds[kind].what}: ${layoutElements(group)}. ${overflowKinds[kind].fix}`
307
332
  };
308
333
  });
309
334
  }
310
-
311
- /** One error per scenario and image rendered at a shape other than the one it declares. */
312
335
  export function imageShapeFindings(runs, scenarios) {
313
- const files = new Map(scenarios.map((scenario) => [scenario.id, scenario.file])),
314
- groups = new Map();
315
- const add = (list, value) => {
316
- if (value !== undefined && !list.includes(value)) list.push(value);
317
- };
336
+ const files = fileMap(scenarios), groups = new Map;
318
337
  for (const run of runs)
319
338
  for (const issue of run.imageShape ?? []) {
320
- const key = JSON.stringify([run.scenario, issue.selector]);
321
- const group = groups.get(key) ?? { scenario: run.scenario, issue, themes: [], brands: [] };
339
+ const key = JSON.stringify([run.scenario, issue.selector]), group = groups.get(key) ?? { scenario: run.scenario, issue, themes: [], brands: [] };
322
340
  groups.set(key, group);
323
- add(group.themes, run.theme);
324
- add(group.brands, run.brand);
341
+ addOnce(group.themes, run.theme);
342
+ addOnce(group.brands, run.brand);
325
343
  }
326
344
  return [...groups.values()].slice(0, limits.findings).map(({ scenario, issue, themes, brands }) => ({
327
345
  rule: "img-shape",
@@ -332,62 +350,85 @@ export function imageShapeFindings(runs, scenarios) {
332
350
  source: "ads",
333
351
  scenario,
334
352
  themes,
335
- ...(brands.length ? { brands } : {}),
353
+ ...brands.length ? { brands } : {},
336
354
  nodes: [issue],
337
355
  rendered: issue.rendered,
338
356
  declared: issue.declared,
339
357
  guidanceUri: "ads://guides/performance",
340
- message: `Image shape in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]: ${issue.selector} renders at ${issue.rendered} at the ${issue.width} px viewport but declares ${issue.declared}, so it is cropped or stretched. A height attribute beats aspect-ratio: add height: auto. For a deliberate crop in a box of its own, set object-fit and no aspect-ratio.`,
358
+ message: `Image shape in ${scenario} ${where(themes, brands)}: ${issue.selector} renders at ${issue.rendered} at the ${issue.width} px viewport but declares ${issue.declared}, so it is cropped or stretched. A height attribute beats aspect-ratio: add height: auto. For a deliberate crop in a box of its own, set object-fit and no aspect-ratio.`
359
+ }));
360
+ }
361
+ export function cornerOverpaintFindings(runs, scenarios) {
362
+ const files = fileMap(scenarios), groups = new Map;
363
+ for (const run of runs)
364
+ for (const issue of run.corners ?? []) {
365
+ const key = JSON.stringify([run.scenario, issue.selector]), group = groups.get(key) ?? { scenario: run.scenario, issue, themes: [], brands: [] };
366
+ groups.set(key, group);
367
+ addOnce(group.themes, run.theme);
368
+ addOnce(group.brands, run.brand);
369
+ }
370
+ return [...groups.values()].slice(0, limits.findings).map(({ scenario, issue, themes, brands }) => ({
371
+ rule: "corner-overpainted",
372
+ severity: findingSeverity("corner-overpainted"),
373
+ file: files.get(scenario) ?? scenario,
374
+ line: 1,
375
+ column: 1,
376
+ source: "ads",
377
+ scenario,
378
+ themes,
379
+ ...brands.length ? { brands } : {},
380
+ nodes: [issue],
381
+ guidanceUri: "ads://guides/recipes",
382
+ message: `Rounded corner in ${scenario} ${where(themes, brands)}: ${issue.selector} has a ${issue.radius} radius and visible overflow, and ${issue.painter} paints over its ${issue.corner} corner at the ${issue.width} px viewport. Clip the rounded element (overflow: "clip"), inset it, or round what it holds.`
341
383
  }));
342
384
  }
343
-
344
- /** What a run measured, and what it skipped and why: per reason, with a few examples. An info finding
345
- * for each reason, and a review item for a render assigned targets that measured none of them. */
346
385
  export function auditCoverage(runs, capped, scenarios) {
347
- const files = new Map(scenarios.map((scenario) => [scenario.id, scenario.file])),
348
- reasons = new Map();
349
- const claimedNow = new Set(runs.flatMap((run) => run.coverage?.claimed ?? []));
350
- const note = (reason, example) => {
386
+ const files = fileMap(scenarios), reasons = new Map, claimedNow = new Set(runs.flatMap((run) => run.coverage?.claimed ?? [])), note = (reason, example) => {
351
387
  const entry = reasons.get(reason) ?? { count: 0, examples: [] };
352
388
  reasons.set(reason, entry);
353
389
  entry.count++;
354
- if (entry.examples.length < limits.nodes) entry.examples.push(example);
390
+ if (entry.examples.length < limits.nodes)
391
+ entry.examples.push(example);
355
392
  };
356
393
  for (const run of runs)
357
394
  for (const { reason, name } of run.coverage?.skipped ?? [])
358
- note(reason, { scenario: run.scenario, theme: run.theme, ...(run.brand ? { brand: run.brand } : {}), name });
359
- for (const { claim, reason, ...example } of capped) if (!claimedNow.has(claim)) note(reason, example);
395
+ note(reason, { scenario: run.scenario, theme: run.theme, ...run.brand ? { brand: run.brand } : {}, name });
396
+ for (const { claim, reason, ...example } of capped)
397
+ if (!claimedNow.has(claim))
398
+ note(reason, example);
360
399
  const coverage = {
361
400
  renders: runs.length,
362
401
  overlaysOpened: 0,
363
402
  controlsMeasured: 0,
364
- skipped: Object.fromEntries([...reasons].sort(([a], [b]) => a.localeCompare(b))),
365
- };
366
- const empty = [];
403
+ skipped: Object.fromEntries([...reasons].sort(([a], [b]) => a.localeCompare(b)))
404
+ }, empty = [];
367
405
  for (const run of runs)
368
406
  if (run.coverage) {
369
407
  coverage.overlaysOpened += run.coverage.overlays;
370
408
  coverage.controlsMeasured += run.coverage.controls;
371
- // A trigger that opened nothing is not a failure to measure: that is a skip, and the rest of the render stands.
372
- const failed = run.coverage.skipped.filter((item) => /^(?:overlay|control)-(?:gone|timeout|detached|failed)$/.test(item.reason)).length;
373
- if (failed && !run.coverage.overlays && !run.coverage.controls) empty.push(run);
409
+ if (run.coverage.skipped.filter((item) => /^(?:overlay|control)-(?:gone|timeout|detached|failed)$/.test(item.reason)).length && !run.coverage.overlays && !run.coverage.controls)
410
+ empty.push(run);
374
411
  }
375
- const findings = [...reasons].map(([reason, { count, examples }]) => ({
376
- rule: "render-audit-skipped",
377
- severity: findingSeverity("render-audit-skipped"),
378
- file: files.get(examples[0].scenario) ?? examples[0].scenario,
379
- line: 1,
380
- column: 1,
381
- source: "ads",
382
- reason,
383
- count,
384
- examples,
385
- guidanceUri: "ads://guides/accessibility",
386
- message: `The audit skipped ${count} target${count === 1 ? "" : "s"}: ${skipReasons[reason] ?? reason}. ${examples
387
- .slice(0, 3)
388
- .map((item) => `"${item.name}" in ${item.scenario} [${item.theme}]`)
389
- .join(", ")}${count > 3 ? ` and ${count - 3} more` : ""}.`,
390
- }));
412
+ const findings = [...reasons].flatMap(([reason, { count, examples }]) => {
413
+ const [first] = examples;
414
+ if (!first)
415
+ return [];
416
+ return [
417
+ {
418
+ rule: "render-audit-skipped",
419
+ severity: findingSeverity("render-audit-skipped"),
420
+ file: files.get(first.scenario) ?? first.scenario,
421
+ line: 1,
422
+ column: 1,
423
+ source: "ads",
424
+ reason,
425
+ count,
426
+ examples,
427
+ guidanceUri: "ads://guides/accessibility",
428
+ message: `The audit skipped ${count} target${count === 1 ? "" : "s"}: ${skipReasons[reason] ?? reason}. ${examples.slice(0, 3).map((item) => `"${item.name}" in ${item.scenario} [${item.theme}]`).join(", ")}${count > 3 ? ` and ${count - 3} more` : ""}.`
429
+ }
430
+ ];
431
+ });
391
432
  for (const run of empty)
392
433
  findings.push({
393
434
  rule: "render-audit-nothing-measured",
@@ -398,26 +439,23 @@ export function auditCoverage(runs, capped, scenarios) {
398
439
  source: "ads",
399
440
  scenario: run.scenario,
400
441
  themes: [run.theme],
401
- message: `Nothing the audit tried to open or hover in ${run.scenario} [${run.theme}] could be measured: ${[...new Set(run.coverage.skipped.map((item) => item.reason))].join(", ")}.`,
442
+ message: `Nothing the audit tried to open or hover in ${run.scenario} [${run.theme}] could be measured: ${[...new Set((run.coverage?.skipped ?? []).map((item) => item.reason))].join(", ")}.`
402
443
  });
403
444
  return { coverage, findings };
404
445
  }
405
-
406
- /** One error per scenario above the threshold, with its worst score, themes, brands and elements. */
407
446
  export function layoutShiftFindings(runs, scenarios) {
408
- const files = new Map(scenarios.map((scenario) => [scenario.id, scenario.file])),
409
- groups = new Map();
410
- const add = (list, value) => {
411
- if (value !== undefined && !list.includes(value)) list.push(value);
412
- };
447
+ const files = fileMap(scenarios), groups = new Map;
413
448
  for (const run of runs) {
414
- if (!(run.layoutShift?.value > shiftLimit)) continue;
449
+ const shift = run.layoutShift;
450
+ if (!shift || !(shift.value > shiftLimit))
451
+ continue;
415
452
  const group = groups.get(run.scenario) ?? { scenario: run.scenario, themes: [], brands: [], value: 0, nodes: [] };
416
453
  groups.set(run.scenario, group);
417
- add(group.themes, run.theme);
418
- add(group.brands, run.brand);
419
- group.value = Math.max(group.value, run.layoutShift.value);
420
- for (const node of run.layoutShift.nodes) add(group.nodes, node);
454
+ addOnce(group.themes, run.theme);
455
+ addOnce(group.brands, run.brand);
456
+ group.value = Math.max(group.value, shift.value);
457
+ for (const node of shift.nodes)
458
+ addOnce(group.nodes, node);
421
459
  }
422
460
  return [...groups.values()].slice(0, limits.findings).map(({ scenario, themes, brands, value, nodes }) => ({
423
461
  rule: SHIFT_RULE,
@@ -429,50 +467,45 @@ export function layoutShiftFindings(runs, scenarios) {
429
467
  scenario,
430
468
  value,
431
469
  themes,
432
- ...(brands.length ? { brands } : {}),
470
+ ...brands.length ? { brands } : {},
433
471
  nodes: nodes.slice(0, limits.nodes).map((selector) => ({ selector })),
434
472
  guidanceUri: "ads://guides/performance",
435
- message: `Layout shift ${value} in ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}], above ${shiftLimit}${nodes.length ? `: ${nodes.slice(0, 3).join(", ")}` : ""}. Give images and media width and height, reserve space for late content, and load the fonts the first text uses early.`,
473
+ message: `Layout shift ${value} in ${scenario} ${where(themes, brands)}, above ${shiftLimit}${nodes.length ? `: ${nodes.slice(0, 3).join(", ")}` : ""}. Give images and media width and height, reserve space for late content, and load the fonts the first text uses early.`
436
474
  }));
437
475
  }
438
-
439
- /**
440
- * UI scenarios a candidate change can affect, for acceptance audits. Changes to configuration,
441
- * foundation, tokens, assets or files outside every unit affect all rendering and select every UI
442
- * scenario; so does a failure to trace imports. Public/review entry re-exports are bookkeeping
443
- * for their own units and do not widen the selection.
444
- */
445
- /** "owners": the changed owners' own scenarios. "affected": every scenario the change reaches. */
446
476
  export async function auditScenarioSelection(options, changedFiles, { mode = "affected", owners = [], before } = {}) {
447
- const scenarios = (await inspectScenarios(options)).scenarios.filter((scenario) => auditedKinds.includes(scenario.kind));
448
- const all = (reason) => ({ mode: "all", reason, scenarios: scenarios.map((scenario) => scenario.id) });
449
- const inventory = await inspectUnits(options),
450
- entries = [inventory.publicEntry, inventory.reviewEntry];
477
+ const scenarios = (await discoverScenarioRegistry(options)).scenarios.filter((scenario) => auditedKinds.includes(scenario.kind)), registered = scenarios.length, all = (reason) => ({ registered, mode: "all", reason, scenarios: scenarios.map((scenario) => scenario.id) }), inventory = await inspectUnits(options), entries = [inventory.publicEntry];
451
478
  if (mode === "owners") {
452
- const changed = new Set([...owners, ...changedFiles.map((file) => inventory.owner(inventory.relative(file))).filter(Boolean)]);
479
+ const changed = new Set([
480
+ ...owners,
481
+ ...changedFiles.map((file) => inventory.owner(inventory.relative(file))).filter((owner) => !!owner)
482
+ ]);
453
483
  return {
484
+ registered,
454
485
  mode: "owners",
455
486
  reason: "Owners' own scenarios; the validation stage audits everything they affect.",
456
- scenarios: scenarios.filter((scenario) => changed.has(inventory.owner(inventory.relative(scenario.file)))).map((scenario) => scenario.id),
487
+ scenarios: scenarios.filter((scenario) => changed.has(inventory.owner(inventory.relative(scenario.file)))).map((scenario) => scenario.id)
457
488
  };
458
489
  }
459
- const traced = changedFiles.filter((file) => !entries.includes(inventory.relative(file)));
460
- const shared = traced.find((file) => {
490
+ const traced = changedFiles.filter((file) => !entries.includes(inventory.relative(file))), shared = traced.find((file) => {
461
491
  const owner = inventory.owner(inventory.relative(file));
462
- return [null, "configuration", "foundation", "tokens"].includes(owner) || owner.startsWith("assets") || !inventory.units.some((unit) => unit.id === owner);
492
+ return owner === null || ["configuration", "foundation", "tokens"].includes(owner) || owner.startsWith("assets") || !inventory.units.some((unit) => unit.id === owner);
463
493
  });
464
- if (shared) return all(`${shared} is shared configuration, foundation, token, asset or unowned input.`);
465
- if (!before && traced.some((file) => !existsSync(path.resolve(options.root, file)))) return all("Deleted inputs have no previous dependency evidence.");
494
+ if (shared)
495
+ return all(`${shared} is shared configuration, foundation, token, asset or unowned input.`);
496
+ if (!before && traced.some((file) => !existsSync(path.resolve(options.root, file))))
497
+ return all("Deleted inputs have no previous dependency evidence.");
466
498
  try {
467
- return { mode: "affected", scenarios: await affectedScenarios(options, traced, scenarios, before) };
499
+ return { registered, mode: "affected", scenarios: await affectedScenarios(options, traced, scenarios, before) };
468
500
  } catch (error) {
469
- return all(`Affected scenario selection failed: ${error.message}`);
501
+ return all(`Affected scenario selection failed: ${error instanceof Error ? error.message : String(error)}`);
470
502
  }
471
503
  }
472
-
473
- /** Policy check entry and routed findings for one audit result. */
504
+ export const emptyAuditSelection = (selection) => selection.registered ? notAvailable("none-selected", "The change reaches no registered UI scenario.") : notAvailable("no-scenarios");
474
505
  export function auditCheck(audit, extra = {}) {
475
506
  const routed = routeFindings([], audit.findings);
507
+ if ("status" in audit)
508
+ return { routed, check: { name: "render-audit", skipped: !0, status: audit.status, reason: audit.reason, message: audit.message, scenarios: 0, ...extra } };
476
509
  return {
477
510
  routed,
478
511
  check: {
@@ -481,149 +514,122 @@ export function auditCheck(audit, extra = {}) {
481
514
  engine: audit.engine,
482
515
  scenarios: audit.scenarios,
483
516
  themes: audit.themes,
484
- ...(audit.brands ? { brands: audit.brands } : {}),
517
+ ...audit.brands ? { brands: audit.brands } : {},
485
518
  renders: audit.runs,
486
- ...(audit.coverage ? { coverage: audit.coverage } : {}),
487
- ...(audit.retries ? { retries: audit.retries } : {}),
519
+ ...audit.coverage ? { coverage: audit.coverage } : {},
520
+ ...audit.retries ? { retries: audit.retries } : {},
488
521
  errors: routed.diagnostics.length,
489
522
  reviews: routed.advisories.filter((item) => item.severity === "review").length,
490
523
  infos: routed.advisories.filter((item) => item.severity === "info").length,
491
524
  elapsedMs: audit.elapsedMs,
492
- ...extra,
493
- },
525
+ ...extra
526
+ }
494
527
  };
495
528
  }
496
-
497
- function projectPlaywright(root) {
498
- const require = createRequire(path.join(root, "package.json"));
499
- for (const name of ["@playwright/test", "playwright"]) {
500
- try {
501
- return require.resolve(name);
502
- } catch {
503
- /* Try the other supported project-installed entry. */
529
+ const unavailable = (message) => Object.assign(Error(message), { code: "ADS_AUDIT_UNAVAILABLE" }), errorCode = (error) => isRecord(error) ? error.code : void 0, errorMessage = (error) => error instanceof Error ? error.message : String(error), renderKey = ({ scenario, theme, brand, state }) => JSON.stringify([scenario, theme, brand ?? null, state ?? null]);
530
+ export function findingsByState(runs, build) {
531
+ const states = [...new Set(runs.map((run) => run.state))];
532
+ if (states.every((state) => state === void 0))
533
+ return [...build(runs)];
534
+ const merged = new Map;
535
+ for (const state of states)
536
+ for (const finding of build(runs.filter((run) => run.state === state))) {
537
+ const key = JSON.stringify(finding), group = merged.get(key) ?? { finding, states: [] };
538
+ if (state !== void 0)
539
+ group.states.push(state);
540
+ merged.set(key, group);
504
541
  }
505
- }
506
- return null;
507
- }
508
-
509
- const installHint =
510
- "`npm install -D @playwright/test` and `npx playwright install chromium` (Bun: `bun add -d @playwright/test` and `bunx playwright install chromium`)";
511
-
512
- /** Whether the project can run the audit: project-local Playwright, as for captures. */
513
- export const renderAuditAvailable = (root) => !!projectPlaywright(path.resolve(root));
514
-
515
- /** Scenarios of an owner in layout.fixedWidthUnits float above the layout, and have no container to fit. */
516
- async function floatingScenarios(options, scenarios) {
517
- const globs = options.config.layout.fixedWidthUnits,
518
- floating = globMatcher(globs);
519
- if (!globs.length) return new Set();
520
- const inventory = await inspectUnits(options);
521
- return new Set(
522
- scenarios
523
- .filter((scenario) => {
524
- const owner = inventory.owner(inventory.relative(scenario.file));
525
- return owner && (floating(owner) || inventory.units.find((unit) => unit.id === owner)?.files.some(floating));
526
- })
527
- .map((scenario) => scenario.id),
528
- );
542
+ return [...merged.values()].map(({ finding, states: found }) => found.length ? { ...finding, states: found, message: `${finding.message} State${found.length === 1 ? "" : "s"}: ${found.join(", ")}.` } : finding);
529
543
  }
530
-
531
- const renderKey = ({ scenario, theme, brand }) => JSON.stringify([scenario, theme, brand ?? null]);
532
544
  const clipCause = (text) => String(text).replace(/\s+/g, " ").trim().slice(0, 500);
533
-
534
- /** Warm scenarios, separating those that cannot build. A project that fails validation fails
535
- * every scenario the same way, so it stops the audit as it always has; anything else is one
536
- * scenario's trouble (a slow or dropped build) and comes back as its cause. */
537
545
  async function warmScenariosApart(host, ids, signal) {
538
- const unbuilt = new Map();
539
- const projectWide = (error) => signal.aborted || error.build?.failure?.scope === "project" || error.build?.failure?.phase === "validation";
546
+ const unbuilt = new Map, projectWide = (error) => {
547
+ const build = isRecord(error) ? error.build : void 0, failure = isRecord(build) ? build.failure : void 0;
548
+ return signal.aborted || isRecord(failure) && (failure.scope === "project" || failure.phase === "validation");
549
+ };
540
550
  try {
541
551
  await host.warmScenarios?.(ids, signal);
542
552
  return unbuilt;
543
553
  } catch (error) {
544
- if (projectWide(error)) throw error;
554
+ if (projectWide(error))
555
+ throw error;
545
556
  }
546
- for (const id of ids) {
557
+ for (const id of ids)
547
558
  try {
548
559
  await host.warmScenarios?.([id], signal);
549
560
  } catch (error) {
550
- if (projectWide(error)) throw error;
551
- unbuilt.set(id, clipCause(error.message));
561
+ if (projectWide(error))
562
+ throw error;
563
+ unbuilt.set(id, clipCause(errorMessage(error)));
552
564
  }
553
- }
554
565
  return unbuilt;
555
566
  }
556
-
557
- /** One browser process over the given renders. Its report grows as they finish, so a worker that
558
- * dies keeps what it finished. A browser that is not installed stops the audit. */
559
- async function runAuditWorker({ root, temporary, playwright, settings, apps, signal, claimed, pages, pictograms }) {
560
- const request = path.join(temporary, "request.json"),
561
- report = path.join(temporary, "report.json"),
562
- runId = randomUUID();
563
- rmSync(report, { force: true });
564
- writeFileSync(
565
- request,
566
- JSON.stringify({
567
- schemaVersion: 1,
568
- runId,
569
- playwright,
570
- axe: requireTool.resolve("axe-core/axe.min.js"),
571
- settings,
572
- viewport,
573
- overflowWidths,
574
- smallPart: 96, // Existing browser-only narrow-container review threshold; source sizing uses roles.
575
- overlayLimit: limits.overlays,
576
- stateLimit: limits.controls,
577
- contentQuietMs: limits.contentQuietMs,
578
- contentLimitMs: limits.contentLimitMs,
579
- claimed,
580
- tags: auditTags,
581
- nodeLimit: limits.nodes,
582
- concurrency: pages,
583
- apps,
584
- pictograms,
585
- output: temporary,
586
- }),
587
- );
588
- const timeoutMs = Math.min(30 * 60 * 1000, settings.timeoutMs + apps.length * Math.min(settings.timeoutMs, 15000));
567
+ const isAuditRun = (value) => isRecord(value) && typeof value.scenario === "string" && typeof value.theme === "string", isCapped = (value) => isRecord(value) && typeof value.claim === "string" && typeof value.reason === "string";
568
+ async function runAuditWorker({
569
+ root,
570
+ temporary,
571
+ playwright,
572
+ settings,
573
+ apps,
574
+ signal,
575
+ claimed,
576
+ pages,
577
+ declared,
578
+ evidence
579
+ }) {
580
+ const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
581
+ rmSync(report, { force: !0 });
582
+ writeFileSync(request, JSON.stringify({
583
+ schemaVersion: 1,
584
+ runId,
585
+ playwright,
586
+ axe: requireTool.resolve("axe-core/axe.min.js"),
587
+ settings,
588
+ viewport,
589
+ overflowWidths,
590
+ textWidths,
591
+ smallPart: 96,
592
+ overlayLimit: limits.overlays,
593
+ stateLimit: limits.controls,
594
+ contentQuietMs: limits.contentQuietMs,
595
+ contentLimitMs: limits.contentLimitMs,
596
+ claimed,
597
+ tags: auditTags,
598
+ nodeLimit: limits.nodes,
599
+ concurrency: pages,
600
+ apps,
601
+ output: temporary,
602
+ declared,
603
+ evidence
604
+ }));
605
+ const timeoutMs = Math.min(1800000, settings.timeoutMs + apps.length * Math.min(settings.timeoutMs, 15000));
589
606
  let cause;
590
607
  try {
591
- const run = await executeDevelopmentCommand(
592
- { command: "runtime", timeoutMs, label: "Accessibility audit" },
593
- [fileURLToPath(new URL("./render-audit/worker.mjs", import.meta.url)), request],
594
- root,
595
- {},
596
- signal,
597
- );
608
+ const run = await executeDevelopmentCommand({ command: "runtime", timeoutMs, label: "Accessibility audit" }, [fileURLToPath(new URL("./render-audit/worker.mjs", import.meta.url)), request], root, {}, signal);
598
609
  if (run.code !== 0 && /Executable doesn't exist|playwright install/i.test(run.output))
599
- throw Object.assign(
600
- new Error(
601
- `The render audit needs Playwright's ${settings.browser} browser. Install it with \`npx playwright install ${settings.browser}\` (Bun: \`bunx playwright install ${settings.browser}\`), or select an installed Chrome with mcp.capture.channel "chrome".`,
602
- ),
603
- { code: "ADS_AUDIT_UNAVAILABLE" },
604
- );
605
- if (run.code !== 0) cause = `Accessibility audit browser failed (${run.code}): ${clipCause(run.output.slice(-400))}`;
610
+ throw unavailable(`The render audit could not start Playwright's ${settings.browser} browser. Run \`${browserInstallCommand(settings.browser)}\`, or select an installed Chrome with mcp.capture.channel "chrome".`);
611
+ if (run.code !== 0)
612
+ cause = `Accessibility audit browser failed (${run.code}): ${clipCause(run.output.slice(-400))}`;
606
613
  } catch (error) {
607
- if (signal.aborted || error.code === "ADS_AUDIT_UNAVAILABLE") throw error;
608
- cause = clipCause(error.message);
614
+ if (signal.aborted || errorCode(error) === "ADS_AUDIT_UNAVAILABLE")
615
+ throw error;
616
+ cause = clipCause(errorMessage(error));
609
617
  }
610
618
  if (!existsSync(report) || realpathSync(report) !== report || lstatSync(report).size > limits.reportBytes)
611
619
  return { runs: [], capped: [], cause: cause ?? "Accessibility audit produced no bounded report." };
612
- const value = JSON.parse(readFileSync(report, "utf8"));
613
- if (value.schemaVersion !== 1 || value.runId !== runId || !Array.isArray(value.runs))
620
+ const value = JSON.parse(readFileSync(report, "utf8")), runs = isRecord(value) ? value.runs : void 0;
621
+ if (!isRecord(value) || value.schemaVersion !== 1 || value.runId !== runId || !Array.isArray(runs) || !runs.every(isAuditRun))
614
622
  return { runs: [], capped: [], cause: cause ?? "Accessibility audit returned the wrong run identity." };
615
- return { runs: value.runs, capped: value.capped ?? [], cause };
623
+ const capped = Array.isArray(value.capped) ? value.capped.filter(isCapped) : [];
624
+ return { runs, capped, cause };
616
625
  }
617
-
618
- /** A scenario that could not be audited is an error naming it and its last cause, never a pass. */
619
626
  function unauditedFindings(renders, scenarios) {
620
- const files = new Map(scenarios.map((scenario) => [scenario.id, scenario.file])),
621
- groups = new Map();
627
+ const files = fileMap(scenarios), groups = new Map;
622
628
  for (const { app, attempts, causes } of renders) {
623
629
  const group = groups.get(app.scenario) ?? { scenario: app.scenario, themes: [], brands: [], attempts, cause: "" };
624
630
  groups.set(app.scenario, group);
625
- if (!group.themes.includes(app.theme)) group.themes.push(app.theme);
626
- if (app.brand && !group.brands.includes(app.brand)) group.brands.push(app.brand);
631
+ addOnce(group.themes, app.theme);
632
+ addOnce(group.brands, app.brand);
627
633
  group.cause = causes.at(-1) ?? group.cause;
628
634
  }
629
635
  return [...groups.values()].map(({ scenario, themes, brands, attempts, cause }) => ({
@@ -635,204 +641,188 @@ function unauditedFindings(renders, scenarios) {
635
641
  source: "ads",
636
642
  scenario,
637
643
  themes,
638
- ...(brands.length ? { brands } : {}),
644
+ ...brands.length ? { brands } : {},
639
645
  attempts,
640
646
  cause,
641
647
  guidanceUri: "ads://guides/accessibility",
642
- message: `Could not audit ${scenario} [${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}] in ${attempts} attempt${attempts === 1 ? "" : "s"}: ${cause}`,
648
+ message: `Could not audit ${scenario} ${where(themes, brands)} in ${attempts} attempt${attempts === 1 ? "" : "s"}: ${cause}`
643
649
  }));
644
650
  }
645
-
646
- /**
647
- * Render every selected scenario in every declared brand and theme and run axe-core on it.
648
- * Without declared brands it renders the single default brand.
649
- * Reuses a showcase-serving preview host when given one; otherwise starts and closes its own.
650
- * A render that fails is retried on its own, up to auditAttempts, and the rest keep their results.
651
- * Findings never cause a retry; a retried pass is listed in retries.
652
- */
653
- export async function runRenderAudit(
654
- root,
655
- { scenarios: selected, themes: selectedThemes, brands: selectedBrands, previewHost, signal = new AbortController().signal, onProgress } = {},
656
- ) {
657
- root = path.resolve(root);
658
- const startedAt = Date.now(),
659
- options = loadConfig(root);
660
- const playwright = projectPlaywright(root);
661
- if (!playwright)
662
- throw Object.assign(
663
- new Error(
664
- `The render audit needs Playwright in the project. Install it with ${installHint}; ads validate always runs it, and acceptance.audit: false turns it off for draft acceptance.`,
665
- ),
666
- { code: "ADS_AUDIT_UNAVAILABLE" },
667
- );
668
- const registry = await analyze(root, "registry", [], signal);
669
- // Registry discovery already checked the captured SVGs. Send only their
670
- // identity/geometry, not another copy of the artwork or a live filesystem read.
671
- const pictograms = registry.scenarios.filter(item => item.foundation?.pictogram).map(({ foundation: { pictogram } }) => ({
672
- id: pictogram.id, minHeight: pictogram.minHeight, variants: pictogram.variants,
673
- assets: Object.fromEntries(Object.entries(pictogram.assets).map(([name, asset]) => [name, { digest: asset.digest, geometry: asset.geometry }])),
674
- }));
675
- if (registry.diagnostics.length) throw new Error(`Scenario registration failed: ${registry.diagnostics[0].message}`);
651
+ export async function runRenderAudit(directory, { scenarios: selected, themes: selectedThemes, brands: selectedBrands, previewHost, signal = new AbortController().signal, onProgress } = {}) {
652
+ const root = path.resolve(directory), startedAt = Date.now(), options = loadConfig(root), registry = parseScenarioRegistry(await analyze(root, "registry", [], signal)), [firstDiagnostic] = registry.diagnostics;
653
+ if (firstDiagnostic)
654
+ throw Error(`Scenario registration failed: ${firstDiagnostic.message}`);
676
655
  const unknown = (selected ?? []).filter((id) => !registry.scenarios.some((scenario) => scenario.id === id));
677
- if (unknown.length) throw new Error(`Unknown scenario ${unknown[0]}. Discover exact IDs with ads_scenarios.`);
678
- // Token and brand scenarios display raw values (token-contrast reviews those pairs); UI scenarios are audited.
679
- // An explicit selection may still name one.
680
- const scenarios = registry.scenarios
681
- .filter((scenario) => (selected?.length ? selected.includes(scenario.id) : auditedKinds.includes(scenario.kind)))
682
- .slice(0, limits.scenarios);
683
- const themes = options.config.themes.filter((theme) => !selectedThemes?.length || selectedThemes.includes(theme.name));
656
+ if (unknown.length)
657
+ throw Error(`Unknown scenario ${unknown[0]}. Discover exact IDs with ads_scenarios.`);
658
+ const scenarios = registry.scenarios.filter((scenario) => selected?.length ? selected.includes(scenario.id) : auditedKinds.includes(scenario.kind)).slice(0, limits.scenarios), contexts = designContextsOrThrow(options), themes = contexts.themes.filter((theme) => !selectedThemes?.length || selectedThemes.includes(theme.name));
684
659
  if (selectedThemes?.length && themes.length !== new Set(selectedThemes).size)
685
- throw new Error(`Unknown theme; the project declares ${options.config.themes.map((theme) => theme.name).join(", ")}.`);
686
- const declaredBrands = options.config.brands ?? [];
687
- if (selectedBrands?.length && !declaredBrands.length) throw new Error("Unknown brand; the project declares no brands.");
660
+ throw Error(`Unknown theme; the project declares ${contexts.themes.map((theme) => theme.name).join(", ")}.`);
661
+ const declaredBrands = contexts.brands;
662
+ if (selectedBrands?.length && !declaredBrands.length)
663
+ throw Error("Unknown brand; the project declares no brands.");
688
664
  const brands = declaredBrands.filter((brand) => !selectedBrands?.length || selectedBrands.includes(brand.name));
689
665
  if (selectedBrands?.length && brands.length !== new Set(selectedBrands).size)
690
- throw new Error(`Unknown brand; the project declares ${declaredBrands.map((brand) => brand.name).join(", ")}.`);
666
+ throw Error(`Unknown brand; the project declares ${declaredBrands.map((brand) => brand.name).join(", ")}.`);
691
667
  const summary = {
692
668
  scenarios: scenarios.length,
693
669
  themes: themes.map((theme) => theme.name),
694
- ...(brands.length ? { brands: brands.map((brand) => brand.name) } : {}),
670
+ ...brands.length ? { brands: brands.map((brand) => brand.name) } : {},
695
671
  tags: auditTags,
696
- engine: `axe-core ${axeVersion()}`,
672
+ engine: `axe-core ${axeVersion()}`
697
673
  };
698
- if (!scenarios.length) return { ...summary, runs: 0, findings: [], elapsedMs: Date.now() - startedAt };
674
+ if (!scenarios.length)
675
+ return {
676
+ ...summary,
677
+ runs: 0,
678
+ findings: [],
679
+ elapsedMs: Date.now() - startedAt,
680
+ ...registry.scenarios.length ? notAvailable("none-selected", "No registered scenario is selected for the audit.") : notAvailable("no-scenarios")
681
+ };
682
+ const playwright = adsPlaywright(), browserSettings = { browser: "chromium", timeoutMs: 60000, ...options.config.mcp.capture };
683
+ try {
684
+ await ensureBrowser(browserSettings.browser, {
685
+ channel: browserSettings.channel,
686
+ signal,
687
+ onProgress: (line) => onProgress?.({ stage: "render-audit", message: line, elapsedMs: Date.now() - startedAt })
688
+ });
689
+ } catch (error) {
690
+ if (signal.aborted)
691
+ throw error;
692
+ throw unavailable(errorMessage(error));
693
+ }
699
694
  const outputRoot = path.join(root, ".ds");
700
- mkdirSync(outputRoot, { recursive: true });
701
- if (realpathSync(outputRoot) !== outputRoot) throw new Error("Audit work output cannot resolve through a symlink.");
702
- const temporary = mkdtempSync(path.join(outputRoot, "audit-work-"));
695
+ mkdirSync(outputRoot, { recursive: !0 });
696
+ if (realpathSync(outputRoot) !== outputRoot)
697
+ throw Error("Audit work output cannot resolve through a symlink.");
698
+ const temporary = mkdtempSync(path.join(outputRoot, "audit-work-")), declared = declaredControls(await analyze(root, "check", [], signal)), evidence = path.join(outputRoot, "audit-evidence");
699
+ rmSync(evidence, { recursive: !0, force: !0 });
703
700
  let host = previewHost;
704
701
  try {
705
702
  onProgress?.({ stage: "render-audit", message: `Accessibility audit: building ${scenarios.length} scenario previews.`, elapsedMs: Date.now() - startedAt });
706
703
  const startHost = async () => {
707
704
  const { startAdsMcp } = await import("./mcp/server.mjs");
708
- return startAdsMcp(root, { stdio: false, showcase: true, despitePolicy: true });
705
+ return startAdsMcp(root, { stdio: !1, showcase: !0 });
709
706
  };
710
- if (!host?.url) host = await startHost();
711
- const settings = { browser: "chromium", timeoutMs: 60000, ...options.config.mcp.capture };
712
- const floating = await floatingScenarios(options, scenarios);
713
- const wanted = themes.flatMap((theme) =>
714
- (brands.length ? brands : [undefined]).flatMap((brand) =>
715
- scenarios.map((scenario) => ({
716
- scenario: scenario.id,
717
- theme: theme.name,
718
- ...(brand ? { brand: brand.name } : {}),
719
- scheme: theme.scheme,
720
- ...(theme === themes[0] && containerKinds.includes(scenario.kind) && !floating.has(scenario.id) ? { container: containerWidth } : {}),
721
- })),
722
- ),
723
- );
724
- const renders = new Map(wanted.map((app) => [renderKey(app), { app, attempts: 0, causes: [] }])),
725
- capped = new Map();
707
+ if (!host?.url)
708
+ host = await startHost();
709
+ const settings = { browser: "chromium", timeoutMs: 60000, ...options.config.mcp.capture }, firstTheme = themes[0], firstBrand = brands[0], wanted = themes.flatMap((theme) => (brands.length ? brands : [void 0]).flatMap((brand) => scenarios.flatMap((scenario) => ((scenario.states?.length) ? scenario.states : [void 0]).map((state) => ({ scenario, state }))).map(({ scenario, state }) => ({
710
+ scenario: scenario.id,
711
+ theme: theme.name,
712
+ ...brand ? { brand: brand.name } : {},
713
+ ...state === void 0 ? {} : { state },
714
+ scheme: theme.scheme,
715
+ ...theme === firstTheme && containerKinds.includes(scenario.kind) ? { container: containerWidth } : {},
716
+ ...theme === firstTheme && brand === firstBrand ? { text: !0 } : {}
717
+ })))), renders = new Map(wanted.map((app) => [renderKey(app), { app, attempts: 0, causes: [] }])), capped = new Map;
726
718
  onProgress?.({
727
719
  stage: "render-audit",
728
- message: `Accessibility audit: ${wanted.length} renders (${scenarios.length} scenarios × ${themes.length} themes${brands.length ? ` × ${brands.length} brands` : ""}).`,
729
- elapsedMs: Date.now() - startedAt,
720
+ message: `Accessibility audit: ${wanted.length} renders (${scenarios.length} scenarios \xD7 ${themes.length} themes${brands.length ? ` \xD7 ${brands.length} brands` : ""}).`,
721
+ elapsedMs: Date.now() - startedAt
730
722
  });
731
- for (let attempt = 1; attempt <= auditAttempts; attempt++) {
723
+ for (let attempt = 1;attempt <= auditAttempts; attempt++) {
732
724
  const pending = [...renders.values()].filter((render) => !render.result);
733
- if (!pending.length) break;
725
+ if (!pending.length)
726
+ break;
734
727
  signal.throwIfAborted();
735
- for (const render of pending) render.attempts = attempt;
736
- if (!host) {
728
+ for (const render of pending)
729
+ render.attempts = attempt;
730
+ if (!host)
737
731
  try {
738
732
  host = await startHost();
739
733
  } catch (error) {
740
- if (signal.aborted) throw error;
741
- for (const render of pending) render.causes.push(clipCause(error.message));
734
+ if (signal.aborted)
735
+ throw error;
736
+ for (const render of pending)
737
+ render.causes.push(clipCause(errorMessage(error)));
742
738
  continue;
743
739
  }
740
+ const current = host, unbuilt = await warmScenariosApart(current, [...new Set(pending.map((render) => render.app.scenario))], signal);
741
+ for (const render of pending) {
742
+ const cause = unbuilt.get(render.app.scenario);
743
+ if (cause !== void 0)
744
+ render.causes.push(cause);
744
745
  }
745
- const unbuilt = await warmScenariosApart(host, [...new Set(pending.map((render) => render.app.scenario))], signal);
746
- for (const render of pending) if (unbuilt.has(render.app.scenario)) render.causes.push(unbuilt.get(render.app.scenario));
747
- const apps = pending
748
- .filter((render) => !unbuilt.has(render.app.scenario))
749
- .map(({ app }) => {
750
- const url = new URL(host.url);
751
- url.searchParams.set("scenario", app.scenario);
752
- url.searchParams.set("capture", "1");
753
- url.searchParams.set("theme", app.theme);
754
- if (app.brand) url.searchParams.set("brand", app.brand);
755
- return { ...app, url: url.href };
756
- });
757
- const reached = apps.length
758
- ? await runAuditWorker({
759
- root,
760
- temporary,
761
- playwright,
762
- settings,
763
- apps,
764
- signal,
765
- pages: options.config.mcp.auditPages,
766
- pictograms,
767
- claimed: [...renders.values()].flatMap((render) => render.result?.coverage?.claimed ?? []),
768
- })
769
- : { runs: [], capped: [] };
770
- for (const item of reached.capped ?? []) capped.set(item.claim, item);
746
+ const hostUrl = current.url, apps = hostUrl ? pending.filter((render) => !unbuilt.has(render.app.scenario)).map(({ app }) => {
747
+ const url = new URL(hostUrl);
748
+ url.searchParams.set("scenario", app.scenario);
749
+ url.searchParams.set("capture", "1");
750
+ url.searchParams.set("theme", app.theme);
751
+ if (app.brand)
752
+ url.searchParams.set("brand", app.brand);
753
+ return { ...app, url: url.href };
754
+ }) : [], reached = apps.length ? await runAuditWorker({
755
+ root,
756
+ temporary,
757
+ playwright,
758
+ settings,
759
+ apps,
760
+ signal,
761
+ pages: options.config.mcp.auditPages,
762
+ claimed: [...renders.values()].flatMap((render) => render.result?.coverage?.claimed ?? []),
763
+ declared,
764
+ evidence
765
+ }) : { runs: [], capped: [] };
766
+ for (const item of reached.capped)
767
+ capped.set(item.claim, item);
771
768
  for (const run of reached.runs) {
772
769
  const render = renders.get(renderKey(run));
773
- if (!render) continue;
770
+ if (!render)
771
+ continue;
774
772
  if (run.failed) {
775
- render.causes.push(run.cause);
776
- if (run.violations) render.partial = run;
777
- } else render.result = run;
773
+ render.causes.push(run.cause ?? "");
774
+ if (run.violations)
775
+ render.partial = run;
776
+ } else
777
+ render.result = run;
778
778
  }
779
- for (const { app } of pending.filter(
780
- (render) =>
781
- !render.result &&
782
- apps.some((app) => renderKey(app) === renderKey(render.app)) &&
783
- !reached.runs.some((run) => renderKey(run) === renderKey(render.app)),
784
- ))
785
- renders.get(renderKey(app)).causes.push(reached.cause ?? "The audit browser stopped before this render.");
786
- // The next attempt gets a new browser and, when this audit owns it, a new preview host.
779
+ for (const { app } of pending.filter((render) => !render.result && apps.some((item) => renderKey(item) === renderKey(render.app)) && !reached.runs.some((run) => renderKey(run) === renderKey(render.app))))
780
+ renders.get(renderKey(app))?.causes.push(reached.cause ?? "The audit browser stopped before this render.");
787
781
  if (attempt < auditAttempts && host !== previewHost && [...renders.values()].some((render) => !render.result)) {
788
782
  const previous = host;
789
- host = undefined;
790
- await previous.close().catch(() => {});
783
+ host = void 0;
784
+ await previous.close?.().catch(() => {});
791
785
  }
792
786
  }
793
- const all = [...renders.values()],
794
- runs = all.map((render) => render.result ?? render.partial).filter(Boolean);
795
- const retries = all
796
- .filter((render) => render.result && render.attempts > 1)
797
- .map(({ app, attempts, causes }) => ({ scenario: app.scenario, theme: app.theme, ...(app.brand ? { brand: app.brand } : {}), attempts, causes }));
798
- const { coverage, findings: coverageItems } = auditCoverage(all.map((render) => render.result).filter(Boolean), [...capped.values()], scenarios);
799
- const findings = [
787
+ const all = [...renders.values()], runs = all.flatMap((render) => {
788
+ const run = render.result ?? render.partial;
789
+ return run ? [run] : [];
790
+ }), retries = all.flatMap(({ app, attempts, causes, result }) => result && attempts > 1 ? [{ scenario: app.scenario, theme: app.theme, ...app.brand ? { brand: app.brand } : {}, attempts, causes }] : []), { coverage, findings: coverageItems } = auditCoverage(all.flatMap((render) => render.result ? [render.result] : []), [...capped.values()], scenarios), findings = [
800
791
  ...coverageItems,
801
- ...auditFindings(runs, scenarios),
802
- ...nonTextContrastFindings(runs, scenarios),
803
- ...layoutOverflowFindings(runs, scenarios),
804
- ...layoutShiftFindings(runs, scenarios),
805
- ...imageShapeFindings(runs, scenarios),
806
- ...pictogramFindings(runs, scenarios),
807
- ...unauditedFindings(
808
- all.filter((render) => !render.result),
809
- scenarios,
810
- ),
811
- ...incompleteFindings(runs, scenarios),
812
- ];
813
- const shifts = runs.filter((run) => run.layoutShift).sort((a, b) => b.layoutShift.value - a.layoutShift.value);
792
+ ...findingsByState(runs, (some) => auditFindings(some, scenarios)),
793
+ ...findingsByState(runs, (some) => nonTextContrastFindings(some, scenarios)),
794
+ ...findingsByState(runs, (some) => declaredBoundaryFindings(some, scenarios, root)),
795
+ ...findingsByState(runs, (some) => layoutOverflowFindings(some, scenarios)),
796
+ ...findingsByState(runs, (some) => textScaleFindings(some, scenarios)),
797
+ ...findingsByState(runs, (some) => layoutShiftFindings(some, scenarios)),
798
+ ...findingsByState(runs, (some) => imageShapeFindings(some, scenarios)),
799
+ ...findingsByState(runs, (some) => cornerOverpaintFindings(some, scenarios)),
800
+ ...unauditedFindings(all.filter((render) => !render.result), scenarios),
801
+ ...findingsByState(runs, (some) => incompleteFindings(some, scenarios))
802
+ ], shifts = runs.flatMap((run) => run.layoutShift ? [{ scenario: run.scenario, value: run.layoutShift.value }] : []).sort((a, b) => b.value - a.value), [worst] = shifts;
814
803
  return {
815
804
  ...summary,
816
- ...(shifts.length ? { worstLayoutShift: { value: shifts[0].layoutShift.value, scenario: shifts[0].scenario } } : {}),
805
+ ...worst ? { worstLayoutShift: { value: worst.value, scenario: worst.scenario } } : {},
817
806
  runs: all.filter((render) => render.result).length,
818
807
  incomplete: findings.filter((finding) => finding.rule === INCOMPLETE_RULE).length,
819
808
  overlaysOpened: coverage.overlaysOpened,
820
809
  controlsMeasured: coverage.controlsMeasured,
821
810
  coverage,
822
811
  findings,
823
- ...(retries.length ? { retries } : {}),
824
- elapsedMs: Date.now() - startedAt,
812
+ ...retries.length ? { retries } : {},
813
+ elapsedMs: Date.now() - startedAt
825
814
  };
826
815
  } finally {
827
816
  try {
828
- if (host !== previewHost) await host?.close();
817
+ if (host !== previewHost)
818
+ await host?.close?.();
829
819
  } finally {
830
- rmSync(temporary, { recursive: true, force: true });
820
+ rmSync(temporary, { recursive: !0, force: !0 });
831
821
  }
832
822
  }
833
823
  }
834
-
835
824
  const requireTool = createRequire(import.meta.url);
836
825
  function axeVersion() {
837
- return JSON.parse(readFileSync(requireTool.resolve("axe-core/package.json"), "utf8")).version;
826
+ const value = JSON.parse(readFileSync(requireTool.resolve("axe-core/package.json"), "utf8"));
827
+ return isRecord(value) && typeof value.version === "string" ? value.version : "unknown";
838
828
  }