@reqvire-org/ads 0.3.53 → 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 (401) hide show
  1. package/README.md +114 -94
  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 +6 -6
  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 +222 -79
  21. package/dist/boundaries.mjs +137 -40
  22. package/dist/brand-assets.mjs +219 -47
  23. package/dist/brands.mjs +86 -27
  24. package/dist/bun-compiler.mjs +34 -13
  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 +66 -0
  30. package/dist/check.mjs +756 -196
  31. package/dist/cli.mjs +203 -100
  32. package/dist/color-values.mjs +21 -21
  33. package/dist/component-contrast.mjs +2 -2
  34. package/dist/config.mjs +308 -163
  35. package/dist/construction-styles.cjs +10 -0
  36. package/dist/contracts.d.mts +9 -0
  37. package/dist/control-padding.mjs +45 -25
  38. package/dist/css-values.mjs +3 -2
  39. package/dist/declarative-flow.mjs +209 -109
  40. package/dist/design-values.mjs +136 -51
  41. package/dist/development-runtime.mjs +4 -6
  42. package/dist/draft-boundary.mjs +11 -6
  43. package/dist/evidence.mjs +1 -1
  44. package/dist/finding-rules.mjs +7 -5
  45. package/dist/font-rules.mjs +2 -2
  46. package/dist/fonts-generated.mjs +4 -2
  47. package/dist/foundation-views.mjs +238 -0
  48. package/dist/foundation.mjs +63 -39
  49. package/dist/generated-entries.mjs +198 -0
  50. package/dist/icons.mjs +80 -33
  51. package/dist/image-attributes.mjs +109 -36
  52. package/dist/image-size.mjs +1 -1
  53. package/dist/index.mjs +0 -2
  54. package/dist/init.mjs +128 -68
  55. package/dist/investigations.mjs +2 -2
  56. package/dist/layers.mjs +300 -127
  57. package/dist/layout-widths.mjs +180 -85
  58. package/dist/linaria/preserve-values.cjs +7 -0
  59. package/dist/linaria/spatial-inputs.cjs +56 -0
  60. package/dist/lockup-composition.mjs +44 -0
  61. package/dist/lockup-model.cjs +64 -0
  62. package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
  63. package/dist/mcp/apps.mjs +4 -30
  64. package/dist/mcp/behavior-pages.mjs +72 -24
  65. package/dist/mcp/build-status.mjs +257 -64
  66. package/dist/mcp/catalog.mjs +91 -26
  67. package/dist/mcp/context.mjs +17 -18
  68. package/dist/mcp/draft-discovery.mjs +44 -21
  69. package/dist/mcp/drafts.mjs +978 -343
  70. package/dist/mcp/execution-coordinator.mjs +417 -167
  71. package/dist/mcp/execution-results.mjs +7 -7
  72. package/dist/mcp/mutations.mjs +701 -219
  73. package/dist/mcp/preview-watch.mjs +465 -161
  74. package/dist/mcp/preview-widget.bundle.js +44 -50
  75. package/dist/mcp/prompts.mjs +6 -6
  76. package/dist/mcp/result-pages.mjs +1 -1
  77. package/dist/mcp/sandbox-host.mjs +1 -1
  78. package/dist/mcp/server.mjs +2436 -570
  79. package/dist/mcp/showcase-host.mjs +176 -39
  80. package/dist/mcp/skills.mjs +1 -1
  81. package/dist/mcp/text-diff.mjs +29 -10
  82. package/dist/paint-contracts.mjs +174 -81
  83. package/dist/palette-generated.mjs +2 -2
  84. package/dist/preview-bun.mjs +493 -187
  85. package/dist/preview-failure.mjs +1 -1
  86. package/dist/preview-files.mjs +13 -13
  87. package/dist/preview-imports.mjs +104 -55
  88. package/dist/preview-inputs.mjs +2 -2
  89. package/dist/preview-requests.mjs +24 -0
  90. package/dist/preview-resources.mjs +288 -147
  91. package/dist/preview-scope.mjs +5 -4
  92. package/dist/program-cache.mjs +10 -0
  93. package/dist/project-documents.mjs +1 -1
  94. package/dist/public-api.mjs +70 -31
  95. package/dist/public-props.mjs +39 -22
  96. package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
  97. package/dist/{browser-audit → render-audit}/image-shape.mjs +2 -2
  98. package/dist/{browser-audit → render-audit}/layout-overflow.mjs +86 -23
  99. package/dist/{browser-audit → render-audit}/non-text-contrast.mjs +86 -27
  100. package/dist/{browser-audit → render-audit}/render-states.mjs +208 -52
  101. package/dist/{browser-audit → render-audit}/worker.mjs +86 -30
  102. package/dist/render-audit.mjs +828 -0
  103. package/dist/render-color-probe.mjs +96 -42
  104. package/dist/resource-limits.mjs +229 -97
  105. package/dist/runtime-contracts.mjs +467 -185
  106. package/dist/scenario-groups.mjs +22 -10
  107. package/dist/scenario-inspector.mjs +6 -43
  108. package/dist/scenario-program.mjs +8 -25
  109. package/dist/scenario-registry.mjs +72 -30
  110. package/dist/scenario-selectors.mjs +161 -64
  111. package/dist/scenario-slots.mjs +149 -56
  112. package/dist/scenario-trace.mjs +215 -109
  113. package/dist/scenarios-compiler.mjs +768 -359
  114. package/dist/scenarios-vite.d.mts +1 -3
  115. package/dist/scenarios-vite.mjs +2 -81
  116. package/dist/scenarios.mjs +424 -159
  117. package/dist/selector-match.mjs +2 -2
  118. package/dist/showcase/client.bundle.js +57 -56
  119. package/dist/showcase/draft-navigation.js +18 -0
  120. package/dist/showcase/favicon.ico +0 -0
  121. package/dist/showcase/favicon.svg +1 -0
  122. package/dist/showcase/foundation-view.css +55 -0
  123. package/dist/showcase/foundation-view.mjs +252 -0
  124. package/dist/showcase/guide-controls.ads.review.mjs +32 -0
  125. package/dist/showcase/icons.js +1 -145
  126. package/dist/showcase/index.html +3 -31
  127. package/dist/showcase/preview-frame.ads.review.css +46 -0
  128. package/dist/showcase/preview-frame.ads.review.d.mts +11 -0
  129. package/dist/showcase/preview-frame.ads.review.mjs +22 -0
  130. package/dist/showcase/preview-state.js +0 -9
  131. package/dist/showcase/refresh-scheduler.js +23 -0
  132. package/dist/showcase/style.css +5 -47
  133. package/dist/showcase/ui/ui.css +1353 -0
  134. package/dist/showcase/ui/ui.js +1062 -0
  135. package/dist/showcase-coverage.mjs +58 -37
  136. package/dist/skills/README.md +24 -23
  137. package/dist/skills/ads-designer/README.md +8 -2
  138. package/dist/skills/ads-designer/SKILL.md +152 -144
  139. package/dist/skills/ads-designer/references/accessibility.md +14 -11
  140. package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
  141. package/dist/skills/ads-designer/references/behaviors.md +34 -30
  142. package/dist/skills/ads-designer/references/branding.md +98 -10
  143. package/dist/skills/ads-designer/references/captures.md +31 -31
  144. package/dist/skills/ads-designer/references/cli.md +21 -20
  145. package/dist/skills/ads-designer/references/contracts.md +63 -29
  146. package/dist/skills/ads-designer/references/design-data.md +49 -52
  147. package/dist/skills/ads-designer/references/drafts.md +71 -52
  148. package/dist/skills/ads-designer/references/evidence.md +1 -5
  149. package/dist/skills/ads-designer/references/guarded-editing.md +58 -51
  150. package/dist/skills/ads-designer/references/layers.md +1 -1
  151. package/dist/skills/ads-designer/references/layout.md +347 -0
  152. package/dist/skills/ads-designer/references/mobile.md +2 -1
  153. package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
  154. package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
  155. package/dist/skills/ads-designer/references/performance.md +3 -2
  156. package/dist/skills/ads-designer/references/review.md +42 -38
  157. package/dist/skills/ads-designer/references/runtimes.md +33 -30
  158. package/dist/skills/ads-designer/references/scenarios.md +17 -19
  159. package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
  160. package/dist/skills/ads-designer/references/stress-test.md +68 -0
  161. package/dist/skills/ads-designer/references/validation.md +83 -71
  162. package/dist/skills/ads-designer/references/workflows.md +19 -37
  163. package/dist/skills/ads-import/SKILL.md +43 -328
  164. package/dist/skills/ads-import/references/atomic-styles.md +4 -4
  165. package/dist/skills/ads-import/references/behaviors.md +34 -30
  166. package/dist/skills/ads-import/references/branding.md +5 -5
  167. package/dist/skills/ads-import/references/captures.md +31 -31
  168. package/dist/skills/ads-import/references/cli.md +21 -20
  169. package/dist/skills/ads-import/references/compatibility.md +1 -1
  170. package/dist/skills/ads-import/references/contracts.md +63 -29
  171. package/dist/skills/ads-import/references/design-data.md +49 -52
  172. package/dist/skills/ads-import/references/drafts.md +71 -52
  173. package/dist/skills/ads-import/references/evidence.md +1 -5
  174. package/dist/skills/ads-import/references/guarded-editing.md +58 -51
  175. package/dist/skills/ads-import/references/implementation.md +2 -1
  176. package/dist/skills/ads-import/references/layers.md +1 -1
  177. package/dist/skills/ads-import/references/layout.md +347 -0
  178. package/dist/skills/ads-import/references/review.md +42 -38
  179. package/dist/skills/ads-import/references/runtimes.md +33 -30
  180. package/dist/skills/ads-import/references/scenarios.md +17 -19
  181. package/dist/skills/ads-import/references/tokens.md +3 -3
  182. package/dist/skills/ads-import/references/validation.md +83 -71
  183. package/dist/skills/ads-import/references/workflows.md +19 -37
  184. package/dist/skills/ads-migrate/SKILL.md +56 -0
  185. package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
  186. package/dist/skills/ads-port/SKILL.md +54 -346
  187. package/dist/skills/ads-port/references/atomic-styles.md +4 -4
  188. package/dist/skills/ads-port/references/behaviors.md +34 -30
  189. package/dist/skills/ads-port/references/captures.md +31 -31
  190. package/dist/skills/ads-port/references/cli.md +21 -20
  191. package/dist/skills/ads-port/references/contracts.md +63 -29
  192. package/dist/skills/ads-port/references/design-data.md +49 -52
  193. package/dist/skills/ads-port/references/drafts.md +71 -52
  194. package/dist/skills/ads-port/references/evidence.md +1 -5
  195. package/dist/skills/ads-port/references/guarded-editing.md +58 -51
  196. package/dist/skills/ads-port/references/layers.md +1 -1
  197. package/dist/skills/ads-port/references/layout.md +347 -0
  198. package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
  199. package/dist/skills/ads-port/references/native-implementation.md +8 -7
  200. package/dist/skills/ads-port/references/review.md +42 -38
  201. package/dist/skills/ads-port/references/runtimes.md +33 -30
  202. package/dist/skills/ads-port/references/scenarios.md +17 -19
  203. package/dist/skills/ads-port/references/validation.md +83 -71
  204. package/dist/skills/ads-port/references/workflows.md +19 -37
  205. package/dist/source-symbols.mjs +1 -8
  206. package/dist/source-values.mjs +266 -128
  207. package/dist/spatial-composition.mjs +322 -0
  208. package/dist/spatial-contexts.cjs +56 -0
  209. package/dist/spatial-css.cjs +351 -0
  210. package/dist/spatial-inputs.cjs +80 -0
  211. package/dist/spatial-metadata.mjs +18 -0
  212. package/dist/spatial-model.cjs +322 -0
  213. package/dist/spatial.mjs +21 -0
  214. package/dist/stage-timing.cjs +20 -0
  215. package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +105 -0
  216. package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +275 -0
  217. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  218. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  219. package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +8 -0
  220. package/dist/starters/preact/ds.config.json +24 -19
  221. package/dist/starters/preact/package.json +4 -8
  222. package/dist/starters/preact/tsconfig.json +4 -5
  223. package/dist/starters/preact/vite.config.ts +3 -3
  224. package/dist/starters/react/ADS.md +42 -47
  225. package/dist/starters/react/README.md +54 -52
  226. package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +1 -0
  227. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +1 -0
  228. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +18 -2
  229. package/dist/starters/react/design-system/components/Actions/IconButton/README.md +3 -0
  230. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +1 -0
  231. package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +1 -0
  232. package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +1 -0
  233. package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +1 -0
  234. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +5 -0
  235. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
  236. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
  237. package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +1 -0
  238. package/dist/starters/react/design-system/index.ts +5 -8
  239. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
  240. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
  241. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
  242. package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
  243. package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
  244. package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +1 -0
  245. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
  246. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
  247. package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
  248. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
  249. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
  250. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
  251. package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
  252. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -0
  253. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  254. package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
  255. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
  256. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
  257. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -0
  258. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  259. package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
  260. package/dist/starters/react/design-system/styles.css +1 -0
  261. package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
  262. package/dist/starters/react/design-system/tokens/colors.css +1 -1
  263. package/dist/starters/react/design-system/tokens/spacing.css +22 -32
  264. package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
  265. package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
  266. package/dist/starters/react/ds.config.json +24 -19
  267. package/dist/starters/react/package.json +2 -6
  268. package/dist/starters/react/tsconfig.json +2 -3
  269. package/dist/starters/react/vite.config.ts +3 -3
  270. package/dist/style-boundaries.mjs +73 -27
  271. package/dist/task-cache.mjs +173 -72
  272. package/dist/task-worker.mjs +22 -11
  273. package/dist/test-boundaries.mjs +133 -60
  274. package/dist/themes-generated.mjs +1 -1
  275. package/dist/themes-watch.mjs +60 -19
  276. package/dist/themes.mjs +176 -73
  277. package/dist/token-export.mjs +39 -14
  278. package/dist/token-policy.mjs +6 -3
  279. package/dist/token-quality.mjs +6 -6
  280. package/dist/token-samples.mjs +16 -5
  281. package/dist/tokens.mjs +71 -26
  282. package/dist/ui-framework.mjs +16 -14
  283. package/dist/unit-contracts.mjs +270 -89
  284. package/dist/units.mjs +215 -180
  285. package/dist/usage.mjs +138 -38
  286. package/dist/validation-checks.mjs +121 -38
  287. package/dist/validation-inputs.mjs +187 -78
  288. package/dist/validation.mjs +268 -102
  289. package/dist/verification/browser.mjs +27 -5
  290. package/dist/verification.mjs +711 -187
  291. package/docs/ADS.md +100 -89
  292. package/docs/ARCHITECTURE.md +353 -159
  293. package/docs/BEHAVIORS.md +33 -28
  294. package/docs/CACHING.md +55 -11
  295. package/docs/CHANGELOG.md +358 -17
  296. package/docs/COMPARISON.md +1 -1
  297. package/docs/CONTRACTS.md +22 -29
  298. package/docs/DESIGN-REFERENCES.md +40 -0
  299. package/docs/GUIDE.md +313 -292
  300. package/docs/MCP.md +261 -439
  301. package/docs/SPATIAL-CHECKS.md +69 -0
  302. package/docs/benchmarks/README.md +39 -0
  303. package/package.json +42 -34
  304. package/dist/browser-audit.mjs +0 -424
  305. package/dist/contract-migration.mjs +0 -110
  306. package/dist/create.mjs +0 -48
  307. package/dist/lint-config.mjs +0 -48
  308. package/dist/mcp/draft-exports.mjs +0 -40
  309. package/dist/mcp/edit-preparation.mjs +0 -115
  310. package/dist/mcp/project-widget.bundle.js +0 -114
  311. package/dist/mcp/reports.mjs +0 -101
  312. package/dist/mcp/widget.bundle.js +0 -147
  313. package/dist/oxlint.mjs +0 -88
  314. package/dist/preview-builder.mjs +0 -133
  315. package/dist/preview-workers.mjs +0 -184
  316. package/dist/showcase.mjs +0 -77
  317. package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
  318. package/dist/skills/ads-break-ui/README.md +0 -16
  319. package/dist/skills/ads-break-ui/SKILL.md +0 -415
  320. package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
  321. package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
  322. package/dist/skills/ads-break-ui/references/behaviors.md +0 -411
  323. package/dist/skills/ads-break-ui/references/captures.md +0 -160
  324. package/dist/skills/ads-break-ui/references/contracts.md +0 -284
  325. package/dist/skills/ads-break-ui/references/design-data.md +0 -354
  326. package/dist/skills/ads-break-ui/references/drafts.md +0 -178
  327. package/dist/skills/ads-break-ui/references/evidence.md +0 -128
  328. package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -154
  329. package/dist/skills/ads-break-ui/references/layers.md +0 -145
  330. package/dist/skills/ads-break-ui/references/reporting.md +0 -101
  331. package/dist/skills/ads-break-ui/references/review.md +0 -96
  332. package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
  333. package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
  334. package/dist/skills/ads-break-ui/references/validation.md +0 -162
  335. package/dist/skills/ads-break-ui/references/verification.md +0 -58
  336. package/dist/skills/ads-break-ui/references/workflows.md +0 -83
  337. package/dist/skills/ads-designer/references/reporting.md +0 -101
  338. package/dist/skills/ads-import/references/reporting.md +0 -101
  339. package/dist/skills/ads-motion/LICENSE.upstream +0 -21
  340. package/dist/skills/ads-motion/README.md +0 -22
  341. package/dist/skills/ads-motion/SKILL.md +0 -388
  342. package/dist/skills/ads-motion/agents/openai.yaml +0 -4
  343. package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
  344. package/dist/skills/ads-motion/references/audit.md +0 -44
  345. package/dist/skills/ads-motion/references/behaviors.md +0 -411
  346. package/dist/skills/ads-motion/references/captures.md +0 -160
  347. package/dist/skills/ads-motion/references/contracts.md +0 -284
  348. package/dist/skills/ads-motion/references/design-data.md +0 -354
  349. package/dist/skills/ads-motion/references/drafts.md +0 -178
  350. package/dist/skills/ads-motion/references/evidence.md +0 -128
  351. package/dist/skills/ads-motion/references/guarded-editing.md +0 -154
  352. package/dist/skills/ads-motion/references/layers.md +0 -145
  353. package/dist/skills/ads-motion/references/motion-review.md +0 -35
  354. package/dist/skills/ads-motion/references/reporting.md +0 -101
  355. package/dist/skills/ads-motion/references/review.md +0 -96
  356. package/dist/skills/ads-motion/references/runtimes.md +0 -203
  357. package/dist/skills/ads-motion/references/scenarios.md +0 -246
  358. package/dist/skills/ads-motion/references/validation.md +0 -162
  359. package/dist/skills/ads-motion/references/verification.md +0 -39
  360. package/dist/skills/ads-motion/references/workflows.md +0 -83
  361. package/dist/skills/ads-port/references/reporting.md +0 -101
  362. package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
  363. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  364. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  365. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
  366. package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
  367. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
  368. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
  369. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
  370. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
  371. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
  372. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
  373. package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
  374. package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
  375. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
  376. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  377. package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
  378. package/dist/starters/react/design-system/review/index.ts +0 -5
  379. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  380. package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
  381. package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
  382. package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
  383. package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
  384. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
  385. package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
  386. package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
  387. package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
  388. package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
  389. package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
  390. package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
  391. package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
  392. package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
  393. package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
  394. package/dist/starters/react/package-lock.json +0 -4707
  395. package/dist/token-fixtures.mjs +0 -30
  396. package/docs/benchmarks/bun-previews.md +0 -91
  397. package/docs/benchmarks/preview-memory.md +0 -147
  398. package/docs/benchmarks/turbo-poc.md +0 -284
  399. package/docs/plans/execution-coordination.md +0 -57
  400. /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
  401. /package/dist/{browser-audit → render-audit}/layout-shift.mjs +0 -0
