@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,468 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { classifyImport, unsupportedReason, resolveLocal } from '../../analyzer/deps.js';
|
|
3
|
+
import { transform } from '../../ir/rewrite.js';
|
|
4
|
+
import { containsJSX } from '../../ir/lower.js';
|
|
5
|
+
import { importPath } from './layout.js';
|
|
6
|
+
import { mapReactTypes, markReactTypes19, motionTypeAlias, reactAlias } from './react-types.js';
|
|
7
|
+
import { carryNextFonts } from '../../fonts/index.js';
|
|
8
|
+
export function moduleFacts(mod) {
|
|
9
|
+
const facts = { reactNames: new Set(), nextFonts: new Map(), nextImage: null, nextLink: null, ownTypes: new Set(), ...(mod.snippetRefusals ? { snippetRefusals: mod.snippetRefusals } : {}) };
|
|
10
|
+
for (const s of mod.moduleBody) {
|
|
11
|
+
const decl = t.isExportNamedDeclaration(s) ? s.declaration : s;
|
|
12
|
+
if (t.isTSInterfaceDeclaration(decl) || t.isTSTypeAliasDeclaration(decl))
|
|
13
|
+
facts.ownTypes?.add(decl.id.name);
|
|
14
|
+
}
|
|
15
|
+
for (const decl of mod.imports) {
|
|
16
|
+
const source = decl.source.value;
|
|
17
|
+
for (const s of decl.specifiers) {
|
|
18
|
+
const imported = t.isImportSpecifier(s) ? (t.isIdentifier(s.imported) ? s.imported.name : s.imported.value) : 'default';
|
|
19
|
+
if (source === 'react' || source === 'react-dom') {
|
|
20
|
+
facts.reactNames.add(s.local.name);
|
|
21
|
+
// `type PointerEvent as ReactPointerEvent`: mapped by the name React gives it
|
|
22
|
+
if (imported !== s.local.name && imported !== 'default')
|
|
23
|
+
reactAlias(facts.reactNames, s.local.name, imported);
|
|
24
|
+
}
|
|
25
|
+
// a Framer type: mapped where it is used when the target's library names or shapes it differently
|
|
26
|
+
else if (classifyImport(source) === 'motion' && (decl.importKind === 'type' || (t.isImportSpecifier(s) && s.importKind === 'type')))
|
|
27
|
+
motionTypeAlias(facts.reactNames, s.local.name, imported);
|
|
28
|
+
else if (source.startsWith('next/font/'))
|
|
29
|
+
facts.nextFonts.set(s.local.name, imported === 'default' ? '' : imported);
|
|
30
|
+
else if (source === 'next/image' && imported === 'default')
|
|
31
|
+
facts.nextImage = s.local.name;
|
|
32
|
+
else if (source === 'next/link' && imported === 'default')
|
|
33
|
+
facts.nextLink = s.local.name;
|
|
34
|
+
else if (/^(\.|@\/|~\/)/.test(source) && (decl.importKind === 'type' || (t.isImportSpecifier(s) && s.importKind === 'type')))
|
|
35
|
+
facts.ownTypes?.add(s.local.name);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (mod.reactTypes19)
|
|
39
|
+
markReactTypes19(facts.reactNames);
|
|
40
|
+
return facts;
|
|
41
|
+
}
|
|
42
|
+
/** The generic family fallback a next/font family most likely means. */
|
|
43
|
+
function genericFamily(family) {
|
|
44
|
+
if (/mono|code/i.test(family))
|
|
45
|
+
return 'monospace';
|
|
46
|
+
if (/serif/i.test(family) && !/sans/i.test(family))
|
|
47
|
+
return 'serif';
|
|
48
|
+
if (/display|playfair|fraunces|garamond|baskerville|lora|merriweather|georgia|times/i.test(family))
|
|
49
|
+
return 'serif';
|
|
50
|
+
return 'sans-serif';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What a next/font loader call becomes outside Next: an object with the same shape whose class sets the family through
|
|
54
|
+
* a Tailwind arbitrary value, with the generic family as fallback. The font file itself is not loaded.
|
|
55
|
+
*/
|
|
56
|
+
export function nextFontObject(loaderName) {
|
|
57
|
+
const family = loaderName.replace(/_/g, ' ');
|
|
58
|
+
const generic = genericFamily(family);
|
|
59
|
+
return { className: family ? `font-['${family.replace(/ /g, '_')}',${generic}]` : '', family: family ? `'${family}', ${generic}` : generic };
|
|
60
|
+
}
|
|
61
|
+
function nextFontExpression(loaderName) {
|
|
62
|
+
const font = nextFontObject(loaderName);
|
|
63
|
+
return t.objectExpression([
|
|
64
|
+
t.objectProperty(t.identifier('className'), t.stringLiteral(font.className)),
|
|
65
|
+
t.objectProperty(t.identifier('style'), t.objectExpression([t.objectProperty(t.identifier('fontFamily'), t.stringLiteral(font.family))])),
|
|
66
|
+
t.objectProperty(t.identifier('variable'), t.stringLiteral('')),
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
/** Svelte names for Framer Motion's hooks, from the framework-free `motion` package. */
|
|
70
|
+
export const SVELTE_MOTION_HOOKS = {
|
|
71
|
+
useMotionValue: 'motionValue',
|
|
72
|
+
useSpring: 'springValue',
|
|
73
|
+
useTransform: 'transformValue',
|
|
74
|
+
useMotionTemplate: 'transformValue',
|
|
75
|
+
useAnimate: 'animate',
|
|
76
|
+
useInView: 'inView',
|
|
77
|
+
useScroll: 'scroll',
|
|
78
|
+
};
|
|
79
|
+
// Vue: `@lucide/vue`, the package lucide-vue-next became (that one stopped at 1.0.0); the same component names, props
|
|
80
|
+
// and icon data as lucide-react of the same version
|
|
81
|
+
const LUCIDE = { vue: '@lucide/vue', svelte: '@lucide/svelte', angular: '@lucide/angular' };
|
|
82
|
+
function diag(ctx, code, severity, message, node) {
|
|
83
|
+
const line = node?.loc?.start.line;
|
|
84
|
+
ctx.diagnostics.push({ code, severity, message, file: ctx.sourceRel, target: ctx.target, ...(line ? { line } : {}) });
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Adds one original import to the set for a file at `outPath`, mapping packages to the target's and local files to
|
|
88
|
+
* their output layout. React imports vanish (React types are mapped where they are used).
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* M3: imports of a file the conversion writes itself (the Svelte Radix cores' barrel), by that file's path in the output:
|
|
92
|
+
* each component file imports it by its own relative path (an emitter adds such an import to a module's imports).
|
|
93
|
+
*/
|
|
94
|
+
export const OUTPUT_IMPORTS = new WeakMap();
|
|
95
|
+
export function addOriginalImport(decl, set, outPath, ctx) {
|
|
96
|
+
const source = decl.source.value;
|
|
97
|
+
// (M3: a file of the output, not of the source: see OUTPUT_IMPORTS)
|
|
98
|
+
const written = OUTPUT_IMPORTS.get(decl);
|
|
99
|
+
if (written !== undefined) {
|
|
100
|
+
for (const s of decl.specifiers) {
|
|
101
|
+
if (!t.isImportSpecifier(s))
|
|
102
|
+
continue;
|
|
103
|
+
const imported = t.isIdentifier(s.imported) ? s.imported.name : s.imported.value;
|
|
104
|
+
set.named(importPath(outPath, written), imported, s.local.name);
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const resolved = resolveLocal(ctx.sourceFile, source, ctx.project);
|
|
109
|
+
const kind = resolved ? (source.endsWith('.css') ? 'css' : 'local') : classifyImport(source);
|
|
110
|
+
const isType = (s) => decl.importKind === 'type' || (t.isImportSpecifier(s) && s.importKind === 'type');
|
|
111
|
+
switch (kind) {
|
|
112
|
+
case 'react':
|
|
113
|
+
case 'next-font':
|
|
114
|
+
return;
|
|
115
|
+
case 'css': {
|
|
116
|
+
// Angular components name their stylesheets in styleUrl instead
|
|
117
|
+
if (ctx.target === 'angular')
|
|
118
|
+
return;
|
|
119
|
+
if (resolved) {
|
|
120
|
+
const layout = ctx.layoutOf(resolved);
|
|
121
|
+
// its rules are in the importing component's own <style>
|
|
122
|
+
if (layout?.kind === 'inlined-style')
|
|
123
|
+
return;
|
|
124
|
+
set.side(importPath(outPath, layout?.modulePath ?? source));
|
|
125
|
+
}
|
|
126
|
+
else
|
|
127
|
+
set.side(source);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
case 'next-web':
|
|
131
|
+
diag(ctx, source === 'next/image' ? 'next-image' : 'next-link', 'warning', `${source} becomes a plain <${source === 'next/image' ? 'img' : 'a'}> (no Next.js optimisation or client routing).`, decl);
|
|
132
|
+
return;
|
|
133
|
+
case 'next-app':
|
|
134
|
+
diag(ctx, 'next-app-api', 'error', `${source} is a Next.js app API (routing, server or headers), outside a UI component's scope.`, decl);
|
|
135
|
+
return;
|
|
136
|
+
case 'unsupported':
|
|
137
|
+
diag(ctx, 'unsupported-dependency', 'error', `${unsupportedReason(source)} is app-level or React-only and is not converted.`, decl);
|
|
138
|
+
return;
|
|
139
|
+
case 'react-lib':
|
|
140
|
+
diag(ctx, 'react-library', 'error', `${source} is a React-only library with no automatic ${ctx.target === 'vue' ? 'Vue' : ctx.target === 'svelte' ? 'Svelte' : 'Angular'} counterpart.`, decl);
|
|
141
|
+
return;
|
|
142
|
+
case 'motion': {
|
|
143
|
+
if (ctx.target === 'angular') {
|
|
144
|
+
diag(ctx, 'angular-motion', 'error', 'Framer Motion is not converted for Angular yet.', decl);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
for (const s of decl.specifiers) {
|
|
148
|
+
if (!t.isImportSpecifier(s))
|
|
149
|
+
continue;
|
|
150
|
+
const imported = t.isIdentifier(s.imported) ? s.imported.name : s.imported.value;
|
|
151
|
+
if (ctx.target === 'vue') {
|
|
152
|
+
if (isType(s))
|
|
153
|
+
set.type('motion-v', imported, s.local.name);
|
|
154
|
+
else
|
|
155
|
+
set.named('motion-v', imported, s.local.name);
|
|
156
|
+
}
|
|
157
|
+
else if (isType(s))
|
|
158
|
+
set.type('motion', imported, s.local.name);
|
|
159
|
+
else if (SVELTE_MOTION_HOOKS[imported])
|
|
160
|
+
set.named('motion', SVELTE_MOTION_HOOKS[imported] ?? imported, s.local.name);
|
|
161
|
+
// (MotionValue is a class motion exports too: `progress: MotionValue<number>` keeps its type)
|
|
162
|
+
else if (imported === 'animate' || imported === 'motionValue' || imported === 'stagger' || imported === 'spring' || imported === 'MotionValue')
|
|
163
|
+
set.named('motion', imported, s.local.name);
|
|
164
|
+
}
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
case 'icons': {
|
|
168
|
+
for (const s of decl.specifiers) {
|
|
169
|
+
if (t.isImportSpecifier(s)) {
|
|
170
|
+
const imported = t.isIdentifier(s.imported) ? s.imported.name : s.imported.value;
|
|
171
|
+
// @lucide/angular: one attribute component per icon (<svg lucideClock>), named LucideClock
|
|
172
|
+
if (ctx.target === 'angular') {
|
|
173
|
+
if (isType(s))
|
|
174
|
+
set.type(LUCIDE.angular, imported, s.local.name);
|
|
175
|
+
else
|
|
176
|
+
set.named(LUCIDE.angular, `Lucide${imported.replace(/^Lucide/, '').replace(/Icon$/, '')}`, s.local.name);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (isType(s))
|
|
180
|
+
set.type(LUCIDE[ctx.target], imported === 'LucideIcon' && ctx.target === 'vue' ? 'LucideIcon' : imported, s.local.name);
|
|
181
|
+
else
|
|
182
|
+
set.named(LUCIDE[ctx.target], imported, s.local.name);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
case 'local': {
|
|
188
|
+
const layout = resolved ? ctx.layoutOf(resolved) : null;
|
|
189
|
+
if (!layout) {
|
|
190
|
+
diag(ctx, 'unresolved-import', 'error', `Could not resolve ${source}.`, decl);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
for (const s of decl.specifiers) {
|
|
194
|
+
if (t.isImportNamespaceSpecifier(s)) {
|
|
195
|
+
set.namespace(importPath(outPath, layout.modulePath), s.local.name);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const imported = t.isImportDefaultSpecifier(s) ? 'default' : t.isIdentifier(s.imported) ? s.imported.name : s.imported.value;
|
|
199
|
+
const componentName = imported === 'default' ? layout.defaultComponent : imported;
|
|
200
|
+
// Angular components are named classes in plain modules: imported as written
|
|
201
|
+
const componentFile = componentName && ctx.target !== 'angular' ? layout.components.get(componentName) : undefined;
|
|
202
|
+
if (componentFile && !isType(s)) {
|
|
203
|
+
set.defaultImport(importPath(outPath, componentFile), s.local.name);
|
|
204
|
+
}
|
|
205
|
+
else if (componentFile) {
|
|
206
|
+
// a component imported for its type (`type Button`, read as `typeof Button`): the component file's default
|
|
207
|
+
set.type(importPath(outPath, componentFile), 'default', s.local.name);
|
|
208
|
+
}
|
|
209
|
+
else if (imported === 'default' && layout.defaultValue) {
|
|
210
|
+
set.named(importPath(outPath, layout.modulePath), layout.defaultValue, s.local.name);
|
|
211
|
+
}
|
|
212
|
+
else if (imported === 'default') {
|
|
213
|
+
set.defaultImport(importPath(outPath, layout.modulePath), s.local.name);
|
|
214
|
+
}
|
|
215
|
+
else if (isType(s) || ctx.types.isTypeOnly(imported, resolved ?? '')) {
|
|
216
|
+
set.type(importPath(outPath, layout.modulePath), imported, s.local.name);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
set.named(importPath(outPath, layout.modulePath), imported, s.local.name);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (decl.specifiers.length === 0)
|
|
223
|
+
set.side(importPath(outPath, layout.modulePath));
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
case 'agnostic':
|
|
227
|
+
case 'unknown': {
|
|
228
|
+
if (kind === 'unknown')
|
|
229
|
+
diag(ctx, 'unknown-dependency', 'info', `${source} is kept as-is; check it works outside React.`, decl);
|
|
230
|
+
for (const s of decl.specifiers) {
|
|
231
|
+
if (t.isImportDefaultSpecifier(s))
|
|
232
|
+
set.defaultImport(source, s.local.name);
|
|
233
|
+
else if (t.isImportNamespaceSpecifier(s))
|
|
234
|
+
set.namespace(source, s.local.name);
|
|
235
|
+
else {
|
|
236
|
+
const imported = t.isIdentifier(s.imported) ? s.imported.name : s.imported.value;
|
|
237
|
+
if (isType(s))
|
|
238
|
+
set.type(source, imported, s.local.name);
|
|
239
|
+
else
|
|
240
|
+
set.named(source, imported, s.local.name);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (decl.specifiers.length === 0)
|
|
244
|
+
set.side(source);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** Rewrites `export { X } from './y'` and `export * from './y'` to the target's layout. */
|
|
250
|
+
export function rewriteReexport(stmt, outPath, ctx) {
|
|
251
|
+
const source = stmt.source?.value;
|
|
252
|
+
if (!source)
|
|
253
|
+
return [];
|
|
254
|
+
const resolved = resolveLocal(ctx.sourceFile, source, ctx.project);
|
|
255
|
+
const layout = resolved ? ctx.layoutOf(resolved) : null;
|
|
256
|
+
if (!layout) {
|
|
257
|
+
const kind = classifyImport(source);
|
|
258
|
+
if (kind === 'react' || kind === 'react-lib' || kind === 'unsupported' || kind === 'next-app') {
|
|
259
|
+
diag(ctx, 'reexport', 'warning', `A re-export from ${source} is dropped.`, stmt);
|
|
260
|
+
return [];
|
|
261
|
+
}
|
|
262
|
+
return [stmt];
|
|
263
|
+
}
|
|
264
|
+
if (t.isExportAllDeclaration(stmt)) {
|
|
265
|
+
const out = [t.exportAllDeclaration(t.stringLiteral(importPath(outPath, layout.modulePath)))];
|
|
266
|
+
if (layout.kind === 'sfc') {
|
|
267
|
+
for (const [name, file] of layout.components) {
|
|
268
|
+
out.push(t.exportNamedDeclaration(null, [t.exportSpecifier(t.identifier('default'), t.identifier(name))], t.stringLiteral(importPath(outPath, file))));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return out;
|
|
272
|
+
}
|
|
273
|
+
const out = [];
|
|
274
|
+
const values = [];
|
|
275
|
+
const types = [];
|
|
276
|
+
for (const s of stmt.specifiers) {
|
|
277
|
+
if (!t.isExportSpecifier(s))
|
|
278
|
+
continue;
|
|
279
|
+
const local = s.local.name === 'default' && layout.defaultValue ? layout.defaultValue : s.local.name;
|
|
280
|
+
const exported = t.isIdentifier(s.exported) ? s.exported.name : s.exported.value;
|
|
281
|
+
const componentName = local === 'default' ? layout.defaultComponent : local;
|
|
282
|
+
const file = componentName && ctx.target !== 'angular' ? layout.components.get(componentName) : undefined;
|
|
283
|
+
const typeOnly = stmt.exportKind === 'type' || s.exportKind === 'type' || (resolved !== null && ctx.types.isTypeOnly(local, resolved));
|
|
284
|
+
if (file && !typeOnly) {
|
|
285
|
+
out.push(t.exportNamedDeclaration(null, [t.exportSpecifier(t.identifier('default'), t.identifier(exported))], t.stringLiteral(importPath(outPath, file))));
|
|
286
|
+
}
|
|
287
|
+
else
|
|
288
|
+
(typeOnly ? types : values).push([local, exported]);
|
|
289
|
+
}
|
|
290
|
+
out.unshift(...exportsFrom(values, types, importPath(outPath, layout.modulePath)));
|
|
291
|
+
return out;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* `export { a } from` and `export type { T } from` for one source. A type re-exported as a value breaks any tool that
|
|
295
|
+
* compiles a file on its own (Vite, esbuild per file, isolatedModules): the browser then asks for an export that is not there.
|
|
296
|
+
*/
|
|
297
|
+
export function exportsFrom(values, types, source) {
|
|
298
|
+
const out = [];
|
|
299
|
+
const specs = (names) => names.map(([local, exported]) => t.exportSpecifier(t.identifier(local), t.identifier(exported)));
|
|
300
|
+
if (values.length)
|
|
301
|
+
out.push(t.exportNamedDeclaration(null, specs(values), t.stringLiteral(source)));
|
|
302
|
+
if (types.length) {
|
|
303
|
+
const decl = t.exportNamedDeclaration(null, specs(types), t.stringLiteral(source));
|
|
304
|
+
decl.exportKind = 'type';
|
|
305
|
+
out.push(decl);
|
|
306
|
+
}
|
|
307
|
+
return out;
|
|
308
|
+
}
|
|
309
|
+
function isFunctionDecl(decl) {
|
|
310
|
+
if (t.isFunctionDeclaration(decl))
|
|
311
|
+
return true;
|
|
312
|
+
return t.isVariableDeclaration(decl) && decl.declarations.some((d) => t.isArrowFunctionExpression(d.init) || t.isFunctionExpression(d.init));
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Module-level statements for a web target: next/font loaders become plain objects, React types become the target's,
|
|
316
|
+
* and anything still tied to React is reported.
|
|
317
|
+
*/
|
|
318
|
+
export function transformModuleBody(stmts, ctx, facts, typeImports) {
|
|
319
|
+
const out = [];
|
|
320
|
+
// F5: names the module binds, so the import of a carried font takes a free one
|
|
321
|
+
const fontNames = new Set(facts.nextFonts.size ? [...facts.nextFonts.keys(), ...stmts.flatMap((s) => Object.keys(t.getOuterBindingIdentifiers(s)))] : []);
|
|
322
|
+
for (const original of stmts) {
|
|
323
|
+
let stmt = t.cloneNode(original, true);
|
|
324
|
+
const taken = containsJSX(stmt) ? (facts.moduleMarkup?.(original) ?? null) : null;
|
|
325
|
+
if (taken && !containsJSX(taken))
|
|
326
|
+
stmt = taken;
|
|
327
|
+
if (containsJSX(stmt)) {
|
|
328
|
+
const decl = t.isExportNamedDeclaration(stmt) ? stmt.declaration : stmt;
|
|
329
|
+
const names = decl ? Object.keys(t.getOuterBindingIdentifiers(decl)) : [];
|
|
330
|
+
// a React value read in code (types do not count)
|
|
331
|
+
const reactRead = new Set();
|
|
332
|
+
const visit = (n) => {
|
|
333
|
+
if (t.isIdentifier(n) && facts.reactNames.has(n.name))
|
|
334
|
+
reactRead.add(n.name);
|
|
335
|
+
if (t.isMemberExpression(n) && !n.computed && t.isIdentifier(n.object) && facts.reactNames.has(n.object.name) && t.isIdentifier(n.property))
|
|
336
|
+
reactRead.add(`${n.object.name}.${n.property.name}`);
|
|
337
|
+
for (const key of t.VISITOR_KEYS[n.type] ?? []) {
|
|
338
|
+
if (key === 'typeAnnotation' || key === 'returnType' || key === 'typeParameters' || key === 'typeArguments')
|
|
339
|
+
continue;
|
|
340
|
+
const value = Reflect.get(n, key);
|
|
341
|
+
for (const child of Array.isArray(value) ? value : [value])
|
|
342
|
+
if (t.isNode(child) && !child.type.startsWith('TS'))
|
|
343
|
+
visit(child);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
visit(stmt);
|
|
347
|
+
// the React values it reads, by name (a namespace read by its member: `React.forwardRef`)
|
|
348
|
+
const shown = [...reactRead].filter((n) => ![...reactRead].some((m) => m.startsWith(`${n}.`)));
|
|
349
|
+
const factory = isFunctionDecl(decl) && shown.some((n) => /(^|\.)(forwardRef|memo|use[A-Z]\w*)$/.test(n));
|
|
350
|
+
// Svelte: a render helper is a snippet with a predicate of whether it renders, where it has both (ir/helper-snippets)
|
|
351
|
+
const refused = names.map((n) => facts.snippetRefusals?.get(n)).find((r) => r !== undefined);
|
|
352
|
+
// Angular: a render helper is a function returning template-bank values, where its values can be followed
|
|
353
|
+
const banked = names.map((n) => facts.markupRefusals?.get(n)).find((r) => r !== undefined);
|
|
354
|
+
const why = banked && !factory
|
|
355
|
+
? `Angular would keep it as a function whose elements are values of the file's template bank, but ${banked}`
|
|
356
|
+
: refused && !shown.length
|
|
357
|
+
? `Svelte would declare it as a snippet of the file's main component, with a test of whether it renders, but ${refused}`
|
|
358
|
+
: shown.length
|
|
359
|
+
? `it calls React's ${shown.map((n) => `\`${n}\``).join(', ')} outside a component${factory ? ' (a function that makes components at run time, which a template-based target cannot do: write each component it makes as a component of its own)' : ' (a value made of elements or a test of one, which a template has no value for)'}`
|
|
360
|
+
: t.isExportNamedDeclaration(stmt)
|
|
361
|
+
? 'it is exported, so other files read it as a value, and elements have no value outside a template'
|
|
362
|
+
: 'module code reads it as a value, or it builds elements in statements';
|
|
363
|
+
diag(ctx, 'module-jsx', 'error', `JSX outside a component (${names.join(', ') || 'a module statement'}) is not converted: ${why}.`, original);
|
|
364
|
+
// the names stay declared, so the code that mentions them still compiles; the error above says what is missing
|
|
365
|
+
out.push(...unconvertedStub(stmt));
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
const reactUsed = new Set();
|
|
369
|
+
// F5 (src/fonts): a next/font call whose font files the conversion reaches becomes a generated module's font object
|
|
370
|
+
const fonts = facts.nextFonts.size ? carryNextFonts(stmt, facts.nextFonts, { diagnostics: ctx.diagnostics, sourceFile: ctx.sourceFile, projectRoot: ctx.project.root, outPath: ctx.layoutOf(ctx.sourceFile)?.modulePath ?? ctx.sourceRel, taken: fontNames, project: ctx.project }) : null;
|
|
371
|
+
if (fonts)
|
|
372
|
+
out.push(...fonts.imports);
|
|
373
|
+
stmt = transform(stmt, (n, parent) => {
|
|
374
|
+
if (t.isCallExpression(n) && t.isIdentifier(n.callee) && facts.nextFonts.has(n.callee.name)) {
|
|
375
|
+
const notCarried = fonts?.refused.get(n);
|
|
376
|
+
diag(ctx, 'next-font', 'warning', `next/font ${n.callee.name} becomes a CSS font-family with a generic fallback; the font file is not loaded.${notCarried ? ` Not carried: ${notCarried}.` : ''}`, original);
|
|
377
|
+
return nextFontExpression(facts.nextFonts.get(n.callee.name) ?? '');
|
|
378
|
+
}
|
|
379
|
+
// a React type is not a runtime use: a type reference, a qualified name, or an interface's `extends` clause
|
|
380
|
+
const typeOnly = parent && (t.isTSTypeReference(parent) || t.isTSQualifiedName(parent) || t.isTSExpressionWithTypeArguments(parent) || t.isTSTypeQuery(parent));
|
|
381
|
+
if (t.isIdentifier(n) && facts.reactNames.has(n.name) && parent && !typeOnly && !(t.isMemberExpression(parent) && parent.property === n && !parent.computed)) {
|
|
382
|
+
reactUsed.add(n.name);
|
|
383
|
+
}
|
|
384
|
+
return null;
|
|
385
|
+
});
|
|
386
|
+
stmt = mapReactTypes(stmt, ctx.target, facts.reactNames, typeImports);
|
|
387
|
+
stmt = rewriteImportTypes(stmt, ctx);
|
|
388
|
+
if (reactUsed.size) {
|
|
389
|
+
const names = [...reactUsed].map((n) => `\`${n}\``).join(', ');
|
|
390
|
+
diag(ctx, 'react-runtime', 'error', `Module-level code reads React's ${names} at run time (outside a component or hook), which has no counterpart in ${ctx.target === 'vue' ? 'Vue' : ctx.target === 'svelte' ? 'Svelte' : 'Angular'}.`, original);
|
|
391
|
+
}
|
|
392
|
+
out.push(stmt);
|
|
393
|
+
}
|
|
394
|
+
return out;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* A stand-in for a module-level declaration built from markup: same names (and export), a function where the original
|
|
398
|
+
* was one, returning nothing, with a comment saying it was not converted.
|
|
399
|
+
*/
|
|
400
|
+
function unconvertedStub(stmt) {
|
|
401
|
+
const exported = t.isExportNamedDeclaration(stmt);
|
|
402
|
+
const decl = t.isExportNamedDeclaration(stmt) ? stmt.declaration : stmt;
|
|
403
|
+
if (!decl)
|
|
404
|
+
return [];
|
|
405
|
+
const isFunction = t.isFunctionDeclaration(decl) || (t.isVariableDeclaration(decl) && decl.declarations.every((d) => t.isArrowFunctionExpression(d.init) || t.isFunctionExpression(d.init)));
|
|
406
|
+
// a generic function keeps its type parameters, so a call that passes type arguments (`make<number>(…)`) still compiles
|
|
407
|
+
const typeParams = (name) => {
|
|
408
|
+
if (t.isFunctionDeclaration(decl) && t.isTSTypeParameterDeclaration(decl.typeParameters))
|
|
409
|
+
return decl.typeParameters;
|
|
410
|
+
if (!t.isVariableDeclaration(decl))
|
|
411
|
+
return null;
|
|
412
|
+
const init = decl.declarations.find((d) => t.isIdentifier(d.id, { name }))?.init;
|
|
413
|
+
return (t.isArrowFunctionExpression(init) || t.isFunctionExpression(init)) && t.isTSTypeParameterDeclaration(init.typeParameters) ? init.typeParameters : null;
|
|
414
|
+
};
|
|
415
|
+
const out = [];
|
|
416
|
+
for (const name of Object.keys(t.getOuterBindingIdentifiers(decl))) {
|
|
417
|
+
const rest = t.restElement(t.identifier('_args'));
|
|
418
|
+
rest.typeAnnotation = t.tsTypeAnnotation(t.tsArrayType(t.tsUnknownKeyword()));
|
|
419
|
+
const id = t.identifier(name);
|
|
420
|
+
id.typeAnnotation = t.tsTypeAnnotation(t.tsAnyKeyword());
|
|
421
|
+
const value = isFunction ? t.arrowFunctionExpression([rest], t.nullLiteral()) : t.nullLiteral();
|
|
422
|
+
const generic = isFunction ? typeParams(name) : null;
|
|
423
|
+
// names only: a bound or default may name types the stub no longer imports
|
|
424
|
+
if (t.isArrowFunctionExpression(value) && generic)
|
|
425
|
+
value.typeParameters = t.tsTypeParameterDeclaration(generic.params.map((p) => t.tsTypeParameter(null, null, p.name)));
|
|
426
|
+
const declaration = t.variableDeclaration('const', [t.variableDeclarator(isFunction ? t.identifier(name) : id, value)]);
|
|
427
|
+
const statement = exported ? t.exportNamedDeclaration(declaration) : declaration;
|
|
428
|
+
t.addComment(statement, 'leading', ` antheo-morph: not converted: ${name} builds elements outside a component `, false);
|
|
429
|
+
out.push(statement);
|
|
430
|
+
}
|
|
431
|
+
return out;
|
|
432
|
+
}
|
|
433
|
+
/** `import('@/x/types').Size` in a type: the path to that file's output, as for any import. */
|
|
434
|
+
export function rewriteImportTypes(node, ctx) {
|
|
435
|
+
return transform(node, (n) => {
|
|
436
|
+
if (!t.isTSImportType(n) || !t.isStringLiteral(n.argument))
|
|
437
|
+
return null;
|
|
438
|
+
const resolved = resolveLocal(ctx.sourceFile, n.argument.value, ctx.project);
|
|
439
|
+
const layout = resolved ? ctx.layoutOf(resolved) : null;
|
|
440
|
+
if (!layout)
|
|
441
|
+
return null;
|
|
442
|
+
n.argument = t.stringLiteral(importPath(ctx.layoutOf(ctx.sourceFile)?.modulePath ?? ctx.sourceRel, layout.modulePath));
|
|
443
|
+
return null;
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
/** Names an AST uses as identifiers (over-approximate: property keys count), for trimming unused imports. */
|
|
447
|
+
export function namesIn(nodes, into = new Set()) {
|
|
448
|
+
for (const node of nodes) {
|
|
449
|
+
t.traverseFast(node, (n) => {
|
|
450
|
+
if (t.isIdentifier(n) || t.isJSXIdentifier(n))
|
|
451
|
+
into.add(n.name);
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
return into;
|
|
455
|
+
}
|
|
456
|
+
/** Whether a type names only the file's own types, keywords and literals (`SortKey`, `'a' | 'b'`, `Item[]`). */
|
|
457
|
+
export function ownTypeOnly(type, own) {
|
|
458
|
+
let ok = true;
|
|
459
|
+
t.traverseFast(type, (n) => {
|
|
460
|
+
if (!ok || !t.isNode(n) || !n.type.startsWith('TS'))
|
|
461
|
+
return;
|
|
462
|
+
if (t.isTSTypeReference(n))
|
|
463
|
+
ok = t.isIdentifier(n.typeName) && !n.typeParameters && !!own?.has(n.typeName.name);
|
|
464
|
+
else if (!(t.isTSUnionType(n) || t.isTSArrayType(n) || t.isTSParenthesizedType(n) || t.isTSLiteralType(n) || t.isTSStringKeyword(n) || t.isTSNumberKeyword(n) || t.isTSBooleanKeyword(n) || t.isTSNullKeyword(n) || t.isTSUndefinedKeyword(n)))
|
|
465
|
+
ok = false;
|
|
466
|
+
});
|
|
467
|
+
return ok;
|
|
468
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import type { FunctionIR } from '../../ir/model.js';
|
|
3
|
+
/**
|
|
4
|
+
* Framer Motion's DOM hooks as the framework-free `motion` package writes them (the plan; each target emits it):
|
|
5
|
+
* - `useInView(ref, { root, margin, amount, once, initial })`: a value set by `inView` as Framer sets its state: true on
|
|
6
|
+
* enter, false on leave unless `once`;
|
|
7
|
+
* - `useScroll({ target, container, offset, axis })`: the scroll values it returns (`scrollYProgress`, …) are
|
|
8
|
+
* `motionValue`s set from `scroll`'s info, as Framer sets them.
|
|
9
|
+
* Options with no counterpart in these functions keep the hook refused, with the option named.
|
|
10
|
+
*/
|
|
11
|
+
export type MotionHookPlan = {
|
|
12
|
+
hook: 'useInView';
|
|
13
|
+
name: string;
|
|
14
|
+
ref: t.Identifier;
|
|
15
|
+
options: Map<string, t.Expression>;
|
|
16
|
+
} | {
|
|
17
|
+
hook: 'useScroll';
|
|
18
|
+
values: Map<string, string>;
|
|
19
|
+
options: Map<string, t.Expression>;
|
|
20
|
+
};
|
|
21
|
+
export declare const SCROLL_VALUES: ReadonlyMap<string, {
|
|
22
|
+
axis: 'x' | 'y';
|
|
23
|
+
field: 'current' | 'progress';
|
|
24
|
+
}>;
|
|
25
|
+
/** Whether a binding holds a motion value from a Framer hook. */
|
|
26
|
+
export declare function isMotionValueBinding(b: {
|
|
27
|
+
kind: string;
|
|
28
|
+
fromHook?: string;
|
|
29
|
+
} | undefined): boolean;
|
|
30
|
+
/** `useMotionTemplate\`…\``: Framer's template tag, under its own name. */
|
|
31
|
+
export declare function isMotionTemplate(e: t.Node): e is t.TaggedTemplateExpression;
|
|
32
|
+
/** Whether `name` is a motion value the component declares: from a Framer hook, or `const bg = useMotionTemplate\`…\``. */
|
|
33
|
+
export declare function holdsMotionValue(fn: FunctionIR, name: string): boolean;
|
|
34
|
+
/** An expression without its TypeScript wrappers (`ref as RefObject<Element>`, `ref!`) and parentheses. */
|
|
35
|
+
export declare function bareExpression(e: t.Expression): t.Expression;
|
|
36
|
+
/** The plan for a Framer hook converted to `motion`; null for another hook; a reason when this one is not converted. */
|
|
37
|
+
export declare function motionHookPlan(hook: string, call: t.CallExpression, id: t.LVal | null): MotionHookPlan | string | null;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
export const SCROLL_VALUES = new Map([
|
|
3
|
+
['scrollX', { axis: 'x', field: 'current' }],
|
|
4
|
+
['scrollY', { axis: 'y', field: 'current' }],
|
|
5
|
+
['scrollXProgress', { axis: 'x', field: 'progress' }],
|
|
6
|
+
['scrollYProgress', { axis: 'y', field: 'progress' }],
|
|
7
|
+
]);
|
|
8
|
+
const IN_VIEW_OPTIONS = new Set(['root', 'margin', 'amount', 'once', 'initial']);
|
|
9
|
+
const SCROLL_OPTIONS = new Set(['target', 'container', 'offset', 'axis']);
|
|
10
|
+
/** The Framer hooks whose results are motion values (a motion element's style takes them as they are). */
|
|
11
|
+
const MOTION_VALUE_HOOKS = new Set(['useMotionValue', 'useSpring', 'useTransform', 'useMotionTemplate', 'useVelocity', 'useTime', 'useScroll']);
|
|
12
|
+
/** Whether a binding holds a motion value from a Framer hook. */
|
|
13
|
+
export function isMotionValueBinding(b) {
|
|
14
|
+
return b?.kind === 'hook' && !!b.fromHook && MOTION_VALUE_HOOKS.has(b.fromHook);
|
|
15
|
+
}
|
|
16
|
+
/** `useMotionTemplate\`…\``: Framer's template tag, under its own name. */
|
|
17
|
+
export function isMotionTemplate(e) {
|
|
18
|
+
return t.isTaggedTemplateExpression(e) && t.isIdentifier(e.tag, { name: 'useMotionTemplate' });
|
|
19
|
+
}
|
|
20
|
+
/** Whether `name` is a motion value the component declares: from a Framer hook, or `const bg = useMotionTemplate\`…\``. */
|
|
21
|
+
export function holdsMotionValue(fn, name) {
|
|
22
|
+
if (isMotionValueBinding(fn.bindings.get(name)))
|
|
23
|
+
return true;
|
|
24
|
+
return fn.items.some((i) => i.kind === 'derived' && t.isIdentifier(i.id, { name }) && isMotionTemplate(i.init));
|
|
25
|
+
}
|
|
26
|
+
/** An expression without its TypeScript wrappers (`ref as RefObject<Element>`, `ref!`) and parentheses. */
|
|
27
|
+
export function bareExpression(e) {
|
|
28
|
+
return t.isTSAsExpression(e) || t.isTSSatisfiesExpression(e) || t.isTSNonNullExpression(e) || t.isParenthesizedExpression(e) ? bareExpression(e.expression) : e;
|
|
29
|
+
}
|
|
30
|
+
/** An options object written out: its members by name, or why it is not one this conversion reads. */
|
|
31
|
+
function optionsOf(arg, allowed, hook) {
|
|
32
|
+
const options = new Map();
|
|
33
|
+
if (!arg)
|
|
34
|
+
return options;
|
|
35
|
+
const obj = t.isExpression(arg) ? bareExpression(arg) : null;
|
|
36
|
+
if (!obj || !t.isObjectExpression(obj))
|
|
37
|
+
return `${hook} is given options that are not an object written out`;
|
|
38
|
+
for (const p of obj.properties) {
|
|
39
|
+
const key = t.isObjectProperty(p) && !p.computed ? (t.isIdentifier(p.key) ? p.key.name : t.isStringLiteral(p.key) ? p.key.value : null) : null;
|
|
40
|
+
if (!t.isObjectProperty(p) || key === null || !t.isExpression(p.value))
|
|
41
|
+
return `${hook} is given options with a spread or computed member`;
|
|
42
|
+
if (!allowed.has(key))
|
|
43
|
+
return `${hook}'s option ${key} has no counterpart in motion's ${hook === 'useInView' ? 'inView' : 'scroll'}`;
|
|
44
|
+
// `{ margin }`: the shorthand's value is the same identifier node as its key; the value is what is read
|
|
45
|
+
options.set(key, p.value);
|
|
46
|
+
}
|
|
47
|
+
return options;
|
|
48
|
+
}
|
|
49
|
+
/** The plan for a Framer hook converted to `motion`; null for another hook; a reason when this one is not converted. */
|
|
50
|
+
export function motionHookPlan(hook, call, id) {
|
|
51
|
+
if (hook === 'useInView') {
|
|
52
|
+
if (!id || !t.isIdentifier(id))
|
|
53
|
+
return 'useInView\'s value is not kept in one name';
|
|
54
|
+
const ref = call.arguments[0];
|
|
55
|
+
const bare = ref && t.isExpression(ref) ? bareExpression(ref) : null;
|
|
56
|
+
if (!bare || !t.isIdentifier(bare))
|
|
57
|
+
return 'useInView is not given a ref by name';
|
|
58
|
+
const options = optionsOf(call.arguments[1], IN_VIEW_OPTIONS, hook);
|
|
59
|
+
if (typeof options === 'string')
|
|
60
|
+
return options;
|
|
61
|
+
const root = options.get('root');
|
|
62
|
+
if (root && !t.isIdentifier(bareExpression(root)))
|
|
63
|
+
return 'useInView\'s root is not a ref by name';
|
|
64
|
+
return { hook, name: id.name, ref: bare, options };
|
|
65
|
+
}
|
|
66
|
+
if (hook === 'useScroll') {
|
|
67
|
+
if (!id || !t.isObjectPattern(id))
|
|
68
|
+
return 'useScroll\'s values are not taken out by name (`const { scrollYProgress } = useScroll()`)';
|
|
69
|
+
const values = new Map();
|
|
70
|
+
for (const p of id.properties) {
|
|
71
|
+
const key = t.isObjectProperty(p) && !p.computed && t.isIdentifier(p.key) ? p.key.name : null;
|
|
72
|
+
if (!t.isObjectProperty(p) || !key || !SCROLL_VALUES.has(key) || !t.isIdentifier(p.value))
|
|
73
|
+
return 'useScroll\'s values are taken out with a rest, a default or a name it does not return';
|
|
74
|
+
values.set(key, p.value.name);
|
|
75
|
+
}
|
|
76
|
+
const options = optionsOf(call.arguments[0], SCROLL_OPTIONS, hook);
|
|
77
|
+
if (typeof options === 'string')
|
|
78
|
+
return options;
|
|
79
|
+
for (const key of ['target', 'container']) {
|
|
80
|
+
const ref = options.get(key);
|
|
81
|
+
if (ref && !t.isIdentifier(bareExpression(ref)))
|
|
82
|
+
return `useScroll's ${key} is not a ref by name`;
|
|
83
|
+
}
|
|
84
|
+
return { hook, values, options };
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|