@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,7 @@
|
|
|
1
|
+
/** An expected failure with a stable code, safe to show to users (it never carries secrets). */
|
|
2
|
+
export declare class MorphError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
constructor(code: string, message: string);
|
|
5
|
+
}
|
|
6
|
+
/** The message of anything thrown, without its stack. */
|
|
7
|
+
export declare function errorMessage(error: unknown): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** An expected failure with a stable code, safe to show to users (it never carries secrets). */
|
|
2
|
+
export class MorphError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(code, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'MorphError';
|
|
7
|
+
this.code = code;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** The message of anything thrown, without its stack. */
|
|
11
|
+
export function errorMessage(error) {
|
|
12
|
+
if (error instanceof Error)
|
|
13
|
+
return error.message;
|
|
14
|
+
return String(error);
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The largest source file morph reads. */
|
|
2
|
+
export declare const MAX_INPUT_BYTES: number;
|
|
3
|
+
/** True when `child` is `root` itself or inside it, after both are resolved through symlinks. */
|
|
4
|
+
export declare function isInside(root: string, child: string): boolean;
|
|
5
|
+
/** Resolves `p` against `root` and refuses anything that lands outside it (`..`, absolute paths, symlinks out). */
|
|
6
|
+
export declare function resolveInside(root: string, p: string): string;
|
|
7
|
+
/** Reads a UTF-8 source file inside `root`, refusing paths outside it and files over 512 KB. */
|
|
8
|
+
export declare function readSourceFile(root: string, p: string): string;
|
|
9
|
+
/** Checks an in-memory source against the size limit. */
|
|
10
|
+
export declare function assertSourceSize(code: string, label: string): void;
|
|
11
|
+
/** Writes `contents` to `rel` under `outRoot`, creating folders, refusing paths that escape it. */
|
|
12
|
+
export declare function writeInside(outRoot: string, rel: string, contents: string | Buffer): string;
|
|
13
|
+
/** Forward-slash form of a path, for output paths and reports. */
|
|
14
|
+
export declare function toPosix(p: string): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { MorphError } from './errors.js';
|
|
4
|
+
/** The largest source file morph reads. */
|
|
5
|
+
export const MAX_INPUT_BYTES = 512 * 1024;
|
|
6
|
+
/** The real path of `p`, or of its nearest existing parent with the missing tail appended. */
|
|
7
|
+
function realish(p) {
|
|
8
|
+
const missing = [];
|
|
9
|
+
let current = p;
|
|
10
|
+
while (!existsSync(current)) {
|
|
11
|
+
const parent = dirname(current);
|
|
12
|
+
if (parent === current)
|
|
13
|
+
break;
|
|
14
|
+
missing.unshift(current.slice(parent.length).replace(/^[\\/]+/, ''));
|
|
15
|
+
current = parent;
|
|
16
|
+
}
|
|
17
|
+
const base = existsSync(current) ? realpathSync(current) : current;
|
|
18
|
+
return missing.length ? resolve(base, ...missing) : base;
|
|
19
|
+
}
|
|
20
|
+
/** True when `child` is `root` itself or inside it, after both are resolved through symlinks. */
|
|
21
|
+
export function isInside(root, child) {
|
|
22
|
+
const realRoot = realish(resolve(root));
|
|
23
|
+
const realChild = realish(resolve(root, child));
|
|
24
|
+
const rel = relative(realRoot, realChild);
|
|
25
|
+
return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel) && !rel.split(sep).includes('..'));
|
|
26
|
+
}
|
|
27
|
+
/** Resolves `p` against `root` and refuses anything that lands outside it (`..`, absolute paths, symlinks out). */
|
|
28
|
+
export function resolveInside(root, p) {
|
|
29
|
+
const full = resolve(root, p);
|
|
30
|
+
if (!isInside(root, full)) {
|
|
31
|
+
throw new MorphError('path-traversal', `Refused a path outside the project root: ${p}`);
|
|
32
|
+
}
|
|
33
|
+
return full;
|
|
34
|
+
}
|
|
35
|
+
/** Reads a UTF-8 source file inside `root`, refusing paths outside it and files over 512 KB. */
|
|
36
|
+
export function readSourceFile(root, p) {
|
|
37
|
+
const full = resolveInside(root, p);
|
|
38
|
+
if (!existsSync(full))
|
|
39
|
+
throw new MorphError('not-found', `File not found: ${p}`);
|
|
40
|
+
const size = statSync(full).size;
|
|
41
|
+
if (size > MAX_INPUT_BYTES) {
|
|
42
|
+
throw new MorphError('input-too-large', `${p} is ${Math.round(size / 1024)} KB; the limit is ${MAX_INPUT_BYTES / 1024} KB`);
|
|
43
|
+
}
|
|
44
|
+
return readFileSync(full, 'utf8');
|
|
45
|
+
}
|
|
46
|
+
/** Checks an in-memory source against the size limit. */
|
|
47
|
+
export function assertSourceSize(code, label) {
|
|
48
|
+
const bytes = Buffer.byteLength(code, 'utf8');
|
|
49
|
+
if (bytes > MAX_INPUT_BYTES) {
|
|
50
|
+
throw new MorphError('input-too-large', `${label} is ${Math.round(bytes / 1024)} KB; the limit is ${MAX_INPUT_BYTES / 1024} KB`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Writes `contents` to `rel` under `outRoot`, creating folders, refusing paths that escape it. */
|
|
54
|
+
export function writeInside(outRoot, rel, contents) {
|
|
55
|
+
mkdirSync(outRoot, { recursive: true });
|
|
56
|
+
const full = resolveInside(outRoot, rel);
|
|
57
|
+
mkdirSync(dirname(full), { recursive: true });
|
|
58
|
+
writeFileSync(full, contents);
|
|
59
|
+
return full;
|
|
60
|
+
}
|
|
61
|
+
/** Forward-slash form of a path, for output paths and reports. */
|
|
62
|
+
export function toPosix(p) {
|
|
63
|
+
return p.split(sep).join('/').replace(/\\/g, '/');
|
|
64
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Diagnostic, EmittedFile, Target, WebTarget } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks a React Native file: it must parse, keep no web tags (<div>, <span>, <button>...), and hold no bare text
|
|
4
|
+
* (string or text node) directly inside a View or Pressable.
|
|
5
|
+
*/
|
|
6
|
+
export declare function checkReactNative(code: string, path: string): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Checks Angular output with the real Angular compiler: strict TypeScript and strict template type-checking over all
|
|
9
|
+
* emitted files together. One diagnostic per failing file. With `projectRoot` (the React project the output came from),
|
|
10
|
+
* the output's package imports resolve from that project, as they will once the files are copied into it; JSON data
|
|
11
|
+
* the output imports is compiled with it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateAngular(files: EmittedFile[], projectRoot?: string): Promise<Diagnostic[]>;
|
|
14
|
+
/** Whether the target's compiler takes a stylesheet as a component's own `<style>` (else it stays a file). */
|
|
15
|
+
export declare function styleInlinable(target: WebTarget, code: string): boolean;
|
|
16
|
+
export declare function validateFiles(files: EmittedFile[], target: Target): Diagnostic[];
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
import { parse as parseSfc, compileScript, compileStyle, compileTemplate } from '@vue/compiler-sfc';
|
|
3
|
+
import { compile as compileSvelte, compileModule as compileSvelteModule } from 'svelte/compiler';
|
|
4
|
+
import { parse as babelParse } from '@babel/parser';
|
|
5
|
+
import * as t from '@babel/types';
|
|
6
|
+
import { errorMessage } from './utils/errors.js';
|
|
7
|
+
import { transformTsForSvelte } from './targets/svelte/strip.js';
|
|
8
|
+
import { componentStyle } from './targets/shared/markup.js';
|
|
9
|
+
import { compileAngular } from './targets/angular/ngc.js';
|
|
10
|
+
const VIRTUAL_ROOT = '/morph-out/';
|
|
11
|
+
/** React Native: tags that are web-only and must not survive. */
|
|
12
|
+
const WEB_TAGS = new Set(['div', 'span', 'button', 'p', 'a', 'img', 'input', 'section', 'ul', 'li', 'label', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'svg', 'path', 'canvas', 'form', 'textarea', 'select', 'nav', 'header', 'footer', 'main', 'article', 'aside', 'strong', 'em', 'b', 'i', 'small', 'code', 'pre']);
|
|
13
|
+
const TEXT_HOSTS = new Set(['View', 'Pressable', 'Animated.View', 'AnimatedPressable', 'TouchableOpacity', 'ScrollView', 'SafeAreaView']);
|
|
14
|
+
function fail(file, target, message) {
|
|
15
|
+
return { code: 'validation-failed', severity: 'error', message: `${file.path}: ${message}`, file: file.path, target };
|
|
16
|
+
}
|
|
17
|
+
/** Checks one emitted Vue SFC with the real @vue/compiler-sfc (script, types through the other emitted files, template). */
|
|
18
|
+
function validateVue(file, all) {
|
|
19
|
+
const { descriptor, errors } = parseSfc(file.contents, { filename: VIRTUAL_ROOT + file.path });
|
|
20
|
+
if (errors.length)
|
|
21
|
+
return errors.map((e) => errorMessage(e)).join('; ');
|
|
22
|
+
const fs = {
|
|
23
|
+
fileExists: (f) => all.has(normalize(f)),
|
|
24
|
+
readFile: (f) => all.get(normalize(f)),
|
|
25
|
+
};
|
|
26
|
+
const id = 'v' + Math.abs(hash(file.path)).toString(16);
|
|
27
|
+
// a component that needs no script is a file with only a <template>: compileScript refuses a file without a script
|
|
28
|
+
if (descriptor.script || descriptor.scriptSetup) {
|
|
29
|
+
try {
|
|
30
|
+
const script = compileScript(descriptor, { id, inlineTemplate: true, fs });
|
|
31
|
+
if (!script.content)
|
|
32
|
+
return 'empty script output';
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return errorMessage(error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (!descriptor.template) {
|
|
39
|
+
return 'the file has neither a script nor a template';
|
|
40
|
+
}
|
|
41
|
+
if (descriptor.template) {
|
|
42
|
+
const result = compileTemplate({ source: descriptor.template.content, filename: file.path, id, compilerOptions: { isTS: true } });
|
|
43
|
+
if (result.errors.length)
|
|
44
|
+
return result.errors.map((e) => (typeof e === 'string' ? e : e.message)).join('; ');
|
|
45
|
+
}
|
|
46
|
+
for (const style of descriptor.styles) {
|
|
47
|
+
const result = compileStyle({ source: style.content, filename: file.path, id: `data-v-${id}`, scoped: !!style.scoped });
|
|
48
|
+
if (result.errors.length)
|
|
49
|
+
return result.errors.map((e) => errorMessage(e)).join('; ');
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
function normalize(f) {
|
|
54
|
+
const p = f.replace(/\\/g, '/');
|
|
55
|
+
const i = p.indexOf(VIRTUAL_ROOT);
|
|
56
|
+
return i >= 0 ? p.slice(i + VIRTUAL_ROOT.length) : posix.normalize(p).replace(/^\.?\//, '');
|
|
57
|
+
}
|
|
58
|
+
function hash(s) {
|
|
59
|
+
let h = 0;
|
|
60
|
+
for (let i = 0; i < s.length; i++)
|
|
61
|
+
h = (h * 31 + s.charCodeAt(i)) | 0;
|
|
62
|
+
return h;
|
|
63
|
+
}
|
|
64
|
+
/** Checks one Svelte component (runes mode) or rune module with the real svelte/compiler. */
|
|
65
|
+
function validateSvelte(file) {
|
|
66
|
+
try {
|
|
67
|
+
if (file.path.endsWith('.svelte')) {
|
|
68
|
+
compileSvelte(file.contents, { filename: file.path, runes: true, generate: 'client' });
|
|
69
|
+
}
|
|
70
|
+
else if (file.path.endsWith('.svelte.ts')) {
|
|
71
|
+
compileSvelteModule(transformTsForSvelte(file.contents, file.path), { filename: file.path.replace(/\.ts$/, '.js'), generate: 'client' });
|
|
72
|
+
}
|
|
73
|
+
else
|
|
74
|
+
return parseTs(file);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
return errorMessage(error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function parseTs(file) {
|
|
82
|
+
try {
|
|
83
|
+
babelParse(file.contents, { sourceType: 'module', plugins: file.path.endsWith('.tsx') ? ['typescript', 'jsx'] : ['typescript'] });
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return errorMessage(error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function jsxName(n) {
|
|
91
|
+
if (t.isJSXIdentifier(n))
|
|
92
|
+
return n.name;
|
|
93
|
+
if (t.isJSXNamespacedName(n))
|
|
94
|
+
return `${n.namespace.name}:${n.name.name}`;
|
|
95
|
+
return `${jsxName(n.object)}.${n.property.name}`;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Checks a React Native file: it must parse, keep no web tags (<div>, <span>, <button>...), and hold no bare text
|
|
99
|
+
* (string or text node) directly inside a View or Pressable.
|
|
100
|
+
*/
|
|
101
|
+
export function checkReactNative(code, path) {
|
|
102
|
+
const problems = [];
|
|
103
|
+
let ast;
|
|
104
|
+
try {
|
|
105
|
+
ast = babelParse(code, { sourceType: 'module', plugins: ['typescript', 'jsx'] });
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
return [errorMessage(error)];
|
|
109
|
+
}
|
|
110
|
+
t.traverseFast(ast, (node) => {
|
|
111
|
+
if (!t.isJSXElement(node))
|
|
112
|
+
return;
|
|
113
|
+
const name = jsxName(node.openingElement.name);
|
|
114
|
+
if (WEB_TAGS.has(name))
|
|
115
|
+
problems.push(`web tag <${name}> left in ${path}`);
|
|
116
|
+
if (!TEXT_HOSTS.has(name))
|
|
117
|
+
return;
|
|
118
|
+
for (const child of node.children) {
|
|
119
|
+
if (t.isJSXText(child) && child.value.trim())
|
|
120
|
+
problems.push(`bare text "${child.value.trim().slice(0, 30)}" inside <${name}>`);
|
|
121
|
+
if (t.isJSXExpressionContainer(child) && (t.isStringLiteral(child.expression) || t.isTemplateLiteral(child.expression) || t.isNumericLiteral(child.expression))) {
|
|
122
|
+
problems.push(`bare text expression inside <${name}>`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return problems;
|
|
127
|
+
}
|
|
128
|
+
const angularCache = new Map();
|
|
129
|
+
/**
|
|
130
|
+
* Checks Angular output with the real Angular compiler: strict TypeScript and strict template type-checking over all
|
|
131
|
+
* emitted files together. One diagnostic per failing file. With `projectRoot` (the React project the output came from),
|
|
132
|
+
* the output's package imports resolve from that project, as they will once the files are copied into it; JSON data
|
|
133
|
+
* the output imports is compiled with it.
|
|
134
|
+
*/
|
|
135
|
+
export async function validateAngular(files, projectRoot) {
|
|
136
|
+
const code = files.filter((f) => f.path.endsWith('.ts') || f.path.endsWith('.css') || f.path.endsWith('.json'));
|
|
137
|
+
if (!code.some((f) => f.path.endsWith('.ts')))
|
|
138
|
+
return [];
|
|
139
|
+
const key = `${projectRoot ?? ''}\u0000${code.map((f) => `${f.path}\u0000${f.contents}`).join('\u0000\u0000')}`;
|
|
140
|
+
let problems = angularCache.get(key);
|
|
141
|
+
if (!problems) {
|
|
142
|
+
try {
|
|
143
|
+
problems = (await compileAngular(code, false, projectRoot)).problems;
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
problems = [{ path: '(project)', message: errorMessage(error) }];
|
|
147
|
+
}
|
|
148
|
+
if (angularCache.size > 2000)
|
|
149
|
+
angularCache.clear();
|
|
150
|
+
angularCache.set(key, problems);
|
|
151
|
+
}
|
|
152
|
+
const byFile = new Map();
|
|
153
|
+
for (const p of problems)
|
|
154
|
+
if (!byFile.has(p.path))
|
|
155
|
+
byFile.set(p.path, p.message);
|
|
156
|
+
return [...byFile].map(([path, message]) => ({ code: 'validation-failed', severity: 'error', message: `${path}: ${message}`, file: path, target: 'angular' }));
|
|
157
|
+
}
|
|
158
|
+
/** Whether the target's compiler takes a stylesheet as a component's own `<style>` (else it stays a file). */
|
|
159
|
+
export function styleInlinable(target, code) {
|
|
160
|
+
try {
|
|
161
|
+
if (target === 'vue')
|
|
162
|
+
return compileStyle({ source: code, filename: 'style.css', id: 'data-v-morph', scoped: false }).errors.length === 0;
|
|
163
|
+
compileSvelte(componentStyle('svelte', [{ file: 'style.css', code }]), { filename: 'Style.svelte', runes: true, generate: 'client' });
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** Runs the target's real compiler or parser over every emitted file; returns one diagnostic per failing file. */
|
|
171
|
+
const validationCache = new Map();
|
|
172
|
+
export function validateFiles(files, target) {
|
|
173
|
+
const all = new Map(files.map((f) => [f.path, f.contents]));
|
|
174
|
+
const out = [];
|
|
175
|
+
for (const file of files) {
|
|
176
|
+
if (file.kind === 'style' || file.kind === 'report')
|
|
177
|
+
continue;
|
|
178
|
+
// the same shared module is checked again for every entry: a .vue file's result also depends on the files it
|
|
179
|
+
// imports types from, so components are keyed with the whole set, modules by their own text
|
|
180
|
+
const key = `${target}\0${file.path}\0${file.contents}${target === 'vue' && file.path.endsWith('.vue') ? `\0${files.map((f) => f.path + f.contents.length).join('|')}` : ''}`;
|
|
181
|
+
if (validationCache.has(key)) {
|
|
182
|
+
const cached = validationCache.get(key) ?? null;
|
|
183
|
+
if (cached)
|
|
184
|
+
out.push(fail(file, target, cached));
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
let problem = null;
|
|
188
|
+
if (target === 'vue')
|
|
189
|
+
problem = file.path.endsWith('.vue') ? validateVue(file, all) : parseTs(file);
|
|
190
|
+
else if (target === 'svelte')
|
|
191
|
+
problem = validateSvelte(file);
|
|
192
|
+
else {
|
|
193
|
+
const problems = checkReactNative(file.contents, file.path);
|
|
194
|
+
problem = problems.length ? problems.join('; ') : null;
|
|
195
|
+
}
|
|
196
|
+
const first = problem ? (problem.split('\n')[0] ?? problem) : null;
|
|
197
|
+
if (validationCache.size > 20000)
|
|
198
|
+
validationCache.clear();
|
|
199
|
+
validationCache.set(key, first);
|
|
200
|
+
if (first)
|
|
201
|
+
out.push(fail(file, target, first));
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Page } from 'playwright-core';
|
|
2
|
+
import type { StepLocator, VerifyStep } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* `verify --auto-steps` (v0.2 M1): the script is discovered on the React page alone, then handed to the ordinary steps
|
|
5
|
+
* runner unchanged, so a discovered step is compared exactly as a hand-written one (whole shot, changed region, DOM
|
|
6
|
+
* facts, in every target). Discovery only chooses which steps to run; it never judges a target.
|
|
7
|
+
*
|
|
8
|
+
* Deterministic: the React page runs on the sandbox's virtual clock with seeded random numbers, candidates are taken in
|
|
9
|
+
* a fixed order (controls revealed by the last kept step first, at most REVEALED_PER_STEP of them, then every control in
|
|
10
|
+
* document order of `document.body`, each control's actions in a fixed order), and nothing reads real time, so the same
|
|
11
|
+
* component gives the same steps on every run.
|
|
12
|
+
*/
|
|
13
|
+
/** Steps discovered when `autoSteps` gives no `maxSteps`. */
|
|
14
|
+
export declare const DEFAULT_AUTO_STEPS = 12;
|
|
15
|
+
/** The roles discovery acts on, and the tags that carry them natively. */
|
|
16
|
+
export declare const AUTO_ROLES: readonly ["switch", "checkbox", "radio", "tab", "button", "combobox", "textbox", "searchbox", "spinbutton", "slider", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "summary"];
|
|
17
|
+
export type AutoRole = (typeof AUTO_ROLES)[number];
|
|
18
|
+
/** The attributes a discovered selector may name: what the component's own markup says, never a generated one. */
|
|
19
|
+
export declare const SELECTOR_ATTRIBUTES: readonly ["type", "role", "name", "placeholder", "aria-label"];
|
|
20
|
+
/** One visible, enabled control as the scan of the React page sees it. */
|
|
21
|
+
export interface ScannedControl {
|
|
22
|
+
/** its place in the scan (the page keeps the element under this index, to confirm a locator names it) */
|
|
23
|
+
index: number;
|
|
24
|
+
role: AutoRole;
|
|
25
|
+
/** the accessible name as the scan computes it (a locator is confirmed by Playwright, never trusted) */
|
|
26
|
+
name: string;
|
|
27
|
+
/** its rendered text, whitespace collapsed */
|
|
28
|
+
text: string;
|
|
29
|
+
tag: string;
|
|
30
|
+
/** the semantic attributes it carries (SELECTOR_ATTRIBUTES only) */
|
|
31
|
+
attrs: Partial<Record<(typeof SELECTOR_ATTRIBUTES)[number], string>>;
|
|
32
|
+
/** 1-based place among its parent's children of the same tag */
|
|
33
|
+
nth: number;
|
|
34
|
+
/** the parent's tag and semantic attributes, for a selector that needs one more level */
|
|
35
|
+
parent: {
|
|
36
|
+
tag: string;
|
|
37
|
+
attrs: Partial<Record<(typeof SELECTOR_ATTRIBUTES)[number], string>>;
|
|
38
|
+
nth: number;
|
|
39
|
+
} | null;
|
|
40
|
+
/** an <input>'s type ('' otherwise) */
|
|
41
|
+
inputType: string;
|
|
42
|
+
/** a <select> element (keyboard changes its value; a click opens a native popup no screenshot shows) */
|
|
43
|
+
nativeSelect: boolean;
|
|
44
|
+
/** a stable key for the control across scans: its role and its tag path with :nth-of-type (not its name, which a step may change: "Show advanced" becomes "Hide advanced") */
|
|
45
|
+
key: string;
|
|
46
|
+
}
|
|
47
|
+
/** What a candidate does to a control. */
|
|
48
|
+
export type AutoAction = 'click' | 'space' | 'arrow-right' | 'arrow-down' | 'type';
|
|
49
|
+
/** The actions tried on a control, in this order. */
|
|
50
|
+
export declare function actionsFor(c: Pick<ScannedControl, 'role' | 'nativeSelect'>): AutoAction[];
|
|
51
|
+
/** The text typed into a field: a value its type accepts, the same on every run. */
|
|
52
|
+
export declare function textFor(c: Pick<ScannedControl, 'role' | 'inputType'>): string;
|
|
53
|
+
/** A value that a framework or a hook generated (React's useId, Vue's data-v, Svelte's hash, Angular's _ng), never written by hand. */
|
|
54
|
+
export declare function looksGenerated(value: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether a selector names only what the component's own markup says: tags, `:nth-of-type`, `>` and the attributes in
|
|
57
|
+
* SELECTOR_ATTRIBUTES, with no class, no id, no framework attribute and no generated value.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isNeutralSelector(selector: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The locators to try for a control, most readable first: its role and name, its role alone (an unnamed control), its
|
|
62
|
+
* exact text, then a selector of tag and semantic attributes, with `:nth-of-type`, then under its parent. Each is
|
|
63
|
+
* confirmed on the React page before it is used; every selector here passes isNeutralSelector.
|
|
64
|
+
*/
|
|
65
|
+
export declare function proposeLocators(c: ScannedControl): StepLocator[];
|
|
66
|
+
/** The step a candidate is: its action on its target, waiting `wait` virtual ms after it. */
|
|
67
|
+
export declare function stepFor(action: AutoAction, target: StepLocator, c: Pick<ScannedControl, 'role' | 'inputType'>, wait: number): VerifyStep;
|
|
68
|
+
/** `autoSteps` as a number of steps: 12 by default, a whole number from 1 to MAX_STEPS when given. */
|
|
69
|
+
export declare function resolveMaxSteps(auto: boolean | {
|
|
70
|
+
maxSteps?: number;
|
|
71
|
+
} | undefined): number;
|
|
72
|
+
/** Gives every step a name no earlier step has (`click tab "One"`, then `click tab "One" #2`). */
|
|
73
|
+
export declare function uniqueName(name: string, used: Set<string>): string;
|
|
74
|
+
declare global {
|
|
75
|
+
interface Window {
|
|
76
|
+
/** auto-steps: the elements of the last scan, by index (the discovery page only) */
|
|
77
|
+
__morphAutoScan?: Element[];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** A discovery page: the React component rendered and settled on the sandbox's clock, and its page errors so far. */
|
|
81
|
+
export interface DiscoveryPage {
|
|
82
|
+
page: Page;
|
|
83
|
+
errors: string[];
|
|
84
|
+
}
|
|
85
|
+
export interface DiscoverOptions {
|
|
86
|
+
/** the most steps to keep */
|
|
87
|
+
maxSteps: number;
|
|
88
|
+
/** virtual ms stepped after each action before its first shot (verify's stepMs) */
|
|
89
|
+
stepMs: number;
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
alive: () => void;
|
|
93
|
+
}
|
|
94
|
+
export interface Discovery {
|
|
95
|
+
steps: VerifyStep[];
|
|
96
|
+
/** candidates carried out (kept or not) */
|
|
97
|
+
attempts: number;
|
|
98
|
+
/** the page kept moving with nothing done: change was judged on the DOM facts alone */
|
|
99
|
+
animated: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Discovers a script on a React page that has rendered and settled: tries each candidate on the live page, keeps it
|
|
103
|
+
* only when it ran cleanly (no step error, no new page error) and changed the render (pixels) or the DOM facts, and
|
|
104
|
+
* gives it the virtual wait after which React's render stopped moving. Kept steps accumulate on the same page, exactly
|
|
105
|
+
* as the steps runner later replays them from a fresh one.
|
|
106
|
+
*/
|
|
107
|
+
export declare function discoverSteps(dp: DiscoveryPage, options: DiscoverOptions): Promise<Discovery>;
|