@@ -1,9 +1,13 @@
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";
10
+ import { cachedProgram } from "./program-cache.mjs";
7
11
  import { projectCompilerOptions } from "./boundaries.mjs";
8
12
  import { inspectTokens } from "./tokens.mjs";
9
13
  import { isSharedToken } from "./token-policy.mjs";
@@ -14,211 +18,423 @@ import { inspectRuntimeContracts } from "./runtime-contracts.mjs";
14
18
  import { inspectUnitContracts } from "./unit-contracts.mjs";
15
19
  import { inspectPaintContracts } from "./paint-contracts.mjs";
16
20
  import { createScenarioGroups } from "./scenario-groups.mjs";
21
+ import { foundationViews } from "./foundation-views.mjs";
17
22
 
18
23
  export const scenarioArtifact = (root, id) => path.join(root, ".ds/scenarios", id, "index.html");
19
24
 
20
- function literal(node, checker, seen = new Set()) {
25
+ async function literal(node, checker, seen = new Set()) {
21
26
  while (node && (ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isParenthesizedExpression(node))) node = node.expression;
22
27
  if (!node || seen.has(node)) return undefined;
23
28
  seen = new Set([...seen, node]);
24
29
  if (node && ts.isStringLiteralLike(node)) return node.text;
25
30
  if (node?.kind === ts.SyntaxKind.TrueKeyword) return true;
26
31
  if (node?.kind === ts.SyntaxKind.FalseKeyword) return false;
27
- if (node && ts.isArrayLiteralExpression(node)) return node.elements.map(item => literal(item, checker, seen));
28
- 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
+ );
29
41
  if (checker && (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node))) {
30
- let symbol = checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
31
- 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);
32
44
  const declaration = symbol?.valueDeclaration;
