@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
package/dist/check.mjs CHANGED
@@ -1,6 +1,10 @@
1
+ import { jsxImportSource } from "./analysis/helpers.mjs";
2
+ import { withProjectAnalysis } from "./analysis/standalone.mjs";
3
+ import { currentAnalysis } from "./analysis/context.mjs";
4
+ import { eachChild, walkAsync } from "./analysis/queries.mjs";
1
5
  import { existsSync, readFileSync, statSync } from "node:fs";
2
6
  import path from "node:path";
3
- import ts from "typescript";
7
+ import ts from "./analysis/syntax.mjs";
4
8
  import postcss from "postcss";
5
9
  import valueParser from "postcss-value-parser";
6
10
  import { importViolation, isInside, loadConfig, sourceFiles, isDevelopmentFile, isTestFile, isReviewFile } from "./config.mjs";
@@ -11,14 +15,23 @@ import { themeAncestorSelector } from "./themes.mjs";
11
15
  import { isSharedToken } from "./token-policy.mjs";
12
16
  import { inspectAssets } from "./assets.mjs";
13
17
  import { a11ySourceAdvisories } from "./a11y.mjs";
14
- import { appImportViolation, showcaseImportViolation, checkComponentVariable, importResolver, projectCompilerOptions, isUiCssProperties, styleWriteViolation } from "./boundaries.mjs";
18
+ import {
19
+ appImportViolation,
20
+ showcaseImportViolation,
21
+ checkComponentVariable,
22
+ tokenNameGuidance,
23
+ variableLayer,
24
+ importResolver,
25
+ projectCompilerOptions,
26
+ isUiCssProperties,
27
+ styleWriteViolation,
28
+ } from "./boundaries.mjs";
15
29
  import { inspectPublicProps } from "./public-props.mjs";
16
30
  import { adsFileRole } from "./config.mjs";
17
31
  import { inspectPaintContracts, inspectTokenValueFlows } from "./paint-contracts.mjs";
18
32
  import { ownerStylePolicy, runtimeBindingOwner } from "./unit-contracts.mjs";
19
33
  import { inspectRuntimeContracts } from "./runtime-contracts.mjs";
20
34
  import { inspectHtml, isMountCss } from "./html.mjs";
21
- import { inspectShowcasePages } from "./showcase.mjs";
22
35
  import { inspectShowcaseCoverage } from "./showcase-coverage.mjs";
23
36
  import { inspectScenarioCoverage } from "./scenarios.mjs";
24
37
  import { uiOperation, importedUiApi } from "./ui-framework.mjs";
@@ -36,221 +49,631 @@ import { createScenarioSelectors } from "./scenario-selectors.mjs";
36
49
  import { architectureEvidence, failure } from "./evidence.mjs";
37
50
  import { propertyRegistration } from "./property-registrations.mjs";
38
51
  import { createLayerBoundaries, layerSourceFiles } from "./layers.mjs";
39
- import { createDesignValues, inspectDesignAliases, isColorKeyword } from "./design-values.mjs";
52
+ import { createDesignValues, designTemplateVariants, inspectDesignAliases, isColorKeyword } from "./design-values.mjs";
40
53
  import { inspectTestBoundaries } from "./test-boundaries.mjs";
41
54
  import { inspectBehaviorLibraries } from "./behavior-libraries.mjs";
42
55
  import { inspectUsage } from "./usage.mjs";
43
56
  import { controlPaddingAdvisories } from "./control-padding.mjs";
44
57
  import { createComponentContrast } from "./component-contrast.mjs";
58
+ import { createContrastComposition } from "./contrast-composition.mjs";
45
59
  import { createFontRules } from "./font-rules.mjs";
46
60
  import { createLayoutWidths, globMatcher } from "./layout-widths.mjs";
47
61
  import { imageAttributeFindings } from "./image-attributes.mjs";
48
62
  import { findingSeverity, routeFindings } from "./finding-rules.mjs";
63
+ import construction from "./construction-styles.cjs";
64
+ import spatialCss from "./spatial-css.cjs";
65
+ import { inspectSpatial } from "./spatial.mjs";
66
+ import { createSpatialComposition } from "./spatial-composition.mjs";
67
+ import timing from "./stage-timing.cjs";
49
68
 
50
- const scenarioLayoutGuidance = "Put demo-only sizing and framing in the development-only review/ layer, imported through the separate review entry. Patterns are production UI. Keep required behavior in the runtime owner; add component props for deliberate product API needs.";
69
+ const scenarioLayoutGuidance =
70
+ "Use ADS preview framing for generic layouts. Put project-specific demonstration sizing in a marked .ads.review.* helper. Patterns are production UI. Keep required behavior in the runtime owner; add component props for deliberate product API needs.";
51
71
  const inlineStyleGuidance = `Own visual styles in component/pattern Linaria. ${scenarioLayoutGuidance} Reserve the owner contract's styles.inline for documented measured geometry, not demo layout.`;
52
72
 
53
- const showcaseControls = new Set(["a", "button", "input", "select", "textarea", "option", "optgroup", "table", "thead", "tbody", "tfoot", "tr", "td", "th", "dialog", "details", "summary", "progress", "meter"]);
54
- const svgTags = new Set(["svg", "g", "path", "circle", "rect", "ellipse", "line", "polyline", "polygon", "text", "tspan", "use", "defs", "clipPath", "mask", "filter", "linearGradient", "radialGradient", "stop", "marker", "pattern"]);
55
- const svgPresentation = new Set(["strokeWidth", "strokeLinecap", "strokeLinejoin", "strokeDasharray", "strokeDashoffset", "strokeOpacity", "strokeMiterlimit", "fillRule", "fillOpacity", "clipRule", "clipPath", "colorInterpolation", "colorInterpolationFilters", "floodColor", "floodOpacity", "stopColor", "stopOpacity", "fontFamily", "fontSize", "fontStyle", "fontWeight", "letterSpacing", "textAnchor", "dominantBaseline", "markerStart", "markerMid", "markerEnd", "vectorEffect", "shapeRendering", "textRendering", "paintOrder", "alignmentBaseline", "baselineShift", "transformOrigin"]);
56
- const widgetRoles = new Set(["button", "link", "checkbox", "radio", "switch", "combobox", "textbox", "listbox", "option", "slider", "spinbutton", "tab", "tablist", "menu", "menuitem", "tree", "treeitem", "grid", "dialog", "alertdialog", "progressbar"]);
73
+ const showcaseControls = new Set([
74
+ "a",
75
+ "button",
76
+ "input",
77
+ "select",
78
+ "textarea",
79
+ "option",
80
+ "optgroup",
81
+ "table",
82
+ "thead",
83
+ "tbody",
84
+ "tfoot",
85
+ "tr",
86
+ "td",
87
+ "th",
88
+ "dialog",
89
+ "details",
90
+ "summary",
91
+ "progress",
92
+ "meter",
93
+ ]);
94
+ const svgTags = new Set([
95
+ "svg",
96
+ "g",
97
+ "path",
98
+ "circle",
99
+ "rect",
100
+ "ellipse",
101
+ "line",
102
+ "polyline",
103
+ "polygon",
104
+ "text",
105
+ "tspan",
106
+ "use",
107
+ "defs",
108
+ "clipPath",
109
+ "mask",
110
+ "filter",
111
+ "linearGradient",
112
+ "radialGradient",
113
+ "stop",
114
+ "marker",
115
+ "pattern",
116
+ ]);
117
+ const svgPresentation = new Set([
118
+ "strokeWidth",
119
+ "strokeLinecap",
120
+ "strokeLinejoin",
121
+ "strokeDasharray",
122
+ "strokeDashoffset",
123
+ "strokeOpacity",
124
+ "strokeMiterlimit",
125
+ "fillRule",
126
+ "fillOpacity",
127
+ "clipRule",
128
+ "clipPath",
129
+ "colorInterpolation",
130
+ "colorInterpolationFilters",
131
+ "floodColor",
132
+ "floodOpacity",
133
+ "stopColor",
134
+ "stopOpacity",
135
+ "fontFamily",
136
+ "fontSize",
137
+ "fontStyle",
138
+ "fontWeight",
139
+ "letterSpacing",
140
+ "textAnchor",
141
+ "dominantBaseline",
142
+ "markerStart",
143
+ "markerMid",
144
+ "markerEnd",
145
+ "vectorEffect",
146
+ "shapeRendering",
147
+ "textRendering",
148
+ "paintOrder",
149
+ "alignmentBaseline",
150
+ "baselineShift",
151
+ "transformOrigin",
152
+ ]);
153
+ const widgetRoles = new Set([
154
+ "button",
155
+ "link",
156
+ "checkbox",
157
+ "radio",
158
+ "switch",
159
+ "combobox",
160
+ "textbox",
161
+ "listbox",
162
+ "option",
163
+ "slider",
164
+ "spinbutton",
165
+ "tab",
166
+ "tablist",
167
+ "menu",
168
+ "menuitem",
169
+ "tree",
170
+ "treeitem",
171
+ "grid",
172
+ "dialog",
173
+ "alertdialog",
174
+ "progressbar",
175
+ ]);
57
176
 
