@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,1136 @@
|
|
|
1
|
+
import { normalizePathnameForRouteMatchStrict } from "../routing/utils.js";
|
|
2
|
+
import { hasBasePath, stripBasePath } from "../utils/base-path.js";
|
|
3
|
+
import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER, VINEXT_STATIC_FILE_HEADER } from "./headers.js";
|
|
4
|
+
import { normalizePath } from "./normalize-path.js";
|
|
5
|
+
import { notFoundResponse } from "./http-error-responses.js";
|
|
6
|
+
import { isOpenRedirectShaped } from "./open-redirect.js";
|
|
7
|
+
import { filterInternalHeaders } from "./request-pipeline.js";
|
|
8
|
+
import { isUnknownRecord } from "../utils/record.js";
|
|
9
|
+
import { resolveRequestHost, resolveRequestProtocol, trustProxy, trustedHosts } from "./proxy-trust.js";
|
|
10
|
+
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, isSafeImageContentType, parseImageParams } from "./image-optimization.js";
|
|
11
|
+
import { installSocketErrorBackstop } from "./socket-error-backstop.js";
|
|
12
|
+
import { ASSET_PREFIX_URL_DIR, assetPrefixPathname, isAbsoluteAssetPrefix } from "../utils/asset-prefix.js";
|
|
13
|
+
import { CONTENT_TYPES, StaticFileCache, etagFromFilenameHash } from "./static-file-cache.js";
|
|
14
|
+
import { buildNextDataNotFoundResponse, isNextDataPathname, parseNextDataPathname } from "./pages-data-route.js";
|
|
15
|
+
import { collectInlineCssManifest } from "../build/inline-css.js";
|
|
16
|
+
import { mergeHeaders } from "./worker-utils.js";
|
|
17
|
+
import { runPagesRequest, wrapMiddlewareWithBasePath } from "./pages-request-pipeline.js";
|
|
18
|
+
import { readTrustedPrerenderRouteParamsFromHeaders, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
|
|
19
|
+
import { computeClientRuntimeMetadata } from "../utils/client-runtime-metadata.js";
|
|
20
|
+
import { readPrerenderSecret } from "../build/server-manifest.js";
|
|
21
|
+
import { seedMemoryCacheFromPrerender } from "./seed-cache.js";
|
|
22
|
+
import { negotiateEncoding, parseAcceptedEncodings, selectContentEncoding } from "./accept-encoding.js";
|
|
23
|
+
import fs from "node:fs";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
import fs$1 from "node:fs/promises";
|
|
26
|
+
import { pathToFileURL } from "node:url";
|
|
27
|
+
import zlib from "node:zlib";
|
|
28
|
+
import { createServer } from "node:http";
|
|
29
|
+
import { Readable, pipeline } from "node:stream";
|
|
30
|
+
//#region src/server/prod-server.ts
|
|
31
|
+
/**
|
|
32
|
+
* Production server for vinext.
|
|
33
|
+
*
|
|
34
|
+
* Serves the built output from `vinext build`. Handles:
|
|
35
|
+
* - Static asset serving from client build output
|
|
36
|
+
* - Pages Router: SSR rendering + API route handling
|
|
37
|
+
* - App Router: RSC/SSR rendering, route handlers, server actions
|
|
38
|
+
* - Zstd/Brotli/Gzip compression for text-based responses
|
|
39
|
+
* - Streaming SSR for App Router
|
|
40
|
+
*
|
|
41
|
+
* Build output for Pages Router:
|
|
42
|
+
* - dist/client/ — static assets (JS, CSS, images) + .vite/ssr-manifest.json
|
|
43
|
+
* - dist/server/entry.js — SSR entry point (virtual:vinext-server-entry)
|
|
44
|
+
*
|
|
45
|
+
* Build output for App Router:
|
|
46
|
+
* - dist/client/ — static assets (JS, CSS, images)
|
|
47
|
+
* - dist/server/index.js — RSC entry (default export: handler(Request) → Response)
|
|
48
|
+
* - dist/server/ssr/index.js — SSR entry (imported by RSC entry at runtime)
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* mtime of the build each bare (query-less) server-entry URL was first
|
|
52
|
+
* imported from in this process. Node's ESM cache pins a bare URL to that
|
|
53
|
+
* build forever, so rebuilds to the same path must be detected and loaded
|
|
54
|
+
* through a cache-busted URL instead.
|
|
55
|
+
*/
|
|
56
|
+
const bareServerEntryMtimes = /* @__PURE__ */ new Map();
|
|
57
|
+
/**
|
|
58
|
+
* Import a built server entry module (App Router RSC entry or Pages Router
|
|
59
|
+
* server entry) by absolute file path.
|
|
60
|
+
*
|
|
61
|
+
* The first import of a given path uses the plain file:// URL with NO query
|
|
62
|
+
* string. This is load-bearing: code-split builds emit lazy chunks that
|
|
63
|
+
* import the entry back by bare specifier (default Vite builds on both
|
|
64
|
+
* supported majors — Rollup on Vite 7 and Rolldown on Vite 8 — hoist modules
|
|
65
|
+
* shared between the entry's static graph and lazy route chunks into the
|
|
66
|
+
* entry chunk, which the chunks then import as e.g. "../../index.js").
|
|
67
|
+
* Node keys its ESM cache on the full URL including the query string, so if
|
|
68
|
+
* the server imported the entry as `index.js?t=<mtime>`, a chunk's bare
|
|
69
|
+
* back-import would evaluate the entire server bundle a second time and
|
|
70
|
+
* module-level singletons (db pools, service registries) would silently
|
|
71
|
+
* diverge between the two copies. See
|
|
72
|
+
* https://github.com/cloudflare/vinext/issues/1923.
|
|
73
|
+
*
|
|
74
|
+
* A `?t=<mtime>` query string is appended only when the same path is
|
|
75
|
+
* imported again after a rebuild (different mtime) — e.g. test suites that
|
|
76
|
+
* rebuild a fixture to the same output path within one process — where the
|
|
77
|
+
* bare URL's cache entry would return the stale previous build. Note this
|
|
78
|
+
* rebuild branch trades the single-instance guarantee back: chunks that
|
|
79
|
+
* import the entry by bare path still resolve to the FIRST build's cache
|
|
80
|
+
* entry, so freshness and single-instance only hold together on the first
|
|
81
|
+
* import of a path. Production processes import each entry path exactly
|
|
82
|
+
* once and always get both.
|
|
83
|
+
*
|
|
84
|
+
* The entry is imported via its canonical real path: the bundler
|
|
85
|
+
* canonicalizes module ids with fs.realpathSync.native, so chunks evaluate
|
|
86
|
+
* under realpath-based URLs and their relative imports resolve to realpath
|
|
87
|
+
* URLs too. Importing the entry through a symlinked path (macOS /var/...
|
|
88
|
+
* tmpdirs, symlinked deploy directories) would otherwise create a second
|
|
89
|
+
* instance keyed on the symlinked URL.
|
|
90
|
+
*
|
|
91
|
+
* Exported for direct unit testing of the URL choice.
|
|
92
|
+
*/
|
|
93
|
+
function resolveServerEntryImportUrl(entryPath) {
|
|
94
|
+
let canonicalEntryPath;
|
|
95
|
+
try {
|
|
96
|
+
canonicalEntryPath = fs.realpathSync.native(entryPath);
|
|
97
|
+
} catch {
|
|
98
|
+
canonicalEntryPath = entryPath;
|
|
99
|
+
}
|
|
100
|
+
const href = pathToFileURL(canonicalEntryPath).href;
|
|
101
|
+
const mtime = fs.statSync(canonicalEntryPath).mtimeMs;
|
|
102
|
+
const bareMtime = bareServerEntryMtimes.get(href);
|
|
103
|
+
if (bareMtime === void 0 || bareMtime === mtime) {
|
|
104
|
+
bareServerEntryMtimes.set(href, mtime);
|
|
105
|
+
return href;
|
|
106
|
+
}
|
|
107
|
+
return `${href}?t=${mtime}`;
|
|
108
|
+
}
|
|
109
|
+
async function importServerEntryModule(entryPath) {
|
|
110
|
+
return import(resolveServerEntryImportUrl(entryPath));
|
|
111
|
+
}
|
|
112
|
+
/** Convert a Node.js IncomingMessage into a ReadableStream for Web Request body. */
|
|
113
|
+
function readNodeStream(req) {
|
|
114
|
+
let cancelled = false;
|
|
115
|
+
let cleanup = () => {};
|
|
116
|
+
return new ReadableStream({
|
|
117
|
+
start(controller) {
|
|
118
|
+
cleanup = () => {
|
|
119
|
+
req.off("data", onData);
|
|
120
|
+
req.off("end", onEnd);
|
|
121
|
+
req.off("error", onError);
|
|
122
|
+
};
|
|
123
|
+
const onData = (chunk) => {
|
|
124
|
+
if (cancelled) return;
|
|
125
|
+
controller.enqueue(new Uint8Array(chunk));
|
|
126
|
+
if ((controller.desiredSize ?? 0) <= 0) req.pause();
|
|
127
|
+
};
|
|
128
|
+
const onEnd = () => {
|
|
129
|
+
cleanup();
|
|
130
|
+
if (!cancelled) controller.close();
|
|
131
|
+
};
|
|
132
|
+
const onError = (error) => {
|
|
133
|
+
cleanup();
|
|
134
|
+
if (!cancelled) controller.error(error);
|
|
135
|
+
};
|
|
136
|
+
req.on("data", onData);
|
|
137
|
+
req.on("end", onEnd);
|
|
138
|
+
req.on("error", onError);
|
|
139
|
+
req.pause();
|
|
140
|
+
},
|
|
141
|
+
pull() {
|
|
142
|
+
if (!cancelled) req.resume();
|
|
143
|
+
},
|
|
144
|
+
cancel() {
|
|
145
|
+
cancelled = true;
|
|
146
|
+
cleanup();
|
|
147
|
+
req.resume();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/** Content types that benefit from compression. */
|
|
152
|
+
const COMPRESSIBLE_TYPES = new Set([
|
|
153
|
+
"text/html",
|
|
154
|
+
"text/css",
|
|
155
|
+
"text/plain",
|
|
156
|
+
"text/xml",
|
|
157
|
+
"text/javascript",
|
|
158
|
+
"application/javascript",
|
|
159
|
+
"application/json",
|
|
160
|
+
"application/xml",
|
|
161
|
+
"application/xhtml+xml",
|
|
162
|
+
"application/rss+xml",
|
|
163
|
+
"application/atom+xml",
|
|
164
|
+
"image/svg+xml",
|
|
165
|
+
"application/manifest+json",
|
|
166
|
+
"application/wasm"
|
|
167
|
+
]);
|
|
168
|
+
/** Minimum size threshold for compression (in bytes). Below this, compression overhead isn't worth it. */
|
|
169
|
+
const COMPRESS_THRESHOLD = 1024;
|
|
170
|
+
/**
|
|
171
|
+
* Create a compression stream for the given encoding.
|
|
172
|
+
*/
|
|
173
|
+
function createCompressor(encoding, mode = "default") {
|
|
174
|
+
switch (encoding) {
|
|
175
|
+
case "zstd": return zlib.createZstdCompress({
|
|
176
|
+
...mode === "streaming" ? { flush: zlib.constants.ZSTD_e_flush } : {},
|
|
177
|
+
params: { [zlib.constants.ZSTD_c_compressionLevel]: 3 }
|
|
178
|
+
});
|
|
179
|
+
case "br": return zlib.createBrotliCompress({
|
|
180
|
+
...mode === "streaming" ? { flush: zlib.constants.BROTLI_OPERATION_FLUSH } : {},
|
|
181
|
+
params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 4 }
|
|
182
|
+
});
|
|
183
|
+
case "gzip": return zlib.createGzip({
|
|
184
|
+
level: 6,
|
|
185
|
+
...mode === "streaming" ? { flush: zlib.constants.Z_SYNC_FLUSH } : {}
|
|
186
|
+
});
|
|
187
|
+
case "deflate": return zlib.createDeflate({
|
|
188
|
+
level: 6,
|
|
189
|
+
...mode === "streaming" ? { flush: zlib.constants.Z_SYNC_FLUSH } : {}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Merge middleware headers and a Web Response's headers into a single
|
|
195
|
+
* record suitable for Node.js `res.writeHead()`. Uses `getSetCookie()`
|
|
196
|
+
* to preserve multiple Set-Cookie values instead of flattening them.
|
|
197
|
+
*/
|
|
198
|
+
function mergeResponseHeaders(middlewareHeaders, response) {
|
|
199
|
+
const merged = { ...middlewareHeaders };
|
|
200
|
+
response.headers.forEach((v, k) => {
|
|
201
|
+
if (k === "set-cookie") return;
|
|
202
|
+
merged[k] = v;
|
|
203
|
+
});
|
|
204
|
+
const responseCookies = response.headers.getSetCookie?.() ?? [];
|
|
205
|
+
if (responseCookies.length > 0) {
|
|
206
|
+
const existing = merged["set-cookie"];
|
|
207
|
+
merged["set-cookie"] = [...existing ? Array.isArray(existing) ? existing : [existing] : [], ...responseCookies];
|
|
208
|
+
}
|
|
209
|
+
return merged;
|
|
210
|
+
}
|
|
211
|
+
function toWebHeaders(headersRecord) {
|
|
212
|
+
const headers = new Headers();
|
|
213
|
+
for (const [key, value] of Object.entries(headersRecord)) appendWebHeader(headers, key, value);
|
|
214
|
+
return headers;
|
|
215
|
+
}
|
|
216
|
+
function appendWebHeader(headers, key, value) {
|
|
217
|
+
if (value === void 0) return;
|
|
218
|
+
if (key.startsWith(":")) return;
|
|
219
|
+
if (Array.isArray(value)) {
|
|
220
|
+
for (const item of value) headers.append(key, item);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
headers.set(key, value);
|
|
224
|
+
}
|
|
225
|
+
function nodeHeadersToWebHeaders(headersRecord) {
|
|
226
|
+
const headers = new Headers();
|
|
227
|
+
for (const [key, value] of Object.entries(headersRecord)) appendWebHeader(headers, key, value);
|
|
228
|
+
return headers;
|
|
229
|
+
}
|
|
230
|
+
const NO_BODY_RESPONSE_STATUSES = new Set([
|
|
231
|
+
204,
|
|
232
|
+
205,
|
|
233
|
+
304
|
|
234
|
+
]);
|
|
235
|
+
const OMIT_BODY_HEADERS = new Set(["content-length", "content-type"]);
|
|
236
|
+
const OMIT_STATIC_RESPONSE_HEADERS = new Set([
|
|
237
|
+
VINEXT_STATIC_FILE_HEADER,
|
|
238
|
+
"content-encoding",
|
|
239
|
+
"content-length",
|
|
240
|
+
"content-type"
|
|
241
|
+
]);
|
|
242
|
+
function omitHeadersCaseInsensitive(headersRecord, targets) {
|
|
243
|
+
const filtered = {};
|
|
244
|
+
for (const [key, value] of Object.entries(headersRecord)) {
|
|
245
|
+
if (targets.has(key.toLowerCase())) continue;
|
|
246
|
+
filtered[key] = value;
|
|
247
|
+
}
|
|
248
|
+
return filtered;
|
|
249
|
+
}
|
|
250
|
+
function mergeVaryHeader(headers, value) {
|
|
251
|
+
const merged = { ...headers };
|
|
252
|
+
const existingKey = Object.keys(merged).find((key) => key.toLowerCase() === "vary");
|
|
253
|
+
if (!existingKey) {
|
|
254
|
+
merged.Vary = value;
|
|
255
|
+
return merged;
|
|
256
|
+
}
|
|
257
|
+
const rawVary = merged[existingKey];
|
|
258
|
+
const existingVary = Array.isArray(rawVary) ? rawVary.join(", ") : rawVary;
|
|
259
|
+
if (existingVary.trim().length === 0) {
|
|
260
|
+
merged[existingKey] = value;
|
|
261
|
+
return merged;
|
|
262
|
+
}
|
|
263
|
+
const values = existingVary.split(",").map((entry) => entry.trim().toLowerCase());
|
|
264
|
+
if (!values.includes("*") && !values.includes(value.toLowerCase())) merged[existingKey] = `${existingVary}, ${value}`;
|
|
265
|
+
return merged;
|
|
266
|
+
}
|
|
267
|
+
function matchesIfNoneMatchHeader(ifNoneMatch, etag) {
|
|
268
|
+
if (!ifNoneMatch) return false;
|
|
269
|
+
if (ifNoneMatch === "*") return true;
|
|
270
|
+
return ifNoneMatch.split(",").map((value) => value.trim()).some((value) => value === etag);
|
|
271
|
+
}
|
|
272
|
+
function installClientBuildManifestGlobals(clientDir, assetBase, assetPrefix) {
|
|
273
|
+
const metadata = computeClientRuntimeMetadata({
|
|
274
|
+
clientDir,
|
|
275
|
+
assetBase,
|
|
276
|
+
assetPrefix
|
|
277
|
+
});
|
|
278
|
+
globalThis.__VINEXT_LAZY_CHUNKS__ = metadata.lazyChunks;
|
|
279
|
+
globalThis.__VINEXT_DYNAMIC_PRELOADS__ = metadata.dynamicPreloads;
|
|
280
|
+
}
|
|
281
|
+
function isNoBodyResponseStatus(status) {
|
|
282
|
+
return NO_BODY_RESPONSE_STATUSES.has(status);
|
|
283
|
+
}
|
|
284
|
+
function cancelResponseBody(response) {
|
|
285
|
+
const body = response.body;
|
|
286
|
+
if (!body || body.locked) return;
|
|
287
|
+
body.cancel().catch(() => {});
|
|
288
|
+
}
|
|
289
|
+
function isVinextStreamedHtmlResponse(response) {
|
|
290
|
+
return response.__vinextStreamedHtmlResponse === true;
|
|
291
|
+
}
|
|
292
|
+
function logProdServerStarted(host, port, purpose) {
|
|
293
|
+
const url = `http://${host}:${port}`;
|
|
294
|
+
if (purpose === "prerender") {
|
|
295
|
+
console.log(`[vinext] Production server for prerendering running at ${url}`);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
console.log(`[vinext] Production server running at ${url}`);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Merge middleware/config headers and an optional status override into a new
|
|
302
|
+
* Web Response while preserving the original body stream when allowed.
|
|
303
|
+
*
|
|
304
|
+
* This is the canonical {@link mergeHeaders} (server/worker-utils.ts) with the
|
|
305
|
+
* arguments in (headers, response) order. The request path now calls
|
|
306
|
+
* `runPagesRequest`, which uses `mergeHeaders` directly; this wrapper is retained
|
|
307
|
+
* only for its existing tests and any external callers, so there is a single
|
|
308
|
+
* implementation to keep in sync. (deploy.ts still emits its own generated copy.)
|
|
309
|
+
*/
|
|
310
|
+
function mergeWebResponse(middlewareHeaders, response, statusOverride) {
|
|
311
|
+
return mergeHeaders(response, middlewareHeaders, statusOverride);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Send a compressed response if the content type is compressible and the
|
|
315
|
+
* client supports compression. Otherwise send uncompressed.
|
|
316
|
+
*/
|
|
317
|
+
function sendCompressed(req, res, body, contentType, statusCode, extraHeaders = {}, compress = true, statusText) {
|
|
318
|
+
const buf = typeof body === "string" ? Buffer.from(body) : body;
|
|
319
|
+
const baseType = contentType.split(";")[0].trim();
|
|
320
|
+
const varyByEncoding = compress && COMPRESSIBLE_TYPES.has(baseType);
|
|
321
|
+
const encoding = compress ? negotiateEncoding(req) : "identity";
|
|
322
|
+
const headersWithoutBodyHeaders = omitHeadersCaseInsensitive(extraHeaders, OMIT_BODY_HEADERS);
|
|
323
|
+
const writeHead = (headers, responseStatus = statusCode, responseStatusText = statusText) => {
|
|
324
|
+
if (responseStatusText) res.writeHead(responseStatus, responseStatusText, headers);
|
|
325
|
+
else res.writeHead(responseStatus, headers);
|
|
326
|
+
};
|
|
327
|
+
if (encoding !== "identity" && varyByEncoding && buf.length >= 1024) {
|
|
328
|
+
writeHead(mergeVaryHeader({
|
|
329
|
+
...headersWithoutBodyHeaders,
|
|
330
|
+
"Content-Type": contentType,
|
|
331
|
+
"Content-Encoding": encoding
|
|
332
|
+
}, "Accept-Encoding"));
|
|
333
|
+
if (req.method === "HEAD") {
|
|
334
|
+
res.end();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const compressor = createCompressor(encoding);
|
|
338
|
+
compressor.end(buf);
|
|
339
|
+
pipeline(compressor, res, () => {});
|
|
340
|
+
} else {
|
|
341
|
+
const identityHeaders = {
|
|
342
|
+
...headersWithoutBodyHeaders,
|
|
343
|
+
"Content-Type": contentType,
|
|
344
|
+
"Content-Length": String(buf.length)
|
|
345
|
+
};
|
|
346
|
+
writeHead(varyByEncoding ? mergeVaryHeader(identityHeaders, "Accept-Encoding") : identityHeaders);
|
|
347
|
+
if (req.method === "HEAD") {
|
|
348
|
+
res.end();
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
res.end(buf);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Try to serve a static file from the client build directory.
|
|
356
|
+
*
|
|
357
|
+
* When a `StaticFileCache` is provided, lookups are pure in-memory Map.get()
|
|
358
|
+
* with zero filesystem calls. Precompressed .br/.gz/.zst variants (generated at
|
|
359
|
+
* build time) are served directly — no per-request compression needed for
|
|
360
|
+
* hashed assets.
|
|
361
|
+
*
|
|
362
|
+
* Without a cache, falls back to async filesystem probing (still non-blocking,
|
|
363
|
+
* unlike the old sync existsSync/statSync approach).
|
|
364
|
+
*/
|
|
365
|
+
async function tryServeStatic(req, res, clientDir, pathname, compress, cache, extraHeaders, statusCode) {
|
|
366
|
+
if (pathname === "/") return false;
|
|
367
|
+
const responseStatus = statusCode ?? 200;
|
|
368
|
+
const omitBody = isNoBodyResponseStatus(responseStatus);
|
|
369
|
+
if (cache) {
|
|
370
|
+
let lookupPath;
|
|
371
|
+
if (pathname.includes("%")) {
|
|
372
|
+
try {
|
|
373
|
+
lookupPath = decodeURIComponent(pathname);
|
|
374
|
+
} catch {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
if (lookupPath.startsWith("/.vite/") || lookupPath === "/.vite") return false;
|
|
378
|
+
} else {
|
|
379
|
+
if (pathname.startsWith("/.vite/") || pathname === "/.vite") return false;
|
|
380
|
+
lookupPath = pathname;
|
|
381
|
+
}
|
|
382
|
+
const entry = cache.lookup(lookupPath);
|
|
383
|
+
if (!entry) return false;
|
|
384
|
+
const rawAe = compress ? req.headers["accept-encoding"] : void 0;
|
|
385
|
+
const parsed = typeof rawAe === "string" ? parseAcceptedEncodings(rawAe) : void 0;
|
|
386
|
+
const availableVariants = [
|
|
387
|
+
...entry.zst ? ["zstd"] : [],
|
|
388
|
+
...entry.br ? ["br"] : [],
|
|
389
|
+
...entry.gz ? ["gzip"] : []
|
|
390
|
+
];
|
|
391
|
+
const variesByEncoding = compress && availableVariants.length > 0;
|
|
392
|
+
const selected = parsed ? selectContentEncoding(parsed, availableVariants) : "identity";
|
|
393
|
+
const variant = selected === "zstd" ? entry.zst : selected === "br" ? entry.br : selected === "gzip" ? entry.gz : entry.original;
|
|
394
|
+
const ifNoneMatch = req.headers["if-none-match"];
|
|
395
|
+
if (responseStatus === 200 && typeof ifNoneMatch === "string" && matchesIfNoneMatchHeader(ifNoneMatch, entry.etag)) {
|
|
396
|
+
const notModifiedHeaders = variesByEncoding ? mergeVaryHeader({
|
|
397
|
+
...entry.notModifiedHeaders,
|
|
398
|
+
...extraHeaders
|
|
399
|
+
}, "Accept-Encoding") : {
|
|
400
|
+
...entry.notModifiedHeaders,
|
|
401
|
+
...extraHeaders
|
|
402
|
+
};
|
|
403
|
+
if (selected !== "identity") notModifiedHeaders["Content-Encoding"] = selected;
|
|
404
|
+
res.writeHead(304, notModifiedHeaders);
|
|
405
|
+
res.end();
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
const responseHeaders = {
|
|
409
|
+
...variant.headers,
|
|
410
|
+
...extraHeaders
|
|
411
|
+
};
|
|
412
|
+
res.writeHead(responseStatus, variesByEncoding ? mergeVaryHeader(responseHeaders, "Accept-Encoding") : responseHeaders);
|
|
413
|
+
if (omitBody || req.method === "HEAD") {
|
|
414
|
+
res.end();
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
if (variant.buffer) res.end(variant.buffer);
|
|
418
|
+
else pipeline(fs.createReadStream(variant.path), res, (err) => {
|
|
419
|
+
if (err) {
|
|
420
|
+
console.warn(`[vinext] Static file stream error for ${variant.path}:`, err.message);
|
|
421
|
+
res.destroy(err);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
const resolvedClient = path.resolve(clientDir);
|
|
427
|
+
let decodedPathname;
|
|
428
|
+
try {
|
|
429
|
+
decodedPathname = decodeURIComponent(pathname);
|
|
430
|
+
} catch {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
if (decodedPathname.startsWith("/.vite/") || decodedPathname === "/.vite") return false;
|
|
434
|
+
const staticFile = path.resolve(clientDir, "." + decodedPathname);
|
|
435
|
+
if (!staticFile.startsWith(resolvedClient + path.sep) && staticFile !== resolvedClient) return false;
|
|
436
|
+
const resolved = await resolveStaticFile(staticFile);
|
|
437
|
+
if (!resolved) return false;
|
|
438
|
+
const ext = path.extname(resolved.path);
|
|
439
|
+
const ct = CONTENT_TYPES[ext] ?? "application/octet-stream";
|
|
440
|
+
const isHashed = pathname.includes(`/${ASSET_PREFIX_URL_DIR}/`);
|
|
441
|
+
const cacheControl = isHashed ? "public, max-age=31536000, immutable" : "public, max-age=3600";
|
|
442
|
+
const etag = isHashed && etagFromFilenameHash(resolved.path, ext) || `W/"${resolved.size}-${Math.floor(resolved.mtimeMs / 1e3)}"`;
|
|
443
|
+
const baseType = ct.split(";")[0].trim();
|
|
444
|
+
const isCompressible = compress && COMPRESSIBLE_TYPES.has(baseType);
|
|
445
|
+
const baseHeaders = {
|
|
446
|
+
"Content-Type": ct,
|
|
447
|
+
"Cache-Control": cacheControl,
|
|
448
|
+
ETag: etag,
|
|
449
|
+
...extraHeaders
|
|
450
|
+
};
|
|
451
|
+
if (isCompressible) {
|
|
452
|
+
const encoding = negotiateEncoding(req);
|
|
453
|
+
const ifNoneMatch = req.headers["if-none-match"];
|
|
454
|
+
if (responseStatus === 200 && typeof ifNoneMatch === "string" && matchesIfNoneMatchHeader(ifNoneMatch, etag)) {
|
|
455
|
+
const notModifiedHeaders = mergeVaryHeader(baseHeaders, "Accept-Encoding");
|
|
456
|
+
if (encoding !== "identity") notModifiedHeaders["Content-Encoding"] = encoding;
|
|
457
|
+
res.writeHead(304, notModifiedHeaders);
|
|
458
|
+
res.end();
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
if (encoding !== "identity") {
|
|
462
|
+
res.writeHead(responseStatus, mergeVaryHeader({
|
|
463
|
+
...baseHeaders,
|
|
464
|
+
"Content-Encoding": encoding
|
|
465
|
+
}, "Accept-Encoding"));
|
|
466
|
+
if (omitBody || req.method === "HEAD") {
|
|
467
|
+
res.end();
|
|
468
|
+
return true;
|
|
469
|
+
}
|
|
470
|
+
const compressor = createCompressor(encoding);
|
|
471
|
+
pipeline(fs.createReadStream(resolved.path), compressor, res, (err) => {
|
|
472
|
+
if (err) {
|
|
473
|
+
console.warn(`[vinext] Static file stream error for ${resolved.path}:`, err.message);
|
|
474
|
+
res.destroy(err);
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
const ifNoneMatch = req.headers["if-none-match"];
|
|
481
|
+
if (responseStatus === 200 && typeof ifNoneMatch === "string" && matchesIfNoneMatchHeader(ifNoneMatch, etag)) {
|
|
482
|
+
res.writeHead(304, isCompressible ? mergeVaryHeader(baseHeaders, "Accept-Encoding") : baseHeaders);
|
|
483
|
+
res.end();
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
const identityHeaders = {
|
|
487
|
+
...baseHeaders,
|
|
488
|
+
"Content-Length": String(resolved.size)
|
|
489
|
+
};
|
|
490
|
+
res.writeHead(responseStatus, isCompressible ? mergeVaryHeader(identityHeaders, "Accept-Encoding") : identityHeaders);
|
|
491
|
+
if (omitBody || req.method === "HEAD") {
|
|
492
|
+
res.end();
|
|
493
|
+
return true;
|
|
494
|
+
}
|
|
495
|
+
pipeline(fs.createReadStream(resolved.path), res, (err) => {
|
|
496
|
+
if (err) {
|
|
497
|
+
console.warn(`[vinext] Static file stream error for ${resolved.path}:`, err.message);
|
|
498
|
+
res.destroy(err);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Resolve the actual file to serve, trying extension-less HTML fallbacks.
|
|
505
|
+
* Returns the resolved path + size + mtime, or null if not found.
|
|
506
|
+
*/
|
|
507
|
+
async function resolveStaticFile(staticFile) {
|
|
508
|
+
const stat = await statIfFile(staticFile);
|
|
509
|
+
if (stat) return {
|
|
510
|
+
path: staticFile,
|
|
511
|
+
size: stat.size,
|
|
512
|
+
mtimeMs: stat.mtimeMs
|
|
513
|
+
};
|
|
514
|
+
const htmlFallback = staticFile + ".html";
|
|
515
|
+
const htmlStat = await statIfFile(htmlFallback);
|
|
516
|
+
if (htmlStat) return {
|
|
517
|
+
path: htmlFallback,
|
|
518
|
+
size: htmlStat.size,
|
|
519
|
+
mtimeMs: htmlStat.mtimeMs
|
|
520
|
+
};
|
|
521
|
+
const indexFallback = path.join(staticFile, "index.html");
|
|
522
|
+
const indexStat = await statIfFile(indexFallback);
|
|
523
|
+
if (indexStat) return {
|
|
524
|
+
path: indexFallback,
|
|
525
|
+
size: indexStat.size,
|
|
526
|
+
mtimeMs: indexStat.mtimeMs
|
|
527
|
+
};
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
async function statIfFile(filePath) {
|
|
531
|
+
try {
|
|
532
|
+
const stat = await fs$1.stat(filePath);
|
|
533
|
+
return stat.isFile() ? {
|
|
534
|
+
size: stat.size,
|
|
535
|
+
mtimeMs: stat.mtimeMs
|
|
536
|
+
} : null;
|
|
537
|
+
} catch {
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Convert a Node.js IncomingMessage to a Web Request object.
|
|
543
|
+
*
|
|
544
|
+
* When `urlOverride` is provided, it is used as the path + query string
|
|
545
|
+
* instead of `req.url`. This avoids redundant path normalization when the
|
|
546
|
+
* caller has already decoded and normalized the pathname (e.g. the App
|
|
547
|
+
* Router prod server normalizes before static-asset lookup, and can pass
|
|
548
|
+
* the result here so the downstream RSC handler doesn't re-normalize).
|
|
549
|
+
*/
|
|
550
|
+
function nodeToWebRequest(req, urlOverride, prerenderSecret) {
|
|
551
|
+
const origin = `${resolveRequestProtocol(req)}://${resolveRequestHost(req, "localhost")}`;
|
|
552
|
+
const url = new URL(urlOverride ?? req.url ?? "/", origin);
|
|
553
|
+
const rawHeaders = nodeHeadersToWebHeaders(req.headers);
|
|
554
|
+
const prerenderRouteParamsPayload = readTrustedPrerenderRouteParamsFromHeaders(rawHeaders, prerenderSecret);
|
|
555
|
+
const headers = filterInternalHeaders(rawHeaders);
|
|
556
|
+
const prerenderRouteParamsHeader = serializePrerenderRouteParamsHeader(prerenderRouteParamsPayload);
|
|
557
|
+
if (prerenderRouteParamsHeader !== null) headers.set(VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, prerenderRouteParamsHeader);
|
|
558
|
+
const method = req.method ?? "GET";
|
|
559
|
+
const hasBody = method !== "GET" && method !== "HEAD";
|
|
560
|
+
const init = {
|
|
561
|
+
method,
|
|
562
|
+
headers
|
|
563
|
+
};
|
|
564
|
+
if (hasBody) {
|
|
565
|
+
init.body = readNodeStream(req);
|
|
566
|
+
init.duplex = "half";
|
|
567
|
+
}
|
|
568
|
+
return new Request(url, init);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Stream a Web Response back to a Node.js ServerResponse.
|
|
572
|
+
* Supports streaming compression for SSR responses.
|
|
573
|
+
*/
|
|
574
|
+
async function sendWebResponse(webResponse, req, res, compress) {
|
|
575
|
+
const status = webResponse.status;
|
|
576
|
+
const statusText = webResponse.statusText || void 0;
|
|
577
|
+
const writeHead = (headers) => {
|
|
578
|
+
if (statusText) res.writeHead(status, statusText, headers);
|
|
579
|
+
else res.writeHead(status, headers);
|
|
580
|
+
};
|
|
581
|
+
const nodeHeaders = {};
|
|
582
|
+
webResponse.headers.forEach((value, key) => {
|
|
583
|
+
const existing = nodeHeaders[key];
|
|
584
|
+
if (existing !== void 0) nodeHeaders[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];
|
|
585
|
+
else nodeHeaders[key] = value;
|
|
586
|
+
});
|
|
587
|
+
const alreadyEncoded = webResponse.headers.get("content-encoding") !== null;
|
|
588
|
+
if (!webResponse.body) {
|
|
589
|
+
writeHead(nodeHeaders);
|
|
590
|
+
res.end();
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const baseType = (webResponse.headers.get("content-type") ?? "").split(";")[0].trim();
|
|
594
|
+
const varyByEncoding = compress && !alreadyEncoded && COMPRESSIBLE_TYPES.has(baseType);
|
|
595
|
+
const encoding = compress && !alreadyEncoded ? negotiateEncoding(req) : "identity";
|
|
596
|
+
const shouldCompress = encoding !== "identity" && COMPRESSIBLE_TYPES.has(baseType);
|
|
597
|
+
if (shouldCompress) {
|
|
598
|
+
delete nodeHeaders["content-length"];
|
|
599
|
+
delete nodeHeaders["Content-Length"];
|
|
600
|
+
nodeHeaders["Content-Encoding"] = encoding;
|
|
601
|
+
}
|
|
602
|
+
writeHead(varyByEncoding ? mergeVaryHeader(nodeHeaders, "Accept-Encoding") : nodeHeaders);
|
|
603
|
+
if (req.method === "HEAD") {
|
|
604
|
+
cancelResponseBody(webResponse);
|
|
605
|
+
res.end();
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
const nodeStream = Readable.fromWeb(webResponse.body);
|
|
609
|
+
if (shouldCompress) pipeline(nodeStream, createCompressor(encoding, "streaming"), res, () => {});
|
|
610
|
+
else pipeline(nodeStream, res, () => {});
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Start the production server.
|
|
614
|
+
*
|
|
615
|
+
* Automatically detects whether the build is App Router (dist/server/index.js) or
|
|
616
|
+
* Pages Router (dist/server/entry.js) and configures the appropriate handler.
|
|
617
|
+
*/
|
|
618
|
+
async function startProdServer(options = {}) {
|
|
619
|
+
installSocketErrorBackstop();
|
|
620
|
+
const { port = process.env.PORT ? parseInt(process.env.PORT) : 3e3, host = "0.0.0.0", outDir = path.resolve("dist"), noCompression = false, purpose } = options;
|
|
621
|
+
const compress = !noCompression;
|
|
622
|
+
const resolvedOutDir = path.resolve(outDir);
|
|
623
|
+
const clientDir = path.join(resolvedOutDir, "client");
|
|
624
|
+
const rscEntryPath = path.join(resolvedOutDir, "server", "index.js");
|
|
625
|
+
const serverEntryPath = path.join(resolvedOutDir, "server", "entry.js");
|
|
626
|
+
const isAppRouter = fs.existsSync(rscEntryPath);
|
|
627
|
+
if (!isAppRouter && !fs.existsSync(serverEntryPath)) {
|
|
628
|
+
console.error(`[vinext] No build output found in ${outDir}`);
|
|
629
|
+
console.error("Run `vinext build` first.");
|
|
630
|
+
process.exit(1);
|
|
631
|
+
}
|
|
632
|
+
if (isAppRouter) return startAppRouterServer({
|
|
633
|
+
port,
|
|
634
|
+
host,
|
|
635
|
+
clientDir,
|
|
636
|
+
rscEntryPath,
|
|
637
|
+
compress,
|
|
638
|
+
purpose
|
|
639
|
+
});
|
|
640
|
+
return startPagesRouterServer({
|
|
641
|
+
port,
|
|
642
|
+
host,
|
|
643
|
+
clientDir,
|
|
644
|
+
serverEntryPath,
|
|
645
|
+
compress,
|
|
646
|
+
purpose
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
function createNodeExecutionContext() {
|
|
650
|
+
return {
|
|
651
|
+
waitUntil(promise) {
|
|
652
|
+
Promise.resolve(promise).catch(() => {});
|
|
653
|
+
},
|
|
654
|
+
passThroughOnException() {}
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function resolveAppRouterHandler(entry) {
|
|
658
|
+
if (typeof entry === "function") return (request) => Promise.resolve(entry(request));
|
|
659
|
+
if (entry && typeof entry === "object" && "fetch" in entry) {
|
|
660
|
+
const workerEntry = entry;
|
|
661
|
+
if (typeof workerEntry.fetch === "function") return (request) => Promise.resolve(workerEntry.fetch(request, void 0, createNodeExecutionContext()));
|
|
662
|
+
}
|
|
663
|
+
console.error("[vinext] App Router entry must export either a default handler function or a Worker-style default export with fetch()");
|
|
664
|
+
process.exit(1);
|
|
665
|
+
}
|
|
666
|
+
function isAppRouterPrerenderSeederExport(value) {
|
|
667
|
+
return typeof value === "function";
|
|
668
|
+
}
|
|
669
|
+
function resolveAppRouterPrerenderSeeder(entryModule) {
|
|
670
|
+
if (typeof entryModule !== "object" || entryModule === null) return seedMemoryCacheFromPrerender;
|
|
671
|
+
const seedExport = Object.getOwnPropertyDescriptor(entryModule, "seedMemoryCacheFromPrerender")?.value;
|
|
672
|
+
if (!isAppRouterPrerenderSeederExport(seedExport)) {
|
|
673
|
+
if (process.env.NEXT_PRIVATE_DEBUG_CACHE) console.debug("[vinext] ISR: using fallback prerender cache seeder");
|
|
674
|
+
return seedMemoryCacheFromPrerender;
|
|
675
|
+
}
|
|
676
|
+
if (process.env.NEXT_PRIVATE_DEBUG_CACHE) console.debug("[vinext] ISR: using App Router entry prerender cache seeder");
|
|
677
|
+
return async (serverDir) => {
|
|
678
|
+
const result = await Promise.resolve(seedExport(serverDir));
|
|
679
|
+
return typeof result === "number" ? result : 0;
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Resolve a request pathname to a static-asset lookup path inside `clientDir`.
|
|
684
|
+
*
|
|
685
|
+
* Returns `null` when the request is not for a built asset, in which case
|
|
686
|
+
* the caller should let the request fall through to the RSC handler.
|
|
687
|
+
*
|
|
688
|
+
* Three URL shapes are recognised:
|
|
689
|
+
*
|
|
690
|
+
* - `/_next/static/...` — the default layout. Files land on disk at
|
|
691
|
+
* `dist/client/_next/static/...`, so the pathname maps 1:1. Also covers
|
|
692
|
+
* absolute-URL `assetPrefix` with no path component (same on-disk and
|
|
693
|
+
* URL shape).
|
|
694
|
+
* - `<assetPathPrefix>/_next/static/...` — when `assetPrefix` is a path
|
|
695
|
+
* prefix (e.g. `/custom-asset-prefix`). The on-disk layout is
|
|
696
|
+
* `dist/client/<prefix>/_next/static/...`, so the pathname maps 1:1.
|
|
697
|
+
* - `<absoluteURLPathname>/_next/static/...` — when `assetPrefix` is an
|
|
698
|
+
* absolute URL with a non-empty pathname (e.g. `https://cdn/sub`).
|
|
699
|
+
* Files are written to `dist/client/_next/static/...` but emitted URLs
|
|
700
|
+
* prepend the full URL. Requests do not normally arrive here — they go
|
|
701
|
+
* to the CDN — but we accept them so a same-origin reverse proxy can
|
|
702
|
+
* route through; the on-disk path is just `_next/static/...`.
|
|
703
|
+
*/
|
|
704
|
+
function resolveAppRouterAssetPath(pathname, assetPathPrefix, assetPrefix) {
|
|
705
|
+
const nextStaticDir = `/${ASSET_PREFIX_URL_DIR}/`;
|
|
706
|
+
if (assetPathPrefix) {
|
|
707
|
+
if (pathname === assetPathPrefix || pathname.startsWith(assetPathPrefix + "/")) {
|
|
708
|
+
const rest = pathname.slice(assetPathPrefix.length) || "/";
|
|
709
|
+
if (rest.startsWith(nextStaticDir)) {
|
|
710
|
+
if (!isAbsoluteAssetPrefix(assetPrefix)) return pathname;
|
|
711
|
+
return rest;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
return null;
|
|
715
|
+
}
|
|
716
|
+
if (pathname.startsWith(nextStaticDir)) return pathname;
|
|
717
|
+
return null;
|
|
718
|
+
}
|
|
719
|
+
function isSsrManifest(value) {
|
|
720
|
+
if (!isUnknownRecord(value)) return false;
|
|
721
|
+
return Object.values(value).every((files) => Array.isArray(files) && files.every((file) => typeof file === "string"));
|
|
722
|
+
}
|
|
723
|
+
function readSsrManifest(clientDir) {
|
|
724
|
+
const manifestPath = path.join(clientDir, ".vite", "ssr-manifest.json");
|
|
725
|
+
if (!fs.existsSync(manifestPath)) return {};
|
|
726
|
+
let parsed;
|
|
727
|
+
try {
|
|
728
|
+
parsed = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
729
|
+
} catch (error) {
|
|
730
|
+
console.warn(`[vinext] Ignoring unparseable SSR manifest at ${manifestPath}:`, error);
|
|
731
|
+
return {};
|
|
732
|
+
}
|
|
733
|
+
if (!isSsrManifest(parsed)) {
|
|
734
|
+
console.warn(`[vinext] Ignoring SSR manifest with unexpected shape at ${manifestPath}`);
|
|
735
|
+
return {};
|
|
736
|
+
}
|
|
737
|
+
return parsed;
|
|
738
|
+
}
|
|
739
|
+
function installPagesClientAssetGlobals(options) {
|
|
740
|
+
const ssrManifest = readSsrManifest(options.clientDir);
|
|
741
|
+
globalThis.__VINEXT_SSR_MANIFEST__ = Object.keys(ssrManifest).length > 0 ? ssrManifest : void 0;
|
|
742
|
+
const metadata = computeClientRuntimeMetadata({
|
|
743
|
+
clientDir: options.clientDir,
|
|
744
|
+
assetBase: options.assetBase,
|
|
745
|
+
assetPrefix: options.assetPrefix,
|
|
746
|
+
includeClientEntry: options.clientEntryLookup === "pages-client-entry" ? "pages-client-entry" : true
|
|
747
|
+
});
|
|
748
|
+
globalThis.__VINEXT_CLIENT_ENTRY__ = metadata.clientEntryFile;
|
|
749
|
+
globalThis.__VINEXT_LAZY_CHUNKS__ = metadata.lazyChunks;
|
|
750
|
+
globalThis.__VINEXT_DYNAMIC_PRELOADS__ = metadata.dynamicPreloads;
|
|
751
|
+
return ssrManifest;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Start the App Router production server.
|
|
755
|
+
*
|
|
756
|
+
* The App Router entry (dist/server/index.js) can export either:
|
|
757
|
+
* - a default handler function: handler(request: Request) → Promise<Response>
|
|
758
|
+
* - a Worker-style object: { fetch(request, env, ctx) → Promise<Response> }
|
|
759
|
+
*
|
|
760
|
+
* This handler already does everything: route matching, RSC rendering,
|
|
761
|
+
* SSR HTML generation (via import("./ssr/index.js")), route handlers,
|
|
762
|
+
* server actions, ISR caching, 404s, redirects, etc.
|
|
763
|
+
*
|
|
764
|
+
* The production server's job is simply to:
|
|
765
|
+
* 1. Serve static assets from dist/client/
|
|
766
|
+
* 2. Convert Node.js IncomingMessage → Web Request
|
|
767
|
+
* 3. Call the RSC handler
|
|
768
|
+
* 4. Stream the Web Response back (with optional compression)
|
|
769
|
+
*/
|
|
770
|
+
async function startAppRouterServer(options) {
|
|
771
|
+
const { port, host, clientDir, rscEntryPath, compress, purpose } = options;
|
|
772
|
+
let imageConfig;
|
|
773
|
+
const imageConfigPath = path.join(path.dirname(rscEntryPath), "image-config.json");
|
|
774
|
+
if (fs.existsSync(imageConfigPath)) try {
|
|
775
|
+
imageConfig = JSON.parse(fs.readFileSync(imageConfigPath, "utf-8"));
|
|
776
|
+
} catch {}
|
|
777
|
+
const prerenderSecret = readPrerenderSecret(path.dirname(rscEntryPath));
|
|
778
|
+
const rscModule = await importServerEntryModule(rscEntryPath);
|
|
779
|
+
const rscHandler = resolveAppRouterHandler(rscModule.default);
|
|
780
|
+
const appRouterAssetPrefix = typeof rscModule.__assetPrefix === "string" ? rscModule.__assetPrefix : "";
|
|
781
|
+
const appRouterBasePath = typeof rscModule.__basePath === "string" ? rscModule.__basePath : "";
|
|
782
|
+
const appRouterInlineCss = rscModule.__inlineCss === true;
|
|
783
|
+
const appRouterHasPagesDir = rscModule.__hasPagesDir === true;
|
|
784
|
+
globalThis.__VINEXT_INLINE_CSS__ = appRouterInlineCss ? collectInlineCssManifest(clientDir, appRouterAssetPrefix) : void 0;
|
|
785
|
+
const appAssetPathPrefix = assetPrefixPathname(appRouterAssetPrefix);
|
|
786
|
+
const appAssetBase = appRouterBasePath ? `${appRouterBasePath}/` : "/";
|
|
787
|
+
if (appRouterHasPagesDir) installPagesClientAssetGlobals({
|
|
788
|
+
clientDir,
|
|
789
|
+
assetPrefix: appRouterAssetPrefix,
|
|
790
|
+
assetBase: appAssetBase,
|
|
791
|
+
clientEntryLookup: "pages-client-entry"
|
|
792
|
+
});
|
|
793
|
+
else installClientBuildManifestGlobals(clientDir, appAssetBase, appRouterAssetPrefix);
|
|
794
|
+
const seededRoutes = await resolveAppRouterPrerenderSeeder(rscModule)(path.dirname(rscEntryPath));
|
|
795
|
+
if (seededRoutes > 0) console.log(`[vinext] Seeded ${seededRoutes} pre-rendered route${seededRoutes !== 1 ? "s" : ""} into memory cache`);
|
|
796
|
+
const staticCache = await StaticFileCache.create(clientDir);
|
|
797
|
+
const handleRequest = async (req, res) => {
|
|
798
|
+
const rawUrl = req.url ?? "/";
|
|
799
|
+
const rawPathname = rawUrl.split("?")[0];
|
|
800
|
+
if (isOpenRedirectShaped(rawPathname)) {
|
|
801
|
+
res.writeHead(404);
|
|
802
|
+
res.end("This page could not be found");
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
const normalizedRawPathname = rawPathname.replaceAll("\\", "/");
|
|
806
|
+
let pathname;
|
|
807
|
+
try {
|
|
808
|
+
pathname = normalizePath(normalizePathnameForRouteMatchStrict(normalizedRawPathname));
|
|
809
|
+
} catch {
|
|
810
|
+
res.writeHead(400);
|
|
811
|
+
res.end("Bad Request");
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
if (pathname === "/__vinext/prerender/static-params" || pathname === "/__vinext/prerender/pages-static-paths") {
|
|
815
|
+
const secret = req.headers[VINEXT_PRERENDER_SECRET_HEADER];
|
|
816
|
+
if (!prerenderSecret || secret !== prerenderSecret) {
|
|
817
|
+
res.writeHead(403);
|
|
818
|
+
res.end("Forbidden");
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
{
|
|
823
|
+
const assetLookupPath = resolveAppRouterAssetPath(pathname, appAssetPathPrefix, appRouterAssetPrefix);
|
|
824
|
+
if (assetLookupPath) {
|
|
825
|
+
if (await tryServeStatic(req, res, clientDir, assetLookupPath, compress, staticCache)) return;
|
|
826
|
+
res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
|
|
827
|
+
res.end("Not Found");
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
if (isImageOptimizationPath(pathname)) {
|
|
832
|
+
const params = parseImageParams(new URL(rawUrl, "http://localhost"), [...imageConfig?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...imageConfig?.imageSizes ?? DEFAULT_IMAGE_SIZES], imageConfig?.qualities);
|
|
833
|
+
if (!params) {
|
|
834
|
+
res.writeHead(400);
|
|
835
|
+
res.end("Bad Request");
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
if (!isSafeImageContentType(CONTENT_TYPES[path.extname(params.imageUrl).toLowerCase()] ?? "application/octet-stream", imageConfig?.dangerouslyAllowSVG)) {
|
|
839
|
+
res.writeHead(400);
|
|
840
|
+
res.end("The requested resource is not an allowed image type");
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
const imageSecurityHeaders = {
|
|
844
|
+
"Content-Security-Policy": imageConfig?.contentSecurityPolicy ?? "script-src 'none'; frame-src 'none'; sandbox;",
|
|
845
|
+
"X-Content-Type-Options": "nosniff",
|
|
846
|
+
"Content-Disposition": imageConfig?.contentDispositionType === "attachment" ? "attachment" : "inline"
|
|
847
|
+
};
|
|
848
|
+
if (await tryServeStatic(req, res, clientDir, params.imageUrl, false, staticCache, imageSecurityHeaders)) return;
|
|
849
|
+
res.writeHead(404);
|
|
850
|
+
res.end("Image not found");
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
try {
|
|
854
|
+
const qs = rawUrl.includes("?") ? rawUrl.slice(rawUrl.indexOf("?")) : "";
|
|
855
|
+
const response = await rscHandler(nodeToWebRequest(req, pathname + qs, prerenderSecret));
|
|
856
|
+
const staticFileSignal = response.headers.get(VINEXT_STATIC_FILE_HEADER);
|
|
857
|
+
if (staticFileSignal) {
|
|
858
|
+
let staticFilePath = "/";
|
|
859
|
+
try {
|
|
860
|
+
staticFilePath = decodeURIComponent(staticFileSignal);
|
|
861
|
+
} catch {
|
|
862
|
+
staticFilePath = staticFileSignal;
|
|
863
|
+
}
|
|
864
|
+
const staticResponseHeaders = omitHeadersCaseInsensitive(mergeResponseHeaders({}, response), OMIT_STATIC_RESPONSE_HEADERS);
|
|
865
|
+
const served = await tryServeStatic(req, res, clientDir, staticFilePath, compress, staticCache, staticResponseHeaders, response.status);
|
|
866
|
+
cancelResponseBody(response);
|
|
867
|
+
if (served) return;
|
|
868
|
+
await sendWebResponse(notFoundResponse({ headers: toWebHeaders(staticResponseHeaders) }), req, res, compress);
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
await sendWebResponse(response, req, res, compress);
|
|
872
|
+
} catch (e) {
|
|
873
|
+
console.error("[vinext] Server error:", e);
|
|
874
|
+
if (!res.headersSent) {
|
|
875
|
+
res.writeHead(500);
|
|
876
|
+
res.end("Internal Server Error");
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
const server = createServer((req, res) => {
|
|
881
|
+
handleRequest(req, res);
|
|
882
|
+
});
|
|
883
|
+
await new Promise((resolve) => {
|
|
884
|
+
server.listen(port, host, () => {
|
|
885
|
+
const addr = server.address();
|
|
886
|
+
logProdServerStarted(host, typeof addr === "object" && addr ? addr.port : port, purpose);
|
|
887
|
+
resolve();
|
|
888
|
+
});
|
|
889
|
+
});
|
|
890
|
+
const addr = server.address();
|
|
891
|
+
return {
|
|
892
|
+
server,
|
|
893
|
+
port: typeof addr === "object" && addr ? addr.port : port
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
function isPagesServerEntryPageRoute(value) {
|
|
897
|
+
if (!value || typeof value !== "object" || !("pattern" in value)) return false;
|
|
898
|
+
if (typeof value.pattern !== "string") return false;
|
|
899
|
+
if (!("module" in value) || value.module === void 0) return true;
|
|
900
|
+
const pageModule = value.module;
|
|
901
|
+
if (!pageModule || typeof pageModule !== "object") return false;
|
|
902
|
+
return !("getStaticPaths" in pageModule) || typeof pageModule.getStaticPaths === "function";
|
|
903
|
+
}
|
|
904
|
+
function readPagesServerEntryPageRoutes(value) {
|
|
905
|
+
return Array.isArray(value) && value.every(isPagesServerEntryPageRoute) ? value : void 0;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Start the Pages Router production server.
|
|
909
|
+
*
|
|
910
|
+
* Uses the server entry (dist/server/entry.js) which exports:
|
|
911
|
+
* - renderPage(request, url, manifest, ctx?, middlewareHeaders?) — SSR rendering (Web Request → Response)
|
|
912
|
+
* - handleApiRoute(request, url, ctx?) — API route handling (ctx optional; pass for ctx.waitUntil() on Workers)
|
|
913
|
+
* - runMiddleware(request, ctx?) — middleware execution (ctx optional; pass for ctx.waitUntil() on Workers)
|
|
914
|
+
* - vinextConfig — embedded next.config.js settings
|
|
915
|
+
*/
|
|
916
|
+
async function startPagesRouterServer(options) {
|
|
917
|
+
const { port, host, clientDir, serverEntryPath, compress, purpose } = options;
|
|
918
|
+
const serverEntry = await importServerEntryModule(serverEntryPath);
|
|
919
|
+
const { renderPage, handleApiRoute: handleApi, runMiddleware, vinextConfig, buildId: pagesBuildId } = serverEntry;
|
|
920
|
+
const matchPageRoute = typeof serverEntry.matchPageRoute === "function" ? serverEntry.matchPageRoute : void 0;
|
|
921
|
+
const pageRoutes = readPagesServerEntryPageRoutes(serverEntry.pageRoutes);
|
|
922
|
+
const prerenderSecret = readPrerenderSecret(path.dirname(serverEntryPath));
|
|
923
|
+
const basePath = vinextConfig?.basePath ?? "";
|
|
924
|
+
const assetPrefix = vinextConfig?.assetPrefix ?? "";
|
|
925
|
+
const pagesAssetPathPrefix = assetPrefixPathname(assetPrefix);
|
|
926
|
+
const assetBase = basePath ? `${basePath}/` : "/";
|
|
927
|
+
const trailingSlash = vinextConfig?.trailingSlash ?? false;
|
|
928
|
+
const i18nConfig = vinextConfig?.i18n ?? null;
|
|
929
|
+
const configRedirects = vinextConfig?.redirects ?? [];
|
|
930
|
+
const configRewrites = vinextConfig?.rewrites ?? {
|
|
931
|
+
beforeFiles: [],
|
|
932
|
+
afterFiles: [],
|
|
933
|
+
fallback: []
|
|
934
|
+
};
|
|
935
|
+
const configHeaders = vinextConfig?.headers ?? [];
|
|
936
|
+
const allowedImageWidths = [...vinextConfig?.images?.deviceSizes ?? DEFAULT_DEVICE_SIZES, ...vinextConfig?.images?.imageSizes ?? DEFAULT_IMAGE_SIZES];
|
|
937
|
+
const pagesImageConfig = vinextConfig?.images ? {
|
|
938
|
+
dangerouslyAllowSVG: vinextConfig.images.dangerouslyAllowSVG,
|
|
939
|
+
dangerouslyAllowLocalIP: vinextConfig.images.dangerouslyAllowLocalIP,
|
|
940
|
+
qualities: vinextConfig.images.qualities,
|
|
941
|
+
contentDispositionType: vinextConfig.images.contentDispositionType,
|
|
942
|
+
contentSecurityPolicy: vinextConfig.images.contentSecurityPolicy
|
|
943
|
+
} : void 0;
|
|
944
|
+
const ssrManifest = installPagesClientAssetGlobals({
|
|
945
|
+
clientDir,
|
|
946
|
+
assetPrefix,
|
|
947
|
+
assetBase,
|
|
948
|
+
clientEntryLookup: "any-client-entry"
|
|
949
|
+
});
|
|
950
|
+
const staticCache = await StaticFileCache.create(clientDir);
|
|
951
|
+
const handleRequest = async (req, res) => {
|
|
952
|
+
const rawUrl = req.url ?? "/";
|
|
953
|
+
const rawPagesPathnameBeforeNormalize = rawUrl.split("?")[0];
|
|
954
|
+
if (isOpenRedirectShaped(rawPagesPathnameBeforeNormalize)) {
|
|
955
|
+
res.writeHead(404);
|
|
956
|
+
res.end("This page could not be found");
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
const rawPagesPathname = rawPagesPathnameBeforeNormalize.replaceAll("\\", "/");
|
|
960
|
+
const rawQs = rawUrl.includes("?") ? rawUrl.slice(rawUrl.indexOf("?")) : "";
|
|
961
|
+
let pathname;
|
|
962
|
+
try {
|
|
963
|
+
pathname = normalizePath(normalizePathnameForRouteMatchStrict(rawPagesPathname));
|
|
964
|
+
} catch {
|
|
965
|
+
res.writeHead(400);
|
|
966
|
+
res.end("Bad Request");
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
let url = pathname + rawQs;
|
|
970
|
+
if (pathname === "/__vinext/prerender/pages-static-paths") {
|
|
971
|
+
const secret = req.headers[VINEXT_PRERENDER_SECRET_HEADER];
|
|
972
|
+
if (!prerenderSecret || secret !== prerenderSecret) {
|
|
973
|
+
res.writeHead(403);
|
|
974
|
+
res.end("Forbidden");
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
const parsedUrl = new URL(rawUrl, "http://localhost");
|
|
978
|
+
const pattern = parsedUrl.searchParams.get("pattern") ?? "";
|
|
979
|
+
const localesRaw = parsedUrl.searchParams.get("locales");
|
|
980
|
+
const locales = localesRaw ? JSON.parse(localesRaw) : [];
|
|
981
|
+
const defaultLocale = parsedUrl.searchParams.get("defaultLocale") ?? "";
|
|
982
|
+
const fn = (pageRoutes?.find((r) => r.pattern === pattern))?.module?.getStaticPaths;
|
|
983
|
+
if (typeof fn !== "function") {
|
|
984
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
985
|
+
res.end("null");
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
try {
|
|
989
|
+
const result = await fn({
|
|
990
|
+
locales,
|
|
991
|
+
defaultLocale
|
|
992
|
+
});
|
|
993
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
994
|
+
res.end(JSON.stringify(result));
|
|
995
|
+
} catch (e) {
|
|
996
|
+
res.writeHead(500);
|
|
997
|
+
res.end(e.message);
|
|
998
|
+
}
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
const staticLookupPath = stripBasePath(pathname, basePath);
|
|
1002
|
+
const pagesAssetLookup = resolveAppRouterAssetPath(pathname, pagesAssetPathPrefix, assetPrefix);
|
|
1003
|
+
if (pagesAssetLookup) {
|
|
1004
|
+
if (await tryServeStatic(req, res, clientDir, pagesAssetLookup, compress, staticCache)) return;
|
|
1005
|
+
res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
|
|
1006
|
+
res.end("Not Found");
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
if (isImageOptimizationPath(pathname) || isImageOptimizationPath(staticLookupPath)) {
|
|
1010
|
+
const params = parseImageParams(new URL(rawUrl, "http://localhost"), allowedImageWidths, pagesImageConfig?.qualities);
|
|
1011
|
+
if (!params) {
|
|
1012
|
+
res.writeHead(400);
|
|
1013
|
+
res.end("Bad Request");
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
if (!isSafeImageContentType(CONTENT_TYPES[path.extname(params.imageUrl).toLowerCase()] ?? "application/octet-stream", pagesImageConfig?.dangerouslyAllowSVG)) {
|
|
1017
|
+
res.writeHead(400);
|
|
1018
|
+
res.end("The requested resource is not an allowed image type");
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
const imageSecurityHeaders = {
|
|
1022
|
+
"Content-Security-Policy": pagesImageConfig?.contentSecurityPolicy ?? "script-src 'none'; frame-src 'none'; sandbox;",
|
|
1023
|
+
"X-Content-Type-Options": "nosniff",
|
|
1024
|
+
"Content-Disposition": pagesImageConfig?.contentDispositionType === "attachment" ? "attachment" : "inline"
|
|
1025
|
+
};
|
|
1026
|
+
if (await tryServeStatic(req, res, clientDir, params.imageUrl, false, staticCache, imageSecurityHeaders)) return;
|
|
1027
|
+
res.writeHead(404);
|
|
1028
|
+
res.end("Image not found");
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
try {
|
|
1032
|
+
const hadBasePath = !basePath || hasBasePath(pathname, basePath);
|
|
1033
|
+
{
|
|
1034
|
+
const stripped = stripBasePath(pathname, basePath);
|
|
1035
|
+
if (stripped !== pathname) {
|
|
1036
|
+
url = stripped + (url.includes("?") ? url.slice(url.indexOf("?")) : "");
|
|
1037
|
+
pathname = stripped;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
let isDataReq = false;
|
|
1041
|
+
const originalRenderUrl = url;
|
|
1042
|
+
if (isNextDataPathname(pathname)) {
|
|
1043
|
+
const dataMatch = pagesBuildId ? parseNextDataPathname(pathname, pagesBuildId) : null;
|
|
1044
|
+
if (!dataMatch) {
|
|
1045
|
+
await sendWebResponse(buildNextDataNotFoundResponse(), req, res, compress);
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
isDataReq = true;
|
|
1049
|
+
const qs = url.includes("?") ? url.slice(url.indexOf("?")) : "";
|
|
1050
|
+
url = dataMatch.pagePathname + qs;
|
|
1051
|
+
pathname = dataMatch.pagePathname;
|
|
1052
|
+
}
|
|
1053
|
+
const protocol = resolveRequestProtocol(req);
|
|
1054
|
+
const hostHeader = resolveRequestHost(req, `${host}:${port}`);
|
|
1055
|
+
const rawReqHeaders = nodeHeadersToWebHeaders(req.headers);
|
|
1056
|
+
const isDataRequest = isDataReq;
|
|
1057
|
+
const reqHeaders = filterInternalHeaders(rawReqHeaders);
|
|
1058
|
+
const method = req.method ?? "GET";
|
|
1059
|
+
const hasBody = method !== "GET" && method !== "HEAD";
|
|
1060
|
+
const result = await runPagesRequest(new Request(`${protocol}://${hostHeader}${url}`, {
|
|
1061
|
+
method,
|
|
1062
|
+
headers: reqHeaders,
|
|
1063
|
+
body: hasBody ? readNodeStream(req) : void 0,
|
|
1064
|
+
duplex: hasBody ? "half" : void 0
|
|
1065
|
+
}), {
|
|
1066
|
+
basePath,
|
|
1067
|
+
trailingSlash,
|
|
1068
|
+
i18nConfig,
|
|
1069
|
+
configRedirects,
|
|
1070
|
+
configRewrites,
|
|
1071
|
+
configHeaders,
|
|
1072
|
+
hadBasePath,
|
|
1073
|
+
isDataReq,
|
|
1074
|
+
isDataRequest,
|
|
1075
|
+
ctx: void 0,
|
|
1076
|
+
rawSearch: rawQs,
|
|
1077
|
+
matchPageRoute: matchPageRoute ?? null,
|
|
1078
|
+
runMiddleware: typeof runMiddleware === "function" ? wrapMiddlewareWithBasePath(runMiddleware, basePath, hadBasePath) : null,
|
|
1079
|
+
renderPage: typeof renderPage === "function" ? (request, resolvedUrl, options, stagedHeaders) => renderPage(request, resolvedUrl, ssrManifest, void 0, stagedHeaders, {
|
|
1080
|
+
...options,
|
|
1081
|
+
originalUrl: originalRenderUrl
|
|
1082
|
+
}) : null,
|
|
1083
|
+
handleApi: typeof handleApi === "function" ? (request, apiUrl) => handleApi(request, apiUrl, createNodeExecutionContext()) : null,
|
|
1084
|
+
serveFilesystemRoute: async (requestPathname, stagedHeaders, phase) => {
|
|
1085
|
+
if (req.method !== "GET" && req.method !== "HEAD" || requestPathname === "/" || requestPathname === "/api" || requestPathname.startsWith("/api/") || phase === "direct" && requestPathname.startsWith(`/_next/static/`)) return false;
|
|
1086
|
+
return tryServeStatic(req, res, clientDir, requestPathname, compress, staticCache, stagedHeaders);
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
if (result.type === "handled") return;
|
|
1090
|
+
if (result.type === "response") {
|
|
1091
|
+
const { response } = result;
|
|
1092
|
+
if (isVinextStreamedHtmlResponse(response) || !response.body || result.defaultContentType === void 0) {
|
|
1093
|
+
await sendWebResponse(response, req, res, compress);
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
const responseBody = Buffer.from(await response.arrayBuffer());
|
|
1097
|
+
const ct = response.headers.get("content-type") ?? result.defaultContentType;
|
|
1098
|
+
const responseHeaders = {};
|
|
1099
|
+
response.headers.forEach((v, k) => {
|
|
1100
|
+
if (k === "set-cookie") return;
|
|
1101
|
+
responseHeaders[k] = v;
|
|
1102
|
+
});
|
|
1103
|
+
const setCookies = response.headers.getSetCookie?.() ?? [];
|
|
1104
|
+
if (setCookies.length > 0) responseHeaders["set-cookie"] = setCookies;
|
|
1105
|
+
const finalStatusText = response.statusText || void 0;
|
|
1106
|
+
sendCompressed(req, res, responseBody, ct, response.status, responseHeaders, compress, finalStatusText);
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
res.writeHead(404);
|
|
1110
|
+
res.end("This page could not be found");
|
|
1111
|
+
} catch (e) {
|
|
1112
|
+
console.error("[vinext] Server error:", e);
|
|
1113
|
+
if (!res.headersSent) {
|
|
1114
|
+
res.writeHead(500);
|
|
1115
|
+
res.end("Internal Server Error");
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
const server = createServer((req, res) => {
|
|
1120
|
+
handleRequest(req, res);
|
|
1121
|
+
});
|
|
1122
|
+
await new Promise((resolve) => {
|
|
1123
|
+
server.listen(port, host, () => {
|
|
1124
|
+
const addr = server.address();
|
|
1125
|
+
logProdServerStarted(host, typeof addr === "object" && addr ? addr.port : port, purpose);
|
|
1126
|
+
resolve();
|
|
1127
|
+
});
|
|
1128
|
+
});
|
|
1129
|
+
const addr = server.address();
|
|
1130
|
+
return {
|
|
1131
|
+
server,
|
|
1132
|
+
port: typeof addr === "object" && addr ? addr.port : port
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
//#endregion
|
|
1136
|
+
export { COMPRESSIBLE_TYPES, COMPRESS_THRESHOLD, importServerEntryModule, mergeResponseHeaders, mergeWebResponse, negotiateEncoding, nodeToWebRequest, readNodeStream, resolveAppRouterAssetPath, resolveAppRouterPrerenderSeeder, resolveRequestHost as resolveHost, resolveServerEntryImportUrl, sendCompressed, sendWebResponse, startProdServer, trustProxy, trustedHosts, tryServeStatic };
|