@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.
- package/LICENSE +21 -0
- package/README.md +266 -2
- package/SKILL.md +61 -0
- package/dist/ai/cli-provider.d.ts +80 -0
- package/dist/ai/cli-provider.js +250 -0
- package/dist/ai/gate.d.ts +39 -0
- package/dist/ai/gate.js +124 -0
- package/dist/ai/provider.d.ts +36 -0
- package/dist/ai/provider.js +168 -0
- package/dist/ai/repair.d.ts +90 -0
- package/dist/ai/repair.js +172 -0
- package/dist/analyzer/deps.d.ts +30 -0
- package/dist/analyzer/deps.js +265 -0
- package/dist/analyzer/manifest.d.ts +5 -0
- package/dist/analyzer/manifest.js +119 -0
- package/dist/analyzer/parse.d.ts +21 -0
- package/dist/analyzer/parse.js +29 -0
- package/dist/batch-worker.d.ts +16 -0
- package/dist/batch-worker.js +10 -0
- package/dist/batch.d.ts +26 -0
- package/dist/batch.js +227 -0
- package/dist/bridge/index.d.ts +26 -0
- package/dist/bridge/index.js +138 -0
- package/dist/bridge/props.d.ts +56 -0
- package/dist/bridge/props.js +191 -0
- package/dist/bridge/wrappers.d.ts +24 -0
- package/dist/bridge/wrappers.js +276 -0
- package/dist/cli/format.d.ts +7 -0
- package/dist/cli/format.js +30 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +492 -0
- package/dist/fonts/carry.d.ts +34 -0
- package/dist/fonts/carry.js +113 -0
- package/dist/fonts/fallback.d.ts +11 -0
- package/dist/fonts/fallback.js +21 -0
- package/dist/fonts/google.d.ts +65 -0
- package/dist/fonts/google.js +343 -0
- package/dist/fonts/index.d.ts +27 -0
- package/dist/fonts/index.js +48 -0
- package/dist/fonts/local.d.ts +46 -0
- package/dist/fonts/local.js +150 -0
- package/dist/fonts/sfnt.d.ts +19 -0
- package/dist/fonts/sfnt.js +174 -0
- package/dist/fonts/shim.d.ts +14 -0
- package/dist/fonts/shim.js +96 -0
- package/dist/gate.d.ts +105 -0
- package/dist/gate.js +157 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +74 -0
- package/dist/ir/annotate.d.ts +16 -0
- package/dist/ir/annotate.js +145 -0
- package/dist/ir/as-child.d.ts +18 -0
- package/dist/ir/as-child.js +239 -0
- package/dist/ir/compounds.d.ts +27 -0
- package/dist/ir/compounds.js +183 -0
- package/dist/ir/contexts.d.ts +26 -0
- package/dist/ir/contexts.js +185 -0
- package/dist/ir/dom.d.ts +11 -0
- package/dist/ir/dom.js +60 -0
- package/dist/ir/effect-returns.d.ts +10 -0
- package/dist/ir/effect-returns.js +25 -0
- package/dist/ir/extract-ui-types.d.ts +33 -0
- package/dist/ir/extract-ui-types.js +224 -0
- package/dist/ir/extract-ui.d.ts +34 -0
- package/dist/ir/extract-ui.js +567 -0
- package/dist/ir/falsy.d.ts +13 -0
- package/dist/ir/falsy.js +66 -0
- package/dist/ir/forward-refs.d.ts +11 -0
- package/dist/ir/forward-refs.js +155 -0
- package/dist/ir/fragment-source.d.ts +4 -0
- package/dist/ir/fragment-source.js +13 -0
- package/dist/ir/fragments.d.ts +32 -0
- package/dist/ir/fragments.js +192 -0
- package/dist/ir/helper-snippets.d.ts +30 -0
- package/dist/ir/helper-snippets.js +550 -0
- package/dist/ir/latest-refs.d.ts +11 -0
- package/dist/ir/latest-refs.js +187 -0
- package/dist/ir/live-args.d.ts +26 -0
- package/dist/ir/live-args.js +335 -0
- package/dist/ir/lower.d.ts +83 -0
- package/dist/ir/lower.js +6016 -0
- package/dist/ir/markup-values.d.ts +16 -0
- package/dist/ir/markup-values.js +188 -0
- package/dist/ir/model.d.ts +605 -0
- package/dist/ir/model.js +1 -0
- package/dist/ir/oracle.d.ts +91 -0
- package/dist/ir/oracle.js +610 -0
- package/dist/ir/radix.d.ts +122 -0
- package/dist/ir/radix.js +344 -0
- package/dist/ir/rename.d.ts +15 -0
- package/dist/ir/rename.js +151 -0
- package/dist/ir/render-props.d.ts +31 -0
- package/dist/ir/render-props.js +67 -0
- package/dist/ir/rewrite.d.ts +44 -0
- package/dist/ir/rewrite.js +381 -0
- package/dist/ir/running-index.d.ts +11 -0
- package/dist/ir/running-index.js +217 -0
- package/dist/ir/snapshots.d.ts +12 -0
- package/dist/ir/snapshots.js +140 -0
- package/dist/ir/style.d.ts +19 -0
- package/dist/ir/style.js +76 -0
- package/dist/ir/types.d.ts +42 -0
- package/dist/ir/types.js +271 -0
- package/dist/ir/walk.d.ts +11 -0
- package/dist/ir/walk.js +18 -0
- package/dist/mcp/server.d.ts +81 -0
- package/dist/mcp/server.js +518 -0
- package/dist/pipeline.d.ts +26 -0
- package/dist/pipeline.js +750 -0
- package/dist/registry/add.d.ts +91 -0
- package/dist/registry/add.js +273 -0
- package/dist/registry/fetch.d.ts +40 -0
- package/dist/registry/fetch.js +186 -0
- package/dist/registry/ip.d.ts +18 -0
- package/dist/registry/ip.js +153 -0
- package/dist/registry/item.d.ts +39 -0
- package/dist/registry/item.js +131 -0
- package/dist/registry/load.d.ts +35 -0
- package/dist/registry/load.js +106 -0
- package/dist/registry/paths.d.ts +8 -0
- package/dist/registry/paths.js +43 -0
- package/dist/registry/publish.d.ts +119 -0
- package/dist/registry/publish.js +439 -0
- package/dist/targets/angular/bank/bank.d.ts +39 -0
- package/dist/targets/angular/bank/bank.js +61 -0
- package/dist/targets/angular/bank/helpers.d.ts +64 -0
- package/dist/targets/angular/bank/helpers.js +246 -0
- package/dist/targets/angular/bank/kept.d.ts +98 -0
- package/dist/targets/angular/bank/kept.js +791 -0
- package/dist/targets/angular/bank/plan-helpers.d.ts +17 -0
- package/dist/targets/angular/bank/plan-helpers.js +286 -0
- package/dist/targets/angular/bank/plan.d.ts +22 -0
- package/dist/targets/angular/bank/plan.js +152 -0
- package/dist/targets/angular/bank/receivers.d.ts +66 -0
- package/dist/targets/angular/bank/receivers.js +293 -0
- package/dist/targets/angular/bank/runtime.d.ts +14 -0
- package/dist/targets/angular/bank/runtime.js +152 -0
- package/dist/targets/angular/controlled.d.ts +7 -0
- package/dist/targets/angular/controlled.js +37 -0
- package/dist/targets/angular/dynamic-tags.d.ts +34 -0
- package/dist/targets/angular/dynamic-tags.js +192 -0
- package/dist/targets/angular/emit.d.ts +41 -0
- package/dist/targets/angular/emit.js +5970 -0
- package/dist/targets/angular/exports.d.ts +48 -0
- package/dist/targets/angular/exports.js +243 -0
- package/dist/targets/angular/helpers.d.ts +15 -0
- package/dist/targets/angular/helpers.js +33 -0
- package/dist/targets/angular/host-boundary.d.ts +5 -0
- package/dist/targets/angular/host-boundary.js +166 -0
- package/dist/targets/angular/host-form.d.ts +150 -0
- package/dist/targets/angular/host-form.js +727 -0
- package/dist/targets/angular/markup-values.d.ts +58 -0
- package/dist/targets/angular/markup-values.js +661 -0
- package/dist/targets/angular/motion-directive.d.ts +12 -0
- package/dist/targets/angular/motion-directive.js +257 -0
- package/dist/targets/angular/motion-hooks.d.ts +73 -0
- package/dist/targets/angular/motion-hooks.js +293 -0
- package/dist/targets/angular/motion-layout.d.ts +14 -0
- package/dist/targets/angular/motion-layout.js +74 -0
- package/dist/targets/angular/motion-templates.d.ts +10 -0
- package/dist/targets/angular/motion-templates.js +65 -0
- package/dist/targets/angular/motion.d.ts +57 -0
- package/dist/targets/angular/motion.js +202 -0
- package/dist/targets/angular/narrowing.d.ts +24 -0
- package/dist/targets/angular/narrowing.js +205 -0
- package/dist/targets/angular/ngc.d.ts +23 -0
- package/dist/targets/angular/ngc.js +134 -0
- package/dist/targets/angular/passed-handle.d.ts +39 -0
- package/dist/targets/angular/passed-handle.js +154 -0
- package/dist/targets/angular/projected.d.ts +9 -0
- package/dist/targets/angular/projected.js +63 -0
- package/dist/targets/angular/radix/cores/alert-dialog.d.ts +13 -0
- package/dist/targets/angular/radix/cores/alert-dialog.js +388 -0
- package/dist/targets/angular/radix/cores/index.d.ts +17 -0
- package/dist/targets/angular/radix/cores/index.js +50 -0
- package/dist/targets/angular/radix/cores/slider.d.ts +8 -0
- package/dist/targets/angular/radix/cores/slider.js +202 -0
- package/dist/targets/angular/radix/index.d.ts +21 -0
- package/dist/targets/angular/radix/index.js +35 -0
- package/dist/targets/angular/radix/packages.d.ts +3 -0
- package/dist/targets/angular/radix/packages.js +558 -0
- package/dist/targets/angular/radix/part.d.ts +236 -0
- package/dist/targets/angular/radix/part.js +71 -0
- package/dist/targets/angular/radix/prepare.d.ts +66 -0
- package/dist/targets/angular/radix/prepare.js +548 -0
- package/dist/targets/angular/radix/template.d.ts +43 -0
- package/dist/targets/angular/radix/template.js +172 -0
- package/dist/targets/angular/refs.d.ts +68 -0
- package/dist/targets/angular/refs.js +443 -0
- package/dist/targets/angular/slots.d.ts +22 -0
- package/dist/targets/angular/slots.js +60 -0
- package/dist/targets/angular/source-types.d.ts +10 -0
- package/dist/targets/angular/source-types.js +45 -0
- package/dist/targets/angular/spread-forward.d.ts +24 -0
- package/dist/targets/angular/spread-forward.js +72 -0
- package/dist/targets/angular/spread.d.ts +32 -0
- package/dist/targets/angular/spread.js +182 -0
- package/dist/targets/angular/svg-hosts.d.ts +25 -0
- package/dist/targets/angular/svg-hosts.js +107 -0
- package/dist/targets/angular/template-expr.d.ts +36 -0
- package/dist/targets/angular/template-expr.js +287 -0
- package/dist/targets/angular/types.d.ts +9 -0
- package/dist/targets/angular/types.js +63 -0
- package/dist/targets/angular/walk.d.ts +11 -0
- package/dist/targets/angular/walk.js +26 -0
- package/dist/targets/react-native/emit.d.ts +14 -0
- package/dist/targets/react-native/emit.js +585 -0
- package/dist/targets/react-native/fidelity.d.ts +5 -0
- package/dist/targets/react-native/fidelity.js +43 -0
- package/dist/targets/react-native/motion.d.ts +10 -0
- package/dist/targets/react-native/motion.js +290 -0
- package/dist/targets/react-native/skia.d.ts +30 -0
- package/dist/targets/react-native/skia.js +358 -0
- package/dist/targets/shared/context.d.ts +47 -0
- package/dist/targets/shared/context.js +195 -0
- package/dist/targets/shared/foreign.d.ts +10 -0
- package/dist/targets/shared/foreign.js +72 -0
- package/dist/targets/shared/fragments.d.ts +21 -0
- package/dist/targets/shared/fragments.js +309 -0
- package/dist/targets/shared/handles.d.ts +65 -0
- package/dist/targets/shared/handles.js +299 -0
- package/dist/targets/shared/inline.d.ts +53 -0
- package/dist/targets/shared/inline.js +524 -0
- package/dist/targets/shared/layout.d.ts +70 -0
- package/dist/targets/shared/layout.js +224 -0
- package/dist/targets/shared/markup.d.ts +26 -0
- package/dist/targets/shared/markup.js +65 -0
- package/dist/targets/shared/module.d.ts +84 -0
- package/dist/targets/shared/module.js +468 -0
- package/dist/targets/shared/motion-hooks.d.ts +37 -0
- package/dist/targets/shared/motion-hooks.js +87 -0
- package/dist/targets/shared/motion-layout.d.ts +70 -0
- package/dist/targets/shared/motion-layout.js +392 -0
- package/dist/targets/shared/portal.d.ts +10 -0
- package/dist/targets/shared/portal.js +23 -0
- package/dist/targets/shared/prop-writes.d.ts +11 -0
- package/dist/targets/shared/prop-writes.js +32 -0
- package/dist/targets/shared/prune.d.ts +54 -0
- package/dist/targets/shared/prune.js +405 -0
- package/dist/targets/shared/react-libs.d.ts +25 -0
- package/dist/targets/shared/react-libs.js +142 -0
- package/dist/targets/shared/react-types.d.ts +16 -0
- package/dist/targets/shared/react-types.js +374 -0
- package/dist/targets/shared/react-values.d.ts +20 -0
- package/dist/targets/shared/react-values.js +145 -0
- package/dist/targets/shared/ref-callback.d.ts +16 -0
- package/dist/targets/shared/ref-callback.js +114 -0
- package/dist/targets/shared/script.d.ts +65 -0
- package/dist/targets/shared/script.js +406 -0
- package/dist/targets/shared/unused.d.ts +12 -0
- package/dist/targets/shared/unused.js +146 -0
- package/dist/targets/svelte/dom-spread.d.ts +27 -0
- package/dist/targets/svelte/dom-spread.js +146 -0
- package/dist/targets/svelte/emit.d.ts +15 -0
- package/dist/targets/svelte/emit.js +3784 -0
- package/dist/targets/svelte/handle-branches.d.ts +22 -0
- package/dist/targets/svelte/handle-branches.js +146 -0
- package/dist/targets/svelte/html-keys.d.ts +9 -0
- package/dist/targets/svelte/html-keys.js +40 -0
- package/dist/targets/svelte/markup-data/data.d.ts +51 -0
- package/dist/targets/svelte/markup-data/data.js +305 -0
- package/dist/targets/svelte/markup-data/helper.d.ts +12 -0
- package/dist/targets/svelte/markup-data/helper.js +81 -0
- package/dist/targets/svelte/markup-data/module-data.d.ts +21 -0
- package/dist/targets/svelte/markup-data/module-data.js +473 -0
- package/dist/targets/svelte/markup-data/sites.d.ts +52 -0
- package/dist/targets/svelte/markup-data/sites.js +303 -0
- package/dist/targets/svelte/motion-layout.d.ts +13 -0
- package/dist/targets/svelte/motion-layout.js +70 -0
- package/dist/targets/svelte/motion-table.d.ts +14 -0
- package/dist/targets/svelte/motion-table.js +308 -0
- package/dist/targets/svelte/motion.d.ts +46 -0
- package/dist/targets/svelte/motion.js +405 -0
- package/dist/targets/svelte/presence.d.ts +71 -0
- package/dist/targets/svelte/presence.js +318 -0
- package/dist/targets/svelte/radix/accordion.d.ts +9 -0
- package/dist/targets/svelte/radix/accordion.js +24 -0
- package/dist/targets/svelte/radix/aspect-ratio.d.ts +6 -0
- package/dist/targets/svelte/radix/aspect-ratio.js +8 -0
- package/dist/targets/svelte/radix/avatar.d.ts +6 -0
- package/dist/targets/svelte/radix/avatar.js +10 -0
- package/dist/targets/svelte/radix/checkbox.d.ts +10 -0
- package/dist/targets/svelte/radix/checkbox.js +24 -0
- package/dist/targets/svelte/radix/collapsible.d.ts +7 -0
- package/dist/targets/svelte/radix/collapsible.js +16 -0
- package/dist/targets/svelte/radix/context-menu.d.ts +8 -0
- package/dist/targets/svelte/radix/context-menu.js +49 -0
- package/dist/targets/svelte/radix/cores/alert-dialog.d.ts +17 -0
- package/dist/targets/svelte/radix/cores/alert-dialog.js +449 -0
- package/dist/targets/svelte/radix/cores/collapsible.d.ts +12 -0
- package/dist/targets/svelte/radix/cores/collapsible.js +214 -0
- package/dist/targets/svelte/radix/cores/core.d.ts +32 -0
- package/dist/targets/svelte/radix/cores/core.js +80 -0
- package/dist/targets/svelte/radix/cores/direction.d.ts +10 -0
- package/dist/targets/svelte/radix/cores/direction.js +64 -0
- package/dist/targets/svelte/radix/cores/index.d.ts +19 -0
- package/dist/targets/svelte/radix/cores/index.js +85 -0
- package/dist/targets/svelte/radix/cores/modal-layer.d.ts +11 -0
- package/dist/targets/svelte/radix/cores/modal-layer.js +244 -0
- package/dist/targets/svelte/radix/cores/presence.d.ts +12 -0
- package/dist/targets/svelte/radix/cores/presence.js +129 -0
- package/dist/targets/svelte/radix/cores/slider-logic.d.ts +10 -0
- package/dist/targets/svelte/radix/cores/slider-logic.js +287 -0
- package/dist/targets/svelte/radix/cores/slider.d.ts +13 -0
- package/dist/targets/svelte/radix/cores/slider.js +267 -0
- package/dist/targets/svelte/radix/dialog.d.ts +8 -0
- package/dist/targets/svelte/radix/dialog.js +20 -0
- package/dist/targets/svelte/radix/dropdown-menu.d.ts +9 -0
- package/dist/targets/svelte/radix/dropdown-menu.js +38 -0
- package/dist/targets/svelte/radix/emit.d.ts +12 -0
- package/dist/targets/svelte/radix/emit.js +1339 -0
- package/dist/targets/svelte/radix/hover-card.d.ts +7 -0
- package/dist/targets/svelte/radix/hover-card.js +22 -0
- package/dist/targets/svelte/radix/index.d.ts +12 -0
- package/dist/targets/svelte/radix/index.js +28 -0
- package/dist/targets/svelte/radix/label.d.ts +3 -0
- package/dist/targets/svelte/radix/label.js +5 -0
- package/dist/targets/svelte/radix/menubar.d.ts +7 -0
- package/dist/targets/svelte/radix/menubar.js +34 -0
- package/dist/targets/svelte/radix/navigation-menu.d.ts +8 -0
- package/dist/targets/svelte/radix/navigation-menu.js +25 -0
- package/dist/targets/svelte/radix/packages.d.ts +34 -0
- package/dist/targets/svelte/radix/packages.js +100 -0
- package/dist/targets/svelte/radix/part.d.ts +161 -0
- package/dist/targets/svelte/radix/part.js +85 -0
- package/dist/targets/svelte/radix/popover.d.ts +7 -0
- package/dist/targets/svelte/radix/popover.js +15 -0
- package/dist/targets/svelte/radix/progress.d.ts +11 -0
- package/dist/targets/svelte/radix/progress.js +27 -0
- package/dist/targets/svelte/radix/radio-group.d.ts +9 -0
- package/dist/targets/svelte/radix/radio-group.js +26 -0
- package/dist/targets/svelte/radix/scroll-area.d.ts +7 -0
- package/dist/targets/svelte/radix/scroll-area.js +19 -0
- package/dist/targets/svelte/radix/select.d.ts +13 -0
- package/dist/targets/svelte/radix/select.js +81 -0
- package/dist/targets/svelte/radix/separator.d.ts +3 -0
- package/dist/targets/svelte/radix/separator.js +5 -0
- package/dist/targets/svelte/radix/slider.d.ts +6 -0
- package/dist/targets/svelte/radix/slider.js +8 -0
- package/dist/targets/svelte/radix/switch.d.ts +6 -0
- package/dist/targets/svelte/radix/switch.js +10 -0
- package/dist/targets/svelte/radix/tabs.d.ts +8 -0
- package/dist/targets/svelte/radix/tabs.js +15 -0
- package/dist/targets/svelte/radix/toggle-group.d.ts +9 -0
- package/dist/targets/svelte/radix/toggle-group.js +17 -0
- package/dist/targets/svelte/radix/toggle.d.ts +6 -0
- package/dist/targets/svelte/radix/toggle.js +9 -0
- package/dist/targets/svelte/radix/tooltip.d.ts +6 -0
- package/dist/targets/svelte/radix/tooltip.js +24 -0
- package/dist/targets/svelte/strip.d.ts +2 -0
- package/dist/targets/svelte/strip.js +5 -0
- package/dist/targets/vue/emit.d.ts +15 -0
- package/dist/targets/vue/emit.js +4092 -0
- package/dist/targets/vue/events.d.ts +11 -0
- package/dist/targets/vue/events.js +13 -0
- package/dist/targets/vue/module-builders.d.ts +28 -0
- package/dist/targets/vue/module-builders.js +258 -0
- package/dist/targets/vue/motion-layout.d.ts +19 -0
- package/dist/targets/vue/motion-layout.js +79 -0
- package/dist/targets/vue/motion.d.ts +12 -0
- package/dist/targets/vue/motion.js +46 -0
- package/dist/targets/vue/radix/accordion.d.ts +3 -0
- package/dist/targets/vue/radix/accordion.js +12 -0
- package/dist/targets/vue/radix/alert-dialog.d.ts +6 -0
- package/dist/targets/vue/radix/alert-dialog.js +18 -0
- package/dist/targets/vue/radix/aspect-ratio.d.ts +6 -0
- package/dist/targets/vue/radix/aspect-ratio.js +8 -0
- package/dist/targets/vue/radix/avatar.d.ts +3 -0
- package/dist/targets/vue/radix/avatar.js +7 -0
- package/dist/targets/vue/radix/checkbox.d.ts +3 -0
- package/dist/targets/vue/radix/checkbox.js +9 -0
- package/dist/targets/vue/radix/collapsible.d.ts +7 -0
- package/dist/targets/vue/radix/collapsible.js +11 -0
- package/dist/targets/vue/radix/context-menu.d.ts +3 -0
- package/dist/targets/vue/radix/context-menu.js +30 -0
- package/dist/targets/vue/radix/dialog.d.ts +3 -0
- package/dist/targets/vue/radix/dialog.js +12 -0
- package/dist/targets/vue/radix/direction.d.ts +7 -0
- package/dist/targets/vue/radix/direction.js +9 -0
- package/dist/targets/vue/radix/dropdown-menu.d.ts +3 -0
- package/dist/targets/vue/radix/dropdown-menu.js +29 -0
- package/dist/targets/vue/radix/hover-card.d.ts +3 -0
- package/dist/targets/vue/radix/hover-card.js +11 -0
- package/dist/targets/vue/radix/index.d.ts +65 -0
- package/dist/targets/vue/radix/index.js +225 -0
- package/dist/targets/vue/radix/label.d.ts +3 -0
- package/dist/targets/vue/radix/label.js +5 -0
- package/dist/targets/vue/radix/menubar.d.ts +6 -0
- package/dist/targets/vue/radix/menubar.js +29 -0
- package/dist/targets/vue/radix/navigation-menu.d.ts +6 -0
- package/dist/targets/vue/radix/navigation-menu.js +21 -0
- package/dist/targets/vue/radix/part.d.ts +41 -0
- package/dist/targets/vue/radix/part.js +46 -0
- package/dist/targets/vue/radix/popover.d.ts +3 -0
- package/dist/targets/vue/radix/popover.js +11 -0
- package/dist/targets/vue/radix/progress.d.ts +3 -0
- package/dist/targets/vue/radix/progress.js +6 -0
- package/dist/targets/vue/radix/radio-group.d.ts +3 -0
- package/dist/targets/vue/radix/radio-group.js +10 -0
- package/dist/targets/vue/radix/scroll-area.d.ts +3 -0
- package/dist/targets/vue/radix/scroll-area.js +11 -0
- package/dist/targets/vue/radix/select.d.ts +3 -0
- package/dist/targets/vue/radix/select.js +29 -0
- package/dist/targets/vue/radix/separator.d.ts +3 -0
- package/dist/targets/vue/radix/separator.js +5 -0
- package/dist/targets/vue/radix/slider.d.ts +3 -0
- package/dist/targets/vue/radix/slider.js +13 -0
- package/dist/targets/vue/radix/switch.d.ts +3 -0
- package/dist/targets/vue/radix/switch.js +9 -0
- package/dist/targets/vue/radix/tabs.d.ts +3 -0
- package/dist/targets/vue/radix/tabs.js +12 -0
- package/dist/targets/vue/radix/toggle-group.d.ts +3 -0
- package/dist/targets/vue/radix/toggle-group.js +10 -0
- package/dist/targets/vue/radix/toggle.d.ts +3 -0
- package/dist/targets/vue/radix/toggle.js +8 -0
- package/dist/targets/vue/radix/tooltip.d.ts +3 -0
- package/dist/targets/vue/radix/tooltip.js +14 -0
- package/dist/targets/vue/render-fn/h.d.ts +52 -0
- package/dist/targets/vue/render-fn/h.js +442 -0
- package/dist/targets/vue/render-fn.d.ts +21 -0
- package/dist/targets/vue/render-fn.js +357 -0
- package/dist/targets/vue/slot.d.ts +9 -0
- package/dist/targets/vue/slot.js +57 -0
- package/dist/typecheck/host.d.ts +45 -0
- package/dist/typecheck/host.js +309 -0
- package/dist/typecheck/index.d.ts +16 -0
- package/dist/typecheck/index.js +17 -0
- package/dist/typecheck/lucide.d.ts +8 -0
- package/dist/typecheck/lucide.js +45 -0
- package/dist/typecheck/sourcemap.d.ts +9 -0
- package/dist/typecheck/sourcemap.js +54 -0
- package/dist/typecheck/svelte.d.ts +9 -0
- package/dist/typecheck/svelte.js +116 -0
- package/dist/typecheck/vue.d.ts +8 -0
- package/dist/typecheck/vue.js +78 -0
- package/dist/types.d.ts +446 -0
- package/dist/types.js +11 -0
- package/dist/utils/cleanup.d.ts +32 -0
- package/dist/utils/cleanup.js +119 -0
- package/dist/utils/errors.d.ts +7 -0
- package/dist/utils/errors.js +15 -0
- package/dist/utils/fs-safe.d.ts +14 -0
- package/dist/utils/fs-safe.js +64 -0
- package/dist/validate.d.ts +16 -0
- package/dist/validate.js +204 -0
- package/dist/verify/auto-steps.d.ts +107 -0
- package/dist/verify/auto-steps.js +471 -0
- package/dist/verify/bundle.d.ts +68 -0
- package/dist/verify/bundle.js +548 -0
- package/dist/verify/diff.d.ts +31 -0
- package/dist/verify/diff.js +133 -0
- package/dist/verify/leaks.d.ts +25 -0
- package/dist/verify/leaks.js +261 -0
- package/dist/verify/link-worker.d.ts +1 -0
- package/dist/verify/link-worker.js +27 -0
- package/dist/verify/runner.d.ts +57 -0
- package/dist/verify/runner.js +867 -0
- package/dist/verify/sandbox.d.ts +40 -0
- package/dist/verify/sandbox.js +496 -0
- package/dist/verify/steps.d.ts +42 -0
- package/dist/verify/steps.js +475 -0
- package/dist/verify/verdict.d.ts +15 -0
- package/dist/verify/verdict.js +19 -0
- package/package.json +118 -4
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Diagnostic, EmittedFile, Status, WebTarget } from '../types.js';
|
|
2
|
+
import type { ProviderName } from '../ai/provider.js';
|
|
3
|
+
import { type LoadOptions } from './load.js';
|
|
4
|
+
/**
|
|
5
|
+
* `antheo-morph add <url-or-file>` (v0.3 Milestone B): a shadcn-format registry item (Aceternity and Magic UI use the
|
|
6
|
+
* same format) converted to the Vue, Svelte or Angular project in the working folder. The item and its dependencies
|
|
7
|
+
* are read through the SSRF guard (load.ts, fetch.ts), laid out in a managed temp folder as a shadcn project
|
|
8
|
+
* (`@/*` for the folder's root), compiled by the full pipeline with validation and the strict type check, and written
|
|
9
|
+
* under the output folder through `writeInside`. Nothing is written when a file would be overwritten without
|
|
10
|
+
* `overwrite`, or when a file stays unsupported. The `npm install` line is printed, never run.
|
|
11
|
+
*/
|
|
12
|
+
export interface AddOptions extends LoadOptions {
|
|
13
|
+
/** the target; default: the one framework the project's package.json depends on (vue, svelte, @angular/core) */
|
|
14
|
+
target?: WebTarget;
|
|
15
|
+
/** the project folder (default: the working directory): its package.json picks the target, its tsconfig the layout */
|
|
16
|
+
projectDir?: string;
|
|
17
|
+
/** where the files go; default: the folder the project's `@/*` path alias points to, else the project folder */
|
|
18
|
+
out?: string;
|
|
19
|
+
/** replace files that exist and differ (default: refuse, and write nothing) */
|
|
20
|
+
overwrite?: boolean;
|
|
21
|
+
/** bridge mode for a file the compiler refuses (writes the React original beside the wrapper) */
|
|
22
|
+
bridge?: boolean;
|
|
23
|
+
/** assisted mode for a file the compiler refuses: the provider to ask */
|
|
24
|
+
ai?: {
|
|
25
|
+
provider: ProviderName;
|
|
26
|
+
model?: string;
|
|
27
|
+
};
|
|
28
|
+
/** run the strict type check (default true) */
|
|
29
|
+
typecheck?: boolean;
|
|
30
|
+
/** TESTS ONLY: told the managed temp folder's path once it exists (to prove it is removed in every outcome) */
|
|
31
|
+
onTempDir?: (dir: string) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface AddEntry {
|
|
34
|
+
/** the item's file, as laid out (`components/ui/button.tsx`) */
|
|
35
|
+
file: string;
|
|
36
|
+
status: Status;
|
|
37
|
+
diagnostics: Diagnostic[];
|
|
38
|
+
}
|
|
39
|
+
export interface AddResult {
|
|
40
|
+
/** the item the user named */
|
|
41
|
+
item: string;
|
|
42
|
+
source: string;
|
|
43
|
+
target: WebTarget;
|
|
44
|
+
/** the output folder, absolute */
|
|
45
|
+
out: string;
|
|
46
|
+
status: Status;
|
|
47
|
+
entries: AddEntry[];
|
|
48
|
+
/** files written (absolute); empty when nothing was written */
|
|
49
|
+
written: string[];
|
|
50
|
+
/** files that already held exactly this content */
|
|
51
|
+
unchanged: string[];
|
|
52
|
+
/** why nothing was written, when nothing was */
|
|
53
|
+
refused: string | null;
|
|
54
|
+
/** the packages the output imports that the project's package.json does not list */
|
|
55
|
+
install: string[];
|
|
56
|
+
/** `npm install ...` for `install`, or null when there is nothing to install; printed, never run */
|
|
57
|
+
installCommand: string | null;
|
|
58
|
+
/** npm packages the items declare that no output file imports (not needed by the converted files) */
|
|
59
|
+
declaredOnly: string[];
|
|
60
|
+
/** the items read, the root first */
|
|
61
|
+
items: {
|
|
62
|
+
name: string;
|
|
63
|
+
source: string;
|
|
64
|
+
}[];
|
|
65
|
+
/** registryDependencies not followed, each with its reason */
|
|
66
|
+
skipped: string[];
|
|
67
|
+
/** what was read but not applied (cssVars, css, the deprecated tailwind field, envVars), and other notes */
|
|
68
|
+
notes: string[];
|
|
69
|
+
/** the root item's install message */
|
|
70
|
+
docs: string | null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Why a laid-out path is not taken, or null when it is: a file at the project root (a tsconfig.json, a package.json, a
|
|
74
|
+
* vite.config.ts that tooling would read or run), under a dot folder or a dot file (.git, .npmrc), or under
|
|
75
|
+
* node_modules (which would change what the compile and the type check resolve). Such a file is never written, to the
|
|
76
|
+
* temp project or to the output.
|
|
77
|
+
*/
|
|
78
|
+
export declare function unplaceable(at: string): string | null;
|
|
79
|
+
/**
|
|
80
|
+
* The shadcn aliases of an item's code, rewritten for the temp project: `@/registry/<style>/ui/x` to
|
|
81
|
+
* `@/components/ui/x` (lib, hooks likewise; any other folder to `@/components/`), and the npm `cn` package (newer
|
|
82
|
+
* items: `import { cn } from "cn"`) to `@/lib/utils`. `@/components/...`, `@/lib/...` and `@/hooks/...` stay.
|
|
83
|
+
*/
|
|
84
|
+
export declare function rewriteImports(code: string): string;
|
|
85
|
+
/** The target from the project's package.json, or a MorphError when it has none or several. */
|
|
86
|
+
export declare function detectTarget(projectDir: string): WebTarget;
|
|
87
|
+
export declare const FRAMEWORK: Record<WebTarget, (pkg: string) => boolean>;
|
|
88
|
+
/** The bare packages an emitted file imports. */
|
|
89
|
+
export declare function importedPackages(files: EmittedFile[]): Set<string>;
|
|
90
|
+
/** Converts a registry item into the project. See the module comment. */
|
|
91
|
+
export declare function addFromRegistry(input: string, options?: AddOptions): Promise<AddResult>;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { existsSync, readFileSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { compileFile, worst } from '../pipeline.js';
|
|
4
|
+
import { applyAlias, makeProject, packageName } from '../analyzer/deps.js';
|
|
5
|
+
import { makeTempDir } from '../utils/cleanup.js';
|
|
6
|
+
import { MorphError } from '../utils/errors.js';
|
|
7
|
+
import { isInside, resolveInside, toPosix, writeInside } from '../utils/fs-safe.js';
|
|
8
|
+
import { runRepair } from '../ai/repair.js';
|
|
9
|
+
import { loadRegistryItems } from './load.js';
|
|
10
|
+
import { safeRelativePath } from './paths.js';
|
|
11
|
+
const CODE = /\.(tsx|ts|jsx|js|mts)$/;
|
|
12
|
+
const COMPONENT_FILE = /\.(tsx|jsx)$/;
|
|
13
|
+
const PLACEABLE = /\.(tsx|ts|jsx|js|mts|css|json)$/;
|
|
14
|
+
/** Where a file goes in the temp project (a shadcn layout, `@/*` = the root): from its target, its registry path, or its type. */
|
|
15
|
+
function placeFile(f) {
|
|
16
|
+
if (f.target) {
|
|
17
|
+
const t = f.target.replace(/^@components\//, 'components/').replace(/^@ui\//, 'components/ui/').replace(/^@lib\//, 'lib/').replace(/^@hooks\//, 'hooks/');
|
|
18
|
+
return safeRelativePath(t, `target ${f.target}`);
|
|
19
|
+
}
|
|
20
|
+
const m = /^registry\/[^/]+\/([^/]+)\/(.+)$/.exec(f.path);
|
|
21
|
+
if (m) {
|
|
22
|
+
const [, kind = '', rest = ''] = m;
|
|
23
|
+
const head = kind === 'ui' ? 'components/ui' : kind === 'lib' ? 'lib' : kind === 'hooks' ? 'hooks' : 'components';
|
|
24
|
+
return safeRelativePath(`${head}/${rest}`, `path ${f.path}`);
|
|
25
|
+
}
|
|
26
|
+
const name = basename(f.path);
|
|
27
|
+
const head = f.type === 'registry:ui' ? 'components/ui' : f.type === 'registry:lib' ? 'lib' : f.type === 'registry:hook' ? 'hooks' : 'components';
|
|
28
|
+
return safeRelativePath(`${head}/${name}`, `path ${f.path}`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Why a laid-out path is not taken, or null when it is: a file at the project root (a tsconfig.json, a package.json, a
|
|
32
|
+
* vite.config.ts that tooling would read or run), under a dot folder or a dot file (.git, .npmrc), or under
|
|
33
|
+
* node_modules (which would change what the compile and the type check resolve). Such a file is never written, to the
|
|
34
|
+
* temp project or to the output.
|
|
35
|
+
*/
|
|
36
|
+
export function unplaceable(at) {
|
|
37
|
+
const segments = at.split('/');
|
|
38
|
+
if (segments.length < 2)
|
|
39
|
+
return 'the project root, where configuration files live';
|
|
40
|
+
if (segments.some((s) => s.startsWith('.')))
|
|
41
|
+
return 'a path with a segment that starts with "."';
|
|
42
|
+
if (segments.some((s) => s.toLowerCase() === 'node_modules'))
|
|
43
|
+
return 'under node_modules';
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The shadcn aliases of an item's code, rewritten for the temp project: `@/registry/<style>/ui/x` to
|
|
48
|
+
* `@/components/ui/x` (lib, hooks likewise; any other folder to `@/components/`), and the npm `cn` package (newer
|
|
49
|
+
* items: `import { cn } from "cn"`) to `@/lib/utils`. `@/components/...`, `@/lib/...` and `@/hooks/...` stay.
|
|
50
|
+
*/
|
|
51
|
+
export function rewriteImports(code) {
|
|
52
|
+
return code.replace(/(\bfrom\s*|\bimport\s*)(['"])([^'"\r\n]+)\2/g, (all, head, q, spec) => {
|
|
53
|
+
let next = spec;
|
|
54
|
+
if (spec === 'cn')
|
|
55
|
+
next = '@/lib/utils';
|
|
56
|
+
const m = /^@\/registry\/[^/]+\/([^/]+)\/(.+)$/.exec(spec);
|
|
57
|
+
if (m) {
|
|
58
|
+
const [, kind = '', rest = ''] = m;
|
|
59
|
+
next = `@/${kind === 'ui' ? 'components/ui' : kind === 'lib' ? 'lib' : kind === 'hooks' ? 'hooks' : 'components'}/${rest}`;
|
|
60
|
+
}
|
|
61
|
+
return next === spec ? all : `${head}${q}${next}${q}`;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const UTILS = "import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n";
|
|
65
|
+
/** The project's package.json: its dependency names, or null when there is none. */
|
|
66
|
+
function projectPackages(projectDir) {
|
|
67
|
+
const file = join(projectDir, 'package.json');
|
|
68
|
+
if (!existsSync(file))
|
|
69
|
+
return null;
|
|
70
|
+
let pkg;
|
|
71
|
+
try {
|
|
72
|
+
pkg = JSON.parse(readFileSync(file, 'utf8'));
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw new MorphError('add-target', `${file} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
76
|
+
}
|
|
77
|
+
const names = new Set();
|
|
78
|
+
if (typeof pkg === 'object' && pkg !== null) {
|
|
79
|
+
for (const key of ['dependencies', 'devDependencies', 'peerDependencies']) {
|
|
80
|
+
const deps = Reflect.get(pkg, key);
|
|
81
|
+
if (typeof deps === 'object' && deps !== null)
|
|
82
|
+
for (const name of Object.keys(deps))
|
|
83
|
+
names.add(name);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return names;
|
|
87
|
+
}
|
|
88
|
+
/** The target from the project's package.json, or a MorphError when it has none or several. */
|
|
89
|
+
export function detectTarget(projectDir) {
|
|
90
|
+
const names = projectPackages(projectDir);
|
|
91
|
+
if (!names)
|
|
92
|
+
throw new MorphError('add-target', `No package.json in ${projectDir}: pass --target vue, svelte or angular.`);
|
|
93
|
+
const found = [];
|
|
94
|
+
if (names.has('vue'))
|
|
95
|
+
found.push('vue');
|
|
96
|
+
if (names.has('svelte'))
|
|
97
|
+
found.push('svelte');
|
|
98
|
+
if (names.has('@angular/core'))
|
|
99
|
+
found.push('angular');
|
|
100
|
+
if (found.length === 1 && found[0])
|
|
101
|
+
return found[0];
|
|
102
|
+
if (!found.length)
|
|
103
|
+
throw new MorphError('add-target', `${join(projectDir, 'package.json')} depends on none of vue, svelte and @angular/core: pass --target vue, svelte or angular.`);
|
|
104
|
+
throw new MorphError('add-target', `${join(projectDir, 'package.json')} depends on ${found.join(' and ')}: pass --target to choose one.`);
|
|
105
|
+
}
|
|
106
|
+
/** The default output folder: where the project's `@/*` alias points (`src/` in most templates), else the project folder. */
|
|
107
|
+
function defaultOut(projectDir) {
|
|
108
|
+
const project = makeProject(join(projectDir, 'index.ts'), { root: projectDir });
|
|
109
|
+
const probe = applyAlias('@/__morph__', project);
|
|
110
|
+
if (!probe)
|
|
111
|
+
return projectDir;
|
|
112
|
+
const dir = dirname(resolve(probe));
|
|
113
|
+
return isInside(projectDir, dir) ? dir : projectDir;
|
|
114
|
+
}
|
|
115
|
+
export const FRAMEWORK = {
|
|
116
|
+
vue: (p) => p === 'vue',
|
|
117
|
+
svelte: (p) => p === 'svelte',
|
|
118
|
+
angular: (p) => p.startsWith('@angular/'),
|
|
119
|
+
};
|
|
120
|
+
/** The bare packages an emitted file imports. */
|
|
121
|
+
export function importedPackages(files) {
|
|
122
|
+
const out = new Set();
|
|
123
|
+
for (const f of files) {
|
|
124
|
+
if (!CODE.test(f.path) && !/\.(vue|svelte)$/.test(f.path))
|
|
125
|
+
continue;
|
|
126
|
+
for (const m of f.contents.matchAll(/(?:\bfrom\s*|\bimport\s*\(?\s*)(['"])([^'"\r\n]+)\1/g)) {
|
|
127
|
+
const spec = m[2] ?? '';
|
|
128
|
+
if (!spec || spec.startsWith('.') || spec.startsWith('/') || spec.startsWith('@/') || spec.startsWith('node:') || spec.startsWith('virtual:'))
|
|
129
|
+
continue;
|
|
130
|
+
out.add(packageName(spec));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
/** Converts a registry item into the project. See the module comment. */
|
|
136
|
+
export async function addFromRegistry(input, options = {}) {
|
|
137
|
+
const projectDir = resolve(options.projectDir ?? process.cwd());
|
|
138
|
+
const target = options.target ?? detectTarget(projectDir);
|
|
139
|
+
if (target !== 'vue' && target !== 'svelte' && target !== 'angular')
|
|
140
|
+
throw new MorphError('add-target', `add writes vue, svelte or angular, not "${String(target)}".`);
|
|
141
|
+
const out = resolve(options.out ?? defaultOut(projectDir));
|
|
142
|
+
const { items, skipped } = await loadRegistryItems(input, options);
|
|
143
|
+
const root = items[0];
|
|
144
|
+
if (!root)
|
|
145
|
+
throw new MorphError('registry-item', 'No item was read.');
|
|
146
|
+
const notes = items.flatMap((i) => i.item.notes);
|
|
147
|
+
// the shadcn project in a managed temp folder, removed in every outcome (finally)
|
|
148
|
+
const work = makeTempDir();
|
|
149
|
+
try {
|
|
150
|
+
options.onTempDir?.(work.dir);
|
|
151
|
+
const placed = new Map();
|
|
152
|
+
for (const loaded of items) {
|
|
153
|
+
for (const f of loaded.item.files) {
|
|
154
|
+
if (!PLACEABLE.test(f.path)) {
|
|
155
|
+
notes.push(`${loaded.item.name}: ${f.path} was not used (only code, CSS and JSON files are converted).`);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const at = placeFile(f);
|
|
159
|
+
const refused = unplaceable(at);
|
|
160
|
+
if (refused) {
|
|
161
|
+
notes.push(`${loaded.item.name}: ${f.path} was left out: it would land at ${at}, ${refused}; it is not written anywhere.`);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const before = placed.get(at);
|
|
165
|
+
if (before) {
|
|
166
|
+
// the same file named by two items (a shared helper): the first one read is kept
|
|
167
|
+
if (before.file.content !== f.content)
|
|
168
|
+
notes.push(`${at} is given by ${before.from.item.name} and by ${loaded.item.name} with different contents; ${before.from.item.name}'s is used.`);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
placed.set(at, { from: loaded, file: f });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
writeInside(work.dir, 'tsconfig.json', `${JSON.stringify({ compilerOptions: { jsx: 'react-jsx', strict: true, target: 'ES2022', module: 'ESNext', moduleResolution: 'Bundler', baseUrl: '.', paths: { '@/*': ['./*'] } } }, null, 2)}\n`);
|
|
175
|
+
let wantsUtils = false;
|
|
176
|
+
for (const [at, { file }] of placed) {
|
|
177
|
+
const contents = CODE.test(at) ? rewriteImports(file.content) : file.content;
|
|
178
|
+
if (CODE.test(at) && /(['"])@\/lib\/utils\1/.test(contents))
|
|
179
|
+
wantsUtils = true;
|
|
180
|
+
writeInside(work.dir, at, contents);
|
|
181
|
+
}
|
|
182
|
+
if (wantsUtils && !['lib/utils.ts', 'lib/utils.tsx', 'lib/utils.js'].some((p) => placed.has(p))) {
|
|
183
|
+
writeInside(work.dir, 'lib/utils.ts', UTILS);
|
|
184
|
+
notes.push('lib/utils.ts (cn: clsx and tailwind-merge, as shadcn\'s utils item and the cn package define it) was added, because the item imports it and no item read provides it.');
|
|
185
|
+
}
|
|
186
|
+
// compile every component file of the item the user named
|
|
187
|
+
const entries = [];
|
|
188
|
+
const results = [];
|
|
189
|
+
const reactSources = [];
|
|
190
|
+
for (const [at, { from }] of placed) {
|
|
191
|
+
if (!from.root || !COMPONENT_FILE.test(at))
|
|
192
|
+
continue;
|
|
193
|
+
const file = join(work.dir, at);
|
|
194
|
+
const compiled = await compileFile(file, { root: work.dir, targets: [target], ...(options.typecheck === false ? { typecheck: false } : {}), ...(options.bridge ? { bridge: true } : {}), ...(options.signal ? { signal: options.signal } : {}) });
|
|
195
|
+
let result = compiled.targets[0];
|
|
196
|
+
if (!result)
|
|
197
|
+
continue;
|
|
198
|
+
// a file with no component (a helper the components import) is converted where it is imported; one the compiler
|
|
199
|
+
// refuses (a class component, which the analysis does not count as a component) is reported
|
|
200
|
+
if (!compiled.analysis.components.some((c) => c.exported) && !result.diagnostics.some((d) => d.severity === 'error')) {
|
|
201
|
+
notes.push(`${at} exports no component; it is used only where the item's components import it.`);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (options.ai && result.status === 'unsupported') {
|
|
205
|
+
const r = await runRepair(file, { target, provider: options.ai.provider, ...(options.ai.model ? { model: options.ai.model } : {}), root: work.dir, ...(options.signal ? { signal: options.signal } : {}) });
|
|
206
|
+
if (r.accepted)
|
|
207
|
+
result = r.result;
|
|
208
|
+
}
|
|
209
|
+
if (result.status === 'bridged')
|
|
210
|
+
reactSources.push(at);
|
|
211
|
+
entries.push({ file: at, status: result.status, diagnostics: result.diagnostics });
|
|
212
|
+
results.push(result);
|
|
213
|
+
}
|
|
214
|
+
if (!entries.length)
|
|
215
|
+
throw new MorphError('registry-item', `${root.item.name} has no component file to convert (.tsx or .jsx exporting a component).`);
|
|
216
|
+
const status = worst(entries.map((e) => e.status));
|
|
217
|
+
// every emitted file once (two entries share their imports)
|
|
218
|
+
const files = new Map();
|
|
219
|
+
for (const r of results)
|
|
220
|
+
for (const f of r.files)
|
|
221
|
+
if (!files.has(f.path))
|
|
222
|
+
files.set(f.path, f);
|
|
223
|
+
// bridge mode: the wrapper imports the React original, which goes beside it with the files it imports
|
|
224
|
+
if (reactSources.length) {
|
|
225
|
+
for (const [at] of placed)
|
|
226
|
+
if (!files.has(at))
|
|
227
|
+
files.set(at, { path: at, contents: readFileSync(join(work.dir, at), 'utf8'), kind: 'module' });
|
|
228
|
+
notes.push('Bridged files import the React original, written beside them with the files it imports; the project needs react and react-dom, and must build those files with React\'s JSX (README, Bridge mode).');
|
|
229
|
+
}
|
|
230
|
+
// packages: what the output imports, minus the framework and what package.json already lists
|
|
231
|
+
const have = projectPackages(projectDir) ?? new Set();
|
|
232
|
+
const imported = importedPackages([...files.values()]);
|
|
233
|
+
const declared = new Map();
|
|
234
|
+
for (const i of items)
|
|
235
|
+
for (const d of [...i.item.dependencies, ...i.item.devDependencies]) {
|
|
236
|
+
const at = d.indexOf('@', 1);
|
|
237
|
+
declared.set(at > 0 ? d.slice(0, at) : d, d);
|
|
238
|
+
}
|
|
239
|
+
if (reactSources.length)
|
|
240
|
+
for (const [name] of declared)
|
|
241
|
+
imported.add(name);
|
|
242
|
+
const install = [...imported].filter((p) => !FRAMEWORK[target](p) && !have.has(p)).sort().map((p) => declared.get(p) ?? p);
|
|
243
|
+
const declaredOnly = [...declared.keys()].filter((p) => !imported.has(p)).sort();
|
|
244
|
+
const base = { item: root.item.name, source: root.source, target, out, status, entries, install, installCommand: install.length ? `npm install ${install.join(' ')}` : null, declaredOnly, items: items.map((i) => ({ name: i.item.name, source: i.source })), skipped, notes, docs: root.item.docs ?? null };
|
|
245
|
+
if (status === 'unsupported')
|
|
246
|
+
return { ...base, written: [], unchanged: [], refused: 'a file stays unsupported, so nothing was written; retry with --bridge, with --ai, or write the file yourself and prove it with antheo-morph gate in your AI editor' };
|
|
247
|
+
// nothing is written when any file would be overwritten without --overwrite
|
|
248
|
+
const plan = [...files.values()].map((f) => ({ f, dest: resolveInside(out, f.path) }));
|
|
249
|
+
const unchanged = [];
|
|
250
|
+
const conflicts = [];
|
|
251
|
+
for (const { f, dest } of plan) {
|
|
252
|
+
if (!existsSync(dest))
|
|
253
|
+
continue;
|
|
254
|
+
if (readFileSync(dest, 'utf8') === f.contents)
|
|
255
|
+
unchanged.push(dest);
|
|
256
|
+
else
|
|
257
|
+
conflicts.push(dest);
|
|
258
|
+
}
|
|
259
|
+
if (conflicts.length && !options.overwrite)
|
|
260
|
+
return { ...base, written: [], unchanged, refused: `${conflicts.length} file${conflicts.length === 1 ? '' : 's'} already exist with other contents (${conflicts.map((c) => toPosix(c)).join(', ')}); nothing was written. Pass --overwrite to replace them.` };
|
|
261
|
+
mkdirSync(out, { recursive: true });
|
|
262
|
+
const written = [];
|
|
263
|
+
for (const { f, dest } of plan) {
|
|
264
|
+
if (unchanged.includes(dest))
|
|
265
|
+
continue;
|
|
266
|
+
written.push(writeInside(out, f.path, f.contents));
|
|
267
|
+
}
|
|
268
|
+
return { ...base, written, unchanged, refused: null };
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
await work.dispose();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The registry fetcher's SSRF guard (v0.3 Milestone B). A registry item is fetched only over HTTPS, from a host name
|
|
3
|
+
* whose every address is public: loopback, private, link-local (169.254.169.254 too), unique-local, unspecified,
|
|
4
|
+
* multicast, reserved and documentation addresses are refused, for IPv4 and IPv6 and for IPv6 forms that carry an IPv4
|
|
5
|
+
* address. The host name is resolved once, every answer is checked, and the request connects to the checked address
|
|
6
|
+
* itself (the TLS name check still uses the host name), so a second DNS answer cannot swap it. A redirect is followed
|
|
7
|
+
* only to another HTTPS URL, at most 3 times, and each hop goes through the same checks. The whole request has a
|
|
8
|
+
* deadline, and the body is cut off as soon as it passes the size cap. Only the URL as written is requested: no
|
|
9
|
+
* credentials, no cookie, no query parameter or header of the user's beyond Accept and User-Agent; a URL that holds a
|
|
10
|
+
* user name or password is refused.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MAX_REGISTRY_BYTES: number;
|
|
13
|
+
export interface ResolvedAddress {
|
|
14
|
+
address: string;
|
|
15
|
+
family: number;
|
|
16
|
+
}
|
|
17
|
+
export interface RegistryFetchOptions {
|
|
18
|
+
/** the whole request, redirects included (default 15000 ms) */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
/** the largest body read (default and upper bound: 2 MB) */
|
|
21
|
+
maxBytes?: number;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
/**
|
|
24
|
+
* TESTS ONLY, programmatic only (no CLI flag, no environment variable, never read from registry content or the MCP
|
|
25
|
+
* server): also allow loopback addresses (127.0.0.0/8, ::1), and plain http to a loopback address, so a test can
|
|
26
|
+
* serve items from a local server. Every other refused range stays refused.
|
|
27
|
+
*/
|
|
28
|
+
allowLoopback?: boolean;
|
|
29
|
+
/** TESTS ONLY: a stand-in for DNS resolution (default: the system resolver, every address). */
|
|
30
|
+
resolve?: (host: string) => Promise<ResolvedAddress[]>;
|
|
31
|
+
}
|
|
32
|
+
export interface FetchedText {
|
|
33
|
+
/** the URL the body came from, after redirects */
|
|
34
|
+
url: string;
|
|
35
|
+
text: string;
|
|
36
|
+
}
|
|
37
|
+
/** Parses and checks a URL the way every hop is checked; returns it, or throws a MorphError naming why. */
|
|
38
|
+
export declare function checkRegistryUrl(raw: string, allowLoopback?: boolean): URL;
|
|
39
|
+
/** Fetches a registry item's JSON text through the SSRF guard. */
|
|
40
|
+
export declare function fetchRegistryText(raw: string, options?: RegistryFetchOptions): Promise<FetchedText>;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { lookup as dnsLookup } from 'node:dns/promises';
|
|
2
|
+
import { request as httpRequest } from 'node:http';
|
|
3
|
+
import { request as httpsRequest } from 'node:https';
|
|
4
|
+
import { isIP } from 'node:net';
|
|
5
|
+
import { MorphError } from '../utils/errors.js';
|
|
6
|
+
import { classifyAddress } from './ip.js';
|
|
7
|
+
/**
|
|
8
|
+
* The registry fetcher's SSRF guard (v0.3 Milestone B). A registry item is fetched only over HTTPS, from a host name
|
|
9
|
+
* whose every address is public: loopback, private, link-local (169.254.169.254 too), unique-local, unspecified,
|
|
10
|
+
* multicast, reserved and documentation addresses are refused, for IPv4 and IPv6 and for IPv6 forms that carry an IPv4
|
|
11
|
+
* address. The host name is resolved once, every answer is checked, and the request connects to the checked address
|
|
12
|
+
* itself (the TLS name check still uses the host name), so a second DNS answer cannot swap it. A redirect is followed
|
|
13
|
+
* only to another HTTPS URL, at most 3 times, and each hop goes through the same checks. The whole request has a
|
|
14
|
+
* deadline, and the body is cut off as soon as it passes the size cap. Only the URL as written is requested: no
|
|
15
|
+
* credentials, no cookie, no query parameter or header of the user's beyond Accept and User-Agent; a URL that holds a
|
|
16
|
+
* user name or password is refused.
|
|
17
|
+
*/
|
|
18
|
+
export const MAX_REGISTRY_BYTES = 2 * 1024 * 1024;
|
|
19
|
+
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
20
|
+
const MAX_REDIRECTS = 3;
|
|
21
|
+
const MAX_URL = 2048;
|
|
22
|
+
const systemResolve = async (host) => dnsLookup(host, { all: true, verbatim: true });
|
|
23
|
+
/** Parses and checks a URL the way every hop is checked; returns it, or throws a MorphError naming why. */
|
|
24
|
+
export function checkRegistryUrl(raw, allowLoopback = false) {
|
|
25
|
+
if (raw.length > MAX_URL)
|
|
26
|
+
throw new MorphError('registry-url', `The URL is over ${MAX_URL} characters.`);
|
|
27
|
+
let url;
|
|
28
|
+
try {
|
|
29
|
+
url = new URL(raw);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
throw new MorphError('registry-url', `Not a URL: ${raw.slice(0, 200)}`);
|
|
33
|
+
}
|
|
34
|
+
if (url.protocol !== 'https:' && !(allowLoopback && url.protocol === 'http:'))
|
|
35
|
+
throw new MorphError('registry-url', `Only https:// registry URLs are fetched, not ${url.protocol}//.`);
|
|
36
|
+
if (url.username || url.password)
|
|
37
|
+
throw new MorphError('registry-url', 'A registry URL may not hold a user name or password.');
|
|
38
|
+
if (!url.hostname)
|
|
39
|
+
throw new MorphError('registry-url', 'The URL has no host.');
|
|
40
|
+
return url;
|
|
41
|
+
}
|
|
42
|
+
/** The address to connect to for `url`: every resolved address checked, the first one pinned. */
|
|
43
|
+
async function pinAddress(url, options, deadline) {
|
|
44
|
+
const host = url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname;
|
|
45
|
+
const literal = isIP(host);
|
|
46
|
+
const lookup = () => (options.resolve ?? systemResolve)(host).catch((error) => {
|
|
47
|
+
throw new MorphError('registry-dns', `${host} could not be resolved: ${error instanceof Error ? error.message : String(error)}`);
|
|
48
|
+
});
|
|
49
|
+
// the resolution is bound by the same deadline (and abort) as the request: a resolver that never answers ends there
|
|
50
|
+
const answers = literal ? [{ address: host, family: literal }] : await untilDeadline(lookup(), deadline, options, url);
|
|
51
|
+
if (!answers.length)
|
|
52
|
+
throw new MorphError('registry-dns', `${host} has no address.`);
|
|
53
|
+
for (const a of answers) {
|
|
54
|
+
const kind = classifyAddress(a.address);
|
|
55
|
+
if (kind.kind === 'blocked')
|
|
56
|
+
throw new MorphError('registry-blocked', `Refused ${url.host}: it resolves to ${a.address}, ${kind.reason}.`);
|
|
57
|
+
if (kind.kind === 'loopback' && !options.allowLoopback)
|
|
58
|
+
throw new MorphError('registry-blocked', `Refused ${url.host}: it resolves to ${a.address}, a loopback address.`);
|
|
59
|
+
}
|
|
60
|
+
const pinned = answers[0];
|
|
61
|
+
if (!pinned)
|
|
62
|
+
throw new MorphError('registry-dns', `${host} has no address.`);
|
|
63
|
+
// plain http is a test-only path to a loopback server
|
|
64
|
+
if (url.protocol === 'http:' && classifyAddress(pinned.address).kind !== 'loopback')
|
|
65
|
+
throw new MorphError('registry-url', 'Only https:// registry URLs are fetched.');
|
|
66
|
+
return pinned;
|
|
67
|
+
}
|
|
68
|
+
function oneRequest(url, pinned, maxBytes, deadline) {
|
|
69
|
+
return new Promise((done, fail) => {
|
|
70
|
+
const host = url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname;
|
|
71
|
+
const make = url.protocol === 'https:' ? httpsRequest : httpRequest;
|
|
72
|
+
const req = make({
|
|
73
|
+
// the checked address itself: no second resolution at connect time
|
|
74
|
+
host: pinned.address,
|
|
75
|
+
family: pinned.family,
|
|
76
|
+
port: url.port ? Number(url.port) : url.protocol === 'https:' ? 443 : 80,
|
|
77
|
+
path: `${url.pathname}${url.search}`,
|
|
78
|
+
method: 'GET',
|
|
79
|
+
// TLS: SNI and the certificate check use the host name the user wrote (an IP literal has no SNI)
|
|
80
|
+
...(url.protocol === 'https:' && !isIP(host) ? { servername: host } : {}),
|
|
81
|
+
headers: { host: url.host, accept: 'application/json', 'user-agent': 'antheo-morph' },
|
|
82
|
+
agent: false,
|
|
83
|
+
signal: deadline,
|
|
84
|
+
});
|
|
85
|
+
req.on('error', (error) => fail(deadline.aborted ? new MorphError('registry-timeout', `${url.host} did not answer in time.`) : new MorphError('registry-network', `${url.host}: ${error.message}`)));
|
|
86
|
+
req.on('response', (res) => {
|
|
87
|
+
const status = res.statusCode ?? 0;
|
|
88
|
+
if (status >= 300 && status < 400) {
|
|
89
|
+
res.resume();
|
|
90
|
+
const location = res.headers.location;
|
|
91
|
+
done({ status, location: typeof location === 'string' ? location : null, text: '' });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const declared = Number(res.headers['content-length'] ?? '0');
|
|
95
|
+
if (declared > maxBytes) {
|
|
96
|
+
res.destroy();
|
|
97
|
+
fail(new MorphError('registry-too-large', `${url.host} sent ${declared} bytes; the limit is ${maxBytes}.`));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const chunks = [];
|
|
101
|
+
let size = 0;
|
|
102
|
+
res.on('data', (chunk) => {
|
|
103
|
+
size += chunk.length;
|
|
104
|
+
if (size > maxBytes) {
|
|
105
|
+
res.destroy();
|
|
106
|
+
req.destroy();
|
|
107
|
+
fail(new MorphError('registry-too-large', `The registry item from ${url.host} is over ${maxBytes} bytes.`));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
chunks.push(chunk);
|
|
111
|
+
});
|
|
112
|
+
res.on('error', (error) => fail(new MorphError('registry-network', `${url.host}: ${error.message}`)));
|
|
113
|
+
res.on('end', () => {
|
|
114
|
+
if (size > maxBytes)
|
|
115
|
+
return;
|
|
116
|
+
let text;
|
|
117
|
+
try {
|
|
118
|
+
text = new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks));
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
fail(new MorphError('registry-json', `The registry item from ${url.host} is not UTF-8 text.`));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
done({ status, location: null, text });
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
req.end();
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/** The error for a deadline that passed: an abort of the caller's, or the timeout. */
|
|
131
|
+
function stopped(options, url) {
|
|
132
|
+
return options.signal?.aborted ? new MorphError('aborted', 'The fetch was stopped.') : new MorphError('registry-timeout', `${url.host} did not answer in time.`);
|
|
133
|
+
}
|
|
134
|
+
/** `work`, or the deadline's error as soon as the deadline passes (or the caller aborts). */
|
|
135
|
+
function untilDeadline(work, deadline, options, url) {
|
|
136
|
+
if (deadline.aborted)
|
|
137
|
+
return Promise.reject(stopped(options, url));
|
|
138
|
+
return new Promise((done, fail) => {
|
|
139
|
+
const onAbort = () => fail(stopped(options, url));
|
|
140
|
+
deadline.addEventListener('abort', onAbort, { once: true });
|
|
141
|
+
work.then((value) => {
|
|
142
|
+
deadline.removeEventListener('abort', onAbort);
|
|
143
|
+
done(value);
|
|
144
|
+
}, (error) => {
|
|
145
|
+
deadline.removeEventListener('abort', onAbort);
|
|
146
|
+
fail(error);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/** Fetches a registry item's JSON text through the SSRF guard. */
|
|
151
|
+
export async function fetchRegistryText(raw, options = {}) {
|
|
152
|
+
const maxBytes = Math.max(1, Math.min(options.maxBytes ?? MAX_REGISTRY_BYTES, MAX_REGISTRY_BYTES));
|
|
153
|
+
// a timer of our own (AbortSignal.timeout's does not keep the process alive while only a DNS lookup is pending)
|
|
154
|
+
const clock = new AbortController();
|
|
155
|
+
const timer = setTimeout(() => clock.abort(new MorphError('registry-timeout', 'deadline')), options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
156
|
+
const deadline = options.signal ? AbortSignal.any([clock.signal, options.signal]) : clock.signal;
|
|
157
|
+
try {
|
|
158
|
+
return await fetchWithin(raw, options, maxBytes, deadline);
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
clearTimeout(timer);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function fetchWithin(raw, options, maxBytes, deadline) {
|
|
165
|
+
let url = checkRegistryUrl(raw, options.allowLoopback === true);
|
|
166
|
+
for (let hop = 0;; hop++) {
|
|
167
|
+
if (deadline.aborted)
|
|
168
|
+
throw stopped(options, url);
|
|
169
|
+
const pinned = await pinAddress(url, options, deadline);
|
|
170
|
+
const r = await oneRequest(url, pinned, maxBytes, deadline).catch((error) => {
|
|
171
|
+
throw options.signal?.aborted ? new MorphError('aborted', 'The fetch was stopped.') : error;
|
|
172
|
+
});
|
|
173
|
+
if (r.status >= 300 && r.status < 400) {
|
|
174
|
+
if (!r.location)
|
|
175
|
+
throw new MorphError('registry-http', `${url.host} answered ${r.status} with no Location.`);
|
|
176
|
+
if (hop >= MAX_REDIRECTS)
|
|
177
|
+
throw new MorphError('registry-http', `More than ${MAX_REDIRECTS} redirects from ${raw.slice(0, 200)}.`);
|
|
178
|
+
// every hop is checked again from the start: scheme, credentials, host, every address
|
|
179
|
+
url = checkRegistryUrl(new URL(r.location, url).href, options.allowLoopback === true);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (r.status < 200 || r.status >= 300)
|
|
183
|
+
throw new MorphError('registry-http', `${url.host} answered ${r.status} for ${url.pathname.slice(0, 200)}.`);
|
|
184
|
+
return { url: url.href, text: r.text };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where an address points, for the registry fetcher's SSRF guard (v0.3 Milestone B): `public` may be fetched,
|
|
3
|
+
* `loopback` only with the test-only allow-loopback option, `blocked` never. An IPv6 address that carries an IPv4
|
|
4
|
+
* address (IPv4-mapped `::ffff:a.b.c.d`, IPv4-compatible `::a.b.c.d`, NAT64 `64:ff9b::/96` and `64:ff9b:1::/48`, 6to4
|
|
5
|
+
* `2002::/16`) is judged by the IPv4 address it carries.
|
|
6
|
+
*/
|
|
7
|
+
export type AddressKind = {
|
|
8
|
+
kind: 'public';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'loopback';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'blocked';
|
|
13
|
+
reason: string;
|
|
14
|
+
};
|
|
15
|
+
/** The eight 16-bit groups of an IPv6 address (an embedded IPv4 tail is read too), or null. */
|
|
16
|
+
export declare function ipv6Groups(address: string): number[] | null;
|
|
17
|
+
/** Classifies an IP address (IPv4 dotted, or IPv6 with or without brackets); anything else is `blocked`. */
|
|
18
|
+
export declare function classifyAddress(address: string): AddressKind;
|