@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,585 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { classifyImport, resolveLocal, unsupportedReason } from '../../analyzer/deps.js';
|
|
3
|
+
import { parseSource, traverse } from '../../analyzer/parse.js';
|
|
4
|
+
import { containsJSX, unwrap } from '../../ir/lower.js';
|
|
5
|
+
import { styleKey } from '../../ir/style.js';
|
|
6
|
+
import { relative } from 'node:path';
|
|
7
|
+
import { importPath } from '../shared/layout.js';
|
|
8
|
+
import { toPosix } from '../../utils/fs-safe.js';
|
|
9
|
+
import { nextFontObject } from '../shared/module.js';
|
|
10
|
+
import { printProgram } from '../shared/markup.js';
|
|
11
|
+
import { glslToSksl, looksLikeGlsl } from './skia.js';
|
|
12
|
+
import { transformMotion } from './motion.js';
|
|
13
|
+
/** Web tags as React Native components. */
|
|
14
|
+
const VIEW_TAGS = new Set(['div', 'section', 'article', 'header', 'footer', 'main', 'nav', 'aside', 'ul', 'ol', 'li', 'form', 'figure', 'figcaption', 'fieldset', 'dl', 'dt', 'dd', 'details', 'summary', 'dialog', 'menu', 'table', 'thead', 'tbody', 'tfoot', 'tr', 'td', 'th', 'i', 'b']);
|
|
15
|
+
const TEXT_TAGS = new Set(['span', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'label', 'strong', 'em', 'small', 'code', 'pre', 'blockquote', 'q', 'cite', 'abbr', 'time', 'mark', 'sub', 'sup', 'kbd', 'legend', 'caption', 'output']);
|
|
16
|
+
/** `<i>` and `<b>` hold icons or text: they become Text when they contain text, else View. */
|
|
17
|
+
const SVG_COMPONENTS = {
|
|
18
|
+
svg: 'Svg', path: 'Path', circle: 'Circle', rect: 'Rect', g: 'G', line: 'Line', polyline: 'Polyline', polygon: 'Polygon', ellipse: 'Ellipse',
|
|
19
|
+
defs: 'Defs', linearGradient: 'LinearGradient', radialGradient: 'RadialGradient', stop: 'Stop', mask: 'Mask', clipPath: 'ClipPath',
|
|
20
|
+
pattern: 'Pattern', use: 'Use', symbol: 'Symbol', text: 'SvgText', tspan: 'TSpan', image: 'SvgImage', marker: 'Marker', foreignObject: 'ForeignObject',
|
|
21
|
+
};
|
|
22
|
+
const TEXT_HOSTS = new Set(['View', 'Pressable', 'ScrollView', 'Animated.View', 'AnimatedPressable']);
|
|
23
|
+
/** Text styling: on React Native it only applies to <Text>, so it moves from a container to the text inside. */
|
|
24
|
+
const TEXT_CLASS = /^(?:[\w-]+:)*(?:text-|font-|leading-|tracking-|decoration-|indent-|whitespace-|break-|italic$|not-italic$|uppercase$|lowercase$|capitalize$|normal-case$|underline$|overline$|line-through$|no-underline$|truncate$|antialiased$|subpixel-antialiased$)/;
|
|
25
|
+
const DROP_ATTRS = new Set(['htmlFor', 'tabIndex', 'title', 'type', 'draggable', 'spellCheck', 'autoComplete', 'contentEditable', 'dir', 'lang', 'translate', 'hidden', 'aria-describedby', 'aria-controls', 'aria-owns', 'aria-haspopup', 'aria-pressed', 'aria-current', 'aria-orientation', 'aria-valuetext', 'aria-roledescription', 'xmlns', 'suppressHydrationWarning', 'target', 'rel', 'name', 'form', 'method', 'action', 'noValidate']);
|
|
26
|
+
const RN_ARIA = new Set(['aria-label', 'aria-labelledby', 'aria-hidden', 'aria-busy', 'aria-disabled', 'aria-expanded', 'aria-selected', 'aria-checked', 'aria-live', 'aria-modal', 'aria-valuemin', 'aria-valuemax', 'aria-valuenow']);
|
|
27
|
+
/** Style properties React Native has no equivalent for. */
|
|
28
|
+
const WEB_ONLY_STYLE = new Set(['boxShadow', 'backgroundImage', 'background', 'transition', 'transitionProperty', 'transitionDuration', 'animation', 'animationName', 'filter', 'backdropFilter', 'cursor', 'userSelect', 'WebkitUserSelect', 'mask', 'maskImage', 'WebkitMaskImage', 'WebkitMask', 'clipPath', 'mixBlendMode', 'isolation', 'willChange', 'contain', 'touchAction', 'outline', 'outlineOffset', 'whiteSpace', 'textOverflow', 'WebkitBackgroundClip', 'backgroundClip', 'backgroundSize', 'backgroundPosition', 'backgroundRepeat', 'gridTemplateColumns', 'gridTemplateRows', 'gridArea', 'gridColumn', 'gridRow', 'placeItems', 'inset', 'verticalAlign', 'listStyle', 'scrollbarWidth', 'appearance', 'resize']);
|
|
29
|
+
/** JSX's own whitespace rule for a text child: what React actually renders. */
|
|
30
|
+
export function cleanJsxText(value) {
|
|
31
|
+
const lines = value.split(/\r\n|\n|\r/);
|
|
32
|
+
let last = 0;
|
|
33
|
+
lines.forEach((l, i) => {
|
|
34
|
+
if (/[^ \t]/.test(l))
|
|
35
|
+
last = i;
|
|
36
|
+
});
|
|
37
|
+
let out = '';
|
|
38
|
+
lines.forEach((line, i) => {
|
|
39
|
+
let l = line.replace(/\t/g, ' ');
|
|
40
|
+
if (i !== 0)
|
|
41
|
+
l = l.replace(/^[ ]+/, '');
|
|
42
|
+
if (i !== lines.length - 1)
|
|
43
|
+
l = l.replace(/[ ]+$/, '');
|
|
44
|
+
if (l) {
|
|
45
|
+
if (i !== last)
|
|
46
|
+
l += ' ';
|
|
47
|
+
out += l;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
function jsxName(n) {
|
|
53
|
+
if (t.isJSXIdentifier(n))
|
|
54
|
+
return n.name;
|
|
55
|
+
if (t.isJSXNamespacedName(n))
|
|
56
|
+
return `${n.namespace.name}:${n.name.name}`;
|
|
57
|
+
return `${jsxName(n.object)}.${n.property.name}`;
|
|
58
|
+
}
|
|
59
|
+
function setName(el, name) {
|
|
60
|
+
const make = () => {
|
|
61
|
+
const parts = name.split('.');
|
|
62
|
+
let node = t.jsxIdentifier(parts[0] ?? name);
|
|
63
|
+
for (const part of parts.slice(1))
|
|
64
|
+
node = t.jsxMemberExpression(node, t.jsxIdentifier(part));
|
|
65
|
+
return node;
|
|
66
|
+
};
|
|
67
|
+
el.openingElement.name = make();
|
|
68
|
+
if (el.closingElement)
|
|
69
|
+
el.closingElement.name = make();
|
|
70
|
+
}
|
|
71
|
+
function attr(el, name) {
|
|
72
|
+
return el.openingElement.attributes.find((a) => t.isJSXAttribute(a) && jsxName(a.name) === name);
|
|
73
|
+
}
|
|
74
|
+
function attrExpr(a) {
|
|
75
|
+
if (!a?.value)
|
|
76
|
+
return null;
|
|
77
|
+
if (t.isStringLiteral(a.value))
|
|
78
|
+
return a.value;
|
|
79
|
+
if (t.isJSXExpressionContainer(a.value) && t.isExpression(a.value.expression))
|
|
80
|
+
return a.value.expression;
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
/** Splits the static class names of a className value into text classes and the rest, rewriting it in place. */
|
|
84
|
+
function hoistTextClasses(a) {
|
|
85
|
+
const moved = [];
|
|
86
|
+
const split = (s) => {
|
|
87
|
+
const keep = [];
|
|
88
|
+
for (const c of s.split(/\s+/).filter(Boolean))
|
|
89
|
+
(TEXT_CLASS.test(c) ? moved : keep).push(c);
|
|
90
|
+
return keep.join(' ');
|
|
91
|
+
};
|
|
92
|
+
if (t.isStringLiteral(a.value)) {
|
|
93
|
+
a.value = t.stringLiteral(split(a.value.value));
|
|
94
|
+
return moved;
|
|
95
|
+
}
|
|
96
|
+
if (!t.isJSXExpressionContainer(a.value) || !t.isExpression(a.value.expression))
|
|
97
|
+
return moved;
|
|
98
|
+
const e = unwrap(a.value.expression);
|
|
99
|
+
// only unconditional literal parts move: cn('...', cond && '...') keeps the conditional part where it is
|
|
100
|
+
if (t.isCallExpression(e)) {
|
|
101
|
+
for (const [i, arg] of e.arguments.entries())
|
|
102
|
+
if (t.isStringLiteral(arg))
|
|
103
|
+
e.arguments[i] = t.stringLiteral(split(arg.value));
|
|
104
|
+
}
|
|
105
|
+
else if (t.isTemplateLiteral(e)) {
|
|
106
|
+
for (const q of e.quasis) {
|
|
107
|
+
const raw = q.value.raw;
|
|
108
|
+
const lead = /^\s/.test(raw) ? ' ' : '';
|
|
109
|
+
const trail = /\s$/.test(raw) ? ' ' : '';
|
|
110
|
+
const kept = split(raw);
|
|
111
|
+
q.value = { raw: kept ? lead + kept + trail : lead || trail, cooked: kept ? lead + kept + trail : lead || trail };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (t.isStringLiteral(e))
|
|
115
|
+
a.value = t.stringLiteral(split(e.value));
|
|
116
|
+
return moved;
|
|
117
|
+
}
|
|
118
|
+
/** Whether a child expression could render text (a string or number) rather than elements. */
|
|
119
|
+
function isTexty(e, nodeProps) {
|
|
120
|
+
const x = unwrap(e);
|
|
121
|
+
if (t.isNullLiteral(x) || t.isBooleanLiteral(x))
|
|
122
|
+
return 'element';
|
|
123
|
+
if (t.isIdentifier(x) && x.name === 'undefined')
|
|
124
|
+
return 'element';
|
|
125
|
+
if (containsJSX(x))
|
|
126
|
+
return 'element';
|
|
127
|
+
if (t.isIdentifier(x) && (x.name === 'children' || nodeProps.has(x.name)))
|
|
128
|
+
return 'node';
|
|
129
|
+
if (t.isMemberExpression(x) && t.isIdentifier(x.property, { name: 'children' }))
|
|
130
|
+
return 'node';
|
|
131
|
+
return 'text';
|
|
132
|
+
}
|
|
133
|
+
/** The resolution of `var(--name)` inside a style object whose own custom properties define it. */
|
|
134
|
+
function resolveCssVars(obj) {
|
|
135
|
+
const vars = new Map();
|
|
136
|
+
let touched = false;
|
|
137
|
+
for (const p of obj.properties) {
|
|
138
|
+
if (t.isObjectProperty(p) && t.isExpression(p.value)) {
|
|
139
|
+
const key = styleKey(p);
|
|
140
|
+
if (key?.startsWith('--'))
|
|
141
|
+
vars.set(key, p.value);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (!vars.size)
|
|
145
|
+
return false;
|
|
146
|
+
obj.properties = obj.properties.filter((p) => !(t.isObjectProperty(p) && styleKey(p)?.startsWith('--')));
|
|
147
|
+
for (const p of obj.properties) {
|
|
148
|
+
if (!t.isObjectProperty(p))
|
|
149
|
+
continue;
|
|
150
|
+
const v = p.value;
|
|
151
|
+
if (t.isStringLiteral(v)) {
|
|
152
|
+
const m = v.value.match(/^var\((--[\w-]+)\)$/);
|
|
153
|
+
const repl = m ? vars.get(m[1] ?? '') : undefined;
|
|
154
|
+
if (repl) {
|
|
155
|
+
p.value = t.cloneNode(repl, true);
|
|
156
|
+
touched = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return touched || vars.size > 0;
|
|
161
|
+
}
|
|
162
|
+
/** A px string as a number ('24px' → 24); other units are left for the fidelity report. */
|
|
163
|
+
function rnStyleValue(v) {
|
|
164
|
+
if (t.isStringLiteral(v)) {
|
|
165
|
+
const px = v.value.match(/^(-?\d*\.?\d+)px$/);
|
|
166
|
+
if (px)
|
|
167
|
+
return t.numericLiteral(Number(px[1]));
|
|
168
|
+
const rem = v.value.match(/^(-?\d*\.?\d+)rem$/);
|
|
169
|
+
if (rem)
|
|
170
|
+
return t.numericLiteral(Number(rem[1]) * 16);
|
|
171
|
+
}
|
|
172
|
+
return v;
|
|
173
|
+
}
|
|
174
|
+
function mapElement(path, st) {
|
|
175
|
+
const el = path.node;
|
|
176
|
+
const name = jsxName(el.openingElement.name);
|
|
177
|
+
if (!/^[a-z]/.test(name) || name.includes('-'))
|
|
178
|
+
return;
|
|
179
|
+
const hasPressHandler = !!(attr(el, 'onClick') || attr(el, 'onPointerDown') || attr(el, 'onMouseDown') || attr(el, 'onPointerUp'));
|
|
180
|
+
let target;
|
|
181
|
+
if (SVG_COMPONENTS[name]) {
|
|
182
|
+
target = SVG_COMPONENTS[name] ?? 'Svg';
|
|
183
|
+
st.svg.add(target);
|
|
184
|
+
}
|
|
185
|
+
else if (name === 'button' || (hasPressHandler && (VIEW_TAGS.has(name) || TEXT_TAGS.has(name) || name === 'a')))
|
|
186
|
+
target = 'Pressable';
|
|
187
|
+
else if (name === 'a')
|
|
188
|
+
target = 'Pressable';
|
|
189
|
+
else if (name === 'img')
|
|
190
|
+
target = 'Image';
|
|
191
|
+
else if (name === 'input' || name === 'textarea')
|
|
192
|
+
target = 'TextInput';
|
|
193
|
+
else if (name === 'canvas') {
|
|
194
|
+
st.diag('rn-canvas', 'error', 'A <canvas> drawn imperatively has no React Native counterpart (Skia draws declaratively).', el);
|
|
195
|
+
target = 'View';
|
|
196
|
+
}
|
|
197
|
+
else if (name === 'br') {
|
|
198
|
+
path.replaceWith(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier('Text'), []), t.jsxClosingElement(t.jsxIdentifier('Text')), [t.jsxExpressionContainer(t.stringLiteral('\n'))]));
|
|
199
|
+
st.rn.add('Text');
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
else if ((name === 'i' || name === 'b') && el.children.some((c) => (t.isJSXText(c) && c.value.trim()) || (t.isJSXExpressionContainer(c) && t.isExpression(c.expression) && isTexty(c.expression, st.nodeProps) === 'text')))
|
|
203
|
+
target = 'Text';
|
|
204
|
+
else if (TEXT_TAGS.has(name))
|
|
205
|
+
target = 'Text';
|
|
206
|
+
else if (VIEW_TAGS.has(name) || name === 'hr')
|
|
207
|
+
target = 'View';
|
|
208
|
+
else {
|
|
209
|
+
st.diag('rn-tag', 'warning', `<${name}> has no React Native counterpart; it becomes a View.`, el);
|
|
210
|
+
target = 'View';
|
|
211
|
+
}
|
|
212
|
+
if (!SVG_COMPONENTS[name])
|
|
213
|
+
st.rn.add(target);
|
|
214
|
+
setName(el, target);
|
|
215
|
+
if (target === 'Image') {
|
|
216
|
+
const src = attr(el, 'src');
|
|
217
|
+
if (src?.value) {
|
|
218
|
+
const value = attrExpr(src) ?? t.stringLiteral('');
|
|
219
|
+
src.name = t.jsxIdentifier('source');
|
|
220
|
+
src.value = t.jsxExpressionContainer(t.objectExpression([t.objectProperty(t.identifier('uri'), value)]));
|
|
221
|
+
}
|
|
222
|
+
const alt = attr(el, 'alt');
|
|
223
|
+
if (alt)
|
|
224
|
+
alt.name = t.jsxIdentifier('accessibilityLabel');
|
|
225
|
+
}
|
|
226
|
+
if (target === 'TextInput') {
|
|
227
|
+
const change = attr(el, 'onChange');
|
|
228
|
+
const handler = attrExpr(change);
|
|
229
|
+
if (change && handler) {
|
|
230
|
+
change.name = t.jsxIdentifier('onChangeText');
|
|
231
|
+
change.value = t.jsxExpressionContainer(t.arrowFunctionExpression([t.identifier('text')], t.callExpression(handler, [t.objectExpression([t.objectProperty(t.identifier('target'), t.objectExpression([t.objectProperty(t.identifier('value'), t.identifier('text'))]))])])));
|
|
232
|
+
st.diag('rn-input', 'warning', 'onChange becomes onChangeText with a { target: { value } } stand-in event.', el);
|
|
233
|
+
}
|
|
234
|
+
if (name === 'textarea')
|
|
235
|
+
el.openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier('multiline'), null));
|
|
236
|
+
}
|
|
237
|
+
if (name === 'a') {
|
|
238
|
+
const href = attrExpr(attr(el, 'href'));
|
|
239
|
+
if (href && !attr(el, 'onClick')) {
|
|
240
|
+
st.needsLinking = true;
|
|
241
|
+
st.rn.add('Linking');
|
|
242
|
+
el.openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier('onPress'), t.jsxExpressionContainer(t.arrowFunctionExpression([], t.callExpression(t.memberExpression(t.identifier('Linking'), t.identifier('openURL')), [href])))));
|
|
243
|
+
}
|
|
244
|
+
el.openingElement.attributes = el.openingElement.attributes.filter((a) => !(t.isJSXAttribute(a) && jsxName(a.name) === 'href'));
|
|
245
|
+
}
|
|
246
|
+
if (name === 'canvas' || name === 'img' || name === 'input' || name === 'hr' || name === 'br')
|
|
247
|
+
el.selfClosing = el.children.length === 0;
|
|
248
|
+
mapAttributes(el, st, !!SVG_COMPONENTS[name]);
|
|
249
|
+
}
|
|
250
|
+
function mapAttributes(el, st, svg) {
|
|
251
|
+
const out = [];
|
|
252
|
+
for (const a of el.openingElement.attributes) {
|
|
253
|
+
if (t.isJSXSpreadAttribute(a)) {
|
|
254
|
+
out.push(a);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const name = jsxName(a.name);
|
|
258
|
+
if (svg) {
|
|
259
|
+
if (name === 'className')
|
|
260
|
+
st.diag('rn-svg-class', 'warning', 'className on react-native-svg elements needs NativeWind cssInterop to apply.', a);
|
|
261
|
+
out.push(a);
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
if (name === 'onClick') {
|
|
265
|
+
a.name = t.jsxIdentifier('onPress');
|
|
266
|
+
checkEventFields(a, st);
|
|
267
|
+
out.push(a);
|
|
268
|
+
}
|
|
269
|
+
else if (name === 'onPointerDown' || name === 'onMouseDown' || name === 'onTouchStart') {
|
|
270
|
+
a.name = t.jsxIdentifier('onPressIn');
|
|
271
|
+
checkEventFields(a, st);
|
|
272
|
+
out.push(a);
|
|
273
|
+
}
|
|
274
|
+
else if (name === 'onPointerUp' || name === 'onMouseUp' || name === 'onTouchEnd') {
|
|
275
|
+
a.name = t.jsxIdentifier('onPressOut');
|
|
276
|
+
checkEventFields(a, st);
|
|
277
|
+
out.push(a);
|
|
278
|
+
}
|
|
279
|
+
else if (name === 'onPointerEnter' || name === 'onMouseEnter') {
|
|
280
|
+
a.name = t.jsxIdentifier('onHoverIn');
|
|
281
|
+
st.diag('rn-hover', 'warning', 'Hover handlers become onHoverIn/onHoverOut, which only fire with a pointer (web, iPad, desktop).', a);
|
|
282
|
+
out.push(a);
|
|
283
|
+
}
|
|
284
|
+
else if (name === 'onPointerLeave' || name === 'onMouseLeave') {
|
|
285
|
+
a.name = t.jsxIdentifier('onHoverOut');
|
|
286
|
+
out.push(a);
|
|
287
|
+
}
|
|
288
|
+
else if (name === 'onFocus' || name === 'onBlur' || name === 'onLayout' || name === 'onLoad' || name === 'onChangeText')
|
|
289
|
+
out.push(a);
|
|
290
|
+
else if (/^on[A-Z]/.test(name)) {
|
|
291
|
+
st.diag('rn-event', 'warning', `${name} has no React Native counterpart and is dropped.`, a);
|
|
292
|
+
}
|
|
293
|
+
else if (name === 'className' || name === 'key' || name === 'ref' || name === 'style' || name === 'disabled' || name === 'role' || name === 'testID' || name === 'source' || name === 'accessibilityLabel' || name === 'value' || name === 'placeholder' || name === 'multiline' || name === 'children') {
|
|
294
|
+
if (name === 'style')
|
|
295
|
+
convertStyle(a, st);
|
|
296
|
+
out.push(a);
|
|
297
|
+
}
|
|
298
|
+
else if (name === 'id') {
|
|
299
|
+
a.name = t.jsxIdentifier('nativeID');
|
|
300
|
+
out.push(a);
|
|
301
|
+
}
|
|
302
|
+
else if (RN_ARIA.has(name))
|
|
303
|
+
out.push(a);
|
|
304
|
+
else if (name === 'dangerouslySetInnerHTML')
|
|
305
|
+
st.diag('rn-html', 'error', 'dangerouslySetInnerHTML has no React Native counterpart.', a);
|
|
306
|
+
else if (name.startsWith('data-')) {
|
|
307
|
+
st.diag('rn-data-attr', 'info', `${name} is dropped (React Native has no data attributes).`, a);
|
|
308
|
+
}
|
|
309
|
+
else if (DROP_ATTRS.has(name) || name.startsWith('aria-'))
|
|
310
|
+
continue;
|
|
311
|
+
else
|
|
312
|
+
out.push(a);
|
|
313
|
+
}
|
|
314
|
+
el.openingElement.attributes = out;
|
|
315
|
+
}
|
|
316
|
+
function checkEventFields(a, st) {
|
|
317
|
+
const handler = attrExpr(a);
|
|
318
|
+
if (!handler)
|
|
319
|
+
return;
|
|
320
|
+
let uses = '';
|
|
321
|
+
t.traverseFast(handler, (n) => {
|
|
322
|
+
if (t.isMemberExpression(n) && t.isIdentifier(n.property) && /^(button|key|clientX|clientY|pageX|pageY|currentTarget|shiftKey|metaKey|ctrlKey|altKey|repeat)$/.test(n.property.name))
|
|
323
|
+
uses = n.property.name;
|
|
324
|
+
});
|
|
325
|
+
if (uses)
|
|
326
|
+
st.diag('rn-event-fields', 'warning', `A press handler reads event.${uses}, which React Native press events do not have.`, a);
|
|
327
|
+
}
|
|
328
|
+
function convertStyle(a, st) {
|
|
329
|
+
const e = attrExpr(a);
|
|
330
|
+
const obj = e ? unwrap(e) : null;
|
|
331
|
+
if (!t.isObjectExpression(obj))
|
|
332
|
+
return;
|
|
333
|
+
if (resolveCssVars(obj))
|
|
334
|
+
st.diag('rn-css-vars', 'info', 'CSS custom properties in a style object are resolved to their values.', a);
|
|
335
|
+
obj.properties = obj.properties.filter((p) => {
|
|
336
|
+
if (!t.isObjectProperty(p))
|
|
337
|
+
return true;
|
|
338
|
+
const key = styleKey(p);
|
|
339
|
+
if (key && WEB_ONLY_STYLE.has(key)) {
|
|
340
|
+
st.diag('rn-style', 'warning', `style.${key} has no React Native counterpart and is dropped.`, p);
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
if (key?.startsWith('--'))
|
|
344
|
+
return false;
|
|
345
|
+
if (t.isExpression(p.value))
|
|
346
|
+
p.value = rnStyleValue(p.value);
|
|
347
|
+
return true;
|
|
348
|
+
});
|
|
349
|
+
if (e && e !== obj && a.value && t.isJSXExpressionContainer(a.value))
|
|
350
|
+
a.value = t.jsxExpressionContainer(obj);
|
|
351
|
+
}
|
|
352
|
+
/** Wraps text in a View or Pressable into <Text>, carrying the container's text classes. */
|
|
353
|
+
function wrapText(el, st) {
|
|
354
|
+
const name = jsxName(el.openingElement.name);
|
|
355
|
+
if (!TEXT_HOSTS.has(name))
|
|
356
|
+
return;
|
|
357
|
+
const className = attr(el, 'className');
|
|
358
|
+
let textClasses = null;
|
|
359
|
+
const classes = () => {
|
|
360
|
+
if (textClasses === null)
|
|
361
|
+
textClasses = className ? hoistTextClasses(className) : [];
|
|
362
|
+
return textClasses;
|
|
363
|
+
};
|
|
364
|
+
const textEl = (children) => {
|
|
365
|
+
st.rn.add('Text');
|
|
366
|
+
const cls = classes();
|
|
367
|
+
const attrs = cls.length ? [t.jsxAttribute(t.jsxIdentifier('className'), t.stringLiteral(cls.join(' ')))] : [];
|
|
368
|
+
return t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier('Text'), attrs), t.jsxClosingElement(t.jsxIdentifier('Text')), children);
|
|
369
|
+
};
|
|
370
|
+
const out = [];
|
|
371
|
+
let run = [];
|
|
372
|
+
const flush = () => {
|
|
373
|
+
if (run.length)
|
|
374
|
+
out.push(textEl(run));
|
|
375
|
+
run = [];
|
|
376
|
+
};
|
|
377
|
+
for (const child of el.children) {
|
|
378
|
+
if (t.isJSXText(child)) {
|
|
379
|
+
const cleaned = cleanJsxText(child.value);
|
|
380
|
+
if (cleaned)
|
|
381
|
+
run.push(t.jsxText(cleaned));
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (t.isJSXExpressionContainer(child) && t.isExpression(child.expression)) {
|
|
385
|
+
const kind = isTexty(child.expression, st.nodeProps);
|
|
386
|
+
if (kind === 'text') {
|
|
387
|
+
run.push(child);
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
if (kind === 'node') {
|
|
391
|
+
flush();
|
|
392
|
+
const value = child.expression;
|
|
393
|
+
const test = t.logicalExpression('||', t.binaryExpression('===', t.unaryExpression('typeof', t.cloneNode(value)), t.stringLiteral('string')), t.binaryExpression('===', t.unaryExpression('typeof', t.cloneNode(value)), t.stringLiteral('number')));
|
|
394
|
+
out.push(t.jsxExpressionContainer(t.conditionalExpression(test, textEl([t.jsxExpressionContainer(t.cloneNode(value))]), value)));
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
flush();
|
|
399
|
+
out.push(child);
|
|
400
|
+
}
|
|
401
|
+
flush();
|
|
402
|
+
el.children = out;
|
|
403
|
+
}
|
|
404
|
+
/** Emits one module for React Native: same file, same React logic, native elements. */
|
|
405
|
+
export function emitReactNative(mod, node, ctx) {
|
|
406
|
+
const ast = parseSource(node.code, node.file);
|
|
407
|
+
const program = ast.program;
|
|
408
|
+
program.directives = program.directives.filter((d) => d.value.value !== 'use client');
|
|
409
|
+
const diag = (code, severity, message, n) => {
|
|
410
|
+
const line = n?.loc?.start.line;
|
|
411
|
+
ctx.diagnostics.push({ code, severity, message, file: node.rel, target: 'react-native', ...(line ? { line } : {}) });
|
|
412
|
+
};
|
|
413
|
+
const st = { rn: new Set(), svg: new Set(), diag, nodeProps: new Set(), needsLinking: false };
|
|
414
|
+
for (const c of mod.components)
|
|
415
|
+
for (const p of c.props)
|
|
416
|
+
if (p.kind === 'node')
|
|
417
|
+
st.nodeProps.add(p.local);
|
|
418
|
+
// imports
|
|
419
|
+
const nextFonts = new Map();
|
|
420
|
+
const body = [];
|
|
421
|
+
for (const stmt of program.body) {
|
|
422
|
+
if (!t.isImportDeclaration(stmt)) {
|
|
423
|
+
body.push(stmt);
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
const source = stmt.source.value;
|
|
427
|
+
const resolved = resolveLocal(node.file, source, ctx.project);
|
|
428
|
+
const kind = resolved ? (source.endsWith('.css') ? 'css' : 'local') : classifyImport(source);
|
|
429
|
+
if (kind === 'css') {
|
|
430
|
+
diag('rn-css-file', 'warning', `${source}: a stylesheet has no React Native counterpart; its classes do nothing.`, stmt);
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
if (kind === 'next-font') {
|
|
434
|
+
for (const s of stmt.specifiers)
|
|
435
|
+
nextFonts.set(s.local.name, t.isImportSpecifier(s) && t.isIdentifier(s.imported) ? s.imported.name : '');
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (kind === 'next-web') {
|
|
439
|
+
diag(source === 'next/image' ? 'next-image' : 'next-link', 'warning', `${source} becomes React Native's ${source === 'next/image' ? 'Image' : 'Pressable + Linking'}.`, stmt);
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
if (kind === 'next-app') {
|
|
443
|
+
diag('next-app-api', 'error', `${source} is a Next.js app API, outside a UI component's scope.`, stmt);
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
if (kind === 'unsupported') {
|
|
447
|
+
diag('unsupported-dependency', 'error', `${unsupportedReason(source)} is app-level or React-only and is not converted.`, stmt);
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
if (kind === 'react-lib' && !source.startsWith('react-dom')) {
|
|
451
|
+
diag('react-library', 'error', `${source} is a web React library with no React Native counterpart.`, stmt);
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
if (source === 'react-dom' || source === 'react-dom/client') {
|
|
455
|
+
diag('rn-portal', 'error', 'react-dom (portals, flushSync) has no React Native counterpart.', stmt);
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (kind === 'icons')
|
|
459
|
+
stmt.source = t.stringLiteral('lucide-react-native');
|
|
460
|
+
if (kind === 'motion')
|
|
461
|
+
continue;
|
|
462
|
+
if (resolved && !source.startsWith('.')) {
|
|
463
|
+
// aliases (@/lib/utils) become relative paths, so the file works without the web project's tsconfig paths
|
|
464
|
+
const target = toPosix(relative(ctx.project.root, resolved));
|
|
465
|
+
stmt.source = t.stringLiteral(importPath(node.rel, target.replace(/\.(tsx|ts|jsx|js)$/, '.ts')));
|
|
466
|
+
}
|
|
467
|
+
body.push(stmt);
|
|
468
|
+
}
|
|
469
|
+
program.body = body;
|
|
470
|
+
// React's web attribute types as React Native props types
|
|
471
|
+
const rnTypes = new Set();
|
|
472
|
+
t.traverseFast(program, (n) => {
|
|
473
|
+
if (!t.isTSInterfaceDeclaration(n) || !n.extends)
|
|
474
|
+
return;
|
|
475
|
+
n.extends = n.extends.map((h) => {
|
|
476
|
+
const e = h.expression;
|
|
477
|
+
const base = t.isTSQualifiedName(e) ? e.right.name : t.isIdentifier(e) ? e.name : '';
|
|
478
|
+
if (!/HTMLAttributes$|^SVGProps$|^ComponentProps/.test(base))
|
|
479
|
+
return h;
|
|
480
|
+
const rnType = /^(Button|Anchor)HTMLAttributes$/.test(base) ? 'PressableProps' : /^(Input|Textarea)HTMLAttributes$/.test(base) ? 'TextInputProps' : base === 'ImgHTMLAttributes' ? 'ImageProps' : base === 'SVGProps' ? 'SvgProps' : 'ViewProps';
|
|
481
|
+
rnTypes.add(rnType);
|
|
482
|
+
return t.tsExpressionWithTypeArguments(t.identifier(rnType));
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
for (const rnType of rnTypes) {
|
|
486
|
+
const source = rnType === 'SvgProps' ? 'react-native-svg' : 'react-native';
|
|
487
|
+
const decl = t.importDeclaration([t.importSpecifier(t.identifier(rnType), t.identifier(rnType))], t.stringLiteral(source));
|
|
488
|
+
decl.importKind = 'type';
|
|
489
|
+
program.body.unshift(decl);
|
|
490
|
+
}
|
|
491
|
+
// next/font loaders: a font family name (it must be loaded with expo-font to show)
|
|
492
|
+
if (nextFonts.size) {
|
|
493
|
+
traverse(ast, {
|
|
494
|
+
CallExpression(p) {
|
|
495
|
+
if (!t.isIdentifier(p.node.callee) || !nextFonts.has(p.node.callee.name))
|
|
496
|
+
return;
|
|
497
|
+
const font = nextFontObject(nextFonts.get(p.node.callee.name) ?? '');
|
|
498
|
+
diag('next-font', 'warning', 'next/font becomes a fontFamily name; load the font with expo-font for it to show.', p.node);
|
|
499
|
+
p.replaceWith(t.objectExpression([t.objectProperty(t.identifier('className'), t.stringLiteral('')), t.objectProperty(t.identifier('style'), t.objectExpression([t.objectProperty(t.identifier('fontFamily'), t.stringLiteral(font.family.split(',')[0]?.replace(/'/g, '') ?? ''))]))]));
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
// Framer Motion elements become Reanimated ones (hooks go into the component body)
|
|
504
|
+
transformMotion(ast, mod, { rn: st.rn, diag });
|
|
505
|
+
// elements, attributes, then text wrapping (children first, so wrapping sees mapped children)
|
|
506
|
+
traverse(ast, {
|
|
507
|
+
JSXElement: {
|
|
508
|
+
exit(p) {
|
|
509
|
+
mapElement(p, st);
|
|
510
|
+
if (p.node.type === 'JSXElement')
|
|
511
|
+
wrapText(p.node, st);
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
});
|
|
515
|
+
// DOM APIs the native side does not have
|
|
516
|
+
const domUse = new Set();
|
|
517
|
+
t.traverseFast(program, (n) => {
|
|
518
|
+
if (t.isMemberExpression(n) && t.isIdentifier(n.object) && (n.object.name === 'document' || (n.object.name === 'window' && t.isIdentifier(n.property) && /^(addEventListener|matchMedia|getComputedStyle|innerWidth|innerHeight|scrollY|scrollX|location|devicePixelRatio)$/.test(n.property.name))))
|
|
519
|
+
domUse.add(n.object.name === 'document' ? 'document' : `window.${n.property.name}`);
|
|
520
|
+
if (t.isNewExpression(n) && t.isIdentifier(n.callee) && /^(IntersectionObserver|ResizeObserver|MutationObserver|AudioContext|Image)$/.test(n.callee.name))
|
|
521
|
+
domUse.add(n.callee.name);
|
|
522
|
+
if (t.isCallExpression(n) && t.isMemberExpression(n.callee) && t.isIdentifier(n.callee.property) && /^(getBoundingClientRect|getContext|querySelector|querySelectorAll|getElementById)$/.test(n.callee.property.name))
|
|
523
|
+
domUse.add(n.callee.property.name);
|
|
524
|
+
});
|
|
525
|
+
if (domUse.size) {
|
|
526
|
+
const blocking = [...domUse].some((d) => d === 'getContext');
|
|
527
|
+
diag('rn-dom-api', blocking ? 'error' : 'warning', `Browser APIs with no React Native counterpart: ${[...domUse].sort().join(', ')}.`, program);
|
|
528
|
+
}
|
|
529
|
+
// GLSL strings become SkSL for react-native-skia's RuntimeEffect
|
|
530
|
+
let shaders = 0;
|
|
531
|
+
traverse(ast, {
|
|
532
|
+
TemplateLiteral(p) {
|
|
533
|
+
if (p.node.expressions.length) {
|
|
534
|
+
const raw = p.node.quasis.map((q) => q.value.raw).join('');
|
|
535
|
+
if (looksLikeGlsl(raw))
|
|
536
|
+
diag('rn-glsl-dynamic', 'warning', 'A GLSL template literal with ${} parts is left as GLSL; translate it after interpolation with glslToSksl().', p.node);
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
const raw = p.node.quasis[0]?.value.cooked ?? '';
|
|
540
|
+
if (!looksLikeGlsl(raw))
|
|
541
|
+
return;
|
|
542
|
+
const result = glslToSksl(raw);
|
|
543
|
+
for (const d of result.diagnostics)
|
|
544
|
+
if (d.severity !== 'info')
|
|
545
|
+
diag(d.code, d.severity, d.message, p.node);
|
|
546
|
+
shaders++;
|
|
547
|
+
p.replaceWith(t.templateLiteral([t.templateElement({ raw: result.sksl.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${'), cooked: result.sksl }, true)], []));
|
|
548
|
+
t.addComment(p.node, 'leading', ' sksl (translated from GLSL by antheo-morph) ', false);
|
|
549
|
+
p.skip();
|
|
550
|
+
},
|
|
551
|
+
StringLiteral(p) {
|
|
552
|
+
if (!looksLikeGlsl(p.node.value) || !/\bvoid\s+main\b|gl_FragColor/.test(p.node.value))
|
|
553
|
+
return;
|
|
554
|
+
const result = glslToSksl(p.node.value);
|
|
555
|
+
for (const d of result.diagnostics)
|
|
556
|
+
if (d.severity !== 'info')
|
|
557
|
+
diag(d.code, d.severity, d.message, p.node);
|
|
558
|
+
shaders++;
|
|
559
|
+
p.replaceWith(t.stringLiteral(result.sksl));
|
|
560
|
+
p.skip();
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
if (shaders)
|
|
564
|
+
diag('rn-sksl', 'info', `${shaders} GLSL shader source(s) translated to SkSL; wire them up with Skia.RuntimeEffect.Make().`, program);
|
|
565
|
+
// imports for what the file now uses
|
|
566
|
+
const imports = [];
|
|
567
|
+
const rnNames = [...st.rn].filter((n) => !n.includes('.') && n !== 'AnimatedPressable').sort();
|
|
568
|
+
if (rnNames.length)
|
|
569
|
+
imports.push(t.importDeclaration(rnNames.map((n) => t.importSpecifier(t.identifier(n), t.identifier(n))), t.stringLiteral('react-native')));
|
|
570
|
+
if (st.svg.size) {
|
|
571
|
+
const named = [...st.svg].filter((n) => n !== 'Svg').sort();
|
|
572
|
+
const specs = [];
|
|
573
|
+
if (st.svg.has('Svg'))
|
|
574
|
+
specs.push(t.importDefaultSpecifier(t.identifier('Svg')));
|
|
575
|
+
for (const n of named) {
|
|
576
|
+
const imported = n === 'SvgText' ? 'Text' : n === 'SvgImage' ? 'Image' : n;
|
|
577
|
+
specs.push(t.importSpecifier(t.identifier(n), t.identifier(imported)));
|
|
578
|
+
}
|
|
579
|
+
imports.push(t.importDeclaration(specs, t.stringLiteral('react-native-svg')));
|
|
580
|
+
}
|
|
581
|
+
const lastImport = program.body.findIndex((s) => !t.isImportDeclaration(s));
|
|
582
|
+
program.body.splice(lastImport === -1 ? program.body.length : lastImport, 0, ...imports);
|
|
583
|
+
const outPath = node.rel.replace(/\.(ts|tsx|js|jsx)$/, /\.(tsx|jsx)$/.test(node.rel) ? '.tsx' : '.ts');
|
|
584
|
+
return [{ path: outPath, contents: printProgram(program.body), kind: mod.components.length ? 'component' : 'module' }];
|
|
585
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Diagnostic, FidelityReport } from '../../types.js';
|
|
2
|
+
import type { ModuleIR } from '../../ir/model.js';
|
|
3
|
+
import type { GraphNode } from '../../pipeline.js';
|
|
4
|
+
/** The static fidelity report of a component's React Native port, from its source and every file it imports. */
|
|
5
|
+
export declare function scoreFidelity(nodes: GraphNode[], _modules: Map<string, ModuleIR>, diagnostics: Diagnostic[]): FidelityReport;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web features a React Native port cannot keep, weighted by how much of the look or behaviour they carry. The score is
|
|
3
|
+
* 100 minus the weights of every feature the component uses (never below 0); it describes the port, not the code.
|
|
4
|
+
*/
|
|
5
|
+
const CHECKS = [
|
|
6
|
+
{ feature: 'canvas', weight: 45, detail: 'Imperative <canvas> drawing (2D or WebGL) does not run; it needs a Skia rewrite.', test: (c) => /getContext\(\s*['"](2d|webgl2?|experimental-webgl)/.test(c) },
|
|
7
|
+
{ feature: 'stylesheet', weight: 25, detail: 'Imported CSS files (custom classes, keyframes, selectors) have no effect.', test: (_c, css) => css.trim().length > 0 },
|
|
8
|
+
{ feature: 'css-gradients', weight: 10, detail: 'CSS gradients (bg-[linear-gradient], bg-gradient-to-*, backgroundImage) need expo-linear-gradient.', test: (c) => /linear-gradient|radial-gradient|conic-gradient|bg-gradient-to-|from-\w+-\d+\s+to-/.test(c) },
|
|
9
|
+
{ feature: 'hover', weight: 10, detail: 'Hover styles and handlers only respond to a pointer (web, iPad, desktop).', test: (c) => /\bhover:|onMouseEnter|onPointerEnter|whileHover/.test(c) },
|
|
10
|
+
{ feature: 'keyframe-animations', weight: 10, detail: 'CSS keyframe animations (animate-[...], @keyframes) do not run.', test: (c, css) => /animate-\[|@keyframes/.test(c + css) },
|
|
11
|
+
{ feature: 'box-shadow', weight: 6, detail: 'Inset and layered box shadows have no React Native counterpart.', test: (c) => /shadow-\[[^\]]*inset|boxShadow|--tw-shadow/.test(c) },
|
|
12
|
+
{ feature: 'blur-filters', weight: 8, detail: 'CSS filters and backdrop blur (blur-*, backdrop-blur, filter) do not apply.', test: (c) => /backdrop-blur|\bblur-|filter:|brightness-|drop-shadow-|saturate-|hue-rotate/.test(c) },
|
|
13
|
+
{ feature: 'transitions', weight: 5, detail: 'CSS transitions (transition-*, [transition:...]) do not animate.', test: (c) => /\btransition-|\[transition:|transition:/.test(c) },
|
|
14
|
+
{ feature: 'pseudo-elements', weight: 6, detail: 'before:/after: pseudo-elements do not render.', test: (c) => /\b(before|after):/.test(c) },
|
|
15
|
+
{ feature: 'group-peer', weight: 5, detail: 'group-*/peer-* variants (styling from a parent or sibling state) do not apply.', test: (c) => /\b(group|peer)-(hover|focus|active|checked|disabled|data)/.test(c) },
|
|
16
|
+
{ feature: 'data-variants', weight: 5, detail: 'data-[...] and aria-[...] variants and data attributes do not exist.', test: (c) => /\b(data|aria)-\[|data-\w+=\{/.test(c) },
|
|
17
|
+
{ feature: 'clip-blend-mask', weight: 6, detail: 'clip-path, masks and blend modes do not apply.', test: (c) => /clip-path|clipPath:|mask-|maskImage|mix-blend|mixBlendMode/.test(c) },
|
|
18
|
+
{ feature: 'dom-apis', weight: 10, detail: 'Browser APIs (document, window listeners, IntersectionObserver, ResizeObserver, getBoundingClientRect) do not exist.', test: (c) => /\bdocument\.|window\.(addEventListener|matchMedia|innerWidth)|IntersectionObserver|ResizeObserver|getBoundingClientRect|getComputedStyle/.test(c) },
|
|
19
|
+
{ feature: 'keyboard', weight: 3, detail: 'Keyboard handlers on non-input elements do not fire.', test: (c) => /onKey(Down|Up|Press)/.test(c) },
|
|
20
|
+
{ feature: 'pointer-tracking', weight: 6, detail: 'Pointer-move tracking needs react-native-gesture-handler.', test: (c) => /onPointerMove|onMouseMove|pointermove|mousemove/.test(c) },
|
|
21
|
+
{ feature: 'svg-filters', weight: 6, detail: 'SVG filter primitives (feGaussianBlur, ...) are not supported by react-native-svg.', test: (c) => /<fe[A-Z]/.test(c) },
|
|
22
|
+
{ feature: 'web-audio', weight: 6, detail: 'Web Audio (AudioContext) does not exist; sounds need expo-av.', test: (c) => /AudioContext|webkitAudioContext/.test(c) },
|
|
23
|
+
{ feature: 'web-fonts', weight: 2, detail: 'Web fonts (next/font, @font-face) must be loaded with expo-font.', test: (c, css) => /next\/font|@font-face/.test(c + css) },
|
|
24
|
+
];
|
|
25
|
+
const KEPT = [
|
|
26
|
+
{ label: 'state, effects and handlers (same React code)', test: () => true },
|
|
27
|
+
{ label: 'Tailwind layout and colour classes (NativeWind)', test: (c) => /className=/.test(c) },
|
|
28
|
+
{ label: 'SVG shapes (react-native-svg)', test: (c) => /<svg[\s>]/.test(c) },
|
|
29
|
+
{ label: 'press handling (Pressable)', test: (c) => /onClick|onPointerDown|<button/.test(c) },
|
|
30
|
+
{ label: 'Framer Motion values, springs and press states (Reanimated)', test: (c) => /from ['"](framer-motion|motion\/react)/.test(c) },
|
|
31
|
+
{ label: 'GLSL shader sources (translated to SkSL)', test: (c) => /gl_FragColor|void\s+main\s*\(/.test(c) },
|
|
32
|
+
];
|
|
33
|
+
/** The static fidelity report of a component's React Native port, from its source and every file it imports. */
|
|
34
|
+
export function scoreFidelity(nodes, _modules, diagnostics) {
|
|
35
|
+
const code = nodes.filter((n) => !n.css).map((n) => n.code).join('\n');
|
|
36
|
+
const css = nodes.filter((n) => n.css).map((n) => n.code).join('\n');
|
|
37
|
+
const lost = CHECKS.filter((c) => c.test(code, css)).map(({ feature, weight, detail }) => ({ feature, weight, detail }));
|
|
38
|
+
if (diagnostics.some((d) => d.code === 'rn-motion' && d.severity !== 'info')) {
|
|
39
|
+
lost.push({ feature: 'motion-partial', weight: 5, detail: 'Some Framer Motion features (variants, layout, exit, drag) are not converted.' });
|
|
40
|
+
}
|
|
41
|
+
const score = Math.max(0, 100 - lost.reduce((sum, l) => sum + l.weight, 0));
|
|
42
|
+
return { score, lost, kept: KEPT.filter((k) => k.test(code)).map((k) => k.label) };
|
|
43
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import type { Diagnostic } from '../../types.js';
|
|
3
|
+
import type { ModuleIR } from '../../ir/model.js';
|
|
4
|
+
interface MotionState {
|
|
5
|
+
rn: Set<string>;
|
|
6
|
+
diag: (code: string, severity: Diagnostic['severity'], message: string, node?: t.Node | null) => void;
|
|
7
|
+
}
|
|
8
|
+
/** Motion elements → Reanimated: shared values, an animated style, effects for `animate`, press and hover handlers. */
|
|
9
|
+
export declare function transformMotion(ast: t.File, mod: ModuleIR, st: MotionState): void;
|
|
10
|
+
export {};
|