@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,439 @@
1
+ import { basename, join, resolve } from 'node:path';
2
+ import { findProjectRoot } from '../analyzer/deps.js';
3
+ import { collectFiles, runBatch } from '../batch.js';
4
+ import { compileFile } from '../pipeline.js';
5
+ import { runVerify } from '../verify/runner.js';
6
+ import { MorphError, errorMessage } from '../utils/errors.js';
7
+ import { toPosix, writeInside } from '../utils/fs-safe.js';
8
+ import { FRAMEWORK, importedPackages } from './add.js';
9
+ import { MAX_REGISTRY_BYTES } from './fetch.js';
10
+ import { parseRegistryItem } from './item.js';
11
+ /**
12
+ * `antheo-morph publish <folder> --out <dir>` (v0.3 Milestone C): a folder of React components becomes one shadcn-format
13
+ * registry per web target, `<out>/<target>/registry.json` (the index) and one `<name>.json` item per converted
14
+ * component, plus `<out>/SCORECARD.md` and `<out>/scorecard.json`.
15
+ *
16
+ * The folder goes through the existing `batch` (so the statuses are exactly batch's: a worker thread per file, a
17
+ * timeout, validation by the targets' real compilers, the strict type check). `batch` returns statuses, not files, so
18
+ * each file that came out clean or partial is compiled once more, in this process, for the files that go into its
19
+ * item; a file whose second compile does not give the status `batch` gave is not published. Every item is parsed back
20
+ * through `parseRegistryItem`, the parser `antheo-morph add` reads items with, before it is written: an item that
21
+ * parser would refuse (a file over its size limit, a path it does not accept) is not written, and says why in the
22
+ * scorecard. An unsupported component gets no item. Every write goes through `writeInside` under `--out`.
23
+ */
24
+ /** The targets a registry is published for, in the order they are written. */
25
+ export const PUBLISH_TARGETS = ['vue', 'svelte', 'angular'];
26
+ const ITEM_SCHEMA = 'https://ui.shadcn.com/schema/registry-item.json';
27
+ const REGISTRY_SCHEMA = 'https://ui.shadcn.com/schema/registry.json';
28
+ /** A verified component passes at this match in every state and step, as the gate holds a model's file to. */
29
+ const PASS_MATCH = 0.99;
30
+ /** `PressButton` to `press-button`; a path's slashes and dots become dashes. */
31
+ export function kebab(raw) {
32
+ return raw
33
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
34
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
35
+ .replace(/[^A-Za-z0-9]+/g, '-')
36
+ .replace(/^-+|-+$/g, '')
37
+ .toLowerCase()
38
+ .slice(0, 100)
39
+ .replace(/-+$/, '');
40
+ }
41
+ const withoutExtension = (p) => p.replace(/\.[^./]+$/, '');
42
+ const pascal = (raw) => raw.replace(/(^|[^A-Za-z0-9]+)([A-Za-z0-9])/g, (_all, _sep, c) => c.toUpperCase());
43
+ /** One item name per source file: its file name, kebab-cased; a name two files share is taken from the whole path, and a name still taken gets a number. */
44
+ export function itemNames(files) {
45
+ const nameOf = (f) => kebab(basename(withoutExtension(f))) || 'component';
46
+ const count = new Map();
47
+ for (const f of files)
48
+ count.set(nameOf(f), (count.get(nameOf(f)) ?? 0) + 1);
49
+ const taken = new Set();
50
+ const out = new Map();
51
+ for (const f of files) {
52
+ const n = nameOf(f);
53
+ let name = (count.get(n) ?? 0) > 1 ? kebab(withoutExtension(f)) || n : n;
54
+ for (let i = 2; taken.has(name); i++)
55
+ name = `${n}-${i}`;
56
+ taken.add(name);
57
+ out.set(f, name);
58
+ }
59
+ return out;
60
+ }
61
+ function cleanBaseUrl(raw) {
62
+ if (raw === undefined)
63
+ return null;
64
+ let url;
65
+ try {
66
+ url = new URL(raw);
67
+ }
68
+ catch {
69
+ throw new MorphError('publish-base-url', `--base-url must be an https URL (for example https://example.com/r); "${raw.slice(0, 80)}" is not a URL.`);
70
+ }
71
+ if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash) {
72
+ throw new MorphError('publish-base-url', '--base-url must be a plain https URL, with no user name, password, query or fragment.');
73
+ }
74
+ return url.href.replace(/\/+$/, '');
75
+ }
76
+ const FILE_TYPE = {
77
+ component: 'registry:component',
78
+ module: 'registry:lib',
79
+ core: 'registry:lib',
80
+ style: 'registry:file',
81
+ report: 'registry:file',
82
+ };
83
+ const jsonText = (value) => `${JSON.stringify(value, null, 2)}\n`;
84
+ const percent = (m) => `${(Math.floor(m * 10000) / 100).toFixed(2)}%`;
85
+ const cellText = (s) => s.replace(/[\r\n]+/g, ' ').replace(/\|/g, '\\|');
86
+ function buildItem(input) {
87
+ const dependencies = [...importedPackages(input.files)].filter((p) => !FRAMEWORK[input.target](p)).sort();
88
+ // the path keeps morph's layout (`components/Button.vue` beside `motion-action.ts`), so the relative imports between
89
+ // the files hold; the target is the path from the project root
90
+ const listed = input.files.map((f) => ({ path: f.path, type: FILE_TYPE[f.kind], target: f.path }));
91
+ const head = {
92
+ name: input.name,
93
+ type: input.type,
94
+ title: input.title,
95
+ description: input.description,
96
+ dependencies,
97
+ ...(input.registryDependencies.length ? { registryDependencies: input.registryDependencies } : {}),
98
+ };
99
+ const meta = { morph: input.meta };
100
+ const text = jsonText({ $schema: ITEM_SCHEMA, ...head, files: input.files.map((f, i) => ({ ...listed[i], content: f.contents })), meta });
101
+ return { name: input.name, registryDependencies: input.registryDependencies, text, entry: { ...head, files: listed, meta } };
102
+ }
103
+ /** Why `add`'s parser would refuse the item as written, or null when it reads it. */
104
+ function refusal(item, where) {
105
+ const bytes = Buffer.byteLength(item.text, 'utf8');
106
+ if (bytes > MAX_REGISTRY_BYTES)
107
+ return `the item is ${Math.round(bytes / 1024)} KB, over the ${MAX_REGISTRY_BYTES / 1024} KB the loader reads`;
108
+ try {
109
+ parseRegistryItem(item.text, where);
110
+ return null;
111
+ }
112
+ catch (error) {
113
+ return errorMessage(error);
114
+ }
115
+ }
116
+ const codesOf = (diagnostics, target) => [...new Set(diagnostics.filter((d) => d.severity !== 'info' && (d.target === target || d.target === undefined)).map((d) => d.code))].sort();
117
+ function verifyCard(result, target) {
118
+ const values = [...result.comparisons.filter((c) => c.target === target).map((c) => c.match), ...(result.steps ?? []).filter((s) => s.target === target).map((s) => s.match)];
119
+ const leaks = result.leaks?.find((l) => l.framework === target);
120
+ const unmountFailed = result.diagnostics.some((d) => d.code === 'unmount-failed');
121
+ return { lowestMatch: values.length ? Math.min(...values) : 0, leakFree: unmountFailed ? false : leaks ? leaks.clean : null, pageErrors: result.pageErrors.length };
122
+ }
123
+ const passed = (v) => !v.error && v.lowestMatch >= PASS_MATCH && v.leakFree !== false && v.pageErrors === 0;
124
+ function verifyCell(v) {
125
+ if (v.error)
126
+ return 'verify failed';
127
+ const leaks = v.leakFree === null ? 'leaks not measured' : v.leakFree ? 'no leaks' : 'leaks';
128
+ return `${percent(v.lowestMatch)}, ${leaks}${v.pageErrors ? `, ${v.pageErrors} page error${v.pageErrors === 1 ? '' : 's'}` : ''}`;
129
+ }
130
+ /** SCORECARD.md: the same facts as scorecard.json, for people. */
131
+ export function scorecardMarkdown(card) {
132
+ const lines = ['# Publish scorecard', '', `Folder \`${cellText(card.folder)}\`, ${card.components.length} component file${card.components.length === 1 ? '' : 's'}, generated ${card.generatedAt}.`, ''];
133
+ lines.push('## Totals', '');
134
+ lines.push(`| Target | Clean | Partial | Unsupported | Published |${card.verify ? ' Verified | Passed |' : ''}`);
135
+ lines.push(`| --- | ---: | ---: | ---: | ---: |${card.verify ? ' ---: | ---: |' : ''}`);
136
+ for (const t of card.targets) {
137
+ const row = card.totals[t];
138
+ if (!row)
139
+ continue;
140
+ lines.push(`| ${t} | ${row.counts.clean} | ${row.counts.partial} | ${row.counts.unsupported} | ${row.published} |${card.verify ? ` ${row.verified?.run ?? 0} | ${row.verified?.passed ?? 0} |` : ''}`);
141
+ }
142
+ lines.push('', '## Components', '', `| Component | ${card.targets.join(' | ')} |`, `| --- |${card.targets.map(() => ' --- |').join('')}`);
143
+ for (const c of card.components) {
144
+ const cells = card.targets.map((t) => {
145
+ const tc = c.targets[t];
146
+ if (!tc)
147
+ return 'not run';
148
+ const parts = [tc.status];
149
+ if (tc.status !== 'unsupported' && !tc.published)
150
+ parts.push('not published');
151
+ return cellText(parts.join(', '));
152
+ });
153
+ lines.push(`| ${cellText(c.file)} | ${cells.join(' | ')} |`);
154
+ }
155
+ if (card.verify) {
156
+ lines.push('', '## Verify', '', 'Each clean component, rendered with the steps morph found on the React page and unmounted, against React: the lowest pixel match in any state or step, and whether it leaves anything running that React does not.', '');
157
+ lines.push('| Component | Target | Lowest match and leaks |', '| --- | --- | --- |');
158
+ for (const c of card.components) {
159
+ for (const t of card.targets) {
160
+ const v = c.targets[t]?.verify;
161
+ if (v)
162
+ lines.push(`| ${cellText(c.file)} | ${t} | ${cellText(verifyCell(v))} |`);
163
+ }
164
+ }
165
+ for (const c of card.components) {
166
+ for (const t of card.targets) {
167
+ const v = c.targets[t]?.verify;
168
+ if (v?.error)
169
+ lines.push('', `${cellText(c.file)} (${t}): ${cellText(v.error)}`);
170
+ }
171
+ }
172
+ }
173
+ const unsupported = card.components.filter((c) => card.targets.some((t) => c.targets[t]?.status === 'unsupported'));
174
+ if (unsupported.length) {
175
+ lines.push('', '## Unsupported (no item)', '');
176
+ for (const c of unsupported) {
177
+ const where = card.targets.filter((t) => c.targets[t]?.status === 'unsupported');
178
+ const codes = [...new Set(where.flatMap((t) => c.targets[t]?.codes ?? []))];
179
+ lines.push(`- \`${cellText(c.file)}\` on ${where.join(', ')}${codes.length ? `: ${codes.join(', ')}` : ''}`);
180
+ }
181
+ }
182
+ const unpublished = card.components.flatMap((c) => card.targets.flatMap((t) => (c.targets[t] && c.targets[t]?.status !== 'unsupported' && !c.targets[t]?.published ? [`- \`${cellText(c.file)}\` on ${t}: ${cellText(c.targets[t]?.reason ?? 'not published')}`] : [])));
183
+ if (unpublished.length)
184
+ lines.push('', '## Converted but not published', '', ...unpublished);
185
+ const partial = card.components.flatMap((c) => card.targets.flatMap((t) => (c.targets[t]?.status === 'partial' ? [`- \`${cellText(c.file)}\` on ${t}: ${(c.targets[t]?.codes ?? []).join(', ') || 'see the compile warnings'}`] : [])));
186
+ if (partial.length)
187
+ lines.push('', '## Partial', '', 'These convert, with a stated difference from the React original.', '', ...partial);
188
+ if (card.causes.length) {
189
+ lines.push('', '## Most common causes', '');
190
+ for (const c of card.causes.slice(0, 10))
191
+ lines.push(`- ${c.code} (${c.severity}): ${c.files} file${c.files === 1 ? '' : 's'}. ${cellText(c.example).slice(0, 200)}`);
192
+ }
193
+ if (card.notes.length)
194
+ lines.push('', '## Notes', '', ...card.notes.map((n) => `- ${cellText(n)}`));
195
+ return `${lines.join('\n')}\n`;
196
+ }
197
+ /** Publishes a folder of React components as shadcn-format registries. See the module comment. */
198
+ export async function publishFolder(input, options) {
199
+ const targets = PUBLISH_TARGETS.filter((t) => (options.targets ?? PUBLISH_TARGETS).includes(t));
200
+ if (!targets.length)
201
+ throw new MorphError('publish-targets', 'publish writes vue, svelte and angular registries: name at least one of them.');
202
+ const baseUrl = cleanBaseUrl(options.baseUrl);
203
+ const out = resolve(options.out);
204
+ const found = collectFiles(input, options.include, options.exclude);
205
+ if (!found.length)
206
+ throw new MorphError('publish-empty', `No component files (.tsx, not tests or stories) were found under ${input}.`);
207
+ const root = resolve(options.root ?? findProjectRoot(found[0] ?? input));
208
+ const say = options.onProgress ?? (() => undefined);
209
+ const typechecking = options.typecheck !== false;
210
+ // 1. the existing batch: a status for every file and target
211
+ const report = await runBatch(input, {
212
+ targets,
213
+ root,
214
+ ...(options.include ? { include: options.include } : {}),
215
+ ...(options.exclude ? { exclude: options.exclude } : {}),
216
+ ...(typechecking ? {} : { typecheck: false }),
217
+ ...(options.fileTimeoutMs ? { fileTimeoutMs: options.fileTimeoutMs } : {}),
218
+ ...(options.signal ? { signal: options.signal } : {}),
219
+ }, (done, total, file) => {
220
+ if (file)
221
+ say(`compiling ${done + 1}/${total} ${file}`);
222
+ });
223
+ const names = itemNames(report.entries.map((e) => e.file));
224
+ // 2. the files of every component that came out clean or partial on some target
225
+ const compiled = [];
226
+ const components = [];
227
+ for (const entry of report.entries) {
228
+ options.signal?.throwIfAborted();
229
+ const name = names.get(entry.file) ?? kebab(entry.file);
230
+ const targetCards = {};
231
+ components.push({ file: entry.file, name, targets: targetCards });
232
+ const wanted = [];
233
+ for (const t of targets) {
234
+ const base = entry.targets[t];
235
+ const status = base?.status ?? 'unsupported';
236
+ const validated = base?.validated ?? false;
237
+ const codes = codesOf(entry.diagnostics, t);
238
+ const converted = status === 'clean' || status === 'partial';
239
+ // vue and svelte: the strict type check runs on validated output and reports `type-error`; angular: the Angular compiler's strict pass is the validation
240
+ const typechecked = converted && validated && (t === 'angular' || typechecking) && !codes.includes('type-error');
241
+ const tc = { status, validated, typechecked, published: false, codes };
242
+ targetCards[t] = tc;
243
+ if (converted)
244
+ wanted.push(t);
245
+ else
246
+ tc.reason = `${status}: no item is written for a component morph does not convert`;
247
+ }
248
+ if (!wanted.length)
249
+ continue;
250
+ const abs = join(root, entry.file);
251
+ say(`collecting ${entry.file}`);
252
+ try {
253
+ const result = await compileFile(abs, { root, targets: wanted, ...(typechecking ? {} : { typecheck: false }), ...(options.signal ? { signal: options.signal } : {}) });
254
+ const results = new Map();
255
+ for (const r of result.targets)
256
+ if (r.target !== 'react-native')
257
+ results.set(r.target, r);
258
+ compiled.push({ file: entry.file, name, abs, result, results });
259
+ }
260
+ catch (error) {
261
+ options.signal?.throwIfAborted();
262
+ for (const t of wanted) {
263
+ const tc = targetCards[t];
264
+ if (tc)
265
+ tc.reason = `its files could not be collected: ${errorMessage(error)}`;
266
+ }
267
+ }
268
+ }
269
+ const cards = new Map(components.map((c) => [c.file, c]));
270
+ // 3. verify, one component at a time: a failure is recorded, and never costs an item
271
+ if (options.verify) {
272
+ for (const c of compiled) {
273
+ const card = cards.get(c.file);
274
+ const clean = targets.filter((t) => card?.targets[t]?.status === 'clean' && c.results.get(t)?.status === 'clean');
275
+ if (!card || !clean.length)
276
+ continue;
277
+ options.signal?.throwIfAborted();
278
+ say(`verifying ${c.name}`);
279
+ try {
280
+ const result = await runVerify(c.abs, { root, targets: clean, compiled: c.result, autoSteps: true, unmount: true, ...(options.chrome ? { executablePath: options.chrome } : {}) });
281
+ for (const t of clean) {
282
+ const tc = card.targets[t];
283
+ if (tc)
284
+ tc.verify = verifyCard(result, t);
285
+ }
286
+ }
287
+ catch (error) {
288
+ options.signal?.throwIfAborted();
289
+ for (const t of clean) {
290
+ const tc = card.targets[t];
291
+ if (tc)
292
+ tc.verify = { lowestMatch: 0, leakFree: null, pageErrors: 0, error: errorMessage(error) };
293
+ }
294
+ }
295
+ }
296
+ }
297
+ // 4. the items, per target, each parsed back with the parser `add` uses before it is written
298
+ const written = [];
299
+ const registries = [];
300
+ const notes = [];
301
+ const write = (rel, text) => {
302
+ writeInside(out, rel, text);
303
+ written.push(toPosix(rel));
304
+ };
305
+ for (const target of targets) {
306
+ const members = compiled.flatMap((c) => {
307
+ const r = c.results.get(target);
308
+ const card = cards.get(c.file)?.targets[target];
309
+ if (!r || !card)
310
+ return [];
311
+ if (r.status !== card.status) {
312
+ card.reason = `the second compile gave ${r.status}, not the batch's ${card.status}`;
313
+ return [];
314
+ }
315
+ return [{ c, r, card, files: r.files.filter((f) => f.kind !== 'report') }];
316
+ });
317
+ // a file given by two or more components with the same contents is an item of its own (a motion helper, a shared directive)
318
+ const owners = new Map();
319
+ const versions = new Map();
320
+ for (const m of members) {
321
+ for (const f of m.files) {
322
+ const key = `${f.path}\u0000${f.contents}`;
323
+ const o = owners.get(key) ?? { file: f, by: new Set() };
324
+ o.by.add(m.c.file);
325
+ owners.set(key, o);
326
+ const v = versions.get(f.path) ?? new Set();
327
+ v.add(f.contents);
328
+ versions.set(f.path, v);
329
+ }
330
+ }
331
+ for (const [path, v] of versions) {
332
+ if (v.size > 1)
333
+ notes.push(`${target}: ${path} is emitted with different contents by different components, so each item carries its own copy and those items cannot be added to one project together.`);
334
+ }
335
+ const used = new Set(members.map((m) => m.c.name));
336
+ const sharedName = new Map();
337
+ const sharedBuilt = new Map();
338
+ const sharedBad = new Map();
339
+ for (const [key, o] of owners) {
340
+ if (o.by.size < 2)
341
+ continue;
342
+ const n = kebab(withoutExtension(o.file.path)) || 'shared';
343
+ let name = used.has(n) ? `${n}-shared` : n;
344
+ for (let i = 2; used.has(name); i++)
345
+ name = `${n}-shared-${i}`;
346
+ used.add(name);
347
+ sharedName.set(key, name);
348
+ const usedBy = [...o.by].map((f) => names.get(f) ?? f).sort();
349
+ const item = buildItem({
350
+ name,
351
+ type: 'registry:lib',
352
+ title: basename(o.file.path),
353
+ description: `${basename(o.file.path)}, shared by ${usedBy.length} components; emitted by antheo-morph for ${target}.`,
354
+ files: [o.file],
355
+ target,
356
+ registryDependencies: [],
357
+ meta: { target, shared: true, usedBy },
358
+ });
359
+ const problem = refusal(item, `${target}/${name}.json`);
360
+ if (problem)
361
+ sharedBad.set(name, problem);
362
+ else
363
+ sharedBuilt.set(name, item);
364
+ }
365
+ const dependencyRef = (name) => (baseUrl ? `${baseUrl}/${target}/${name}.json` : `./${name}.json`);
366
+ const items = [];
367
+ for (const m of members) {
368
+ const own = [];
369
+ const shared = new Set();
370
+ for (const f of m.files) {
371
+ const name = sharedName.get(`${f.path}\u0000${f.contents}`);
372
+ if (name)
373
+ shared.add(name);
374
+ else
375
+ own.push(f);
376
+ }
377
+ const bad = [...shared].find((n) => sharedBad.has(n));
378
+ if (bad) {
379
+ m.card.reason = `its shared file ${bad} cannot be published: ${sharedBad.get(bad)}`;
380
+ continue;
381
+ }
382
+ const v = m.card.verify;
383
+ const title = pascal(basename(withoutExtension(m.c.file)));
384
+ const item = buildItem({
385
+ name: m.c.name,
386
+ type: 'registry:component',
387
+ title,
388
+ description: `${title}, converted from React for ${target} by antheo-morph (${m.r.status}).`,
389
+ files: own,
390
+ target,
391
+ registryDependencies: [...shared].sort().map(dependencyRef),
392
+ meta: {
393
+ status: m.r.status,
394
+ validated: m.r.validated,
395
+ typechecked: m.card.typechecked,
396
+ target,
397
+ source: m.c.file,
398
+ ...(m.card.codes.length ? { diagnostics: m.card.codes } : {}),
399
+ ...(v && !v.error ? { verified: { lowestMatch: v.lowestMatch, leakFree: v.leakFree } } : {}),
400
+ },
401
+ });
402
+ const problem = refusal(item, `${target}/${m.c.name}.json`);
403
+ if (problem) {
404
+ m.card.reason = problem;
405
+ continue;
406
+ }
407
+ items.push(item);
408
+ m.card.published = true;
409
+ m.card.item = `${target}/${m.c.name}.json`;
410
+ }
411
+ // a shared item is written only when a published item depends on it
412
+ const needed = new Set(items.flatMap((i) => i.registryDependencies));
413
+ const sharedItems = [...sharedBuilt.values()].filter((s) => needed.has(dependencyRef(s.name)));
414
+ const all = [...items, ...sharedItems];
415
+ for (const i of all)
416
+ write(`${target}/${i.name}.json`, i.text);
417
+ const registryName = `${kebab(basename(resolve(input))) || 'morph'}-${target}`;
418
+ write(`${target}/registry.json`, jsonText({ $schema: REGISTRY_SCHEMA, name: registryName, ...(baseUrl ? { homepage: baseUrl } : {}), items: all.map((i) => i.entry) }));
419
+ registries.push({ target, index: `${target}/registry.json`, items: items.map((i) => `${target}/${i.name}.json`), shared: sharedItems.map((i) => `${target}/${i.name}.json`) });
420
+ }
421
+ // 5. the scorecard
422
+ const totals = {};
423
+ for (const t of targets) {
424
+ const counts = report.totals.byTarget[t];
425
+ const row = { files: report.totals.files, counts: { clean: counts.clean, partial: counts.partial, unsupported: counts.unsupported }, published: components.filter((c) => c.targets[t]?.published).length };
426
+ if (options.verify) {
427
+ const cardsRun = components.flatMap((c) => {
428
+ const v = c.targets[t]?.verify;
429
+ return v ? [v] : [];
430
+ });
431
+ row.verified = { run: cardsRun.length, passed: cardsRun.filter(passed).length };
432
+ }
433
+ totals[t] = row;
434
+ }
435
+ const scorecard = { generatedAt: report.generatedAt, folder: basename(resolve(input)), targets, verify: options.verify === true, baseUrl, totals, components, causes: report.topCauses, notes };
436
+ write('scorecard.json', jsonText(scorecard));
437
+ write('SCORECARD.md', scorecardMarkdown(scorecard));
438
+ return { out, registries, scorecard, written };
439
+ }
@@ -0,0 +1,39 @@
1
+ import * as t from '@babel/types';
2
+ /**
3
+ * A module's template bank on Angular: the markup the module holds outside its components' templates (a table of
4
+ * icons, a helper's returned markup) as `<ng-template>` blocks of one component, `<File>Markup`, which the runtime
5
+ * (runtime.ts, `MarkupBanks`) creates once per application, off the page. Each piece is then a value,
6
+ * `markup(FileMarkup, 'name', { …context })`, that `MorphNode` stamps where React renders it, with no element of its own.
7
+ */
8
+ /** One banked template: its name (a template reference variable), the context names it reads, its printed markup. */
9
+ export interface BankedTemplate {
10
+ name: string;
11
+ /** `let-` variables, each read from the context key of the same name */
12
+ params: string[];
13
+ /** the markup, printed by the Angular template printer */
14
+ markup: string;
15
+ }
16
+ /** The bank class's name for a module: its file's base name in PascalCase, then `Markup`, free in the module. */
17
+ export declare function bankName(file: string, taken: ReadonlySet<string>): string;
18
+ /** A template string as Angular's `template:` takes it (backslashes, backticks and `${` kept literal). */
19
+ export declare function templateLiteral(markup: string): t.TemplateLiteral;
20
+ /**
21
+ * The bank component: `ChangeDetectionStrategy.OnPush`, a template of only `<ng-template>` blocks, one required view
22
+ * query per block, and `templates`, the record the runtime reads them from. `imports`: the components and directives
23
+ * the banked markup uses; `api`: the local name of an `@angular/core` export (the module may shadow one).
24
+ *
25
+ * The bank is declared before the module's data, since that data calls `markup(Bank, …)` as the module loads and a
26
+ * class is not hoisted. A component of the same file the banked markup uses is declared after it, so it is listed
27
+ * as `forwardRef(() => Chip)` (`later`): ngtsc then reads the dependency lazily (`dependencies: () => [Chip]`), and
28
+ * TypeScript sees no use before declaration.
29
+ */
30
+ export declare function bankClass(className: string, templates: BankedTemplate[], imports: {
31
+ name: string;
32
+ later: boolean;
33
+ }[], api: (name: string) => string, bankInterface: string): t.ClassDeclaration;
34
+ /** A bank's members: one required view query per template (`private readonly ok = viewChild.required<…>('ok')`), and `templates`. */
35
+ export declare function bankMembers(names: string[], api: (name: string) => string): t.ClassProperty[];
36
+ /** The bank's `implements` and its doc comment. */
37
+ export declare function asBank(klass: t.ClassDeclaration, bankInterface: string): void;
38
+ /** A piece of banked markup as a value: `markup(Bank, 'name', { a, b })`, with React's key when it had one. */
39
+ export declare function markupValue(markupFn: string, bank: string, name: string, context: string[], key?: t.Expression): t.CallExpression;
@@ -0,0 +1,61 @@
1
+ import * as t from '@babel/types';
2
+ /** The bank class's name for a module: its file's base name in PascalCase, then `Markup`, free in the module. */
3
+ export function bankName(file, taken) {
4
+ const base = (file.split(/[\\/]/).pop() ?? 'module').replace(/\.[^.]+$/, '');
5
+ const pascal = base.replace(/(^|[^A-Za-z0-9]+)([A-Za-z0-9])/g, (_, _sep, c) => c.toUpperCase()).replace(/^[0-9]/, (d) => `M${d}`);
6
+ let name = `${pascal}Markup`;
7
+ for (let i = 2; taken.has(name); i++)
8
+ name = `${pascal}Markup${i}`;
9
+ return name;
10
+ }
11
+ /** A template string as Angular's `template:` takes it (backslashes, backticks and `${` kept literal). */
12
+ export function templateLiteral(markup) {
13
+ const raw = markup.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${');
14
+ return t.templateLiteral([t.templateElement({ raw, cooked: markup }, true)], []);
15
+ }
16
+ /**
17
+ * The bank component: `ChangeDetectionStrategy.OnPush`, a template of only `<ng-template>` blocks, one required view
18
+ * query per block, and `templates`, the record the runtime reads them from. `imports`: the components and directives
19
+ * the banked markup uses; `api`: the local name of an `@angular/core` export (the module may shadow one).
20
+ *
21
+ * The bank is declared before the module's data, since that data calls `markup(Bank, …)` as the module loads and a
22
+ * class is not hoisted. A component of the same file the banked markup uses is declared after it, so it is listed
23
+ * as `forwardRef(() => Chip)` (`later`): ngtsc then reads the dependency lazily (`dependencies: () => [Chip]`), and
24
+ * TypeScript sees no use before declaration.
25
+ */
26
+ export function bankClass(className, templates, imports, api, bankInterface) {
27
+ const blocks = templates.map((tpl) => `<ng-template #${tpl.name}${tpl.params.map((p) => ` let-${p}="${p}"`).join('')}>${tpl.markup}</ng-template>`).join('\n');
28
+ const meta = [t.objectProperty(t.identifier('changeDetection'), t.memberExpression(t.identifier(api('ChangeDetectionStrategy')), t.identifier('OnPush')))];
29
+ const listed = [...imports].sort((a, b) => a.name.localeCompare(b.name)).map((i) => (i.later ? t.callExpression(t.identifier(api('forwardRef')), [t.arrowFunctionExpression([], t.identifier(i.name))]) : t.identifier(i.name)));
30
+ if (listed.length)
31
+ meta.push(t.objectProperty(t.identifier('imports'), t.arrayExpression(listed)));
32
+ meta.push(t.objectProperty(t.identifier('template'), templateLiteral(blocks)));
33
+ const klass = t.classDeclaration(t.identifier(className), null, t.classBody(bankMembers(templates.map((tpl) => tpl.name), api)), [t.decorator(t.callExpression(t.identifier(api('Component')), [t.objectExpression(meta)]))]);
34
+ asBank(klass, bankInterface);
35
+ return klass;
36
+ }
37
+ /** A bank's members: one required view query per template (`private readonly ok = viewChild.required<…>('ok')`), and `templates`. */
38
+ export function bankMembers(names, api) {
39
+ const templateRef = t.tsTypeReference(t.identifier(api('TemplateRef')), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier('object'))]));
40
+ const members = names.map((name) => {
41
+ const query = t.callExpression(t.memberExpression(t.identifier(api('viewChild')), t.identifier('required')), [t.stringLiteral(name)]);
42
+ query.typeParameters = t.tsTypeParameterInstantiation([t.cloneNode(templateRef, true)]);
43
+ const p = t.classProperty(t.identifier(name), query);
44
+ p.accessibility = 'private';
45
+ p.readonly = true;
46
+ return p;
47
+ });
48
+ const record = t.classProperty(t.identifier('templates'), t.objectExpression(names.map((name) => t.objectProperty(t.identifier(name), t.memberExpression(t.thisExpression(), t.identifier(name))))));
49
+ record.readonly = true;
50
+ return [...members, record];
51
+ }
52
+ /** The bank's `implements` and its doc comment. */
53
+ export function asBank(klass, bankInterface) {
54
+ klass.implements = [t.tsExpressionWithTypeArguments(t.identifier(bankInterface))];
55
+ t.addComment(klass, 'leading', '* Markup this file holds outside its components, as templates its values name (see markup-node.directive.ts). ', false);
56
+ }
57
+ /** A piece of banked markup as a value: `markup(Bank, 'name', { a, b })`, with React's key when it had one. */
58
+ export function markupValue(markupFn, bank, name, context, key) {
59
+ const ctx = t.objectExpression(context.map((c) => t.objectProperty(t.identifier(c), t.identifier(c), false, true)));
60
+ return t.callExpression(t.identifier(markupFn), [t.identifier(bank), t.stringLiteral(name), ctx, ...(key ? [key] : [])]);
61
+ }
@@ -0,0 +1,64 @@
1
+ import * as t from '@babel/types';
2
+ import type { ModuleIR, TNode } from '../../../ir/model.js';
3
+ /**
4
+ * Render helpers kept as module code on Angular (`export function renderIcon(icon, size) { … return <Icon … /> }`):
5
+ * the function stays a function and runs as written (its tests, lookups and early returns), and each element it
6
+ * returns becomes a value of the file's template bank, `markup(FileMarkup, 'renderIcon_1', { Icon, size })`, whose
7
+ * `<ng-template let-Icon="Icon" let-size="size">` holds the element's markup. A React element captures the values it
8
+ * reads when it is created, and so does the context object. React's `isValidElement` in such a helper is the runtime's
9
+ * `isMarkup`. Where the values go (rendered by `[morphNode]`, passed to a component that renders them so) is planned
10
+ * across the conversion in plan.ts; a helper whose values go anywhere else stays refused.
11
+ */
12
+ export type HelperFn = t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression;
13
+ /** One element a helper returns, as a banked template. */
14
+ export interface BankPiece {
15
+ /** the template's name in the bank (`renderIcon_1`) */
16
+ name: string;
17
+ /** the element as the module's code holds it (replaced by its value when the statement is written) */
18
+ jsx: t.JSXElement | t.JSXFragment;
19
+ template: TNode;
20
+ /** the helper's names the markup reads: its `let-` variables and its value's context, in source order */
21
+ params: string[];
22
+ moduleNames: string[];
23
+ /** React's key on the element, passed as the value's key */
24
+ key: t.Expression | null;
25
+ }
26
+ export interface BankHelper {
27
+ name: string;
28
+ /** the module statement that declares it */
29
+ stmt: t.Statement;
30
+ fn: HelperFn;
31
+ exported: boolean;
32
+ pieces: BankPiece[];
33
+ }
34
+ /** The function a module statement declares under one name: `function f() {}` or `const f = () => …`. */
35
+ export declare function declaredFunction(stmt: t.Statement): {
36
+ name: string;
37
+ fn: HelperFn;
38
+ exported: boolean;
39
+ } | null;
40
+ /**
41
+ * The expressions a function returns (each `return x`, or an arrow's expression body), and each value one of them may
42
+ * be through `?:` arms, the right side of `&&` / `||` / `??`, and parentheses or type assertions. Nested functions are
43
+ * not entered.
44
+ */
45
+ export declare function returnedValues(fn: HelperFn): t.Expression[];
46
+ /** `isValidElement(x)` (or `React.isValidElement(x)`): the calls to rewrite as the runtime's `isMarkup(x)`. */
47
+ export declare function elementTests(mod: ModuleIR, root: t.Node): t.CallExpression[];
48
+ /**
49
+ * The module's render helpers that can become bank values, and why each other function that builds markup cannot.
50
+ * A helper qualifies when every element it builds is one of its returned values (see returnedValues), outside nested
51
+ * functions; it reads no React value but `isValidElement`; and each element lowers as module markup with no diagnostic.
52
+ */
53
+ export declare function bankHelpers(mod: ModuleIR): {
54
+ helpers: BankHelper[];
55
+ refused: Map<string, {
56
+ why: string;
57
+ line: number | null;
58
+ }>;
59
+ };
60
+ /**
61
+ * The statement with each banked element replaced by its value (`make(piece)`) and each element test by `isMarkup`,
62
+ * as a copy: the module's own statement is left as it was.
63
+ */
64
+ export declare function withBankValues(stmt: t.Statement, replace: Map<t.Node, t.Expression>): t.Statement;