58
- export function checkProject(directory, { trackingRoot } = {}) {
177
+ export async function checkProject(directory, { trackingRoot } = {}) {
178
+ // Missing targets fail the structure gate below before any source capture or compiler work.
179
+ if (!currentAnalysis()?.provideProgram && existsSync(directory))
180
+ return withProjectAnalysis(directory, () => checkProject(directory, { trackingRoot })).catch((error) => {
181
+ if (error.diagnostic) return architectureEvidence({ ok: false, diagnostics: [error.diagnostic] });
182
+ throw error;
183
+ });
184
+ return timing.timeStage("architecture-check", () => checkCapturedProject(directory, { trackingRoot }));
185
+ }
186
+
187
+ async function checkCapturedProject(directory, { trackingRoot }) {
59
188
  const options = { ...loadConfig(directory), ...(trackingRoot ? { trackingRoot: path.resolve(trackingRoot) } : {}) };
60
189
  const { root, config, dsRoot, sourceRoot } = options;
61
- const diagnostics = [], advisories = [];
62
- for (const [field, file] of [["dsDir", dsRoot], ["publicEntry", path.join(dsRoot, config.publicEntry)], ["stylesEntry", path.join(dsRoot, config.stylesEntry)]]) {
63
- if (!existsSync(file) || (field === "dsDir" ? !statSync(file).isDirectory() : !statSync(file).isFile())) diagnostics.push({ rule: "project-structure", file: path.relative(root, file), line: 1, column: 1, message: `Missing or invalid ${field}. Bootstrap an empty ADS or configure its actual path.` });
190
+ const diagnostics = [],
191
+ advisories = [];
192
+ for (const [field, file] of [
193
+ ["dsDir", dsRoot],
194
+ ["publicEntry", path.join(dsRoot, config.publicEntry)],
195
+ ["stylesEntry", path.join(dsRoot, config.stylesEntry)],
196
+ ]) {
197
+ if (!existsSync(file) || (field === "dsDir" ? !statSync(file).isDirectory() : !statSync(file).isFile()))
198
+ diagnostics.push({
199
+ rule: "project-structure",
200
+ file: path.relative(root, file),
201
+ line: 1,
202
+ column: 1,
203
+ message: `Missing or invalid ${field}. Bootstrap an empty ADS or configure its actual path.`,
204
+ });
64
205
  }
65
206
  if (diagnostics.length) return architectureEvidence({ ok: false, diagnostics });
66
- diagnostics.push(...generatedEntryDiagnostics(options, inspectUnits(options)));
67
- const tokenInventory = inspectTokens(root, options);
207
+ diagnostics.push(...(await generatedEntryDiagnostics(options, await inspectUnits(options))));
208
+ const tokenInventory = await inspectTokens(root, options);
68
209
  const declaredTokens = new Set(tokenInventory.tokens.map((token) => token.name));
69
210
  // Display switches are defined by the generated themes.generated.css, not a token sheet.
70
211
  const generatedSwitches = new Set(displaySwitches(config));
71
212
  diagnostics.push(...tokenInventory.diagnostics);
213
+ let spatialFoundation;
214
+ try {
215
+ spatialFoundation = inspectSpatial(options)?.model;
216
+ } catch (error) {
217
+ diagnostics.push({ rule: "grid-definition", file: `${config.dsDir}/${config.tokenDir}/spatial.ads.json`, line: 1, column: 1, message: error.message, guidanceUri: "ads://guides/layout" });
218
+ }
72
219
  const assetFindings = inspectAssets(options);
73
- diagnostics.push(...assetFindings.filter(finding => !finding.severity || finding.severity === "error"));
74
- const assetAdvisories = assetFindings.filter(finding => finding.severity && finding.severity !== "error");
75
- const resolveImport = importResolver(options);
76
- const units = inspectUnits(options);
77
- options.testOwner = file => units.owner(units.relative(path.relative(root,file)));
78
- const configurationScripts=new Set((units.units.find(unit=>unit.id==="configuration")?.files??[]).filter(file=>/\.[cm]?[jt]sx?$/.test(file)).map(file=>path.resolve(root,file)).filter(file=>existsSync(file)&&statSync(file).isFile()));
220
+ diagnostics.push(...assetFindings.filter((finding) => !finding.severity || finding.severity === "error"));
221
+ const assetAdvisories = assetFindings.filter((finding) => finding.severity && finding.severity !== "error");
222
+ const resolveImport = await importResolver(options);
223
+ const units = await inspectUnits(options);
224
+ options.testOwner = (file) => units.owner(units.relative(path.relative(root, file)));
225
+ const configurationScripts = new Set(
226
+ (units.units.find((unit) => unit.id === "configuration")?.files ?? [])
227
+ .filter((file) => /\.[cm]?[jt]sx?$/.test(file))
228
+ .map((file) => path.resolve(root, file))
229
+ .filter((file) => existsSync(file) && statSync(file).isFile()),
230
+ );
79
231
  const rootHtml = path.join(root, "index.html");
80
232
  const files = [...new Set([...sourceFiles(sourceRoot), ...sourceFiles(dsRoot), ...configurationScripts, ...(existsSync(rootHtml) ? [rootHtml] : [])])];
81
- const stylePolicy = ownerStylePolicy(options);
82
- const boundaryFiles = [...stylePolicy.inlineStyleFiles, ...stylePolicy.styleWrites.map(entry => entry.file)].map(file => path.resolve(root, file)).filter(file => existsSync(file) && statSync(file).isFile());
83
- const scriptFiles = [...new Set([...layerSourceFiles([...new Set([...files, ...boundaryFiles])].filter((file) => /\.[cm]?[jt]sx?$/.test(file)), options), ...configurationScripts])];
84
- const compiler = projectCompilerOptions(options);
85
- const program = cachedProgram(`check:${root}`, scriptFiles, { ...compiler, paths: { ...compiler.paths, [config.publicAlias]: [path.join(dsRoot, config.publicEntry)] }, allowJs: true, noResolve: true, noLib: true, types: [], target: ts.ScriptTarget.Latest, module: ts.ModuleKind.ESNext, jsx: ts.JsxEmit.Preserve });
233
+ const stylePolicy = await ownerStylePolicy(options);
234
+ const boundaryFiles = [...stylePolicy.inlineStyleFiles, ...stylePolicy.styleWrites.map((entry) => entry.file)]
235
+ .map((file) => path.resolve(root, file))
236
+ .filter((file) => existsSync(file) && statSync(file).isFile());
237
+ const scriptFiles = [
238
+ ...new Set([
239
+ ...(await layerSourceFiles(
240
+ [...new Set([...files, ...boundaryFiles])].filter((file) => /\.[cm]?[jt]sx?$/.test(file)),
241
+ options,
242
+ )),
243
+ ...configurationScripts,
244
+ ]),
245
+ ];
246
+ const compiler = await projectCompilerOptions(options);
247
+ const program = await cachedProgram(`check:${root}`, scriptFiles, {
248
+ ...compiler,
249
+ paths: { ...compiler.paths, [config.publicAlias]: [path.join(dsRoot, config.publicEntry)] },
250
+ allowJs: true,
251
+ noResolve: true,
252
+ noLib: true,
253
+ types: [],
254
+ target: ts.ScriptTarget.Latest,
255
+ module: ts.ModuleKind.ESNext,
256
+ jsx: ts.JsxEmit.Preserve,
257
+ });
86
258
  const checker = program.getTypeChecker();
87
- diagnostics.push(...inspectBehaviorLibraries(options, program).diagnostics);
88
- const designValues = createDesignValues(program,options);
89
- const paintContracts = inspectPaintContracts(options);
259
+ diagnostics.push(...(await inspectBehaviorLibraries(options, program)).diagnostics);
260
+ const designValues = createDesignValues(program, options);
261
+ const spatialComposition = createSpatialComposition(program, options);
262
+ const paintContracts = await inspectPaintContracts(options);
90
263
  diagnostics.push(...paintContracts.diagnostics);
91
- const runtimeContracts = inspectRuntimeContracts(options, program);
264
+ const runtimeContracts = await inspectRuntimeContracts(options, program);
92
265
  diagnostics.push(...runtimeContracts.diagnostics);
93
266
  const atomicCompositionReview = createAtomicCompositionReview(program, options);
94
267
  const renderColorProbe = createRenderColorProbe(program);
95
- const scenarioTrace = createScenarioTrace(program, options);
268
+ const scenarioTrace = await createScenarioTrace(program, options);
96
269
  let scenarioSlot, scenarioSelector;
97
270
  function report(file, rule, message, line = 1, column = 1, detail = {}) {
98
271
  diagnostics.push({ file: path.relative(root, file).replaceAll("\\", "/"), rule, message, line, column, ...detail });
99
272
  }
100
- const layers = createLayerBoundaries(program, options, report), layerStyles = [];
101
- inspectUsage(options, program, report);
273
+ const layers = await createLayerBoundaries(program, options, report),
274
+ layerStyles = [];
275
+ await inspectUsage(options, program, report);
102
276
  layers.inspectDependencies();
103
- inspectTokenValueFlows(program, options, tokenInventory, units, report);
104
- for (const file of layers.runtimeHelpers()) if (!files.includes(file)) files.push(file);
105
- inspectStyleBoundaries(options, program, report);
106
- inspectShowcasePages(options, program, resolveImport, report);
107
- inspectShowcaseCoverage(options, program, report);
108
- inspectScenarioCoverage(options, program, report, (file, rule, message) => advisories.push({ file: path.relative(root, file).replaceAll("\\", "/"), rule, message, line: 1, column: 1 }), scenarioTrace);
109
- const behaviors = inspectBehaviors(options, program);
277
+ await inspectTokenValueFlows(program, options, tokenInventory, units, report);
278
+ for (const file of await layers.runtimeHelpers()) if (!files.includes(file)) files.push(file);
279
+ await inspectStyleBoundaries(options, program, report);
280
+ await inspectShowcaseCoverage(options, program, report);
281
+ await inspectScenarioCoverage(
282
+ options,
283
+ program,
284
+ report,
285
+ (file, rule, message) => advisories.push({ file: path.relative(root, file).replaceAll("\\", "/"), rule, message, line: 1, column: 1 }),
286
+ scenarioTrace,
287
+ );
288
+ const behaviors = await inspectBehaviors(options, program);
110
289
  diagnostics.push(...behaviors.diagnostics);
111
- diagnostics.push(...inspectTestBoundaries(options,units,behaviors.contracts,program));
112
- inspectControllers(options, program, report, behaviors.contracts);
290
+ diagnostics.push(...(await inspectTestBoundaries(options, units, behaviors.contracts, program)));
291
+ await inspectControllers(options, program, report, behaviors.contracts);
113
292
  // The foundation remains a fixed import-only entry, not an extra styling layer.
114
293
  const foundationEntry = path.join(dsRoot, config.stylesEntry);
115
- const registeredProperties=new Map(), controlPaddingSeen=new Set();
294
+ const registeredProperties = new Map(),
295
+ controlPaddingSeen = new Set();
116
296
  const componentContrast = createComponentContrast(tokenInventory.tokens, config.themes, config.brands);
117
- const layoutWidths = createLayoutWidths(tokenInventory.tokens, config), fixedWidthOwner = globMatcher(config.layout.fixedWidthUnits);
118
- for (const glob of config.layout.widthTokens) if (!tokenInventory.tokens.some(token => globMatcher([glob])(token.name))) diagnostics.push({ rule: "layout-config", file: "ds.config.json", line: 1, column: 1, message: `layout.widthTokens entry ${glob} matches no declared token. Remove it or declare the token.` });
119
- for (const glob of config.layout.fixedWidthUnits) if (!units.units.some(unit => globMatcher([glob])(unit.id) || unit.files.some(file => globMatcher([glob])(file)))) diagnostics.push({ rule: "layout-config", file: "ds.config.json", line: 1, column: 1, message: `layout.fixedWidthUnits entry ${glob} matches no unit or owned file. Remove it or correct the path.` });
297
+ const contrastComposition = createContrastComposition(program, options, componentContrast);
298
+ const layoutWidths = createLayoutWidths(tokenInventory.tokens, config, spatialFoundation),
299
+ fixedWidthOwner = globMatcher(config.layout.fixedWidthUnits);
300
+ for (const glob of config.layout.widthTokens)
301
+ if (!tokenInventory.tokens.some((token) => globMatcher([glob])(token.name)))
302
+ diagnostics.push({
303
+ rule: "layout-config",
304
+ file: "ds.config.json",
305
+ line: 1,
306
+ column: 1,
307
+ message: `layout.widthTokens entry ${glob} matches no declared token. Remove it or declare the token.`,
308
+ });
309
+ for (const glob of config.layout.fixedWidthUnits)
310
+ if (!units.units.some((unit) => globMatcher([glob])(unit.id) || unit.files.some((file) => globMatcher([glob])(file))))
311
+ diagnostics.push({
312
+ rule: "layout-config",
313
+ file: "ds.config.json",
314
+ line: 1,
315
+ column: 1,
316
+ message: `layout.fixedWidthUnits entry ${glob} matches no unit or owned file. Remove it or correct the path.`,
317
+ });
120
318
  const ownerFixedWidths = [];
121
319
  const fontRules = createFontRules(options, tokenInventory.tokens);
122
- function checkRegistrations(file,css,offset={line:1}){
123
- css.walkAtRules(/^property$/i,rule=>{
124
- const line=offset.line+(rule.source?.start.line??1)-1;
125
- try{
126
- const registration=propertyRegistration(rule),relative=units.relative(path.relative(root,file));
127
- const owner=units.owner(relative),foundation=isInside(path.join(dsRoot,config.tokenDir),file);
128
- if(foundation){
129
- let defined=false;css.walkDecls(registration.name,()=>{defined=true;});
130
- if(!isSharedToken(registration.name)||!declaredTokens.has(registration.name)||!defined||["base.css","fonts.css"].includes(path.basename(file)))throw new Error("Shared @property registrations belong beside their real token definitions in foundation value sheets, not base.css or fonts.css.");
131
- }else{
132
- if(!owner||!/^(?:components|patterns|review)\//.test(owner))throw new Error("@property belongs to its component/pattern/review implementation or real token value sheet, never application, scenario, controller or shared reset styling.");
133
- const violation=checkComponentVariable(registration.name,file,options);if(violation)throw new Error(violation.message);
134
- }
135
- for(const descriptor of rule.nodes??[])if(descriptor.type==="decl")for(const ref of references(descriptor.value)){
136
- if(!/^(?:--ds-|--ux-|--showcase-)/.test(ref.name)&&(!isSharedToken(ref.name)||!declaredTokens.has(ref.name)&&!ref.fallback))throw new Error(`Invalid or cross-owner token reference ${ref.name} in registration metadata.`);
320
+ async function checkRegistrations(file, css, offset = { line: 1 }) {
321
+ await walkAsync(css, "walkAtRules", /^property$/i, async (rule) => {
322
+ const line = offset.line + (rule.source?.start.line ?? 1) - 1;
323
+ try {
324
+ const registration = propertyRegistration(rule),
325
+ relative = units.relative(path.relative(root, file));
326
+ const owner = units.owner(relative),
327
+ foundation = isInside(path.join(dsRoot, config.tokenDir), file);
328
+ if (foundation) {
329
+ let defined = false;
330
+ css.walkDecls(registration.name, () => {
331
+ defined = true;
332
+ });
333
+ if (
334
+ !isSharedToken(registration.name) ||
335
+ !declaredTokens.has(registration.name) ||
336
+ !defined ||
337
+ ["base.css", "fonts.css"].includes(path.basename(file))
338
+ )
339
+ throw new Error("Shared @property registrations belong beside their real token definitions in foundation value sheets, not base.css or fonts.css.");
340
+ } else {
341
+ if (!owner || !/^(?:components|patterns|review)\//.test(owner))
342
+ throw new Error(
343
+ "@property belongs to its component/pattern/review implementation or real token value sheet, never application, scenario, controller or shared reset styling.",
344
+ );
345
+ const violation = await checkComponentVariable(registration.name, file, options);
346
+ if (violation) throw new Error(violation.message);
137
347
  }
138
- const previous=registeredProperties.get(registration.name);
139
- if(previous&&(previous.owner!==owner||previous.signature!==registration.signature))throw new Error(`Conflicting @property registration for ${registration.name}; ${path.relative(root,previous.file)} already registers it. Keep one owner and identical descriptors across that owner's modules.`);
140
- registeredProperties.set(registration.name,{...registration,owner,file});
141
- }catch(error){report(file,"property-registration",`${error.message} See ads://guides/atomic-styles.`,line,rule.source?.start.column??1);diagnostics.at(-1).guidanceUri="ads://guides/atomic-styles";}
348
+ for (const descriptor of rule.nodes ?? [])
349
+ if (descriptor.type === "decl")
350
+ for (const ref of references(descriptor.value)) {
351
+ if (!/^(?:--ds-|--ux-|--showcase-)/.test(ref.name) && (!isSharedToken(ref.name) || (!declaredTokens.has(ref.name) && !ref.fallback)))
352
+ throw new Error(`Invalid or cross-owner token reference ${ref.name} in registration metadata.`);
353
+ }
354
+ const previous = registeredProperties.get(registration.name);
355
+ if (previous && (previous.owner !== owner || previous.signature !== registration.signature))
356
+ throw new Error(
357
+ `Conflicting @property registration for ${registration.name}; ${path.relative(root, previous.file)} already registers it. Keep one owner and identical descriptors across that owner's modules.`,
358
+ );
359
+ registeredProperties.set(registration.name, { ...registration, owner, file });
360
+ } catch (error) {
361
+ report(file, "property-registration", `${error.message} See ads://guides/atomic-styles.`, line, rule.source?.start.column ?? 1);
362
+ diagnostics.at(-1).guidanceUri = "ads://guides/atomic-styles";
363
+ }
142
364
  });
143
365
  }
144
- function checkCss(file, text, offset = { line: 1, column: 1 }, foundation = false) {
366
+ async function checkCss(file, text, offset, foundation = false, template) {
367
+ if (offset === undefined) offset = { line: 1, column: 1 };
145
368
  let css;
146
- try { css = postcss.parse(text, { from: file }); }
147
- catch (error) { report(file, "css-syntax", error.reason ?? error.message, offset.line + (error.line ?? 1) - 1); return; }
369
+ try {
370
+ css = timing.timeStage("check-css-parse", () => postcss.parse(text, { from: file }));
371
+ // This tree is owned by this check. Normalize once so sizing, token,
372
+ // ownership and construction rules all see the same CSS property identity.
373
+ css.walkDecls(decl=>{decl.prop=spatialCss.propertyName(decl.prop);});
374
+ } catch (error) {
375
+ report(file, "css-syntax", error.reason ?? error.message, offset.line + (error.line ?? 1) - 1);
376
+ return;
377
+ }
378
+ try {
379
+ const spatialFact = spatialComposition.record(template, css);
380
+ construction.expandConstructionStyles(css, spatialFoundation, {deferPlacement:!!template});
381
+ spatialComposition.compiled(spatialFact, css);
382
+ } catch (error) {
383
+ const rule = error.rule ?? "grid-construction", guide = rule === "lockup-construction" ? "branding" : "layout";
384
+ report(file, rule, `${error.message} See ads://guides/${guide}.`, offset.line + (error.line ?? 1) - 1, error.column ?? offset.column);
385
+ diagnostics.at(-1).guidanceUri = `ads://guides/${guide}`;
386
+ return;
387
+ }
148
388
  layers.collectComponentStyles(file, css);
149
389
  layerStyles.push({ file, css, offset });
150
390
  if (foundation || !isDevelopmentFile(file, options)) fontRules.collect(css, file, offset);
151
- checkRegistrations(file,css,offset);
152
- if (!foundation && !isDevelopmentFile(file, options) && ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file))) componentContrast.collect(path.relative(root, file).replaceAll("\\", "/"), css, offset);
153
- if (!foundation && (isInside(path.join(dsRoot, "composition"), file) || !isDevelopmentFile(file, options) && ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file)))) {
154
- const relative = path.relative(root, file).replaceAll("\\", "/"), owner = units.owner(units.relative(path.relative(root, file)));
391
+ await checkRegistrations(file, css, offset);
392
+ if (!foundation && !isDevelopmentFile(file, options) && ["components", "patterns"].some((layer) => isInside(path.join(dsRoot, layer), file))) {
393
+ componentContrast.collect(path.relative(root, file).replaceAll("\\", "/"), css, offset);
394
+ contrastComposition.record(template, css, path.relative(root, file).replaceAll("\\", "/"), offset);
395
+ }
396
+ if (
397
+ !foundation &&
398
+ (isInside(path.join(dsRoot, "composition"), file) ||
399
+ (!isDevelopmentFile(file, options) && ["components", "patterns"].some((layer) => isInside(path.join(dsRoot, layer), file))))
400
+ ) {
401
+ const relative = path.relative(root, file).replaceAll("\\", "/"),
402
+ owner = units.owner(units.relative(path.relative(root, file)));
155
403
  const widths = layoutWidths.inspect(css, relative, offset);
156
404
  if (!fixedWidthOwner(relative) && !(owner && fixedWidthOwner(owner))) advisories.push(...widths);
157
- else ownerFixedWidths.push(...widths.filter(finding => finding.rule === "layout-fixed-width"));
405
+ else ownerFixedWidths.push(...widths.filter((finding) => finding.rule === "layout-fixed-width"));
158
406
  }
159
407
  // Linaria templates are checked once per resolved interpolation variant.
160
- if (!foundation) for (const finding of controlPaddingAdvisories(css, { tokens: declaredTokens, file: path.relative(root, file).replaceAll("\\", "/"), offset })) {
161
- const key = JSON.stringify([finding.file, finding.line, finding.column, finding.message]);
162
- if (!controlPaddingSeen.has(key)) { controlPaddingSeen.add(key); advisories.push(finding); }
163
- }
164
- if (!foundation && !isReviewFile(file, options) && (isDevelopmentFile(file, options) || !isInside(path.join(dsRoot, "components"), file) && !isInside(path.join(dsRoot, "patterns"), file) && file !== foundationEntry)) report(file, "style-ownership", "Visual CSS belongs to the local ADS's runtime components/patterns or development review implementations.");
165
- if (isDevelopmentFile(file, options) && !isReviewFile(file, options) && css.nodes.some((node) => node.type !== "comment" && !(node.type === "atrule" && node.name === "import"))) report(file, "showcase-style", `Scenarios and fixtures define no styles. ${scenarioLayoutGuidance}`, offset.line);
166
- css.walkAtRules("import", (rule) => {
167
- if (foundation) report(file, "foundation-import", "Import foundation sheets through the configured styles entry. Token sheets cannot import an unchecked styling layer.", rule.source.start.line);
408
+ if (!foundation)
409
+ for (const finding of controlPaddingAdvisories(css, { tokens: declaredTokens, file: path.relative(root, file).replaceAll("\\", "/"), offset })) {
410
+ const key = JSON.stringify([finding.file, finding.line, finding.column, finding.message]);
411
+ if (!controlPaddingSeen.has(key)) {
412
+ controlPaddingSeen.add(key);
413
+ advisories.push(finding);
414
+ }
415
+ }
416
+ if (
417
+ !foundation &&
418
+ !isReviewFile(file, options) &&
419
+ (isDevelopmentFile(file, options) ||
420
+ (!isInside(path.join(dsRoot, "components"), file) && !isInside(path.join(dsRoot, "patterns"), file) && file !== foundationEntry))
421
+ )
422
+ report(file, "style-ownership", "Visual CSS belongs to the local ADS's runtime components/patterns or development review implementations.");
423
+ if (
424
+ isDevelopmentFile(file, options) &&
425
+ !isReviewFile(file, options) &&
426
+ css.nodes.some((node) => node.type !== "comment" && !(node.type === "atrule" && node.name === "import"))
427
+ )
428
+ report(file, "showcase-style", `Scenarios and fixtures define no styles. ${scenarioLayoutGuidance}`, offset.line);
429
+ await walkAsync(css, "walkAtRules", "import", async (rule) => {
430
+ if (foundation)
431
+ report(
432
+ file,
433
+ "foundation-import",
434
+ "Import foundation sheets through the configured styles entry. Token sheets cannot import an unchecked styling layer.",
435
+ rule.source.start.line,
436
+ );
168
437
  const first = valueParser(rule.params).nodes.find((node) => node.type !== "space" && node.type !== "comment");
169
438
  const specifier = first?.type === "string" ? first.value : first?.type === "function" && first.value === "url" ? first.nodes[0]?.value : null;
170
439
  if (!specifier || /^(?:[a-z]+:|\/\/)/i.test(specifier)) return;
171
440
  const line = offset.line + rule.source.start.line - 1;
172
- if (importViolation(specifier, file, options, resolveImport)) report(file, "public-import", `Import through ${config.publicAlias}, not ADS implementation paths.`, line);
173
- if (showcaseImportViolation(specifier, file, options, resolveImport)) report(file, "showcase-import", "Showcase code and styles are development fixtures; runtime code must not import them.", line);
441
+ if (await importViolation(specifier, file, options, resolveImport))
442
+ report(file, "public-import", `Import through ${config.publicAlias}, not ADS implementation paths.`, line);
443
+ if (await showcaseImportViolation(specifier, file, options, resolveImport))
444
+ report(file, "showcase-import", "Showcase code and styles are development fixtures; runtime code must not import them.", line);
174
445
  });
175
446
  css.walkRules((rule) => {
176
447
  if (foundation) {
177
- if (rule.parent.type === "rule") report(file, "foundation-role", "Foundation rules cannot nest owner/context selectors. Use root theme conditions or Linaria owners.", rule.source.start.line);
178
- const violation = foundationSelector(rule.selector, { definitions: rule.nodes.some(node => node.type === "decl" && node.prop.startsWith("--")) });
448
+ if (rule.parent.type === "rule")
449
+ report(
450
+ file,
451
+ "foundation-role",
452
+ "Foundation rules cannot nest owner/context selectors. Use root theme conditions or Linaria owners.",
453
+ rule.source.start.line,
454
+ );
455
+ const violation = foundationSelector(rule.selector, { definitions: rule.nodes.some((node) => node.type === "decl" && node.prop.startsWith("--")) });
179
456
  if (violation) report(file, "foundation-selector", violation, rule.source.start.line, rule.source.start.column);
180
457
  }
181
- if (isInside(path.join(dsRoot, "showcase"), file) && /:(?:hover|active|focus(?:-visible|-within)?|checked|disabled|enabled)\b|\[(?:aria-(?:selected|pressed|checked|disabled|expanded)|data-state)\b/.test(rule.selector)) report(file, "showcase-state", "Interactive state styling belongs to the real ADS component or pattern, not showcase or mock styles.", offset.line + rule.source.start.line - 1);
182
- if (!foundation && (isReviewFile(file, options) || ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file))) && themeAncestorSelector(rule.selector)) report(file, "theme-selector", "Theme and brand selectors don't follow the nearest section; show theme- or brand-specific content with display: var(--display-<theme>, <display>), and give theme- or brand-specific values as token halves.", offset.line + rule.source.start.line - 1, rule.source.start.column, { severity: findingSeverity("theme-selector") });
183
- if (/\.ads-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "components"), file)) report(file, "style-ownership", "ADS component internals are owned by components, not app or showcase CSS.", offset.line + rule.source.start.line - 1);
184
- if (/\.ux-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "patterns"), file) && !isReviewFile(file, options)) report(file, "style-ownership", "Pattern internals are owned by patterns, not app or scenario CSS.", offset.line + rule.source.start.line - 1);
185
- if (/\.showcase-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "showcase"), file)) report(file, "style-ownership", "Showcase internals are owned by showcase scaffolding.", offset.line + rule.source.start.line - 1);
186
- });
187
- if (foundation) css.walkAtRules(rule => {
188
- if (/(?:^|-)keyframes$|^(?:scope|custom-selector|starting-style)$/i.test(rule.name)) report(file, "foundation-role", "Animations and scoped UI styles belong in their component/pattern's Linaria source, not the token foundation.", rule.source.start.line);
189
- if (rule.name === "font-face" && path.basename(file) !== "fonts.css") report(file, "foundation-role", "Font faces belong in the canonical fonts.css foundation sheet.", rule.source.start.line);
458
+ if (
459
+ isInside(path.join(dsRoot, "showcase"), file) &&
460
+ /:(?:hover|active|focus(?:-visible|-within)?|checked|disabled|enabled)\b|\[(?:aria-(?:selected|pressed|checked|disabled|expanded)|data-state)\b/.test(
461
+ rule.selector,
462
+ )
463
+ )
464
+ report(
465
+ file,
466
+ "showcase-state",
467
+ "Interactive state styling belongs to the real ADS component or pattern, not showcase or mock styles.",
468
+ offset.line + rule.source.start.line - 1,
469
+ );
470
+ if (
471
+ !foundation &&
472
+ (isReviewFile(file, options) || ["components", "patterns"].some((layer) => isInside(path.join(dsRoot, layer), file))) &&
473
+ themeAncestorSelector(rule.selector)
474
+ )
475
+ report(
476
+ file,
477
+ "theme-selector",
478
+ "Theme and brand selectors don't follow the nearest section; show theme- or brand-specific content with display: var(--display-<theme>, <display>), and give theme- or brand-specific values as token halves.",
479
+ offset.line + rule.source.start.line - 1,
480
+ rule.source.start.column,
481
+ { severity: findingSeverity("theme-selector") },
482
+ );
483
+ if (/\.ads-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "components"), file))
484
+ report(file, "style-ownership", "ADS component internals are owned by components, not app or showcase CSS.", offset.line + rule.source.start.line - 1);
485
+ if (/\.ux-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "patterns"), file) && !isReviewFile(file, options))
486
+ report(file, "style-ownership", "Pattern internals are owned by patterns, not app or scenario CSS.", offset.line + rule.source.start.line - 1);
487
+ if (/\.showcase-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "showcase"), file))
488
+ report(file, "style-ownership", "Showcase internals are owned by showcase scaffolding.", offset.line + rule.source.start.line - 1);
190
489
  });