33
- 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);
34
47
  }
35
48
  return undefined;
36
49
  }
37
50
 
38
- export function publicUi(program, options) {
39
- 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");
40
53
  }
41
54
 
42
55
  /** Discover metadata statically. The MCP process never imports scenario modules. */
43
- export function inspectScenarios(options, suppliedProgram) {
56
+ export async function inspectScenarios(options, suppliedProgram) {
57
+ if (!currentAnalysis()?.provideProgram) return withProjectAnalysis(options.root, async () => inspectScenarios(options, suppliedProgram));
44
58
  const { root, dsRoot } = options;
45
59
  const files = sourceFiles(dsRoot).filter(isScenarioFile);
46
- const contracts = inspectUnitContracts(options, suppliedProgram);
47
- const program = suppliedProgram ?? contracts.program ?? ts.createProgram([path.join(dsRoot, options.config.publicEntry), path.join(dsRoot, options.config.reviewEntry), ...files], { ...projectCompilerOptions(options), allowJs: true });
48
- 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);
49
70
  const duplicate = apis.find((item, index) => apis.some((other, otherIndex) => index !== otherIndex && item.name === other.name));
50
- 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]));
51
72
  const checker = program.getTypeChecker();
52
- const declarativeParts = inspectRuntimeContracts(options, program).parts;
53
- const contractDeclarations=inspectUnitContracts(options).contracts;
54
- const bindingTrace = contractDeclarations.some(contract=>contract.paintInputs?.length) ? createScenarioTrace(program, options) : null;
55
- const behaviorApis = new Map(publicApi(program, options).filter(item => !item.renderable && item.behavioral).map(item => [item.name, item]));
56
- const tokenInventory = inspectTokens(root, options);
57
- const tokenNames = new Set(tokenInventory.tokens.map(token => token.name));
58
- 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);
59
80
  const scenarioGroup = createScenarioGroups(options);
