@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,119 @@
1
+ import { relative } from 'node:path';
2
+ import * as t from '@babel/types';
3
+ import { classifyImport, resolveLocal } from './deps.js';
4
+ import { lowerGraph } from '../pipeline.js';
5
+ import { moduleDiagnostics } from '../ir/lower.js';
6
+ import { toPosix } from '../utils/fs-safe.js';
7
+ const GLSL = /gl_FragColor|gl_FragCoord|\bvoid\s+main\s*\(|precision\s+(high|medium|low)p\b|\/\*\s*glsl\s*\*\//;
8
+ function componentInfo(c) {
9
+ const hooks = new Set();
10
+ let usesCanvas = false;
11
+ let usesWebGL = false;
12
+ for (const item of c.items) {
13
+ if (item.kind === 'hook')
14
+ hooks.add(item.hook);
15
+ if (item.kind === 'state')
16
+ hooks.add('useState');
17
+ if (item.kind === 'ref')
18
+ hooks.add('useRef');
19
+ if (item.kind === 'effect') {
20
+ hooks.add(item.phase === 'effect' ? 'useEffect' : 'useLayoutEffect');
21
+ t.traverseFast(item.body, (n) => {
22
+ if (t.isCallExpression(n) && t.isMemberExpression(n.callee) && t.isIdentifier(n.callee.property, { name: 'getContext' })) {
23
+ const arg = n.arguments[0];
24
+ if (t.isStringLiteral(arg) && /webgl/.test(arg.value))
25
+ usesWebGL = true;
26
+ else
27
+ usesCanvas = true;
28
+ }
29
+ });
30
+ }
31
+ if (item.kind === 'id')
32
+ hooks.add('useId');
33
+ }
34
+ let usesMotion = false;
35
+ const walk = (n) => {
36
+ if (!n || typeof n !== 'object')
37
+ return;
38
+ if ('motion' in n && n.motion)
39
+ usesMotion = true;
40
+ if ('type' in n && n.type === 'presence')
41
+ usesMotion = true;
42
+ for (const key of ['children', 'branches']) {
43
+ const v = n[key];
44
+ if (Array.isArray(v))
45
+ v.forEach(walk);
46
+ }
47
+ };
48
+ walk(c.template);
49
+ return {
50
+ name: c.name,
51
+ exported: c.exported,
52
+ isDefault: c.isDefault,
53
+ props: [...c.declared.entries()].map(([name, m]) => {
54
+ const p = c.props.find((x) => x.key === name);
55
+ return { name, optional: m.optional, hasDefault: !!p?.defaultValue, kind: p?.kind ?? (name === 'children' ? 'children' : 'value') };
56
+ }),
57
+ hooks: [...hooks],
58
+ usesMotion,
59
+ usesCanvas,
60
+ usesWebGL,
61
+ };
62
+ }
63
+ /** What a component file is made of: its components, hooks, imports, the web features it uses and every finding. */
64
+ export function buildAnalysis(entry, nodes, project, graphDiagnostics) {
65
+ const modules = lowerGraph(nodes, project);
66
+ const mod = modules.get(entry);
67
+ const features = { tailwind: false, framerMotion: false, canvas2d: false, webgl: false, glsl: false, svg: false, cssImports: [], nextFont: false, customHooks: [], effects: 0 };
68
+ const imports = [];
69
+ for (const node of nodes) {
70
+ if (node.css) {
71
+ features.cssImports.push(node.rel);
72
+ continue;
73
+ }
74
+ if (/class(Name)?=["'{][^"'}]*\b(flex|grid|px-|py-|text-|bg-|rounded|shadow|w-|h-)/.test(node.code) || /cn\(/.test(node.code))
75
+ features.tailwind = true;
76
+ if (/from ['"](framer-motion|motion\/react)/.test(node.code))
77
+ features.framerMotion = true;
78
+ if (/getContext\(\s*['"]2d/.test(node.code))
79
+ features.canvas2d = true;
80
+ if (/getContext\(\s*['"](webgl2?|experimental-webgl)/.test(node.code))
81
+ features.webgl = true;
82
+ if (GLSL.test(node.code))
83
+ features.glsl = true;
84
+ if (/<svg[\s>]/.test(node.code))
85
+ features.svg = true;
86
+ if (/from ['"]next\/font/.test(node.code))
87
+ features.nextFont = true;
88
+ const m = modules.get(node.file);
89
+ if (m) {
90
+ features.customHooks.push(...m.hooks.map((h) => h.name));
91
+ for (const c of m.components)
92
+ features.effects += c.items.filter((i) => i.kind === 'effect').length;
93
+ }
94
+ }
95
+ if (mod) {
96
+ for (const decl of mod.imports) {
97
+ const source = decl.source.value;
98
+ const resolved = resolveLocal(entry, source, project);
99
+ const names = decl.specifiers.map((s) => s.local.name);
100
+ const kind = resolved ? (source.endsWith('.css') ? 'css' : 'local') : classifyImport(source);
101
+ imports.push({ source, kind, names, ...(resolved ? { resolved: toPosix(relative(project.root, resolved)) } : {}) });
102
+ }
103
+ }
104
+ const diagnostics = [...graphDiagnostics];
105
+ for (const m of modules.values()) {
106
+ for (const d of moduleDiagnostics(m))
107
+ diagnostics.push({ ...d, ...(d.file ? { file: toPosix(relative(project.root, d.file)) } : {}) });
108
+ }
109
+ const entryNode = nodes.find((n) => n.file === entry);
110
+ return {
111
+ file: entryNode?.rel ?? toPosix(relative(project.root, entry)),
112
+ components: mod?.components.map(componentInfo) ?? [],
113
+ hooks: mod?.hooks.map((h) => h.name) ?? [],
114
+ imports,
115
+ features,
116
+ diagnostics,
117
+ graph: [...(entryNode ? [entryNode.rel] : []), ...nodes.filter((n) => n.file !== entry).map((n) => n.rel)],
118
+ };
119
+ }
@@ -0,0 +1,21 @@
1
+ import babelTraverse from '@babel/traverse';
2
+ import babelGenerate from '@babel/generator';
3
+ import type * as t from '@babel/types';
4
+ export declare const traverse: {
5
+ <S>(parent: babelTraverse.Node, opts: babelTraverse.TraverseOptions<S>, scope: babelTraverse.Scope | undefined, state: S, parentPath?: babelTraverse.NodePath): void;
6
+ (parent: babelTraverse.Node, opts?: babelTraverse.TraverseOptions, scope?: babelTraverse.Scope, state?: any, parentPath?: babelTraverse.NodePath): void;
7
+ visitors: typeof babelTraverse.visitors;
8
+ verify: typeof babelTraverse.visitors.verify;
9
+ explode: typeof babelTraverse.visitors.explode;
10
+ cheap: (node: babelTraverse.Node, enter: (node: babelTraverse.Node) => void) => void;
11
+ node: (node: babelTraverse.Node, opts: babelTraverse.TraverseOptions, scope?: babelTraverse.Scope, state?: any, path?: babelTraverse.NodePath, skipKeys?: Record<string, boolean>) => void;
12
+ clearNode: (node: babelTraverse.Node, opts?: babelTraverse.RemovePropertiesOptions) => void;
13
+ removeProperties: (tree: babelTraverse.Node, opts?: babelTraverse.RemovePropertiesOptions) => babelTraverse.Node;
14
+ hasType: (tree: babelTraverse.Node, type: babelTraverse.Node["type"], denylistTypes?: string[]) => boolean;
15
+ cache: typeof babelTraverse.cache;
16
+ };
17
+ export declare const generate: typeof babelGenerate.generate;
18
+ /** Parses TypeScript (and JSX for .tsx/.jsx) into a Babel AST; refuses inputs over 512 KB. */
19
+ export declare function parseSource(code: string, file: string): t.File;
20
+ /** Generates code for one node (no formatting beyond Babel's own). */
21
+ export declare function print(node: t.Node): string;
@@ -0,0 +1,29 @@
1
+ import { parse as babelParse } from '@babel/parser';
2
+ import babelTraverse from '@babel/traverse';
3
+ import babelGenerate from '@babel/generator';
4
+ import { assertSourceSize } from '../utils/fs-safe.js';
5
+ import { MorphError } from '../utils/errors.js';
6
+ // Babel ships CommonJS: under Node ESM the default import is the module object, whose `default` is the function.
7
+ export const traverse = babelTraverse.default;
8
+ export const generate = babelGenerate.default;
9
+ /** Parses TypeScript (and JSX for .tsx/.jsx) into a Babel AST; refuses inputs over 512 KB. */
10
+ export function parseSource(code, file) {
11
+ assertSourceSize(code, file);
12
+ const jsx = /\.(tsx|jsx)$/.test(file);
13
+ try {
14
+ return babelParse(code, {
15
+ sourceType: 'module',
16
+ sourceFilename: file,
17
+ plugins: jsx ? ['typescript', 'jsx'] : ['typescript'],
18
+ errorRecovery: false,
19
+ });
20
+ }
21
+ catch (error) {
22
+ const message = error instanceof Error ? error.message : String(error);
23
+ throw new MorphError('parse-error', `${file}: ${message}`);
24
+ }
25
+ }
26
+ /** Generates code for one node (no formatting beyond Babel's own). */
27
+ export function print(node) {
28
+ return generate(node, { jsescOption: { minimal: true }, retainLines: false }).code;
29
+ }
@@ -0,0 +1,16 @@
1
+ import type { CompileOptions, CompileResult } from './types.js';
2
+ export interface CompileRequest {
3
+ id: number;
4
+ file: string;
5
+ options: Omit<CompileOptions, 'signal'>;
6
+ }
7
+ export type CompileReply = {
8
+ id: number;
9
+ result: CompileResult;
10
+ } | {
11
+ id: number;
12
+ error: {
13
+ code: string | null;
14
+ message: string;
15
+ };
16
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The worker thread `batch` compiles in (see batch.ts): one file per message, the result posted back. A thread can be
3
+ * terminated in the middle of synchronous code, so a file that never finishes costs its time limit, not the run.
4
+ */
5
+ import { parentPort } from 'node:worker_threads';
6
+ import { compileFile } from './pipeline.js';
7
+ import { MorphError, errorMessage } from './utils/errors.js';
8
+ parentPort?.on('message', (request) => {
9
+ void compileFile(request.file, request.options).then((result) => parentPort?.postMessage({ id: request.id, result }), (error) => parentPort?.postMessage({ id: request.id, error: { code: error instanceof MorphError ? error.code : null, message: errorMessage(error) } }));
10
+ });
@@ -0,0 +1,26 @@
1
+ import type { BatchEntry, BatchOptions, BatchReport, Target } from './types.js';
2
+ import { type AssistOptions } from './ai/repair.js';
3
+ /** The longest one file may take to compile in a batch before it is stopped and reported (`compile-timeout`). */
4
+ export declare const FILE_TIMEOUT = 180000;
5
+ /**
6
+ * A corpus: the sub-folders of a batch's input to compile, read from a JSON file that lists them (`["buttons", "ui"]`),
7
+ * as `include` takes them. The file is the caller's: morph knows no project's folders.
8
+ */
9
+ export declare function readFolderList(file: string): string[];
10
+ /** The .tsx files under `input`, limited to `include` sub-folders when given. */
11
+ export declare function collectFiles(input: string, include?: string[], exclude?: string[]): string[];
12
+ /**
13
+ * Compiles every component file under a folder to every target, optionally writing the output, and reports an honest
14
+ * scorecard: per file and target, clean / partial / unsupported, whether the real compilers accepted the output, and
15
+ * the most common causes.
16
+ */
17
+ export declare function runBatch(input: string, options?: BatchOptions & {
18
+ assist?: AssistOptions;
19
+ }, onProgress?: (done: number, total: number, file: string) => void): Promise<BatchReport>;
20
+ /** A batch report small enough to keep in git: totals, top causes, and per file its statuses and diagnostic codes. */
21
+ export interface BatchSummary extends Omit<BatchReport, 'entries'> {
22
+ entries: (Omit<BatchEntry, 'diagnostics'> & {
23
+ codes: Partial<Record<Target | 'all', string[]>>;
24
+ })[];
25
+ }
26
+ export declare function summarizeReport(report: BatchReport): BatchSummary;
package/dist/batch.js ADDED
@@ -0,0 +1,227 @@
1
+ import { readdirSync, readFileSync, statSync } from 'node:fs';
2
+ import { join, relative, resolve } from 'node:path';
3
+ import { Worker } from 'node:worker_threads';
4
+ import { TARGETS } from './types.js';
5
+ import { findProjectRoot } from './analyzer/deps.js';
6
+ import { toPosix, writeInside } from './utils/fs-safe.js';
7
+ import { errorMessage, MorphError } from './utils/errors.js';
8
+ import { worst } from './pipeline.js';
9
+ import { runRepair } from './ai/repair.js';
10
+ /** The longest one file may take to compile in a batch before it is stopped and reported (`compile-timeout`). */
11
+ export const FILE_TIMEOUT = 180_000;
12
+ /**
13
+ * Compiles one file at a time in a worker thread. A compile is synchronous most of its way, so a promise timer could
14
+ * never stop one that does not finish: a thread can be terminated anywhere. The thread is kept from file to file (its
15
+ * caches stay warm) and replaced only after one was stopped or crashed.
16
+ */
17
+ class CompileThread {
18
+ worker = null;
19
+ nextId = 1;
20
+ compile(file, options, timeoutMs, signal) {
21
+ signal?.throwIfAborted();
22
+ const worker = (this.worker ??= new Worker(new URL('./batch-worker.js', import.meta.url)));
23
+ const id = this.nextId++;
24
+ return new Promise((resolvePromise, reject) => {
25
+ const settle = () => {
26
+ clearTimeout(timer);
27
+ worker.off('message', onMessage);
28
+ worker.off('error', onError);
29
+ worker.off('exit', onExit);
30
+ signal?.removeEventListener('abort', onAbort);
31
+ };
32
+ const drop = (error) => {
33
+ settle();
34
+ if (this.worker === worker)
35
+ this.worker = null;
36
+ void worker.terminate();
37
+ reject(error);
38
+ };
39
+ const onMessage = (reply) => {
40
+ if (reply.id !== id)
41
+ return;
42
+ settle();
43
+ if ('result' in reply)
44
+ resolvePromise(reply.result);
45
+ else
46
+ reject(new MorphError(reply.error.code ?? 'compile-crash', reply.error.message));
47
+ };
48
+ const onError = (error) => drop(new MorphError('compile-crash', `The compiler thread failed on this file: ${errorMessage(error)}`));
49
+ const onExit = (code) => drop(new MorphError('compile-crash', `The compiler thread stopped on this file (exit code ${code}).`));
50
+ const onAbort = () => drop(signal?.reason instanceof MorphError ? signal.reason : new MorphError('batch-stopped', 'The batch was stopped.'));
51
+ const timer = setTimeout(() => drop(new MorphError('compile-timeout', `Compiling this file took longer than ${Math.round(timeoutMs / 1000)}s, so it was stopped.`)), timeoutMs);
52
+ worker.on('message', onMessage);
53
+ worker.on('error', onError);
54
+ worker.on('exit', onExit);
55
+ signal?.addEventListener('abort', onAbort, { once: true });
56
+ worker.postMessage({ id, file, options });
57
+ });
58
+ }
59
+ async close() {
60
+ const worker = this.worker;
61
+ this.worker = null;
62
+ await worker?.terminate();
63
+ }
64
+ }
65
+ /**
66
+ * A corpus: the sub-folders of a batch's input to compile, read from a JSON file that lists them (`["buttons", "ui"]`),
67
+ * as `include` takes them. The file is the caller's: morph knows no project's folders.
68
+ */
69
+ export function readFolderList(file) {
70
+ let value;
71
+ try {
72
+ value = JSON.parse(readFileSync(resolve(file), 'utf8'));
73
+ }
74
+ catch (error) {
75
+ throw new MorphError('bad-corpus', `The corpus file ${file} could not be read as JSON: ${errorMessage(error)}`);
76
+ }
77
+ if (!Array.isArray(value) || !value.length || !value.every((v) => typeof v === 'string' && v.trim() !== '')) {
78
+ throw new MorphError('bad-corpus', `The corpus file ${file} must hold a non-empty JSON array of folder names, relative to the batch's input folder.`);
79
+ }
80
+ return value.map((v) => v.trim());
81
+ }
82
+ function walk(dir, out) {
83
+ for (const name of readdirSync(dir).sort()) {
84
+ const full = join(dir, name);
85
+ const st = statSync(full);
86
+ if (st.isDirectory()) {
87
+ if (name === 'node_modules' || name.startsWith('.'))
88
+ continue;
89
+ walk(full, out);
90
+ }
91
+ else if (name.endsWith('.tsx') && !/\.(test|spec|stories)\.tsx$/.test(name))
92
+ out.push(full);
93
+ }
94
+ }
95
+ /** The .tsx files under `input`, limited to `include` sub-folders when given. */
96
+ export function collectFiles(input, include, exclude) {
97
+ const root = resolve(input);
98
+ const dirs = include?.length ? include.map((d) => join(root, d)) : [root];
99
+ const files = [];
100
+ for (const dir of dirs) {
101
+ if (!statSync(dir, { throwIfNoEntry: false })?.isDirectory())
102
+ throw new MorphError('not-found', `No such folder: ${toPosix(relative(process.cwd(), dir))}`);
103
+ walk(dir, files);
104
+ }
105
+ const skip = (exclude ?? []).map((e) => toPosix(join(root, e)) + '/');
106
+ return files.filter((f) => !skip.some((s) => toPosix(f).startsWith(s)));
107
+ }
108
+ /** `bridged` is counted only in a run with bridge mode on: without it the totals are what they always were. */
109
+ function emptyCounts(bridge = false, assisted = false) {
110
+ const counts = bridge ? { clean: 0, partial: 0, unsupported: 0, bridged: 0 } : { clean: 0, partial: 0, unsupported: 0 };
111
+ // assisted mode (X6): `assisted` is counted only in a run with it on
112
+ if (assisted)
113
+ counts.assisted = 0;
114
+ return counts;
115
+ }
116
+ function count(counts, status) {
117
+ if (status === 'bridged')
118
+ counts.bridged = (counts.bridged ?? 0) + 1;
119
+ // assisted mode (X6): counted on its own, never as clean or partial
120
+ else if (status === 'assisted')
121
+ counts.assisted = (counts.assisted ?? 0) + 1;
122
+ else
123
+ counts[status]++;
124
+ }
125
+ /**
126
+ * Compiles every component file under a folder to every target, optionally writing the output, and reports an honest
127
+ * scorecard: per file and target, clean / partial / unsupported, whether the real compilers accepted the output, and
128
+ * the most common causes.
129
+ */
130
+ export async function runBatch(input, options = {}, onProgress) {
131
+ const files = collectFiles(input, options.include, options.exclude);
132
+ const targets = options.targets ?? [...TARGETS];
133
+ const root = resolve(options.root ?? findProjectRoot(files[0] ?? join(resolve(input), 'x.tsx')));
134
+ const entries = [];
135
+ const byTarget = Object.fromEntries(TARGETS.map((t) => [t, emptyCounts(options.bridge, options.assist !== undefined)]));
136
+ const allTargets = emptyCounts(options.bridge, options.assist !== undefined);
137
+ const validationFailures = Object.fromEntries(TARGETS.map((t) => [t, 0]));
138
+ const causes = new Map();
139
+ let done = 0;
140
+ const { signal, fileTimeoutMs, assist, ...compileOptions } = options;
141
+ const thread = new CompileThread();
142
+ try {
143
+ for (const file of files) {
144
+ signal?.throwIfAborted();
145
+ const rel = toPosix(relative(root, file));
146
+ onProgress?.(done, files.length, rel);
147
+ const entryTargets = {};
148
+ let diagnostics = [];
149
+ try {
150
+ const result = await thread.compile(file, { ...compileOptions, root, targets }, fileTimeoutMs ?? FILE_TIMEOUT, signal);
151
+ for (let tr of result.targets) {
152
+ // assisted mode (X6, opt-in): a refused web target is written by the model only if it passes every gate
153
+ if (assist && tr.status === 'unsupported' && tr.target !== 'react-native') {
154
+ const r = await runRepair(file, { ...assist, target: tr.target, root, ...(compileOptions.aliases ? { aliases: compileOptions.aliases } : {}), ...(compileOptions.typecheck === false ? { typecheck: false } : {}), ...(compileOptions.fonts ? { fonts: compileOptions.fonts } : {}), ...(signal ? { signal } : {}) });
155
+ if (r.accepted)
156
+ tr = r.result;
157
+ }
158
+ entryTargets[tr.target] = { status: tr.status, validated: tr.validated, diagnostics: tr.diagnostics.length, ...(tr.fidelity ? { fidelity: tr.fidelity.score } : {}) };
159
+ diagnostics.push(...tr.diagnostics);
160
+ // a file whose output the target's compiler rejected; a file refused before that step is not compiled at all
161
+ // (validated: false) and is counted under its own error, not here
162
+ if (tr.diagnostics.some((d) => d.code === 'validation-failed'))
163
+ validationFailures[tr.target]++;
164
+ if (options.outDir)
165
+ for (const f of tr.files)
166
+ writeInside(join(resolve(options.outDir), tr.target), f.path, f.contents);
167
+ }
168
+ }
169
+ catch (error) {
170
+ // a stopped batch ends here; anything else is this file's failure, reported
171
+ signal?.throwIfAborted();
172
+ const d = { code: error instanceof MorphError ? error.code : 'compile-crash', severity: 'error', message: errorMessage(error), file: rel };
173
+ diagnostics = [d];
174
+ for (const t of targets)
175
+ entryTargets[t] = { status: 'unsupported', validated: false, diagnostics: 1 };
176
+ }
177
+ const statuses = targets.map((t) => entryTargets[t]?.status ?? 'unsupported');
178
+ // the worst target's status (unsupported, bridged, assisted, partial, clean), as a compile's file status is
179
+ const entry = { file: rel, status: worst(statuses), targets: entryTargets, diagnostics };
180
+ entries.push(entry);
181
+ for (const t of targets)
182
+ count(byTarget[t], entryTargets[t]?.status ?? 'unsupported');
183
+ count(allTargets, entry.status);
184
+ for (const d of diagnostics) {
185
+ if (d.severity === 'info')
186
+ continue;
187
+ const key = `${d.severity}:${d.code}`;
188
+ const c = causes.get(key) ?? { code: d.code, severity: d.severity, count: 0, files: new Set(), example: d.message };
189
+ c.count++;
190
+ c.files.add(rel);
191
+ causes.set(key, c);
192
+ }
193
+ done++;
194
+ }
195
+ }
196
+ finally {
197
+ await thread.close();
198
+ }
199
+ onProgress?.(done, files.length, '');
200
+ const topCauses = [...causes.values()]
201
+ .sort((a, b) => b.files.size - a.files.size || b.count - a.count)
202
+ .slice(0, 30)
203
+ .map((c) => ({ code: c.code, severity: c.severity, count: c.count, files: c.files.size, example: c.example }));
204
+ return {
205
+ generatedAt: new Date().toISOString(),
206
+ root: '.',
207
+ dirs: options.include ?? [toPosix(relative(root, resolve(input)))],
208
+ totals: { files: files.length, byTarget, allTargets, validationFailures },
209
+ topCauses,
210
+ entries,
211
+ };
212
+ }
213
+ export function summarizeReport(report) {
214
+ const entries = report.entries.map(({ diagnostics, ...entry }) => {
215
+ const codes = {};
216
+ for (const d of diagnostics) {
217
+ if (d.severity === 'info')
218
+ continue;
219
+ // diagnostics of the analysis (no target) apply to every target
220
+ const list = (codes[d.target ?? 'all'] ??= []);
221
+ if (!list.includes(d.code))
222
+ list.push(d.code);
223
+ }
224
+ return { ...entry, codes };
225
+ });
226
+ return { ...report, entries };
227
+ }
@@ -0,0 +1,26 @@
1
+ import type { AnalyzeResult, TargetResult } from '../types.js';
2
+ import type { Project } from '../analyzer/deps.js';
3
+ import { type BridgeComponent } from './props.js';
4
+ export type { BridgeComponent, BridgeProp, PropPlan } from './props.js';
5
+ /** The costs every bridged component carries, stated in its `bridged` diagnostic. */
6
+ export declare const BRIDGE_COSTS = "Costs: React's runtime (react, react-dom) is in the bundle; the wrapper adds one element (display: contents) around React's DOM, so the page is not DOM-identical to React's component rendered alone (child and sibling selectors such as :first-child see the wrapper); the bridged part does not render on the server; context the host framework provides does not reach React, and React context does not leave it.";
7
+ /**
8
+ * How the wrapper imports the React original from where it lives: through the project's own path alias when one covers
9
+ * the file (`@/components/card/Card`), else as a sibling (`./Card`: the wrapper is then placed beside the original).
10
+ */
11
+ export declare function importSpecifier(entry: string, project: Project): string;
12
+ /** One bridged entry's shared work (TypeScript's view of the React module), made once for every target. */
13
+ export interface BridgePlan {
14
+ components: BridgeComponent[];
15
+ specifier: string;
16
+ declaration: string | null;
17
+ }
18
+ export declare function planBridge(entry: string, project: Project, analysis: AnalyzeResult): BridgePlan;
19
+ /**
20
+ * Bridge mode for one target the compiler refused: a thin wrapper per exported component mounts the React original,
21
+ * unchanged, with react-dom's createRoot. Returns the refused result with the bridge's files and status `bridged`, or
22
+ * the refused result with the reasons the bridge could not be made (still `unsupported`).
23
+ */
24
+ export declare function bridgeResult(refused: TargetResult, plan: BridgePlan, sourceRel: string, project: Project, validate: boolean, typecheck: boolean): Promise<TargetResult>;
25
+ /** The relative path of an entry in a project, as diagnostics name it. */
26
+ export declare function sourceRelOf(entry: string, project: Project): string;
@@ -0,0 +1,138 @@
1
+ import { basename, dirname, relative } from 'node:path';
2
+ import prettier from 'prettier';
3
+ import { toPosix } from '../utils/fs-safe.js';
4
+ import { errorMessage } from '../utils/errors.js';
5
+ import { validateAngular, validateFiles } from '../validate.js';
6
+ import { typecheckWeb } from '../typecheck/index.js';
7
+ import { ambientDeclaration, bridgeComponents, bridgeProgram, classComponents } from './props.js';
8
+ import { angularInputs, angularWrapper, svelteWrapper, vueWrapper } from './wrappers.js';
9
+ /** The costs every bridged component carries, stated in its `bridged` diagnostic. */
10
+ export const BRIDGE_COSTS = "Costs: React's runtime (react, react-dom) is in the bundle; the wrapper adds one element (display: contents) around React's DOM, so the page is not DOM-identical to React's component rendered alone (child and sibling selectors such as :first-child see the wrapper); the bridged part does not render on the server; context the host framework provides does not reach React, and React context does not leave it.";
11
+ const BRIDGEABLE = ['vue', 'svelte', 'angular'];
12
+ /**
13
+ * How the wrapper imports the React original from where it lives: through the project's own path alias when one covers
14
+ * the file (`@/components/card/Card`), else as a sibling (`./Card`: the wrapper is then placed beside the original).
15
+ */
16
+ export function importSpecifier(entry, project) {
17
+ const file = toPosix(entry).replace(/\.(tsx|ts|jsx|js)$/, '');
18
+ for (const [alias, dir] of Object.entries(project.aliases)) {
19
+ const base = toPosix(dir);
20
+ const prefix = base.endsWith('/') ? base : `${base}/`;
21
+ if (file.toLowerCase().startsWith(prefix.toLowerCase()))
22
+ return `${alias}${file.slice(prefix.length)}`;
23
+ }
24
+ return `./${basename(file)}`;
25
+ }
26
+ export function planBridge(entry, project, analysis) {
27
+ const wanted = analysis.components.filter((c) => c.exported).map((c) => ({ name: c.name, isDefault: c.isDefault }));
28
+ const specifier = importSpecifier(entry, project);
29
+ // one program answers the type questions and emits the declaration
30
+ const program = bridgeProgram(project, [entry], { declaration: true, emitDeclarationOnly: true, noEmit: false, outDir: undefined, declarationDir: undefined, sourceMap: false, declarationMap: false });
31
+ // X6: class components too (the analysis lists function components only)
32
+ for (const c of classComponents(program, entry))
33
+ if (!wanted.some((w) => w.name === c.name || (w.isDefault && c.isDefault)))
34
+ wanted.push(c);
35
+ const components = bridgeComponents(program, entry, wanted, project.root);
36
+ return { components, specifier, declaration: ambientDeclaration(program, entry, specifier) };
37
+ }
38
+ /** Where a wrapper goes: where the target's emitter puts the component (Angular: `<file>.component.ts`, others beside it). */
39
+ function wrapperPath(target, sourceRel, name, index) {
40
+ const dir = dirname(sourceRel);
41
+ const prefix = dir === '.' ? '' : `${toPosix(dir)}/`;
42
+ if (target === 'vue')
43
+ return `${prefix}${name}.vue`;
44
+ if (target === 'svelte')
45
+ return `${prefix}${name}.svelte`;
46
+ // `.component.ts`: a sibling import of the original (`./card`) must not find the wrapper itself
47
+ return `${prefix}${basename(sourceRel).replace(/\.(tsx|ts|jsx|js)$/, '')}${index === 0 ? '' : `.${name}`}.component.ts`;
48
+ }
49
+ /**
50
+ * Bridge mode for one target the compiler refused: a thin wrapper per exported component mounts the React original,
51
+ * unchanged, with react-dom's createRoot. Returns the refused result with the bridge's files and status `bridged`, or
52
+ * the refused result with the reasons the bridge could not be made (still `unsupported`).
53
+ */
54
+ export async function bridgeResult(refused, plan, sourceRel, project, validate, typecheck) {
55
+ const target = refused.target;
56
+ if (target === 'react-native' || !BRIDGEABLE.includes(target))
57
+ return refused;
58
+ const errors = refused.diagnostics.filter((d) => d.severity === 'error');
59
+ const blocked = [];
60
+ const notes = [];
61
+ if (!plan.components.length)
62
+ blocked.push({ code: 'bridge-boundary', severity: 'error', message: 'Bridge mode: the file exports no component TypeScript can see the props of, so there is nothing to mount.', file: sourceRel, target });
63
+ if (!plan.declaration)
64
+ blocked.push({ code: 'bridge-boundary', severity: 'error', message: 'Bridge mode: TypeScript emits no declaration for this file, so the wrapper has no types to import.', file: sourceRel, target });
65
+ for (const c of plan.components) {
66
+ const at = { file: sourceRel, target, ...(c.line ? { line: c.line } : {}) };
67
+ for (const p of c.props) {
68
+ if (p.plan === 'refuse')
69
+ blocked.push({ code: 'bridge-boundary', severity: 'error', message: `Bridge mode: ${c.name}'s required prop ${p.name} cannot cross from ${target} into React (${p.reason}), so ${c.name} is not bridged.`, ...at });
70
+ else if (p.plan === 'drop')
71
+ notes.push({ code: 'bridge-prop-dropped', severity: 'warning', message: `Bridge mode: ${c.name}'s optional prop ${p.name} is left out of the wrapper (${p.reason}); React renders as if it was not passed.`, ...at });
72
+ else if (p.plan === 'text')
73
+ notes.push({ code: 'bridge-prop-text', severity: 'warning', message: `Bridge mode: ${c.name}'s prop ${p.name} takes text only through the wrapper (${p.reason}).`, ...at });
74
+ }
75
+ if (target === 'angular') {
76
+ const inputs = new Set(angularInputs(c).map((p) => p.name));
77
+ const missing = c.props.filter((p) => (p.plan === 'cross' || p.plan === 'text') && !inputs.has(p.name));
78
+ const required = missing.filter((p) => !p.optional);
79
+ if (required.length)
80
+ blocked.push({ code: 'bridge-boundary', severity: 'error', message: `Bridge mode: ${c.name}'s required props ${required.map((p) => p.name).join(', ')} come from a library's types (or are not identifiers), and the Angular wrapper takes only the props the project declares as inputs.`, ...at });
81
+ else if (missing.length)
82
+ notes.push({ code: 'bridge-prop-dropped', severity: 'warning', message: `Bridge mode: the Angular wrapper takes as inputs only the props ${c.name} declares itself; ${missing.length} prop${missing.length === 1 ? '' : 's'} from a library's types (${missing.slice(0, 6).map((p) => p.name).join(', ')}${missing.length > 6 ? ', …' : ''}) are not passed.`, ...at });
83
+ // inputs are separate values: they cannot keep a union's pairing of props (`as: 'button'` with `onPress`)
84
+ const paired = angularInputs(c).filter((p) => p.partial);
85
+ if (paired.length)
86
+ blocked.push({ code: 'bridge-boundary', severity: 'error', message: `Bridge mode: ${c.name}'s props type is a union whose members take different props (${paired.map((p) => p.name).join(', ')}); Angular inputs are separate values and cannot keep that pairing, so ${c.name} is not bridged for Angular.`, ...at });
87
+ }
88
+ }
89
+ if (blocked.length)
90
+ return { ...refused, diagnostics: [...refused.diagnostics, ...blocked] };
91
+ const made = [];
92
+ for (const [index, c] of plan.components.entries()) {
93
+ const input = { component: c, specifier: plan.specifier };
94
+ made.push({ path: wrapperPath(target, sourceRel, c.name, index), contents: target === 'vue' ? vueWrapper(input) : target === 'svelte' ? svelteWrapper(input) : angularWrapper(input), kind: 'component' });
95
+ }
96
+ // an ambient module for an alias import; for a sibling import, the declaration file the import finds beside the wrapper
97
+ const declarationPath = `${dirname(sourceRel) === '.' ? '' : `${toPosix(dirname(sourceRel))}/`}${basename(sourceRel).replace(/\.(tsx|ts|jsx|js)$/, '')}${plan.specifier.startsWith('.') ? '' : '.react'}.d.ts`;
98
+ if (plan.declaration)
99
+ made.push({ path: declarationPath, contents: plan.declaration, kind: 'module' });
100
+ // printed as the emitters' output is (Prettier); the Svelte wrapper is written already formatted
101
+ const files = await Promise.all(made.map(async (f) => {
102
+ const parser = f.path.endsWith('.vue') ? 'vue' : f.path.endsWith('.ts') && !f.path.endsWith('.d.ts') ? 'typescript' : null;
103
+ return parser ? { ...f, contents: await prettier.format(f.contents, { parser, singleQuote: true, printWidth: 120, trailingComma: 'all', vueIndentScriptAndStyle: false }) } : f;
104
+ }));
105
+ // the wrappers pass the target's real compiler, and Vue's and Svelte's strict type check
106
+ let problems = [];
107
+ try {
108
+ if (validate)
109
+ problems = target === 'angular' ? await validateAngular(files) : validateFiles(files.filter((f) => !f.path.endsWith('.d.ts')), target);
110
+ if (validate && typecheck && !problems.length && (target === 'vue' || target === 'svelte')) {
111
+ for (const p of await typecheckWeb(files, target, project.root))
112
+ problems.push({ code: 'type-error', severity: 'error', message: `${p.path}${p.line ? `: line ${p.line}` : ''}: ${p.message.split('\n')[0]}`, file: p.path, target });
113
+ }
114
+ }
115
+ catch (error) {
116
+ problems = [{ code: 'bridge-invalid', severity: 'error', message: `Bridge mode: the wrapper could not be checked: ${errorMessage(error)}`, file: sourceRel, target }];
117
+ }
118
+ if (problems.length) {
119
+ const invalid = problems.map((d) => ({ ...d, code: 'bridge-invalid', severity: 'error', message: `Bridge mode: the generated wrapper fails its check: ${d.message}`, target }));
120
+ return { ...refused, diagnostics: [...refused.diagnostics, ...invalid] };
121
+ }
122
+ const why = errors.length ? errors.map((d) => `${d.code}${d.file ? ` ${d.file}${d.line ? `:${d.line}` : ''}` : ''}: ${d.message}`).join(' | ') : 'no error was recorded';
123
+ const names = plan.components.map((c) => c.name).join(', ');
124
+ const bridged = {
125
+ code: 'bridged',
126
+ severity: 'warning',
127
+ message: `${names} is bridged, not converted: the React original runs unchanged inside a ${target} wrapper that mounts it with react-dom's createRoot. The ${target} project must install react and react-dom, and build the original file (imported as '${plan.specifier}') with React's JSX. ${BRIDGE_COSTS} The native conversion was refused because: ${why}`,
128
+ file: sourceRel,
129
+ target,
130
+ };
131
+ // the refusal's own errors stay, as errors: the native conversion still does not exist; its warnings and notes were
132
+ // about the refused output, which the bridge replaces, so they go with it
133
+ return { target, status: 'bridged', files, diagnostics: [...errors, bridged, ...notes], validated: validate };
134
+ }
135
+ /** The relative path of an entry in a project, as diagnostics name it. */
136
+ export function sourceRelOf(entry, project) {
137
+ return toPosix(relative(project.root, entry));
138
+ }