@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,72 @@
1
+ import * as t from '@babel/types';
2
+ /**
3
+ * The default a component gives a prop it reads off its props object (`const { unit = '' } = props`), or null: React
4
+ * applies it when the prop is undefined, as a parent that passes its own props on may pass it.
5
+ */
6
+ export function propsObjectDefault(comp, key) {
7
+ for (const item of comp.items) {
8
+ if (item.kind !== 'derived' || !t.isObjectPattern(item.id) || !t.isIdentifier(item.init))
9
+ continue;
10
+ const name = comp.refs.get(item.init);
11
+ if (!name || comp.bindings.get(name)?.kind !== 'propsObject')
12
+ continue;
13
+ for (const p of item.id.properties) {
14
+ if (!t.isObjectProperty(p) || p.computed || !t.isIdentifier(p.key, { name: key }))
15
+ continue;
16
+ if (t.isAssignmentPattern(p.value))
17
+ return p.value.right;
18
+ }
19
+ }
20
+ return null;
21
+ }
22
+ /**
23
+ * The keys of a props spread that an attribute written before it also sets (`onSubmit={…} {...props}`). React's spread
24
+ * wins there where the parent gave the prop; the binding keeps the attribute (an input cannot tell a prop not given
25
+ * from one given as undefined), so where the parent does give it, React and Angular differ: said as a warning.
26
+ */
27
+ export function setBeforeSpread(n, attr, keys) {
28
+ const before = new Set(n.attrs.slice(0, Math.max(0, n.attrs.indexOf(attr))).flatMap(attrNames));
29
+ return keys.filter((k) => before.has(k));
30
+ }
31
+ /** The prop names an attribute of an element sets itself (not a spread). */
32
+ function attrNames(a) {
33
+ if (a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool')
34
+ return [a.name === 'class' ? 'className' : a.name];
35
+ if (a.kind === 'event')
36
+ return [a.react];
37
+ if (a.kind === 'style')
38
+ return ['style'];
39
+ if (a.kind === 'slotProp')
40
+ return [a.name];
41
+ return [];
42
+ }
43
+ /**
44
+ * Why a component's own props object (or rest props), spread onto a child component (`<View {...DEFAULTS} {...props} />`),
45
+ * cannot be passed on input by input exactly, or null when it can. Each key the spread passes is bound from the
46
+ * component's input of that name; an attribute written after the spread wins over it, as in React. Refused, with the
47
+ * reason (the spread stays an `angular-spread` error, never dropped):
48
+ * - no key of the props object is known (its type could not be read), so nothing would reach the child;
49
+ * - another spread on the element passes keys that are not known, or the same key (which one wins depends, again, on
50
+ * whether the parent gave it);
51
+ * - the child takes some of the keys only through its own rest props, which its list of inputs does not carry.
52
+ */
53
+ export function forwardRefusal(n, attr, keys, childKeys, child, known) {
54
+ if (!keys.length)
55
+ return "the props object's keys are not known (its props type could not be read), so nothing would reach the child";
56
+ for (const other of n.attrs) {
57
+ if (other === attr || other.kind !== 'spread')
58
+ continue;
59
+ const theirs = known(other.expr);
60
+ if (!theirs)
61
+ return 'another spread on the element passes keys that are not known, and the later one wins where both pass a key';
62
+ const shared = theirs.filter((k) => keys.includes(k));
63
+ if (shared.length)
64
+ return `another spread on the element also passes ${shared.slice(0, 4).join(', ')}, and which one wins depends on whether the parent gave ${shared.length > 1 ? 'them' : 'it'}`;
65
+ }
66
+ if (child?.rest && childKeys) {
67
+ const extra = keys.filter((k) => !childKeys.has(k));
68
+ if (extra.length)
69
+ return `<${n.tag}> takes ${extra.slice(0, 4).join(', ')}${extra.length > 4 ? ` and ${extra.length - 4} more` : ''} only through its rest props, which its inputs do not carry`;
70
+ }
71
+ return null;
72
+ }
@@ -0,0 +1,32 @@
1
+ import * as t from '@babel/types';
2
+ import type { ComponentIR } from '../../ir/model.js';
3
+ /**
4
+ * React's `{...props}` on an element. Angular templates have no attribute spreading, so the spread object goes to one
5
+ * small directive, `[spreadProps]`, which sets each prop as React DOM would (a class, a style, a listener, a DOM property
6
+ * or an attribute) and takes back what it set when the object changes or the element leaves.
7
+ */
8
+ /** The directive's class name, as a component's `imports` list it. */
9
+ export declare const SPREAD = "SpreadProps";
10
+ /** The directive's file, written once per conversion and imported by every component that spreads props this way. */
11
+ export declare const SPREAD_FILE = "import { afterRenderEffect, Directive, ElementRef, inject, input, untracked } from '@angular/core';\n\n/**\n * React's `{...props}` on an element: each prop set as React DOM sets it (className, style, `on*` listeners, DOM\n * properties, attributes), and taken back when the object changes or the element leaves.\n */\n@Directive({ selector: '[spreadProps]' })\nexport class SpreadProps {\n readonly spreadProps = input.required<object | null | undefined>();\n private readonly element = inject<ElementRef<HTMLElement | SVGElement>>(ElementRef).nativeElement;\n\n constructor() {\n // after the render, so a select's options are there when its value is set\n let first = true;\n afterRenderEffect((onCleanup) => {\n const props = this.spreadProps() ?? {};\n onCleanup(untracked(() => applyProps(this.element, props, first)));\n first = false;\n });\n }\n}\n\n/** Sets React props on an element (first: it has just been rendered); returns what undoes it. */\nfunction applyProps(element: HTMLElement | SVGElement, props: object, first: boolean): () => void {\n const undo: (() => void)[] = [];\n const svg = element instanceof SVGElement;\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || key === 'children' || key === 'key' || key === 'ref' || key === 'dangerouslySetInnerHTML') continue;\n if (key === 'defaultValue' && element instanceof HTMLSelectElement) {\n // a select has no default value of its own: React picks the option once, when it mounts\n if (first) element.value = String(value);\n } else if (/^on[A-Z]/.test(key) && typeof value === 'function') {\n const type = domEvent(element, key);\n const listener = (event: Event) => value(event);\n element.addEventListener(type, listener);\n undo.push(() => element.removeEventListener(type, listener));\n } else if (key === 'className' || key === 'class') {\n const classes = String(value ?? '').split(/\\s+/).filter(Boolean);\n element.classList.add(...classes);\n undo.push(() => element.classList.remove(...classes));\n } else if (key === 'style' && value && typeof value === 'object') {\n for (const [name, v] of Object.entries(value)) {\n if (v == null || v === false) continue;\n const property = name.startsWith('--') ? name : name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n element.style.setProperty(property, typeof v === 'number' && v !== 0 && !name.startsWith('--') && !UNITLESS.test(name) ? `${v}px` : String(v));\n undo.push(() => element.style.removeProperty(property));\n }\n } else if (!svg && key in element && typeof Reflect.get(element, key) !== 'object') {\n // a DOM property (value, checked, disabled, tabIndex, placeholder): set as React sets it, put back after\n const previous: unknown = Reflect.get(element, key);\n Reflect.set(element, key, value);\n undo.push(() => Reflect.set(element, key, previous));\n } else {\n const name = key === 'htmlFor' ? 'for' : /^(aria|data)-/.test(key) || !/[A-Z]/.test(key) ? key : svg ? (SVG_CAMEL.has(key) ? key : key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)) : key.toLowerCase();\n if (value === null || (value === false && !/^aria-/.test(key))) continue;\n element.setAttribute(name, value === true ? '' : String(value));\n undo.push(() => element.removeAttribute(name));\n }\n }\n return () => undo.forEach((step) => step());\n}\n\n/** The DOM event a React event prop listens to (`onChange` is `input` on a text field, `change` on a box or a select). */\nfunction domEvent(element: Element, key: string): string {\n const name = key.slice(2).toLowerCase();\n if (name === 'doubleclick') return 'dblclick';\n if (name === 'change') return element instanceof HTMLSelectElement || (element instanceof HTMLInputElement && /^(checkbox|radio|file)$/.test(element.type)) ? 'change' : 'input';\n return name;\n}\n\nconst UNITLESS = /^(opacity|zIndex|fontWeight|lineHeight|flex|flexGrow|flexShrink|order|scale|zoom)$/;\n/** SVG attributes React writes in camelCase that keep it */\nconst SVG_CAMEL = new Set(['viewBox', 'preserveAspectRatio', 'gradientUnits', 'gradientTransform', 'patternUnits', 'patternContentUnits', 'patternTransform', 'clipPathUnits', 'maskUnits', 'maskContentUnits', 'filterUnits', 'primitiveUnits', 'stdDeviation', 'pathLength', 'textLength', 'lengthAdjust', 'markerWidth', 'markerHeight', 'markerUnits', 'refX', 'refY', 'baseFrequency', 'numOctaves', 'tableValues', 'kernelMatrix', 'specularExponent', 'surfaceScale']);";
12
+ /**
13
+ * The HTML attributes a parent commonly passes to a component whose props inherit an element's attributes and which
14
+ * spreads the rest of its props on that element (`<input {...props} />`): each becomes an input, so the rest object
15
+ * carries it on to the element. Other inherited attributes (`aria-*`, `data-*`, listeners) cannot be inputs of an
16
+ * Angular component without being named; the emitter says so.
17
+ */
18
+ export declare const HTML_INPUTS: Record<string, Record<string, 'string' | 'number' | 'boolean' | 'value'>>;
19
+ /** Whether a props heritage type names React's HTML or SVG attribute types (`Omit<InputHTMLAttributes<…>, 'type'>`). */
20
+ export declare function inheritsHtml(heritage: readonly t.TSType[]): boolean;
21
+ /**
22
+ * The DOM element a component spreads its rest props on (`<input {...props} />`), if any. A Lucide icon
23
+ * (`isIcon`) renders as its own `<svg>`, which takes every attribute the icon has no input for.
24
+ */
25
+ export declare function restElement(comp: ComponentIR, isIcon?: (tag: string) => boolean): string | null;
26
+ /** The type of an HTML attribute input. */
27
+ export declare function htmlInputType(kind: 'string' | 'number' | 'boolean' | 'value'): t.TSType;
28
+ /**
29
+ * The keys of a module constant written as an object literal (`const SELECT_ROW = { size: 'sm', align: 'end' }`, with
30
+ * or without `as const`), so a spread of it on a component can be bound key by key; null otherwise.
31
+ */
32
+ export declare function constObjectKeys(moduleBody: t.Statement[], name: string): string[] | null;
@@ -0,0 +1,182 @@
1
+ import * as t from '@babel/types';
2
+ /**
3
+ * React's `{...props}` on an element. Angular templates have no attribute spreading, so the spread object goes to one
4
+ * small directive, `[spreadProps]`, which sets each prop as React DOM would (a class, a style, a listener, a DOM property
5
+ * or an attribute) and takes back what it set when the object changes or the element leaves.
6
+ */
7
+ /** The directive's class name, as a component's `imports` list it. */
8
+ export const SPREAD = 'SpreadProps';
9
+ /** The directive's file, written once per conversion and imported by every component that spreads props this way. */
10
+ export const SPREAD_FILE = `import { afterRenderEffect, Directive, ElementRef, inject, input, untracked } from '@angular/core';
11
+
12
+ /**
13
+ * React's \`{...props}\` on an element: each prop set as React DOM sets it (className, style, \`on*\` listeners, DOM
14
+ * properties, attributes), and taken back when the object changes or the element leaves.
15
+ */
16
+ @Directive({ selector: '[spreadProps]' })
17
+ export class SpreadProps {
18
+ readonly spreadProps = input.required<object | null | undefined>();
19
+ private readonly element = inject<ElementRef<HTMLElement | SVGElement>>(ElementRef).nativeElement;
20
+
21
+ constructor() {
22
+ // after the render, so a select's options are there when its value is set
23
+ let first = true;
24
+ afterRenderEffect((onCleanup) => {
25
+ const props = this.spreadProps() ?? {};
26
+ onCleanup(untracked(() => applyProps(this.element, props, first)));
27
+ first = false;
28
+ });
29
+ }
30
+ }
31
+
32
+ /** Sets React props on an element (first: it has just been rendered); returns what undoes it. */
33
+ function applyProps(element: HTMLElement | SVGElement, props: object, first: boolean): () => void {
34
+ const undo: (() => void)[] = [];
35
+ const svg = element instanceof SVGElement;
36
+ for (const [key, value] of Object.entries(props)) {
37
+ if (value === undefined || key === 'children' || key === 'key' || key === 'ref' || key === 'dangerouslySetInnerHTML') continue;
38
+ if (key === 'defaultValue' && element instanceof HTMLSelectElement) {
39
+ // a select has no default value of its own: React picks the option once, when it mounts
40
+ if (first) element.value = String(value);
41
+ } else if (/^on[A-Z]/.test(key) && typeof value === 'function') {
42
+ const type = domEvent(element, key);
43
+ const listener = (event: Event) => value(event);
44
+ element.addEventListener(type, listener);
45
+ undo.push(() => element.removeEventListener(type, listener));
46
+ } else if (key === 'className' || key === 'class') {
47
+ const classes = String(value ?? '').split(/\\s+/).filter(Boolean);
48
+ element.classList.add(...classes);
49
+ undo.push(() => element.classList.remove(...classes));
50
+ } else if (key === 'style' && value && typeof value === 'object') {
51
+ for (const [name, v] of Object.entries(value)) {
52
+ if (v == null || v === false) continue;
53
+ const property = name.startsWith('--') ? name : name.replace(/[A-Z]/g, (c) => \`-\${c.toLowerCase()}\`);
54
+ element.style.setProperty(property, typeof v === 'number' && v !== 0 && !name.startsWith('--') && !UNITLESS.test(name) ? \`\${v}px\` : String(v));
55
+ undo.push(() => element.style.removeProperty(property));
56
+ }
57
+ } else if (!svg && key in element && typeof Reflect.get(element, key) !== 'object') {
58
+ // a DOM property (value, checked, disabled, tabIndex, placeholder): set as React sets it, put back after
59
+ const previous: unknown = Reflect.get(element, key);
60
+ Reflect.set(element, key, value);
61
+ undo.push(() => Reflect.set(element, key, previous));
62
+ } else {
63
+ const name = key === 'htmlFor' ? 'for' : /^(aria|data)-/.test(key) || !/[A-Z]/.test(key) ? key : svg ? (SVG_CAMEL.has(key) ? key : key.replace(/[A-Z]/g, (c) => \`-\${c.toLowerCase()}\`)) : key.toLowerCase();
64
+ if (value === null || (value === false && !/^aria-/.test(key))) continue;
65
+ element.setAttribute(name, value === true ? '' : String(value));
66
+ undo.push(() => element.removeAttribute(name));
67
+ }
68
+ }
69
+ return () => undo.forEach((step) => step());
70
+ }
71
+
72
+ /** The DOM event a React event prop listens to (\`onChange\` is \`input\` on a text field, \`change\` on a box or a select). */
73
+ function domEvent(element: Element, key: string): string {
74
+ const name = key.slice(2).toLowerCase();
75
+ if (name === 'doubleclick') return 'dblclick';
76
+ if (name === 'change') return element instanceof HTMLSelectElement || (element instanceof HTMLInputElement && /^(checkbox|radio|file)$/.test(element.type)) ? 'change' : 'input';
77
+ return name;
78
+ }
79
+
80
+ const UNITLESS = /^(opacity|zIndex|fontWeight|lineHeight|flex|flexGrow|flexShrink|order|scale|zoom)$/;
81
+ /** SVG attributes React writes in camelCase that keep it */
82
+ const SVG_CAMEL = new Set(['viewBox', 'preserveAspectRatio', 'gradientUnits', 'gradientTransform', 'patternUnits', 'patternContentUnits', 'patternTransform', 'clipPathUnits', 'maskUnits', 'maskContentUnits', 'filterUnits', 'primitiveUnits', 'stdDeviation', 'pathLength', 'textLength', 'lengthAdjust', 'markerWidth', 'markerHeight', 'markerUnits', 'refX', 'refY', 'baseFrequency', 'numOctaves', 'tableValues', 'kernelMatrix', 'specularExponent', 'surfaceScale']);`;
83
+ /**
84
+ * The HTML attributes a parent commonly passes to a component whose props inherit an element's attributes and which
85
+ * spreads the rest of its props on that element (`<input {...props} />`): each becomes an input, so the rest object
86
+ * carries it on to the element. Other inherited attributes (`aria-*`, `data-*`, listeners) cannot be inputs of an
87
+ * Angular component without being named; the emitter says so.
88
+ */
89
+ export const HTML_INPUTS = {
90
+ input: { type: 'string', name: 'string', value: 'value', defaultValue: 'value', placeholder: 'string', disabled: 'boolean', readOnly: 'boolean', required: 'boolean', autoComplete: 'string', autoFocus: 'boolean', maxLength: 'number', minLength: 'number', min: 'value', max: 'value', step: 'value', pattern: 'string', inputMode: 'string', checked: 'boolean', defaultChecked: 'boolean', title: 'string', tabIndex: 'number' },
91
+ // a box or a radio button: the attributes a choice takes
92
+ 'input[checkbox]': { name: 'string', value: 'value', disabled: 'boolean', required: 'boolean', checked: 'boolean', defaultChecked: 'boolean', autoFocus: 'boolean', title: 'string', tabIndex: 'number' },
93
+ textarea: { name: 'string', value: 'string', defaultValue: 'string', placeholder: 'string', disabled: 'boolean', readOnly: 'boolean', required: 'boolean', rows: 'number', cols: 'number', maxLength: 'number', minLength: 'number', autoComplete: 'string', autoFocus: 'boolean', wrap: 'string', title: 'string', tabIndex: 'number' },
94
+ select: { name: 'string', value: 'value', defaultValue: 'value', disabled: 'boolean', required: 'boolean', multiple: 'boolean', autoComplete: 'string', autoFocus: 'boolean', title: 'string', tabIndex: 'number' },
95
+ button: { type: 'string', name: 'string', value: 'value', disabled: 'boolean', autoFocus: 'boolean', form: 'string', title: 'string', tabIndex: 'number' },
96
+ a: { href: 'string', target: 'string', rel: 'string', download: 'string', title: 'string', tabIndex: 'number' },
97
+ };
98
+ /** Whether a props heritage type names React's HTML or SVG attribute types (`Omit<InputHTMLAttributes<…>, 'type'>`). */
99
+ export function inheritsHtml(heritage) {
100
+ let found = false;
101
+ for (const h of heritage) {
102
+ t.traverseFast(h, (n) => {
103
+ if (!t.isTSTypeReference(n))
104
+ return;
105
+ const name = t.isIdentifier(n.typeName) ? n.typeName.name : t.isTSQualifiedName(n.typeName) ? n.typeName.right.name : '';
106
+ if (/HTMLAttributes$|^(SVGProps|SVGAttributes|AriaAttributes|DOMAttributes|DetailedHTMLProps|ComponentProps\w*|HTMLMotionProps|SVGMotionProps)$/.test(name))
107
+ found = true;
108
+ });
109
+ }
110
+ return found;
111
+ }
112
+ /**
113
+ * The DOM element a component spreads its rest props on (`<input {...props} />`), if any. A Lucide icon
114
+ * (`isIcon`) renders as its own `<svg>`, which takes every attribute the icon has no input for.
115
+ */
116
+ export function restElement(comp, isIcon = () => false) {
117
+ if (!comp.rest)
118
+ return null;
119
+ let tag = null;
120
+ const visit = (n) => {
121
+ if (tag)
122
+ return;
123
+ if (n.type === 'element') {
124
+ if ((!n.component || isIcon(n.tag)) && n.attrs.some((a) => a.kind === 'spread' && t.isIdentifier(a.expr, { name: comp.rest ?? '' }))) {
125
+ // `<input type="checkbox">` and `<input type="radio">` take a choice's attributes
126
+ const type = n.attrs.find((a) => a.kind === 'static' && a.name === 'type');
127
+ tag = n.component ? 'svg' : n.tag === 'input' && type?.kind === 'static' && /^(checkbox|radio)$/.test(type.value) ? 'input[checkbox]' : n.tag;
128
+ return;
129
+ }
130
+ for (const a of n.attrs)
131
+ if (a.kind === 'slotProp')
132
+ a.children.forEach(visit);
133
+ }
134
+ const kids = n.type === 'if' ? n.branches.flatMap((b) => b.children) : n.type === 'slot' ? n.fallback : 'children' in n ? n.children : [];
135
+ kids.forEach(visit);
136
+ };
137
+ visit(comp.template);
138
+ return tag;
139
+ }
140
+ /** The type of an HTML attribute input. */
141
+ export function htmlInputType(kind) {
142
+ if (kind === 'number')
143
+ return t.tsNumberKeyword();
144
+ if (kind === 'boolean')
145
+ return t.tsBooleanKeyword();
146
+ if (kind === 'value')
147
+ return t.tsUnionType([t.tsStringKeyword(), t.tsNumberKeyword()]);
148
+ return t.tsStringKeyword();
149
+ }
150
+ /**
151
+ * The keys of a module constant written as an object literal (`const SELECT_ROW = { size: 'sm', align: 'end' }`, with
152
+ * or without `as const`), so a spread of it on a component can be bound key by key; null otherwise.
153
+ */
154
+ export function constObjectKeys(moduleBody, name) {
155
+ for (const st of moduleBody) {
156
+ const decl = t.isExportNamedDeclaration(st) ? st.declaration : st;
157
+ if (!t.isVariableDeclaration(decl) || decl.kind !== 'const')
158
+ continue;
159
+ for (const d of decl.declarations) {
160
+ if (!t.isIdentifier(d.id, { name }) || !d.init)
161
+ continue;
162
+ let init = d.init;
163
+ while (t.isTSAsExpression(init) || t.isTSSatisfiesExpression(init))
164
+ init = init.expression;
165
+ if (!t.isObjectExpression(init))
166
+ return null;
167
+ const keys = [];
168
+ for (const p of init.properties) {
169
+ if (!t.isObjectProperty(p) || p.computed)
170
+ return null;
171
+ if (t.isIdentifier(p.key))
172
+ keys.push(p.key.name);
173
+ else if (t.isStringLiteral(p.key))
174
+ keys.push(p.key.value);
175
+ else
176
+ return null;
177
+ }
178
+ return keys;
179
+ }
180
+ }
181
+ return null;
182
+ }
@@ -0,0 +1,25 @@
1
+ import type { ComponentIR, ModuleIR } from '../../ir/model.js';
2
+ /**
3
+ * Components drawn inside SVG content. An Angular component renders through a host element, and a browser draws no
4
+ * shape inside an element the SVG namespace does not know (`<ui-dot>`), where React renders the component's shapes
5
+ * straight into the `<svg>`. A component of this file rendered only inside SVG content, and no other file's to render,
6
+ * takes an SVG `<g>` as its host instead: the parent writes `<svg:g uiDot …>` (the namespace is the element's, in the
7
+ * parent's template; Angular's selector parser keeps no namespace, so the selector is `g[uiDot]`), and the shapes of its
8
+ * template are SVG elements under that `<g>`. A `<g>` with no attributes of its own changes no drawing; it is one
9
+ * element more than React renders.
10
+ */
11
+ export interface SvgHosts {
12
+ /** the components of this file whose host is an SVG `<g>` */
13
+ hosts: Set<string>;
14
+ /** a component rendered inside SVG content that keeps its element host: why */
15
+ kept: Map<string, string>;
16
+ }
17
+ /** The attribute a `<g>` host is selected by: its element selector camel-cased (`ui-dot` → `uiDot`). */
18
+ export declare function svgHostAttribute(selector: string): string;
19
+ /**
20
+ * The components of this file whose host is an SVG `<g>`, found to a fixed point (a `<g>` host's own markup is SVG
21
+ * content, so the components it renders sit inside SVG too), and why each other component rendered inside SVG keeps
22
+ * its element host: it is exported (another file may render it outside SVG), or this file renders it outside SVG too
23
+ * (one Angular component has one host element), or it is another file's component.
24
+ */
25
+ export declare function svgHosts(mod: ModuleIR, inline: Map<string, ComponentIR>): SvgHosts;
@@ -0,0 +1,107 @@
1
+ /** The attribute a `<g>` host is selected by: its element selector camel-cased (`ui-dot` → `uiDot`). */
2
+ export function svgHostAttribute(selector) {
3
+ return selector.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
4
+ }
5
+ /**
6
+ * Where each component the file's markup renders sits: inside SVG content (from an `<svg>` down to a `<foreignObject>`)
7
+ * or outside it. A component written in place (`inline`) and a render helper are followed into their markup; the
8
+ * children a component is given render where the component puts them, which is taken to be where it sits (as the
9
+ * template printer takes it); markup held in data renders wherever the data is read, which is taken to be outside.
10
+ */
11
+ function placements(mod, inline, hosts) {
12
+ const inSvg = new Set();
13
+ const outside = new Set();
14
+ const following = new Set();
15
+ const walk = (nodes, svg, comp) => {
16
+ for (const n of nodes) {
17
+ switch (n.type) {
18
+ case 'element': {
19
+ if (n.portal) {
20
+ walk(n.children, false, comp);
21
+ break;
22
+ }
23
+ for (const a of n.attrs)
24
+ if (a.kind === 'slotProp')
25
+ walk(a.children, svg, comp);
26
+ if (!n.component) {
27
+ walk(n.children, n.tag === 'svg' ? true : n.tag === 'foreignObject' ? false : svg, comp);
28
+ break;
29
+ }
30
+ const written = inline.get(n.tag);
31
+ if (written && !following.has(written)) {
32
+ following.add(written);
33
+ walk([written.template], svg, written);
34
+ following.delete(written);
35
+ }
36
+ else
37
+ (svg ? inSvg : outside).add(n.tag);
38
+ walk(n.children, svg, comp);
39
+ break;
40
+ }
41
+ case 'if':
42
+ for (const b of n.branches)
43
+ walk(b.children, svg, comp);
44
+ break;
45
+ case 'for':
46
+ case 'fragment':
47
+ case 'keyed':
48
+ case 'presence':
49
+ walk(n.children, svg, comp);
50
+ break;
51
+ case 'slot':
52
+ walk(n.fallback, svg, comp);
53
+ break;
54
+ case 'render': {
55
+ const fragment = comp.fragments.find((f) => f.name === n.name);
56
+ if (fragment && !following.has(fragment)) {
57
+ following.add(fragment);
58
+ walk([fragment.template], svg, comp);
59
+ following.delete(fragment);
60
+ }
61
+ break;
62
+ }
63
+ case 'text':
64
+ case 'expr':
65
+ case 'unconverted':
66
+ break;
67
+ }
68
+ }
69
+ };
70
+ for (const comp of mod.components) {
71
+ if (inline.has(comp.name))
72
+ continue;
73
+ walk([comp.template], hosts.has(comp.name), comp);
74
+ for (const v of comp.markupValues ?? [])
75
+ walk([v.template], false, comp);
76
+ }
77
+ return { inSvg, outside };
78
+ }
79
+ /**
80
+ * The components of this file whose host is an SVG `<g>`, found to a fixed point (a `<g>` host's own markup is SVG
81
+ * content, so the components it renders sit inside SVG too), and why each other component rendered inside SVG keeps
82
+ * its element host: it is exported (another file may render it outside SVG), or this file renders it outside SVG too
83
+ * (one Angular component has one host element), or it is another file's component.
84
+ */
85
+ export function svgHosts(mod, inline) {
86
+ const exported = (c) => c.exported || mod.exportedNames.has(c.name) || mod.defaultExport === c.name;
87
+ let hosts = new Set();
88
+ for (;;) {
89
+ const { inSvg, outside } = placements(mod, inline, hosts);
90
+ const next = new Set(mod.components.filter((c) => !inline.has(c.name) && inSvg.has(c.name) && !outside.has(c.name) && !exported(c)).map((c) => c.name));
91
+ if (next.size === hosts.size) {
92
+ const kept = new Map();
93
+ for (const name of inSvg) {
94
+ if (hosts.has(name))
95
+ continue;
96
+ const own = mod.components.find((c) => c.name === name);
97
+ kept.set(name, !own
98
+ ? 'it is a component of another file, whose class keeps the element host other files render'
99
+ : outside.has(name)
100
+ ? 'this file renders it outside <svg> too, and one Angular component has one host element'
101
+ : 'it is exported, and a file that renders it outside <svg> needs its element host');
102
+ }
103
+ return { hosts, kept };
104
+ }
105
+ hosts = next;
106
+ }
107
+ }
@@ -0,0 +1,36 @@
1
+ import * as t from '@babel/types';
2
+ import type { ComponentIR } from '../../ir/model.js';
3
+ /**
4
+ * Angular's strict template check does not narrow a call: after `@if (label())`, `label().length` is still "possibly
5
+ * undefined", and so is `accent()[0]` after `typeof accent() === 'string' || !accent() ? …`. React read a value once per
6
+ * render, so the template reads such a value once too, as a `@let` (which the check narrows like a local).
7
+ *
8
+ * The bindings of a component that its template both tests (a branch test, a condition, the left of `&&` / `||` /
9
+ * `??`, `typeof`, `!`, a comparison) and reads more than once: these are the ones a narrowing must survive.
10
+ */
11
+ export declare function narrowedBindings(comp: ComponentIR): Map<string, 'self' | 'member'>;
12
+ /** `this.m()` (a signal read in class code), for members in `members`: the member's name, else null. */
13
+ export declare function signalRead(n: t.Node, members: ReadonlyMap<string, string>): string | null;
14
+ /** Whether an expression is a constant any file can write (literals, and arrays and objects of them). */
15
+ export declare function isConstant(e: t.Node): boolean;
16
+ /** The names an expression reads that the template declares (loop rows, `@let`s), in first-read order. */
17
+ export declare function templateNames(e: t.Node, inScope: (name: string) => boolean): string[];
18
+ /** A class member name from a hint (`aria-label` → `ariaLabel`, `class` → `classes`). */
19
+ export declare function memberName(hint: string): string;
20
+ /**
21
+ * Whether a class-form expression may be a `computed()`: it reads at least one signal (`this.m()`), and nothing whose
22
+ * changes a signal does not see: a plain field's value (a ref's `current`), the clock (`Date.now()`, `new Date()`,
23
+ * `Math.random()`), the DOM.
24
+ */
25
+ export declare function tracksAll(e: t.Node, signals: ReadonlySet<string>): boolean;
26
+ /** Whether an expression asserts a type (`x as T`, `x satisfies T`), which a template drops (`as const` included). */
27
+ export declare function assertsType(e: t.Node): boolean;
28
+ /** A function type's shape: whether it may be absent (`(() => void) | undefined`) and whether it takes an argument. */
29
+ export declare function functionShape(type: t.TSType | null): {
30
+ optional: boolean;
31
+ takes: boolean;
32
+ } | null;
33
+ /** A template expression as text: objects and arrays on one line (the formatter breaks them only where they are long). */
34
+ export declare function printTemplate(node: t.Node): string;
35
+ /** Types taken out of an expression for a template, except the non-null assertion (`cached!.id`), which templates keep. */
36
+ export declare function templateTypes(node: t.Expression): t.Expression;