@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,56 @@
1
+ import ts from 'typescript';
2
+ import type { Project } from '../analyzer/deps.js';
3
+ /**
4
+ * What a bridge does with one prop of the React component:
5
+ * - `cross`: passed to React as it is (data, callbacks);
6
+ * - `text`: a prop typed as markup that also takes text (`ReactNode`): only its text members cross (a string, a number, a
7
+ * boolean, null), since a host framework's markup is not a React node;
8
+ * - `drop`: optional and cannot cross (a render prop, a ref, markup with no text member, data that holds markup): it is
9
+ * left out of the wrapper's props, so React renders as if it was not passed;
10
+ * - `refuse`: required and cannot cross: the component is not bridged.
11
+ */
12
+ export type PropPlan = 'cross' | 'text' | 'drop' | 'refuse';
13
+ export interface BridgeProp {
14
+ name: string;
15
+ optional: boolean;
16
+ plan: PropPlan;
17
+ /** why it is text, dropped or refused */
18
+ reason?: string;
19
+ /** declared in the project's own source (not inherited from a library's types, like React's HTML attributes) */
20
+ own: boolean;
21
+ /** a union of props types declares it in some members only */
22
+ partial: boolean;
23
+ }
24
+ export interface BridgeComponent {
25
+ /** the export's name in the source module ('default' for the default export) */
26
+ exportName: string;
27
+ /** the component's own name */
28
+ name: string;
29
+ props: BridgeProp[];
30
+ line: number | null;
31
+ /** the props type is a union of object types */
32
+ union: boolean;
33
+ /** the component takes no props parameter */
34
+ noProps: boolean;
35
+ }
36
+ /** One TypeScript program per bridged entry: the project's tsconfig (as the TypeOracle reads it), React's JSX. */
37
+ export declare function bridgeProgram(project: Project, files: string[], extra?: ts.CompilerOptions): ts.Program;
38
+ /**
39
+ * The exported class components of the entry (X6), which the analysis does not list (it converts function components
40
+ * only): an exported class whose instances have React's `render` and `props`.
41
+ */
42
+ export declare function classComponents(program: ts.Program, entry: string): {
43
+ name: string;
44
+ isDefault: boolean;
45
+ }[];
46
+ /** The exported components of the entry, each with the plan of every prop, as React's own types state them. */
47
+ export declare function bridgeComponents(program: ts.Program, entry: string, wanted: {
48
+ name: string;
49
+ isDefault: boolean;
50
+ }[], projectRoot: string): BridgeComponent[];
51
+ /**
52
+ * The React module's types as an ambient module declaration (`declare module '<specifier>' { … }`), from TypeScript's
53
+ * declaration emit of the entry: a host project's type check (and the Angular compiler) sees the component's types
54
+ * without compiling React's JSX. Null when TypeScript emits no declaration.
55
+ */
56
+ export declare function ambientDeclaration(program: ts.Program, entry: string, specifier: string): string | null;
@@ -0,0 +1,191 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import ts from 'typescript';
4
+ /** A prop type member that is markup: an element, a portal, an iterable or promise of nodes. */
5
+ const MARKUP = /\b(ReactElement|ReactPortal|ReactNode|JSX\.Element|Iterable<|AsyncIterable<|Promise<AwaitedReactNode>|AwaitedReactNode)\b/;
6
+ /** A ref or an imperative handle. */
7
+ const REF = /\b(Ref|RefObject|RefCallback|LegacyRef|ForwardedRef|MutableRefObject)</;
8
+ function members(type) {
9
+ return type.isUnion() ? type.types : [type];
10
+ }
11
+ function isPrimitive(type) {
12
+ const f = type.flags;
13
+ return (f & (ts.TypeFlags.StringLike | ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike | ts.TypeFlags.BooleanLike | ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.Void)) !== 0;
14
+ }
15
+ function isMarkupMember(checker, type) {
16
+ if (isPrimitive(type))
17
+ return false;
18
+ if (type.getCallSignatures().length)
19
+ return false;
20
+ return MARKUP.test(checker.typeToString(type, undefined, ts.TypeFormatFlags.NoTruncation));
21
+ }
22
+ /** Whether a data value (an object, an array) holds markup or render functions somewhere inside, a few levels deep. */
23
+ function holdsMarkup(checker, type, node, depth, seen) {
24
+ if (depth > 3 || seen.has(type))
25
+ return false;
26
+ seen.add(type);
27
+ for (const m of members(type)) {
28
+ if (isPrimitive(m))
29
+ continue;
30
+ if (isMarkupMember(checker, m))
31
+ return true;
32
+ for (const sig of m.getCallSignatures())
33
+ if (members(sig.getReturnType()).some((r) => isMarkupMember(checker, r)))
34
+ return true;
35
+ if (m.getCallSignatures().length)
36
+ continue;
37
+ const index = m.getNumberIndexType() ?? m.getStringIndexType();
38
+ if (index && holdsMarkup(checker, index, node, depth + 1, seen))
39
+ return true;
40
+ // an array's or a tuple's elements are its number index type, read above
41
+ if (checker.isArrayType(m) || checker.isTupleType(m))
42
+ continue;
43
+ // DOM objects and the like carry no markup a React tree would render
44
+ const fromLib = m.getSymbol()?.declarations?.some((d) => d.getSourceFile().isDeclarationFile && /[\\/]typescript[\\/]lib[\\/]/.test(d.getSourceFile().fileName));
45
+ if (fromLib)
46
+ continue;
47
+ for (const p of m.getProperties()) {
48
+ if (holdsMarkup(checker, checker.getTypeOfSymbolAtLocation(p, node), node, depth + 1, seen))
49
+ return true;
50
+ }
51
+ }
52
+ return false;
53
+ }
54
+ function planOf(checker, name, type, optional, node) {
55
+ const text = checker.typeToString(type, undefined, ts.TypeFormatFlags.NoTruncation);
56
+ const cannot = (reason) => ({ plan: optional ? 'drop' : 'refuse', reason });
57
+ if (name === 'ref' || REF.test(text))
58
+ return cannot('a ref or imperative handle does not cross into a host framework');
59
+ const list = members(type);
60
+ const markup = list.some((m) => isMarkupMember(checker, m));
61
+ const render = list.some((m) => m.getCallSignatures().some((sig) => members(sig.getReturnType()).some((r) => isMarkupMember(checker, r))));
62
+ if (render)
63
+ return cannot('a render prop returns React markup, which a host framework cannot write');
64
+ if (markup) {
65
+ const textual = list.some((m) => isPrimitive(m) && !(m.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Null | ts.TypeFlags.Void | ts.TypeFlags.BooleanLike)));
66
+ if (textual)
67
+ return { plan: 'text', reason: 'markup from the host is not a React node: only text crosses' };
68
+ return cannot('it takes React markup only, and a host framework\'s markup is not a React node');
69
+ }
70
+ if (list.some((m) => !m.getCallSignatures().length && holdsMarkup(checker, m, node, 0, new Set())))
71
+ return cannot('its data holds React markup, which a host framework cannot write');
72
+ return { plan: 'cross' };
73
+ }
74
+ /** One TypeScript program per bridged entry: the project's tsconfig (as the TypeOracle reads it), React's JSX. */
75
+ export function bridgeProgram(project, files, extra = {}) {
76
+ const configPath = join(project.root, 'tsconfig.json');
77
+ let options = { jsx: ts.JsxEmit.ReactJSX, strict: true, target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext, moduleResolution: ts.ModuleResolutionKind.Bundler };
78
+ if (existsSync(configPath)) {
79
+ const config = ts.readConfigFile(configPath, ts.sys.readFile);
80
+ if (!config.error)
81
+ options = ts.parseJsonConfigFileContent(config.config, ts.sys, project.root).options;
82
+ }
83
+ return ts.createProgram(files, { ...options, skipLibCheck: true, incremental: false, composite: false, ...extra });
84
+ }
85
+ /**
86
+ * The exported class components of the entry (X6), which the analysis does not list (it converts function components
87
+ * only): an exported class whose instances have React's `render` and `props`.
88
+ */
89
+ export function classComponents(program, entry) {
90
+ const checker = program.getTypeChecker();
91
+ const sf = program.getSourceFile(entry);
92
+ const moduleSymbol = sf ? checker.getSymbolAtLocation(sf) : undefined;
93
+ if (!sf || !moduleSymbol)
94
+ return [];
95
+ const out = [];
96
+ for (const symbol of checker.getExportsOfModule(moduleSymbol)) {
97
+ const decl = symbol.declarations?.[0];
98
+ const target = (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol;
99
+ const classDecl = target.declarations?.find((d) => ts.isClassDeclaration(d));
100
+ if (!classDecl || !decl)
101
+ continue;
102
+ const instance = checker.getTypeOfSymbolAtLocation(target, classDecl).getConstructSignatures()[0]?.getReturnType();
103
+ if (!instance || !checker.getPropertyOfType(instance, 'render') || !checker.getPropertyOfType(instance, 'props'))
104
+ continue;
105
+ const isDefault = symbol.getName() === 'default';
106
+ out.push({ name: isDefault ? (target.getName() === 'default' ? 'Component' : target.getName()) : symbol.getName(), isDefault });
107
+ }
108
+ return out;
109
+ }
110
+ /** The exported components of the entry, each with the plan of every prop, as React's own types state them. */
111
+ export function bridgeComponents(program, entry, wanted, projectRoot) {
112
+ const checker = program.getTypeChecker();
113
+ const sf = program.getSourceFile(entry);
114
+ const moduleSymbol = sf ? checker.getSymbolAtLocation(sf) : undefined;
115
+ if (!sf || !moduleSymbol)
116
+ return [];
117
+ const exports = checker.getExportsOfModule(moduleSymbol);
118
+ const out = [];
119
+ const rootKey = projectRoot.replace(/\\/g, '/').toLowerCase();
120
+ for (const w of wanted) {
121
+ const exportName = w.isDefault ? 'default' : w.name;
122
+ const symbol = exports.find((s) => s.getName() === exportName);
123
+ if (!symbol)
124
+ continue;
125
+ const decl = symbol.declarations?.[0];
126
+ const node = decl ?? sf;
127
+ const type = checker.getTypeOfSymbolAtLocation(symbol, node);
128
+ // a function component's props are its first parameter; a class component's, its constructor's (X6)
129
+ const sig = type.getCallSignatures()[0] ?? type.getConstructSignatures()[0];
130
+ const line = decl ? sf.getLineAndCharacterOfPosition(decl.getStart()).line + 1 : null;
131
+ const param = sig?.getParameters()[0];
132
+ const props = [];
133
+ let union = false;
134
+ if (param) {
135
+ const propsType = checker.getTypeOfSymbolAtLocation(param, node);
136
+ union = propsType.isUnion();
137
+ const seen = new Map();
138
+ for (const m of members(propsType))
139
+ for (const p of checker.getPropertiesOfType(m))
140
+ if (!seen.has(p.getName()))
141
+ seen.set(p.getName(), p);
142
+ for (const [name, p] of seen) {
143
+ // a prop of only some members of a union is optional for the wrapper as a whole
144
+ // (or optional in any one of them)
145
+ const optional = members(propsType).some((m) => {
146
+ const own = checker.getPropertyOfType(m, name);
147
+ return !own || (own.flags & ts.SymbolFlags.Optional) !== 0;
148
+ });
149
+ const own = (p.declarations ?? []).some((d) => {
150
+ const f = d.getSourceFile().fileName.replace(/\\/g, '/').toLowerCase();
151
+ return f.startsWith(rootKey + '/') && !f.includes('/node_modules/');
152
+ });
153
+ const { plan, reason } = planOf(checker, name, checker.getTypeOfSymbolAtLocation(p, node), optional, node);
154
+ const partial = !members(propsType).every((m) => checker.getPropertyOfType(m, name));
155
+ props.push({ name, optional, plan, own, partial, ...(reason ? { reason } : {}) });
156
+ }
157
+ }
158
+ out.push({ exportName, name: w.name, props, line, union, noProps: !param });
159
+ }
160
+ return out;
161
+ }
162
+ /**
163
+ * The React module's types as an ambient module declaration (`declare module '<specifier>' { … }`), from TypeScript's
164
+ * declaration emit of the entry: a host project's type check (and the Angular compiler) sees the component's types
165
+ * without compiling React's JSX. Null when TypeScript emits no declaration.
166
+ */
167
+ export function ambientDeclaration(program, entry, specifier) {
168
+ const sf = program.getSourceFile(entry);
169
+ if (!sf)
170
+ return null;
171
+ const emitted = [];
172
+ const result = program.emit(sf, (file, data) => {
173
+ if (file.endsWith('.d.ts'))
174
+ emitted.push(data);
175
+ }, undefined, true);
176
+ const text = emitted[0];
177
+ if (result.emitSkipped || text === undefined)
178
+ return null;
179
+ const lines = text.split('\n');
180
+ // a sibling import (`./Card`): a declaration file of the same name beside the wrapper, as TypeScript emits it
181
+ if (specifier.startsWith('.'))
182
+ return lines.filter((l) => !/^import\s+['"]/.test(l)).join('\n');
183
+ const body = lines
184
+ // a side-effect import (a stylesheet) carries no types; the rest stay, read inside the ambient module
185
+ .filter((l) => !/^import\s+['"]/.test(l))
186
+ .map((l) => l.replace(/^export declare /, 'export ').replace(/^declare /, ''))
187
+ .filter((l) => l.trim() !== 'export {};')
188
+ .map((l) => (l ? ` ${l}` : l))
189
+ .join('\n');
190
+ return `// The types of the React component the wrapper mounts (bridge mode), for the host project's type check.\ndeclare module '${specifier}' {\n${body.trimEnd()}\n}\n`;
191
+ }
@@ -0,0 +1,24 @@
1
+ import type { BridgeComponent, BridgeProp } from './props.js';
2
+ /** What every wrapper is generated from. */
3
+ export interface WrapperInput {
4
+ component: BridgeComponent;
5
+ /** the specifier the wrapper imports the React original by */
6
+ specifier: string;
7
+ }
8
+ /** The local name the React original is imported as (the wrapper takes the component's own name). */
9
+ export declare function reactLocal(c: BridgeComponent): string;
10
+ /**
11
+ * Vue 3: a component typed by the props type, with no runtime props: every attribute and listener (`@change` arrives as
12
+ * `onChange`) goes to React as it is. The React root lives in one `div` with `display: contents`, made on mount,
13
+ * rendered again on every update of the wrapper (any attribute that changes updates it), unmounted before the wrapper is.
14
+ */
15
+ export declare function vueWrapper(input: WrapperInput): string;
16
+ /**
17
+ * Svelte 5: the props as `$props()`, typed by the props type. One effect makes the React root in the wrapper's own
18
+ * `div` (`display: contents`) and unmounts it when the component is destroyed; another renders React with the props
19
+ * as they are now, and runs again when any of them changes.
20
+ */
21
+ export declare function svelteWrapper(input: WrapperInput): string;
22
+ /** The props an Angular wrapper takes as inputs: the ones the project's own source declares, named as identifiers. */
23
+ export declare function angularInputs(c: BridgeComponent): BridgeProp[];
24
+ export declare function angularWrapper(input: WrapperInput): string;
@@ -0,0 +1,276 @@
1
+ const IDENT = /^[A-Za-z_$][\w$]*$/;
2
+ /** The local name the React original is imported as (the wrapper takes the component's own name). */
3
+ export function reactLocal(c) {
4
+ return `React${c.name}`;
5
+ }
6
+ function importLine(input) {
7
+ const local = reactLocal(input.component);
8
+ return input.component.exportName === 'default'
9
+ ? `import ${local} from '${input.specifier}';`
10
+ : `import { ${input.component.exportName} as ${local} } from '${input.specifier}';`;
11
+ }
12
+ /** React's own imports: ComponentProps only where the props type is read from the component. */
13
+ function reactImport(c) {
14
+ return c.noProps ? "import { createElement } from 'react';" : "import { createElement, type ComponentProps } from 'react';";
15
+ }
16
+ const quote = (name) => (IDENT.test(name) ? name : `'${name}'`);
17
+ /** The wrapper's props type: React's own, without the props that cannot cross and with markup props narrowed to text. */
18
+ function propsType(c) {
19
+ const dropped = c.props.filter((p) => p.plan === 'drop' || p.plan === 'text');
20
+ const text = c.props.filter((p) => p.plan === 'text');
21
+ // a component with no parameter takes no props (React's ComponentProps of it is `unknown`)
22
+ const lines = [c.noProps ? 'type ReactProps = Record<string, never>;' : `type ReactProps = ComponentProps<typeof ${reactLocal(c)}>;`];
23
+ if (text.length)
24
+ lines.push('/** Only text crosses into React: markup from this framework is not a React node. */', 'type TextOnly<T> = Extract<T, string | number | bigint | boolean | null | undefined>;');
25
+ if (!dropped.length) {
26
+ lines.push('type Props = ReactProps;');
27
+ return lines;
28
+ }
29
+ const omit = dropped.map((p) => `'${p.name}'`).join(' | ');
30
+ const narrowed = text.map((p) => `${quote(p.name)}${p.optional ? '?' : ''}: TextOnly<ReactProps['${p.name}']>`).join('; ');
31
+ // a union of props types (`{ as: 'button' } | { as?: 'div' }`) stays a union: Omit alone would merge its members
32
+ if (c.union)
33
+ lines.push('/** Omit on each member of the union, so the union stays. */', 'type OmitEach<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;');
34
+ lines.push(`type Props = ${c.union ? 'OmitEach' : 'Omit'}<ReactProps, ${omit}>${text.length ? ` & { ${narrowed} }` : ''};`);
35
+ return lines;
36
+ }
37
+ const kebab = (name) => name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/([A-Z])([A-Z][a-z])/g, '$1-$2').toLowerCase();
38
+ function hasChildren(c) {
39
+ return c.props.find((p) => p.name === 'children' && (p.plan === 'cross' || p.plan === 'text'));
40
+ }
41
+ /**
42
+ * Vue 3: a component typed by the props type, with no runtime props: every attribute and listener (`@change` arrives as
43
+ * `onChange`) goes to React as it is. The React root lives in one `div` with `display: contents`, made on mount,
44
+ * rendered again on every update of the wrapper (any attribute that changes updates it), unmounted before the wrapper is.
45
+ */
46
+ export function vueWrapper(input) {
47
+ const c = input.component;
48
+ const local = reactLocal(c);
49
+ const children = hasChildren(c);
50
+ const className = c.props.some((p) => p.name === 'className' && p.plan === 'cross');
51
+ const body = [];
52
+ body.push(' const host = ref<HTMLDivElement | null>(null);', ' let root: Root | null = null;');
53
+ body.push(' const reactProps = (): ReactProps => {', ' const next: Record<string, unknown> = { ...attrs };');
54
+ // Vue keeps `class` apart from the other attributes; React's name for it is className
55
+ if (className)
56
+ body.push(" if (typeof next['class'] === 'string') {", " next['className'] = [next['className'], next['class']].filter(Boolean).join(' ');", " delete next['class'];", ' }');
57
+ else
58
+ body.push(` if ('class' in next) throw new Error('${c.name} (bridged React component) takes no class: the React ${c.name} has no className prop.');`);
59
+ // Vue lets any component take a style written as a string; React takes an object only
60
+ body.push(` if (typeof next['style'] === 'string') throw new Error('${c.name} (bridged React component) takes style as an object (:style="{ ... }"), as React does.');`);
61
+ if (children)
62
+ body.push(' const text = slots.default ? slotText(slots.default()) : null;', " if (text !== null) next['children'] = text;");
63
+ else
64
+ body.push(` if (slots.default) throw new Error('${c.name} (bridged React component) takes no content: the React ${c.name} has no children prop.');`);
65
+ if (c.noProps)
66
+ body.push(` if (Object.keys(next).length) throw new Error('${c.name} (bridged React component) takes no props.');`, ' return {};', ' };');
67
+ else {
68
+ body.push(' // no runtime props are declared, so every prop arrives in attrs; `declared` (empty at run time) carries their', " // type, Props, which the host's type check holds them to", ' return { ...declared, ...next };', ' };');
69
+ }
70
+ body.push(` const render = (): void => root?.render(createElement(${local}, reactProps()));`, ' onMounted(() => {', ' if (!host.value) return;', ' root = createRoot(host.value);', ' render();', ' });', ' onUpdated(render);', ' onBeforeUnmount(() => {', ' root?.unmount();', ' root = null;', ' });',
71
+ // X6: Vue compiles a host's slot of text as stable, so a change of that text reaches the wrapper only if its render
72
+ // reads the slot: reading it here makes the wrapper update (and onUpdated render React) when the text changes
73
+ ...(children
74
+ ? [' return () => {', ' if (slots.default) slotText(slots.default());', " return h('div', { ref: host, style: { display: 'contents' } });", ' };']
75
+ : [" return () => h('div', { ref: host, style: { display: 'contents' } });"]));
76
+ const vueImports = ['defineComponent', 'h', 'onBeforeUnmount', 'onMounted', 'onUpdated', 'ref', ...(children ? ['Comment', 'Fragment', 'Text', 'type VNode'] : [])].sort((a, b) => a.replace('type ', '').localeCompare(b.replace('type ', '')));
77
+ const helper = children
78
+ ? [
79
+ '',
80
+ '/** A default slot of text only becomes React\'s children; any other content is a host node React cannot render. */',
81
+ 'function slotText(nodes: VNode[]): string {',
82
+ ' let text = \'\';',
83
+ ' for (const node of nodes) {',
84
+ ' if (node.type === Comment) continue;',
85
+ // X6: text a host writes in a `<template v-if>` arrives wrapped in a keyed Fragment
86
+ ' if (node.type === Fragment && Array.isArray(node.children)) {',
87
+ ' text += slotText(node.children as VNode[]);',
88
+ ' continue;',
89
+ ' }',
90
+ " if (node.type !== Text || typeof node.children !== 'string') throw new Error('" + c.name + " (bridged React component) takes text as its content: a Vue element or component is not a React node.');",
91
+ ' text += node.children;',
92
+ ' }',
93
+ ' return text;',
94
+ '}',
95
+ ]
96
+ : [];
97
+ return [
98
+ '<script lang="ts">',
99
+ reactImport(c),
100
+ "import { createRoot, type Root } from 'react-dom/client';",
101
+ `import { ${vueImports.join(', ')} } from 'vue';`,
102
+ importLine(input),
103
+ '',
104
+ ...propsType(c),
105
+ ...helper,
106
+ '',
107
+ `/** React's ${c.name}, mounted as it is inside this wrapper (bridge mode): not a Vue conversion. */`,
108
+ 'export default defineComponent<Props>(',
109
+ ` (${c.noProps ? '_props' : 'declared'}, { attrs, slots }) => {`,
110
+ ...body,
111
+ ' },',
112
+ ` { name: '${c.name}', props: [], inheritAttrs: false },`,
113
+ ');',
114
+ '</script>',
115
+ '',
116
+ ].join('\n');
117
+ }
118
+ /**
119
+ * Svelte 5: the props as `$props()`, typed by the props type. One effect makes the React root in the wrapper's own
120
+ * `div` (`display: contents`) and unmounts it when the component is destroyed; another renders React with the props
121
+ * as they are now, and runs again when any of them changes.
122
+ */
123
+ export function svelteWrapper(input) {
124
+ const c = input.component;
125
+ const local = reactLocal(c);
126
+ const children = hasChildren(c);
127
+ const guard = children
128
+ ? [` if (typeof next.children === 'function') throw new Error('${c.name} (bridged React component) takes text as its children: a Svelte snippet is not a React node.');`]
129
+ : [];
130
+ return [
131
+ '<script lang="ts">',
132
+ ` ${reactImport(c)}`,
133
+ " import { createRoot, type Root } from 'react-dom/client';",
134
+ ` ${importLine(input)}`,
135
+ '',
136
+ ...propsType(c).map((l) => ` ${l}`),
137
+ '',
138
+ ` // React's ${c.name}, mounted as it is inside this wrapper (bridge mode): not a Svelte conversion`,
139
+ ' const props: Props = $props();',
140
+ ' let host: HTMLDivElement | undefined;',
141
+ ' let root: Root | null = null;',
142
+ '',
143
+ ' $effect(() => {',
144
+ ' if (!host) return;',
145
+ ' const own = createRoot(host);',
146
+ ' root = own;',
147
+ ' return () => {',
148
+ ' own.unmount();',
149
+ ' root = null;',
150
+ ' };',
151
+ ' });',
152
+ '',
153
+ ' $effect(() => {',
154
+ ' const next = { ...props };',
155
+ ...guard,
156
+ ` root?.render(createElement(${local}, next));`,
157
+ ' });',
158
+ '</script>',
159
+ '',
160
+ '<div bind:this={host} style="display: contents"></div>',
161
+ '',
162
+ ].join('\n');
163
+ }
164
+ /** The props an Angular wrapper takes as inputs: the ones the project's own source declares, named as identifiers. */
165
+ export function angularInputs(c) {
166
+ return c.props.filter((p) => (p.plan === 'cross' || p.plan === 'text') && p.own && IDENT.test(p.name) && p.name !== 'constructor');
167
+ }
168
+ /**
169
+ * Angular: a standalone OnPush component whose host element holds the React root (`display: contents`); one signal
170
+ * input per prop the component declares; an after-render effect renders React with the inputs as they are now (it runs
171
+ * again when one changes) and the root is unmounted when the component is destroyed.
172
+ */
173
+ /**
174
+ * X6: the Angular wrapper of a component that takes children. Its template projects the content between its tags into
175
+ * one holder element; React's createRoot takes the wrapper's element and removes the holder at its first render, but
176
+ * Angular keeps the projected nodes alive (and their bindings current) inside the detached holder. A mutation observer
177
+ * on the holder re-runs the render; the holder's text (trimmed) becomes React's children, taking the place of the
178
+ * `children` input as a Vue slot takes the place of the attribute; an element there throws the documented error.
179
+ */
180
+ function angularWrapperWithContent(input, inputs, typeOf) {
181
+ const c = input.component;
182
+ const local = reactLocal(c);
183
+ const fields = inputs.map((p) => (p.optional || p.name === 'children' ? ` readonly ${p.name} = input<${typeOf(p)}>();` : ` readonly ${p.name} = input.required<${typeOf(p)}>();`));
184
+ const values = inputs.filter((p) => p.name !== 'children').map((p) => `${p.name}: this.${p.name}()`);
185
+ values.push('children: projectedText(holder) ?? this.children()');
186
+ return [
187
+ "import { afterRenderEffect, ChangeDetectionStrategy, Component, DestroyRef, ElementRef, inject, input, signal, viewChild } from '@angular/core';",
188
+ reactImport(c),
189
+ "import { createRoot } from 'react-dom/client';",
190
+ importLine(input),
191
+ '',
192
+ ...propsType(c),
193
+ '',
194
+ '/** Text projected between the tags (formatting white space trimmed), or null when there is none; an element throws. */',
195
+ 'function projectedText(holder: HTMLElement): string | null {',
196
+ " let text = '';",
197
+ ' for (const node of Array.from(holder.childNodes)) {',
198
+ ' if (node.nodeType === Node.COMMENT_NODE) continue;',
199
+ " if (node.nodeType !== Node.TEXT_NODE) throw new Error('" + c.name + " (bridged React component) takes text as its content: an Angular element or component is not a React node.');",
200
+ " text += node.nodeValue ?? '';",
201
+ ' }',
202
+ ' const trimmed = text.trim();',
203
+ ' return trimmed ? trimmed : null;',
204
+ '}',
205
+ '',
206
+ `/** React's ${c.name}, mounted as it is inside this component's element (bridge mode): not an Angular conversion. */`,
207
+ '@Component({',
208
+ ` selector: '${kebab(c.name)}',`,
209
+ ' changeDetection: ChangeDetectionStrategy.OnPush,',
210
+ " template: '<span #projected><ng-content /></span>',",
211
+ " host: { style: 'display: contents' },",
212
+ '})',
213
+ `export class ${c.name} {`,
214
+ ...fields,
215
+ " private readonly projected = viewChild.required<ElementRef<HTMLElement>>('projected');",
216
+ ' private readonly changed = signal(0);',
217
+ '',
218
+ ' constructor() {',
219
+ ' const root = createRoot(inject<ElementRef<HTMLElement>>(ElementRef).nativeElement);',
220
+ ' let watch: MutationObserver | null = null;',
221
+ ' afterRenderEffect(() => {',
222
+ ' const holder = this.projected().nativeElement;',
223
+ ' this.changed();',
224
+ ' if (!watch) {',
225
+ ' watch = new MutationObserver(() => this.changed.update((n) => n + 1));',
226
+ ' watch.observe(holder, { childList: true, characterData: true, subtree: true });',
227
+ ' }',
228
+ ` root.render(createElement(${local}, { ${values.join(', ')} } satisfies Props));`,
229
+ ' });',
230
+ ' inject(DestroyRef).onDestroy(() => {',
231
+ ' watch?.disconnect();',
232
+ ' root.unmount();',
233
+ ' });',
234
+ ' }',
235
+ '}',
236
+ '',
237
+ ].join('\n');
238
+ }
239
+ export function angularWrapper(input) {
240
+ const c = input.component;
241
+ const local = reactLocal(c);
242
+ const inputs = angularInputs(c);
243
+ const typeOf = (p) => (p.plan === 'text' ? `TextOnly<ReactProps['${p.name}']>` : `ReactProps['${p.name}']`);
244
+ const fields = inputs.map((p) => (p.optional ? ` readonly ${p.name} = input<${typeOf(p)}>();` : ` readonly ${p.name} = input.required<${typeOf(p)}>();`));
245
+ const values = inputs.map((p) => `${p.name}: this.${p.name}()`);
246
+ const object = values.length ? `{ ${values.join(', ')} }` : '{}';
247
+ // X6: a component with children also takes text projected between its tags (as Vue's slot and Svelte's text do)
248
+ if (hasChildren(c) && inputs.some((p) => p.name === 'children'))
249
+ return angularWrapperWithContent(input, inputs, typeOf);
250
+ return [
251
+ "import { afterRenderEffect, ChangeDetectionStrategy, Component, DestroyRef, ElementRef, inject, input } from '@angular/core';",
252
+ reactImport(c),
253
+ "import { createRoot } from 'react-dom/client';",
254
+ importLine(input),
255
+ '',
256
+ ...propsType(c),
257
+ '',
258
+ `/** React's ${c.name}, mounted as it is inside this component's element (bridge mode): not an Angular conversion. */`,
259
+ '@Component({',
260
+ ` selector: '${kebab(c.name)}',`,
261
+ ' changeDetection: ChangeDetectionStrategy.OnPush,',
262
+ " template: '',",
263
+ " host: { style: 'display: contents' },",
264
+ '})',
265
+ `export class ${c.name} {`,
266
+ ...fields,
267
+ ...(fields.length ? [''] : []),
268
+ ' constructor() {',
269
+ ' const root = createRoot(inject<ElementRef<HTMLElement>>(ElementRef).nativeElement);',
270
+ ` afterRenderEffect(() => root.render(createElement(${local}, ${object} satisfies Props)));`,
271
+ ' inject(DestroyRef).onDestroy(() => root.unmount());',
272
+ ' }',
273
+ '}',
274
+ '',
275
+ ].join('\n');
276
+ }
@@ -0,0 +1,7 @@
1
+ import type { StepComparison, UnmountLeaks, VerifyResult } from '../types.js';
2
+ /** One line per framework for what an unmount left running (`verify --unmount`). */
3
+ export declare function leakLine(l: UnmountLeaks): string;
4
+ /** The lines for one scripted step (`verify --steps`): its match, what changed, a failure, and each differing DOM fact. */
5
+ export declare function stepLines(c: StepComparison): string[];
6
+ /** The text `verify` prints for a result: states, totals, steps, unmount leaks, diagnostics and the report path. */
7
+ export declare function verifyLines(result: VerifyResult): string[];
@@ -0,0 +1,30 @@
1
+ import { describeLeaks } from '../verify/leaks.js';
2
+ /** One line per framework for what an unmount left running (`verify --unmount`). */
3
+ export function leakLine(l) {
4
+ const own = l.framework === 'react' ? l : l.beyondReact;
5
+ if (l.clean)
6
+ return ` unmount ${l.framework.padEnd(7)} leaves nothing${l.framework === 'react' ? '' : ' that React does not'}`;
7
+ if (!own)
8
+ return ` unmount ${l.framework.padEnd(7)} not compared (React could not be measured)`;
9
+ return ` unmount ${l.framework.padEnd(7)} leaves running${l.framework === 'react' ? '' : ' (beyond React)'}: ${describeLeaks(own)}`;
10
+ }
11
+ /** The lines for one scripted step (`verify --steps`): its match, what changed, a failure, and each differing DOM fact. */
12
+ export function stepLines(c) {
13
+ const changed = c.changedMatch === null ? (c.changedInReact ? '' : ' (React shows no change)') : `, changed region ${(c.changedMatch * 100).toFixed(2)}%`;
14
+ return [
15
+ ` step ${String(c.index + 1).padStart(2)} ${c.step} ${c.target.padEnd(7)} ${(c.match * 100).toFixed(2)}% match${changed}${c.failure ? ` FAILED: ${c.failure}` : ''}`,
16
+ ...c.state.map((m) => ` ${m.fact}: React ${m.react ?? 'missing'}, ${c.target} ${m.actual ?? 'missing'}`),
17
+ ];
18
+ }
19
+ /** The text `verify` prints for a result: states, totals, steps, unmount leaks, diagnostics and the report path. */
20
+ export function verifyLines(result) {
21
+ return [
22
+ `${result.file} · ${result.exportName}`,
23
+ ...result.comparisons.map((c) => ` ${c.state.padEnd(6)} ${c.target.padEnd(7)} ${(c.match * 100).toFixed(2)}% match${c.changedFromIdle === false ? ' (no visible change from idle)' : ''}`),
24
+ ` lowest ${(result.minMatch * 100).toFixed(2)}% · ${result.blocked.length} blocked request(s) · ${result.pageErrors.length} page error(s)`,
25
+ ...(result.steps ?? []).flatMap(stepLines),
26
+ ...(result.leaks ?? []).map(leakLine),
27
+ ...result.diagnostics.map((d) => ` [${d.severity}] ${d.code}: ${d.message}`),
28
+ ...(result.reportPath ? [` report: ${result.reportPath}`] : []),
29
+ ];
30
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};