@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,6 +1,9 @@
1
+ import { withProjectAnalysis } from "./analysis/standalone.mjs";
2
+ import { currentAnalysis } from "./analysis/context.mjs";
3
+ import { eachChild, filterAsync, mapAsync } from "./analysis/queries.mjs";
1
4
  import path from "node:path";
2
5
  import { existsSync } from "node:fs";
3
- import ts from "typescript";
6
+ import ts from "./analysis/syntax.mjs";
4
7
  import { publicApi, scenarioApi } from "./public-api.mjs";
5
8
  import { uiOperation } from "./ui-framework.mjs";
6
9
  import { isDevelopmentFile, isInside, isScenarioFile, scenarioIdentity, sourceFiles } from "./config.mjs";
@@ -15,211 +18,423 @@ import { inspectRuntimeContracts } from "./runtime-contracts.mjs";
15
18
  import { inspectUnitContracts } from "./unit-contracts.mjs";
16
19
  import { inspectPaintContracts } from "./paint-contracts.mjs";
17
20
  import { createScenarioGroups } from "./scenario-groups.mjs";
21
+ import { foundationViews } from "./foundation-views.mjs";
18
22
 
19
23
  export const scenarioArtifact = (root, id) => path.join(root, ".ds/scenarios", id, "index.html");
20
24
 
21
- function literal(node, checker, seen = new Set()) {
25
+ async function literal(node, checker, seen = new Set()) {
22
26
  while (node && (ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isParenthesizedExpression(node))) node = node.expression;
23
27
  if (!node || seen.has(node)) return undefined;
24
28
  seen = new Set([...seen, node]);
25
29
  if (node && ts.isStringLiteralLike(node)) return node.text;
26
30
  if (node?.kind === ts.SyntaxKind.TrueKeyword) return true;
27
31
  if (node?.kind === ts.SyntaxKind.FalseKeyword) return false;
28
- if (node && ts.isArrayLiteralExpression(node)) return node.elements.map(item => literal(item, checker, seen));
29
- if (node && ts.isObjectLiteralExpression(node)) return Object.fromEntries(node.properties.map((item) => ts.isPropertyAssignment(item) && item.name && (ts.isIdentifier(item.name) || ts.isStringLiteralLike(item.name)) ? [item.name.text, literal(item.initializer, checker, seen)] : ["invalid", undefined]));
32
+ if (node && ts.isArrayLiteralExpression(node)) return mapAsync(node.elements, async (item) => literal(item, checker, seen));
33
+ if (node && ts.isObjectLiteralExpression(node))
34
+ return Object.fromEntries(
35
+ await mapAsync(node.properties, async (item) =>
36
+ ts.isPropertyAssignment(item) && item.name && (ts.isIdentifier(item.name) || ts.isStringLiteralLike(item.name))
37
+ ? [item.name.text, await literal(item.initializer, checker, seen)]
38
+ : ["invalid", undefined],
39
+ ),
40
+ );
30
41
  if (checker && (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node))) {
31
- let symbol = checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
32
- if (symbol?.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol);
42
+ let symbol = await checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
43
+ if (symbol?.flags & ts.SymbolFlags.Alias) symbol = await checker.getAliasedSymbol(symbol);
33
44
  const declaration = symbol?.valueDeclaration;
34
- if (declaration && (ts.isPropertyAssignment(declaration) || ts.isVariableDeclaration(declaration) && declaration.parent.flags & ts.NodeFlags.Const)) return literal(declaration.initializer, checker, seen);
45
+ if (declaration && (ts.isPropertyAssignment(declaration) || (ts.isVariableDeclaration(declaration) && declaration.parent.flags & ts.NodeFlags.Const)))
46
+ return literal(declaration.initializer, checker, seen);
35
47
  }
36
48
  return undefined;
37
49
  }
38
50
 
