@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
package/dist/gate.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { basename, resolve } from 'node:path';
|
|
3
|
+
import { compileFile } from './pipeline.js';
|
|
4
|
+
import { makeProject } from './analyzer/deps.js';
|
|
5
|
+
import { runVerify } from './verify/runner.js';
|
|
6
|
+
import { checkSteps } from './verify/steps.js';
|
|
7
|
+
import { MAX_INPUT_BYTES } from './utils/fs-safe.js';
|
|
8
|
+
import { MorphError, errorMessage } from './utils/errors.js';
|
|
9
|
+
import { ASSIST_GATES, ASSIST_MATCH, browserVerdict, staticGates } from './ai/gate.js';
|
|
10
|
+
/**
|
|
11
|
+
* `gate` (v0.3 Milestone A): the four gates assisted mode holds a model-written file to, run on a candidate a person or
|
|
12
|
+
* an agent wrote. It reuses assisted mode's own gates (src/ai/gate.ts: staticGates, browserVerdict), never a second set.
|
|
13
|
+
*/
|
|
14
|
+
/** At most this many candidate files per run. */
|
|
15
|
+
export const MAX_CANDIDATES = 16;
|
|
16
|
+
function readCandidate(path) {
|
|
17
|
+
const full = resolve(path);
|
|
18
|
+
const stat = existsSync(full) ? statSync(full) : null;
|
|
19
|
+
if (!stat?.isFile())
|
|
20
|
+
throw new MorphError('not-found', `Candidate file not found: ${path}`);
|
|
21
|
+
const size = stat.size;
|
|
22
|
+
if (size > MAX_INPUT_BYTES)
|
|
23
|
+
throw new MorphError('input-too-large', `${path} is ${Math.round(size / 1024)} KB; the limit is ${MAX_INPUT_BYTES / 1024} KB`);
|
|
24
|
+
return readFileSync(full, 'utf8');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Puts each candidate in place of the output file with the same name (Foo.vue replaces the compiler's Foo.vue). A
|
|
28
|
+
* candidate no output file is named like (the compiler refused the component whole) is added beside the first
|
|
29
|
+
* component file. Two output files with the candidate's name is an error: the candidate's place is not clear.
|
|
30
|
+
*/
|
|
31
|
+
export function placeCandidates(own, candidates) {
|
|
32
|
+
const files = [...own];
|
|
33
|
+
const placed = [];
|
|
34
|
+
const firstComponent = own.find((f) => f.kind === 'component');
|
|
35
|
+
const folder = firstComponent ? firstComponent.path.slice(0, firstComponent.path.lastIndexOf('/') + 1) : '';
|
|
36
|
+
const seen = new Set();
|
|
37
|
+
for (const c of candidates) {
|
|
38
|
+
const name = basename(c.file);
|
|
39
|
+
if (seen.has(name))
|
|
40
|
+
throw new MorphError('gate-candidate', `Two candidates are named ${name}: each candidate stands in for one output file.`);
|
|
41
|
+
seen.add(name);
|
|
42
|
+
const matches = files.map((f, i) => ({ f, i })).filter(({ f }) => f.path === name || f.path.endsWith(`/${name}`));
|
|
43
|
+
if (matches.length > 1)
|
|
44
|
+
throw new MorphError('gate-candidate', `${name} matches ${matches.length} output files (${matches.map((m) => m.f.path).join(', ')}); rename the candidate after the one it replaces.`);
|
|
45
|
+
const match = matches[0];
|
|
46
|
+
if (match) {
|
|
47
|
+
files[match.i] = { ...match.f, contents: c.contents };
|
|
48
|
+
placed.push({ file: c.file, replaces: match.f.path });
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const path = `${folder}${name}`;
|
|
52
|
+
files.push({ path, contents: c.contents, kind: /\.(vue|svelte)$/.test(name) || /\.component\.ts$/.test(name) ? 'component' : 'module' });
|
|
53
|
+
placed.push({ file: c.file, replaces: path });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { files, placed };
|
|
57
|
+
}
|
|
58
|
+
function scoreOf(result, target, steps) {
|
|
59
|
+
const states = result.comparisons.filter((c) => c.target === target).map((c) => ({ state: c.state, match: c.match }));
|
|
60
|
+
const stepRows = (result.steps ?? []).filter((s) => s.target === target).map((s) => ({ name: steps[s.index]?.name ?? s.step, index: s.index, match: s.match, failure: s.failure ?? null, stateMismatches: s.state.length }));
|
|
61
|
+
const all = [...states.map((s) => s.match), ...stepRows.map((s) => s.match)];
|
|
62
|
+
return { minMatch: all.length ? Math.min(...all) : null, states, steps: stepRows };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Runs the four gates on candidate files for one web target, in order, stopping at the first that fails: (1) the
|
|
66
|
+
* target's real compiler and no `antheo-morph: not converted` mark left, (2) the strict type check (vue-tsc's /
|
|
67
|
+
* svelte-check's; Angular: ngtsc with strictTemplates covers both), (3) the browser harness against the React original
|
|
68
|
+
* (every state and every step at 99% or more at pixelmatch threshold 0.1, no DOM fact that differs after a step, no page
|
|
69
|
+
* error), (4) the unmount check (nothing left running that React does not leave). Passes only if all four pass.
|
|
70
|
+
*/
|
|
71
|
+
export async function runGate(sourceFile, candidateFiles, options) {
|
|
72
|
+
const { target } = options;
|
|
73
|
+
if (target !== 'vue' && target !== 'svelte' && target !== 'angular')
|
|
74
|
+
throw new MorphError('gate-target', `gate needs one web target (vue, svelte or angular), not "${String(target)}".`);
|
|
75
|
+
if (!candidateFiles.length)
|
|
76
|
+
throw new MorphError('gate-candidate', 'gate needs at least one candidate file.');
|
|
77
|
+
if (candidateFiles.length > MAX_CANDIDATES)
|
|
78
|
+
throw new MorphError('gate-candidate', `gate takes at most ${MAX_CANDIDATES} candidate files.`);
|
|
79
|
+
const entry = resolve(sourceFile);
|
|
80
|
+
if (!existsSync(entry))
|
|
81
|
+
throw new MorphError('not-found', `File not found: ${sourceFile}`);
|
|
82
|
+
// a bad script is the caller's error, found before anything is compiled
|
|
83
|
+
if (options.steps?.length)
|
|
84
|
+
checkSteps(options.steps);
|
|
85
|
+
const candidates = candidateFiles.map((file) => ({ file: resolve(file), contents: readCandidate(file) }));
|
|
86
|
+
const project = makeProject(entry, options);
|
|
87
|
+
const compileOptions = { ...(options.root ? { root: options.root } : {}), ...(options.aliases ? { aliases: options.aliases } : {}), ...(options.signal ? { signal: options.signal } : {}) };
|
|
88
|
+
const compiled = await compileFile(entry, { ...compileOptions, targets: [target], typecheck: false });
|
|
89
|
+
const own = compiled.targets[0];
|
|
90
|
+
if (!own)
|
|
91
|
+
throw new MorphError('gate-target', `The compiler returned no result for ${target}.`);
|
|
92
|
+
const { files, placed } = placeCandidates(own.files, candidates);
|
|
93
|
+
const states = options.states ?? ['idle', 'hover', 'active'];
|
|
94
|
+
const gates = ASSIST_GATES.map((gate) => ({ gate, status: 'not-run', reason: null, details: [] }));
|
|
95
|
+
const result = (failure, score, leaks, steps, discovered) => {
|
|
96
|
+
const failedGate = failure && failure.gate !== 'reply' && failure.gate !== 'provider' ? failure.gate : null;
|
|
97
|
+
const at = failedGate ? ASSIST_GATES.indexOf(failedGate) : ASSIST_GATES.length;
|
|
98
|
+
for (const [i, g] of gates.entries()) {
|
|
99
|
+
if (i < at)
|
|
100
|
+
g.status = 'pass';
|
|
101
|
+
else if (i === at && failure) {
|
|
102
|
+
g.status = 'fail';
|
|
103
|
+
g.reason = failure.reason;
|
|
104
|
+
g.details = failure.details ?? [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return { version: 1, file: compiled.file, target, candidates: placed, passed: failure === null, failedGate, reason: failure?.reason ?? null, gates, score, leaks, steps, discoveredSteps: discovered };
|
|
108
|
+
};
|
|
109
|
+
const noScore = { minMatch: null, states: [], steps: [] };
|
|
110
|
+
let failure;
|
|
111
|
+
try {
|
|
112
|
+
failure = await staticGates(files, target, project.root);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
failure = { gate: 'compiler', reason: `the check could not run: ${errorMessage(error)}` };
|
|
116
|
+
}
|
|
117
|
+
if (failure)
|
|
118
|
+
return result(failure, noScore, null, options.steps ?? [], null);
|
|
119
|
+
const auto = options.steps === undefined && options.autoSteps ? { autoSteps: options.autoSteps } : {};
|
|
120
|
+
const verifyResult = await runVerify(entry, {
|
|
121
|
+
...compileOptions,
|
|
122
|
+
targets: [target],
|
|
123
|
+
compiled,
|
|
124
|
+
files: { [target]: files },
|
|
125
|
+
unmount: true,
|
|
126
|
+
states,
|
|
127
|
+
...(options.exportName ? { exportName: options.exportName } : {}),
|
|
128
|
+
...(options.props ? { props: options.props } : {}),
|
|
129
|
+
...(options.steps ? { steps: options.steps } : {}),
|
|
130
|
+
...auto,
|
|
131
|
+
...(options.executablePath ? { executablePath: options.executablePath } : {}),
|
|
132
|
+
});
|
|
133
|
+
const steps = options.steps ?? verifyResult.discoveredSteps ?? [];
|
|
134
|
+
const score = scoreOf(verifyResult, target, steps);
|
|
135
|
+
failure = browserVerdict(verifyResult, target, states, steps, own.diagnostics);
|
|
136
|
+
const measured = verifyResult.leaks?.find((l) => l.framework === target);
|
|
137
|
+
const leaks = measured ? { clean: measured.clean, beyondReact: measured.beyondReact ?? null } : null;
|
|
138
|
+
return result(failure, score, leaks, steps, verifyResult.discoveredSteps ?? null);
|
|
139
|
+
}
|
|
140
|
+
const pct = (n) => `${(n * 100).toFixed(2)}%`;
|
|
141
|
+
/** The verdict as text an agent can act on: the result, each gate, the failing gate's located problems, the scores. */
|
|
142
|
+
export function gateLines(r) {
|
|
143
|
+
const lines = [r.passed ? `gate ${r.target}: PASS (all 4 gates)` : `gate ${r.target}: FAIL at the ${r.failedGate} gate (${ASSIST_GATES.indexOf(r.failedGate ?? 'compiler') + 1} of 4)`];
|
|
144
|
+
for (const c of r.candidates)
|
|
145
|
+
lines.push(` candidate ${c.file} -> ${c.replaces}`);
|
|
146
|
+
for (const g of r.gates) {
|
|
147
|
+
lines.push(` ${g.gate.padEnd(10)} ${g.status === 'pass' ? 'pass' : g.status === 'fail' ? 'FAIL' : 'not run'}${g.reason ? ` ${g.reason}` : ''}`);
|
|
148
|
+
for (const d of g.details)
|
|
149
|
+
lines.push(` ${d}`);
|
|
150
|
+
}
|
|
151
|
+
if (r.score.minMatch !== null) {
|
|
152
|
+
lines.push(` scores (needs ${pct(ASSIST_MATCH)} each): ${[...r.score.states.map((s) => `${s.state} ${pct(s.match)}`), ...r.score.steps.map((s) => `step "${s.name}" ${pct(s.match)}${s.failure ? ` (${s.failure})` : ''}${s.stateMismatches ? ` (${s.stateMismatches} DOM fact${s.stateMismatches === 1 ? '' : 's'} differ)` : ''}`)].join(', ')}`);
|
|
153
|
+
}
|
|
154
|
+
if (r.discoveredSteps)
|
|
155
|
+
lines.push(` auto-steps: ${r.discoveredSteps.length} step(s) discovered on the React page`);
|
|
156
|
+
return lines;
|
|
157
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AnalyzeResult, BatchOptions, BatchReport, CompileOptions, CompileResult, ProjectOptions, VerifyOptions, VerifyResult } from './types.js';
|
|
2
|
+
import { type AssistOptions, type RepairOptions, type RepairResult } from './ai/repair.js';
|
|
3
|
+
import { type GateOptions, type GateResult } from './gate.js';
|
|
4
|
+
import { type AddOptions, type AddResult } from './registry/add.js';
|
|
5
|
+
import { type PublishOptions, type PublishResult } from './registry/publish.js';
|
|
6
|
+
export type * from './types.js';
|
|
7
|
+
export type { AssistGate, AssistOptions, AssistRequest, AssistStop, AssistWriter, RepairAttempt, RepairOptions, RepairResult } from './ai/repair.js';
|
|
8
|
+
export { TARGETS } from './types.js';
|
|
9
|
+
export { readFolderList } from './batch.js';
|
|
10
|
+
export { glslToSksl } from './targets/react-native/skia.js';
|
|
11
|
+
export { cleanup } from './utils/cleanup.js';
|
|
12
|
+
/** What a component file is made of: components, props, hooks, imports, web features and every finding. */
|
|
13
|
+
export declare function analyze(file: string, options?: ProjectOptions): Promise<AnalyzeResult>;
|
|
14
|
+
/** Compiles a component file (and the local files it imports) to Vue 3, Svelte 5 and React Native. */
|
|
15
|
+
export declare function compile(file: string, options?: CompileOptions): Promise<CompileResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Compiles every component under a folder and returns an honest clean / partial / unsupported scorecard. With `assist`
|
|
18
|
+
* (assisted mode, opt-in), each refused web target is offered to the model and counted `assisted` only if it passes
|
|
19
|
+
* every gate.
|
|
20
|
+
*/
|
|
21
|
+
export declare function batch(input: string, options?: BatchOptions & {
|
|
22
|
+
assist?: AssistOptions;
|
|
23
|
+
}): Promise<BatchReport>;
|
|
24
|
+
/** Renders the React original and its Vue and Svelte output in a sandboxed Chromium and compares them pixel by pixel. */
|
|
25
|
+
export declare function verify(file: string, options?: VerifyOptions): Promise<VerifyResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Assisted mode (opt-in): on blocking diagnostics (or, with `verify`, a browser match under 99%), a model rewrites the
|
|
28
|
+
* file, at most 3 times; a result is accepted only if it passes every gate (compiler, strict type check, browser harness
|
|
29
|
+
* against React, unmount check) and then has status `assisted`. Otherwise the compiler's output comes back unchanged.
|
|
30
|
+
*/
|
|
31
|
+
export declare function repair(file: string, options: RepairOptions): Promise<RepairResult>;
|
|
32
|
+
export type { GateCheck, GateOptions, GateResult, GateScore, GateStatus } from './gate.js';
|
|
33
|
+
export type { CliProviderName, HttpProviderName, ProviderName, ProviderOptions } from './ai/provider.js';
|
|
34
|
+
/**
|
|
35
|
+
* Runs the four gates assisted mode holds a model-written file to, on candidate files a person or an agent wrote for one
|
|
36
|
+
* web target: the target's real compiler (and no `not converted` mark), the strict type check, the browser harness
|
|
37
|
+
* against the React original (99% in every state and step, no DOM fact that differs, no page error) and the unmount
|
|
38
|
+
* check. `passed` only when all four pass; otherwise `failedGate` and `reason` name the first that failed.
|
|
39
|
+
*/
|
|
40
|
+
export declare function gate(sourceFile: string, candidateFiles: string | readonly string[], options: GateOptions): Promise<GateResult>;
|
|
41
|
+
export type { AddEntry, AddOptions, AddResult } from './registry/add.js';
|
|
42
|
+
export type { RegistryFile, RegistryItem } from './registry/item.js';
|
|
43
|
+
/**
|
|
44
|
+
* Converts a shadcn-format registry item (an https URL, fetched through the SSRF guard, or a local .json file) and the
|
|
45
|
+
* items it depends on into the project in `options.projectDir` (default: the working directory). The `npm install`
|
|
46
|
+
* line it returns is never run. See the README, "Add".
|
|
47
|
+
*/
|
|
48
|
+
export declare function addFromRegistry(input: string, options?: AddOptions): Promise<AddResult>;
|
|
49
|
+
export type { ComponentCard, PublishOptions, PublishResult, PublishedRegistry, Scorecard, TargetCard, TargetTotals, VerifyCard } from './registry/publish.js';
|
|
50
|
+
/**
|
|
51
|
+
* Publishes a folder of React components: runs `batch`, then writes `<out>/<target>/registry.json` and one registry item
|
|
52
|
+
* per converted component for each of Vue, Svelte and Angular, plus `<out>/SCORECARD.md` and `<out>/scorecard.json`
|
|
53
|
+
* (with `verify`, each clean component's lowest browser match and leak status). See the README, "Publish".
|
|
54
|
+
*/
|
|
55
|
+
export declare function publish(folder: string, options: PublishOptions): Promise<PublishResult>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @antheo/morph: compile animated React UI components to Vue 3, Svelte 5 and React Native, and verify the web output
|
|
3
|
+
* against the React original, pixel by pixel, in a sandboxed headless Chromium. Everything here works offline.
|
|
4
|
+
*/
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { makeProject } from './analyzer/deps.js';
|
|
7
|
+
import { buildAnalysis } from './analyzer/manifest.js';
|
|
8
|
+
import { buildGraph, compileFile } from './pipeline.js';
|
|
9
|
+
import { runBatch } from './batch.js';
|
|
10
|
+
import { runVerify } from './verify/runner.js';
|
|
11
|
+
import { runRepair } from './ai/repair.js';
|
|
12
|
+
import { runGate } from './gate.js';
|
|
13
|
+
import { addFromRegistry as runAdd } from './registry/add.js';
|
|
14
|
+
import { publishFolder } from './registry/publish.js';
|
|
15
|
+
export { TARGETS } from './types.js';
|
|
16
|
+
export { readFolderList } from './batch.js';
|
|
17
|
+
export { glslToSksl } from './targets/react-native/skia.js';
|
|
18
|
+
export { cleanup } from './utils/cleanup.js';
|
|
19
|
+
/** What a component file is made of: components, props, hooks, imports, web features and every finding. */
|
|
20
|
+
export async function analyze(file, options = {}) {
|
|
21
|
+
const entry = resolve(file);
|
|
22
|
+
const project = makeProject(entry, options);
|
|
23
|
+
const { nodes, diagnostics } = buildGraph(entry, project);
|
|
24
|
+
return buildAnalysis(entry, nodes, project, diagnostics);
|
|
25
|
+
}
|
|
26
|
+
/** Compiles a component file (and the local files it imports) to Vue 3, Svelte 5 and React Native. */
|
|
27
|
+
export async function compile(file, options = {}) {
|
|
28
|
+
return compileFile(file, options);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Compiles every component under a folder and returns an honest clean / partial / unsupported scorecard. With `assist`
|
|
32
|
+
* (assisted mode, opt-in), each refused web target is offered to the model and counted `assisted` only if it passes
|
|
33
|
+
* every gate.
|
|
34
|
+
*/
|
|
35
|
+
export async function batch(input, options = {}) {
|
|
36
|
+
return runBatch(input, options);
|
|
37
|
+
}
|
|
38
|
+
/** Renders the React original and its Vue and Svelte output in a sandboxed Chromium and compares them pixel by pixel. */
|
|
39
|
+
export async function verify(file, options = {}) {
|
|
40
|
+
return runVerify(file, options);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Assisted mode (opt-in): on blocking diagnostics (or, with `verify`, a browser match under 99%), a model rewrites the
|
|
44
|
+
* file, at most 3 times; a result is accepted only if it passes every gate (compiler, strict type check, browser harness
|
|
45
|
+
* against React, unmount check) and then has status `assisted`. Otherwise the compiler's output comes back unchanged.
|
|
46
|
+
*/
|
|
47
|
+
export async function repair(file, options) {
|
|
48
|
+
return runRepair(file, options);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Runs the four gates assisted mode holds a model-written file to, on candidate files a person or an agent wrote for one
|
|
52
|
+
* web target: the target's real compiler (and no `not converted` mark), the strict type check, the browser harness
|
|
53
|
+
* against the React original (99% in every state and step, no DOM fact that differs, no page error) and the unmount
|
|
54
|
+
* check. `passed` only when all four pass; otherwise `failedGate` and `reason` name the first that failed.
|
|
55
|
+
*/
|
|
56
|
+
export async function gate(sourceFile, candidateFiles, options) {
|
|
57
|
+
return runGate(sourceFile, typeof candidateFiles === 'string' ? [candidateFiles] : candidateFiles, options);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Converts a shadcn-format registry item (an https URL, fetched through the SSRF guard, or a local .json file) and the
|
|
61
|
+
* items it depends on into the project in `options.projectDir` (default: the working directory). The `npm install`
|
|
62
|
+
* line it returns is never run. See the README, "Add".
|
|
63
|
+
*/
|
|
64
|
+
export async function addFromRegistry(input, options = {}) {
|
|
65
|
+
return runAdd(input, options);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Publishes a folder of React components: runs `batch`, then writes `<out>/<target>/registry.json` and one registry item
|
|
69
|
+
* per converted component for each of Vue, Svelte and Angular, plus `<out>/SCORECARD.md` and `<out>/scorecard.json`
|
|
70
|
+
* (with `verify`, each clean component's lowest browser match and leak status). See the README, "Publish".
|
|
71
|
+
*/
|
|
72
|
+
export async function publish(folder, options) {
|
|
73
|
+
return publishFolder(folder, options);
|
|
74
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ModuleIR } from './model.js';
|
|
2
|
+
import type { TypeOracle } from './oracle.js';
|
|
3
|
+
/**
|
|
4
|
+
* React types many parameters from their context: `onClick={(event) => …}` gets `MouseEvent<HTMLButtonElement>`, a
|
|
5
|
+
* callback passed to a typed prop gets that prop's parameters. Moved into a script function they lose that context, so
|
|
6
|
+
* every unannotated parameter still at its place in the source gets the type TypeScript gave it there.
|
|
7
|
+
*/
|
|
8
|
+
export declare function annotateParams(mod: ModuleIR, file: string, oracle: TypeOracle): void;
|
|
9
|
+
/** The same for the functions inside one value (an expression, a node list, IR holding nodes). */
|
|
10
|
+
export declare function annotateIn(root: unknown, file: string, oracle: TypeOracle, seen?: Set<object>): void;
|
|
11
|
+
/**
|
|
12
|
+
* A handler typed with React's event (`(e: React.DragEvent<HTMLDivElement>) => …`) reads `e.dataTransfer` and
|
|
13
|
+
* `e.target` as React typed them, never null; the DOM event a target hands over types them `… | null`. Each such read
|
|
14
|
+
* states React's type with `!` (only these fields, only on a parameter React typed as its event).
|
|
15
|
+
*/
|
|
16
|
+
export declare function assertReactEventFields(mod: ModuleIR): void;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
/**
|
|
3
|
+
* React types many parameters from their context: `onClick={(event) => …}` gets `MouseEvent<HTMLButtonElement>`, a
|
|
4
|
+
* callback passed to a typed prop gets that prop's parameters. Moved into a script function they lose that context, so
|
|
5
|
+
* every unannotated parameter still at its place in the source gets the type TypeScript gave it there.
|
|
6
|
+
*/
|
|
7
|
+
export function annotateParams(mod, file, oracle) {
|
|
8
|
+
for (const fn of [...mod.components, ...mod.hooks]) {
|
|
9
|
+
annotateIn(fn.items, file, oracle);
|
|
10
|
+
if ('template' in fn)
|
|
11
|
+
annotateIn(fn.template, file, oracle);
|
|
12
|
+
// markup kept out of the template (KeptMarkup `expression`): a target that writes it reads its parameters typed too
|
|
13
|
+
annotateIn((fn.keptMarkup ?? []).flatMap((k) => (k.kind === 'expression' ? [k.expr] : [])), file, oracle);
|
|
14
|
+
if ('returns' in fn)
|
|
15
|
+
annotateIn(fn.returns, file, oracle);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** The same for the functions inside one value (an expression, a node list, IR holding nodes). */
|
|
19
|
+
export function annotateIn(root, file, oracle, seen = new Set()) {
|
|
20
|
+
const visit = (value) => {
|
|
21
|
+
if (!value || typeof value !== 'object' || seen.has(value))
|
|
22
|
+
return;
|
|
23
|
+
seen.add(value);
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
for (const v of value)
|
|
26
|
+
visit(v);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const node = value;
|
|
30
|
+
if (typeof node.type === 'string' && (t.isFunction(node) || t.isObjectMethod(node))) {
|
|
31
|
+
for (const p of node.params) {
|
|
32
|
+
if (!t.isIdentifier(p) || p.typeAnnotation || (p.start == null && !p.loc))
|
|
33
|
+
continue;
|
|
34
|
+
// a copied node (a row of a list kept in a local) has its location but no offset
|
|
35
|
+
const type = p.start != null ? oracle.typeAt(file, p.start) : p.loc ? oracle.typeAtLocation(file, p.loc.start.line, p.loc.start.column) : null;
|
|
36
|
+
if (type)
|
|
37
|
+
p.typeAnnotation = t.tsTypeAnnotation(type);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
for (const [key, v] of Object.entries(value)) {
|
|
41
|
+
if (key === 'loc' || key === 'leadingComments' || key === 'trailingComments' || key === 'innerComments' || key === 'extra')
|
|
42
|
+
continue;
|
|
43
|
+
visit(v);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
visit(root);
|
|
47
|
+
}
|
|
48
|
+
/** React's event fields that are never null in its types, though the DOM's may be, by the event type that has them. */
|
|
49
|
+
const NON_NULL_FIELDS = {
|
|
50
|
+
DragEvent: ['dataTransfer', 'target'],
|
|
51
|
+
ClipboardEvent: ['clipboardData', 'target'],
|
|
52
|
+
MouseEvent: ['target'], PointerEvent: ['target'], KeyboardEvent: ['target'], FocusEvent: ['target'], TouchEvent: ['target'],
|
|
53
|
+
WheelEvent: ['target'], AnimationEvent: ['target'], TransitionEvent: ['target'], CompositionEvent: ['target'], UIEvent: ['target'],
|
|
54
|
+
SyntheticEvent: ['target'], BaseSyntheticEvent: ['target'],
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* A handler typed with React's event (`(e: React.DragEvent<HTMLDivElement>) => …`) reads `e.dataTransfer` and
|
|
58
|
+
* `e.target` as React typed them, never null; the DOM event a target hands over types them `… | null`. Each such read
|
|
59
|
+
* states React's type with `!` (only these fields, only on a parameter React typed as its event).
|
|
60
|
+
*/
|
|
61
|
+
export function assertReactEventFields(mod) {
|
|
62
|
+
const reactTypes = new Map();
|
|
63
|
+
for (const d of mod.imports) {
|
|
64
|
+
if (d.source.value !== 'react')
|
|
65
|
+
continue;
|
|
66
|
+
for (const s of d.specifiers) {
|
|
67
|
+
if (t.isImportSpecifier(s))
|
|
68
|
+
reactTypes.set(s.local.name, t.isIdentifier(s.imported) ? s.imported.name : s.imported.value);
|
|
69
|
+
else
|
|
70
|
+
reactTypes.set(`${s.local.name}.`, '');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const eventOf = (type) => {
|
|
74
|
+
if (!t.isTSTypeAnnotation(type) || !t.isTSTypeReference(type.typeAnnotation))
|
|
75
|
+
return null;
|
|
76
|
+
const name = type.typeAnnotation.typeName;
|
|
77
|
+
if (t.isTSQualifiedName(name) && t.isIdentifier(name.left) && (name.left.name === 'React' || reactTypes.has(`${name.left.name}.`)))
|
|
78
|
+
return name.right.name;
|
|
79
|
+
return t.isIdentifier(name) ? (reactTypes.get(name.name) ?? null) : null;
|
|
80
|
+
};
|
|
81
|
+
const fix = (fn) => {
|
|
82
|
+
const fields = new Map();
|
|
83
|
+
for (const p of fn.params) {
|
|
84
|
+
const event = t.isIdentifier(p) ? eventOf(p.typeAnnotation) : null;
|
|
85
|
+
const list = event ? NON_NULL_FIELDS[event] : undefined;
|
|
86
|
+
if (t.isIdentifier(p) && list)
|
|
87
|
+
fields.set(p.name, list);
|
|
88
|
+
}
|
|
89
|
+
if (!fields.size)
|
|
90
|
+
return;
|
|
91
|
+
const visit = (n) => {
|
|
92
|
+
for (const k of t.VISITOR_KEYS[n.type] ?? []) {
|
|
93
|
+
const v = Reflect.get(n, k);
|
|
94
|
+
if (Array.isArray(v)) {
|
|
95
|
+
v.forEach((c, i) => {
|
|
96
|
+
if (!t.isNode(c))
|
|
97
|
+
return;
|
|
98
|
+
visit(c);
|
|
99
|
+
v[i] = wrap(c, n, k);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else if (t.isNode(v)) {
|
|
103
|
+
visit(v);
|
|
104
|
+
Reflect.set(n, k, wrap(v, n, k));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const wrap = (c, parent, key) => {
|
|
109
|
+
if (!t.isMemberExpression(c) || c.computed || !t.isIdentifier(c.object) || !t.isIdentifier(c.property))
|
|
110
|
+
return c;
|
|
111
|
+
if (!fields.get(c.object.name)?.includes(c.property.name))
|
|
112
|
+
return c;
|
|
113
|
+
// a write, an existing `!`, or a test (`if (e.target)`) needs no statement
|
|
114
|
+
// the author's own cast (`e.target as Element`) already says what it is
|
|
115
|
+
if (t.isTSAsExpression(parent) || t.isTSSatisfiesExpression(parent) || t.isTSTypeAssertion(parent) || t.isTSNonNullExpression(parent) || (t.isAssignmentExpression(parent) && key === 'left') || ((t.isIfStatement(parent) || t.isConditionalExpression(parent)) && key === 'test') || t.isLogicalExpression(parent) || t.isUnaryExpression(parent, { operator: '!' }) || (t.isOptionalMemberExpression(parent) && key === 'object') || (t.isBinaryExpression(parent) && /^[!=]==?$/.test(parent.operator)))
|
|
116
|
+
return c;
|
|
117
|
+
return t.tsNonNullExpression(c);
|
|
118
|
+
};
|
|
119
|
+
visit(fn.body);
|
|
120
|
+
};
|
|
121
|
+
const seen = new Set();
|
|
122
|
+
const walk = (value) => {
|
|
123
|
+
if (!value || typeof value !== 'object' || seen.has(value))
|
|
124
|
+
return;
|
|
125
|
+
seen.add(value);
|
|
126
|
+
if (Array.isArray(value)) {
|
|
127
|
+
for (const v of value)
|
|
128
|
+
walk(v);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (t.isNode(value) && t.isFunction(value))
|
|
132
|
+
fix(value);
|
|
133
|
+
for (const [k, v] of Object.entries(value)) {
|
|
134
|
+
if (k === 'loc' || k === 'leadingComments' || k === 'trailingComments' || k === 'innerComments' || k === 'extra')
|
|
135
|
+
continue;
|
|
136
|
+
walk(v);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
for (const fn of [...mod.components, ...mod.hooks]) {
|
|
140
|
+
walk(fn.items);
|
|
141
|
+
if ('template' in fn)
|
|
142
|
+
walk(fn.template);
|
|
143
|
+
walk((fn.keptMarkup ?? []).flatMap((k) => (k.kind === 'expression' ? [k.expr] : [])));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentIR, ElementNode, ModuleIR } from './model.js';
|
|
2
|
+
/**
|
|
3
|
+
* Radix's Slot without Radix. shadcn's components switch their element for a Slot when given `asChild`:
|
|
4
|
+
*
|
|
5
|
+
* const Comp = asChild ? Slot.Root : 'button';
|
|
6
|
+
* return <Comp data-slot="button" className={…} {...props} />;
|
|
7
|
+
*
|
|
8
|
+
* The Slot renders the one element it is given as children, with the Slot's props merged onto it (Radix's mergeProps:
|
|
9
|
+
* the child's own props win, class names are joined, styles merged with the child's winning, a handler both have runs
|
|
10
|
+
* the child's first, refs composed). This pass recognises the Slot by its import (`Slot` from 'radix-ui', read as
|
|
11
|
+
* `Slot.Root` or `Slot.Slot`; `Slot` or `Root` from '@radix-ui/react-slot') and by that one use: a value of the
|
|
12
|
+
* component that picks it or a tag name by a test, read only as an element's tag. The element keeps the tag and holds
|
|
13
|
+
* the test (ElementNode.asChild); the value goes, and the import with it when nothing else reads the Slot. Any other
|
|
14
|
+
* use stays as it was (the React-library placeholder and its diagnostic).
|
|
15
|
+
*/
|
|
16
|
+
export declare function slotAsChild(mod: ModuleIR): void;
|
|
17
|
+
/** The elements of a component's markup that become a Radix Slot under a test (ElementNode.asChild). */
|
|
18
|
+
export declare function asChildElements(comp: ComponentIR): ElementNode[];
|