@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,548 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { parse } from '@babel/parser';
|
|
3
|
+
import { forEachElement } from '../../../ir/radix.js';
|
|
4
|
+
import { templateExpressions } from '../../shared/inline.js';
|
|
5
|
+
import { HOST_FORMS, hostFormFor, noteValueReads } from '../host-form.js';
|
|
6
|
+
import { NG_RADIX } from './packages.js';
|
|
7
|
+
import { ngPart, ngType } from './part.js';
|
|
8
|
+
/** M3: the DOM event a React handler prop listens to (`onClick` → `click`, `onDoubleClick` → `dblclick`), its capture suffix aside. */
|
|
9
|
+
export function domEventName(react) {
|
|
10
|
+
const name = react.replace(/Capture$/, '').slice(2).toLowerCase();
|
|
11
|
+
return name === 'doubleclick' ? 'dblclick' : name;
|
|
12
|
+
}
|
|
13
|
+
/** Each claimed Radix element of the conversion, by node (set by prepareAngularRadix). */
|
|
14
|
+
export const NG_PLANS = new WeakMap();
|
|
15
|
+
const NEEDS = new WeakMap();
|
|
16
|
+
/** H6: a component that spreads its rest props onto a Radix part it keeps in its own template, and that part. */
|
|
17
|
+
const REST_PARTS = new WeakMap();
|
|
18
|
+
const REST_MAPS = new WeakMap();
|
|
19
|
+
/** The map of the Radix part a component's rest props reach (see REST_PARTS), if any. */
|
|
20
|
+
export function radixRestMapOf(comp) {
|
|
21
|
+
return comp ? REST_MAPS.get(comp) : undefined;
|
|
22
|
+
}
|
|
23
|
+
/** The Radix part a component's rest props reach in its own template (see REST_PARTS), if any. */
|
|
24
|
+
export function radixRestPartOf(comp) {
|
|
25
|
+
return comp ? REST_PARTS.get(comp) : undefined;
|
|
26
|
+
}
|
|
27
|
+
/** What a component's callers must place it inside (see RadixNeed). */
|
|
28
|
+
export function radixNeedsOf(comp) {
|
|
29
|
+
return (comp && NEEDS.get(comp)) ?? [];
|
|
30
|
+
}
|
|
31
|
+
function addNeed(comp, need) {
|
|
32
|
+
const list = NEEDS.get(comp) ?? [];
|
|
33
|
+
if (!list.some((n) => n.pkg === need.pkg && n.part === need.part))
|
|
34
|
+
list.push(need);
|
|
35
|
+
NEEDS.set(comp, list);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A part radix-ng mounts through a structural directive (NgPartMap.presence): the node becomes the `<ng-template>` that
|
|
39
|
+
* carries the directive, and the part's element (a copy of the node, with its plan) its one child.
|
|
40
|
+
*/
|
|
41
|
+
function wrapInPresence(el, presence) {
|
|
42
|
+
const inner = { ...el };
|
|
43
|
+
const plan = NG_PLANS.get(el);
|
|
44
|
+
if (plan)
|
|
45
|
+
NG_PLANS.set(inner, plan);
|
|
46
|
+
el.tag = 'ng-template';
|
|
47
|
+
el.component = false;
|
|
48
|
+
el.motion = null;
|
|
49
|
+
el.attrs = [];
|
|
50
|
+
el.children = [inner];
|
|
51
|
+
delete el.radix;
|
|
52
|
+
NG_PLANS.set(el, { map: ngPart('ng-template', { ...presence, exportAs: '' }), pkg: plan?.pkg ?? '', part: 'Presence', events: [] });
|
|
53
|
+
}
|
|
54
|
+
/** A plain part's Radix props as its element gave them, by element (a part below it may read them: stateFrom). */
|
|
55
|
+
const PLAIN_VALUES = new WeakMap();
|
|
56
|
+
/** The name an attribute has in React (the IR renames `className` to `class`). */
|
|
57
|
+
function reactName(a) {
|
|
58
|
+
if (a.kind === 'event')
|
|
59
|
+
return a.react;
|
|
60
|
+
if (a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool')
|
|
61
|
+
return a.name === 'class' ? 'className' : a.name;
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
/** Whether an element's markup projects the children its component is given (a `slot` node anywhere below it). */
|
|
65
|
+
function projectsChildren(el) {
|
|
66
|
+
const walk = (n) => {
|
|
67
|
+
switch (n.type) {
|
|
68
|
+
case 'slot':
|
|
69
|
+
return true;
|
|
70
|
+
case 'element':
|
|
71
|
+
return n.children.some(walk) || n.attrs.some((a) => a.kind === 'slotProp' && a.children.some(walk));
|
|
72
|
+
case 'if':
|
|
73
|
+
return n.branches.some((b) => b.children.some(walk));
|
|
74
|
+
case 'for':
|
|
75
|
+
case 'fragment':
|
|
76
|
+
case 'keyed':
|
|
77
|
+
case 'presence':
|
|
78
|
+
return n.children.some(walk);
|
|
79
|
+
default:
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return el.children.some(walk);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A part radix-ng writes as two elements (NgPartMap.outer): the node becomes the outer element, with the outer
|
|
87
|
+
* directive and the Radix props it takes, and the part's element (a copy of the node, with its plan and the rest of its
|
|
88
|
+
* attributes) its one child.
|
|
89
|
+
*/
|
|
90
|
+
function wrapInOuter(el, outer, pkg) {
|
|
91
|
+
const inner = { ...el };
|
|
92
|
+
const plan = NG_PLANS.get(el);
|
|
93
|
+
if (plan)
|
|
94
|
+
NG_PLANS.set(inner, plan);
|
|
95
|
+
const mine = (a) => (a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool') && Object.hasOwn(outer.inputs, a.name);
|
|
96
|
+
inner.attrs = el.attrs.filter((a) => !mine(a));
|
|
97
|
+
el.tag = outer.tag;
|
|
98
|
+
el.component = false;
|
|
99
|
+
el.motion = null;
|
|
100
|
+
el.attrs = el.attrs.filter(mine);
|
|
101
|
+
el.children = [inner];
|
|
102
|
+
delete el.radix;
|
|
103
|
+
NG_PLANS.set(el, { map: ngPart(outer.tag, outer.directive, { inputs: { ...outer.inputs } }), pkg, part: 'Outer', events: [] });
|
|
104
|
+
}
|
|
105
|
+
/** What a part's differences read from the attributes an element gives it (NgPartMap.differencesAt). */
|
|
106
|
+
export function writtenContext(attrs) {
|
|
107
|
+
const find = (prop) => attrs.find((x) => reactName(x) === prop);
|
|
108
|
+
return {
|
|
109
|
+
literal: (prop) => {
|
|
110
|
+
const a = find(prop);
|
|
111
|
+
return a?.kind === 'static' ? a.value : undefined;
|
|
112
|
+
},
|
|
113
|
+
given: (prop) => find(prop) !== undefined,
|
|
114
|
+
isTrue: (prop) => {
|
|
115
|
+
const a = find(prop);
|
|
116
|
+
return a?.kind === 'bool' || (a?.kind === 'expr' && t.isBooleanLiteral(a.expr, { value: true }));
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** The value an attribute gives, as an expression (`checked` alone is true). */
|
|
121
|
+
function valueOf(a) {
|
|
122
|
+
return a.kind === 'static' ? t.stringLiteral(a.value) : a.kind === 'bool' ? t.booleanLiteral(true) : a.expr;
|
|
123
|
+
}
|
|
124
|
+
function lineOf(el) {
|
|
125
|
+
for (const a of el.attrs) {
|
|
126
|
+
const e = a.kind === 'event' ? a.handler : 'expr' in a ? a.expr : null;
|
|
127
|
+
const line = e?.loc?.start.line;
|
|
128
|
+
if (line)
|
|
129
|
+
return line;
|
|
130
|
+
}
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Prepares the claimed Radix parts of one module for the Angular emitter, before any module is emitted (a parent in
|
|
135
|
+
* another file reads this module's components as they are now). Each claimed element becomes the element Radix renders
|
|
136
|
+
* (`<TogglePrimitive.Root>` → `<button>`): a plain part gets Radix's attributes computed from its props; a directive
|
|
137
|
+
* part is printed with its directive by the template (template.ts). A component that takes the part's props as its own
|
|
138
|
+
* and spreads its rest onto the part (shadcn's `{ className, ...props }: React.ComponentProps<typeof
|
|
139
|
+
* TogglePrimitive.Root>`) takes each mapped Radix prop and callback as a prop of its own, passed on to the part, and its
|
|
140
|
+
* other rest props as the element's attributes (the HTML rest props of `<button {...props}>`).
|
|
141
|
+
*/
|
|
142
|
+
export function prepareAngularRadix(mod, packages, diagnostics) {
|
|
143
|
+
// M5: the names this module reads as values, for every module of the conversion before any is emitted (the plain
|
|
144
|
+
// host form, host-form.ts plainHostFor); the diagnostics list is the conversion's own
|
|
145
|
+
noteValueReads(mod, diagnostics);
|
|
146
|
+
if (!mod.radix)
|
|
147
|
+
return;
|
|
148
|
+
// a binding claimRadix claimed has left the imports; one still there is refused, and its elements stay as they are
|
|
149
|
+
const imported = new Set(mod.imports.flatMap((d) => d.specifiers.map((s) => s.local.name)));
|
|
150
|
+
const extras = new Map();
|
|
151
|
+
const clicks = [];
|
|
152
|
+
// a module function a plain part's attributes call: declared once in the module, under a name the module leaves free
|
|
153
|
+
const declared = new Map();
|
|
154
|
+
const helper = (h) => {
|
|
155
|
+
const known = declared.get(h.name);
|
|
156
|
+
if (known !== undefined)
|
|
157
|
+
return known;
|
|
158
|
+
const taken = new Set([...mod.moduleBody.flatMap((st) => Object.keys(t.getOuterBindingIdentifiers(st))), ...mod.imports.flatMap((d) => d.specifiers.map((sp) => sp.local.name)), ...mod.components.map((c) => c.name)]);
|
|
159
|
+
let local = h.name;
|
|
160
|
+
for (let i = 2; taken.has(local); i++)
|
|
161
|
+
local = `${h.name}${i}`;
|
|
162
|
+
mod.moduleBody.push(...parse(h.source(local), { sourceType: 'module', plugins: ['typescript'] }).program.body);
|
|
163
|
+
declared.set(h.name, local);
|
|
164
|
+
return local;
|
|
165
|
+
};
|
|
166
|
+
for (const comp of mod.components) {
|
|
167
|
+
// (H6: the first element of the component that injects each directive, whose member the others share)
|
|
168
|
+
const injecting = new Map();
|
|
169
|
+
walkElements(comp, (el, above) => {
|
|
170
|
+
const part = el.radix;
|
|
171
|
+
if (!part || !el.component || !packages.has(part.pkg))
|
|
172
|
+
return;
|
|
173
|
+
const local = el.tag.split('.')[0] ?? el.tag;
|
|
174
|
+
if (imported.has(local))
|
|
175
|
+
return;
|
|
176
|
+
const parts = NG_RADIX[part.pkg];
|
|
177
|
+
const map = parts && Object.hasOwn(parts, part.part) ? parts[part.part] : undefined;
|
|
178
|
+
if (!map)
|
|
179
|
+
return;
|
|
180
|
+
// a part whose state reads another part's directive: inside it in the same template (a template reference), or (H6)
|
|
181
|
+
// inside the element its component's callers place it in (the directive injected by the component, the need
|
|
182
|
+
// checked where each caller writes the component, see radixNeedsAt)
|
|
183
|
+
const ancestor = map.stateFrom ? [...above].reverse().find((a) => a.radix?.pkg === part.pkg && a.radix.part === map.stateFrom) : undefined;
|
|
184
|
+
const stateDirective = map.stateFrom && !ancestor ? parts?.[map.stateFrom]?.directive : undefined;
|
|
185
|
+
if (map.stateFrom && !ancestor && !stateDirective) {
|
|
186
|
+
const message = `<${el.tag}> (Radix ${part.pkg} ${part.part}) is not inside its ${map.stateFrom} in the same component: radix-ng's ${map.name} reads its ${map.stateFrom} through the element tree, and Radix's data-state on it cannot be read here; not converted.`;
|
|
187
|
+
diagnostics.push({ code: 'radix-prop', severity: 'error', message, file: mod.file, target: 'angular', ...(lineOf(el) ? { line: lineOf(el) } : {}) });
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
// H6: a component whose root is this part becomes the part's element itself (host-form.ts)
|
|
191
|
+
const host = el === comp.template && map.directive && !map.presence && (!map.stateFrom || stateDirective) ? hostFormFor(mod, comp, el, map, part.pkg, part.part) : null;
|
|
192
|
+
// a part radix-ng finds its root through the injector: inside that root's element here, or inside the element its
|
|
193
|
+
// component's callers place it in (an element of that part, or a component in the host form that is one)
|
|
194
|
+
const within = map.within ? [...above].reverse().find((a) => a.radix?.pkg === part.pkg && a.radix.part === map.within) : undefined;
|
|
195
|
+
// a provider whose children a component projects: they are declared in its caller's template, where the provider
|
|
196
|
+
// inside this component's own template is not above them (NgPartMap.providesToChildren)
|
|
197
|
+
if (map.providesToChildren && projectsChildren(el)) {
|
|
198
|
+
const message = `<${el.tag}> (Radix ${part.pkg} ${part.part}) holds children this component is given: radix-ng's ${map.name} reaches the parts below it through Angular's injector, and children a component projects are declared in its caller's template, where this provider is not above them; not converted (write the provider where its parts are written).`;
|
|
199
|
+
const line = lineOf(el) ?? comp.line;
|
|
200
|
+
diagnostics.push({ code: 'radix-prop', severity: 'error', message, file: mod.file, target: 'angular', ...(line ? { line } : {}) });
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
// a part that converts only as a host-form root (NgPartMap.hostOnly)
|
|
204
|
+
if (map.hostOnly && !host) {
|
|
205
|
+
const message = `<${el.tag}> (Radix ${part.pkg} ${part.part}): ${map.hostOnly}; here it is not the one root element of an exported component that spreads its rest props onto it: not converted.`;
|
|
206
|
+
const line = lineOf(el) ?? comp.line;
|
|
207
|
+
diagnostics.push({ code: 'radix-prop', severity: 'error', message, file: mod.file, target: 'angular', ...(line ? { line } : {}) });
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const needs = [...(map.within && !within ? [map.within] : []), ...(stateDirective && map.stateFrom && map.stateFrom !== map.within ? [map.stateFrom] : [])];
|
|
211
|
+
for (const need of needs)
|
|
212
|
+
addNeed(comp, { pkg: part.pkg, part: need, by: `<${el.tag}> (Radix ${part.pkg} ${part.part})`, directive: map.name });
|
|
213
|
+
// a prop another prop's value shape follows must be a literal where the part is written (the host form: where its
|
|
214
|
+
// caller writes it, see host-form.ts)
|
|
215
|
+
if (!host) {
|
|
216
|
+
const restSpread = !!comp.rest && el.attrs.some((a) => a.kind === 'spread' && t.isIdentifier(a.expr, { name: comp.rest ?? '' }));
|
|
217
|
+
for (const [key, prop] of Object.entries(map.inputs)) {
|
|
218
|
+
if (!prop.literal)
|
|
219
|
+
continue;
|
|
220
|
+
const given = el.attrs.find((a) => reactName(a) === key);
|
|
221
|
+
if (given ? given.kind === 'static' : !restSpread || comp.props.some((p) => p.key === key))
|
|
222
|
+
continue;
|
|
223
|
+
const message = `<${el.tag}> (Radix ${part.pkg} ${part.part}): ${key} must be written here as a string literal, as radix-ng's value shapes follow it (${map.name} takes ${prop.input ?? key}); ${given ? 'it is a value' : 'it comes through the rest props'}: not converted.`;
|
|
224
|
+
diagnostics.push({ code: 'radix-prop', severity: 'error', message, file: mod.file, target: 'angular', ...(lineOf(el) ? { line: lineOf(el) } : {}) });
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (map.differs) {
|
|
229
|
+
const line = lineOf(el) ?? comp.line;
|
|
230
|
+
diagnostics.push({ code: 'radix-behaviour', severity: 'warning', message: `<${el.tag}> (Radix ${part.pkg} ${part.part}): ${map.differs}.`, file: mod.file, target: 'angular', ...(line ? { line } : {}) });
|
|
231
|
+
}
|
|
232
|
+
// differences that follow the props where the part is written: here, or (host form) at its callers
|
|
233
|
+
if (map.differencesAt && !host) {
|
|
234
|
+
for (const why of map.differencesAt(writtenContext(el.attrs))) {
|
|
235
|
+
const line = lineOf(el) ?? comp.line;
|
|
236
|
+
diagnostics.push({ code: 'radix-behaviour', severity: 'warning', message: `<${el.tag}> (Radix ${part.pkg} ${part.part}): ${why}.`, file: mod.file, target: 'angular', ...(line ? { line } : {}) });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// a Radix prop radix-ng needs no input for (NgPartMap.drops) leaves the element
|
|
240
|
+
if (map.drops)
|
|
241
|
+
el.attrs = el.attrs.filter((a) => !Object.hasOwn(map.drops ?? {}, reactName(a) ?? ''));
|
|
242
|
+
if (map.clickDiffers)
|
|
243
|
+
clicks.push({ el, comp, why: map.clickDiffers, where: `<${el.tag}> (Radix ${part.pkg} ${part.part})` });
|
|
244
|
+
if (host) {
|
|
245
|
+
// the caller's own attributes land on the host element, as React spreads them onto the part: no rest input
|
|
246
|
+
el.attrs = el.attrs.filter((a) => !(a.kind === 'spread' && t.isIdentifier(a.expr, { name: comp.rest ?? '' })));
|
|
247
|
+
comp.rest = null;
|
|
248
|
+
HOST_FORMS.set(comp, host);
|
|
249
|
+
// (a part that renders no element: the root's own attributes go nowhere, in React and in the output: a note)
|
|
250
|
+
if (host.contents)
|
|
251
|
+
for (const a of el.attrs) {
|
|
252
|
+
const name = reactName(a);
|
|
253
|
+
if (name === null || a.kind === 'event' || Object.hasOwn(map.inputs, name))
|
|
254
|
+
continue;
|
|
255
|
+
diagnostics.push({ code: 'radix-ignored', severity: 'info', message: `${name} on <${el.tag}> (Radix ${part.pkg} ${part.part}) is ignored: Radix renders no element for this part and passes nothing but its own props on, and neither does the Angular output.`, file: mod.file, target: 'angular', ...(lineOf(el) ?? comp.line ? { line: lineOf(el) ?? comp.line } : {}) });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else if (map.tag === 'ng-template' || map.tag === 'ng-container') {
|
|
259
|
+
// a part Radix renders no element for (Dialog's Portal): Radix reads its own props and passes nothing else on
|
|
260
|
+
// (read from its source), so another attribute given to it goes nowhere in React either, said as a note; Radix's
|
|
261
|
+
// own props stay for the directive; the rest props reach no element, and their callers are checked where they
|
|
262
|
+
// give them (radixNeedsAt: a refused Radix prop is an error there, anything else the same note)
|
|
263
|
+
const keep = (a) => a.kind === 'slotProp' || (a.kind === 'event' ? Object.hasOwn(map.outputs, a.react) : (a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool') && Object.hasOwn(map.inputs, a.name));
|
|
264
|
+
const restSpread = (a) => a.kind === 'spread' && !!comp.rest && t.isIdentifier(a.expr, { name: comp.rest });
|
|
265
|
+
for (const a of el.attrs) {
|
|
266
|
+
if (keep(a) || restSpread(a))
|
|
267
|
+
continue;
|
|
268
|
+
const name = reactName(a) ?? (a.kind === 'spread' ? 'a spread' : a.kind);
|
|
269
|
+
diagnostics.push({ code: 'radix-ignored', severity: 'info', message: `${name} on <${el.tag}> (Radix ${part.pkg} ${part.part}) is ignored: Radix renders no element for this part and passes nothing but its own props on, and neither does the Angular output.`, file: mod.file, target: 'angular', ...(lineOf(el) ? { line: lineOf(el) } : {}) });
|
|
270
|
+
}
|
|
271
|
+
if (el.attrs.some(restSpread) && !REST_PARTS.has(comp)) {
|
|
272
|
+
REST_PARTS.set(comp, `<${el.tag}> (Radix ${part.pkg} ${part.part})`);
|
|
273
|
+
REST_MAPS.set(comp, map);
|
|
274
|
+
}
|
|
275
|
+
el.attrs = el.attrs.filter(keep);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
takeRestProps(comp, el, map);
|
|
279
|
+
// (H6: the rest props reach this part: an asChild a caller gives the component would reach it too)
|
|
280
|
+
if (comp.rest && el.attrs.some((a) => a.kind === 'spread' && t.isIdentifier(a.expr, { name: comp.rest ?? '' })) && !REST_PARTS.has(comp)) {
|
|
281
|
+
REST_PARTS.set(comp, `<${el.tag}> (Radix ${part.pkg} ${part.part})`);
|
|
282
|
+
REST_MAPS.set(comp, map);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
retypeProps(comp, map);
|
|
286
|
+
el.tag = map.tag;
|
|
287
|
+
el.component = false;
|
|
288
|
+
// (M3: the element is a DOM element now: a DOM handler written on the part, `onClick`, carried React's name as a
|
|
289
|
+
// component's; it listens under the DOM event's name, as on any element; Radix's callbacks stay the directive's)
|
|
290
|
+
el.attrs = el.attrs.map((a) => (a.kind === 'event' && !Object.hasOwn(map.outputs, a.react) ? { ...a, name: domEventName(a.react) } : a));
|
|
291
|
+
if (map.plainAttrs)
|
|
292
|
+
writePlain(comp, el, map, ancestor, helper);
|
|
293
|
+
else {
|
|
294
|
+
// Radix's callbacks leave the element now: they are the directive's outputs, never DOM listeners, and a handler
|
|
295
|
+
// left in the markup would read as a callback the component tests (an input holding a function, not an output)
|
|
296
|
+
const events = el.attrs.filter((a) => a.kind === 'event' && Object.hasOwn(map.outputs, a.react));
|
|
297
|
+
el.attrs = el.attrs.filter((a) => !events.includes(a));
|
|
298
|
+
NG_PLANS.set(el, { map, pkg: part.pkg, part: part.part, events, ...(ancestor ? { ancestor } : {}), ...(host ? { host: true } : {}), ...(stateDirective ? { injectState: stateDirective } : {}), ...(stateDirective && injecting.has(stateDirective.name) ? { injectOwner: injecting.get(stateDirective.name) } : {}) });
|
|
299
|
+
if (stateDirective && !injecting.has(stateDirective.name))
|
|
300
|
+
injecting.set(stateDirective.name, el);
|
|
301
|
+
if (map.presence)
|
|
302
|
+
wrapInPresence(el, map.presence);
|
|
303
|
+
if (map.outer)
|
|
304
|
+
wrapInOuter(el, map.outer, part.pkg);
|
|
305
|
+
}
|
|
306
|
+
for (const attr of map.extraAttributes ?? [])
|
|
307
|
+
if (!extras.has(attr))
|
|
308
|
+
extras.set(attr, lineOf(el));
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
// a click handler on a part whose radix-ng directive handles clicks differently: on the part itself, or given by a
|
|
312
|
+
// caller of this module to a component that spreads its rest props onto the part
|
|
313
|
+
const isClick = (a) => a.kind === 'event' && a.react === 'onClick';
|
|
314
|
+
for (const { el, comp, why, where } of clicks) {
|
|
315
|
+
const lines = [];
|
|
316
|
+
const own = el.attrs.find(isClick);
|
|
317
|
+
if (own?.kind === 'event')
|
|
318
|
+
lines.push(own.handler.loc?.start.line);
|
|
319
|
+
const rest = comp.rest;
|
|
320
|
+
if (rest && el.attrs.some((a) => a.kind === 'spread' && t.isIdentifier(a.expr, { name: rest }))) {
|
|
321
|
+
for (const caller of mod.components) {
|
|
322
|
+
forEachElement(caller, (c) => {
|
|
323
|
+
const given = c.component && c.tag === comp.name ? c.attrs.find(isClick) : undefined;
|
|
324
|
+
if (given?.kind === 'event')
|
|
325
|
+
lines.push(given.handler.loc?.start.line);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
for (const line of lines)
|
|
330
|
+
diagnostics.push({ code: 'radix-behaviour', severity: 'warning', message: `${where}: ${why}.`, file: mod.file, target: 'angular', ...(line ? { line } : {}) });
|
|
331
|
+
}
|
|
332
|
+
// (M3: morph's slider core reads its own dir only, not a DirectionProvider's, which is radix-ng's here: said at each
|
|
333
|
+
// slider of a file that renders a provider)
|
|
334
|
+
const parts = [];
|
|
335
|
+
for (const comp of mod.components)
|
|
336
|
+
forEachElement(comp, (el) => void (el.radix && parts.push({ el, pkg: el.radix.pkg, part: el.radix.part, line: lineOf(el) ?? comp.line })));
|
|
337
|
+
// (M3: children a component projects into the alert dialog's Portal are made once, by the template that declares them)
|
|
338
|
+
for (const p of parts) {
|
|
339
|
+
if (p.pkg !== 'alert-dialog' || p.part !== 'Portal' || !projectsChildren(p.el))
|
|
340
|
+
continue;
|
|
341
|
+
const line = p.line;
|
|
342
|
+
diagnostics.push({ code: 'radix-behaviour', severity: 'warning', message: "children this component passes into the alert dialog's Portal are made once by the template that declares them, so what they hold (an input's text, a checkbox) stays between openings, where Radix makes them again each time the dialog opens.", file: mod.file, target: 'angular', ...(line ? { line } : {}) });
|
|
343
|
+
}
|
|
344
|
+
if (parts.some((p) => p.pkg === 'direction')) {
|
|
345
|
+
for (const p of parts) {
|
|
346
|
+
if (p.pkg !== 'slider' || p.part !== 'Root')
|
|
347
|
+
continue;
|
|
348
|
+
const line = p.line;
|
|
349
|
+
diagnostics.push({ code: 'radix-behaviour', severity: 'warning', message: "Radix's Slider reads the direction of a DirectionProvider above it; morph's Angular slider follows its own dir (else ltr), so a provider's dir does not reach it.", file: mod.file, target: 'angular', ...(line ? { line } : {}) });
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
// an attribute radix-ng sets and Radix does not: a class of this module that reads it matches on Angular only
|
|
353
|
+
for (const [attr, line] of extras) {
|
|
354
|
+
if (!readsAttribute(mod, attr))
|
|
355
|
+
continue;
|
|
356
|
+
diagnostics.push({ code: 'radix-data', severity: 'warning', message: `radix-ng sets ${attr} where Radix does not: a class name of this file that reads it applies on Angular only.`, file: mod.file, target: 'angular', ...(line ? { line } : {}) });
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* The component spreads its rest props onto the part: each Radix prop and callback the part maps that the element is not
|
|
361
|
+
* given by name and the component does not take itself is a prop of the component, passed on by name (a Radix prop in
|
|
362
|
+
* an Angular component's rest would be set as an attribute, not on the directive).
|
|
363
|
+
*/
|
|
364
|
+
function takeRestProps(comp, el, map) {
|
|
365
|
+
const rest = comp.rest;
|
|
366
|
+
if (!rest || comp.propsStyle !== 'destructured')
|
|
367
|
+
return;
|
|
368
|
+
const at = el.attrs.findIndex((a) => a.kind === 'spread' && t.isIdentifier(a.expr, { name: rest }));
|
|
369
|
+
if (at < 0)
|
|
370
|
+
return;
|
|
371
|
+
const given = new Set(el.attrs.map((a) => (a.kind === 'style' ? 'style' : reactName(a))).filter((n) => n !== null));
|
|
372
|
+
const own = new Set(comp.props.map((p) => p.key));
|
|
373
|
+
const added = [];
|
|
374
|
+
const alloc = (key) => {
|
|
375
|
+
let name = key;
|
|
376
|
+
for (let i = 2; comp.bindings.has(name) || comp.props.some((p) => p.local === name); i++)
|
|
377
|
+
name = `${key}${i}`;
|
|
378
|
+
return name;
|
|
379
|
+
};
|
|
380
|
+
const declare = (key, kind, type) => {
|
|
381
|
+
const local = alloc(key);
|
|
382
|
+
comp.props.push({ key, local, defaultValue: null, kind, type, optional: true, inherited: true, doc: null, templateDefault: null });
|
|
383
|
+
comp.bindings.set(local, { name: local, kind: 'prop', reactive: true });
|
|
384
|
+
const id = t.identifier(local);
|
|
385
|
+
comp.refs.set(id, local);
|
|
386
|
+
return id;
|
|
387
|
+
};
|
|
388
|
+
// (and those an outer element takes: NgPartMap.outer)
|
|
389
|
+
for (const [key, prop] of Object.entries({ ...map.inputs, ...map.outer?.inputs })) {
|
|
390
|
+
if (given.has(key) || own.has(key) || prop.attribute)
|
|
391
|
+
continue;
|
|
392
|
+
const id = declare(key, prop.type === 'style' ? 'style' : 'value', ngType(prop.type));
|
|
393
|
+
added.push(prop.type === 'style' ? { kind: 'style', expr: id } : { kind: 'expr', name: key, expr: id });
|
|
394
|
+
}
|
|
395
|
+
for (const [key, out] of Object.entries(map.outputs)) {
|
|
396
|
+
if (given.has(key) || own.has(key))
|
|
397
|
+
continue;
|
|
398
|
+
const param = t.identifier('value');
|
|
399
|
+
param.typeAnnotation = t.tsTypeAnnotation(ngType(out.payload) ?? t.tsUnknownKeyword());
|
|
400
|
+
const type = t.tsFunctionType(null, [param], t.tsTypeAnnotation(t.tsVoidKeyword()));
|
|
401
|
+
added.push({ kind: 'event', name: out.output, react: key, capture: false, handler: declare(key, 'event', type) });
|
|
402
|
+
}
|
|
403
|
+
el.attrs.splice(at, 0, ...added);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Props typed as the part's own (`React.ComponentProps<typeof TogglePrimitive.Root>`) are the attributes of the element
|
|
407
|
+
* Radix renders (`React.ComponentProps<'button'>`) on Angular, its Radix props being the component's own (see
|
|
408
|
+
* takeRestProps). (A prop the component destructures keeps the type React's checker gives it.)
|
|
409
|
+
*/
|
|
410
|
+
function retypeProps(comp, map) {
|
|
411
|
+
let retyped = false;
|
|
412
|
+
const visit = (type) => {
|
|
413
|
+
if (!type)
|
|
414
|
+
return;
|
|
415
|
+
t.traverseFast(type, (n) => {
|
|
416
|
+
if (!t.isTSTypeReference(n) || !n.typeParameters)
|
|
417
|
+
return;
|
|
418
|
+
const name = t.isIdentifier(n.typeName) ? n.typeName.name : t.isTSQualifiedName(n.typeName) ? n.typeName.right.name : '';
|
|
419
|
+
if (!/^(ComponentProps|ComponentPropsWithoutRef|ComponentPropsWithRef|ElementRef|ComponentRef)$/.test(name))
|
|
420
|
+
return;
|
|
421
|
+
n.typeParameters.params = n.typeParameters.params.map((p) => {
|
|
422
|
+
if (!t.isTSTypeQuery(p))
|
|
423
|
+
return p;
|
|
424
|
+
retyped = true;
|
|
425
|
+
return t.tsLiteralType(t.stringLiteral(map.tag));
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
};
|
|
429
|
+
visit(comp.propsType);
|
|
430
|
+
comp.propsHeritage.forEach(visit);
|
|
431
|
+
if (retyped && comp.extendsHtml && !comp.extendsHtml.anyElement)
|
|
432
|
+
comp.extendsHtml = { ...comp.extendsHtml, element: map.tag };
|
|
433
|
+
}
|
|
434
|
+
/** A plain part: Radix's attributes, computed from the props the element gives, before the element's own. */
|
|
435
|
+
function writePlain(comp, el, map, ancestor, helper) {
|
|
436
|
+
const values = new Map();
|
|
437
|
+
const kept = [];
|
|
438
|
+
for (const a of el.attrs) {
|
|
439
|
+
const name = reactName(a);
|
|
440
|
+
if (name !== null && a.kind !== 'event' && Object.hasOwn(map.inputs, name) && (a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool'))
|
|
441
|
+
values.set(name, valueOf(a));
|
|
442
|
+
// a part that takes its style as a prop (a wrapper's: AspectRatio) computes the element's style from it
|
|
443
|
+
else if (a.kind === 'style' && map.wrapper)
|
|
444
|
+
values.set('style', a.expr);
|
|
445
|
+
else
|
|
446
|
+
kept.push(a);
|
|
447
|
+
}
|
|
448
|
+
PLAIN_VALUES.set(el, values);
|
|
449
|
+
const own = new Set(kept.map(reactName));
|
|
450
|
+
// the props the attributes read: the part's own, or (stateFrom) the part's above it
|
|
451
|
+
const from = ancestor ? (PLAIN_VALUES.get(ancestor) ?? new Map()) : values;
|
|
452
|
+
// each read is a copy whose names still resolve to the component's bindings
|
|
453
|
+
const get = (prop) => {
|
|
454
|
+
const v = from.get(prop);
|
|
455
|
+
return v ? linkedClone(v, comp.refs) : null;
|
|
456
|
+
};
|
|
457
|
+
const computed = map.plainAttrs?.(get, helper) ?? {};
|
|
458
|
+
const radix = Object.entries(computed)
|
|
459
|
+
.filter(([name, e]) => !own.has(name) && !t.isIdentifier(e, { name: 'undefined' }))
|
|
460
|
+
.map(([name, e]) => (t.isStringLiteral(e) ? { kind: 'static', name, value: e.value } : { kind: 'expr', name, expr: e }));
|
|
461
|
+
const wrapper = map.wrapper;
|
|
462
|
+
if (!wrapper) {
|
|
463
|
+
el.attrs = [...radix, ...kept];
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
// Radix renders an element of its own around the part's: this node becomes it, and the part's element its one child
|
|
467
|
+
const style = get('style');
|
|
468
|
+
const inner = { type: 'element', tag: map.tag, component: false, motion: null, attrs: [...radix, ...kept, { kind: 'style', expr: wrapper.innerStyle(style) }], children: el.children };
|
|
469
|
+
el.tag = wrapper.tag;
|
|
470
|
+
el.attrs = [...Object.entries(wrapper.attrs).map(([name, value]) => ({ kind: 'static', name, value })), { kind: 'style', expr: wrapper.style(get) }];
|
|
471
|
+
el.children = [inner];
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Calls `visit` on every element of a component's markup, as ir/radix forEachElement walks it, with the elements above
|
|
475
|
+
* it in the same template (an element's own attributes are visited before its children).
|
|
476
|
+
*/
|
|
477
|
+
function walkElements(comp, visit) {
|
|
478
|
+
const walk = (n, above) => {
|
|
479
|
+
switch (n.type) {
|
|
480
|
+
case 'element': {
|
|
481
|
+
visit(n, above);
|
|
482
|
+
const inner = [...above, n];
|
|
483
|
+
for (const a of n.attrs)
|
|
484
|
+
if (a.kind === 'slotProp')
|
|
485
|
+
a.children.forEach((c) => walk(c, inner));
|
|
486
|
+
n.children.forEach((c) => walk(c, inner));
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
case 'if':
|
|
490
|
+
for (const b of n.branches)
|
|
491
|
+
b.children.forEach((c) => walk(c, above));
|
|
492
|
+
return;
|
|
493
|
+
case 'slot':
|
|
494
|
+
n.fallback.forEach((c) => walk(c, above));
|
|
495
|
+
return;
|
|
496
|
+
case 'for':
|
|
497
|
+
case 'fragment':
|
|
498
|
+
case 'keyed':
|
|
499
|
+
case 'presence':
|
|
500
|
+
n.children.forEach((c) => walk(c, above));
|
|
501
|
+
return;
|
|
502
|
+
default:
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
walk(comp.template, []);
|
|
507
|
+
for (const f of comp.fragments)
|
|
508
|
+
walk(f.template, []);
|
|
509
|
+
}
|
|
510
|
+
/** A deep copy of an expression whose identifiers resolve to the same bindings as the original's (FunctionIR.refs). */
|
|
511
|
+
function linkedClone(e, refs) {
|
|
512
|
+
const copy = t.cloneNode(e, true, false);
|
|
513
|
+
const from = [];
|
|
514
|
+
const to = [];
|
|
515
|
+
t.traverseFast(e, (n) => void from.push(n));
|
|
516
|
+
t.traverseFast(copy, (n) => void to.push(n));
|
|
517
|
+
from.forEach((n, i) => {
|
|
518
|
+
const name = refs.get(n);
|
|
519
|
+
const twin = to[i];
|
|
520
|
+
if (name !== undefined && twin)
|
|
521
|
+
refs.set(twin, name);
|
|
522
|
+
});
|
|
523
|
+
return copy;
|
|
524
|
+
}
|
|
525
|
+
/** Whether a string of the module (a class name) reads a data attribute (`data-[pressed]:…`, `[data-pressed]`). */
|
|
526
|
+
function readsAttribute(mod, attr) {
|
|
527
|
+
const bare = attr.replace(/^data-/, '');
|
|
528
|
+
const pattern = new RegExp(`data-\\[${bare}[\\]=]|\\[${attr}[\\]=]|data-${bare}:`);
|
|
529
|
+
let found = false;
|
|
530
|
+
const look = (root) => {
|
|
531
|
+
t.traverseFast(root, (n) => {
|
|
532
|
+
if ((t.isStringLiteral(n) && pattern.test(n.value)) || (t.isTemplateElement(n) && pattern.test(n.value.raw)))
|
|
533
|
+
found = true;
|
|
534
|
+
});
|
|
535
|
+
};
|
|
536
|
+
for (const st of mod.moduleBody)
|
|
537
|
+
look(st);
|
|
538
|
+
for (const comp of mod.components) {
|
|
539
|
+
for (const e of templateExpressions(comp.template))
|
|
540
|
+
look(e);
|
|
541
|
+
forEachElement(comp, (el) => {
|
|
542
|
+
for (const a of el.attrs)
|
|
543
|
+
if (a.kind === 'static' && pattern.test(a.value))
|
|
544
|
+
found = true;
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
return found;
|
|
548
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import type { AttrNode, ElementNode, TNode } from '../../../ir/model.js';
|
|
3
|
+
import type { NgPartMap } from './part.js';
|
|
4
|
+
/** What the Angular template printer lends the Radix bindings: its own printing of values and handlers. */
|
|
5
|
+
export interface NgRadixPrinter {
|
|
6
|
+
/** a value as a template expression */
|
|
7
|
+
expr(e: t.Expression, hint: string): string;
|
|
8
|
+
/** a handler as a template statement for an output */
|
|
9
|
+
handler(e: t.Expression, event: string): string;
|
|
10
|
+
/** a fresh template name (a template reference to the directive) */
|
|
11
|
+
name(base: string): string;
|
|
12
|
+
/** the component imports this directive class */
|
|
13
|
+
use(name: string): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The bindings of a claimed Radix element that carries a radix-ng directive (prepare.ts): the directive's attribute,
|
|
17
|
+
* Radix's props as its inputs, Radix's callbacks as its outputs, and Radix's own attributes read from the directive
|
|
18
|
+
* (`#toggle="rdxToggle" [attr.data-state]="toggle.pressed() ? 'on' : 'off'"`). The attributes it takes leave the
|
|
19
|
+
* element's, which the printer writes as for any element. Null for any other element.
|
|
20
|
+
*/
|
|
21
|
+
export declare function angularRadixBindings(n: ElementNode, p: NgRadixPrinter): string[] | null;
|
|
22
|
+
/**
|
|
23
|
+
* Radix's props and callbacks given to a part, as its directive's input and output bindings: each value through the
|
|
24
|
+
* map's adapter where radix-ng's shape differs (`[controlledValue]="align() ? [align()] : []"`), each callback reading
|
|
25
|
+
* Radix's argument from the output's event (`$event.checked`, `($event.value[0] ?? '')`). The element's other
|
|
26
|
+
* attributes are not printed here. Used on a part's element and, for a component in the host form, where a caller
|
|
27
|
+
* writes the component's host element (host-form.ts).
|
|
28
|
+
*/
|
|
29
|
+
export declare function radixInputsAndOutputs(map: NgPartMap, attrs: readonly AttrNode[], p: Pick<NgRadixPrinter, 'expr' | 'handler'> & {
|
|
30
|
+
mayBeUndefined?: (e: t.Expression) => boolean;
|
|
31
|
+
mayBeText?: (e: t.Expression, text: string) => boolean;
|
|
32
|
+
}): string[];
|
|
33
|
+
/** The radix-ng directives the given class names of a file name (`RdxToggle`), each with the entry point it comes from. */
|
|
34
|
+
export declare function angularRadixImports(uses: Iterable<string>): [name: string, from: string][];
|
|
35
|
+
/**
|
|
36
|
+
* H6: the directives a component's markup reads the state of through the injector (NgPlan.injectState), each as the
|
|
37
|
+
* member its template names: `protected readonly accordionItem = inject(RdxAccordionItemDirective);`. Read after the
|
|
38
|
+
* template is printed.
|
|
39
|
+
*/
|
|
40
|
+
export declare function injectedDirectives(roots: readonly TNode[]): {
|
|
41
|
+
member: string;
|
|
42
|
+
directive: string;
|
|
43
|
+
}[];
|