@qzsy/vinext 0.1.7
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 +773 -0
- package/dist/build/assets-ignore.d.ts +32 -0
- package/dist/build/assets-ignore.js +48 -0
- package/dist/build/clean-output.d.ts +13 -0
- package/dist/build/clean-output.js +34 -0
- package/dist/build/client-build-config.d.ts +171 -0
- package/dist/build/client-build-config.js +270 -0
- package/dist/build/css-url-assets.d.ts +29 -0
- package/dist/build/css-url-assets.js +213 -0
- package/dist/build/google-fonts/build-url.d.ts +9 -0
- package/dist/build/google-fonts/build-url.js +28 -0
- package/dist/build/google-fonts/fallback-metrics-data.js +14029 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +12 -0
- package/dist/build/google-fonts/fallback-metrics.js +44 -0
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +16 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +28 -0
- package/dist/build/google-fonts/font-data.js +24983 -0
- package/dist/build/google-fonts/font-metadata.d.ts +16 -0
- package/dist/build/google-fonts/font-metadata.js +5 -0
- package/dist/build/google-fonts/get-axes.d.ts +6 -0
- package/dist/build/google-fonts/get-axes.js +37 -0
- package/dist/build/google-fonts/sort-variants.d.ts +4 -0
- package/dist/build/google-fonts/sort-variants.js +12 -0
- package/dist/build/google-fonts/validate.d.ts +27 -0
- package/dist/build/google-fonts/validate.js +54 -0
- package/dist/build/inline-css.d.ts +6 -0
- package/dist/build/inline-css.js +48 -0
- package/dist/build/layout-classification-types.d.ts +61 -0
- package/dist/build/layout-classification-types.js +1 -0
- package/dist/build/layout-classification.d.ts +59 -0
- package/dist/build/layout-classification.js +98 -0
- package/dist/build/next-client-runtime-manifests.d.ts +14 -0
- package/dist/build/next-client-runtime-manifests.js +39 -0
- package/dist/build/nitro-route-rules.d.ts +49 -0
- package/dist/build/nitro-route-rules.js +79 -0
- package/dist/build/precompress.d.ts +27 -0
- package/dist/build/precompress.js +110 -0
- package/dist/build/prerender.d.ts +209 -0
- package/dist/build/prerender.js +932 -0
- package/dist/build/report.d.ts +132 -0
- package/dist/build/report.js +504 -0
- package/dist/build/route-classification-injector.d.ts +34 -0
- package/dist/build/route-classification-injector.js +59 -0
- package/dist/build/route-classification-manifest.d.ts +52 -0
- package/dist/build/route-classification-manifest.js +143 -0
- package/dist/build/run-prerender.d.ts +61 -0
- package/dist/build/run-prerender.js +224 -0
- package/dist/build/server-manifest.d.ts +18 -0
- package/dist/build/server-manifest.js +22 -0
- package/dist/build/ssr-manifest.d.ts +18 -0
- package/dist/build/ssr-manifest.js +69 -0
- package/dist/build/standalone.d.ts +31 -0
- package/dist/build/standalone.js +203 -0
- package/dist/build/static-export.d.ts +55 -0
- package/dist/build/static-export.js +60 -0
- package/dist/cache/cache-adapters-virtual.d.ts +50 -0
- package/dist/cache/cache-adapters-virtual.js +45 -0
- package/dist/cache.d.ts +2 -0
- package/dist/cache.js +2 -0
- package/dist/check.d.ts +87 -0
- package/dist/check.js +1037 -0
- package/dist/cli-args.d.ts +33 -0
- package/dist/cli-args.js +124 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +744 -0
- package/dist/client/app-nav-failure-handler.d.ts +8 -0
- package/dist/client/app-nav-failure-handler.js +44 -0
- package/dist/client/empty-module.d.ts +1 -0
- package/dist/client/empty-module.js +1 -0
- package/dist/client/instrumentation-client-inject.d.ts +33 -0
- package/dist/client/instrumentation-client-inject.js +55 -0
- package/dist/client/instrumentation-client-state.d.ts +9 -0
- package/dist/client/instrumentation-client-state.js +17 -0
- package/dist/client/instrumentation-client.d.ts +7 -0
- package/dist/client/instrumentation-client.js +6 -0
- package/dist/client/navigation-runtime.d.ts +70 -0
- package/dist/client/navigation-runtime.js +169 -0
- package/dist/client/pages-router-link-navigation.d.ts +61 -0
- package/dist/client/pages-router-link-navigation.js +42 -0
- package/dist/client/validate-module-path.d.ts +17 -0
- package/dist/client/validate-module-path.js +24 -0
- package/dist/client/vinext-next-data.d.ts +44 -0
- package/dist/client/vinext-next-data.js +50 -0
- package/dist/client/window-next.d.ts +168 -0
- package/dist/client/window-next.js +57 -0
- package/dist/cloudflare/index.d.ts +3 -0
- package/dist/cloudflare/index.js +3 -0
- package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +102 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +126 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.js +435 -0
- package/dist/cloudflare/src/utils/cache-control-metadata.js +20 -0
- package/dist/cloudflare/tpr.d.ts +82 -0
- package/dist/cloudflare/tpr.js +558 -0
- package/dist/config/config-matchers.d.ts +257 -0
- package/dist/config/config-matchers.js +1046 -0
- package/dist/config/dotenv.d.ts +56 -0
- package/dist/config/dotenv.js +88 -0
- package/dist/config/next-config.d.ts +540 -0
- package/dist/config/next-config.js +1050 -0
- package/dist/config/tsconfig-paths.d.ts +21 -0
- package/dist/config/tsconfig-paths.js +157 -0
- package/dist/deploy.d.ts +190 -0
- package/dist/deploy.js +1033 -0
- package/dist/entries/app-browser-entry.d.ts +29 -0
- package/dist/entries/app-browser-entry.js +83 -0
- package/dist/entries/app-rsc-entry.d.ts +81 -0
- package/dist/entries/app-rsc-entry.js +943 -0
- package/dist/entries/app-rsc-manifest.d.ts +53 -0
- package/dist/entries/app-rsc-manifest.js +294 -0
- package/dist/entries/app-ssr-entry.d.ts +15 -0
- package/dist/entries/app-ssr-entry.js +24 -0
- package/dist/entries/pages-client-entry.d.ts +11 -0
- package/dist/entries/pages-client-entry.js +204 -0
- package/dist/entries/pages-entry-helpers.d.ts +2 -0
- package/dist/entries/pages-entry-helpers.js +2 -0
- package/dist/entries/pages-server-entry.d.ts +11 -0
- package/dist/entries/pages-server-entry.js +398 -0
- package/dist/entries/runtime-entry-module.d.ts +25 -0
- package/dist/entries/runtime-entry-module.js +46 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +2661 -0
- package/dist/init.d.ts +69 -0
- package/dist/init.js +253 -0
- package/dist/plugins/ast-utils.d.ts +20 -0
- package/dist/plugins/ast-utils.js +78 -0
- package/dist/plugins/async-hooks-stub.d.ts +18 -0
- package/dist/plugins/async-hooks-stub.js +40 -0
- package/dist/plugins/client-reference-dedup.d.ts +35 -0
- package/dist/plugins/client-reference-dedup.js +189 -0
- package/dist/plugins/css-data-url.d.ts +6 -0
- package/dist/plugins/css-data-url.js +83 -0
- package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
- package/dist/plugins/dynamic-preload-metadata.js +413 -0
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +155 -0
- package/dist/plugins/fonts.d.ts +95 -0
- package/dist/plugins/fonts.js +711 -0
- package/dist/plugins/import-meta-url.d.ts +16 -0
- package/dist/plugins/import-meta-url.js +353 -0
- package/dist/plugins/instrumentation-client.d.ts +6 -0
- package/dist/plugins/instrumentation-client.js +27 -0
- package/dist/plugins/middleware-export-validation.d.ts +5 -0
- package/dist/plugins/middleware-export-validation.js +36 -0
- package/dist/plugins/middleware-server-only.d.ts +53 -0
- package/dist/plugins/middleware-server-only.js +90 -0
- package/dist/plugins/og-asset-ownership.d.ts +27 -0
- package/dist/plugins/og-asset-ownership.js +285 -0
- package/dist/plugins/og-assets.d.ts +50 -0
- package/dist/plugins/og-assets.js +229 -0
- package/dist/plugins/optimize-imports.d.ts +42 -0
- package/dist/plugins/optimize-imports.js +587 -0
- package/dist/plugins/postcss.d.ts +26 -0
- package/dist/plugins/postcss.js +96 -0
- package/dist/plugins/remove-console.d.ts +21 -0
- package/dist/plugins/remove-console.js +177 -0
- package/dist/plugins/require-context.d.ts +6 -0
- package/dist/plugins/require-context.js +185 -0
- package/dist/plugins/rsc-client-reference-loaders.d.ts +6 -0
- package/dist/plugins/rsc-client-reference-loaders.js +46 -0
- package/dist/plugins/rsc-client-shim-excludes.d.ts +6 -0
- package/dist/plugins/rsc-client-shim-excludes.js +35 -0
- package/dist/plugins/sass.d.ts +62 -0
- package/dist/plugins/sass.js +268 -0
- package/dist/plugins/server-externals-manifest.d.ts +26 -0
- package/dist/plugins/server-externals-manifest.js +81 -0
- package/dist/plugins/strip-server-exports.d.ts +21 -0
- package/dist/plugins/strip-server-exports.js +519 -0
- package/dist/plugins/typeof-window.d.ts +14 -0
- package/dist/plugins/typeof-window.js +150 -0
- package/dist/plugins/wasm-module-import.d.ts +15 -0
- package/dist/plugins/wasm-module-import.js +50 -0
- package/dist/routing/app-route-graph.d.ts +336 -0
- package/dist/routing/app-route-graph.js +1518 -0
- package/dist/routing/app-router.d.ts +30 -0
- package/dist/routing/app-router.js +59 -0
- package/dist/routing/file-matcher.d.ts +60 -0
- package/dist/routing/file-matcher.js +147 -0
- package/dist/routing/pages-router.d.ts +48 -0
- package/dist/routing/pages-router.js +163 -0
- package/dist/routing/route-matching.d.ts +27 -0
- package/dist/routing/route-matching.js +42 -0
- package/dist/routing/route-pattern.d.ts +64 -0
- package/dist/routing/route-pattern.js +165 -0
- package/dist/routing/route-trie.d.ts +67 -0
- package/dist/routing/route-trie.js +143 -0
- package/dist/routing/route-validation.d.ts +10 -0
- package/dist/routing/route-validation.js +101 -0
- package/dist/routing/utils.d.ts +117 -0
- package/dist/routing/utils.js +242 -0
- package/dist/server/accept-encoding.d.ts +29 -0
- package/dist/server/accept-encoding.js +95 -0
- package/dist/server/api-handler.d.ts +17 -0
- package/dist/server/api-handler.js +276 -0
- package/dist/server/app-action-request.d.ts +4 -0
- package/dist/server/app-action-request.js +9 -0
- package/dist/server/app-bfcache-id.d.ts +5 -0
- package/dist/server/app-bfcache-id.js +5 -0
- package/dist/server/app-bfcache-identity.d.ts +36 -0
- package/dist/server/app-bfcache-identity.js +156 -0
- package/dist/server/app-browser-action-result.d.ts +64 -0
- package/dist/server/app-browser-action-result.js +111 -0
- package/dist/server/app-browser-client-reuse-manifest.d.ts +12 -0
- package/dist/server/app-browser-client-reuse-manifest.js +101 -0
- package/dist/server/app-browser-entry.d.ts +1 -0
- package/dist/server/app-browser-entry.js +1087 -0
- package/dist/server/app-browser-error.d.ts +13 -0
- package/dist/server/app-browser-error.js +52 -0
- package/dist/server/app-browser-history-controller.d.ts +104 -0
- package/dist/server/app-browser-history-controller.js +210 -0
- package/dist/server/app-browser-hydration.d.ts +32 -0
- package/dist/server/app-browser-hydration.js +29 -0
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +43 -0
- package/dist/server/app-browser-mpa-navigation.d.ts +16 -0
- package/dist/server/app-browser-mpa-navigation.js +42 -0
- package/dist/server/app-browser-navigation-controller.d.ts +109 -0
- package/dist/server/app-browser-navigation-controller.js +465 -0
- package/dist/server/app-browser-popstate.d.ts +26 -0
- package/dist/server/app-browser-popstate.js +44 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +38 -0
- package/dist/server/app-browser-rsc-redirect.js +64 -0
- package/dist/server/app-browser-server-action-client.d.ts +32 -0
- package/dist/server/app-browser-server-action-client.js +128 -0
- package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
- package/dist/server/app-browser-server-action-navigation.js +9 -0
- package/dist/server/app-browser-state.d.ts +140 -0
- package/dist/server/app-browser-state.js +315 -0
- package/dist/server/app-browser-stream.d.ts +28 -0
- package/dist/server/app-browser-stream.js +122 -0
- package/dist/server/app-browser-visible-commit.d.ts +78 -0
- package/dist/server/app-browser-visible-commit.js +241 -0
- package/dist/server/app-client-reference-preloader.d.ts +14 -0
- package/dist/server/app-client-reference-preloader.js +44 -0
- package/dist/server/app-elements-wire.d.ts +192 -0
- package/dist/server/app-elements-wire.js +443 -0
- package/dist/server/app-elements.d.ts +9 -0
- package/dist/server/app-elements.js +18 -0
- package/dist/server/app-fallback-renderer.d.ts +89 -0
- package/dist/server/app-fallback-renderer.js +136 -0
- package/dist/server/app-history-state.d.ts +85 -0
- package/dist/server/app-history-state.js +223 -0
- package/dist/server/app-hook-warning-suppression.d.ts +6 -0
- package/dist/server/app-hook-warning-suppression.js +10 -0
- package/dist/server/app-inline-css-client.d.ts +6 -0
- package/dist/server/app-inline-css-client.js +35 -0
- package/dist/server/app-interception-context-header.d.ts +32 -0
- package/dist/server/app-interception-context-header.js +42 -0
- package/dist/server/app-layout-param-observation.d.ts +43 -0
- package/dist/server/app-layout-param-observation.js +168 -0
- package/dist/server/app-middleware.d.ts +46 -0
- package/dist/server/app-middleware.js +168 -0
- package/dist/server/app-mounted-slots-header.d.ts +35 -0
- package/dist/server/app-mounted-slots-header.js +58 -0
- package/dist/server/app-optimistic-routing.d.ts +53 -0
- package/dist/server/app-optimistic-routing.js +227 -0
- package/dist/server/app-page-boundary-render.d.ts +85 -0
- package/dist/server/app-page-boundary-render.js +305 -0
- package/dist/server/app-page-boundary.d.ts +102 -0
- package/dist/server/app-page-boundary.js +120 -0
- package/dist/server/app-page-cache-finalizer.d.ts +62 -0
- package/dist/server/app-page-cache-finalizer.js +122 -0
- package/dist/server/app-page-cache-render.d.ts +53 -0
- package/dist/server/app-page-cache-render.js +91 -0
- package/dist/server/app-page-cache.d.ts +83 -0
- package/dist/server/app-page-cache.js +272 -0
- package/dist/server/app-page-dispatch.d.ts +223 -0
- package/dist/server/app-page-dispatch.js +610 -0
- package/dist/server/app-page-element-builder.d.ts +96 -0
- package/dist/server/app-page-element-builder.js +205 -0
- package/dist/server/app-page-execution.d.ts +138 -0
- package/dist/server/app-page-execution.js +328 -0
- package/dist/server/app-page-head.d.ts +65 -0
- package/dist/server/app-page-head.js +228 -0
- package/dist/server/app-page-method.d.ts +15 -0
- package/dist/server/app-page-method.js +25 -0
- package/dist/server/app-page-params.d.ts +8 -0
- package/dist/server/app-page-params.js +39 -0
- package/dist/server/app-page-ppr-runtime.d.ts +7 -0
- package/dist/server/app-page-ppr-runtime.js +70 -0
- package/dist/server/app-page-probe.d.ts +134 -0
- package/dist/server/app-page-probe.js +276 -0
- package/dist/server/app-page-render-identity.d.ts +21 -0
- package/dist/server/app-page-render-identity.js +40 -0
- package/dist/server/app-page-render-observation.d.ts +36 -0
- package/dist/server/app-page-render-observation.js +82 -0
- package/dist/server/app-page-render.d.ts +111 -0
- package/dist/server/app-page-render.js +602 -0
- package/dist/server/app-page-request.d.ts +137 -0
- package/dist/server/app-page-request.js +216 -0
- package/dist/server/app-page-response.d.ts +68 -0
- package/dist/server/app-page-response.js +120 -0
- package/dist/server/app-page-route-wiring.d.ts +151 -0
- package/dist/server/app-page-route-wiring.js +452 -0
- package/dist/server/app-page-search-params-observation.d.ts +10 -0
- package/dist/server/app-page-search-params-observation.js +20 -0
- package/dist/server/app-page-segment-state.d.ts +9 -0
- package/dist/server/app-page-segment-state.js +80 -0
- package/dist/server/app-page-stream.d.ts +151 -0
- package/dist/server/app-page-stream.js +143 -0
- package/dist/server/app-pages-bridge.d.ts +63 -0
- package/dist/server/app-pages-bridge.js +63 -0
- package/dist/server/app-post-middleware-context.d.ts +15 -0
- package/dist/server/app-post-middleware-context.js +26 -0
- package/dist/server/app-ppr-fallback-shell-render.d.ts +18 -0
- package/dist/server/app-ppr-fallback-shell-render.js +26 -0
- package/dist/server/app-ppr-fallback-shell.d.ts +33 -0
- package/dist/server/app-ppr-fallback-shell.js +89 -0
- package/dist/server/app-prerender-endpoints.d.ts +18 -0
- package/dist/server/app-prerender-endpoints.js +94 -0
- package/dist/server/app-prerender-static-params.d.ts +30 -0
- package/dist/server/app-prerender-static-params.js +81 -0
- package/dist/server/app-render-dependency.d.ts +14 -0
- package/dist/server/app-render-dependency.js +41 -0
- package/dist/server/app-request-context.d.ts +20 -0
- package/dist/server/app-request-context.js +29 -0
- package/dist/server/app-route-handler-cache.d.ts +46 -0
- package/dist/server/app-route-handler-cache.js +78 -0
- package/dist/server/app-route-handler-dispatch.d.ts +49 -0
- package/dist/server/app-route-handler-dispatch.js +163 -0
- package/dist/server/app-route-handler-execution.d.ts +86 -0
- package/dist/server/app-route-handler-execution.js +128 -0
- package/dist/server/app-route-handler-policy.d.ts +55 -0
- package/dist/server/app-route-handler-policy.js +58 -0
- package/dist/server/app-route-handler-response.d.ts +28 -0
- package/dist/server/app-route-handler-response.js +145 -0
- package/dist/server/app-route-handler-runtime.d.ts +39 -0
- package/dist/server/app-route-handler-runtime.js +250 -0
- package/dist/server/app-route-module-loader.d.ts +91 -0
- package/dist/server/app-route-module-loader.js +83 -0
- package/dist/server/app-router-entry.d.ts +13 -0
- package/dist/server/app-router-entry.js +49 -0
- package/dist/server/app-rsc-cache-busting.d.ts +64 -0
- package/dist/server/app-rsc-cache-busting.js +206 -0
- package/dist/server/app-rsc-embedded-chunks.d.ts +8 -0
- package/dist/server/app-rsc-embedded-chunks.js +32 -0
- package/dist/server/app-rsc-error-handler.d.ts +20 -0
- package/dist/server/app-rsc-error-handler.js +28 -0
- package/dist/server/app-rsc-errors.d.ts +40 -0
- package/dist/server/app-rsc-errors.js +60 -0
- package/dist/server/app-rsc-handler.d.ts +201 -0
- package/dist/server/app-rsc-handler.js +538 -0
- package/dist/server/app-rsc-render-mode.d.ts +11 -0
- package/dist/server/app-rsc-render-mode.js +25 -0
- package/dist/server/app-rsc-request-normalization.d.ts +48 -0
- package/dist/server/app-rsc-request-normalization.js +75 -0
- package/dist/server/app-rsc-response-finalizer.d.ts +37 -0
- package/dist/server/app-rsc-response-finalizer.js +54 -0
- package/dist/server/app-rsc-route-matching.d.ts +93 -0
- package/dist/server/app-rsc-route-matching.js +134 -0
- package/dist/server/app-segment-config.d.ts +46 -0
- package/dist/server/app-segment-config.js +113 -0
- package/dist/server/app-server-action-execution.d.ts +219 -0
- package/dist/server/app-server-action-execution.js +767 -0
- package/dist/server/app-ssr-entry.d.ts +52 -0
- package/dist/server/app-ssr-entry.js +295 -0
- package/dist/server/app-ssr-error-meta.d.ts +13 -0
- package/dist/server/app-ssr-error-meta.js +48 -0
- package/dist/server/app-ssr-router-instance.d.ts +6 -0
- package/dist/server/app-ssr-router-instance.js +24 -0
- package/dist/server/app-ssr-stream.d.ts +60 -0
- package/dist/server/app-ssr-stream.js +408 -0
- package/dist/server/app-static-generation.d.ts +15 -0
- package/dist/server/app-static-generation.js +19 -0
- package/dist/server/app-visited-response-cache.d.ts +23 -0
- package/dist/server/app-visited-response-cache.js +19 -0
- package/dist/server/artifact-compatibility.d.ts +54 -0
- package/dist/server/artifact-compatibility.js +91 -0
- package/dist/server/before-interactive-head.d.ts +17 -0
- package/dist/server/before-interactive-head.js +35 -0
- package/dist/server/cache-control.d.ts +37 -0
- package/dist/server/cache-control.js +56 -0
- package/dist/server/cache-headers.d.ts +6 -0
- package/dist/server/cache-headers.js +17 -0
- package/dist/server/cache-proof.d.ts +364 -0
- package/dist/server/cache-proof.js +794 -0
- package/dist/server/client-reuse-manifest.d.ts +104 -0
- package/dist/server/client-reuse-manifest.js +209 -0
- package/dist/server/client-trace-metadata.d.ts +30 -0
- package/dist/server/client-trace-metadata.js +81 -0
- package/dist/server/cookie-utils.d.ts +12 -0
- package/dist/server/cookie-utils.js +18 -0
- package/dist/server/csp.d.ts +10 -0
- package/dist/server/csp.js +41 -0
- package/dist/server/default-global-error-module.d.ts +19 -0
- package/dist/server/default-global-error-module.js +18 -0
- package/dist/server/default-not-found-module.d.ts +19 -0
- package/dist/server/default-not-found-module.js +18 -0
- package/dist/server/defer-until-stream-consumed.d.ts +7 -0
- package/dist/server/defer-until-stream-consumed.js +34 -0
- package/dist/server/dev-error-overlay-store.d.ts +39 -0
- package/dist/server/dev-error-overlay-store.js +86 -0
- package/dist/server/dev-error-overlay.d.ts +51 -0
- package/dist/server/dev-error-overlay.js +1341 -0
- package/dist/server/dev-initial-server-error.d.ts +9 -0
- package/dist/server/dev-initial-server-error.js +26 -0
- package/dist/server/dev-lockfile.d.ts +109 -0
- package/dist/server/dev-lockfile.js +179 -0
- package/dist/server/dev-module-runner.d.ts +30 -0
- package/dist/server/dev-module-runner.js +91 -0
- package/dist/server/dev-origin-check.d.ts +62 -0
- package/dist/server/dev-origin-check.js +156 -0
- package/dist/server/dev-route-files.d.ts +6 -0
- package/dist/server/dev-route-files.js +71 -0
- package/dist/server/dev-server.d.ts +58 -0
- package/dist/server/dev-server.js +1114 -0
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/server/dev-stack-sourcemap-endpoint.js +4 -0
- package/dist/server/dev-stack-sourcemap.d.ts +43 -0
- package/dist/server/dev-stack-sourcemap.js +443 -0
- package/dist/server/document-initial-head.d.ts +6 -0
- package/dist/server/document-initial-head.js +33 -0
- package/dist/server/edge-api-runtime.d.ts +4 -0
- package/dist/server/edge-api-runtime.js +6 -0
- package/dist/server/file-based-metadata.d.ts +29 -0
- package/dist/server/file-based-metadata.js +401 -0
- package/dist/server/headers.d.ts +114 -0
- package/dist/server/headers.js +136 -0
- package/dist/server/html.d.ts +28 -0
- package/dist/server/html.js +41 -0
- package/dist/server/http-error-responses.d.ts +91 -0
- package/dist/server/http-error-responses.js +105 -0
- package/dist/server/hybrid-route-priority.d.ts +22 -0
- package/dist/server/hybrid-route-priority.js +33 -0
- package/dist/server/image-optimization.d.ts +130 -0
- package/dist/server/image-optimization.js +247 -0
- package/dist/server/implicit-tags.d.ts +6 -0
- package/dist/server/implicit-tags.js +44 -0
- package/dist/server/instrumentation-runtime.d.ts +49 -0
- package/dist/server/instrumentation-runtime.js +35 -0
- package/dist/server/instrumentation.d.ts +85 -0
- package/dist/server/instrumentation.js +130 -0
- package/dist/server/isr-cache.d.ts +127 -0
- package/dist/server/isr-cache.js +282 -0
- package/dist/server/isr-decision.d.ts +79 -0
- package/dist/server/isr-decision.js +70 -0
- package/dist/server/metadata-route-build-data.d.ts +24 -0
- package/dist/server/metadata-route-build-data.js +148 -0
- package/dist/server/metadata-route-response.d.ts +16 -0
- package/dist/server/metadata-route-response.js +205 -0
- package/dist/server/metadata-routes.d.ts +139 -0
- package/dist/server/metadata-routes.js +433 -0
- package/dist/server/middleware-matcher.d.ts +14 -0
- package/dist/server/middleware-matcher.js +111 -0
- package/dist/server/middleware-request-headers.d.ts +11 -0
- package/dist/server/middleware-request-headers.js +65 -0
- package/dist/server/middleware-response-headers.d.ts +12 -0
- package/dist/server/middleware-response-headers.js +42 -0
- package/dist/server/middleware-runtime.d.ts +67 -0
- package/dist/server/middleware-runtime.js +240 -0
- package/dist/server/middleware.d.ts +62 -0
- package/dist/server/middleware.js +114 -0
- package/dist/server/navigation-planner.d.ts +308 -0
- package/dist/server/navigation-planner.js +831 -0
- package/dist/server/navigation-trace.d.ts +68 -0
- package/dist/server/navigation-trace.js +71 -0
- package/dist/server/next-error-digest.d.ts +44 -0
- package/dist/server/next-error-digest.js +40 -0
- package/dist/server/normalize-path.d.ts +38 -0
- package/dist/server/normalize-path.js +70 -0
- package/dist/server/open-redirect.d.ts +12 -0
- package/dist/server/open-redirect.js +21 -0
- package/dist/server/operation-token.d.ts +40 -0
- package/dist/server/operation-token.js +85 -0
- package/dist/server/otel-tracer-extension.d.ts +45 -0
- package/dist/server/otel-tracer-extension.js +89 -0
- package/dist/server/pages-api-route.d.ts +83 -0
- package/dist/server/pages-api-route.js +75 -0
- package/dist/server/pages-asset-tags.d.ts +78 -0
- package/dist/server/pages-asset-tags.js +126 -0
- package/dist/server/pages-body-parser-config.d.ts +59 -0
- package/dist/server/pages-body-parser-config.js +77 -0
- package/dist/server/pages-data-route.d.ts +121 -0
- package/dist/server/pages-data-route.js +157 -0
- package/dist/server/pages-default-404.d.ts +30 -0
- package/dist/server/pages-default-404.js +38 -0
- package/dist/server/pages-dev-module-url.d.ts +4 -0
- package/dist/server/pages-dev-module-url.js +15 -0
- package/dist/server/pages-document-initial-props.d.ts +77 -0
- package/dist/server/pages-document-initial-props.js +109 -0
- package/dist/server/pages-get-initial-props.d.ts +67 -0
- package/dist/server/pages-get-initial-props.js +92 -0
- package/dist/server/pages-i18n.d.ts +106 -0
- package/dist/server/pages-i18n.js +183 -0
- package/dist/server/pages-media-type.d.ts +15 -0
- package/dist/server/pages-media-type.js +24 -0
- package/dist/server/pages-node-compat.d.ts +55 -0
- package/dist/server/pages-node-compat.js +235 -0
- package/dist/server/pages-page-data.d.ts +223 -0
- package/dist/server/pages-page-data.js +484 -0
- package/dist/server/pages-page-handler.d.ts +100 -0
- package/dist/server/pages-page-handler.js +403 -0
- package/dist/server/pages-page-method.d.ts +47 -0
- package/dist/server/pages-page-method.js +17 -0
- package/dist/server/pages-page-response.d.ts +138 -0
- package/dist/server/pages-page-response.js +285 -0
- package/dist/server/pages-readiness.d.ts +36 -0
- package/dist/server/pages-readiness.js +21 -0
- package/dist/server/pages-request-pipeline.d.ts +116 -0
- package/dist/server/pages-request-pipeline.js +311 -0
- package/dist/server/pages-revalidate.d.ts +15 -0
- package/dist/server/pages-revalidate.js +19 -0
- package/dist/server/pages-serializable-props.d.ts +24 -0
- package/dist/server/pages-serializable-props.js +67 -0
- package/dist/server/pregenerated-concrete-paths.d.ts +16 -0
- package/dist/server/pregenerated-concrete-paths.js +61 -0
- package/dist/server/prerender-manifest.d.ts +33 -0
- package/dist/server/prerender-manifest.js +54 -0
- package/dist/server/prerender-route-params.d.ts +23 -0
- package/dist/server/prerender-route-params.js +113 -0
- package/dist/server/prerender-work-unit-setup.d.ts +6 -0
- package/dist/server/prerender-work-unit-setup.js +28 -0
- package/dist/server/prod-server.d.ts +148 -0
- package/dist/server/prod-server.js +1136 -0
- package/dist/server/proxy-trust.d.ts +40 -0
- package/dist/server/proxy-trust.js +68 -0
- package/dist/server/request-log.d.ts +39 -0
- package/dist/server/request-log.js +56 -0
- package/dist/server/request-pipeline.d.ts +187 -0
- package/dist/server/request-pipeline.js +447 -0
- package/dist/server/rsc-stream-hints.d.ts +10 -0
- package/dist/server/rsc-stream-hints.js +41 -0
- package/dist/server/seed-cache.d.ts +29 -0
- package/dist/server/seed-cache.js +125 -0
- package/dist/server/server-action-not-found.d.ts +21 -0
- package/dist/server/server-action-not-found.js +62 -0
- package/dist/server/server-globals.d.ts +4 -0
- package/dist/server/server-globals.js +35 -0
- package/dist/server/skip-cache-proof.d.ts +61 -0
- package/dist/server/skip-cache-proof.js +168 -0
- package/dist/server/socket-error-backstop.d.ts +34 -0
- package/dist/server/socket-error-backstop.js +200 -0
- package/dist/server/static-file-cache.d.ts +56 -0
- package/dist/server/static-file-cache.js +231 -0
- package/dist/server/static-layout-client-reuse-proof.d.ts +15 -0
- package/dist/server/static-layout-client-reuse-proof.js +33 -0
- package/dist/server/streaming-metadata.d.ts +4 -0
- package/dist/server/streaming-metadata.js +8 -0
- package/dist/server/worker-utils.d.ts +7 -0
- package/dist/server/worker-utils.js +99 -0
- package/dist/shims/amp.d.ts +19 -0
- package/dist/shims/amp.js +23 -0
- package/dist/shims/app-router-scroll-state.d.ts +15 -0
- package/dist/shims/app-router-scroll-state.js +61 -0
- package/dist/shims/app-router-scroll.d.ts +29 -0
- package/dist/shims/app-router-scroll.js +141 -0
- package/dist/shims/app.d.ts +42 -0
- package/dist/shims/app.js +48 -0
- package/dist/shims/before-interactive-context.d.ts +40 -0
- package/dist/shims/before-interactive-context.js +8 -0
- package/dist/shims/cache-for-request.d.ts +57 -0
- package/dist/shims/cache-for-request.js +72 -0
- package/dist/shims/cache-handler.d.ts +106 -0
- package/dist/shims/cache-handler.js +176 -0
- package/dist/shims/cache-request-state.d.ts +47 -0
- package/dist/shims/cache-request-state.js +126 -0
- package/dist/shims/cache-runtime.d.ts +83 -0
- package/dist/shims/cache-runtime.js +452 -0
- package/dist/shims/cache.d.ts +145 -0
- package/dist/shims/cache.js +401 -0
- package/dist/shims/cdn-cache.d.ts +125 -0
- package/dist/shims/cdn-cache.js +100 -0
- package/dist/shims/client-hook-error.d.ts +13 -0
- package/dist/shims/client-hook-error.js +17 -0
- package/dist/shims/client-locale.d.ts +14 -0
- package/dist/shims/client-locale.js +11 -0
- package/dist/shims/client-only.d.ts +1 -0
- package/dist/shims/client-only.js +1 -0
- package/dist/shims/compat-router.d.ts +16 -0
- package/dist/shims/compat-router.js +25 -0
- package/dist/shims/config.d.ts +28 -0
- package/dist/shims/config.js +21 -0
- package/dist/shims/constants.d.ts +130 -0
- package/dist/shims/constants.js +167 -0
- package/dist/shims/default-global-error.d.ts +31 -0
- package/dist/shims/default-global-error.js +179 -0
- package/dist/shims/default-not-found.d.ts +11 -0
- package/dist/shims/default-not-found.js +59 -0
- package/dist/shims/document.d.ts +92 -0
- package/dist/shims/document.js +76 -0
- package/dist/shims/dynamic-preload-chunks.d.ts +8 -0
- package/dist/shims/dynamic-preload-chunks.js +79 -0
- package/dist/shims/dynamic.d.ts +35 -0
- package/dist/shims/dynamic.js +204 -0
- package/dist/shims/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +44 -0
- package/dist/shims/error-boundary.d.ts +155 -0
- package/dist/shims/error-boundary.js +342 -0
- package/dist/shims/error.d.ts +31 -0
- package/dist/shims/error.js +123 -0
- package/dist/shims/error.react-server.d.ts +9 -0
- package/dist/shims/error.react-server.js +6 -0
- package/dist/shims/fetch-cache.d.ts +136 -0
- package/dist/shims/fetch-cache.js +766 -0
- package/dist/shims/font-google-base.d.ts +83 -0
- package/dist/shims/font-google-base.js +290 -0
- package/dist/shims/font-google.d.ts +2 -0
- package/dist/shims/font-google.js +2 -0
- package/dist/shims/font-local.d.ts +50 -0
- package/dist/shims/font-local.js +195 -0
- package/dist/shims/font-utils.d.ts +56 -0
- package/dist/shims/font-utils.js +107 -0
- package/dist/shims/form.d.ts +19 -0
- package/dist/shims/form.js +236 -0
- package/dist/shims/hash-scroll.d.ts +10 -0
- package/dist/shims/hash-scroll.js +47 -0
- package/dist/shims/head-state.d.ts +16 -0
- package/dist/shims/head-state.js +43 -0
- package/dist/shims/head.d.ts +73 -0
- package/dist/shims/head.js +340 -0
- package/dist/shims/headers.d.ts +253 -0
- package/dist/shims/headers.js +754 -0
- package/dist/shims/i18n-context.d.ts +22 -0
- package/dist/shims/i18n-context.js +42 -0
- package/dist/shims/i18n-state.d.ts +14 -0
- package/dist/shims/i18n-state.js +38 -0
- package/dist/shims/image-config.d.ts +45 -0
- package/dist/shims/image-config.js +85 -0
- package/dist/shims/image.d.ts +55 -0
- package/dist/shims/image.js +582 -0
- package/dist/shims/internal/als-registry.d.ts +14 -0
- package/dist/shims/internal/als-registry.js +80 -0
- package/dist/shims/internal/api-utils.d.ts +14 -0
- package/dist/shims/internal/api-utils.js +1 -0
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -0
- package/dist/shims/internal/app-page-props-cache-key.js +16 -0
- package/dist/shims/internal/app-route-detection.d.ts +39 -0
- package/dist/shims/internal/app-route-detection.js +62 -0
- package/dist/shims/internal/app-router-context.d.ts +31 -0
- package/dist/shims/internal/app-router-context.js +28 -0
- package/dist/shims/internal/cookie-serialize.d.ts +45 -0
- package/dist/shims/internal/cookie-serialize.js +49 -0
- package/dist/shims/internal/cookies.d.ts +2 -0
- package/dist/shims/internal/cookies.js +2 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
- package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
- package/dist/shims/internal/interpolate-as.d.ts +25 -0
- package/dist/shims/internal/interpolate-as.js +196 -0
- package/dist/shims/internal/link-status-registry.d.ts +43 -0
- package/dist/shims/internal/link-status-registry.js +42 -0
- package/dist/shims/internal/make-hanging-promise.d.ts +15 -0
- package/dist/shims/internal/make-hanging-promise.js +44 -0
- package/dist/shims/internal/navigation-untracked.d.ts +35 -0
- package/dist/shims/internal/navigation-untracked.js +56 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +54 -0
- package/dist/shims/internal/pages-data-fetch-dedup.js +121 -0
- package/dist/shims/internal/pages-data-target.d.ts +62 -0
- package/dist/shims/internal/pages-data-target.js +98 -0
- package/dist/shims/internal/pages-data-url.d.ts +41 -0
- package/dist/shims/internal/pages-data-url.js +71 -0
- package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
- package/dist/shims/internal/pages-router-accessor.js +13 -0
- package/dist/shims/internal/route-pattern-for-warning.d.ts +27 -0
- package/dist/shims/internal/route-pattern-for-warning.js +40 -0
- package/dist/shims/internal/router-context.d.ts +7 -0
- package/dist/shims/internal/router-context.js +13 -0
- package/dist/shims/internal/utils.d.ts +52 -0
- package/dist/shims/internal/utils.js +27 -0
- package/dist/shims/internal/work-unit-async-storage.d.ts +30 -0
- package/dist/shims/internal/work-unit-async-storage.js +17 -0
- package/dist/shims/layout-segment-context.d.ts +24 -0
- package/dist/shims/layout-segment-context.js +39 -0
- package/dist/shims/legacy-image.d.ts +41 -0
- package/dist/shims/legacy-image.js +49 -0
- package/dist/shims/link-prefetch.d.ts +41 -0
- package/dist/shims/link-prefetch.js +43 -0
- package/dist/shims/link.d.ts +102 -0
- package/dist/shims/link.js +687 -0
- package/dist/shims/metadata.d.ts +285 -0
- package/dist/shims/metadata.js +820 -0
- package/dist/shims/navigation-context-state.d.ts +40 -0
- package/dist/shims/navigation-context-state.js +116 -0
- package/dist/shims/navigation-errors.d.ts +55 -0
- package/dist/shims/navigation-errors.js +110 -0
- package/dist/shims/navigation-server.d.ts +3 -0
- package/dist/shims/navigation-server.js +3 -0
- package/dist/shims/navigation-state.d.ts +25 -0
- package/dist/shims/navigation-state.js +66 -0
- package/dist/shims/navigation.d.ts +286 -0
- package/dist/shims/navigation.js +1206 -0
- package/dist/shims/navigation.react-server.d.ts +14 -0
- package/dist/shims/navigation.react-server.js +32 -0
- package/dist/shims/offline.d.ts +4 -0
- package/dist/shims/offline.js +15 -0
- package/dist/shims/og.d.ts +17 -0
- package/dist/shims/og.js +48 -0
- package/dist/shims/pages-router-runtime.d.ts +12 -0
- package/dist/shims/pages-router-runtime.js +24 -0
- package/dist/shims/ppr-fallback-shell.d.ts +33 -0
- package/dist/shims/ppr-fallback-shell.js +170 -0
- package/dist/shims/readonly-url-search-params.d.ts +13 -0
- package/dist/shims/readonly-url-search-params.js +26 -0
- package/dist/shims/request-context.d.ts +58 -0
- package/dist/shims/request-context.js +45 -0
- package/dist/shims/request-state-types.d.ts +12 -0
- package/dist/shims/request-state-types.js +1 -0
- package/dist/shims/root-params.d.ts +12 -0
- package/dist/shims/root-params.js +30 -0
- package/dist/shims/router-state.d.ts +32 -0
- package/dist/shims/router-state.js +39 -0
- package/dist/shims/router.d.ts +192 -0
- package/dist/shims/router.js +1786 -0
- package/dist/shims/script-nonce-context.d.ts +11 -0
- package/dist/shims/script-nonce-context.js +23 -0
- package/dist/shims/script.d.ts +43 -0
- package/dist/shims/script.js +370 -0
- package/dist/shims/server-only.d.ts +1 -0
- package/dist/shims/server-only.js +1 -0
- package/dist/shims/server.d.ts +323 -0
- package/dist/shims/server.js +729 -0
- package/dist/shims/slot.d.ts +45 -0
- package/dist/shims/slot.js +230 -0
- package/dist/shims/thenable-params.d.ts +11 -0
- package/dist/shims/thenable-params.js +176 -0
- package/dist/shims/unified-request-context.d.ts +68 -0
- package/dist/shims/unified-request-context.js +86 -0
- package/dist/shims/unrecognized-action-error.d.ts +34 -0
- package/dist/shims/unrecognized-action-error.js +39 -0
- package/dist/shims/url-safety.d.ts +34 -0
- package/dist/shims/url-safety.js +70 -0
- package/dist/shims/url-utils.d.ts +51 -0
- package/dist/shims/url-utils.js +156 -0
- package/dist/shims/use-merged-ref.d.ts +6 -0
- package/dist/shims/use-merged-ref.js +38 -0
- package/dist/shims/web-vitals.d.ts +8 -0
- package/dist/shims/web-vitals.js +22 -0
- package/dist/typegen.d.ts +9 -0
- package/dist/typegen.js +228 -0
- package/dist/utils/asset-prefix.d.ts +96 -0
- package/dist/utils/asset-prefix.js +122 -0
- package/dist/utils/base-path.d.ts +31 -0
- package/dist/utils/base-path.js +45 -0
- package/dist/utils/built-asset-url.d.ts +4 -0
- package/dist/utils/built-asset-url.js +11 -0
- package/dist/utils/cache-control-metadata.d.ts +4 -0
- package/dist/utils/cache-control-metadata.js +12 -0
- package/dist/utils/client-build-manifest.d.ts +21 -0
- package/dist/utils/client-build-manifest.js +87 -0
- package/dist/utils/client-entry-manifest.d.ts +11 -0
- package/dist/utils/client-entry-manifest.js +29 -0
- package/dist/utils/client-runtime-metadata.d.ts +45 -0
- package/dist/utils/client-runtime-metadata.js +63 -0
- package/dist/utils/commonjs-loader.d.ts +16 -0
- package/dist/utils/commonjs-loader.js +100 -0
- package/dist/utils/compare.d.ts +4 -0
- package/dist/utils/compare.js +8 -0
- package/dist/utils/deployment-id.d.ts +8 -0
- package/dist/utils/deployment-id.js +22 -0
- package/dist/utils/dev-error-recovery-event.d.ts +4 -0
- package/dist/utils/dev-error-recovery-event.js +4 -0
- package/dist/utils/domain-locale.d.ts +26 -0
- package/dist/utils/domain-locale.js +50 -0
- package/dist/utils/encode-cache-tag.d.ts +30 -0
- package/dist/utils/encode-cache-tag.js +36 -0
- package/dist/utils/error-cause.d.ts +4 -0
- package/dist/utils/error-cause.js +95 -0
- package/dist/utils/has-trailing-comma.d.ts +24 -0
- package/dist/utils/has-trailing-comma.js +62 -0
- package/dist/utils/hash.d.ts +24 -0
- package/dist/utils/hash.js +55 -0
- package/dist/utils/html-limited-bots.d.ts +21 -0
- package/dist/utils/html-limited-bots.js +35 -0
- package/dist/utils/lazy-chunks.d.ts +59 -0
- package/dist/utils/lazy-chunks.js +112 -0
- package/dist/utils/manifest-paths.d.ts +30 -0
- package/dist/utils/manifest-paths.js +66 -0
- package/dist/utils/mdx-scan.d.ts +9 -0
- package/dist/utils/mdx-scan.js +34 -0
- package/dist/utils/navigation-signal.d.ts +4 -0
- package/dist/utils/navigation-signal.js +12 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/number.js +6 -0
- package/dist/utils/parse-cookie.d.ts +13 -0
- package/dist/utils/parse-cookie.js +52 -0
- package/dist/utils/path.d.ts +22 -0
- package/dist/utils/path.js +30 -0
- package/dist/utils/prerender-output-paths.d.ts +14 -0
- package/dist/utils/prerender-output-paths.js +22 -0
- package/dist/utils/project.d.ts +76 -0
- package/dist/utils/project.js +213 -0
- package/dist/utils/promise.d.ts +4 -0
- package/dist/utils/promise.js +6 -0
- package/dist/utils/public-routes.d.ts +4 -0
- package/dist/utils/public-routes.js +48 -0
- package/dist/utils/query.d.ts +49 -0
- package/dist/utils/query.js +122 -0
- package/dist/utils/record.d.ts +4 -0
- package/dist/utils/record.js +6 -0
- package/dist/utils/regex.d.ts +4 -0
- package/dist/utils/regex.js +6 -0
- package/dist/utils/safe-json-file.d.ts +17 -0
- package/dist/utils/safe-json-file.js +23 -0
- package/dist/utils/sorted-array.d.ts +8 -0
- package/dist/utils/sorted-array.js +20 -0
- package/dist/utils/text-stream.d.ts +28 -0
- package/dist/utils/text-stream.js +64 -0
- package/dist/utils/vinext-root.d.ts +23 -0
- package/dist/utils/vinext-root.js +29 -0
- package/dist/utils/virtual-module.d.ts +5 -0
- package/dist/utils/virtual-module.js +0 -0
- package/dist/utils/vite-version.d.ts +21 -0
- package/dist/utils/vite-version.js +42 -0
- package/package.json +145 -0
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
import { escapeRegExp } from "../utils/regex.js";
|
|
2
|
+
import { lastSignificantChar } from "../utils/has-trailing-comma.js";
|
|
3
|
+
import { buildFallbackFontFace, getFallbackFontOverrideMetrics } from "../build/google-fonts/fallback-metrics.js";
|
|
4
|
+
import { validateGoogleFontOptions } from "../build/google-fonts/validate.js";
|
|
5
|
+
import { getFontAxes } from "../build/google-fonts/get-axes.js";
|
|
6
|
+
import { buildGoogleFontsUrl } from "../build/google-fonts/build-url.js";
|
|
7
|
+
import { findFontFilesInCss } from "../build/google-fonts/find-font-files-in-css.js";
|
|
8
|
+
import { ASSET_PREFIX_URL_DIR } from "../utils/asset-prefix.js";
|
|
9
|
+
import { CONTENT_TYPES } from "../server/static-file-cache.js";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { parseAst } from "vite";
|
|
13
|
+
import MagicString from "magic-string";
|
|
14
|
+
//#region src/plugins/fonts.ts
|
|
15
|
+
/**
|
|
16
|
+
* Thrown when Google Fonts returns a non-2xx response. Distinct from a raw
|
|
17
|
+
* `fetch` rejection (network error, DNS failure, AbortError) so the call
|
|
18
|
+
* site can decide whether to surface as a build error or fall through to
|
|
19
|
+
* the runtime CDN path.
|
|
20
|
+
*/
|
|
21
|
+
var GoogleFontsHttpError = class extends Error {
|
|
22
|
+
url;
|
|
23
|
+
status;
|
|
24
|
+
responseBody;
|
|
25
|
+
constructor(url, status, responseBody) {
|
|
26
|
+
super(`Google Fonts returned HTTP ${status} for ${url}`);
|
|
27
|
+
this.url = url;
|
|
28
|
+
this.status = status;
|
|
29
|
+
this.responseBody = responseBody;
|
|
30
|
+
this.name = "GoogleFontsHttpError";
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const VIRTUAL_GOOGLE_FONTS = "virtual:vinext-google-fonts";
|
|
34
|
+
const RESOLVED_VIRTUAL_GOOGLE_FONTS = "\0virtual:vinext-google-fonts";
|
|
35
|
+
const GOOGLE_FONT_UTILITY_EXPORTS = new Set([
|
|
36
|
+
"buildGoogleFontsUrl",
|
|
37
|
+
"getSSRFontLinks",
|
|
38
|
+
"getSSRFontStyles",
|
|
39
|
+
"getSSRFontPreloads",
|
|
40
|
+
"createFontLoader"
|
|
41
|
+
]);
|
|
42
|
+
/**
|
|
43
|
+
* Served URL prefix for self-hosted Google Font files.
|
|
44
|
+
*
|
|
45
|
+
* `fetchAndCacheFont()` downloads .woff2 files into `<root>/.vinext/fonts/`
|
|
46
|
+
* and writes an `@font-face` CSS snippet whose `src: url(...)` references
|
|
47
|
+
* the files by absolute filesystem path — convenient for disk, unusable at
|
|
48
|
+
* runtime because browsers resolve relative to the origin. Before the CSS
|
|
49
|
+
* is embedded in the bundle as `_vinext.font.selfHostedCSS`, the filesystem
|
|
50
|
+
* prefix is rewritten to this URL prefix by `_rewriteCachedFontCssToServedUrls()`,
|
|
51
|
+
* and the matching `writeBundle` hook in `createGoogleFontsPlugin` copies
|
|
52
|
+
* the font files into `<clientOutDir>/<assetsDir>/_vinext_fonts/` so the
|
|
53
|
+
* rewritten URL actually resolves against the origin at request time.
|
|
54
|
+
*
|
|
55
|
+
* The leading `_` keeps the namespace distinct from Vite's content-hashed
|
|
56
|
+
* asset names (which are emitted flat into `<assetsDir>/`) and from any
|
|
57
|
+
* user-provided public files.
|
|
58
|
+
*/
|
|
59
|
+
const VINEXT_FONT_URL_NAMESPACE = "_vinext_fonts";
|
|
60
|
+
const MAX_GOOGLE_FONTS_ERROR_BODY_LENGTH = 500;
|
|
61
|
+
function formatGoogleFontsErrorBody(body) {
|
|
62
|
+
const trimmed = body.trim();
|
|
63
|
+
if (!trimmed) return "(empty response body)";
|
|
64
|
+
if (trimmed.length <= MAX_GOOGLE_FONTS_ERROR_BODY_LENGTH) return trimmed;
|
|
65
|
+
const omitted = trimmed.length - MAX_GOOGLE_FONTS_ERROR_BODY_LENGTH;
|
|
66
|
+
return `${trimmed.slice(0, MAX_GOOGLE_FONTS_ERROR_BODY_LENGTH)}\n... (truncated ${omitted} characters)`;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Rewrite absolute filesystem paths in cached Google Fonts CSS so the
|
|
70
|
+
* `@font-face { src: url(...) }` references point at the served URL the
|
|
71
|
+
* plugin's `writeBundle` hook copies the font files to.
|
|
72
|
+
*
|
|
73
|
+
* This is called once per transform, before the CSS string is embedded in
|
|
74
|
+
* the bundle as `_vinext.font.selfHostedCSS`. Every downstream consumer reads
|
|
75
|
+
* from the same rewritten CSS: the injected `<style data-vinext-fonts>` block, the
|
|
76
|
+
* HTML body's `<link rel="preload">` tags (via `collectFontPreloadsFromCSS`
|
|
77
|
+
* in `shims/font-google-base.ts`), and the HTTP `Link:` response header
|
|
78
|
+
* (via `buildAppPageFontLinkHeader` in `server/app-page-execution.ts`).
|
|
79
|
+
*
|
|
80
|
+
* Without this rewrite, all three emit the dev-machine filesystem path
|
|
81
|
+
* (e.g. `/home/user/project/.vinext/fonts/geist-<hash>/geist-<hash>.woff2`)
|
|
82
|
+
* and any production request fetches `<origin>/home/user/...` → 404.
|
|
83
|
+
*
|
|
84
|
+
* `assetsDir` must match whatever Vite has resolved for
|
|
85
|
+
* `build.assetsDir` on the client environment — otherwise the embedded
|
|
86
|
+
* CSS URLs and the files emitted by the `writeBundle` hook would diverge
|
|
87
|
+
* and a user who customizes `build.assetsDir` (e.g. to `"static"`) would
|
|
88
|
+
* see 404s on every preload. The call site in `injectSelfHostedCss`
|
|
89
|
+
* passes the resolved value through from plugin state. The default is
|
|
90
|
+
* kept only so the exported helper can be driven directly from unit
|
|
91
|
+
* tests without synthesizing a full plugin context.
|
|
92
|
+
*
|
|
93
|
+
* Uses split/join rather than regex because `cacheDir` is an absolute
|
|
94
|
+
* filesystem path that may contain regex metacharacters on unusual
|
|
95
|
+
* filesystems.
|
|
96
|
+
*/
|
|
97
|
+
function _rewriteCachedFontCssToServedUrls(css, cacheDir, assetsDir = DEFAULT_ASSETS_DIR) {
|
|
98
|
+
if (!cacheDir || !css.includes(cacheDir)) return css;
|
|
99
|
+
const prefix = assetsDir || DEFAULT_ASSETS_DIR;
|
|
100
|
+
return css.split(cacheDir).join(`/${prefix}/${VINEXT_FONT_URL_NAMESPACE}`);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Default `build.assetsDir` — matches vinext's resolved default in
|
|
104
|
+
* `resolveAssetsDir("")` (Next.js's canonical convention). Used as the
|
|
105
|
+
* fallback for the `assetsDir` parameter of
|
|
106
|
+
* `_rewriteCachedFontCssToServedUrls` so the exported helper can be unit
|
|
107
|
+
* tested without synthesizing plugin state. Production call sites thread
|
|
108
|
+
* the real `envConfig.build.assetsDir` resolved by Vite through so that
|
|
109
|
+
* the embedded CSS URLs always match the directory the `writeBundle`
|
|
110
|
+
* hook copies the font files into.
|
|
111
|
+
*/
|
|
112
|
+
const DEFAULT_ASSETS_DIR = ASSET_PREFIX_URL_DIR;
|
|
113
|
+
/**
|
|
114
|
+
* Safely parse a static JS object literal string into a plain object.
|
|
115
|
+
* Uses Vite's parseAst (Rollup/acorn) so no code is ever evaluated.
|
|
116
|
+
* Returns null if the expression contains anything dynamic (function calls,
|
|
117
|
+
* template literals, identifiers, computed properties, etc.).
|
|
118
|
+
*
|
|
119
|
+
* Supports: string literals, numeric literals, boolean literals,
|
|
120
|
+
* arrays of the above, and nested object literals.
|
|
121
|
+
*/
|
|
122
|
+
function parseStaticObjectLiteral(objectStr) {
|
|
123
|
+
let ast;
|
|
124
|
+
try {
|
|
125
|
+
ast = parseAst(`(${objectStr})`);
|
|
126
|
+
} catch {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const body = ast.body;
|
|
130
|
+
if (body.length !== 1 || body[0].type !== "ExpressionStatement") return null;
|
|
131
|
+
const expr = body[0].expression;
|
|
132
|
+
if (expr.type !== "ObjectExpression") return null;
|
|
133
|
+
const result = extractStaticValue(expr);
|
|
134
|
+
return result === void 0 ? null : result;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Recursively extract a static value from an ESTree AST node.
|
|
138
|
+
* Returns undefined (not null) if the node contains any dynamic expression.
|
|
139
|
+
*
|
|
140
|
+
* Uses `any` for the node parameter because Rollup's internal ESTree types
|
|
141
|
+
* (estree.Expression, estree.ObjectExpression, etc.) aren't re-exported by Vite,
|
|
142
|
+
* and the recursive traversal touches many different node shapes.
|
|
143
|
+
*/
|
|
144
|
+
function extractStaticValue(node) {
|
|
145
|
+
switch (node.type) {
|
|
146
|
+
case "Literal": return node.value;
|
|
147
|
+
case "UnaryExpression":
|
|
148
|
+
if (node.operator === "-" && node.argument?.type === "Literal" && typeof node.argument.value === "number") return -node.argument.value;
|
|
149
|
+
return;
|
|
150
|
+
case "ArrayExpression": {
|
|
151
|
+
const arr = [];
|
|
152
|
+
for (const elem of node.elements) {
|
|
153
|
+
if (!elem) return void 0;
|
|
154
|
+
const val = extractStaticValue(elem);
|
|
155
|
+
if (val === void 0) return void 0;
|
|
156
|
+
arr.push(val);
|
|
157
|
+
}
|
|
158
|
+
return arr;
|
|
159
|
+
}
|
|
160
|
+
case "ObjectExpression": {
|
|
161
|
+
const obj = {};
|
|
162
|
+
for (const prop of node.properties) {
|
|
163
|
+
if (prop.type !== "Property") return void 0;
|
|
164
|
+
if (prop.computed) return void 0;
|
|
165
|
+
let key;
|
|
166
|
+
if (prop.key.type === "Identifier") key = prop.key.name;
|
|
167
|
+
else if (prop.key.type === "Literal" && typeof prop.key.value === "string") key = prop.key.value;
|
|
168
|
+
else return;
|
|
169
|
+
const val = extractStaticValue(prop.value);
|
|
170
|
+
if (val === void 0) return void 0;
|
|
171
|
+
obj[key] = val;
|
|
172
|
+
}
|
|
173
|
+
return obj;
|
|
174
|
+
}
|
|
175
|
+
default: return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function encodeGoogleFontsVirtualId(payload) {
|
|
179
|
+
const params = new URLSearchParams();
|
|
180
|
+
if (payload.hasDefault) params.set("default", "1");
|
|
181
|
+
if (payload.fonts.length > 0) params.set("fonts", payload.fonts.join(","));
|
|
182
|
+
if (payload.utilities.length > 0) params.set("utilities", payload.utilities.join(","));
|
|
183
|
+
return `${VIRTUAL_GOOGLE_FONTS}?${params.toString()}`;
|
|
184
|
+
}
|
|
185
|
+
function parseGoogleFontsVirtualId(id) {
|
|
186
|
+
const cleanId = id.startsWith("\0") ? id.slice(1) : id;
|
|
187
|
+
if (!cleanId.startsWith("virtual:vinext-google-fonts")) return null;
|
|
188
|
+
const queryIndex = cleanId.indexOf("?");
|
|
189
|
+
const params = new URLSearchParams(queryIndex === -1 ? "" : cleanId.slice(queryIndex + 1));
|
|
190
|
+
return {
|
|
191
|
+
hasDefault: params.get("default") === "1",
|
|
192
|
+
fonts: params.get("fonts")?.split(",").map((value) => value.trim()).filter(Boolean) ?? [],
|
|
193
|
+
utilities: params.get("utilities")?.split(",").map((value) => value.trim()).filter(Boolean) ?? []
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function generateGoogleFontsVirtualModule(id, fontGoogleShimPath) {
|
|
197
|
+
const payload = parseGoogleFontsVirtualId(id);
|
|
198
|
+
if (!payload) return null;
|
|
199
|
+
const utilities = Array.from(new Set(payload.utilities));
|
|
200
|
+
const fonts = Array.from(new Set(payload.fonts));
|
|
201
|
+
const lines = [];
|
|
202
|
+
lines.push(`import { createFontLoader } from ${JSON.stringify(fontGoogleShimPath)};`);
|
|
203
|
+
const reExports = [];
|
|
204
|
+
if (payload.hasDefault) reExports.push("default");
|
|
205
|
+
reExports.push(...utilities);
|
|
206
|
+
if (reExports.length > 0) lines.push(`export { ${reExports.join(", ")} } from ${JSON.stringify(fontGoogleShimPath)};`);
|
|
207
|
+
for (const fontName of fonts) {
|
|
208
|
+
const family = fontName.replace(/_/g, " ");
|
|
209
|
+
lines.push(`export const ${fontName} = /*#__PURE__*/ createFontLoader(${JSON.stringify(family)});`);
|
|
210
|
+
}
|
|
211
|
+
lines.push("");
|
|
212
|
+
return lines.join("\n");
|
|
213
|
+
}
|
|
214
|
+
function parseGoogleFontNamedSpecifiers(specifiersStr, forceType = false) {
|
|
215
|
+
return specifiersStr.split(",").map((spec) => spec.trim()).filter(Boolean).map((raw) => {
|
|
216
|
+
const isType = forceType || raw.startsWith("type ");
|
|
217
|
+
const asParts = (isType ? raw.replace(/^type\s+/, "") : raw).split(/\s+as\s+/);
|
|
218
|
+
return {
|
|
219
|
+
imported: asParts[0]?.trim() ?? "",
|
|
220
|
+
local: (asParts[1] || asParts[0] || "").trim(),
|
|
221
|
+
isType,
|
|
222
|
+
raw
|
|
223
|
+
};
|
|
224
|
+
}).filter((spec) => spec.imported.length > 0 && spec.local.length > 0);
|
|
225
|
+
}
|
|
226
|
+
function parseGoogleFontImportClause(clause) {
|
|
227
|
+
const trimmed = clause.trim();
|
|
228
|
+
if (trimmed.startsWith("type ")) {
|
|
229
|
+
const braceStart = trimmed.indexOf("{");
|
|
230
|
+
const braceEnd = trimmed.lastIndexOf("}");
|
|
231
|
+
if (braceStart === -1 || braceEnd === -1) return {
|
|
232
|
+
defaultLocal: null,
|
|
233
|
+
namespaceLocal: null,
|
|
234
|
+
named: []
|
|
235
|
+
};
|
|
236
|
+
return {
|
|
237
|
+
defaultLocal: null,
|
|
238
|
+
namespaceLocal: null,
|
|
239
|
+
named: parseGoogleFontNamedSpecifiers(trimmed.slice(braceStart + 1, braceEnd), true)
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const braceStart = trimmed.indexOf("{");
|
|
243
|
+
const braceEnd = trimmed.lastIndexOf("}");
|
|
244
|
+
if (braceStart !== -1 && braceEnd !== -1) return {
|
|
245
|
+
defaultLocal: trimmed.slice(0, braceStart).trim().replace(/,\s*$/, "").trim() || null,
|
|
246
|
+
namespaceLocal: null,
|
|
247
|
+
named: parseGoogleFontNamedSpecifiers(trimmed.slice(braceStart + 1, braceEnd))
|
|
248
|
+
};
|
|
249
|
+
const commaIndex = trimmed.indexOf(",");
|
|
250
|
+
if (commaIndex !== -1) {
|
|
251
|
+
const defaultLocal = trimmed.slice(0, commaIndex).trim() || null;
|
|
252
|
+
const rest = trimmed.slice(commaIndex + 1).trim();
|
|
253
|
+
if (rest.startsWith("* as ")) return {
|
|
254
|
+
defaultLocal,
|
|
255
|
+
namespaceLocal: rest.slice(5).trim() || null,
|
|
256
|
+
named: []
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
if (trimmed.startsWith("* as ")) return {
|
|
260
|
+
defaultLocal: null,
|
|
261
|
+
namespaceLocal: trimmed.slice(5).trim() || null,
|
|
262
|
+
named: []
|
|
263
|
+
};
|
|
264
|
+
return {
|
|
265
|
+
defaultLocal: trimmed || null,
|
|
266
|
+
namespaceLocal: null,
|
|
267
|
+
named: []
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function propertyNameToGoogleFontFamily(prop) {
|
|
271
|
+
return prop.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Fetch Google Fonts CSS, download .woff2 files, cache locally, and return
|
|
275
|
+
* @font-face CSS with local file references.
|
|
276
|
+
*
|
|
277
|
+
* Cache dir structure: .vinext/fonts/<family-hash>/
|
|
278
|
+
* - style.css (the rewritten @font-face CSS)
|
|
279
|
+
* - *.woff2 (downloaded font files)
|
|
280
|
+
*/
|
|
281
|
+
async function fetchAndCacheFont(cssUrl, family, cacheDir) {
|
|
282
|
+
const { createHash } = await import("node:crypto");
|
|
283
|
+
const urlHash = createHash("md5").update(cssUrl).digest("hex").slice(0, 12);
|
|
284
|
+
const fontDir = path.join(cacheDir, `${family.toLowerCase().replace(/\s+/g, "-")}-${urlHash}`);
|
|
285
|
+
const cachedCSSPath = path.join(fontDir, "style.css");
|
|
286
|
+
if (fs.existsSync(cachedCSSPath)) return fs.readFileSync(cachedCSSPath, "utf-8");
|
|
287
|
+
const cssResponse = await fetch(cssUrl, { headers: { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" } });
|
|
288
|
+
if (!cssResponse.ok) {
|
|
289
|
+
const body = await cssResponse.text().catch(() => "");
|
|
290
|
+
throw new GoogleFontsHttpError(cssUrl, cssResponse.status, body);
|
|
291
|
+
}
|
|
292
|
+
let css = await cssResponse.text();
|
|
293
|
+
const urlRe = /url\((https:\/\/fonts\.gstatic\.com\/[^)]+)\)/g;
|
|
294
|
+
const urls = /* @__PURE__ */ new Map();
|
|
295
|
+
let urlMatch;
|
|
296
|
+
while ((urlMatch = urlRe.exec(css)) !== null) {
|
|
297
|
+
const fontUrl = urlMatch[1];
|
|
298
|
+
if (!urls.has(fontUrl)) {
|
|
299
|
+
const ext = fontUrl.includes(".woff2") ? ".woff2" : fontUrl.includes(".woff") ? ".woff" : ".ttf";
|
|
300
|
+
const fileHash = createHash("md5").update(fontUrl).digest("hex").slice(0, 8);
|
|
301
|
+
urls.set(fontUrl, `${family.toLowerCase().replace(/\s+/g, "-")}-${fileHash}${ext}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
fs.mkdirSync(fontDir, { recursive: true });
|
|
305
|
+
for (const [fontUrl, filename] of urls) {
|
|
306
|
+
const filePath = path.join(fontDir, filename);
|
|
307
|
+
if (!fs.existsSync(filePath)) {
|
|
308
|
+
const fontResponse = await fetch(fontUrl);
|
|
309
|
+
if (fontResponse.ok) {
|
|
310
|
+
const buffer = Buffer.from(await fontResponse.arrayBuffer());
|
|
311
|
+
fs.writeFileSync(filePath, buffer);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
css = css.split(fontUrl).join(filePath.replaceAll("\\", "/"));
|
|
315
|
+
}
|
|
316
|
+
fs.writeFileSync(cachedCSSPath, css);
|
|
317
|
+
return css;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Create the `vinext:google-fonts` Vite plugin.
|
|
321
|
+
*
|
|
322
|
+
* @param fontGoogleShimPath - Absolute path to the font-google shim module
|
|
323
|
+
* (either `.ts` in source or `.js` in built packages). Resolved by the caller
|
|
324
|
+
* so the plugin file has no dependency on `__dirname`.
|
|
325
|
+
* @param shimsDir - Absolute path to the shims directory. Used to skip shim
|
|
326
|
+
* files from transform (they contain `next/font/google` references that must
|
|
327
|
+
* not be rewritten).
|
|
328
|
+
*/
|
|
329
|
+
/**
|
|
330
|
+
* Scan `code` forward from `searchStart` for a `{...}` object literal that
|
|
331
|
+
* may contain arbitrarily nested braces. Returns `[objStart, objEnd]` where
|
|
332
|
+
* `code[objStart] === '{'` and `code[objEnd - 1] === '}'`, or `null` if no
|
|
333
|
+
* balanced object is found.
|
|
334
|
+
*
|
|
335
|
+
* String literals (single-quoted, double-quoted, and backtick template
|
|
336
|
+
* literals including `${...}` interpolations) are fully skipped so that brace
|
|
337
|
+
* characters inside string values do not affect the depth count.
|
|
338
|
+
*/
|
|
339
|
+
function _findBalancedObject(code, searchStart) {
|
|
340
|
+
let i = searchStart;
|
|
341
|
+
while (i < code.length && (code[i] === " " || code[i] === " " || code[i] === "\n" || code[i] === "\r")) i++;
|
|
342
|
+
if (i >= code.length || code[i] !== "{") return null;
|
|
343
|
+
const objStart = i;
|
|
344
|
+
let depth = 0;
|
|
345
|
+
while (i < code.length) {
|
|
346
|
+
const ch = code[i];
|
|
347
|
+
if (ch === "\"" || ch === "'") {
|
|
348
|
+
const quote = ch;
|
|
349
|
+
i++;
|
|
350
|
+
while (i < code.length) {
|
|
351
|
+
const sc = code[i];
|
|
352
|
+
if (sc === "\\") i += 2;
|
|
353
|
+
else if (sc === quote) {
|
|
354
|
+
i++;
|
|
355
|
+
break;
|
|
356
|
+
} else i++;
|
|
357
|
+
}
|
|
358
|
+
} else if (ch === "`") {
|
|
359
|
+
i++;
|
|
360
|
+
while (i < code.length) {
|
|
361
|
+
const tc = code[i];
|
|
362
|
+
if (tc === "\\") i += 2;
|
|
363
|
+
else if (tc === "`") {
|
|
364
|
+
i++;
|
|
365
|
+
break;
|
|
366
|
+
} else if (tc === "$" && code[i + 1] === "{") {
|
|
367
|
+
i += 2;
|
|
368
|
+
let exprDepth = 1;
|
|
369
|
+
while (i < code.length && exprDepth > 0) {
|
|
370
|
+
const ec = code[i];
|
|
371
|
+
if (ec === "{") {
|
|
372
|
+
exprDepth++;
|
|
373
|
+
i++;
|
|
374
|
+
} else if (ec === "}") {
|
|
375
|
+
exprDepth--;
|
|
376
|
+
i++;
|
|
377
|
+
} else if (ec === "\"" || ec === "'") {
|
|
378
|
+
const q = ec;
|
|
379
|
+
i++;
|
|
380
|
+
while (i < code.length) if (code[i] === "\\") i += 2;
|
|
381
|
+
else if (code[i] === q) {
|
|
382
|
+
i++;
|
|
383
|
+
break;
|
|
384
|
+
} else i++;
|
|
385
|
+
} else if (ec === "`") {
|
|
386
|
+
i++;
|
|
387
|
+
while (i < code.length) if (code[i] === "\\") i += 2;
|
|
388
|
+
else if (code[i] === "`") {
|
|
389
|
+
i++;
|
|
390
|
+
break;
|
|
391
|
+
} else i++;
|
|
392
|
+
} else i++;
|
|
393
|
+
}
|
|
394
|
+
} else i++;
|
|
395
|
+
}
|
|
396
|
+
} else if (ch === "{") {
|
|
397
|
+
depth++;
|
|
398
|
+
i++;
|
|
399
|
+
} else if (ch === "}") {
|
|
400
|
+
depth--;
|
|
401
|
+
i++;
|
|
402
|
+
if (depth === 0) return [objStart, i];
|
|
403
|
+
} else i++;
|
|
404
|
+
}
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Given the index just past the closing `}` of an options object, skip
|
|
409
|
+
* optional whitespace and return the index after the closing `)`.
|
|
410
|
+
* Returns `null` if the next non-whitespace character is not `)`.
|
|
411
|
+
*/
|
|
412
|
+
function _findCallEnd(code, objEnd) {
|
|
413
|
+
let i = objEnd;
|
|
414
|
+
while (i < code.length && (code[i] === " " || code[i] === " " || code[i] === "\n" || code[i] === "\r")) i++;
|
|
415
|
+
if (i >= code.length || code[i] !== ")") return null;
|
|
416
|
+
return i + 1;
|
|
417
|
+
}
|
|
418
|
+
function createGoogleFontsPlugin(fontGoogleShimPath, shimsDir) {
|
|
419
|
+
const fontCache = /* @__PURE__ */ new Map();
|
|
420
|
+
let cacheDir = "";
|
|
421
|
+
return {
|
|
422
|
+
name: "vinext:google-fonts",
|
|
423
|
+
enforce: "pre",
|
|
424
|
+
configResolved(config) {
|
|
425
|
+
cacheDir = path.join(config.root, ".vinext", "fonts");
|
|
426
|
+
},
|
|
427
|
+
configureServer(server) {
|
|
428
|
+
if (!cacheDir) return;
|
|
429
|
+
const urlPrefix = `/${server.environments?.client?.config?.build?.assetsDir ?? server.config?.build?.assetsDir ?? DEFAULT_ASSETS_DIR}/${VINEXT_FONT_URL_NAMESPACE}/`;
|
|
430
|
+
server.middlewares.use((req, res, next) => {
|
|
431
|
+
const url = req.url;
|
|
432
|
+
if (!url || !url.startsWith(urlPrefix)) return next();
|
|
433
|
+
const rawPath = url.slice(urlPrefix.length).split("?")[0];
|
|
434
|
+
let decoded;
|
|
435
|
+
try {
|
|
436
|
+
decoded = decodeURIComponent(rawPath);
|
|
437
|
+
} catch {
|
|
438
|
+
return next();
|
|
439
|
+
}
|
|
440
|
+
const filePath = path.resolve(cacheDir, decoded);
|
|
441
|
+
if (filePath !== cacheDir && !filePath.startsWith(cacheDir + path.sep)) return next();
|
|
442
|
+
fs.stat(filePath, (err, stat) => {
|
|
443
|
+
if (err || !stat.isFile()) return next();
|
|
444
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
445
|
+
res.setHeader("Content-Type", CONTENT_TYPES[ext] ?? "application/octet-stream");
|
|
446
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
447
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
448
|
+
fs.createReadStream(filePath).pipe(res);
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
},
|
|
452
|
+
transform: {
|
|
453
|
+
filter: {
|
|
454
|
+
id: { include: /\.(tsx?|jsx?|mjs)$/ },
|
|
455
|
+
code: "next/font/google"
|
|
456
|
+
},
|
|
457
|
+
async handler(code, id) {
|
|
458
|
+
if (id.startsWith("\0")) return null;
|
|
459
|
+
if (!id.match(/\.(tsx?|jsx?|mjs)$/)) return null;
|
|
460
|
+
if (!code.includes("next/font/google")) return null;
|
|
461
|
+
if (id.startsWith(shimsDir)) return null;
|
|
462
|
+
const transformAssetsDir = this.environment?.config?.build?.assetsDir ?? DEFAULT_ASSETS_DIR;
|
|
463
|
+
const s = new MagicString(code);
|
|
464
|
+
let hasChanges = false;
|
|
465
|
+
let proxyImportCounter = 0;
|
|
466
|
+
const overwrittenRanges = [];
|
|
467
|
+
const fontLocals = /* @__PURE__ */ new Map();
|
|
468
|
+
const proxyObjectLocals = /* @__PURE__ */ new Set();
|
|
469
|
+
const importRe = /^[ \t]*import\s+((?:\{[^}]*?\}|[^;\n])+?)\s+from\s*(["'])next\/font\/google\2\s*;?/gm;
|
|
470
|
+
let importMatch;
|
|
471
|
+
while ((importMatch = importRe.exec(code)) !== null) {
|
|
472
|
+
const [fullMatch, clause] = importMatch;
|
|
473
|
+
const matchStart = importMatch.index;
|
|
474
|
+
const matchEnd = matchStart + fullMatch.length;
|
|
475
|
+
const parsed = parseGoogleFontImportClause(clause);
|
|
476
|
+
const utilityImports = parsed.named.filter((spec) => !spec.isType && GOOGLE_FONT_UTILITY_EXPORTS.has(spec.imported));
|
|
477
|
+
const fontImports = parsed.named.filter((spec) => !spec.isType && !GOOGLE_FONT_UTILITY_EXPORTS.has(spec.imported));
|
|
478
|
+
if (parsed.defaultLocal) proxyObjectLocals.add(parsed.defaultLocal);
|
|
479
|
+
for (const fontImport of fontImports) fontLocals.set(fontImport.local, fontImport.imported);
|
|
480
|
+
if (fontImports.length > 0) {
|
|
481
|
+
const virtualId = encodeGoogleFontsVirtualId({
|
|
482
|
+
hasDefault: Boolean(parsed.defaultLocal),
|
|
483
|
+
fonts: Array.from(new Set(fontImports.map((spec) => spec.imported))),
|
|
484
|
+
utilities: Array.from(new Set(utilityImports.map((spec) => spec.imported)))
|
|
485
|
+
});
|
|
486
|
+
s.overwrite(matchStart, matchEnd, `import ${clause} from ${JSON.stringify(virtualId)};`);
|
|
487
|
+
overwrittenRanges.push([matchStart, matchEnd]);
|
|
488
|
+
hasChanges = true;
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
if (parsed.namespaceLocal) {
|
|
492
|
+
const proxyImportName = `__vinext_google_fonts_proxy_${proxyImportCounter++}`;
|
|
493
|
+
const replacementLines = [`import ${proxyImportName} from ${JSON.stringify(fontGoogleShimPath)};`];
|
|
494
|
+
if (parsed.defaultLocal) replacementLines.push(`var ${parsed.defaultLocal} = ${proxyImportName};`);
|
|
495
|
+
replacementLines.push(`var ${parsed.namespaceLocal} = ${proxyImportName};`);
|
|
496
|
+
s.overwrite(matchStart, matchEnd, replacementLines.join("\n"));
|
|
497
|
+
overwrittenRanges.push([matchStart, matchEnd]);
|
|
498
|
+
proxyObjectLocals.add(parsed.namespaceLocal);
|
|
499
|
+
hasChanges = true;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
const exportRe = /^[ \t]*export\s*\{([^}]+)\}\s*from\s*(["'])next\/font\/google\2\s*;?/gm;
|
|
503
|
+
let exportMatch;
|
|
504
|
+
while ((exportMatch = exportRe.exec(code)) !== null) {
|
|
505
|
+
const [fullMatch, specifiers] = exportMatch;
|
|
506
|
+
const matchStart = exportMatch.index;
|
|
507
|
+
const matchEnd = matchStart + fullMatch.length;
|
|
508
|
+
const namedExports = parseGoogleFontNamedSpecifiers(specifiers);
|
|
509
|
+
const utilityExports = namedExports.filter((spec) => !spec.isType && GOOGLE_FONT_UTILITY_EXPORTS.has(spec.imported));
|
|
510
|
+
const fontExports = namedExports.filter((spec) => !spec.isType && !GOOGLE_FONT_UTILITY_EXPORTS.has(spec.imported));
|
|
511
|
+
if (fontExports.length === 0) continue;
|
|
512
|
+
const virtualId = encodeGoogleFontsVirtualId({
|
|
513
|
+
hasDefault: false,
|
|
514
|
+
fonts: Array.from(new Set(fontExports.map((spec) => spec.imported))),
|
|
515
|
+
utilities: Array.from(new Set(utilityExports.map((spec) => spec.imported)))
|
|
516
|
+
});
|
|
517
|
+
s.overwrite(matchStart, matchEnd, `export { ${specifiers.trim()} } from ${JSON.stringify(virtualId)};`);
|
|
518
|
+
overwrittenRanges.push([matchStart, matchEnd]);
|
|
519
|
+
hasChanges = true;
|
|
520
|
+
}
|
|
521
|
+
async function injectSelfHostedCss(callStart, callEnd, optionsStr, family, calleeSource) {
|
|
522
|
+
let options = {};
|
|
523
|
+
try {
|
|
524
|
+
const parsed = parseStaticObjectLiteral(optionsStr);
|
|
525
|
+
if (!parsed) return;
|
|
526
|
+
options = parsed;
|
|
527
|
+
} catch {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
let validated;
|
|
531
|
+
try {
|
|
532
|
+
validated = validateGoogleFontOptions(family, options);
|
|
533
|
+
} catch (err) {
|
|
534
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
535
|
+
throw new Error(`[vinext:google-fonts] ${id}: ${message}`);
|
|
536
|
+
}
|
|
537
|
+
const cssUrl = buildGoogleFontsUrl(family, getFontAxes(family, validated.weights, validated.styles, validated.selectedVariableAxes), validated.display);
|
|
538
|
+
let localCSS = fontCache.get(cssUrl);
|
|
539
|
+
if (!localCSS) try {
|
|
540
|
+
localCSS = await fetchAndCacheFont(cssUrl, family, cacheDir);
|
|
541
|
+
fontCache.set(cssUrl, localCSS);
|
|
542
|
+
} catch (err) {
|
|
543
|
+
if (err instanceof GoogleFontsHttpError) throw new Error(`[vinext:google-fonts] ${id}: Google Fonts returned HTTP ${err.status} for ${err.url}.\n${formatGoogleFontsErrorBody(err.responseBody)}`);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
const servedCSS = _rewriteCachedFontCssToServedUrls(localCSS, cacheDir, transformAssetsDir);
|
|
547
|
+
const preloadUrls = findFontFilesInCss(servedCSS, validated.preload ? validated.subsets : void 0).filter((file) => file.preloadFontFile).map((file) => file.googleFontFileUrl);
|
|
548
|
+
const fallbackMetrics = validated.adjustFontFallback === false ? void 0 : getFallbackFontOverrideMetrics(family);
|
|
549
|
+
const adjustedFallbackCSS = fallbackMetrics ? buildFallbackFontFace(family, fallbackMetrics) : void 0;
|
|
550
|
+
const validatedFontWeight = validated.weights.length === 1 && validated.weights[0] !== "variable" ? Number(validated.weights[0]) : void 0;
|
|
551
|
+
const validatedFontStyle = validated.styles.length === 1 ? validated.styles[0] : void 0;
|
|
552
|
+
const internalFontProperties = [`selfHostedCSS: ${JSON.stringify(servedCSS)}`, `preloadUrls: ${JSON.stringify(preloadUrls)}`];
|
|
553
|
+
if (adjustedFallbackCSS) internalFontProperties.push(`adjustedFallbackCSS: ${JSON.stringify(adjustedFallbackCSS)}`);
|
|
554
|
+
if (Number.isFinite(validatedFontWeight)) internalFontProperties.push(`fontWeight: ${validatedFontWeight}`);
|
|
555
|
+
if (validatedFontStyle) internalFontProperties.push(`fontStyle: ${JSON.stringify(validatedFontStyle)}`);
|
|
556
|
+
const injectedProperties = [`_vinext: { font: { ${internalFontProperties.join(", ")} } }`];
|
|
557
|
+
const closingBrace = optionsStr.lastIndexOf("}");
|
|
558
|
+
const lastChar = lastSignificantChar(optionsStr.slice(0, closingBrace));
|
|
559
|
+
const separator = lastChar === "{" || lastChar === "," ? "" : ", ";
|
|
560
|
+
const replacement = `${calleeSource}(${optionsStr.slice(0, closingBrace) + separator + injectedProperties.join(", ") + optionsStr.slice(closingBrace)})`;
|
|
561
|
+
s.overwrite(callStart, callEnd, replacement);
|
|
562
|
+
overwrittenRanges.push([callStart, callEnd]);
|
|
563
|
+
hasChanges = true;
|
|
564
|
+
}
|
|
565
|
+
const namedCallRe = /\b([A-Za-z_$][A-Za-z0-9_$]*)\s*\(\s*(?=\{)/g;
|
|
566
|
+
let namedCallMatch;
|
|
567
|
+
while ((namedCallMatch = namedCallRe.exec(code)) !== null) {
|
|
568
|
+
const [fullMatch, localName] = namedCallMatch;
|
|
569
|
+
const importedName = fontLocals.get(localName);
|
|
570
|
+
if (!importedName) continue;
|
|
571
|
+
const callStart = namedCallMatch.index;
|
|
572
|
+
const objRange = _findBalancedObject(code, callStart + fullMatch.length);
|
|
573
|
+
if (!objRange) continue;
|
|
574
|
+
const optionsStr = code.slice(objRange[0], objRange[1]);
|
|
575
|
+
const callEnd = _findCallEnd(code, objRange[1]);
|
|
576
|
+
if (callEnd === null) continue;
|
|
577
|
+
if (overwrittenRanges.some(([start, end]) => callStart < end && callEnd > start)) continue;
|
|
578
|
+
await injectSelfHostedCss(callStart, callEnd, optionsStr, importedName.replace(/_/g, " "), localName);
|
|
579
|
+
}
|
|
580
|
+
const memberCallRe = /\b([A-Za-z_$][A-Za-z0-9_$]*)\.([A-Za-z_$][A-Za-z0-9_$]*)\s*\(\s*(?=\{)/g;
|
|
581
|
+
let memberCallMatch;
|
|
582
|
+
while ((memberCallMatch = memberCallRe.exec(code)) !== null) {
|
|
583
|
+
const [fullMatch, objectName, propName] = memberCallMatch;
|
|
584
|
+
if (!proxyObjectLocals.has(objectName)) continue;
|
|
585
|
+
const callStart = memberCallMatch.index;
|
|
586
|
+
const objRange = _findBalancedObject(code, callStart + fullMatch.length);
|
|
587
|
+
if (!objRange) continue;
|
|
588
|
+
const optionsStr = code.slice(objRange[0], objRange[1]);
|
|
589
|
+
const callEnd = _findCallEnd(code, objRange[1]);
|
|
590
|
+
if (callEnd === null) continue;
|
|
591
|
+
if (overwrittenRanges.some(([start, end]) => callStart < end && callEnd > start)) continue;
|
|
592
|
+
await injectSelfHostedCss(callStart, callEnd, optionsStr, propertyNameToGoogleFontFamily(propName), `${objectName}.${propName}`);
|
|
593
|
+
}
|
|
594
|
+
if (!hasChanges) return null;
|
|
595
|
+
return {
|
|
596
|
+
code: s.toString(),
|
|
597
|
+
map: s.generateMap({ hires: "boundary" })
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
writeBundle: {
|
|
602
|
+
sequential: true,
|
|
603
|
+
order: "post",
|
|
604
|
+
handler(outputOptions) {
|
|
605
|
+
if (this.environment?.name !== "client") return;
|
|
606
|
+
if (!cacheDir || !fs.existsSync(cacheDir)) return;
|
|
607
|
+
const outDir = outputOptions.dir;
|
|
608
|
+
if (!outDir) return;
|
|
609
|
+
const assetsDir = this.environment.config?.build?.assetsDir ?? DEFAULT_ASSETS_DIR;
|
|
610
|
+
const targetRoot = path.join(outDir, assetsDir, VINEXT_FONT_URL_NAMESPACE);
|
|
611
|
+
const stack = [cacheDir];
|
|
612
|
+
while (stack.length > 0) {
|
|
613
|
+
const dir = stack.pop();
|
|
614
|
+
if (!dir) continue;
|
|
615
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
616
|
+
const src = path.join(dir, entry.name);
|
|
617
|
+
if (entry.isDirectory()) {
|
|
618
|
+
stack.push(src);
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
if (!/\.(woff2?|ttf|otf|eot)$/i.test(entry.name)) continue;
|
|
622
|
+
const relative = path.relative(cacheDir, src);
|
|
623
|
+
const dest = path.join(targetRoot, relative);
|
|
624
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
625
|
+
fs.copyFileSync(src, dest);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Create the `vinext:local-fonts` Vite plugin.
|
|
634
|
+
*
|
|
635
|
+
* Rewrites relative font file paths in `next/font/local` calls into Vite
|
|
636
|
+
* asset import references so that both dev (/@fs/...) and prod
|
|
637
|
+
* (/assets/font-xxx.woff2) URLs resolve correctly.
|
|
638
|
+
*
|
|
639
|
+
* @param shimsDir - Absolute path to the shims directory (with trailing
|
|
640
|
+
* separator). Used to skip vinext's own shim files from transform — they
|
|
641
|
+
* contain example `next/font/local` paths in comments that must not be
|
|
642
|
+
* rewritten. A precise prefix check is required (rather than a loose
|
|
643
|
+
* substring match) because, now that `node_modules` is no longer excluded,
|
|
644
|
+
* the guard runs against arbitrary third-party package paths — some of
|
|
645
|
+
* which may legitimately contain the substring `font-local` (e.g. a
|
|
646
|
+
* package named `font-local-loader`) and must still be transformed. This
|
|
647
|
+
* mirrors `createGoogleFontsPlugin`, which takes `shimsDir` for the same
|
|
648
|
+
* reason.
|
|
649
|
+
*/
|
|
650
|
+
function createLocalFontsPlugin(shimsDir) {
|
|
651
|
+
return {
|
|
652
|
+
name: "vinext:local-fonts",
|
|
653
|
+
enforce: "pre",
|
|
654
|
+
transform: {
|
|
655
|
+
filter: {
|
|
656
|
+
id: { include: /\.(tsx?|jsx?|mjs)$/ },
|
|
657
|
+
code: "next/font/local"
|
|
658
|
+
},
|
|
659
|
+
handler(code, id) {
|
|
660
|
+
if (id.startsWith("\0")) return null;
|
|
661
|
+
if (!id.match(/\.(tsx?|jsx?|mjs)$/)) return null;
|
|
662
|
+
if (!code.includes("next/font/local")) return null;
|
|
663
|
+
if (id.startsWith(shimsDir)) return null;
|
|
664
|
+
const importMatch = /\bimport\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+from\s*(['"])next\/font\/local\2/.exec(code);
|
|
665
|
+
if (!importMatch) return null;
|
|
666
|
+
const localFontIdentifier = importMatch[1];
|
|
667
|
+
const s = new MagicString(code);
|
|
668
|
+
let hasChanges = false;
|
|
669
|
+
let fontImportCounter = 0;
|
|
670
|
+
const imports = [];
|
|
671
|
+
const fontPathRe = /((?:path|src)\s*:\s*)(['"])([^'"]+\.(?:woff2?|ttf|otf|eot))\2/g;
|
|
672
|
+
let match;
|
|
673
|
+
while ((match = fontPathRe.exec(code)) !== null) {
|
|
674
|
+
const [fullMatch, prefix, _quote, fontPath] = match;
|
|
675
|
+
const varName = `__vinext_local_font_${fontImportCounter++}`;
|
|
676
|
+
imports.push(`import ${varName} from ${JSON.stringify(fontPath)};`);
|
|
677
|
+
const matchStart = match.index;
|
|
678
|
+
const matchEnd = matchStart + fullMatch.length;
|
|
679
|
+
s.overwrite(matchStart, matchEnd, `${prefix}${varName}`);
|
|
680
|
+
hasChanges = true;
|
|
681
|
+
}
|
|
682
|
+
const localFontCallRe = new RegExp(String.raw`(?:^|[;{}\n])\s*(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*(?::[^=]+)?=\s*${escapeRegExp(localFontIdentifier)}\s*\(\s*(?=\{)`, "g");
|
|
683
|
+
const familyPayloadInsertions = /* @__PURE__ */ new Set();
|
|
684
|
+
let localFontCallMatch;
|
|
685
|
+
while ((localFontCallMatch = localFontCallRe.exec(code)) !== null) {
|
|
686
|
+
const bindingName = localFontCallMatch[1];
|
|
687
|
+
const objRange = _findBalancedObject(code, localFontCallRe.lastIndex);
|
|
688
|
+
if (!objRange) continue;
|
|
689
|
+
if (_findCallEnd(code, objRange[1]) === null) continue;
|
|
690
|
+
const insertAt = objRange[1] - 1;
|
|
691
|
+
if (familyPayloadInsertions.has(insertAt)) continue;
|
|
692
|
+
const optionsStr = code.slice(objRange[0], objRange[1]);
|
|
693
|
+
if (/(?:^|[,{])\s*_vinext\s*:/.test(optionsStr)) continue;
|
|
694
|
+
const lastChar = lastSignificantChar(optionsStr.slice(0, -1));
|
|
695
|
+
const separator = lastChar === "{" || lastChar === "," ? "" : ", ";
|
|
696
|
+
s.appendLeft(insertAt, `${separator}_vinext: { font: { family: ${JSON.stringify(bindingName)} } }`);
|
|
697
|
+
familyPayloadInsertions.add(insertAt);
|
|
698
|
+
hasChanges = true;
|
|
699
|
+
}
|
|
700
|
+
if (!hasChanges) return null;
|
|
701
|
+
if (imports.length > 0) s.prepend(imports.join("\n") + "\n");
|
|
702
|
+
return {
|
|
703
|
+
code: s.toString(),
|
|
704
|
+
map: s.generateMap({ hires: "boundary" })
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
//#endregion
|
|
711
|
+
export { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, _findBalancedObject, _findCallEnd, _rewriteCachedFontCssToServedUrls, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral };
|