@reqvire-org/ads 0.4.0 → 0.4.2

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