60
81
  const scenarios = [];
61
- 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
+ ];
62
87
  const ids = new Set();
63
88
  function report(file, message, node, detail = {}) {
64
89
  const position = node?.getSourceFile().getLineAndCharacterOfPosition(node.getStart());
65
- 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
+ });
66
98
  }
67
- 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
+ );
68
104
  for (const file of files) {
69
105
  const relative = path.relative(dsRoot, file).replaceAll("\\", "/");
70
106
  let kind = isInside(path.join(dsRoot, options.config.tokenDir), file) ? "tokens" : relative.split("/")[0];
71
- 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
+ }
72
111
  let id = scenarioIdentity(file, dsRoot);
73
- const source = program.getSourceFile(file);
74
- 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
+ }
75
117
  let metadata, metadataExpression;
76
118
  let entry = false;
77
119
  for (const node of source.statements) {
78
120
  if (ts.isExportAssignment(node) || node.modifiers?.some((item) => item.kind === ts.SyntaxKind.DefaultKeyword)) entry = true;
79
121
  if (ts.isVariableStatement(node) && node.modifiers?.some((item) => item.kind === ts.SyntaxKind.ExportKeyword)) {
80
- 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
+ }
81
127
  }
82
128
  }
83
- if(metadata?.id!==undefined) {
84
- const owner=units.owner(relative);
85
- 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"});
86
- 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;
87
150
  }
