@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,21 +1,25 @@
1
- import ts from "typescript";
1
+ import { eachChild, flatMapAsync, forEachAsync, mapAsync } from "./analysis/queries.mjs";
2
+ import ts from "./analysis/syntax.mjs";
2
3
  import { isInside } from "./config.mjs";
3
4
  import { uiOperation } from "./ui-framework.mjs";
4
5
  import { sourceSymbol } from "./source-symbols.mjs";
6
+ import { memoProgram } from "./analysis/helpers.mjs";
5
7
 
6
- export const unknown = reason => ({ kind: "unknown", reason });
7
- export const literal = value => ({ kind: "literal", value });
8
- export const reference = (node, env = new Map(), via = []) => node ? { kind: "node", node, env, via } : literal(undefined);
9
- export const union = values => values.length === 1 ? values[0] : { kind: "union", values };
10
- export const isFunction = node => node && (ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodDeclaration(node));
11
- const nameOf = node => node && (ts.isIdentifier(node) || ts.isStringLiteralLike(node) || ts.isNumericLiteral(node)) ? node.text : undefined;
8
+ export const unknown = (reason) => ({ kind: "unknown", reason });
9
+ export const literal = (value) => ({ kind: "literal", value });
10
+ export const reference = (node, env = new Map(), via = []) => (node ? { kind: "node", node, env, via } : literal(undefined));
11
+ export const union = (values) => (values.length === 1 ? values[0] : { kind: "union", values });
12
+ export const isFunction = (node) =>
13
+ node && (ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodDeclaration(node));
14
+ const nameOf = (node) => (node && (ts.isIdentifier(node) || ts.isStringLiteralLike(node) || ts.isNumericLiteral(node)) ? node.text : undefined);
12
15
  export function unwrap(node) {
13
- while (node && (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node))) node = node.expression;
16
+ while (node && (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node)))
17
+ node = node.expression;
14
18
  return node;
15
19
  }
16
20
 
17
21
  /** Bounded symbolic source traversal. No project code is imported or executed. */
