@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
package/dist/cli.js ADDED
@@ -0,0 +1,492 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from 'node:util';
3
+ import { readFileSync, writeFileSync } from 'node:fs';
4
+ import { join, resolve } from 'node:path';
5
+ import { EXPERIMENTAL, TARGETS, TIER_ONE } from './types.js';
6
+ import { addFromRegistry, analyze, batch, compile, gate, publish, repair, verify } from './index.js';
7
+ import { worst } from './pipeline.js';
8
+ import { readFolderList, runBatch, summarizeReport } from './batch.js';
9
+ import { checkSteps } from './verify/steps.js';
10
+ import { verifyLines } from './cli/format.js';
11
+ import { writeInside } from './utils/fs-safe.js';
12
+ import { cleanup } from './utils/cleanup.js';
13
+ import { errorMessage } from './utils/errors.js';
14
+ import { envSecrets, providerName, redact } from './ai/provider.js';
15
+ import { gateLines } from './gate.js';
16
+ import { runMcpServer } from './mcp/server.js';
17
+ const HELP = `antheo-morph: compile animated React UI components to Vue 3, Svelte 5 and Angular.
18
+
19
+ Targets:
20
+ vue, svelte Tier 1: the default; checked by their compilers, type-checked, scored in a browser
21
+ angular Ask for it with --target; checked by the Angular compiler in strict mode (needs the
22
+ optional @angular packages)
23
+ react-native Experimental: ask for it with --target; expect more of the code to need a hand
24
+
25
+ Usage:
26
+ antheo-morph analyze <file> [--json]
27
+ antheo-morph convert <file> [--target vue,svelte,angular,react-native] [--out dir] [--json] [--no-typecheck] [--bridge] [--fonts]
28
+ [--extract-ui]
29
+ [--ai --provider name [--model id] [--export Name] [--props json]
30
+ [--states ...] [--steps steps.json]]
31
+ antheo-morph batch <folder> [--include a,b] [--exclude a,b] [--corpus folders.json] [--out dir] [--report file.json]
32
+ [--summary file.json] [--target ...] [--no-typecheck] [--file-timeout ms] [--bridge] [--extract-ui]
33
+ [--fonts] [--ai --provider name [--model id]]
34
+ antheo-morph verify <file> [--export Name] [--props '{"label":"Hi"}'] [--states idle,hover,active]
35
+ [--steps steps.json | --auto-steps] [--unmount] [--fonts]
36
+ [--target vue,svelte,angular] [--report-dir dir] [--chrome path] [--json]
37
+ [--ai --provider name [--model id] [--out dir]]
38
+ antheo-morph gate <file> --candidate <file> [--candidate <file> ...] --target vue|svelte|angular [--export Name]
39
+ [--props json] [--states idle,hover,active] [--steps steps.json | --auto-steps] [--unmount]
40
+ [--chrome path] [--json]
41
+ antheo-morph mcp [--root dir]
42
+ antheo-morph add <url-or-file.json> [--target vue|svelte|angular] [--out dir] [--overwrite] [--no-typecheck] [--bridge]
43
+ [--ai --provider name [--model id]] [--json]
44
+ antheo-morph publish <folder> --out dir [--target vue,svelte,angular] [--base-url https://...] [--verify]
45
+ [--include a,b] [--exclude a,b] [--no-typecheck] [--file-timeout ms] [--chrome path] [--json]
46
+
47
+ Options:
48
+ --no-typecheck skip the strict type check of Vue and Svelte output (the real compilers still run)
49
+ --file-timeout ms batch: the longest one file may take, in ms (default 180000); a slower file is reported as compile-timeout
50
+ --steps file.json verify: a JSON array of scripted user actions (click, hover, focus, type, press, leave, wait), each
51
+ followed by a shot compared with React's; the script is checked before anything renders
52
+ --auto-steps verify: without --steps, discover a script on the React page (up to 12 clicks, key presses and
53
+ typed text on its switches, tabs, buttons, fields, sliders and what they reveal, each kept only
54
+ if it changed React's render or DOM state), then compare it in every target exactly as --steps
55
+ --bridge convert, batch: for a Vue, Svelte or Angular target the compiler refuses, emit a thin wrapper
56
+ that mounts the React original with react-dom (status bridged: not a conversion; the target
57
+ project needs react and react-dom, see the README's Bridge mode)
58
+ --extract-ui convert, batch: slice the component from its app first: what it reads from next/navigation, a
59
+ zustand store hook, a 'use server' action or an await while it renders becomes props the caller
60
+ must pass (warning ui-extracted, and <Component>.contract.ts with the exact boundary; never clean)
61
+ --fonts convert, batch, verify: carry next/font/google fonts in the output: asks Google Fonts
62
+ (https://fonts.googleapis.com, https://fonts.gstatic.com only) at conversion time for the CSS
63
+ and files Next.js would serve, logging every URL; the fonts' own licences apply to the copied
64
+ files. Without it nothing is fetched
65
+ --unmount verify: unmount each component and report what it leaves running that React does not leave
66
+ (animation frames, timers, listeners, observers); exit code 3 when a target leaks. gate always
67
+ runs this check; there the flag is accepted and changes nothing
68
+
69
+ --ai convert, verify, batch: assisted mode. It sends the component's source file and the generated file to
70
+ the chosen provider, only when a conversion has blocking diagnostics (or a verify score under
71
+ 99%), at most 3 times. A model-written file is kept only if it passes every gate: the target's
72
+ compiler, the strict type check, the browser harness against the React original (99% in every
73
+ state and step) and the unmount check. It then gets status assisted and a warning; otherwise the
74
+ compiler's output is kept unchanged and each attempt names the gate that rejected it.
75
+ --provider name --ai: anthropic, openai, ollama, gemini, openrouter (API keys from ANTHROPIC_API_KEY, OPENAI_API_KEY,
76
+ GEMINI_API_KEY, OPENROUTER_API_KEY; ollama needs none), or claude-cli, codex-cli, gemini-cli: your
77
+ own installed official CLI, run as a separate program for personal local use (it uses its own
78
+ sign-in, which morph never reads; each vendor's terms apply; use API keys in CI and on servers)
79
+
80
+ gate runs the four gates on candidate files you (or an agent) wrote for one web target: the target's
81
+ compiler (and no "not converted" mark), the strict type check, the browser harness against the
82
+ React original (99% in every state and step) and the unmount check (always on in gate). Each
83
+ --candidate replaces the output file with the same name. Exit 0: all four pass; 3: a gate fails;
84
+ 1: bad arguments, or a check could not run (no Chrome, for example)
85
+ add converts a shadcn-format registry item (an https URL or a local .json file, with the items it
86
+ depends on) into this project: the target from package.json unless --target; files go where the
87
+ tsconfig's @/* alias points (else this folder) unless --out; nothing is written if a file exists
88
+ with other contents (--overwrite replaces it) or a file stays unsupported (exit 2). It prints the
89
+ npm install line and never runs it. URLs: https only, public addresses only, 2 MB, 30 files,
90
+ 10 dependencies followed
91
+ --overwrite add: replace files that exist with other contents
92
+ publish runs batch over a folder of React components and writes, under --out, a shadcn-format registry
93
+ for each target (<out>/<target>/registry.json and one <name>.json item per converted component,
94
+ with meta.morph: status, validated, typechecked), SCORECARD.md and scorecard.json (clean /
95
+ partial / unsupported per target; an unsupported component gets no item). Exit 0 when items were
96
+ written, 2 when none was, 3 with --verify when a verified component is under 99% or leaks
97
+ --base-url url publish: the https address the registry will be served from; shared files become dependencies
98
+ at <url>/<target>/<name>.json (without it: ./<name>.json)
99
+ --verify publish: run verify (auto-steps and unmount) on every clean component, one at a time, and record
100
+ the lowest match and the leak status (needs Chrome)
101
+ mcp serves morph_convert, morph_verify and morph_gate over MCP on stdio (protocol 2026-07-28 and
102
+ 2025-11-25); every path must be inside --root (default: the working folder)
103
+
104
+ Everything runs offline, except --ai, which calls the provider you name, and --fonts, which calls Google Fonts.
105
+ `;
106
+ /** `--file-timeout`: whole milliseconds above 0, or an error that names the flag and what was given. */
107
+ function timeoutMs(value) {
108
+ if (!/^\d+$/.test(value) || Number(value) <= 0)
109
+ throw new Error(`--file-timeout takes a whole number of milliseconds above 0, not "${value}".`);
110
+ return Number(value);
111
+ }
112
+ /** `--steps`: reads the file and runs the check the API runs, so a bad script fails before any browser starts. */
113
+ function readSteps(file) {
114
+ let text;
115
+ try {
116
+ text = readFileSync(resolve(file), 'utf8');
117
+ }
118
+ catch (error) {
119
+ throw new Error(`--steps: cannot read ${file}: ${errorMessage(error)}`);
120
+ }
121
+ let parsed;
122
+ try {
123
+ parsed = JSON.parse(text);
124
+ }
125
+ catch (error) {
126
+ throw new Error(`--steps: ${file} is not valid JSON: ${errorMessage(error)}`);
127
+ }
128
+ if (!Array.isArray(parsed))
129
+ throw new Error(`--steps: ${file} must hold a JSON array of steps.`);
130
+ // the file's content is untrusted until checkSteps has passed; it checks every field it relies on
131
+ const steps = parsed;
132
+ try {
133
+ checkSteps(steps);
134
+ }
135
+ catch (error) {
136
+ throw new Error(`--steps: ${file}, ${errorMessage(error)}`);
137
+ }
138
+ return steps;
139
+ }
140
+ function list(value, allowed) {
141
+ if (!value)
142
+ return undefined;
143
+ const parts = value.split(',').map((s) => s.trim()).filter(Boolean);
144
+ for (const p of parts)
145
+ if (!allowed.includes(p))
146
+ throw new Error(`Unknown value "${p}" (expected ${allowed.join(', ')})`);
147
+ return parts;
148
+ }
149
+ /** Assisted mode: one line per attempt, naming the gate that rejected it. */
150
+ function attemptLines(r) {
151
+ const why = (stop) => (stop === 'provider' ? 'the provider call failed' : stop === 'reply' ? 'the reply held no code' : `rejected by the ${stop} gate`);
152
+ return r.attempts.map((a) => ` attempt ${a.iteration}: ${a.accepted ? 'accepted, passed every gate' : why(a.failedGate)}${a.score === null ? '' : ` (lowest match ${(a.score * 100).toFixed(2)}%)`}: ${a.reason}`);
153
+ }
154
+ /** `add`: the result in lines (control characters in registry text are already removed by the parser). */
155
+ function addLines(r) {
156
+ const lines = [`${r.item} -> ${r.target}: ${r.status}${r.items.length > 1 ? ` (with ${r.items.slice(1).map((i) => i.name).join(', ')})` : ''}`];
157
+ for (const e of r.entries) {
158
+ lines.push(` ${e.file}: ${e.status}`);
159
+ for (const d of e.diagnostics.filter((x) => x.severity !== 'info'))
160
+ lines.push(` [${d.severity}] ${d.code}${d.file ? ` ${d.file}${d.line ? `:${d.line}` : ''}` : ''}: ${d.message}`);
161
+ }
162
+ for (const s of r.skipped)
163
+ lines.push(` not followed: ${s}`);
164
+ for (const n of r.notes)
165
+ lines.push(` note: ${n}`);
166
+ if (r.refused)
167
+ lines.push(` ${r.refused}`);
168
+ else {
169
+ lines.push(` wrote ${r.written.length} file${r.written.length === 1 ? '' : 's'} under ${r.out}${r.unchanged.length ? ` (${r.unchanged.length} unchanged)` : ''}`);
170
+ for (const w of r.written)
171
+ lines.push(` ${w}`);
172
+ }
173
+ lines.push(r.installCommand ? ` install (not run): ${r.installCommand}` : ' install: nothing new');
174
+ if (r.docs)
175
+ lines.push(` the item says: ${r.docs}`);
176
+ return lines;
177
+ }
178
+ /** `publish`: the scorecard's totals, what has no item, and where everything went. */
179
+ function publishLines(r) {
180
+ const card = r.scorecard;
181
+ const lines = [`${card.components.length} component file${card.components.length === 1 ? '' : 's'} from ${card.folder}, published under ${r.out}`];
182
+ for (const t of card.targets) {
183
+ const row = card.totals[t];
184
+ if (!row)
185
+ continue;
186
+ const shared = r.registries.find((x) => x.target === t)?.shared.length ?? 0;
187
+ lines.push(` ${t.padEnd(8)} clean ${row.counts.clean} partial ${row.counts.partial} unsupported ${row.counts.unsupported} items ${row.published}${shared ? ` (+${shared} shared)` : ''}${row.verified ? ` verified ${row.verified.passed}/${row.verified.run}` : ''}`);
188
+ }
189
+ for (const c of card.components) {
190
+ for (const t of card.targets) {
191
+ const tc = c.targets[t];
192
+ if (tc && !tc.published)
193
+ lines.push(` no item: ${c.file} on ${t}: ${tc.reason ?? tc.status}`);
194
+ const v = tc?.verify;
195
+ if (v)
196
+ lines.push(` verify ${c.file} on ${t}: ${v.error ?? `lowest match ${(v.lowestMatch * 100).toFixed(2)}%, ${v.leakFree === null ? 'leaks not measured' : v.leakFree ? 'no leaks' : 'leaks'}`}`);
197
+ }
198
+ }
199
+ for (const n of card.notes)
200
+ lines.push(` note: ${n}`);
201
+ lines.push(` scorecard: ${join(r.out, 'SCORECARD.md')} and scorecard.json`);
202
+ return lines;
203
+ }
204
+ function out(json, data, text) {
205
+ process.stdout.write(json ? `${JSON.stringify(data, (k, v) => (k === 'png' ? undefined : v), 2)}\n` : `${text}\n`);
206
+ }
207
+ async function main(argv) {
208
+ const { positionals, values } = parseArgs({
209
+ args: argv,
210
+ allowPositionals: true,
211
+ options: {
212
+ target: { type: 'string' },
213
+ out: { type: 'string' },
214
+ json: { type: 'boolean', default: false },
215
+ include: { type: 'string' },
216
+ exclude: { type: 'string' },
217
+ corpus: { type: 'string' },
218
+ report: { type: 'string' },
219
+ summary: { type: 'string' },
220
+ export: { type: 'string' },
221
+ props: { type: 'string' },
222
+ states: { type: 'string' },
223
+ 'report-dir': { type: 'string' },
224
+ steps: { type: 'string' },
225
+ unmount: { type: 'boolean', default: false },
226
+ 'auto-steps': { type: 'boolean', default: false },
227
+ bridge: { type: 'boolean', default: false },
228
+ // M6
229
+ 'extract-ui': { type: 'boolean', default: false },
230
+ fonts: { type: 'boolean', default: false },
231
+ 'no-typecheck': { type: 'boolean', default: false },
232
+ 'file-timeout': { type: 'string' },
233
+ chrome: { type: 'string' },
234
+ ai: { type: 'boolean', default: false },
235
+ provider: { type: 'string' },
236
+ model: { type: 'string' },
237
+ // gate's candidates, mcp's root
238
+ candidate: { type: 'string', multiple: true },
239
+ overwrite: { type: 'boolean', default: false },
240
+ // publish
241
+ 'base-url': { type: 'string' },
242
+ verify: { type: 'boolean', default: false },
243
+ root: { type: 'string' },
244
+ help: { type: 'boolean', short: 'h', default: false },
245
+ },
246
+ });
247
+ const [command, input] = positionals;
248
+ if (values.help || !command) {
249
+ process.stdout.write(HELP);
250
+ return command || values.help ? 0 : 1;
251
+ }
252
+ // mcp takes no file; its stdout is the protocol's from here on
253
+ if (command === 'mcp') {
254
+ for (const [flag, set] of Object.entries(values))
255
+ if (set !== undefined && set !== false && flag !== 'root')
256
+ throw new Error(`--${flag} does not apply to mcp.`);
257
+ if (input)
258
+ throw new Error('mcp takes no file: pass --root for the folder it serves.');
259
+ await runMcpServer({ ...(values.root ? { root: values.root } : {}) });
260
+ return 0;
261
+ }
262
+ if (values.root !== undefined)
263
+ throw new Error(`--root applies to mcp, not ${command}.`);
264
+ if (values.candidate !== undefined && command !== 'gate')
265
+ throw new Error(`--candidate applies to gate, not ${command}.`);
266
+ if (!input)
267
+ throw new Error(`${command} needs a file or folder.`);
268
+ const json = values.json ?? false;
269
+ // checked up front, so a typo fails before any work (never falls through to another provider)
270
+ const provider = providerName(values.provider ?? 'anthropic');
271
+ const only = (flag, set, ...commands) => {
272
+ if (set && !commands.includes(command))
273
+ throw new Error(`${flag} applies to ${commands.join(' and ')}, not ${command}.`);
274
+ };
275
+ // convert takes steps only for assisted mode's browser gate
276
+ // gate takes --steps, --auto-steps and --unmount as verify does
277
+ only('--steps', values.steps !== undefined && !(values.ai && command === 'convert') && command !== 'gate', 'verify');
278
+ only('--unmount', values.unmount === true && command !== 'gate', 'verify');
279
+ only('--auto-steps', values['auto-steps'] === true && command !== 'gate', 'verify');
280
+ if (values['auto-steps'] && values.steps !== undefined)
281
+ throw new Error('--auto-steps discovers a script and --steps gives one: use one of them.');
282
+ // add takes --bridge, --no-typecheck and --ai too (the messages for the other commands are unchanged)
283
+ only('--bridge', values.bridge === true && command !== 'add', 'convert', 'batch');
284
+ only('--overwrite', values.overwrite === true, 'add');
285
+ // M6
286
+ only('--extract-ui', values['extract-ui'] === true, 'convert', 'batch');
287
+ only('--no-typecheck', values['no-typecheck'] === true && command !== 'add' && command !== 'publish', 'convert', 'batch');
288
+ // publish takes --no-typecheck and --file-timeout too (as add does, so the messages for the other commands are unchanged)
289
+ only('--file-timeout', values['file-timeout'] !== undefined && command !== 'publish', 'batch');
290
+ only('--base-url', values['base-url'] !== undefined, 'publish');
291
+ only('--verify', values.verify === true, 'publish');
292
+ only('--fonts', values.fonts === true, 'convert', 'batch', 'verify');
293
+ only('--ai', values.ai === true && command !== 'add', 'convert', 'verify', 'batch');
294
+ const fileTimeoutMs = values['file-timeout'] === undefined ? undefined : timeoutMs(values['file-timeout']);
295
+ // M6: --extract-ui rides with the other compile options
296
+ const typecheck = { ...(values['no-typecheck'] ? { typecheck: false } : {}), ...(values.bridge ? { bridge: true } : {}), ...(values.fonts ? { fonts: true } : {}), ...(values['extract-ui'] ? { extractUi: true } : {}) };
297
+ const steps = values.steps === undefined ? undefined : readSteps(values.steps);
298
+ // how to render: shared by verify and by assisted mode's browser gate (which writes no report)
299
+ const states = list(values.states, ['idle', 'hover', 'active']);
300
+ const render = {
301
+ ...(values.export ? { exportName: values.export } : {}),
302
+ ...(values.props ? { props: JSON.parse(values.props) } : {}),
303
+ ...(states ? { states } : {}),
304
+ ...(values.chrome ? { executablePath: values.chrome } : {}),
305
+ };
306
+ if (command === 'analyze') {
307
+ const result = await analyze(input);
308
+ const errors = result.diagnostics.filter((d) => d.severity === 'error').length;
309
+ out(json, result, `${result.file}\n components: ${result.components.map((c) => c.name).join(', ') || '(none)'}\n hooks: ${result.hooks.join(', ') || '(none)'}\n local files: ${result.graph.length}\n diagnostics: ${result.diagnostics.length} (${errors} error${errors === 1 ? '' : 's'})`);
310
+ return 0;
311
+ }
312
+ if (command === 'convert') {
313
+ const targets = list(values.target, TARGETS) ?? [...TIER_ONE];
314
+ const result = await compile(input, { targets, ...typecheck });
315
+ const shown = [];
316
+ const notes = [];
317
+ for (const tr of result.targets) {
318
+ let final = tr;
319
+ const note = [];
320
+ // assisted mode (X6): a model-written result replaces the compiler's only when it passed every gate
321
+ if (values.ai && tr.status !== 'clean') {
322
+ const r = await repair(input, { target: tr.target, provider, ...(values.model ? { model: values.model } : {}), ...typecheck, verifyOptions: render });
323
+ if (r.accepted) {
324
+ final = r.result;
325
+ // the attempts rejected before the accepted one, each with the gate that stopped it
326
+ if (r.attempts.length > 1)
327
+ note.push(' assisted mode attempts:', ...attemptLines(r));
328
+ }
329
+ else if (r.skipped)
330
+ note.push(` assisted mode: ${r.skipped}`);
331
+ else if (r.triggered)
332
+ note.push(` assisted mode: no attempt passed every gate; the compiler's output is kept unchanged`, ...attemptLines(r));
333
+ }
334
+ shown.push(final);
335
+ notes.push(note);
336
+ }
337
+ const status = worst(shown.map((t) => t.status));
338
+ const lines = [`${result.file}: ${status}`];
339
+ for (const [i, tr] of shown.entries()) {
340
+ lines.push(` ${tr.target}${EXPERIMENTAL.includes(tr.target) ? ' (experimental)' : ''}: ${tr.status}, ${tr.validated ? 'passes' : 'FAILS'} its compiler, ${tr.files.length} files${tr.fidelity ? `, fidelity ${tr.fidelity.score}/100` : ''}`);
341
+ for (const d of tr.diagnostics.filter((x) => x.severity !== 'info'))
342
+ lines.push(` [${d.severity}] ${d.code}${d.file ? ` ${d.file}${d.line ? `:${d.line}` : ''}` : ''}: ${d.message}`);
343
+ lines.push(...(notes[i] ?? []));
344
+ if (values.out)
345
+ for (const f of tr.files)
346
+ writeInside(join(resolve(values.out), tr.target), f.path, f.contents);
347
+ }
348
+ if (values.out)
349
+ lines.push(`written to ${resolve(values.out)}`);
350
+ out(json, { ...result, status, targets: shown }, lines.join('\n'));
351
+ return status === 'unsupported' ? 2 : 0;
352
+ }
353
+ if (command === 'batch') {
354
+ // --corpus: a JSON file listing the sub-folders to compile, as --include takes them
355
+ const include = values.corpus !== undefined ? readFolderList(values.corpus) : values.include?.split(',').map((s) => s.trim());
356
+ const exclude = values.exclude?.split(',').map((s) => s.trim());
357
+ const targets = list(values.target, TARGETS);
358
+ // assisted mode (X6): each refused web target is offered to the model, kept only if it passes every gate
359
+ const assist = values.ai ? { assist: { provider, ...(values.model ? { model: values.model } : {}), verifyOptions: render } } : {};
360
+ const options = { ...(include ? { include } : {}), ...(exclude ? { exclude } : {}), ...(targets ? { targets } : {}), ...(values.out ? { outDir: values.out } : {}), ...typecheck, ...(fileTimeoutMs ? { fileTimeoutMs } : {}), ...assist };
361
+ const report = json ? await batch(input, options) : await runBatch(input, options, (done, total, file) => process.stderr.write(`\r${done}/${total} ${file.slice(-60).padEnd(60)}`));
362
+ if (!json)
363
+ process.stderr.write('\n');
364
+ if (values.report)
365
+ writeFileSync(resolve(values.report), `${JSON.stringify(report, null, 2)}\n`);
366
+ // small enough for git: one line per file, so a re-run shows as a readable diff
367
+ if (values.summary) {
368
+ const { entries, ...head } = summarizeReport(report);
369
+ const lines = entries.map((e) => ` ${JSON.stringify(e)}`).join(',\n');
370
+ writeFileSync(resolve(values.summary), `${JSON.stringify(head, null, 2).replace(/\n}$/, ',')}\n "entries": [\n${lines}\n ]\n}\n`);
371
+ }
372
+ const t = report.totals;
373
+ const row = (name, c) => ` ${name.padEnd(13)} clean ${String(c.clean).padStart(4)} partial ${String(c.partial).padStart(4)} unsupported ${String(c.unsupported).padStart(4)}${c.bridged === undefined ? '' : ` bridged ${String(c.bridged).padStart(4)}`}${c.assisted === undefined ? '' : ` assisted ${String(c.assisted).padStart(4)}`}`;
374
+ const text = [
375
+ `${t.files} files`,
376
+ ...TARGETS.map((target) => row(target, t.byTarget[target])),
377
+ row('all targets', t.allTargets),
378
+ ` output failing its compiler: ${TARGETS.map((target) => `${target} ${t.validationFailures[target]}`).join(', ')}`,
379
+ 'top causes:',
380
+ ...report.topCauses.slice(0, 12).map((c) => ` ${String(c.files).padStart(4)} files [${c.severity}] ${c.code}`),
381
+ ].join('\n');
382
+ out(json, report, text);
383
+ return 0;
384
+ }
385
+ if (command === 'verify') {
386
+ const targets = list(values.target, ['vue', 'svelte', 'angular']);
387
+ const checks = { ...(steps ? { steps } : {}), ...(values['auto-steps'] ? { autoSteps: true } : {}), ...(values.unmount ? { unmount: true } : {}), ...(values.fonts ? { fonts: true } : {}) };
388
+ const result = await verify(input, { ...render, ...checks, ...(targets ? { targets } : {}), ...(values['report-dir'] ? { reportDir: values['report-dir'] } : {}) });
389
+ const lines = verifyLines(result);
390
+ if (result.discoveredSteps)
391
+ lines.splice(1, 0, ` auto-steps: ${result.discoveredSteps.length} step(s) discovered on the React page${result.discoveredSteps.length ? `: ${result.discoveredSteps.map((s) => s.name).join(', ')}` : ''}`);
392
+ // assisted mode replays the very script that was compared, discovered or given
393
+ const script = steps ?? result.discoveredSteps;
394
+ let lowest = result.minMatch;
395
+ const repairs = [];
396
+ if (values.ai && result.minMatch < 0.99) {
397
+ // assisted mode (X6) for each target under 99% on its own; the run passes only if every target ends at 99% or more
398
+ lowest = 1;
399
+ for (const target of new Set(result.comparisons.map((c) => c.target))) {
400
+ const own = Math.min(...result.comparisons.filter((c) => c.target === target).map((c) => c.match));
401
+ if (own >= 0.99) {
402
+ lowest = Math.min(lowest, own);
403
+ continue;
404
+ }
405
+ const r = await repair(input, { target, provider, ...(values.model ? { model: values.model } : {}), verify: true, verifyOptions: { ...render, ...(script?.length ? { steps: script } : {}) } });
406
+ repairs.push(r);
407
+ lowest = Math.min(lowest, r.accepted ? (r.finalScore ?? 0) : own);
408
+ lines.push(` ${target} assisted mode: ${r.accepted ? `a model-written result passed every gate (lowest match ${((r.finalScore ?? 0) * 100).toFixed(2)}%); status assisted` : r.skipped ? r.skipped : r.triggered ? "no attempt passed every gate; the compiler's output is kept unchanged" : 'not started (the output already passes the browser gate)'}`);
409
+ lines.push(...attemptLines(r));
410
+ if (r.accepted && values.out)
411
+ for (const f of r.files)
412
+ writeInside(join(resolve(values.out), target), f.path, f.contents);
413
+ }
414
+ if (values.out && repairs.some((r) => r.accepted))
415
+ lines.push(` assisted files written to ${resolve(values.out)}`);
416
+ }
417
+ out(json, repairs.length ? { ...result, repairs } : result, lines.join('\n'));
418
+ // a target that leaves running what React does not fails the run, like a low match does
419
+ const leaks = (result.leaks ?? []).some((l) => l.framework !== 'react' && !l.clean) || result.diagnostics.some((d) => d.code === 'unmount-failed');
420
+ return lowest >= 0.99 && !leaks ? 0 : 3;
421
+ }
422
+ // the four gates on a candidate; exit 0 when all pass, 3 when one fails
423
+ if (command === 'gate') {
424
+ const targets = list(values.target, ['vue', 'svelte', 'angular']);
425
+ const target = targets?.[0];
426
+ if (!target || targets.length !== 1)
427
+ throw new Error('gate needs exactly one --target: vue, svelte or angular.');
428
+ const candidates = values.candidate ?? [];
429
+ if (!candidates.length)
430
+ throw new Error('gate needs --candidate <file> (once per file).');
431
+ const r = await gate(input, candidates, { target, ...render, ...(steps ? { steps } : {}), ...(values['auto-steps'] ? { autoSteps: true } : {}) });
432
+ out(json, r, gateLines(r).join('\n'));
433
+ return r.passed ? 0 : 3;
434
+ }
435
+ // a shadcn-format registry item into this project; exit 0 when written, 2 when a file stays unsupported, 1 otherwise
436
+ if (command === 'add') {
437
+ const targets = list(values.target, ['vue', 'svelte', 'angular']);
438
+ if (targets && targets.length !== 1)
439
+ throw new Error('add takes one --target: vue, svelte or angular.');
440
+ const r = await addFromRegistry(input, {
441
+ ...(targets?.[0] ? { target: targets[0] } : {}),
442
+ ...(values.out ? { out: values.out } : {}),
443
+ ...(values.overwrite ? { overwrite: true } : {}),
444
+ ...(values.bridge ? { bridge: true } : {}),
445
+ ...(values['no-typecheck'] ? { typecheck: false } : {}),
446
+ ...(values.ai ? { ai: { provider, ...(values.model ? { model: values.model } : {}) } } : {}),
447
+ });
448
+ out(json, r, addLines(r).join('\n'));
449
+ return r.status === 'unsupported' ? 2 : r.refused ? 1 : 0;
450
+ }
451
+ // a folder of React components as registries for Vue, Svelte and Angular; exit 0 when items were written, 2 when none was,
452
+ // 3 when --verify finds a component under 99% or leaking
453
+ if (command === 'publish') {
454
+ for (const flag of ['corpus', 'report', 'summary', 'export', 'props', 'states', 'report-dir', 'provider', 'model']) {
455
+ if (values[flag] !== undefined)
456
+ throw new Error(`--${flag} does not apply to publish.`);
457
+ }
458
+ if (!values.out)
459
+ throw new Error('publish needs --out <dir>: where the registries and the scorecard are written.');
460
+ const targets = list(values.target, ['vue', 'svelte', 'angular']);
461
+ const include = values.include?.split(',').map((s) => s.trim());
462
+ const exclude = values.exclude?.split(',').map((s) => s.trim());
463
+ const r = await publish(input, {
464
+ out: values.out,
465
+ ...(targets ? { targets } : {}),
466
+ ...(values['base-url'] ? { baseUrl: values['base-url'] } : {}),
467
+ ...(values.verify ? { verify: true } : {}),
468
+ ...(include ? { include } : {}),
469
+ ...(exclude ? { exclude } : {}),
470
+ ...(values['no-typecheck'] ? { typecheck: false } : {}),
471
+ ...(fileTimeoutMs ? { fileTimeoutMs } : {}),
472
+ ...(values.chrome ? { chrome: values.chrome } : {}),
473
+ ...(json ? {} : { onProgress: (m) => process.stderr.write(`\r${m.slice(0, 78).padEnd(78)}`) }),
474
+ });
475
+ if (!json)
476
+ process.stderr.write(`\r${''.padEnd(78)}\r`);
477
+ out(json, r, publishLines(r).join('\n'));
478
+ const published = r.registries.reduce((n, reg) => n + reg.items.length, 0);
479
+ const failed = r.scorecard.components.some((c) => Object.values(c.targets).some((t) => t.verify && (t.verify.error || t.verify.lowestMatch < 0.99 || t.verify.leakFree === false || t.verify.pageErrors > 0)));
480
+ return !published ? 2 : failed ? 3 : 0;
481
+ }
482
+ throw new Error(`Unknown command "${command}".\n\n${HELP}`);
483
+ }
484
+ main(process.argv.slice(2))
485
+ .then((code) => {
486
+ process.exitCode = code;
487
+ })
488
+ .catch(async (error) => {
489
+ process.stderr.write(`antheo-morph: ${redact(errorMessage(error), envSecrets())}\n`);
490
+ await cleanup.runAll().catch(() => undefined);
491
+ process.exitCode = 1;
492
+ });
@@ -0,0 +1,34 @@
1
+ import * as t from '@babel/types';
2
+ import type { Diagnostic, EmittedFile } from '../types.js';
3
+ import type { FontRequest } from './local.js';
4
+ /** The CSS Next.js writes for a font (next/font's loader and its postcss plugin), with our class and family names. */
5
+ export declare function fontCss(request: FontRequest, names: {
6
+ family: string;
7
+ className: string;
8
+ variableClass: string;
9
+ }): {
10
+ css: string;
11
+ fontFamily: string;
12
+ };
13
+ /** The font object Next.js hands the component: `{ className, style, variable? }`. */
14
+ export declare function fontObject(request: FontRequest, names: {
15
+ className: string;
16
+ variableClass: string;
17
+ }, fontFamily: string): Record<string, unknown>;
18
+ /** A short name for a font request: its files' bytes and its options. */
19
+ export declare function fontHash(request: FontRequest): string;
20
+ /** The CSS and the font object of one next/font call, under names made from its hash. */
21
+ export declare function fontParts(request: FontRequest, localName: string, hash: string): {
22
+ css: string;
23
+ object: Record<string, unknown>;
24
+ };
25
+ /**
26
+ * Carries one next/font call: registers its module for the conversion and returns the import to add and the name the
27
+ * call becomes. `fromPath` is the output path of the file that makes the call.
28
+ */
29
+ export declare function carryFont(diagnostics: Diagnostic[], request: FontRequest, localName: string, fromPath: string, importName: string): {
30
+ importDecl: t.ImportDeclaration;
31
+ value: t.Identifier;
32
+ };
33
+ /** The font modules the conversion's files asked for, once each. */
34
+ export declare function carriedFontFiles(diagnostics: Diagnostic[]): EmittedFile[];
@@ -0,0 +1,113 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { posix } from 'node:path';
3
+ import * as t from '@babel/types';
4
+ /**
5
+ * The font files a conversion carries, one generated module per next/font call, kept per conversion (keyed by its
6
+ * diagnostics list, as the other once-per-conversion helper files are) until the pipeline writes them.
7
+ */
8
+ const carried = new WeakMap();
9
+ /** A family name as CSS quotes it. */
10
+ const quote = (family) => `'${family}'`;
11
+ /** The CSS Next.js writes for a font (next/font's loader and its postcss plugin), with our class and family names. */
12
+ export function fontCss(request, names) {
13
+ const rules = [];
14
+ const custom = request.declarations.some(([prop]) => prop === 'font-family');
15
+ // Google's rules as they came (the fonts option), each face's family renamed as Next.js's postcss plugin renames it
16
+ if (request.faceCss)
17
+ rules.push(request.faceCss.replace(/font-family: [^;]*;/g, `font-family: ${quote(names.family)};`));
18
+ for (const file of request.faceCss ? [] : request.files) {
19
+ const props = [...request.declarations];
20
+ if (!custom)
21
+ props.push(['font-family', quote(names.family)]);
22
+ props.push(['src', `url(data:${file.mime};base64,${file.bytes.toString('base64')}) format('${file.format}')`], ['font-display', request.display]);
23
+ if (file.weight)
24
+ props.push(['font-weight', file.weight]);
25
+ if (file.style)
26
+ props.push(['font-style', file.style]);
27
+ rules.push(`@font-face {\n${props.map(([p, v]) => ` ${p}: ${v};`).join('\n')}\n}`);
28
+ }
29
+ // the family of the first face (its own name, or the one its declarations give)
30
+ const family = custom ? (request.declarations.find(([p]) => p === 'font-family')?.[1] ?? names.family).replace(/['"]/g, '') : names.family;
31
+ const fallbackFamily = request.adjust ? quote(`${family} Fallback`) : null;
32
+ if (request.adjust && fallbackFamily) {
33
+ const a = request.adjust;
34
+ rules.push(`@font-face {\n font-family: ${fallbackFamily};\n src: local("${a.fallbackFont}");\n ascent-override: ${a.ascentOverride};\n descent-override: ${a.descentOverride};\n line-gap-override: ${a.lineGapOverride};\n size-adjust: ${a.sizeAdjust};\n}`);
35
+ }
36
+ const fontFamily = [quote(family), ...(fallbackFamily ? [fallbackFamily] : []), ...request.fallback].join(', ');
37
+ const isRange = (v) => v.trim().includes(' ');
38
+ const classProps = [`font-family: ${fontFamily};`, ...(request.weight && !isRange(request.weight) ? [`font-weight: ${request.weight};`] : []), ...(request.style && !isRange(request.style) ? [`font-style: ${request.style};`] : [])];
39
+ rules.push(`.${names.className} {\n ${classProps.join('\n ')}\n}`);
40
+ if (request.variable)
41
+ rules.push(`.${names.variableClass} {\n ${request.variable}: ${fontFamily};\n}`);
42
+ return { css: `${rules.join('\n')}\n`, fontFamily };
43
+ }
44
+ /** The font object Next.js hands the component: `{ className, style, variable? }`. */
45
+ export function fontObject(request, names, fontFamily) {
46
+ const weight = request.weight !== undefined && !Number.isNaN(Number(request.weight)) ? Number(request.weight) : undefined;
47
+ const style = request.style && !request.style.trim().includes(' ') ? request.style : undefined;
48
+ return {
49
+ className: names.className,
50
+ style: { fontFamily, ...(weight !== undefined ? { fontWeight: weight } : {}), ...(style ? { fontStyle: style } : {}) },
51
+ ...(request.variable ? { variable: names.variableClass } : {}),
52
+ };
53
+ }
54
+ /** A short name for a font request: its files' bytes and its options. */
55
+ export function fontHash(request) {
56
+ const digest = createHash('sha256');
57
+ for (const f of request.files)
58
+ digest.update(f.bytes);
59
+ digest.update(JSON.stringify({ ...request, files: request.files.map((f) => [f.written, f.weight, f.style]) }));
60
+ return digest.digest('hex').slice(0, 6);
61
+ }
62
+ /** The CSS and the font object of one next/font call, under names made from its hash. */
63
+ export function fontParts(request, localName, hash) {
64
+ const names = { family: `__${localName}_${hash}`, className: `__className_${hash}`, variableClass: `__variable_${hash}` };
65
+ const { css, fontFamily } = fontCss(request, names);
66
+ return { css, object: fontObject(request, names, fontFamily) };
67
+ }
68
+ /**
69
+ * The generated module for one next/font call: its CSS, added to the document once (no document on a server: the
70
+ * class then has no rule until the module runs in the browser), and the font object as its default export.
71
+ */
72
+ function moduleText(request, localName, hash) {
73
+ const { css, object } = fontParts(request, localName, hash);
74
+ return [
75
+ `// antheo-morph: the font \`${localName}\` loads in React, carried with the output (from ${request.source}).`,
76
+ `// The same file Next.js serves, as a data URL, with the @font-face rules${request.adjust ? ', the adjusted fallback face' : ''} and the class Next.js`,
77
+ "// writes. The font's own licence applies to the file.",
78
+ `const css = ${JSON.stringify(css)};`,
79
+ '',
80
+ `if (typeof document !== 'undefined' && !document.querySelector('style[data-font="${hash}"]')) {`,
81
+ " const style = document.createElement('style');",
82
+ ` style.dataset.font = '${hash}';`,
83
+ ' style.textContent = css;',
84
+ ' document.head.append(style);',
85
+ '}',
86
+ '',
87
+ `export default ${JSON.stringify(object, null, 2).replace(/"([A-Za-z]+)":/g, '$1:')};`,
88
+ '',
89
+ ].join('\n');
90
+ }
91
+ /**
92
+ * Carries one next/font call: registers its module for the conversion and returns the import to add and the name the
93
+ * call becomes. `fromPath` is the output path of the file that makes the call.
94
+ */
95
+ export function carryFont(diagnostics, request, localName, fromPath, importName) {
96
+ const hash = fontHash(request);
97
+ const dir = posix.dirname(fromPath);
98
+ const path = posix.join(dir === '.' ? '' : dir, 'next-font', `${localName}-${hash}.ts`);
99
+ let files = carried.get(diagnostics);
100
+ if (!files)
101
+ carried.set(diagnostics, (files = new Map()));
102
+ if (!files.has(path))
103
+ files.set(path, { path, contents: moduleText(request, localName, hash), kind: 'module' });
104
+ const value = t.identifier(importName);
105
+ let rel = posix.relative(dir, path.replace(/\.ts$/, ''));
106
+ if (!rel.startsWith('.'))
107
+ rel = `./${rel}`;
108
+ return { importDecl: t.importDeclaration([t.importDefaultSpecifier(value)], t.stringLiteral(rel)), value };
109
+ }
110
+ /** The font modules the conversion's files asked for, once each. */
111
+ export function carriedFontFiles(diagnostics) {
112
+ return [...(carried.get(diagnostics)?.values() ?? [])];
113
+ }