88
- if (id.length > 256) { report(file, "Scenario paths must fit within 256 characters."); continue; }
89
- if (ids.has(id)) { report(file, `Duplicate scenario id ${id}. Use one entrypoint per identity.`); continue; }
90
151
  ids.add(id);
91
152
  if (metadata?.kind !== undefined) {
92
153
  const owner = units.owner(relative);
93
- 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
+ );
94
161
  else kind = "tokens";
95
162
  }
96
163
  if (!entry) report(file, "Export a default independently mountable scenario entrypoint.");
97
- const module = checker.getSymbolAtLocation(source);
98
- 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");
99
166
  if (defaultExport) {
100
- const type = checker.getTypeOfSymbolAtLocation(defaultExport, source);
101
- const calls = [...type.getCallSignatures(), ...type.getConstructSignatures()];
102
- 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.");
103
171
  for (const call of calls) {
104
172
  const props = call.parameters[0];
105
- const optional = props?.declarations?.some(item => item.initializer || item.questionToken);
106
- 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.");
107
180
  }
108
181
  }
109
- const fixtureBase = path.basename(file).startsWith("Scenario.") ? path.join(path.dirname(file), "fixture") : file.replace(/\.scenario\.[^.]+$/, ".fixture");
110
- const fixture = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs", ".json"].map(extension => fixtureBase + extension).find(existsSync);
111
- if (!fixture) report(file, "Keep this scenario's inputs beside it: fixture.ts (directory entry) or <Owner>.fixture.ts (flat entry). An empty fixture is valid for a component without inputs.");
112
- function entryNode(field, index) {
182
+ const fixtureBase = file.replace(/\.ads\.scenario\.[^.]+$/, ".ads.fixture");
183
+ const fixture = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs", ".json"].map((extension) => fixtureBase + extension).find(existsSync);
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.");
185
+ async function entryNode(field, index) {
113
186
  let value = metadataExpression;
114
187
  const seen = new Set();
115
188
  while (value && !seen.has(value)) {
116
189
  seen.add(value);
117
190
  if (ts.isSatisfiesExpression(value) || ts.isAsExpression(value) || ts.isParenthesizedExpression(value)) value = value.expression;
118
- else if (ts.isIdentifier(value)) { let symbol = checker.getSymbolAtLocation(value); if (symbol?.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol); value = symbol?.valueDeclaration?.initializer; }
119
- 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;
120
196
  }
121
- 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);
122
- 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);
123
206
  }