18
- export function createSourceValues(program, options, { preserveCall = () => false, strict = false } = {}) {
22
+ export function createSourceValues(program, options, { preserveCall = () => false, strict = false, completeReturns = strict } = {}) {
19
23
  const checker = program.getTypeChecker();
20
24
  const ownedFiles = new Map();
21
25
  function owned(node) {
@@ -23,99 +27,158 @@ export function createSourceValues(program, options, { preserveCall = () => fals
23
27
  if (!ownedFiles.has(file)) ownedFiles.set(file, isInside(options.dsRoot, file));
24
28
  return ownedFiles.get(file);
25
29
  }
26
- const symbol = node => {
27
- const value = sourceSymbol(checker, ts.isPropertyAccessExpression(node) ? node.name : node);
28
- return value?.valueDeclaration && ts.isShorthandPropertyAssignment(value.valueDeclaration) ? checker.getShorthandAssignmentValueSymbol(value.valueDeclaration) ?? value : value;
30
+ const symbol = async (node) => {
31
+ const value = await sourceSymbol(checker, ts.isPropertyAccessExpression(node) ? node.name : node);
32
+ return value?.valueDeclaration && ts.isShorthandPropertyAssignment(value.valueDeclaration)
33
+ ? ((await checker.getShorthandAssignmentValueSymbol(value.valueDeclaration)) ?? value)
34
+ : value;
29
35
  };
30
- function declaration(node) {
31
- let value = symbol(node);
32
- if (value?.flags & ts.SymbolFlags.Alias) value = checker.getAliasedSymbol(value);
36
+ async function declaration(node) {
37
+ let value = await symbol(node);
38
+ if (value?.flags & ts.SymbolFlags.Alias) value = await checker.getAliasedSymbol(value);
33
39
  return value?.valueDeclaration;
34
40
  }
35
- const writes = new Set(), escapes = new Set(), aliases = [];
36
- if (strict) {
37
- function root(node) {
38
- node = unwrap(node);
39
- while (node && (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node))) node = unwrap(node.expression);
40
- return node && ts.isIdentifier(node) ? symbol(node) : null;
41
- }
42
- function scan(node) {
43
- if (ts.isBinaryExpression(node) && node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment && node.operatorToken.kind <= ts.SyntaxKind.LastAssignment) writes.add(root(node.left));
44
- if ((ts.isPrefixUnaryExpression(node) || ts.isPostfixUnaryExpression(node)) && [ts.SyntaxKind.PlusPlusToken, ts.SyntaxKind.MinusMinusToken].includes(node.operator)) writes.add(root(node.operand));
45
- if (ts.isDeleteExpression(node)) writes.add(root(node.expression));
46
- if (ts.isCallExpression(node) || ts.isNewExpression(node)) for (const argument of node.arguments ?? []) {
47
- const value = unwrap(argument);
48
- if (ts.isIdentifier(value)) escapes.add(symbol(value));
41
+ let effects;
42
+ const strictEffects = async () =>
43
+ (effects ??= await memoProgram(program, `strict-source-effects:${options.dsRoot}`, async () => {
44
+ const writes = new Set(),
45
+ escapes = new Set(),
46
+ aliases = [];
47
+ async function root(node) {
48
+ node = unwrap(node);
49
+ while (node && (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node))) node = unwrap(node.expression);
50
+ return node && ts.isIdentifier(node) ? await symbol(node) : null;
49
51
  }
50
- if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer && root(node.initializer)) aliases.push([symbol(node.name), root(node.initializer)]);
51
- ts.forEachChild(node, scan);
52
- }
53
- for (const file of program.getSourceFiles()) if (isInside(options.dsRoot, file.fileName)) scan(file);
54
- const targets = new Map();
55
- for (const [alias, target] of aliases) { if (!targets.has(alias)) targets.set(alias, []); targets.get(alias).push(target); }
56
- for (const affected of [writes, escapes]) {
57
- const queue = [...affected];
58
- for (let index = 0; index < queue.length; ++index) for (const target of targets.get(queue[index]) ?? []) if (!affected.has(target)) { affected.add(target); queue.push(target); }
59
- }
60
- }
52
+ async function scan(node) {
53
+ if (ts.isBinaryExpression(node) && node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment && node.operatorToken.kind <= ts.SyntaxKind.LastAssignment)
54
+ writes.add(await root(node.left));
55
+ if (
56
+ (ts.isPrefixUnaryExpression(node) || ts.isPostfixUnaryExpression(node)) &&
57
+ [ts.SyntaxKind.PlusPlusToken, ts.SyntaxKind.MinusMinusToken].includes(node.operator)
58
+ )
59
+ writes.add(await root(node.operand));
60
+ if (ts.isDeleteExpression(node)) writes.add(await root(node.expression));
61
+ if (ts.isCallExpression(node) || ts.isNewExpression(node))
62
+ for (const argument of node.arguments ?? []) {
63
+ const value = unwrap(argument);
64
+ if (ts.isIdentifier(value)) escapes.add(await symbol(value));
65
+ }
66
+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer && (await root(node.initializer)))
67
+ aliases.push([await symbol(node.name), await root(node.initializer)]);
68
+ await eachChild(node, scan);
69
+ }
70
+ for (const file of await program.getSourceFiles()) if (isInside(options.dsRoot, file.fileName)) await scan(file);
71
+ const targets = new Map();
72
+ for (const [alias, target] of aliases) {
73
+ if (!targets.has(alias)) targets.set(alias, []);
74
+ targets.get(alias).push(target);
75
+ }
76
+ for (const affected of [writes, escapes]) {
77
+ const queue = [...affected];
78
+ for (let index = 0; index < queue.length; ++index)
79
+ for (const target of targets.get(queue[index]) ?? [])
80
+ if (!affected.has(target)) {
81
+ affected.add(target);
82
+ queue.push(target);
83
+ }
84
+ }
85
+ return { writes, escapes };
86
+ }));
61
87
  const state = () => ({ budget: { steps: 0 }, depth: 0, calls: new Set() });
62
- function next(context) { return { ...context, depth: context.depth + 1 }; }
63
- function exhausted(context) { return ++context.budget.steps > (context.maxSteps??4000) || context.depth > (context.maxDepth??48); }
88
+ function next(context) {
89
+ return { ...context, depth: context.depth + 1 };
90
+ }
91
+ function exhausted(context) {
92
+ return ++context.budget.steps > (context.maxSteps ?? 4000) || context.depth > (context.maxDepth ?? 48);
93
+ }
64
94
  function at(node, kind, name) {
65
- const source = node.getSourceFile(), position = source.getLineAndCharacterOfPosition(node.getStart(source));
95
+ const source = node.getSourceFile(),
96
+ position = source.getLineAndCharacterOfPosition(node.getStart(source));
66
97
  return { file: source.fileName, line: position.line + 1, column: position.character + 1, kind, name: name.slice(0, 100) };
67
98
  }
68
99
  function withVia(value, via) {
69
- if (value.kind === "union") return { ...value, values: value.values.map(item => withVia(item, via)) };
70
- return value.kind === "node" ? { ...value, via: [...new Map([...via, ...value.via].map(item => [JSON.stringify(item), item])).values()].slice(0, 16) } : value;
100
+ if (value.kind === "union") return { ...value, values: value.values.map((item) => withVia(item, via)) };
101
+ return value.kind === "node"
102
+ ? { ...value, via: [...new Map([...via, ...value.via].map((item) => [JSON.stringify(item), item])).values()].slice(0, 16) }
103
+ : value;
71
104
  }
72
- function withDefault(value, fallback, context) {
105
+ async function withDefault(value, fallback, context) {
73
106
  if (!fallback) return value;
74
- value = resolve(value, next(context));
107
+ value = await resolve(value, next(context));
75
108
  if (value.kind === "literal") return value.value === undefined ? fallback : value;
76
109
  if (value.kind === "unknown") return union([value, fallback]);
77
- if (value.kind === "union") return union(value.values.map(item => withDefault(item, fallback, next(context))));
110
+ if (value.kind === "union") return union(await mapAsync(value.values, async (item) => withDefault(item, fallback, next(context))));
78
111
  return value;
79
112
  }
80
- function bind(pattern, value, env, via, context) {
81
- if (ts.isIdentifier(pattern)) { env.set(symbol(pattern), value); return; }
113
+ async function bind(pattern, value, env, via, context) {
114
+ if (ts.isIdentifier(pattern)) {
115
+ env.set(await symbol(pattern), value);
116
+ return;
117
+ }
82
118
  if (ts.isObjectBindingPattern(pattern)) {
83
119
  const excluded = new Set();
84
120
  for (const part of pattern.elements) {
85
121
  const key = nameOf(part.propertyName ?? part.name);
86
- if (part.dotDotDotToken) bind(part.name, { kind: "rest", value, excluded: new Set(excluded) }, env, via, next(context));
122
+ if (part.dotDotDotToken) await bind(part.name, { kind: "rest", value, excluded: new Set(excluded) }, env, via, next(context));
87
123
  else {
88
124
  if (key === undefined) continue;
89
125
  excluded.add(key);
90
- bind(part.name, withDefault(get(value, key, next(context)), part.initializer && reference(part.initializer, env, via), context), env, via, next(context));
126
+ await bind(
127
+ part.name,
128
+ await withDefault(await get(value, key, next(context)), part.initializer && reference(part.initializer, env, via), context),
129
+ env,
130
+ via,
131
+ next(context),
132
+ );
91
133
  }
92
134
  }
93
135
  } else if (ts.isArrayBindingPattern(pattern)) {
94
- pattern.elements.forEach((part, index) => {
95
- if (ts.isBindingElement(part) && !part.dotDotDotToken) bind(part.name, withDefault(get(value, String(index), next(context)), part.initializer && reference(part.initializer, env, via), context), env, via, next(context));
136
+ await forEachAsync(pattern.elements, async (part, index) => {
137
+ if (ts.isBindingElement(part) && !part.dotDotDotToken)
138
+ await bind(
139
+ part.name,
140
+ await withDefault(await get(value, String(index), next(context)), part.initializer && reference(part.initializer, env, via), context),
141
+ env,
142
+ via,
143
+ next(context),
144
+ );
96
145
  });
97
146
  }
98
147
  }
99
- function boundElement(node, env, via, context) {
148
+ async function boundElement(node, env, via, context) {
100
149
  let owner = node;
101
150
  while (ts.isBindingElement(owner) || ts.isObjectBindingPattern(owner) || ts.isArrayBindingPattern(owner)) owner = owner.parent;
102
151
  if (!ts.isVariableDeclaration(owner) || !owner.initializer || !(owner.parent.flags & ts.NodeFlags.Const)) return unknown();
103
152
  const local = new Map(env);
104
- bind(owner.name, reference(owner.initializer, env, via), local, via, next(context));
105
- return local.get(symbol(node.name)) ?? unknown();
153
+ await bind(owner.name, reference(owner.initializer, env, via), local, via, next(context));
154
+ return local.get(await symbol(node.name)) ?? unknown();
106
155
  }
107
- function get(value, key, context) {
108
- value = resolve(value, next(context));
156
+ async function get(value, key, context) {
157
+ value = await resolve(value, next(context));
109
158
  if (strict && value.kind === "context" && key === "Provider") return { kind: "provider" };
110
- if (value.kind === "union") return union(value.values.map(item => get(item, key, next(context))));
111
- if (value.kind === "rest") return value.excluded.has(key) ? literal(undefined) : get(value.value, key, next(context));
159
+ if (value.kind === "union") return union(await mapAsync(value.values, async (item) => get(item, key, next(context))));
160
+ if (value.kind === "rest") return value.excluded.has(key) ? literal(undefined) : await get(value.value, key, next(context));
112
161
  const layers = value.kind === "object" ? value.layers : [];
113
162
  if (value.kind === "node" && ts.isObjectLiteralExpression(value.node)) {
114
163
  for (const property of value.node.properties) {
115
164
  if (ts.isSpreadAssignment(property)) layers.push(reference(property.expression, value.env, value.via));
116
165
  else {
117
166
  const name = nameOf(property.name);
118
- if (name !== undefined) layers.push(new Map([[name, strict && (ts.isGetAccessorDeclaration(property) || ts.isSetAccessorDeclaration(property)) ? unknown("An accessor is not a statically known property.") : reference(ts.isShorthandPropertyAssignment(property) ? property.name : ts.isMethodDeclaration(property) ? property : property.initializer, value.env, value.via)]]));
167
+ if (name !== undefined)
168
+ layers.push(
169
+ new Map([
170
+ [
171
+ name,
172
+ strict && (ts.isGetAccessorDeclaration(property) || ts.isSetAccessorDeclaration(property))
173
+ ? unknown("An accessor is not a statically known property.")
174
+ : reference(
175
+ ts.isShorthandPropertyAssignment(property) ? property.name : ts.isMethodDeclaration(property) ? property : property.initializer,
176
+ value.env,
177
+ value.via,
178
+ ),
179
+ ],
180
+ ]),
181
+ );
119
182
  else if (strict) layers.push(unknown("A computed object key may replace the selected property."));
120
183
  }
121
184
  }
@@ -124,132 +187,207 @@ export function createSourceValues(program, options, { preserveCall = () => fals
124
187
  } else if (value.kind !== "object") return unknown(value.reason);
125
188
  for (let index = layers.length - 1; index >= 0; index--) {
126
189
  const layer = layers[index];
127
- if (layer instanceof Map) { if (layer.has(key)) return layer.get(key); }
128
- else {
129
- const selected = get(layer, key, next(context));
190
+ if (layer instanceof Map) {
191
+ if (layer.has(key)) return layer.get(key);
192
+ } else {
193
+ const selected = await get(layer, key, next(context));
130
194
  if (selected.kind === "literal" && selected.value === undefined) continue;
131
195
  // An opaque later spread may replace an earlier explicit property.
132
- if (selected.kind === "unknown" || selected.kind === "union") return union([selected, get({ kind: "object", layers: layers.slice(0, index) }, key, next(context))]);
196
+ if (selected.kind === "unknown" || selected.kind === "union")
197
+ return union([selected, await get({ kind: "object", layers: layers.slice(0, index) }, key, next(context))]);
133
198
  return selected;
134
199
  }
135
200
  }
136
201
  return literal(undefined);
137
202
  }
138
- function keys(value, context) {
139
- value = resolve(value, next(context));
140
- if (value.kind === "union") return [...new Set(value.values.flatMap(item => keys(item, next(context))))];
141
- if (value.kind === "rest") return keys(value.value, next(context)).filter(key => !value.excluded.has(key));
142
- if (value.kind === "node" && ts.isObjectLiteralExpression(value.node)) return value.node.properties.flatMap(property => ts.isSpreadAssignment(property) ? keys(reference(property.expression, value.env, value.via), next(context)) : nameOf(property.name) ?? []);
143
- if (value.kind === "object") return [...new Set(value.layers.flatMap(layer => layer instanceof Map ? [...layer.keys()] : keys(layer, next(context))))];
203
+ async function keys(value, context) {
204
+ value = await resolve(value, next(context));
205
+ if (value.kind === "union") return [...new Set(await flatMapAsync(value.values, async (item) => keys(item, next(context))))];
206
+ if (value.kind === "rest") return (await keys(value.value, next(context))).filter((key) => !value.excluded.has(key));
207
+ if (value.kind === "node" && ts.isObjectLiteralExpression(value.node))
208
+ return flatMapAsync(value.node.properties, async (property) =>
209
+ ts.isSpreadAssignment(property) ? await keys(reference(property.expression, value.env, value.via), next(context)) : (nameOf(property.name) ?? []),
210
+ );
211
+ if (value.kind === "object")
212
+ return [...new Set(await flatMapAsync(value.layers, async (layer) => (layer instanceof Map ? [...layer.keys()] : await keys(layer, next(context)))))];
144
213
  return [];
145
214
  }
146
- function returns(fn, args, context, kind = "helper") {
147
- if (kind!=="component"&&context.calls.has(fn.node)) return [unknown("Recursive local call could not be fully traced.")];
148
- if (!fn.node.body || fn.node.asteriskToken || fn.node.modifiers?.some(item => item.kind === ts.SyntaxKind.AsyncKeyword)) return [unknown("Async, generator or declaration-only calls are outside atomic source tracing.")];
149
- const env = new Map(fn.env), via = [...fn.via, at(fn.node, kind, fn.node.name?.getText() ?? "local function")];
150
- const inner = { ...next(context), calls: new Set(kind==="component"?[fn.node]:[...context.calls, fn.node]) };
215
+ async function returns(fn, args, context, kind = "helper") {
216
+ if (kind !== "component" && context.calls.has(fn.node)) return [unknown("Recursive local call could not be fully traced.")];
217
+ if (!fn.node.body || fn.node.asteriskToken || fn.node.modifiers?.some((item) => item.kind === ts.SyntaxKind.AsyncKeyword))
218
+ return [unknown("Async, generator or declaration-only calls are outside atomic source tracing.")];
219
+ const env = new Map(fn.env),
220
+ via = [...fn.via, at(fn.node, kind, fn.node.name?.getText() ?? "local function")];
221
+ const inner = { ...next(context), calls: new Set(kind === "component" ? [fn.node] : [...context.calls, fn.node]) };
151
222
  for (const [index, parameter] of fn.node.parameters.entries()) {
152
- if (parameter.dotDotDotToken) { bind(parameter.name, { kind: "array", values: args.slice(index) }, env, via, inner); break; }
153
- bind(parameter.name, withDefault(resolve(args[index] ?? literal(undefined), inner), parameter.initializer && reference(parameter.initializer, env, via), inner), env, via, inner);
223
+ if (parameter.dotDotDotToken) {
224
+ await bind(parameter.name, { kind: "array", values: args.slice(index) }, env, via, inner);
225
+ break;
226
+ }
227
+ await bind(
228
+ parameter.name,
229
+ await withDefault(await resolve(args[index] ?? literal(undefined), inner), parameter.initializer && reference(parameter.initializer, env, via), inner),
230
+ env,
231
+ via,
232
+ inner,
233
+ );
154
234
  }
155
235
  const outputs = [];
156
- function statement(node) {
157
- if (ts.isReturnStatement(node)) { outputs.push(reference(node.expression, env, via)); return true; }
158
- if (ts.isBlock(node)) { for (const child of node.statements) if (statement(child)) return true; }
159
- else if (ts.isIfStatement(node)) {
160
- const condition = resolve(reference(node.expression, env, via), inner);
161
- if (condition.kind === "literal") return condition.value ? statement(node.thenStatement) : node.elseStatement ? statement(node.elseStatement) : false;
162
- const left = statement(node.thenStatement), right = node.elseStatement ? statement(node.elseStatement) : false;
236
+ async function statement(node) {
237
+ if (ts.isReturnStatement(node)) {
238
+ outputs.push(reference(node.expression, env, via));
239
+ return true;
240
+ }
241
+ if (ts.isBlock(node)) {
242
+ for (const child of node.statements) if (await statement(child)) return true;
243
+ } else if (ts.isIfStatement(node)) {
244
+ const condition = await resolve(reference(node.expression, env, via), inner);
245
+ if (condition.kind === "literal")
246
+ return condition.value ? await statement(node.thenStatement) : node.elseStatement ? await statement(node.elseStatement) : false;
247
+ const left = await statement(node.thenStatement),
248
+ right = node.elseStatement ? await statement(node.elseStatement) : false;
163
249
  return left && right;
164
- } else if (ts.isThrowStatement(node)) { if (strict) outputs.push(unknown("A throwing branch does not establish a returned value.")); return true; }
165
- else if (ts.isIterationStatement(node, false) || ts.isSwitchStatement(node) || ts.isTryStatement(node)) outputs.push(unknown("Loop, switch or try control flow could not be fully traced."));
250
+ } else if (ts.isThrowStatement(node)) {
251
+ if (completeReturns) outputs.push(unknown("A throwing branch does not establish a returned value."));
252
+ return true;
253
+ } else if (ts.isIterationStatement(node, false) || ts.isSwitchStatement(node) || ts.isTryStatement(node))
254
+ outputs.push(unknown("Loop, switch or try control flow could not be fully traced."));
166
255
  return false;
167
256
  }
168
- if (ts.isBlock(fn.node.body)) { if (!statement(fn.node.body) && strict) outputs.push(literal(undefined)); }
169
- else outputs.push(reference(fn.node.body, env, via));
257
+ if (ts.isBlock(fn.node.body)) {
258
+ if (!(await statement(fn.node.body)) && completeReturns) outputs.push(literal(undefined));
259
+ } else outputs.push(reference(fn.node.body, env, via));
170
260
  // Keep call stacks with lazy return references, including nested helpers.
171
- return outputs.length ? outputs.map(value => ({ ...value, context: inner })) : [literal(undefined)];
261
+ return outputs.length ? outputs.map((value) => ({ ...value, context: inner })) : [literal(undefined)];
172
262
  }
173
- function resolve(value, context) {
263
+ async function resolve(value, context) {
174
264
  if (!value) return literal(undefined);
175
265
  context = value.context ?? context;
176
266
  if (exhausted(context)) return unknown("Atomic source tracing reached its depth or work limit.");
177
267
  if (value.kind !== "node") return value;
178
- const node = unwrap(value.node), { env, via } = value;
179
- if (ts.isStringLiteralLike(node) || ts.isNumericLiteral(node)) return { ...literal(ts.isNumericLiteral(node) ? Number(node.text) : node.text), ...(strict ? { origin: node, via } : {}) };
268
+ const node = unwrap(value.node),
269
+ { env, via } = value;
270
+ if (ts.isStringLiteralLike(node) || ts.isNumericLiteral(node))
271
+ return { ...literal(ts.isNumericLiteral(node) ? Number(node.text) : node.text), ...(strict ? { origin: node, via } : {}) };
180
272
  if (node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword) return literal(node.kind === ts.SyntaxKind.TrueKeyword);
181
273
  if (node.kind === ts.SyntaxKind.NullKeyword) return literal(null);
182
274
  if (ts.isIdentifier(node)) {
183
- if (strict && writes.has(symbol(node))) return unknown("A written binding or object is not a statically known value.");
184
- if (strict && ["Fragment", "StrictMode"].includes(uiOperation(node, checker))) return { kind: "provider" };
185
- if (env.has(symbol(node))) {
186
- const result = resolve(env.get(symbol(node)), next(context));
187
- return strict && escapes.has(symbol(node)) && (result.kind === "object" || result.kind === "array" || result.kind === "node" && (ts.isObjectLiteralExpression(result.node) || ts.isArrayLiteralExpression(result.node))) ? unknown("An object passed to another call may have been mutated.") : result;
275
+ if (strict && (await strictEffects()).writes.has(await symbol(node))) return unknown("A written binding or object is not a statically known value.");
276
+ if (strict && ["Fragment", "StrictMode"].includes(await uiOperation(node, checker))) return { kind: "provider" };
277
+ if (env.has(await symbol(node))) {
278
+ const result = await resolve(env.get(await symbol(node)), next(context));
279
+ return strict &&
280
+ (await strictEffects()).escapes.has(await symbol(node)) &&
281
+ (result.kind === "object" ||
282
+ result.kind === "array" ||
283
+ (result.kind === "node" && (ts.isObjectLiteralExpression(result.node) || ts.isArrayLiteralExpression(result.node))))
284
+ ? unknown("An object passed to another call may have been mutated.")
285
+ : result;
188
286
  }
189
- const owner = declaration(node);
287
+ const owner = await declaration(node);
190
288
  if (owner && owned(owner)) {
191
289
  if (isFunction(owner)) return reference(owner, env, via);
192
290
  if (ts.isVariableDeclaration(owner) && owner.initializer && owner.parent.flags & ts.NodeFlags.Const) {
193
- const result = resolve(reference(owner.initializer, env, via), next(context));
194
- return strict && escapes.has(symbol(node)) && (result.kind === "object" || result.kind === "array" || result.kind === "node" && (ts.isObjectLiteralExpression(result.node) || ts.isArrayLiteralExpression(result.node))) ? unknown("An object passed to another call may have been mutated.") : result;
291
+ const result = await resolve(reference(owner.initializer, env, via), next(context));
292
+ return strict &&
293
+ (await strictEffects()).escapes.has(await symbol(node)) &&
294
+ (result.kind === "object" ||
295
+ result.kind === "array" ||
296
+ (result.kind === "node" && (ts.isObjectLiteralExpression(result.node) || ts.isArrayLiteralExpression(result.node))))
297
+ ? unknown("An object passed to another call may have been mutated.")
298
+ : result;
195
299
  }
196
- if (ts.isBindingElement(owner)) return resolve(boundElement(owner, env, via, context), next(context));
300
+ if (ts.isBindingElement(owner)) return resolve(await boundElement(owner, env, via, context), next(context));
197
301
  }
198
302
  return node.text === "undefined" && !owner ? literal(undefined) : unknown();
199
303
  }
200
304
  if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
201
- const key = ts.isPropertyAccessExpression(node) ? literal(node.name.text) : resolve(reference(node.argumentExpression, env, via), next(context));
305
+ const key = ts.isPropertyAccessExpression(node) ? literal(node.name.text) : await resolve(reference(node.argumentExpression, env, via), next(context));
202
306
  const object = reference(node.expression, env, via);
203
307
  if (key.kind === "literal") {
204
- const selected = get(object, String(key.value), next(context));
205
- const owner = declaration(node);
308
+ const selected = await get(object, String(key.value), next(context));
309
+ const owner = await declaration(node);
206
310
  if (selected.kind === "unknown" && owner && owned(owner)) {
207
311
  if (isFunction(owner)) return reference(owner, env, via);
208
- if (ts.isVariableDeclaration(owner) && owner.initializer && owner.parent.flags & ts.NodeFlags.Const) return resolve(reference(owner.initializer, env, via), next(context));
312
+ if (ts.isVariableDeclaration(owner) && owner.initializer && owner.parent.flags & ts.NodeFlags.Const)
313
+ return resolve(reference(owner.initializer, env, via), next(context));
209
314
  }
210
315
  return resolve(selected, next(context));
211
316
  }
212
- const names = keys(object, next(context));
317
+ const names = await keys(object, next(context));
213
318
  if (strict) return unknown("A dynamic property selection is not a statically known value.");
214
- return names.length ? union(names.map(name => get(object, name, next(context)))) : unknown();
319
+ return names.length ? resolve(union(await mapAsync(names, async (name) => get(object, name, next(context)))), next(context)) : unknown();
215
320
  }
216
321
  if (ts.isConditionalExpression(node)) {
217
- const condition = resolve(reference(node.condition, env, via), next(context));
218
- return condition.kind === "literal" ? resolve(reference(condition.value ? node.whenTrue : node.whenFalse, env, via), next(context)) : union([reference(node.whenTrue, env, via), reference(node.whenFalse, env, via)]);
322
+ const condition = await resolve(reference(node.condition, env, via), next(context));
323
+ return condition.kind === "literal"
324
+ ? await resolve(reference(condition.value ? node.whenTrue : node.whenFalse, env, via), next(context))
325
+ : union([reference(node.whenTrue, env, via), reference(node.whenFalse, env, via)]);
219
326
  }
220
327
  if (ts.isBinaryExpression(node)) {
221
- const left = resolve(reference(node.left, env, via), next(context)), right = reference(node.right, env, via), operator = node.operatorToken.kind;
222
- if (operator === ts.SyntaxKind.AmpersandAmpersandToken) return left.kind === "literal" ? left.value ? right : literal(undefined) : union([literal(undefined), right]);
223
- if (operator === ts.SyntaxKind.BarBarToken) return left.kind === "literal" ? left.value ? left : right : union([left, right]);
224
- if (operator === ts.SyntaxKind.QuestionQuestionToken) return left.kind === "literal" ? left.value == null ? right : left : union([left, right]);
225
- const other = resolve(right, next(context));
226
- if (left.kind === "literal" && other.kind === "literal" && [ts.SyntaxKind.EqualsEqualsEqualsToken, ts.SyntaxKind.ExclamationEqualsEqualsToken].includes(operator)) return literal(operator === ts.SyntaxKind.EqualsEqualsEqualsToken ? left.value === other.value : left.value !== other.value);
328
+ const left = await resolve(reference(node.left, env, via), next(context)),
329
+ right = reference(node.right, env, via),
330
+ operator = node.operatorToken.kind;
331
+ if (operator === ts.SyntaxKind.AmpersandAmpersandToken)
332
+ return left.kind === "literal" ? (left.value ? right : literal(undefined)) : union([literal(undefined), right]);
333
+ if (operator === ts.SyntaxKind.BarBarToken) return left.kind === "literal" ? (left.value ? left : right) : union([left, right]);
334
+ if (operator === ts.SyntaxKind.QuestionQuestionToken) return left.kind === "literal" ? (left.value == null ? right : left) : union([left, right]);
335
+ const other = await resolve(right, next(context));
336
+ if (
337
+ left.kind === "literal" &&
338
+ other.kind === "literal" &&
339
+ [ts.SyntaxKind.EqualsEqualsEqualsToken, ts.SyntaxKind.ExclamationEqualsEqualsToken].includes(operator)
340
+ )
341
+ return literal(operator === ts.SyntaxKind.EqualsEqualsEqualsToken ? left.value === other.value : left.value !== other.value);
227
342
  }
228
343
  if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) {
229
- const operand = resolve(reference(node.operand, env, via), next(context));
344
+ const operand = await resolve(reference(node.operand, env, via), next(context));
230
345
  return operand.kind === "literal" ? literal(!operand.value) : unknown();
231
346
  }
232
- if (ts.isCallExpression(node) && !preserveCall(node.expression)) {
233
- if (strict && uiOperation(node.expression, checker) === "createContext") return { kind: "context" };
234
- if (["memo", "forwardRef"].includes(uiOperation(node.expression, checker))) return resolve(reference(node.arguments[0], env, via), next(context));
235
- const fn = resolve(reference(node.expression, env, via), next(context));
347
+ if (ts.isCallExpression(node) && !(await preserveCall(node.expression))) {
348
+ if (strict && (await uiOperation(node.expression, checker)) === "createContext") return { kind: "context" };
349
+ if (["memo", "forwardRef"].includes(await uiOperation(node.expression, checker))) return resolve(reference(node.arguments[0], env, via), next(context));
350
+ const fn = await resolve(reference(node.expression, env, via), next(context));
236
351
  if (fn.kind === "node" && isFunction(fn.node)) {
237
- const outputs = returns(fn, node.arguments.map(argument => reference(argument, env, via)), next(context));
238
- return withVia(resolve(union(outputs), next(context)), outputs.flatMap(item => item.via ?? []));
352
+ const outputs = await returns(
353
+ fn,
354
+ node.arguments.map((argument) => reference(argument, env, via)),
355
+ next(context),
356
+ );
357
+ return withVia(
358
+ await resolve(union(outputs), next(context)),
359
+ outputs.flatMap((item) => item.via ?? []),
360
+ );
239
361
  }
240
362
  return unknown(`Call ${node.expression.getText().slice(0, 80)} could not be traced to a local function.`);
241
363
  }
242
364
  return { ...value, node };
243
365
  }
244
- function arrays(value, context) {
245
- value = resolve(value, next(context));
366
+ async function arrays(value, context) {
367
+ value = await resolve(value, next(context));
246
368
  if (value.kind === "array") return value.values;
247
- if (value.kind === "node" && ts.isArrayLiteralExpression(value.node)) return value.node.elements.map(node => reference(node, value.env, value.via));
369
+ if (value.kind === "node" && ts.isArrayLiteralExpression(value.node)) return value.node.elements.map((node) => reference(node, value.env, value.via));
248
370
  return null;
249
371
  }
250
372
 
251
373
  function props(node, env = new Map(), via = []) {
252
- return { kind: "object", layers: node.attributes.properties.map(attribute => ts.isJsxSpreadAttribute(attribute) ? reference(attribute.expression, env, via) : new Map([[attribute.name.text, attribute.initializer ? ts.isJsxExpression(attribute.initializer) ? reference(attribute.initializer.expression, env, via) : reference(attribute.initializer, env, via) : literal(true)]])) };
374
+ return {
375
+ kind: "object",
376
+ layers: node.attributes.properties.map((attribute) =>
377
+ ts.isJsxSpreadAttribute(attribute)
378
+ ? reference(attribute.expression, env, via)
379
+ : new Map([
380
+ [
381
+ attribute.name.text,
382
+ attribute.initializer
383
+ ? ts.isJsxExpression(attribute.initializer)
384
+ ? reference(attribute.initializer.expression, env, via)
385
+ : reference(attribute.initializer, env, via)
386
+ : literal(true),
387
+ ],
388
+ ]),
389
+ ),
390
+ };
253
391
  }
254
392
  return { state, next, at, resolve, get, keys, arrays, returns, props, declaration };
255
393
  }