@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,475 @@
|
|
|
1
|
+
import { STEP_KEYS } from '../types.js';
|
|
2
|
+
import { MorphError } from '../utils/errors.js';
|
|
3
|
+
/** The longest virtual wait one step may ask for, ms: stepping virtual time costs about as much real time. */
|
|
4
|
+
export const MAX_STEP_WAIT = 5000;
|
|
5
|
+
/** The longest script verify runs: every step costs a shot and a few evaluations in every framework. */
|
|
6
|
+
export const MAX_STEPS = 24;
|
|
7
|
+
/** A drag (X6): at most this many pointer moves, and an offset at most this far in each axis, CSS px. */
|
|
8
|
+
export const MAX_DRAG_MOVES = 30;
|
|
9
|
+
export const MAX_DRAG_PX = 2000;
|
|
10
|
+
/** A drag's defaults: a few moves over a sixth of a second, as a quick hand drags. */
|
|
11
|
+
const DRAG_MOVES = 5;
|
|
12
|
+
const DRAG_MS = 160;
|
|
13
|
+
/** How long a locator that matched may take to answer, real ms (it is already in the page: this only guards a hang). */
|
|
14
|
+
const LOCATOR_TIMEOUT = 2000;
|
|
15
|
+
/** Every role Playwright's role locator knows (its own list): a step's role is checked against it, not cast. */
|
|
16
|
+
const ROLES = ['alert', 'alertdialog', 'application', 'article', 'banner', 'blockquote', 'button', 'caption', 'cell', 'checkbox', 'code', 'columnheader', 'combobox', 'complementary', 'contentinfo', 'definition', 'deletion', 'dialog', 'directory', 'document', 'emphasis', 'feed', 'figure', 'form', 'generic', 'grid', 'gridcell', 'group', 'heading', 'img', 'insertion', 'link', 'list', 'listbox', 'listitem', 'log', 'main', 'marquee', 'math', 'meter', 'menu', 'menubar', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'navigation', 'none', 'note', 'option', 'paragraph', 'presentation', 'progressbar', 'radio', 'radiogroup', 'region', 'row', 'rowgroup', 'rowheader', 'scrollbar', 'search', 'searchbox', 'separator', 'slider', 'spinbutton', 'status', 'strong', 'subscript', 'superscript', 'switch', 'tab', 'table', 'tablist', 'tabpanel', 'term', 'textbox', 'time', 'timer', 'toolbar', 'tooltip', 'tree', 'treegrid', 'treeitem'];
|
|
17
|
+
/** The DOM state compared after every step, on every element of the component that carries it. */
|
|
18
|
+
const STATE_ATTRIBUTES = ['aria-expanded', 'aria-selected', 'aria-checked', 'aria-pressed', 'aria-current', 'aria-valuenow', 'aria-valuetext', 'data-state', 'open'];
|
|
19
|
+
const KEYS = STEP_KEYS;
|
|
20
|
+
/** A step that could not be carried out on a page: its target matched nothing there, or the action itself failed. */
|
|
21
|
+
export class StepError extends Error {
|
|
22
|
+
kind;
|
|
23
|
+
constructor(kind, message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.kind = kind;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function describeLocator(loc) {
|
|
29
|
+
if ('role' in loc)
|
|
30
|
+
return `role ${loc.role}${loc.name === undefined ? '' : ` named ${JSON.stringify(loc.name)}`}`;
|
|
31
|
+
if ('text' in loc)
|
|
32
|
+
return `text ${JSON.stringify(loc.text)}`;
|
|
33
|
+
return `selector ${loc.selector}`;
|
|
34
|
+
}
|
|
35
|
+
function badStep(index, message) {
|
|
36
|
+
return new MorphError('bad-step', `step ${index + 1}: ${message}`);
|
|
37
|
+
}
|
|
38
|
+
function checkLocator(loc, index) {
|
|
39
|
+
if (typeof loc !== 'object' || loc === null)
|
|
40
|
+
throw badStep(index, 'needs a target (role, text or selector)');
|
|
41
|
+
const kinds = ['role' in loc, 'text' in loc, 'selector' in loc].filter(Boolean).length;
|
|
42
|
+
if (kinds !== 1)
|
|
43
|
+
throw badStep(index, 'a target is exactly one of role, text or selector');
|
|
44
|
+
if ('role' in loc) {
|
|
45
|
+
if (!ROLES.some((r) => r === loc.role))
|
|
46
|
+
throw badStep(index, `${JSON.stringify(loc.role)} is not an ARIA role`);
|
|
47
|
+
if (loc.name !== undefined && typeof loc.name !== 'string')
|
|
48
|
+
throw badStep(index, 'a role name is a string');
|
|
49
|
+
}
|
|
50
|
+
else if ('text' in loc) {
|
|
51
|
+
if (typeof loc.text !== 'string' || !loc.text)
|
|
52
|
+
throw badStep(index, 'a text target is a non-empty string');
|
|
53
|
+
}
|
|
54
|
+
else if (typeof loc.selector !== 'string' || !loc.selector.trim())
|
|
55
|
+
throw badStep(index, 'a selector is a non-empty string');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Checks a script before anything renders (it may come from JSON): every step is named, uniquely, has an action it can
|
|
59
|
+
* carry out and the target and text or key that action needs, and waits a finite virtual time under the cap.
|
|
60
|
+
*/
|
|
61
|
+
export function checkSteps(steps) {
|
|
62
|
+
if (!Array.isArray(steps))
|
|
63
|
+
throw new MorphError('bad-step', 'steps is a list');
|
|
64
|
+
if (steps.length > MAX_STEPS)
|
|
65
|
+
throw new MorphError('bad-step', `a script has at most ${MAX_STEPS} steps (this one has ${steps.length})`);
|
|
66
|
+
const names = new Set();
|
|
67
|
+
steps.forEach((step, i) => {
|
|
68
|
+
if (typeof step !== 'object' || step === null)
|
|
69
|
+
throw badStep(i, 'is not an object');
|
|
70
|
+
if (typeof step.name !== 'string' || !step.name.trim())
|
|
71
|
+
throw badStep(i, 'needs a name');
|
|
72
|
+
if (names.has(step.name))
|
|
73
|
+
throw badStep(i, `the name ${JSON.stringify(step.name)} is used twice`);
|
|
74
|
+
names.add(step.name);
|
|
75
|
+
if (step.wait !== undefined && (typeof step.wait !== 'number' || !Number.isFinite(step.wait) || step.wait < 0 || step.wait > MAX_STEP_WAIT))
|
|
76
|
+
throw badStep(i, `wait is virtual ms from 0 to ${MAX_STEP_WAIT}`);
|
|
77
|
+
switch (step.action) {
|
|
78
|
+
case 'click':
|
|
79
|
+
case 'hover':
|
|
80
|
+
case 'focus':
|
|
81
|
+
case 'right-click':
|
|
82
|
+
checkLocator(step.target, i);
|
|
83
|
+
return;
|
|
84
|
+
case 'type':
|
|
85
|
+
checkLocator(step.target, i);
|
|
86
|
+
if (typeof step.text !== 'string' || !step.text)
|
|
87
|
+
throw badStep(i, 'type needs the text to type');
|
|
88
|
+
return;
|
|
89
|
+
case 'press':
|
|
90
|
+
if (typeof step.key !== 'string' || !(KEYS.includes(step.key) || [...step.key].length === 1))
|
|
91
|
+
throw badStep(i, `press takes one of ${STEP_KEYS.join(', ')} or a single character, not ${JSON.stringify(step.key)}`);
|
|
92
|
+
if (step.target !== undefined)
|
|
93
|
+
checkLocator(step.target, i);
|
|
94
|
+
if (step.hold !== undefined && (typeof step.hold !== 'number' || !Number.isFinite(step.hold) || step.hold <= 0 || step.hold > MAX_STEP_WAIT))
|
|
95
|
+
throw badStep(i, `hold is virtual ms above 0 and at most ${MAX_STEP_WAIT}`);
|
|
96
|
+
return;
|
|
97
|
+
case 'drag': {
|
|
98
|
+
// X6: a drag from a target to an offset or another target, in a few moves over virtual time
|
|
99
|
+
checkLocator(step.target, i);
|
|
100
|
+
// from JSON `to` can be anything: what TypeScript calls impossible is still checked
|
|
101
|
+
const to = step.to;
|
|
102
|
+
if (typeof to !== 'object' || to === null)
|
|
103
|
+
throw badStep(i, 'drag needs `to`: an offset { dx, dy } or a target');
|
|
104
|
+
const px = (v) => typeof v === 'number' && Number.isFinite(v) && Math.abs(v) <= MAX_DRAG_PX;
|
|
105
|
+
const offset = `a drag offset is { dx, dy }, each a number of CSS px from -${MAX_DRAG_PX} to ${MAX_DRAG_PX}`;
|
|
106
|
+
if ('dx' in to) {
|
|
107
|
+
if (!px(to.dx) || !('dy' in to) || !px(to.dy))
|
|
108
|
+
throw badStep(i, offset);
|
|
109
|
+
}
|
|
110
|
+
else if ('dy' in to)
|
|
111
|
+
throw badStep(i, offset);
|
|
112
|
+
else
|
|
113
|
+
checkLocator(to, i);
|
|
114
|
+
if (step.moves !== undefined && (typeof step.moves !== 'number' || !Number.isInteger(step.moves) || step.moves < 1 || step.moves > MAX_DRAG_MOVES))
|
|
115
|
+
throw badStep(i, `moves is a whole number from 1 to ${MAX_DRAG_MOVES}`);
|
|
116
|
+
if (step.duration !== undefined && (typeof step.duration !== 'number' || !Number.isFinite(step.duration) || step.duration < 0 || step.duration > MAX_STEP_WAIT))
|
|
117
|
+
throw badStep(i, `duration is virtual ms from 0 to ${MAX_STEP_WAIT}`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
case 'leave':
|
|
121
|
+
case 'wait':
|
|
122
|
+
return;
|
|
123
|
+
default: {
|
|
124
|
+
// a script from JSON can hold anything: what TypeScript calls impossible is still checked
|
|
125
|
+
const given = step;
|
|
126
|
+
throw badStep(i, `unknown action ${JSON.stringify(given.action)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Where a locator searches and facts are collected: the page's whole body, not only `#root`, so what a component
|
|
133
|
+
* portals to `document.body` (a dialog, a menu, a listbox, a tooltip) can be reached and is compared. The sandboxed
|
|
134
|
+
* page holds nothing but the component under test, and every framework's page is searched the same way.
|
|
135
|
+
*/
|
|
136
|
+
const SCOPE = 'body';
|
|
137
|
+
/** Every element a locator matches on a page, searched the way a step searches (exported for auto-steps' confirmation). */
|
|
138
|
+
export function locate(page, loc) {
|
|
139
|
+
const root = page.locator(SCOPE);
|
|
140
|
+
if ('role' in loc) {
|
|
141
|
+
const role = ROLES.find((r) => r === loc.role);
|
|
142
|
+
if (!role)
|
|
143
|
+
throw new StepError('failed', `${JSON.stringify(loc.role)} is not an ARIA role`);
|
|
144
|
+
return root.getByRole(role, loc.name === undefined ? {} : { name: loc.name, exact: true });
|
|
145
|
+
}
|
|
146
|
+
if ('text' in loc)
|
|
147
|
+
return root.getByText(loc.text, { exact: true });
|
|
148
|
+
return root.locator(loc.selector);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The one element the locator matches, now (no waiting for it to appear: the page is on a stopped clock). A target
|
|
152
|
+
* that matches more than one element is an error: which of them a step acted on could differ between frameworks.
|
|
153
|
+
*/
|
|
154
|
+
async function find(page, loc, alive) {
|
|
155
|
+
const all = locate(page, loc);
|
|
156
|
+
let count;
|
|
157
|
+
try {
|
|
158
|
+
count = await all.count();
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
alive();
|
|
162
|
+
throw new StepError('failed', `the ${describeLocator(loc)} could not be searched for: ${firstLine(error)}`);
|
|
163
|
+
}
|
|
164
|
+
alive();
|
|
165
|
+
if (!count)
|
|
166
|
+
throw new StepError('missing', `the ${describeLocator(loc)} matched nothing`);
|
|
167
|
+
if (count > 1)
|
|
168
|
+
throw new StepError('failed', `the ${describeLocator(loc)} matched ${count} elements; a target names exactly one`);
|
|
169
|
+
return all;
|
|
170
|
+
}
|
|
171
|
+
/** The centre of an element in viewport coordinates, scrolled into view first when it is outside the viewport. */
|
|
172
|
+
async function centre(el, loc, alive) {
|
|
173
|
+
const box = await el.evaluate((node) => {
|
|
174
|
+
const outside = (r) => r.bottom <= 0 || r.right <= 0 || r.top >= innerHeight || r.left >= innerWidth;
|
|
175
|
+
if (outside(node.getBoundingClientRect()))
|
|
176
|
+
node.scrollIntoView({ block: 'center', inline: 'center' });
|
|
177
|
+
const r = node.getBoundingClientRect();
|
|
178
|
+
return { x: r.left + r.width / 2, y: r.top + r.height / 2, width: r.width, height: r.height };
|
|
179
|
+
}, undefined, { timeout: LOCATOR_TIMEOUT });
|
|
180
|
+
alive();
|
|
181
|
+
if (box.width <= 0 || box.height <= 0)
|
|
182
|
+
throw new StepError('missing', `the ${describeLocator(loc)} has no box to point at`);
|
|
183
|
+
return { x: box.x, y: box.y };
|
|
184
|
+
}
|
|
185
|
+
function firstLine(error) {
|
|
186
|
+
return (error instanceof Error ? error.message : String(error)).split('\n')[0] ?? '';
|
|
187
|
+
}
|
|
188
|
+
/** Focuses the element (with `caret`: an input's caret at the end, or its text selected) and says how much text it holds. */
|
|
189
|
+
async function focusOn(el, caret, alive) {
|
|
190
|
+
const length = await el.evaluate((node, where) => {
|
|
191
|
+
if (node instanceof HTMLElement || node instanceof SVGElement)
|
|
192
|
+
node.focus();
|
|
193
|
+
if (where && (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement)) {
|
|
194
|
+
try {
|
|
195
|
+
if (where === 'select')
|
|
196
|
+
node.select();
|
|
197
|
+
else
|
|
198
|
+
node.setSelectionRange(node.value.length, node.value.length);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
// an input type without a selection (email, number): the caret stays where focus put it
|
|
202
|
+
}
|
|
203
|
+
return node.value.length;
|
|
204
|
+
}
|
|
205
|
+
return 0;
|
|
206
|
+
}, caret, { timeout: LOCATOR_TIMEOUT });
|
|
207
|
+
alive();
|
|
208
|
+
return length;
|
|
209
|
+
}
|
|
210
|
+
/** Lets `ms` pass on the page's clock: the sandbox's virtual clock when it has one, else real time in the page. */
|
|
211
|
+
async function holdFor(page, ms) {
|
|
212
|
+
await page.evaluate((m) => (window.__morphClock ? window.__morphClock.advance(m).then(() => undefined) : new Promise((resolve) => setTimeout(resolve, m))), ms);
|
|
213
|
+
}
|
|
214
|
+
/** Carries out one step's action on a page (not its wait or its shot). A failure is a StepError; a stopped run rethrows. */
|
|
215
|
+
export async function performStep(page, step, alive) {
|
|
216
|
+
const then = async (action) => {
|
|
217
|
+
let value;
|
|
218
|
+
try {
|
|
219
|
+
value = await action;
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
alive();
|
|
223
|
+
if (error instanceof StepError)
|
|
224
|
+
throw error;
|
|
225
|
+
throw new StepError('failed', `the ${step.action} failed: ${firstLine(error)}`);
|
|
226
|
+
}
|
|
227
|
+
alive();
|
|
228
|
+
return value;
|
|
229
|
+
};
|
|
230
|
+
switch (step.action) {
|
|
231
|
+
case 'click':
|
|
232
|
+
case 'hover': {
|
|
233
|
+
const el = await find(page, step.target, alive);
|
|
234
|
+
const at = await then(centre(el, step.target, alive));
|
|
235
|
+
await then(page.mouse.move(at.x, at.y));
|
|
236
|
+
if (step.action === 'click') {
|
|
237
|
+
await then(page.mouse.down());
|
|
238
|
+
await then(page.mouse.up());
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
case 'leave':
|
|
243
|
+
await then(page.mouse.move(0, 0));
|
|
244
|
+
return;
|
|
245
|
+
case 'focus': {
|
|
246
|
+
const el = await find(page, step.target, alive);
|
|
247
|
+
await then(focusOn(el, null, alive));
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
case 'type': {
|
|
251
|
+
const el = await find(page, step.target, alive);
|
|
252
|
+
const length = await then(focusOn(el, step.clear ? 'select' : 'end', alive));
|
|
253
|
+
if (step.clear && length > 0)
|
|
254
|
+
await then(page.keyboard.press('Backspace'));
|
|
255
|
+
await then(page.keyboard.type(step.text));
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
case 'right-click': {
|
|
259
|
+
const el = await find(page, step.target, alive);
|
|
260
|
+
const at = await then(centre(el, step.target, alive));
|
|
261
|
+
await then(page.mouse.move(at.x, at.y));
|
|
262
|
+
await then(page.mouse.down({ button: 'right' }));
|
|
263
|
+
await then(page.mouse.up({ button: 'right' }));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
case 'press': {
|
|
267
|
+
if (step.target)
|
|
268
|
+
await then(focusOn(await find(page, step.target, alive), null, alive));
|
|
269
|
+
if (step.hold === undefined) {
|
|
270
|
+
await then(page.keyboard.press(step.key));
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
// held: modifiers and the key go down, the hold passes on the page's clock (virtual in verify's sandbox, so
|
|
274
|
+
// timers the key-down started run while the key is down), then they come up in reverse order
|
|
275
|
+
const keys = [...step.key].length === 1 ? [step.key] : step.key.split('+');
|
|
276
|
+
for (const key of keys)
|
|
277
|
+
await then(page.keyboard.down(key));
|
|
278
|
+
await then(holdFor(page, step.hold));
|
|
279
|
+
for (const key of [...keys].reverse())
|
|
280
|
+
await then(page.keyboard.up(key));
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
case 'drag': {
|
|
284
|
+
// X6: real input through the browser: press on the target's centre, move in even steps with virtual time between
|
|
285
|
+
// them (so velocity, inertia and timers see a hand's pace), release where the drag ends
|
|
286
|
+
const el = await find(page, step.target, alive);
|
|
287
|
+
const from = await then(centre(el, step.target, alive));
|
|
288
|
+
const to = 'dx' in step.to ? { x: from.x + step.to.dx, y: from.y + step.to.dy } : await then(centre(await find(page, step.to, alive), step.to, alive));
|
|
289
|
+
const moves = step.moves ?? DRAG_MOVES;
|
|
290
|
+
const pause = (step.duration ?? DRAG_MS) / moves;
|
|
291
|
+
await then(page.mouse.move(from.x, from.y));
|
|
292
|
+
await then(page.mouse.down());
|
|
293
|
+
for (let k = 1; k <= moves; k++) {
|
|
294
|
+
if (pause > 0)
|
|
295
|
+
await then(holdFor(page, pause));
|
|
296
|
+
await then(page.mouse.move(from.x + ((to.x - from.x) * k) / moves, from.y + ((to.y - from.y) * k) / moves));
|
|
297
|
+
}
|
|
298
|
+
await then(page.mouse.up());
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
case 'wait':
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The framework-neutral DOM state of the component after a step: each element's ARIA and `data-state` state, form
|
|
307
|
+
* values and checked states, disabled controls, and what has focus, each keyed by the element's role and accessible
|
|
308
|
+
* name (its `aria-label`, `aria-labelledby` text, `<label>` text, placeholder, or rendered text content), over the
|
|
309
|
+
* page's whole body so portalled content counts. Generated ids and classes never appear, so React and every target
|
|
310
|
+
* describe the same element the same way.
|
|
311
|
+
*/
|
|
312
|
+
export async function collectFacts(page, alive) {
|
|
313
|
+
const facts = await page.evaluate(({ attributes, scope }) => {
|
|
314
|
+
const out = [];
|
|
315
|
+
const root = document.querySelector(scope);
|
|
316
|
+
if (!root)
|
|
317
|
+
return out;
|
|
318
|
+
const squash = (s) => (s ?? '').replace(/\s+/g, ' ').trim().slice(0, 60);
|
|
319
|
+
const roleOf = (el) => {
|
|
320
|
+
const explicit = el.getAttribute('role')?.trim();
|
|
321
|
+
if (explicit)
|
|
322
|
+
return explicit.split(/\s+/)[0] ?? explicit;
|
|
323
|
+
if (el instanceof HTMLInputElement) {
|
|
324
|
+
const t = el.type;
|
|
325
|
+
if (t === 'checkbox' || t === 'radio')
|
|
326
|
+
return t;
|
|
327
|
+
if (t === 'range')
|
|
328
|
+
return 'slider';
|
|
329
|
+
if (t === 'search')
|
|
330
|
+
return 'searchbox';
|
|
331
|
+
if (t === 'number')
|
|
332
|
+
return 'spinbutton';
|
|
333
|
+
if (t === 'button' || t === 'submit' || t === 'reset' || t === 'image')
|
|
334
|
+
return 'button';
|
|
335
|
+
return 'textbox';
|
|
336
|
+
}
|
|
337
|
+
if (el instanceof HTMLTextAreaElement)
|
|
338
|
+
return 'textbox';
|
|
339
|
+
if (el instanceof HTMLSelectElement)
|
|
340
|
+
return el.multiple || el.size > 1 ? 'listbox' : 'combobox';
|
|
341
|
+
if (el instanceof HTMLAnchorElement && el.hasAttribute('href'))
|
|
342
|
+
return 'link';
|
|
343
|
+
const tag = el.tagName.toLowerCase();
|
|
344
|
+
if (tag === 'button')
|
|
345
|
+
return 'button';
|
|
346
|
+
if (/^h[1-6]$/.test(tag))
|
|
347
|
+
return 'heading';
|
|
348
|
+
return tag;
|
|
349
|
+
};
|
|
350
|
+
// An element's rendered text: its text content without the text nobody meets, neither on screen nor through a
|
|
351
|
+
// screen reader: a subtree that is `display: none` (the `hidden` attribute, unless a style shows it again),
|
|
352
|
+
// `content-visibility: hidden` (`hidden="until-found"`), `aria-hidden="true"`, the content of a closed <details>
|
|
353
|
+
// after its summary, and a text node whose element is `visibility: hidden` (inherited, so a visible child of a
|
|
354
|
+
// hidden parent still counts). Text is joined exactly as textContent joins it, so an element with no such text
|
|
355
|
+
// gets the name it always had. An element that is itself not rendered (a hidden label an aria-labelledby points
|
|
356
|
+
// at) is named by all of its text, as the accessible name computation and innerText both do.
|
|
357
|
+
const renderedText = (el) => {
|
|
358
|
+
if (!el.getClientRects().length)
|
|
359
|
+
return el.textContent ?? '';
|
|
360
|
+
let text = '';
|
|
361
|
+
const walk = (node) => {
|
|
362
|
+
let summarySeen = false;
|
|
363
|
+
const closed = node instanceof HTMLDetailsElement && !node.open;
|
|
364
|
+
for (const child of node.childNodes) {
|
|
365
|
+
if (child instanceof Text) {
|
|
366
|
+
const parent = child.parentElement;
|
|
367
|
+
if (!closed && parent && getComputedStyle(parent).visibility === 'visible')
|
|
368
|
+
text += child.data;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (!(child instanceof Element))
|
|
372
|
+
continue;
|
|
373
|
+
if (closed) {
|
|
374
|
+
// a closed <details> renders its first <summary> only
|
|
375
|
+
if (summarySeen || child.tagName.toLowerCase() !== 'summary')
|
|
376
|
+
continue;
|
|
377
|
+
summarySeen = true;
|
|
378
|
+
}
|
|
379
|
+
if (child.getAttribute('aria-hidden') === 'true')
|
|
380
|
+
continue;
|
|
381
|
+
const style = getComputedStyle(child);
|
|
382
|
+
if (style.display === 'none' || style.getPropertyValue('content-visibility') === 'hidden')
|
|
383
|
+
continue;
|
|
384
|
+
walk(child);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
walk(el);
|
|
388
|
+
return text;
|
|
389
|
+
};
|
|
390
|
+
const nameOf = (el) => {
|
|
391
|
+
const label = el.getAttribute('aria-label');
|
|
392
|
+
if (label?.trim())
|
|
393
|
+
return squash(label);
|
|
394
|
+
const by = el.getAttribute('aria-labelledby');
|
|
395
|
+
if (by) {
|
|
396
|
+
const text = by
|
|
397
|
+
.split(/\s+/)
|
|
398
|
+
.map((id) => {
|
|
399
|
+
const target = document.getElementById(id);
|
|
400
|
+
return target ? renderedText(target) : '';
|
|
401
|
+
})
|
|
402
|
+
.join(' ');
|
|
403
|
+
if (text.trim())
|
|
404
|
+
return squash(text);
|
|
405
|
+
}
|
|
406
|
+
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) {
|
|
407
|
+
const labels = el.labels ? [...el.labels].map((l) => renderedText(l)).join(' ') : '';
|
|
408
|
+
if (labels.trim())
|
|
409
|
+
return squash(labels);
|
|
410
|
+
return el instanceof HTMLSelectElement ? '' : squash(el.placeholder);
|
|
411
|
+
}
|
|
412
|
+
return squash(renderedText(el));
|
|
413
|
+
};
|
|
414
|
+
const seen = new Map();
|
|
415
|
+
const keyOf = (el) => {
|
|
416
|
+
const base = `${roleOf(el)} "${nameOf(el)}"`;
|
|
417
|
+
const n = (seen.get(base) ?? 0) + 1;
|
|
418
|
+
seen.set(base, n);
|
|
419
|
+
return n === 1 ? base : `${base} #${n}`;
|
|
420
|
+
};
|
|
421
|
+
for (const el of root.querySelectorAll('*')) {
|
|
422
|
+
// not rendered (display: none, or inside it): not part of what a user or a screen reader meets
|
|
423
|
+
if (!el.getClientRects().length)
|
|
424
|
+
continue;
|
|
425
|
+
const own = [];
|
|
426
|
+
for (const a of attributes) {
|
|
427
|
+
const v = el.getAttribute(a);
|
|
428
|
+
if (v !== null)
|
|
429
|
+
own.push([a, v]);
|
|
430
|
+
}
|
|
431
|
+
if (el instanceof HTMLInputElement && (el.type === 'checkbox' || el.type === 'radio'))
|
|
432
|
+
own.push(['checked', String(el.checked)]);
|
|
433
|
+
else if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement)
|
|
434
|
+
own.push(['value', el.value]);
|
|
435
|
+
if ((el instanceof HTMLButtonElement || el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) && el.disabled)
|
|
436
|
+
own.push(['disabled', 'true']);
|
|
437
|
+
if (!own.length)
|
|
438
|
+
continue;
|
|
439
|
+
const key = keyOf(el);
|
|
440
|
+
for (const [a, v] of own)
|
|
441
|
+
out.push([`${key} ${a}`, v]);
|
|
442
|
+
}
|
|
443
|
+
const active = document.activeElement;
|
|
444
|
+
out.push(['focus', !active || active === document.body ? 'nothing' : root.contains(active) ? `${roleOf(active)} "${nameOf(active)}"` : 'something outside the component']);
|
|
445
|
+
return out;
|
|
446
|
+
}, { attributes: STATE_ATTRIBUTES, scope: SCOPE });
|
|
447
|
+
alive();
|
|
448
|
+
return facts;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* The facts that differ between React and a target. Facts are matched by their key with whitespace taken out (one
|
|
452
|
+
* framework keeps a space between a label and a count where another does not, which no pixel shows); values must be
|
|
453
|
+
* equal exactly.
|
|
454
|
+
*/
|
|
455
|
+
export function diffFacts(react, actual) {
|
|
456
|
+
const norm = (key) => key.replace(/\s+/g, '');
|
|
457
|
+
const theirs = new Map(actual.map(([k, v]) => [norm(k), { key: k, value: v }]));
|
|
458
|
+
const ours = new Map(react.map(([k, v]) => [norm(k), { key: k, value: v }]));
|
|
459
|
+
const out = [];
|
|
460
|
+
for (const [n, { key, value }] of ours) {
|
|
461
|
+
const other = theirs.get(n);
|
|
462
|
+
const focusValue = (v) => (key === 'focus' && v !== undefined ? norm(v) : v);
|
|
463
|
+
if (focusValue(other?.value) !== focusValue(value))
|
|
464
|
+
out.push({ fact: key, react: value, actual: other?.value ?? null });
|
|
465
|
+
}
|
|
466
|
+
for (const [n, { key, value }] of theirs)
|
|
467
|
+
if (!ours.has(n))
|
|
468
|
+
out.push({ fact: key, react: null, actual: value });
|
|
469
|
+
return out;
|
|
470
|
+
}
|
|
471
|
+
/** One line for a diagnostic: `aria-checked of switch "Email notifications" is "true" (React: "false")`. */
|
|
472
|
+
export function describeMismatches(list) {
|
|
473
|
+
const shown = list.slice(0, 4).map((m) => `${m.fact} is ${m.actual === null ? 'missing' : JSON.stringify(m.actual)} (React: ${m.react === null ? 'missing' : JSON.stringify(m.react)})`);
|
|
474
|
+
return `${shown.join('; ')}${list.length > shown.length ? `; and ${list.length - shown.length} more` : ''}`;
|
|
475
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { VerifyResult } from '../types.js';
|
|
2
|
+
/** Why no target can be scored when React itself renders nothing: one sentence, the same for every target. */
|
|
3
|
+
export declare const REACT_BLANK_REASON = "React renders nothing with these props, so there is nothing to compare";
|
|
4
|
+
/**
|
|
5
|
+
* Whether the React reference rendered nothing: its resting shot is one flat colour or its component box is empty.
|
|
6
|
+
* It is read from React's own shots, never from a target's diagnostics, so every target gets the same answer (a target
|
|
7
|
+
* that failed to render, or has no comparison, cannot turn it into a verdict of its own).
|
|
8
|
+
*/
|
|
9
|
+
export declare function reactRendersNothing(result: Pick<VerifyResult, 'shots'>): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The reason a verify result cannot score its targets at all, or null when it can. With no React reference nothing is
|
|
12
|
+
* compared: a target is `unmeasured`, never `same`. (A blank target against a React render that has content is a
|
|
13
|
+
* different case and still scores 0 in verify: it is a failure, not an absence of a reference.)
|
|
14
|
+
*/
|
|
15
|
+
export declare function unmeasuredReason(result: Pick<VerifyResult, 'shots'>): string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Why no target can be scored when React itself renders nothing: one sentence, the same for every target. */
|
|
2
|
+
export const REACT_BLANK_REASON = 'React renders nothing with these props, so there is nothing to compare';
|
|
3
|
+
/**
|
|
4
|
+
* Whether the React reference rendered nothing: its resting shot is one flat colour or its component box is empty.
|
|
5
|
+
* It is read from React's own shots, never from a target's diagnostics, so every target gets the same answer (a target
|
|
6
|
+
* that failed to render, or has no comparison, cannot turn it into a verdict of its own).
|
|
7
|
+
*/
|
|
8
|
+
export function reactRendersNothing(result) {
|
|
9
|
+
const idle = result.shots.find((s) => s.framework === 'react' && s.state === 'idle');
|
|
10
|
+
return !!idle && (idle.variance === 0 || idle.box.width === 0 || idle.box.height === 0);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The reason a verify result cannot score its targets at all, or null when it can. With no React reference nothing is
|
|
14
|
+
* compared: a target is `unmeasured`, never `same`. (A blank target against a React render that has content is a
|
|
15
|
+
* different case and still scores 0 in verify: it is a failure, not an absence of a reference.)
|
|
16
|
+
*/
|
|
17
|
+
export function unmeasuredReason(result) {
|
|
18
|
+
return reactRendersNothing(result) ? REACT_BLANK_REASON : null;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,120 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antheo/morph",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Compile animated React UI components to Vue 3, Svelte 5, Angular and React Native, and verify the web output pixel by pixel in a sandboxed browser.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/antheo-design/morph.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/antheo-design/morph#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/antheo-design/morph/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"bin": {
|
|
16
|
+
"antheo-morph": "dist/cli.js"
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"!dist/browser",
|
|
29
|
+
"!dist/browser.js",
|
|
30
|
+
"!dist/browser.d.ts",
|
|
31
|
+
"!dist/**/*.map",
|
|
32
|
+
"README.md",
|
|
33
|
+
"SKILL.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json",
|
|
44
|
+
"test": "node scripts/clean-test-build.mjs && tsc -p tsconfig.test.json && node scripts/run-tests.mjs",
|
|
45
|
+
"test:site": "node scripts/clean-test-build.mjs && tsc -p tsconfig.test.json && node scripts/run-tests.mjs --site-only",
|
|
46
|
+
"corpus": "npm run build && node dist/cli.js batch ../../src/components --corpus scripts/corpus-dirs.json --out .corpus-out --report .corpus-out/corpus-report.json --summary corpus-summary.json",
|
|
47
|
+
"benchmark": "npm run build && node scripts/benchmark.mjs",
|
|
48
|
+
"check:pack": "node scripts/check-pack.mjs"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"react",
|
|
52
|
+
"vue",
|
|
53
|
+
"svelte",
|
|
54
|
+
"angular",
|
|
55
|
+
"react-native",
|
|
56
|
+
"compiler",
|
|
57
|
+
"framer-motion",
|
|
58
|
+
"tailwind",
|
|
59
|
+
"visual-regression"
|
|
60
|
+
],
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@babel/generator": "^7.29.16",
|
|
63
|
+
"@babel/parser": "^7.29.15",
|
|
64
|
+
"@babel/traverse": "^7.29.16",
|
|
65
|
+
"@babel/types": "^7.29.15",
|
|
66
|
+
"@internationalized/date": "^3.12.4",
|
|
67
|
+
"@lucide/svelte": "^1.84.0",
|
|
68
|
+
"@lucide/vue": "^1.84.0",
|
|
69
|
+
"@volar/typescript": "2.4.30",
|
|
70
|
+
"@vue/compiler-sfc": "^3.5.46",
|
|
71
|
+
"@vue/language-core": "3.3.14",
|
|
72
|
+
"bits-ui": "^2.22.0",
|
|
73
|
+
"clsx": "^2.1.1",
|
|
74
|
+
"esbuild": "^0.28.2",
|
|
75
|
+
"framer-motion": "^14.14.0",
|
|
76
|
+
"lucide-react": "^1.84.0",
|
|
77
|
+
"motion": "^14.14.0",
|
|
78
|
+
"motion-v": "^2.13.0",
|
|
79
|
+
"pixelmatch": "^8.0.0",
|
|
80
|
+
"pngjs": "^7.0.0",
|
|
81
|
+
"prettier": "^3.10.1",
|
|
82
|
+
"react": "^19.3.1",
|
|
83
|
+
"react-dom": "^19.3.1",
|
|
84
|
+
"reka-ui": "^2.12.0",
|
|
85
|
+
"svelte": "^5.59.2",
|
|
86
|
+
"svelte2tsx": "0.7.63",
|
|
87
|
+
"tailwind-merge": "^3.7.1",
|
|
88
|
+
"tailwindcss": "^4.3.5",
|
|
89
|
+
"tslib": "^2.9.1",
|
|
90
|
+
"typescript": "~6.0.3",
|
|
91
|
+
"vue": "^3.5.46"
|
|
92
|
+
},
|
|
93
|
+
"optionalDependencies": {
|
|
94
|
+
"@angular/common": "~22.2.6",
|
|
95
|
+
"@angular/compiler": "~22.2.6",
|
|
96
|
+
"@angular/compiler-cli": "~22.2.6",
|
|
97
|
+
"@angular/core": "~22.2.6",
|
|
98
|
+
"@angular/forms": "~22.2.6",
|
|
99
|
+
"@angular/platform-browser": "~22.2.6",
|
|
100
|
+
"@babel/core": "^8.0.1",
|
|
101
|
+
"@internationalized/number": "^3.6.10",
|
|
102
|
+
"@lucide/angular": "^1.84.0",
|
|
103
|
+
"@radix-ng/primitives": "^1.4.2",
|
|
104
|
+
"playwright-core": "^1.65.1",
|
|
105
|
+
"rxjs": "^7.8.2"
|
|
106
|
+
},
|
|
107
|
+
"devDependencies": {
|
|
108
|
+
"@types/babel__generator": "^7.27.0",
|
|
109
|
+
"@types/babel__traverse": "^7.28.0",
|
|
110
|
+
"@types/node": "^26.6.11",
|
|
111
|
+
"@types/pngjs": "^6.0.5",
|
|
112
|
+
"@types/react": "^19.3.3",
|
|
113
|
+
"@types/react-dom": "^19.3.0",
|
|
114
|
+
"class-variance-authority": "^0.7.1",
|
|
115
|
+
"next": "16.3.3",
|
|
116
|
+
"radix-ui": "^1.8.1",
|
|
117
|
+
"react-resizable-panels": "^4.27.0",
|
|
118
|
+
"vaul": "^1.1.2"
|
|
119
|
+
}
|
|
120
|
+
}
|