@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,293 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
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
|
+
function bare(e) {
|
|
11
|
+
return t.isTSAsExpression(e) || t.isTSSatisfiesExpression(e) || t.isTSNonNullExpression(e) || t.isParenthesizedExpression(e) ? bare(e.expression) : e;
|
|
12
|
+
}
|
|
13
|
+
/** An options object written out: its members by name, or why it is not one this conversion reads. */
|
|
14
|
+
function optionsOf(arg, allowed, hook) {
|
|
15
|
+
const options = new Map();
|
|
16
|
+
if (!arg)
|
|
17
|
+
return options;
|
|
18
|
+
const obj = t.isExpression(arg) ? bare(arg) : null;
|
|
19
|
+
if (!obj || !t.isObjectExpression(obj))
|
|
20
|
+
return `${hook} is given options that are not an object written out`;
|
|
21
|
+
for (const p of obj.properties) {
|
|
22
|
+
const key = t.isObjectProperty(p) && !p.computed ? (t.isIdentifier(p.key) ? p.key.name : t.isStringLiteral(p.key) ? p.key.value : null) : null;
|
|
23
|
+
if (!t.isObjectProperty(p) || key === null || !t.isExpression(p.value))
|
|
24
|
+
return `${hook} is given options with a spread or computed member`;
|
|
25
|
+
if (!allowed.has(key))
|
|
26
|
+
return `${hook}'s option ${key} has no counterpart in motion's ${hook === 'useInView' ? 'inView' : 'scroll'}`;
|
|
27
|
+
options.set(key, p.value);
|
|
28
|
+
}
|
|
29
|
+
return options;
|
|
30
|
+
}
|
|
31
|
+
/** The plan for a Framer hook converted here; null for another hook; a reason when this one is not converted. */
|
|
32
|
+
export function motionHookPlan(hook, call, id) {
|
|
33
|
+
if (hook === 'useInView') {
|
|
34
|
+
if (!id || !t.isIdentifier(id))
|
|
35
|
+
return 'useInView\'s value is not kept in one name';
|
|
36
|
+
const ref = call.arguments[0];
|
|
37
|
+
if (!ref || !t.isExpression(ref) || !t.isIdentifier(bare(ref)))
|
|
38
|
+
return 'useInView is not given a ref by name';
|
|
39
|
+
const options = optionsOf(call.arguments[1], IN_VIEW_OPTIONS, hook);
|
|
40
|
+
if (typeof options === 'string')
|
|
41
|
+
return options;
|
|
42
|
+
const root = options.get('root');
|
|
43
|
+
if (root && !t.isIdentifier(bare(root)))
|
|
44
|
+
return 'useInView\'s root is not a ref by name';
|
|
45
|
+
// (a first value read from the inputs would be read before Angular sets them)
|
|
46
|
+
const initial = options.get('initial');
|
|
47
|
+
if (initial && !t.isBooleanLiteral(bare(initial)))
|
|
48
|
+
return 'useInView\'s initial is not written as true or false';
|
|
49
|
+
return { hook, name: id.name, ref: bare(ref), options };
|
|
50
|
+
}
|
|
51
|
+
if (hook === 'useScroll') {
|
|
52
|
+
if (!id || !t.isObjectPattern(id))
|
|
53
|
+
return 'useScroll\'s values are not taken out by name (`const { scrollYProgress } = useScroll()`)';
|
|
54
|
+
const values = new Map();
|
|
55
|
+
for (const p of id.properties) {
|
|
56
|
+
const key = t.isObjectProperty(p) && !p.computed && t.isIdentifier(p.key) ? p.key.name : null;
|
|
57
|
+
if (!t.isObjectProperty(p) || !key || !SCROLL_VALUES.has(key) || !t.isIdentifier(p.value))
|
|
58
|
+
return 'useScroll\'s values are taken out with a rest, a default or a name it does not return';
|
|
59
|
+
values.set(key, p.value.name);
|
|
60
|
+
}
|
|
61
|
+
const options = optionsOf(call.arguments[0], SCROLL_OPTIONS, hook);
|
|
62
|
+
if (typeof options === 'string')
|
|
63
|
+
return options;
|
|
64
|
+
for (const key of ['target', 'container']) {
|
|
65
|
+
const ref = options.get(key);
|
|
66
|
+
if (ref && !t.isIdentifier(bare(ref)))
|
|
67
|
+
return `useScroll's ${key} is not a ref by name`;
|
|
68
|
+
}
|
|
69
|
+
return { hook, values, options };
|
|
70
|
+
}
|
|
71
|
+
if (hook === 'useVelocity') {
|
|
72
|
+
if (!id || !t.isIdentifier(id))
|
|
73
|
+
return 'useVelocity\'s value is not kept in one name';
|
|
74
|
+
const source = call.arguments[0];
|
|
75
|
+
if (!source || !t.isExpression(source) || !t.isIdentifier(bare(source)) || call.arguments.length > 1)
|
|
76
|
+
return 'useVelocity is not given one motion value by name';
|
|
77
|
+
return { hook, name: id.name, source: bare(source) };
|
|
78
|
+
}
|
|
79
|
+
if (hook === 'useAnimationFrame') {
|
|
80
|
+
// (Framer's hook returns nothing)
|
|
81
|
+
if (id)
|
|
82
|
+
return 'useAnimationFrame returns nothing to keep';
|
|
83
|
+
const callback = call.arguments[0];
|
|
84
|
+
if (!callback || !t.isExpression(callback) || call.arguments.length > 1)
|
|
85
|
+
return 'useAnimationFrame is not given one callback';
|
|
86
|
+
return { hook, callback };
|
|
87
|
+
}
|
|
88
|
+
if (hook === 'useAnimate') {
|
|
89
|
+
if (call.arguments.length)
|
|
90
|
+
return 'useAnimate is given arguments, which Framer\'s takes none of';
|
|
91
|
+
if (!id || !t.isArrayPattern(id) || id.elements.length > 2 || id.elements.some((e) => e !== null && !t.isIdentifier(e)))
|
|
92
|
+
return 'useAnimate\'s scope and animate are not taken out by name (`const [scope, animate] = useAnimate()`)';
|
|
93
|
+
const [scope, animate] = id.elements;
|
|
94
|
+
return { hook, scope: t.isIdentifier(scope) ? scope.name : null, animate: t.isIdentifier(animate) ? animate.name : null };
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
/** The element a ref holds, or undefined (`ref.current ?? undefined`), as class code. */
|
|
99
|
+
function element(ref, scope) {
|
|
100
|
+
const read = scope.rewrite(t.memberExpression(ref, t.identifier('current')));
|
|
101
|
+
// (a query read `el()?.nativeElement ?? null` gives undefined in place of its null)
|
|
102
|
+
if (t.isLogicalExpression(read, { operator: '??' }) && t.isNullLiteral(read.right))
|
|
103
|
+
return t.logicalExpression('??', read.left, t.identifier('undefined'));
|
|
104
|
+
return t.logicalExpression('??', read, t.identifier('undefined'));
|
|
105
|
+
}
|
|
106
|
+
/** `afterRenderEffect((onCleanup) => { … onCleanup(stop) })`. */
|
|
107
|
+
function effectWith(statements, scope) {
|
|
108
|
+
return t.expressionStatement(t.callExpression(t.identifier(scope.api('afterRenderEffect')), [t.arrowFunctionExpression([t.identifier('onCleanup')], t.blockStatement(statements))]));
|
|
109
|
+
}
|
|
110
|
+
/** The member a plan declares: the value it starts with. */
|
|
111
|
+
export function hookMembers(plan, scope) {
|
|
112
|
+
if (plan.hook === 'useInView') {
|
|
113
|
+
const initial = plan.options.get('initial');
|
|
114
|
+
return [{ name: plan.name, value: t.callExpression(t.identifier(scope.api('signal')), [initial ? scope.rewrite(initial) : t.booleanLiteral(false)]), signal: true }];
|
|
115
|
+
}
|
|
116
|
+
if (plan.hook === 'useAnimationFrame')
|
|
117
|
+
return [];
|
|
118
|
+
if (plan.hook === 'useAnimate') {
|
|
119
|
+
// Framer: `const scope = { current: null, animations: [] }; const animate = createScopedAnimate({ scope })`
|
|
120
|
+
scope.motion('createScopedAnimate');
|
|
121
|
+
scope.motionType('AnimationPlaybackControls');
|
|
122
|
+
const holder = scope.alloc(plan.scope ? `${plan.scope}Animations` : 'animationScope');
|
|
123
|
+
plan.holder = holder;
|
|
124
|
+
const members = [];
|
|
125
|
+
if (plan.scope) {
|
|
126
|
+
const query = t.callExpression(t.identifier(scope.api('viewChild')), [t.stringLiteral(plan.scope)]);
|
|
127
|
+
query.typeParameters = t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(scope.api('ElementRef')), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier('HTMLElement'))]))]);
|
|
128
|
+
members.push({ name: plan.scope, value: query, signal: false, query: true });
|
|
129
|
+
}
|
|
130
|
+
const type = t.tsTypeLiteral([
|
|
131
|
+
t.tsPropertySignature(t.identifier('current'), t.tsTypeAnnotation(t.tsUnionType([t.tsTypeReference(t.identifier('HTMLElement')), t.tsUndefinedKeyword()]))),
|
|
132
|
+
t.tsPropertySignature(t.identifier('animations'), t.tsTypeAnnotation(t.tsArrayType(t.tsTypeReference(t.identifier('AnimationPlaybackControls'))))),
|
|
133
|
+
]);
|
|
134
|
+
const value = t.objectExpression([t.objectProperty(t.identifier('current'), t.identifier('undefined')), t.objectProperty(t.identifier('animations'), t.arrayExpression([]))]);
|
|
135
|
+
members.push({ name: holder, value, signal: false, type });
|
|
136
|
+
if (plan.animate)
|
|
137
|
+
members.push({ name: plan.animate, value: t.callExpression(t.identifier('createScopedAnimate'), [t.objectExpression([t.objectProperty(t.identifier('scope'), scope.member(holder))])]), signal: false });
|
|
138
|
+
return members;
|
|
139
|
+
}
|
|
140
|
+
scope.motion('motionValue');
|
|
141
|
+
// Framer: `useMotionValue(value.getVelocity())`
|
|
142
|
+
if (plan.hook === 'useVelocity')
|
|
143
|
+
return [{ name: plan.name, value: t.callExpression(t.identifier('motionValue'), [t.callExpression(t.memberExpression(scope.rewrite(plan.source), t.identifier('getVelocity')), [])]), signal: false }];
|
|
144
|
+
return [...plan.values.values()].map((name) => ({ name, value: t.callExpression(t.identifier('motionValue'), [t.numericLiteral(0)]), signal: false }));
|
|
145
|
+
}
|
|
146
|
+
/** The constructor statements that start what a plan watches. */
|
|
147
|
+
export function hookEffects(plan, scope) {
|
|
148
|
+
if (plan.hook === 'useAnimate')
|
|
149
|
+
return animateEffects(plan, scope);
|
|
150
|
+
return [hookEffect(plan, scope)];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* useAnimate: the scope's element set after each render (`current`), the animations stopped on destroy (Framer's
|
|
154
|
+
* unmount effect: `scope.animations.forEach((animation) => animation.stop())`).
|
|
155
|
+
*/
|
|
156
|
+
function animateEffects(plan, scope) {
|
|
157
|
+
const holder = scope.member(plan.holder ?? 'animationScope');
|
|
158
|
+
const out = [];
|
|
159
|
+
if (plan.scope) {
|
|
160
|
+
const element = t.optionalMemberExpression(t.callExpression(scope.member(plan.scope), []), t.identifier('nativeElement'), false, true);
|
|
161
|
+
const setCurrent = t.assignmentExpression('=', t.memberExpression(holder, t.identifier('current')), element);
|
|
162
|
+
out.push(t.expressionStatement(t.callExpression(t.identifier(scope.api('afterRenderEffect')), [t.arrowFunctionExpression([], t.blockStatement([t.expressionStatement(setCurrent)]))])));
|
|
163
|
+
}
|
|
164
|
+
const animation = t.identifier('animation');
|
|
165
|
+
const stopAll = t.blockStatement([
|
|
166
|
+
t.forOfStatement(t.variableDeclaration('const', [t.variableDeclarator(animation)]), t.memberExpression(t.cloneNode(holder, true), t.identifier('animations')), t.expressionStatement(t.callExpression(t.memberExpression(animation, t.identifier('stop')), []))),
|
|
167
|
+
t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.memberExpression(t.cloneNode(holder, true), t.identifier('animations')), t.identifier('length')), t.numericLiteral(0))),
|
|
168
|
+
]);
|
|
169
|
+
const destroyRef = t.callExpression(t.identifier(scope.api('inject')), [t.identifier(scope.api('DestroyRef'))]);
|
|
170
|
+
out.push(t.expressionStatement(t.callExpression(t.memberExpression(destroyRef, t.identifier('onDestroy')), [t.arrowFunctionExpression([], stopAll)])));
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
function hookEffect(plan, scope) {
|
|
174
|
+
if (plan.hook === 'useInView') {
|
|
175
|
+
scope.motion('inView');
|
|
176
|
+
const set = (value) => t.callExpression(t.memberExpression(scope.member(plan.name), t.identifier('set')), [t.booleanLiteral(value)]);
|
|
177
|
+
const once = plan.options.get('once');
|
|
178
|
+
const leave = t.arrowFunctionExpression([], set(false));
|
|
179
|
+
// Framer: `setInView(true); return once ? undefined : () => setInView(false)`
|
|
180
|
+
const after = once && t.isBooleanLiteral(bare(once), { value: true }) ? [] : [t.returnStatement(once && !t.isBooleanLiteral(bare(once), { value: false }) ? t.conditionalExpression(scope.rewrite(once), t.identifier('undefined'), leave) : leave)];
|
|
181
|
+
const enter = t.arrowFunctionExpression([], t.blockStatement([t.expressionStatement(set(true)), ...after]));
|
|
182
|
+
const options = [];
|
|
183
|
+
const root = plan.options.get('root');
|
|
184
|
+
if (root)
|
|
185
|
+
options.push(t.objectProperty(t.identifier('root'), element(bare(root), scope)));
|
|
186
|
+
for (const key of ['margin', 'amount']) {
|
|
187
|
+
const value = plan.options.get(key);
|
|
188
|
+
if (value)
|
|
189
|
+
options.push(t.objectProperty(t.identifier(key), scope.rewrite(value)));
|
|
190
|
+
}
|
|
191
|
+
const target = t.identifier('element');
|
|
192
|
+
const watch = t.callExpression(t.identifier('inView'), [target, enter, ...(options.length ? [t.objectExpression(options)] : [])]);
|
|
193
|
+
return effectWith([
|
|
194
|
+
t.variableDeclaration('const', [t.variableDeclarator(target, scope.rewrite(t.memberExpression(plan.ref, t.identifier('current'))))]),
|
|
195
|
+
t.ifStatement(t.unaryExpression('!', target), t.returnStatement()),
|
|
196
|
+
t.expressionStatement(t.callExpression(t.identifier('onCleanup'), [watch])),
|
|
197
|
+
], scope);
|
|
198
|
+
}
|
|
199
|
+
if (plan.hook === 'useVelocity')
|
|
200
|
+
return velocityEffect(plan.name, plan.source, scope);
|
|
201
|
+
if (plan.hook === 'useAnimationFrame')
|
|
202
|
+
return frameEffect(plan.callback, scope);
|
|
203
|
+
scope.motion('scroll');
|
|
204
|
+
// Framer: `scroll((_progress, { x, y }) => { scrollX.set(x.current); … })`, the values the component takes out
|
|
205
|
+
const axes = [...new Set([...plan.values.keys()].map((k) => SCROLL_VALUES.get(k)?.axis ?? 'y'))].sort();
|
|
206
|
+
const info = t.objectPattern(axes.map((a) => t.objectProperty(t.identifier(a), t.identifier(a), false, true)));
|
|
207
|
+
const sets = [...plan.values].map(([key, name]) => {
|
|
208
|
+
const how = SCROLL_VALUES.get(key);
|
|
209
|
+
return t.expressionStatement(t.callExpression(t.memberExpression(scope.member(name), t.identifier('set')), [t.memberExpression(t.identifier(how?.axis ?? 'y'), t.identifier(how?.field ?? 'progress'))]));
|
|
210
|
+
});
|
|
211
|
+
const options = [];
|
|
212
|
+
for (const key of ['target', 'container']) {
|
|
213
|
+
const ref = plan.options.get(key);
|
|
214
|
+
if (ref)
|
|
215
|
+
options.push(t.objectProperty(t.identifier(key), element(bare(ref), scope)));
|
|
216
|
+
}
|
|
217
|
+
for (const key of ['offset', 'axis']) {
|
|
218
|
+
const value = plan.options.get(key);
|
|
219
|
+
if (value)
|
|
220
|
+
options.push(t.objectProperty(t.identifier(key), scope.rewrite(value)));
|
|
221
|
+
}
|
|
222
|
+
const onScroll = t.arrowFunctionExpression([t.identifier('_progress'), info], t.blockStatement(sets));
|
|
223
|
+
return effectWith([t.expressionStatement(t.callExpression(t.identifier('onCleanup'), [t.callExpression(t.identifier('scroll'), [onScroll, ...(options.length ? [t.objectExpression(options)] : [])])]))], scope);
|
|
224
|
+
}
|
|
225
|
+
/** A local name the given code does not read (the effect's own locals must not hide a name the code means). */
|
|
226
|
+
function fresh(base, code) {
|
|
227
|
+
const taken = new Set();
|
|
228
|
+
for (const node of code)
|
|
229
|
+
t.traverseFast(node, (x) => void (t.isIdentifier(x) && taken.add(x.name)));
|
|
230
|
+
let name = base;
|
|
231
|
+
for (let i = 2; taken.has(name); i++)
|
|
232
|
+
name = `${base}${i}`;
|
|
233
|
+
return name;
|
|
234
|
+
}
|
|
235
|
+
const call = (callee, args) => t.callExpression(callee, args);
|
|
236
|
+
const frameUpdate = (args) => call(t.memberExpression(t.identifier('frame'), t.identifier('update')), args);
|
|
237
|
+
/**
|
|
238
|
+
* Framer's useVelocity: `const update = () => { const latest = value.getVelocity(); velocity.set(latest); if (latest)
|
|
239
|
+
* frame.update(update) }`, scheduled at the end of the frame on every change of the value.
|
|
240
|
+
*/
|
|
241
|
+
function velocityEffect(name, source, scope) {
|
|
242
|
+
scope.motion('frame');
|
|
243
|
+
scope.motion('cancelFrame');
|
|
244
|
+
const value = scope.rewrite(source);
|
|
245
|
+
const velocity = scope.member(name);
|
|
246
|
+
const update = t.identifier(fresh('update', [value]));
|
|
247
|
+
const latest = t.identifier(fresh('latest', [value]));
|
|
248
|
+
const stop = t.identifier(fresh('stop', [value]));
|
|
249
|
+
const body = t.blockStatement([
|
|
250
|
+
t.variableDeclaration('const', [t.variableDeclarator(latest, call(t.memberExpression(t.cloneNode(value, true), t.identifier('getVelocity')), []))]),
|
|
251
|
+
t.expressionStatement(call(t.memberExpression(velocity, t.identifier('set')), [latest])),
|
|
252
|
+
t.ifStatement(latest, t.expressionStatement(frameUpdate([update]))),
|
|
253
|
+
]);
|
|
254
|
+
const onChange = t.arrowFunctionExpression([], t.blockStatement([t.expressionStatement(frameUpdate([update, t.booleanLiteral(false), t.booleanLiteral(true)]))]));
|
|
255
|
+
return effectWith([
|
|
256
|
+
t.variableDeclaration('const', [t.variableDeclarator(update, Object.assign(t.arrowFunctionExpression([], body), { returnType: t.tsTypeAnnotation(t.tsVoidKeyword()) }))]),
|
|
257
|
+
t.variableDeclaration('const', [t.variableDeclarator(stop, call(t.memberExpression(t.cloneNode(value, true), t.identifier('on')), [t.stringLiteral('change'), onChange]))]),
|
|
258
|
+
t.expressionStatement(call(t.identifier('onCleanup'), [t.arrowFunctionExpression([], t.blockStatement([t.expressionStatement(call(stop, [])), t.expressionStatement(call(t.identifier('cancelFrame'), [update]))]))])),
|
|
259
|
+
], scope);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Framer's useAnimationFrame: the callback on each frame's update step, given the time since the first frame and the
|
|
263
|
+
* frame's delta (`frame.update(provideTimeSinceStart, true)`, `cancelFrame` on cleanup).
|
|
264
|
+
*/
|
|
265
|
+
function frameEffect(callback, scope) {
|
|
266
|
+
scope.motion('frame');
|
|
267
|
+
scope.motion('cancelFrame');
|
|
268
|
+
scope.motionType('FrameData');
|
|
269
|
+
let fn = scope.rewrite(callback);
|
|
270
|
+
// Framer types the parameters (time, delta) as numbers: written out where the source leaves them to inference
|
|
271
|
+
if (t.isArrowFunctionExpression(fn) || t.isFunctionExpression(fn)) {
|
|
272
|
+
fn = t.cloneNode(fn, true);
|
|
273
|
+
for (const p of fn.params)
|
|
274
|
+
if (t.isIdentifier(p) && !p.typeAnnotation)
|
|
275
|
+
p.typeAnnotation = t.tsTypeAnnotation(t.tsNumberKeyword());
|
|
276
|
+
}
|
|
277
|
+
const named = t.identifier(fresh('callback', [fn]));
|
|
278
|
+
const start = t.identifier(fresh('start', [fn]));
|
|
279
|
+
const tick = t.identifier(fresh('tick', [fn]));
|
|
280
|
+
const data = t.objectPattern([t.objectProperty(t.identifier('timestamp'), t.identifier('timestamp'), false, true), t.objectProperty(t.identifier('delta'), t.identifier('delta'), false, true)]);
|
|
281
|
+
data.typeAnnotation = t.tsTypeAnnotation(t.tsTypeReference(t.identifier('FrameData')));
|
|
282
|
+
const tickBody = t.blockStatement([
|
|
283
|
+
t.ifStatement(t.unaryExpression('!', start), t.expressionStatement(t.assignmentExpression('=', start, t.identifier('timestamp')))),
|
|
284
|
+
t.expressionStatement(call(named, [t.binaryExpression('-', t.identifier('timestamp'), start), t.identifier('delta')])),
|
|
285
|
+
]);
|
|
286
|
+
return effectWith([
|
|
287
|
+
t.variableDeclaration('const', [t.variableDeclarator(named, fn)]),
|
|
288
|
+
t.variableDeclaration('let', [t.variableDeclarator(start, t.numericLiteral(0))]),
|
|
289
|
+
t.variableDeclaration('const', [t.variableDeclarator(tick, Object.assign(t.arrowFunctionExpression([data], tickBody), { returnType: t.tsTypeAnnotation(t.tsVoidKeyword()) }))]),
|
|
290
|
+
t.expressionStatement(frameUpdate([tick, t.booleanLiteral(true)])),
|
|
291
|
+
t.expressionStatement(call(t.identifier('onCleanup'), [t.arrowFunctionExpression([], call(t.identifier('cancelFrame'), [tick]))])),
|
|
292
|
+
], scope);
|
|
293
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framer Motion's `layout`, `layoutId` and `drag` on Angular: two directives the output brings along (see helpers.ts),
|
|
3
|
+
* each in a file of its own written only when a component uses it, over the framework-free `motion` package's own
|
|
4
|
+
* engines (animateLayout and drag, the ones React's motion components use). The code shared with the Svelte target
|
|
5
|
+
* comes from ../shared/motion-layout.ts.
|
|
6
|
+
*/
|
|
7
|
+
/** The layout directive's class name, as a component's `imports` list it. */
|
|
8
|
+
export declare const MOTION_LAYOUT = "MotionLayout";
|
|
9
|
+
/** The drag directive's class name. */
|
|
10
|
+
export declare const MOTION_DRAG = "MotionDrag";
|
|
11
|
+
/** The layout directive's file. */
|
|
12
|
+
export declare const MOTION_LAYOUT_FILE: string;
|
|
13
|
+
/** The drag directive's file. */
|
|
14
|
+
export declare const MOTION_DRAG_FILE: string;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { NEVER_REDUCE_SOURCE, dragCoreSource, layoutCoreSource, layoutPropsTypes } from '../shared/motion-layout.js';
|
|
2
|
+
/**
|
|
3
|
+
* Framer Motion's `layout`, `layoutId` and `drag` on Angular: two directives the output brings along (see helpers.ts),
|
|
4
|
+
* each in a file of its own written only when a component uses it, over the framework-free `motion` package's own
|
|
5
|
+
* engines (animateLayout and drag, the ones React's motion components use). The code shared with the Svelte target
|
|
6
|
+
* comes from ../shared/motion-layout.ts.
|
|
7
|
+
*/
|
|
8
|
+
/** The layout directive's class name, as a component's `imports` list it. */
|
|
9
|
+
export const MOTION_LAYOUT = 'MotionLayout';
|
|
10
|
+
/** The drag directive's class name. */
|
|
11
|
+
export const MOTION_DRAG = 'MotionDrag';
|
|
12
|
+
/** The layout directive's file. */
|
|
13
|
+
export const MOTION_LAYOUT_FILE = `/**
|
|
14
|
+
* Framer Motion's layout animations (\`layout\`, \`layoutId\`) on Angular, with the framework-free \`motion\` package's
|
|
15
|
+
* animateLayout (the projection React's motion components animate layout with): every layout element is measured before
|
|
16
|
+
* an event's handlers run, the updates they make are applied, then motion animates each element from its old box.
|
|
17
|
+
*/
|
|
18
|
+
import { ApplicationRef, DestroyRef, Directive, effect, ElementRef, inject, input } from '@angular/core';
|
|
19
|
+
import { animateLayout, flushLayoutSnapshots, hasReducedMotionListener, visualElementStore } from 'motion';
|
|
20
|
+
import type { LayoutAnimationBuilder, Transition } from 'motion';
|
|
21
|
+
|
|
22
|
+
${layoutPropsTypes(new Set(['layout']))}${NEVER_REDUCE_SOURCE}
|
|
23
|
+
/** The application each layout element renders in: an event's updates are applied by ticking it. */
|
|
24
|
+
const layoutApps = new Map<HTMLElement, ApplicationRef>();
|
|
25
|
+
${layoutCoreSource('for (const app of new Set(layoutApps.values())) app.tick();')}
|
|
26
|
+
/** \`[motionLayout]\`: an element with React's \`layout\` or \`layoutId\` (and the element's \`transition\`). */
|
|
27
|
+
@Directive({ selector: '[motionLayout]' })
|
|
28
|
+
export class MotionLayout {
|
|
29
|
+
readonly motionLayout = input.required<LayoutProps>();
|
|
30
|
+
|
|
31
|
+
constructor() {
|
|
32
|
+
const element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
|
|
33
|
+
const app = inject(ApplicationRef);
|
|
34
|
+
let added = false;
|
|
35
|
+
// in the change detection that creates the element: marked before the update that added it ends
|
|
36
|
+
effect(() => {
|
|
37
|
+
const props = this.motionLayout();
|
|
38
|
+
if (added) return markLayout(element, props);
|
|
39
|
+
added = true;
|
|
40
|
+
layoutApps.set(element, app);
|
|
41
|
+
addLayout(element, props);
|
|
42
|
+
});
|
|
43
|
+
inject(DestroyRef).onDestroy(() => {
|
|
44
|
+
layoutApps.delete(element);
|
|
45
|
+
if (added) removeLayout(element);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
/** The drag directive's file. */
|
|
51
|
+
export const MOTION_DRAG_FILE = `/**
|
|
52
|
+
* Framer Motion's drag gesture (\`drag\` and its props) on Angular, with the framework-free \`motion\` package's drag
|
|
53
|
+
* (React's drag controls): its options read once, its callbacks live.
|
|
54
|
+
*/
|
|
55
|
+
import { afterNextRender, DestroyRef, Directive, ElementRef, inject, input } from '@angular/core';
|
|
56
|
+
import { animate, drag, hasReducedMotionListener } from 'motion';
|
|
57
|
+
import type { AnimationPlaybackControls, DragHandler, DragOptions, TargetAndTransition } from 'motion';
|
|
58
|
+
|
|
59
|
+
${layoutPropsTypes(new Set(['drag', 'whileDrag']))}${NEVER_REDUCE_SOURCE}${dragCoreSource(true)}
|
|
60
|
+
/** \`[motionDrag]\`: an element with React's \`drag\`. */
|
|
61
|
+
@Directive({ selector: '[motionDrag]' })
|
|
62
|
+
export class MotionDrag {
|
|
63
|
+
readonly motionDrag = input.required<DragProps>();
|
|
64
|
+
|
|
65
|
+
constructor() {
|
|
66
|
+
const element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
|
|
67
|
+
let stop: (() => void) | undefined;
|
|
68
|
+
afterNextRender(() => {
|
|
69
|
+
stop = startDrag(element, () => this.motionDrag());
|
|
70
|
+
});
|
|
71
|
+
inject(DestroyRef).onDestroy(() => stop?.());
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ModuleIR } from '../../ir/model.js';
|
|
2
|
+
import type { WebContext } from '../shared/module.js';
|
|
3
|
+
/**
|
|
4
|
+
* Framer's useMotionTemplate is a tag (`useMotionTemplate\`blur(${x}px)\``). Kept in a name of its own
|
|
5
|
+
* (`const bg = useMotionTemplate\`…\``, or the IR's `useMotionTemplate` hook item) the Angular emitter writes it as
|
|
6
|
+
* motion's `transformValue` member (emit.ts, declareMotionTemplate). Written anywhere else (in the markup, inside a
|
|
7
|
+
* style object, in a handler, under another local name), nothing converts it and the tag would be printed as it is, a
|
|
8
|
+
* name the output never declares: a located `motion-hook` error, once per file, at the first such tag.
|
|
9
|
+
*/
|
|
10
|
+
export declare function reportInlineMotionTemplates(mod: ModuleIR, ctx: WebContext): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { MOTION_PACKAGES } from '../../analyzer/deps.js';
|
|
3
|
+
import { templateExpressions } from '../shared/inline.js';
|
|
4
|
+
/**
|
|
5
|
+
* Framer's useMotionTemplate is a tag (`useMotionTemplate\`blur(${x}px)\``). Kept in a name of its own
|
|
6
|
+
* (`const bg = useMotionTemplate\`…\``, or the IR's `useMotionTemplate` hook item) the Angular emitter writes it as
|
|
7
|
+
* motion's `transformValue` member (emit.ts, declareMotionTemplate). Written anywhere else (in the markup, inside a
|
|
8
|
+
* style object, in a handler, under another local name), nothing converts it and the tag would be printed as it is, a
|
|
9
|
+
* name the output never declares: a located `motion-hook` error, once per file, at the first such tag.
|
|
10
|
+
*/
|
|
11
|
+
export function reportInlineMotionTemplates(mod, ctx) {
|
|
12
|
+
const tags = new Set();
|
|
13
|
+
for (const decl of mod.imports) {
|
|
14
|
+
if (!MOTION_PACKAGES.has(decl.source.value))
|
|
15
|
+
continue;
|
|
16
|
+
for (const s of decl.specifiers)
|
|
17
|
+
if (t.isImportSpecifier(s) && (t.isIdentifier(s.imported) ? s.imported.name : s.imported.value) === 'useMotionTemplate')
|
|
18
|
+
tags.add(s.local.name);
|
|
19
|
+
}
|
|
20
|
+
if (!tags.size)
|
|
21
|
+
return;
|
|
22
|
+
const roots = [];
|
|
23
|
+
for (const comp of mod.components) {
|
|
24
|
+
templateExpressions(comp.template, roots);
|
|
25
|
+
for (const f of comp.fragments)
|
|
26
|
+
templateExpressions(f.template, roots);
|
|
27
|
+
}
|
|
28
|
+
for (const fn of [...mod.components, ...mod.hooks]) {
|
|
29
|
+
for (const item of fn.items) {
|
|
30
|
+
// the forms the emitter converts: only their interpolations are searched
|
|
31
|
+
if (item.kind === 'hook' && item.hook === 'useMotionTemplate' && item.id && t.isIdentifier(item.id)) {
|
|
32
|
+
for (const a of item.call.arguments)
|
|
33
|
+
roots.push(a);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (item.kind === 'derived' && t.isIdentifier(item.id) && t.isTaggedTemplateExpression(item.init) && t.isIdentifier(item.init.tag, { name: 'useMotionTemplate' })) {
|
|
37
|
+
roots.push(item.init.quasi);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
for (const v of Object.values(item))
|
|
41
|
+
if (t.isNode(v))
|
|
42
|
+
roots.push(v);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const root of roots) {
|
|
46
|
+
let found = null;
|
|
47
|
+
t.traverseFast(root, (n) => {
|
|
48
|
+
if (!found && t.isTaggedTemplateExpression(n) && t.isIdentifier(n.tag) && tags.has(n.tag.name))
|
|
49
|
+
found = n;
|
|
50
|
+
});
|
|
51
|
+
if (!found)
|
|
52
|
+
continue;
|
|
53
|
+
const at = found;
|
|
54
|
+
const line = at.loc?.start.line;
|
|
55
|
+
ctx.diagnostics.push({
|
|
56
|
+
code: 'motion-hook',
|
|
57
|
+
severity: 'error',
|
|
58
|
+
message: 'useMotionTemplate is written inline (in the markup or an expression), not kept in a name: Angular writes it as one motion value made at setup (`transformValue(() => `…${x.get()}…`)`), a class member that needs a name of its own (`const bg = useMotionTemplate`…``). Not converted.',
|
|
59
|
+
file: ctx.sourceRel,
|
|
60
|
+
target: ctx.target,
|
|
61
|
+
...(line ? { line } : {}),
|
|
62
|
+
});
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import type { AttrNode, ElementNode, TNode } from '../../ir/model.js';
|
|
3
|
+
/**
|
|
4
|
+
* Framer Motion element props on Angular. The `[motion]` directive (motion-directive.ts) takes the props it can play,
|
|
5
|
+
* as written, in one object: the same set the Svelte target's motion action takes, plus `exit`, which Angular plays
|
|
6
|
+
* through `animate.leave`. The rest is reported by name.
|
|
7
|
+
*/
|
|
8
|
+
/** Framer element props the directive handles. */
|
|
9
|
+
export declare const MOTION_PROPS: ReadonlySet<string>;
|
|
10
|
+
/** Props with no counterpart in the directive: what each one does, for the diagnostic. */
|
|
11
|
+
export declare const MOTION_UNCONVERTED: ReadonlyMap<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* The object a motion element passes to `[motion]`: its Framer props the directive plays, as written, with the objects
|
|
14
|
+
* of Framer props spread on it (`{...motionProps}`, see motionSpreads) where the source spreads them.
|
|
15
|
+
*/
|
|
16
|
+
export declare function motionParams(motion: Record<string, t.Expression>, styleValues: t.ObjectProperty[], spreads?: t.Expression[]): t.ObjectExpression | null;
|
|
17
|
+
/**
|
|
18
|
+
* The spreads on a motion element whose object is Framer's `MotionProps` by its declared type (`motionProps?:
|
|
19
|
+
* MotionProps`, `const enter: MotionProps = { … }`): `[motion]` takes them, where `[spreadProps]` would write each key
|
|
20
|
+
* as an attribute. `motionType(e)`: whether the expression is declared with that type. Null when one of them cannot be
|
|
21
|
+
* placed in source order among the element's own Framer props.
|
|
22
|
+
*/
|
|
23
|
+
export declare function motionSpreads(n: ElementNode, motionType: (e: t.Expression) => boolean): Extract<AttrNode, {
|
|
24
|
+
kind: 'spread';
|
|
25
|
+
}>[] | null;
|
|
26
|
+
/**
|
|
27
|
+
* The keys of the directive's props a props heritage type gives, when it is Framer's `MotionProps` (`names`: its local
|
|
28
|
+
* names) or `Omit<MotionProps, 'children' | …>`: those it does not leave out. Null for any other type.
|
|
29
|
+
*/
|
|
30
|
+
export declare function motionHeritage(h: t.TSType, names: ReadonlySet<string>): string[] | null;
|
|
31
|
+
/** Whether a component spreads its rest props once, on a motion element, and nowhere else in its markup. */
|
|
32
|
+
export declare function restOnMotion(comp: {
|
|
33
|
+
rest: string | null;
|
|
34
|
+
template: TNode;
|
|
35
|
+
}): boolean;
|
|
36
|
+
/** `<AnimatePresence mode="wait">`: the mode, when it is written as a string. */
|
|
37
|
+
export declare function presenceMode(attrs: AttrNode[]): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* What the `[motionPresence]` directive cannot time for an AnimatePresence with `initial={false}` or `mode="wait"`: a
|
|
40
|
+
* motion element with an initial animation inside a condition, list or key of a child (or of a component of the file a
|
|
41
|
+
* child renders). React times it by the child it sits in, the directive by when the element itself is created. And with
|
|
42
|
+
* `mode="wait"`, a child that is not a motion element: only a motion element can wait. Each problem, said in words.
|
|
43
|
+
*/
|
|
44
|
+
export declare function presenceGaps(presence: Extract<TNode, {
|
|
45
|
+
type: 'presence';
|
|
46
|
+
}>, componentOf: (tag: string) => {
|
|
47
|
+
template: TNode;
|
|
48
|
+
} | null): string[];
|
|
49
|
+
/** Framer Motion's value hooks as the `motion` functions an Angular class calls once (the Svelte target's mapping). */
|
|
50
|
+
export declare const MOTION_VALUE_HOOKS: Readonly<Record<string, string>>;
|
|
51
|
+
/**
|
|
52
|
+
* A `framer-motion` / `motion/react` import in Angular output: types `motion` shares, and the functions it shares
|
|
53
|
+
* (`animate`, `stagger`, `spring`, `motionValue`), come from `motion`; the hooks are written as their functions where they
|
|
54
|
+
* are declared (see emit.ts); `motion` and `AnimatePresence` are templates' business. A type `motion` does not have is
|
|
55
|
+
* returned, to be reported.
|
|
56
|
+
*/
|
|
57
|
+
export declare function motionImports(decl: t.ImportDeclaration, named: (source: string, imported: string, local: string) => void, type: (source: string, imported: string, local: string) => void): string[];
|