@antheo/morph 0.0.0-stage → 0.3.0

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 (464) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -2
  3. package/SKILL.md +61 -0
  4. package/dist/ai/cli-provider.d.ts +80 -0
  5. package/dist/ai/cli-provider.js +250 -0
  6. package/dist/ai/gate.d.ts +39 -0
  7. package/dist/ai/gate.js +124 -0
  8. package/dist/ai/provider.d.ts +36 -0
  9. package/dist/ai/provider.js +168 -0
  10. package/dist/ai/repair.d.ts +90 -0
  11. package/dist/ai/repair.js +172 -0
  12. package/dist/analyzer/deps.d.ts +30 -0
  13. package/dist/analyzer/deps.js +265 -0
  14. package/dist/analyzer/manifest.d.ts +5 -0
  15. package/dist/analyzer/manifest.js +119 -0
  16. package/dist/analyzer/parse.d.ts +21 -0
  17. package/dist/analyzer/parse.js +29 -0
  18. package/dist/batch-worker.d.ts +16 -0
  19. package/dist/batch-worker.js +10 -0
  20. package/dist/batch.d.ts +26 -0
  21. package/dist/batch.js +227 -0
  22. package/dist/bridge/index.d.ts +26 -0
  23. package/dist/bridge/index.js +138 -0
  24. package/dist/bridge/props.d.ts +56 -0
  25. package/dist/bridge/props.js +191 -0
  26. package/dist/bridge/wrappers.d.ts +24 -0
  27. package/dist/bridge/wrappers.js +276 -0
  28. package/dist/cli/format.d.ts +7 -0
  29. package/dist/cli/format.js +30 -0
  30. package/dist/cli.d.ts +2 -0
  31. package/dist/cli.js +492 -0
  32. package/dist/fonts/carry.d.ts +34 -0
  33. package/dist/fonts/carry.js +113 -0
  34. package/dist/fonts/fallback.d.ts +11 -0
  35. package/dist/fonts/fallback.js +21 -0
  36. package/dist/fonts/google.d.ts +65 -0
  37. package/dist/fonts/google.js +343 -0
  38. package/dist/fonts/index.d.ts +27 -0
  39. package/dist/fonts/index.js +48 -0
  40. package/dist/fonts/local.d.ts +46 -0
  41. package/dist/fonts/local.js +150 -0
  42. package/dist/fonts/sfnt.d.ts +19 -0
  43. package/dist/fonts/sfnt.js +174 -0
  44. package/dist/fonts/shim.d.ts +14 -0
  45. package/dist/fonts/shim.js +96 -0
  46. package/dist/gate.d.ts +105 -0
  47. package/dist/gate.js +157 -0
  48. package/dist/index.d.ts +55 -0
  49. package/dist/index.js +74 -0
  50. package/dist/ir/annotate.d.ts +16 -0
  51. package/dist/ir/annotate.js +145 -0
  52. package/dist/ir/as-child.d.ts +18 -0
  53. package/dist/ir/as-child.js +239 -0
  54. package/dist/ir/compounds.d.ts +27 -0
  55. package/dist/ir/compounds.js +183 -0
  56. package/dist/ir/contexts.d.ts +26 -0
  57. package/dist/ir/contexts.js +185 -0
  58. package/dist/ir/dom.d.ts +11 -0
  59. package/dist/ir/dom.js +60 -0
  60. package/dist/ir/effect-returns.d.ts +10 -0
  61. package/dist/ir/effect-returns.js +25 -0
  62. package/dist/ir/extract-ui-types.d.ts +33 -0
  63. package/dist/ir/extract-ui-types.js +224 -0
  64. package/dist/ir/extract-ui.d.ts +34 -0
  65. package/dist/ir/extract-ui.js +567 -0
  66. package/dist/ir/falsy.d.ts +13 -0
  67. package/dist/ir/falsy.js +66 -0
  68. package/dist/ir/forward-refs.d.ts +11 -0
  69. package/dist/ir/forward-refs.js +155 -0
  70. package/dist/ir/fragment-source.d.ts +4 -0
  71. package/dist/ir/fragment-source.js +13 -0
  72. package/dist/ir/fragments.d.ts +32 -0
  73. package/dist/ir/fragments.js +192 -0
  74. package/dist/ir/helper-snippets.d.ts +30 -0
  75. package/dist/ir/helper-snippets.js +550 -0
  76. package/dist/ir/latest-refs.d.ts +11 -0
  77. package/dist/ir/latest-refs.js +187 -0
  78. package/dist/ir/live-args.d.ts +26 -0
  79. package/dist/ir/live-args.js +335 -0
  80. package/dist/ir/lower.d.ts +83 -0
  81. package/dist/ir/lower.js +6016 -0
  82. package/dist/ir/markup-values.d.ts +16 -0
  83. package/dist/ir/markup-values.js +188 -0
  84. package/dist/ir/model.d.ts +605 -0
  85. package/dist/ir/model.js +1 -0
  86. package/dist/ir/oracle.d.ts +91 -0
  87. package/dist/ir/oracle.js +610 -0
  88. package/dist/ir/radix.d.ts +122 -0
  89. package/dist/ir/radix.js +344 -0
  90. package/dist/ir/rename.d.ts +15 -0
  91. package/dist/ir/rename.js +151 -0
  92. package/dist/ir/render-props.d.ts +31 -0
  93. package/dist/ir/render-props.js +67 -0
  94. package/dist/ir/rewrite.d.ts +44 -0
  95. package/dist/ir/rewrite.js +381 -0
  96. package/dist/ir/running-index.d.ts +11 -0
  97. package/dist/ir/running-index.js +217 -0
  98. package/dist/ir/snapshots.d.ts +12 -0
  99. package/dist/ir/snapshots.js +140 -0
  100. package/dist/ir/style.d.ts +19 -0
  101. package/dist/ir/style.js +76 -0
  102. package/dist/ir/types.d.ts +42 -0
  103. package/dist/ir/types.js +271 -0
  104. package/dist/ir/walk.d.ts +11 -0
  105. package/dist/ir/walk.js +18 -0
  106. package/dist/mcp/server.d.ts +81 -0
  107. package/dist/mcp/server.js +518 -0
  108. package/dist/pipeline.d.ts +26 -0
  109. package/dist/pipeline.js +750 -0
  110. package/dist/registry/add.d.ts +91 -0
  111. package/dist/registry/add.js +273 -0
  112. package/dist/registry/fetch.d.ts +40 -0
  113. package/dist/registry/fetch.js +186 -0
  114. package/dist/registry/ip.d.ts +18 -0
  115. package/dist/registry/ip.js +153 -0
  116. package/dist/registry/item.d.ts +39 -0
  117. package/dist/registry/item.js +131 -0
  118. package/dist/registry/load.d.ts +35 -0
  119. package/dist/registry/load.js +106 -0
  120. package/dist/registry/paths.d.ts +8 -0
  121. package/dist/registry/paths.js +43 -0
  122. package/dist/registry/publish.d.ts +119 -0
  123. package/dist/registry/publish.js +439 -0
  124. package/dist/targets/angular/bank/bank.d.ts +39 -0
  125. package/dist/targets/angular/bank/bank.js +61 -0
  126. package/dist/targets/angular/bank/helpers.d.ts +64 -0
  127. package/dist/targets/angular/bank/helpers.js +246 -0
  128. package/dist/targets/angular/bank/kept.d.ts +98 -0
  129. package/dist/targets/angular/bank/kept.js +791 -0
  130. package/dist/targets/angular/bank/plan-helpers.d.ts +17 -0
  131. package/dist/targets/angular/bank/plan-helpers.js +286 -0
  132. package/dist/targets/angular/bank/plan.d.ts +22 -0
  133. package/dist/targets/angular/bank/plan.js +152 -0
  134. package/dist/targets/angular/bank/receivers.d.ts +66 -0
  135. package/dist/targets/angular/bank/receivers.js +293 -0
  136. package/dist/targets/angular/bank/runtime.d.ts +14 -0
  137. package/dist/targets/angular/bank/runtime.js +152 -0
  138. package/dist/targets/angular/controlled.d.ts +7 -0
  139. package/dist/targets/angular/controlled.js +37 -0
  140. package/dist/targets/angular/dynamic-tags.d.ts +34 -0
  141. package/dist/targets/angular/dynamic-tags.js +192 -0
  142. package/dist/targets/angular/emit.d.ts +41 -0
  143. package/dist/targets/angular/emit.js +5970 -0
  144. package/dist/targets/angular/exports.d.ts +48 -0
  145. package/dist/targets/angular/exports.js +243 -0
  146. package/dist/targets/angular/helpers.d.ts +15 -0
  147. package/dist/targets/angular/helpers.js +33 -0
  148. package/dist/targets/angular/host-boundary.d.ts +5 -0
  149. package/dist/targets/angular/host-boundary.js +166 -0
  150. package/dist/targets/angular/host-form.d.ts +150 -0
  151. package/dist/targets/angular/host-form.js +727 -0
  152. package/dist/targets/angular/markup-values.d.ts +58 -0
  153. package/dist/targets/angular/markup-values.js +661 -0
  154. package/dist/targets/angular/motion-directive.d.ts +12 -0
  155. package/dist/targets/angular/motion-directive.js +257 -0
  156. package/dist/targets/angular/motion-hooks.d.ts +73 -0
  157. package/dist/targets/angular/motion-hooks.js +293 -0
  158. package/dist/targets/angular/motion-layout.d.ts +14 -0
  159. package/dist/targets/angular/motion-layout.js +74 -0
  160. package/dist/targets/angular/motion-templates.d.ts +10 -0
  161. package/dist/targets/angular/motion-templates.js +65 -0
  162. package/dist/targets/angular/motion.d.ts +57 -0
  163. package/dist/targets/angular/motion.js +202 -0
  164. package/dist/targets/angular/narrowing.d.ts +24 -0
  165. package/dist/targets/angular/narrowing.js +205 -0
  166. package/dist/targets/angular/ngc.d.ts +23 -0
  167. package/dist/targets/angular/ngc.js +134 -0
  168. package/dist/targets/angular/passed-handle.d.ts +39 -0
  169. package/dist/targets/angular/passed-handle.js +154 -0
  170. package/dist/targets/angular/projected.d.ts +9 -0
  171. package/dist/targets/angular/projected.js +63 -0
  172. package/dist/targets/angular/radix/cores/alert-dialog.d.ts +13 -0
  173. package/dist/targets/angular/radix/cores/alert-dialog.js +388 -0
  174. package/dist/targets/angular/radix/cores/index.d.ts +17 -0
  175. package/dist/targets/angular/radix/cores/index.js +50 -0
  176. package/dist/targets/angular/radix/cores/slider.d.ts +8 -0
  177. package/dist/targets/angular/radix/cores/slider.js +202 -0
  178. package/dist/targets/angular/radix/index.d.ts +21 -0
  179. package/dist/targets/angular/radix/index.js +35 -0
  180. package/dist/targets/angular/radix/packages.d.ts +3 -0
  181. package/dist/targets/angular/radix/packages.js +558 -0
  182. package/dist/targets/angular/radix/part.d.ts +236 -0
  183. package/dist/targets/angular/radix/part.js +71 -0
  184. package/dist/targets/angular/radix/prepare.d.ts +66 -0
  185. package/dist/targets/angular/radix/prepare.js +548 -0
  186. package/dist/targets/angular/radix/template.d.ts +43 -0
  187. package/dist/targets/angular/radix/template.js +172 -0
  188. package/dist/targets/angular/refs.d.ts +68 -0
  189. package/dist/targets/angular/refs.js +443 -0
  190. package/dist/targets/angular/slots.d.ts +22 -0
  191. package/dist/targets/angular/slots.js +60 -0
  192. package/dist/targets/angular/source-types.d.ts +10 -0
  193. package/dist/targets/angular/source-types.js +45 -0
  194. package/dist/targets/angular/spread-forward.d.ts +24 -0
  195. package/dist/targets/angular/spread-forward.js +72 -0
  196. package/dist/targets/angular/spread.d.ts +32 -0
  197. package/dist/targets/angular/spread.js +182 -0
  198. package/dist/targets/angular/svg-hosts.d.ts +25 -0
  199. package/dist/targets/angular/svg-hosts.js +107 -0
  200. package/dist/targets/angular/template-expr.d.ts +36 -0
  201. package/dist/targets/angular/template-expr.js +287 -0
  202. package/dist/targets/angular/types.d.ts +9 -0
  203. package/dist/targets/angular/types.js +63 -0
  204. package/dist/targets/angular/walk.d.ts +11 -0
  205. package/dist/targets/angular/walk.js +26 -0
  206. package/dist/targets/react-native/emit.d.ts +14 -0
  207. package/dist/targets/react-native/emit.js +585 -0
  208. package/dist/targets/react-native/fidelity.d.ts +5 -0
  209. package/dist/targets/react-native/fidelity.js +43 -0
  210. package/dist/targets/react-native/motion.d.ts +10 -0
  211. package/dist/targets/react-native/motion.js +290 -0
  212. package/dist/targets/react-native/skia.d.ts +30 -0
  213. package/dist/targets/react-native/skia.js +358 -0
  214. package/dist/targets/shared/context.d.ts +47 -0
  215. package/dist/targets/shared/context.js +195 -0
  216. package/dist/targets/shared/foreign.d.ts +10 -0
  217. package/dist/targets/shared/foreign.js +72 -0
  218. package/dist/targets/shared/fragments.d.ts +21 -0
  219. package/dist/targets/shared/fragments.js +309 -0
  220. package/dist/targets/shared/handles.d.ts +65 -0
  221. package/dist/targets/shared/handles.js +299 -0
  222. package/dist/targets/shared/inline.d.ts +53 -0
  223. package/dist/targets/shared/inline.js +524 -0
  224. package/dist/targets/shared/layout.d.ts +70 -0
  225. package/dist/targets/shared/layout.js +224 -0
  226. package/dist/targets/shared/markup.d.ts +26 -0
  227. package/dist/targets/shared/markup.js +65 -0
  228. package/dist/targets/shared/module.d.ts +84 -0
  229. package/dist/targets/shared/module.js +468 -0
  230. package/dist/targets/shared/motion-hooks.d.ts +37 -0
  231. package/dist/targets/shared/motion-hooks.js +87 -0
  232. package/dist/targets/shared/motion-layout.d.ts +70 -0
  233. package/dist/targets/shared/motion-layout.js +392 -0
  234. package/dist/targets/shared/portal.d.ts +10 -0
  235. package/dist/targets/shared/portal.js +23 -0
  236. package/dist/targets/shared/prop-writes.d.ts +11 -0
  237. package/dist/targets/shared/prop-writes.js +32 -0
  238. package/dist/targets/shared/prune.d.ts +54 -0
  239. package/dist/targets/shared/prune.js +405 -0
  240. package/dist/targets/shared/react-libs.d.ts +25 -0
  241. package/dist/targets/shared/react-libs.js +142 -0
  242. package/dist/targets/shared/react-types.d.ts +16 -0
  243. package/dist/targets/shared/react-types.js +374 -0
  244. package/dist/targets/shared/react-values.d.ts +20 -0
  245. package/dist/targets/shared/react-values.js +145 -0
  246. package/dist/targets/shared/ref-callback.d.ts +16 -0
  247. package/dist/targets/shared/ref-callback.js +114 -0
  248. package/dist/targets/shared/script.d.ts +65 -0
  249. package/dist/targets/shared/script.js +406 -0
  250. package/dist/targets/shared/unused.d.ts +12 -0
  251. package/dist/targets/shared/unused.js +146 -0
  252. package/dist/targets/svelte/dom-spread.d.ts +27 -0
  253. package/dist/targets/svelte/dom-spread.js +146 -0
  254. package/dist/targets/svelte/emit.d.ts +15 -0
  255. package/dist/targets/svelte/emit.js +3784 -0
  256. package/dist/targets/svelte/handle-branches.d.ts +22 -0
  257. package/dist/targets/svelte/handle-branches.js +146 -0
  258. package/dist/targets/svelte/html-keys.d.ts +9 -0
  259. package/dist/targets/svelte/html-keys.js +40 -0
  260. package/dist/targets/svelte/markup-data/data.d.ts +51 -0
  261. package/dist/targets/svelte/markup-data/data.js +305 -0
  262. package/dist/targets/svelte/markup-data/helper.d.ts +12 -0
  263. package/dist/targets/svelte/markup-data/helper.js +81 -0
  264. package/dist/targets/svelte/markup-data/module-data.d.ts +21 -0
  265. package/dist/targets/svelte/markup-data/module-data.js +473 -0
  266. package/dist/targets/svelte/markup-data/sites.d.ts +52 -0
  267. package/dist/targets/svelte/markup-data/sites.js +303 -0
  268. package/dist/targets/svelte/motion-layout.d.ts +13 -0
  269. package/dist/targets/svelte/motion-layout.js +70 -0
  270. package/dist/targets/svelte/motion-table.d.ts +14 -0
  271. package/dist/targets/svelte/motion-table.js +308 -0
  272. package/dist/targets/svelte/motion.d.ts +46 -0
  273. package/dist/targets/svelte/motion.js +405 -0
  274. package/dist/targets/svelte/presence.d.ts +71 -0
  275. package/dist/targets/svelte/presence.js +318 -0
  276. package/dist/targets/svelte/radix/accordion.d.ts +9 -0
  277. package/dist/targets/svelte/radix/accordion.js +24 -0
  278. package/dist/targets/svelte/radix/aspect-ratio.d.ts +6 -0
  279. package/dist/targets/svelte/radix/aspect-ratio.js +8 -0
  280. package/dist/targets/svelte/radix/avatar.d.ts +6 -0
  281. package/dist/targets/svelte/radix/avatar.js +10 -0
  282. package/dist/targets/svelte/radix/checkbox.d.ts +10 -0
  283. package/dist/targets/svelte/radix/checkbox.js +24 -0
  284. package/dist/targets/svelte/radix/collapsible.d.ts +7 -0
  285. package/dist/targets/svelte/radix/collapsible.js +16 -0
  286. package/dist/targets/svelte/radix/context-menu.d.ts +8 -0
  287. package/dist/targets/svelte/radix/context-menu.js +49 -0
  288. package/dist/targets/svelte/radix/cores/alert-dialog.d.ts +17 -0
  289. package/dist/targets/svelte/radix/cores/alert-dialog.js +449 -0
  290. package/dist/targets/svelte/radix/cores/collapsible.d.ts +12 -0
  291. package/dist/targets/svelte/radix/cores/collapsible.js +214 -0
  292. package/dist/targets/svelte/radix/cores/core.d.ts +32 -0
  293. package/dist/targets/svelte/radix/cores/core.js +80 -0
  294. package/dist/targets/svelte/radix/cores/direction.d.ts +10 -0
  295. package/dist/targets/svelte/radix/cores/direction.js +64 -0
  296. package/dist/targets/svelte/radix/cores/index.d.ts +19 -0
  297. package/dist/targets/svelte/radix/cores/index.js +85 -0
  298. package/dist/targets/svelte/radix/cores/modal-layer.d.ts +11 -0
  299. package/dist/targets/svelte/radix/cores/modal-layer.js +244 -0
  300. package/dist/targets/svelte/radix/cores/presence.d.ts +12 -0
  301. package/dist/targets/svelte/radix/cores/presence.js +129 -0
  302. package/dist/targets/svelte/radix/cores/slider-logic.d.ts +10 -0
  303. package/dist/targets/svelte/radix/cores/slider-logic.js +287 -0
  304. package/dist/targets/svelte/radix/cores/slider.d.ts +13 -0
  305. package/dist/targets/svelte/radix/cores/slider.js +267 -0
  306. package/dist/targets/svelte/radix/dialog.d.ts +8 -0
  307. package/dist/targets/svelte/radix/dialog.js +20 -0
  308. package/dist/targets/svelte/radix/dropdown-menu.d.ts +9 -0
  309. package/dist/targets/svelte/radix/dropdown-menu.js +38 -0
  310. package/dist/targets/svelte/radix/emit.d.ts +12 -0
  311. package/dist/targets/svelte/radix/emit.js +1339 -0
  312. package/dist/targets/svelte/radix/hover-card.d.ts +7 -0
  313. package/dist/targets/svelte/radix/hover-card.js +22 -0
  314. package/dist/targets/svelte/radix/index.d.ts +12 -0
  315. package/dist/targets/svelte/radix/index.js +28 -0
  316. package/dist/targets/svelte/radix/label.d.ts +3 -0
  317. package/dist/targets/svelte/radix/label.js +5 -0
  318. package/dist/targets/svelte/radix/menubar.d.ts +7 -0
  319. package/dist/targets/svelte/radix/menubar.js +34 -0
  320. package/dist/targets/svelte/radix/navigation-menu.d.ts +8 -0
  321. package/dist/targets/svelte/radix/navigation-menu.js +25 -0
  322. package/dist/targets/svelte/radix/packages.d.ts +34 -0
  323. package/dist/targets/svelte/radix/packages.js +100 -0
  324. package/dist/targets/svelte/radix/part.d.ts +161 -0
  325. package/dist/targets/svelte/radix/part.js +85 -0
  326. package/dist/targets/svelte/radix/popover.d.ts +7 -0
  327. package/dist/targets/svelte/radix/popover.js +15 -0
  328. package/dist/targets/svelte/radix/progress.d.ts +11 -0
  329. package/dist/targets/svelte/radix/progress.js +27 -0
  330. package/dist/targets/svelte/radix/radio-group.d.ts +9 -0
  331. package/dist/targets/svelte/radix/radio-group.js +26 -0
  332. package/dist/targets/svelte/radix/scroll-area.d.ts +7 -0
  333. package/dist/targets/svelte/radix/scroll-area.js +19 -0
  334. package/dist/targets/svelte/radix/select.d.ts +13 -0
  335. package/dist/targets/svelte/radix/select.js +81 -0
  336. package/dist/targets/svelte/radix/separator.d.ts +3 -0
  337. package/dist/targets/svelte/radix/separator.js +5 -0
  338. package/dist/targets/svelte/radix/slider.d.ts +6 -0
  339. package/dist/targets/svelte/radix/slider.js +8 -0
  340. package/dist/targets/svelte/radix/switch.d.ts +6 -0
  341. package/dist/targets/svelte/radix/switch.js +10 -0
  342. package/dist/targets/svelte/radix/tabs.d.ts +8 -0
  343. package/dist/targets/svelte/radix/tabs.js +15 -0
  344. package/dist/targets/svelte/radix/toggle-group.d.ts +9 -0
  345. package/dist/targets/svelte/radix/toggle-group.js +17 -0
  346. package/dist/targets/svelte/radix/toggle.d.ts +6 -0
  347. package/dist/targets/svelte/radix/toggle.js +9 -0
  348. package/dist/targets/svelte/radix/tooltip.d.ts +6 -0
  349. package/dist/targets/svelte/radix/tooltip.js +24 -0
  350. package/dist/targets/svelte/strip.d.ts +2 -0
  351. package/dist/targets/svelte/strip.js +5 -0
  352. package/dist/targets/vue/emit.d.ts +15 -0
  353. package/dist/targets/vue/emit.js +4092 -0
  354. package/dist/targets/vue/events.d.ts +11 -0
  355. package/dist/targets/vue/events.js +13 -0
  356. package/dist/targets/vue/module-builders.d.ts +28 -0
  357. package/dist/targets/vue/module-builders.js +258 -0
  358. package/dist/targets/vue/motion-layout.d.ts +19 -0
  359. package/dist/targets/vue/motion-layout.js +79 -0
  360. package/dist/targets/vue/motion.d.ts +12 -0
  361. package/dist/targets/vue/motion.js +46 -0
  362. package/dist/targets/vue/radix/accordion.d.ts +3 -0
  363. package/dist/targets/vue/radix/accordion.js +12 -0
  364. package/dist/targets/vue/radix/alert-dialog.d.ts +6 -0
  365. package/dist/targets/vue/radix/alert-dialog.js +18 -0
  366. package/dist/targets/vue/radix/aspect-ratio.d.ts +6 -0
  367. package/dist/targets/vue/radix/aspect-ratio.js +8 -0
  368. package/dist/targets/vue/radix/avatar.d.ts +3 -0
  369. package/dist/targets/vue/radix/avatar.js +7 -0
  370. package/dist/targets/vue/radix/checkbox.d.ts +3 -0
  371. package/dist/targets/vue/radix/checkbox.js +9 -0
  372. package/dist/targets/vue/radix/collapsible.d.ts +7 -0
  373. package/dist/targets/vue/radix/collapsible.js +11 -0
  374. package/dist/targets/vue/radix/context-menu.d.ts +3 -0
  375. package/dist/targets/vue/radix/context-menu.js +30 -0
  376. package/dist/targets/vue/radix/dialog.d.ts +3 -0
  377. package/dist/targets/vue/radix/dialog.js +12 -0
  378. package/dist/targets/vue/radix/direction.d.ts +7 -0
  379. package/dist/targets/vue/radix/direction.js +9 -0
  380. package/dist/targets/vue/radix/dropdown-menu.d.ts +3 -0
  381. package/dist/targets/vue/radix/dropdown-menu.js +29 -0
  382. package/dist/targets/vue/radix/hover-card.d.ts +3 -0
  383. package/dist/targets/vue/radix/hover-card.js +11 -0
  384. package/dist/targets/vue/radix/index.d.ts +65 -0
  385. package/dist/targets/vue/radix/index.js +225 -0
  386. package/dist/targets/vue/radix/label.d.ts +3 -0
  387. package/dist/targets/vue/radix/label.js +5 -0
  388. package/dist/targets/vue/radix/menubar.d.ts +6 -0
  389. package/dist/targets/vue/radix/menubar.js +29 -0
  390. package/dist/targets/vue/radix/navigation-menu.d.ts +6 -0
  391. package/dist/targets/vue/radix/navigation-menu.js +21 -0
  392. package/dist/targets/vue/radix/part.d.ts +41 -0
  393. package/dist/targets/vue/radix/part.js +46 -0
  394. package/dist/targets/vue/radix/popover.d.ts +3 -0
  395. package/dist/targets/vue/radix/popover.js +11 -0
  396. package/dist/targets/vue/radix/progress.d.ts +3 -0
  397. package/dist/targets/vue/radix/progress.js +6 -0
  398. package/dist/targets/vue/radix/radio-group.d.ts +3 -0
  399. package/dist/targets/vue/radix/radio-group.js +10 -0
  400. package/dist/targets/vue/radix/scroll-area.d.ts +3 -0
  401. package/dist/targets/vue/radix/scroll-area.js +11 -0
  402. package/dist/targets/vue/radix/select.d.ts +3 -0
  403. package/dist/targets/vue/radix/select.js +29 -0
  404. package/dist/targets/vue/radix/separator.d.ts +3 -0
  405. package/dist/targets/vue/radix/separator.js +5 -0
  406. package/dist/targets/vue/radix/slider.d.ts +3 -0
  407. package/dist/targets/vue/radix/slider.js +13 -0
  408. package/dist/targets/vue/radix/switch.d.ts +3 -0
  409. package/dist/targets/vue/radix/switch.js +9 -0
  410. package/dist/targets/vue/radix/tabs.d.ts +3 -0
  411. package/dist/targets/vue/radix/tabs.js +12 -0
  412. package/dist/targets/vue/radix/toggle-group.d.ts +3 -0
  413. package/dist/targets/vue/radix/toggle-group.js +10 -0
  414. package/dist/targets/vue/radix/toggle.d.ts +3 -0
  415. package/dist/targets/vue/radix/toggle.js +8 -0
  416. package/dist/targets/vue/radix/tooltip.d.ts +3 -0
  417. package/dist/targets/vue/radix/tooltip.js +14 -0
  418. package/dist/targets/vue/render-fn/h.d.ts +52 -0
  419. package/dist/targets/vue/render-fn/h.js +442 -0
  420. package/dist/targets/vue/render-fn.d.ts +21 -0
  421. package/dist/targets/vue/render-fn.js +357 -0
  422. package/dist/targets/vue/slot.d.ts +9 -0
  423. package/dist/targets/vue/slot.js +57 -0
  424. package/dist/typecheck/host.d.ts +45 -0
  425. package/dist/typecheck/host.js +309 -0
  426. package/dist/typecheck/index.d.ts +16 -0
  427. package/dist/typecheck/index.js +17 -0
  428. package/dist/typecheck/lucide.d.ts +8 -0
  429. package/dist/typecheck/lucide.js +45 -0
  430. package/dist/typecheck/sourcemap.d.ts +9 -0
  431. package/dist/typecheck/sourcemap.js +54 -0
  432. package/dist/typecheck/svelte.d.ts +9 -0
  433. package/dist/typecheck/svelte.js +116 -0
  434. package/dist/typecheck/vue.d.ts +8 -0
  435. package/dist/typecheck/vue.js +78 -0
  436. package/dist/types.d.ts +446 -0
  437. package/dist/types.js +11 -0
  438. package/dist/utils/cleanup.d.ts +32 -0
  439. package/dist/utils/cleanup.js +119 -0
  440. package/dist/utils/errors.d.ts +7 -0
  441. package/dist/utils/errors.js +15 -0
  442. package/dist/utils/fs-safe.d.ts +14 -0
  443. package/dist/utils/fs-safe.js +64 -0
  444. package/dist/validate.d.ts +16 -0
  445. package/dist/validate.js +204 -0
  446. package/dist/verify/auto-steps.d.ts +107 -0
  447. package/dist/verify/auto-steps.js +471 -0
  448. package/dist/verify/bundle.d.ts +68 -0
  449. package/dist/verify/bundle.js +548 -0
  450. package/dist/verify/diff.d.ts +31 -0
  451. package/dist/verify/diff.js +133 -0
  452. package/dist/verify/leaks.d.ts +25 -0
  453. package/dist/verify/leaks.js +261 -0
  454. package/dist/verify/link-worker.d.ts +1 -0
  455. package/dist/verify/link-worker.js +27 -0
  456. package/dist/verify/runner.d.ts +57 -0
  457. package/dist/verify/runner.js +867 -0
  458. package/dist/verify/sandbox.d.ts +40 -0
  459. package/dist/verify/sandbox.js +496 -0
  460. package/dist/verify/steps.d.ts +42 -0
  461. package/dist/verify/steps.js +475 -0
  462. package/dist/verify/verdict.d.ts +15 -0
  463. package/dist/verify/verdict.js +19 -0
  464. package/package.json +118 -4
