@reqvire-org/ads 0.4.0 → 0.4.3

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 (410) hide show
  1. package/README.md +115 -87
  2. package/dist/a11y.mjs +133 -48
  3. package/dist/analysis/compiler-options.mjs +13 -0
  4. package/dist/analysis/context.mjs +46 -0
  5. package/dist/analysis/file-tree.mjs +52 -0
  6. package/dist/analysis/helpers.mjs +142 -0
  7. package/dist/analysis/impact.mjs +20 -0
  8. package/dist/analysis/inputs.mjs +22 -0
  9. package/dist/analysis/module-resolvers.mjs +46 -0
  10. package/dist/analysis/native-adapter.mjs +180 -0
  11. package/dist/analysis/native-project.mjs +323 -0
  12. package/dist/analysis/queries.mjs +133 -0
  13. package/dist/analysis/service.mjs +153 -0
  14. package/dist/analysis/standalone.mjs +57 -0
  15. package/dist/analysis/syntax.mjs +179 -0
  16. package/dist/analysis/worker.mjs +182 -0
  17. package/dist/assets.mjs +6 -6
  18. package/dist/atomic-composition.mjs +191 -70
  19. package/dist/atomic-trace.mjs +120 -50
  20. package/dist/behavior-libraries.mjs +106 -37
  21. package/dist/behaviors.mjs +219 -77
  22. package/dist/boundaries.mjs +140 -41
  23. package/dist/brand-assets.mjs +219 -47
  24. package/dist/brands.mjs +86 -27
  25. package/dist/bun-compiler.mjs +28 -14
  26. package/dist/bun-worker.mjs +7 -5
  27. package/dist/capture/worker.mjs +15 -4
  28. package/dist/capture-store.mjs +4 -2
  29. package/dist/capture.mjs +17 -14
  30. package/dist/check-service.mjs +44 -58
  31. package/dist/check.mjs +754 -188
  32. package/dist/cli.mjs +200 -99
  33. package/dist/color-values.mjs +21 -21
  34. package/dist/component-contrast.mjs +127 -9
  35. package/dist/config.mjs +303 -135
  36. package/dist/construction-styles.cjs +10 -0
  37. package/dist/contrast-composition.mjs +134 -0
  38. package/dist/control-padding.mjs +45 -25
  39. package/dist/css-values.mjs +3 -2
  40. package/dist/declarative-flow.mjs +209 -109
  41. package/dist/design-values.mjs +136 -51
  42. package/dist/development-runtime.mjs +4 -6
  43. package/dist/draft-boundary.mjs +11 -6
  44. package/dist/evidence.mjs +1 -1
  45. package/dist/finding-rules.mjs +9 -5
  46. package/dist/font-rules.mjs +22 -17
  47. package/dist/fonts-generated.mjs +23 -16
  48. package/dist/foundation-views.mjs +242 -0
  49. package/dist/foundation.mjs +63 -39
  50. package/dist/generated-entries.mjs +101 -34
  51. package/dist/icons.mjs +79 -32
  52. package/dist/image-attributes.mjs +143 -66
  53. package/dist/image-size.mjs +1 -1
  54. package/dist/index.mjs +0 -2
  55. package/dist/init.mjs +122 -41
  56. package/dist/investigations.mjs +2 -2
  57. package/dist/layers.mjs +298 -129
  58. package/dist/layout-widths.mjs +180 -85
  59. package/dist/linaria/preserve-values.cjs +7 -0
  60. package/dist/linaria/spatial-inputs.cjs +56 -0
  61. package/dist/lockup-composition.mjs +44 -0
  62. package/dist/lockup-model.cjs +64 -0
  63. package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
  64. package/dist/mcp/apps.mjs +4 -30
  65. package/dist/mcp/behavior-pages.mjs +72 -24
  66. package/dist/mcp/build-status.mjs +257 -64
  67. package/dist/mcp/catalog.mjs +90 -26
  68. package/dist/mcp/context.mjs +17 -18
  69. package/dist/mcp/draft-discovery.mjs +44 -21
  70. package/dist/mcp/drafts.mjs +903 -281
  71. package/dist/mcp/execution-coordinator.mjs +417 -167
  72. package/dist/mcp/execution-results.mjs +7 -7
  73. package/dist/mcp/mutations.mjs +673 -234
  74. package/dist/mcp/preview-watch.mjs +448 -170
  75. package/dist/mcp/preview-widget.bundle.js +44 -50
  76. package/dist/mcp/prompts.mjs +5 -5
  77. package/dist/mcp/result-pages.mjs +1 -1
  78. package/dist/mcp/sandbox-host.mjs +1 -1
  79. package/dist/mcp/server.mjs +2409 -577
  80. package/dist/mcp/showcase-host.mjs +165 -41
  81. package/dist/mcp/skills.mjs +1 -1
  82. package/dist/mcp/text-diff.mjs +29 -10
  83. package/dist/paint-contracts.mjs +174 -81
  84. package/dist/palette-generated.mjs +2 -2
  85. package/dist/pictogram-model.mjs +59 -0
  86. package/dist/pictograms.mjs +52 -0
  87. package/dist/preview-bun.mjs +494 -187
  88. package/dist/preview-failure.mjs +1 -1
  89. package/dist/preview-files.mjs +13 -13
  90. package/dist/preview-imports.mjs +104 -55
  91. package/dist/preview-inputs.mjs +2 -2
  92. package/dist/preview-requests.mjs +24 -0
  93. package/dist/preview-resources.mjs +288 -147
  94. package/dist/preview-scope.mjs +5 -4
  95. package/dist/program-cache.mjs +8 -34
  96. package/dist/project-documents.mjs +1 -1
  97. package/dist/public-api.mjs +69 -31
  98. package/dist/public-props.mjs +39 -22
  99. package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
  100. package/dist/{browser-audit → render-audit}/image-shape.mjs +15 -5
  101. package/dist/{browser-audit → render-audit}/layout-overflow.mjs +86 -23
  102. package/dist/{browser-audit → render-audit}/non-text-contrast.mjs +86 -27
  103. package/dist/render-audit/pictograms.mjs +88 -0
  104. package/dist/{browser-audit → render-audit}/render-states.mjs +208 -52
  105. package/dist/{browser-audit → render-audit}/worker.mjs +98 -30
  106. package/dist/render-audit.mjs +838 -0
  107. package/dist/render-color-probe.mjs +96 -42
  108. package/dist/render-composition.mjs +164 -0
  109. package/dist/resource-limits.mjs +229 -97
  110. package/dist/runtime-contracts.mjs +467 -185
  111. package/dist/scenario-groups.mjs +22 -10
  112. package/dist/scenario-inspector.mjs +6 -43
  113. package/dist/scenario-program.mjs +8 -25
  114. package/dist/scenario-registry.mjs +72 -30
  115. package/dist/scenario-selectors.mjs +161 -64
  116. package/dist/scenario-slots.mjs +149 -56
  117. package/dist/scenario-trace.mjs +215 -109
  118. package/dist/scenarios-compiler.mjs +719 -378
  119. package/dist/scenarios-vite.d.mts +1 -3
  120. package/dist/scenarios-vite.mjs +2 -81
  121. package/dist/scenarios.mjs +421 -157
  122. package/dist/selector-match.mjs +2 -2
  123. package/dist/showcase/client.bundle.js +57 -56
  124. package/dist/showcase/draft-navigation.js +21 -3
  125. package/dist/showcase/favicon.ico +0 -0
  126. package/dist/showcase/favicon.svg +1 -0
  127. package/dist/showcase/foundation-view.css +58 -0
  128. package/dist/showcase/foundation-view.mjs +255 -0
  129. package/dist/showcase/guide-controls.ads.review.mjs +32 -0
  130. package/dist/showcase/icons.js +1 -145
  131. package/dist/showcase/index.html +3 -31
  132. package/dist/showcase/pictogram-view.mjs +53 -0
  133. package/dist/showcase/preview-frame.ads.review.css +46 -0
  134. package/dist/showcase/preview-frame.ads.review.d.mts +11 -0
  135. package/dist/showcase/preview-frame.ads.review.mjs +22 -0
  136. package/dist/showcase/preview-state.js +0 -9
  137. package/dist/showcase/refresh-scheduler.js +23 -0
  138. package/dist/showcase/style.css +5 -47
  139. package/dist/showcase/ui/ui.css +1353 -0
  140. package/dist/showcase/ui/ui.js +1064 -0
  141. package/dist/showcase-coverage.mjs +58 -37
  142. package/dist/skills/README.md +24 -23
  143. package/dist/skills/ads-designer/README.md +8 -2
  144. package/dist/skills/ads-designer/SKILL.md +143 -120
  145. package/dist/skills/ads-designer/references/accessibility.md +78 -15
  146. package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
  147. package/dist/skills/ads-designer/references/behaviors.md +30 -27
  148. package/dist/skills/ads-designer/references/branding.md +101 -24
  149. package/dist/skills/ads-designer/references/captures.md +25 -0
  150. package/dist/skills/ads-designer/references/cli.md +21 -24
  151. package/dist/skills/ads-designer/references/contracts.md +7 -6
  152. package/dist/skills/ads-designer/references/design-data.md +49 -52
  153. package/dist/skills/ads-designer/references/drafts.md +20 -17
  154. package/dist/skills/ads-designer/references/evidence.md +1 -5
  155. package/dist/skills/ads-designer/references/guarded-editing.md +14 -18
  156. package/dist/skills/ads-designer/references/layers.md +1 -1
  157. package/dist/skills/ads-designer/references/layout.md +347 -0
  158. package/dist/skills/ads-designer/references/mobile.md +2 -1
  159. package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
  160. package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
  161. package/dist/skills/ads-designer/references/performance.md +3 -2
  162. package/dist/skills/ads-designer/references/pictograms.md +131 -0
  163. package/dist/skills/ads-designer/references/review.md +37 -34
  164. package/dist/skills/ads-designer/references/runtimes.md +33 -30
  165. package/dist/skills/ads-designer/references/scenarios.md +16 -18
  166. package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
  167. package/dist/skills/ads-designer/references/stress-test.md +68 -0
  168. package/dist/skills/ads-designer/references/validation.md +83 -75
  169. package/dist/skills/ads-designer/references/workflows.md +8 -33
  170. package/dist/skills/ads-import/SKILL.md +43 -325
  171. package/dist/skills/ads-import/references/atomic-styles.md +4 -4
  172. package/dist/skills/ads-import/references/behaviors.md +30 -27
  173. package/dist/skills/ads-import/references/branding.md +5 -5
  174. package/dist/skills/ads-import/references/captures.md +25 -0
  175. package/dist/skills/ads-import/references/cli.md +21 -24
  176. package/dist/skills/ads-import/references/compatibility.md +1 -1
  177. package/dist/skills/ads-import/references/contracts.md +7 -6
  178. package/dist/skills/ads-import/references/design-data.md +49 -52
  179. package/dist/skills/ads-import/references/drafts.md +20 -17
  180. package/dist/skills/ads-import/references/evidence.md +1 -5
  181. package/dist/skills/ads-import/references/guarded-editing.md +14 -18
  182. package/dist/skills/ads-import/references/implementation.md +2 -1
  183. package/dist/skills/ads-import/references/layers.md +1 -1
  184. package/dist/skills/ads-import/references/layout.md +347 -0
  185. package/dist/skills/ads-import/references/review.md +37 -34
  186. package/dist/skills/ads-import/references/runtimes.md +33 -30
  187. package/dist/skills/ads-import/references/scenarios.md +16 -18
  188. package/dist/skills/ads-import/references/tokens.md +3 -3
  189. package/dist/skills/ads-import/references/validation.md +83 -75
  190. package/dist/skills/ads-import/references/workflows.md +8 -33
  191. package/dist/skills/ads-migrate/SKILL.md +56 -0
  192. package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
  193. package/dist/skills/ads-port/SKILL.md +58 -344
  194. package/dist/skills/ads-port/references/atomic-styles.md +4 -4
  195. package/dist/skills/ads-port/references/behaviors.md +30 -27
  196. package/dist/skills/ads-port/references/captures.md +25 -0
  197. package/dist/skills/ads-port/references/cli.md +21 -24
  198. package/dist/skills/ads-port/references/contracts.md +7 -6
  199. package/dist/skills/ads-port/references/design-data.md +49 -52
  200. package/dist/skills/ads-port/references/drafts.md +20 -17
  201. package/dist/skills/ads-port/references/evidence.md +1 -5
  202. package/dist/skills/ads-port/references/guarded-editing.md +14 -18
  203. package/dist/skills/ads-port/references/layers.md +1 -1
  204. package/dist/skills/ads-port/references/layout.md +347 -0
  205. package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
  206. package/dist/skills/ads-port/references/native-implementation.md +2 -1
  207. package/dist/skills/ads-port/references/review.md +37 -34
  208. package/dist/skills/ads-port/references/runtimes.md +33 -30
  209. package/dist/skills/ads-port/references/scenarios.md +16 -18
  210. package/dist/skills/ads-port/references/validation.md +83 -75
  211. package/dist/skills/ads-port/references/workflows.md +8 -33
  212. package/dist/source-symbols.mjs +1 -8
  213. package/dist/source-values.mjs +270 -129
  214. package/dist/spatial-composition.mjs +322 -0
  215. package/dist/spatial-contexts.cjs +56 -0
  216. package/dist/spatial-css.cjs +351 -0
  217. package/dist/spatial-inputs.cjs +80 -0
  218. package/dist/spatial-metadata.mjs +18 -0
  219. package/dist/spatial-model.cjs +322 -0
  220. package/dist/spatial.mjs +21 -0
  221. package/dist/stage-timing.cjs +20 -0
  222. package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +105 -0
  223. package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +275 -0
  224. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  225. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  226. package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +8 -0
  227. package/dist/starters/preact/ds.config.json +25 -6
  228. package/dist/starters/preact/package.json +4 -8
  229. package/dist/starters/preact/tsconfig.json +4 -5
  230. package/dist/starters/preact/vite.config.ts +3 -3
  231. package/dist/starters/react/ADS.md +42 -47
  232. package/dist/starters/react/README.md +47 -49
  233. package/dist/starters/react/design-system/assets/pictograms/catalog.ads.json +13 -0
  234. package/dist/starters/react/design-system/assets/pictograms/journey.dark.svg +7 -0
  235. package/dist/starters/react/design-system/assets/pictograms/journey.svg +7 -0
  236. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +18 -2
  237. package/dist/starters/react/design-system/components/Actions/IconButton/README.md +3 -0
  238. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.exports.ts +1 -0
  239. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.fixture.ts +1 -0
  240. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.scenario.tsx +7 -0
  241. package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.tsx +26 -0
  242. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +5 -0
  243. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
  244. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
  245. package/dist/starters/react/design-system/index.ts +2 -1
  246. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
  247. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
  248. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
  249. package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
  250. package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
  251. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
  252. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
  253. package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
  254. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
  255. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
  256. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
  257. package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
  258. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -1
  259. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  260. package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
  261. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
  262. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
  263. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -1
  264. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  265. package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
  266. package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
  267. package/dist/starters/react/design-system/tokens/colors.css +1 -1
  268. package/dist/starters/react/design-system/tokens/spacing.css +22 -32
  269. package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
  270. package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
  271. package/dist/starters/react/ds.config.json +25 -6
  272. package/dist/starters/react/package.json +2 -6
  273. package/dist/starters/react/tsconfig.json +2 -3
  274. package/dist/starters/react/vite.config.ts +3 -3
  275. package/dist/style-boundaries.mjs +70 -25
  276. package/dist/task-cache.mjs +173 -72
  277. package/dist/task-worker.mjs +22 -11
  278. package/dist/test-boundaries.mjs +132 -59
  279. package/dist/themes-generated.mjs +1 -1
  280. package/dist/themes-watch.mjs +57 -22
  281. package/dist/themes.mjs +176 -73
  282. package/dist/token-export.mjs +39 -14
  283. package/dist/token-policy.mjs +6 -3
  284. package/dist/token-quality.mjs +6 -6
  285. package/dist/token-samples.mjs +16 -5
  286. package/dist/tokens.mjs +71 -26
  287. package/dist/ui-framework.mjs +16 -14
  288. package/dist/unit-contracts.mjs +251 -104
  289. package/dist/units.mjs +209 -99
  290. package/dist/usage.mjs +138 -38
  291. package/dist/validation-checks.mjs +115 -38
  292. package/dist/validation-inputs.mjs +191 -78
  293. package/dist/validation.mjs +268 -102
  294. package/dist/verification/browser.mjs +27 -5
  295. package/dist/verification.mjs +711 -187
  296. package/docs/ADS.md +96 -80
  297. package/docs/ARCHITECTURE.md +368 -137
  298. package/docs/BEHAVIORS.md +29 -25
  299. package/docs/CACHING.md +77 -17
  300. package/docs/CHANGELOG.md +332 -17
  301. package/docs/CONTRACTS.md +12 -4
  302. package/docs/DESIGN-REFERENCES.md +40 -0
  303. package/docs/GUIDE.md +300 -263
  304. package/docs/MCP.md +187 -324
  305. package/docs/SPATIAL-CHECKS.md +69 -0
  306. package/docs/benchmarks/README.md +39 -0
  307. package/package.json +43 -34
  308. package/dist/browser-audit.mjs +0 -429
  309. package/dist/create.mjs +0 -48
  310. package/dist/lint-config.mjs +0 -50
  311. package/dist/mcp/project-widget.bundle.js +0 -114
  312. package/dist/mcp/reports.mjs +0 -101
  313. package/dist/mcp/widget.bundle.js +0 -147
  314. package/dist/oxlint.mjs +0 -89
  315. package/dist/preview-builder.mjs +0 -133
  316. package/dist/preview-workers.mjs +0 -184
  317. package/dist/showcase.mjs +0 -77
  318. package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
  319. package/dist/skills/ads-break-ui/README.md +0 -16
  320. package/dist/skills/ads-break-ui/SKILL.md +0 -412
  321. package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
  322. package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
  323. package/dist/skills/ads-break-ui/references/behaviors.md +0 -412
  324. package/dist/skills/ads-break-ui/references/captures.md +0 -135
  325. package/dist/skills/ads-break-ui/references/contracts.md +0 -317
  326. package/dist/skills/ads-break-ui/references/design-data.md +0 -354
  327. package/dist/skills/ads-break-ui/references/drafts.md +0 -194
  328. package/dist/skills/ads-break-ui/references/evidence.md +0 -128
  329. package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -165
  330. package/dist/skills/ads-break-ui/references/layers.md +0 -145
  331. package/dist/skills/ads-break-ui/references/reporting.md +0 -101
  332. package/dist/skills/ads-break-ui/references/review.md +0 -97
  333. package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
  334. package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
  335. package/dist/skills/ads-break-ui/references/validation.md +0 -166
  336. package/dist/skills/ads-break-ui/references/verification.md +0 -58
  337. package/dist/skills/ads-break-ui/references/workflows.md +0 -90
  338. package/dist/skills/ads-designer/references/reporting.md +0 -101
  339. package/dist/skills/ads-import/references/reporting.md +0 -101
  340. package/dist/skills/ads-motion/LICENSE.upstream +0 -21
  341. package/dist/skills/ads-motion/README.md +0 -22
  342. package/dist/skills/ads-motion/SKILL.md +0 -385
  343. package/dist/skills/ads-motion/agents/openai.yaml +0 -4
  344. package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
  345. package/dist/skills/ads-motion/references/audit.md +0 -44
  346. package/dist/skills/ads-motion/references/behaviors.md +0 -412
  347. package/dist/skills/ads-motion/references/captures.md +0 -135
  348. package/dist/skills/ads-motion/references/contracts.md +0 -317
  349. package/dist/skills/ads-motion/references/design-data.md +0 -354
  350. package/dist/skills/ads-motion/references/drafts.md +0 -194
  351. package/dist/skills/ads-motion/references/evidence.md +0 -128
  352. package/dist/skills/ads-motion/references/guarded-editing.md +0 -165
  353. package/dist/skills/ads-motion/references/layers.md +0 -145
  354. package/dist/skills/ads-motion/references/motion-review.md +0 -35
  355. package/dist/skills/ads-motion/references/reporting.md +0 -101
  356. package/dist/skills/ads-motion/references/review.md +0 -97
  357. package/dist/skills/ads-motion/references/runtimes.md +0 -203
  358. package/dist/skills/ads-motion/references/scenarios.md +0 -246
  359. package/dist/skills/ads-motion/references/validation.md +0 -166
  360. package/dist/skills/ads-motion/references/verification.md +0 -39
  361. package/dist/skills/ads-motion/references/workflows.md +0 -90
  362. package/dist/skills/ads-port/references/reporting.md +0 -101
  363. package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
  364. package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
  365. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  366. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  367. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
  368. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
  369. package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
  370. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
  371. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
  372. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
  373. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
  374. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
  375. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +0 -1
  376. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
  377. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
  378. package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
  379. package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
  380. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.ads.exports.ts +0 -1
  381. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
  382. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  383. package/dist/starters/react/design-system/review/grid-cell/GridCell.ads.exports.ts +0 -1
  384. package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
  385. package/dist/starters/react/design-system/review/index.ts +0 -6
  386. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  387. package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
  388. package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +0 -1
  389. package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
  390. package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
  391. package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
  392. package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
  393. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
  394. package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
  395. package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
  396. package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
  397. package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
  398. package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
  399. package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
  400. package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
  401. package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
  402. package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
  403. package/dist/starters/react/package-lock.json +0 -4707
  404. package/dist/token-fixtures.mjs +0 -30
  405. package/docs/benchmarks/bun-previews.md +0 -91
  406. package/docs/benchmarks/preview-memory.md +0 -147
  407. package/docs/benchmarks/turbo-poc.md +0 -284
  408. package/docs/plans/execution-coordination.md +0 -57
  409. /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
  410. /package/dist/{browser-audit → render-audit}/layout-shift.mjs +0 -0
