@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,70 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import type { ElementNode, ScriptItem } from '../../ir/model.js';
|
|
3
|
+
/**
|
|
4
|
+
* Framer Motion's `layout`, `layoutId` and `drag` props on Svelte and Angular (Vue's motion-v has its own). Both targets
|
|
5
|
+
* play them with the framework-free `motion` package's own engines, the ones React's motion components use:
|
|
6
|
+
* `animateLayout` (motion-dom's projection: measure before the update, invert, animate to the new box, with the
|
|
7
|
+
* scale correction of corners and children) and `drag` (motion-dom's VisualElementDragControls). This file reads an
|
|
8
|
+
* element's props into the params its target's helper takes, and says what is not played.
|
|
9
|
+
*/
|
|
10
|
+
/** The layout props the helper plays. */
|
|
11
|
+
export declare const LAYOUT_PROPS: ReadonlySet<string>;
|
|
12
|
+
/** The drag props the helper plays, by their React name, with the `drag()` option each becomes. */
|
|
13
|
+
export declare const DRAG_PROPS: ReadonlyMap<string, string>;
|
|
14
|
+
/** Whether the helper plays this Framer prop (the emitters' "not converted" warnings skip it). */
|
|
15
|
+
export declare function playsLayoutOrDrag(name: string): boolean;
|
|
16
|
+
/** What a conversion's elements ask of the helper: layout animations, drag, the whileDrag state. */
|
|
17
|
+
export type LayoutFeature = 'layout' | 'drag' | 'whileDrag';
|
|
18
|
+
export interface LayoutDragParams {
|
|
19
|
+
/** `{ layout, layoutId, transition }`, when the element has `layout` or `layoutId` */
|
|
20
|
+
layout: t.ObjectExpression | null;
|
|
21
|
+
/** `{ drag, dragConstraints, …, onDragEnd }` (React's names), when the element has `drag` */
|
|
22
|
+
drag: t.ObjectExpression | null;
|
|
23
|
+
features: LayoutFeature[];
|
|
24
|
+
/** what is not played as React plays it, each with its source line */
|
|
25
|
+
warnings: {
|
|
26
|
+
message: string;
|
|
27
|
+
line: number | undefined;
|
|
28
|
+
of: 'layout' | 'drag';
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A motion element's layout and drag props as the helper's params, with what is not played the same. `items`: the
|
|
33
|
+
* script of the component that renders it (an update it makes outside an event is not animated).
|
|
34
|
+
*/
|
|
35
|
+
export declare function layoutDragParams(n: ElementNode, items: readonly ScriptItem[]): LayoutDragParams;
|
|
36
|
+
/** Records that a component of the conversion uses the helper, with these features. */
|
|
37
|
+
export declare function useLayoutHelper(conversion: object, features: Iterable<LayoutFeature>): void;
|
|
38
|
+
/** The features the conversion's elements use, or null when none uses the helper. */
|
|
39
|
+
export declare function layoutHelperFeatures(conversion: object): ReadonlySet<LayoutFeature> | null;
|
|
40
|
+
/** The helper's props types (React's names), with only the features used. */
|
|
41
|
+
export declare function layoutPropsTypes(features: ReadonlySet<LayoutFeature>): string;
|
|
42
|
+
/**
|
|
43
|
+
* The framework-free part of the layout code: the registry of layout elements and the two window listeners that make
|
|
44
|
+
* an update from an event a layout animation, as React makes one. `flush`: the statement that applies the updates the
|
|
45
|
+
* event's handlers made (Svelte's flushSync, Angular's ApplicationRef.tick).
|
|
46
|
+
*/
|
|
47
|
+
export declare function layoutCoreSource(flush: string): string;
|
|
48
|
+
/** The drag part, framework-free: motion's drag() with React's props, whileDrag played from its start and end. */
|
|
49
|
+
export declare function dragCoreSource(whileDrag: boolean): string;
|
|
50
|
+
/**
|
|
51
|
+
* React's motion components ignore the system's reduced-motion setting unless a MotionConfig asks for it (its
|
|
52
|
+
* `reducedMotion` is "never" by default). The elements motion's layout and drag engines make for an element would read
|
|
53
|
+
* it through a media-query listener that is never removed; marked as already listening, they play as React plays.
|
|
54
|
+
*/
|
|
55
|
+
export declare const NEVER_REDUCE_SOURCE = "\n/** React's motion components play whatever the reduced-motion setting (MotionConfig reducedMotion \"never\" by default). */\nfunction neverReduce(): void {\n hasReducedMotionListener.current = true;\n}\n";
|
|
56
|
+
/** The names the helper imports from \`motion\` for these features. */
|
|
57
|
+
export declare function layoutMotionImports(features: ReadonlySet<LayoutFeature>): {
|
|
58
|
+
values: string[];
|
|
59
|
+
types: string[];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The first source line of an element that the IR keeps (its props and attributes written as expressions): where a
|
|
63
|
+
* bare prop (`drag`, `layout`), which carries no location of its own, is reported.
|
|
64
|
+
*/
|
|
65
|
+
export declare function elementLine(n: ElementNode): number | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* What in a component updates outside an event of the page (an effect, a timer, a promise): a layout change made there
|
|
68
|
+
* is not animated by the helper, which measures before an event's handlers run. Null when there is none.
|
|
69
|
+
*/
|
|
70
|
+
export declare function layoutUpdatesOutsideEvents(items: readonly ScriptItem[]): string | null;
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
/**
|
|
3
|
+
* Framer Motion's `layout`, `layoutId` and `drag` props on Svelte and Angular (Vue's motion-v has its own). Both targets
|
|
4
|
+
* play them with the framework-free `motion` package's own engines, the ones React's motion components use:
|
|
5
|
+
* `animateLayout` (motion-dom's projection: measure before the update, invert, animate to the new box, with the
|
|
6
|
+
* scale correction of corners and children) and `drag` (motion-dom's VisualElementDragControls). This file reads an
|
|
7
|
+
* element's props into the params its target's helper takes, and says what is not played.
|
|
8
|
+
*/
|
|
9
|
+
/** The layout props the helper plays. */
|
|
10
|
+
export const LAYOUT_PROPS = new Set(['layout', 'layoutId']);
|
|
11
|
+
/** The drag props the helper plays, by their React name, with the `drag()` option each becomes. */
|
|
12
|
+
export const DRAG_PROPS = new Map([
|
|
13
|
+
['drag', 'axis'],
|
|
14
|
+
['dragConstraints', 'constraints'],
|
|
15
|
+
['dragElastic', 'elastic'],
|
|
16
|
+
['dragMomentum', 'momentum'],
|
|
17
|
+
['dragTransition', 'transition'],
|
|
18
|
+
['dragSnapToOrigin', 'snapToOrigin'],
|
|
19
|
+
['dragDirectionLock', 'directionLock'],
|
|
20
|
+
['dragPropagation', 'propagation'],
|
|
21
|
+
['whileDrag', 'whileDrag'],
|
|
22
|
+
['onDragStart', 'onStart'],
|
|
23
|
+
['onDrag', 'onMove'],
|
|
24
|
+
['onDragEnd', 'onEnd'],
|
|
25
|
+
['onDirectionLock', 'onDirectionLock'],
|
|
26
|
+
['onDragTransitionEnd', 'onTransitionEnd'],
|
|
27
|
+
]);
|
|
28
|
+
/** The style values motion's projection corrects while it scales an element (motion-dom's scaleCorrectors). */
|
|
29
|
+
const SCALE_CORRECTED = new Set(['borderRadius', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomLeftRadius', 'borderBottomRightRadius', 'boxShadow']);
|
|
30
|
+
/** Whether the helper plays this Framer prop (the emitters' "not converted" warnings skip it). */
|
|
31
|
+
export function playsLayoutOrDrag(name) {
|
|
32
|
+
return LAYOUT_PROPS.has(name) || DRAG_PROPS.has(name);
|
|
33
|
+
}
|
|
34
|
+
/** A value that cannot change after the element is created: a literal, or an object or array of literals. */
|
|
35
|
+
function constant(e) {
|
|
36
|
+
if (t.isStringLiteral(e) || t.isNumericLiteral(e) || t.isBooleanLiteral(e) || t.isNullLiteral(e))
|
|
37
|
+
return true;
|
|
38
|
+
if (t.isUnaryExpression(e, { operator: '-' }))
|
|
39
|
+
return t.isNumericLiteral(e.argument);
|
|
40
|
+
if (t.isObjectExpression(e))
|
|
41
|
+
return e.properties.every((p) => t.isObjectProperty(p) && !p.computed && t.isExpression(p.value) && constant(p.value));
|
|
42
|
+
if (t.isArrayExpression(e))
|
|
43
|
+
return e.elements.every((x) => !!x && t.isExpression(x) && constant(x));
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A motion element's layout and drag props as the helper's params, with what is not played the same. `items`: the
|
|
48
|
+
* script of the component that renders it (an update it makes outside an event is not animated).
|
|
49
|
+
*/
|
|
50
|
+
export function layoutDragParams(n, items) {
|
|
51
|
+
const motion = n.motion ?? {};
|
|
52
|
+
const tag = n.tag;
|
|
53
|
+
const style = n.attrs.find((a) => a.kind === 'style')?.expr;
|
|
54
|
+
const warnings = [];
|
|
55
|
+
const features = [];
|
|
56
|
+
const prop = (name, value) => t.objectProperty(t.identifier(name), value);
|
|
57
|
+
const line = (e) => e.loc?.start.line;
|
|
58
|
+
let layout = null;
|
|
59
|
+
const layoutProps = Object.entries(motion).filter(([name]) => LAYOUT_PROPS.has(name));
|
|
60
|
+
if (layoutProps.length) {
|
|
61
|
+
const props = layoutProps.map(([name, value]) => prop(name, value));
|
|
62
|
+
if (motion.transition)
|
|
63
|
+
props.push(prop('transition', motion.transition));
|
|
64
|
+
// the values of its `style` React corrects while the element is scaled (its corners, its shadow)
|
|
65
|
+
const corrected = t.isObjectExpression(style) ? style.properties.flatMap((p) => (t.isObjectProperty(p) && !p.computed && t.isExpression(p.value) && SCALE_CORRECTED.has(t.isIdentifier(p.key) ? p.key.name : t.isStringLiteral(p.key) ? p.key.value : '') ? [p] : [])) : [];
|
|
66
|
+
if (corrected.length)
|
|
67
|
+
props.push(prop('corrected', t.objectExpression(corrected)));
|
|
68
|
+
else if (style && !t.isObjectExpression(style))
|
|
69
|
+
warnings.push({ message: `<motion.${tag}>: while its layout animation scales it, React corrects the corners and shadow its style sets; they are corrected here only when written in the element's style={{ … }}.`, line: line(style), of: 'layout' });
|
|
70
|
+
layout = t.objectExpression(props);
|
|
71
|
+
features.push('layout');
|
|
72
|
+
const outside = layoutUpdatesOutsideEvents(items);
|
|
73
|
+
if (outside)
|
|
74
|
+
warnings.push({ message: `<motion.${tag}>: its component also updates from ${outside}; a layout change made there is not animated (the converted element animates the updates a click, key, pointer press, input or change makes; React animates every re-render).`, line: layoutProps[0]?.[1].loc?.start.line ?? elementLine(n), of: 'layout' });
|
|
75
|
+
}
|
|
76
|
+
let drag = null;
|
|
77
|
+
// whileDrag as values only (a variant label is reported below and left out)
|
|
78
|
+
const dragProps = Object.entries(motion).filter(([name, value]) => DRAG_PROPS.has(name) && (name !== 'whileDrag' || t.isObjectExpression(value)));
|
|
79
|
+
if (motion.drag && !t.isBooleanLiteral(motion.drag, { value: false })) {
|
|
80
|
+
drag = t.objectExpression(dragProps.map(([name, value]) => prop(name, value)));
|
|
81
|
+
features.push('drag');
|
|
82
|
+
if (motion.whileDrag && t.isObjectExpression(motion.whileDrag))
|
|
83
|
+
features.push('whileDrag');
|
|
84
|
+
// drag() takes its options once: a value that can change after the element is created is read once
|
|
85
|
+
for (const [name, value] of dragProps) {
|
|
86
|
+
if (/^on[A-Z]/.test(name) || constant(value) || t.isIdentifier(value))
|
|
87
|
+
continue;
|
|
88
|
+
warnings.push({ message: `<motion.${tag}>: ${name} is read when the element is created; React follows its later values, the converted element keeps the first.`, line: line(value), of: 'drag' });
|
|
89
|
+
}
|
|
90
|
+
if (motion.whileDrag && !t.isObjectExpression(motion.whileDrag))
|
|
91
|
+
warnings.push({ message: `<motion.${tag}>: whileDrag is played only when it is written as values (an object); a variant label is not played.`, line: line(motion.whileDrag), of: 'drag' });
|
|
92
|
+
}
|
|
93
|
+
// the drag props without `drag` (or with drag={false}): React does not drag the element either, nothing is emitted
|
|
94
|
+
return { layout, drag, features, warnings };
|
|
95
|
+
}
|
|
96
|
+
/** What each conversion's elements use (keyed by the conversion's diagnostics list, one per target run). */
|
|
97
|
+
const used = new WeakMap();
|
|
98
|
+
/** Records that a component of the conversion uses the helper, with these features. */
|
|
99
|
+
export function useLayoutHelper(conversion, features) {
|
|
100
|
+
const set = used.get(conversion) ?? new Set();
|
|
101
|
+
for (const f of features)
|
|
102
|
+
set.add(f);
|
|
103
|
+
used.set(conversion, set);
|
|
104
|
+
}
|
|
105
|
+
/** The features the conversion's elements use, or null when none uses the helper. */
|
|
106
|
+
export function layoutHelperFeatures(conversion) {
|
|
107
|
+
return used.get(conversion) ?? null;
|
|
108
|
+
}
|
|
109
|
+
/** The helper's props types (React's names), with only the features used. */
|
|
110
|
+
export function layoutPropsTypes(features) {
|
|
111
|
+
const parts = [];
|
|
112
|
+
if (features.has('layout')) {
|
|
113
|
+
parts.push(`/** An element's layout props, as React wrote them. */
|
|
114
|
+
export interface LayoutProps {
|
|
115
|
+
layout?: boolean | 'position' | 'size' | 'preserve-aspect' | 'x' | 'y';
|
|
116
|
+
layoutId?: string;
|
|
117
|
+
transition?: Transition;
|
|
118
|
+
/** the values of its style that motion corrects while it scales the element (corners, shadow), as React reads them */
|
|
119
|
+
corrected?: Record<string, string | number>;
|
|
120
|
+
}
|
|
121
|
+
`);
|
|
122
|
+
}
|
|
123
|
+
if (features.has('drag')) {
|
|
124
|
+
parts.push(`/** An element's drag props, as React wrote them. */
|
|
125
|
+
export interface DragProps {
|
|
126
|
+
drag?: boolean | 'x' | 'y';
|
|
127
|
+
dragConstraints?: DragOptions['constraints'] | { readonly current: Element | null | undefined } | null;
|
|
128
|
+
dragElastic?: DragOptions['elastic'];
|
|
129
|
+
dragMomentum?: boolean;
|
|
130
|
+
dragTransition?: DragOptions['transition'];
|
|
131
|
+
dragSnapToOrigin?: DragOptions['snapToOrigin'];
|
|
132
|
+
dragDirectionLock?: boolean;
|
|
133
|
+
dragPropagation?: boolean;
|
|
134
|
+
${features.has('whileDrag') ? ' whileDrag?: TargetAndTransition;\n' : ''} onDragStart?: DragHandler;
|
|
135
|
+
onDrag?: DragHandler;
|
|
136
|
+
onDragEnd?: DragHandler;
|
|
137
|
+
onDirectionLock?: (axis: 'x' | 'y') => void;
|
|
138
|
+
onDragTransitionEnd?: () => void;
|
|
139
|
+
}
|
|
140
|
+
`);
|
|
141
|
+
}
|
|
142
|
+
return parts.join('\n');
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The framework-free part of the layout code: the registry of layout elements and the two window listeners that make
|
|
146
|
+
* an update from an event a layout animation, as React makes one. `flush`: the statement that applies the updates the
|
|
147
|
+
* event's handlers made (Svelte's flushSync, Angular's ApplicationRef.tick).
|
|
148
|
+
*/
|
|
149
|
+
export function layoutCoreSource(flush) {
|
|
150
|
+
return `
|
|
151
|
+
/** The elements in the page with layout props. */
|
|
152
|
+
const layoutElements = new Map<HTMLElement, LayoutProps>();
|
|
153
|
+
/** The events React re-renders after at once (discrete events): an update one of them makes is measured before it. */
|
|
154
|
+
const LAYOUT_EVENTS = ['pointerdown', 'pointerup', 'click', 'keydown', 'keyup', 'input', 'change'] as const;
|
|
155
|
+
/** The update of the event being handled, ended once the event's handlers have run (\`flush\`: its updates applied first). */
|
|
156
|
+
let pending: ((flush: boolean) => void) | undefined;
|
|
157
|
+
let fallback: ReturnType<typeof setTimeout> | undefined;
|
|
158
|
+
/** true while the updates of an event are applied: an element removed then is the layout animation's business */
|
|
159
|
+
let committing = false;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Each layout element's transition on its measured node (a shared one by its layoutId, for the element that takes it
|
|
163
|
+
* over), and the style values React keeps among its animated values (corrected while the element is scaled).
|
|
164
|
+
*/
|
|
165
|
+
function transitions(builder: LayoutAnimationBuilder): void {
|
|
166
|
+
for (const [element, props] of layoutElements) {
|
|
167
|
+
const visual = visualElementStore.get(element);
|
|
168
|
+
if (visual && props.corrected) Object.assign(visual.latestValues, props.corrected);
|
|
169
|
+
if (!props.transition) continue;
|
|
170
|
+
if (props.layoutId !== undefined) builder.shared(props.layoutId, props.transition);
|
|
171
|
+
visual?.projection?.setOptions({ transition: props.transition });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Before an event's handlers run (window, capture): every layout element is measured, as React measures before it re-renders. */
|
|
176
|
+
function measureLayout(): void {
|
|
177
|
+
if (pending) return;
|
|
178
|
+
let done = (): void => undefined;
|
|
179
|
+
const committed = new Promise<void>((resolve) => (done = resolve));
|
|
180
|
+
// the whole document is its scope: an element may take over a layoutId from anywhere in the page. An element without
|
|
181
|
+
// a transition of its own takes React's default layout transition (motion-dom's defaultLayoutTransition), where
|
|
182
|
+
// animateLayout's own default is motion's default for a value
|
|
183
|
+
const builder = animateLayout(() => committed, { duration: 0.45, ease: [0.4, 0, 0.1, 1] });
|
|
184
|
+
flushLayoutSnapshots();
|
|
185
|
+
transitions(builder);
|
|
186
|
+
// whether the event changes the page: one that changes nothing is no update (React does not re-render for it), and an
|
|
187
|
+
// update that is none would restart the layout animations playing now
|
|
188
|
+
// (a framework that applies its updates in a microtask before the event ends has its records delivered there)
|
|
189
|
+
let mutated = false;
|
|
190
|
+
const changes = new MutationObserver(() => (mutated = true));
|
|
191
|
+
changes.observe(document, { subtree: true, childList: true, attributes: true, characterData: true });
|
|
192
|
+
pending = (flush) => {
|
|
193
|
+
pending = undefined;
|
|
194
|
+
clearTimeout(fallback);
|
|
195
|
+
if (flush) {
|
|
196
|
+
committing = true;
|
|
197
|
+
try {
|
|
198
|
+
${flush}
|
|
199
|
+
} finally {
|
|
200
|
+
committing = false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const changed = !flush || mutated || changes.takeRecords().length > 0;
|
|
204
|
+
changes.disconnect();
|
|
205
|
+
// nothing changed: motion ends the measurement without an update (its projection root is told no update ran)
|
|
206
|
+
if (!changed) for (const element of layoutElements.keys()) {
|
|
207
|
+
const root = visualElementStore.get(element)?.projection?.root;
|
|
208
|
+
if (root) root.isUpdating = false;
|
|
209
|
+
}
|
|
210
|
+
// the elements the update added take their transitions before motion animates them
|
|
211
|
+
transitions(builder);
|
|
212
|
+
done();
|
|
213
|
+
};
|
|
214
|
+
// a handler that stops the event before it reaches the window: its update ends with the next timer
|
|
215
|
+
fallback = setTimeout(applyLayout);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** After an event's handlers ran (window, bubble): their updates are applied, then motion animates what moved. */
|
|
219
|
+
function applyLayout(): void {
|
|
220
|
+
pending?.(true);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** A layout element enters the page. */
|
|
224
|
+
function addLayout(element: HTMLElement, props: LayoutProps): void {
|
|
225
|
+
neverReduce();
|
|
226
|
+
if (!layoutElements.size) {
|
|
227
|
+
for (const type of LAYOUT_EVENTS) {
|
|
228
|
+
window.addEventListener(type, measureLayout, true);
|
|
229
|
+
window.addEventListener(type, applyLayout);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
markLayout(element, props);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Its layout props, where motion's animateLayout reads them (data-layout, data-layout-id), and in the registry. */
|
|
236
|
+
function markLayout(element: HTMLElement, props: LayoutProps): void {
|
|
237
|
+
if (props.layoutId !== undefined) element.dataset.layoutId = props.layoutId;
|
|
238
|
+
else delete element.dataset.layoutId;
|
|
239
|
+
if (props.layout) element.dataset.layout = String(props.layout);
|
|
240
|
+
else delete element.dataset.layout;
|
|
241
|
+
layoutElements.set(element, props);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** A layout element leaves the page. */
|
|
245
|
+
function removeLayout(element: HTMLElement): void {
|
|
246
|
+
layoutElements.delete(element);
|
|
247
|
+
// removed by something other than an event's update (its component went): its layout animation stops with it
|
|
248
|
+
if (!committing) visualElementStore.get(element)?.projection?.currentAnimation?.stop();
|
|
249
|
+
if (layoutElements.size) return;
|
|
250
|
+
for (const type of LAYOUT_EVENTS) {
|
|
251
|
+
window.removeEventListener(type, measureLayout, true);
|
|
252
|
+
window.removeEventListener(type, applyLayout);
|
|
253
|
+
}
|
|
254
|
+
pending?.(false);
|
|
255
|
+
}
|
|
256
|
+
`;
|
|
257
|
+
}
|
|
258
|
+
/** The drag part, framework-free: motion's drag() with React's props, whileDrag played from its start and end. */
|
|
259
|
+
export function dragCoreSource(whileDrag) {
|
|
260
|
+
const gesture = whileDrag
|
|
261
|
+
? `
|
|
262
|
+
/** Framer's resting values for the transforms and opacity, used when whileDrag ends and \`animate\` does not set them. */
|
|
263
|
+
const DRAG_RESTING: Record<string, string | number> = { opacity: 1, scale: 1, scaleX: 1, scaleY: 1, x: 0, y: 0, z: 0, rotate: 0, rotateX: 0, rotateY: 0, rotateZ: 0, skewX: 0, skewY: 0 };
|
|
264
|
+
`
|
|
265
|
+
: '';
|
|
266
|
+
const start = whileDrag
|
|
267
|
+
? `
|
|
268
|
+
if (props.whileDrag) {
|
|
269
|
+
const { transition, ...values } = props.whileDrag;
|
|
270
|
+
// x and y belong to the drag itself
|
|
271
|
+
delete values.x;
|
|
272
|
+
delete values.y;
|
|
273
|
+
const keys = Object.keys(values);
|
|
274
|
+
state?.stop();
|
|
275
|
+
state = animate(element, values, transition);
|
|
276
|
+
back = () => {
|
|
277
|
+
const computed = getComputedStyle(element);
|
|
278
|
+
const resting: Record<string, string | number> = {};
|
|
279
|
+
for (const key of keys) resting[key] = key in DRAG_RESTING ? DRAG_RESTING[key] : computed.getPropertyValue(key);
|
|
280
|
+
state?.stop();
|
|
281
|
+
state = animate(element, resting, transition);
|
|
282
|
+
};
|
|
283
|
+
}`
|
|
284
|
+
: '';
|
|
285
|
+
const end = whileDrag ? `\n back?.();\n back = undefined;` : '';
|
|
286
|
+
const vars = whileDrag ? `\n let state: AnimationPlaybackControls | undefined;\n let back: (() => void) | undefined;` : '';
|
|
287
|
+
const stopState = whileDrag ? '\n state?.stop();' : '';
|
|
288
|
+
return `${gesture}
|
|
289
|
+
/** React's drag on an element: motion's drag() (React's drag controls), its options read once, its callbacks live. */
|
|
290
|
+
function startDrag(element: HTMLElement, current: () => DragProps): () => void {
|
|
291
|
+
const props = current();
|
|
292
|
+
if (!props.drag) return () => undefined;
|
|
293
|
+
neverReduce();${vars}
|
|
294
|
+
const options: DragOptions = {
|
|
295
|
+
axis: props.drag === 'x' || props.drag === 'y' ? props.drag : undefined,
|
|
296
|
+
elastic: props.dragElastic,
|
|
297
|
+
momentum: props.dragMomentum,
|
|
298
|
+
transition: props.dragTransition,
|
|
299
|
+
snapToOrigin: props.dragSnapToOrigin,
|
|
300
|
+
directionLock: props.dragDirectionLock,
|
|
301
|
+
propagation: props.dragPropagation,
|
|
302
|
+
onStart: (event, info) => {
|
|
303
|
+
current().onDragStart?.(event, info);${start}
|
|
304
|
+
},
|
|
305
|
+
onMove: (event, info) => current().onDrag?.(event, info),
|
|
306
|
+
onEnd: (event, info) => {
|
|
307
|
+
current().onDragEnd?.(event, info);${end}
|
|
308
|
+
},
|
|
309
|
+
onDirectionLock: (axis) => current().onDirectionLock?.(axis),
|
|
310
|
+
onTransitionEnd: () => current().onDragTransitionEnd?.(),
|
|
311
|
+
};
|
|
312
|
+
// an element, or a ref to one ({ current }): motion's drag controls read a ref when the drag starts, as React's do
|
|
313
|
+
// (their options type names only the element)
|
|
314
|
+
Object.assign(options, { constraints: props.dragConstraints ?? undefined });
|
|
315
|
+
const stop = drag(element, options);
|
|
316
|
+
return () => {
|
|
317
|
+
stop();${stopState}
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
`;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* React's motion components ignore the system's reduced-motion setting unless a MotionConfig asks for it (its
|
|
324
|
+
* `reducedMotion` is "never" by default). The elements motion's layout and drag engines make for an element would read
|
|
325
|
+
* it through a media-query listener that is never removed; marked as already listening, they play as React plays.
|
|
326
|
+
*/
|
|
327
|
+
export const NEVER_REDUCE_SOURCE = `
|
|
328
|
+
/** React's motion components play whatever the reduced-motion setting (MotionConfig reducedMotion "never" by default). */
|
|
329
|
+
function neverReduce(): void {
|
|
330
|
+
hasReducedMotionListener.current = true;
|
|
331
|
+
}
|
|
332
|
+
`;
|
|
333
|
+
/** The names the helper imports from \`motion\` for these features. */
|
|
334
|
+
export function layoutMotionImports(features) {
|
|
335
|
+
const values = ['hasReducedMotionListener', features.has('layout') && 'animateLayout', features.has('layout') && 'flushLayoutSnapshots', features.has('layout') && 'visualElementStore', features.has('drag') && 'drag', features.has('whileDrag') && 'animate'].filter((x) => !!x);
|
|
336
|
+
const types = [features.has('layout') && 'LayoutAnimationBuilder', features.has('layout') && 'Transition', features.has('drag') && 'DragHandler', features.has('drag') && 'DragOptions', features.has('whileDrag') && 'TargetAndTransition', features.has('whileDrag') && 'AnimationPlaybackControls'].filter((x) => !!x);
|
|
337
|
+
return { values, types };
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* The first source line of an element that the IR keeps (its props and attributes written as expressions): where a
|
|
341
|
+
* bare prop (`drag`, `layout`), which carries no location of its own, is reported.
|
|
342
|
+
*/
|
|
343
|
+
export function elementLine(n) {
|
|
344
|
+
const lines = [];
|
|
345
|
+
const add = (e) => {
|
|
346
|
+
if (e?.loc)
|
|
347
|
+
lines.push(e.loc.start.line);
|
|
348
|
+
};
|
|
349
|
+
for (const value of Object.values(n.motion ?? {}))
|
|
350
|
+
add(value);
|
|
351
|
+
for (const a of n.attrs) {
|
|
352
|
+
if (a.kind === 'expr' || a.kind === 'spread' || a.kind === 'ref' || a.kind === 'style' || a.kind === 'html')
|
|
353
|
+
add(a.expr);
|
|
354
|
+
else if (a.kind === 'event')
|
|
355
|
+
add(a.handler);
|
|
356
|
+
}
|
|
357
|
+
return lines.length ? Math.min(...lines) : undefined;
|
|
358
|
+
}
|
|
359
|
+
/** The calls that run code later, outside the event that started them. */
|
|
360
|
+
const LATER = new Set(['setTimeout', 'setInterval', 'requestAnimationFrame', 'queueMicrotask', 'requestIdleCallback']);
|
|
361
|
+
/**
|
|
362
|
+
* What in a component updates outside an event of the page (an effect, a timer, a promise): a layout change made there
|
|
363
|
+
* is not animated by the helper, which measures before an event's handlers run. Null when there is none.
|
|
364
|
+
*/
|
|
365
|
+
export function layoutUpdatesOutsideEvents(items) {
|
|
366
|
+
if (items.some((i) => i.kind === 'effect'))
|
|
367
|
+
return 'an effect';
|
|
368
|
+
let found = null;
|
|
369
|
+
const seen = new Set();
|
|
370
|
+
const walk = (value) => {
|
|
371
|
+
if (found || !value || typeof value !== 'object' || seen.has(value))
|
|
372
|
+
return;
|
|
373
|
+
seen.add(value);
|
|
374
|
+
if (Array.isArray(value))
|
|
375
|
+
return value.forEach(walk);
|
|
376
|
+
if (t.isNode(value)) {
|
|
377
|
+
if (t.isAwaitExpression(value))
|
|
378
|
+
found = 'a promise (await)';
|
|
379
|
+
else if (t.isCallExpression(value) && t.isIdentifier(value.callee) && LATER.has(value.callee.name))
|
|
380
|
+
found = `a timer (${value.callee.name})`;
|
|
381
|
+
else if (t.isCallExpression(value) && t.isMemberExpression(value.callee) && t.isIdentifier(value.callee.property, { name: 'then' }))
|
|
382
|
+
found = 'a promise (.then)';
|
|
383
|
+
if (found)
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
for (const [key, child] of Object.entries(value))
|
|
387
|
+
if (key !== 'loc' && key !== 'leadingComments' && key !== 'trailingComments')
|
|
388
|
+
walk(child);
|
|
389
|
+
};
|
|
390
|
+
walk(items);
|
|
391
|
+
return found;
|
|
392
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
/** Whether an expression reads the page (`document`, `window`) as a free name: a template cannot reach either. */
|
|
3
|
+
export declare function readsPage(e: t.Node): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Svelte's portal: an attachment that moves the element it sits on under the container and removes it when the
|
|
6
|
+
* attachment is torn down (the block around it ends, or the component unmounts). The element is the one root of a
|
|
7
|
+
* `{#key container}` block, so Svelte's own removal of that block reaches it wherever it is, and a new container
|
|
8
|
+
* renders the children afresh there, as React does when a portal's container changes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SVELTE_PORTAL_SOURCE = "/** Renders the element under another container (a portal) while it is rendered here, and removes it after. */\nfunction portal(container: Element | DocumentFragment | null | undefined) {\n return (node: Element) => {\n container?.appendChild(node);\n return () => node.remove();\n };\n}";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
/** Whether an expression reads the page (`document`, `window`) as a free name: a template cannot reach either. */
|
|
3
|
+
export function readsPage(e) {
|
|
4
|
+
let found = false;
|
|
5
|
+
t.traverseFast(e, (n) => {
|
|
6
|
+
if (t.isMemberExpression(n) && t.isIdentifier(n.object) && (n.object.name === 'document' || n.object.name === 'window'))
|
|
7
|
+
found = true;
|
|
8
|
+
});
|
|
9
|
+
return found;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Svelte's portal: an attachment that moves the element it sits on under the container and removes it when the
|
|
13
|
+
* attachment is torn down (the block around it ends, or the component unmounts). The element is the one root of a
|
|
14
|
+
* `{#key container}` block, so Svelte's own removal of that block reaches it wherever it is, and a new container
|
|
15
|
+
* renders the children afresh there, as React does when a portal's container changes.
|
|
16
|
+
*/
|
|
17
|
+
export const SVELTE_PORTAL_SOURCE = `/** Renders the element under another container (a portal) while it is rendered here, and removes it after. */
|
|
18
|
+
function portal(container: Element | DocumentFragment | null | undefined) {
|
|
19
|
+
return (node: Element) => {
|
|
20
|
+
container?.appendChild(node);
|
|
21
|
+
return () => node.remove();
|
|
22
|
+
};
|
|
23
|
+
}`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentIR } from '../../ir/model.js';
|
|
2
|
+
/**
|
|
3
|
+
* The props a component assigns to (`if (typeof tooltip === 'string') tooltip = { children: tooltip }`), with the line
|
|
4
|
+
* of the first write. React re-runs that code on every render, so the write normalises each new value the parent
|
|
5
|
+
* passes; neither a Vue prop (read-only) nor a Svelte prop (written once, then replaced by the parent's next value)
|
|
6
|
+
* keeps that.
|
|
7
|
+
*/
|
|
8
|
+
export declare function propWrites(comp: ComponentIR): {
|
|
9
|
+
name: string;
|
|
10
|
+
line: number | undefined;
|
|
11
|
+
}[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
/**
|
|
3
|
+
* The props a component assigns to (`if (typeof tooltip === 'string') tooltip = { children: tooltip }`), with the line
|
|
4
|
+
* of the first write. React re-runs that code on every render, so the write normalises each new value the parent
|
|
5
|
+
* passes; neither a Vue prop (read-only) nor a Svelte prop (written once, then replaced by the parent's next value)
|
|
6
|
+
* keeps that.
|
|
7
|
+
*/
|
|
8
|
+
export function propWrites(comp) {
|
|
9
|
+
const found = new Map();
|
|
10
|
+
const isProp = (n) => {
|
|
11
|
+
const name = t.isIdentifier(n) ? comp.refs.get(n) : undefined;
|
|
12
|
+
return name && comp.bindings.get(name)?.kind === 'prop' ? name : null;
|
|
13
|
+
};
|
|
14
|
+
const seen = new Set();
|
|
15
|
+
const visit = (value) => {
|
|
16
|
+
if (!value || typeof value !== 'object' || seen.has(value))
|
|
17
|
+
return;
|
|
18
|
+
seen.add(value);
|
|
19
|
+
if (Array.isArray(value))
|
|
20
|
+
return value.forEach(visit);
|
|
21
|
+
if (!t.isNode(value))
|
|
22
|
+
return Object.values(value).forEach(visit);
|
|
23
|
+
t.traverseFast(value, (n) => {
|
|
24
|
+
const target = t.isAssignmentExpression(n) ? n.left : t.isUpdateExpression(n) ? n.argument : null;
|
|
25
|
+
const name = target ? isProp(target) : null;
|
|
26
|
+
if (name && !found.has(name))
|
|
27
|
+
found.set(name, n.loc?.start.line);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
visit([comp.items, comp.template, comp.fragments]);
|
|
31
|
+
return [...found].map(([name, line]) => ({ name, line }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
/**
|
|
3
|
+
* Dead-code pruning for generated single-file components. Emission is driven by what the React source declared, so a
|
|
4
|
+
* value whose only reader was dropped on the way (a prop of a coordinating wrapper, a dependency list, a props
|
|
5
|
+
* interface the component flattened) is still declared. This removes, from a component's script blocks, every
|
|
6
|
+
* top-level declaration nothing reads, and says which names the markup reads so the imports can follow.
|
|
7
|
+
*/
|
|
8
|
+
/** What is safe to drop when nobody reads the result: no effect beyond building a value. */
|
|
9
|
+
export interface PurityRules {
|
|
10
|
+
/** callee names (`ref`, `$state.raw`, `useId`) that only build a value */
|
|
11
|
+
calls: ReadonlySet<string>;
|
|
12
|
+
/** an expression of the emitter's own making that is safe to drop although it is not built from the above */
|
|
13
|
+
also?: (e: t.Node) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* the props declaration (`const { a, b } = defineProps<Props>()`, `let { a } = $props()`): a prop it destructures and
|
|
16
|
+
* nothing reads is taken out of the destructuring; when none is left the declaration becomes the bare call
|
|
17
|
+
* ('call', for Vue, where the call itself declares the props) or an empty destructuring that keeps its type ('empty',
|
|
18
|
+
* for Svelte, where `$props()` must initialize a declaration: `let {}: Props = $props()`), so the component still
|
|
19
|
+
* declares what its callers pass. A prop whose default calls one of `declares` (`$bindable()`) always stays: the
|
|
20
|
+
* default is what makes it bindable.
|
|
21
|
+
*/
|
|
22
|
+
props?: {
|
|
23
|
+
calls: ReadonlySet<string>;
|
|
24
|
+
whenUnread: 'call' | 'empty';
|
|
25
|
+
declares?: ReadonlySet<string>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Whether evaluating the expression only builds a value (so a binding nobody reads may go). */
|
|
29
|
+
export declare function isPure(e: t.Node | null | undefined, rules: PurityRules): boolean;
|
|
30
|
+
/** Every identifier-like word in a piece of text. */
|
|
31
|
+
export declare function wordsIn(code: string, into?: Set<string>): Set<string>;
|
|
32
|
+
/**
|
|
33
|
+
* The names a template reads: the code inside its expressions, its component tags, and the actions, transitions and
|
|
34
|
+
* refs it names. Class names, text, static attributes and the inside of string literals read nothing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function markupNames(markup: string, target: 'vue' | 'svelte'): Set<string>;
|
|
37
|
+
/** Names a block reads or writes: values (a local that shadows a top-level name is not one of them) and types. */
|
|
38
|
+
export declare function readNames(statements: t.Statement[], into?: Set<string>): Set<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Removes the top-level declarations of the given script blocks that nothing reads, repeating until nothing more goes.
|
|
41
|
+
* Exports are read by definition; so is whatever `fromMarkup` names. A variable goes only when its initializer merely
|
|
42
|
+
* builds a value (`isPure`); a function or a type goes whenever unread.
|
|
43
|
+
*/
|
|
44
|
+
export declare function pruneUnused(blocks: t.Statement[][], fromMarkup: ReadonlySet<string>, rules: PurityRules): t.Statement[][];
|
|
45
|
+
/**
|
|
46
|
+
* The names an Angular template reads from its class: the code in its bindings, interpolations and control flow. The
|
|
47
|
+
* markup around them, class names, comments and string literals read nothing.
|
|
48
|
+
*/
|
|
49
|
+
export declare function angularNames(markup: string): Set<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Removes the private and protected members of a component class that neither its own code (`this.x`) nor its template
|
|
52
|
+
* reads, repeating until nothing more goes. A property goes only when its initializer merely builds a value.
|
|
53
|
+
*/
|
|
54
|
+
export declare function pruneMembers(members: t.ClassBody['body'], fromTemplate: ReadonlySet<string>, rules: PurityRules): void;
|