@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,40 @@
|
|
|
1
|
+
import type { Browser, BrowserContext, Page } from 'playwright-core';
|
|
2
|
+
export interface SandboxServer {
|
|
3
|
+
origin: string;
|
|
4
|
+
close: () => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
/** Serves one folder on 127.0.0.1 at an ephemeral port, refusing anything outside it; registered for cleanup. */
|
|
7
|
+
/**
|
|
8
|
+
* Serves the page files from `root`; with `assets`, a path not found there is looked up in that folder too (a site's
|
|
9
|
+
* public files, so `/photos/1.jpg` loads as it does on the site). Both stay on the sandbox's own origin and are checked
|
|
10
|
+
* with the same path rules.
|
|
11
|
+
*/
|
|
12
|
+
export declare function startServer(root: string, assets?: string | null): Promise<SandboxServer>;
|
|
13
|
+
export interface SandboxBrowser {
|
|
14
|
+
browser: Browser;
|
|
15
|
+
/** the browser's OS process id, for leak checks */
|
|
16
|
+
pid: number | null;
|
|
17
|
+
close: () => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* X6 (determinism): with GPU rasterization, Chrome's raster of photos in 3D-transformed layers differed between runs of
|
|
21
|
+
* the same page with the same DOM and styles (measured on carousels/variants/turntable.tsx: React's own idle shot
|
|
22
|
+
* differed from run to run by 64,657 to 131,566 pixels, every card's transform string identical). Rasterizing on the CPU
|
|
23
|
+
* gave the same pixels in every run. One flag; nothing compared changes.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DETERMINISTIC_RASTER: string[];
|
|
26
|
+
/** Headless Chrome (the installed one unless a path is given), registered so it is killed however the run ends. */
|
|
27
|
+
export declare function launchBrowser(executablePath?: string): Promise<SandboxBrowser>;
|
|
28
|
+
export interface SandboxPage {
|
|
29
|
+
page: Page;
|
|
30
|
+
context: BrowserContext;
|
|
31
|
+
/** every request the sandbox refused */
|
|
32
|
+
blocked: string[];
|
|
33
|
+
errors: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A page that can only talk to the sandbox origin: every other request (and every WebSocket) is aborted, service
|
|
37
|
+
* workers are blocked, and the virtual clock is installed before any page script runs. `probe`, when given, is
|
|
38
|
+
* installed right after the clock (so it sees the virtual timers), still before any page script.
|
|
39
|
+
*/
|
|
40
|
+
export declare function newSandboxPage(browser: Browser, origin: string, width: number, height: number, timeoutMs: number, probe?: string): Promise<SandboxPage>;
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
3
|
+
import { extname } from 'node:path';
|
|
4
|
+
import { cleanup } from '../utils/cleanup.js';
|
|
5
|
+
import { isInside, resolveInside } from '../utils/fs-safe.js';
|
|
6
|
+
/** The CSP every sandbox page is served with: only its own origin, no network connections at all. */
|
|
7
|
+
const SANDBOX_CSP = "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'none'; frame-src 'none'; object-src 'none'; worker-src 'none'; base-uri 'none'; form-action 'none'";
|
|
8
|
+
const TYPES = {
|
|
9
|
+
'.html': 'text/html; charset=utf-8',
|
|
10
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
11
|
+
'.css': 'text/css; charset=utf-8',
|
|
12
|
+
'.png': 'image/png',
|
|
13
|
+
'.svg': 'image/svg+xml',
|
|
14
|
+
'.json': 'application/json',
|
|
15
|
+
};
|
|
16
|
+
/** Serves one folder on 127.0.0.1 at an ephemeral port, refusing anything outside it; registered for cleanup. */
|
|
17
|
+
/**
|
|
18
|
+
* Serves the page files from `root`; with `assets`, a path not found there is looked up in that folder too (a site's
|
|
19
|
+
* public files, so `/photos/1.jpg` loads as it does on the site). Both stay on the sandbox's own origin and are checked
|
|
20
|
+
* with the same path rules.
|
|
21
|
+
*/
|
|
22
|
+
export async function startServer(root, assets = null) {
|
|
23
|
+
const server = createServer((req, res) => {
|
|
24
|
+
const url = new URL(req.url ?? '/', 'http://127.0.0.1');
|
|
25
|
+
let pathname;
|
|
26
|
+
try {
|
|
27
|
+
pathname = decodeURIComponent(url.pathname);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// malformed percent-encoding (e.g. /%E0%A4%A): a bad request, not a crash
|
|
31
|
+
res.writeHead(400).end();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const rel = pathname.replace(/^\/+/, '') || 'index.html';
|
|
35
|
+
if (!isInside(root, rel)) {
|
|
36
|
+
res.writeHead(403).end();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let file = resolveInside(root, rel);
|
|
40
|
+
if ((!existsSync(file) || !statSync(file).isFile()) && assets && isInside(assets, rel))
|
|
41
|
+
file = resolveInside(assets, rel);
|
|
42
|
+
if (!existsSync(file) || !statSync(file).isFile()) {
|
|
43
|
+
res.writeHead(404).end();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
res.writeHead(200, {
|
|
47
|
+
'Content-Type': TYPES[extname(file)] ?? 'application/octet-stream',
|
|
48
|
+
'Content-Security-Policy': SANDBOX_CSP,
|
|
49
|
+
'Cache-Control': 'no-store',
|
|
50
|
+
'X-Content-Type-Options': 'nosniff',
|
|
51
|
+
});
|
|
52
|
+
res.end(readFileSync(file));
|
|
53
|
+
});
|
|
54
|
+
await new Promise((resolve, reject) => {
|
|
55
|
+
server.once('error', reject);
|
|
56
|
+
server.listen(0, '127.0.0.1', () => resolve());
|
|
57
|
+
});
|
|
58
|
+
const port = server.address().port;
|
|
59
|
+
const shut = () => new Promise((resolve) => {
|
|
60
|
+
server.closeAllConnections();
|
|
61
|
+
server.close(() => resolve());
|
|
62
|
+
});
|
|
63
|
+
const dispose = cleanup.add(`server :${port}`, shut, () => {
|
|
64
|
+
server.closeAllConnections();
|
|
65
|
+
server.close();
|
|
66
|
+
});
|
|
67
|
+
return { origin: `http://127.0.0.1:${port}`, close: dispose };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Playwright drives Chrome for `verify` only, so it is an optional dependency: converting never needs it, and a missing
|
|
71
|
+
* install says what to add.
|
|
72
|
+
*/
|
|
73
|
+
async function loadChromium() {
|
|
74
|
+
try {
|
|
75
|
+
return (await import('playwright-core')).chromium;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
throw new Error('verify needs the optional dependency playwright-core (npm install playwright-core) and an installed Chrome.');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* X6 (determinism): with GPU rasterization, Chrome's raster of photos in 3D-transformed layers differed between runs of
|
|
83
|
+
* the same page with the same DOM and styles (measured on carousels/variants/turntable.tsx: React's own idle shot
|
|
84
|
+
* differed from run to run by 64,657 to 131,566 pixels, every card's transform string identical). Rasterizing on the CPU
|
|
85
|
+
* gave the same pixels in every run. One flag; nothing compared changes.
|
|
86
|
+
*/
|
|
87
|
+
export const DETERMINISTIC_RASTER = ['--disable-gpu-rasterization'];
|
|
88
|
+
/** Headless Chrome (the installed one unless a path is given), registered so it is killed however the run ends. */
|
|
89
|
+
export async function launchBrowser(executablePath) {
|
|
90
|
+
const launchOptions = {
|
|
91
|
+
headless: true,
|
|
92
|
+
// the cleanup registry owns SIGINT/SIGTERM: Playwright's own handlers would exit before our cleanup finishes
|
|
93
|
+
handleSIGINT: false,
|
|
94
|
+
handleSIGTERM: false,
|
|
95
|
+
handleSIGHUP: false,
|
|
96
|
+
args: ['--disable-gpu-sandbox', '--no-first-run', '--no-default-browser-check', '--disable-extensions', '--disable-background-networking', '--disable-sync', '--force-device-scale-factor=1', '--hide-scrollbars', '--font-render-hinting=none', ...DETERMINISTIC_RASTER],
|
|
97
|
+
...(executablePath ? { executablePath } : { channel: 'chrome' }),
|
|
98
|
+
};
|
|
99
|
+
const chromium = await loadChromium();
|
|
100
|
+
const server = await chromium.launchServer(launchOptions);
|
|
101
|
+
const proc = server.process();
|
|
102
|
+
const kill = () => {
|
|
103
|
+
try {
|
|
104
|
+
proc.kill('SIGKILL');
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// already gone
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
let browser;
|
|
112
|
+
try {
|
|
113
|
+
browser = await chromium.connect(server.wsEndpoint());
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
await server.close().catch(kill);
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
const dispose = cleanup.add(`browser ${proc.pid ?? '?'}`, async () => {
|
|
120
|
+
await browser.close().catch(() => undefined);
|
|
121
|
+
// close normally; if that hangs (a renderer stuck in a loop), kill the process
|
|
122
|
+
await Promise.race([server.close(), new Promise((resolve) => setTimeout(resolve, 3000))]);
|
|
123
|
+
if (proc.exitCode === null && proc.signalCode === null)
|
|
124
|
+
kill();
|
|
125
|
+
}, kill);
|
|
126
|
+
return { browser, pid: proc.pid ?? null, close: dispose };
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A page that can only talk to the sandbox origin: every other request (and every WebSocket) is aborted, service
|
|
130
|
+
* workers are blocked, and the virtual clock is installed before any page script runs. `probe`, when given, is
|
|
131
|
+
* installed right after the clock (so it sees the virtual timers), still before any page script.
|
|
132
|
+
*/
|
|
133
|
+
export async function newSandboxPage(browser, origin, width, height, timeoutMs, probe) {
|
|
134
|
+
const context = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: 1, serviceWorkers: 'block', reducedMotion: 'no-preference', colorScheme: 'light', locale: 'en-US', timezoneId: 'UTC' });
|
|
135
|
+
const blocked = [];
|
|
136
|
+
const errors = [];
|
|
137
|
+
await context.route('**/*', async (route) => {
|
|
138
|
+
const url = route.request().url();
|
|
139
|
+
if (url === origin || url.startsWith(`${origin}/`))
|
|
140
|
+
await route.continue();
|
|
141
|
+
else {
|
|
142
|
+
blocked.push(url);
|
|
143
|
+
await route.abort('blockedbyclient');
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
await context.routeWebSocket(/.*/, (ws) => {
|
|
147
|
+
blocked.push(ws.url());
|
|
148
|
+
void ws.close();
|
|
149
|
+
});
|
|
150
|
+
await context.addInitScript({ content: CLOCK_SCRIPT });
|
|
151
|
+
await context.addInitScript({ content: NAVIGATION_GUARD });
|
|
152
|
+
if (probe)
|
|
153
|
+
await context.addInitScript({ content: probe });
|
|
154
|
+
const page = await context.newPage();
|
|
155
|
+
page.setDefaultTimeout(timeoutMs);
|
|
156
|
+
page.setDefaultNavigationTimeout(timeoutMs);
|
|
157
|
+
page.on('pageerror', (e) => errors.push(e.message));
|
|
158
|
+
page.on('console', (m) => {
|
|
159
|
+
if (m.type() === 'error')
|
|
160
|
+
errors.push(m.text());
|
|
161
|
+
});
|
|
162
|
+
return { page, context, blocked, errors };
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The page never leaves itself: a link, a form, `location.href = …` or a reload that would load another document is
|
|
166
|
+
* cancelled through the Navigation API's `navigate` event, which fires after the click (or the code) that started it
|
|
167
|
+
* has run in full, so every handler still runs and nothing is prevented on the event itself. Same-document navigations
|
|
168
|
+
* (a hash change, `history.pushState`) pass. Navigations Playwright starts itself (`page.goto`) are not page-initiated,
|
|
169
|
+
* fire no cancelable event, and still meet the route guard.
|
|
170
|
+
*/
|
|
171
|
+
const NAVIGATION_GUARD = `(() => {
|
|
172
|
+
const nav = window.navigation;
|
|
173
|
+
if (!nav || typeof nav.addEventListener !== 'function') return;
|
|
174
|
+
nav.addEventListener('navigate', (event) => {
|
|
175
|
+
if (event.destination && event.destination.sameDocument) return;
|
|
176
|
+
if (event.cancelable) event.preventDefault();
|
|
177
|
+
});
|
|
178
|
+
})();`;
|
|
179
|
+
/**
|
|
180
|
+
* A steppable virtual clock, installed before page scripts: performance.now, Date, timers and requestAnimationFrame
|
|
181
|
+
* follow `window.__morphClock.advance(ms)` in 16 ms frames, and every CSS transition, CSS animation and Web Animation
|
|
182
|
+
* is paused and seeked to the same virtual time. React, Vue and Svelte renders therefore land on the same frame, while
|
|
183
|
+
* hovers and presses still animate when time is stepped.
|
|
184
|
+
*/
|
|
185
|
+
const CLOCK_SCRIPT = `(() => {
|
|
186
|
+
const realTimeout = window.setTimeout.bind(window);
|
|
187
|
+
const realRaf = window.requestAnimationFrame.bind(window);
|
|
188
|
+
const BASE = 1700000000000;
|
|
189
|
+
let now = 0;
|
|
190
|
+
let nextId = 1;
|
|
191
|
+
const timers = new Map();
|
|
192
|
+
const frames = new Map();
|
|
193
|
+
const started = new WeakMap();
|
|
194
|
+
const RealDate = Date;
|
|
195
|
+
performance.now = () => now;
|
|
196
|
+
class VirtualDate extends RealDate {
|
|
197
|
+
constructor(...args) { if (args.length === 0) super(BASE + now); else super(...args); }
|
|
198
|
+
static now() { return BASE + now; }
|
|
199
|
+
}
|
|
200
|
+
window.Date = VirtualDate;
|
|
201
|
+
window.setTimeout = (fn, ms = 0, ...args) => { const id = nextId++; timers.set(id, { at: now + Math.max(0, Number(ms) || 0), fn, args, every: null }); return id; };
|
|
202
|
+
window.setInterval = (fn, ms = 0, ...args) => { const id = nextId++; const every = Math.max(1, Number(ms) || 0); timers.set(id, { at: now + every, fn, args, every }); return id; };
|
|
203
|
+
window.clearTimeout = (id) => { timers.delete(id); };
|
|
204
|
+
window.clearInterval = (id) => { timers.delete(id); };
|
|
205
|
+
window.requestAnimationFrame = (cb) => { const id = nextId++; frames.set(id, cb); return id; };
|
|
206
|
+
window.cancelAnimationFrame = (id) => { frames.delete(id); };
|
|
207
|
+
// X6 (determinism): the other clocks a page can read are put on the virtual one too.
|
|
208
|
+
// An event's timeStamp is on performance.now's scale: it reads the virtual time when it is first read (input that
|
|
209
|
+
// arrives between two steps is at the time of the step before it), the same value every later read.
|
|
210
|
+
const stamps = new WeakMap();
|
|
211
|
+
Object.defineProperty(Event.prototype, 'timeStamp', { configurable: true, get() { if (!stamps.has(this)) stamps.set(this, now); return stamps.get(this); } });
|
|
212
|
+
// document.timeline is the clock Web Animations run on (sync below seeks each one); code that reads it reads virtual time
|
|
213
|
+
if (window.AnimationTimeline) Object.defineProperty(AnimationTimeline.prototype, 'currentTime', { configurable: true, get() { return now; } });
|
|
214
|
+
// the page's time origin is the virtual epoch Date counts from, not the real moment the page loaded
|
|
215
|
+
Object.defineProperty(performance, 'timeOrigin', { configurable: true, get() { return BASE; } });
|
|
216
|
+
// idle callbacks run on the virtual clock (a real idle period comes when the machine allows, not at a set frame)
|
|
217
|
+
window.requestIdleCallback = (cb, opts) => window.setTimeout(() => cb({ didTimeout: false, timeRemaining: () => 50 }), 1);
|
|
218
|
+
window.cancelIdleCallback = (id) => window.clearTimeout(id);
|
|
219
|
+
// X6: random numbers are seeded, the same seed on every page (mulberry32 from RANDOM_SEED): Math.random,
|
|
220
|
+
// crypto.getRandomValues and crypto.randomUUID. This makes each page's own sequence repeatable from run to run, and
|
|
221
|
+
// makes two pages draw the same values only when they ask for random numbers in the same order, which a faithful
|
|
222
|
+
// conversion does; one that asks in another order still draws other values, and verify shows it.
|
|
223
|
+
const RANDOM_SEED = 0x9e3779b9;
|
|
224
|
+
let seed = RANDOM_SEED >>> 0;
|
|
225
|
+
const nextRandom = () => {
|
|
226
|
+
seed = (seed + 0x6d2b79f5) >>> 0;
|
|
227
|
+
let t = seed;
|
|
228
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
229
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
230
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
231
|
+
};
|
|
232
|
+
Math.random = nextRandom;
|
|
233
|
+
// X6: the entry calls this right before it mounts the component (verify/bundle.ts), after the page's imports ran: a
|
|
234
|
+
// framework that draws random numbers when it loads (react-dom draws its internal keys) would otherwise have shifted
|
|
235
|
+
// the sequence, so each framework's component code would start from a different value. Not covered: a framework that
|
|
236
|
+
// draws during mount or render still shifts its page (measured: see tests/visual/sandbox-clock.test.ts and the report).
|
|
237
|
+
window.__morphReseed = () => { seed = RANDOM_SEED >>> 0; };
|
|
238
|
+
if (window.crypto) {
|
|
239
|
+
const fill = function (array) {
|
|
240
|
+
const bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
241
|
+
for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(nextRandom() * 256);
|
|
242
|
+
return array;
|
|
243
|
+
};
|
|
244
|
+
Object.defineProperty(Crypto.prototype, 'getRandomValues', { configurable: true, writable: true, value: fill });
|
|
245
|
+
Object.defineProperty(Crypto.prototype, 'randomUUID', {
|
|
246
|
+
configurable: true,
|
|
247
|
+
writable: true,
|
|
248
|
+
value: function () {
|
|
249
|
+
const b = fill(new Uint8Array(16));
|
|
250
|
+
b[6] = (b[6] & 0x0f) | 0x40;
|
|
251
|
+
b[8] = (b[8] & 0x3f) | 0x80;
|
|
252
|
+
const h = [...b].map((x) => x.toString(16).padStart(2, '0')).join('');
|
|
253
|
+
return h.slice(0, 8) + '-' + h.slice(8, 12) + '-' + h.slice(12, 16) + '-' + h.slice(16, 20) + '-' + h.slice(20);
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
// An image arrives when the network and decoder are done, in real time: its load or error event would reach the page
|
|
258
|
+
// at whatever virtual frame is current then. Each image's events are held and handed over at the next step, after
|
|
259
|
+
// the step has waited (real time, at most IMAGE_WAIT ms) for every image still loading, so the page meets its images at
|
|
260
|
+
// the same virtual frame every run.
|
|
261
|
+
const IMAGE_WAIT = 3000;
|
|
262
|
+
const pendingImages = new Map();
|
|
263
|
+
const heldImages = [];
|
|
264
|
+
const watched = new WeakSet();
|
|
265
|
+
const watchImage = (img) => {
|
|
266
|
+
pendingImages.set(img, Date.prototype.getTime.call(new RealDate()));
|
|
267
|
+
if (watched.has(img)) return;
|
|
268
|
+
watched.add(img);
|
|
269
|
+
const hold = (e) => {
|
|
270
|
+
if (!e.isTrusted) return;
|
|
271
|
+
e.stopImmediatePropagation();
|
|
272
|
+
pendingImages.delete(img);
|
|
273
|
+
heldImages.push([img, e.type]);
|
|
274
|
+
};
|
|
275
|
+
img.addEventListener('load', hold, true);
|
|
276
|
+
img.addEventListener('error', hold, true);
|
|
277
|
+
};
|
|
278
|
+
const srcDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, 'src');
|
|
279
|
+
const srcsetDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, 'srcset');
|
|
280
|
+
for (const [name, desc] of [['src', srcDesc], ['srcset', srcsetDesc]]) {
|
|
281
|
+
if (!desc || !desc.set) continue;
|
|
282
|
+
Object.defineProperty(HTMLImageElement.prototype, name, { configurable: true, enumerable: desc.enumerable, get: desc.get, set(v) { watchImage(this); desc.set.call(this, v); } });
|
|
283
|
+
}
|
|
284
|
+
const realSetAttribute = Element.prototype.setAttribute;
|
|
285
|
+
Element.prototype.setAttribute = function (name, value) {
|
|
286
|
+
if (this instanceof HTMLImageElement && (String(name).toLowerCase() === 'src' || String(name).toLowerCase() === 'srcset')) watchImage(this);
|
|
287
|
+
return realSetAttribute.call(this, name, value);
|
|
288
|
+
};
|
|
289
|
+
// A CSS background image (url(...) in a style) is fetched and decoded in real time too, and painted on whatever frame
|
|
290
|
+
// it is ready: every element whose style or class changes, or that is added, is looked at on the next step, each new
|
|
291
|
+
// url is decoded (real time, at most IMAGE_WAIT ms) and a real frame is let pass to paint it, before time moves.
|
|
292
|
+
const touched = new Set();
|
|
293
|
+
const decodes = new Map();
|
|
294
|
+
// An image whose source arrives by HTML parsing (innerHTML, a cloned <template>, insertAdjacentHTML), setAttributeNS
|
|
295
|
+
// or a <picture> <source> never meets the property and setAttribute paths above: the observer below watches it when
|
|
296
|
+
// it is added or its source attributes change. The observer's callback is a microtask, run at the end of the task
|
|
297
|
+
// that added the image, and an image's load or error event is always a later task, so the hold is in place before the
|
|
298
|
+
// event (tests/visual/sandbox-clock.test.ts proves the three ways give the same virtual time). An image already
|
|
299
|
+
// complete when first seen (loaded before, or served from memory at once) is not held.
|
|
300
|
+
const IMAGE_ATTRS = ['src', 'srcset', 'sizes', 'href', 'xlink:href'];
|
|
301
|
+
const watchFromDom = (el) => {
|
|
302
|
+
if (el instanceof HTMLImageElement) {
|
|
303
|
+
if ((el.getAttribute('src') || el.getAttribute('srcset')) && !el.complete) watchImage(el);
|
|
304
|
+
} else if (window.SVGImageElement && el instanceof SVGImageElement) {
|
|
305
|
+
if (!watched.has(el) && (el.getAttribute('href') || el.getAttribute('xlink:href'))) watchImage(el);
|
|
306
|
+
} else if (el instanceof HTMLSourceElement && el.parentElement instanceof HTMLPictureElement) {
|
|
307
|
+
const img = el.parentElement.querySelector('img');
|
|
308
|
+
if (img && !img.complete) watchImage(img);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
const notice = (node) => {
|
|
312
|
+
if (!node || node.nodeType !== 1) return;
|
|
313
|
+
touched.add(node);
|
|
314
|
+
watchFromDom(node);
|
|
315
|
+
for (const el of node.querySelectorAll('*')) { touched.add(el); watchFromDom(el); }
|
|
316
|
+
};
|
|
317
|
+
new MutationObserver((records) => {
|
|
318
|
+
for (const r of records) {
|
|
319
|
+
if (r.type === 'attributes') {
|
|
320
|
+
touched.add(r.target);
|
|
321
|
+
if (IMAGE_ATTRS.includes(r.attributeName)) watchFromDom(r.target);
|
|
322
|
+
} else for (const n of r.addedNodes) notice(n);
|
|
323
|
+
}
|
|
324
|
+
}).observe(document, { subtree: true, childList: true, attributes: true, attributeFilter: ['style', 'class', ...IMAGE_ATTRS] });
|
|
325
|
+
const urlsIn = (v) => {
|
|
326
|
+
const out = [];
|
|
327
|
+
const re = /url\\(\\s*(?:"([^"]*)"|'([^']*)'|([^)"']*))\\s*\\)/g;
|
|
328
|
+
let m;
|
|
329
|
+
while ((m = re.exec(v))) out.push(m[1] ?? m[2] ?? m[3] ?? '');
|
|
330
|
+
return out;
|
|
331
|
+
};
|
|
332
|
+
const settleBackgrounds = async () => {
|
|
333
|
+
const waits = [];
|
|
334
|
+
for (const el of touched) {
|
|
335
|
+
if (!el.isConnected) continue;
|
|
336
|
+
const v = getComputedStyle(el).backgroundImage;
|
|
337
|
+
if (!v || v.indexOf('url(') < 0) continue;
|
|
338
|
+
for (const u of urlsIn(v)) {
|
|
339
|
+
if (!u || decodes.has(u)) continue;
|
|
340
|
+
const img = document.createElement('img');
|
|
341
|
+
const done = { ready: false };
|
|
342
|
+
decodes.set(u, done);
|
|
343
|
+
srcDesc.set.call(img, u);
|
|
344
|
+
waits.push(img.decode().then(() => undefined, () => undefined).then(() => { done.ready = true; }));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
touched.clear();
|
|
348
|
+
if (!waits.length) return;
|
|
349
|
+
await Promise.race([Promise.all(waits), new Promise((resolve) => realTimeout(resolve, IMAGE_WAIT))]);
|
|
350
|
+
// the decoded image is painted on the next real frames
|
|
351
|
+
await new Promise((resolve) => realRaf(() => resolve()));
|
|
352
|
+
await new Promise((resolve) => realRaf(() => resolve()));
|
|
353
|
+
};
|
|
354
|
+
const settleImages = async () => {
|
|
355
|
+
for (;;) {
|
|
356
|
+
const nowReal = Date.prototype.getTime.call(new RealDate());
|
|
357
|
+
// an image leaves the wait when its event is held (above), or after IMAGE_WAIT (one that never loads: lazy, offscreen)
|
|
358
|
+
for (const [img, since] of pendingImages) if (nowReal - since > IMAGE_WAIT) pendingImages.delete(img);
|
|
359
|
+
if (!pendingImages.size) break;
|
|
360
|
+
await new Promise((resolve) => realTimeout(resolve, 5));
|
|
361
|
+
}
|
|
362
|
+
// a complete image's event may still be queued: one real turn lets it reach the hold
|
|
363
|
+
await new Promise((resolve) => realTimeout(resolve, 0));
|
|
364
|
+
for (const [img, type] of heldImages.splice(0)) run(() => img.dispatchEvent(new Event(type)), []);
|
|
365
|
+
};
|
|
366
|
+
// An animation whose virtual time has reached its end is finished, not held paused past it: its finish handlers run as
|
|
367
|
+
// they would in a browser (Svelte removes an element after its out: transition, motion commits its final style and
|
|
368
|
+
// cancels), so an exit completes on the virtual clock instead of never.
|
|
369
|
+
const sync = () => {
|
|
370
|
+
for (const a of document.getAnimations()) {
|
|
371
|
+
if (!started.has(a)) started.set(a, now);
|
|
372
|
+
const t = now - started.get(a);
|
|
373
|
+
try {
|
|
374
|
+
const end = a.effect ? a.effect.getComputedTiming().endTime : Infinity;
|
|
375
|
+
if (a.playState !== 'finished' && a.playbackRate > 0 && Number.isFinite(end) && t >= end) {
|
|
376
|
+
if (a.playState === 'paused') a.play();
|
|
377
|
+
a.finish();
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (a.playState === 'finished') continue;
|
|
381
|
+
a.pause(); a.currentTime = t;
|
|
382
|
+
} catch (e) { /* a finished, detached animation */ }
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
// Observers report on virtual steps too: their real callbacks come on real frames, which arrive at a different virtual
|
|
386
|
+
// time under load, so a component that waits to be on screen (or sized) would start a different number of frames in.
|
|
387
|
+
const observers = new Set();
|
|
388
|
+
const rectOf = (el) => el.getBoundingClientRect();
|
|
389
|
+
const visible = (r) => r.width > 0 && r.height > 0 && r.bottom > 0 && r.right > 0 && r.top < innerHeight && r.left < innerWidth;
|
|
390
|
+
const contentSize = (el) => {
|
|
391
|
+
const cs = getComputedStyle(el);
|
|
392
|
+
const w = Math.max(0, el.clientWidth - parseFloat(cs.paddingLeft) - parseFloat(cs.paddingRight));
|
|
393
|
+
const h = Math.max(0, el.clientHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom));
|
|
394
|
+
return { w, h };
|
|
395
|
+
};
|
|
396
|
+
class VirtualIntersectionObserver {
|
|
397
|
+
constructor(cb, options) { this.cb = cb; this.options = options || {}; this.root = this.options.root || null; this.rootMargin = this.options.rootMargin || '0px'; this.thresholds = [].concat(this.options.threshold ?? 0); this.seen = new Map(); observers.add(this); }
|
|
398
|
+
observe(el) { if (!this.seen.has(el)) this.seen.set(el, null); }
|
|
399
|
+
unobserve(el) { this.seen.delete(el); }
|
|
400
|
+
disconnect() { this.seen.clear(); observers.delete(this); }
|
|
401
|
+
takeRecords() { return []; }
|
|
402
|
+
check() {
|
|
403
|
+
const entries = [];
|
|
404
|
+
for (const [el, was] of this.seen) {
|
|
405
|
+
const r = rectOf(el);
|
|
406
|
+
const is = visible(r);
|
|
407
|
+
if (was === is) continue;
|
|
408
|
+
this.seen.set(el, is);
|
|
409
|
+
entries.push({ target: el, isIntersecting: is, intersectionRatio: is ? 1 : 0, boundingClientRect: r, intersectionRect: is ? r : new DOMRect(), rootBounds: new DOMRect(0, 0, innerWidth, innerHeight), time: now });
|
|
410
|
+
}
|
|
411
|
+
if (entries.length) run(this.cb, [entries, this]);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
class VirtualResizeObserver {
|
|
415
|
+
constructor(cb) { this.cb = cb; this.seen = new Map(); observers.add(this); }
|
|
416
|
+
observe(el) { if (!this.seen.has(el)) this.seen.set(el, null); }
|
|
417
|
+
unobserve(el) { this.seen.delete(el); }
|
|
418
|
+
disconnect() { this.seen.clear(); observers.delete(this); }
|
|
419
|
+
check() {
|
|
420
|
+
const entries = [];
|
|
421
|
+
for (const [el, was] of this.seen) {
|
|
422
|
+
const { w, h } = contentSize(el);
|
|
423
|
+
if (was && was.w === w && was.h === h) continue;
|
|
424
|
+
this.seen.set(el, { w, h });
|
|
425
|
+
const r = rectOf(el);
|
|
426
|
+
entries.push({ target: el, contentRect: new DOMRect(0, 0, w, h), borderBoxSize: [{ inlineSize: r.width, blockSize: r.height }], contentBoxSize: [{ inlineSize: w, blockSize: h }], devicePixelContentBoxSize: [{ inlineSize: w * devicePixelRatio, blockSize: h * devicePixelRatio }] });
|
|
427
|
+
}
|
|
428
|
+
if (entries.length) run(this.cb, [entries, this]);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
window.IntersectionObserver = VirtualIntersectionObserver;
|
|
432
|
+
window.ResizeObserver = VirtualResizeObserver;
|
|
433
|
+
// Shaders compiled in parallel finish on the GPU's own time; code that waits for them would start its animation a
|
|
434
|
+
// real-time-dependent number of frames in. Without the extension a program is ready when linked, the same every run.
|
|
435
|
+
for (const Ctx of [window.WebGLRenderingContext, window.WebGL2RenderingContext]) {
|
|
436
|
+
if (!Ctx) continue;
|
|
437
|
+
const getExtension = Ctx.prototype.getExtension;
|
|
438
|
+
const getSupported = Ctx.prototype.getSupportedExtensions;
|
|
439
|
+
Ctx.prototype.getExtension = function (name) { return name === 'KHR_parallel_shader_compile' ? null : getExtension.call(this, name); };
|
|
440
|
+
Ctx.prototype.getSupportedExtensions = function () { return (getSupported.call(this) || []).filter((n) => n !== 'KHR_parallel_shader_compile'); };
|
|
441
|
+
}
|
|
442
|
+
const run = (fn, args) => { try { if (typeof fn === 'function') fn(...args); } catch (e) { setTimeoutReport(e); } };
|
|
443
|
+
const setTimeoutReport = (e) => realTimeout(() => { throw e; }, 0);
|
|
444
|
+
const step = async (dt) => {
|
|
445
|
+
// X6: images still loading are waited for, and their held events handed over, before time moves
|
|
446
|
+
if (pendingImages.size || heldImages.length) await settleImages();
|
|
447
|
+
now += dt;
|
|
448
|
+
for (const o of [...observers]) o.check();
|
|
449
|
+
for (;;) {
|
|
450
|
+
let due = null;
|
|
451
|
+
for (const [id, t] of timers) if (t.at <= now && (!due || t.at < due[1].at)) due = [id, t];
|
|
452
|
+
if (!due) break;
|
|
453
|
+
const [id, t] = due;
|
|
454
|
+
if (t.every) t.at += t.every; else timers.delete(id);
|
|
455
|
+
run(t.fn, t.args);
|
|
456
|
+
}
|
|
457
|
+
const batch = [...frames.entries()];
|
|
458
|
+
frames.clear();
|
|
459
|
+
for (const [, cb] of batch) run(cb, [now]);
|
|
460
|
+
// X6: background images the page now shows are decoded and painted before the frame counts
|
|
461
|
+
if (touched.size) await settleBackgrounds();
|
|
462
|
+
await new Promise((resolve) => realRaf(() => resolve()));
|
|
463
|
+
sync();
|
|
464
|
+
await new Promise((resolve) => realTimeout(resolve, 0));
|
|
465
|
+
};
|
|
466
|
+
window.__morphClock = {
|
|
467
|
+
async advance(ms) {
|
|
468
|
+
let left = ms;
|
|
469
|
+
if (left <= 0) { await step(0); return now; }
|
|
470
|
+
while (left > 0) { const dt = Math.min(16, left); await step(dt); left -= dt; }
|
|
471
|
+
return now;
|
|
472
|
+
},
|
|
473
|
+
// Jumps ms ahead firing only the timers due on the way, in order, each at its own time, and no frames: the unmount
|
|
474
|
+
// check uses it to see whether a timeout re-arms without stepping seconds frame by frame. A few microtask turns
|
|
475
|
+
// after each callback let a promise-based re-arm happen in its place.
|
|
476
|
+
async elapse(ms) {
|
|
477
|
+
const end = now + Math.max(0, ms);
|
|
478
|
+
for (let fired = 0; fired < 100000; fired++) {
|
|
479
|
+
let due = null;
|
|
480
|
+
for (const [id, t] of timers) if (t.at <= end && (!due || t.at < due[1].at)) due = [id, t];
|
|
481
|
+
if (!due) break;
|
|
482
|
+
const [id, t] = due;
|
|
483
|
+
now = Math.max(now, t.at);
|
|
484
|
+
if (t.every) t.at += t.every; else timers.delete(id);
|
|
485
|
+
run(t.fn, t.args);
|
|
486
|
+
await null; await null; await null;
|
|
487
|
+
}
|
|
488
|
+
now = end;
|
|
489
|
+
await new Promise((resolve) => realRaf(() => resolve()));
|
|
490
|
+
sync();
|
|
491
|
+
await new Promise((resolve) => realTimeout(resolve, 0));
|
|
492
|
+
return now;
|
|
493
|
+
},
|
|
494
|
+
now: () => now,
|
|
495
|
+
};
|
|
496
|
+
})();`;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Locator, Page } from 'playwright-core';
|
|
2
|
+
import { type StepLocator, type StepStateMismatch, type VerifyStep } from '../types.js';
|
|
3
|
+
/** The longest virtual wait one step may ask for, ms: stepping virtual time costs about as much real time. */
|
|
4
|
+
export declare 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 declare 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 declare const MAX_DRAG_MOVES = 30;
|
|
9
|
+
export declare const MAX_DRAG_PX = 2000;
|
|
10
|
+
/** A step that could not be carried out on a page: its target matched nothing there, or the action itself failed. */
|
|
11
|
+
export declare class StepError extends Error {
|
|
12
|
+
readonly kind: 'missing' | 'failed';
|
|
13
|
+
constructor(kind: 'missing' | 'failed', message: string);
|
|
14
|
+
}
|
|
15
|
+
export declare function describeLocator(loc: StepLocator): string;
|
|
16
|
+
/**
|
|
17
|
+
* Checks a script before anything renders (it may come from JSON): every step is named, uniquely, has an action it can
|
|
18
|
+
* carry out and the target and text or key that action needs, and waits a finite virtual time under the cap.
|
|
19
|
+
*/
|
|
20
|
+
export declare function checkSteps(steps: VerifyStep[]): void;
|
|
21
|
+
/** Every element a locator matches on a page, searched the way a step searches (exported for auto-steps' confirmation). */
|
|
22
|
+
export declare function locate(page: Page, loc: StepLocator): Locator;
|
|
23
|
+
/** Carries out one step's action on a page (not its wait or its shot). A failure is a StepError; a stopped run rethrows. */
|
|
24
|
+
export declare function performStep(page: Page, step: VerifyStep, alive: () => void): Promise<void>;
|
|
25
|
+
/** One fact per line: `[fact, value]`, in document order. */
|
|
26
|
+
export type StepFacts = [string, string][];
|
|
27
|
+
/**
|
|
28
|
+
* The framework-neutral DOM state of the component after a step: each element's ARIA and `data-state` state, form
|
|
29
|
+
* values and checked states, disabled controls, and what has focus, each keyed by the element's role and accessible
|
|
30
|
+
* name (its `aria-label`, `aria-labelledby` text, `<label>` text, placeholder, or rendered text content), over the
|
|
31
|
+
* page's whole body so portalled content counts. Generated ids and classes never appear, so React and every target
|
|
32
|
+
* describe the same element the same way.
|
|
33
|
+
*/
|
|
34
|
+
export declare function collectFacts(page: Page, alive: () => void): Promise<StepFacts>;
|
|
35
|
+
/**
|
|
36
|
+
* The facts that differ between React and a target. Facts are matched by their key with whitespace taken out (one
|
|
37
|
+
* framework keeps a space between a label and a count where another does not, which no pixel shows); values must be
|
|
38
|
+
* equal exactly.
|
|
39
|
+
*/
|
|
40
|
+
export declare function diffFacts(react: StepFacts, actual: StepFacts): StepStateMismatch[];
|
|
41
|
+
/** One line for a diagnostic: `aria-checked of switch "Email notifications" is "true" (React: "false")`. */
|
|
42
|
+
export declare function describeMismatches(list: StepStateMismatch[]): string;
|