@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,48 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import type { ComponentIR, ModuleIR } from '../../ir/model.js';
|
|
3
|
+
import type { WebContext } from '../shared/module.js';
|
|
4
|
+
/**
|
|
5
|
+
* Names a file imports and exports again with a local export (`import { type Frame } from './prepare'; export type {
|
|
6
|
+
* Frame };`): the lowered module keeps them only in `exportedNames`, so the Angular file writes the export again (its
|
|
7
|
+
* import stays, since the export reads it). Type-only imports are exported as types.
|
|
8
|
+
*/
|
|
9
|
+
export declare function exportedImports(mod: ModuleIR, declared: ReadonlySet<string>, classes: ReadonlySet<string>): t.Statement[];
|
|
10
|
+
/**
|
|
11
|
+
* Where a type named in a props type copied from another file comes from, for this file's import: that file imports it
|
|
12
|
+
* (from a third file or a package: imported from there, under the name it has there), or declares it (imported from it).
|
|
13
|
+
*/
|
|
14
|
+
export declare function foreignTypeSource(name: string, file: string, outPath: string, ctx: WebContext): {
|
|
15
|
+
source: string;
|
|
16
|
+
imported: string;
|
|
17
|
+
} | null;
|
|
18
|
+
/**
|
|
19
|
+
* A name a statement of the file already exports where it is declared (`export type CarouselApi = …`) leaves the file's
|
|
20
|
+
* export list (`export { type CarouselApi, Carousel }` of the React source): exported twice is an error, and the Angular
|
|
21
|
+
* compiler, following the second export back to the first, never returns.
|
|
22
|
+
*/
|
|
23
|
+
export declare function withoutDoubleExports(body: t.Statement[]): t.Statement[];
|
|
24
|
+
/** Angular's class decorators: a component named like one keeps that name only as its export (see below). */
|
|
25
|
+
export declare const DECORATOR_NAMES: ReadonlySet<string>;
|
|
26
|
+
/**
|
|
27
|
+
* A component named like an Angular decorator (`export const Component = …`): its class cannot have that name, which the
|
|
28
|
+
* decorator import holds (and an aliased decorator import hides the component from the compiler), so the class is
|
|
29
|
+
* `ComponentComponent` and is exported under its React name (`export { ComponentComponent as Component }`).
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* A type the file declares under a component's name (`type Signup = { … }` beside `function Signup()`): React keeps a
|
|
33
|
+
* type and a function of one name apart, a class is a type itself, so the type takes another name (`SignupData`), in
|
|
34
|
+
* its declaration and every type reference to it. Returns the renames (from → to), to be reported: a file that imports
|
|
35
|
+
* the type by its old name gets the class.
|
|
36
|
+
*/
|
|
37
|
+
export declare function renameTypesNamedLikeClasses(body: t.Statement[]): Map<string, string>;
|
|
38
|
+
export declare function renameDecoratorNamedClasses(body: t.Statement[]): t.Statement[];
|
|
39
|
+
/**
|
|
40
|
+
* React values the emitted code still names (a React hook no rule converts, such as `useSyncExternalStore`): the React
|
|
41
|
+
* import is gone, so each is reported where it would otherwise fail as an unknown name.
|
|
42
|
+
*/
|
|
43
|
+
export declare function leftoverReactValues(mod: ModuleIR, body: t.Statement[]): string[];
|
|
44
|
+
/**
|
|
45
|
+
* The component a file exports under a name, followed through barrels (`export { PcCase } from './shell'`,
|
|
46
|
+
* `export * from './parts'`) and aliases (`export const Card = CardRoot`); `default` for the default export.
|
|
47
|
+
*/
|
|
48
|
+
export declare function exportedComponent(file: string, name: string, ctx: WebContext, depth?: number): ComponentIR | null;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { classifyImport, isAliased, resolveLocal } from '../../analyzer/deps.js';
|
|
3
|
+
import { importPath } from '../shared/layout.js';
|
|
4
|
+
import { childNodes } from './walk.js';
|
|
5
|
+
/**
|
|
6
|
+
* Names a file imports and exports again with a local export (`import { type Frame } from './prepare'; export type {
|
|
7
|
+
* Frame };`): the lowered module keeps them only in `exportedNames`, so the Angular file writes the export again (its
|
|
8
|
+
* import stays, since the export reads it). Type-only imports are exported as types.
|
|
9
|
+
*/
|
|
10
|
+
export function exportedImports(mod, declared, classes) {
|
|
11
|
+
const values = [];
|
|
12
|
+
const types = [];
|
|
13
|
+
// a name the lowered module already exports again from its source (`export type { Frame } from './prepare'`)
|
|
14
|
+
const reexported = new Set(mod.reexports.flatMap((r) => (t.isExportNamedDeclaration(r) ? r.specifiers.map((s) => (t.isIdentifier(s.exported) ? s.exported.name : s.exported.value)) : [])));
|
|
15
|
+
for (const decl of mod.imports) {
|
|
16
|
+
for (const s of decl.specifiers) {
|
|
17
|
+
const name = s.local.name;
|
|
18
|
+
if (!mod.exportedNames.has(name) || reexported.has(name) || declared.has(name) || classes.has(name) || mod.aliases.has(name))
|
|
19
|
+
continue;
|
|
20
|
+
const typeOnly = decl.importKind === 'type' || (t.isImportSpecifier(s) && s.importKind === 'type');
|
|
21
|
+
(typeOnly ? types : values).push(name);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const out = [];
|
|
25
|
+
const specifiers = (names) => names.map((n) => t.exportSpecifier(t.identifier(n), t.identifier(n)));
|
|
26
|
+
if (values.length)
|
|
27
|
+
out.push(t.exportNamedDeclaration(null, specifiers(values)));
|
|
28
|
+
if (types.length)
|
|
29
|
+
out.push(Object.assign(t.exportNamedDeclaration(null, specifiers(types)), { exportKind: 'type' }));
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Where a type named in a props type copied from another file comes from, for this file's import: that file imports it
|
|
34
|
+
* (from a third file or a package: imported from there, under the name it has there), or declares it (imported from it).
|
|
35
|
+
*/
|
|
36
|
+
export function foreignTypeSource(name, file, outPath, ctx) {
|
|
37
|
+
const other = ctx.moduleOf?.(file);
|
|
38
|
+
const from = ctx.layoutOf(file);
|
|
39
|
+
for (const decl of other?.imports ?? []) {
|
|
40
|
+
for (const s of decl.specifiers) {
|
|
41
|
+
if (s.local.name !== name)
|
|
42
|
+
continue;
|
|
43
|
+
if (!t.isImportSpecifier(s))
|
|
44
|
+
return null;
|
|
45
|
+
const imported = t.isIdentifier(s.imported) ? s.imported.name : s.imported.value;
|
|
46
|
+
const resolved = resolveLocal(file, decl.source.value, ctx.project);
|
|
47
|
+
if (!resolved) {
|
|
48
|
+
const kind = classifyImport(decl.source.value);
|
|
49
|
+
const aliased = isAliased(decl.source.value, ctx.project);
|
|
50
|
+
return kind === 'react' || kind === 'local' || aliased ? null : { source: decl.source.value, imported };
|
|
51
|
+
}
|
|
52
|
+
const layout = ctx.layoutOf(resolved);
|
|
53
|
+
return layout ? { source: importPath(outPath, layout.modulePath), imported } : null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return from ? { source: importPath(outPath, from.modulePath), imported: name } : null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A name a statement of the file already exports where it is declared (`export type CarouselApi = …`) leaves the file's
|
|
60
|
+
* export list (`export { type CarouselApi, Carousel }` of the React source): exported twice is an error, and the Angular
|
|
61
|
+
* compiler, following the second export back to the first, never returns.
|
|
62
|
+
*/
|
|
63
|
+
export function withoutDoubleExports(body) {
|
|
64
|
+
const declared = new Set();
|
|
65
|
+
for (const s of body) {
|
|
66
|
+
if (!t.isExportNamedDeclaration(s) || !s.declaration)
|
|
67
|
+
continue;
|
|
68
|
+
const d = s.declaration;
|
|
69
|
+
if (t.isVariableDeclaration(d))
|
|
70
|
+
for (const v of d.declarations)
|
|
71
|
+
for (const name of Object.keys(t.getBindingIdentifiers(v.id)))
|
|
72
|
+
declared.add(name);
|
|
73
|
+
else if ((t.isFunctionDeclaration(d) || t.isClassDeclaration(d) || t.isTSTypeAliasDeclaration(d) || t.isTSInterfaceDeclaration(d) || t.isTSEnumDeclaration(d)) && d.id)
|
|
74
|
+
declared.add(d.id.name);
|
|
75
|
+
}
|
|
76
|
+
if (!declared.size)
|
|
77
|
+
return body;
|
|
78
|
+
return body.flatMap((s) => {
|
|
79
|
+
if (!t.isExportNamedDeclaration(s) || s.declaration || s.source)
|
|
80
|
+
return [s];
|
|
81
|
+
const kept = s.specifiers.filter((sp) => !(t.isExportSpecifier(sp) && t.isIdentifier(sp.local) && declared.has(sp.local.name) && (t.isIdentifier(sp.exported) ? sp.exported.name : sp.exported.value) === sp.local.name));
|
|
82
|
+
if (kept.length === s.specifiers.length)
|
|
83
|
+
return [s];
|
|
84
|
+
return kept.length ? [Object.assign(t.exportNamedDeclaration(null, kept), { exportKind: s.exportKind })] : [];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** Angular's class decorators: a component named like one keeps that name only as its export (see below). */
|
|
88
|
+
export const DECORATOR_NAMES = new Set(['Component', 'Directive']);
|
|
89
|
+
/**
|
|
90
|
+
* A component named like an Angular decorator (`export const Component = …`): its class cannot have that name, which the
|
|
91
|
+
* decorator import holds (and an aliased decorator import hides the component from the compiler), so the class is
|
|
92
|
+
* `ComponentComponent` and is exported under its React name (`export { ComponentComponent as Component }`).
|
|
93
|
+
*/
|
|
94
|
+
/**
|
|
95
|
+
* A type the file declares under a component's name (`type Signup = { … }` beside `function Signup()`): React keeps a
|
|
96
|
+
* type and a function of one name apart, a class is a type itself, so the type takes another name (`SignupData`), in
|
|
97
|
+
* its declaration and every type reference to it. Returns the renames (from → to), to be reported: a file that imports
|
|
98
|
+
* the type by its old name gets the class.
|
|
99
|
+
*/
|
|
100
|
+
export function renameTypesNamedLikeClasses(body) {
|
|
101
|
+
const classes = new Set();
|
|
102
|
+
const declared = new Set();
|
|
103
|
+
for (const s of body) {
|
|
104
|
+
const d = t.isExportNamedDeclaration(s) ? s.declaration : s;
|
|
105
|
+
if (t.isClassDeclaration(d) && d.id)
|
|
106
|
+
classes.add(d.id.name);
|
|
107
|
+
if ((t.isTSTypeAliasDeclaration(d) || t.isTSInterfaceDeclaration(d)) && d.id)
|
|
108
|
+
declared.add(d.id.name);
|
|
109
|
+
}
|
|
110
|
+
const renames = new Map();
|
|
111
|
+
for (const name of declared) {
|
|
112
|
+
if (!classes.has(name))
|
|
113
|
+
continue;
|
|
114
|
+
let to = `${name}Data`;
|
|
115
|
+
for (let i = 2; classes.has(to) || declared.has(to); i++)
|
|
116
|
+
to = `${name}Data${i}`;
|
|
117
|
+
renames.set(name, to);
|
|
118
|
+
}
|
|
119
|
+
if (!renames.size)
|
|
120
|
+
return renames;
|
|
121
|
+
for (const s of body)
|
|
122
|
+
t.traverseFast(s, (n) => {
|
|
123
|
+
if ((t.isTSTypeAliasDeclaration(n) || t.isTSInterfaceDeclaration(n)) && renames.has(n.id.name))
|
|
124
|
+
n.id.name = renames.get(n.id.name) ?? n.id.name;
|
|
125
|
+
else if (t.isTSTypeReference(n) && t.isIdentifier(n.typeName) && renames.has(n.typeName.name))
|
|
126
|
+
n.typeName.name = renames.get(n.typeName.name) ?? n.typeName.name;
|
|
127
|
+
else if (t.isExportSpecifier(n) && n.exportKind === 'type' && t.isIdentifier(n.local) && renames.has(n.local.name))
|
|
128
|
+
n.local.name = renames.get(n.local.name) ?? n.local.name;
|
|
129
|
+
});
|
|
130
|
+
return renames;
|
|
131
|
+
}
|
|
132
|
+
export function renameDecoratorNamedClasses(body) {
|
|
133
|
+
const renames = new Map();
|
|
134
|
+
for (const s of body) {
|
|
135
|
+
const decl = t.isExportNamedDeclaration(s) ? s.declaration : s;
|
|
136
|
+
if (t.isClassDeclaration(decl) && decl.id && DECORATOR_NAMES.has(decl.id.name))
|
|
137
|
+
renames.set(decl.id.name, `${decl.id.name}Component`);
|
|
138
|
+
}
|
|
139
|
+
if (!renames.size)
|
|
140
|
+
return body;
|
|
141
|
+
const rename = (n, parent) => {
|
|
142
|
+
if (t.isDecorator(n)) {
|
|
143
|
+
// the decorator's own name stays; its arguments (imports, providers) are renamed
|
|
144
|
+
if (t.isCallExpression(n.expression))
|
|
145
|
+
for (const a of n.expression.arguments)
|
|
146
|
+
rename(a, n.expression);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (t.isImportDeclaration(n))
|
|
150
|
+
return;
|
|
151
|
+
if (t.isIdentifier(n) && renames.has(n.name)) {
|
|
152
|
+
const isKey = parent && (t.isObjectProperty(parent) || t.isClassProperty(parent) || t.isClassMethod(parent)) && parent.key === n && !parent.computed;
|
|
153
|
+
const isMember = parent && (t.isMemberExpression(parent) || t.isOptionalMemberExpression(parent)) && parent.property === n && !parent.computed;
|
|
154
|
+
if (!isKey && !isMember)
|
|
155
|
+
n.name = renames.get(n.name) ?? n.name;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
for (const c of childNodes(n))
|
|
159
|
+
rename(c.node, n);
|
|
160
|
+
};
|
|
161
|
+
const out = [];
|
|
162
|
+
for (const s of body) {
|
|
163
|
+
if (t.isExportNamedDeclaration(s) && t.isClassDeclaration(s.declaration) && s.declaration.id && renames.has(s.declaration.id.name)) {
|
|
164
|
+
const name = s.declaration.id.name;
|
|
165
|
+
rename(s.declaration, s);
|
|
166
|
+
out.push(s.declaration, t.exportNamedDeclaration(null, [t.exportSpecifier(t.identifier(renames.get(name) ?? name), t.identifier(name))]));
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
rename(s, null);
|
|
170
|
+
out.push(s);
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* React values the emitted code still names (a React hook no rule converts, such as `useSyncExternalStore`): the React
|
|
176
|
+
* import is gone, so each is reported where it would otherwise fail as an unknown name.
|
|
177
|
+
*/
|
|
178
|
+
export function leftoverReactValues(mod, body) {
|
|
179
|
+
const react = new Set();
|
|
180
|
+
for (const decl of mod.imports) {
|
|
181
|
+
if (classifyImport(decl.source.value) !== 'react' || decl.importKind === 'type')
|
|
182
|
+
continue;
|
|
183
|
+
// named imports (`useSyncExternalStore`); the namespace (`React.Children`) is reported where it is read (react-runtime)
|
|
184
|
+
for (const s of decl.specifiers)
|
|
185
|
+
if (t.isImportSpecifier(s) && s.importKind !== 'type')
|
|
186
|
+
react.add(s.local.name);
|
|
187
|
+
}
|
|
188
|
+
const found = new Set();
|
|
189
|
+
if (!react.size)
|
|
190
|
+
return [];
|
|
191
|
+
const visit = (n, parent) => {
|
|
192
|
+
if (t.isTSType(n) || t.isTSTypeAnnotation(n) || t.isTSTypeParameterInstantiation(n) || t.isTSInterfaceDeclaration(n) || t.isTSTypeAliasDeclaration(n) || t.isImportDeclaration(n))
|
|
193
|
+
return;
|
|
194
|
+
if (t.isIdentifier(n)) {
|
|
195
|
+
const property = parent && (t.isMemberExpression(parent) || t.isOptionalMemberExpression(parent)) && parent.property === n && !parent.computed;
|
|
196
|
+
const key = parent && (t.isObjectProperty(parent) || t.isClassProperty(parent) || t.isClassMethod(parent) || t.isObjectMethod(parent)) && parent.key === n && !parent.computed;
|
|
197
|
+
if (!property && !key && react.has(n.name))
|
|
198
|
+
found.add(n.name);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
for (const c of childNodes(n))
|
|
202
|
+
visit(c.node, n);
|
|
203
|
+
};
|
|
204
|
+
for (const s of body)
|
|
205
|
+
visit(s, null);
|
|
206
|
+
return [...found].sort();
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The component a file exports under a name, followed through barrels (`export { PcCase } from './shell'`,
|
|
210
|
+
* `export * from './parts'`) and aliases (`export const Card = CardRoot`); `default` for the default export.
|
|
211
|
+
*/
|
|
212
|
+
export function exportedComponent(file, name, ctx, depth = 0) {
|
|
213
|
+
const mod = ctx.moduleOf?.(file);
|
|
214
|
+
if (!mod || depth > 8)
|
|
215
|
+
return null;
|
|
216
|
+
const own = name === 'default' ? mod.defaultExport : name;
|
|
217
|
+
const real = own ? (mod.aliases.get(own) ?? own) : null;
|
|
218
|
+
const found = real ? mod.components.find((c) => c.name === real) : undefined;
|
|
219
|
+
if (found)
|
|
220
|
+
return found;
|
|
221
|
+
for (const re of mod.reexports) {
|
|
222
|
+
const resolved = re.source ? resolveLocal(file, re.source.value, ctx.project) : null;
|
|
223
|
+
if (!resolved)
|
|
224
|
+
continue;
|
|
225
|
+
if (t.isExportAllDeclaration(re)) {
|
|
226
|
+
if (name === 'default')
|
|
227
|
+
continue;
|
|
228
|
+
const c = exportedComponent(resolved, name, ctx, depth + 1);
|
|
229
|
+
if (c)
|
|
230
|
+
return c;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
for (const s of re.specifiers) {
|
|
234
|
+
const exported = t.isIdentifier(s.exported) ? s.exported.name : s.exported.value;
|
|
235
|
+
if (exported !== name)
|
|
236
|
+
continue;
|
|
237
|
+
const local = t.isExportSpecifier(s) ? (t.isIdentifier(s.local) ? s.local.name : 'default') : t.isExportDefaultSpecifier(s) ? 'default' : null;
|
|
238
|
+
if (local)
|
|
239
|
+
return exportedComponent(resolved, local, ctx, depth + 1);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EmittedFile } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The directives Angular output brings along: each is a file of its own at the root of the output, written once per
|
|
4
|
+
* conversion, and every component that uses it imports it (plain code the user owns, with no runtime of morph's).
|
|
5
|
+
*/
|
|
6
|
+
export interface HelperDirective {
|
|
7
|
+
/** the class a component's `imports` lists */
|
|
8
|
+
name: string;
|
|
9
|
+
/** the file, relative to the output root */
|
|
10
|
+
path: string;
|
|
11
|
+
source: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const HELPER_DIRECTIVES: readonly HelperDirective[];
|
|
14
|
+
/** The files of the directives a module uses that this conversion has not written yet. */
|
|
15
|
+
export declare function helperFiles(conversion: object, used: readonly HelperDirective[]): EmittedFile[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BIND_REF, BIND_REF_FILE } from './refs.js';
|
|
2
|
+
import { SPREAD, SPREAD_FILE } from './spread.js';
|
|
3
|
+
import { MOTION, MOTION_FILE, MOTION_PRESENCE } from './motion-directive.js';
|
|
4
|
+
// M2: layout / layoutId and drag directives (motion-layout.ts)
|
|
5
|
+
import { MOTION_DRAG, MOTION_DRAG_FILE, MOTION_LAYOUT, MOTION_LAYOUT_FILE } from './motion-layout.js';
|
|
6
|
+
import { CONTROLLED, CONTROLLED_FILE } from './controlled.js';
|
|
7
|
+
import { MARKUP_NODE, MARKUP_NODE_FILE, MARKUP_NODE_PATH } from './bank/runtime.js';
|
|
8
|
+
export const HELPER_DIRECTIVES = [
|
|
9
|
+
{ name: BIND_REF, path: 'bind-ref.directive.ts', source: BIND_REF_FILE },
|
|
10
|
+
{ name: SPREAD, path: 'spread-props.directive.ts', source: SPREAD_FILE },
|
|
11
|
+
{ name: MOTION, path: 'motion.directive.ts', source: MOTION_FILE },
|
|
12
|
+
{ name: MOTION_PRESENCE, path: 'motion.directive.ts', source: MOTION_FILE },
|
|
13
|
+
// M2: each in a file of its own, written only when a component uses it
|
|
14
|
+
{ name: MOTION_LAYOUT, path: 'motion-layout.directive.ts', source: MOTION_LAYOUT_FILE },
|
|
15
|
+
{ name: MOTION_DRAG, path: 'motion-drag.directive.ts', source: MOTION_DRAG_FILE },
|
|
16
|
+
{ name: CONTROLLED, path: 'controlled.directive.ts', source: CONTROLLED_FILE },
|
|
17
|
+
{ name: MARKUP_NODE, path: MARKUP_NODE_PATH, source: MARKUP_NODE_FILE },
|
|
18
|
+
];
|
|
19
|
+
/** The helper files already written in one conversion (keyed by the conversion's diagnostics list, one per target run). */
|
|
20
|
+
const written = new WeakMap();
|
|
21
|
+
/** The files of the directives a module uses that this conversion has not written yet. */
|
|
22
|
+
export function helperFiles(conversion, used) {
|
|
23
|
+
const done = written.get(conversion) ?? new Set();
|
|
24
|
+
written.set(conversion, done);
|
|
25
|
+
const out = [];
|
|
26
|
+
for (const d of used) {
|
|
27
|
+
if (done.has(d.path))
|
|
28
|
+
continue;
|
|
29
|
+
done.add(d.path);
|
|
30
|
+
out.push({ path: d.path, contents: d.source, kind: 'module' });
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
/**
|
|
3
|
+
* An Angular component renders inside its host element (`<ui-label style="display: contents">`), where React's component
|
|
4
|
+
* leaves only its own elements. `display: contents` takes the host out of the box tree, so layout, inheritance and
|
|
5
|
+
* descendant selectors (`group-hover:`, `has-*`, `.a .b`) are as in React; selectors that count or cross element
|
|
6
|
+
* positions are not, because the host sits between a parent and the component's root element:
|
|
7
|
+
*
|
|
8
|
+
* - a parent's class that styles its children (`space-x-*`, `space-y-*`, `divide-*`, `*:`, `[&>…]`: Tailwind's
|
|
9
|
+
* `.space-x-2 > :not(:last-child)`) lands on the host, which has no box, not on the component's root;
|
|
10
|
+
* - a structural variant on the component's root (`first:`, `last:`, `only:`, `odd:`, `even:`, `nth-*`): the root is
|
|
11
|
+
* the only child of its host, so it is always first, last and only;
|
|
12
|
+
* - `peer` on the component's root, or a `peer-*` variant on it (`.peer:disabled ~ .peer-disabled\:opacity-50`): the
|
|
13
|
+
* root and the element before or after the host are not siblings.
|
|
14
|
+
*
|
|
15
|
+
* Each place a component of this conversion is rendered with such a class in that position is a located warning.
|
|
16
|
+
*/
|
|
17
|
+
/** A class string's tokens, from a static attribute or every string in its expression (`cn('a', on && 'b')`). */
|
|
18
|
+
function classTokens(el) {
|
|
19
|
+
const tokens = [];
|
|
20
|
+
let line = null;
|
|
21
|
+
for (const a of el.attrs) {
|
|
22
|
+
if ((a.kind !== 'static' && a.kind !== 'expr') || (a.name !== 'className' && a.name !== 'class'))
|
|
23
|
+
continue;
|
|
24
|
+
if (a.kind === 'static')
|
|
25
|
+
tokens.push(...a.value.split(/\s+/));
|
|
26
|
+
else {
|
|
27
|
+
line ??= a.expr.loc?.start.line ?? null;
|
|
28
|
+
t.traverseFast(a.expr, (n) => {
|
|
29
|
+
if (t.isStringLiteral(n))
|
|
30
|
+
tokens.push(...n.value.split(/\s+/));
|
|
31
|
+
else if (t.isTemplateElement(n))
|
|
32
|
+
tokens.push(...(n.value.cooked ?? n.value.raw).split(/\s+/));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return { tokens: tokens.filter(Boolean), line };
|
|
37
|
+
}
|
|
38
|
+
/** A class's variants and its utility (`md:hover:space-x-2` gives `md`, `hover` and `space-x-2`), brackets kept whole. */
|
|
39
|
+
function parts(token) {
|
|
40
|
+
const out = [];
|
|
41
|
+
let depth = 0;
|
|
42
|
+
let cur = '';
|
|
43
|
+
for (const c of token) {
|
|
44
|
+
if (c === '[')
|
|
45
|
+
depth++;
|
|
46
|
+
if (c === ']')
|
|
47
|
+
depth--;
|
|
48
|
+
if (c === ':' && depth === 0) {
|
|
49
|
+
out.push(cur);
|
|
50
|
+
cur = '';
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
cur += c;
|
|
54
|
+
}
|
|
55
|
+
return { variants: out, utility: cur.replace(/^!/, '') };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A class on a parent that styles its children by the child combinator, or null. (`space-x-*`, `space-y-*` and
|
|
59
|
+
* `divide-*` are not: the emitter gives such a parent's child hosts a box, `display: block` or `inline-block`, so the
|
|
60
|
+
* margin or border lands as in React; see AngularTemplate.hostSpacing, info `angular-host-spacing`.)
|
|
61
|
+
*/
|
|
62
|
+
function childStyling(token) {
|
|
63
|
+
const { variants } = parts(token);
|
|
64
|
+
if (variants.some((v) => v === '*' || (v.startsWith('[') && /[>+~]/.test(v))))
|
|
65
|
+
return token;
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const STRUCTURAL = /^(first|last|only|odd|even|first-of-type|last-of-type|only-of-type|nth-.+|nth-last-.+)$/;
|
|
69
|
+
/** A class on a component's root element that depends on its position among its siblings, or null. */
|
|
70
|
+
function positional(token) {
|
|
71
|
+
const { variants, utility } = parts(token);
|
|
72
|
+
if (utility === 'peer' || utility.startsWith('peer/'))
|
|
73
|
+
return token;
|
|
74
|
+
if (variants.some((v) => STRUCTURAL.test(v) || v.startsWith('peer-') || v.startsWith('peer/')))
|
|
75
|
+
return token;
|
|
76
|
+
if (variants.some((v) => v.startsWith('[') && /[+~]|:(first|last|only|nth)-/.test(v)))
|
|
77
|
+
return token;
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
/** The elements a component renders at its top: through fragments, conditions, keys and lists. */
|
|
81
|
+
function rootElements(node) {
|
|
82
|
+
switch (node.type) {
|
|
83
|
+
case 'element':
|
|
84
|
+
return [node];
|
|
85
|
+
case 'fragment':
|
|
86
|
+
case 'keyed':
|
|
87
|
+
case 'presence':
|
|
88
|
+
case 'for':
|
|
89
|
+
return node.children.flatMap(rootElements);
|
|
90
|
+
case 'if':
|
|
91
|
+
return node.branches.flatMap((b) => b.children.flatMap(rootElements));
|
|
92
|
+
default:
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// (M5: `ownElement`, a child that is its root element on Angular (a host form): no gap of its own, but its root's classes
|
|
97
|
+
// are what it shows to its siblings)
|
|
98
|
+
export function hostBoundaryGaps(comp, hosted, ownElement) {
|
|
99
|
+
const out = [];
|
|
100
|
+
const seen = new Set();
|
|
101
|
+
const say = (message, line) => {
|
|
102
|
+
if (seen.has(message))
|
|
103
|
+
return;
|
|
104
|
+
seen.add(message);
|
|
105
|
+
out.push({ message, line });
|
|
106
|
+
};
|
|
107
|
+
// the class tokens an element shows to its siblings: its own, or a hosted component's root elements'
|
|
108
|
+
const shown = (n) => {
|
|
109
|
+
if (n.type !== 'element')
|
|
110
|
+
return rootElements(n).flatMap(shown);
|
|
111
|
+
const child = n.component ? (hosted(n.tag) ?? ownElement?.(n.tag) ?? null) : null;
|
|
112
|
+
if (!child)
|
|
113
|
+
return classTokens(n).tokens;
|
|
114
|
+
return rootElements(child.template).flatMap((r) => (r.component ? [] : classTokens(r).tokens));
|
|
115
|
+
};
|
|
116
|
+
const isPeer = (tokens) => tokens.some((x) => parts(x).utility === 'peer' || parts(x).utility.startsWith('peer/'));
|
|
117
|
+
const peerTarget = (tokens) => tokens.some((x) => parts(x).variants.some((v) => v.startsWith('peer-') || v.startsWith('peer/')));
|
|
118
|
+
const visit = (n, parent, siblings, inLoop) => {
|
|
119
|
+
if (n.type === 'element') {
|
|
120
|
+
const child = n.component ? hosted(n.tag) : null;
|
|
121
|
+
if (child) {
|
|
122
|
+
const own = classTokens(n);
|
|
123
|
+
const at = own.line ?? comp.line ?? null;
|
|
124
|
+
if (parent) {
|
|
125
|
+
const p = classTokens(parent);
|
|
126
|
+
const styling = p.tokens.map(childStyling).find((x) => x !== null);
|
|
127
|
+
if (styling)
|
|
128
|
+
say(`<${parent.tag}> styles its children with "${styling}", and one of them is <${n.tag}>: in Angular the child is ${n.tag}'s host element (display: contents, no box of its own), not ${n.tag}'s root element, so the style does not reach it as it does in React.`, p.line ?? at);
|
|
129
|
+
}
|
|
130
|
+
const others = siblings.filter((s) => s !== n && !(s.type === 'text' && !s.value.trim()));
|
|
131
|
+
// (inside a condition or a fragment of the list, every other element of the list may be either side)
|
|
132
|
+
const at0 = siblings.indexOf(n);
|
|
133
|
+
const before = (at0 >= 0 ? siblings.slice(0, at0) : siblings).flatMap(shown);
|
|
134
|
+
const after = (at0 >= 0 ? siblings.slice(at0 + 1) : siblings).flatMap(shown);
|
|
135
|
+
for (const root of rootElements(child.template)) {
|
|
136
|
+
if (root.component)
|
|
137
|
+
continue;
|
|
138
|
+
const tokens = classTokens(root).tokens;
|
|
139
|
+
const structural = tokens.find((x) => parts(x).variants.some((v) => STRUCTURAL.test(v)));
|
|
140
|
+
if (structural && (others.length || inLoop))
|
|
141
|
+
say(`${n.tag}'s root element carries "${structural}", which depends on its place among its siblings; in Angular it is the only child of ${n.tag}'s host element, so it always matches as the first, last and only child.`, at);
|
|
142
|
+
const peer = (isPeer(tokens) && peerTarget(after)) || (peerTarget(tokens) && isPeer(before)) ? tokens.find((x) => positional(x) !== null) : undefined;
|
|
143
|
+
if (peer)
|
|
144
|
+
say(`${n.tag}'s root element carries "${peer}", which pairs it with a sibling of <${n.tag}> (Tailwind's peer, the ~ combinator); in Angular the root is inside ${n.tag}'s host element, not a sibling of that element, so the style does not apply as it does in React.`, at);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// markup passed to a child component is laid out inside that child: its parent is not this element
|
|
148
|
+
const next = n.component ? null : n;
|
|
149
|
+
for (const a of n.attrs)
|
|
150
|
+
if (a.kind === 'slotProp')
|
|
151
|
+
a.children.forEach((c) => visit(c, null, a.children, false));
|
|
152
|
+
n.children.forEach((c) => visit(c, next, n.children, false));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (n.type === 'if')
|
|
156
|
+
n.branches.forEach((b) => b.children.forEach((c) => visit(c, parent, siblings, inLoop)));
|
|
157
|
+
else if (n.type === 'for')
|
|
158
|
+
n.children.forEach((c) => visit(c, parent, siblings, true));
|
|
159
|
+
else if (n.type === 'fragment' || n.type === 'keyed' || n.type === 'presence')
|
|
160
|
+
n.children.forEach((c) => visit(c, parent, siblings, inLoop));
|
|
161
|
+
else if (n.type === 'slot')
|
|
162
|
+
n.fallback.forEach((c) => visit(c, parent, siblings, inLoop));
|
|
163
|
+
};
|
|
164
|
+
visit(comp.template, null, [comp.template], false);
|
|
165
|
+
return out;
|
|
166
|
+
}
|