@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,548 @@
|
|
|
1
|
+
import { readFileSync, existsSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { Worker } from 'node:worker_threads';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { context, stop, transform } from 'esbuild';
|
|
7
|
+
import { parse as parseSfc, compileScript, compileStyle, compileTemplate } from '@vue/compiler-sfc';
|
|
8
|
+
import { compile as compileSvelte, compileModule as compileSvelteModule } from 'svelte/compiler';
|
|
9
|
+
import { compile as compileTailwind } from 'tailwindcss';
|
|
10
|
+
import { applyAlias, resolveLocal } from '../analyzer/deps.js';
|
|
11
|
+
import { nextFontObject } from '../targets/shared/module.js';
|
|
12
|
+
import { googleFontShim, localFontShim } from '../fonts/shim.js';
|
|
13
|
+
import { googleCarriedAt } from '../fonts/google.js';
|
|
14
|
+
import { isDomEventProp } from '../ir/dom.js';
|
|
15
|
+
import { VUE_PROP_RENAMES } from '../targets/vue/emit.js';
|
|
16
|
+
/** The package's own folder: every npm import in a sandbox bundle resolves from its node_modules, offline. */
|
|
17
|
+
const MORPH_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
18
|
+
const require = createRequire(join(MORPH_ROOT, 'package.json'));
|
|
19
|
+
/** The frameworks' own packages (and the runtimes their output imports): one copy, morph's, for every bundle. */
|
|
20
|
+
const FRAMEWORK_PACKAGES = /^(react|react-dom|scheduler|framer-motion|motion|motion-v|vue|@vue\/[^/]+|svelte|@angular\/[^/]+|rxjs|tslib|zone\.js)(\/|$)/;
|
|
21
|
+
/**
|
|
22
|
+
* Bare package imports. The frameworks' own resolve from morph's node_modules, so React, Vue, Svelte and Angular bundles
|
|
23
|
+
* share exact versions. Any other package (`class-variance-authority`, a project's own `cn`) resolves from the source
|
|
24
|
+
* project first, as its code does there: a target's files are written to a temporary folder, away from the project's
|
|
25
|
+
* node_modules. Then from morph's copy (the icon packages a conversion maps to). Only the build reads these files.
|
|
26
|
+
*/
|
|
27
|
+
function packagesPlugin(projectRoot) {
|
|
28
|
+
return {
|
|
29
|
+
name: 'morph-packages',
|
|
30
|
+
setup(b) {
|
|
31
|
+
b.onResolve({ filter: /^[^./\0][^:]*$/ }, async (args) => {
|
|
32
|
+
if (args.namespace === 'morph-virtual' || args.pluginData === 'morph-packages')
|
|
33
|
+
return undefined;
|
|
34
|
+
// a package's own imports resolve beside that package, as Node resolves them (framer-motion must load the
|
|
35
|
+
// motion-dom it was installed with); only a framework package is still morph's one copy from anywhere, so a
|
|
36
|
+
// project's library and the page share one React
|
|
37
|
+
if (/[\\/]node_modules[\\/]/.test(args.importer) && !FRAMEWORK_PACKAGES.test(args.path))
|
|
38
|
+
return undefined;
|
|
39
|
+
const roots = FRAMEWORK_PACKAGES.test(args.path) ? [MORPH_ROOT] : [projectRoot, MORPH_ROOT];
|
|
40
|
+
for (const resolveDir of roots) {
|
|
41
|
+
// esbuild's own resolver (browser export conditions), rooted at that folder's node_modules chain
|
|
42
|
+
const result = await b.resolve(args.path, { resolveDir, kind: args.kind, pluginData: 'morph-packages' });
|
|
43
|
+
if (!result.errors.length)
|
|
44
|
+
return { path: result.path, ...(result.external ? { external: true } : {}) };
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Path aliases of the project (tsconfig paths), and the Next.js modules a component may import. */
|
|
52
|
+
function projectPlugin(project, nextFonts, fonts = false) {
|
|
53
|
+
return {
|
|
54
|
+
name: 'morph-project',
|
|
55
|
+
setup(b) {
|
|
56
|
+
const escape = (p) => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
57
|
+
// prefix keys match the start of an import, exact keys the whole of it
|
|
58
|
+
const patterns = [...Object.keys(project.aliases).map(escape), ...Object.keys(project.exact).map((p) => `${escape(p)}$`)];
|
|
59
|
+
if (patterns.length) {
|
|
60
|
+
b.onResolve({ filter: new RegExp(`^(${patterns.join('|')})`) }, (args) => {
|
|
61
|
+
if (!applyAlias(args.path, project))
|
|
62
|
+
return undefined;
|
|
63
|
+
const resolved = resolveLocal(args.importer || join(project.root, 'index.ts'), args.path, project);
|
|
64
|
+
return resolved ? { path: resolved } : undefined;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// F5 (src/fonts): next/font/local answers for the file that imports it, so the React page loads the very font file
|
|
68
|
+
// (same bytes, faces and class) the converted output carries, as Next.js serves it; a call not carried gets the
|
|
69
|
+
// same fallback object the converted output then has
|
|
70
|
+
b.onResolve({ filter: /^next\/font\/local$/ }, (args) => (args.importer ? { path: `next/font/local?${args.importer}`, namespace: 'morph-font', pluginData: args.importer } : undefined));
|
|
71
|
+
b.onLoad({ filter: /.*/, namespace: 'morph-font' }, (args) => {
|
|
72
|
+
const local = nextFontObject('');
|
|
73
|
+
const fallback = { className: local.className, style: { fontFamily: local.family }, variable: '' };
|
|
74
|
+
return { contents: typeof args.pluginData === 'string' ? localFontShim(args.pluginData, project.root, fallback) : `export default () => (${JSON.stringify(fallback)});`, loader: 'js' };
|
|
75
|
+
});
|
|
76
|
+
// X6 (src/fonts/google.ts): only under the fonts option, next/font/google answers for the file that imports it
|
|
77
|
+
// with the very Google files the conversion downloaded and carries; any call not carried gets the same fallback
|
|
78
|
+
// object the converted output then has. Without the option this is not registered: nothing changes.
|
|
79
|
+
const google = fonts ? googleCarriedAt(project.root) : undefined;
|
|
80
|
+
if (google) {
|
|
81
|
+
b.onResolve({ filter: /^next\/font\/google$/ }, (args) => (args.importer ? { path: `next/font/google?${args.importer}`, namespace: 'morph-google-font', pluginData: args.importer } : undefined));
|
|
82
|
+
b.onLoad({ filter: /.*/, namespace: 'morph-google-font' }, (args) => {
|
|
83
|
+
const fallbackOf = (loader) => {
|
|
84
|
+
const font = nextFontObject(loader);
|
|
85
|
+
return { className: font.className, style: { fontFamily: font.family }, variable: '' };
|
|
86
|
+
};
|
|
87
|
+
return { contents: googleFontShim(typeof args.pluginData === 'string' ? args.pluginData : '', google, fallbackOf), loader: 'js' };
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
b.onResolve({ filter: /^next\/(font\/(google|local)|image|link)$/ }, (args) => ({ path: args.path, namespace: 'morph-virtual' }));
|
|
91
|
+
b.onLoad({ filter: /.*/, namespace: 'morph-virtual' }, (args) => {
|
|
92
|
+
if (args.path.startsWith('next/font/')) {
|
|
93
|
+
const exports = nextFonts.map((name) => {
|
|
94
|
+
const font = nextFontObject(name);
|
|
95
|
+
return `export const ${name} = () => (${JSON.stringify({ className: font.className, style: { fontFamily: font.family }, variable: '' })});`;
|
|
96
|
+
});
|
|
97
|
+
const local = nextFontObject('');
|
|
98
|
+
return { contents: `${exports.join('\n')}\nexport default () => (${JSON.stringify({ className: local.className, style: { fontFamily: local.family }, variable: '' })});`, loader: 'js' };
|
|
99
|
+
}
|
|
100
|
+
if (args.path === 'next/image') {
|
|
101
|
+
return {
|
|
102
|
+
contents: `import { createElement } from 'react';\nexport default function Image({ src, alt, width, height, priority, quality, placeholder, blurDataURL, loader, unoptimized, fill, sizes, ...rest }) { return createElement('img', { src: typeof src === 'string' ? src : src && src.src, alt, width, height, ...rest }); }`,
|
|
103
|
+
loader: 'js',
|
|
104
|
+
resolveDir: MORPH_ROOT,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
contents: `import { createElement } from 'react';\nexport default function Link({ href, prefetch, replace, scroll, shallow, passHref, legacyBehavior, ...rest }) { return createElement('a', { href: typeof href === 'string' ? href : href && href.pathname, ...rest }); }`,
|
|
109
|
+
loader: 'js',
|
|
110
|
+
resolveDir: MORPH_ROOT,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** The Angular linker and Babel are optional dependencies: a missing install says what to add. */
|
|
117
|
+
const MISSING_ANGULAR_TOOLING = 'verify of Angular output needs the optional dependencies @babel/core and @angular/compiler-cli (npm install them).';
|
|
118
|
+
/** Angular libraries after the Angular linker, by path: linking @angular/core takes a few seconds, once. */
|
|
119
|
+
const linked = new Map();
|
|
120
|
+
/** The paths whose link is done (a bundle that reads one waits for nothing). */
|
|
121
|
+
const linkedDone = new Set();
|
|
122
|
+
/** The thread the Angular linker runs on (link-worker.ts), started on the first link, and the links it owes. */
|
|
123
|
+
let linkThread = null;
|
|
124
|
+
const linkJobs = new Map();
|
|
125
|
+
let nextLinkJob = 0;
|
|
126
|
+
/**
|
|
127
|
+
* Links one Angular library file on the linker's own thread. Babel and the linker are synchronous: linking a large
|
|
128
|
+
* library (`@lucide/angular`, one 10 MB file) on this thread held it for over 30 s on a cold start, and with it the
|
|
129
|
+
* sandbox's file server and the page clocks of any verify run sharing the process, whose pages then timed out. The
|
|
130
|
+
* thread is held open only while links are owed, so it never keeps the process alive.
|
|
131
|
+
*/
|
|
132
|
+
function linkOffThread(path, source) {
|
|
133
|
+
if (!linkThread) {
|
|
134
|
+
const thread = new Worker(new URL('./link-worker.js', import.meta.url));
|
|
135
|
+
thread.on('message', (reply) => {
|
|
136
|
+
const job = linkJobs.get(reply.id);
|
|
137
|
+
if (!job)
|
|
138
|
+
return;
|
|
139
|
+
linkJobs.delete(reply.id);
|
|
140
|
+
if (!linkJobs.size)
|
|
141
|
+
thread.unref();
|
|
142
|
+
if (reply.code !== undefined)
|
|
143
|
+
job.resolve(reply.code);
|
|
144
|
+
else
|
|
145
|
+
job.reject(new Error(reply.missing ? MISSING_ANGULAR_TOOLING : `the Angular linker failed on ${job.path}: ${reply.error ?? 'no reason given'}`));
|
|
146
|
+
});
|
|
147
|
+
// a thread that dies fails every link it owes; the next link starts a new one
|
|
148
|
+
const fail = (error) => {
|
|
149
|
+
if (linkThread === thread)
|
|
150
|
+
linkThread = null;
|
|
151
|
+
for (const job of linkJobs.values())
|
|
152
|
+
job.reject(error);
|
|
153
|
+
linkJobs.clear();
|
|
154
|
+
};
|
|
155
|
+
thread.on('error', fail);
|
|
156
|
+
thread.on('exit', (code) => fail(new Error(`the Angular linker's thread stopped (exit code ${code})`)));
|
|
157
|
+
linkThread = thread;
|
|
158
|
+
}
|
|
159
|
+
const thread = linkThread;
|
|
160
|
+
const id = nextLinkJob++;
|
|
161
|
+
return new Promise((resolve, reject) => {
|
|
162
|
+
linkJobs.set(id, { path, resolve, reject });
|
|
163
|
+
thread.ref();
|
|
164
|
+
thread.postMessage({ id, path, source });
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/** Whether a package folder holds an Angular library, by package folder: `@angular/*`, or one that names `@angular/core`. */
|
|
168
|
+
const angularPackages = new Map();
|
|
169
|
+
/**
|
|
170
|
+
* Whether the file at `path` (inside `node_modules`) belongs to an Angular library: a package named `@angular/…`, or
|
|
171
|
+
* one whose own package.json names `@angular/core` as a peer or a dependency (the libraries the Angular linker must
|
|
172
|
+
* finish: `@lucide/angular`, `@radix-ng/primitives`, …). Read once per package.
|
|
173
|
+
*/
|
|
174
|
+
function inAngularPackage(path) {
|
|
175
|
+
const parts = path.split(/[\\/]/);
|
|
176
|
+
const at = parts.lastIndexOf('node_modules');
|
|
177
|
+
if (at < 0 || at + 1 >= parts.length)
|
|
178
|
+
return false;
|
|
179
|
+
const depth = parts[at + 1]?.startsWith('@') ? 2 : 1;
|
|
180
|
+
const root = parts.slice(0, at + 1 + depth).join('/');
|
|
181
|
+
let known = angularPackages.get(root);
|
|
182
|
+
if (known === undefined) {
|
|
183
|
+
known = false;
|
|
184
|
+
const manifest = join(root, 'package.json');
|
|
185
|
+
if (existsSync(manifest)) {
|
|
186
|
+
const pkg = JSON.parse(readFileSync(manifest, 'utf8'));
|
|
187
|
+
if (typeof pkg === 'object' && pkg !== null) {
|
|
188
|
+
const name = 'name' in pkg ? pkg.name : undefined;
|
|
189
|
+
const lists = ['peerDependencies' in pkg ? pkg.peerDependencies : undefined, 'dependencies' in pkg ? pkg.dependencies : undefined];
|
|
190
|
+
known = (typeof name === 'string' && name.startsWith('@angular/')) || lists.some((l) => typeof l === 'object' && l !== null && '@angular/core' in l);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
angularPackages.set(root, known);
|
|
194
|
+
}
|
|
195
|
+
return known;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Angular libraries ship partially compiled (`ɵɵngDeclare…`); the Angular CLI finishes them with the Angular linker at
|
|
199
|
+
* build time, and so does this bundle, with the linker's own Babel plugin, for every package that is an Angular
|
|
200
|
+
* library (see inAngularPackage) and whose file declares something.
|
|
201
|
+
*/
|
|
202
|
+
function angularLinkerPlugin(oneTimeWork) {
|
|
203
|
+
// the loads of this build waiting on links not yet done (overlapping waits are one wait)
|
|
204
|
+
let waiting = 0;
|
|
205
|
+
return {
|
|
206
|
+
name: 'morph-angular-linker',
|
|
207
|
+
setup(b) {
|
|
208
|
+
b.onLoad({ filter: /[\\/]node_modules[\\/].*\.m?js$/ }, async (args) => {
|
|
209
|
+
if (!inAngularPackage(args.path))
|
|
210
|
+
return undefined;
|
|
211
|
+
const source = readFileSync(args.path, 'utf8');
|
|
212
|
+
if (!source.includes('ɵɵngDeclare'))
|
|
213
|
+
return undefined;
|
|
214
|
+
let job = linked.get(args.path);
|
|
215
|
+
if (!job) {
|
|
216
|
+
job = linkOffThread(args.path, source);
|
|
217
|
+
// a failed link is not kept: the next bundle tries again
|
|
218
|
+
job.catch(() => linked.delete(args.path));
|
|
219
|
+
job.then(() => linkedDone.add(args.path), () => undefined);
|
|
220
|
+
linked.set(args.path, job);
|
|
221
|
+
}
|
|
222
|
+
if (linkedDone.has(args.path))
|
|
223
|
+
return { contents: await job, loader: 'js', resolveDir: dirname(args.path) };
|
|
224
|
+
if (waiting++ === 0)
|
|
225
|
+
oneTimeWork?.('start');
|
|
226
|
+
try {
|
|
227
|
+
return { contents: await job, loader: 'js', resolveDir: dirname(args.path) };
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
if (--waiting === 0)
|
|
231
|
+
oneTimeWork?.('end');
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** .vue files through the real @vue/compiler-sfc (script setup with the template inlined, <style> blocks as CSS). */
|
|
238
|
+
function vuePlugin() {
|
|
239
|
+
return {
|
|
240
|
+
name: 'morph-vue',
|
|
241
|
+
setup(b) {
|
|
242
|
+
b.onResolve({ filter: /\?vue-style$/ }, (args) => ({ path: args.path, namespace: 'morph-vue-style' }));
|
|
243
|
+
b.onLoad({ filter: /.*/, namespace: 'morph-vue-style' }, (args) => {
|
|
244
|
+
const file = args.path.replace(/\?vue-style$/, '');
|
|
245
|
+
const { descriptor } = parseSfc(readFileSync(file, 'utf8'), { filename: file });
|
|
246
|
+
const css = descriptor.styles.map((s) => compileStyle({ source: s.content, filename: file, id: 'data-v-morph', scoped: false }).code).join('\n');
|
|
247
|
+
return { contents: css, loader: 'css', resolveDir: dirname(file) };
|
|
248
|
+
});
|
|
249
|
+
b.onLoad({ filter: /\.vue$/ }, (args) => {
|
|
250
|
+
const source = readFileSync(args.path, 'utf8');
|
|
251
|
+
const { descriptor, errors } = parseSfc(source, { filename: args.path });
|
|
252
|
+
if (errors.length)
|
|
253
|
+
return { errors: errors.map((e) => ({ text: e.message })) };
|
|
254
|
+
const id = 'm' + Math.abs([...args.path].reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 7)).toString(16);
|
|
255
|
+
const style = descriptor.styles.length ? `import ${JSON.stringify(`${args.path}?vue-style`)};\n` : '';
|
|
256
|
+
if (!descriptor.script && !descriptor.scriptSetup) {
|
|
257
|
+
// a file with only a <template>: compileScript needs a script, so the template is compiled to its render
|
|
258
|
+
// function and the component is that function alone
|
|
259
|
+
if (!descriptor.template)
|
|
260
|
+
return { errors: [{ text: `${args.path}: the file has neither a script nor a template` }] };
|
|
261
|
+
const template = compileTemplate({ source: descriptor.template.content, filename: args.path, id });
|
|
262
|
+
if (template.errors.length)
|
|
263
|
+
return { errors: template.errors.map((e) => ({ text: typeof e === 'string' ? e : e.message })) };
|
|
264
|
+
return { contents: `${style}${template.code}\nexport default { render };\n`, loader: 'js', resolveDir: dirname(args.path) };
|
|
265
|
+
}
|
|
266
|
+
const script = compileScript(descriptor, {
|
|
267
|
+
id,
|
|
268
|
+
inlineTemplate: true,
|
|
269
|
+
fs: { fileExists: (f) => existsSync(f), readFile: (f) => (existsSync(f) ? readFileSync(f, 'utf8') : undefined) },
|
|
270
|
+
});
|
|
271
|
+
return { contents: style + script.content, loader: 'ts', resolveDir: dirname(args.path) };
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* A turn of the event loop before a file's synchronous work. esbuild hands a plugin its loads in batches, and a library
|
|
278
|
+
* of many .svelte files (`@lucide/svelte`, one file per icon) read and compiled back to back held this thread for over
|
|
279
|
+
* 10 s on a cold start: the sandbox's file server, which runs on it, then answered no page of a verify run sharing the
|
|
280
|
+
* process, and that page timed out. One file per turn lets the server and the page clocks run between files: the turns
|
|
281
|
+
* are queued, as immediates queued together would all run in the same turn.
|
|
282
|
+
*/
|
|
283
|
+
let turns = Promise.resolve();
|
|
284
|
+
const turn = () => (turns = turns.then(() => new Promise((resolve) => setImmediate(resolve))));
|
|
285
|
+
/** .svelte files and .svelte.ts rune modules through the real svelte/compiler (runes mode). */
|
|
286
|
+
function sveltePlugin() {
|
|
287
|
+
return {
|
|
288
|
+
name: 'morph-svelte',
|
|
289
|
+
setup(b) {
|
|
290
|
+
b.onResolve({ filter: /\.svelte\.js$/ }, (args) => {
|
|
291
|
+
const ts = resolve(args.resolveDir, args.path.replace(/\.js$/, '.ts'));
|
|
292
|
+
return existsSync(ts) ? { path: ts } : undefined;
|
|
293
|
+
});
|
|
294
|
+
b.onLoad({ filter: /\.svelte$/ }, async (args) => {
|
|
295
|
+
await turn();
|
|
296
|
+
const source = readFileSync(args.path, 'utf8');
|
|
297
|
+
const result = compileSvelte(source, { filename: args.path, runes: true, generate: 'client', css: 'injected', dev: false });
|
|
298
|
+
return { contents: result.js.code, loader: 'js', resolveDir: dirname(args.path) };
|
|
299
|
+
});
|
|
300
|
+
b.onLoad({ filter: /\.svelte\.ts$/ }, async (args) => {
|
|
301
|
+
const ts = await transform(readFileSync(args.path, 'utf8'), { loader: 'ts', format: 'esm', target: 'es2022' });
|
|
302
|
+
const result = compileSvelteModule(ts.code, { filename: args.path.replace(/\.ts$/, '.js'), generate: 'client', dev: false });
|
|
303
|
+
return { contents: result.js.code, loader: 'js', resolveDir: dirname(args.path) };
|
|
304
|
+
});
|
|
305
|
+
// a library's rune module shipped as JavaScript (bits-ui, runed, svelte-toolbelt: `$derived` in a `.svelte.js`),
|
|
306
|
+
// compiled as Svelte's own build compiles it
|
|
307
|
+
b.onLoad({ filter: /\.svelte\.js$/ }, async (args) => {
|
|
308
|
+
await turn();
|
|
309
|
+
const result = compileSvelteModule(readFileSync(args.path, 'utf8'), { filename: args.path, generate: 'client', dev: false });
|
|
310
|
+
return { contents: result.js.code, loader: 'js', resolveDir: dirname(args.path) };
|
|
311
|
+
});
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* The props as the framework's component declares them. The emitters rename a few React props to the target's own
|
|
317
|
+
* spelling, and a prop passed under React's name would miss: Vue declares `className` as `class` (the Vue emitter's
|
|
318
|
+
* VUE_PROP_RENAMES), Svelte declares `className` as `class` and DOM event props in lower case (`onClick` as `onclick`,
|
|
319
|
+
* the Svelte emitter's props keys). React keeps its own names, and so does Angular, whose inputs keep React's names.
|
|
320
|
+
*/
|
|
321
|
+
export function propsFor(framework, props) {
|
|
322
|
+
if (framework === 'react' || framework === 'angular')
|
|
323
|
+
return props;
|
|
324
|
+
const rename = (key) => {
|
|
325
|
+
if (framework === 'vue')
|
|
326
|
+
return VUE_PROP_RENAMES.get(key) ?? key;
|
|
327
|
+
return key === 'className' ? 'class' : isDomEventProp(key) ? key.toLowerCase() : key;
|
|
328
|
+
};
|
|
329
|
+
return Object.fromEntries(Object.entries(props).map(([key, value]) => [rename(key), value]));
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* The Angular page script: a host element inside #root, as React renders inside it, inputs set by their React prop
|
|
333
|
+
* names. Text children reach the component the way a parent template would write them: bound to the `children` input
|
|
334
|
+
* when the component declares one (`<x [children]="'…'">`, read from Angular's own metadata), projected as content
|
|
335
|
+
* otherwise (`<x>…</x>`).
|
|
336
|
+
*
|
|
337
|
+
* After the first `detectChanges()` the page runs the application's tick, as a real bootstrap's first tick does:
|
|
338
|
+
* `detectChanges()` runs no after-render hooks, so a component's `afterNextRender` code (the converted `useEffect`)
|
|
339
|
+
* would wait for the scheduler's next tick, one frame later, while the React page's flushSync runs its effects at once.
|
|
340
|
+
* Measured on beams.tsx (a WebGL animation whose clock starts at mount): React's first draw at virtual t=0.0,
|
|
341
|
+
* Angular's at t=16.0 before this tick and t=0.0 with it. The tick re-checks only views still dirty and runs each
|
|
342
|
+
* after-render callback once.
|
|
343
|
+
*/
|
|
344
|
+
export function angularEntry(req) {
|
|
345
|
+
const props = JSON.stringify(propsFor(req.framework, req.props));
|
|
346
|
+
const children = req.children === null ? null : JSON.stringify(req.children);
|
|
347
|
+
const probe = req.probe ? `${req.probe}\n` : '';
|
|
348
|
+
const file = JSON.stringify(req.file);
|
|
349
|
+
// Angular's own unmount: destroy the component, then the application (its injector and everything registered on it)
|
|
350
|
+
const unmount = req.unmount ? ` window.__morphUnmount = () => { ref.destroy(); app.destroy(); };\n` : '';
|
|
351
|
+
// (M5: a component selected on its root element (`button[uiSegment]`, the Angular host form) is mounted on an element
|
|
352
|
+
// of that tag, as its callers write it; any other on a div, as before)
|
|
353
|
+
const core = 'createComponent, provideZonelessChangeDetection, reflectComponentType';
|
|
354
|
+
const text = children
|
|
355
|
+
? ` const children = ${children};\n const takesChildren = reflectComponentType(C)?.inputs.some((input) => input.templateName === 'children') ?? false;\n`
|
|
356
|
+
: '';
|
|
357
|
+
const projected = children ? `takesChildren ? [] : [[document.createTextNode(children)]]` : '[]';
|
|
358
|
+
const inputs = children ? `{ ...${props}, ...(takesChildren ? { children } : {}) }` : props;
|
|
359
|
+
return `${probe}import { ${core} } from '@angular/core';\nimport { createApplication } from '@angular/platform-browser';\nimport * as M from ${file};\nconst C = M[${JSON.stringify(req.exportName)}] ?? M.default;\n(async () => {\n const app = await createApplication({ providers: [provideZonelessChangeDetection()] });\n const host = document.createElement(/^([a-z][a-z0-9]*)\\[/.exec(reflectComponentType(C)?.selector ?? '')?.[1] ?? 'div');\n document.getElementById('root').appendChild(host);\n${text} ${RESEED} const ref = createComponent(C, { environmentInjector: app.injector, hostElement: host, projectableNodes: ${projected} });\n for (const [key, value] of Object.entries(${inputs})) {\n // a prop the component does not take as an input: reported (verify collects console errors as page errors), and the render goes on\n try { ref.setInput(key, value); } catch (error) { console.error('morph: the ' + key + ' input could not be set: ' + (error instanceof Error ? error.message : String(error))); }\n }\n app.attachView(ref.hostView);\n ref.changeDetectorRef.detectChanges();\n app.tick();\n${unmount} window.__morphReady = true;\n})();\n`;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* X6: every entry reseeds the page's random numbers (sandbox.ts's clock script) right before it mounts the component,
|
|
363
|
+
* after the page's imports have run: a framework runtime that draws random numbers when it loads (react-dom's
|
|
364
|
+
* internal keys) no longer shifts the sequence the component's own code draws from, and every page's component starts
|
|
365
|
+
* from the same value. A framework that draws during mount or render would still shift its page.
|
|
366
|
+
*/
|
|
367
|
+
const RESEED = 'window.__morphReseed?.();\n';
|
|
368
|
+
function entrySource(req) {
|
|
369
|
+
const props = JSON.stringify(propsFor(req.framework, req.props));
|
|
370
|
+
const children = req.children === null ? null : JSON.stringify(req.children);
|
|
371
|
+
const probe = req.probe ? `${req.probe}\n` : '';
|
|
372
|
+
const file = JSON.stringify(req.file);
|
|
373
|
+
const ready = `window.__morphReady = true;`;
|
|
374
|
+
// each framework's own unmount: React root.unmount(), Vue app.unmount(), Svelte unmount(), Angular destroys the
|
|
375
|
+
// component and then the application (its injector and everything registered on it)
|
|
376
|
+
const unmount = (body) => (req.unmount ? `window.__morphUnmount = ${body};\n` : '');
|
|
377
|
+
const reseed = RESEED;
|
|
378
|
+
if (req.framework === 'react') {
|
|
379
|
+
return {
|
|
380
|
+
contents: `${probe}import { createElement } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { flushSync } from 'react-dom';\nimport * as M from ${file};\nconst C = M[${JSON.stringify(req.exportName)}] ?? M.default;\nconst root = createRoot(document.getElementById('root'));\n${reseed}flushSync(() => root.render(${children ? `createElement(C, ${props}, ${children})` : `createElement(C, ${props})`}));\n${unmount('() => { root.unmount(); }')}${ready}`,
|
|
381
|
+
loader: 'js',
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
if (req.framework === 'angular')
|
|
385
|
+
return { contents: angularEntry(req), loader: 'js' };
|
|
386
|
+
if (req.framework === 'vue') {
|
|
387
|
+
const app = `createApp({ render: () => h(C, ${props}${children ? `, { default: () => ${children} }` : ''}) })`;
|
|
388
|
+
return {
|
|
389
|
+
contents: req.unmount
|
|
390
|
+
? `${probe}import { createApp, h } from 'vue';\nimport C from ${file};\nconst app = ${app};\n${reseed}app.mount('#root');\n${unmount('() => { app.unmount(); }')}${ready}`
|
|
391
|
+
: `${probe}import { createApp, h } from 'vue';\nimport C from ${file};\n${reseed}${app}.mount('#root');\n${ready}`,
|
|
392
|
+
loader: 'js',
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
if (req.unmount) {
|
|
396
|
+
return { contents: `${probe}import { mount, unmount, flushSync } from 'svelte';\nimport Root from './__root.svelte';\n${RESEED}const app = mount(Root, { target: document.getElementById('root') });\nflushSync();\n${unmount('async () => { await unmount(app); flushSync(); }')}${ready}`, loader: 'js' };
|
|
397
|
+
}
|
|
398
|
+
return { contents: `${probe}import { mount, flushSync } from 'svelte';\nimport Root from './__root.svelte';\n${RESEED}mount(Root, { target: document.getElementById('root') });\nflushSync();\n${ready}`, loader: 'js' };
|
|
399
|
+
}
|
|
400
|
+
/** Svelte children are a snippet: a tiny root component passes the text the way a Svelte parent would. */
|
|
401
|
+
function svelteRoot(req) {
|
|
402
|
+
const escaped = (req.children ?? '').replace(/[&<>{}]/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
403
|
+
return `<script>\n import C from ${JSON.stringify(req.file)};\n const props = ${JSON.stringify(propsFor(req.framework, req.props))};\n</script>\n${req.children === null ? '<C {...props} />' : `<C {...props}>${escaped}</C>`}\n`;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Bundles one framework's page script (and the CSS its files import) into `outDir`. With a `signal`, an abort cancels
|
|
407
|
+
* the build in flight and nothing is written after it: a stopped verify's folder is never recreated by a late build.
|
|
408
|
+
* Each bundle is its own esbuild context in the process's one esbuild service, so cancelling it touches no other run.
|
|
409
|
+
*/
|
|
410
|
+
export async function bundleEntry(req, signal) {
|
|
411
|
+
signal?.throwIfAborted();
|
|
412
|
+
const entry = entrySource(req);
|
|
413
|
+
const outfile = join(req.outDir, `${req.framework}.js`);
|
|
414
|
+
if (req.framework === 'svelte')
|
|
415
|
+
writeFileSync(join(req.outDir, '__root.svelte'), svelteRoot(req));
|
|
416
|
+
const ctx = await withService(() => context(bundleOptions(req, entry, outfile)));
|
|
417
|
+
const cancel = () => void ctx.cancel().catch(() => undefined);
|
|
418
|
+
signal?.addEventListener('abort', cancel, { once: true });
|
|
419
|
+
try {
|
|
420
|
+
signal?.throwIfAborted();
|
|
421
|
+
let outputs;
|
|
422
|
+
try {
|
|
423
|
+
outputs = (await ctx.rebuild()).outputFiles ?? [];
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
// a build cancelled by the abort fails with esbuild's own message: the abort is the reason
|
|
427
|
+
signal?.throwIfAborted();
|
|
428
|
+
throw error;
|
|
429
|
+
}
|
|
430
|
+
// checked and written with no await between: a stop cannot slip in after the check
|
|
431
|
+
signal?.throwIfAborted();
|
|
432
|
+
for (const f of outputs)
|
|
433
|
+
writeFileSync(f.path, f.contents);
|
|
434
|
+
}
|
|
435
|
+
finally {
|
|
436
|
+
signal?.removeEventListener('abort', cancel);
|
|
437
|
+
await ctx.dispose();
|
|
438
|
+
}
|
|
439
|
+
const css = outfile.replace(/\.js$/, '.css');
|
|
440
|
+
if (!existsSync(css))
|
|
441
|
+
return { js: outfile, css: null };
|
|
442
|
+
// a stylesheet that extends Tailwind's theme (`@theme inline { --color-primary: var(--primary) }`, as shadcn's does) is
|
|
443
|
+
// run through Tailwind with the bundle's class names: `bg-primary` then paints the theme's colour
|
|
444
|
+
const sheet = readFileSync(css, 'utf8');
|
|
445
|
+
if (/@theme\b/.test(sheet))
|
|
446
|
+
writeFileSync(css, await buildThemed(sheet, readFileSync(outfile, 'utf8')));
|
|
447
|
+
return { js: outfile, css };
|
|
448
|
+
}
|
|
449
|
+
/** A stylesheet with `@theme` blocks, compiled by Tailwind (its theme and utilities, no preflight) for a bundle's classes. */
|
|
450
|
+
async function buildThemed(sheet, code) {
|
|
451
|
+
const compiler = await compileTailwind(`@import "tailwindcss/theme.css" layer(theme);\n@import "tailwindcss/utilities.css" layer(utilities);\n${sheet.replace(/@import\s+["']tailwindcss[^;]*;/g, '')}`, {
|
|
452
|
+
base: MORPH_ROOT,
|
|
453
|
+
loadStylesheet: async (id, base) => {
|
|
454
|
+
const pkg = id.startsWith('tailwindcss/') ? require.resolve(id, { paths: [MORPH_ROOT] }) : resolve(base, id);
|
|
455
|
+
return { path: pkg, base: dirname(pkg), content: readFileSync(pkg, 'utf8') };
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
return compiler.build(candidates(code));
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* The stylesheets an Angular bundle's components name (`styleUrl`), as the other frameworks' bundles get theirs: the
|
|
462
|
+
* Angular compiler inlines each one as it is written into its component, so a `@theme` block in it (Tailwind's, which
|
|
463
|
+
* an Angular CLI build with Tailwind compiles) never meets Tailwind. Given their text in order, joined as esbuild joins
|
|
464
|
+
* the CSS a bundle imports, and the bundle's own code: the same Tailwind build the esbuild CSS gets (buildThemed), or
|
|
465
|
+
* null when no stylesheet holds `@theme` (then nothing changes).
|
|
466
|
+
*/
|
|
467
|
+
export async function themedAngularStyles(sheets, code) {
|
|
468
|
+
const sheet = sheets.join('\n');
|
|
469
|
+
return /@theme\b/.test(sheet) ? buildThemed(sheet, code) : null;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* esbuild runs one service process for the whole Node process, and if that process dies (killed, or out of memory when
|
|
473
|
+
* the machine runs out) every later call fails with "The service is no longer running": the service is never started
|
|
474
|
+
* again on its own. The first call that finds it dead stops the stale handle (`stop()` only resets it then: the child is
|
|
475
|
+
* already gone, so no other build is lost) and the call is made once more on a fresh service. A generation counter keeps
|
|
476
|
+
* two runs that find it dead at once from stopping each other's fresh service.
|
|
477
|
+
*/
|
|
478
|
+
let serviceGeneration = 0;
|
|
479
|
+
async function withService(call) {
|
|
480
|
+
const generation = serviceGeneration;
|
|
481
|
+
try {
|
|
482
|
+
return await call();
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
if (!/The service (is no longer running|was stopped)/.test(error instanceof Error ? error.message : String(error)))
|
|
486
|
+
throw error;
|
|
487
|
+
if (generation === serviceGeneration) {
|
|
488
|
+
serviceGeneration++;
|
|
489
|
+
await stop();
|
|
490
|
+
}
|
|
491
|
+
return call();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
function bundleOptions(req, entry, outfile) {
|
|
495
|
+
return {
|
|
496
|
+
stdin: { contents: entry.contents, loader: entry.loader, resolveDir: req.outDir, sourcefile: `${req.framework}-entry.js` },
|
|
497
|
+
bundle: true,
|
|
498
|
+
outfile,
|
|
499
|
+
format: 'iife',
|
|
500
|
+
platform: 'browser',
|
|
501
|
+
target: 'es2022',
|
|
502
|
+
jsx: 'automatic',
|
|
503
|
+
jsxImportSource: 'react',
|
|
504
|
+
minify: false,
|
|
505
|
+
sourcemap: false,
|
|
506
|
+
logLevel: 'silent',
|
|
507
|
+
// written by bundleEntry once it knows the run was not stopped
|
|
508
|
+
write: false,
|
|
509
|
+
define: { 'process.env.NODE_ENV': '"production"', __VUE_OPTIONS_API__: 'true', __VUE_PROD_DEVTOOLS__: 'false', __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false' },
|
|
510
|
+
loader: { '.png': 'dataurl', '.jpg': 'dataurl', '.svg': 'dataurl', '.woff2': 'dataurl', '.woff': 'dataurl' },
|
|
511
|
+
plugins: [projectPlugin(req.project, req.nextFonts, req.fonts === true), packagesPlugin(req.project.root), vuePlugin(), sveltePlugin(), ...(req.framework === 'angular' ? [angularLinkerPlugin(req.oneTimeWork)] : [])],
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
/** Class-name candidates in built code: Tailwind keeps the ones that are real utilities. */
|
|
515
|
+
export function candidates(code) {
|
|
516
|
+
const out = new Set();
|
|
517
|
+
for (const m of code.matchAll(/[^\s"'`<>{}=\\]+/g)) {
|
|
518
|
+
const c = m[0];
|
|
519
|
+
if (c.length < 200 && /[a-z]/.test(c))
|
|
520
|
+
out.add(c.replace(/[,;]+$/, ''));
|
|
521
|
+
}
|
|
522
|
+
// a class whose `=` (and quotes) sit inside an arbitrary value or variant (`data-[state=open]:animate-in`,
|
|
523
|
+
// `data-[state="open"]:…`, `[&[data-state=open]>svg]:rotate-180`, `has-[[data-x=y]]:…`): the split above cuts it at
|
|
524
|
+
// the `=`, so it is also taken whole, brackets nested two deep, a quote escaped inside a string literal unescaped
|
|
525
|
+
for (const m of code.matchAll(BRACKETED)) {
|
|
526
|
+
const c = m[0].replace(/\\(["'`])/g, '$1');
|
|
527
|
+
if (c.includes('=') && c.length < 200 && /[a-z]/.test(c))
|
|
528
|
+
out.add(c.replace(/[,;]+$/, ''));
|
|
529
|
+
}
|
|
530
|
+
return [...out];
|
|
531
|
+
}
|
|
532
|
+
/** A token of plain class characters and `[...]` groups (one more group may nest inside), inside which `=` and quotes may stand. */
|
|
533
|
+
const BRACKETED = /(?:[^\s"'`<>{}=\\[\]]|\[(?:[^\s[\]]|\[[^\s[\]]*\])*\])+/g;
|
|
534
|
+
/** One Tailwind v4 stylesheet (preflight, theme, utilities) for the classes found in every bundle. */
|
|
535
|
+
export async function buildTailwind(sources) {
|
|
536
|
+
const compiler = await compileTailwind('@import "tailwindcss";', {
|
|
537
|
+
base: MORPH_ROOT,
|
|
538
|
+
loadStylesheet: async (id, base) => {
|
|
539
|
+
const pkg = id === 'tailwindcss' ? require.resolve('tailwindcss/index.css', { paths: [MORPH_ROOT] }) : resolve(base, id);
|
|
540
|
+
return { path: pkg, base: dirname(pkg), content: readFileSync(pkg, 'utf8') };
|
|
541
|
+
},
|
|
542
|
+
});
|
|
543
|
+
const all = new Set();
|
|
544
|
+
for (const s of sources)
|
|
545
|
+
for (const c of candidates(s))
|
|
546
|
+
all.add(c);
|
|
547
|
+
return compiler.build([...all]);
|
|
548
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PNG } from 'pngjs';
|
|
2
|
+
import type { VerifyResult } from '../types.js';
|
|
3
|
+
/** pixelmatch's per-pixel colour tolerance (0..1). Verify never uses anything looser than 0.1. */
|
|
4
|
+
export declare const PIXEL_THRESHOLD = 0.1;
|
|
5
|
+
export declare function decodePng(buffer: Buffer): PNG;
|
|
6
|
+
/** The colour variance of an image: 0 means a single flat colour (a blank render). */
|
|
7
|
+
export declare function variance(png: PNG): number;
|
|
8
|
+
export interface PixelDiff {
|
|
9
|
+
diffPixels: number;
|
|
10
|
+
totalPixels: number;
|
|
11
|
+
match: number;
|
|
12
|
+
/** the diff image (changed pixels in red) */
|
|
13
|
+
png: Buffer;
|
|
14
|
+
}
|
|
15
|
+
/** Compares two same-size screenshots with pixelmatch at a threshold of 0.1 (anti-aliased pixels count as equal). */
|
|
16
|
+
export declare function compare(a: Buffer, b: Buffer, threshold?: number): PixelDiff;
|
|
17
|
+
export interface ChangedRegion {
|
|
18
|
+
/** pixels the step changed in React (its shot before against its shot after) */
|
|
19
|
+
changedPixels: number;
|
|
20
|
+
/** of those, the share where the target's shot matches React's after the step (null when React changed nothing) */
|
|
21
|
+
match: number | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* How far a target made the change a step made in React. A step usually changes a small part of the page (a switch's
|
|
25
|
+
* knob, a tab's underline), so a whole-page score barely moves when a target ignores it: a dead click handler on a
|
|
26
|
+
* switch still matches 99.5% of the viewport. This looks only at the pixels React changed and asks how many of them
|
|
27
|
+
* the target got right, with the same pixelmatch threshold.
|
|
28
|
+
*/
|
|
29
|
+
export declare function changedRegion(before: Buffer, after: Buffer, other: Buffer, threshold?: number): ChangedRegion;
|
|
30
|
+
/** A self-contained HTML report: every state side by side (React, Vue, Svelte, and the diffs), with the scores. */
|
|
31
|
+
export declare function htmlReport(result: VerifyResult, diffs: Map<string, Buffer>): string;
|