39
- export function publicUi(program, options) {
40
- return publicApi(program, options).filter(item => item.kind !== "controllers");
51
+ export async function publicUi(program, options) {
52
+ return (await publicApi(program, options)).filter((item) => item.kind !== "controllers");
41
53
  }
42
54
 
43
55
  /** Discover metadata statically. The MCP process never imports scenario modules. */
44
- export function inspectScenarios(options, suppliedProgram) {
56
+ export async function inspectScenarios(options, suppliedProgram) {
57
+ if (!currentAnalysis()?.provideProgram) return withProjectAnalysis(options.root, async () => inspectScenarios(options, suppliedProgram));
45
58
  const { root, dsRoot } = options;
46
59
  const files = sourceFiles(dsRoot).filter(isScenarioFile);
47
- const contracts = inspectUnitContracts(options, suppliedProgram);
48
- const program = suppliedProgram ?? contracts.program ?? cachedProgram(`scenarios:${options.root}`, [path.join(dsRoot, options.config.publicEntry), path.join(dsRoot, options.config.reviewEntry), ...files], { ...projectCompilerOptions(options), allowJs: true });
49
- const apis = scenarioApi(program, options);
60
+ const contracts = await inspectUnitContracts(options, suppliedProgram);
61
+ const program =
62
+ suppliedProgram ??
63
+ contracts.program ??
64
+ (await cachedProgram(
65
+ `scenarios:${options.root}`,
66
+ [path.join(dsRoot, options.config.publicEntry), path.join(dsRoot, options.config.reviewEntry), ...files],
67
+ { ...(await projectCompilerOptions(options)), allowJs: true },
68
+ ));
69
+ const apis = await scenarioApi(program, options);
50
70
  const duplicate = apis.find((item, index) => apis.some((other, otherIndex) => index !== otherIndex && item.name === other.name));
51
- const known = new Map(apis.filter(item => item.kind !== "controllers").map((item) => [item.name, item]));
71
+ const known = new Map(apis.filter((item) => item.kind !== "controllers").map((item) => [item.name, item]));
52
72
  const checker = program.getTypeChecker();
53
- const declarativeParts = inspectRuntimeContracts(options, program).parts;
54
- const contractDeclarations=inspectUnitContracts(options).contracts;
55
- const bindingTrace = contractDeclarations.some(contract=>contract.paintInputs?.length) ? createScenarioTrace(program, options) : null;
56
- const behaviorApis = new Map(publicApi(program, options).filter(item => !item.renderable && item.behavioral).map(item => [item.name, item]));
57
- const tokenInventory = inspectTokens(root, options);
58
- const tokenNames = new Set(tokenInventory.tokens.map(token => token.name));
59
- const units = inspectUnits(options);
73
+ const declarativeParts = (await inspectRuntimeContracts(options, program)).parts;
74
+ const contractDeclarations = (await inspectUnitContracts(options)).contracts;
75
+ const bindingTrace = contractDeclarations.some((contract) => contract.paintInputs?.length) ? await createScenarioTrace(program, options) : null;
76
+ const behaviorApis = new Map((await publicApi(program, options)).filter((item) => !item.renderable && item.behavioral).map((item) => [item.name, item]));
77
+ const tokenInventory = await inspectTokens(root, options);
78
+ const tokenNames = new Set(tokenInventory.tokens.map((token) => token.name));
79
+ const units = await inspectUnits(options);
60
80
  const scenarioGroup = createScenarioGroups(options);
61
81
  const scenarios = [];
62
- const diagnostics = [...inspectUnitContracts(options).diagnostics,...inspectRuntimeContracts(options,program).diagnostics,...inspectPaintContracts(options).diagnostics];
82
+ const diagnostics = [
83
+ ...(await inspectUnitContracts(options)).diagnostics,
84
+ ...(await inspectRuntimeContracts(options, program)).diagnostics,
85
+ ...(await inspectPaintContracts(options)).diagnostics,
86
+ ];
63
87
  const ids = new Set();
64
88
  function report(file, message, node, detail = {}) {
65
89
  const position = node?.getSourceFile().getLineAndCharacterOfPosition(node.getStart());
66
- diagnostics.push({ file: path.relative(root, file).replaceAll("\\", "/"), rule: "scenario-contract", line: (position?.line ?? 0) + 1, column: (position?.character ?? 0) + 1, message, ...detail });
90
+ diagnostics.push({
91
+ file: path.relative(root, file).replaceAll("\\", "/"),
92
+ rule: "scenario-contract",
93
+ line: (position?.line ?? 0) + 1,
94
+ column: (position?.character ?? 0) + 1,
95
+ message,
96
+ ...detail,
97
+ });
67
98
  }
68
- if (duplicate) report(path.join(dsRoot, options.config.reviewEntry), `Review export ${duplicate.name} collides with the production API. Use a distinct development export so scenario coverage is unambiguous.`);
99
+ if (duplicate)
100
+ report(
101
+ path.join(dsRoot, options.config.reviewEntry),
102
+ `Review export ${duplicate.name} collides with the production API. Use a distinct development export so scenario coverage is unambiguous.`,
103
+ );
69
104
  for (const file of files) {
70
105
  const relative = path.relative(dsRoot, file).replaceAll("\\", "/");
71
106
  let kind = isInside(path.join(dsRoot, options.config.tokenDir), file) ? "tokens" : relative.split("/")[0];
72
- if (!["brand", "tokens", "components", "patterns", "composition"].includes(kind)) { report(file, "Scenarios live under brand/, beside tokens/components/patterns or under composition/, not inside showcase pages."); continue; }
107
+ if (!["brand", "tokens", "components", "patterns", "composition"].includes(kind)) {
108
+ report(file, "Scenarios live under brand/, beside tokens/components/patterns or under composition/, not inside showcase pages.");
109
+ continue;
110
+ }
73
111
  let id = scenarioIdentity(file, dsRoot);
74
- const source = program.getSourceFile(file);
75
- if (!source) { report(file, "Cannot inspect scenario source."); continue; }
112
+ const source = await program.getSourceFile(file);
113
+ if (!source) {
114
+ report(file, "Cannot inspect scenario source.");
115
+ continue;
116
+ }
76
117
  let metadata, metadataExpression;
77
118
  let entry = false;
78
119
  for (const node of source.statements) {
79
120
  if (ts.isExportAssignment(node) || node.modifiers?.some((item) => item.kind === ts.SyntaxKind.DefaultKeyword)) entry = true;
80
121
  if (ts.isVariableStatement(node) && node.modifiers?.some((item) => item.kind === ts.SyntaxKind.ExportKeyword)) {
81
- for (const declaration of node.declarationList.declarations) if (ts.isIdentifier(declaration.name) && declaration.name.text === "scenario") { metadataExpression = declaration.initializer; metadata = literal(metadataExpression, checker); }
122
+ for (const declaration of node.declarationList.declarations)
123
+ if (ts.isIdentifier(declaration.name) && declaration.name.text === "scenario") {
124
+ metadataExpression = declaration.initializer;
125
+ metadata = await literal(metadataExpression, checker);
126
+ }
82
127
  }
83
128
  }
84
- if(metadata?.id!==undefined) {
85
- const owner=units.owner(relative);
86
- if(typeof metadata.id!=="string"||metadata.id.length>256||!/^[\w-]+(?:[/.][\w-]+)*$/.test(metadata.id)||!owner||!(metadata.id===owner||metadata.id.startsWith(owner+"/")||metadata.id.startsWith(owner+".")))report(file,"Scenario id must be a safe stable identity inside this owner; it cannot capture another layer/owner.",metadataExpression,{entry:"id"});
87
- else id=metadata.id;
129
+ if (metadata?.id !== undefined) {
130
+ const owner = units.owner(relative);
131
+ if (
132
+ typeof metadata.id !== "string" ||
133
+ metadata.id.length > 256 ||
134
+ !/^[\w-]+(?:[/.][\w-]+)*$/.test(metadata.id) ||
135
+ !owner ||
136
+ !(metadata.id === owner || metadata.id.startsWith(owner + "/") || metadata.id.startsWith(owner + "."))
137
+ )
138
+ report(file, "Scenario id must be a safe stable identity inside this owner; it cannot capture another layer/owner.", metadataExpression, {
139
+ entry: "id",
140
+ });
141
+ else id = metadata.id;
142
+ }
143
+ if (id.length > 256) {
144
+ report(file, "Scenario paths must fit within 256 characters.");
145
+ continue;
146
+ }
147
+ if (ids.has(id)) {
148
+ report(file, `Duplicate scenario id ${id}. Use one entrypoint per identity.`);
149
+ continue;
88
150
  }
89
- if (id.length > 256) { report(file, "Scenario paths must fit within 256 characters."); continue; }
90
- if (ids.has(id)) { report(file, `Duplicate scenario id ${id}. Use one entrypoint per identity.`); continue; }
91
151
  ids.add(id);
92
152
  if (metadata?.kind !== undefined) {
93
153
  const owner = units.owner(relative);
94
- if (metadata.kind !== "tokens" || owner !== "tokens") report(file, "Token previews belong in the shared Data token directory. Components and patterns map shared tokens; they do not own independent token catalogues.",entryNode("kind"),{entry:"kind"});
154
+ if (metadata.kind !== "tokens" || owner !== "tokens")
155
+ report(
156
+ file,
157
+ "Token previews belong in the shared Data token directory. Components and patterns map shared tokens; they do not own independent token catalogues.",
158
+ await entryNode("kind"),
159
+ { entry: "kind" },
160
+ );
95
161
  else kind = "tokens";
96
162
  }
97
163
  if (!entry) report(file, "Export a default independently mountable scenario entrypoint.");
98
- const module = checker.getSymbolAtLocation(source);
99
- const defaultExport = module && checker.getExportsOfModule(module).find(item => item.name === "default");
164
+ const module = await checker.getSymbolAtLocation(source);
165
+ const defaultExport = module && (await checker.getExportsOfModule(module)).find((item) => item.name === "default");
100
166
  if (defaultExport) {
101
- const type = checker.getTypeOfSymbolAtLocation(defaultExport, source);
102
- const calls = [...type.getCallSignatures(), ...type.getConstructSignatures()];
103
- if (!calls.length && !(type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown))) report(file, "Export a mountable component as default, not an already-created element or data object.");
167
+ const type = await checker.getTypeOfSymbolAtLocation(defaultExport, source);
168
+ const calls = [...(await type.getCallSignatures()), ...(await type.getConstructSignatures())];
169
+ if (!calls.length && !(type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)))
170
+ report(file, "Export a mountable component as default, not an already-created element or data object.");
104
171
  for (const call of calls) {
105
172
  const props = call.parameters[0];
106
- const optional = props?.declarations?.some(item => item.initializer || item.questionToken);
107
- if (props && !optional && checker.getTypeOfSymbolAtLocation(props, source).getProperties().some(item => !(item.flags & ts.SymbolFlags.Optional))) report(file, "Scenario entrypoints cannot require caller props. Supply required inputs in the colocated fixture adapter.");
173
+ const optional = props?.declarations?.some((item) => item.initializer || item.questionToken);
174
+ if (
175
+ props &&
176
+ !optional &&
177
+ (await (await checker.getTypeOfSymbolAtLocation(props, source)).getProperties()).some((item) => !(item.flags & ts.SymbolFlags.Optional))
178
+ )
179
+ report(file, "Scenario entrypoints cannot require caller props. Supply required inputs in the colocated fixture adapter.");
108
180
  }
109
181
  }
110
182
  const fixtureBase = file.replace(/\.ads\.scenario\.[^.]+$/, ".ads.fixture");
111
- const fixture = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs", ".json"].map(extension => fixtureBase + extension).find(existsSync);
183
+ const fixture = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs", ".json"].map((extension) => fixtureBase + extension).find(existsSync);
112
184
  if (!fixture) report(file, "Keep this scenario's inputs beside it in <Owner>.ads.fixture.ts. An empty fixture is valid for a component without inputs.");
113
- function entryNode(field, index) {
185
+ async function entryNode(field, index) {
114
186
  let value = metadataExpression;
115
187
  const seen = new Set();
116
188
  while (value && !seen.has(value)) {
117
189
  seen.add(value);
118
190
  if (ts.isSatisfiesExpression(value) || ts.isAsExpression(value) || ts.isParenthesizedExpression(value)) value = value.expression;
119
- else if (ts.isIdentifier(value)) { let symbol = checker.getSymbolAtLocation(value); if (symbol?.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol); value = symbol?.valueDeclaration?.initializer; }
120
- else break;
191
+ else if (ts.isIdentifier(value)) {
192
+ let symbol = await checker.getSymbolAtLocation(value);
193
+ if (symbol?.flags & ts.SymbolFlags.Alias) symbol = await checker.getAliasedSymbol(symbol);
194
+ value = symbol?.valueDeclaration?.initializer;
195
+ } else break;
121
196
  }
122
- const property = value && ts.isObjectLiteralExpression(value) && value.properties.find(item => ts.isPropertyAssignment(item) && (ts.isIdentifier(item.name) || ts.isStringLiteralLike(item.name)) && item.name.text === field);
123
- return index !== undefined && property && ts.isArrayLiteralExpression(property.initializer) ? property.initializer.elements[index] : property?.initializer ?? metadataExpression;
197
+ const property =
198
+ value &&
199
+ ts.isObjectLiteralExpression(value) &&
200
+ value.properties.find(
201
+ (item) => ts.isPropertyAssignment(item) && (ts.isIdentifier(item.name) || ts.isStringLiteralLike(item.name)) && item.name.text === field,
202
+ );
203
+ return index !== undefined && property && ts.isArrayLiteralExpression(property.initializer)
204
+ ? property.initializer.elements[index]
205
+ : (property?.initializer ?? metadataExpression);
124
206
  }
125
207
  if (!metadata) {
126
- report(file, "Scenario metadata is not statically readable. Render coverage is not established until this prerequisite is repaired.", metadataExpression, {coverage:"not-established",owner:units.owner(relative)});
208
+ report(
209
+ file,
210
+ "Scenario metadata is not statically readable. Render coverage is not established until this prerequisite is repaired.",
211
+ metadataExpression,
212
+ { coverage: "not-established", owner: units.owner(relative) },
213
+ );
127
214
  continue;
128
215
  }
129
- for(const field of Object.keys(metadata))if(!["id","title","kind","covers","exercises","tokens","samples","captureTargets"].includes(field))report(file,`Unknown scenario field ${field}.`,entryNode(field),{entry:field});
216
+ for (const field of Object.keys(metadata))
217
+ if (!["id", "title", "kind", "covers", "exercises", "tokens", "samples", "captureTargets"].includes(field))
218
+ report(file, `Unknown scenario field ${field}.`, await entryNode(field), { entry: field });
130
219
  const group = scenarioGroup(file, units.owner(relative));
131
- if(typeof metadata.title!=="string"||!metadata.title.trim()) {
132
- report(file,"Scenario title must be a nonempty static string; independent render evidence is retained.",entryNode("title"),{entry:"title"});
133
- metadata.title=id;
220
+ if (typeof metadata.title !== "string" || !metadata.title.trim()) {
221
+ report(file, "Scenario title must be a nonempty static string; independent render evidence is retained.", await entryNode("title"), { entry: "title" });
222
+ metadata.title = id;
134
223
  }
135
- if(!Array.isArray(metadata.covers)||!metadata.covers.length) {
136
- report(file,"Scenario covers must be a nonempty static array naming rendered public UI. Coverage is not established until repaired.",entryNode("covers"),{entry:"covers",coverage:"not-established",owner:units.owner(relative)});
137
- metadata.covers=[];
224
+ if (!Array.isArray(metadata.covers) || !metadata.covers.length) {
225
+ report(
226
+ file,
227
+ "Scenario covers must be a nonempty static array naming rendered public UI. Coverage is not established until repaired.",
228
+ await entryNode("covers"),
229
+ { entry: "covers", coverage: "not-established", owner: units.owner(relative) },
230
+ );
231
+ metadata.covers = [];
138
232
  }
139
- if(Object.hasOwn(metadata,"tokens")&&(!Array.isArray(metadata.tokens)||metadata.tokens.some(name=>typeof name!=="string"||!name.startsWith("--")))) {
140
- report(file,"Scenario tokens must be a static list of real token names.",entryNode("tokens"),{entry:"tokens"});metadata.tokens=[];
233
+ if (
234
+ Object.hasOwn(metadata, "tokens") &&
235
+ (!Array.isArray(metadata.tokens) || metadata.tokens.some((name) => typeof name !== "string" || !name.startsWith("--")))
236
+ ) {
237
+ report(file, "Scenario tokens must be a static list of real token names.", await entryNode("tokens"), { entry: "tokens" });
238
+ metadata.tokens = [];
141
239
  }
142
- if(kind==="tokens"&&Object.hasOwn(metadata,"tokens")||kind==="tokens"&&!validTokenSamples(metadata.samples)||Object.hasOwn(metadata,"samples")&&!validTokenSamples(metadata.samples)) {
143
- report(file,"Token scenarios need samples: fixture.samples, a literal list of { token, property, probe } real CSS bindings. Printing values or covers: [] is incomplete.",entryNode("samples"),{entry:"samples"});delete metadata.samples;
240
+ if (
241
+ (kind === "tokens" && Object.hasOwn(metadata, "tokens")) ||
242
+ (kind === "tokens" && !validTokenSamples(metadata.samples)) ||
243
+ (Object.hasOwn(metadata, "samples") && !validTokenSamples(metadata.samples))
244
+ ) {
245
+ report(
246
+ file,
247
+ "Token scenarios need samples: fixture.samples, a literal list of { token, property, probe } real CSS bindings. Printing values or covers: [] is incomplete.",
248
+ await entryNode("samples"),
249
+ { entry: "samples" },
250
+ );
251
+ delete metadata.samples;
144
252
  }
145
253
  const covers = [];
146
254
  for (const [index, name] of metadata.covers.entries()) {
147
255
  const api = typeof name === "string" && known.get(name);
148
- if (!api?.renderable || declarativeParts.some(part=>part.apiName===name)) report(file, `Scenario covers[${index}] ${JSON.stringify(name) ?? "(unresolved)"} ${api ? "is not independently rendered UI. Use exercises for a behavioral or registered declarative API." : "does not name a known public UI export."} Independent valid render evidence is retained.`, entryNode("covers", index), { entry: `covers[${index}]`, ...(typeof name === "string" ? { api: name } : {}), reason: api ? "wrong-api-role" : "unknown-api" });
256
+ if (!api?.renderable || declarativeParts.some((part) => part.apiName === name))
257
+ report(
258
+ file,
259
+ `Scenario covers[${index}] ${JSON.stringify(name) ?? "(unresolved)"} ${api ? "is not independently rendered UI. Use exercises for a behavioral or registered declarative API." : "does not name a known public UI export."} Independent valid render evidence is retained.`,
260
+ await entryNode("covers", index),
261
+ { entry: `covers[${index}]`, ...(typeof name === "string" ? { api: name } : {}), reason: api ? "wrong-api-role" : "unknown-api" },
262
+ );
149
263
  else covers.push(name);
150
264
  }
151
265
  metadata = { ...metadata, covers };
152
- if (kind === "tokens" && !covers.some(name => ["patterns", "review"].includes(known.get(name)?.kind))) report(file, "Token covers must name the real development review renderer or product pattern consuming samples.", entryNode("covers"));
266
+ if (kind === "tokens" && !covers.some((name) => ["patterns", "review"].includes(known.get(name)?.kind)))
267
+ report(file, "Token covers must name the real development review renderer or product pattern consuming samples.", await entryNode("covers"));
153
268
  // A bad behavioral entry must fail validation without erasing independent
154
269
  // render evidence and manufacturing missing-coverage errors for real UI.
155
270
  const exercises = [];
156
271
  let captureTargets;
157
272
  if (Object.hasOwn(metadata, "captureTargets")) {
158
- if (!metadata.captureTargets || typeof metadata.captureTargets !== "object" || Array.isArray(metadata.captureTargets) || Object.keys(metadata.captureTargets).length > 20 || Object.entries(metadata.captureTargets).some(([name, selector]) => !/^[a-zA-Z0-9][\w.-]{0,79}$/.test(name) || typeof selector !== "string" || !selector.trim() || selector.length > 500)) report(file, "captureTargets must map up to 20 named targets to nonempty CSS selectors (max 500 characters), scoped to this scenario's App iframe. Each selected target must resolve to exactly one visible element at capture time.");
273
+ if (
274
+ !metadata.captureTargets ||
275
+ typeof metadata.captureTargets !== "object" ||
276
+ Array.isArray(metadata.captureTargets) ||
277
+ Object.keys(metadata.captureTargets).length > 20 ||
278
+ Object.entries(metadata.captureTargets).some(
279
+ ([name, selector]) => !/^[a-zA-Z0-9][\w.-]{0,79}$/.test(name) || typeof selector !== "string" || !selector.trim() || selector.length > 500,
280
+ )
281
+ )
282
+ report(
283
+ file,
284
+ "captureTargets must map up to 20 named targets to nonempty CSS selectors (max 500 characters), scoped to this scenario's App iframe. Each selected target must resolve to exactly one visible element at capture time.",
285
+ );
159
286
  else captureTargets = metadata.captureTargets;
160
287
  }
161
288
  if (Object.hasOwn(metadata, "exercises")) {
162
289
  if (!Array.isArray(metadata.exercises)) report(file, "Scenario exercises must be a static array naming public behavioral APIs.");
163
- else for (const [index, name] of metadata.exercises.entries()) {
164
- if (typeof name !== "string") report(file, `Scenario exercises[${index}] must name a public behavioral API, not ${JSON.stringify(name) ?? "an unresolved value"}.`, entryNode("exercises", index), { entry: `exercises[${index}]` });
165
- else if (!behaviorApis.has(name) && !declarativeParts.some(part=>part.apiName===name)) report(file, `Scenario exercises[${index}] ${JSON.stringify(name)} is not a recognized public behavioral API. Use a public callable function, hook or controller; rendered UI belongs in covers. Discover the project's exports before declaring exercises.`, entryNode("exercises", index), { entry: `exercises[${index}]`, api: name });
166
- else exercises.push(name);
167
- }
290
+ else
291
+ for (const [index, name] of metadata.exercises.entries()) {
292
+ if (typeof name !== "string")
293
+ report(
294
+ file,
295
+ `Scenario exercises[${index}] must name a public behavioral API, not ${JSON.stringify(name) ?? "an unresolved value"}.`,
296
+ await entryNode("exercises", index),
297
+ { entry: `exercises[${index}]` },
298
+ );
299
+ else if (!behaviorApis.has(name) && !declarativeParts.some((part) => part.apiName === name))
300
+ report(
301
+ file,
302
+ `Scenario exercises[${index}] ${JSON.stringify(name)} is not a recognized public behavioral API. Use a public callable function, hook or controller; rendered UI belongs in covers. Discover the project's exports before declaring exercises.`,
303
+ await entryNode("exercises", index),
304
+ { entry: `exercises[${index}]`, api: name },
305
+ );
306
+ else exercises.push(name);
307
+ }
168
308
  }
169
- if (!["composition", "tokens", "brand"].includes(kind) && metadata.covers.some((name) => known.get(name).kind !== kind)) report(file, "Component scenarios cover primitives; pattern scenarios cover patterns. Use composition/ for larger interfaces.");
170
- const tokens = [...new Set([...(metadata.tokens ?? []), ...(metadata.samples ?? []).map(sample => sample.token)])];
171
- for (const name of tokens) if (!tokenNames.has(name)) diagnostics.push({ file: path.relative(root, file).replaceAll("\\", "/"), rule: "token-scenario-reference", line: 1, column: 1, message: `Scenario references undeclared token ${name}. Use a real token from its defining owner.` });
309
+ if (!["composition", "tokens", "brand"].includes(kind) && metadata.covers.some((name) => known.get(name).kind !== kind))
310
+ report(file, "Component scenarios cover primitives; pattern scenarios cover patterns. Use composition/ for larger interfaces.");
311
+ const tokens = [...new Set([...(metadata.tokens ?? []), ...(metadata.samples ?? []).map((sample) => sample.token)])];
312
+ for (const name of tokens)
313
+ if (!tokenNames.has(name))
314
+ diagnostics.push({
315
+ file: path.relative(root, file).replaceAll("\\", "/"),
316
+ rule: "token-scenario-reference",
317
+ line: 1,
318
+ column: 1,
319
+ message: `Scenario references undeclared token ${name}. Use a real token from its defining owner.`,
320
+ });
172
321
  if (kind === "tokens") {
173
322
  const owner = units.owner(relative);
174
- for (const name of tokens) if (tokenInventory.tokens.find(token => token.name === name)?.owner !== owner) report(file, `Token ${name} needs a preview beside its defining owner. All design tokens and their previews belong under the configured shared token directory.`);
323
+ for (const name of tokens)
324
+ if (tokenInventory.tokens.find((token) => token.name === name)?.owner !== owner)
325
+ report(
326
+ file,
327
+ `Token ${name} needs a preview beside its defining owner. All design tokens and their previews belong under the configured shared token directory.`,
328
+ );
175
329
  }
176
330
 
177
331
  const reachable = new Set(metadata.covers);
178
- function findBindings(node) { if(ts.isJsxElement(node)||ts.isJsxSelfClosingElement(node))for(const name of bindingTrace.traceRenders(node).rendered)reachable.add(name);ts.forEachChild(node,findBindings); }
179
- if(bindingTrace) findBindings(source);
180
- const paintBindings = inspectRuntimeContracts(options,program).bindings.filter(binding=>reachable.has(binding.scope.apiName)).map(binding=>({owner:binding.unit,name:binding.name,scope:binding.scope.selector,prefix:binding.prefix,suffix:binding.suffix,themes:options.config.themes.map(theme=>theme.name),tokens:tokenInventory.tokens.filter(token=>!token.owner||token.owner==="tokens"||token.owner===binding.unit).map(token=>token.name)}));
181
- const paintAudit=contractDeclarations.some(contract=>contract.paintInputs?.some(input=>reachable.has(input.apiName)));
182
- scenarios.push({ id, kind, title: metadata.title, ...(group ? { group } : {}), ...(fixture ? { fixture: path.relative(root, fixture).replaceAll("\\", "/") } : {}), covers: [...new Set(metadata.covers)], ...(captureTargets ? { captureTargets } : {}), ...(Object.hasOwn(metadata, "exercises") ? { exercises: [...new Set(exercises)] } : {}), tokens, ...(metadata.samples ? { samples: metadata.samples } : {}), ...(paintBindings.length?{paintBindings}:{}), ...(paintAudit?{paintAudit:true}:{}), file: path.relative(root, file).replaceAll("\\", "/"), artifact: path.relative(root, scenarioArtifact(root, id)).replaceAll("\\", "/") });
332
+ async function findBindings(node) {
333
+ if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) for (const name of (await bindingTrace.traceRenders(node)).rendered) reachable.add(name);
334
+ await eachChild(node, findBindings);
335
+ }
336
+ if (bindingTrace) await findBindings(source);
337
+ const paintBindings = (await inspectRuntimeContracts(options, program)).bindings
338
+ .filter((binding) => reachable.has(binding.scope.apiName))
339
+ .map((binding) => ({
340
+ owner: binding.unit,
341
+ name: binding.name,
342
+ scope: binding.scope.selector,
343
+ prefix: binding.prefix,
344
+ suffix: binding.suffix,
345
+ themes: options.config.themes.map((theme) => theme.name),
346
+ tokens: tokenInventory.tokens.filter((token) => !token.owner || token.owner === "tokens" || token.owner === binding.unit).map((token) => token.name),
347
+ }));
348
+ const paintAudit = contractDeclarations.some((contract) => contract.paintInputs?.some((input) => reachable.has(input.apiName)));
349
+ scenarios.push({
350
+ id,
351
+ kind,
352
+ title: metadata.title,
353
+ ...(group ? { group } : {}),
354
+ ...(fixture ? { fixture: path.relative(root, fixture).replaceAll("\\", "/") } : {}),
355
+ covers: [...new Set(metadata.covers)],
356
+ // The owner folders of the covered component/pattern APIs. Previews mark
357
+ // what these owners render as the subject; everything else is framing.
358
+ subjects: [
359
+ ...new Set(
360
+ metadata.covers
361
+ .map((name) => known.get(name))
362
+ .filter((api) => api?.renderable && ["components", "patterns"].includes(api.kind))
363
+ .map((api) => {
364
+ // A folder owner (Owner/Owner.tsx or Owner/index.tsx) is its folder;
365
+ // a flat owner (components/Box.tsx) is its file without extension.
366
+ const file = path.relative(root, api.file).replaceAll("\\", "/"), folder = path.posix.dirname(file);
367
+ const base = path.posix.basename(file).replace(/\.[^.]+$/, "");
368
+ return base === "index" || base === path.posix.basename(folder) ? folder : file.replace(/\.[^.]+$/, "");
369
+ }),
370
+ ),
371
+ ],
372
+ ...(captureTargets ? { captureTargets } : {}),
373
+ ...(Object.hasOwn(metadata, "exercises") ? { exercises: [...new Set(exercises)] } : {}),
374
+ tokens,
375
+ ...(metadata.samples ? { samples: metadata.samples } : {}),
376
+ ...(paintBindings.length ? { paintBindings } : {}),
377
+ ...(paintAudit ? { paintAudit: true } : {}),
378
+ file: path.relative(root, file).replaceAll("\\", "/"),
379
+ artifact: path.relative(root, scenarioArtifact(root, id)).replaceAll("\\", "/"),
380
+ });
381
+ }
382
+ const foundations = foundationViews(options, tokenInventory);
383
+ diagnostics.push(...foundations.diagnostics);
384
+ for (const view of foundations.views) {
385
+ if (ids.has(view.id))
386
+ report(
387
+ path.join(root, scenarios.find((item) => item.id === view.id).file),
388
+ `Remove the render-only ${view.id} scenario. ADS owns this foundation view from definitions and catalog.ads.json.`,
389
+ );
390
+ else scenarios.push(view);
183
391
  }
184
- return { scenarios: scenarios.sort((a, b) => a.id.localeCompare(b.id)), diagnostics };
392
+ return { scenarios: scenarios.sort((a, b) => (a.sortKey ?? a.id).localeCompare(b.sortKey ?? b.id)), diagnostics };
185
393
  }
186
394
 
187
- export function inspectScenarioCoverage(options, program, report, advise = () => {}, trace = createScenarioTrace(program, options)) {
188
- const registry = inspectScenarios(options, program);
189
- for (const {file,rule,message,line,column,...detail} of registry.diagnostics) report(path.join(options.root, file), rule, message, line, column, detail);
395
+ export async function inspectScenarioCoverage(options, program, report, advise = () => {}, trace) {
396
+ if (trace === undefined) trace = await createScenarioTrace(program, options);
397
+ const registry = await inspectScenarios(options, program);
398
+ for (const { file, rule, message, line, column, ...detail } of registry.diagnostics)
399
+ report(path.join(options.root, file), rule, message, line, column, detail);
190
400
  const checker = program.getTypeChecker();
191
- const ui = publicUi(program, options);
192
- const parts = inspectRuntimeContracts(options, program).parts;
193
- function symbolOf(expression) {
194
- while (expression && (ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isSatisfiesExpression(expression) || ts.isNonNullExpression(expression))) expression = expression.expression;
401
+ const ui = await publicUi(program, options);
402
+ const parts = (await inspectRuntimeContracts(options, program)).parts;
403
+ async function symbolOf(expression) {
404
+ while (
405
+ expression &&
406
+ (ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isSatisfiesExpression(expression) || ts.isNonNullExpression(expression))
407
+ )
408
+ expression = expression.expression;
195
409
  if (!expression) return null;
196
410
  if (ts.isElementAccessExpression(expression) && expression.argumentExpression && ts.isStringLiteralLike(expression.argumentExpression)) {
197
- return checker.getPropertyOfType(checker.getTypeAtLocation(expression.expression), expression.argumentExpression.text);
411
+ return checker.getPropertyOfType(await checker.getTypeAtLocation(expression.expression), expression.argumentExpression.text);
198
412
  }
199
413
  return checker.getSymbolAtLocation(expression);
200
414
  }
201
- function canonical(symbol, seen = new Set()) {
415
+ async function canonical(symbol, seen = new Set()) {
202
416
  if (!symbol || seen.has(symbol)) return null;
203
417
  seen.add(symbol);
204
- if (symbol.flags & ts.SymbolFlags.Alias) return canonical(checker.getAliasedSymbol(symbol), seen);
418
+ if (symbol.flags & ts.SymbolFlags.Alias) return canonical(await checker.getAliasedSymbol(symbol), seen);
205
419
  for (const declaration of symbol.declarations ?? []) {
206
420
  if (ts.isVariableDeclaration(declaration) && declaration.initializer) {
207
- const target = symbolOf(declaration.initializer);
421
+ const target = await symbolOf(declaration.initializer);
208
422
  if (target) return canonical(target, seen);
209
423
  }
210
424
  if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent) && ts.isVariableDeclaration(declaration.parent.parent)) {
211
425
  const initializer = declaration.parent.parent.initializer;
212
426
  const key = declaration.propertyName ?? declaration.name;
213
427
  if (initializer && (ts.isIdentifier(key) || ts.isStringLiteralLike(key))) {
214
- const target = checker.getPropertyOfType(checker.getTypeAtLocation(initializer), key.text);
428
+ const target = await checker.getPropertyOfType(await checker.getTypeAtLocation(initializer), key.text);
215
429
  if (target) return canonical(target, seen);
216
430
  }
217
431
  }
218
432
  }
219
433
  return symbol.declarations?.length ? symbol : null;
220
434
  }
221
- const identities = new Map(), behaviorIdentities = new Set();
222
- for (const item of scenarioApi(program, options)) {
435
+ const identities = new Map(),
436
+ behaviorIdentities = new Set();
437
+ for (const item of await scenarioApi(program, options)) {
223
438
  if (!identities.has(item.declaration)) identities.set(item.declaration, new Set());
224
439
  identities.get(item.declaration).add(item.name);
225
440
  if (item.behavioral && !item.renderable) behaviorIdentities.add(item.declaration);
@@ -227,52 +442,77 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
227
442
 
228
443
  const covered = new Set();
229
444
  const coveredTokens = new Set();
230
- const tokenInventory = inspectTokens(options.root, options);
231
- const declaredTokens = new Set(tokenInventory.tokens.map(token => token.name));
445
+ const tokenInventory = await inspectTokens(options.root, options);
446
+ const declaredTokens = new Set(tokenInventory.tokens.map((token) => token.name));
232
447
  for (const scenario of registry.scenarios) {
233
- const source = program.getSourceFile(path.join(options.root, scenario.file));
448
+ if (scenario.foundation) {
449
+ for (const name of scenario.tokens) coveredTokens.add(name);
450
+ continue;
451
+ }
452
+ const source = await program.getSourceFile(path.join(options.root, scenario.file));
234
453
  const rendered = new Set();
235
- const exercised = new Set(), referencedApis = new Set(), declarative = new Set();
454
+ const exercised = new Set(),
455
+ referencedApis = new Set(),
456
+ declarative = new Set();
236
457
  const referencedTokens = new Set();
237
458
  let samplesPassed = false;
238
459
  const renderLimits = new Set();
239
460
  const visited = new Set();
240
- function visit(node, reached = false) {
461
+ async function visit(node, reached = false) {
241
462
  if (!node || visited.has(node)) return;
242
463
  if (!reached && ts.isFunctionDeclaration(node)) return;
243
464
  // Calls/construction in a mounted adapter execute even when only a result
244
465
  // property is read later. Unused literal fixture fields still do not count.
245
- if (!reached && ts.isVariableDeclaration(node) && !(node.initializer && (ts.isCallExpression(node.initializer) || ts.isNewExpression(node.initializer)))) return;
246
- if (!reached && (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && !ts.isCallExpression(node.parent) && !ts.isJsxExpression(node.parent)) return;
466
+ if (!reached && ts.isVariableDeclaration(node) && !(node.initializer && (ts.isCallExpression(node.initializer) || ts.isNewExpression(node.initializer))))
467
+ return;
468
+ if (!reached && (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && !ts.isCallExpression(node.parent) && !ts.isJsxExpression(node.parent))
469
+ return;
247
470
  visited.add(node);
248
471
  if (ts.isStringLiteralLike(node) && (isSharedToken(node.text) || scenario.tokens.includes(node.text))) referencedTokens.add(node.text);
249
472
  let expression;
250
473
  if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) expression = node.tagName;
251
- if (ts.isCallExpression(node) && uiOperation(node.expression, checker) === "createElement") expression = node.arguments[0];
474
+ if (ts.isCallExpression(node) && (await uiOperation(node.expression, checker)) === "createElement") expression = node.arguments[0];
252
475
  if (expression) {
253
476
  const site = ts.isJsxOpeningElement(node) ? node.parent : node;
254
- const evidence = trace.traceRenders(site);
477
+ const evidence = await trace.traceRenders(site);
255
478
  for (const name of evidence.rendered) rendered.add(name);
256
479
  for (const reason of evidence.limits) renderLimits.add(reason);
257
- const symbol = canonical(symbolOf(expression));
480
+ const symbol = await canonical(await symbolOf(expression));
258
481
  const names = identities.get(symbol?.valueDeclaration ?? symbol?.declarations?.[0]);
259
- for (const name of names ?? []) { rendered.add(name); exercised.add(name); }
260
- if (scenario.kind === "tokens" && [...names ?? []].some(name => scenario.covers.includes(name))) {
261
- const attributes = ts.isCallExpression(node) ? literal(node.arguments[1], checker) : Object.assign({}, ...node.attributes.properties.map(attribute => ts.isJsxSpreadAttribute(attribute) ? literal(attribute.expression, checker) : ts.isJsxAttribute(attribute) && ts.isIdentifier(attribute.name) && attribute.initializer && ts.isJsxExpression(attribute.initializer) ? { [attribute.name.text]: literal(attribute.initializer.expression, checker) } : {}));
482
+ for (const name of names ?? []) {
483
+ rendered.add(name);
484
+ exercised.add(name);
485
+ }
486
+ if (scenario.kind === "tokens" && [...(names ?? [])].some((name) => scenario.covers.includes(name))) {
487
+ const attributes = ts.isCallExpression(node)
488
+ ? await literal(node.arguments[1], checker)
489
+ : Object.assign(
490
+ {},
491
+ ...(await mapAsync(node.attributes.properties, async (attribute) =>
492
+ ts.isJsxSpreadAttribute(attribute)
493
+ ? await literal(attribute.expression, checker)
494
+ : ts.isJsxAttribute(attribute) && ts.isIdentifier(attribute.name) && attribute.initializer && ts.isJsxExpression(attribute.initializer)
495
+ ? { [attribute.name.text]: await literal(attribute.initializer.expression, checker) }
496
+ : {},
497
+ )),
498
+ );
262
499
  if (JSON.stringify(attributes?.samples) === JSON.stringify(scenario.samples)) samplesPassed = true;
263
500
  }
264
501
  }
265
502
  if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
266
503
  let expression = node.expression;
267
504
  if (ts.isPropertyAccessExpression(expression) && ["call", "apply"].includes(expression.name.text)) expression = expression.expression;
268
- const symbol = canonical(symbolOf(expression));
505
+ const symbol = await canonical(await symbolOf(expression));
269
506
  for (const name of identities.get(symbol?.valueDeclaration ?? symbol?.declarations?.[0]) ?? []) exercised.add(name);
270
507
  // A call on an attached method exercises its public behavioral receiver.
271
508
  // Follow symbol identities through aliases, namespaces and re-exports;
272
509
  // a property read or an unused callback still does not establish a call.
273
- while (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression) && expression.argumentExpression && ts.isStringLiteralLike(expression.argumentExpression)) {
510
+ while (
511
+ ts.isPropertyAccessExpression(expression) ||
512
+ (ts.isElementAccessExpression(expression) && expression.argumentExpression && ts.isStringLiteralLike(expression.argumentExpression))
513
+ ) {
274
514
  expression = expression.expression;
275
- const receiver = canonical(symbolOf(expression));
515
+ const receiver = await canonical(await symbolOf(expression));
276
516
  const owner = receiver?.valueDeclaration ?? receiver?.declarations?.[0];
277
517
  if (behaviorIdentities.has(owner)) for (const name of identities.get(owner) ?? []) exercised.add(name);
278
518
  }
@@ -280,73 +520,97 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
280
520
  // Follow local adapters reachable from the default entry. Production
281
521
  // children get evidence only from bounded returned-JSX tracing above,
282
522
  // never by scanning every reference in their implementation.
283
- if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) || ts.isIdentifier(node) && !(ts.isPropertyAccessExpression(node.parent) || ts.isElementAccessExpression(node.parent))) {
284
- const symbol = canonical(symbolOf(node));
523
+ if (
524
+ ts.isPropertyAccessExpression(node) ||
525
+ ts.isElementAccessExpression(node) ||
526
+ (ts.isIdentifier(node) && !(ts.isPropertyAccessExpression(node.parent) || ts.isElementAccessExpression(node.parent)))
527
+ ) {
528
+ const symbol = await canonical(await symbolOf(node));
285
529
  const declaration = symbol?.valueDeclaration;
286
530
  for (const name of identities.get(declaration ?? symbol?.declarations?.[0]) ?? []) referencedApis.add(name);
287
- if (declaration && isDevelopmentFile(declaration.getSourceFile().fileName, options)) visit(declaration, true);
531
+ if (declaration && isDevelopmentFile(declaration.getSourceFile().fileName, options)) await visit(declaration, true);
288
532
  }
289
- ts.forEachChild(node, child => visit(child, reached && (ts.isExportAssignment(node) || ts.isVariableDeclaration(node))));
533
+ await eachChild(node, async (child) => visit(child, reached && (ts.isExportAssignment(node) || ts.isVariableDeclaration(node))));
290
534
  }
291
- for (const node of source.statements) if (ts.isExportAssignment(node) || node.modifiers?.some(item => item.kind === ts.SyntaxKind.DefaultKeyword)) visit(node, true);
292
- if(parts.some(part=>scenario.exercises?.includes(part.apiName)))for(const name of trace.traceEntry(source,{exercise:true}).declarative)declarative.add(name);
535
+ for (const node of source.statements)
536
+ if (ts.isExportAssignment(node) || node.modifiers?.some((item) => item.kind === ts.SyntaxKind.DefaultKeyword)) await visit(node, true);
537
+ if (parts.some((part) => scenario.exercises?.includes(part.apiName)))
538
+ for (const name of (await trace.traceEntry(source, { exercise: true })).declarative) declarative.add(name);
293
539
  for (const name of scenario.covers) {
294
- if (!rendered.has(name)) report(source.fileName, "scenario-render", `${name} is declared in covers but has no reachable public render reference. Render it directly or through a traced parent with fixture props/defaults selecting that child. Imports, unused JSX and unknown conditional paths do not establish coverage.${renderLimits.size ? ` Source tracing could not establish: ${[...renderLimits].slice(0, 2).join(" ")}` : ""} Review the real scenario in a browser; do not hide a valid public part just to avoid coverage. See ads://guides/scenarios.`);
540
+ if (!rendered.has(name))
541
+ report(
542
+ source.fileName,
543
+ "scenario-render",
544
+ `${name} is declared in covers but has no reachable public render reference. Render it directly or through a traced parent with fixture props/defaults selecting that child. Imports, unused JSX and unknown conditional paths do not establish coverage.${renderLimits.size ? ` Source tracing could not establish: ${[...renderLimits].slice(0, 2).join(" ")}` : ""} Review the real scenario in a browser; do not hide a valid public part just to avoid coverage. See ads://guides/scenarios.`,
545
+ );
295
546
  else covered.add(name);
296
547
  }
297
548
  for (const name of scenario.exercises ?? []) {
298
- if (parts.some(part=>part.apiName===name) && !declarative.has(name)) report(source.fileName, "scenario-exercise", `${name} is a registered declarative API, but its child does not reach the declared consumer through a rendered parent. Imports, unused children and unrelated parent renders do not establish consumption.`);
299
- else if (!exercised.has(name) && !referencedApis.has(name)) report(source.fileName, "scenario-exercise", `${name} is declared in exercises but has no reachable behavioral use. Imports and unused adapters do not count.`);
300
- else if (!exercised.has(name)) advise(source.fileName, "scenario-exercise-review", `${name} is referenced dynamically. Verify its invocation in the registered browser/behavior checks; a reference alone does not prove execution.`);
549
+ if (parts.some((part) => part.apiName === name) && !declarative.has(name))
550
+ report(
551
+ source.fileName,
552
+ "scenario-exercise",
553
+ `${name} is a registered declarative API, but its child does not reach the declared consumer through a rendered parent. Imports, unused children and unrelated parent renders do not establish consumption.`,
554
+ );
555
+ else if (!exercised.has(name) && !referencedApis.has(name))
556
+ report(
557
+ source.fileName,
558
+ "scenario-exercise",
559
+ `${name} is declared in exercises but has no reachable behavioral use. Imports and unused adapters do not count.`,
560
+ );
561
+ else if (!exercised.has(name))
562
+ advise(
563
+ source.fileName,
564
+ "scenario-exercise-review",
565
+ `${name} is referenced dynamically. Verify its invocation in the registered browser/behavior checks; a reference alone does not prove execution.`,
566
+ );
301
567
  }
302
- for (const name of referencedTokens) if (!declaredTokens.has(name)) report(source.fileName, "token-scenario-reference", `Reachable scenario input references undeclared token ${name}.`);
303
- if (scenario.kind === "tokens" && !samplesPassed) report(source.fileName, "token-scenario-render", "Pass the declared fixture.samples into a rendered review renderer's samples prop. Printing token names or reading unused fixtures is not sample coverage.");
568
+ for (const name of referencedTokens)
569
+ if (!declaredTokens.has(name)) report(source.fileName, "token-scenario-reference", `Reachable scenario input references undeclared token ${name}.`);
570
+ if (scenario.kind === "tokens" && !samplesPassed)
571
+ report(
572
+ source.fileName,
573
+ "token-scenario-render",
574
+ "Pass the declared fixture.samples into a rendered review renderer's samples prop. Printing token names or reading unused fixtures is not sample coverage.",
575
+ );
304
576
  for (const name of scenario.tokens) {
305
- if (!referencedTokens.has(name)) report(source.fileName, "token-scenario-render", `${name} is declared in tokens but has no reachable reference from the default scenario entry. Consume the real token fixture; metadata alone does not count.`);
577
+ if (!referencedTokens.has(name))
578
+ report(
579
+ source.fileName,
580
+ "token-scenario-render",
581
+ `${name} is declared in tokens but has no reachable reference from the default scenario entry. Consume the real token fixture; metadata alone does not count.`,
582
+ );
306
583
  else if (scenario.kind === "tokens" && samplesPassed && declaredTokens.has(name)) coveredTokens.add(name);
307
584
  }
308
585
  }
309
- const blockedOwners=new Set(registry.diagnostics.filter(item=>item.coverage==="not-established").map(item=>item.owner));
310
- for (const item of ui.filter((item) => item.renderable && !covered.has(item.name) && !blockedOwners.has(inspectUnits(options).owner(inspectUnits(options).relative(path.relative(options.root,item.file)))))) report(item.file, "scenario-coverage", `Public UI ${item.name} needs a colocated, registered scenario render reference. Related parts may share a scenario.`);
311
- for (const token of tokenInventory.tokens.filter(token => !coveredTokens.has(token.name))) {
586
+ const blockedOwners = new Set(registry.diagnostics.filter((item) => item.coverage === "not-established").map((item) => item.owner));
587
+ for (const item of await filterAsync(
588
+ ui,
589
+ async (item) =>
590
+ item.renderable &&
591
+ !covered.has(item.name) &&
592
+ !blockedOwners.has((await inspectUnits(options)).owner((await inspectUnits(options)).relative(path.relative(options.root, item.file)))),
593
+ ))
594
+ report(
595
+ item.file,
596
+ "scenario-coverage",
597
+ `Public UI ${item.name} needs a colocated, registered scenario render reference. Related parts may share a scenario.`,
598
+ );
599
+ for (const token of tokenInventory.tokens.filter((token) => !coveredTokens.has(token.name))) {
312
600
  const definition = token.definitions[0];
313
- report(path.join(options.root, definition.file), "token-scenario-coverage", `Token ${token.name} needs a registered scenario with a reachable token fixture reference.`, definition.line, definition.column);
601
+ report(
602
+ path.join(options.root, definition.file),
603
+ "token-scenario-coverage",
604
+ `Token ${token.name} needs a registered scenario with a reachable token fixture reference.`,
605
+ definition.line,
606
+ definition.column,
607
+ );
314
608
  }
315
609
  }
316
610
 
317
- export function writeScenarioRegistry(options, write) {
318
- const registry = inspectScenarios(options);
611
+ export async function writeScenarioRegistry(options, write) {
612
+ const registry = await inspectScenarios(options);
319
613
  if (registry.diagnostics.length) throw new Error(registry.diagnostics.map((item) => `${item.file}: ${item.message}`).join("\n"));
320
614
  write({ schemaVersion: 1, scenarios: registry.scenarios });
321
615
  return registry.scenarios;
322
616
  }
323
-
324
- /** Locate the actual consumed array, rather than regenerating a whole fixture. */
325
- export function tokenSampleSource(options, scenario) {
326
- const file = path.join(options.root, scenario.file);
327
- const program = ts.createProgram([file], { ...projectCompilerOptions(options), allowJs:true, resolveJsonModule:true });
328
- const checker = program.getTypeChecker(), source = program.getSourceFile(file);
329
- function resolve(node, seen = new Set()) {
330
- while (node && (ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isParenthesizedExpression(node))) node = node.expression;
331
- if (!node || seen.has(node)) return null;
332
- if (ts.isArrayLiteralExpression(node) || ts.isObjectLiteralExpression(node)) return node;
333
- let symbol = checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
334
- if (symbol?.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol);
335
- const declaration = symbol?.valueDeclaration;
336
- return declaration?.initializer ? resolve(declaration.initializer, new Set([...seen,node])) : null;
337
- }
338
- for (const statement of source.statements) if (ts.isVariableStatement(statement)) for (const declaration of statement.declarationList.declarations) {
339
- if (!ts.isIdentifier(declaration.name) || declaration.name.text !== "scenario") continue;
340
- const metadata = resolve(declaration.initializer);
341
- const property = metadata && ts.isObjectLiteralExpression(metadata) && metadata.properties.find(node => ts.isPropertyAssignment(node) && (ts.isIdentifier(node.name) || ts.isStringLiteralLike(node.name)) && node.name.text === "samples");
342
- const array = property && resolve(property.initializer);
343
- if (array && ts.isArrayLiteralExpression(array)) {
344
- const source = array.getSourceFile();
345
- const units = inspectUnits(options), owner = units.owner(units.relative(scenario.file));
346
- const relative = path.relative(options.root, source.fileName).replaceAll("\\", "/");
347
- if (!isDevelopmentFile(source.fileName, options) || units.owner(units.relative(relative)) !== owner) throw new Error("The consumed samples array must live in this scenario's own development fixture.");
348
- return {file:relative, content:source.text, start:array.getStart(source), end:array.end};
349
- }
350
- }
351
- throw new Error("Cannot locate a literal consumed samples array. Keep fixture.samples statically inspectable; edit other fixture shapes with a normal owner patch.");
352
- }