124
207
  if (!metadata) {
125
- 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
+ );
126
214
  continue;
127
215
  }
128
- 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 });
129
219
  const group = scenarioGroup(file, units.owner(relative));
130
- if(typeof metadata.title!=="string"||!metadata.title.trim()) {
131
- report(file,"Scenario title must be a nonempty static string; independent render evidence is retained.",entryNode("title"),{entry:"title"});
132
- 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;
133
223
  }
134
- if(!Array.isArray(metadata.covers)||!metadata.covers.length) {
135
- 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)});
136
- 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 = [];
137
232
  }
138
- if(Object.hasOwn(metadata,"tokens")&&(!Array.isArray(metadata.tokens)||metadata.tokens.some(name=>typeof name!=="string"||!name.startsWith("--")))) {
139
- 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 = [];
140
239
  }
141
- if(kind==="tokens"&&Object.hasOwn(metadata,"tokens")||kind==="tokens"&&!validTokenSamples(metadata.samples)||Object.hasOwn(metadata,"samples")&&!validTokenSamples(metadata.samples)) {
142
- 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;
143
252
  }
144
253
  const covers = [];
145
254
  for (const [index, name] of metadata.covers.entries()) {
146
255
  const api = typeof name === "string" && known.get(name);
147
- 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
+ );
148
263
  else covers.push(name);
149
264
  }
150
265
  metadata = { ...metadata, covers };
151
- 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"));
152
268
  // A bad behavioral entry must fail validation without erasing independent
153
269
  // render evidence and manufacturing missing-coverage errors for real UI.
154
270
  const exercises = [];
155
271
  let captureTargets;
156
272
  if (Object.hasOwn(metadata, "captureTargets")) {
157
- 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
+ );
158
286
  else captureTargets = metadata.captureTargets;
159
287
  }
