@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,293 @@
1
+ import * as t from '@babel/types';
2
+ /** The root identifier of a member chain (`a.b[c].d` → `a`), or null. */
3
+ function rootName(e) {
4
+ let n = e;
5
+ while (t.isMemberExpression(n) || t.isOptionalMemberExpression(n) || t.isTSNonNullExpression(n))
6
+ n = t.isTSNonNullExpression(n) ? n.expression : n.object;
7
+ return t.isIdentifier(n) ? n.name : null;
8
+ }
9
+ /** Every identifier an expression reads (property keys and member names excluded). */
10
+ export function readNames(e) {
11
+ const out = new Set();
12
+ t.traverse(e, (n, ancestors) => {
13
+ if (!t.isIdentifier(n))
14
+ return;
15
+ const parent = ancestors[ancestors.length - 1];
16
+ if (parent && (t.isMemberExpression(parent.node) || t.isOptionalMemberExpression(parent.node)) && parent.key === 'property' && !parent.node.computed)
17
+ return;
18
+ if (parent && t.isObjectProperty(parent.node) && parent.key === 'key' && !parent.node.computed)
19
+ return;
20
+ out.add(n.name);
21
+ });
22
+ return out;
23
+ }
24
+ /**
25
+ * The module names that hold banked markup: the values themselves and every module `const` whose initializer reads one
26
+ * of them (directly, or through another such const), in module order.
27
+ */
28
+ export function markupHolders(mod, values) {
29
+ const holders = new Set(values);
30
+ let grew = true;
31
+ while (grew) {
32
+ grew = false;
33
+ for (const s of mod.moduleBody) {
34
+ const d = t.isExportNamedDeclaration(s) ? s.declaration : s;
35
+ if (!t.isVariableDeclaration(d))
36
+ continue;
37
+ for (const v of d.declarations) {
38
+ if (!t.isIdentifier(v.id) || holders.has(v.id.name) || !v.init)
39
+ continue;
40
+ if ([...readNames(v.init)].some((n) => holders.has(n))) {
41
+ holders.add(v.id.name);
42
+ grew = true;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ return holders;
48
+ }
49
+ export function walk(nodes, visit, loops = []) {
50
+ for (const n of nodes) {
51
+ visit(n, loops);
52
+ if (n.type === 'element') {
53
+ for (const a of n.attrs)
54
+ if (a.kind === 'slotProp')
55
+ walk(a.children, visit, loops);
56
+ walk(n.children, visit, loops);
57
+ }
58
+ else if (n.type === 'if')
59
+ for (const b of n.branches)
60
+ walk(b.children, visit, loops);
61
+ else if (n.type === 'for')
62
+ walk(n.children, visit, [...loops, n]);
63
+ else if (n.type === 'fragment' || n.type === 'keyed' || n.type === 'presence')
64
+ walk(n.children, visit, loops);
65
+ else if (n.type === 'slot')
66
+ walk(n.fallback, visit, loops);
67
+ }
68
+ }
69
+ /** The keys under which the module's data holds a markup value (`{ icon: optionsIcon }` gives `icon`). */
70
+ export function markupKeys(mod, values) {
71
+ const keys = new Set();
72
+ for (const s of mod.moduleBody)
73
+ t.traverseFast(s, (n) => {
74
+ if (t.isObjectProperty(n) && !n.computed && t.isIdentifier(n.value) && values.has(n.value.name)) {
75
+ if (t.isIdentifier(n.key))
76
+ keys.add(n.key.name);
77
+ else if (t.isStringLiteral(n.key))
78
+ keys.add(n.key.value);
79
+ }
80
+ });
81
+ return keys;
82
+ }
83
+ /** Array methods whose result is still the data (or an entry of it), and whose callbacks only test entries. */
84
+ const KEEPS_DATA = new Set(['find', 'filter', 'slice', 'at', 'concat', 'toSorted', 'toReversed']);
85
+ /** Array methods and members whose result is never markup (a test, a count, an index). */
86
+ const ENDS_DATA = new Set(['length', 'some', 'every', 'findIndex', 'indexOf', 'includes']);
87
+ /**
88
+ * Whether every read of a holder in `e` ends in a value that is not markup: through `find` / `filter` / `slice` and
89
+ * optional chains to a member that is not a markup key (`OPTIONS.find((o) => o.id === id)?.title`), or a count or a
90
+ * test (`OPTIONS.length`). A callback given to those methods must not read a markup key either. Anything else (the
91
+ * data passed on, returned, kept, spread, a markup key read) may carry markup into code that would see a value, not an
92
+ * element, and is not followed.
93
+ */
94
+ export function readsOnlyData(e, holders, keys) {
95
+ let ok = true;
96
+ t.traverse(e, (n, ancestors) => {
97
+ if (!ok || !t.isIdentifier(n) || !holders.has(n.name))
98
+ return;
99
+ const parent = ancestors[ancestors.length - 1];
100
+ if (parent && (t.isMemberExpression(parent.node) || t.isOptionalMemberExpression(parent.node)) && parent.key === 'property' && !parent.node.computed)
101
+ return;
102
+ if (parent && t.isObjectProperty(parent.node) && parent.key === 'key')
103
+ return;
104
+ let cur = n;
105
+ for (let i = ancestors.length - 1; i >= 0; i--) {
106
+ const a = ancestors[i];
107
+ if (!a)
108
+ break;
109
+ const p = a.node;
110
+ if ((t.isMemberExpression(p) || t.isOptionalMemberExpression(p)) && p.object === cur) {
111
+ const key = !p.computed && t.isIdentifier(p.property) ? p.property.name : t.isStringLiteral(p.property) ? p.property.value : t.isNumericLiteral(p.property) ? null : undefined;
112
+ if (key === undefined)
113
+ break;
114
+ if (key === null) {
115
+ cur = p;
116
+ continue;
117
+ }
118
+ if (keys.has(key))
119
+ break;
120
+ const call = ancestors[i - 1]?.node;
121
+ const called = call && (t.isCallExpression(call) || t.isOptionalCallExpression(call)) && call.callee === p;
122
+ if (called && ENDS_DATA.has(key) && !call.arguments.some((arg) => readsKey(arg, keys)))
123
+ return;
124
+ if (called && KEEPS_DATA.has(key) && !call.arguments.some((arg) => readsKey(arg, keys))) {
125
+ cur = call;
126
+ i--;
127
+ continue;
128
+ }
129
+ if (!called && ENDS_DATA.has(key))
130
+ return;
131
+ // a member that is not a markup key ends the read in plain data (`.title`, `.id`)
132
+ if (!called && !KEEPS_DATA.has(key))
133
+ return;
134
+ break;
135
+ }
136
+ if (t.isTSNonNullExpression(p) || t.isParenthesizedExpression(p)) {
137
+ cur = p;
138
+ continue;
139
+ }
140
+ break;
141
+ }
142
+ ok = false;
143
+ });
144
+ return ok;
145
+ }
146
+ /**
147
+ * Whether code reads a markup key of an entry (`o.icon`, `o['icon']`) as a value. A callback that only tests one
148
+ * (`(s) => s.art`, `(s) => !s.art`: the array method reads its result as true or false) reads no value: an element
149
+ * and a banked piece of markup are both truthy, and what is not markup is the same value on both sides.
150
+ */
151
+ function readsKey(e, keys) {
152
+ const tested = new Set();
153
+ if ((t.isArrowFunctionExpression(e) || t.isFunctionExpression(e)) && t.isExpression(e.body)) {
154
+ let body = e.body;
155
+ while (t.isUnaryExpression(body, { operator: '!' }))
156
+ body = body.argument;
157
+ tested.add(body);
158
+ }
159
+ let found = false;
160
+ t.traverseFast(e, (n) => {
161
+ if (tested.has(n))
162
+ return;
163
+ if ((t.isMemberExpression(n) || t.isOptionalMemberExpression(n)) && ((!n.computed && t.isIdentifier(n.property) && keys.has(n.property.name)) || (t.isStringLiteral(n.property) && keys.has(n.property.value))))
164
+ found = true;
165
+ if (t.isObjectPattern(n) && n.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key) && keys.has(p.key.name)))
166
+ found = true;
167
+ });
168
+ return found;
169
+ }
170
+ /**
171
+ * The receivers of a file's banked markup, or why one read of it cannot be followed (then the file stays refused).
172
+ * A component prop whose value is computed from the data (`options={paths ? OPTIONS : []}`, `steps={steps(ink).slice(0, n)}`)
173
+ * receives it, unless that value only reads plain data out of it (`count={OPTIONS.length}`); every other read (a
174
+ * handler, script code, the template) must only read plain data out of it (readsOnlyData).
175
+ */
176
+ export function bankReceivers(mod, holders, keys = new Set()) {
177
+ const receivers = [];
178
+ let refused = null;
179
+ let line = null;
180
+ const refuse = (why, at) => {
181
+ if (refused)
182
+ return;
183
+ refused = why;
184
+ line = at.loc?.start.line ?? null;
185
+ };
186
+ const holds = (e) => [...readNames(e)].some((n) => holders.has(n));
187
+ for (const comp of mod.components) {
188
+ // a read in the component's script (a handler, an effect, a derived value) that may carry markup is not followed
189
+ for (const item of comp.items)
190
+ for (const v of Object.values(item))
191
+ if (t.isNode(v) && holds(v) && !readsOnlyData(v, holders, keys))
192
+ refuse(`${comp.name} reads it in its script code`, v);
193
+ walk([comp.template], (n) => {
194
+ if (n.type === 'expr' && holds(n.expr) && !readsOnlyData(n.expr, holders, keys))
195
+ refuse(`${comp.name} renders it directly`, n.expr);
196
+ if (n.type !== 'element')
197
+ return;
198
+ for (const a of n.attrs) {
199
+ const e = a.kind === 'event' ? a.handler : a.kind === 'static' || a.kind === 'bool' || a.kind === 'slotProp' ? null : a.expr;
200
+ if (!e || !holds(e) || readsOnlyData(e, holders, keys))
201
+ continue;
202
+ if (a.kind !== 'expr' || !n.component) {
203
+ refuse(`<${n.tag}> ${a.kind === 'expr' ? 'is not a component' : a.kind === 'event' ? 'reads it in a handler' : `reads it in its ${a.kind}`}`, e);
204
+ continue;
205
+ }
206
+ if (!receivers.some((r) => r.tag === n.tag && r.prop === a.name))
207
+ receivers.push({ tag: n.tag, prop: a.name, line: e.loc?.start.line ?? null });
208
+ }
209
+ });
210
+ }
211
+ return { receivers, refused, line };
212
+ }
213
+ /**
214
+ * The component's values that are an entry or a member of the prop, read through a chain of members and indexes
215
+ * (`const current = steps[index]`): the same data under another name, followed like the prop. The derived items that
216
+ * declare them are returned too, so the script check does not count them as reads that carry the data away.
217
+ */
218
+ export function propAliases(comp, local) {
219
+ const out = new Map();
220
+ let grew = true;
221
+ while (grew) {
222
+ grew = false;
223
+ for (const item of comp.items) {
224
+ if (item.kind !== 'derived' || !t.isIdentifier(item.id) || out.has(item.id.name))
225
+ continue;
226
+ let n = item.init;
227
+ while (t.isMemberExpression(n) || t.isOptionalMemberExpression(n) || t.isTSNonNullExpression(n))
228
+ n = t.isTSNonNullExpression(n) ? n.expression : n.object;
229
+ if (n === item.init || !t.isIdentifier(n) || (n.name !== local && !out.has(n.name)))
230
+ continue;
231
+ out.set(item.id.name, item);
232
+ grew = true;
233
+ }
234
+ }
235
+ return out;
236
+ }
237
+ /**
238
+ * The `{…}` reads of a receiver's template that render a value coming through `prop`: the prop itself or a member of
239
+ * it, or a loop variable over it (`options.map((o) => … {o.icon} …)`) or a member of that. These, and only these,
240
+ * render through `[morphNode]`.
241
+ */
242
+ export function readsOfProp(comp, prop) {
243
+ const decl = comp.props.find((p) => p.key === prop);
244
+ const out = new Set();
245
+ if (!decl)
246
+ return out;
247
+ const aliases = propAliases(comp, decl.local);
248
+ const fromProp = (e) => {
249
+ if (comp.propsObject && (t.isMemberExpression(e) || t.isOptionalMemberExpression(e))) {
250
+ let n = e;
251
+ while ((t.isMemberExpression(n) || t.isOptionalMemberExpression(n)) && !t.isIdentifier(n.object, { name: comp.propsObject }))
252
+ n = n.object;
253
+ if ((t.isMemberExpression(n) || t.isOptionalMemberExpression(n)) && !n.computed && t.isIdentifier(n.property, { name: prop }))
254
+ return true;
255
+ }
256
+ const root = rootName(e);
257
+ return root === decl.local || (root !== null && aliases.has(root));
258
+ };
259
+ walk([comp.template], (n, loops) => {
260
+ if (n.type !== 'expr')
261
+ return;
262
+ const root = rootName(n.expr);
263
+ if (fromProp(n.expr)) {
264
+ out.add(n);
265
+ return;
266
+ }
267
+ // a loop variable bound by a loop over the prop (or over a loop variable that is)
268
+ const over = (name, depth) => {
269
+ for (let i = depth - 1; i >= 0; i--) {
270
+ const loop = loops[i];
271
+ if (!loop || !t.isIdentifier(loop.item) || loop.item.name !== name)
272
+ continue;
273
+ return fromProp(loop.iterable) || over(rootName(loop.iterable), i);
274
+ }
275
+ return false;
276
+ };
277
+ if (over(root, loops.length))
278
+ out.add(n);
279
+ });
280
+ return out;
281
+ }
282
+ /** The `slot` nodes of a receiver's template that render the prop whole (a node prop: `{icon}` of `icon: ReactNode`). */
283
+ export function slotsOfProp(comp, prop) {
284
+ const decl = comp.props.find((p) => p.key === prop);
285
+ const out = new Set();
286
+ if (!decl)
287
+ return out;
288
+ walk([comp.template], (n) => {
289
+ if (n.type === 'slot' && n.prop === decl.local && !n.args?.length)
290
+ out.add(n);
291
+ });
292
+ return out;
293
+ }
@@ -0,0 +1,14 @@
1
+ /** The directive's class name, as a component's `imports` list it. */
2
+ export declare const MARKUP_NODE = "MorphNode";
3
+ /** The runtime's type of what React renders as `{node}` (not `Node`: the DOM's own type keeps its name). */
4
+ export declare const MARKUP_NODE_TYPE = "MarkupNode";
5
+ /** The runtime file, at the root of the output, written once per conversion (see ../helpers.ts). */
6
+ export declare const MARKUP_NODE_PATH = "markup-node.directive.ts";
7
+ /**
8
+ * The template bank's runtime: markup that lives outside a component's own template (a module's table of icons, a
9
+ * helper that returns markup, markup passed between functions and files) is plain data, `{ bank, name, context }`,
10
+ * where `bank` is a component whose template is only `<ng-template>` blocks. `MorphNode` stamps such a value where
11
+ * React renders `{node}`, with no element of its own; `MarkupBanks` creates each bank once per application, off the
12
+ * page, and destroys it with the application.
13
+ */
14
+ export declare const MARKUP_NODE_FILE = "import {\n ChangeDetectionStrategy,\n Component,\n Directive,\n EnvironmentInjector,\n Injectable,\n Input,\n ViewContainerRef,\n createComponent,\n inject,\n viewChild,\n type ComponentRef,\n type EmbeddedViewRef,\n type OnChanges,\n type OnDestroy,\n type Signal,\n type TemplateRef,\n type Type,\n} from '@angular/core';\n\n/** A component whose template is only `<ng-template>` blocks, each a piece of markup kept outside a component. */\nexport interface MarkupBank {\n readonly templates: Readonly<Record<string, Signal<TemplateRef<object>>>>;\n}\n\n/** A piece of markup as a value: which banked template, with which context, and React's key when it had one. */\nexport interface Markup<C extends object = object> {\n readonly bank: Type<MarkupBank>;\n readonly name: string;\n readonly context: C;\n readonly key?: string | number;\n}\n\n/** What React renders for `{node}`: markup, text, a list of nodes, or nothing. */\nexport type MarkupNode = Markup | string | number | bigint | boolean | null | undefined | readonly MarkupNode[];\n\nexport function markup<C extends object>(bank: Type<MarkupBank>, name: string, context: C, key?: string | number): Markup<C> {\n return key === undefined ? { bank, name, context } : { bank, name, context, key };\n}\n\n/** React's `isValidElement` for these values. */\nexport function isMarkup(node: unknown): node is Markup {\n return typeof node === 'object' && node !== null && !Array.isArray(node) && 'bank' in node && 'name' in node && 'context' in node;\n}\n\n/** Text and numbers in a node: one text node each, as React writes them. */\n@Component({\n selector: 'morph-text-bank',\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `<ng-template #text let-value=\"value\">{{ value }}</ng-template>`,\n})\nexport class TextBank implements MarkupBank {\n private readonly text = viewChild.required<TemplateRef<object>>('text');\n readonly templates = { text: this.text };\n}\n\n/**\n * Every bank of the application, each created on first use, never attached to the page (its host element is not in\n * the document) and never checked again (a bank has no bindings); destroyed with the application's root injector.\n */\n@Injectable({ providedIn: 'root' })\nexport class MarkupBanks implements OnDestroy {\n private readonly injector = inject(EnvironmentInjector);\n private readonly banks = new Map<Type<MarkupBank>, ComponentRef<MarkupBank>>();\n\n template(bank: Type<MarkupBank>, name: string): TemplateRef<object> {\n let ref = this.banks.get(bank);\n if (!ref) {\n ref = createComponent(bank, { environmentInjector: this.injector });\n // one pass resolves the template queries\n ref.changeDetectorRef.detectChanges();\n this.banks.set(bank, ref);\n }\n const template = ref.instance.templates[name];\n if (!template) throw new Error(`The markup bank ${bank.name} has no template named ${name}.`);\n return template();\n }\n\n ngOnDestroy(): void {\n for (const ref of this.banks.values()) ref.destroy();\n this.banks.clear();\n }\n}\n\ninterface Shown {\n bank: Type<MarkupBank>;\n name: string;\n key: string | number | undefined;\n view: EmbeddedViewRef<object>;\n context: Record<string, unknown>;\n}\n\n/**\n * Renders a node where React renders `{node}`, with no element of its own: each piece of markup is an embedded view\n * of its banked template at this anchor. As React reconciles, a view is kept while the same template stays at the same\n * key (or, unkeyed, the same position), and only its context changes; keyed views move instead of being recreated.\n */\n@Directive({ selector: 'ng-container[morphNode]' })\nexport class MorphNode implements OnChanges {\n @Input({ required: true }) morphNode: MarkupNode = null;\n private readonly container = inject(ViewContainerRef);\n private readonly banks = inject(MarkupBanks);\n private shown: Shown[] = [];\n\n ngOnChanges(): void {\n // React's commit puts the focus back on a focused element that the update moved (a keyed view moved below)\n const focused = typeof document === 'undefined' ? null : document.activeElement;\n const items: Markup[] = [];\n const flatten = (node: MarkupNode): void => {\n if (Array.isArray(node)) for (const n of node) flatten(n);\n else if (isMarkup(node)) items.push(node);\n else if (typeof node === 'string' || typeof node === 'number' || typeof node === 'bigint') items.push(markup(TextBank, 'text', { value: node }));\n };\n flatten(this.morphNode);\n const before = this.shown;\n const old = [...before];\n const next: Shown[] = [];\n items.forEach((item, index) => {\n const same = (s: Shown | undefined): s is Shown => s !== undefined && s.bank === item.bank && s.name === item.name && s.key === item.key;\n const kept = item.key === undefined ? (same(before[index]) && old.includes(before[index]) ? before[index] : undefined) : old.find(same);\n if (kept) {\n old.splice(old.indexOf(kept), 1);\n for (const k of Object.keys(kept.context)) if (!(k in item.context)) delete kept.context[k];\n Object.assign(kept.context, item.context);\n if (this.container.indexOf(kept.view) !== index) this.container.move(kept.view, index);\n next.push(kept);\n return;\n }\n const context: Record<string, unknown> = { ...item.context };\n const view = this.container.createEmbeddedView(this.banks.template(item.bank, item.name), context, index);\n next.push({ bank: item.bank, name: item.name, key: item.key, view, context });\n });\n for (const s of old) s.view.destroy();\n this.shown = next;\n if (focused instanceof HTMLElement && focused !== document.activeElement && focused.isConnected) focused.focus();\n }\n}\n";
@@ -0,0 +1,152 @@
1
+ /** The directive's class name, as a component's `imports` list it. */
2
+ export const MARKUP_NODE = 'MorphNode';
3
+ /** The runtime's type of what React renders as `{node}` (not `Node`: the DOM's own type keeps its name). */
4
+ export const MARKUP_NODE_TYPE = 'MarkupNode';
5
+ /** The runtime file, at the root of the output, written once per conversion (see ../helpers.ts). */
6
+ export const MARKUP_NODE_PATH = 'markup-node.directive.ts';
7
+ /**
8
+ * The template bank's runtime: markup that lives outside a component's own template (a module's table of icons, a
9
+ * helper that returns markup, markup passed between functions and files) is plain data, `{ bank, name, context }`,
10
+ * where `bank` is a component whose template is only `<ng-template>` blocks. `MorphNode` stamps such a value where
11
+ * React renders `{node}`, with no element of its own; `MarkupBanks` creates each bank once per application, off the
12
+ * page, and destroys it with the application.
13
+ */
14
+ // M4: MorphNode.ngOnChanges puts the focus back on a focused element a keyed move took it from, as React's commit does
15
+ export const MARKUP_NODE_FILE = `import {
16
+ ChangeDetectionStrategy,
17
+ Component,
18
+ Directive,
19
+ EnvironmentInjector,
20
+ Injectable,
21
+ Input,
22
+ ViewContainerRef,
23
+ createComponent,
24
+ inject,
25
+ viewChild,
26
+ type ComponentRef,
27
+ type EmbeddedViewRef,
28
+ type OnChanges,
29
+ type OnDestroy,
30
+ type Signal,
31
+ type TemplateRef,
32
+ type Type,
33
+ } from '@angular/core';
34
+
35
+ /** A component whose template is only \`<ng-template>\` blocks, each a piece of markup kept outside a component. */
36
+ export interface MarkupBank {
37
+ readonly templates: Readonly<Record<string, Signal<TemplateRef<object>>>>;
38
+ }
39
+
40
+ /** A piece of markup as a value: which banked template, with which context, and React's key when it had one. */
41
+ export interface Markup<C extends object = object> {
42
+ readonly bank: Type<MarkupBank>;
43
+ readonly name: string;
44
+ readonly context: C;
45
+ readonly key?: string | number;
46
+ }
47
+
48
+ /** What React renders for \`{node}\`: markup, text, a list of nodes, or nothing. */
49
+ export type MarkupNode = Markup | string | number | bigint | boolean | null | undefined | readonly MarkupNode[];
50
+
51
+ export function markup<C extends object>(bank: Type<MarkupBank>, name: string, context: C, key?: string | number): Markup<C> {
52
+ return key === undefined ? { bank, name, context } : { bank, name, context, key };
53
+ }
54
+
55
+ /** React's \`isValidElement\` for these values. */
56
+ export function isMarkup(node: unknown): node is Markup {
57
+ return typeof node === 'object' && node !== null && !Array.isArray(node) && 'bank' in node && 'name' in node && 'context' in node;
58
+ }
59
+
60
+ /** Text and numbers in a node: one text node each, as React writes them. */
61
+ @Component({
62
+ selector: 'morph-text-bank',
63
+ changeDetection: ChangeDetectionStrategy.OnPush,
64
+ template: \`<ng-template #text let-value="value">{{ value }}</ng-template>\`,
65
+ })
66
+ export class TextBank implements MarkupBank {
67
+ private readonly text = viewChild.required<TemplateRef<object>>('text');
68
+ readonly templates = { text: this.text };
69
+ }
70
+
71
+ /**
72
+ * Every bank of the application, each created on first use, never attached to the page (its host element is not in
73
+ * the document) and never checked again (a bank has no bindings); destroyed with the application's root injector.
74
+ */
75
+ @Injectable({ providedIn: 'root' })
76
+ export class MarkupBanks implements OnDestroy {
77
+ private readonly injector = inject(EnvironmentInjector);
78
+ private readonly banks = new Map<Type<MarkupBank>, ComponentRef<MarkupBank>>();
79
+
80
+ template(bank: Type<MarkupBank>, name: string): TemplateRef<object> {
81
+ let ref = this.banks.get(bank);
82
+ if (!ref) {
83
+ ref = createComponent(bank, { environmentInjector: this.injector });
84
+ // one pass resolves the template queries
85
+ ref.changeDetectorRef.detectChanges();
86
+ this.banks.set(bank, ref);
87
+ }
88
+ const template = ref.instance.templates[name];
89
+ if (!template) throw new Error(\`The markup bank \${bank.name} has no template named \${name}.\`);
90
+ return template();
91
+ }
92
+
93
+ ngOnDestroy(): void {
94
+ for (const ref of this.banks.values()) ref.destroy();
95
+ this.banks.clear();
96
+ }
97
+ }
98
+
99
+ interface Shown {
100
+ bank: Type<MarkupBank>;
101
+ name: string;
102
+ key: string | number | undefined;
103
+ view: EmbeddedViewRef<object>;
104
+ context: Record<string, unknown>;
105
+ }
106
+
107
+ /**
108
+ * Renders a node where React renders \`{node}\`, with no element of its own: each piece of markup is an embedded view
109
+ * of its banked template at this anchor. As React reconciles, a view is kept while the same template stays at the same
110
+ * key (or, unkeyed, the same position), and only its context changes; keyed views move instead of being recreated.
111
+ */
112
+ @Directive({ selector: 'ng-container[morphNode]' })
113
+ export class MorphNode implements OnChanges {
114
+ @Input({ required: true }) morphNode: MarkupNode = null;
115
+ private readonly container = inject(ViewContainerRef);
116
+ private readonly banks = inject(MarkupBanks);
117
+ private shown: Shown[] = [];
118
+
119
+ ngOnChanges(): void {
120
+ // React's commit puts the focus back on a focused element that the update moved (a keyed view moved below)
121
+ const focused = typeof document === 'undefined' ? null : document.activeElement;
122
+ const items: Markup[] = [];
123
+ const flatten = (node: MarkupNode): void => {
124
+ if (Array.isArray(node)) for (const n of node) flatten(n);
125
+ else if (isMarkup(node)) items.push(node);
126
+ else if (typeof node === 'string' || typeof node === 'number' || typeof node === 'bigint') items.push(markup(TextBank, 'text', { value: node }));
127
+ };
128
+ flatten(this.morphNode);
129
+ const before = this.shown;
130
+ const old = [...before];
131
+ const next: Shown[] = [];
132
+ items.forEach((item, index) => {
133
+ const same = (s: Shown | undefined): s is Shown => s !== undefined && s.bank === item.bank && s.name === item.name && s.key === item.key;
134
+ const kept = item.key === undefined ? (same(before[index]) && old.includes(before[index]) ? before[index] : undefined) : old.find(same);
135
+ if (kept) {
136
+ old.splice(old.indexOf(kept), 1);
137
+ for (const k of Object.keys(kept.context)) if (!(k in item.context)) delete kept.context[k];
138
+ Object.assign(kept.context, item.context);
139
+ if (this.container.indexOf(kept.view) !== index) this.container.move(kept.view, index);
140
+ next.push(kept);
141
+ return;
142
+ }
143
+ const context: Record<string, unknown> = { ...item.context };
144
+ const view = this.container.createEmbeddedView(this.banks.template(item.bank, item.name), context, index);
145
+ next.push({ bank: item.bank, name: item.name, key: item.key, view, context });
146
+ });
147
+ for (const s of old) s.view.destroy();
148
+ this.shown = next;
149
+ if (focused instanceof HTMLElement && focused !== document.activeElement && focused.isConnected) focused.focus();
150
+ }
151
+ }
152
+ `;
@@ -0,0 +1,7 @@
1
+ import type { ElementNode } from '../../ir/model.js';
2
+ /** The directive's class name, as a component's `imports` list it. */
3
+ export declare const CONTROLLED = "Controlled";
4
+ /** The directive's file, written once per conversion and imported by every component with a controlled field. */
5
+ export declare const CONTROLLED_FILE = "import { afterEveryRender, Directive, ElementRef, inject, input } from '@angular/core';\n\n/**\n * React's controlled field (`value={draft}`): after every render, and so after every event whatever it changed, the\n * field shows the value the component holds, as React puts it back. Angular's own `[value]` writes only when the bound\n * value changes, so a field typed into and then cleared before the next check would keep its text.\n */\n@Directive({ selector: '[controlled]' })\nexport class Controlled {\n readonly value = input<string | number | null | undefined>();\n private readonly element = inject<ElementRef<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>>(ElementRef).nativeElement;\n\n constructor() {\n afterEveryRender({\n write: () => {\n const value = this.value();\n const text = value == null ? '' : String(value);\n if (this.element.value !== text) this.element.value = text;\n },\n });\n }\n}\n";
6
+ /** Whether an element is a field React controls: an input (not a box or a radio), a textarea or a select whose value is bound. */
7
+ export declare function isControlledField(n: ElementNode): boolean;
@@ -0,0 +1,37 @@
1
+ /** The directive's class name, as a component's `imports` list it. */
2
+ export const CONTROLLED = 'Controlled';
3
+ /** The directive's file, written once per conversion and imported by every component with a controlled field. */
4
+ export const CONTROLLED_FILE = `import { afterEveryRender, Directive, ElementRef, inject, input } from '@angular/core';
5
+
6
+ /**
7
+ * React's controlled field (\`value={draft}\`): after every render, and so after every event whatever it changed, the
8
+ * field shows the value the component holds, as React puts it back. Angular's own \`[value]\` writes only when the bound
9
+ * value changes, so a field typed into and then cleared before the next check would keep its text.
10
+ */
11
+ @Directive({ selector: '[controlled]' })
12
+ export class Controlled {
13
+ readonly value = input<string | number | null | undefined>();
14
+ private readonly element = inject<ElementRef<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>>(ElementRef).nativeElement;
15
+
16
+ constructor() {
17
+ afterEveryRender({
18
+ write: () => {
19
+ const value = this.value();
20
+ const text = value == null ? '' : String(value);
21
+ if (this.element.value !== text) this.element.value = text;
22
+ },
23
+ });
24
+ }
25
+ }
26
+ `;
27
+ /** Whether an element is a field React controls: an input (not a box or a radio), a textarea or a select whose value is bound. */
28
+ export function isControlledField(n) {
29
+ if (n.component || !/^(input|textarea|select)$/.test(n.tag))
30
+ return false;
31
+ const type = n.attrs.find((a) => a.kind === 'static' && a.name === 'type');
32
+ if (type?.kind === 'static' && /^(checkbox|radio|file)$/.test(type.value))
33
+ return false;
34
+ if (n.attrs.some((a) => (a.kind === 'bool' && a.name === 'multiple')))
35
+ return false;
36
+ return n.attrs.some((a) => a.kind === 'expr' && a.name === 'value');
37
+ }
@@ -0,0 +1,34 @@
1
+ import * as t from '@babel/types';
2
+ import type { ComponentIR, ElementNode, ModuleIR } from '../../ir/model.js';
3
+ /**
4
+ * A tag held in a variable whose values are a known set of elements. An Angular template names every tag it writes, so
5
+ * the element is an `@switch` over the value with one branch per tag; each branch writes the same attributes, and the
6
+ * children once, in an `<ng-template>` every branch renders. Exact for two sources:
7
+ * - a prop typed as a union of tag names (`as?: 'h1' | 'p'`, or a type alias of the file naming one), with a default
8
+ * or required: the value is always one of them;
9
+ * - a lookup in a constant object of the file (`const els = { p: motion.p, span: 'span' }`, `els[as]`) whose values
10
+ * are intrinsic or motion elements, which React's checker accepted (an index outside its keys types the lookup as
11
+ * `any` in strict mode, and the lookup is then not converted): each key is a branch rendering its value's element.
12
+ */
13
+ export interface TagChoice {
14
+ /** the value the branches test (the prop, the lookup's key) */
15
+ subject: t.Expression;
16
+ cases: {
17
+ value: string;
18
+ tag: string;
19
+ motion: boolean;
20
+ }[];
21
+ }
22
+ /** `typed`: whether React's checker gave a source expression a type (not `any`: a string type, or components). */
23
+ export declare function tagChoice(comp: ComponentIR, mod: ModuleIR, name: string, typed: (e: t.Expression) => boolean): TagChoice | null;
24
+ /**
25
+ * A table of motion elements (`const els = { p: motion.p }`) read only as `els[key]` into a value the markup renders
26
+ * as its tag: the template's `@switch` writes each element itself, so on Angular the table holds each one's tag name
27
+ * (`{ p: 'p' }`), which keeps its keys for the types that name them (`keyof typeof els`) and reads no `motion` export.
28
+ */
29
+ export declare function motionTablesAsTags(mod: ModuleIR): t.Statement[];
30
+ /**
31
+ * The element one branch writes: the variable's element with this tag, its props as that element takes them (React's
32
+ * DOM names, DOM events, Framer's props on a motion element); a reason when a prop has no element counterpart.
33
+ */
34
+ export declare function asTagElement(n: ElementNode, c: TagChoice['cases'][number]): ElementNode | string;