@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,442 @@
1
+ import * as t from '@babel/types';
2
+ import { generate } from '../../../analyzer/parse.js';
3
+ import { domAttributeName, domEventName, isDomEventProp } from '../../../ir/dom.js';
4
+ import { isStringy, isUnitless, numericLiteral, reactStyleValue, styleKey } from '../../../ir/style.js';
5
+ import { domElementType } from '../../shared/handles.js';
6
+ import { MOTION_RENAME, MOTION_UNSUPPORTED } from '../motion.js';
7
+ import { vueDomEvent } from '../events.js';
8
+ class Refused extends Error {
9
+ }
10
+ /** `node` (an expression or a statement) with each piece of markup in it written with `h()`; null when refused. */
11
+ export function writeMarkup(node, ctx) {
12
+ const writer = new HWriter(ctx);
13
+ try {
14
+ return writer.walk(t.cloneNode(node, true));
15
+ }
16
+ catch (error) {
17
+ if (error instanceof Refused)
18
+ return null;
19
+ throw error;
20
+ }
21
+ }
22
+ /** SVG attributes the browser takes in camel case, as React writes them. */
23
+ const SVG_CASED = new Set(['viewBox', 'preserveAspectRatio', 'gradientUnits', 'gradientTransform', 'patternUnits', 'patternContentUnits', 'patternTransform', 'clipPathUnits', 'maskUnits', 'maskContentUnits', 'markerWidth', 'markerHeight', 'markerUnits', 'refX', 'refY', 'stdDeviation', 'pathLength', 'textLength', 'lengthAdjust', 'spreadMethod', 'startOffset', 'filterUnits', 'primitiveUnits', 'baseFrequency', 'numOctaves', 'kernelMatrix', 'tableValues', 'viewTarget']);
24
+ function key(name) {
25
+ return /^[A-Za-z_$][\w$]*$/.test(name) ? t.identifier(name) : t.stringLiteral(name);
26
+ }
27
+ class HWriter {
28
+ ctx;
29
+ constructor(ctx) {
30
+ this.ctx = ctx;
31
+ }
32
+ refuse(code, message, at) {
33
+ this.ctx.refuse(code, message, at.loc?.start.line);
34
+ throw new Refused(message);
35
+ }
36
+ /** Replaces markup anywhere under `node`, bottom-up. */
37
+ walk(node) {
38
+ for (const field of t.VISITOR_KEYS[node.type] ?? []) {
39
+ const child = Reflect.get(node, field);
40
+ if (Array.isArray(child)) {
41
+ child.forEach((c, i) => {
42
+ if (t.isNode(c))
43
+ child[i] = this.replace(c);
44
+ });
45
+ }
46
+ else if (t.isNode(child))
47
+ Reflect.set(node, field, this.replace(child));
48
+ }
49
+ return node;
50
+ }
51
+ replace(n) {
52
+ if (t.isJSXElement(n) || t.isJSXFragment(n))
53
+ return this.markup(n);
54
+ if (t.isCallExpression(n))
55
+ return this.reactCall(n) ?? this.walk(n);
56
+ return this.walk(n);
57
+ }
58
+ /** An expression with its markup written, itself included. */
59
+ expression(e) {
60
+ if (t.isCallExpression(e))
61
+ return this.reactCall(e) ?? this.walk(e);
62
+ return t.isJSXElement(e) || t.isJSXFragment(e) ? this.markup(e) : this.walk(e);
63
+ }
64
+ /**
65
+ * React's element functions on VNodes. `Children.toArray / count / map / forEach` read the component's children
66
+ * through `slotChildren` (a `v-for` list flattened into its items, a `v-if` placeholder as the empty node React counts
67
+ * and skips); `isValidElement` is `isVNode`; `cloneElement(el, props)` is `cloneVNode(el, props)` where Vue's merge
68
+ * equals React's replacement: props with no class, style, handler or ref (Vue joins those, React replaces them), the
69
+ * element's own props spread into it left out (React's no-op). Anything else is refused. Null: not such a call.
70
+ */
71
+ reactCall(call) {
72
+ const callee = call.callee;
73
+ if (!t.isExpression(callee))
74
+ return null;
75
+ const args = call.arguments;
76
+ if (t.isMemberExpression(callee) && !callee.computed && t.isIdentifier(callee.property) && this.ctx.reactApi(callee.object) === 'Children') {
77
+ const method = callee.property.name;
78
+ const first = args[0];
79
+ const nodes = first && t.isExpression(first) ? this.ctx.childrenNodes(first) : null;
80
+ if (!nodes)
81
+ return this.refuse('react-runtime', `Children.${method} reads something other than this component's children; Vue has no React elements to read there.`, call);
82
+ if (!['toArray', 'count', 'map', 'forEach'].includes(method))
83
+ return this.refuse('react-runtime', `Children.${method} has no exact Vue form here.`, call);
84
+ this.ctx.helper('slotChildren');
85
+ const list = t.callExpression(t.identifier('slotChildren'), [nodes]);
86
+ if (method === 'count')
87
+ return t.memberExpression(list, t.identifier('length'));
88
+ if (method === 'toArray')
89
+ return t.callExpression(t.memberExpression(list, t.identifier('filter')), [t.arrowFunctionExpression([t.identifier('child')], t.binaryExpression('!==', t.identifier('child'), t.nullLiteral()))]);
90
+ const fn = args[1];
91
+ if (!fn || !t.isExpression(fn) || args.length > 2)
92
+ return this.refuse('react-runtime', `Children.${method} with a this-argument has no exact Vue form here.`, call);
93
+ // the child is a VNode (or null for an empty node) here, not the ReactNode React's types gave the parameter
94
+ const child = (t.isArrowFunctionExpression(fn) || t.isFunctionExpression(fn)) && t.isIdentifier(fn.params[0]) ? fn.params[0] : null;
95
+ if (child)
96
+ child.typeAnnotation = null;
97
+ return t.callExpression(t.memberExpression(list, t.identifier(method)), [this.expression(fn)]);
98
+ }
99
+ const api = this.ctx.reactApi(callee);
100
+ if (api === 'isValidElement') {
101
+ const [value] = args;
102
+ if (args.length !== 1 || !value || !t.isExpression(value))
103
+ return this.refuse('react-runtime', 'isValidElement with other than one argument has no Vue form here.', call);
104
+ this.ctx.use('vue', 'isVNode');
105
+ return t.callExpression(t.identifier('isVNode'), [this.expression(value)]);
106
+ }
107
+ if (api === 'cloneElement') {
108
+ const [element, props] = args;
109
+ if (!element || !t.isExpression(element) || args.length > 2)
110
+ return this.refuse('react-runtime', 'cloneElement with new children has no exact Vue form here (cloneVNode keeps the children).', call);
111
+ const out = [];
112
+ if (props && !t.isObjectExpression(props))
113
+ return this.refuse('react-runtime', "cloneElement's props are not written out: Vue's cloneVNode joins class, style and handlers where React replaces them, so each key must be known.", call);
114
+ for (const p of props && t.isObjectExpression(props) ? props.properties : []) {
115
+ // `{ ...child.props, x }`: the element's own props over themselves, which changes nothing in React
116
+ if (t.isSpreadElement(p) && t.isMemberExpression(p.argument) && t.isIdentifier(p.argument.property, { name: 'props' }) && t.isIdentifier(p.argument.object) && t.isIdentifier(element, { name: p.argument.object.name }))
117
+ continue;
118
+ const name = t.isObjectProperty(p) && !p.computed ? (t.isIdentifier(p.key) ? p.key.name : t.isStringLiteral(p.key) ? p.key.value : null) : null;
119
+ if (!t.isObjectProperty(p) || name === null || !t.isExpression(p.value))
120
+ return this.refuse('react-runtime', "cloneElement's props hold a spread or a computed key: Vue's cloneVNode joins class, style and handlers where React replaces them, so each key must be known.", call);
121
+ if (name === 'className' || name === 'class' || name === 'style' || name === 'ref' || /^on[A-Z]/.test(name))
122
+ return this.refuse('react-runtime', `cloneElement sets ${name}: Vue's cloneVNode joins it with the element's own where React replaces it.`, call);
123
+ out.push(t.objectProperty(key(name), this.expression(p.value), false, t.isIdentifier(p.value, { name })));
124
+ }
125
+ this.ctx.use('vue', 'cloneVNode');
126
+ return t.callExpression(t.identifier('cloneVNode'), [this.expression(element), ...(out.length ? [t.objectExpression(out)] : [])]);
127
+ }
128
+ return null;
129
+ }
130
+ h(args) {
131
+ this.ctx.use('vue', 'h');
132
+ return t.callExpression(t.identifier('h'), args);
133
+ }
134
+ /** One element or fragment as a VNode. */
135
+ markup(e) {
136
+ const kids = this.children(e);
137
+ if (t.isJSXFragment(e)) {
138
+ this.ctx.use('vue', 'Fragment');
139
+ return this.h([t.identifier('Fragment'), t.nullLiteral(), t.arrayExpression(kids)]);
140
+ }
141
+ const open = e.openingElement;
142
+ const name = open.name;
143
+ if (t.isJSXNamespacedName(name))
144
+ this.refuse('jsx-in-script', `<${name.namespace.name}:${name.name.name}> has no render-function form here.`, e);
145
+ // `<Fragment key={k}>`, `<React.Fragment key={k}>`: a keyed fragment
146
+ const tagText = t.isJSXIdentifier(name) ? name.name : `${memberText(name)}`;
147
+ if (tagText === 'Fragment' || tagText === 'React.Fragment') {
148
+ this.ctx.use('vue', 'Fragment');
149
+ const props = this.componentProps(open.attributes, tagText);
150
+ return this.h([t.identifier('Fragment'), props.properties.length ? props : t.nullLiteral(), t.arrayExpression(kids)]);
151
+ }
152
+ // a context's provider or consumer: Vue provides a value in a component's setup (provide/inject), so the context
153
+ // object is no component h() can render
154
+ if (/\.(Provider|Consumer)$/.test(tagText))
155
+ this.refuse('jsx-in-script', `<${tagText}> is a React context's ${tagText.endsWith('Provider') ? 'provider' : 'consumer'}; Vue provides values with provide() in a component's setup, so a render function has no form for it.`, e);
156
+ const problem = /^[a-z]/.test(tagText) && !tagText.includes('.') ? null : this.ctx.tagProblem(tagText);
157
+ if (problem)
158
+ this.refuse('jsx-in-script', `<${tagText}> ${problem}; a render function holding it is not converted.`, e);
159
+ if (t.isJSXMemberExpression(name)) {
160
+ const object = name.object;
161
+ if (t.isJSXIdentifier(object) && this.ctx.isMotion(object.name))
162
+ return this.motion(name.property.name, open.attributes, kids, e);
163
+ // `<Icons.Close>`: a component held in an object
164
+ const type = memberExpression(name);
165
+ return this.component(type, tagText, open.attributes, kids);
166
+ }
167
+ if (/^[a-z]/.test(name.name) && !name.name.includes('-'))
168
+ return this.element(name.name, open.attributes, kids, e);
169
+ return this.component(t.identifier(name.name), name.name, open.attributes, kids);
170
+ }
171
+ /** JSX children as h() children, with React's whitespace rules (t.react.buildChildren). */
172
+ children(e) {
173
+ const out = [];
174
+ for (const c of t.react.buildChildren(e)) {
175
+ if (t.isJSXSpreadChild(c))
176
+ this.refuse('jsx-in-script', 'A spread child ({...items}) has no render-function form here.', c);
177
+ else if (t.isJSXElement(c) || t.isJSXFragment(c))
178
+ out.push(this.markup(c));
179
+ else if (t.isStringLiteral(c))
180
+ out.push(c);
181
+ // a value: Vue renders null, undefined and booleans as nothing and numbers as text, as React does; one that may
182
+ // hold markup held as a value (a functional component) is rendered as that component (markupChild)
183
+ else if (this.ctx.markupChild(c)) {
184
+ this.ctx.helper('markupChild');
185
+ out.push(t.callExpression(t.identifier('markupChild'), [this.expression(c)]));
186
+ }
187
+ else
188
+ out.push(this.expression(c));
189
+ }
190
+ return out;
191
+ }
192
+ /** A value of an attribute: JSX inside it written with h(). */
193
+ value(a) {
194
+ const v = a.value;
195
+ if (v === null || v === undefined)
196
+ return t.booleanLiteral(true);
197
+ if (t.isStringLiteral(v))
198
+ return v;
199
+ if (t.isJSXElement(v) || t.isJSXFragment(v))
200
+ return this.markup(v);
201
+ if (t.isJSXExpressionContainer(v) && t.isExpression(v.expression))
202
+ return this.expression(v.expression);
203
+ return this.refuse('jsx-in-script', 'An empty attribute value ({}) has no render-function form here.', a);
204
+ }
205
+ element(tag, attrs, kids, at) {
206
+ const props = [];
207
+ for (const a of attrs) {
208
+ if (t.isJSXSpreadAttribute(a)) {
209
+ props.push(t.spreadElement(this.expression(a.argument)));
210
+ continue;
211
+ }
212
+ if (!t.isJSXIdentifier(a.name))
213
+ this.refuse('jsx-in-script', `The attribute ${a.name.namespace.name}:${a.name.name.name} has no render-function form here.`, a);
214
+ const react = a.name.name;
215
+ if (react === 'children')
216
+ this.refuse('jsx-in-script', `children passed as an attribute of <${tag}> has no render-function form here.`, a);
217
+ if (react === 'suppressHydrationWarning' || react === 'suppressContentEditableWarning')
218
+ continue;
219
+ if (react === 'key') {
220
+ props.push(t.objectProperty(t.identifier('key'), this.value(a)));
221
+ continue;
222
+ }
223
+ if (react === 'ref') {
224
+ props.push(t.objectProperty(t.identifier('ref'), this.ref(this.value(a), tag, a)));
225
+ continue;
226
+ }
227
+ if (react === 'style') {
228
+ props.push(t.objectProperty(t.identifier('style'), this.style(this.value(a))));
229
+ continue;
230
+ }
231
+ if (react === 'dangerouslySetInnerHTML') {
232
+ const v = this.value(a);
233
+ const html = t.isObjectExpression(v) ? v.properties.find((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: '__html' })) : undefined;
234
+ const inner = html && t.isExpression(html.value) ? html.value : t.memberExpression(v, t.identifier('__html'));
235
+ this.ctx.warn('inner-html', `<${tag}> sets its markup from a string (innerHTML): review where the string comes from.`, a.loc?.start.line);
236
+ props.push(t.objectProperty(t.identifier('innerHTML'), inner));
237
+ continue;
238
+ }
239
+ if (/^on[A-Z]/.test(react)) {
240
+ props.push(t.objectProperty(t.identifier(this.eventKey(react, tag, attrs, a)), this.value(a)));
241
+ continue;
242
+ }
243
+ const name = domAttributeName(react);
244
+ // a name React passes on as written is lower case (`role`, `aria-hidden`), or SVG's own (`viewBox`)
245
+ if (name === react && /[A-Z]/.test(react) && !SVG_CASED.has(react))
246
+ this.refuse('jsx-in-script', `<${tag}> sets ${react}, an attribute whose browser name is not known here.`, a);
247
+ props.push(t.objectProperty(key(name), this.value(a)));
248
+ }
249
+ // a controlled field: React puts its value back after every change event, so a handler that refuses a change leaves
250
+ // the field as it was; Vue sets the value only when it renders, which a refused change does not cause
251
+ const named = (n) => attrs.some((a) => t.isJSXAttribute(a) && t.isJSXIdentifier(a.name, { name: n }));
252
+ if ((tag === 'input' || tag === 'textarea' || tag === 'select') && (named('value') || named('checked')) && (named('onChange') || named('onInput'))) {
253
+ this.ctx.warn('controlled-input', `<${tag}> is controlled (value and a change handler) in a render function: when the handler does not take a change (sets no state, or the same value), React puts the old value back at once, while Vue leaves what was typed until the component next renders.`, at.loc?.start.line);
254
+ }
255
+ const args = [t.stringLiteral(tag)];
256
+ if (props.length || kids.length)
257
+ args.push(props.length ? t.objectExpression(props) : t.nullLiteral());
258
+ if (kids.length)
259
+ args.push(t.arrayExpression(kids));
260
+ return this.h(args);
261
+ }
262
+ /**
263
+ * The Vue prop that listens to a React DOM handler: Vue binds `onXyz` to the event `xyz` (camel case is hyphenated, so
264
+ * the event is written in lower case after `on`), and reads the `Capture` and `Passive` suffixes as listener options.
265
+ * React's onFocus and onBlur bubble (React listens to focusin and focusout), and React listens to wheel and touch
266
+ * events passively.
267
+ */
268
+ eventKey(react, tag, attrs, at) {
269
+ const capture = react.endsWith('Capture') && react !== 'onGotPointerCapture' && react !== 'onLostPointerCapture';
270
+ const base = capture ? react.slice(0, -'Capture'.length) : react;
271
+ if (!isDomEventProp(base) && base !== 'onDoubleClick')
272
+ this.refuse('jsx-in-script', `<${tag}> listens to ${react}, which is not a DOM event the browser fires.`, at);
273
+ const { event, passive } = vueDomEvent(domEventName(base, tag, attrs));
274
+ return `on${event.charAt(0).toUpperCase()}${event.slice(1)}${passive ? 'Passive' : ''}${capture ? 'Capture' : ''}`;
275
+ }
276
+ /** React's style rule: a number gets px unless unitless or zero; Vue appends nothing. */
277
+ style(v) {
278
+ if (t.isStringLiteral(v))
279
+ return v;
280
+ if (t.isObjectExpression(v) && v.properties.every((p) => t.isObjectProperty(p) && styleKey(p) !== null)) {
281
+ const out = [];
282
+ for (const p of v.properties) {
283
+ const name = styleKey(p) ?? '';
284
+ const value = p.value;
285
+ if (!t.isExpression(value))
286
+ return this.refuse('jsx-in-script', `The style ${name} has no render-function form here.`, p);
287
+ const n = numericLiteral(value);
288
+ let written = value;
289
+ if (n !== null) {
290
+ const r = reactStyleValue(name, n);
291
+ written = typeof r === 'string' ? t.stringLiteral(r) : value;
292
+ }
293
+ else if (!isUnitless(name) && !isStringy(value) && !(t.isIdentifier(value) && this.ctx.isMotionValue(value.name))) {
294
+ this.ctx.helper('toPx');
295
+ written = t.callExpression(t.identifier('toPx'), [value]);
296
+ }
297
+ out.push(t.objectProperty(key(name), written, false, t.isIdentifier(written) && written.name === name));
298
+ }
299
+ return t.objectExpression(out);
300
+ }
301
+ this.ctx.helper('toStyle');
302
+ return t.callExpression(t.identifier('toStyle'), [v]);
303
+ }
304
+ /**
305
+ * A ref: an element ref object is passed as it is (Vue fills `.value` with the element and empties it on unmount);
306
+ * a callback gets the element typed as React typed it (Vue's ref callback is typed for any element or instance).
307
+ */
308
+ ref(v, tag, at) {
309
+ if (t.isIdentifier(v) && this.ctx.refKind(v.name) === 'dom')
310
+ return v;
311
+ const typed = (name) => t.tsAsExpression(t.identifier(name), t.tsUnionType([domElementType(tag), t.tsNullKeyword()]));
312
+ // an inline callback (`(el) => { if (el) map.set(k, el); }`): its element is a const of the body, typed once, so
313
+ // its tests narrow it as they did in React
314
+ const param = (t.isArrowFunctionExpression(v) || t.isFunctionExpression(v)) && v.params.length === 1 && t.isIdentifier(v.params[0]) ? v.params[0].name : null;
315
+ if (param !== null && (t.isArrowFunctionExpression(v) || t.isFunctionExpression(v)) && !v.async && !v.generator) {
316
+ const words = new Set();
317
+ t.traverseFast(v.body, (n) => void (t.isIdentifier(n) && words.add(n.name)));
318
+ let raw = 'node';
319
+ for (let i = 2; words.has(raw) || raw === param; i++)
320
+ raw = `node${i}`;
321
+ const own = t.variableDeclaration('const', [t.variableDeclarator(t.identifier(param), typed(raw))]);
322
+ const body = t.isBlockStatement(v.body) ? v.body.body : [t.expressionStatement(v.body)];
323
+ return t.arrowFunctionExpression([t.identifier(raw)], t.blockStatement([own, ...body]));
324
+ }
325
+ // a callback held in a name (`ref={take}`): called with the element React promised it
326
+ if (t.isIdentifier(v) || t.isMemberExpression(v))
327
+ return t.arrowFunctionExpression([t.identifier('el')], t.callExpression(v, [typed('el')]));
328
+ return this.refuse('jsx-in-script', `The ref of <${tag}> is neither an element ref nor a callback; it has no render-function form here.`, at);
329
+ }
330
+ /** `motion.div`: motion-v's component of the same tag, with Framer's props under motion-v's names. */
331
+ motion(tag, attrs, kids, at) {
332
+ this.ctx.use('motion-v', 'motion');
333
+ const dom = this.element(tag, attrs.filter((a) => !(t.isJSXAttribute(a) && t.isJSXIdentifier(a.name) && isMotionProp(a.name.name))), [], at);
334
+ const props = [];
335
+ const domProps = dom.arguments[1];
336
+ if (t.isObjectExpression(domProps)) {
337
+ for (const p of domProps.properties) {
338
+ if (t.isObjectMethod(p))
339
+ continue;
340
+ // motion-v's element is a component: its template ref is the component, the element is `$el`
341
+ if (t.isObjectProperty(p) && t.isIdentifier(p.key, { name: 'ref' }))
342
+ this.refuse('jsx-in-script', `A ref on <motion.${tag}> in a render function reaches motion-v's component, not the element; not converted.`, at);
343
+ props.push(p);
344
+ }
345
+ }
346
+ for (const a of attrs) {
347
+ if (!t.isJSXAttribute(a) || !t.isJSXIdentifier(a.name) || !isMotionProp(a.name.name))
348
+ continue;
349
+ const raw = a.name.name;
350
+ if (MOTION_UNSUPPORTED.has(raw)) {
351
+ this.ctx.warn('motion-prop', `motion-v has no ${raw}; it is dropped.`, a.loc?.start.line);
352
+ continue;
353
+ }
354
+ props.push(t.objectProperty(key(MOTION_RENAME[raw] ?? raw), this.value(a)));
355
+ }
356
+ const args = [t.memberExpression(t.identifier('motion'), t.identifier(tag))];
357
+ if (props.length || kids.length)
358
+ args.push(props.length ? t.objectExpression(props) : t.nullLiteral());
359
+ if (kids.length)
360
+ args.push(slotsOf(kids));
361
+ return this.h(args);
362
+ }
363
+ /** A component's props as React passes them: names as written (`className` is Vue's `class`), markup as slots or values. */
364
+ componentProps(attrs, tag, slots) {
365
+ const props = [];
366
+ for (const a of attrs) {
367
+ if (t.isJSXSpreadAttribute(a)) {
368
+ props.push(t.spreadElement(this.expression(a.argument)));
369
+ continue;
370
+ }
371
+ if (!t.isJSXIdentifier(a.name))
372
+ this.refuse('jsx-in-script', `The attribute ${a.name.namespace.name}:${a.name.name.name} has no render-function form here.`, a);
373
+ const react = a.name.name;
374
+ if (react === 'children')
375
+ this.refuse('jsx-in-script', `children passed as an attribute of <${tag}> has no render-function form here.`, a);
376
+ if (react === 'ref')
377
+ this.refuse('jsx-in-script', `A ref passed to <${tag}> in a render function reaches the Vue component, not what React's forwardRef hands back; not converted.`, a);
378
+ const raw = a.value;
379
+ const markup = t.isJSXExpressionContainer(raw) && t.isExpression(raw.expression) ? holdsMarkup(raw.expression) : t.isJSXElement(raw) || t.isJSXFragment(raw);
380
+ if (markup && slots) {
381
+ const how = this.ctx.markupProp(tag, react);
382
+ const written = t.isJSXExpressionContainer(raw) && t.isExpression(raw.expression) ? raw.expression : raw;
383
+ // the receiver renders the prop as a slot: markup written as it is fills the slot; markup given only sometimes
384
+ // (`ink ? <Art/> : undefined`) or a render function would fill it always, or with Vue's slot props in place of
385
+ // React's arguments
386
+ if (how === 'slot' && (t.isJSXElement(written) || t.isJSXFragment(written))) {
387
+ slots.push(t.objectProperty(key(react), t.arrowFunctionExpression([], this.value(a))));
388
+ continue;
389
+ }
390
+ if (how === 'slot')
391
+ this.refuse('slot-prop', `"${react}" on <${tag}> passes markup that is not always there or is a render function, and <${tag}> renders "${react}" as a slot: a slot function has no exact form for it here.`, a);
392
+ if (how === 'value')
393
+ this.refuse('slot-prop', `"${react}" on <${tag}> passes markup, and <${tag}> reads "${react}" as a value, which Vue's converted <${tag}> does not render as markup.`, a);
394
+ }
395
+ props.push(t.objectProperty(key(react === 'className' ? 'class' : react), this.value(a)));
396
+ }
397
+ return t.objectExpression(props);
398
+ }
399
+ component(type, tag, attrs, kids) {
400
+ const named = [];
401
+ const props = this.componentProps(attrs, tag, named);
402
+ const args = [type];
403
+ const slots = kids.length ? [t.objectProperty(t.identifier('default'), t.arrowFunctionExpression([], t.arrayExpression(kids))), ...named] : named;
404
+ if (props.properties.length || slots.length)
405
+ args.push(props.properties.length ? props : t.nullLiteral());
406
+ if (slots.length)
407
+ args.push(t.objectExpression(slots));
408
+ return this.h(args);
409
+ }
410
+ }
411
+ /** A component's children as its default slot, called when it renders. */
412
+ function slotsOf(kids) {
413
+ return t.objectExpression([t.objectProperty(t.identifier('default'), t.arrowFunctionExpression([], t.arrayExpression(kids)))]);
414
+ }
415
+ /** Framer Motion's own element props (the rest are the element's). */
416
+ const MOTION_PROPS = /^(initial|animate|exit|variants|transition|custom|inherit|layout|layoutId|layoutDependency|layoutScroll|layoutRoot|drag|dragConstraints|dragElastic|dragMomentum|dragTransition|dragSnapToOrigin|dragListener|dragControls|dragPropagation|dragDirectionLock|whileHover|whileTap|whileFocus|whileDrag|whileInView|viewport|transformTemplate|onUpdate|onAnimationStart|onAnimationComplete|onHoverStart|onHoverEnd|onTap|onTapStart|onTapCancel|onPan|onPanStart|onPanEnd|onDrag|onDragStart|onDragEnd|onViewportEnter|onViewportLeave|onLayoutAnimationStart|onLayoutAnimationComplete)$/;
417
+ function isMotionProp(name) {
418
+ return MOTION_PROPS.test(name);
419
+ }
420
+ function holdsMarkup(e) {
421
+ let found = false;
422
+ t.traverseFast(e, (n) => {
423
+ if (t.isJSXElement(n) || t.isJSXFragment(n))
424
+ found = true;
425
+ });
426
+ return found;
427
+ }
428
+ function memberText(n) {
429
+ const object = t.isJSXIdentifier(n.object) ? n.object.name : memberText(n.object);
430
+ return `${object}.${n.property.name}`;
431
+ }
432
+ function memberExpression(n) {
433
+ const object = t.isJSXIdentifier(n.object) ? t.identifier(n.object.name) : memberExpression(n.object);
434
+ return t.memberExpression(object, t.identifier(n.property.name));
435
+ }
436
+ /**
437
+ * Render-function code as source, each statement on one line, for the formatter to lay out: `h()` props objects then
438
+ * stay on one line wherever they fit (`{ key: item.id }`), as a Vue engineer writes them.
439
+ */
440
+ export function printRenderCode(stmts) {
441
+ return stmts.map((s) => generate(s, { jsescOption: { minimal: true, quotes: 'single' }, concise: true }).code).join('\n');
442
+ }
@@ -0,0 +1,21 @@
1
+ import * as t from '@babel/types';
2
+ import type { TNode } from '../../ir/model.js';
3
+ /**
4
+ * Markup held as a value (ModuleIR.markupValues, ComponentIR.markupValues) as a Vue functional component:
5
+ * `() => h(Layers, { size: 14 })`. The markup is written with `h()` as Vue's own render functions are: elements and
6
+ * components with their props, text, values, choices (`a ? h(…) : null`) and lists (`items.map((item) => h(…))`).
7
+ * Anything else (a style object that needs units, refs, slots, Framer Motion) has no form here: null, and the caller
8
+ * reports it. `clone` copies each expression of the markup (a component's keeps what its names are bound to).
9
+ */
10
+ export declare function renderFunction(template: TNode, clone?: <T extends t.Node>(node: T) => T): t.ArrowFunctionExpression | null;
11
+ /**
12
+ * A module function kept as code that returns markup (`export function renderIcon(icon, size): ReactNode`, exported for
13
+ * other files, or read by other module code) as Vue writes markup held as a value: each element it returns is a
14
+ * functional component (`() => h(Icon, { size })`), and React's element test (`isValidElement(x)`) is the test for one
15
+ * (`typeof x === 'function'`). The function keeps its parameters, so the files that import it call it as before, and a
16
+ * template renders what it returns as markup (`<component :is>`), as a value React's types say may be an element.
17
+ * Null (the statement stays, and is reported) when the function builds elements anywhere but in what it returns (a
18
+ * nested function, a local, an argument), or an element has no exact `h()` form here (see RenderCallWriter).
19
+ * `elementTest` says whether a callee is React's `isValidElement`.
20
+ */
21
+ export declare function renderHelperValue(stmt: t.Statement, elementTest: (callee: t.Node) => boolean): t.Statement | null;