160
288
  if (Object.hasOwn(metadata, "exercises")) {
161
289
  if (!Array.isArray(metadata.exercises)) report(file, "Scenario exercises must be a static array naming public behavioral APIs.");
162
- else for (const [index, name] of metadata.exercises.entries()) {
163
- 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}]` });
164
- 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 });
165
- else exercises.push(name);
166
- }
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
+ }
167
308
  }
168
- 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.");
169
- const tokens = [...new Set([...(metadata.tokens ?? []), ...(metadata.samples ?? []).map(sample => sample.token)])];
170
- 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
+ });
171
321
  if (kind === "tokens") {
172
322
  const owner = units.owner(relative);
173
- 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
+ );
174
329
  }
175
330
 
176
331
  const reachable = new Set(metadata.covers);
177
- 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); }
178
- if(bindingTrace) findBindings(source);
179
- 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)}));
180
- const paintAudit=contractDeclarations.some(contract=>contract.paintInputs?.some(input=>reachable.has(input.apiName)));
181
- 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);
182
391
  }
183
- 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 };
184
393
  }
185
394
 
186
- export function inspectScenarioCoverage(options, program, report, advise = () => {}, trace = createScenarioTrace(program, options)) {
187
- const registry = inspectScenarios(options, program);
188
- 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);
189
400
  const checker = program.getTypeChecker();
190
- const ui = publicUi(program, options);
191
- const parts = inspectRuntimeContracts(options, program).parts;
192
- function symbolOf(expression) {
193
- 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;
194
409
  if (!expression) return null;
195
410
  if (ts.isElementAccessExpression(expression) && expression.argumentExpression && ts.isStringLiteralLike(expression.argumentExpression)) {
196
- return checker.getPropertyOfType(checker.getTypeAtLocation(expression.expression), expression.argumentExpression.text);
411
+ return checker.getPropertyOfType(await checker.getTypeAtLocation(expression.expression), expression.argumentExpression.text);
197
412
  }
198
413
  return checker.getSymbolAtLocation(expression);
199
414
  }
200
- function canonical(symbol, seen = new Set()) {
415
+ async function canonical(symbol, seen = new Set()) {
201
416
  if (!symbol || seen.has(symbol)) return null;
202
417
  seen.add(symbol);
203
- 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);
204
419
  for (const declaration of symbol.declarations ?? []) {
205
420
  if (ts.isVariableDeclaration(declaration) && declaration.initializer) {
206
- const target = symbolOf(declaration.initializer);
421
+ const target = await symbolOf(declaration.initializer);
207
422
  if (target) return canonical(target, seen);
208
423
  }
209
424
  if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent) && ts.isVariableDeclaration(declaration.parent.parent)) {
210
425
  const initializer = declaration.parent.parent.initializer;
211
426
  const key = declaration.propertyName ?? declaration.name;
212
427
  if (initializer && (ts.isIdentifier(key) || ts.isStringLiteralLike(key))) {
213
- const target = checker.getPropertyOfType(checker.getTypeAtLocation(initializer), key.text);
428
+ const target = await checker.getPropertyOfType(await checker.getTypeAtLocation(initializer), key.text);
214
429
  if (target) return canonical(target, seen);
215
430
  }
216
431
  }
217
432
  }
218
433
  return symbol.declarations?.length ? symbol : null;
219
434
  }
220
- const identities = new Map(), behaviorIdentities = new Set();
221
- 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)) {
222
438
  if (!identities.has(item.declaration)) identities.set(item.declaration, new Set());
223
439
  identities.get(item.declaration).add(item.name);
224
440
  if (item.behavioral && !item.renderable) behaviorIdentities.add(item.declaration);
@@ -226,52 +442,77 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
226
442
 
227
443
  const covered = new Set();
228
444
  const coveredTokens = new Set();
229
- const tokenInventory = inspectTokens(options.root, options);
230
- 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));
231
447
  for (const scenario of registry.scenarios) {
232
- 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));
233
453
  const rendered = new Set();
234
- const exercised = new Set(), referencedApis = new Set(), declarative = new Set();
454
+ const exercised = new Set(),
455
+ referencedApis = new Set(),
456
+ declarative = new Set();
235
457
  const referencedTokens = new Set();
236
458
  let samplesPassed = false;
237
459
  const renderLimits = new Set();
238
460
  const visited = new Set();
239
- function visit(node, reached = false) {
461
+ async function visit(node, reached = false) {
240
462
  if (!node || visited.has(node)) return;
241
463
  if (!reached && ts.isFunctionDeclaration(node)) return;
242
464
  // Calls/construction in a mounted adapter execute even when only a result
243
465
  // property is read later. Unused literal fixture fields still do not count.
244
- if (!reached && ts.isVariableDeclaration(node) && !(node.initializer && (ts.isCallExpression(node.initializer) || ts.isNewExpression(node.initializer)))) return;
245
- 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;
246
470
  visited.add(node);
247
471
  if (ts.isStringLiteralLike(node) && (isSharedToken(node.text) || scenario.tokens.includes(node.text))) referencedTokens.add(node.text);
248
472
  let expression;
249
473
  if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) expression = node.tagName;
250
- 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];
251
475
  if (expression) {
252
476
  const site = ts.isJsxOpeningElement(node) ? node.parent : node;
253
- const evidence = trace.traceRenders(site);
477
+ const evidence = await trace.traceRenders(site);
254
478
  for (const name of evidence.rendered) rendered.add(name);
255
479
  for (const reason of evidence.limits) renderLimits.add(reason);
256
- const symbol = canonical(symbolOf(expression));
480
+ const symbol = await canonical(await symbolOf(expression));
257
481
  const names = identities.get(symbol?.valueDeclaration ?? symbol?.declarations?.[0]);
258
- for (const name of names ?? []) { rendered.add(name); exercised.add(name); }
259
- if (scenario.kind === "tokens" && [...names ?? []].some(name => scenario.covers.includes(name))) {
260
- 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
+ );
261
499
  if (JSON.stringify(attributes?.samples) === JSON.stringify(scenario.samples)) samplesPassed = true;
262
500
  }
263
501
  }
264
502
  if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
265
503
  let expression = node.expression;
266
504
  if (ts.isPropertyAccessExpression(expression) && ["call", "apply"].includes(expression.name.text)) expression = expression.expression;
267
- const symbol = canonical(symbolOf(expression));
505
+ const symbol = await canonical(await symbolOf(expression));
268
506
  for (const name of identities.get(symbol?.valueDeclaration ?? symbol?.declarations?.[0]) ?? []) exercised.add(name);
269
507
  // A call on an attached method exercises its public behavioral receiver.
270
508
  // Follow symbol identities through aliases, namespaces and re-exports;
271
509
  // a property read or an unused callback still does not establish a call.
272
- 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
+ ) {
273
514
  expression = expression.expression;
274
- const receiver = canonical(symbolOf(expression));
515
+ const receiver = await canonical(await symbolOf(expression));
275
516
  const owner = receiver?.valueDeclaration ?? receiver?.declarations?.[0];
276
517
  if (behaviorIdentities.has(owner)) for (const name of identities.get(owner) ?? []) exercised.add(name);
277
518
  }
@@ -279,73 +520,97 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
279
520
  // Follow local adapters reachable from the default entry. Production
280
521
  // children get evidence only from bounded returned-JSX tracing above,
281
522
  // never by scanning every reference in their implementation.
282
- if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) || ts.isIdentifier(node) && !(ts.isPropertyAccessExpression(node.parent) || ts.isElementAccessExpression(node.parent))) {
283
- 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));
284
529
  const declaration = symbol?.valueDeclaration;
285
530
  for (const name of identities.get(declaration ?? symbol?.declarations?.[0]) ?? []) referencedApis.add(name);
286
- if (declaration && isDevelopmentFile(declaration.getSourceFile().fileName, options)) visit(declaration, true);
531
+ if (declaration && isDevelopmentFile(declaration.getSourceFile().fileName, options)) await visit(declaration, true);
287
532
  }
288
- 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))));
289
534
  }
290
- for (const node of source.statements) if (ts.isExportAssignment(node) || node.modifiers?.some(item => item.kind === ts.SyntaxKind.DefaultKeyword)) visit(node, true);
291
- 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);
292
539
  for (const name of scenario.covers) {
293
- 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
+ );
294
546
  else covered.add(name);
295
547
  }
296
548
  for (const name of scenario.exercises ?? []) {
297
- 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.`);
298
- 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.`);
299
- 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
+ );
300
567
  }
301
- for (const name of referencedTokens) if (!declaredTokens.has(name)) report(source.fileName, "token-scenario-reference", `Reachable scenario input references undeclared token ${name}.`);
302
- 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
+ );
303
576
  for (const name of scenario.tokens) {
304
- 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
+ );
305
583
  else if (scenario.kind === "tokens" && samplesPassed && declaredTokens.has(name)) coveredTokens.add(name);
306
584
  }
307
585
  }
308
- const blockedOwners=new Set(registry.diagnostics.filter(item=>item.coverage==="not-established").map(item=>item.owner));
309
- 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.`);
310
- 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))) {
311
600
  const definition = token.definitions[0];
312
- 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
+ );
313
608
  }
