@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,524 @@
1
+ import * as t from '@babel/types';
2
+ import { childAt, setChildAt } from '../../ir/walk.js';
3
+ import { patternNames } from '../../ir/lower.js';
4
+ import { fold } from './fragments.js';
5
+ /** Every element of the module's templates that renders one of its own components, keyed by that component. */
6
+ export function renderSites(mod) {
7
+ const own = new Set(mod.components.map((c) => c.name));
8
+ const out = new Map();
9
+ for (const host of mod.components) {
10
+ const walk = (n, loopNames) => {
11
+ switch (n.type) {
12
+ case 'element':
13
+ if (n.component && own.has(n.tag)) {
14
+ const list = out.get(n.tag) ?? [];
15
+ list.push({ host, element: n, loopNames });
16
+ out.set(n.tag, list);
17
+ }
18
+ for (const a of n.attrs) {
19
+ if (a.kind !== 'slotProp')
20
+ continue;
21
+ // a render prop's parameters are names of its markup, as a loop's are
22
+ const inner = a.render ? new Set([...loopNames, ...a.render.params.flatMap((p) => patternNames(p))]) : loopNames;
23
+ a.children.forEach((c) => walk(c, inner));
24
+ }
25
+ n.children.forEach((c) => walk(c, loopNames));
26
+ return;
27
+ case 'if':
28
+ for (const b of n.branches)
29
+ b.children.forEach((c) => walk(c, loopNames));
30
+ return;
31
+ case 'for': {
32
+ const inner = new Set([...loopNames, ...(n.item ? patternNames(n.item) : []), ...(n.index ? [n.index] : []), ...n.locals.flatMap((l) => l.declarations.flatMap((d) => patternNames(d.id)))]);
33
+ n.children.forEach((c) => walk(c, inner));
34
+ return;
35
+ }
36
+ case 'slot':
37
+ n.fallback.forEach((c) => walk(c, loopNames));
38
+ return;
39
+ case 'fragment':
40
+ case 'keyed':
41
+ case 'presence':
42
+ n.children.forEach((c) => walk(c, loopNames));
43
+ return;
44
+ default:
45
+ return;
46
+ }
47
+ };
48
+ walk(host.template, new Set());
49
+ }
50
+ return out;
51
+ }
52
+ /** Every Babel node held anywhere in a TNode tree (attribute values, tests, keys, loop parts). */
53
+ export function templateExpressions(n, into = []) {
54
+ switch (n.type) {
55
+ case 'expr':
56
+ into.push(n.expr);
57
+ break;
58
+ case 'element':
59
+ for (const a of n.attrs) {
60
+ if (a.kind === 'expr' || a.kind === 'spread' || a.kind === 'ref' || a.kind === 'style' || a.kind === 'html')
61
+ into.push(a.expr);
62
+ else if (a.kind === 'event')
63
+ into.push(a.handler);
64
+ else if (a.kind === 'slotProp') {
65
+ if (a.when)
66
+ into.push(a.when);
67
+ a.children.forEach((c) => templateExpressions(c, into));
68
+ }
69
+ }
70
+ if (n.motion)
71
+ into.push(...Object.values(n.motion));
72
+ if (n.portal)
73
+ into.push(n.portal);
74
+ if (n.asChild)
75
+ into.push(n.asChild);
76
+ n.children.forEach((c) => templateExpressions(c, into));
77
+ break;
78
+ case 'if':
79
+ for (const b of n.branches) {
80
+ if (b.test)
81
+ into.push(b.test);
82
+ b.children.forEach((c) => templateExpressions(c, into));
83
+ }
84
+ break;
85
+ case 'for':
86
+ into.push(n.iterable, ...n.locals);
87
+ if (n.key)
88
+ into.push(n.key);
89
+ n.children.forEach((c) => templateExpressions(c, into));
90
+ break;
91
+ case 'slot':
92
+ if (n.args)
93
+ into.push(...n.args);
94
+ n.fallback.forEach((c) => templateExpressions(c, into));
95
+ break;
96
+ case 'keyed':
97
+ into.push(n.key);
98
+ n.children.forEach((c) => templateExpressions(c, into));
99
+ break;
100
+ case 'presence':
101
+ for (const a of n.attrs)
102
+ if (a.kind === 'expr' || a.kind === 'spread' || a.kind === 'style')
103
+ into.push(a.expr);
104
+ n.children.forEach((c) => templateExpressions(c, into));
105
+ break;
106
+ case 'render':
107
+ into.push(...n.args);
108
+ break;
109
+ case 'fragment':
110
+ n.children.forEach((c) => templateExpressions(c, into));
111
+ break;
112
+ default:
113
+ break;
114
+ }
115
+ return into;
116
+ }
117
+ function identifierNames(nodes) {
118
+ const out = new Set();
119
+ for (const node of nodes) {
120
+ t.traverseFast(node, (n) => {
121
+ if (t.isIdentifier(n))
122
+ out.add(n.name);
123
+ });
124
+ }
125
+ return out;
126
+ }
127
+ /** Names a template's loops declare. */
128
+ function loopNamesIn(n, into = new Set()) {
129
+ if (n.type === 'for') {
130
+ for (const name of n.item ? patternNames(n.item) : [])
131
+ into.add(name);
132
+ if (n.index)
133
+ into.add(n.index);
134
+ for (const l of n.locals)
135
+ for (const d of l.declarations)
136
+ for (const name of patternNames(d.id))
137
+ into.add(name);
138
+ }
139
+ const kids = n.type === 'if' ? n.branches.flatMap((b) => b.children) : n.type === 'slot' ? n.fallback : 'children' in n ? n.children : [];
140
+ if (n.type === 'element')
141
+ for (const a of n.attrs)
142
+ if (a.kind === 'slotProp')
143
+ a.children.forEach((c) => loopNamesIn(c, into));
144
+ kids.forEach((c) => loopNamesIn(c, into));
145
+ return into;
146
+ }
147
+ function hasNode(n, test) {
148
+ if (test(n))
149
+ return true;
150
+ const kids = n.type === 'if' ? n.branches.flatMap((b) => b.children) : n.type === 'slot' ? n.fallback : 'children' in n ? n.children : [];
151
+ if (n.type === 'element' && n.attrs.some((a) => a.kind === 'slotProp' && a.children.some((c) => hasNode(c, test))))
152
+ return true;
153
+ return kids.some((c) => hasNode(c, test));
154
+ }
155
+ /** How many nodes a template prints (a rough size, to keep Vue from copying big markup into several places). */
156
+ export function templateSize(n) {
157
+ let count = 0;
158
+ hasNode(n, () => {
159
+ count++;
160
+ return false;
161
+ });
162
+ return count;
163
+ }
164
+ /**
165
+ * Props in, markup out: no state, refs, effects, hooks or statements, and nothing the markup could not take inline.
166
+ * `isContext` says whether a name is a context the file declares (`<Theme value>`, `<Theme.Provider value>` provide it).
167
+ */
168
+ export function isPureComponent(comp, isContext = () => false) {
169
+ // a fragment belongs to its component's own markup
170
+ if (comp.propsStyle === 'object' || comp.rest || comp.forwardRef || comp.fragments.length)
171
+ return false;
172
+ for (const item of comp.items) {
173
+ if (item.kind === 'derived' && t.isIdentifier(item.id))
174
+ continue;
175
+ if (item.kind === 'function')
176
+ continue;
177
+ return false;
178
+ }
179
+ // a ref the caller passes in (`ref={inputRef}` with `inputRef` a prop) lands on the caller's own ref once written in place
180
+ const foreignRef = (a) => a.kind === 'ref' && !(t.isIdentifier(a.expr) && comp.props.some((p) => p.local === a.expr.name));
181
+ // a context provider provides from its own component instance: written in place, it would provide from the caller's.
182
+ // A context imported from another file is known once the emitter links the providers (see keepProvidersFiled).
183
+ const provider = (n) => n.component && isContext(n.tag.endsWith('.Provider') ? n.tag.slice(0, -'.Provider'.length) : n.tag);
184
+ if (comp.provides.length)
185
+ return false;
186
+ // a render prop it calls (`{actions(chosen)}`) is filled by its caller's function: a component of its own
187
+ if (hasNode(comp.template, (n) => n.type === 'slot' && !!n.args))
188
+ return false;
189
+ return !hasNode(comp.template, (n) => n.type === 'unconverted' || (n.type === 'element' && ((n.component && comp.bindings.has(n.tag)) || n.attrs.some(foreignRef) || provider(n))));
190
+ }
191
+ /** Whether the markup places a ref the caller passes (a snippet would receive the element, not the caller's ref). */
192
+ export function takesRef(comp) {
193
+ return hasNode(comp.template, (n) => n.type === 'element' && n.attrs.some((a) => a.kind === 'ref'));
194
+ }
195
+ /** The prop key a call-site attribute sets (component attributes are lowered with `class` and React event names). */
196
+ function attrKey(a) {
197
+ switch (a.kind) {
198
+ case 'static':
199
+ case 'expr':
200
+ case 'bool':
201
+ return a.name === 'class' ? 'className' : a.name;
202
+ case 'event':
203
+ return a.react;
204
+ case 'style':
205
+ return 'style';
206
+ case 'slotProp':
207
+ return a.name;
208
+ default:
209
+ return null;
210
+ }
211
+ }
212
+ /** Whether a component is referenced as a value anywhere (passed, stored, compared): then it needs a real component. */
213
+ function referencedAsValue(mod, name) {
214
+ const nodes = [...mod.moduleBody];
215
+ for (const c of [...mod.components, ...mod.hooks]) {
216
+ for (const item of c.items) {
217
+ for (const v of Object.values(item)) {
218
+ if (v && typeof v === 'object' && 'type' in v)
219
+ nodes.push(v);
220
+ else if (Array.isArray(v))
221
+ for (const x of v)
222
+ if (x && typeof x === 'object' && 'type' in x)
223
+ nodes.push(x);
224
+ }
225
+ }
226
+ }
227
+ for (const c of mod.components)
228
+ nodes.push(...templateExpressions(c.template));
229
+ return identifierNames(nodes).has(name);
230
+ }
231
+ /**
232
+ * The private components of a module that get no file: pure, used only as elements, never recursively, and safe to
233
+ * place in every host (their free names mean the same there, and no loop of theirs captures a name the caller passes).
234
+ * Vue copies markup, so a component used in several places must also be small.
235
+ */
236
+ export function inlinedComponents(mod, mode, isPrivate, contextNamed) {
237
+ const sites = renderSites(mod);
238
+ const byName = new Map(mod.components.map((c) => [c.name, c]));
239
+ // the contexts the file declares, and (when the caller can resolve them) the ones it imports
240
+ const isContext = (name) => mod.contexts.some((c) => c.name === name) || !!contextNamed?.(name);
241
+ const candidates = new Set(mod.components.filter((c) => isPrivate(c) && isPureComponent(c, isContext)).map((c) => c.name));
242
+ // a component that renders itself, directly or through others, cannot be written out in place
243
+ const rendersOf = (name) => [...sites.entries()].filter(([, list]) => list.some((s) => s.host.name === name)).map(([rendered]) => rendered);
244
+ const reaches = (from, target, seen = new Set()) => {
245
+ for (const next of rendersOf(from)) {
246
+ if (next === target)
247
+ return true;
248
+ if (!seen.has(next)) {
249
+ seen.add(next);
250
+ if (reaches(next, target, seen))
251
+ return true;
252
+ }
253
+ }
254
+ return false;
255
+ };
256
+ const out = new Set();
257
+ for (const name of candidates) {
258
+ const comp = byName.get(name);
259
+ const list = sites.get(name) ?? [];
260
+ if (!comp || !list.length || reaches(name, name) || referencedAsValue(mod, name))
261
+ continue;
262
+ const ownLoops = loopNamesIn(comp.template);
263
+ const safe = list.every((site) => {
264
+ if (site.element.attrs.some((a) => a.kind === 'spread' || a.kind === 'ref' || a.kind === 'html'))
265
+ return false;
266
+ // markup passed only while a test holds, or a render function: the component tests and calls the prop itself
267
+ if (site.element.attrs.some((a) => a.kind === 'slotProp' && (a.when || a.render)))
268
+ return false;
269
+ // the component's free names must resolve to the same module names inside the host
270
+ for (const free of comp.moduleNames)
271
+ if (site.host.bindings.has(free) || site.loopNames.has(free))
272
+ return false;
273
+ // a loop of the component must not capture a name the caller's values read
274
+ const passed = identifierNames(site.element.attrs.flatMap((a) => (a.kind === 'expr' || a.kind === 'style' ? [a.expr] : a.kind === 'event' ? [a.handler] : [])));
275
+ for (const n of ownLoops)
276
+ if (passed.has(n))
277
+ return false;
278
+ return true;
279
+ });
280
+ if (!safe)
281
+ continue;
282
+ if (mode === 'vue' && list.length > 1 && templateSize(comp.template) > 12)
283
+ continue;
284
+ out.add(name);
285
+ }
286
+ return out;
287
+ }
288
+ /** Whether a use passes markup (children or an element-valued prop), which a Svelte snippet call cannot take inline. */
289
+ export function passesMarkup(site) {
290
+ return site.children.length > 0 || site.attrs.some((a) => a.kind === 'slotProp');
291
+ }
292
+ /** A deep clone that keeps the host's identifier → binding links (the rewriter finds bindings by node identity). */
293
+ export function cloneKeeping(node, refs) {
294
+ const copy = t.cloneNode(node, true);
295
+ const pair = (a, b) => {
296
+ const name = refs.get(a);
297
+ if (name)
298
+ refs.set(b, name);
299
+ for (const key of t.VISITOR_KEYS[a.type] ?? []) {
300
+ const va = childAt(a, key);
301
+ const vb = childAt(b, key);
302
+ if (Array.isArray(va) && Array.isArray(vb)) {
303
+ va.forEach((x, i) => {
304
+ const y = vb[i];
305
+ if (x && y && typeof x === 'object' && typeof y === 'object' && 'type' in x && 'type' in y)
306
+ pair(x, y);
307
+ });
308
+ }
309
+ else if (va && vb && typeof va === 'object' && typeof vb === 'object' && 'type' in va && 'type' in vb)
310
+ pair(va, vb);
311
+ }
312
+ };
313
+ pair(node, copy);
314
+ return copy;
315
+ }
316
+ /** Replaces free uses of mapped names with copies of their values (nested functions that re-declare a name keep it). */
317
+ export function substitute(node, map, refs) {
318
+ const root = cloneKeeping(node, refs);
319
+ if (!map.size)
320
+ return root;
321
+ const visit = (n, parent, shadow) => {
322
+ if (t.isIdentifier(n)) {
323
+ const replacement = map.get(n.name);
324
+ if (!replacement || shadow.has(n.name))
325
+ return n;
326
+ if (parent && (t.isMemberExpression(parent) || t.isOptionalMemberExpression(parent)) && parent.property === n && !parent.computed)
327
+ return n;
328
+ if (parent && t.isObjectProperty(parent) && parent.key === n && !parent.computed) {
329
+ if (parent.shorthand)
330
+ parent.shorthand = false;
331
+ return n;
332
+ }
333
+ if (parent && t.isObjectProperty(parent) && parent.value === n)
334
+ parent.shorthand = false;
335
+ return cloneKeeping(replacement, refs);
336
+ }
337
+ let inner = shadow;
338
+ if (t.isFunction(n)) {
339
+ inner = new Set(shadow);
340
+ for (const p of n.params)
341
+ for (const name of Object.keys(t.getBindingIdentifiers(p, false)))
342
+ inner.add(name);
343
+ if (t.isBlockStatement(n.body))
344
+ for (const s of n.body.body)
345
+ for (const name of Object.keys(t.getOuterBindingIdentifiers(s)))
346
+ inner.add(name);
347
+ }
348
+ for (const key of t.VISITOR_KEYS[n.type] ?? []) {
349
+ const value = childAt(n, key);
350
+ if (Array.isArray(value)) {
351
+ for (let i = 0; i < value.length; i++) {
352
+ const child = value[i];
353
+ if (child && typeof child === 'object' && 'type' in child)
354
+ value[i] = visit(child, n, inner);
355
+ }
356
+ }
357
+ else if (value && typeof value === 'object' && 'type' in value)
358
+ setChildAt(n, key, visit(value, n, inner));
359
+ }
360
+ return n;
361
+ };
362
+ return visit(root, null, new Set());
363
+ }
364
+ /** A component's function item as an expression (`function f() {}` becomes an arrow, which is how a template holds it). */
365
+ function functionValue(node) {
366
+ if (!t.isFunctionDeclaration(node))
367
+ return node;
368
+ const arrow = t.arrowFunctionExpression(node.params, node.body, node.async);
369
+ arrow.returnType = node.returnType ?? null;
370
+ return arrow;
371
+ }
372
+ /** The values a use passes, by prop key: expressions, and markup for element-valued props. */
373
+ function passedValues(site) {
374
+ const values = new Map();
375
+ const markup = new Map();
376
+ for (const a of site.attrs) {
377
+ const key = attrKey(a);
378
+ if (!key)
379
+ continue;
380
+ if (a.kind === 'static')
381
+ values.set(key, t.stringLiteral(a.value));
382
+ else if (a.kind === 'bool')
383
+ values.set(key, t.booleanLiteral(true));
384
+ else if (a.kind === 'expr' || a.kind === 'style')
385
+ values.set(key, a.expr);
386
+ else if (a.kind === 'event')
387
+ values.set(key, a.handler);
388
+ else if (a.kind === 'slotProp')
389
+ markup.set(key, a.children);
390
+ }
391
+ return { values, markup };
392
+ }
393
+ /** The snippet-call argument for a use: `{ checked: row.done, size: 14 }`, keyed by the component's prop keys. */
394
+ export function snippetArgument(site, comp) {
395
+ const { values } = passedValues(site);
396
+ const props = [];
397
+ for (const p of comp.props) {
398
+ const value = values.get(p.key);
399
+ if (!value || p.kind === 'children')
400
+ continue;
401
+ const key = /^[A-Za-z_$][\w$]*$/.test(p.key) ? t.identifier(p.key) : t.stringLiteral(p.key);
402
+ props.push(t.objectProperty(key, value, false, t.isIdentifier(key) && t.isIdentifier(value) && value.name === key.name));
403
+ }
404
+ return t.objectExpression(props);
405
+ }
406
+ /**
407
+ * The markup of `comp` as written at `site`: each prop replaced by the value passed (or its default), derived values
408
+ * and functions by their definitions, children and element-valued props by the caller's markup. Expressions keep the
409
+ * host's binding links, so the host's rewriting (refs, setters) still applies to them.
410
+ */
411
+ export function expandUse(site, comp, hostRefs) {
412
+ const { values, markup } = passedValues(site);
413
+ const map = new Map();
414
+ const slots = new Map();
415
+ for (const p of comp.props) {
416
+ if (p.kind === 'children') {
417
+ if (site.children.length)
418
+ slots.set(p.local, site.children);
419
+ continue;
420
+ }
421
+ const passed = values.get(p.key);
422
+ const passedMarkup = markup.get(p.key);
423
+ if (passedMarkup) {
424
+ slots.set(p.local, passedMarkup);
425
+ continue;
426
+ }
427
+ if (passed)
428
+ map.set(p.local, passed);
429
+ else if (p.defaultValue)
430
+ map.set(p.local, substitute(p.defaultValue, map, hostRefs));
431
+ else
432
+ map.set(p.local, t.identifier('undefined'));
433
+ }
434
+ for (const item of comp.items) {
435
+ if (item.kind === 'derived' && t.isIdentifier(item.id))
436
+ map.set(item.id.name, substitute(item.init, map, hostRefs));
437
+ else if (item.kind === 'function')
438
+ map.set(item.name, substitute(functionValue(item.node), map, hostRefs));
439
+ }
440
+ return substituteTemplate(comp.template, map, hostRefs, slots);
441
+ }
442
+ /**
443
+ * A copy of a template with the free names in `map` replaced by their values (loop variables shadow them) and each slot
444
+ * named in `slots` replaced by that markup. Expressions keep the host's binding links.
445
+ */
446
+ export function substituteTemplate(template, map, hostRefs, slots = new Map()) {
447
+ const sub = (node, m) => substitute(node, m, hostRefs);
448
+ const without = (m, names) => {
449
+ if (!names.some((n) => m.has(n)))
450
+ return m;
451
+ const copy = new Map(m);
452
+ for (const n of names)
453
+ copy.delete(n);
454
+ return copy;
455
+ };
456
+ const attrs = (list, m) => list.map((a) => {
457
+ switch (a.kind) {
458
+ case 'expr':
459
+ // a prop the caller did not pass is `undefined` here: what it decides is settled (`dark || undefined`)
460
+ return { ...a, expr: fold(sub(a.expr, m)) };
461
+ case 'spread':
462
+ case 'ref':
463
+ case 'style':
464
+ case 'html':
465
+ return { ...a, expr: sub(a.expr, m) };
466
+ case 'event':
467
+ return { ...a, handler: sub(a.handler, m) };
468
+ case 'slotProp': {
469
+ // a render prop's own parameters shadow the names substituted around it
470
+ const inner = a.render ? without(m, a.render.params.flatMap((p) => patternNames(p))) : m;
471
+ return { ...a, ...(a.when ? { when: sub(a.when, m) } : {}), children: a.children.flatMap((c) => node(c, inner)) };
472
+ }
473
+ default:
474
+ return { ...a };
475
+ }
476
+ });
477
+ const node = (n, m) => {
478
+ switch (n.type) {
479
+ case 'text':
480
+ case 'unconverted':
481
+ return [{ ...n }];
482
+ case 'expr':
483
+ return [{ type: 'expr', expr: sub(n.expr, m), ...(n.markup ? { markup: n.markup } : {}) }];
484
+ case 'render':
485
+ return [{ type: 'render', name: n.name, args: n.args.map((a) => sub(a, m)) }];
486
+ case 'element': {
487
+ const motion = n.motion ? Object.fromEntries(Object.entries(n.motion).map(([k, v]) => [k, sub(v, m)])) : null;
488
+ return [{ ...n, motion, ...(n.portal ? { portal: sub(n.portal, m) } : {}), attrs: attrs(n.attrs, m), children: n.children.flatMap((c) => node(c, m)) }];
489
+ }
490
+ case 'if':
491
+ return [{ type: 'if', branches: n.branches.map((b) => ({ test: b.test ? sub(b.test, m) : null, children: b.children.flatMap((c) => node(c, m)) })) }];
492
+ case 'for': {
493
+ const declared = [...(n.item ? patternNames(n.item) : []), ...(n.index ? [n.index] : [])];
494
+ let inner = without(m, declared);
495
+ const locals = n.locals.map((l) => {
496
+ const decl = sub(l, inner);
497
+ inner = without(inner, l.declarations.flatMap((d) => patternNames(d.id)));
498
+ return decl;
499
+ });
500
+ return [{ ...n, iterable: sub(n.iterable, m), item: n.item ? t.cloneNode(n.item, true) : null, key: n.key ? sub(n.key, inner) : null, locals, children: n.children.flatMap((c) => node(c, inner)) }];
501
+ }
502
+ case 'slot': {
503
+ // a render prop called with arguments belongs to the component that declares it: never written in place (see
504
+ // isPureComponent), so here it is in a render helper of that component
505
+ if (n.args)
506
+ return [{ ...n, args: n.args.map((a) => sub(a, m)) }];
507
+ const given = slots.get(n.prop);
508
+ if (given)
509
+ return given;
510
+ const value = m.get(n.prop);
511
+ if (value && !(t.isIdentifier(value) && value.name === 'undefined'))
512
+ return [{ type: 'expr', expr: cloneKeeping(value, hostRefs) }];
513
+ return n.fallback.flatMap((c) => node(c, m));
514
+ }
515
+ case 'keyed':
516
+ return [{ type: 'keyed', key: sub(n.key, m), children: n.children.flatMap((c) => node(c, m)) }];
517
+ case 'presence':
518
+ return [{ type: 'presence', attrs: attrs(n.attrs, m), children: n.children.flatMap((c) => node(c, m)) }];
519
+ case 'fragment':
520
+ return [{ type: 'fragment', children: n.children.flatMap((c) => node(c, m)) }];
521
+ }
522
+ };
523
+ return node(template, map);
524
+ }
@@ -0,0 +1,70 @@
1
+ import * as t from '@babel/types';
2
+ import type { Target } from '../../types.js';
3
+ import type { ComponentIR, ModuleIR } from '../../ir/model.js';
4
+ /**
5
+ * Where one source file's output lives for one target, and where each of its exports can be imported from.
6
+ *
7
+ * A file with components becomes one main component file (`sfc`) that also holds the file's types, constants, hooks
8
+ * and canvas loops, and its own stylesheet. Small private components get no file (Vue writes them in place, Svelte as
9
+ * snippets). Only components that must stand alone get a file beside it: other exported components, and private ones
10
+ * with state of their own.
11
+ */
12
+ export interface ModuleLayout {
13
+ /** absolute source path */
14
+ source: string;
15
+ /** source path relative to the project root, forward slashes */
16
+ sourceRel: string;
17
+ /** `inlined-style`: a stylesheet folded into the `<style>` of the one component file that imports it */
18
+ kind: 'sfc' | 'module' | 'copy' | 'inlined-style';
19
+ /** the main component file (it holds the non-component exports), or the plain module */
20
+ modulePath: string;
21
+ /** the component whose file is `modulePath` */
22
+ mainComponent: string | null;
23
+ /** component name → its output file, for every component that has one */
24
+ components: Map<string, string>;
25
+ /** private components with no file of their own */
26
+ inlined: Set<string>;
27
+ defaultComponent: string | null;
28
+ /** a default export that is not a component: a component file's default is the component, so this one is named */
29
+ defaultValue: string | null;
30
+ /** stylesheets whose rules go in the main file's `<style>` */
31
+ styles: {
32
+ file: string;
33
+ code: string;
34
+ }[];
35
+ /** Svelte: the module file uses runes (a .svelte.ts file) */
36
+ runes: boolean;
37
+ }
38
+ /** `CrmTable` → `crm-table`, `shader-background` stays as it is. */
39
+ export declare function angularFileName(stem: string): string;
40
+ export declare function isExportedComponent(mod: ModuleIR, c: ComponentIR): boolean;
41
+ export declare function emptyLayout(source: string, sourceRel: string, kind: ModuleLayout['kind']): ModuleLayout;
42
+ /**
43
+ * A component written in place must not provide a context: it would provide from its caller's instance, for everything
44
+ * the caller renders. The layout knows the contexts the file declares; once the emitter has linked every provider to
45
+ * its declaration (imported contexts, React 19's `<Theme value>` form), a private component that provides one gets its
46
+ * own file after all.
47
+ */
48
+ export declare function keepProvidersFiled(mod: ModuleIR, layout: ModuleLayout, target: Target): void;
49
+ /**
50
+ * Lays out a lowered module for a target. React Native keeps the source layout. `contextNamed` says whether a name the
51
+ * module reads is a context (its own or an imported one): a private component that provides one keeps a file.
52
+ */
53
+ export declare function layoutFor(mod: ModuleIR, sourceRel: string, target: Target, absSource: string, contextNamed?: (name: string) => boolean): ModuleLayout;
54
+ /** The import specifier that reaches `to` from a file at `from` (both output paths). */
55
+ export declare function importPath(from: string, to: string): string;
56
+ /** Collects imports for one output file and prints them once each, in a stable order. */
57
+ export declare class ImportSet {
58
+ private readonly entries;
59
+ private entry;
60
+ named(source: string, imported: string, local?: string): void;
61
+ type(source: string, imported: string, local?: string): void;
62
+ defaultImport(source: string, local: string): void;
63
+ namespace(source: string, local: string): void;
64
+ side(source: string): void;
65
+ get size(): number;
66
+ /** Every local name these imports bind. */
67
+ locals(): Set<string>;
68
+ /** Import declarations, keeping only names in `used` (when given); side-effect imports always stay. */
69
+ declarations(used?: Set<string>): t.ImportDeclaration[];
70
+ }