@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
@@ -1,5 +1,6 @@
1
+ import { eachChild } from "./analysis/queries.mjs";
1
2
  import path from "node:path";
2
- import ts from "typescript";
3
+ import ts from "./analysis/syntax.mjs";
3
4
  import postcss from "postcss";
4
5
  import valueParser from "postcss-value-parser";
5
6
  import { isInside } from "./config.mjs";
@@ -11,14 +12,32 @@ export const atomicStyleGuide = "ads://guides/atomic-styles";
11
12
 
12
13
  const sides = ["top", "right", "bottom", "left"];
13
14
  const logicalSides = ["block-start", "block-end", "inline-start", "inline-end"];
14
- const intersects = (a, b) => a.some(value => b.includes(value));
15
- const previewValue = value => value.length > 200 ? value.slice(0, 197) + "..." : value;
15
+ const intersects = (a, b) => a.some((value) => b.includes(value));
16
+ const previewValue = (value) => (value.length > 200 ? value.slice(0, 197) + "..." : value);
16
17
  const shorthands = {
17
- background: ["background-attachment", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-repeat", "background-size"],
18
+ background: [
19
+ "background-attachment",
20
+ "background-clip",
21
+ "background-color",
22
+ "background-image",
23
+ "background-origin",
24
+ "background-position",
25
+ "background-repeat",
26
+ "background-size",
27
+ ],
18
28
  "background-position": ["background-position-x", "background-position-y"],
19
29
  "background-repeat": ["background-repeat-x", "background-repeat-y"],
20
30
  font: ["font-family", "font-size", "font-stretch", "font-style", "font-variant", "font-weight", "line-height"],
21
- animation: ["animation-name", "animation-duration", "animation-timing-function", "animation-delay", "animation-iteration-count", "animation-direction", "animation-fill-mode", "animation-play-state"],
31
+ animation: [
32
+ "animation-name",
33
+ "animation-duration",
34
+ "animation-timing-function",
35
+ "animation-delay",
36
+ "animation-iteration-count",
37
+ "animation-direction",
38
+ "animation-fill-mode",
39
+ "animation-play-state",
40
+ ],
22
41
  transition: ["transition-property", "transition-duration", "transition-timing-function", "transition-delay", "transition-behavior"],
23
42
  flex: ["flex-grow", "flex-shrink", "flex-basis"],
24
43
  "flex-flow": ["flex-direction", "flex-wrap"],
@@ -29,12 +48,15 @@ const shorthands = {
29
48
  "list-style": ["list-style-image", "list-style-position", "list-style-type"],
30
49
  "text-decoration": ["text-decoration-color", "text-decoration-style", "text-decoration-line", "text-decoration-thickness"],
31
50
  };
32
- const expand = property => shorthands[property]?.flatMap(expand) ?? [property];
33
- const longhands = new Map(Object.keys(shorthands).map(property => [property, expand(property)]));
51
+ const expand = (property) => shorthands[property]?.flatMap(expand) ?? [property];
52
+ const longhands = new Map(Object.keys(shorthands).map((property) => [property, expand(property)]));
34
53
 
35
54
  // CSS-language relationships, independent of components, tokens and frameworks.
36
55
  function footprint(property) {
37
- const box = /^(padding|margin|scroll-padding|scroll-margin|inset)(?:-(top|right|bottom|left|block|inline|block-start|block-end|inline-start|inline-end))?$/.exec(property);
56
+ const box =
57
+ /^(padding|margin|scroll-padding|scroll-margin|inset)(?:-(top|right|bottom|left|block|inline|block-start|block-end|inline-start|inline-end))?$/.exec(
58
+ property,
59
+ );
38
60
  if (box) {
39
61
  const side = box[2];
40
62
  const logical = !!side && !sides.includes(side);
@@ -44,7 +66,13 @@ function footprint(property) {
44
66
  const border = /^border(?:-(top|right|bottom|left|block|inline|block-start|block-end|inline-start|inline-end))?(?:-(color|style|width))?$/.exec(property);
45
67
  if (border) {
46
68
  const side = border[1];
47
- return { family: "border", logical: !!side && !sides.includes(side), slots: !side ? logicalSides : /^(block|inline)$/.test(side) ? [`${side}-start`, `${side}-end`] : [side], whole: !side, fields: border[2] ? [border[2]] : ["color", "style", "width"] };
69
+ return {
70
+ family: "border",
71
+ logical: !!side && !sides.includes(side),
72
+ slots: !side ? logicalSides : /^(block|inline)$/.test(side) ? [`${side}-start`, `${side}-end`] : [side],
73
+ whole: !side,
74
+ fields: border[2] ? [border[2]] : ["color", "style", "width"],
75
+ };
48
76
  }
49
77
  const corner = /^border-(?:(top-left|top-right|bottom-left|bottom-right|start-start|start-end|end-start|end-end)-)?radius$/.exec(property);
50
78
  if (corner) return { family: "radius", logical: /^(start|end)-/.test(corner[1] ?? ""), whole: !corner[1], slots: [corner[1]] };
@@ -57,8 +85,9 @@ function footprint(property) {
57
85
 
58
86
  function overlaps(a, b) {
59
87
  if (a === b || a.startsWith("--") || b.startsWith("--")) return false;
60
- if ([a, b].includes("all")) return ![a, b].some(value => ["direction", "unicode-bidi"].includes(value));
61
- const first = footprint(a), second = footprint(b);
88
+ if ([a, b].includes("all")) return ![a, b].some((value) => ["direction", "unicode-bidi"].includes(value));
89
+ const first = footprint(a),
90
+ second = footprint(b);
62
91
  if (first && second && first.family === second.family) {
63
92
  if (first.fields && !intersects(first.fields, second.fields)) return false;
64
93
  return first.whole || second.whole || first.logical !== second.logical || intersects(first.slots, second.slots);
@@ -66,7 +95,7 @@ function overlaps(a, b) {
66
95
  return intersects(longhands.get(a) ?? [a], longhands.get(b) ?? [b]);
67
96
  }
68
97
 
69
- const modes = ["horizontal-tb", "vertical-rl", "vertical-lr"].flatMap(mode => ["ltr", "rtl"].map(direction => ({ mode, direction })));
98
+ const modes = ["horizontal-tb", "vertical-rl", "vertical-lr"].flatMap((mode) => ["ltr", "rtl"].map((direction) => ({ mode, direction })));
70
99
  function physicalSlots(property, { mode, direction }) {
71
100
  const value = footprint(property);
72
101
  if (!value) return null;
@@ -75,38 +104,59 @@ function physicalSlots(property, { mode, direction }) {
75
104
  const axes = {
76
105
  "block-start": horizontal ? "top" : mode === "vertical-rl" ? "right" : "left",
77
106
  "block-end": horizontal ? "bottom" : mode === "vertical-rl" ? "left" : "right",
78
- "inline-start": horizontal ? direction === "ltr" ? "left" : "right" : direction === "ltr" ? "top" : "bottom",
79
- "inline-end": horizontal ? direction === "ltr" ? "right" : "left" : direction === "ltr" ? "bottom" : "top",
80
- "inline-size": horizontal ? "width" : "height", "block-size": horizontal ? "height" : "width",
81
- inline: horizontal ? "x" : "y", block: horizontal ? "y" : "x",
107
+ "inline-start": horizontal ? (direction === "ltr" ? "left" : "right") : direction === "ltr" ? "top" : "bottom",
108
+ "inline-end": horizontal ? (direction === "ltr" ? "right" : "left") : direction === "ltr" ? "bottom" : "top",
109
+ "inline-size": horizontal ? "width" : "height",
110
+ "block-size": horizontal ? "height" : "width",
111
+ inline: horizontal ? "x" : "y",
112
+ block: horizontal ? "y" : "x",
82
113
  };
83
- return value.slots.map(slot => value.family === "radius" && slot ? (/^(start|end)-/.test(slot) ? [axes[`block-${slot.split("-")[0]}`], axes[`inline-${slot.split("-")[1]}`]] : slot.split("-")).sort().join("-") : axes[slot] ?? slot);
114
+ return value.slots.map((slot) =>
115
+ value.family === "radius" && slot
116
+ ? (/^(start|end)-/.test(slot) ? [axes[`block-${slot.split("-")[0]}`], axes[`inline-${slot.split("-")[1]}`]] : slot.split("-")).sort().join("-")
117
+ : (axes[slot] ?? slot),
118
+ );
84
119
  }
85
120
  function writingModeDependent(a, b) {
86
- const first = footprint(a), second = footprint(b);
121
+ const first = footprint(a),
122
+ second = footprint(b);
87
123
  if (!first || !second || first.family !== second.family || first.whole || second.whole || first.logical === second.logical) return false;
88
- const matches = modes.map(mode => intersects(physicalSlots(a, mode), physicalSlots(b, mode)));
124
+ const matches = modes.map((mode) => intersects(physicalSlots(a, mode), physicalSlots(b, mode)));
89
125
  return matches.some(Boolean) && !matches.every(Boolean);
90
126
  }
91
127
  function words(value) {
92
128
  const nodes = valueParser(value).nodes;
93
- return nodes.every(node => ["word", "space", "comment"].includes(node.type)) ? nodes.filter(node => node.type === "word").map(node => node.value.toLowerCase()) : null;
129
+ return nodes.every((node) => ["word", "space", "comment"].includes(node.type))
130
+ ? nodes.filter((node) => node.type === "word").map((node) => node.value.toLowerCase())
131
+ : null;
94
132
  }
95
133
  function boxValues(entry, mode) {
96
- const value = footprint(entry.property), parts = words(entry.value);
97
- if (!value || !["padding", "margin", "scroll-padding", "scroll-margin", "inset"].includes(value.family) || !parts?.length || parts.length > 4 || parts.some(part => ["inherit", "initial", "unset", "revert", "revert-layer"].includes(part))) return null;
134
+ const value = footprint(entry.property),
135
+ parts = words(entry.value);
136
+ if (
137
+ !value ||
138
+ !["padding", "margin", "scroll-padding", "scroll-margin", "inset"].includes(value.family) ||
139
+ !parts?.length ||
140
+ parts.length > 4 ||
141
+ parts.some((part) => ["inherit", "initial", "unset", "revert", "revert-layer"].includes(part))
142
+ )
143
+ return null;
98
144
  const slots = physicalSlots(entry.property, mode);
99
145
  if (!value.whole && parts.length > slots.length) return null;
100
- const expanded = value.whole ? [parts[0], parts[1] ?? parts[0], parts[2] ?? parts[0], parts[3] ?? parts[1] ?? parts[0]] : slots.map((_slot, index) => parts[index] ?? parts[0]);
146
+ const expanded = value.whole
147
+ ? [parts[0], parts[1] ?? parts[0], parts[2] ?? parts[0], parts[3] ?? parts[1] ?? parts[0]]
148
+ : slots.map((_slot, index) => parts[index] ?? parts[0]);
101
149
  return new Map(slots.map((slot, index) => [slot, expanded[index]]));
102
150
  }
103
151
  function equivalent(a, b) {
104
152
  // Only suppress values whose overlap can be established from literal source.
105
153
  // var(), calc(), inheritance and token aliases still need rendered review.
106
- const first = footprint(a.property), second = footprint(b.property);
154
+ const first = footprint(a.property),
155
+ second = footprint(b.property);
107
156
  if (first && second && first.family === second.family && ["padding", "margin", "scroll-padding", "scroll-margin", "inset"].includes(first.family)) {
108
- return modes.every(mode => {
109
- const left = boxValues(a, mode), right = boxValues(b, mode);
157
+ return modes.every((mode) => {
158
+ const left = boxValues(a, mode),
159
+ right = boxValues(b, mode);
110
160
  return left && right && [...left].every(([slot, value]) => !right.has(slot) || right.get(slot) === value);
111
161
  });
112
162
  }
@@ -114,103 +164,174 @@ function equivalent(a, b) {
114
164
  const field = flex === a ? b : a;
115
165
  if (flex && ["flex-grow", "flex-shrink", "flex-basis"].includes(field.property)) {
116
166
  const parts = words(flex.value);
117
- return parts?.length === 3 && /^\d+(?:\.\d+)?$/.test(parts[0]) && /^\d+(?:\.\d+)?$/.test(parts[1]) && /^(?:auto|0|\d+(?:\.\d+)?(?:px|rem|em|%))$/.test(parts[2]) && parts[["flex-grow", "flex-shrink", "flex-basis"].indexOf(field.property)] === field.value.trim().toLowerCase();
167
+ return (
168
+ parts?.length === 3 &&
169
+ /^\d+(?:\.\d+)?$/.test(parts[0]) &&
170
+ /^\d+(?:\.\d+)?$/.test(parts[1]) &&
171
+ /^(?:auto|0|\d+(?:\.\d+)?(?:px|rem|em|%))$/.test(parts[2]) &&
172
+ parts[["flex-grow", "flex-shrink", "flex-basis"].indexOf(field.property)] === field.value.trim().toLowerCase()
173
+ );
118
174
  }
119
175
  return false;
120
176
  }
121
177
 
122
178
  function valueModeDependent(a, b) {
123
- const equal = modes.map(mode => {
124
- const left = boxValues(a, mode), right = boxValues(b, mode);
179
+ const equal = modes.map((mode) => {
180
+ const left = boxValues(a, mode),
181
+ right = boxValues(b, mode);
125
182
  return left && right ? [...left].every(([slot, value]) => !right.has(slot) || right.get(slot) === value) : null;
126
183
  });
127
184
  return !equal.includes(null) && equal.some(Boolean) && !equal.every(Boolean);
128
185
  }
129
186
 
130
187
  function unwrap(node) {
131
- while (node && (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node))) node = node.expression;
188
+ while (node && (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node)))
189
+ node = node.expression;
132
190
  return node;
133
191
  }
134
192
 
135
193
  /** Review only: valid CSS can intentionally overlap. Never rewrite project CSS. */
136
194
  export function createAtomicCompositionReview(program, options) {
137
- const checker = program.getTypeChecker(), templates = new Map();
138
- function imported(node, names, modules, seen = new Set()) {
195
+ const checker = program.getTypeChecker(),
196
+ templates = new Map();
197
+ async function imported(node, names, modules, seen = new Set()) {
139
198
  node = unwrap(node);
140
199
  if (!node || seen.has(node)) return false;
141
200
  seen = new Set([...seen, node]);
142
201
  const base = ts.isPropertyAccessExpression(node) ? node.expression : node;
143
- const symbol = sourceSymbol(checker, base);
202
+ const symbol = await sourceSymbol(checker, base);
144
203
  for (const item of symbol?.declarations ?? []) {
145
- if (ts.isImportSpecifier(item) && names.includes((item.propertyName ?? item.name).text) && modules.includes(item.parent.parent.parent.moduleSpecifier.text)) return true;
146
- if (ts.isNamespaceImport(item) && ts.isPropertyAccessExpression(node) && names.includes(node.name.text) && modules.includes(item.parent.parent.moduleSpecifier.text)) return true;
147
- if (ts.isVariableDeclaration(item) && imported(item.initializer, names, modules, seen)) return true;
204
+ if (
205
+ ts.isImportSpecifier(item) &&
206
+ names.includes((item.propertyName ?? item.name).text) &&
207
+ modules.includes(item.parent.parent.parent.moduleSpecifier.text)
208
+ )
209
+ return true;
210
+ if (
211
+ ts.isNamespaceImport(item) &&
212
+ ts.isPropertyAccessExpression(node) &&
213
+ names.includes(node.name.text) &&
214
+ modules.includes(item.parent.parent.moduleSpecifier.text)
215
+ )
216
+ return true;
217
+ if (ts.isVariableDeclaration(item) && (await imported(item.initializer, names, modules, seen))) return true;
148
218
  }
149
219
  return false;
150
220
  }
151
- const isCx = node => imported(node, ["cx"], ["@linaria/atomic", "@linaria/core"]);
152
- function isAtomic(tag) {
221
+ const isCx = async (node) => imported(node, ["cx"], ["@linaria/atomic", "@linaria/core"]);
222
+ async function isAtomic(tag) {
153
223
  if (ts.isCallExpression(tag)) tag = tag.expression;
154
- if (imported(tag, ["css", "styled"], ["@linaria/atomic"])) return true;
155
- return ts.isPropertyAccessExpression(tag) && imported(tag.expression, ["styled"], ["@linaria/atomic"]);
224
+ if (await imported(tag, ["css", "styled"], ["@linaria/atomic"])) return true;
225
+ return ts.isPropertyAccessExpression(tag) && (await imported(tag.expression, ["styled"], ["@linaria/atomic"]));
156
226
  }
157
227
  function entries(node) {
158
228
  if (templates.has(node)) return templates.get(node);
159
229
  const result = [];
160
230
  templates.set(node, result);
161
- const source = node.getSourceFile(), template = node.template;
162
- const text = ts.isNoSubstitutionTemplateLiteral(template) ? template.text : template.head.text + template.templateSpans.map(span => `__ads_expression__${"\n".repeat(span.expression.getText(source).split("\n").length - 1)}${span.literal.text}`).join("");
231
+ const source = node.getSourceFile(),
232
+ template = node.template;
233
+ const text = ts.isNoSubstitutionTemplateLiteral(template)
234
+ ? template.text
235
+ : template.head.text +
236
+ template.templateSpans
237
+ .map((span) => `__ads_expression__${"\n".repeat(span.expression.getText(source).split("\n").length - 1)}${span.literal.text}`)
238
+ .join("");
163
239
  const position = source.getLineAndCharacterOfPosition(template.getStart(source) + 1);
164
240
  try {
165
- postcss.parse(text).walkDecls(decl => {
166
- const selectors = [], conditions = [];
241
+ postcss.parse(text).walkDecls((decl) => {
242
+ const selectors = [],
243
+ conditions = [];
167
244
  for (let parent = decl.parent; parent?.type !== "root"; parent = parent?.parent) {
168
245
  if (!parent) break;
169
246
  if (parent.type === "rule") selectors.unshift(parent.selector.trim().replace(/\s+/g, " "));
170
247
  if (parent.type === "atrule") conditions.unshift(`${parent.name} ${parent.params}`.trim().replace(/\s+/g, " "));
171
248
  }
172
249
  // Animation frames describe different instants, not combined classes.
173
- if (conditions.some(condition => /^(?:(?:-\w+-)?keyframes|property)\b/.test(condition))) return;
174
- result.push({ property: decl.prop.toLowerCase(), value: decl.value, important: !!decl.important, selectors: JSON.stringify(selectors), conditions: JSON.stringify(conditions),
175
- file: path.relative(options.root, source.fileName).replaceAll("\\", "/"), line: position.line + decl.source.start.line, column: decl.source.start.column + (decl.source.start.line === 1 ? position.character : 0) });
250
+ if (conditions.some((condition) => /^(?:(?:-\w+-)?keyframes|property)\b/.test(condition))) return;
251
+ result.push({
252
+ property: decl.prop.toLowerCase(),
253
+ value: decl.value,
254
+ important: !!decl.important,
255
+ selectors: JSON.stringify(selectors),
256
+ conditions: JSON.stringify(conditions),
257
+ file: path.relative(options.root, source.fileName).replaceAll("\\", "/"),
258
+ line: position.line + decl.source.start.line,
259
+ column: decl.source.start.column + (decl.source.start.line === 1 ? position.character : 0),
260
+ });
176
261
  });
177
- } catch { /* The core CSS syntax diagnostic owns malformed templates. */ }
262
+ } catch {
263
+ /* The core CSS syntax diagnostic owns malformed templates. */
264
+ }
178
265
  return result;
179
266
  }
180
267
  const trace = createAtomicTrace(program, options, { entries, isAtomic, isCx });
181
- return source => {
182
- const warnings = new Map(), limits = new Map();
183
- const relative = entry => ({ ...entry, file: path.relative(options.root, entry.file).replaceAll("\\", "/") });
268
+ return async (source) => {
269
+ const warnings = new Map(),
270
+ limits = new Map();
271
+ const relative = (entry) => ({ ...entry, file: path.relative(options.root, entry.file).replaceAll("\\", "/") });
184
272
  function compare(first, second, location, context = {}) {
185
- for (const a of first) for (const b of second) {
186
- if (a === b || a.selectors !== b.selectors || a.conditions !== b.conditions || a.important !== b.important || !overlaps(a.property, b.property) || equivalent(a, b)) continue;
187
- const key = JSON.stringify([a, b].map(entry => [entry.file, entry.line, entry.column]).sort());
188
- const composition = [...new Map([...(context.path ?? []), ...(a.via ?? []), ...(b.via ?? [])].map(entry => [JSON.stringify(entry), relative(entry)])).values()].slice(0, 16);
189
- const previous = warnings.get(key);
190
- if (previous && (previous.target || !context.target) && previous.composition.length >= composition.length) continue;
191
- const position = source.getLineAndCharacterOfPosition(location.getStart(source));
192
- const dependent = writingModeDependent(a.property, b.property) || valueModeDependent(a, b);
193
- warnings.set(key, { rule: "atomic-composition-review", severity: findingSeverity("atomic-composition-review"), line: position.line + 1, column: position.character + 1,
194
- message: `Atomic declarations ${a.property}: ${previewValue(a.value)} and ${b.property}: ${previewValue(b.value)} may overlap without matching cx merge keys.${context.target ? ` Source tracing reaches the same <${context.target.name}> className.` : " This is a source composition risk, not a confirmed rendered conflict."}${dependent ? " The overlap depends on writing mode or direction." : ""} Their winner can depend on extraction order, specificity or writing mode. Use consistent property names/granularity across the base and variants, compose with Linaria cx, and verify computed styles in the built preview. Review all affected variants; valid tokens do not establish cascade correctness. See ${atomicStyleGuide}.`,
195
- guidanceUri: atomicStyleGuide, writingModeDependent: dependent, composition, ...(context.target ? { target: relative(context.target) } : {}), ...(context.limits?.length ? { analysisLimits: [...new Set(context.limits)].slice(0, 5) } : {}),
196
- related: [a, b].map(({ selectors: _selectors, conditions: _conditions, important: _important, via: _via, ...entry }) => ({...entry,value:previewValue(entry.value)})) });
197
- }
273
+ for (const a of first)
274
+ for (const b of second) {
275
+ if (
276
+ a === b ||
277
+ a.selectors !== b.selectors ||
278
+ a.conditions !== b.conditions ||
279
+ a.important !== b.important ||
280
+ !overlaps(a.property, b.property) ||
281
+ equivalent(a, b)
282
+ )
283
+ continue;
284
+ const key = JSON.stringify([a, b].map((entry) => [entry.file, entry.line, entry.column]).sort());
285
+ const composition = [
286
+ ...new Map([...(context.path ?? []), ...(a.via ?? []), ...(b.via ?? [])].map((entry) => [JSON.stringify(entry), relative(entry)])).values(),
287
+ ].slice(0, 16);
288
+ const previous = warnings.get(key);
289
+ if (previous && (previous.target || !context.target) && previous.composition.length >= composition.length) continue;
290
+ const position = source.getLineAndCharacterOfPosition(location.getStart(source));
291
+ const dependent = writingModeDependent(a.property, b.property) || valueModeDependent(a, b);
292
+ warnings.set(key, {
293
+ rule: "atomic-composition-review",
294
+ severity: findingSeverity("atomic-composition-review"),
295
+ line: position.line + 1,
296
+ column: position.character + 1,
297
+ message: `Atomic declarations ${a.property}: ${previewValue(a.value)} and ${b.property}: ${previewValue(b.value)} may overlap without matching cx merge keys.${context.target ? ` Source tracing reaches the same <${context.target.name}> className.` : " This is a source composition risk, not a confirmed rendered conflict."}${dependent ? " The overlap depends on writing mode or direction." : ""} Their winner can depend on extraction order, specificity or writing mode. Use consistent property names/granularity across the base and variants, compose with Linaria cx, and verify computed styles in the built preview. Review all affected variants; valid tokens do not establish cascade correctness. See ${atomicStyleGuide}.`,
298
+ guidanceUri: atomicStyleGuide,
299
+ writingModeDependent: dependent,
300
+ composition,
301
+ ...(context.target ? { target: relative(context.target) } : {}),
302
+ ...(context.limits?.length ? { analysisLimits: [...new Set(context.limits)].slice(0, 5) } : {}),
303
+ related: [a, b].map(({ selectors: _selectors, conditions: _conditions, important: _important, via: _via, ...entry }) => ({
304
+ ...entry,
305
+ value: previewValue(entry.value),
306
+ })),
307
+ });
308
+ }
198
309
  }
199
310
  function limit(node, reasons, composition) {
200
311
  const key = reasons.join("\n");
201
312
  if (limits.has(key) || limits.size >= 5) return;
202
313
  const position = source.getLineAndCharacterOfPosition(node.getStart(source));
203
- limits.set(key, { rule: "atomic-composition-limit", severity: findingSeverity("atomic-composition-limit"), line: position.line + 1, column: position.character + 1,
204
- message: `Atomic source review is incomplete: ${[...new Set(reasons)].slice(0, 3).join(" ")} Review the actual DOM classes and computed styles in a built scenario. An unresolved path is not evidence that composition is safe. See ${atomicStyleGuide}.`, guidanceUri: atomicStyleGuide, composition: composition.slice(0, 16).map(relative) });
314
+ limits.set(key, {
315
+ rule: "atomic-composition-limit",
316
+ severity: findingSeverity("atomic-composition-limit"),
317
+ line: position.line + 1,
318
+ column: position.character + 1,
319
+ message: `Atomic source review is incomplete: ${[...new Set(reasons)].slice(0, 3).join(" ")} Review the actual DOM classes and computed styles in a built scenario. An unresolved path is not evidence that composition is safe. See ${atomicStyleGuide}.`,
320
+ guidanceUri: atomicStyleGuide,
321
+ composition: composition.slice(0, 16).map(relative),
322
+ });
205
323
  }
206
- function visit(node) {
207
- if (ts.isTaggedTemplateExpression(node) && isAtomic(node.tag)) {
324
+ async function visit(node) {
325
+ if (ts.isTaggedTemplateExpression(node) && (await isAtomic(node.tag))) {
208
326
  const declarations = entries(node);
209
327
  for (let index = 0; index < declarations.length; index++) compare([declarations[index]], declarations.slice(index + 1), node);
210
328
  }
211
- ts.forEachChild(node, visit);
329
+ await eachChild(node, visit);
330
+ }
331
+ if (isInside(options.dsRoot, source.fileName)) {
332
+ await visit(source);
333
+ await trace(source, { compare, limit });
212
334
  }
213
- if (isInside(options.dsRoot, source.fileName)) { visit(source); trace(source, { compare, limit }); }
214
335
  return [...warnings.values(), ...limits.values()];
215
336
  };
216
337
  }
@@ -1,39 +1,65 @@
1
- import ts from "typescript";
1
+ import { eachChild, flatMapAsync, mapAsync, someAsync } from "./analysis/queries.mjs";
2
+ import ts from "./analysis/syntax.mjs";
2
3
  import { createSourceValues, reference, literal, unknown, isFunction } from "./source-values.mjs";
3
4
 
4
5
  /** Bounded symbolic composition review, sharing source evaluation with scenarios. */
5
6
  export function createAtomicTrace(program, options, { entries, isAtomic, isCx }) {
6
7
  const { state, next, at, resolve, get, arrays, returns } = createSourceValues(program, options, { preserveCall: isCx });
7
- return function review(source, { compare, limit }) {
8
+ return async function review(source, { compare, limit }) {
8
9
  const maxBranches = 32;
9
- const unique = branches => [...new Map(branches.map(branch => [JSON.stringify(branch.map(entry => [entry.file, entry.line, entry.column])), branch])).values()];
10
- function styles(input, context) {
11
- const value = resolve(input, next(context));
10
+ const unique = (branches) => [
11
+ ...new Map(branches.map((branch) => [JSON.stringify(branch.map((entry) => [entry.file, entry.line, entry.column])), branch])).values(),
12
+ ];
13
+ async function styles(input, context) {
14
+ const value = await resolve(input, next(context));
12
15
  context = value.context ?? input.context ?? context;
13
16
  if (value.kind === "unknown") return { branches: [[]], limits: value.reason ? [value.reason] : [] };
14
17
  if (value.kind === "union") {
15
- const results = value.values.slice(0, maxBranches).map(item => styles(item, next(context)));
16
- const branches = unique(results.flatMap(item => item.branches));
17
- return { branches: branches.slice(0, maxBranches), limits: [...results.flatMap(item => item.limits), ...(value.values.length > maxBranches || branches.length > maxBranches ? ["Atomic source tracing reached its alternative limit."] : [])] };
18
+ const results = await mapAsync(value.values.slice(0, maxBranches), async (item) => styles(item, next(context)));
19
+ const branches = unique(results.flatMap((item) => item.branches));
20
+ return {
21
+ branches: branches.slice(0, maxBranches),
22
+ limits: [
23
+ ...results.flatMap((item) => item.limits),
24
+ ...(value.values.length > maxBranches || branches.length > maxBranches ? ["Atomic source tracing reached its alternative limit."] : []),
25
+ ],
26
+ };
18
27
  }
19
28
  if (value.kind !== "node") return { branches: [[]], limits: [] };
20
29
  const { node, env, via } = value;
21
- if (ts.isTaggedTemplateExpression(node) && isAtomic(node.tag)) return { branches: [entries(node).map(entry => ({ ...entry, via }))], limits: [] };
22
- if (ts.isCallExpression(node) && isCx(node.expression)) {
23
- const inputs = node.arguments.flatMap(argument => ts.isSpreadElement(argument) ? arrays(reference(argument.expression, env, via), context) ?? [unknown("A dynamic class argument spread could not be traced.")] : [reference(argument, env, via)]);
24
- let branches = [[]]; const limits = [];
30
+ if (ts.isTaggedTemplateExpression(node) && (await isAtomic(node.tag)))
31
+ return { branches: [entries(node).map((entry) => ({ ...entry, via }))], limits: [] };
32
+ if (ts.isCallExpression(node) && (await isCx(node.expression))) {
33
+ const inputs = await flatMapAsync(node.arguments, async (argument) =>
34
+ ts.isSpreadElement(argument)
35
+ ? ((await arrays(reference(argument.expression, env, via), context)) ?? [unknown("A dynamic class argument spread could not be traced.")])
36
+ : [reference(argument, env, via)],
37
+ );
38
+ let branches = [[]];
39
+ const limits = [];
25
40
  for (const argument of inputs) {
26
- const result = styles(argument, next(context));
41
+ const result = await styles(argument, next(context));
27
42
  limits.push(...result.limits);
28
- const combined = new Map(); let truncated = false;
29
- for (const first of branches) for (const second of result.branches) {
30
- // cx replaces exact property/selector/condition keys; shorthand
31
- // expansion remains the CSS overlap review's responsibility.
32
- const merged = new Map([...first, ...second.map(entry => ({ ...entry, via: [...via, ...(entry.via ?? [])] }))].map(entry => [JSON.stringify([entry.property, entry.selectors, entry.conditions]), entry]));
33
- const branch = [...merged.values()], key = JSON.stringify(branch.map(entry => [entry.file, entry.line, entry.column]));
34
- if (!combined.has(key) && combined.size >= maxBranches) { truncated = true; continue; }
35
- combined.set(key, branch);
36
- }
43
+ const combined = new Map();
44
+ let truncated = false;
45
+ for (const first of branches)
46
+ for (const second of result.branches) {
47
+ // cx replaces exact property/selector/condition keys; shorthand
48
+ // expansion remains the CSS overlap review's responsibility.
49
+ const merged = new Map(
50
+ [...first, ...second.map((entry) => ({ ...entry, via: [...via, ...(entry.via ?? [])] }))].map((entry) => [
51
+ JSON.stringify([entry.property, entry.selectors, entry.conditions]),
52
+ entry,
53
+ ]),
54
+ );
55
+ const branch = [...merged.values()],
56
+ key = JSON.stringify(branch.map((entry) => [entry.file, entry.line, entry.column]));
57
+ if (!combined.has(key) && combined.size >= maxBranches) {
58
+ truncated = true;
59
+ continue;
60
+ }
61
+ combined.set(key, branch);
62
+ }
37
63
  if (truncated) limits.push("Atomic source tracing reached its alternative limit.");
38
64
  branches = [...combined.values()];
39
65
  }
@@ -41,52 +67,96 @@ export function createAtomicTrace(program, options, { entries, isAtomic, isCx })
41
67
  }
42
68
  return { branches: [[]], limits: [] };
43
69
  }
44
- function inspect(value, node, context, target, path = []) {
45
- const result = styles(value, context);
46
- for (const branch of result.branches) for (let index = 0; index < branch.length; index++) compare([branch[index]], branch.slice(index + 1), node, { target, path, limits: result.limits });
47
- if (result.limits.length && (result.branches.some(branch => branch.length) || ts.isCallExpression(node) && node.arguments.some(argument => styles(reference(argument), next(context)).branches.some(branch => branch.length)))) limit(node, result.limits, path);
70
+ async function inspect(value, node, context, target, path = []) {
71
+ const result = await styles(value, context);
72
+ for (const branch of result.branches)
73
+ for (let index = 0; index < branch.length; index++) compare([branch[index]], branch.slice(index + 1), node, { target, path, limits: result.limits });
74
+ if (
75
+ result.limits.length &&
76
+ (result.branches.some((branch) => branch.length) ||
77
+ (ts.isCallExpression(node) &&
78
+ (await someAsync(node.arguments, async (argument) => (await styles(reference(argument), next(context))).branches.some((branch) => branch.length)))))
79
+ )
80
+ limit(node, result.limits, path);
48
81
  return result;
49
82
  }
50
83
  function props(node, env, via) {
51
- return { kind: "object", layers: node.attributes.properties.map(attribute => ts.isJsxSpreadAttribute(attribute) ? reference(attribute.expression, env, via) : new Map([[attribute.name.text, attribute.initializer ? ts.isJsxExpression(attribute.initializer) ? reference(attribute.initializer.expression, env, via) : reference(attribute.initializer, env, via) : literal(true)]])) };
84
+ return {
85
+ kind: "object",
86
+ layers: node.attributes.properties.map((attribute) =>
87
+ ts.isJsxSpreadAttribute(attribute)
88
+ ? reference(attribute.expression, env, via)
89
+ : new Map([
90
+ [
91
+ attribute.name.text,
92
+ attribute.initializer
93
+ ? ts.isJsxExpression(attribute.initializer)
94
+ ? reference(attribute.initializer.expression, env, via)
95
+ : reference(attribute.initializer, env, via)
96
+ : literal(true),
97
+ ],
98
+ ]),
99
+ ),
100
+ };
52
101
  }
53
- function render(input, location, context, path = [], pendingStyles = false) {
54
- const value = resolve(input, next(context));
102
+ async function render(input, location, context, path = [], pendingStyles = false) {
103
+ const value = await resolve(input, next(context));
55
104
  context = value.context ?? input.context ?? context;
56
- if (value.kind === "union") { for (const item of value.values.slice(0, maxBranches)) render(item, location, next(context), path, pendingStyles); return; }
57
- if (value.kind !== "node") { if (value.reason && pendingStyles) limit(location, [value.reason], path); return; }
105
+ if (value.kind === "union") {
106
+ for (const item of value.values.slice(0, maxBranches)) await render(item, location, next(context), path, pendingStyles);
107
+ return;
108
+ }
109
+ if (value.kind !== "node") {
110
+ if (value.reason && pendingStyles) limit(location, [value.reason], path);
111
+ return;
112
+ }
58
113
  const { node, env, via } = value;
59
- if (ts.isJsxExpression(node)) { render(reference(node.expression, env, via), location, next(context), path, pendingStyles); return; }
60
- if (ts.isJsxFragment(node)) { for (const child of node.children) render(reference(child, env, via), location, next(context), path); return; }
61
- if (ts.isArrayLiteralExpression(node)) { for (const child of node.elements) render(reference(child, env, via), location, next(context), path); return; }
114
+ if (ts.isJsxExpression(node)) {
115
+ await render(reference(node.expression, env, via), location, next(context), path, pendingStyles);
116
+ return;
117
+ }
118
+ if (ts.isJsxFragment(node)) {
119
+ for (const child of node.children) await render(reference(child, env, via), location, next(context), path);
120
+ return;
121
+ }
122
+ if (ts.isArrayLiteralExpression(node)) {
123
+ for (const child of node.elements) await render(reference(child, env, via), location, next(context), path);
124
+ return;
125
+ }
62
126
  if (!ts.isJsxElement(node) && !ts.isJsxSelfClosingElement(node)) return;
63
127
  const opening = ts.isJsxElement(node) ? node.openingElement : node;
64
- const attributes = props(opening, env, via), classValue = get(attributes, "className", next(context));
128
+ const attributes = props(opening, env, via),
129
+ classValue = await get(attributes, "className", next(context));
65
130
  const tag = opening.tagName.getText();
66
131
  if (/^[a-z]/.test(tag) && !tag.includes(".")) {
67
- inspect(classValue, location, context, at(opening, "element", tag), [...path, ...via]);
68
- if (ts.isJsxElement(node)) for (const child of node.children) render(reference(child, env, via), location, next(context), path);
132
+ await inspect(classValue, location, context, at(opening, "element", tag), [...path, ...via]);
133
+ if (ts.isJsxElement(node)) for (const child of node.children) await render(reference(child, env, via), location, next(context), path);
69
134
  return;
70
135
  }
71
- function componentTarget(component) {
72
- if (component.kind === "union") { for (const alternative of component.values.slice(0, maxBranches)) componentTarget(resolve(alternative, next(context))); return; }
136
+ async function componentTarget(component) {
137
+ if (component.kind === "union") {
138
+ for (const alternative of component.values.slice(0, maxBranches)) await componentTarget(await resolve(alternative, next(context)));
139
+ return;
140
+ }
73
141
  if (component.kind === "literal" && typeof component.value === "string") {
74
- inspect(classValue, location, context, at(opening, "element", component.value), [...path, ...via]);
142
+ await inspect(classValue, location, context, at(opening, "element", component.value), [...path, ...via]);
75
143
  } else if (component.kind === "node" && isFunction(component.node)) {
76
- const passed = pendingStyles || styles(classValue, context).branches.some(branch => branch.length);
77
- for (const output of returns(component, [attributes], next(context), "component")) render(output, location, output.context ?? next(context), [...path, at(opening, "component", tag)], passed);
144
+ const passed = pendingStyles || (await styles(classValue, context)).branches.some((branch) => branch.length);
145
+ for (const output of await returns(component, [attributes], next(context), "component"))
146
+ await render(output, location, output.context ?? next(context), [...path, at(opening, "component", tag)], passed);
78
147
  } else {
79
- const passed = styles(classValue, context);
80
- if (passed.branches.some(branch => branch.length)) limit(location, [`Component ${tag.slice(0, 80)} could not be traced to its DOM className target.`, ...passed.limits], path);
148
+ const passed = await styles(classValue, context);
149
+ if (passed.branches.some((branch) => branch.length))
150
+ limit(location, [`Component ${tag.slice(0, 80)} could not be traced to its DOM className target.`, ...passed.limits], path);
81
151
  }
82
152
  }
83
- componentTarget(resolve(reference(opening.tagName, env, via), next(context)));
153
+ await componentTarget(await resolve(reference(opening.tagName, env, via), next(context)));
84
154
  }
85
- function visit(node) {
86
- if (ts.isCallExpression(node)) inspect(reference(node), node, state());
87
- if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) render(reference(node), node, state());
88
- ts.forEachChild(node, visit);
155
+ async function visit(node) {
156
+ if (ts.isCallExpression(node)) await inspect(reference(node), node, state());
157
+ if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) await render(reference(node), node, state());
158
+ await eachChild(node, visit);
89
159
  }
90
- visit(source);
160
+ await visit(source);
91
161
  };
92
162
  }