314
609
  }
315
610
 
316
- export function writeScenarioRegistry(options, write) {
317
- const registry = inspectScenarios(options);
611
+ export async function writeScenarioRegistry(options, write) {
612
+ const registry = await inspectScenarios(options);
318
613
  if (registry.diagnostics.length) throw new Error(registry.diagnostics.map((item) => `${item.file}: ${item.message}`).join("\n"));
319
614
  write({ schemaVersion: 1, scenarios: registry.scenarios });
320
615
  return registry.scenarios;
321
616
  }
322
-
323
- /** Locate the actual consumed array, rather than regenerating a whole fixture. */
324
- export function tokenSampleSource(options, scenario) {
325
- const file = path.join(options.root, scenario.file);
326
- const program = ts.createProgram([file], { ...projectCompilerOptions(options), allowJs:true, resolveJsonModule:true });
327
- const checker = program.getTypeChecker(), source = program.getSourceFile(file);
328
- function resolve(node, seen = new Set()) {
329
- while (node && (ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isParenthesizedExpression(node))) node = node.expression;
330
- if (!node || seen.has(node)) return null;
331
- if (ts.isArrayLiteralExpression(node) || ts.isObjectLiteralExpression(node)) return node;
332
- let symbol = checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
333
- if (symbol?.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol);
334
- const declaration = symbol?.valueDeclaration;
335
- return declaration?.initializer ? resolve(declaration.initializer, new Set([...seen,node])) : null;
336
- }
337
- for (const statement of source.statements) if (ts.isVariableStatement(statement)) for (const declaration of statement.declarationList.declarations) {
338
- if (!ts.isIdentifier(declaration.name) || declaration.name.text !== "scenario") continue;
339
- const metadata = resolve(declaration.initializer);
340
- 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");
341
- const array = property && resolve(property.initializer);
342
- if (array && ts.isArrayLiteralExpression(array)) {
343
- const source = array.getSourceFile();
344
- const units = inspectUnits(options), owner = units.owner(units.relative(scenario.file));
345
- const relative = path.relative(options.root, source.fileName).replaceAll("\\", "/");
346
- 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.");
347
- return {file:relative, content:source.text, start:array.getStart(source), end:array.end};
348
- }
349
- }
350
- throw new Error("Cannot locate a literal consumed samples array. Keep fixture.samples statically inspectable; edit other fixture shapes with a normal owner patch.");
351
- }