@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,471 @@
|
|
|
1
|
+
import { MorphError } from '../utils/errors.js';
|
|
2
|
+
import { compare } from './diff.js';
|
|
3
|
+
import { MAX_STEPS, MAX_STEP_WAIT, StepError, collectFacts, describeLocator, diffFacts, locate, performStep } from './steps.js';
|
|
4
|
+
/**
|
|
5
|
+
* `verify --auto-steps` (v0.2 M1): the script is discovered on the React page alone, then handed to the ordinary steps
|
|
6
|
+
* runner unchanged, so a discovered step is compared exactly as a hand-written one (whole shot, changed region, DOM
|
|
7
|
+
* facts, in every target). Discovery only chooses which steps to run; it never judges a target.
|
|
8
|
+
*
|
|
9
|
+
* Deterministic: the React page runs on the sandbox's virtual clock with seeded random numbers, candidates are taken in
|
|
10
|
+
* a fixed order (controls revealed by the last kept step first, at most REVEALED_PER_STEP of them, then every control in
|
|
11
|
+
* document order of `document.body`, each control's actions in a fixed order), and nothing reads real time, so the same
|
|
12
|
+
* component gives the same steps on every run.
|
|
13
|
+
*/
|
|
14
|
+
/** Steps discovered when `autoSteps` gives no `maxSteps`. */
|
|
15
|
+
export const DEFAULT_AUTO_STEPS = 12;
|
|
16
|
+
/** Newly revealed controls (a menu's items, a dialog's buttons) explored right after the step that revealed them. */
|
|
17
|
+
const REVEALED_PER_STEP = 2;
|
|
18
|
+
/** Candidates actually carried out, per kept step allowed: bounds the time discovery takes. */
|
|
19
|
+
const ATTEMPTS_PER_STEP = 3;
|
|
20
|
+
/** After an action, the page is shot every SETTLE_PROBE_MS once `stepMs` has passed until two shots agree, up to SETTLE_CAP_MS. */
|
|
21
|
+
const SETTLE_PROBE_MS = 100;
|
|
22
|
+
const SETTLE_CAP_MS = 2000;
|
|
23
|
+
/** A role and name longer than this is not used as a locator (the name would be a paragraph). */
|
|
24
|
+
const MAX_NAME = 80;
|
|
25
|
+
/** The roles discovery acts on, and the tags that carry them natively. */
|
|
26
|
+
export const AUTO_ROLES = ['switch', 'checkbox', 'radio', 'tab', 'button', 'combobox', 'textbox', 'searchbox', 'spinbutton', 'slider', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'option', 'summary'];
|
|
27
|
+
/** The attributes a discovered selector may name: what the component's own markup says, never a generated one. */
|
|
28
|
+
export const SELECTOR_ATTRIBUTES = ['type', 'role', 'name', 'placeholder', 'aria-label'];
|
|
29
|
+
/** The actions tried on a control, in this order. */
|
|
30
|
+
export function actionsFor(c) {
|
|
31
|
+
if (c.nativeSelect)
|
|
32
|
+
return ['arrow-down'];
|
|
33
|
+
switch (c.role) {
|
|
34
|
+
case 'switch':
|
|
35
|
+
case 'checkbox':
|
|
36
|
+
return ['click', 'space'];
|
|
37
|
+
case 'tab':
|
|
38
|
+
return ['click', 'arrow-right'];
|
|
39
|
+
case 'slider':
|
|
40
|
+
return ['arrow-right'];
|
|
41
|
+
case 'textbox':
|
|
42
|
+
case 'searchbox':
|
|
43
|
+
case 'spinbutton':
|
|
44
|
+
return ['type'];
|
|
45
|
+
default:
|
|
46
|
+
return ['click'];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** The text typed into a field: a value its type accepts, the same on every run. */
|
|
50
|
+
export function textFor(c) {
|
|
51
|
+
if (c.role === 'spinbutton' || c.inputType === 'number')
|
|
52
|
+
return '7';
|
|
53
|
+
if (c.inputType === 'email')
|
|
54
|
+
return 'ada@example.com';
|
|
55
|
+
if (c.inputType === 'url')
|
|
56
|
+
return 'https://example.com';
|
|
57
|
+
if (c.inputType === 'tel')
|
|
58
|
+
return '5550100';
|
|
59
|
+
return 'Morph';
|
|
60
|
+
}
|
|
61
|
+
/** 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. */
|
|
62
|
+
export function looksGenerated(value) {
|
|
63
|
+
return /[:«»]/.test(value) || /^(?:v-|data-v-|svelte-|_ng|ng-|radix-|headlessui-|react-aria)/i.test(value) || /\b[0-9a-f]{8,}\b/i.test(value);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether a selector names only what the component's own markup says: tags, `:nth-of-type`, `>` and the attributes in
|
|
67
|
+
* SELECTOR_ATTRIBUTES, with no class, no id, no framework attribute and no generated value.
|
|
68
|
+
*/
|
|
69
|
+
export function isNeutralSelector(selector) {
|
|
70
|
+
const values = [];
|
|
71
|
+
const bare = selector.replace(/"(?:[^"\\]|\\.)*"/g, (m) => {
|
|
72
|
+
values.push(m.slice(1, -1));
|
|
73
|
+
return '""';
|
|
74
|
+
});
|
|
75
|
+
if (/[.#,~+*]|::?(?!nth-of-type\()/.test(bare.replace(/:nth-of-type\(\d+\)/g, '')))
|
|
76
|
+
return false;
|
|
77
|
+
if (/data-v-|svelte-|_ng|ng-/.test(bare))
|
|
78
|
+
return false;
|
|
79
|
+
for (const m of bare.matchAll(/\[([^\]=]*)(=""|\])/g)) {
|
|
80
|
+
const name = (m[1] ?? '').trim();
|
|
81
|
+
if (!SELECTOR_ATTRIBUTES.some((a) => a === name))
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (values.some((v) => looksGenerated(v)))
|
|
85
|
+
return false;
|
|
86
|
+
// what is left between attributes: tag names, :nth-of-type, child combinators and spaces
|
|
87
|
+
return /^[a-z][a-z0-9-]*(?:\[[^\]]*\]|:nth-of-type\(\d+\))*(?:\s*>\s*[a-z][a-z0-9-]*(?:\[[^\]]*\]|:nth-of-type\(\d+\))*)*$/.test(bare.trim());
|
|
88
|
+
}
|
|
89
|
+
function quote(value) {
|
|
90
|
+
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
91
|
+
}
|
|
92
|
+
function semantic(tag, attrs) {
|
|
93
|
+
let out = tag;
|
|
94
|
+
for (const a of SELECTOR_ATTRIBUTES) {
|
|
95
|
+
const v = attrs[a];
|
|
96
|
+
if (v === undefined || looksGenerated(v))
|
|
97
|
+
continue;
|
|
98
|
+
out += `[${a}=${quote(v)}]`;
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The locators to try for a control, most readable first: its role and name, its role alone (an unnamed control), its
|
|
104
|
+
* exact text, then a selector of tag and semantic attributes, with `:nth-of-type`, then under its parent. Each is
|
|
105
|
+
* confirmed on the React page before it is used; every selector here passes isNeutralSelector.
|
|
106
|
+
*/
|
|
107
|
+
export function proposeLocators(c) {
|
|
108
|
+
const out = [];
|
|
109
|
+
if (c.role !== 'summary') {
|
|
110
|
+
if (c.name && c.name.length <= MAX_NAME)
|
|
111
|
+
out.push({ role: c.role, name: c.name });
|
|
112
|
+
else if (!c.name)
|
|
113
|
+
out.push({ role: c.role });
|
|
114
|
+
}
|
|
115
|
+
if (c.text && c.text.length <= MAX_NAME)
|
|
116
|
+
out.push({ text: c.text });
|
|
117
|
+
const base = semantic(c.tag, c.attrs);
|
|
118
|
+
const own = `${base}:nth-of-type(${c.nth})`;
|
|
119
|
+
const selectors = [base, own];
|
|
120
|
+
if (c.parent)
|
|
121
|
+
selectors.push(`${semantic(c.parent.tag, c.parent.attrs)}:nth-of-type(${c.parent.nth}) > ${own}`);
|
|
122
|
+
for (const s of selectors)
|
|
123
|
+
if (isNeutralSelector(s))
|
|
124
|
+
out.push({ selector: s });
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
/** The step a candidate is: its action on its target, waiting `wait` virtual ms after it. */
|
|
128
|
+
export function stepFor(action, target, c, wait) {
|
|
129
|
+
const what = 'role' in target && target.name !== undefined ? `${target.role} ${JSON.stringify(target.name)}` : describeLocator(target);
|
|
130
|
+
switch (action) {
|
|
131
|
+
case 'click':
|
|
132
|
+
return { name: `click ${what}`, action: 'click', target, wait };
|
|
133
|
+
case 'space':
|
|
134
|
+
return { name: `Space on ${what}`, action: 'press', key: 'Space', target, wait };
|
|
135
|
+
case 'arrow-right':
|
|
136
|
+
return { name: `ArrowRight on ${what}`, action: 'press', key: 'ArrowRight', target, wait };
|
|
137
|
+
case 'arrow-down':
|
|
138
|
+
return { name: `ArrowDown on ${what}`, action: 'press', key: 'ArrowDown', target, wait };
|
|
139
|
+
case 'type':
|
|
140
|
+
return { name: `type into ${what}`, action: 'type', target, text: textFor(c), clear: true, wait };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** `autoSteps` as a number of steps: 12 by default, a whole number from 1 to MAX_STEPS when given. */
|
|
144
|
+
export function resolveMaxSteps(auto) {
|
|
145
|
+
if (auto === undefined || auto === false)
|
|
146
|
+
return 0;
|
|
147
|
+
if (auto === true)
|
|
148
|
+
return DEFAULT_AUTO_STEPS;
|
|
149
|
+
if (typeof auto !== 'object' || auto === null)
|
|
150
|
+
throw new MorphError('bad-step', 'autoSteps is true or { maxSteps }');
|
|
151
|
+
const n = auto.maxSteps;
|
|
152
|
+
if (n === undefined)
|
|
153
|
+
return DEFAULT_AUTO_STEPS;
|
|
154
|
+
if (typeof n !== 'number' || !Number.isInteger(n) || n < 1 || n > MAX_STEPS)
|
|
155
|
+
throw new MorphError('bad-step', `autoSteps.maxSteps is a whole number from 1 to ${MAX_STEPS}, not ${JSON.stringify(n)}`);
|
|
156
|
+
return n;
|
|
157
|
+
}
|
|
158
|
+
/** Gives every step a name no earlier step has (`click tab "One"`, then `click tab "One" #2`). */
|
|
159
|
+
export function uniqueName(name, used) {
|
|
160
|
+
let out = name;
|
|
161
|
+
for (let n = 2; used.has(out); n++)
|
|
162
|
+
out = `${name} #${n}`;
|
|
163
|
+
used.add(out);
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Scans the page for visible, enabled controls discovery can act on, in document order over `document.body` (the
|
|
168
|
+
* component's root and what it portals), and keeps them on `window.__morphAutoScan` by index.
|
|
169
|
+
*/
|
|
170
|
+
function scan(page) {
|
|
171
|
+
return page.evaluate(({ roles, attributes }) => {
|
|
172
|
+
const squash = (s) => (s ?? '').replace(/\s+/g, ' ').trim();
|
|
173
|
+
const query = ['button', 'input', 'select', 'textarea', 'summary', ...roles.map((r) => `[role="${r}"]`)].join(',');
|
|
174
|
+
const roleOf = (el) => {
|
|
175
|
+
const explicit = el.getAttribute('role')?.trim().split(/\s+/)[0];
|
|
176
|
+
if (explicit)
|
|
177
|
+
return explicit;
|
|
178
|
+
if (el instanceof HTMLInputElement) {
|
|
179
|
+
const t = el.type;
|
|
180
|
+
if (t === 'checkbox' || t === 'radio')
|
|
181
|
+
return t;
|
|
182
|
+
if (t === 'range')
|
|
183
|
+
return 'slider';
|
|
184
|
+
if (t === 'search')
|
|
185
|
+
return 'searchbox';
|
|
186
|
+
if (t === 'number')
|
|
187
|
+
return 'spinbutton';
|
|
188
|
+
if (t === 'button' || t === 'submit' || t === 'reset' || t === 'image')
|
|
189
|
+
return 'button';
|
|
190
|
+
if (t === 'hidden' || t === 'file' || t === 'color' || t === 'date' || t === 'time' || t === 'datetime-local' || t === 'month' || t === 'week')
|
|
191
|
+
return '';
|
|
192
|
+
return 'textbox';
|
|
193
|
+
}
|
|
194
|
+
if (el instanceof HTMLTextAreaElement)
|
|
195
|
+
return 'textbox';
|
|
196
|
+
if (el instanceof HTMLSelectElement)
|
|
197
|
+
return el.multiple || el.size > 1 ? '' : 'combobox';
|
|
198
|
+
const tag = el.tagName.toLowerCase();
|
|
199
|
+
if (tag === 'button')
|
|
200
|
+
return 'button';
|
|
201
|
+
if (tag === 'summary')
|
|
202
|
+
return 'summary';
|
|
203
|
+
return '';
|
|
204
|
+
};
|
|
205
|
+
const nameOf = (el) => {
|
|
206
|
+
const label = el.getAttribute('aria-label');
|
|
207
|
+
if (label?.trim())
|
|
208
|
+
return squash(label);
|
|
209
|
+
const by = el.getAttribute('aria-labelledby');
|
|
210
|
+
if (by) {
|
|
211
|
+
const text = by
|
|
212
|
+
.split(/\s+/)
|
|
213
|
+
.map((id) => document.getElementById(id)?.textContent ?? '')
|
|
214
|
+
.join(' ');
|
|
215
|
+
if (text.trim())
|
|
216
|
+
return squash(text);
|
|
217
|
+
}
|
|
218
|
+
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) {
|
|
219
|
+
const labels = el.labels ? [...el.labels].map((l) => l.textContent ?? '').join(' ') : '';
|
|
220
|
+
if (labels.trim())
|
|
221
|
+
return squash(labels);
|
|
222
|
+
if (el instanceof HTMLSelectElement)
|
|
223
|
+
return '';
|
|
224
|
+
return squash(el.placeholder);
|
|
225
|
+
}
|
|
226
|
+
return squash(el.textContent);
|
|
227
|
+
};
|
|
228
|
+
const attrsOf = (el) => {
|
|
229
|
+
const out = {};
|
|
230
|
+
for (const a of attributes) {
|
|
231
|
+
const v = el.getAttribute(a);
|
|
232
|
+
if (v !== null && v !== '')
|
|
233
|
+
out[a] = v;
|
|
234
|
+
}
|
|
235
|
+
return out;
|
|
236
|
+
};
|
|
237
|
+
const nthOf = (el) => {
|
|
238
|
+
let n = 1;
|
|
239
|
+
for (let s = el.previousElementSibling; s; s = s.previousElementSibling)
|
|
240
|
+
if (s.tagName === el.tagName)
|
|
241
|
+
n++;
|
|
242
|
+
return n;
|
|
243
|
+
};
|
|
244
|
+
const pathOf = (el) => {
|
|
245
|
+
const parts = [];
|
|
246
|
+
for (let e = el; e && e !== document.body; e = e.parentElement)
|
|
247
|
+
parts.push(`${e.tagName.toLowerCase()}:${nthOf(e)}`);
|
|
248
|
+
return parts.reverse().join('>');
|
|
249
|
+
};
|
|
250
|
+
const usable = (el) => {
|
|
251
|
+
if (!(el instanceof HTMLElement))
|
|
252
|
+
return false;
|
|
253
|
+
if (el.closest('[inert],[aria-hidden="true"]'))
|
|
254
|
+
return false;
|
|
255
|
+
if (el.getAttribute('aria-disabled') === 'true')
|
|
256
|
+
return false;
|
|
257
|
+
if ((el instanceof HTMLButtonElement || el instanceof HTMLInputElement || el instanceof HTMLSelectElement || el instanceof HTMLTextAreaElement) && el.disabled)
|
|
258
|
+
return false;
|
|
259
|
+
if ((el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) && el.readOnly)
|
|
260
|
+
return false;
|
|
261
|
+
// a submit button inside a form would submit it: the page's own handler decides what that does, not a step
|
|
262
|
+
if ((el instanceof HTMLButtonElement || el instanceof HTMLInputElement) && el.form && el.type === 'submit')
|
|
263
|
+
return false;
|
|
264
|
+
const style = getComputedStyle(el);
|
|
265
|
+
if (style.visibility !== 'visible' || style.pointerEvents === 'none')
|
|
266
|
+
return false;
|
|
267
|
+
const r = el.getBoundingClientRect();
|
|
268
|
+
if (r.width < 1 || r.height < 1)
|
|
269
|
+
return false;
|
|
270
|
+
// what a pointer at its centre would hit is the control itself (not an overlay over it)
|
|
271
|
+
const x = r.left + r.width / 2;
|
|
272
|
+
const y = r.top + r.height / 2;
|
|
273
|
+
// wholly outside the viewport: a step scrolls it into view first (in every framework alike), so no hit test
|
|
274
|
+
// here; partly inside with its centre outside: a step would point outside the page, so it is left alone
|
|
275
|
+
if (x < 0 || y < 0 || x >= innerWidth || y >= innerHeight)
|
|
276
|
+
return r.bottom <= 0 || r.right <= 0 || r.top >= innerHeight || r.left >= innerWidth;
|
|
277
|
+
const hit = document.elementFromPoint(x, y);
|
|
278
|
+
// a native control's own label can sit over it (a styled checkbox or switch): a click on it still reaches it
|
|
279
|
+
return !!hit && (hit === el || el.contains(hit) || (el instanceof HTMLInputElement && [...(el.labels ?? [])].some((l) => l === hit || l.contains(hit))));
|
|
280
|
+
};
|
|
281
|
+
const found = [];
|
|
282
|
+
const out = [];
|
|
283
|
+
for (const el of document.body.querySelectorAll(query)) {
|
|
284
|
+
const role = roleOf(el);
|
|
285
|
+
if (!roles.some((r) => r === role) || !usable(el))
|
|
286
|
+
continue;
|
|
287
|
+
// a control nested in another control is reached through the outer one (a button inside an option)
|
|
288
|
+
if (found.some((f) => f.contains(el)))
|
|
289
|
+
continue;
|
|
290
|
+
const parent = el.parentElement && el.parentElement !== document.body ? el.parentElement : null;
|
|
291
|
+
const name = nameOf(el);
|
|
292
|
+
const index = found.length;
|
|
293
|
+
found.push(el);
|
|
294
|
+
out.push({
|
|
295
|
+
index,
|
|
296
|
+
role: role,
|
|
297
|
+
name,
|
|
298
|
+
text: squash(el.textContent),
|
|
299
|
+
tag: el.tagName.toLowerCase(),
|
|
300
|
+
attrs: attrsOf(el),
|
|
301
|
+
nth: nthOf(el),
|
|
302
|
+
parent: parent ? { tag: parent.tagName.toLowerCase(), attrs: attrsOf(parent), nth: nthOf(parent) } : null,
|
|
303
|
+
inputType: el instanceof HTMLInputElement ? el.type : '',
|
|
304
|
+
nativeSelect: el instanceof HTMLSelectElement,
|
|
305
|
+
key: `${role}|${pathOf(el)}`,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
window.__morphAutoScan = found;
|
|
309
|
+
return out;
|
|
310
|
+
}, { roles: [...AUTO_ROLES], attributes: [...SELECTOR_ATTRIBUTES] });
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The first proposed locator that matches exactly one element on the page, and that element is the control (or, for a
|
|
314
|
+
* click, something inside it: exact text matches the innermost element holding it). Null when none does.
|
|
315
|
+
*/
|
|
316
|
+
async function confirmLocator(page, c, action, alive) {
|
|
317
|
+
for (const loc of proposeLocators(c)) {
|
|
318
|
+
let ok = false;
|
|
319
|
+
try {
|
|
320
|
+
const all = locate(page, loc);
|
|
321
|
+
if ((await all.count()) === 1) {
|
|
322
|
+
const where = await all.evaluate((el, i) => {
|
|
323
|
+
const want = window.__morphAutoScan?.[i];
|
|
324
|
+
return !want ? 'gone' : el === want ? 'same' : want.contains(el) ? 'inside' : 'other';
|
|
325
|
+
}, c.index);
|
|
326
|
+
ok = where === 'same' || (where === 'inside' && action === 'click');
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
// a selector Playwright cannot parse is not a locator; anything else is the run's own failure
|
|
331
|
+
alive();
|
|
332
|
+
if (!(error instanceof StepError) && !/selector|parse/i.test(error instanceof Error ? error.message : String(error)))
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
alive();
|
|
336
|
+
if (ok)
|
|
337
|
+
return loc;
|
|
338
|
+
}
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Discovers a script on a React page that has rendered and settled: tries each candidate on the live page, keeps it
|
|
343
|
+
* only when it ran cleanly (no step error, no new page error) and changed the render (pixels) or the DOM facts, and
|
|
344
|
+
* gives it the virtual wait after which React's render stopped moving. Kept steps accumulate on the same page, exactly
|
|
345
|
+
* as the steps runner later replays them from a fresh one.
|
|
346
|
+
*/
|
|
347
|
+
export async function discoverSteps(dp, options) {
|
|
348
|
+
const { page } = dp;
|
|
349
|
+
const { alive, maxSteps, stepMs, width, height } = options;
|
|
350
|
+
const shoot = async () => {
|
|
351
|
+
const png = await page.screenshot({ clip: { x: 0, y: 0, width, height }, animations: 'allow', caret: 'hide' });
|
|
352
|
+
alive();
|
|
353
|
+
return png;
|
|
354
|
+
};
|
|
355
|
+
const advance = async (ms) => {
|
|
356
|
+
await page.evaluate((m) => window.__morphClock?.advance(m) ?? Promise.resolve(0), ms);
|
|
357
|
+
alive();
|
|
358
|
+
};
|
|
359
|
+
const same = (a, b) => compare(a, b).diffPixels === 0;
|
|
360
|
+
let shot = await shoot();
|
|
361
|
+
let facts = await collectFacts(page, alive);
|
|
362
|
+
// a page that moves on its own (a loop, a ticker) cannot show a step's change in pixels: facts decide there
|
|
363
|
+
await advance(stepMs);
|
|
364
|
+
const idle = await shoot();
|
|
365
|
+
const animated = !same(shot, idle);
|
|
366
|
+
shot = idle;
|
|
367
|
+
facts = await collectFacts(page, alive);
|
|
368
|
+
const steps = [];
|
|
369
|
+
const names = new Set();
|
|
370
|
+
const tried = new Set();
|
|
371
|
+
const seen = new Set();
|
|
372
|
+
let priority = [];
|
|
373
|
+
let attempts = 0;
|
|
374
|
+
const maxAttempts = maxSteps * ATTEMPTS_PER_STEP;
|
|
375
|
+
let controls = await scan(page);
|
|
376
|
+
alive();
|
|
377
|
+
for (const c of controls)
|
|
378
|
+
seen.add(c.key);
|
|
379
|
+
for (let guard = 0; steps.length < maxSteps && attempts < maxAttempts && guard < maxAttempts * 4; guard++) {
|
|
380
|
+
// the next candidate: a revealed control first, else the first control in document order with an untried action
|
|
381
|
+
let next = null;
|
|
382
|
+
while (priority.length && !next) {
|
|
383
|
+
const p = priority.shift();
|
|
384
|
+
if (!p)
|
|
385
|
+
break;
|
|
386
|
+
const id = `${p.key}|${p.action}`;
|
|
387
|
+
if (tried.has(id))
|
|
388
|
+
continue;
|
|
389
|
+
const control = p.action === 'escape' ? null : (controls.find((c) => c.key === p.key) ?? null);
|
|
390
|
+
if (p.action !== 'escape' && !control)
|
|
391
|
+
continue;
|
|
392
|
+
next = { candidate: p, control };
|
|
393
|
+
}
|
|
394
|
+
if (!next) {
|
|
395
|
+
for (const c of controls) {
|
|
396
|
+
const action = actionsFor(c).find((a) => !tried.has(`${c.key}|${a}`));
|
|
397
|
+
if (action) {
|
|
398
|
+
next = { candidate: { key: c.key, action }, control: c };
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (!next)
|
|
404
|
+
break;
|
|
405
|
+
const { candidate, control } = next;
|
|
406
|
+
tried.add(`${candidate.key}|${candidate.action}`);
|
|
407
|
+
let step;
|
|
408
|
+
if (candidate.action === 'escape' || !control)
|
|
409
|
+
step = { name: 'Escape', action: 'press', key: 'Escape', wait: stepMs };
|
|
410
|
+
else {
|
|
411
|
+
const target = await confirmLocator(page, control, candidate.action, alive);
|
|
412
|
+
if (!target)
|
|
413
|
+
continue;
|
|
414
|
+
step = stepFor(candidate.action, target, control, stepMs);
|
|
415
|
+
}
|
|
416
|
+
attempts++;
|
|
417
|
+
const errorsBefore = dp.errors.length;
|
|
418
|
+
let failed = false;
|
|
419
|
+
try {
|
|
420
|
+
await performStep(page, step, alive);
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
alive();
|
|
424
|
+
if (!(error instanceof StepError))
|
|
425
|
+
throw error;
|
|
426
|
+
failed = true;
|
|
427
|
+
}
|
|
428
|
+
// the wait: stepMs, then longer while React's render is still moving (a spring, a transition), up to the cap
|
|
429
|
+
// (`waited` is every virtual ms stepped since the action, the last probe included, so the replay's timeline is
|
|
430
|
+
// discovery's)
|
|
431
|
+
let waited = stepMs;
|
|
432
|
+
await advance(stepMs);
|
|
433
|
+
let after = await shoot();
|
|
434
|
+
if (!animated) {
|
|
435
|
+
while (waited + SETTLE_PROBE_MS <= SETTLE_CAP_MS) {
|
|
436
|
+
await advance(SETTLE_PROBE_MS);
|
|
437
|
+
waited += SETTLE_PROBE_MS;
|
|
438
|
+
const later = await shoot();
|
|
439
|
+
const settled = same(after, later);
|
|
440
|
+
after = later;
|
|
441
|
+
if (settled)
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const afterFacts = await collectFacts(page, alive);
|
|
446
|
+
const changed = (!animated && !same(shot, after)) || diffFacts(facts, afterFacts).length > 0;
|
|
447
|
+
const clean = !failed && dp.errors.length === errorsBefore;
|
|
448
|
+
shot = after;
|
|
449
|
+
facts = afterFacts;
|
|
450
|
+
if (!clean) {
|
|
451
|
+
// a step that changed the page but not cleanly leaves a state no script can reach: stop here
|
|
452
|
+
if (changed)
|
|
453
|
+
break;
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if (!changed)
|
|
457
|
+
continue;
|
|
458
|
+
steps.push({ ...step, name: uniqueName(step.name, names), wait: Math.min(waited, MAX_STEP_WAIT) });
|
|
459
|
+
controls = await scan(page);
|
|
460
|
+
alive();
|
|
461
|
+
const revealed = controls.filter((c) => !seen.has(c.key));
|
|
462
|
+
for (const c of controls)
|
|
463
|
+
seen.add(c.key);
|
|
464
|
+
if (revealed.length) {
|
|
465
|
+
// explore what the step revealed (a menu, a dialog, a panel) before anything else, then try Escape to close it
|
|
466
|
+
const first = revealed.slice(0, REVEALED_PER_STEP).map((c) => ({ key: c.key, action: actionsFor(c)[0] ?? 'click' }));
|
|
467
|
+
priority = [...first, { key: `escape after ${steps.length}`, action: 'escape' }, ...priority];
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return { steps, attempts, animated };
|
|
471
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type Project } from '../analyzer/deps.js';
|
|
2
|
+
export type Framework = 'react' | 'vue' | 'svelte' | 'angular';
|
|
3
|
+
export interface BundleRequest {
|
|
4
|
+
framework: Framework;
|
|
5
|
+
/** the component file: the React source, or the emitted .vue / .svelte file */
|
|
6
|
+
file: string;
|
|
7
|
+
/** React: the named export to render ('default' for the default export) */
|
|
8
|
+
exportName: string;
|
|
9
|
+
props: Record<string, unknown>;
|
|
10
|
+
/** text children, passed the way each framework passes children */
|
|
11
|
+
children: string | null;
|
|
12
|
+
outDir: string;
|
|
13
|
+
project: Project;
|
|
14
|
+
/** next/font loader names the graph imports (they get a shim) */
|
|
15
|
+
nextFonts: string[];
|
|
16
|
+
probe?: string;
|
|
17
|
+
/** also define `window.__morphUnmount()`, which unmounts the component the framework's own way */
|
|
18
|
+
unmount?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Told when this build starts and ends waiting on work done once per process (the Angular linker's first link of a
|
|
21
|
+
* library: over 30 s for `@lucide/angular` on a cold start), so a caller's clock can leave the wait out.
|
|
22
|
+
*/
|
|
23
|
+
oneTimeWork?: (phase: 'start' | 'end') => void;
|
|
24
|
+
/** X6: the run has the fonts option: next/font/google gives React the Google files the conversion carries */
|
|
25
|
+
fonts?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The props as the framework's component declares them. The emitters rename a few React props to the target's own
|
|
29
|
+
* spelling, and a prop passed under React's name would miss: Vue declares `className` as `class` (the Vue emitter's
|
|
30
|
+
* VUE_PROP_RENAMES), Svelte declares `className` as `class` and DOM event props in lower case (`onClick` as `onclick`,
|
|
31
|
+
* the Svelte emitter's props keys). React keeps its own names, and so does Angular, whose inputs keep React's names.
|
|
32
|
+
*/
|
|
33
|
+
export declare function propsFor(framework: Framework, props: Record<string, unknown>): Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* The Angular page script: a host element inside #root, as React renders inside it, inputs set by their React prop
|
|
36
|
+
* names. Text children reach the component the way a parent template would write them: bound to the `children` input
|
|
37
|
+
* when the component declares one (`<x [children]="'…'">`, read from Angular's own metadata), projected as content
|
|
38
|
+
* otherwise (`<x>…</x>`).
|
|
39
|
+
*
|
|
40
|
+
* After the first `detectChanges()` the page runs the application's tick, as a real bootstrap's first tick does:
|
|
41
|
+
* `detectChanges()` runs no after-render hooks, so a component's `afterNextRender` code (the converted `useEffect`)
|
|
42
|
+
* would wait for the scheduler's next tick, one frame later, while the React page's flushSync runs its effects at once.
|
|
43
|
+
* Measured on beams.tsx (a WebGL animation whose clock starts at mount): React's first draw at virtual t=0.0,
|
|
44
|
+
* Angular's at t=16.0 before this tick and t=0.0 with it. The tick re-checks only views still dirty and runs each
|
|
45
|
+
* after-render callback once.
|
|
46
|
+
*/
|
|
47
|
+
export declare function angularEntry(req: BundleRequest): string;
|
|
48
|
+
/**
|
|
49
|
+
* Bundles one framework's page script (and the CSS its files import) into `outDir`. With a `signal`, an abort cancels
|
|
50
|
+
* the build in flight and nothing is written after it: a stopped verify's folder is never recreated by a late build.
|
|
51
|
+
* Each bundle is its own esbuild context in the process's one esbuild service, so cancelling it touches no other run.
|
|
52
|
+
*/
|
|
53
|
+
export declare function bundleEntry(req: BundleRequest, signal?: AbortSignal): Promise<{
|
|
54
|
+
js: string;
|
|
55
|
+
css: string | null;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* The stylesheets an Angular bundle's components name (`styleUrl`), as the other frameworks' bundles get theirs: the
|
|
59
|
+
* Angular compiler inlines each one as it is written into its component, so a `@theme` block in it (Tailwind's, which
|
|
60
|
+
* an Angular CLI build with Tailwind compiles) never meets Tailwind. Given their text in order, joined as esbuild joins
|
|
61
|
+
* the CSS a bundle imports, and the bundle's own code: the same Tailwind build the esbuild CSS gets (buildThemed), or
|
|
62
|
+
* null when no stylesheet holds `@theme` (then nothing changes).
|
|
63
|
+
*/
|
|
64
|
+
export declare function themedAngularStyles(sheets: string[], code: string): Promise<string | null>;
|
|
65
|
+
/** Class-name candidates in built code: Tailwind keeps the ones that are real utilities. */
|
|
66
|
+
export declare function candidates(code: string): string[];
|
|
67
|
+
/** One Tailwind v4 stylesheet (preflight, theme, utilities) for the classes found in every bundle. */
|
|
68
|
+
export declare function buildTailwind(sources: string[]): Promise<string>;
|