@@ -4,45 +4,80 @@ import { loadConfig } from "./config.mjs";
4
4
  import { inspectTokens } from "./tokens.mjs";
5
5
  import { generatedThemeFiles, generatedThemesFile, writeThemesCss } from "./themes-generated.mjs";
6
6
  import { isExportsFile, writeGeneratedEntries } from "./generated-entries.mjs";
7
+ import { analyze } from "./analysis/service.mjs";
7
8
 
8
9
  /** Rewrites the project's themes.generated.css and themes.generated.ts from its token sheets and config when stale. */
9
- export function refreshThemesCss(directory) {
10
+ export async function refreshThemesCss(directory) {
10
11
  const options = loadConfig(directory);
11
- return { ...writeThemesCss(options, inspectTokens(directory, options)), root: options.root };
12
+ return { ...writeThemesCss(options, await inspectTokens(directory, options)), root: options.root };
13
+ }
14
+
15
+ export async function refreshThemesCssAsync(directory) {
16
+ const options = loadConfig(directory);
17
+ return { ...writeThemesCss(options, await analyze(options.root, "tokens")), root: options.root };
12
18
  }
13
19
 
14
20
  /** Keeps themes.generated.css and .ts current on every token sheet or config change, and the
15
21
  * generated barrels current on every exports file change: once now, then on each change. */
16
22
  export function watchThemesCss(directory, { log = () => {} } = {}) {
17
23
  const watchers = [];
18
- let timer;
19
- const refresh = () => {
20
- try {
21
- const result = refreshThemesCss(directory);
22
- for (const item of result.files ?? []) if (item.written) log(`ADS wrote ${path.relative(result.root, item.file).replaceAll("\\", "/")}`);
23
- } catch (error) { log(`ADS could not write ${generatedThemesFile}: ${error.message}`); }
24
- try {
25
- const options = loadConfig(directory);
26
- for (const item of writeGeneratedEntries(options).files) if (item.changed) log(`ADS wrote ${path.relative(options.root, item.file).replaceAll("\\", "/")}`);
27
- } catch (error) { log(`ADS could not write the generated entries: ${error.message}`); }
28
- };
29
- const changed = file => {
24
+ let timer,
25
+ closed = false,
26
+ queue = Promise.resolve();
27
+ const refresh = () =>
28
+ (queue = queue.then(async () => {
29
+ if (closed) return;
30
+ try {
31
+ const result = await refreshThemesCssAsync(directory);
32
+ for (const item of result.files ?? []) if (item.written) log(`ADS wrote ${path.relative(result.root, item.file).replaceAll("\\", "/")}`);
33
+ } catch (error) {
34
+ log(`ADS could not write ${generatedThemesFile}: ${error.message}`);
35
+ }
36
+ try {
37
+ const options = loadConfig(directory);
38
+ for (const item of (await writeGeneratedEntries(options)).files)
39
+ if (item.changed) log(`ADS wrote ${path.relative(options.root, item.file).replaceAll("\\", "/")}`);
40
+ } catch (error) {
41
+ log(`ADS could not write the generated entries: ${error.message}`);
42
+ }
43
+ }));
44
+ const changed = (file) => {
30
45
  const name = path.basename(String(file ?? ""));
31
- if (generatedThemeFiles.some(generated => name === generated || name.startsWith(`${generated}.`))) return;
46
+ if (generatedThemeFiles.some((generated) => name === generated || name.startsWith(`${generated}.`))) return;
32
47
  clearTimeout(timer);
33
48
  timer = setTimeout(refresh, 50);
34
49
  timer.unref?.();
35
50
  };
36
- refresh();
51
+ const ready = refresh();
37
52
  try {
38
53
  const { root, dsRoot, config } = loadConfig(directory);
39
- for (const [folder, filter] of [[path.join(dsRoot, config.tokenDir), file => String(file).endsWith(".css")], [root, file => String(file) === "ds.config.json"], [dsRoot, file => isExportsFile(String(file))]]) {
54
+ for (const [folder, filter] of [
55
+ [path.join(dsRoot, config.tokenDir), (file) => String(file).endsWith(".css")],
56
+ [root, (file) => String(file) === "ds.config.json"],
57
+ [dsRoot, (file) => isExportsFile(String(file))],
58
+ ]) {
40
59
  try {
41
- const watcher = watch(folder, { recursive: folder !== root }, (_event, file) => { if (file && filter(file)) changed(file); });
42
- watcher.unref(); watcher.on("error", () => watcher.close());
60
+ const watcher = watch(folder, { recursive: folder !== root }, (_event, file) => {
61
+ if (file && filter(file)) changed(file);
62
+ });
63
+ watcher.unref();
64
+ watcher.on("error", () => watcher.close());
43
65
  watchers.push(watcher);
44
- } catch { /* A missing token folder has nothing to generate from. */ }
66
+ } catch {
67
+ /* A missing token folder has nothing to generate from. */
68
+ }
45
69
  }
46
- } catch { /* An invalid configuration is reported by the server itself. */ }
47
- return { refresh, close() { clearTimeout(timer); for (const watcher of watchers) watcher.close(); } };
70
+ } catch {
71
+ /* An invalid configuration is reported by the server itself. */
72
+ }
73
+ return {
74
+ ready,
75
+ refresh,
76
+ async close() {
77
+ closed = true;
78
+ clearTimeout(timer);
79
+ for (const watcher of watchers) watcher.close();
80
+ await queue;
81
+ },
82
+ };
48
83
  }
package/dist/themes.mjs CHANGED
@@ -9,7 +9,10 @@ import { findingSeverity } from "./finding-rules.mjs";
9
9
  // and a resolver that picks the active theme's half on every themed or branded element, so
10
10
  // themes and brands nest at any depth, each following its nearest ancestor.
11
11
 
12
- export const defaultThemes = [{ name: "light", scheme: "light" }, { name: "dark", scheme: "dark" }];
12
+ export const defaultThemes = [
13
+ { name: "light", scheme: "light" },
14
+ { name: "dark", scheme: "dark" },
15
+ ];
13
16
 
14
17
  export function validateThemes(themes) {
15
18
  if (!Array.isArray(themes) || !themes.length || themes.length > 8) throw new Error("themes must list 1–8 themes; the first is the default.");
@@ -17,18 +20,20 @@ export function validateThemes(themes) {
17
20
  for (const [index, theme] of themes.entries()) {
18
21
  const field = `themes[${index}]`;
19
22
  if (!theme || typeof theme !== "object" || Array.isArray(theme)) throw new Error(`${field} must be an object with name and scheme.`);
20
- const unknown = Object.keys(theme).filter(key => !["name", "scheme"].includes(key));
23
+ const unknown = Object.keys(theme).filter((key) => !["name", "scheme"].includes(key));
21
24
  if (unknown.length) throw new Error(`${field} has unknown keys: ${unknown.join(", ")}.`);
22
- if (typeof theme.name !== "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(theme.name)) throw new Error(`${field}.name must be a lowercase name such as "dark" or "high-contrast".`);
23
- if (!["light", "dark"].includes(theme.scheme)) throw new Error(`${field}.scheme must be "light" or "dark": the color scheme browsers use for native controls.`);
25
+ if (typeof theme.name !== "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(theme.name))
26
+ throw new Error(`${field}.name must be a lowercase name such as "dark" or "high-contrast".`);
27
+ if (!["light", "dark"].includes(theme.scheme))
28
+ throw new Error(`${field}.scheme must be "light" or "dark": the color scheme browsers use for native controls.`);
24
29
  if (names.has(theme.name)) throw new Error(`Theme "${theme.name}" is declared twice.`);
25
30
  names.add(theme.name);
26
31
  }
27
32
  }
28
33
 
29
34
  const cache = new Map();
30
- const rootNode = node => node.type === "pseudo" && node.value.toLowerCase() === ":root" || node.type === "tag" && node.value.toLowerCase() === "html";
31
- const unquote = value => value.replace(/^["']|["']$/g, "");
35
+ const rootNode = (node) => (node.type === "pseudo" && node.value.toLowerCase() === ":root") || (node.type === "tag" && node.value.toLowerCase() === "html");
36
+ const unquote = (value) => value.replace(/^["']|["']$/g, "");
32
37
 
33
38
  /** Where a token declaration applies: the default brand ({ kind: "root" }: :root or html, or the
34
39
  * default brand's [data-brand]), one brand ({ kind: "brand", brand }), the old theme form
@@ -42,9 +47,10 @@ export function classifyScope(scope, defaultBrand) {
42
47
  else if (scope.includes("@") || scope.includes(" > ")) result = { kind: "conditional" };
43
48
  else {
44
49
  try {
45
- let old = false, other = false;
50
+ let old = false,
51
+ other = false;
46
52
  const brands = [];
47
- selectorParser(root => {
53
+ selectorParser((root) => {
48
54
  for (const selector of root.nodes) {
49
55
  let brand = null;
50
56
  for (const node of selector.nodes) {
@@ -60,15 +66,24 @@ export function classifyScope(scope, defaultBrand) {
60
66
  brands.push(brand === defaultBrand ? null : brand);
61
67
  }
62
68
  }).processSync(scope);
63
- result = old ? { kind: "old" } : other ? { kind: "conditional" } : new Set(brands).size > 1 ? { kind: "old" }
64
- : brands[0] === null ? { kind: "root" } : { kind: "brand", brand: brands[0] };
65
- } catch { result = { kind: "conditional" }; }
69
+ result = old
70
+ ? { kind: "old" }
71
+ : other
72
+ ? { kind: "conditional" }
73
+ : new Set(brands).size > 1
74
+ ? { kind: "old" }
75
+ : brands[0] === null
76
+ ? { kind: "root" }
77
+ : { kind: "brand", brand: brands[0] };
78
+ } catch {
79
+ result = { kind: "conditional" };
80
+ }
66
81
  }
67
82
  cache.set(key, result);
68
83
  return result;
69
84
  }
70
85
 
71
- const plainScope = where => where.kind === "root" || where.kind === "brand";
86
+ const plainScope = (where) => where.kind === "root" || where.kind === "brand";
72
87
 
73
88
  /** Token definitions from the token sheets' custom property declarations ({ prop, value, file,
74
89
  * line, column, scope }, in source order). A name ending in a declared theme's name is a half
@@ -77,13 +92,13 @@ const plainScope = where => where.kind === "root" || where.kind === "brand";
77
92
  * default brand); a half's value names other halves of its own theme by their token name, and
78
93
  * keeps the authored text and property. */
79
94
  export function buildTokens(declarations, { themes = defaultThemes, brands = [] } = {}) {
80
- const names = themes.map(theme => theme.name).sort((a, b) => b.length - a.length);
81
- const split = prop => {
95
+ const names = themes.map((theme) => theme.name).sort((a, b) => b.length - a.length);
96
+ const split = (prop) => {
82
97
  if (themes.length < 2) return null;
83
98
  for (const name of names) if (prop.endsWith(`-${name}`) && prop.length > name.length + 3) return { base: prop.slice(0, -name.length - 1), theme: name };
84
99
  return null;
85
100
  };
86
- const entries = declarations.map(declaration => ({ ...declaration, where: classifyScope(declaration.scope, brands[0]?.name) }));
101
+ const entries = declarations.map((declaration) => ({ ...declaration, where: classifyScope(declaration.scope, brands[0]?.name) }));
87
102
  const halves = new Map();
88
103
  for (const entry of entries) {
89
104
  const half = plainScope(entry.where) && split(entry.prop);
@@ -92,12 +107,15 @@ export function buildTokens(declarations, { themes = defaultThemes, brands = []
92
107
  halves.get(half.base).add(half.theme);
93
108
  }
94
109
  const themed = new Set([...halves].filter(([, set]) => set.size > 1).map(([base]) => base));
95
- const halfOf = prop => { const half = split(prop); return half && themed.has(half.base) ? half : null; };
110
+ const halfOf = (prop) => {
111
+ const half = split(prop);
112
+ return half && themed.has(half.base) ? half : null;
113
+ };
96
114
  const normalize = (value, theme) => {
97
115
  const parsed = valueParser(value);
98
- parsed.walk(node => {
116
+ parsed.walk((node) => {
99
117
  if (node.type !== "function" || node.value !== "var") return;
100
- const word = node.nodes.find(child => child.type === "word");
118
+ const word = node.nodes.find((child) => child.type === "word");
101
119
  const half = word && halfOf(word.value);
102
120
  if (half?.theme === theme) word.value = half.base;
103
121
  });
@@ -105,32 +123,44 @@ export function buildTokens(declarations, { themes = defaultThemes, brands = []
105
123
  };
106
124
  const tokens = new Map();
107
125
  for (const entry of entries) {
108
- const half = halfOf(entry.prop), name = half ? half.base : entry.prop;
109
- const definition = { file: entry.file, line: entry.line, column: entry.column, scope: entry.scope, value: half ? normalize(entry.value, half.theme) : entry.value,
110
- theme: half?.theme ?? null, brand: entry.where.kind === "brand" ? entry.where.brand : null,
126
+ const half = halfOf(entry.prop),
127
+ name = half ? half.base : entry.prop;
128
+ const definition = {
129
+ file: entry.file,
130
+ line: entry.line,
131
+ column: entry.column,
132
+ scope: entry.scope,
133
+ value: half ? normalize(entry.value, half.theme) : entry.value,
134
+ theme: half?.theme ?? null,
135
+ brand: entry.where.kind === "brand" ? entry.where.brand : null,
111
136
  ...(half ? { property: entry.prop, authored: entry.value } : {}),
112
- ...(entry.where.kind === "conditional" ? { conditional: true } : entry.where.kind === "old" ? { conditional: true, old: true } : {}) };
137
+ ...(entry.where.kind === "conditional" ? { conditional: true } : entry.where.kind === "old" ? { conditional: true, old: true } : {}),
138
+ };
113
139
  if (!tokens.has(name)) tokens.set(name, []);
114
140
  tokens.get(name).push(definition);
115
141
  }
116
- return [...tokens].sort(([a], [b]) => a.localeCompare(b)).map(([name, definitions]) => ({ name, ...(themed.has(name) ? { themed: true } : {}), definitions }));
142
+ return [...tokens]
143
+ .sort(([a], [b]) => a.localeCompare(b))
144
+ .map(([name, definitions]) => ({ name, ...(themed.has(name) ? { themed: true } : {}), definitions }));
117
145
  }
118
146
 
119
- const applies = definition => !definition.conditional;
147
+ const applies = (definition) => !definition.conditional;
120
148
 
121
149
  /** A token's definition where a theme and a brand apply: the brand's own one, else the default
122
150
  * brand's; within a brand the theme's half, else the single value. Undefined brand = default. */
123
151
  export function contextDefinition(token, { theme, brand } = {}) {
124
- const matches = definition => applies(definition) && (definition.theme === null || definition.theme === theme);
125
- return (brand !== undefined && brand !== null ? token.definitions.findLast(definition => definition.brand === brand && matches(definition)) : undefined)
126
- ?? token.definitions.findLast(definition => definition.brand === null && matches(definition));
152
+ const matches = (definition) => applies(definition) && (definition.theme === null || definition.theme === theme);
153
+ return (
154
+ (brand !== undefined && brand !== null ? token.definitions.findLast((definition) => definition.brand === brand && matches(definition)) : undefined) ??
155
+ token.definitions.findLast((definition) => definition.brand === null && matches(definition))
156
+ );
127
157
  }
128
158
 
129
159
  /** A token's default-brand definition: its single value, else its half for the named theme
130
160
  * (the first half when no theme is named). */
131
161
  export function baseDefinition(token, theme) {
132
- const own = token.definitions.filter(definition => applies(definition) && definition.brand === null);
133
- return own.findLast(definition => definition.theme === null) ?? own.find(definition => theme === undefined || definition.theme === theme);
162
+ const own = token.definitions.filter((definition) => applies(definition) && definition.brand === null);
163
+ return own.findLast((definition) => definition.theme === null) ?? own.find((definition) => theme === undefined || definition.theme === theme);
134
164
  }
135
165
 
136
166
  /** A token's default-brand definition in one theme. */
@@ -161,78 +191,144 @@ export function resolveValue(values, name, seen = new Set()) {
161
191
  return values.has(reference[1]) ? resolveValue(values, reference[1], new Set([...seen, name])) : reference[2]?.trim() || null;
162
192
  }
163
193
 
164
- export const referencedTokens = value => {
194
+ export const referencedTokens = (value) => {
165
195
  const names = [];
166
- valueParser(value).walk(node => { if (node.type === "function" && node.value === "var") { const word = node.nodes.find(child => child.type === "word"); if (word?.value.startsWith("--")) names.push(word.value); } });
196
+ valueParser(value).walk((node) => {
197
+ if (node.type === "function" && node.value === "var") {
198
+ const word = node.nodes.find((child) => child.type === "word");
199
+ if (word?.value.startsWith("--")) names.push(word.value);
200
+ }
201
+ });
167
202
  return names;
168
203
  };
169
204
 
170
205
  /** Tokens that follow the theme: themed tokens and every default single value that refers to
171
206
  * one, directly or through other tokens. The generated resolver re-resolves them per element. */
172
207
  export function themeDependents(tokens) {
173
- const dependent = new Set(tokens.filter(token => token.themed).map(token => token.name));
174
- for (let changed = true; changed;) {
208
+ const dependent = new Set(tokens.filter((token) => token.themed).map((token) => token.name));
209
+ for (let changed = true; changed; ) {
175
210
  changed = false;
176
211
  for (const token of tokens) {
177
212
  if (dependent.has(token.name)) continue;
178
213
  const base = baseDefinition(token);
179
- if (base && base.theme === null && referencedTokens(base.value).some(name => dependent.has(name))) { dependent.add(token.name); changed = true; }
214
+ if (base && base.theme === null && referencedTokens(base.value).some((name) => dependent.has(name))) {
215
+ dependent.add(token.name);
216
+ changed = true;
217
+ }
180
218
  }
181
219
  }
182
220
  return dependent;
183
221
  }
184
222
 
185
- export const nameList = names => names.length === 1 ? names[0] : `${names.length} tokens (${names.slice(0, 3).join(", ")}${names.length > 3 ? ", …" : ""})`;
223
+ export const nameList = (names) => (names.length === 1 ? names[0] : `${names.length} tokens (${names.slice(0, 3).join(", ")}${names.length > 3 ? ", …" : ""})`);
186
224
 
187
225
  /** The theme form: old [data-theme] value blocks are errors; a themed token has a default half
188
226
  * for every declared theme, only halves, and halves that refer to other halves. */
189
227
  export function themeFindings(tokens, themes, { dsDir } = {}) {
190
- const diagnostics = [], advisories = [];
191
- const error = (rule, at, message, names) => diagnostics.push({ rule, file: at.file, line: at.line, column: at.column, ...(names ? { tokens: names } : {}), message });
192
- const finding = (rule, at, message, names) => (findingSeverity(rule) === "error" ? diagnostics : advisories).push({ rule, severity: findingSeverity(rule), file: at.file, line: at.line, column: at.column, ...(names ? { tokens: names } : {}), guidanceUri: "ads://guides/tokens", message });
228
+ const diagnostics = [],
229
+ advisories = [];
230
+ const error = (rule, at, message, names) =>
231
+ diagnostics.push({ rule, file: at.file, line: at.line, column: at.column, ...(names ? { tokens: names } : {}), message });
232
+ const finding = (rule, at, message, names) =>
233
+ (findingSeverity(rule) === "error" ? diagnostics : advisories).push({
234
+ rule,
235
+ severity: findingSeverity(rule),
236
+ file: at.file,
237
+ line: at.line,
238
+ column: at.column,
239
+ ...(names ? { tokens: names } : {}),
240
+ guidanceUri: "ads://guides/tokens",
241
+ message,
242
+ });
193
243
  // One finding per old rule, naming what it sets.
194
244
  const old = new Map();
195
- for (const token of tokens) for (const definition of token.definitions.filter(definition => definition.old)) {
196
- const key = `${definition.file}\0${definition.scope}`;
197
- if (!old.has(key)) old.set(key, { at: definition, names: [] });
198
- old.get(key).names.push(token.name);
199
- }
245
+ for (const token of tokens)
246
+ for (const definition of token.definitions.filter((definition) => definition.old)) {
247
+ const key = `${definition.file}\0${definition.scope}`;
248
+ if (!old.has(key)) old.set(key, { at: definition, names: [] });
249
+ old.get(key).names.push(token.name);
250
+ }
200
251
  for (const { at, names } of [...old.values()].sort((a, b) => a.at.file.localeCompare(b.at.file) || a.at.line - b.at.line)) {
201
- const theme = at.scope.match(/data-theme\s*=\s*["']?([\w-]+)/)?.[1] ?? (/prefers-color-scheme\s*:\s*dark/.test(at.scope) ? "dark" : themes[1]?.name ?? themes[0].name);
202
- error("theme-old-form", at, `Old theme form: ${at.scope} sets ${nameList(names)}. Write per-theme halves on :root (or [data-brand="<name>"]) instead, such as ${names[0]}-${theme}; ADS generates the theme switches.`, names);
252
+ const theme =
253
+ at.scope.match(/data-theme\s*=\s*["']?([\w-]+)/)?.[1] ??
254
+ (/prefers-color-scheme\s*:\s*dark/.test(at.scope) ? "dark" : (themes[1]?.name ?? themes[0].name));
255
+ error(
256
+ "theme-old-form",
257
+ at,
258
+ `Old theme form: ${at.scope} sets ${nameList(names)}. Write per-theme halves on :root (or [data-brand="<name>"]) instead, such as ${names[0]}-${theme}; ADS generates the theme switches.`,
259
+ names,
260
+ );
203
261
  }
204
262
  if (themes.length < 2) return { diagnostics, advisories };
205
263
  const dependent = themeDependents(tokens);
206
- for (const token of tokens.filter(token => token.themed)) {
207
- const own = token.definitions.filter(definition => applies(definition) && definition.brand === null);
208
- const single = own.find(definition => definition.theme === null);
209
- if (single) error("theme-half-conflict", single, `${token.name} is set both as one value and as per-theme halves (${token.definitions.find(definition => definition.property)?.property}, …); keep only the halves.`, [token.name]);
210
- const missing = own.length ? themes.filter(theme => !own.some(definition => definition.theme === theme.name)).map(theme => theme.name) : [];
211
- if (missing.length) error("theme-coverage", own.find(definition => definition.theme !== null) ?? own[0], `${token.name} has no ${missing.map(name => `${token.name}-${name}`).join(", ")} on :root; a themed token needs a half for every declared theme, or it is unset in ${missing.join(", ")}.`, [token.name]);
264
+ for (const token of tokens.filter((token) => token.themed)) {
265
+ const own = token.definitions.filter((definition) => applies(definition) && definition.brand === null);
266
+ const single = own.find((definition) => definition.theme === null);
267
+ if (single)
268
+ error(
269
+ "theme-half-conflict",
270
+ single,
271
+ `${token.name} is set both as one value and as per-theme halves (${token.definitions.find((definition) => definition.property)?.property}, …); keep only the halves.`,
272
+ [token.name],
273
+ );
274
+ const missing = own.length ? themes.filter((theme) => !own.some((definition) => definition.theme === theme.name)).map((theme) => theme.name) : [];
275
+ if (missing.length)
276
+ error(
277
+ "theme-coverage",
278
+ own.find((definition) => definition.theme !== null) ?? own[0],
279
+ `${token.name} has no ${missing.map((name) => `${token.name}-${name}`).join(", ")} on :root; a themed token needs a half for every declared theme, or it is unset in ${missing.join(", ")}.`,
280
+ [token.name],
281
+ );
212
282
  }
213
283
  // A half is resolved where it is declared, on :root or a brand: it names halves, not tokens that follow the theme.
214
- const byName = new Map(tokens.map(token => [token.name, token]));
284
+ const byName = new Map(tokens.map((token) => [token.name, token]));
215
285
  // The half a theme-following alias stands for: --accent → --color-accent-9 → --color-accent-9-dark.
216
286
  const halfFor = (name, theme, seen = new Set()) => {
217
287
  const token = byName.get(name);
218
288
  if (token?.themed) return `${name}-${theme}`;
219
- const alias = !seen.has(name) && baseDefinition(token ?? { definitions: [] })?.value.trim().match(/^var\(\s*(--[\w-]+)\s*\)$/)?.[1];
289
+ const alias =
290
+ !seen.has(name) &&
291
+ baseDefinition(token ?? { definitions: [] })
292
+ ?.value.trim()
293
+ .match(/^var\(\s*(--[\w-]+)\s*\)$/)?.[1];
220
294
  return alias ? halfFor(alias, theme, new Set([...seen, name])) : null;
221
295
  };
222
- for (const token of tokens.filter(token => token.themed)) for (const definition of token.definitions.filter(definition => applies(definition) && definition.authored)) {
223
- const wrong = referencedTokens(definition.authored).filter(name => dependent.has(name));
224
- if (wrong.length) error("theme-half-reference", definition, `${definition.property} refers to ${wrong.join(", ")}, which follows the theme; a half is resolved where it is declared, so refer to ${wrong.map(name => halfFor(name, definition.theme) ?? `halves of ${name}`).join(", ")}.`, [token.name]);
225
- }
296
+ for (const token of tokens.filter((token) => token.themed))
297
+ for (const definition of token.definitions.filter((definition) => applies(definition) && definition.authored)) {
298
+ const wrong = referencedTokens(definition.authored).filter((name) => dependent.has(name));
299
+ if (wrong.length)
300
+ error(
301
+ "theme-half-reference",
302
+ definition,
303
+ `${definition.property} refers to ${wrong.join(", ")}, which follows the theme; a half is resolved where it is declared, so refer to ${wrong.map((name) => halfFor(name, definition.theme) ?? `halves of ${name}`).join(", ")}.`,
304
+ [token.name],
305
+ );
306
+ }
226
307
  // A lone half-like name: the other themes' halves are missing, so it is a plain token.
227
- const declared = new Set(tokens.map(token => token.name));
228
- for (const token of tokens.filter(token => !token.themed)) {
229
- const theme = themes.slice(1).find(theme => token.name.endsWith(`-${theme.name}`));
308
+ const declared = new Set(tokens.map((token) => token.name));
309
+ for (const token of tokens.filter((token) => !token.themed)) {
310
+ const theme = themes.slice(1).find((theme) => token.name.endsWith(`-${theme.name}`));
230
311
  const base = theme && token.name.slice(0, -theme.name.length - 1);
231
312
  const at = token.definitions.find(applies);
232
- if (base && at && !declared.has(base)) finding("theme-new-token", at, `${token.name} reads as the ${theme.name} half of ${base}, but no other theme gives ${base}; add ${themes.filter(item => item !== theme).map(item => `${base}-${item.name}`).join(", ")} on :root, or rename it.`, [token.name]);
313
+ if (base && at && !declared.has(base))
314
+ finding(
315
+ "theme-new-token",
316
+ at,
317
+ `${token.name} reads as the ${theme.name} half of ${base}, but no other theme gives ${base}; add ${themes
318
+ .filter((item) => item !== theme)
319
+ .map((item) => `${base}-${item.name}`)
320
+ .join(", ")} on :root, or rename it.`,
321
+ [token.name],
322
+ );
233
323
  }
234
324
  // While the old form remains, theme-old-form already names what to write.
235
- if (!tokens.some(token => token.themed) && !old.size && dsDir) for (const theme of themes.slice(1)) finding("theme-empty", { file: dsDir, line: 1, column: 1 }, `Theme "${theme.name}" is declared but no token has a ${theme.name} half; give the tokens that change per theme halves such as --color-accent-9-${themes[0].name} and --color-accent-9-${theme.name}, or remove it from ds.config.json.`);
325
+ if (!tokens.some((token) => token.themed) && !old.size && dsDir)
326
+ for (const theme of themes.slice(1))
327
+ finding(
328
+ "theme-empty",
329
+ { file: dsDir, line: 1, column: 1 },
330
+ `Theme "${theme.name}" is declared but no token has a ${theme.name} half; give the tokens that change per theme halves such as --color-accent-9-${themes[0].name} and --color-accent-9-${theme.name}, or remove it from ds.config.json.`,
331
+ );
236
332
  return { diagnostics, advisories };
237
333
  }
238
334
 
@@ -242,16 +338,23 @@ export function themeFindings(tokens, themes, { dsDir } = {}) {
242
338
  export function themeAncestorSelector(selector) {
243
339
  let found = false;
244
340
  try {
245
- selectorParser(root => root.walkAttributes(node => {
246
- if (!["data-theme", "data-brand"].includes(node.attribute)) return;
247
- // The selector's own subject compound (&[data-theme="dark"]) is the section itself.
248
- let top = node;
249
- while (top.parent && top.parent.type !== "root") top = top.parent;
250
- const compound = top.nodes, index = compound.indexOf(node);
251
- const own = index >= 0 && !compound.slice(index).some(part => part.type === "combinator")
252
- && !compound.some(part => part.type === "pseudo" && part.value.toLowerCase() === ":root");
253
- if (!own) found = true;
254
- })).processSync(selector);
255
- } catch { /* CSS syntax diagnostics are owned by the parser/build. */ }
341
+ selectorParser((root) =>
342
+ root.walkAttributes((node) => {
343
+ if (!["data-theme", "data-brand"].includes(node.attribute)) return;
344
+ // The selector's own subject compound (&[data-theme="dark"]) is the section itself.
345
+ let top = node;
346
+ while (top.parent && top.parent.type !== "root") top = top.parent;
347
+ const compound = top.nodes,
348
+ index = compound.indexOf(node);
349
+ const own =
350
+ index >= 0 &&
351
+ !compound.slice(index).some((part) => part.type === "combinator") &&
352
+ !compound.some((part) => part.type === "pseudo" && part.value.toLowerCase() === ":root");
353
+ if (!own) found = true;
354
+ }),
355
+ ).processSync(selector);
356
+ } catch {
357
+ /* CSS syntax diagnostics are owned by the parser/build. */
358
+ }
256
359
  return found;
257
360
  }
@@ -11,10 +11,11 @@ const extension = "org.reqvire.ads";
11
11
 
12
12
  /** A token's path in the export: its family, then the rest of its name. */
13
13
  function tokenPath(name) {
14
- const bare = name.slice(2), dash = bare.indexOf("-");
14
+ const bare = name.slice(2),
15
+ dash = bare.indexOf("-");
15
16
  return dash < 0 ? [bare, "$root"] : [bare.slice(0, dash), bare.slice(dash + 1)];
16
17
  }
17
- const reference = name => `{${tokenPath(name).join(".")}}`;
18
+ const reference = (name) => `{${tokenPath(name).join(".")}}`;
18
19
 
19
20
  /** A CSS value as a DTCG value and type, or null when the format cannot express it. */
20
21
  function typed(name, value) {
@@ -23,8 +24,19 @@ function typed(name, value) {
23
24
  if (alias) return { $value: reference(alias[1]) };
24
25
  const color = parseColor(text);
25
26
  if (color && !/^(?:--font-|--weight-|--leading-|--z-)/.test(name)) {
26
- const hex = `#${color.slice(0, 3).map(channel => Math.round(channel).toString(16).padStart(2, "0")).join("")}`;
27
- return { $type: "color", $value: { colorSpace: "srgb", components: color.slice(0, 3).map(channel => Number((channel / 255).toFixed(4))), ...(color[3] < 1 ? { alpha: color[3] } : {}), hex } };
27
+ const hex = `#${color
28
+ .slice(0, 3)
29
+ .map((channel) => Math.round(channel).toString(16).padStart(2, "0"))
30
+ .join("")}`;
31
+ return {
32
+ $type: "color",
33
+ $value: {
34
+ colorSpace: "srgb",
35
+ components: color.slice(0, 3).map((channel) => Number((channel / 255).toFixed(4))),
36
+ ...(color[3] < 1 ? { alpha: color[3] } : {}),
37
+ hex,
38
+ },
39
+ };
28
40
  }
29
41
  let match = text.match(/^(-?\d*\.?\d+)(px|rem)$/);
30
42
  if (match) return { $type: "dimension", $value: { value: Number(match[1]), unit: match[2] } };
@@ -32,7 +44,7 @@ function typed(name, value) {
32
44
  if (match) return { $type: "duration", $value: { value: Number(match[1]), unit: match[2] } };
33
45
  match = text.match(/^cubic-bezier\(([^)]*)\)$/);
34
46
  if (match) return { $type: "cubicBezier", $value: match[1].split(",").map(Number) };
35
- if (name.startsWith("--font-")) return { $type: "fontFamily", $value: text.split(",").map(family => family.trim().replace(/^["']|["']$/g, "")) };
47
+ if (name.startsWith("--font-")) return { $type: "fontFamily", $value: text.split(",").map((family) => family.trim().replace(/^["']|["']$/g, "")) };
36
48
  if (name.startsWith("--weight-") && /^\d+$/.test(text)) return { $type: "fontWeight", $value: Number(text) };
37
49
  if (/^-?\d*\.?\d+$/.test(text)) return { $type: "number", $value: Number(text) };
38
50
  return null;
@@ -40,12 +52,18 @@ function typed(name, value) {
40
52
 
41
53
  /** The project's tokens as one DTCG document, with the values of one theme and one brand
42
54
  * (default: the first of each). */
43
- export function exportTokensDtcg(directory, { theme, brand } = {}) {
44
- const { tokens, themes, brands = [] } = inspectTokens(directory);
45
- if (theme !== undefined && !themes.some(item => item.name === theme)) throw new Error(`Unknown theme "${theme}"; the project declares ${themes.map(item => item.name).join(", ")}.`);
46
- if (brand !== undefined && !brands.some(item => item.name === brand)) throw new Error(`Unknown brand "${brand}"; ${brands.length ? `the project declares ${brands.map(item => item.name).join(", ")}` : "the project declares no brands"}.`);
47
- const selected = theme ?? themes[0].name, own = brand === brands[0]?.name ? undefined : brand;
48
- const names = new Set(tokens.map(token => token.name));
55
+ export async function exportTokensDtcg(directory, { theme, brand } = {}, inventory) {
56
+ if (inventory === undefined) inventory = await inspectTokens(directory);
57
+ const { tokens, themes, brands = [] } = inventory;
58
+ if (theme !== undefined && !themes.some((item) => item.name === theme))
59
+ throw new Error(`Unknown theme "${theme}"; the project declares ${themes.map((item) => item.name).join(", ")}.`);
60
+ if (brand !== undefined && !brands.some((item) => item.name === brand))
61
+ throw new Error(
62
+ `Unknown brand "${brand}"; ${brands.length ? `the project declares ${brands.map((item) => item.name).join(", ")}` : "the project declares no brands"}.`,
63
+ );
64
+ const selected = theme ?? themes[0].name,
65
+ own = brand === brands[0]?.name ? undefined : brand;
66
+ const names = new Set(tokens.map((token) => token.name));
49
67
  let values;
50
68
  const document = {};
51
69
  for (const token of tokens) {
@@ -53,13 +71,20 @@ export function exportTokensDtcg(directory, { theme, brand } = {}) {
53
71
  if (!base) continue;
54
72
  // A half that names another theme's half has no DTCG alias; export its resolved value.
55
73
  const alias = base.value.trim().match(/^var\(\s*(--[\w-]+)\s*\)$/)?.[1];
56
- const value = alias && !names.has(alias) ? resolveValue(values ??= contextValues(tokens, { theme: selected, brand: own, themes }), token.name) ?? base.value : base.value;
74
+ const value =
75
+ alias && !names.has(alias)
76
+ ? (resolveValue((values ??= contextValues(tokens, { theme: selected, brand: own, themes })), token.name) ?? base.value)
77
+ : base.value;
57
78
  const entry = typed(token.name, value) ?? { $value: value.trim() };
58
79
  if (!("$type" in entry) && !entry.$value.toString().startsWith("{")) entry.$extensions = { [extension]: { css: value.trim() } };
59
80
  if (token.meaning) entry.$description = token.meaning;
60
81
  // The other contexts: a theme ("dark"), a brand ("acme") or both ("acme/dark"), or a condition.
61
- const label = definition => definition.conditional ? definition.scope : [definition.brand, definition.theme].filter(Boolean).join("/") || "default";
62
- const others = Object.fromEntries(token.definitions.filter(definition => definition !== base).map(definition => [label(definition), (typed(token.name, definition.value) ?? { $value: definition.value.trim() }).$value]));
82
+ const label = (definition) => (definition.conditional ? definition.scope : [definition.brand, definition.theme].filter(Boolean).join("/") || "default");
83
+ const others = Object.fromEntries(
84
+ token.definitions
85
+ .filter((definition) => definition !== base)
86
+ .map((definition) => [label(definition), (typed(token.name, definition.value) ?? { $value: definition.value.trim() }).$value]),
87
+ );
63
88
  if (Object.keys(others).length) entry.$extensions = { ...entry.$extensions, [extension]: { ...entry.$extensions?.[extension], values: others } };
64
89
  const [group, key] = tokenPath(token.name);
65
90
  document[group] ??= {};
@@ -5,8 +5,11 @@ import valueParser from "postcss-value-parser";
5
5
  export const tokenContract = JSON.parse(readFileSync(new URL("./contracts/tokens.json", import.meta.url), "utf8"));
6
6
 
7
7
  export function isSharedToken(name) {
8
- return name in tokenContract.tokens || tokenContract.naming.names.includes(name)
9
- || tokenContract.naming.prefixes.some((prefix) => name.startsWith(prefix) && name.length > prefix.length);
8
+ return (
9
+ name in tokenContract.tokens ||
10
+ tokenContract.naming.names.includes(name) ||
11
+ tokenContract.naming.prefixes.some((prefix) => name.startsWith(prefix) && name.length > prefix.length)
12
+ );
10
13
  }
11
14
 
12
15
  // The foundation sheets in import order; themes.generated.css comes last, after every sheet it re-applies.
@@ -15,7 +18,7 @@ export const foundationFiles = ["fonts.css", "colors.css", "typography.css", "sp
15
18
  /** The foundation entry accepts only a single, unconditional local import. */
16
19
  export function foundationImportTarget(node, file) {
17
20
  if (node.type !== "atrule" || node.name !== "import" || node.nodes) return null;
18
- const parts = valueParser(node.params).nodes.filter(part => part.type !== "space" && part.type !== "comment");
21
+ const parts = valueParser(node.params).nodes.filter((part) => part.type !== "space" && part.type !== "comment");
19
22
  if (parts.length !== 1) return null;
20
23
  const part = parts[0];
21
24
  const value = part.type === "string" ? part.value : part.type === "function" && part.value === "url" && part.nodes.length === 1 ? part.nodes[0].value : null;