@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,122 @@
|
|
|
1
|
+
import type { Diagnostic } from '../types.js';
|
|
2
|
+
import type { ComponentIR, ElementNode, ModuleIR } from './model.js';
|
|
3
|
+
/**
|
|
4
|
+
* Radix UI primitives, recognised by their import (never by a component's name), and handed to a target that maps them
|
|
5
|
+
* to its own Radix-like library (Vue: reka-ui; Svelte: bits-ui). shadcn/ui's components are thin wrappers over these
|
|
6
|
+
* primitives:
|
|
7
|
+
*
|
|
8
|
+
* import * as DialogPrimitive from '@radix-ui/react-dialog'; // or: import { Dialog as DialogPrimitive } from 'radix-ui'
|
|
9
|
+
* <DialogPrimitive.Content data-slot="dialog-content" className={cn(…)} {...props} />
|
|
10
|
+
*
|
|
11
|
+
* `markRadix` records every binding a Radix package gives the module (ModuleIR.radix) and marks each element that renders
|
|
12
|
+
* a Radix part (ElementNode.radix), for every target, additively. `claimRadix` then runs for a target that maps Radix:
|
|
13
|
+
* each element is checked against the target's map (an unmapped part or prop is a located error, never a silent drop),
|
|
14
|
+
* and a binding read only as the tag of mapped parts leaves the module's imports, so the React-library guard no longer
|
|
15
|
+
* refuses it; the target prints the mapped component and imports it itself. A target without a map (Angular, React
|
|
16
|
+
* Native) never claims anything: every Radix import stays refused as `react-library`.
|
|
17
|
+
*/
|
|
18
|
+
/** The Radix packages a target may map (the part of `@radix-ui/react-<pkg>`, and the unified package's name in kebab case). */
|
|
19
|
+
export declare const RADIX_PACKAGES: readonly ["slot", "dialog", "popover", "dropdown-menu", "tabs", "accordion", "switch", "checkbox", "select", "tooltip", "slider", "progress", "avatar", "separator", "label", "aspect-ratio", "toggle", "collapsible", "radio-group", "toggle-group", "alert-dialog", "hover-card", "scroll-area", "direction", "context-menu", "menubar", "navigation-menu"];
|
|
20
|
+
/** One local name bound to a Radix package or to one of its parts. */
|
|
21
|
+
export interface RadixBinding {
|
|
22
|
+
/** the local name (`DialogPrimitive`, `Root`) */
|
|
23
|
+
local: string;
|
|
24
|
+
/** the package, kebab case (`dialog`, `dropdown-menu`), for any Radix package (mapped or not) */
|
|
25
|
+
pkg: string;
|
|
26
|
+
/** the part the binding is (`Root`), or null when it is the whole package (`DialogPrimitive.Content` names the part) */
|
|
27
|
+
part: string | null;
|
|
28
|
+
/** the import's source as written */
|
|
29
|
+
source: string;
|
|
30
|
+
line?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface RadixModuleInfo {
|
|
33
|
+
/** by local name */
|
|
34
|
+
bindings: Map<string, RadixBinding>;
|
|
35
|
+
}
|
|
36
|
+
/** The Radix part an element renders: `<DialogPrimitive.Content>` → { pkg: 'dialog', part: 'Content' }. */
|
|
37
|
+
export interface RadixPart {
|
|
38
|
+
pkg: string;
|
|
39
|
+
part: string;
|
|
40
|
+
}
|
|
41
|
+
declare module './model.js' {
|
|
42
|
+
interface ModuleIR {
|
|
43
|
+
/** the bindings Radix packages give the module (ir/radix); unset when it imports none */
|
|
44
|
+
radix?: RadixModuleInfo;
|
|
45
|
+
}
|
|
46
|
+
interface ElementNode {
|
|
47
|
+
/** the Radix part this element renders (ir/radix); unset for anything else */
|
|
48
|
+
radix?: RadixPart;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** A React prop the target drops, with the reason the drop is harmless (it changes nothing the user can see or do). */
|
|
52
|
+
export interface RadixDrop {
|
|
53
|
+
drop: true;
|
|
54
|
+
why: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* One Radix part in a target's library. `props`: each React prop the map covers, by its React name, to the target's prop
|
|
58
|
+
* name (or a harmless drop). `events`: each React callback prop to the target's event (`onOpenChange` → `update:open`).
|
|
59
|
+
* `element`: the part renders a DOM element and passes any other attribute and DOM event to it (Radix spreads the rest
|
|
60
|
+
* onto the element, as the targets' parts do), so `className`, `data-*`, `aria-*`, `id`, DOM attributes and DOM events
|
|
61
|
+
* are passed through as they are; a part without one (Root, Portal) refuses any prop its map does not name.
|
|
62
|
+
* `asChild`: the target's name of Radix's `asChild` (Vue `as-child`), when the part takes it.
|
|
63
|
+
*/
|
|
64
|
+
export interface RadixPartMap {
|
|
65
|
+
/** the target package (`reka-ui`) */
|
|
66
|
+
from: string;
|
|
67
|
+
/** the exported component (`DialogRoot`) */
|
|
68
|
+
name: string;
|
|
69
|
+
props: Record<string, string | RadixDrop>;
|
|
70
|
+
events: Record<string, string>;
|
|
71
|
+
element: boolean;
|
|
72
|
+
asChild?: string;
|
|
73
|
+
/** a documented difference that leaves the output correct (a data-* attribute Radix sets and the target does not, say) */
|
|
74
|
+
notes?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* Radix focuses the part itself on a left mouse press, before anything else (Tabs.Trigger: `currentTarget.focus()`,
|
|
77
|
+
* so the tab shows its focus-visible ring after a click), and the target's part does not: the target adds that focus.
|
|
78
|
+
*/
|
|
79
|
+
pressFocus?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* React callbacks (keys of `events`) whose target event may carry `undefined` where Radix always passes a value
|
|
82
|
+
* (reka's Slider `update:modelValue` is `number[] | undefined`, Radix's `onValueChange` takes `number[]`): the
|
|
83
|
+
* target calls the callback only with a value, which is every call React makes.
|
|
84
|
+
*/
|
|
85
|
+
definedPayload?: string[];
|
|
86
|
+
}
|
|
87
|
+
/** A target's map of Radix: the packages it maps and each part's counterpart (undefined: no counterpart). */
|
|
88
|
+
export interface RadixTarget {
|
|
89
|
+
/** the target's display name, for messages (`Vue`) */
|
|
90
|
+
label: string;
|
|
91
|
+
/** the library the parts come from, for messages (`reka-ui`) */
|
|
92
|
+
library: string;
|
|
93
|
+
packages: ReadonlySet<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Why a package the target leaves out of `packages` is refused, when the target says (a mapped package whose browser
|
|
96
|
+
* proof has not passed): claimRadix says it once per package, at its first element.
|
|
97
|
+
*/
|
|
98
|
+
refusal?(pkg: string): string | undefined;
|
|
99
|
+
mapRadixPart(pkg: string, part: string): RadixPartMap | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* The target library's name of a CSS variable Radix sets on a part (`--radix-select-trigger-width` →
|
|
102
|
+
* `--reka-select-trigger-width`), which shadcn's classes read (`min-w-(--radix-select-trigger-width)`); undefined when
|
|
103
|
+
* the library sets none.
|
|
104
|
+
*/
|
|
105
|
+
cssVariable(name: string): string | undefined;
|
|
106
|
+
}
|
|
107
|
+
/** The Radix package an import source names (`@radix-ui/react-dropdown-menu` → `dropdown-menu`), or null. */
|
|
108
|
+
export declare function radixPackageOf(source: string): string | null;
|
|
109
|
+
/** Calls `visit` on every element of a component's markup (fragments and markup passed as props included). */
|
|
110
|
+
export declare function forEachElement(comp: ComponentIR, visit: (el: ElementNode) => void): void;
|
|
111
|
+
/** Records the module's Radix bindings and marks each element that renders a Radix part. Runs for every target. */
|
|
112
|
+
export declare function markRadix(mod: ModuleIR): void;
|
|
113
|
+
/** The Radix part an element renders, when it renders one (set by markRadix). */
|
|
114
|
+
export declare function radixPartOf(el: ElementNode): RadixPart | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* For a target that maps Radix: checks every Radix element of the module against the map and claims each binding that
|
|
117
|
+
* is read only as the tag of mapped parts (its import leaves `mod.imports`; the target imports the mapped components).
|
|
118
|
+
* Diagnostics: `react-library` (error) for a package or part the target does not map, `radix-prop` (error) for a prop or
|
|
119
|
+
* handler its map does not cover. A binding with any refused or unmapped use is not claimed, so the React-library guard
|
|
120
|
+
* still refuses its import and stubs it.
|
|
121
|
+
*/
|
|
122
|
+
export declare function claimRadix(mod: ModuleIR, map: RadixTarget, diagnostics: Diagnostic[], target: Diagnostic['target']): void;
|
package/dist/ir/radix.js
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { templateExpressions } from '../targets/shared/inline.js';
|
|
3
|
+
/**
|
|
4
|
+
* Radix UI primitives, recognised by their import (never by a component's name), and handed to a target that maps them
|
|
5
|
+
* to its own Radix-like library (Vue: reka-ui; Svelte: bits-ui). shadcn/ui's components are thin wrappers over these
|
|
6
|
+
* primitives:
|
|
7
|
+
*
|
|
8
|
+
* import * as DialogPrimitive from '@radix-ui/react-dialog'; // or: import { Dialog as DialogPrimitive } from 'radix-ui'
|
|
9
|
+
* <DialogPrimitive.Content data-slot="dialog-content" className={cn(…)} {...props} />
|
|
10
|
+
*
|
|
11
|
+
* `markRadix` records every binding a Radix package gives the module (ModuleIR.radix) and marks each element that renders
|
|
12
|
+
* a Radix part (ElementNode.radix), for every target, additively. `claimRadix` then runs for a target that maps Radix:
|
|
13
|
+
* each element is checked against the target's map (an unmapped part or prop is a located error, never a silent drop),
|
|
14
|
+
* and a binding read only as the tag of mapped parts leaves the module's imports, so the React-library guard no longer
|
|
15
|
+
* refuses it; the target prints the mapped component and imports it itself. A target without a map (Angular, React
|
|
16
|
+
* Native) never claims anything: every Radix import stays refused as `react-library`.
|
|
17
|
+
*/
|
|
18
|
+
/** The Radix packages a target may map (the part of `@radix-ui/react-<pkg>`, and the unified package's name in kebab case). */
|
|
19
|
+
export const RADIX_PACKAGES = ['slot', 'dialog', 'popover', 'dropdown-menu', 'tabs', 'accordion', 'switch', 'checkbox', 'select', 'tooltip', 'slider', 'progress', 'avatar', 'separator', 'label', 'aspect-ratio', 'toggle', 'collapsible', 'radio-group', 'toggle-group', 'alert-dialog', 'hover-card', 'scroll-area', 'direction', 'context-menu', 'menubar', 'navigation-menu'];
|
|
20
|
+
/** The Radix package an import source names (`@radix-ui/react-dropdown-menu` → `dropdown-menu`), or null. */
|
|
21
|
+
export function radixPackageOf(source) {
|
|
22
|
+
const m = /^@radix-ui\/react-([a-z][a-z-]*)$/.exec(source);
|
|
23
|
+
return m?.[1] ?? null;
|
|
24
|
+
}
|
|
25
|
+
/** `DropdownMenu` → `dropdown-menu` (the unified package's export names a package in Pascal case). */
|
|
26
|
+
function kebab(name) {
|
|
27
|
+
return name.replace(/[A-Z]/g, (c, i) => (i ? '-' : '') + c.toLowerCase());
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A part by its short name: each Radix package exports its parts twice (`Root` and `Dialog`, `Content` and
|
|
31
|
+
* `DialogContent`), and the long form is the package's name followed by the short one (the package's own name alone is
|
|
32
|
+
* its Root).
|
|
33
|
+
*/
|
|
34
|
+
function partName(pkg, name) {
|
|
35
|
+
const prefix = pkg.replace(/(^|-)([a-z])/g, (_, _dash, c) => c.toUpperCase());
|
|
36
|
+
if (name === prefix)
|
|
37
|
+
return 'Root';
|
|
38
|
+
return name.startsWith(prefix) && /^[A-Z]/.test(name.slice(prefix.length)) ? name.slice(prefix.length) : name;
|
|
39
|
+
}
|
|
40
|
+
function bindingsOf(mod) {
|
|
41
|
+
const out = new Map();
|
|
42
|
+
for (const decl of mod.imports) {
|
|
43
|
+
if (decl.importKind === 'type')
|
|
44
|
+
continue;
|
|
45
|
+
const source = decl.source.value;
|
|
46
|
+
const pkg = radixPackageOf(source);
|
|
47
|
+
if (!pkg && source !== 'radix-ui')
|
|
48
|
+
continue;
|
|
49
|
+
const line = decl.loc?.start.line;
|
|
50
|
+
for (const s of decl.specifiers) {
|
|
51
|
+
if (t.isImportSpecifier(s) && s.importKind === 'type')
|
|
52
|
+
continue;
|
|
53
|
+
const imported = t.isImportSpecifier(s) ? (t.isIdentifier(s.imported) ? s.imported.name : s.imported.value) : null;
|
|
54
|
+
const base = { local: s.local.name, source, ...(line ? { line } : {}) };
|
|
55
|
+
if (pkg) {
|
|
56
|
+
// `import * as DialogPrimitive`: the package; `import { Root }`: a part; a default import names nothing of Radix
|
|
57
|
+
if (t.isImportNamespaceSpecifier(s))
|
|
58
|
+
out.set(s.local.name, { ...base, pkg, part: null });
|
|
59
|
+
else if (imported)
|
|
60
|
+
out.set(s.local.name, { ...base, pkg, part: partName(pkg, imported) });
|
|
61
|
+
}
|
|
62
|
+
else if (imported && /^[A-Z]/.test(imported)) {
|
|
63
|
+
// `import { Dialog as DialogPrimitive } from 'radix-ui'`: the package, its parts read as members
|
|
64
|
+
out.set(s.local.name, { ...base, pkg: kebab(imported), part: null });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/** The part a tag names through the module's Radix bindings (`DialogPrimitive.Content`, `Root`), or null. */
|
|
71
|
+
function partOfTag(tag, bindings) {
|
|
72
|
+
const [root, member, ...more] = tag.split('.');
|
|
73
|
+
const b = root ? bindings.get(root) : undefined;
|
|
74
|
+
if (!b || more.length)
|
|
75
|
+
return null;
|
|
76
|
+
if (b.part === null)
|
|
77
|
+
return member ? { pkg: b.pkg, part: partName(b.pkg, member) } : null;
|
|
78
|
+
return member ? null : { pkg: b.pkg, part: b.part };
|
|
79
|
+
}
|
|
80
|
+
/** Calls `visit` on every element of a component's markup (fragments and markup passed as props included). */
|
|
81
|
+
export function forEachElement(comp, visit) {
|
|
82
|
+
const walk = (n) => {
|
|
83
|
+
switch (n.type) {
|
|
84
|
+
case 'element':
|
|
85
|
+
visit(n);
|
|
86
|
+
for (const a of n.attrs)
|
|
87
|
+
if (a.kind === 'slotProp')
|
|
88
|
+
a.children.forEach(walk);
|
|
89
|
+
n.children.forEach(walk);
|
|
90
|
+
return;
|
|
91
|
+
case 'if':
|
|
92
|
+
for (const b of n.branches)
|
|
93
|
+
b.children.forEach(walk);
|
|
94
|
+
return;
|
|
95
|
+
case 'slot':
|
|
96
|
+
n.fallback.forEach(walk);
|
|
97
|
+
return;
|
|
98
|
+
case 'for':
|
|
99
|
+
case 'fragment':
|
|
100
|
+
case 'keyed':
|
|
101
|
+
case 'presence':
|
|
102
|
+
n.children.forEach(walk);
|
|
103
|
+
return;
|
|
104
|
+
default:
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
walk(comp.template);
|
|
109
|
+
for (const f of comp.fragments)
|
|
110
|
+
walk(f.template);
|
|
111
|
+
}
|
|
112
|
+
/** Records the module's Radix bindings and marks each element that renders a Radix part. Runs for every target. */
|
|
113
|
+
export function markRadix(mod) {
|
|
114
|
+
const bindings = bindingsOf(mod);
|
|
115
|
+
if (!bindings.size)
|
|
116
|
+
return;
|
|
117
|
+
mod.radix = { bindings };
|
|
118
|
+
for (const comp of mod.components) {
|
|
119
|
+
forEachElement(comp, (el) => {
|
|
120
|
+
if (!el.component)
|
|
121
|
+
return;
|
|
122
|
+
const part = partOfTag(el.tag, bindings);
|
|
123
|
+
if (part)
|
|
124
|
+
el.radix = part;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** The Radix part an element renders, when it renders one (set by markRadix). */
|
|
129
|
+
export function radixPartOf(el) {
|
|
130
|
+
return el.radix;
|
|
131
|
+
}
|
|
132
|
+
/** Attributes every element part passes to its element as they are. */
|
|
133
|
+
function passesThrough(name) {
|
|
134
|
+
return name === 'class' || name === 'id' || name === 'key' || name === 'style' || name === 'role' || name === 'tabIndex' || name === 'title' || name === 'dir' || /^(data|aria)-/.test(name);
|
|
135
|
+
}
|
|
136
|
+
/** The name an attribute has in React (the IR renames `className` to `class`). */
|
|
137
|
+
function reactName(a) {
|
|
138
|
+
if (a.kind === 'event')
|
|
139
|
+
return a.react;
|
|
140
|
+
if (a.kind === 'static' || a.kind === 'expr' || a.kind === 'bool' || a.kind === 'slotProp')
|
|
141
|
+
return a.name === 'class' ? 'className' : a.name;
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* For a target that maps Radix: checks every Radix element of the module against the map and claims each binding that
|
|
146
|
+
* is read only as the tag of mapped parts (its import leaves `mod.imports`; the target imports the mapped components).
|
|
147
|
+
* Diagnostics: `react-library` (error) for a package or part the target does not map, `radix-prop` (error) for a prop or
|
|
148
|
+
* handler its map does not cover. A binding with any refused or unmapped use is not claimed, so the React-library guard
|
|
149
|
+
* still refuses its import and stubs it.
|
|
150
|
+
*/
|
|
151
|
+
export function claimRadix(mod, map, diagnostics, target) {
|
|
152
|
+
const info = mod.radix;
|
|
153
|
+
if (!info)
|
|
154
|
+
return;
|
|
155
|
+
const refused = new Set();
|
|
156
|
+
const used = new Set();
|
|
157
|
+
const saidRefusal = new Set();
|
|
158
|
+
const report = (code, message, line) => {
|
|
159
|
+
diagnostics.push({ code, severity: 'error', message, file: mod.file, ...(target ? { target } : {}), ...(line ? { line } : {}) });
|
|
160
|
+
};
|
|
161
|
+
for (const comp of mod.components) {
|
|
162
|
+
forEachElement(comp, (el) => {
|
|
163
|
+
const part = el.radix;
|
|
164
|
+
if (!part)
|
|
165
|
+
return;
|
|
166
|
+
const local = el.tag.split('.')[0] ?? el.tag;
|
|
167
|
+
used.add(local);
|
|
168
|
+
const binding = info.bindings.get(local);
|
|
169
|
+
const line = lineOf(el) ?? binding?.line;
|
|
170
|
+
const where = `<${el.tag}> (Radix ${part.pkg} ${part.part})`;
|
|
171
|
+
if (!map.packages.has(part.pkg)) {
|
|
172
|
+
refused.add(local);
|
|
173
|
+
// Slot is converted where a component picks it by asChild (ir/as-child), never as a tag of its own
|
|
174
|
+
const refusal = map.refusal?.(part.pkg);
|
|
175
|
+
const first = refusal !== undefined && !saidRefusal.has(part.pkg);
|
|
176
|
+
if (first)
|
|
177
|
+
saidRefusal.add(part.pkg);
|
|
178
|
+
const why = part.pkg === 'slot'
|
|
179
|
+
? `Radix's Slot rendered as a tag (it merges its props onto its one child at run time) has no ${map.label} counterpart; morph converts Slot only where a component picks it by asChild (\`const Comp = asChild ? Slot.Root : 'button'\`); not converted.`
|
|
180
|
+
: first
|
|
181
|
+
? `the Radix package ${part.pkg} is not converted to ${map.library}: ${refusal}.`
|
|
182
|
+
: `the Radix package ${part.pkg} has no ${map.label} counterpart in morph's map of ${map.library}; not converted.`;
|
|
183
|
+
report('react-library', `${where}: ${why}`, line);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const mapped = map.mapRadixPart(part.pkg, part.part);
|
|
187
|
+
if (!mapped) {
|
|
188
|
+
refused.add(local);
|
|
189
|
+
report('react-library', `${where}: ${map.library} has no counterpart of this part; not converted.`, line);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
for (const a of el.attrs) {
|
|
193
|
+
const name = reactName(a);
|
|
194
|
+
if (a.kind === 'spread' || a.kind === 'ref' || a.kind === 'style' || name === null)
|
|
195
|
+
continue;
|
|
196
|
+
if (name === 'asChild') {
|
|
197
|
+
if (mapped.asChild)
|
|
198
|
+
continue;
|
|
199
|
+
refused.add(local);
|
|
200
|
+
report('radix-prop', `${where}: asChild has no ${map.label} counterpart on ${mapped.name}; not converted.`, line);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (name === 'children' || name in mapped.props || (a.kind === 'event' && name in mapped.events))
|
|
204
|
+
continue;
|
|
205
|
+
// a part without an element (Root, Portal, Provider) puts a data-* attribute nowhere in React either
|
|
206
|
+
if (!mapped.element && a.kind !== 'event' && /^data-/.test(name))
|
|
207
|
+
continue;
|
|
208
|
+
if (mapped.element && (passesThrough(name) || (a.kind === 'event' && !isRadixHandler(name)) || (a.kind !== 'event' && !/^on[A-Z]/.test(name) && /^[a-z]/.test(name) && !RADIX_ONLY_PROP.test(name))))
|
|
209
|
+
continue;
|
|
210
|
+
refused.add(local);
|
|
211
|
+
report('radix-prop', `${where}: "${name}" is not covered by morph's map of ${mapped.name} (${map.library}); not converted rather than dropped.`, line);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// a binding read anywhere but as a tag (a value, `Primitive.Root.displayName`) keeps its import and its refusal
|
|
216
|
+
const claimed = [...used].filter((l) => !refused.has(l) && !readOutsideTags(mod, l));
|
|
217
|
+
if (!claimed.length)
|
|
218
|
+
return;
|
|
219
|
+
renameCssVariables(mod, map, diagnostics, target);
|
|
220
|
+
const gone = new Set(claimed);
|
|
221
|
+
mod.imports = mod.imports.flatMap((decl) => {
|
|
222
|
+
if (!info.bindings.size || decl.importKind === 'type')
|
|
223
|
+
return [decl];
|
|
224
|
+
const kept = decl.specifiers.filter((s) => !gone.has(s.local.name));
|
|
225
|
+
if (kept.length === decl.specifiers.length)
|
|
226
|
+
return [decl];
|
|
227
|
+
if (!kept.length)
|
|
228
|
+
return [];
|
|
229
|
+
const copy = t.cloneNode(decl, false);
|
|
230
|
+
copy.specifiers = kept;
|
|
231
|
+
return [copy];
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Radix's CSS variables in the module's strings (class names such as `max-h-(--radix-select-content-available-height)`)
|
|
236
|
+
* become the target library's (`--reka-…`), which sets the same values on the same parts. A Radix variable the library
|
|
237
|
+
* does not set stays as written, with a warning: what reads it falls back as it would with no Radix at all.
|
|
238
|
+
*/
|
|
239
|
+
function renameCssVariables(mod, map, diagnostics, target) {
|
|
240
|
+
const missing = new Set();
|
|
241
|
+
const rename = (text) => text.replace(/--radix-[a-z][a-z-]*[a-z]/g, (name) => {
|
|
242
|
+
const to = map.cssVariable(name);
|
|
243
|
+
if (to === undefined)
|
|
244
|
+
missing.add(name);
|
|
245
|
+
return to ?? name;
|
|
246
|
+
});
|
|
247
|
+
const visit = (root) => {
|
|
248
|
+
t.traverseFast(root, (n) => {
|
|
249
|
+
if (t.isStringLiteral(n) && n.value.includes('--radix-'))
|
|
250
|
+
n.value = rename(n.value);
|
|
251
|
+
else if (t.isTemplateElement(n) && n.value.raw.includes('--radix-'))
|
|
252
|
+
n.value = { raw: rename(n.value.raw), cooked: n.value.cooked === null || n.value.cooked === undefined ? n.value.cooked : rename(n.value.cooked) };
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
for (const stmt of mod.moduleBody)
|
|
256
|
+
visit(stmt);
|
|
257
|
+
for (const fn of [...mod.components, ...mod.hooks]) {
|
|
258
|
+
for (const item of fn.items) {
|
|
259
|
+
for (const value of Object.values(item)) {
|
|
260
|
+
if (Array.isArray(value))
|
|
261
|
+
for (const v of value)
|
|
262
|
+
if (t.isNode(v))
|
|
263
|
+
visit(v);
|
|
264
|
+
if (t.isNode(value))
|
|
265
|
+
visit(value);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
for (const comp of mod.components) {
|
|
270
|
+
for (const root of [comp.template, ...comp.fragments.map((f) => f.template)])
|
|
271
|
+
for (const e of templateExpressions(root))
|
|
272
|
+
visit(e);
|
|
273
|
+
forEachElement(comp, (el) => {
|
|
274
|
+
for (const a of el.attrs)
|
|
275
|
+
if (a.kind === 'static' && a.value.includes('--radix-'))
|
|
276
|
+
a.value = rename(a.value);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
for (const name of missing) {
|
|
280
|
+
diagnostics.push({ code: 'radix-css-var', severity: 'warning', message: `${name} is a CSS variable Radix sets that ${map.library} does not: what reads it is left as written and gets no value in ${map.label}.`, file: mod.file, ...(target ? { target } : {}) });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Radix's own callback props on a part (`onEscapeKeyDown`, `onPointerDownOutside`, `onOpenAutoFocus`, `onValueChange`):
|
|
285
|
+
* not DOM events, so passing one through to the element would silently do nothing; each must be mapped.
|
|
286
|
+
*/
|
|
287
|
+
function isRadixHandler(name) {
|
|
288
|
+
return /^on(Open|Close)AutoFocus$|^onEscapeKeyDown$|^onPointerDownOutside$|^onFocusOutside$|^onInteractOutside$|^on\w+Change$|^onSelect$|^onValueCommit$|^onLoadingStatusChange$|^onEntryFocus$/.test(name);
|
|
289
|
+
}
|
|
290
|
+
/** Radix props that change behaviour (not DOM attributes): each must be in the map, or it is refused. */
|
|
291
|
+
const RADIX_ONLY_PROP = /^(forceMount|loop|side|sideOffset|align|alignOffset|avoidCollisions|collisionPadding|collisionBoundary|updatePositionStrategy|container|nonce|getValueLabel|sticky|hideWhenDetached|position|disableOutsidePointerEvents|trapFocus|modal|orientation|activationMode|collapsible|textValue|delayDuration|skipDelayDuration|disableHoverableContent|decorative|delayMs|inverted|minStepsBetweenThumbs|arrowPadding|ratio|pressed|defaultPressed|rovingFocus|value|defaultValue|checked|defaultChecked|open|defaultOpen|disabled|required|name|type|dir|max|min|step)$/;
|
|
292
|
+
function lineOf(el) {
|
|
293
|
+
for (const a of el.attrs) {
|
|
294
|
+
const e = a.kind === 'event' ? a.handler : 'expr' in a ? a.expr : null;
|
|
295
|
+
const line = e?.loc?.start.line;
|
|
296
|
+
if (line)
|
|
297
|
+
return line;
|
|
298
|
+
}
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
/** Whether the module reads a name anywhere but as an element's tag: its statements, script items or markup values. */
|
|
302
|
+
function readOutsideTags(mod, name) {
|
|
303
|
+
let found = false;
|
|
304
|
+
const lookValue = (root) => {
|
|
305
|
+
// types (`ComponentProps<typeof DialogPrimitive.Root>`) are mapped where they are used, not read as values
|
|
306
|
+
const strip = (n) => n.type.startsWith('TS') && n.type !== 'TSAsExpression' && n.type !== 'TSNonNullExpression' && n.type !== 'TSSatisfiesExpression';
|
|
307
|
+
const walk = (n) => {
|
|
308
|
+
if (found || strip(n))
|
|
309
|
+
return;
|
|
310
|
+
if (t.isIdentifier(n, { name }) || t.isJSXIdentifier(n, { name })) {
|
|
311
|
+
found = true;
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
for (const key of t.VISITOR_KEYS[n.type] ?? []) {
|
|
315
|
+
if (key === 'typeAnnotation' || key === 'returnType' || key === 'typeParameters' || key === 'typeArguments')
|
|
316
|
+
continue;
|
|
317
|
+
const value = Reflect.get(n, key);
|
|
318
|
+
for (const child of Array.isArray(value) ? value : [value])
|
|
319
|
+
if (t.isNode(child))
|
|
320
|
+
walk(child);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
walk(root);
|
|
324
|
+
};
|
|
325
|
+
for (const stmt of mod.moduleBody)
|
|
326
|
+
lookValue(stmt);
|
|
327
|
+
for (const fn of [...mod.components, ...mod.hooks]) {
|
|
328
|
+
for (const item of fn.items) {
|
|
329
|
+
for (const value of Object.values(item)) {
|
|
330
|
+
if (Array.isArray(value))
|
|
331
|
+
for (const v of value)
|
|
332
|
+
if (t.isNode(v))
|
|
333
|
+
lookValue(v);
|
|
334
|
+
if (t.isNode(value))
|
|
335
|
+
lookValue(value);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
for (const comp of mod.components)
|
|
340
|
+
for (const root of [comp.template, ...comp.fragments.map((f) => f.template)])
|
|
341
|
+
for (const e of templateExpressions(root))
|
|
342
|
+
lookValue(e);
|
|
343
|
+
return found;
|
|
344
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FunctionIR } from './model.js';
|
|
2
|
+
/**
|
|
3
|
+
* Renames one binding of a lowered function (component or hook) everywhere the IR holds it: its declaration, every
|
|
4
|
+
* reference the lowering linked to it (script items, template, render helpers) and the names lists that mention it.
|
|
5
|
+
* Shadowing locals (a parameter or a loop item of the same name) are separate bindings, never linked, so they stay.
|
|
6
|
+
* Returns false, changing nothing, for a binding of a kind it does not rename (the props object, rest props).
|
|
7
|
+
*/
|
|
8
|
+
export declare function renameBinding(ir: FunctionIR & {
|
|
9
|
+
props?: {
|
|
10
|
+
local: string;
|
|
11
|
+
}[];
|
|
12
|
+
template?: unknown;
|
|
13
|
+
fragments?: unknown;
|
|
14
|
+
returns?: unknown;
|
|
15
|
+
}, from: string, to: string): boolean;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
/** Whether a value is a Babel node (TNode and AttrNode kinds are lower case, Babel's are PascalCase). */
|
|
3
|
+
function isBabelNode(value) {
|
|
4
|
+
return !!value && typeof value === 'object' && 'type' in value && typeof value.type === 'string' && value.type in t.VISITOR_KEYS;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Renames one binding of a lowered function (component or hook) everywhere the IR holds it: its declaration, every
|
|
8
|
+
* reference the lowering linked to it (script items, template, render helpers) and the names lists that mention it.
|
|
9
|
+
* Shadowing locals (a parameter or a loop item of the same name) are separate bindings, never linked, so they stay.
|
|
10
|
+
* Returns false, changing nothing, for a binding of a kind it does not rename (the props object, rest props).
|
|
11
|
+
*/
|
|
12
|
+
export function renameBinding(ir, from, to) {
|
|
13
|
+
const binding = ir.bindings.get(from);
|
|
14
|
+
if (!binding || binding.kind === 'propsObject' || binding.kind === 'rest' || binding.kind === 'param' || ir.bindings.has(to))
|
|
15
|
+
return false;
|
|
16
|
+
const seen = new WeakSet();
|
|
17
|
+
const renameId = (id) => {
|
|
18
|
+
id.name = to;
|
|
19
|
+
ir.refs.set(id, to);
|
|
20
|
+
};
|
|
21
|
+
const walkNode = (n, parent) => {
|
|
22
|
+
if (seen.has(n))
|
|
23
|
+
return;
|
|
24
|
+
seen.add(n);
|
|
25
|
+
if (t.isIdentifier(n)) {
|
|
26
|
+
if (ir.refs.get(n) !== from)
|
|
27
|
+
return;
|
|
28
|
+
renameId(n);
|
|
29
|
+
// `{ state }` keeps its key
|
|
30
|
+
if (parent && t.isObjectProperty(parent) && parent.shorthand && parent.value === n)
|
|
31
|
+
parent.shorthand = false;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (const key of t.VISITOR_KEYS[n.type] ?? []) {
|
|
35
|
+
const value = Reflect.get(n, key);
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
for (const c of value)
|
|
38
|
+
if (isBabelNode(c))
|
|
39
|
+
walkNode(c, n);
|
|
40
|
+
}
|
|
41
|
+
else if (isBabelNode(value))
|
|
42
|
+
walkNode(value, n);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/** TNodes, AttrNodes, script items and fragments: plain objects holding Babel nodes */
|
|
46
|
+
const walk = (value) => {
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
for (const v of value)
|
|
49
|
+
walk(v);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!value || typeof value !== 'object')
|
|
53
|
+
return;
|
|
54
|
+
if (isBabelNode(value)) {
|
|
55
|
+
walkNode(value, null);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (seen.has(value))
|
|
59
|
+
return;
|
|
60
|
+
seen.add(value);
|
|
61
|
+
for (const v of Object.values(value))
|
|
62
|
+
walk(v);
|
|
63
|
+
};
|
|
64
|
+
/** The identifiers a declaration pattern binds under the old name. */
|
|
65
|
+
const declare = (pattern) => {
|
|
66
|
+
for (const [name, ids] of Object.entries(t.getBindingIdentifiers(pattern, true))) {
|
|
67
|
+
if (name !== from)
|
|
68
|
+
continue;
|
|
69
|
+
for (const id of ids)
|
|
70
|
+
renameId(id);
|
|
71
|
+
}
|
|
72
|
+
t.traverseFast(pattern, (n) => {
|
|
73
|
+
if (t.isObjectProperty(n) && n.shorthand && t.isIdentifier(n.value, { name: to }))
|
|
74
|
+
n.shorthand = false;
|
|
75
|
+
if (t.isObjectProperty(n) && n.shorthand && t.isAssignmentPattern(n.value) && t.isIdentifier(n.value.left, { name: to }))
|
|
76
|
+
n.shorthand = false;
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const item = (i) => {
|
|
80
|
+
switch (i.kind) {
|
|
81
|
+
case 'state':
|
|
82
|
+
case 'ref':
|
|
83
|
+
case 'id':
|
|
84
|
+
case 'context':
|
|
85
|
+
if (i.name === from)
|
|
86
|
+
i.name = to;
|
|
87
|
+
break;
|
|
88
|
+
case 'reducer':
|
|
89
|
+
if (i.name === from)
|
|
90
|
+
i.name = to;
|
|
91
|
+
break;
|
|
92
|
+
case 'block':
|
|
93
|
+
if (i.name === from) {
|
|
94
|
+
i.name = to;
|
|
95
|
+
for (const s of i.statements)
|
|
96
|
+
if (t.isVariableDeclaration(s))
|
|
97
|
+
for (const d of s.declarations)
|
|
98
|
+
declare(d.id);
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case 'function':
|
|
102
|
+
if (i.name === from) {
|
|
103
|
+
i.name = to;
|
|
104
|
+
if (t.isFunctionDeclaration(i.node) && i.node.id)
|
|
105
|
+
renameId(i.node.id);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
case 'derived':
|
|
109
|
+
if (i.names.includes(from)) {
|
|
110
|
+
i.names = i.names.map((n) => (n === from ? to : n));
|
|
111
|
+
declare(i.id);
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
case 'hook':
|
|
115
|
+
if (i.id)
|
|
116
|
+
declare(i.id);
|
|
117
|
+
break;
|
|
118
|
+
case 'effect':
|
|
119
|
+
if (i.core) {
|
|
120
|
+
const c = i.core;
|
|
121
|
+
const swap = (list) => list.map((n) => (n === from ? to : n));
|
|
122
|
+
c.inputs = swap(c.inputs);
|
|
123
|
+
c.setters = swap(c.setters);
|
|
124
|
+
c.boxes = swap(c.boxes);
|
|
125
|
+
if (c.elementRef === from)
|
|
126
|
+
c.elementRef = to;
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
default:
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
for (const i of ir.items) {
|
|
134
|
+
item(i);
|
|
135
|
+
walk(i);
|
|
136
|
+
}
|
|
137
|
+
for (const p of ir.props ?? [])
|
|
138
|
+
if (p.local === from)
|
|
139
|
+
p.local = to;
|
|
140
|
+
walk(ir.props);
|
|
141
|
+
walk(ir.template);
|
|
142
|
+
walk(ir.fragments);
|
|
143
|
+
walk(ir.returns);
|
|
144
|
+
ir.bindings.delete(from);
|
|
145
|
+
binding.name = to;
|
|
146
|
+
ir.bindings.set(to, binding);
|
|
147
|
+
for (const b of ir.bindings.values())
|
|
148
|
+
if (b.state === from)
|
|
149
|
+
b.state = to;
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import type { ComponentIR, PropDecl } from './model.js';
|
|
3
|
+
/**
|
|
4
|
+
* Render props: a prop that is a function returning markup (`actions?: (picked: Row[]) => ReactNode`, `children:
|
|
5
|
+
* (close: () => void) => ReactNode`). The component calls it where the markup goes (`{actions(chosen)}`); a caller
|
|
6
|
+
* passes a function of those values (`actions={(picked) => <Bar rows={picked} />}`). Vue writes it as a scoped slot
|
|
7
|
+
* (the parameters become slot props named as the prop's type names them), Svelte as a snippet with parameters.
|
|
8
|
+
*/
|
|
9
|
+
/** One parameter of a render prop, as the prop's type declares it. */
|
|
10
|
+
export interface RenderParam {
|
|
11
|
+
name: string;
|
|
12
|
+
type: t.TSType | null;
|
|
13
|
+
optional: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** The parameters of a render prop's type, or null when the type is not a function returning markup. */
|
|
16
|
+
export declare function renderSignature(type: t.TSType | null | undefined): RenderParam[] | null;
|
|
17
|
+
/** A component's render prop by its public key, with its parameters, or null. */
|
|
18
|
+
export declare function renderProp(comp: ComponentIR, key: string): {
|
|
19
|
+
prop: PropDecl | null;
|
|
20
|
+
params: RenderParam[];
|
|
21
|
+
} | null;
|
|
22
|
+
/** The slot a render prop fills in Vue: `children` is the default slot. */
|
|
23
|
+
export declare function slotName(key: string): string;
|
|
24
|
+
/** The error for markup passed to a prop the receiving component never renders as markup. */
|
|
25
|
+
export declare function droppedSlotMessage(tag: string, key: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a component renders the markup a caller passes for a prop: a slot of it somewhere in its markup (its own
|
|
28
|
+
* template or a render helper's). A prop it only reads as a value (passed on to a child, an unresolved props type)
|
|
29
|
+
* would drop markup passed as a slot or snippet.
|
|
30
|
+
*/
|
|
31
|
+
export declare function rendersSlot(comp: ComponentIR, key: string): boolean;
|