@reqvire-org/ads 0.4.0 → 0.4.2

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 (394) hide show
  1. package/README.md +105 -86
  2. package/dist/a11y.mjs +108 -29
  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 +140 -0
  7. package/dist/analysis/impact.mjs +20 -0
  8. package/dist/analysis/inputs.mjs +15 -0
  9. package/dist/analysis/native-adapter.mjs +180 -0
  10. package/dist/analysis/native-project.mjs +323 -0
  11. package/dist/analysis/queries.mjs +133 -0
  12. package/dist/analysis/service.mjs +146 -0
  13. package/dist/analysis/standalone.mjs +57 -0
  14. package/dist/analysis/syntax.mjs +164 -0
  15. package/dist/analysis/worker.mjs +182 -0
  16. package/dist/assets.mjs +5 -5
  17. package/dist/atomic-composition.mjs +191 -70
  18. package/dist/atomic-trace.mjs +120 -50
  19. package/dist/behavior-libraries.mjs +106 -37
  20. package/dist/behaviors.mjs +219 -77
  21. package/dist/boundaries.mjs +135 -38
  22. package/dist/brand-assets.mjs +219 -47
  23. package/dist/brands.mjs +86 -27
  24. package/dist/bun-compiler.mjs +28 -14
  25. package/dist/bun-worker.mjs +7 -5
  26. package/dist/capture/worker.mjs +15 -4
  27. package/dist/capture-store.mjs +4 -2
  28. package/dist/capture.mjs +17 -14
  29. package/dist/check-service.mjs +40 -57
  30. package/dist/check.mjs +749 -188
  31. package/dist/cli.mjs +200 -99
  32. package/dist/color-values.mjs +21 -21
  33. package/dist/component-contrast.mjs +2 -2
  34. package/dist/config.mjs +303 -135
  35. package/dist/construction-styles.cjs +10 -0
  36. package/dist/control-padding.mjs +45 -25
  37. package/dist/css-values.mjs +3 -2
  38. package/dist/declarative-flow.mjs +209 -109
  39. package/dist/design-values.mjs +136 -51
  40. package/dist/development-runtime.mjs +4 -6
  41. package/dist/draft-boundary.mjs +11 -6
  42. package/dist/evidence.mjs +1 -1
  43. package/dist/finding-rules.mjs +7 -5
  44. package/dist/font-rules.mjs +2 -2
  45. package/dist/fonts-generated.mjs +2 -2
  46. package/dist/foundation-views.mjs +238 -0
  47. package/dist/foundation.mjs +63 -39
  48. package/dist/generated-entries.mjs +101 -34
  49. package/dist/icons.mjs +79 -32
  50. package/dist/image-attributes.mjs +109 -36
  51. package/dist/image-size.mjs +1 -1
  52. package/dist/index.mjs +0 -2
  53. package/dist/init.mjs +122 -41
  54. package/dist/investigations.mjs +2 -2
  55. package/dist/layers.mjs +298 -129
  56. package/dist/layout-widths.mjs +180 -85
  57. package/dist/linaria/preserve-values.cjs +7 -0
  58. package/dist/linaria/spatial-inputs.cjs +56 -0
  59. package/dist/lockup-composition.mjs +44 -0
  60. package/dist/lockup-model.cjs +64 -0
  61. package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
  62. package/dist/mcp/apps.mjs +4 -30
  63. package/dist/mcp/behavior-pages.mjs +72 -24
  64. package/dist/mcp/build-status.mjs +257 -64
  65. package/dist/mcp/catalog.mjs +90 -26
  66. package/dist/mcp/context.mjs +17 -18
  67. package/dist/mcp/draft-discovery.mjs +44 -21
  68. package/dist/mcp/drafts.mjs +901 -281
  69. package/dist/mcp/execution-coordinator.mjs +417 -167
  70. package/dist/mcp/execution-results.mjs +7 -7
  71. package/dist/mcp/mutations.mjs +670 -234
  72. package/dist/mcp/preview-watch.mjs +448 -170
  73. package/dist/mcp/preview-widget.bundle.js +44 -50
  74. package/dist/mcp/prompts.mjs +5 -5
  75. package/dist/mcp/result-pages.mjs +1 -1
  76. package/dist/mcp/sandbox-host.mjs +1 -1
  77. package/dist/mcp/server.mjs +2402 -577
  78. package/dist/mcp/showcase-host.mjs +165 -41
  79. package/dist/mcp/skills.mjs +1 -1
  80. package/dist/mcp/text-diff.mjs +29 -10
  81. package/dist/paint-contracts.mjs +174 -81
  82. package/dist/palette-generated.mjs +2 -2
  83. package/dist/preview-bun.mjs +493 -187
  84. package/dist/preview-failure.mjs +1 -1
  85. package/dist/preview-files.mjs +13 -13
  86. package/dist/preview-imports.mjs +104 -55
  87. package/dist/preview-inputs.mjs +2 -2
  88. package/dist/preview-requests.mjs +24 -0
  89. package/dist/preview-resources.mjs +288 -147
  90. package/dist/preview-scope.mjs +5 -4
  91. package/dist/program-cache.mjs +8 -34
  92. package/dist/project-documents.mjs +1 -1
  93. package/dist/public-api.mjs +69 -31
  94. package/dist/public-props.mjs +39 -22
  95. package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
  96. package/dist/{browser-audit → render-audit}/image-shape.mjs +2 -2
  97. package/dist/{browser-audit → render-audit}/layout-overflow.mjs +86 -23
  98. package/dist/{browser-audit → render-audit}/non-text-contrast.mjs +86 -27
  99. package/dist/{browser-audit → render-audit}/render-states.mjs +208 -52
  100. package/dist/{browser-audit → render-audit}/worker.mjs +86 -30
  101. package/dist/render-audit.mjs +828 -0
  102. package/dist/render-color-probe.mjs +96 -42
  103. package/dist/resource-limits.mjs +229 -97
  104. package/dist/runtime-contracts.mjs +467 -185
  105. package/dist/scenario-groups.mjs +22 -10
  106. package/dist/scenario-inspector.mjs +6 -43
  107. package/dist/scenario-program.mjs +8 -25
  108. package/dist/scenario-registry.mjs +72 -30
  109. package/dist/scenario-selectors.mjs +161 -64
  110. package/dist/scenario-slots.mjs +149 -56
  111. package/dist/scenario-trace.mjs +215 -109
  112. package/dist/scenarios-compiler.mjs +719 -378
  113. package/dist/scenarios-vite.d.mts +1 -3
  114. package/dist/scenarios-vite.mjs +2 -81
  115. package/dist/scenarios.mjs +421 -157
  116. package/dist/selector-match.mjs +2 -2
  117. package/dist/showcase/client.bundle.js +57 -56
  118. package/dist/showcase/draft-navigation.js +18 -0
  119. package/dist/showcase/favicon.ico +0 -0
  120. package/dist/showcase/favicon.svg +1 -0
  121. package/dist/showcase/foundation-view.css +55 -0
  122. package/dist/showcase/foundation-view.mjs +252 -0
  123. package/dist/showcase/guide-controls.ads.review.mjs +32 -0
  124. package/dist/showcase/icons.js +1 -145
  125. package/dist/showcase/index.html +3 -31
  126. package/dist/showcase/preview-frame.ads.review.css +46 -0
  127. package/dist/showcase/preview-frame.ads.review.d.mts +11 -0
  128. package/dist/showcase/preview-frame.ads.review.mjs +22 -0
  129. package/dist/showcase/preview-state.js +0 -9
  130. package/dist/showcase/refresh-scheduler.js +23 -0
  131. package/dist/showcase/style.css +5 -47
  132. package/dist/showcase/ui/ui.css +1353 -0
  133. package/dist/showcase/ui/ui.js +1062 -0
  134. package/dist/showcase-coverage.mjs +58 -37
  135. package/dist/skills/README.md +24 -23
  136. package/dist/skills/ads-designer/README.md +8 -2
  137. package/dist/skills/ads-designer/SKILL.md +130 -119
  138. package/dist/skills/ads-designer/references/accessibility.md +12 -13
  139. package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
  140. package/dist/skills/ads-designer/references/behaviors.md +30 -27
  141. package/dist/skills/ads-designer/references/branding.md +98 -10
  142. package/dist/skills/ads-designer/references/captures.md +25 -0
  143. package/dist/skills/ads-designer/references/cli.md +21 -24
  144. package/dist/skills/ads-designer/references/contracts.md +7 -6
  145. package/dist/skills/ads-designer/references/design-data.md +49 -52
  146. package/dist/skills/ads-designer/references/drafts.md +20 -17
  147. package/dist/skills/ads-designer/references/evidence.md +1 -5
  148. package/dist/skills/ads-designer/references/guarded-editing.md +14 -18
  149. package/dist/skills/ads-designer/references/layers.md +1 -1
  150. package/dist/skills/ads-designer/references/layout.md +347 -0
  151. package/dist/skills/ads-designer/references/mobile.md +2 -1
  152. package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
  153. package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
  154. package/dist/skills/ads-designer/references/review.md +37 -34
  155. package/dist/skills/ads-designer/references/runtimes.md +33 -30
  156. package/dist/skills/ads-designer/references/scenarios.md +16 -18
  157. package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
  158. package/dist/skills/ads-designer/references/stress-test.md +68 -0
  159. package/dist/skills/ads-designer/references/validation.md +83 -75
  160. package/dist/skills/ads-designer/references/workflows.md +8 -33
  161. package/dist/skills/ads-import/SKILL.md +43 -325
  162. package/dist/skills/ads-import/references/atomic-styles.md +4 -4
  163. package/dist/skills/ads-import/references/behaviors.md +30 -27
  164. package/dist/skills/ads-import/references/branding.md +5 -5
  165. package/dist/skills/ads-import/references/captures.md +25 -0
  166. package/dist/skills/ads-import/references/cli.md +21 -24
  167. package/dist/skills/ads-import/references/compatibility.md +1 -1
  168. package/dist/skills/ads-import/references/contracts.md +7 -6
  169. package/dist/skills/ads-import/references/design-data.md +49 -52
  170. package/dist/skills/ads-import/references/drafts.md +20 -17
  171. package/dist/skills/ads-import/references/evidence.md +1 -5
  172. package/dist/skills/ads-import/references/guarded-editing.md +14 -18
  173. package/dist/skills/ads-import/references/implementation.md +2 -1
  174. package/dist/skills/ads-import/references/layers.md +1 -1
  175. package/dist/skills/ads-import/references/layout.md +347 -0
  176. package/dist/skills/ads-import/references/review.md +37 -34
  177. package/dist/skills/ads-import/references/runtimes.md +33 -30
  178. package/dist/skills/ads-import/references/scenarios.md +16 -18
  179. package/dist/skills/ads-import/references/tokens.md +3 -3
  180. package/dist/skills/ads-import/references/validation.md +83 -75
  181. package/dist/skills/ads-import/references/workflows.md +8 -33
  182. package/dist/skills/ads-migrate/SKILL.md +56 -0
  183. package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
  184. package/dist/skills/ads-port/SKILL.md +54 -343
  185. package/dist/skills/ads-port/references/atomic-styles.md +4 -4
  186. package/dist/skills/ads-port/references/behaviors.md +30 -27
  187. package/dist/skills/ads-port/references/captures.md +25 -0
  188. package/dist/skills/ads-port/references/cli.md +21 -24
  189. package/dist/skills/ads-port/references/contracts.md +7 -6
  190. package/dist/skills/ads-port/references/design-data.md +49 -52
  191. package/dist/skills/ads-port/references/drafts.md +20 -17
  192. package/dist/skills/ads-port/references/evidence.md +1 -5
  193. package/dist/skills/ads-port/references/guarded-editing.md +14 -18
  194. package/dist/skills/ads-port/references/layers.md +1 -1
  195. package/dist/skills/ads-port/references/layout.md +347 -0
  196. package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
  197. package/dist/skills/ads-port/references/native-implementation.md +2 -1
  198. package/dist/skills/ads-port/references/review.md +37 -34
  199. package/dist/skills/ads-port/references/runtimes.md +33 -30
  200. package/dist/skills/ads-port/references/scenarios.md +16 -18
  201. package/dist/skills/ads-port/references/validation.md +83 -75
  202. package/dist/skills/ads-port/references/workflows.md +8 -33
  203. package/dist/source-symbols.mjs +1 -8
  204. package/dist/source-values.mjs +266 -128
  205. package/dist/spatial-composition.mjs +322 -0
  206. package/dist/spatial-contexts.cjs +56 -0
  207. package/dist/spatial-css.cjs +351 -0
  208. package/dist/spatial-inputs.cjs +80 -0
  209. package/dist/spatial-metadata.mjs +18 -0
  210. package/dist/spatial-model.cjs +322 -0
  211. package/dist/spatial.mjs +21 -0
  212. package/dist/stage-timing.cjs +20 -0
  213. package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +105 -0
  214. package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +275 -0
  215. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  216. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  217. package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +8 -0
  218. package/dist/starters/preact/ds.config.json +25 -6
  219. package/dist/starters/preact/package.json +4 -8
  220. package/dist/starters/preact/tsconfig.json +4 -5
  221. package/dist/starters/preact/vite.config.ts +3 -3
  222. package/dist/starters/react/ADS.md +42 -47
  223. package/dist/starters/react/README.md +47 -49
  224. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +18 -2
  225. package/dist/starters/react/design-system/components/Actions/IconButton/README.md +3 -0
  226. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +5 -0
  227. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
  228. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
  229. package/dist/starters/react/design-system/index.ts +2 -1
  230. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
  231. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
  232. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
  233. package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
  234. package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
  235. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
  236. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
  237. package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
  238. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
  239. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
  240. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
  241. package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
  242. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -1
  243. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  244. package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
  245. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
  246. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
  247. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -1
  248. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  249. package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
  250. package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
  251. package/dist/starters/react/design-system/tokens/colors.css +1 -1
  252. package/dist/starters/react/design-system/tokens/spacing.css +22 -32
  253. package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
  254. package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
  255. package/dist/starters/react/ds.config.json +25 -6
  256. package/dist/starters/react/package.json +2 -6
  257. package/dist/starters/react/tsconfig.json +2 -3
  258. package/dist/starters/react/vite.config.ts +3 -3
  259. package/dist/style-boundaries.mjs +70 -25
  260. package/dist/task-cache.mjs +173 -72
  261. package/dist/task-worker.mjs +22 -11
  262. package/dist/test-boundaries.mjs +132 -59
  263. package/dist/themes-generated.mjs +1 -1
  264. package/dist/themes-watch.mjs +57 -22
  265. package/dist/themes.mjs +176 -73
  266. package/dist/token-export.mjs +39 -14
  267. package/dist/token-policy.mjs +6 -3
  268. package/dist/token-quality.mjs +6 -6
  269. package/dist/token-samples.mjs +16 -5
  270. package/dist/tokens.mjs +71 -26
  271. package/dist/ui-framework.mjs +16 -14
  272. package/dist/unit-contracts.mjs +251 -104
  273. package/dist/units.mjs +208 -98
  274. package/dist/usage.mjs +138 -38
  275. package/dist/validation-checks.mjs +115 -38
  276. package/dist/validation-inputs.mjs +187 -78
  277. package/dist/validation.mjs +268 -102
  278. package/dist/verification/browser.mjs +27 -5
  279. package/dist/verification.mjs +711 -187
  280. package/docs/ADS.md +90 -79
  281. package/docs/ARCHITECTURE.md +294 -136
  282. package/docs/BEHAVIORS.md +29 -25
  283. package/docs/CACHING.md +52 -17
  284. package/docs/CHANGELOG.md +309 -17
  285. package/docs/CONTRACTS.md +12 -4
  286. package/docs/DESIGN-REFERENCES.md +40 -0
  287. package/docs/GUIDE.md +270 -258
  288. package/docs/MCP.md +181 -324
  289. package/docs/SPATIAL-CHECKS.md +69 -0
  290. package/docs/benchmarks/README.md +39 -0
  291. package/package.json +42 -34
  292. package/dist/browser-audit.mjs +0 -429
  293. package/dist/create.mjs +0 -48
  294. package/dist/lint-config.mjs +0 -50
  295. package/dist/mcp/project-widget.bundle.js +0 -114
  296. package/dist/mcp/reports.mjs +0 -101
  297. package/dist/mcp/widget.bundle.js +0 -147
  298. package/dist/oxlint.mjs +0 -89
  299. package/dist/preview-builder.mjs +0 -133
  300. package/dist/preview-workers.mjs +0 -184
  301. package/dist/showcase.mjs +0 -77
  302. package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
  303. package/dist/skills/ads-break-ui/README.md +0 -16
  304. package/dist/skills/ads-break-ui/SKILL.md +0 -412
  305. package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
  306. package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
  307. package/dist/skills/ads-break-ui/references/behaviors.md +0 -412
  308. package/dist/skills/ads-break-ui/references/captures.md +0 -135
  309. package/dist/skills/ads-break-ui/references/contracts.md +0 -317
  310. package/dist/skills/ads-break-ui/references/design-data.md +0 -354
  311. package/dist/skills/ads-break-ui/references/drafts.md +0 -194
  312. package/dist/skills/ads-break-ui/references/evidence.md +0 -128
  313. package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -165
  314. package/dist/skills/ads-break-ui/references/layers.md +0 -145
  315. package/dist/skills/ads-break-ui/references/reporting.md +0 -101
  316. package/dist/skills/ads-break-ui/references/review.md +0 -97
  317. package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
  318. package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
  319. package/dist/skills/ads-break-ui/references/validation.md +0 -166
  320. package/dist/skills/ads-break-ui/references/verification.md +0 -58
  321. package/dist/skills/ads-break-ui/references/workflows.md +0 -90
  322. package/dist/skills/ads-designer/references/reporting.md +0 -101
  323. package/dist/skills/ads-import/references/reporting.md +0 -101
  324. package/dist/skills/ads-motion/LICENSE.upstream +0 -21
  325. package/dist/skills/ads-motion/README.md +0 -22
  326. package/dist/skills/ads-motion/SKILL.md +0 -385
  327. package/dist/skills/ads-motion/agents/openai.yaml +0 -4
  328. package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
  329. package/dist/skills/ads-motion/references/audit.md +0 -44
  330. package/dist/skills/ads-motion/references/behaviors.md +0 -412
  331. package/dist/skills/ads-motion/references/captures.md +0 -135
  332. package/dist/skills/ads-motion/references/contracts.md +0 -317
  333. package/dist/skills/ads-motion/references/design-data.md +0 -354
  334. package/dist/skills/ads-motion/references/drafts.md +0 -194
  335. package/dist/skills/ads-motion/references/evidence.md +0 -128
  336. package/dist/skills/ads-motion/references/guarded-editing.md +0 -165
  337. package/dist/skills/ads-motion/references/layers.md +0 -145
  338. package/dist/skills/ads-motion/references/motion-review.md +0 -35
  339. package/dist/skills/ads-motion/references/reporting.md +0 -101
  340. package/dist/skills/ads-motion/references/review.md +0 -97
  341. package/dist/skills/ads-motion/references/runtimes.md +0 -203
  342. package/dist/skills/ads-motion/references/scenarios.md +0 -246
  343. package/dist/skills/ads-motion/references/validation.md +0 -166
  344. package/dist/skills/ads-motion/references/verification.md +0 -39
  345. package/dist/skills/ads-motion/references/workflows.md +0 -90
  346. package/dist/skills/ads-port/references/reporting.md +0 -101
  347. package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
  348. package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
  349. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  350. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  351. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
  352. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
  353. package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
  354. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
  355. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
  356. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
  357. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
  358. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
  359. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +0 -1
  360. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
  361. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
  362. package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
  363. package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
  364. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.ads.exports.ts +0 -1
  365. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
  366. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  367. package/dist/starters/react/design-system/review/grid-cell/GridCell.ads.exports.ts +0 -1
  368. package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
  369. package/dist/starters/react/design-system/review/index.ts +0 -6
  370. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  371. package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
  372. package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +0 -1
  373. package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
  374. package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
  375. package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
  376. package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
  377. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
  378. package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
  379. package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
  380. package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
  381. package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
  382. package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
  383. package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
  384. package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
  385. package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
  386. package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
  387. package/dist/starters/react/package-lock.json +0 -4707
  388. package/dist/token-fixtures.mjs +0 -30
  389. package/docs/benchmarks/bun-previews.md +0 -91
  390. package/docs/benchmarks/preview-memory.md +0 -147
  391. package/docs/benchmarks/turbo-poc.md +0 -284
  392. package/docs/plans/execution-coordination.md +0 -57
  393. /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
  394. /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;