@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,150 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { dirname, relative, resolve, isAbsolute } from 'node:path';
|
|
3
|
+
import * as t from '@babel/types';
|
|
4
|
+
import { readFontMetrics } from './sfnt.js';
|
|
5
|
+
import { fallbackMetrics } from './fallback.js';
|
|
6
|
+
const FORMATS = {
|
|
7
|
+
woff2: ['woff2', 'font/woff2'],
|
|
8
|
+
woff: ['woff', 'font/woff'],
|
|
9
|
+
ttf: ['truetype', 'font/ttf'],
|
|
10
|
+
otf: ['opentype', 'font/otf'],
|
|
11
|
+
};
|
|
12
|
+
const DISPLAY = new Set(['auto', 'block', 'swap', 'fallback']);
|
|
13
|
+
/** A literal value of a next/font option: strings, numbers, booleans, arrays and objects of them; undefined otherwise. */
|
|
14
|
+
export function literal(node) {
|
|
15
|
+
if (t.isStringLiteral(node) || t.isNumericLiteral(node) || t.isBooleanLiteral(node))
|
|
16
|
+
return node.value;
|
|
17
|
+
if (t.isTemplateLiteral(node) && node.expressions.length === 0)
|
|
18
|
+
return node.quasis[0]?.value.cooked;
|
|
19
|
+
if (t.isArrayExpression(node)) {
|
|
20
|
+
const items = node.elements.map((e) => (t.isSpreadElement(e) ? undefined : literal(e)));
|
|
21
|
+
return items.every((v) => v !== undefined) ? items : undefined;
|
|
22
|
+
}
|
|
23
|
+
if (t.isObjectExpression(node)) {
|
|
24
|
+
const out = {};
|
|
25
|
+
for (const p of node.properties) {
|
|
26
|
+
if (!t.isObjectProperty(p) || p.computed)
|
|
27
|
+
return undefined;
|
|
28
|
+
const key = t.isIdentifier(p.key) ? p.key.name : t.isStringLiteral(p.key) ? p.key.value : null;
|
|
29
|
+
const value = literal(p.value);
|
|
30
|
+
if (key === null || value === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
out[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node))
|
|
37
|
+
return literal(node.expression);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
41
|
+
const str = (v) => (typeof v === 'string' ? v : typeof v === 'number' ? String(v) : undefined);
|
|
42
|
+
/** The category of Next.js's fallback face: Times New Roman only when the call names it. */
|
|
43
|
+
function adjustFor(option, files) {
|
|
44
|
+
if (option === false)
|
|
45
|
+
return null;
|
|
46
|
+
if (option !== undefined && option !== 'Arial' && option !== 'Times New Roman' && option !== true)
|
|
47
|
+
return `adjustFontFallback ${JSON.stringify(option)} is not one Next.js takes`;
|
|
48
|
+
// the file nearest weight 400, normal style, the thinner on a tie (pickFontFileForFallbackGeneration)
|
|
49
|
+
const weightNumber = (w) => (w === 'normal' ? 400 : w === 'bold' ? 700 : Number(w));
|
|
50
|
+
const distance = (w) => {
|
|
51
|
+
if (!w)
|
|
52
|
+
return 0;
|
|
53
|
+
const [a = NaN, b] = w.trim().split(/ +/).map(weightNumber);
|
|
54
|
+
if (b === undefined)
|
|
55
|
+
return a - 400;
|
|
56
|
+
if (a <= 400 && b >= 400)
|
|
57
|
+
return 0;
|
|
58
|
+
return Math.abs(a - 400) < Math.abs(b - 400) ? a - 400 : b - 400;
|
|
59
|
+
};
|
|
60
|
+
let picked;
|
|
61
|
+
for (const f of files) {
|
|
62
|
+
if (!picked) {
|
|
63
|
+
picked = f;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const used = distance(picked.weight);
|
|
67
|
+
const current = distance(f.weight);
|
|
68
|
+
if (used === current && (f.style === undefined || f.style === 'normal'))
|
|
69
|
+
picked = f;
|
|
70
|
+
else if (Math.abs(current) < Math.abs(used))
|
|
71
|
+
picked = f;
|
|
72
|
+
else if (Math.abs(used) === Math.abs(current) && current < used)
|
|
73
|
+
picked = f;
|
|
74
|
+
}
|
|
75
|
+
const metrics = picked ? readFontMetrics(picked.bytes) : null;
|
|
76
|
+
if (!metrics)
|
|
77
|
+
return `the metrics of ${picked?.written ?? 'its file'} that Next.js's adjusted fallback face is built from could not be read`;
|
|
78
|
+
return fallbackMetrics(metrics, option === 'Times New Roman' ? 'serif' : 'sans-serif');
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Reads a `next/font/local` call as Next.js's loader does (`validateLocalFontFunctionCall`): literal options only, each
|
|
82
|
+
* file beside the calling file and inside the project.
|
|
83
|
+
*/
|
|
84
|
+
export function localFontRequest(call, sourceFile, projectRoot) {
|
|
85
|
+
if (call.arguments.length !== 1)
|
|
86
|
+
return { refused: 'its call has no single options object' };
|
|
87
|
+
const options = literal(call.arguments[0]);
|
|
88
|
+
if (!isRecord(options))
|
|
89
|
+
return { refused: 'its options are not all literal values' };
|
|
90
|
+
const display = options.display === undefined ? 'swap' : str(options.display);
|
|
91
|
+
if (!display || !DISPLAY.has(display))
|
|
92
|
+
return { refused: `display ${JSON.stringify(options.display)} depends on when the file arrives, which a carried file does not reproduce` };
|
|
93
|
+
const topWeight = str(options.weight);
|
|
94
|
+
const topStyle = str(options.style);
|
|
95
|
+
const entries = Array.isArray(options.src) ? options.src : typeof options.src === 'string' ? [{ path: options.src, weight: topWeight, style: topStyle }] : null;
|
|
96
|
+
if (!entries?.length)
|
|
97
|
+
return { refused: 'its src is not a path or a list of files' };
|
|
98
|
+
const files = [];
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
if (!isRecord(entry) || typeof entry.path !== 'string')
|
|
101
|
+
return { refused: 'an src entry has no literal path' };
|
|
102
|
+
const ext = /\.(woff2|woff|ttf|otf)$/.exec(entry.path)?.[1];
|
|
103
|
+
const format = ext ? FORMATS[ext] : undefined;
|
|
104
|
+
if (!format)
|
|
105
|
+
return { refused: `${entry.path} is not a woff2, woff, ttf or otf file` };
|
|
106
|
+
if (!entry.path.startsWith('./') && !entry.path.startsWith('../'))
|
|
107
|
+
return { refused: `${entry.path} is not a path relative to the file` };
|
|
108
|
+
const full = resolve(dirname(sourceFile), entry.path);
|
|
109
|
+
const rel = relative(projectRoot, full);
|
|
110
|
+
if (rel.startsWith('..') || isAbsolute(rel))
|
|
111
|
+
return { refused: `${entry.path} is outside the project` };
|
|
112
|
+
if (!existsSync(full) || !statSync(full).isFile())
|
|
113
|
+
return { refused: `${entry.path} is not in the project` };
|
|
114
|
+
const weight = str(entry.weight);
|
|
115
|
+
const style = str(entry.style);
|
|
116
|
+
files.push({ written: entry.path, bytes: readFileSync(full), format: format[0], mime: format[1], ...(weight ? { weight } : {}), ...(style ? { style } : {}) });
|
|
117
|
+
}
|
|
118
|
+
const declarations = [];
|
|
119
|
+
if (options.declarations !== undefined) {
|
|
120
|
+
if (!Array.isArray(options.declarations))
|
|
121
|
+
return { refused: 'its declarations are not a list' };
|
|
122
|
+
for (const d of options.declarations) {
|
|
123
|
+
if (!isRecord(d) || typeof d.prop !== 'string' || typeof d.value !== 'string')
|
|
124
|
+
return { refused: 'a declaration is not a literal { prop, value }' };
|
|
125
|
+
declarations.push([d.prop, d.value]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const fallback = options.fallback === undefined ? [] : Array.isArray(options.fallback) && options.fallback.every((f) => typeof f === 'string') ? options.fallback : null;
|
|
129
|
+
if (!fallback)
|
|
130
|
+
return { refused: 'its fallback is not a list of families' };
|
|
131
|
+
if (options.variable !== undefined && typeof options.variable !== 'string')
|
|
132
|
+
return { refused: 'its variable is not a literal name' };
|
|
133
|
+
const adjust = adjustFor(options.adjustFontFallback, files);
|
|
134
|
+
if (typeof adjust === 'string')
|
|
135
|
+
return { refused: adjust };
|
|
136
|
+
const only = files.length === 1 ? files[0] : undefined;
|
|
137
|
+
return {
|
|
138
|
+
request: {
|
|
139
|
+
files,
|
|
140
|
+
display,
|
|
141
|
+
declarations,
|
|
142
|
+
fallback,
|
|
143
|
+
...(typeof options.variable === 'string' ? { variable: options.variable } : {}),
|
|
144
|
+
...(only?.weight ? { weight: only.weight } : {}),
|
|
145
|
+
...(only?.style ? { style: only.style } : {}),
|
|
146
|
+
adjust,
|
|
147
|
+
source: `next/font/local, ${files.map((f) => f.written).join(', ')}`,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The few numbers Next.js reads from a font file (with fontkit) to build its adjusted fallback face: the vertical
|
|
3
|
+
* metrics of `hhea`, `head`'s units per em, and the advance of a character through `cmap` and `hmtx`.
|
|
4
|
+
*/
|
|
5
|
+
export interface FontMetrics {
|
|
6
|
+
unitsPerEm: number;
|
|
7
|
+
ascent: number;
|
|
8
|
+
descent: number;
|
|
9
|
+
lineGap: number;
|
|
10
|
+
/** the advance width of the glyph a code point maps to (glyph 0 when the font has none, as fontkit gives) */
|
|
11
|
+
advance(codePoint: number): number;
|
|
12
|
+
/** whether the font maps the code point to a glyph */
|
|
13
|
+
has(codePoint: number): boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reads a TrueType, OpenType, WOFF or WOFF2 file's metrics. Null when the file is not one of those or holds its
|
|
17
|
+
* metrics in a form this reader does not follow (a collection, a transformed `hmtx`, a cmap format other than 4 or 12).
|
|
18
|
+
*/
|
|
19
|
+
export declare function readFontMetrics(bytes: Buffer): FontMetrics | null;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { brotliDecompressSync, inflateSync } from 'node:zlib';
|
|
2
|
+
/** WOFF2's known table tags, by the index its table directory stores in place of the tag. */
|
|
3
|
+
const WOFF2_TAGS = [
|
|
4
|
+
'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'OS/2', 'post', 'cvt ', 'fpgm', 'glyf', 'loca', 'prep', 'CFF ', 'VORG', 'EBDT',
|
|
5
|
+
'EBLC', 'gasp', 'hdmx', 'kern', 'LTSH', 'PCLT', 'VDMX', 'vhea', 'vmtx', 'BASE', 'GDEF', 'GPOS', 'GSUB', 'EBSC', 'JSTF', 'MATH',
|
|
6
|
+
'CBDT', 'CBLC', 'COLR', 'CPAL', 'SVG ', 'sbix', 'acnt', 'avar', 'bdat', 'bloc', 'bsln', 'cvar', 'fdsc', 'feat', 'fmtx', 'fvar',
|
|
7
|
+
'gvar', 'hsty', 'just', 'lcar', 'mort', 'morx', 'opbd', 'prop', 'trak', 'Zapf', 'Silf', 'Glat', 'Gloc', 'Feat', 'Sill',
|
|
8
|
+
];
|
|
9
|
+
const NEEDED = new Set(['head', 'hhea', 'hmtx', 'cmap']);
|
|
10
|
+
/** The tables a TrueType / OpenType file holds, by tag. */
|
|
11
|
+
function sfntTables(b) {
|
|
12
|
+
const tables = new Map();
|
|
13
|
+
const count = b.readUInt16BE(4);
|
|
14
|
+
for (let i = 0; i < count; i++) {
|
|
15
|
+
const rec = 12 + i * 16;
|
|
16
|
+
const tag = b.toString('latin1', rec, rec + 4);
|
|
17
|
+
const offset = b.readUInt32BE(rec + 8);
|
|
18
|
+
const length = b.readUInt32BE(rec + 12);
|
|
19
|
+
if (NEEDED.has(tag))
|
|
20
|
+
tables.set(tag, b.subarray(offset, offset + length));
|
|
21
|
+
}
|
|
22
|
+
return tables;
|
|
23
|
+
}
|
|
24
|
+
/** WOFF 1.0: each table zlib-compressed on its own (or stored as is). */
|
|
25
|
+
function woffTables(b) {
|
|
26
|
+
const tables = new Map();
|
|
27
|
+
const count = b.readUInt16BE(12);
|
|
28
|
+
for (let i = 0; i < count; i++) {
|
|
29
|
+
const rec = 44 + i * 20;
|
|
30
|
+
const tag = b.toString('latin1', rec, rec + 4);
|
|
31
|
+
const offset = b.readUInt32BE(rec + 4);
|
|
32
|
+
const compLength = b.readUInt32BE(rec + 8);
|
|
33
|
+
const origLength = b.readUInt32BE(rec + 12);
|
|
34
|
+
if (!NEEDED.has(tag))
|
|
35
|
+
continue;
|
|
36
|
+
const data = b.subarray(offset, offset + compLength);
|
|
37
|
+
tables.set(tag, compLength < origLength ? inflateSync(data) : data);
|
|
38
|
+
}
|
|
39
|
+
return tables;
|
|
40
|
+
}
|
|
41
|
+
/** WOFF 2.0: one Brotli stream of every table in directory order; null when a table this reader needs is transformed. */
|
|
42
|
+
function woff2Tables(b) {
|
|
43
|
+
if (b.toString('latin1', 4, 8) === 'ttcf')
|
|
44
|
+
return null;
|
|
45
|
+
const count = b.readUInt16BE(12);
|
|
46
|
+
const compressedSize = b.readUInt32BE(20);
|
|
47
|
+
let at = 48;
|
|
48
|
+
const base128 = () => {
|
|
49
|
+
let value = 0;
|
|
50
|
+
for (let i = 0; i < 5; i++) {
|
|
51
|
+
const byte = b.readUInt8(at++);
|
|
52
|
+
value = value * 128 + (byte & 0x7f);
|
|
53
|
+
if (!(byte & 0x80))
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
throw new Error('bad UIntBase128');
|
|
57
|
+
};
|
|
58
|
+
const dir = [];
|
|
59
|
+
for (let i = 0; i < count; i++) {
|
|
60
|
+
const flags = b.readUInt8(at++);
|
|
61
|
+
let tag = WOFF2_TAGS[flags & 0x3f] ?? '';
|
|
62
|
+
if ((flags & 0x3f) === 0x3f) {
|
|
63
|
+
tag = b.toString('latin1', at, at + 4);
|
|
64
|
+
at += 4;
|
|
65
|
+
}
|
|
66
|
+
const version = flags >> 6;
|
|
67
|
+
const origLength = base128();
|
|
68
|
+
// glyf and loca are transformed unless version 3; every other table is transformed unless version 0
|
|
69
|
+
const transformed = tag === 'glyf' || tag === 'loca' ? version !== 3 : version !== 0;
|
|
70
|
+
const length = transformed ? base128() : origLength;
|
|
71
|
+
dir.push({ tag, length, transformed });
|
|
72
|
+
}
|
|
73
|
+
const data = brotliDecompressSync(b.subarray(at, at + compressedSize));
|
|
74
|
+
const tables = new Map();
|
|
75
|
+
let offset = 0;
|
|
76
|
+
for (const entry of dir) {
|
|
77
|
+
if (NEEDED.has(entry.tag)) {
|
|
78
|
+
if (entry.transformed)
|
|
79
|
+
return null;
|
|
80
|
+
tables.set(entry.tag, data.subarray(offset, offset + entry.length));
|
|
81
|
+
}
|
|
82
|
+
offset += entry.length;
|
|
83
|
+
}
|
|
84
|
+
return tables;
|
|
85
|
+
}
|
|
86
|
+
/** A code point to glyph lookup from `cmap`, preferring the subtables fontkit prefers; null for a format it cannot read. */
|
|
87
|
+
function cmapLookup(cmap) {
|
|
88
|
+
const count = cmap.readUInt16BE(2);
|
|
89
|
+
const subtables = new Map();
|
|
90
|
+
for (let i = 0; i < count; i++) {
|
|
91
|
+
const rec = 4 + i * 8;
|
|
92
|
+
subtables.set(`${cmap.readUInt16BE(rec)},${cmap.readUInt16BE(rec + 2)}`, cmap.readUInt32BE(rec + 4));
|
|
93
|
+
}
|
|
94
|
+
for (const key of ['3,10', '0,6', '0,4', '3,1', '0,3', '0,2', '0,1', '0,0']) {
|
|
95
|
+
const offset = subtables.get(key);
|
|
96
|
+
if (offset === undefined)
|
|
97
|
+
continue;
|
|
98
|
+
const t = cmap.subarray(offset);
|
|
99
|
+
const format = t.readUInt16BE(0);
|
|
100
|
+
if (format === 12) {
|
|
101
|
+
const groups = t.readUInt32BE(12);
|
|
102
|
+
return (cp) => {
|
|
103
|
+
for (let g = 0; g < groups; g++) {
|
|
104
|
+
const rec = 16 + g * 12;
|
|
105
|
+
const start = t.readUInt32BE(rec);
|
|
106
|
+
const end = t.readUInt32BE(rec + 4);
|
|
107
|
+
if (cp >= start && cp <= end)
|
|
108
|
+
return t.readUInt32BE(rec + 8) + (cp - start);
|
|
109
|
+
}
|
|
110
|
+
return 0;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (format === 4) {
|
|
114
|
+
const segCount = t.readUInt16BE(6) / 2;
|
|
115
|
+
const ends = 14;
|
|
116
|
+
const starts = ends + segCount * 2 + 2;
|
|
117
|
+
const deltas = starts + segCount * 2;
|
|
118
|
+
const ranges = deltas + segCount * 2;
|
|
119
|
+
return (cp) => {
|
|
120
|
+
for (let s = 0; s < segCount; s++) {
|
|
121
|
+
if (cp > t.readUInt16BE(ends + s * 2))
|
|
122
|
+
continue;
|
|
123
|
+
const start = t.readUInt16BE(starts + s * 2);
|
|
124
|
+
if (cp < start)
|
|
125
|
+
return 0;
|
|
126
|
+
const delta = t.readInt16BE(deltas + s * 2);
|
|
127
|
+
const rangeOffset = t.readUInt16BE(ranges + s * 2);
|
|
128
|
+
if (rangeOffset === 0)
|
|
129
|
+
return (cp + delta) & 0xffff;
|
|
130
|
+
const glyph = t.readUInt16BE(ranges + s * 2 + rangeOffset + (cp - start) * 2);
|
|
131
|
+
return glyph === 0 ? 0 : (glyph + delta) & 0xffff;
|
|
132
|
+
}
|
|
133
|
+
return 0;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Reads a TrueType, OpenType, WOFF or WOFF2 file's metrics. Null when the file is not one of those or holds its
|
|
142
|
+
* metrics in a form this reader does not follow (a collection, a transformed `hmtx`, a cmap format other than 4 or 12).
|
|
143
|
+
*/
|
|
144
|
+
export function readFontMetrics(bytes) {
|
|
145
|
+
try {
|
|
146
|
+
const sig = bytes.toString('latin1', 0, 4);
|
|
147
|
+
const tables = sig === 'wOF2' ? woff2Tables(bytes) : sig === 'wOFF' ? woffTables(bytes) : sig === 'OTTO' || sig === 'true' || bytes.readUInt32BE(0) === 0x00010000 ? sfntTables(bytes) : null;
|
|
148
|
+
const head = tables?.get('head');
|
|
149
|
+
const hhea = tables?.get('hhea');
|
|
150
|
+
const hmtx = tables?.get('hmtx');
|
|
151
|
+
const cmap = tables?.get('cmap');
|
|
152
|
+
if (!head || !hhea || !hmtx || !cmap)
|
|
153
|
+
return null;
|
|
154
|
+
const lookup = cmapLookup(cmap);
|
|
155
|
+
if (!lookup)
|
|
156
|
+
return null;
|
|
157
|
+
const metrics = hhea.readUInt16BE(34);
|
|
158
|
+
if (!metrics)
|
|
159
|
+
return null;
|
|
160
|
+
return {
|
|
161
|
+
unitsPerEm: head.readUInt16BE(18),
|
|
162
|
+
ascent: hhea.readInt16BE(4),
|
|
163
|
+
descent: hhea.readInt16BE(6),
|
|
164
|
+
lineGap: hhea.readInt16BE(8),
|
|
165
|
+
advance: (cp) => hmtx.readUInt16BE(Math.min(lookup(cp), metrics - 1) * 4),
|
|
166
|
+
has: (cp) => lookup(cp) !== 0,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
if (error instanceof RangeError || (error instanceof Error && /UIntBase128|decompress|incorrect header|invalid/i.test(error.message)))
|
|
171
|
+
return null;
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Carried } from './local.js';
|
|
2
|
+
/**
|
|
3
|
+
* The `next/font/local` module the React original is bundled with in verify, for one importing file: each call of that
|
|
4
|
+
* file whose font the converter carries returns the same font object and adds the same CSS (the same file's bytes, the
|
|
5
|
+
* same faces and class) the converted output does, as Next.js would serve that file. A call the converter does not carry
|
|
6
|
+
* returns `fallback`, the object the converted output then has too.
|
|
7
|
+
*/
|
|
8
|
+
export declare function localFontShim(importer: string, projectRoot: string, fallback: Record<string, unknown>): string;
|
|
9
|
+
/**
|
|
10
|
+
* The `next/font/google` module the React original is bundled with in verify under the fonts option, for one importing
|
|
11
|
+
* file: a call the conversion carried returns the same object and adds the same CSS (the same downloaded files) as the
|
|
12
|
+
* converted output; any other call returns `fallbackFor(loader)`, the object the converted output then has too.
|
|
13
|
+
*/
|
|
14
|
+
export declare function googleFontShim(importer: string, carried: Map<string, Carried>, fallbackFor: (loader: string) => Record<string, unknown>): string;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import * as t from '@babel/types';
|
|
3
|
+
import { parseSource } from '../analyzer/parse.js';
|
|
4
|
+
import { literal, localFontRequest } from './local.js';
|
|
5
|
+
import { fontHash, fontParts } from './carry.js';
|
|
6
|
+
import { googleKey } from './google.js';
|
|
7
|
+
/**
|
|
8
|
+
* The `next/font/local` module the React original is bundled with in verify, for one importing file: each call of that
|
|
9
|
+
* file whose font the converter carries returns the same font object and adds the same CSS (the same file's bytes, the
|
|
10
|
+
* same faces and class) the converted output does, as Next.js would serve that file. A call the converter does not carry
|
|
11
|
+
* returns `fallback`, the object the converted output then has too.
|
|
12
|
+
*/
|
|
13
|
+
export function localFontShim(importer, projectRoot, fallback) {
|
|
14
|
+
const ast = parseSource(readFileSync(importer, 'utf8'), importer);
|
|
15
|
+
const loaders = new Set();
|
|
16
|
+
for (const s of ast.program.body) {
|
|
17
|
+
if (t.isImportDeclaration(s) && s.source.value === 'next/font/local')
|
|
18
|
+
for (const sp of s.specifiers)
|
|
19
|
+
if (t.isImportDefaultSpecifier(sp))
|
|
20
|
+
loaders.add(sp.local.name);
|
|
21
|
+
}
|
|
22
|
+
const fonts = {};
|
|
23
|
+
for (const s of ast.program.body) {
|
|
24
|
+
const decl = t.isExportNamedDeclaration(s) ? s.declaration : s;
|
|
25
|
+
if (!t.isVariableDeclaration(decl) || decl.kind !== 'const')
|
|
26
|
+
continue;
|
|
27
|
+
for (const d of decl.declarations) {
|
|
28
|
+
if (!t.isIdentifier(d.id) || !t.isCallExpression(d.init) || !t.isIdentifier(d.init.callee) || !loaders.has(d.init.callee.name))
|
|
29
|
+
continue;
|
|
30
|
+
const carried = localFontRequest(d.init, importer, projectRoot);
|
|
31
|
+
if ('refused' in carried)
|
|
32
|
+
continue;
|
|
33
|
+
const options = d.init.arguments[0];
|
|
34
|
+
const key = JSON.stringify(literal(options));
|
|
35
|
+
const hash = fontHash(carried.request);
|
|
36
|
+
fonts[key] = { hash, ...fontParts(carried.request, d.id.name, hash) };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return [
|
|
40
|
+
`const fonts = ${JSON.stringify(fonts)};`,
|
|
41
|
+
`const fallback = ${JSON.stringify(fallback)};`,
|
|
42
|
+
'export default function localFont(options) {',
|
|
43
|
+
' const font = fonts[JSON.stringify(options)];',
|
|
44
|
+
' if (!font) return fallback;',
|
|
45
|
+
' if (!document.querySelector(`style[data-font="${font.hash}"]`)) {',
|
|
46
|
+
" const style = document.createElement('style');",
|
|
47
|
+
' style.dataset.font = font.hash;',
|
|
48
|
+
' style.textContent = font.css;',
|
|
49
|
+
' document.head.append(style);',
|
|
50
|
+
' }',
|
|
51
|
+
' return font.object;',
|
|
52
|
+
'}',
|
|
53
|
+
'',
|
|
54
|
+
].join('\n');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The `next/font/google` module the React original is bundled with in verify under the fonts option, for one importing
|
|
58
|
+
* file: a call the conversion carried returns the same object and adds the same CSS (the same downloaded files) as the
|
|
59
|
+
* converted output; any other call returns `fallbackFor(loader)`, the object the converted output then has too.
|
|
60
|
+
*/
|
|
61
|
+
export function googleFontShim(importer, carried, fallbackFor) {
|
|
62
|
+
const ast = parseSource(readFileSync(importer, 'utf8'), importer);
|
|
63
|
+
const names = new Map();
|
|
64
|
+
for (const s of ast.program.body) {
|
|
65
|
+
if (!t.isImportDeclaration(s) || s.source.value !== 'next/font/google')
|
|
66
|
+
continue;
|
|
67
|
+
for (const sp of s.specifiers)
|
|
68
|
+
if (t.isImportSpecifier(sp))
|
|
69
|
+
names.set(t.isIdentifier(sp.imported) ? sp.imported.name : sp.imported.value, sp.local.name);
|
|
70
|
+
}
|
|
71
|
+
const fonts = {};
|
|
72
|
+
for (const [key, c] of carried) {
|
|
73
|
+
const loader = key.split('\0')[0] ?? '';
|
|
74
|
+
if (!names.has(loader) || 'refused' in c)
|
|
75
|
+
continue;
|
|
76
|
+
const hash = fontHash(c.request);
|
|
77
|
+
fonts[key] = { hash, ...fontParts(c.request, localNameOf(ast, names.get(loader) ?? loader, key) ?? loader, hash) };
|
|
78
|
+
}
|
|
79
|
+
const lines = [`const fonts = ${JSON.stringify(fonts)};`, 'function load(key, fallback) {', ' const font = fonts[key];', ' if (!font) return fallback;', ' if (!document.querySelector(`style[data-font="${font.hash}"]`)) {', " const style = document.createElement('style');", ' style.dataset.font = font.hash;', ' style.textContent = font.css;', ' document.head.append(style);', ' }', ' return font.object;', '}'];
|
|
80
|
+
for (const loader of names.keys())
|
|
81
|
+
lines.push(`export const ${loader} = (options) => load(${JSON.stringify(loader)} + '\\0' + JSON.stringify(options), ${JSON.stringify(fallbackFor(loader))});`);
|
|
82
|
+
return `${lines.join('\n')}\n`;
|
|
83
|
+
}
|
|
84
|
+
/** The const a call with this key is assigned to in the file (the family name of the converted output comes from it). */
|
|
85
|
+
function localNameOf(ast, local, key) {
|
|
86
|
+
for (const s of ast.program.body) {
|
|
87
|
+
const decl = t.isExportNamedDeclaration(s) ? s.declaration : s;
|
|
88
|
+
if (!t.isVariableDeclaration(decl))
|
|
89
|
+
continue;
|
|
90
|
+
for (const d of decl.declarations) {
|
|
91
|
+
if (t.isIdentifier(d.id) && t.isCallExpression(d.init) && t.isIdentifier(d.init.callee, { name: local }) && googleKey(key.split('\0')[0] ?? '', d.init.arguments[0]) === key)
|
|
92
|
+
return d.id.name;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
package/dist/gate.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { EmittedFile, InteractionState, LeakCounts, ProjectOptions, VerifyStep, WebTarget } from './types.js';
|
|
2
|
+
import { type AssistGate } from './ai/gate.js';
|
|
3
|
+
/**
|
|
4
|
+
* `gate` (v0.3 Milestone A): the four gates assisted mode holds a model-written file to, run on a candidate a person or
|
|
5
|
+
* an agent wrote. It reuses assisted mode's own gates (src/ai/gate.ts: staticGates, browserVerdict), never a second set.
|
|
6
|
+
*/
|
|
7
|
+
/** At most this many candidate files per run. */
|
|
8
|
+
export declare const MAX_CANDIDATES = 16;
|
|
9
|
+
export interface GateOptions extends ProjectOptions {
|
|
10
|
+
target: WebTarget;
|
|
11
|
+
/** the named export to render; default: the file's default export, else its first exported component */
|
|
12
|
+
exportName?: string;
|
|
13
|
+
props?: Record<string, unknown>;
|
|
14
|
+
/** default: idle, hover, active */
|
|
15
|
+
states?: InteractionState[];
|
|
16
|
+
/** a script of user actions, each compared with React's */
|
|
17
|
+
steps?: VerifyStep[];
|
|
18
|
+
/** with no `steps`: discover the script on the React page (as verify's autoSteps) */
|
|
19
|
+
autoSteps?: boolean | {
|
|
20
|
+
maxSteps?: number;
|
|
21
|
+
};
|
|
22
|
+
/** Chrome or Chromium executable; default: the installed Chrome channel */
|
|
23
|
+
executablePath?: string;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
export type GateStatus = 'pass' | 'fail' | 'not-run';
|
|
27
|
+
export interface GateCheck {
|
|
28
|
+
gate: AssistGate;
|
|
29
|
+
status: GateStatus;
|
|
30
|
+
/** why it failed (null when it passed or did not run) */
|
|
31
|
+
reason: string | null;
|
|
32
|
+
/** every located problem the gate found (`path:line: message`), at most 20 */
|
|
33
|
+
details: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface GateScore {
|
|
36
|
+
/** the lowest match of every state and step (null when the browser gate did not run) */
|
|
37
|
+
minMatch: number | null;
|
|
38
|
+
states: {
|
|
39
|
+
state: InteractionState;
|
|
40
|
+
match: number;
|
|
41
|
+
}[];
|
|
42
|
+
steps: {
|
|
43
|
+
name: string;
|
|
44
|
+
index: number;
|
|
45
|
+
match: number;
|
|
46
|
+
failure: string | null;
|
|
47
|
+
stateMismatches: number;
|
|
48
|
+
}[];
|
|
49
|
+
}
|
|
50
|
+
/** The verdict of one `gate` run. The shape is stable (README: "gate"): fields are only added, never renamed or removed. */
|
|
51
|
+
export interface GateResult {
|
|
52
|
+
/** the shape's version: 1 */
|
|
53
|
+
version: 1;
|
|
54
|
+
/** the React original, absolute */
|
|
55
|
+
file: string;
|
|
56
|
+
target: WebTarget;
|
|
57
|
+
/** each candidate file and the output path it stood in for */
|
|
58
|
+
candidates: {
|
|
59
|
+
file: string;
|
|
60
|
+
replaces: string;
|
|
61
|
+
}[];
|
|
62
|
+
/** true only when all four gates passed */
|
|
63
|
+
passed: boolean;
|
|
64
|
+
/** the first gate that failed, or null */
|
|
65
|
+
failedGate: AssistGate | null;
|
|
66
|
+
/** the failed gate's reason, or null */
|
|
67
|
+
reason: string | null;
|
|
68
|
+
/** the four gates, in the order they run */
|
|
69
|
+
gates: GateCheck[];
|
|
70
|
+
score: GateScore;
|
|
71
|
+
/** what the component left running after unmount beyond React (null when not measured) */
|
|
72
|
+
leaks: {
|
|
73
|
+
clean: boolean;
|
|
74
|
+
beyondReact: LeakCounts | null;
|
|
75
|
+
} | null;
|
|
76
|
+
/** the script that was compared (given or discovered) */
|
|
77
|
+
steps: VerifyStep[];
|
|
78
|
+
/** with autoSteps: the script discovered on the React page */
|
|
79
|
+
discoveredSteps: VerifyStep[] | null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Puts each candidate in place of the output file with the same name (Foo.vue replaces the compiler's Foo.vue). A
|
|
83
|
+
* candidate no output file is named like (the compiler refused the component whole) is added beside the first
|
|
84
|
+
* component file. Two output files with the candidate's name is an error: the candidate's place is not clear.
|
|
85
|
+
*/
|
|
86
|
+
export declare function placeCandidates(own: EmittedFile[], candidates: {
|
|
87
|
+
file: string;
|
|
88
|
+
contents: string;
|
|
89
|
+
}[]): {
|
|
90
|
+
files: EmittedFile[];
|
|
91
|
+
placed: {
|
|
92
|
+
file: string;
|
|
93
|
+
replaces: string;
|
|
94
|
+
}[];
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Runs the four gates on candidate files for one web target, in order, stopping at the first that fails: (1) the
|
|
98
|
+
* target's real compiler and no `antheo-morph: not converted` mark left, (2) the strict type check (vue-tsc's /
|
|
99
|
+
* svelte-check's; Angular: ngtsc with strictTemplates covers both), (3) the browser harness against the React original
|
|
100
|
+
* (every state and every step at 99% or more at pixelmatch threshold 0.1, no DOM fact that differs after a step, no page
|
|
101
|
+
* error), (4) the unmount check (nothing left running that React does not leave). Passes only if all four pass.
|
|
102
|
+
*/
|
|
103
|
+
export declare function runGate(sourceFile: string, candidateFiles: readonly string[], options: GateOptions): Promise<GateResult>;
|
|
104
|
+
/** The verdict as text an agent can act on: the result, each gate, the failing gate's located problems, the scores. */
|
|
105
|
+
export declare function gateLines(r: GateResult): string[];
|