@@ -0,0 +1,21 @@
1
+ import type { FragmentDef, ModuleIR } from '../../../ir/model.js';
2
+ import type { WebContext } from '../../shared/module.js';
3
+ /** The template's value node reads elements module code holds as data: drawn by MarkupView. */
4
+ export declare function drawsModuleData(node: object): boolean;
5
+ export interface ModuleDataPlan {
6
+ /** the module names whose code is written as data */
7
+ names: string[];
8
+ /** the sites, as render helpers of the module the file of sites prints as snippets */
9
+ sites: FragmentDef[];
10
+ /** a site draws a child value through MarkupView */
11
+ view: boolean;
12
+ /** the code names `Markup` once committed (a type React wrote as ReactNode) */
13
+ type(): boolean;
14
+ /** rewrites the statements (records in place of elements) and marks the template reads drawn by MarkupView */
15
+ commit(): void;
16
+ }
17
+ /**
18
+ * Plans the module's statements that build elements as data. Nothing changes until `commit`; null when none can be.
19
+ * `taken`: every name the module and its components use (the site names are added to it).
20
+ */
21
+ export declare function planModuleData(mod: ModuleIR, ctx: WebContext, reactNames: ReadonlySet<string>, taken: Set<string>): ModuleDataPlan | null;
@@ -0,0 +1,473 @@
1
+ import * as t from '@babel/types';
2
+ import { lowerModuleFragments } from '../../../ir/lower.js';
3
+ import { moduleLets } from '../../shared/script.js';
4
+ import { MARKUP_ELEMENT_TYPE, MARKUP_TYPE, MARKUP_VIEW } from './helper.js';
5
+ import { markupTypes, planSites, textType } from './sites.js';
6
+ /**
7
+ * Elements that module code builds (Svelte, markup as data): a table of elements (`const DOODLES = [<path/>, …]`), a
8
+ * table of functions that return one (`(g) => <g/>`), a function that builds them in statements (`marked(text, ranges)`
9
+ * pushing `<mark>`s and strings). The code stays as written, each element a record (see sites.ts); the sites become
10
+ * snippets of a file of their own, `<Main>Elements.svelte`, exported from its module script, which the main file's
11
+ * module script imports (a snippet of the main file itself would be declared after the module code that reads it).
12
+ *
13
+ * Only where every read is known: the value is not exported, no module code, hook or component script reads it, and a
14
+ * component's markup reads it (or a loop item over it) only as a child, drawn by MarkupView as React draws a child, or
15
+ * in places that do not render it (a DOM element's attribute, a test, a key). Anything else keeps its module-jsx error.
16
+ */
17
+ /** The template nodes drawn through MarkupView, as the Svelte template finds them. */
18
+ const drawn = new WeakSet();
19
+ /** The template's value node reads elements module code holds as data: drawn by MarkupView. */
20
+ export function drawsModuleData(node) {
21
+ return drawn.has(node);
22
+ }
23
+ const isJsx = (n) => t.isJSXElement(n) || t.isJSXFragment(n);
24
+ function containsJsx(node) {
25
+ let found = false;
26
+ t.traverseFast(node, (n) => {
27
+ if (isJsx(n))
28
+ found = true;
29
+ });
30
+ return found;
31
+ }
32
+ /** The identifiers an expression reads (references only: not a member's property or an object's key). */
33
+ function referencedNodes(node) {
34
+ const out = [];
35
+ t.traverse(node, (n, ancestors) => {
36
+ if (!t.isIdentifier(n))
37
+ return;
38
+ const parent = ancestors[ancestors.length - 1]?.node;
39
+ const grand = ancestors[ancestors.length - 2]?.node;
40
+ if (!parent || t.isReferenced(n, parent, grand))
41
+ out.push(n);
42
+ });
43
+ return out;
44
+ }
45
+ /** The names an expression reads (references only: not a member's property or an object's key). */
46
+ function referenced(node) {
47
+ const out = new Set();
48
+ for (const n of referencedNodes(node))
49
+ out.add(n.name);
50
+ return out;
51
+ }
52
+ /** Every name any source node under `value` mentions (the IR's own objects walked through). */
53
+ function mentioned(value, names, out, seen) {
54
+ if (typeof value !== 'object' || value === null || seen.has(value))
55
+ return;
56
+ seen.add(value);
57
+ if (t.isNode(value)) {
58
+ t.traverseFast(value, (n) => {
59
+ if (t.isIdentifier(n) && names.has(n.name))
60
+ out.add(n.name);
61
+ });
62
+ return;
63
+ }
64
+ if (value instanceof Map) {
65
+ for (const v of value.values())
66
+ mentioned(v, names, out, seen);
67
+ return;
68
+ }
69
+ if (Array.isArray(value)) {
70
+ for (const v of value)
71
+ mentioned(v, names, out, seen);
72
+ return;
73
+ }
74
+ for (const v of Object.values(value))
75
+ mentioned(v, names, out, seen);
76
+ }
77
+ /** A name in SCREAMING_CASE as a camelCase prefix (`DOODLES` → `doodles`, `STICKER_SET` → `stickerSet`). */
78
+ function prefixOf(name) {
79
+ if (!/^[A-Z0-9_]+$/.test(name))
80
+ return name;
81
+ return name.toLowerCase().replace(/_+([a-z0-9])/g, (_, c) => c.toUpperCase());
82
+ }
83
+ /** Reads React at run time (outside types): a factory of components, or a test of elements. */
84
+ function readsReact(stmt, reactNames) {
85
+ let found = false;
86
+ const visit = (n) => {
87
+ if (found || n.type.startsWith('TS'))
88
+ return;
89
+ if (t.isIdentifier(n) && reactNames.has(n.name))
90
+ found = true;
91
+ for (const key of t.VISITOR_KEYS[n.type] ?? []) {
92
+ if (key === 'typeAnnotation' || key === 'returnType' || key === 'typeParameters' || key === 'typeArguments')
93
+ continue;
94
+ const value = Reflect.get(n, key);
95
+ for (const child of Array.isArray(value) ? value : [value])
96
+ if (t.isNode(child))
97
+ visit(child);
98
+ }
99
+ };
100
+ visit(stmt);
101
+ return found;
102
+ }
103
+ /**
104
+ * Every function in the statement changes nothing outside itself and reads no module `let`: a template re-runs a call
105
+ * when what it reads changes, which is not React's count of renders, so a call must give the same value and leave
106
+ * nothing behind however often it runs (`let calls = 0; function badge() { calls += 1; … }` does not). A call of
107
+ * another function of the module that fails this fails it too; other calls are not looked into.
108
+ */
109
+ function effectFree(stmt, mutable, impure) {
110
+ let ok = true;
111
+ // each outermost function of the statement, with everything declared inside it (a nested callback's locals are its
112
+ // locals too: `forEach(([s, e]) => { at = e; })` writes the outer function's own `at`; a nested callback's parameters
113
+ // count as parameters: they may be reassigned, not written through)
114
+ const outermost = [];
115
+ const find = (n) => {
116
+ if (t.isFunction(n)) {
117
+ outermost.push(n);
118
+ return;
119
+ }
120
+ for (const key of t.VISITOR_KEYS[n.type] ?? []) {
121
+ const child = Reflect.get(n, key);
122
+ for (const c of Array.isArray(child) ? child : [child])
123
+ if (t.isNode(c))
124
+ find(c);
125
+ }
126
+ };
127
+ find(stmt);
128
+ for (const fn of outermost) {
129
+ if (!ok)
130
+ break;
131
+ const own = new Set();
132
+ const params = new Set();
133
+ for (const p of fn.params)
134
+ for (const n of Object.keys(t.getBindingIdentifiers(p)))
135
+ params.add(n);
136
+ t.traverseFast(fn.body, (n) => {
137
+ if (t.isVariableDeclarator(n))
138
+ for (const name of Object.keys(t.getBindingIdentifiers(n.id)))
139
+ own.add(name);
140
+ if (t.isFunctionDeclaration(n) && n.id)
141
+ own.add(n.id.name);
142
+ if (t.isFunction(n))
143
+ for (const p of n.params)
144
+ for (const name of Object.keys(t.getBindingIdentifiers(p)))
145
+ params.add(name);
146
+ });
147
+ const root = (e) => {
148
+ let cur = e;
149
+ let member = false;
150
+ while (t.isMemberExpression(cur) || t.isOptionalMemberExpression(cur)) {
151
+ cur = cur.object;
152
+ member = true;
153
+ }
154
+ return t.isIdentifier(cur) ? { name: cur.name, member } : null;
155
+ };
156
+ t.traverseFast(fn.body, (n) => {
157
+ if (!ok)
158
+ return;
159
+ if (t.isAssignmentExpression(n) || t.isUpdateExpression(n)) {
160
+ const target = root(t.isAssignmentExpression(n) ? n.left : n.argument);
161
+ // the function's own locals, or its parameters themselves (not what they point to: the caller's objects)
162
+ if (!target || !(own.has(target.name) || (params.has(target.name) && !target.member)))
163
+ ok = false;
164
+ }
165
+ else if (t.isIdentifier(n) && mutable.has(n.name) && !own.has(n.name) && !params.has(n.name))
166
+ ok = false;
167
+ else if ((t.isCallExpression(n) || t.isOptionalCallExpression(n)) && t.isIdentifier(n.callee) && impure.has(n.callee.name))
168
+ ok = false;
169
+ });
170
+ }
171
+ return ok;
172
+ }
173
+ /** The module's functions that fail effectFree, each with the ones it calls. */
174
+ function impureFunctions(mod, mutable) {
175
+ const fns = new Map();
176
+ for (const s of mod.moduleBody) {
177
+ const d = t.isExportNamedDeclaration(s) ? s.declaration : s;
178
+ if (t.isFunctionDeclaration(d) && d.id)
179
+ fns.set(d.id.name, s);
180
+ if (t.isVariableDeclaration(d))
181
+ for (const v of d.declarations)
182
+ if (t.isIdentifier(v.id) && v.init && t.isFunction(v.init))
183
+ fns.set(v.id.name, s);
184
+ }
185
+ const impure = new Set();
186
+ for (let grew = true; grew;) {
187
+ grew = false;
188
+ for (const [name, s] of fns) {
189
+ if (impure.has(name) || effectFree(s, mutable, impure))
190
+ continue;
191
+ impure.add(name);
192
+ grew = true;
193
+ }
194
+ }
195
+ return impure;
196
+ }
197
+ /** The type may hold an element (or is not known): a read of it anywhere but where MarkupView draws it may differ. */
198
+ function mayHoldElement(type) {
199
+ if (!type)
200
+ return true;
201
+ let holds = false;
202
+ t.traverseFast(type, (n) => {
203
+ if (t.isTSTypeReference(n) || t.isTSImportType(n) || t.isTSAnyKeyword(n) || t.isTSUnknownKeyword(n) || t.isTSObjectKeyword(n) || t.isTSTypeQuery(n))
204
+ holds = true;
205
+ });
206
+ return holds;
207
+ }
208
+ /**
209
+ * Where the components' markup reads the data, and whether every read is one MarkupView draws exactly. `fails` gets the
210
+ * data names a read cannot be (passed to a component, a render helper or a slot, mixed with a snippet prop); `draws`
211
+ * the value nodes to draw.
212
+ */
213
+ function templateReads(comps, data, fails, draws, text, snippets, typeOf) {
214
+ for (const comp of comps) {
215
+ const snippetProps = new Set(comp.props.filter((p) => p.kind === 'children' || p.kind === 'node').map((p) => p.local));
216
+ /** the data an expression reads, directly or through a loop item or local over it */
217
+ const origins = (e, tainted) => {
218
+ const out = new Set();
219
+ for (const n of referenced(e)) {
220
+ if (data.has(n) || snippets.has(n))
221
+ out.add(n);
222
+ for (const o of tainted.get(n) ?? [])
223
+ out.add(o);
224
+ }
225
+ return out;
226
+ };
227
+ // (only the data's own names fail: a snippet value is not this plan's to drop)
228
+ const fail = (from) => {
229
+ for (const n of from)
230
+ if (data.has(n))
231
+ fails.add(n);
232
+ };
233
+ // a read anywhere MarkupView does not draw it: only of a value that cannot be an element (a size, a key)
234
+ const quiet = (e, tainted) => {
235
+ for (const id of referencedNodes(e)) {
236
+ if (!data.has(id.name) && !tainted.has(id.name))
237
+ continue;
238
+ if (mayHoldElement(typeOf(id)))
239
+ fail(origins(id, tainted));
240
+ }
241
+ };
242
+ const withLocals = (locals, tainted) => {
243
+ const next = new Map(tainted);
244
+ for (const l of locals) {
245
+ for (const d of l.declarations) {
246
+ const from = d.init ? origins(d.init, next) : new Set();
247
+ if (!from.size)
248
+ continue;
249
+ for (const name of Object.keys(t.getBindingIdentifiers(d.id)))
250
+ next.set(name, from);
251
+ }
252
+ }
253
+ return next;
254
+ };
255
+ const attrs = (list, component, tainted) => {
256
+ for (const a of list) {
257
+ if (a.kind === 'slotProp') {
258
+ if (a.when)
259
+ fail(origins(a.when, tainted));
260
+ if (a.render)
261
+ fail(origins(a.render, tainted));
262
+ nodes(a.children, tainted);
263
+ continue;
264
+ }
265
+ const e = a.kind === 'expr' || a.kind === 'spread' || a.kind === 'ref' || a.kind === 'style' || a.kind === 'html' ? a.expr : a.kind === 'event' ? a.handler : null;
266
+ // a DOM element's attribute renders no element (React writes it as text too); a component's prop may
267
+ if (e && component)
268
+ fail(origins(e, tainted));
269
+ else if (e)
270
+ quiet(e, tainted);
271
+ }
272
+ };
273
+ const nodes = (list, tainted) => {
274
+ for (const n of list)
275
+ node(n, tainted);
276
+ };
277
+ const node = (n, tainted) => {
278
+ switch (n.type) {
279
+ case 'text':
280
+ case 'unconverted':
281
+ return;
282
+ case 'expr': {
283
+ const from = origins(n.expr, tainted);
284
+ if (![...from].some((o) => data.has(o)))
285
+ return;
286
+ // a snippet (one the component is given, or markup the file's data holds as a snippet) has no Markup form:
287
+ // MarkupView would draw nothing for it
288
+ if ([...from].some((o) => snippets.has(o)) || [...referenced(n.expr)].some((r) => snippetProps.has(r)))
289
+ fail(from);
290
+ // text by React's types (a size read from the same row): printed as it is
291
+ else if (!text(n.expr))
292
+ draws.push(n);
293
+ else
294
+ quiet(n.expr, tainted);
295
+ return;
296
+ }
297
+ case 'element': {
298
+ const component = n.component || /^[A-Z]/.test(n.tag);
299
+ attrs(n.attrs, component, tainted);
300
+ for (const e of [...Object.values(n.motion ?? {}), ...(n.portal ? [n.portal] : []), ...(n.asChild ? [n.asChild] : [])])
301
+ fail(origins(e, tainted));
302
+ nodes(n.children, tainted);
303
+ return;
304
+ }
305
+ case 'if':
306
+ for (const b of n.branches) {
307
+ if (b.test)
308
+ quiet(b.test, tainted);
309
+ nodes(b.children, tainted);
310
+ }
311
+ return;
312
+ case 'for': {
313
+ const from = origins(n.iterable, tainted);
314
+ let inner = new Map(tainted);
315
+ if (from.size && n.item)
316
+ for (const name of Object.keys(t.getBindingIdentifiers(n.item)))
317
+ inner.set(name, from);
318
+ inner = withLocals(n.locals, inner);
319
+ if (n.key)
320
+ quiet(n.key, inner);
321
+ nodes(n.children, inner);
322
+ return;
323
+ }
324
+ case 'slot':
325
+ for (const a of n.args ?? [])
326
+ fail(origins(a, tainted));
327
+ nodes(n.fallback, tainted);
328
+ return;
329
+ case 'render':
330
+ for (const a of n.args)
331
+ fail(origins(a, tainted));
332
+ return;
333
+ case 'keyed':
334
+ quiet(n.key, tainted);
335
+ nodes(n.children, tainted);
336
+ return;
337
+ case 'fragment':
338
+ nodes(n.children, tainted);
339
+ return;
340
+ case 'presence':
341
+ attrs(n.attrs, false, tainted);
342
+ nodes(n.children, tainted);
343
+ return;
344
+ }
345
+ };
346
+ node(comp.template, new Map());
347
+ for (const f of comp.fragments)
348
+ node(f.template, withLocals(f.locals, new Map()));
349
+ for (const v of comp.markupValues ?? [])
350
+ node(v.template, new Map());
351
+ }
352
+ }
353
+ /**
354
+ * Plans the module's statements that build elements as data. Nothing changes until `commit`; null when none can be.
355
+ * `taken`: every name the module and its components use (the site names are added to it).
356
+ */
357
+ export function planModuleData(mod, ctx, reactNames, taken) {
358
+ if (!mod.components.length || [MARKUP_VIEW, MARKUP_TYPE, MARKUP_ELEMENT_TYPE].some((n) => taken.has(n)))
359
+ return null;
360
+ const statements = new Map();
361
+ const mutable = moduleLets(mod.moduleBody);
362
+ const impure = impureFunctions(mod, mutable);
363
+ for (const s of mod.moduleBody) {
364
+ if (!(t.isVariableDeclaration(s) || t.isFunctionDeclaration(s)) || !containsJsx(s) || readsReact(s, reactNames) || !effectFree(s, mutable, impure))
365
+ continue;
366
+ const names = Object.keys(t.getOuterBindingIdentifiers(s));
367
+ // exported: other files read it as a value, where nothing says how they render it
368
+ if (!names.length || names.some((n) => mod.exportedNames.has(n)))
369
+ continue;
370
+ statements.set(s, names);
371
+ }
372
+ if (!statements.size)
373
+ return null;
374
+ const imports = new Set(mod.imports.filter((d) => d.importKind !== 'type').flatMap((d) => d.specifiers.filter((s) => !(t.isImportSpecifier(s) && s.importKind === 'type')).map((s) => s.local.name)));
375
+ const typeOf = (e) => ctx.oracle?.typeOfExpression(ctx.sourceFile, e.loc) ?? null;
376
+ // markup Svelte holds as snippets: the file's data, a component's data, the file's render helpers
377
+ const snippets = new Set([...(mod.markupValues ?? []), ...mod.components.flatMap((c) => c.markupValues ?? []), ...(mod.snippetHelpers?.defs ?? [])].map((v) => v.name));
378
+ // and the module values that hold them (`const DOODLES = [doodles, doodles2]` once lowering took its elements out)
379
+ for (let grew = true; grew;) {
380
+ grew = false;
381
+ for (const s of mod.moduleBody) {
382
+ if (statements.has(s))
383
+ continue;
384
+ const reads = new Set();
385
+ mentioned(s, snippets, reads, new WeakSet());
386
+ if (!reads.size)
387
+ continue;
388
+ for (const n of Object.keys(t.getOuterBindingIdentifiers(s))) {
389
+ if (snippets.has(n))
390
+ continue;
391
+ snippets.add(n);
392
+ grew = true;
393
+ }
394
+ }
395
+ }
396
+ for (;;) {
397
+ const data = new Set([...statements.values()].flat());
398
+ const fails = new Set();
399
+ // module code that is not data, hooks, and the components' script code read it as a value they may hand on
400
+ for (const s of mod.moduleBody)
401
+ if (!statements.has(s))
402
+ mentioned(s, data, fails, new WeakSet());
403
+ mentioned(mod.hooks, data, fails, new WeakSet());
404
+ for (const c of mod.components)
405
+ mentioned([c.items, c.props, c.bindings, c.keptMarkup ?? [], c.provides], data, fails, new WeakSet());
406
+ mentioned(mod.markupValues ?? [], data, fails, new WeakSet());
407
+ mentioned(mod.snippetHelpers?.defs ?? [], data, fails, new WeakSet());
408
+ const draws = [];
409
+ templateReads(mod.components, data, fails, draws, (e) => {
410
+ const type = typeOf(e);
411
+ return type !== null && textType(type);
412
+ }, snippets, typeOf);
413
+ // a statement that reads data dropped is dropped too (it would hold a stand-in)
414
+ for (const [s, names] of statements) {
415
+ const reads = new Set();
416
+ mentioned(s, data, reads, new WeakSet());
417
+ if ([...reads].some((r) => fails.has(r) && !names.includes(r)))
418
+ for (const n of names)
419
+ fails.add(n);
420
+ }
421
+ for (const [s, names] of statements)
422
+ if (names.some((n) => fails.has(n)))
423
+ statements.delete(s);
424
+ if (fails.size) {
425
+ if (!statements.size)
426
+ return null;
427
+ continue;
428
+ }
429
+ // every read is drawn exactly: plan the sites
430
+ const planned = [];
431
+ let refused = null;
432
+ for (const [stmt, names] of statements) {
433
+ const result = planSites([stmt], {
434
+ moduleNames: imports,
435
+ motionNames: mod.motionNames,
436
+ snippetProps: new Set(),
437
+ taken: { has: (n) => taken.has(n), add: (n) => taken.add(n) },
438
+ typeOf,
439
+ prefix: prefixOf(names[0] ?? 'value'),
440
+ script: true,
441
+ });
442
+ if (!result.ok) {
443
+ refused = stmt;
444
+ break;
445
+ }
446
+ planned.push({ stmt, commit: result.commit, fns: result.sites.map((s) => [s.name, s.fn]), view: result.view });
447
+ }
448
+ if (refused) {
449
+ statements.delete(refused);
450
+ if (!statements.size)
451
+ return null;
452
+ continue;
453
+ }
454
+ const defs = lowerModuleFragments(mod, new Map(planned.flatMap((p) => p.fns)));
455
+ if (!defs)
456
+ return null;
457
+ let type = false;
458
+ return {
459
+ names: [...statements.values()].flat(),
460
+ sites: defs,
461
+ view: planned.some((p) => p.view),
462
+ type: () => type,
463
+ commit: () => {
464
+ for (const p of planned) {
465
+ p.commit();
466
+ type = markupTypes([p.stmt]) || p.view || type;
467
+ }
468
+ for (const d of draws)
469
+ drawn.add(d);
470
+ },
471
+ };
472
+ }
473
+ }
@@ -0,0 +1,52 @@
1
+ import * as t from '@babel/types';
2
+ /**
3
+ * Elements that script code builds (Svelte, markup as data). Each JSX element or fragment written in script code is a
4
+ * site: the code keeps running as written, and the site becomes a plain record, `{ draw: site, key, ...values }`, the
5
+ * values being every `{expression}` the element holds, evaluated where React evaluated them. The site itself becomes
6
+ * a snippet that reads only its record and module names: `{#snippet site(el: MarkupElement & { … })}`. A child value
7
+ * is drawn by the conversion's MarkupView, which renders it as React renders a child.
8
+ */
9
+ export interface SiteContext {
10
+ /** names the snippets may read (imports and module-level declarations): a tag must be one of these or a DOM tag */
11
+ moduleNames: ReadonlySet<string>;
12
+ /** local names bound to framer-motion's `motion` */
13
+ motionNames: ReadonlySet<string>;
14
+ /** the component's props that hold a snippet in Svelte (children, markup props): not a value a record can draw */
15
+ snippetProps: ReadonlySet<string>;
16
+ /** names already used in the file; a site name taken is added */
17
+ taken: {
18
+ has: (name: string) => boolean;
19
+ add: (name: string) => void;
20
+ };
21
+ /** the type React's checker gives the expression (null when unknown or `any`) */
22
+ typeOf: (e: t.Expression) => t.TSType | null;
23
+ /** the site names start with it (`rows` → `rowsItem`) */
24
+ prefix: string;
25
+ /** the code runs in the script (a kept value), not in markup (where a parameter's written type is dropped) */
26
+ script: boolean;
27
+ }
28
+ export interface Site {
29
+ name: string;
30
+ /** `(el: MarkupElement & { … }) => <markup>`: the site as a render helper, lowered to a snippet by the caller */
31
+ fn: t.ArrowFunctionExpression;
32
+ }
33
+ /** `view`: a site draws a child value through MarkupView (and its record type names `Markup`). */
34
+ export type SiteResult = {
35
+ ok: true;
36
+ sites: Site[];
37
+ view: boolean;
38
+ commit: () => void;
39
+ } | {
40
+ ok: false;
41
+ reason: string;
42
+ node: t.Node;
43
+ };
44
+ /** A text-like type (string, number, their literals): drawn as text, not through MarkupView. */
45
+ export declare function textType(type: t.TSType): boolean;
46
+ /**
47
+ * Plans every site in `roots` (statements or expressions): nothing changes until `commit` runs, so a refusal leaves
48
+ * the code as it was.
49
+ */
50
+ export declare function planSites(roots: t.Node[], ctx: SiteContext): SiteResult;
51
+ /** React's element types written in the code (`ReactNode`, `React.ReactElement`, `JSX.Element`) as `Markup`. */
52
+ export declare function markupTypes(roots: t.Node[]): boolean;