@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,727 @@
1
+ import * as t from '@babel/types';
2
+ import { templateExpressions } from '../shared/inline.js';
3
+ import { svgHostAttribute } from './svg-hosts.js';
4
+ // (M3: domEventName, the DOM event a React handler listens to)
5
+ import { NG_PLANS, domEventName, radixNeedsOf, radixRestMapOf, radixRestPartOf, writtenContext } from './radix/prepare.js';
6
+ import { injectedDirectives, radixInputsAndOutputs } from './radix/template.js';
7
+ /** Each component in the host form, by its IR (set while the Radix parts are prepared, before any file is emitted). */
8
+ export const HOST_FORMS = new WeakMap();
9
+ /** The host form of a component, if it has one. */
10
+ export function hostFormOf(comp) {
11
+ return comp ? HOST_FORMS.get(comp) : undefined;
12
+ }
13
+ /** The HTML tags a plain host may have (each an element Angular lets a component select by an attribute). */
14
+ const HOSTLESS_TAGS = new Set([
15
+ 'a', 'abbr', 'article', 'aside', 'b', 'blockquote', 'button', 'caption', 'code', 'dd', 'details', 'div', 'dl', 'dt', 'em', 'fieldset', 'figcaption', 'figure',
16
+ 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'i', 'img', 'input', 'kbd', 'label', 'legend', 'li', 'main', 'mark', 'nav', 'ol', 'output',
17
+ 'p', 'pre', 'section', 'small', 'span', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'u', 'ul',
18
+ ]);
19
+ const NAME_USES = new WeakMap();
20
+ const USES_OF = new WeakMap();
21
+ const PLAIN_HOSTS = new WeakMap();
22
+ /**
23
+ * The children that make Angular's template parser close an element of this tag before them (Angular's own
24
+ * `closedByChildren`, @angular/compiler html_tags): a caller writing `<p uiNote><div>…</div></p>`, or `<p><div uiCard>`,
25
+ * would not parse, so a component written in such a place keeps its element host.
26
+ */
27
+ const CLOSED_BY = {
28
+ p: ['address', 'article', 'aside', 'blockquote', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'],
29
+ thead: ['tbody', 'tfoot'],
30
+ tbody: ['tbody', 'tfoot'],
31
+ tfoot: ['tbody'],
32
+ tr: ['tr'],
33
+ td: ['td', 'th'],
34
+ th: ['td', 'th'],
35
+ li: ['li'],
36
+ dt: ['dt', 'dd'],
37
+ dd: ['dt', 'dd'],
38
+ };
39
+ const nameOf = (n) => (n.component ? `<${n.tag}` : n.tag);
40
+ const noteIn = (map, key, value) => {
41
+ let known = map.get(key);
42
+ if (!known)
43
+ map.set(key, (known = new Set()));
44
+ known.add(value);
45
+ };
46
+ /** The elements written directly as children (through branches, loops and fragments), each noted. */
47
+ function childElements(nodes, note) {
48
+ for (const n of nodes) {
49
+ if (n.type === 'element')
50
+ note(n);
51
+ else if (n.type === 'if')
52
+ for (const b of n.branches)
53
+ childElements(b.children, note);
54
+ else if (n.type === 'slot')
55
+ childElements(n.fallback, note);
56
+ else if (n.type === 'for' || n.type === 'fragment' || n.type === 'keyed' || n.type === 'presence')
57
+ childElements(n.children, note);
58
+ }
59
+ }
60
+ /**
61
+ * The component tags in markup as lowered (elements, branches, loops, slots and the markup passed as props), with the
62
+ * elements written directly inside and around each.
63
+ */
64
+ function renderedTags(n, into, children, parents) {
65
+ switch (n.type) {
66
+ case 'element':
67
+ if (n.component)
68
+ into.add(n.tag);
69
+ childElements(n.children, (c) => {
70
+ if (n.component)
71
+ noteIn(children, n.tag, nameOf(c));
72
+ if (c.component)
73
+ noteIn(parents, c.tag, nameOf(n));
74
+ });
75
+ for (const a of n.attrs)
76
+ if (a.kind === 'slotProp')
77
+ for (const c of a.children)
78
+ renderedTags(c, into, children, parents);
79
+ for (const c of n.children)
80
+ renderedTags(c, into, children, parents);
81
+ return;
82
+ case 'if':
83
+ for (const b of n.branches)
84
+ for (const c of b.children)
85
+ renderedTags(c, into, children, parents);
86
+ return;
87
+ case 'slot':
88
+ for (const c of n.fallback)
89
+ renderedTags(c, into, children, parents);
90
+ return;
91
+ case 'for':
92
+ case 'fragment':
93
+ case 'keyed':
94
+ case 'presence':
95
+ for (const c of n.children)
96
+ renderedTags(c, into, children, parents);
97
+ return;
98
+ default:
99
+ return;
100
+ }
101
+ }
102
+ /**
103
+ * Notes the names a module reads as values (its components' code and markup, its hooks and module code; not the
104
+ * `Name.displayName = …` lines or `export { Name }` lists that only name a component) and the names it renders as a
105
+ * tag. Called for every Angular module before any is emitted, with the Radix preparation (radix/prepare.ts), so a
106
+ * component's form is known to every caller. `conversion`: an object of the conversion that prepares the module (the
107
+ * same for all its modules).
108
+ */
109
+ export function noteValueReads(mod, conversion) {
110
+ let uses = NAME_USES.get(conversion);
111
+ if (!uses)
112
+ NAME_USES.set(conversion, (uses = { values: new Set(), rendered: new Set(), children: new Map(), parents: new Map(), components: new Map() }));
113
+ const into = uses;
114
+ for (const comp of mod.components) {
115
+ USES_OF.set(comp, into);
116
+ into.components.set(comp.name, comp);
117
+ }
118
+ const roots = [];
119
+ const tags = new Set();
120
+ const children = new Map();
121
+ const parents = new Map();
122
+ for (const comp of mod.components) {
123
+ roots.push(...templateExpressions(comp.template));
124
+ renderedTags(comp.template, tags, children, parents);
125
+ for (const item of comp.items)
126
+ for (const v of Object.values(item))
127
+ if (t.isNode(v))
128
+ roots.push(v);
129
+ for (const f of comp.fragments) {
130
+ roots.push(...templateExpressions(f.template));
131
+ renderedTags(f.template, tags, children, parents);
132
+ }
133
+ for (const v of comp.markupValues ?? [])
134
+ renderedTags(v.template, tags, children, parents);
135
+ }
136
+ for (const hook of mod.hooks)
137
+ for (const item of hook.items)
138
+ for (const v of Object.values(item))
139
+ if (t.isNode(v))
140
+ roots.push(v);
141
+ for (const st of mod.moduleBody) {
142
+ if (t.isExportNamedDeclaration(st) && !st.declaration)
143
+ continue;
144
+ if (t.isExportDefaultDeclaration(st) && t.isIdentifier(st.declaration))
145
+ continue;
146
+ if (t.isExpressionStatement(st) && t.isAssignmentExpression(st.expression) && t.isMemberExpression(st.expression.left) && t.isIdentifier(st.expression.left.object))
147
+ continue;
148
+ roots.push(st);
149
+ }
150
+ const local = new Set();
151
+ for (const root of roots)
152
+ t.traverse(root, (n, ancestors) => {
153
+ // markup in code (a module table, a value): its tags are rendered (the template bank stamps them)
154
+ if (t.isJSXOpeningElement(n) && t.isJSXIdentifier(n.name) && /^[A-Z]/.test(n.name.name))
155
+ tags.add(n.name.name);
156
+ if (!t.isIdentifier(n))
157
+ return;
158
+ const parent = ancestors[ancestors.length - 1];
159
+ // (a member's or an object key's name is no read of the binding)
160
+ if (parent && (t.isMemberExpression(parent.node) || t.isOptionalMemberExpression(parent.node)) && parent.key === 'property' && !parent.node.computed)
161
+ return;
162
+ if (parent && t.isObjectProperty(parent.node) && parent.key === 'key' && !parent.node.computed)
163
+ return;
164
+ local.add(n.name);
165
+ });
166
+ for (const name of local)
167
+ into.values.add(name);
168
+ for (const name of tags)
169
+ into.rendered.add(name);
170
+ // (a component tag is noted by its own name where the module imports it under another)
171
+ const alias = new Map();
172
+ for (const d of mod.imports)
173
+ for (const sp of d.specifiers)
174
+ if (t.isImportSpecifier(sp))
175
+ alias.set(sp.local.name, t.isIdentifier(sp.imported) ? sp.imported.name : sp.imported.value);
176
+ const own = (x) => (x.startsWith('<') ? `<${alias.get(x.slice(1)) ?? x.slice(1)}` : x);
177
+ for (const [map, to] of [[children, into.children], [parents, into.parents]])
178
+ for (const [name, from] of map)
179
+ for (const x of from)
180
+ noteIn(to, alias.get(name) ?? name, own(x));
181
+ // (an imported component used under another name: its own name is used too)
182
+ for (const d of mod.imports)
183
+ for (const s of d.specifiers) {
184
+ if (!t.isImportSpecifier(s))
185
+ continue;
186
+ const imported = t.isIdentifier(s.imported) ? s.imported.name : s.imported.value;
187
+ if (local.has(s.local.name))
188
+ into.values.add(imported);
189
+ if (tags.has(s.local.name))
190
+ into.rendered.add(imported);
191
+ }
192
+ }
193
+ /** Whether a component takes the plain host form (the condition above), decided once per component. */
194
+ export function plainHostFor(comp) {
195
+ if (!comp)
196
+ return undefined;
197
+ const known = PLAIN_HOSTS.get(comp);
198
+ if (known !== undefined)
199
+ return known ?? undefined;
200
+ const decided = decidePlainHost(comp);
201
+ PLAIN_HOSTS.set(comp, decided);
202
+ return decided ?? undefined;
203
+ }
204
+ function decidePlainHost(comp) {
205
+ const el = comp.template;
206
+ if (HOST_FORMS.has(comp) || el.type !== 'element' || el.component || NG_PLANS.has(el) || !HOSTLESS_TAGS.has(el.tag))
207
+ return null;
208
+ if (comp.forwardRef || comp.rest || comp.fragments.length || comp.markupValues?.length || comp.keptMarkup?.length)
209
+ return null;
210
+ if (el.motion || el.portal || el.asChild)
211
+ return null;
212
+ for (const a of el.attrs)
213
+ if (a.kind !== 'static' && a.kind !== 'expr' && a.kind !== 'bool' && a.kind !== 'event' && a.kind !== 'style')
214
+ return null;
215
+ // a field React controls carries the Controlled directive, which a host cannot
216
+ if (/^(input|textarea|select)$/.test(el.tag) && el.attrs.some((a) => a.kind === 'expr' && a.name === 'value'))
217
+ return null;
218
+ // (a component no conversion prepared, one no component of the conversion renders (an entry: its callers are
219
+ // hand-written, and its element selector stays), or one whose name is read as a value: today's host)
220
+ const uses = USES_OF.get(comp);
221
+ if (!uses || !uses.rendered.has(comp.name) || uses.values.has(comp.name))
222
+ return null;
223
+ // (an element Angular's parser would close before a child its callers write inside it, or one it closes before this
224
+ // element where a caller writes it: CLOSED_BY; a component counts by its root element's tag)
225
+ const tagOf = (x) => {
226
+ if (!x.startsWith('<'))
227
+ return x;
228
+ const root = uses.components.get(x.slice(1))?.template;
229
+ return root?.type === 'element' && !root.component ? root.tag : null;
230
+ };
231
+ const inside = [...(uses.children.get(comp.name) ?? [])].map(tagOf);
232
+ if (inside.some((x) => x !== null && (CLOSED_BY[el.tag] ?? []).includes(x)))
233
+ return null;
234
+ const around = [...(uses.parents.get(comp.name) ?? [])].map(tagOf);
235
+ if (around.some((x) => x !== null && (CLOSED_BY[x] ?? []).includes(el.tag)))
236
+ return null;
237
+ return { tag: el.tag };
238
+ }
239
+ /** The attribute a host-form component is selected by: its element selector camel-cased (`ui-toggle` → `uiToggle`). */
240
+ export function hostAttribute(selector) {
241
+ return svgHostAttribute(selector);
242
+ }
243
+ /**
244
+ * Whether a component whose root element `el` is a claimed Radix part takes the host form; checked on the component as
245
+ * lowered (before the part's element is prepared). Narrow on purpose: everything else keeps the element host.
246
+ * - the component is exported (a private one may be written in place by its caller, which has no host to put it on),
247
+ * takes no forwarded ref, has no render helper or markup held in data;
248
+ * - its template is this one element, with a static tag, no Framer props, no portal, no `asChild`, no ref, no inner HTML
249
+ * and no markup passed as a prop;
250
+ * - the element gives the part none of Radix's props or callbacks itself (they reach it only through the rest props,
251
+ * so the caller binds them on the host), and spreads nothing but the component's rest props, which nothing else reads.
252
+ */
253
+ export function hostFormFor(mod, comp, el, map, pkg, part) {
254
+ const directive = map.directive;
255
+ // (a part whose state reads another part's injects that part's directive: radix/template.ts)
256
+ if (!directive || map.plainAttrs || map.wrapper)
257
+ return null;
258
+ const exported = comp.exported || mod.exportedNames.has(comp.name) || mod.defaultExport === comp.name;
259
+ if (!exported || comp.forwardRef || comp.fragments.length || comp.markupValues?.length)
260
+ return null;
261
+ if (comp.template !== el || el.motion || el.portal || el.asChild || map.tag === 'ng-template')
262
+ return null;
263
+ const rest = comp.rest;
264
+ for (const a of el.attrs) {
265
+ if (a.kind === 'ref' || a.kind === 'html' || a.kind === 'slotProp')
266
+ return null;
267
+ if (a.kind === 'spread' && !(rest && t.isIdentifier(a.expr, { name: rest })))
268
+ return null;
269
+ if (a.kind === 'event' && Object.hasOwn(map.outputs, a.react))
270
+ return null;
271
+ if ((a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool') && Object.hasOwn(map.inputs, a.name === 'class' ? 'className' : a.name))
272
+ return null;
273
+ }
274
+ if (rest) {
275
+ if (comp.propsStyle !== 'destructured')
276
+ return null;
277
+ // the rest props are read only by the spread onto the element
278
+ let reads = 0;
279
+ const roots = [...templateExpressions(comp.template)];
280
+ for (const item of comp.items)
281
+ for (const v of Object.values(item))
282
+ if (t.isNode(v))
283
+ roots.push(v);
284
+ for (const root of roots)
285
+ t.traverseFast(root, (n) => void (t.isIdentifier(n) && comp.refs.get(n) === rest && reads++));
286
+ const spreads = el.attrs.filter((a) => a.kind === 'spread').length;
287
+ if (reads > spreads)
288
+ return null;
289
+ }
290
+ return { tag: map.tag, map, directive, pkg, part, ...(map.tag === 'ng-container' ? { contents: true } : {}) };
291
+ }
292
+ const reactName = (a) => a.kind === 'event' ? a.react : a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool' ? (a.name === 'class' ? 'className' : a.name) : null;
293
+ const lineOf = (n) => {
294
+ for (const a of n.attrs) {
295
+ const e = a.kind === 'event' ? a.handler : 'expr' in a ? a.expr : null;
296
+ if (e?.loc?.start.line)
297
+ return e.loc.start.line;
298
+ }
299
+ return undefined;
300
+ };
301
+ /** The elements above `target` in a component's markup (empty when it is not found there). */
302
+ function ancestorsOf(comp, target) {
303
+ const walk = (n, above) => {
304
+ switch (n.type) {
305
+ case 'element': {
306
+ if (n === target)
307
+ return above;
308
+ const inner = [...above, n];
309
+ for (const a of n.attrs)
310
+ if (a.kind === 'slotProp')
311
+ for (const c of a.children) {
312
+ const found = walk(c, inner);
313
+ if (found)
314
+ return found;
315
+ }
316
+ for (const c of n.children) {
317
+ const found = walk(c, inner);
318
+ if (found)
319
+ return found;
320
+ }
321
+ return null;
322
+ }
323
+ case 'if':
324
+ for (const b of n.branches)
325
+ for (const c of b.children) {
326
+ const found = walk(c, above);
327
+ if (found)
328
+ return found;
329
+ }
330
+ return null;
331
+ case 'slot':
332
+ for (const c of n.fallback) {
333
+ const found = walk(c, above);
334
+ if (found)
335
+ return found;
336
+ }
337
+ return null;
338
+ case 'for':
339
+ case 'fragment':
340
+ case 'keyed':
341
+ case 'presence':
342
+ for (const c of n.children) {
343
+ const found = walk(c, above);
344
+ if (found)
345
+ return found;
346
+ }
347
+ return null;
348
+ default:
349
+ return null;
350
+ }
351
+ };
352
+ return walk(comp.template, []) ?? comp.fragments.map((f) => walk(f.template, [])).find((x) => x !== null) ?? null;
353
+ }
354
+ /**
355
+ * The attributes a caller writes on a host-form component's element (`<button uiToggleGroupItem …>`): Radix's props and
356
+ * callbacks of the part as the directive's inputs and outputs (adapted as on a part's element), the component's own
357
+ * props as its inputs (bound, so none lands on the element as an attribute too), and every other attribute and listener
358
+ * as the element's own, as React spreads the rest props onto the part. A part radix-ng finds its root through the
359
+ * injector must be written inside that root (its element, or a host-form component of it) in the caller's template.
360
+ * (M3: `ownEvents`, the event props the child declares: any other handler is the element's listener.)
361
+ */
362
+ export function hostFormCaller(n, form, ownKeys, p, ownEvents) {
363
+ const radix = [];
364
+ const own = [];
365
+ const dom = [];
366
+ // (a Radix prop radix-ng needs no input for: NgPartMap.drops)
367
+ const drops = [];
368
+ for (const a of n.attrs) {
369
+ const name = reactName(a);
370
+ if (name !== null && form.map.drops && Object.hasOwn(form.map.drops, name)) {
371
+ drops.push(a);
372
+ continue;
373
+ }
374
+ if (a.kind === 'event' ? Object.hasOwn(form.map.outputs, a.react) : name !== null && Object.hasOwn(form.map.inputs, a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool' ? a.name : ''))
375
+ radix.push(a);
376
+ // (M3: a handler is the component's own only where it declares that event prop (`ownEvents`); a DOM handler its
377
+ // element type takes, `onClick`, is the element's listener, as React spreads it onto the part)
378
+ else if (name === null || (ownKeys.has(name) && !(a.kind === 'event' && ownEvents && !ownEvents.has(name))))
379
+ own.push(a);
380
+ else
381
+ dom.push(a);
382
+ }
383
+ const where = `<${n.tag}> (Radix ${form.pkg} ${form.part}, written as its <${form.tag}>)`;
384
+ // Radix's asChild reaches the part through the rest props: the part's attributes would go onto the child element,
385
+ // which the host form cannot do (the element is the component's own)
386
+ if (dom.some((a) => reactName(a) === 'asChild'))
387
+ p.warn('radix-prop', `${where}: asChild would put the part's attributes onto the one element given as children; the component is that element itself on Angular, so it cannot: not converted.`, 'error', lineOf(n));
388
+ for (const [key, prop] of Object.entries(form.map.inputs)) {
389
+ const given = radix.find((a) => reactName(a) === key);
390
+ if (prop.literal && given && given.kind !== 'static')
391
+ p.warn('radix-prop', `${where}: ${key} must be written here as a string literal, as radix-ng's value shapes follow it; it is a value: not converted.`, 'error', lineOf(n));
392
+ }
393
+ for (const why of form.map.differencesAt?.(writtenContext([...radix, ...drops])) ?? [])
394
+ p.warn('radix-behaviour', `${where}: ${why}.`, 'warning', lineOf(n));
395
+ // what React's types say a value may be (true where they say nothing)
396
+ const may = (e, test) => {
397
+ const type = p.typeOf(e);
398
+ if (!type || t.isTSAnyKeyword(type) || t.isTSUnknownKeyword(type))
399
+ return true;
400
+ return (t.isTSUnionType(type) ? type.types : [type]).some((x) => t.isTSAnyKeyword(x) || t.isTSUnknownKeyword(x) || test(x));
401
+ };
402
+ const printer = {
403
+ expr: p.expr,
404
+ handler: p.handler,
405
+ mayBeUndefined: (e) => may(e, (x) => t.isTSUndefinedKeyword(x)),
406
+ mayBeText: (e, text) => may(e, (x) => t.isTSStringKeyword(x) || (t.isTSLiteralType(x) && t.isStringLiteral(x.literal) && x.literal.value === text)),
407
+ };
408
+ // a part that renders no element (HostForm.contents): Radix passes nothing but its own props on, so the caller's other
409
+ // attributes and listeners go nowhere in React; on Angular they would land on the wrapper's contents host (a class
410
+ // or a listener there would reach the children), so they are left out, said as a note
411
+ if (form.contents) {
412
+ for (const a of dom)
413
+ p.warn('radix-ignored', `${reactName(a) ?? 'a spread'} on <${n.tag}> is ignored: ${form.pkg} ${form.part} renders no element in Radix and passes nothing but its own props on, and neither does the Angular output.`, 'info', lineOf(n));
414
+ return [...radixInputsAndOutputs(form.map, radix, printer), ...p.own(own)];
415
+ }
416
+ // (M3: a handler written on a component carries React's name, `onClick`; on the element it is the DOM event's, `click`,
417
+ // as on any element, so React's focus and blur become the bubbling focusin and focusout there too)
418
+ const listeners = dom.map((a) => (a.kind === 'event' ? { ...a, name: domEventName(a.react) } : a));
419
+ return [...radixInputsAndOutputs(form.map, radix, printer), ...p.own(own), ...p.dom(listeners)];
420
+ }
421
+ /**
422
+ * Where a caller writes a component that holds a Radix part radix-ng finds (or reads) through the injector outside the
423
+ * component's own template (radixNeedsOf): the caller's template must have, above it, an element of that part or a
424
+ * component in the host form that is one. Otherwise the part would silently run on its own: a located error.
425
+ */
426
+ export function radixNeedsAt(caller, n, child, formOf, warn, note) {
427
+ // an asChild that reaches a Radix part through the child's rest props: React's Slot would put the part's attributes
428
+ // onto the one element given as children; the part is an element of the child's own template on Angular, and the
429
+ // rest props would set asChild on it as an attribute
430
+ const restPart = radixRestPartOf(child);
431
+ const asChild = n.attrs.find((a) => (a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool') && a.name === 'asChild');
432
+ if (restPart && asChild && !(asChild.kind === 'expr' && t.isBooleanLiteral(asChild.expr, { value: false })))
433
+ warn(`<${n.tag}> is given asChild, which its rest props pass on to ${restPart}: Radix's Slot would put that part's attributes onto the one element given as children instead of rendering the part's own; on Angular the part is an element of ${n.tag}'s own template, which a directive cannot move onto projected content; not converted.`, lineOf(n));
434
+ // a Radix prop the part's map refuses, given to the child for its rest props to pass on (NgPartMap.refusedProps)
435
+ const restMap = radixRestMapOf(child);
436
+ const refused = restMap?.refusedProps ?? {};
437
+ for (const a of n.attrs) {
438
+ const name = a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool' ? a.name : null;
439
+ if (restPart && name && Object.hasOwn(refused, name))
440
+ warn(`<${n.tag}> is given ${name}, which its rest props pass on to ${restPart}: ${refused[name]}; not converted.`, lineOf(n));
441
+ }
442
+ // the rest props reach a part that renders no element: an attribute the child does not take goes nowhere, in React
443
+ // (Radix passes nothing but its own props on) and in the output, said as a note
444
+ if (restPart && child && restMap && (restMap.tag === 'ng-template' || restMap.tag === 'ng-container')) {
445
+ const own = new Set([...child.props.map((x) => x.key), 'key', 'children']);
446
+ for (const a of n.attrs) {
447
+ const name = a.kind === 'event' ? a.react : a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool' ? (a.name === 'class' ? 'className' : a.name) : a.kind === 'ref' ? 'ref' : null;
448
+ if (!name || own.has(name) || Object.hasOwn(refused, name) || name === 'asChild' || Object.hasOwn(restMap.inputs, name) || Object.hasOwn(restMap.outputs, name))
449
+ continue;
450
+ note?.(`${name} on <${n.tag}> is ignored: its rest props pass it on to ${restPart}, which renders no element in Radix and passes nothing but its own props on, and neither does the Angular output.`, lineOf(n) ?? caller.line);
451
+ }
452
+ }
453
+ const needs = radixNeedsOf(child);
454
+ if (!needs.length)
455
+ return;
456
+ const above = ancestorsOf(caller, n) ?? [];
457
+ // (a caller that holds parts of its own needing the same root is placed inside that root by its own callers, where
458
+ // they check it: shadcn's DialogContent holds the Content part and the DialogPortal wrapper)
459
+ const own = radixNeedsOf(caller);
460
+ for (const need of needs) {
461
+ if (own.some((o) => o.pkg === need.pkg && o.part === need.part))
462
+ continue;
463
+ const inside = above.some((a) => {
464
+ const plan = NG_PLANS.get(a);
465
+ if (plan)
466
+ return plan.pkg === need.pkg && plan.part === need.part;
467
+ const other = a.component ? formOf(a.tag) : undefined;
468
+ return other?.pkg === need.pkg && other.part === need.part;
469
+ });
470
+ if (!inside)
471
+ warn(`<${n.tag}> holds ${need.by}, and is not written inside its ${need.part} in this template: radix-ng's ${need.directive} finds its ${need.part} through Angular's injector, which follows the templates the elements are written in, so here it would run on its own; not converted.`, lineOf(n));
472
+ }
473
+ }
474
+ /**
475
+ * The element a caller writes for a child whose rest props reach a Radix part that renders no element, without the
476
+ * attributes that go nowhere (as in React; radixNeedsAt says them): the child's own props, Radix's props of the part
477
+ * and asChild stay. Any other child: the element as it is.
478
+ */
479
+ export function withoutIgnoredAttrs(n, child) {
480
+ const map = radixRestMapOf(child);
481
+ if (!child || !map || (map.tag !== 'ng-template' && map.tag !== 'ng-container'))
482
+ return n;
483
+ const own = new Set([...child.props.map((x) => x.key), 'key', 'children']);
484
+ const refused = map.refusedProps ?? {};
485
+ const stays = (a) => {
486
+ const name = a.kind === 'event' ? a.react : a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool' ? (a.name === 'class' ? 'className' : a.name) : a.kind === 'ref' ? 'ref' : null;
487
+ return !name || own.has(name) || Object.hasOwn(refused, name) || name === 'asChild' || Object.hasOwn(map.inputs, name) || Object.hasOwn(map.outputs, name);
488
+ };
489
+ return n.attrs.every(stays) ? n : { ...n, attrs: n.attrs.filter(stays) };
490
+ }
491
+ /** Names of the helper directives a host binding cannot carry (they are directives, not attributes). */
492
+ const HELPER_ATTRIBUTES = new Set(['spreadProps', 'bindRef', 'bindRefTo', 'motion', 'controlled', 'morphNode', 'lucideIcon', 'ngTemplateOutlet', 'ngComponentOutlet', 'ngProjectAs']);
493
+ const unescape = (s) => s.replace(/&quot;/g, '"').replace(/&amp;/g, '&');
494
+ /** The root element of printed markup: its attributes and its content, or why it cannot be read as one element. */
495
+ function readRoot(markup, tag) {
496
+ const text = markup.trim();
497
+ if (!text.startsWith(`<${tag}`) || !/[\s>/]/.test(text.charAt(tag.length + 1)))
498
+ return `the template does not start with its <${tag}>`;
499
+ const attrs = [];
500
+ let i = tag.length + 1;
501
+ let end = -1;
502
+ let closed = false;
503
+ while (i < text.length) {
504
+ while (i < text.length && /\s/.test(text.charAt(i)))
505
+ i++;
506
+ if (text.startsWith('/>', i)) {
507
+ end = i + 2;
508
+ closed = true;
509
+ break;
510
+ }
511
+ if (text.charAt(i) === '>') {
512
+ end = i + 1;
513
+ break;
514
+ }
515
+ let j = i;
516
+ while (j < text.length && !/[\s=>]/.test(text.charAt(j)) && !text.startsWith('/>', j))
517
+ j++;
518
+ const name = text.slice(i, j);
519
+ if (!name)
520
+ return `an attribute of <${tag}> could not be read`;
521
+ if (text.charAt(j) === '=' && text.charAt(j + 1) === '"') {
522
+ const close = text.indexOf('"', j + 2);
523
+ if (close < 0)
524
+ return `an attribute of <${tag}> is not closed`;
525
+ attrs.push({ name, value: unescape(text.slice(j + 2, close)) });
526
+ i = close + 1;
527
+ }
528
+ else {
529
+ attrs.push({ name, value: null });
530
+ i = j;
531
+ }
532
+ }
533
+ if (end < 0)
534
+ return `<${tag}> is not closed`;
535
+ if (closed)
536
+ return text.slice(end).trim() ? `the template has more than its <${tag}>` : { attrs, content: '' };
537
+ const closing = `</${tag}>`;
538
+ const rest = text.slice(end);
539
+ if (!rest.trimEnd().endsWith(closing))
540
+ return VOID.has(tag) && !rest.trim() ? { attrs, content: '' } : `the template has more than its <${tag}>`;
541
+ const content = rest.trimEnd().slice(0, -closing.length);
542
+ // (an element of the same tag inside: the closing tag found last must be the root's)
543
+ const opens = (content.match(new RegExp(`<${tag}[\\s>/]`, 'g')) ?? []).length;
544
+ const closes = (content.match(new RegExp(`</${tag}>`, 'g')) ?? []).length;
545
+ if (opens !== closes)
546
+ return `the template has more than its <${tag}>`;
547
+ // (only white space that holds a line break goes, which React's JSX drops too; the printer writes the children's own
548
+ // white space exactly, so any other space is text React renders)
549
+ return { attrs, content: content.replace(/^[ \t]*\n\s*/, '').replace(/\s*\n[ \t]*$/, '') };
550
+ }
551
+ /** A read of the component's className input in a printed expression. */
552
+ const CLASS_READ = /(?<![\w$.])className\(\)/;
553
+ /** The member holding the class attribute a caller writes on the host element (see hostedClass). */
554
+ const CLASS_ATTRIBUTE = 'classAttribute';
555
+ /** One `@let` at the start of a template. */
556
+ const LET = /^@let ([A-Za-z_$][\w$]*) = ([^;]*);/;
557
+ /**
558
+ * `code` with each read of `name` (not a member, not inside a string) written as `by`; with `by` null, `code` itself
559
+ * when it never reads the name, and something else when it does.
560
+ */
561
+ function readsName(code, name, by) {
562
+ const pattern = new RegExp(`(?<![\\w$.])${name.replace(/\$/g, '\\$')}(?![\\w$])`, 'g');
563
+ return code
564
+ .split(/('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")/)
565
+ .map((part, i) => i % 2 === 1
566
+ ? part
567
+ : part.replace(pattern, (found, at) => {
568
+ const before = part.slice(0, at).trimEnd().slice(-1);
569
+ const after = part.slice(at + found.length).trimStart().charAt(0);
570
+ const member = before === '{' || before === ',';
571
+ // an object key (`{ name: … }`) is no read; a shorthand (`{ name }`) is the key and the read
572
+ if (member && after === ':')
573
+ return found;
574
+ const value = by ?? `\u0000${name}`;
575
+ return member && (after === '}' || after === ',') ? `${found}: ${value}` : value;
576
+ }))
577
+ .join('');
578
+ }
579
+ const VOID = new Set(['input', 'img', 'br', 'hr', 'area', 'base', 'col', 'embed', 'link', 'meta', 'source', 'track', 'wbr']);
580
+ /**
581
+ * The class of a host-form component: its root element as printed becomes its host (attributes and bindings as host
582
+ * metadata, the part's directive in hostDirectives with every mapped input and output exposed under radix-ng's names),
583
+ * the element's children its template, and a template reference to the directive a member that injects it (host
584
+ * bindings and the children read it by the same name). A string: why the printed root cannot be the host.
585
+ */
586
+ export function hostedClass(given, selector, markup, api) {
587
+ // (M5: a plain host has no Radix part: no directive, no exportAs, never contents)
588
+ const form = 'directive' in given ? given : null;
589
+ const tag = given.tag;
590
+ const inject = () => api('inject');
591
+ // the template's `@let` values (`@let contextValue = context();`): a host binding cannot read one, so each binding
592
+ // reads its expression in its place (a read of signals and members, the same value each time it is read); the
593
+ // template keeps those its children read
594
+ const lets = [];
595
+ let body = markup.trimStart();
596
+ for (let m = LET.exec(body); m; m = LET.exec(body)) {
597
+ const [whole, name = '', expr = ''] = m;
598
+ if (/(^|[^=!<>])=(?!=)|\+\+|--/.test(expr.replace(/'[^']*'|"[^"]*"/g, "''")))
599
+ return `its @let ${name} writes a value`;
600
+ lets.push({ name, expr });
601
+ body = body.slice(whole.length).trimStart();
602
+ }
603
+ const root = readRoot(body, tag);
604
+ if (typeof root === 'string')
605
+ return root;
606
+ // a part with no element (contents): its attributes have nowhere to go, as in React; a binding is refused
607
+ if (form?.contents) {
608
+ const bound = root.attrs.find((a) => /^[[(*]/.test(a.name));
609
+ if (bound)
610
+ return `its root renders no element in Radix and carries ${bound.name}`;
611
+ root.attrs = root.attrs.filter((a) => a.name.startsWith('#'));
612
+ }
613
+ const inlined = (value) => lets.reduceRight((v, l) => readsName(v, l.name, /^[\w$.]+(\(\))?$/.test(l.expr) ? l.expr : `(${l.expr})`), value);
614
+ for (const a of root.attrs)
615
+ if (a.value !== null && !a.name.startsWith('#') && /^[[(]/.test(a.name))
616
+ a.value = inlined(a.value);
617
+ // (the content is markup, not an expression: a child's binding reads the name inside the double quotes of its
618
+ // attribute, `[paused]="pausedValue"`, which readsName takes for a string and skips. The name anywhere in the content
619
+ // keeps the `@let`: one kept and unread is harmless, one dropped and read fails the compiler.)
620
+ const namedInMarkup = (name) => new RegExp(`(?<![\\w$.])${name.replace(/\$/g, '\\$')}(?![\\w$])`).test(root.content);
621
+ const kept = lets.filter((l) => namedInMarkup(l.name) || lets.some((o) => o !== l && readsName(o.expr, l.name, null) !== o.expr));
622
+ // (joined with nothing between: a line break before text would be a leading space Angular keeps)
623
+ root.content = kept.map((l) => `@let ${l.name} = ${l.expr};`).join('') + root.content;
624
+ const host = [];
625
+ const members = [];
626
+ for (const a of root.attrs) {
627
+ if (a.name.startsWith('#')) {
628
+ if (!form || a.value !== form.directive.exportAs)
629
+ return `the template names its <${tag}> (${a.name})`;
630
+ const member = t.classProperty(t.identifier(a.name.slice(1)), t.callExpression(t.identifier(inject()), [t.identifier(form.directive.name)]));
631
+ member.accessibility = 'protected';
632
+ member.readonly = true;
633
+ members.push(member);
634
+ continue;
635
+ }
636
+ const bare = a.name.replace(/^\[\(?|\)?\]$|^\(|\)$/g, '').split('.')[0] ?? a.name;
637
+ if (HELPER_ATTRIBUTES.has(bare) || a.name.startsWith('*') || a.name.startsWith('[('))
638
+ return `its <${tag}> carries ${a.name}, a directive or binding a host cannot take`;
639
+ // the class the component computes from its className (shadcn's `cn(…, className)`): a class a hand-written caller
640
+ // writes on the element (`<button uiToggle class="px-8">`) is read as that className, so it merges as React's
641
+ // className does (Angular would keep the static class beside the computed one, unmerged)
642
+ let value = a.value ?? '';
643
+ if (a.name === '[class]' && CLASS_READ.test(value)) {
644
+ value = value.replace(new RegExp(CLASS_READ.source, 'g'), `(className() ?? ${CLASS_ATTRIBUTE})`);
645
+ const member = t.classProperty(t.identifier(CLASS_ATTRIBUTE), t.callExpression(t.identifier(inject()), [t.newExpression(t.identifier(api('HostAttributeToken')), [t.stringLiteral('class')]), t.objectExpression([t.objectProperty(t.identifier('optional'), t.booleanLiteral(true))])]));
646
+ member.accessibility = 'protected';
647
+ member.readonly = true;
648
+ members.push(member);
649
+ }
650
+ host.push(t.objectProperty(/^[A-Za-z_$][\w$]*$/.test(a.name) ? t.identifier(a.name) : t.stringLiteral(a.name), t.stringLiteral(value)));
651
+ }
652
+ const names = (list) => t.arrayExpression([...new Set(list)].map((x) => t.stringLiteral(x)));
653
+ // one entry per directive on the element (the part's, then NgPartMap.also), each exposing the inputs that are its own
654
+ const radixForm = form;
655
+ const entries = (radixForm ? [radixForm.directive, ...(radixForm.map.also ?? [])] : []).map((d, i) => {
656
+ if (!radixForm)
657
+ return t.objectExpression([]);
658
+ const form = radixForm;
659
+ const mine = (x) => (x.on ?? form.directive.name) === d.name;
660
+ const inputs = Object.values(form.map.inputs).flatMap((x) => (x.input && mine(x) ? [x.input, ...(x.extra ? [x.extra.input] : [])] : []));
661
+ const outputs = i === 0 ? Object.values(form.map.outputs).map((x) => x.output) : [];
662
+ return t.objectExpression([
663
+ t.objectProperty(t.identifier('directive'), t.identifier(d.name)),
664
+ ...(inputs.length ? [t.objectProperty(t.identifier('inputs'), names(inputs))] : []),
665
+ ...(outputs.length ? [t.objectProperty(t.identifier('outputs'), names(outputs))] : []),
666
+ ]);
667
+ });
668
+ // (contents: the component's own element host, display: contents)
669
+ if (form?.contents)
670
+ host.push(t.objectProperty(t.identifier('style'), t.stringLiteral('display: contents')));
671
+ return { selector: form?.contents ? selector : `${tag}[${hostAttribute(selector)}]`, template: root.content, host: t.objectExpression(host), hostDirectives: t.arrayExpression(entries), members, uses: form ? [form.directive, ...(form.map.also ?? [])].map((d) => d.name) : [] };
672
+ }
673
+ /**
674
+ * Writes a host-form class into a component's decorator and members as the emitter built them: the attribute selector,
675
+ * the host bindings in place of `display: contents`, the directive in `hostDirectives` (after `imports`), the root's
676
+ * children as the template, and the injected directive first among the members.
677
+ */
678
+ export function applyHostedClass(meta, members, hosted, template) {
679
+ const at = (key) => meta.findIndex((p) => t.isIdentifier(p.key, { name: key }));
680
+ const set = (key, value) => {
681
+ const i = at(key);
682
+ if (i >= 0)
683
+ meta[i] = t.objectProperty(t.identifier(key), value);
684
+ };
685
+ set('selector', t.stringLiteral(hosted.selector));
686
+ set('template', template);
687
+ const host = t.objectProperty(t.identifier('host'), hosted.host);
688
+ const hostAt = at('host');
689
+ if (hosted.host.properties.length) {
690
+ if (hostAt >= 0)
691
+ meta[hostAt] = host;
692
+ }
693
+ else if (hostAt >= 0)
694
+ meta.splice(hostAt, 1);
695
+ const after = Math.max(at('imports'), at('changeDetection'), at('providers'));
696
+ // (M5: a plain host has no directive)
697
+ if (hosted.hostDirectives.elements.length)
698
+ meta.splice(after + 1, 0, t.objectProperty(t.identifier('hostDirectives'), hosted.hostDirectives));
699
+ // (a member of the class already named like the class attribute's: the attribute's takes another name)
700
+ const taken = new Set(members.flatMap((m) => ('key' in m && t.isIdentifier(m.key) ? [m.key.name] : [])));
701
+ if (taken.has(CLASS_ATTRIBUTE)) {
702
+ let name = CLASS_ATTRIBUTE;
703
+ for (let i = 2; taken.has(name); i++)
704
+ name = `${CLASS_ATTRIBUTE}${i}`;
705
+ for (const m of hosted.members)
706
+ if (t.isIdentifier(m.key, { name: CLASS_ATTRIBUTE }))
707
+ m.key = t.identifier(name);
708
+ for (const p of hosted.host.properties)
709
+ if (t.isObjectProperty(p) && t.isStringLiteral(p.value))
710
+ p.value = t.stringLiteral(p.value.value.replace(new RegExp(`\\b${CLASS_ATTRIBUTE}\\b`, 'g'), name));
711
+ }
712
+ members.unshift(...hosted.members);
713
+ }
714
+ /**
715
+ * The members a component injects for the Radix parts its template reads through the injector (radix/template.ts
716
+ * injectedDirectives): `protected readonly accordionItem = inject(RdxAccordionItemDirective);`. `use` names each class
717
+ * for the file's imports (not the decorator's: a class it injects is no template import).
718
+ */
719
+ export function injectedMembers(comp, inject, use) {
720
+ return injectedDirectives([comp.template, ...comp.fragments.map((f) => f.template)]).map(({ member, directive }) => {
721
+ use(directive);
722
+ const p = t.classProperty(t.identifier(member), t.callExpression(t.identifier(inject()), [t.identifier(directive)]));
723
+ p.accessibility = 'protected';
724
+ p.readonly = true;
725
+ return p;
726
+ });
727
+ }