191
- css.walkDecls((decl) => {
192
- const propertyDescriptor=decl.parent.type==="atrule"&&decl.parent.name.toLowerCase()==="property";
193
- if ((foundation || ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file))) && /\blight-dark\(/i.test(decl.value)) report(file, "theme-light-dark", "Give per-theme values as token halves (--x-light, --x-dark); light-dark() is limited to two schemes.", offset.line + decl.source.start.line - 1, decl.source.start.column, { severity: findingSeverity("theme-light-dark") });
490
+ if (foundation)
491
+ css.walkAtRules((rule) => {
492
+ if (/(?:^|-)keyframes$|^(?:scope|custom-selector|starting-style)$/i.test(rule.name))
493
+ report(
494
+ file,
495
+ "foundation-role",
496
+ "Animations and scoped UI styles belong in their component/pattern's Linaria source, not the token foundation.",
497
+ rule.source.start.line,
498
+ );
499
+ if (rule.name === "font-face" && path.basename(file) !== "fonts.css")
500
+ report(file, "foundation-role", "Font faces belong in the canonical fonts.css foundation sheet.", rule.source.start.line);
501
+ });
502
+ await walkAsync(css, "walkDecls", async (decl) => {
503
+ const propertyDescriptor = decl.parent.type === "atrule" && decl.parent.name.toLowerCase() === "property";
504
+ if ((foundation || ["components", "patterns"].some((layer) => isInside(path.join(dsRoot, layer), file))) && /\blight-dark\(/i.test(decl.value))
505
+ report(
506
+ file,
507
+ "theme-light-dark",
508
+ "Give per-theme values as token halves (--x-light, --x-dark); light-dark() is limited to two schemes.",
509
+ offset.line + decl.source.start.line - 1,
510
+ decl.source.start.column,
511
+ { severity: findingSeverity("theme-light-dark") },
512
+ );
194
513
  if (foundation && decl.prop.startsWith("--")) {
195
- if (path.basename(file) === "base.css") report(file, "foundation-role", "Shared token definitions belong in value sheets, not base.css.", decl.source.start.line, decl.source.start.column);
514
+ if (path.basename(file) === "base.css")
515
+ report(file, "foundation-role", "Shared token definitions belong in value sheets, not base.css.", decl.source.start.line, decl.source.start.column);
196
516
  return; // Definition names, values and aliases are validated by inspectTokens.
197
517
  }
198
518
  const fontDescriptor = foundation && path.basename(file) === "fonts.css" && decl.parent.type === "atrule" && decl.parent.name === "font-face";
199
- if (foundation && !fontDescriptor && !propertyDescriptor && (path.basename(file) !== "base.css" || decl.parent.type !== "rule")) report(file, "foundation-role", "Token sheets contain shared definitions; native defaults belong in base.css, font descriptors in fonts.css, and UI styling in Linaria owners.", decl.source.start.line, decl.source.start.column);
519
+ if (foundation && !fontDescriptor && !propertyDescriptor && (path.basename(file) !== "base.css" || decl.parent.type !== "rule"))
520
+ report(
521
+ file,
522
+ "foundation-role",
523
+ "Token sheets contain shared definitions; native defaults belong in base.css, font descriptors in fonts.css, and UI styling in Linaria owners.",
524
+ decl.source.start.line,
525
+ decl.source.start.column,
526
+ );
200
527
  if (foundation && path.basename(file) === "base.css" && decl.parent.type === "rule") {
201
528
  const violation = foundationDeclaration(decl.parent, decl);
202
529
  if (violation) report(file, "foundation-role", violation, decl.source.start.line, decl.source.start.column);
203
530
  }
204
- const variable = checkComponentVariable(decl.prop, file, options);
531
+ const variable = await checkComponentVariable(decl.prop, file, options);
205
532
  if (variable) report(file, variable.rule, variable.message, offset.line + decl.source.start.line - 1, decl.source.start.column);
206
533
  for (const ref of references(decl.value)) {
207
- const binding = runtimeBindingOwner(options, ref.name);
534
+ const binding = await runtimeBindingOwner(options, ref.name);
208
535
  if (binding) {
209
- if (units.owner(units.relative(path.relative(root, file))) !== binding.unit) report(file, "binding-ownership", `${ref.name} is an instance binding owned by ${binding.unit}, not a shared design token.`, offset.line + decl.source.start.line - 1, decl.source.start.column);
536
+ if (units.owner(units.relative(path.relative(root, file))) !== binding.unit)
537
+ report(
538
+ file,
539
+ "binding-ownership",
540
+ `${ref.name} is an instance binding owned by ${binding.unit}, not a shared design token.`,
541
+ offset.line + decl.source.start.line - 1,
542
+ decl.source.start.column,
543
+ );
210
544
  continue;
211
545
  }
212
546
  if (generatedSwitches.has(ref.name)) continue;
213
- if (ref.name.startsWith("--display-")) { report(file, "token-reference", `${ref.name} is not a display switch; themes.generated.css defines ${[...generatedSwitches].join(", ")} from ds.config.json themes and brands.`, offset.line + decl.source.start.line - 1, decl.source.start.column); continue; }
547
+ if (ref.name.startsWith("--display-")) {
548
+ report(
549
+ file,
550
+ "token-reference",
551
+ `${ref.name} is not a display switch; themes.generated.css defines ${[...generatedSwitches].join(", ")} from ds.config.json themes and brands.`,
552
+ offset.line + decl.source.start.line - 1,
553
+ decl.source.start.column,
554
+ );
555
+ continue;
556
+ }
214
557
  const local = /^(?:--ds-|--ux-|--showcase-)/.test(ref.name);
215
- if (foundation && local) report(file, "foundation-role", "Foundation defaults consume shared tokens, not component, pattern or scenario-local variables.", offset.line + decl.source.start.line - 1, decl.source.start.column);
216
- if (!local && !isSharedToken(ref.name)) report(file, "token-name", `${ref.name} does not follow ADS's fixed token naming contract.`, offset.line + decl.source.start.line - 1, decl.source.start.column);
217
- else if (!local && !declaredTokens.has(ref.name) && !ref.fallback) report(file, "token-reference", `Undefined shared token ${ref.name}.`, offset.line + decl.source.start.line - 1, decl.source.start.column);
558
+ if (foundation && local)
559
+ report(
560
+ file,
561
+ "foundation-role",
562
+ "Foundation defaults consume shared tokens, not component, pattern or scenario-local variables.",
563
+ offset.line + decl.source.start.line - 1,
564
+ decl.source.start.column,
565
+ );
566
+ if (!local && !isSharedToken(ref.name))
567
+ report(
568
+ file,
569
+ "token-name",
570
+ tokenNameGuidance(ref.name, variableLayer(file, options)),
571
+ offset.line + decl.source.start.line - 1,
572
+ decl.source.start.column,
573
+ );
574
+ else if (!local && !declaredTokens.has(ref.name) && !ref.fallback)
575
+ report(file, "token-reference", `Undefined shared token ${ref.name}.`, offset.line + decl.source.start.line - 1, decl.source.start.column);
218
576
  }
219
577
  if (fontDescriptor || propertyDescriptor) return; // Font metadata defines source assets, not token-backed UI styles.
220
578
  const violations = new Set();
221
- if(decl.value.includes("__ds_expression__"))violations.add("Cannot establish this interpolated design value from source. Use a source-resolvable shared token/mapping; unknown interpolation does not grant permission for private design values.");
579
+ if (decl.value.includes("__ds_expression__"))
580
+ violations.add(
581
+ "Cannot establish this interpolated design value from source. Use a source-resolvable shared token/mapping; unknown interpolation does not grant permission for private design values.",
582
+ );
222
583
  valueParser(decl.value).walk((node) => {
223
584
  if (node.type === "function" && node.value === "url") return false;
224
- if (node.type === "word" && decl.prop.startsWith("--") && isColorKeyword(node.value)) violations.add("Component variables map shared Data; named colors also require shared tokens.");
225
- if (node.type === "word" && (/^#[\da-f]{3,8}$/i.test(node.value) || tokenLengthLiteral(node.value) || ["s", "ms"].includes(numericCssUnit(node.value)))) violations.add("Use a token for colors, absolute/font-relative lengths (including ch), and durations. Unitless geometry and structural angle/viewport/container relationships remain valid.");
226
- if (node.type === "function" && /^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|cubic-bezier)$/.test(node.value)) violations.add("Define color formulas and easing in tokens.");
227
- if (node.type === "function" && /^(?:blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia)$/.test(node.value)) violations.add("Define visual filter effects in tokens.");
585
+ if (node.type === "word" && decl.prop.startsWith("--") && isColorKeyword(node.value))
586
+ violations.add("Component variables map shared Data; named colors also require shared tokens.");
587
+ if (
588
+ node.type === "word" &&
589
+ (/^#[\da-f]{3,8}$/i.test(node.value) ||
590
+ (tokenLengthLiteral(node.value) &&
591
+ !(
592
+ isReviewFile(file, options) &&
593
+ /^(?:(?:min-|max-)?(?:width|height|inline-size|block-size)|flex-basis|grid-template-columns|grid-template-rows)$/.test(decl.prop)
594
+ )) ||
595
+ ["s", "ms"].includes(numericCssUnit(node.value)))
596
+ )
597
+ violations.add(
598
+ "Use a token for colors, absolute/font-relative lengths (including ch), and durations. Unitless geometry and structural angle/viewport/container relationships remain valid.",
599
+ );
600
+ if (node.type === "function" && /^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|cubic-bezier)$/.test(node.value))
601
+ violations.add("Define color formulas and easing in tokens.");
602
+ if (node.type === "function" && /^(?:blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia)$/.test(node.value))
603
+ violations.add("Define visual filter effects in tokens.");
228
604
  if (node.type === "word" && /^ease(?:-in|-out|-in-out)?$/.test(node.value)) violations.add("Use a motion token for easing.");
229
- if (node.type === "word" && /^(?:color|background-color|(?:border|outline|caret|text-decoration|column-rule)(?:-[a-z]+)?-color|fill|stroke)$/.test(decl.prop) && /^[a-z]+$/i.test(node.value) && !/^(?:inherit|initial|unset|revert|currentcolor|transparent|none)$/i.test(node.value)) violations.add("Use a semantic color token.");
605
+ if (
606
+ node.type === "word" &&
607
+ /^(?:color|background-color|(?:border|outline|caret|text-decoration|column-rule)(?:-[a-z]+)?-color|fill|stroke)$/.test(decl.prop) &&
608
+ /^[a-z]+$/i.test(node.value) &&
609
+ !/^(?:inherit|initial|unset|revert|currentcolor|transparent|none)$/i.test(node.value)
610
+ )
611
+ violations.add("Use a semantic color token.");
230
612
  });
231
- if (/^(?:font-family|font-weight|z-index)$/.test(decl.prop) && !/^(?:var\(|inherit$|initial$|unset$|revert(?:-layer)?$|auto$)/.test(decl.value) && !(foundation && decl.prop === "font-weight" && /^(?:bolder|lighter)$/.test(decl.value))) violations.add("Use a semantic typography or layering token.");
613
+ if (
614
+ /^(?:font-family|font-weight|z-index)$/.test(decl.prop) &&
615
+ !/^(?:var\(|inherit$|initial$|unset$|revert(?:-layer)?$|auto$)/.test(decl.value) &&
616
+ !(foundation && decl.prop === "font-weight" && /^(?:bolder|lighter)$/.test(decl.value))
617
+ )
618
+ violations.add("Use a semantic typography or layering token.");
232
619
  for (const message of violations) report(file, "style-token", message, offset.line + decl.source.start.line - 1, decl.source.start.column);
233
620
  });
234
621
  }
235
622
  for (const file of files) {
236
623
  const role = adsFileRole(file);
237
- const roleExtension=["contract","exports"].includes(role)?/\.[cm]?ts$/.test(file):["fixture","fixtures"].includes(role)?/\.(?:[cm]?[jt]sx?|json)$/.test(file):/\.[cm]?[jt]sx?$/.test(file);
238
- if (role && !configurationScripts.has(file) && (!["contract", "exports", "scenario", "fixture", "fixtures", "helpers", "test", "spec", "behavior.spec"].includes(role)||!roleExtension)) report(file, "development-role", `Unknown .ads. role or unsupported extension: ${role}. Use a TypeScript contract, a script scenario/fixture/helpers/test/behavior.spec, or JSON fixture; marking development code does not grant styling or mutation permissions.`);
624
+ if (
625
+ ["review", "showcase", "composition", "brand"].some((directory) => isInside(path.join(dsRoot, directory), file)) &&
626
+ !role &&
627
+ !isTestFile(file) &&
628
+ !/\.d\.[cm]?ts$/.test(file)
629
+ )
630
+ report(
631
+ file,
632
+ "development-role",
633
+ "Project ADS development sources must use a .ads.* role: .ads.scenario.*, .ads.fixture.*, .ads.helpers.*, .ads.review.* or .ads.mount.*. A folder name does not replace the development-only filename marker.",
634
+ );
635
+ const roleExtension = ["contract", "exports"].includes(role)
636
+ ? /\.[cm]?ts$/.test(file)
637
+ : role === "review"
638
+ ? /\.(?:[cm]?[jt]sx?|css)$/.test(file)
639
+ : role === "mount"
640
+ ? /\.(?:[cm]?[jt]sx?|html)$/.test(file)
641
+ : role === "fixture"
642
+ ? /\.(?:[cm]?[jt]sx?|json)$/.test(file)
643
+ : /\.[cm]?[jt]sx?$/.test(file);
644
+ if (
645
+ role &&
646
+ !configurationScripts.has(file) &&
647
+ (!["contract", "exports", "scenario", "fixture", "helpers", "review", "mount", "test", "spec", "behavior.spec"].includes(role) || !roleExtension)
648
+ )
649
+ report(
650
+ file,
651
+ "development-role",
652
+ `Unknown .ads. role or unsupported extension: ${role}. Use a TypeScript contract, a script scenario/fixture/helpers/test/behavior.spec, JSON fixture, .ads.review.* helper/style or .ads.mount.* adapter; marking development code does not grant styling or mutation permissions.`,
653
+ );
239
654
  // The generated theme sheet and palette are checked for freshness with the tokens, not authored.
240
- if (generatedThemeFiles.some(generated => file === path.join(dsRoot, config.tokenDir, generated))) continue;
241
- if (file.endsWith(".css") && isInside(path.join(dsRoot, config.tokenDir), file) && !isDevelopmentFile(file, options)) { checkCss(file, readFileSync(file, "utf8"), undefined, true); continue; }
242
- if (file.endsWith(".html")) { inspectHtml(readFileSync(file, "utf8"), (rule, message, line) => report(file, rule, message, line)); continue; }
655
+ if (generatedThemeFiles.some((generated) => file === path.join(dsRoot, config.tokenDir, generated))) continue;
656
+ if (file.endsWith(".css") && isInside(path.join(dsRoot, config.tokenDir), file) && !isDevelopmentFile(file, options)) {
657
+ await checkCss(file, readFileSync(file, "utf8"), undefined, true);
658
+ continue;
659
+ }
660
+ if (file.endsWith(".html")) {
661
+ inspectHtml(readFileSync(file, "utf8"), (rule, message, line) => report(file, rule, message, line));
662
+ continue;
663
+ }
243
664
  if (file.endsWith(".css")) {
244
665
  const text = readFileSync(file, "utf8");
245
666
  if (file === path.join(sourceRoot, "app-mount.css") && isMountCss(text)) continue;
246
- checkCss(file, text); continue;
667
+ await checkCss(file, text);
668
+ continue;
247
669
  }
248
- const source = program.getSourceFile(file);
670
+ const source = await program.getSourceFile(file);
249
671
  if (!source) continue;
250
- advisories.push(...pointerCaptureAdvisories(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
251
- advisories.push(...atomicCompositionReview(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
252
- if (["components", "patterns"].some(section => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options)) advisories.push(...renderColorProbe(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
253
- for (const diagnostic of program.getSyntacticDiagnostics(source)) {
672
+ advisories.push(...pointerCaptureAdvisories(source).map((entry) => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
673
+ advisories.push(...(await atomicCompositionReview(source)).map((entry) => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
674
+ if (["components", "patterns"].some((section) => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options))
675
+ advisories.push(...(await renderColorProbe(source)).map((entry) => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
676
+ for (const diagnostic of await program.getSyntacticDiagnostics(source)) {
254
677
  const position = source.getLineAndCharacterOfPosition(diagnostic.start ?? 0);
255
678
  report(file, "source-syntax", ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"), position.line + 1, position.character + 1);
256
679
  }
@@ -261,133 +684,276 @@ export function checkProject(directory, { trackingRoot } = {}) {
261
684
  report(file, rule, message, position.line + 1, position.character + 1);
262
685
  if (detail) Object.assign(diagnostics.at(-1), detail);
263
686
  }
264
- function scenarioClass(node, expression, property = false) {
265
- const proof = scenarioTrace.classValue(expression, property);
266
- if (proof.present && !proof.ok) nodeReport(node, "showcase-class", `Scenarios define no custom class names. A public class helper must return runtime-owned Linaria styles; stable hooks authored in that owner may accompany real styles. Arbitrary strings, private styles and forwarded consumer classes do not qualify.${proof.reasons.length ? ` ${proof.reasons.join(" ")}` : ""} ${scenarioLayoutGuidance} See ads://guides/scenarios.`);
687
+ async function scenarioClass(node, expression, property = false) {
688
+ if (expression && ts.isCallExpression(expression) && ts.isIdentifier(expression.expression) && expression.arguments.every(ts.isStringLiteralLike)) {
689
+ const symbol = await checker.getSymbolAtLocation(expression.expression);
690
+ if (
691
+ symbol?.declarations?.some(
692
+ (decl) =>
693
+ ts.isImportSpecifier(decl) &&
694
+ (decl.propertyName ?? decl.name).text === "previewFrameClasses" &&
695
+ decl.parent.parent.parent.moduleSpecifier.text === "@reqvire-org/ads/preview",
696
+ )
697
+ )
698
+ return;
699
+ }
700
+ const proof = await scenarioTrace.classValue(expression, property);
701
+ if (proof.present && !proof.ok)
702
+ nodeReport(
703
+ node,
704
+ "showcase-class",
705
+ `Scenarios define no custom class names. A public class helper must return runtime-owned Linaria styles; stable hooks authored in that owner may accompany real styles. Arbitrary strings, private styles and forwarded consumer classes do not qualify.${proof.reasons.length ? ` ${proof.reasons.join(" ")}` : ""} ${scenarioLayoutGuidance} See ads://guides/scenarios.`,
706
+ );
267
707
  }
268
- function scenarioControl(node, native) {
269
- const proof = (scenarioSlot ??= createScenarioSlots(program, options))(node);
708
+ async function scenarioControl(node, native) {
709
+ const proof = await (scenarioSlot ??= await createScenarioSlots(program, options))(node);
270
710
  if (proof.ok) return;
271
- const selector = native ? (scenarioSelector ??= createScenarioSelectors(program, options))(node) : { ok: false, reasons: ["A selector cannot establish custom widget behavior or keyboard semantics."] };
272
- if (!selector.ok) nodeReport(node, "showcase-control", `Scenario controls must compose public ADS runtime UI. Native semantics require source evidence of owned cloning props or an attached runtime Linaria selector addressing that native tag or a verified runtime-owned part in that position. A prop name, broad selector or scenario-authored marker grants no permission. ${selector.reasons.join(" ")} Preserve valid APIs when tracing is inconclusive; report the limitation instead of changing the API to satisfy coverage. ${scenarioLayoutGuidance} See ads://guides/scenarios.`, { failure: failure("architecture", "source-ownership", "ownership-not-proven", { certainty: "inconclusive" }) });
711
+ const selector = native
712
+ ? await (scenarioSelector ??= await createScenarioSelectors(program, options))(node)
713
+ : { ok: false, reasons: ["A selector cannot establish custom widget behavior or keyboard semantics."] };
714
+ if (!selector.ok)
715
+ nodeReport(
716
+ node,
717
+ "showcase-control",
718
+ `Scenario controls must compose public ADS runtime UI. Native semantics require source evidence of owned cloning props or an attached runtime Linaria selector addressing that native tag or a verified runtime-owned part in that position. A prop name, broad selector or scenario-authored marker grants no permission. ${selector.reasons.join(" ")} Preserve valid APIs when tracing is inconclusive; report the limitation instead of changing the API to satisfy coverage. ${scenarioLayoutGuidance} See ads://guides/scenarios.`,
719
+ { failure: failure("architecture", "source-ownership", "ownership-not-proven", { certainty: "inconclusive" }) },
720
+ );
273
721
  }
274
- if (!showcase && (isInside(path.join(dsRoot, "components"), file) || isInside(path.join(dsRoot, "patterns"), file))) inspectPublicProps(source, checker, nodeReport, paintContracts.allowedProperties);
275
- function isLinariaTag(tag) {
722
+ if (!showcase && (isInside(path.join(dsRoot, "components"), file) || isInside(path.join(dsRoot, "patterns"), file)))
723
+ await inspectPublicProps(source, checker, nodeReport, paintContracts.allowedProperties);
724
+ async function isLinariaTag(tag) {
276
725
  if (ts.isCallExpression(tag)) tag = tag.expression;
277
726
  let symbolNode = tag;
278
727
  while (ts.isPropertyAccessExpression(symbolNode)) symbolNode = symbolNode.expression;
279
- const symbol = checker.getSymbolAtLocation(symbolNode);
728
+ const symbol = await checker.getSymbolAtLocation(symbolNode);
280
729
  return symbol?.declarations?.some((decl) => {
281
730
  if (ts.isImportSpecifier(decl)) {
282
731
  const module = decl.parent.parent.parent.moduleSpecifier;
283
732
  return ["css", "styled"].includes((decl.propertyName ?? decl.name).text) && ts.isStringLiteral(module) && module.text.startsWith("@linaria/");
284
733
  }
285
- if (ts.isNamespaceImport(decl) && ts.isPropertyAccessExpression(tag) && /^(?:css|styled)(?:\.|$)/.test(tag.getText(source).slice(symbolNode.getText(source).length + 1))) {
734
+ if (
735
+ ts.isNamespaceImport(decl) &&
736
+ ts.isPropertyAccessExpression(tag) &&
737
+ /^(?:css|styled)(?:\.|$)/.test(tag.getText(source).slice(symbolNode.getText(source).length + 1))
738
+ ) {
286
739
  const module = decl.parent.parent.moduleSpecifier;
287
740
  return ts.isStringLiteral(module) && module.text.startsWith("@linaria/");
288
741
  }
289
742
  return false;
290
743
  });
291
744
  }
292
- function inspectProperty(value) {
745
+ async function inspectProperty(value) {
293
746
  if (ts.isPropertyAssignment(value) && (ts.isStringLiteralLike(value.name) || ts.isIdentifier(value.name))) {
294
- const variable = checkComponentVariable(value.name.text, file, options);
747
+ const variable = await checkComponentVariable(value.name.text, file, options);
295
748
  if (variable) nodeReport(value.name, variable.rule, variable.message);
296
749
  }
297
- ts.forEachChild(value, inspectProperty);
750
+ await eachChild(value, inspectProperty);
298
751
  }
299
752
  function inspectClass(value) {
300
753
  if (ts.isStringLiteralLike(value)) {
301
- if (/(?:^|\s)ads-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "components"), file)) nodeReport(value, "style-ownership", "Primitive ads-* classes must be emitted by components, not consumers.");
302
- if (/(?:^|\s)ux-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "patterns"), file) && !isReviewFile(file, options)) nodeReport(value, "style-ownership", "Pattern ux-* classes must be emitted by patterns, not consumers.");
303
- if (/(?:^|\s)showcase-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "showcase"), file) && !isReviewFile(file, options)) nodeReport(value, "style-ownership", "Showcase hooks must be emitted by development review code, not runtime implementations.");
754
+ if (/(?:^|\s)ads-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "components"), file))
755
+ nodeReport(value, "style-ownership", "Primitive ads-* classes must be emitted by components, not consumers.");
756
+ if (/(?:^|\s)ux-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "patterns"), file) && !isReviewFile(file, options))
757
+ nodeReport(value, "style-ownership", "Pattern ux-* classes must be emitted by patterns, not consumers.");
758
+ if (/(?:^|\s)showcase-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "showcase"), file) && !isReviewFile(file, options))
759
+ nodeReport(value, "style-ownership", "Showcase hooks must be emitted by development review code, not runtime implementations.");
304
760
  }
305
761
  ts.forEachChild(value, inspectClass);
306
762
  }
307
- const nativePreact = (source.pragmas?.get("jsximportsource")?.arguments.factory ?? compiler.jsxImportSource) === "preact";
763
+ const nativePreact = jsxImportSource(source, compiler) === "preact";
308
764
  function checkSvgAttribute(node, name) {
309
- if (svgPresentation.has(name)) nodeReport(node, "svg-attribute", `Native Preact SVG needs ${name.replace(/[A-Z]/g, letter => "-" + letter.toLowerCase())}; React-style ${name} is not normalized by its native renderer.`);
765
+ if (svgPresentation.has(name))
766
+ nodeReport(
767
+ node,
768
+ "svg-attribute",
769
+ `Native Preact SVG needs ${name.replace(/[A-Z]/g, (letter) => "-" + letter.toLowerCase())}; React-style ${name} is not normalized by its native renderer.`,
770
+ );
310
771
  }
311
- const lightDarkLiterals = ["components", "patterns"].some(section => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options);
772
+ const lightDarkLiterals = ["components", "patterns"].some((section) => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options);
312
773
  // Per-file facts, computed once rather than at every syntax node.
313
- const fileInDs = isInside(dsRoot, file);
314
- function inLinariaTemplate(node) {
774
+ const fileInDs = isInside(dsRoot, file),
775
+ testFile = isTestFile(file);
776
+ async function inLinariaTemplate(node) {
315
777
  const template = ts.isTemplateMiddle(node) || ts.isTemplateTail(node) ? node.parent.parent : node.parent;
316
778
  const tagged = ts.isTemplateExpression(template) ? template.parent : template;
317
- return ts.isTaggedTemplateExpression(tagged) && isLinariaTag(tagged.tag);
779
+ return ts.isTaggedTemplateExpression(tagged) && (await isLinariaTag(tagged.tag));
318
780
  }
319
- function visit(node) {
781
+ async function visit(node) {
320
782
  if (nativePreact && ts.isJsxAttribute(node) && ts.isIdentifier(node.name)) {
321
783
  const parent = node.parent.parent;
322
- if ((ts.isJsxOpeningElement(parent) || ts.isJsxSelfClosingElement(parent)) && ts.isIdentifier(parent.tagName) && svgTags.has(parent.tagName.text)) checkSvgAttribute(node, node.name.text);
784
+ if ((ts.isJsxOpeningElement(parent) || ts.isJsxSelfClosingElement(parent)) && ts.isIdentifier(parent.tagName) && svgTags.has(parent.tagName.text))
785
+ checkSvgAttribute(node, node.name.text);
323
786
  }
324
- if (ts.isCallExpression(node) && uiOperation(node.expression, checker) === "createElement") {
787
+ if (ts.isCallExpression(node) && (await uiOperation(node.expression, checker)) === "createElement") {
325
788
  const [tag, props] = node.arguments;
326
789
  const properties = props && ts.isObjectLiteralExpression(props) ? props.properties : [];
327
790
  for (const property of properties) {
328
791
  if (!ts.isPropertyAssignment(property) || !(ts.isIdentifier(property.name) || ts.isStringLiteralLike(property.name))) continue;
329
- if (tag && ts.isStringLiteralLike(tag) && svgTags.has(tag.text) && importedUiApi(node.expression, checker)?.module === "preact") checkSvgAttribute(property, property.name.text);
330
- if (property.name.text === "style" && (!inlineAllowed || showcase)) nodeReport(property, "no-inline-style", showcase ? `Scenarios define no inline styles. ${scenarioLayoutGuidance}` : inlineStyleGuidance);
331
- if (property.name.text === "style") inspectProperty(property.initializer);
792
+ if (tag && ts.isStringLiteralLike(tag) && svgTags.has(tag.text) && (await importedUiApi(node.expression, checker))?.module === "preact")
793
+ checkSvgAttribute(property, property.name.text);
794
+ if (property.name.text === "style" && (!inlineAllowed || showcase))
795
+ nodeReport(property, "no-inline-style", showcase ? `Scenarios define no inline styles. ${scenarioLayoutGuidance}` : inlineStyleGuidance);
796
+ if (property.name.text === "style") await inspectProperty(property.initializer);
332
797
  if (property.name.text === "className") inspectClass(property.initializer);
333
- if (showcase && property.name.text === "className") scenarioClass(property, property.initializer);
798
+ if (showcase && property.name.text === "className") await scenarioClass(property, property.initializer);
334
799
  }
335
- if (showcase && props && !ts.isObjectLiteralExpression(props)) scenarioClass(props, props, true);
336
- if (showcase) for (const property of properties) if (ts.isSpreadAssignment(property)) scenarioClass(property, property.expression, true);
800
+ if (showcase && props && !ts.isObjectLiteralExpression(props)) await scenarioClass(props, props, true);
801
+ if (showcase) for (const property of properties) if (ts.isSpreadAssignment(property)) await scenarioClass(property, property.expression, true);
337
802
  if (showcase && tag && ts.isStringLiteralLike(tag)) {
338
- const role = properties.find(property => ts.isPropertyAssignment(property) && (ts.isIdentifier(property.name) || ts.isStringLiteralLike(property.name)) && property.name.text === "role")?.initializer;
339
- if (showcaseControls.has(tag.text) || role && ts.isStringLiteralLike(role) && widgetRoles.has(role.text)) scenarioControl(node, showcaseControls.has(tag.text));
803
+ const role = properties.find(
804
+ (property) =>
805
+ ts.isPropertyAssignment(property) && (ts.isIdentifier(property.name) || ts.isStringLiteralLike(property.name)) && property.name.text === "role",
806
+ )?.initializer;
807
+ if (showcaseControls.has(tag.text) || (role && ts.isStringLiteralLike(role) && widgetRoles.has(role.text)))
808
+ await scenarioControl(node, showcaseControls.has(tag.text));
340
809
  }
341
810
  }
342
- if (fileInDs && (ts.isIdentifier(node) && ["fetch", "XMLHttpRequest", "WebSocket", "EventSource"].includes(node.text) && !(ts.isPropertyAccessExpression(node.parent) && node.parent.name === node))) {
343
- const declarations = checker.getSymbolAtLocation(node)?.declarations ?? [];
344
- if (!declarations.some((declaration) => !declaration.getSourceFile().isDeclarationFile)) nodeReport(node, "data-access", "ADS UI and scenarios receive business data through typed inputs or injected services. Direct network access belongs in an application adapter; fixture services remain local.");
811
+ // Tests may stub or observe the network (a behavior spec injecting transport failures);
812
+ // the rule keeps business data out of UI and scenarios.
813
+ if (
814
+ fileInDs &&
815
+ !testFile &&
816
+ ts.isIdentifier(node) && ["fetch", "XMLHttpRequest", "WebSocket", "EventSource"].includes(node.text) &&
817
+ !(ts.isPropertyAccessExpression(node.parent) && node.parent.name === node)
818
+ ) {
819
+ const declarations = (await checker.getSymbolAtLocation(node))?.declarations ?? [];
820
+ if (!declarations.some((declaration) => !declaration.getSourceFile().isDeclarationFile))
821
+ nodeReport(
822
+ node,
823
+ "data-access",
824
+ "ADS UI and scenarios receive business data through typed inputs or injected services. Direct network access belongs in an application adapter; fixture services remain local.",
825
+ );
345
826
  }
346
- if (fileInDs && ts.isPropertyAccessExpression(node) && ["window", "globalThis", "self"].includes(node.expression.getText(source)) && ["fetch", "XMLHttpRequest", "WebSocket", "EventSource"].includes(node.name.text)) nodeReport(node, "data-access", "Inject the data service instead of using a global network API in ADS UI or scenarios.");
827
+ if (
828
+ fileInDs &&
829
+ !testFile &&
830
+ ts.isPropertyAccessExpression(node) &&
831
+ ["window", "globalThis", "self"].includes(node.expression.getText(source)) &&
832
+ ["fetch", "XMLHttpRequest", "WebSocket", "EventSource"].includes(node.name.text)
833
+ )
834
+ nodeReport(node, "data-access", "Inject the data service instead of using a global network API in ADS UI or scenarios.");
347
835
  if (showcase && (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && ts.isIdentifier(node.tagName) && /^[a-z]/.test(node.tagName.text)) {
348
836
  const role = node.attributes.properties.find((attr) => ts.isJsxAttribute(attr) && attr.name.text === "role")?.initializer;
349
- const roleValue = role && ts.isStringLiteralLike(role) ? role.text : role && ts.isJsxExpression(role) && role.expression && ts.isStringLiteralLike(role.expression) ? role.expression.text : null;
350
- if (showcaseControls.has(node.tagName.text) || widgetRoles.has(roleValue)) scenarioControl(node, showcaseControls.has(node.tagName.text));
837
+ const roleValue =
838
+ role && ts.isStringLiteralLike(role)
839
+ ? role.text
840
+ : role && ts.isJsxExpression(role) && role.expression && ts.isStringLiteralLike(role.expression)
841
+ ? role.expression.text
842
+ : null;
843
+ if (showcaseControls.has(node.tagName.text) || widgetRoles.has(roleValue)) await scenarioControl(node, showcaseControls.has(node.tagName.text));
351
844
  }
352
- if (showcase && ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className") scenarioClass(node, node.initializer && ts.isJsxExpression(node.initializer) ? node.initializer.expression : node.initializer);
353
- if (showcase && ts.isJsxSpreadAttribute(node)) scenarioClass(node, node.expression, true);
845
+ if (showcase && ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className")
846
+ await scenarioClass(node, node.initializer && ts.isJsxExpression(node.initializer) ? node.initializer.expression : node.initializer);
847
+ if (showcase && ts.isJsxSpreadAttribute(node)) await scenarioClass(node, node.expression, true);
354
848
  let specifier;
355
- if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) specifier = node.moduleSpecifier.text;
356
- if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword && node.arguments[0] && ts.isStringLiteral(node.arguments[0])) specifier = node.arguments[0].text;
357
- if (specifier && !(configurationScripts.has(file)&&resolveImport(specifier,file).every(target=>configurationScripts.has(target))) && importViolation(specifier, file, options, resolveImport)) nodeReport(node, "public-import", `Import through ${config.publicAlias}, not ADS implementation paths.`);
358
- if (specifier && resolveImport(specifier, file).some((target) => (specifier.startsWith(".") || existsSync(target)) && target.endsWith(".css") && isInside(root, target) && !isInside(dsRoot, target) && target !== path.join(sourceRoot, "app-mount.css") && !isInside(path.join(root, "node_modules"), target))) nodeReport(node, "style-ownership", "Imported project CSS belongs to ADS components, patterns, or the foundation. Only structural app-mount.css is allowed outside the ADS.");
359
- if (specifier && appImportViolation(specifier, file, options, resolveImport)) nodeReport(node, "no-app-import", "ADS implementations and showcase fixtures must not import app code. Use public ADS APIs with local fixture data; keep application integration harnesses in application tests.");
360
- if (specifier && showcaseImportViolation(specifier, file, options, resolveImport)) nodeReport(node, "showcase-import", "Showcase code and styles are development fixtures; runtime code must not import them.");
849
+ if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier))
850
+ specifier = node.moduleSpecifier.text;
851
+ if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword && node.arguments[0] && ts.isStringLiteral(node.arguments[0]))
852
+ specifier = node.arguments[0].text;
853
+ if (
854
+ specifier &&
855
+ !(configurationScripts.has(file) && (await resolveImport(specifier, file)).every((target) => configurationScripts.has(target))) &&
856
+ (await importViolation(specifier, file, options, resolveImport))
857
+ )
858
+ nodeReport(node, "public-import", `Import through ${config.publicAlias}, not ADS implementation paths.`);
859
+ if (
860
+ specifier &&
861
+ (await resolveImport(specifier, file)).some(
862
+ (target) =>
863
+ (specifier.startsWith(".") || existsSync(target)) &&
864
+ target.endsWith(".css") &&
865
+ isInside(root, target) &&
866
+ !isInside(dsRoot, target) &&
867
+ target !== path.join(sourceRoot, "app-mount.css") &&
868
+ !isInside(path.join(root, "node_modules"), target),
869
+ )
870
+ )
871
+ nodeReport(
872
+ node,
873
+ "style-ownership",
874
+ "Imported project CSS belongs to ADS components, patterns, or the foundation. Only structural app-mount.css is allowed outside the ADS.",
875
+ );
876
+ if (specifier && (await appImportViolation(specifier, file, options, resolveImport)))
877
+ nodeReport(
878
+ node,
879
+ "no-app-import",
880
+ "ADS implementations and showcase fixtures must not import app code. Use public ADS APIs with local fixture data; keep application integration harnesses in application tests.",
881
+ );
882
+ if (specifier && (await showcaseImportViolation(specifier, file, options, resolveImport)))
883
+ nodeReport(node, "showcase-import", "Showcase code and styles are development fixtures; runtime code must not import them.");
361
884
  const boundStyle = runtimeContracts.allowedStyles.has(`${file}:${node.pos}`);
362
- if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "style" && (!inlineAllowed || showcase) && !boundStyle) nodeReport(node, "no-inline-style", showcase ? `Scenarios define no inline styles. ${scenarioLayoutGuidance}` : inlineStyleGuidance);
885
+ if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "style" && (!inlineAllowed || showcase) && !boundStyle)
886
+ nodeReport(node, "no-inline-style", showcase ? `Scenarios define no inline styles. ${scenarioLayoutGuidance}` : inlineStyleGuidance);
363
887
  if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "style" && node.initializer) {
364
- inspectProperty(node.initializer);
888
+ await inspectProperty(node.initializer);
365
889
  }
366
- const mutation = styleWriteViolation(node, file, options);
890
+ const mutation = await styleWriteViolation(node, file, options);
367
891
  if (mutation) nodeReport(node, "style-mutation", mutation);
368
- if (!inlineAllowed && isUiCssProperties(node, checker) && !runtimeContracts.allowedStyleTypes.has(`${file}:${node.pos}`)) nodeReport(node, "css-properties", "Keep CSSProperties out of the public API. Use deliberate component contracts or a documented measured-geometry renderer boundary; demo layout belongs in a development-only review/ helper.");
892
+ if (!inlineAllowed && (await isUiCssProperties(node, checker)) && !runtimeContracts.allowedStyleTypes.has(`${file}:${node.pos}`))
893
+ nodeReport(
894
+ node,
895
+ "css-properties",
896
+ "Keep CSSProperties out of the public API. Use deliberate component contracts or a documented measured-geometry renderer boundary; demo layout belongs in a development-only review/ helper.",
897
+ );
369
898
  if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className" && node.initializer) {
370
899
  inspectClass(node.initializer);
371
900
  }
372
901
  // Runtime inline values (style objects, inline custom properties, <style> text) give
373
902
  // per-theme values with the generated themed(), not light-dark(); Linaria templates are
374
903
  // checked as CSS above.
375
- if (lightDarkLiterals && (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node) || ts.isTemplateHead(node) || ts.isTemplateMiddle(node) || ts.isTemplateTail(node)) && /\blight-dark\(/i.test(node.text) && !inLinariaTemplate(node)) nodeReport(node, "theme-light-dark", `Give per-theme values as token halves (--x-light, --x-dark); light-dark() is limited to two schemes; for runtime values use themed() from ${config.tokenDir}/${generatedPaletteFile}.`, { severity: findingSeverity("theme-light-dark") });
376
- if (ts.isTaggedTemplateExpression(node) && isLinariaTag(node.tag)) {
904
+ if (
905
+ lightDarkLiterals &&
906
+ (ts.isStringLiteral(node) ||
907
+ ts.isNoSubstitutionTemplateLiteral(node) ||
908
+ ts.isTemplateHead(node) ||
909
+ ts.isTemplateMiddle(node) ||
910
+ ts.isTemplateTail(node)) &&
911
+ /\blight-dark\(/i.test(node.text) &&
912
+ !(await inLinariaTemplate(node))
913
+ )
914
+ nodeReport(
915
+ node,
916
+ "theme-light-dark",
917
+ `Give per-theme values as token halves (--x-light, --x-dark); light-dark() is limited to two schemes; for runtime values use themed() from ${config.tokenDir}/${generatedPaletteFile}.`,
918
+ { severity: findingSeverity("theme-light-dark") },
919
+ );
920
+ if (ts.isTaggedTemplateExpression(node) && (await isLinariaTag(node.tag))) {
377
921
  const template = node.template;
378
- const texts = ts.isNoSubstitutionTemplateLiteral(template) ? [template.text] : template.templateSpans.reduce((prefixes,span)=>{const parts=designValues(span.expression);return prefixes.flatMap(prefix=>(parts.length?parts:["__ds_expression__"]).map(value=>prefix+value+span.literal.text)).slice(0,32);},[template.head.text]);
922
+ const variants = await designTemplateVariants(template, designValues);
923
+ if (variants.reason) nodeReport(variants.node, "design-value-source", `Cannot establish every interpolated style alternative from source. ${variants.reason}`);
379
924
  const position = source.getLineAndCharacterOfPosition(template.getStart(source) + 1);
380
- for(const text of texts)checkCss(file, text, { line: position.line + 1, column: position.character + 1 });
925
+ for (const text of variants.texts) await checkCss(file, text, { line: position.line + 1, column: position.character + 1 }, false, node);
381
926
  }
382
- ts.forEachChild(node, visit);
927
+ await eachChild(node, visit);
383
928
  }
384
- visit(source);
929
+ await visit(source);
385
930
  }
386
- inspectDesignAliases(layerStyles,options,report);
387
- for (const { file, css, offset } of layerStyles) layers.inspectStyles(file, css, offset);
388
- advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories, ...a11ySourceAdvisories(options), ...imageAttributeFindings(options), ...componentContrast.findings(), ...layoutWidths.declaredWidths(ownerFixedWidths), ...fontRules.findings());
931
+ diagnostics.push(...await spatialComposition.check());
932
+ await contrastComposition.check();
933
+ inspectDesignAliases(layerStyles, options, report);
934
+ for (const { file, css, offset } of layerStyles) await layers.inspectStyles(file, css, offset);
935
+ advisories.push(
936
+ ...(tokenInventory.advisories ?? []),
937
+ ...assetAdvisories,
938
+ ...(await a11ySourceAdvisories(options, scriptFiles)),
939
+ ...(await imageAttributeFindings(options, scriptFiles)),
940
+ ...componentContrast.findings(),
941
+ ...layoutWidths.declaredWidths(ownerFixedWidths),
942
+ ...fontRules.findings(),
943
+ );
389
944
  // Errors block by class; bounded clients see review items before informational limits.
390
- const routed=routeFindings(diagnostics,advisories);
391
- const uniqueDiagnostics=[...new Map(routed.diagnostics.map(diagnostic=>[JSON.stringify([diagnostic.file,diagnostic.rule,diagnostic.line,diagnostic.column,diagnostic.message]),diagnostic])).values()];
392
- return architectureEvidence({ ok: uniqueDiagnostics.length === 0, diagnostics:uniqueDiagnostics, ...(routed.advisories.length ? { advisories: routed.advisories } : {}) });
945
+ const routed = routeFindings(diagnostics, advisories);
946
+ const uniqueDiagnostics = [
947
+ ...new Map(
948
+ routed.diagnostics.map((diagnostic) => [
949
+ JSON.stringify([diagnostic.file, diagnostic.rule, diagnostic.line, diagnostic.column, diagnostic.message]),
950
+ diagnostic,
951
+ ]),
952
+ ).values(),
953
+ ];
954
+ return architectureEvidence({
955
+ ok: uniqueDiagnostics.length === 0,
956
+ diagnostics: uniqueDiagnostics,
957
+ ...(routed.advisories.length ? { advisories: routed.advisories } : {}),
958
+ });
393
959
  }