vinext 0.0.51 → 0.0.53
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/README.md +1 -1
- package/dist/build/clean-output.d.ts +14 -0
- package/dist/build/clean-output.js +36 -0
- package/dist/build/clean-output.js.map +1 -0
- package/dist/build/precompress.d.ts +7 -7
- package/dist/build/precompress.js +18 -17
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +9 -16
- package/dist/build/prerender.js +88 -50
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/run-prerender.js +10 -1
- package/dist/build/run-prerender.js.map +1 -1
- package/dist/build/static-export.d.ts +5 -0
- package/dist/build/static-export.js +8 -3
- package/dist/build/static-export.js.map +1 -1
- package/dist/check.js +4 -0
- package/dist/check.js.map +1 -1
- package/dist/cli-args.d.ts +1 -0
- package/dist/cli-args.js +5 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli.js +58 -4
- package/dist/cli.js.map +1 -1
- package/dist/client/instrumentation-client-inject.d.ts +34 -0
- package/dist/client/instrumentation-client-inject.js +57 -0
- package/dist/client/instrumentation-client-inject.js.map +1 -0
- package/dist/client/navigation-runtime.d.ts +60 -0
- package/dist/client/navigation-runtime.js +171 -0
- package/dist/client/navigation-runtime.js.map +1 -0
- package/dist/client/pages-router-link-navigation.d.ts +26 -0
- package/dist/client/pages-router-link-navigation.js +14 -0
- package/dist/client/pages-router-link-navigation.js.map +1 -0
- package/dist/client/vinext-next-data.d.ts +14 -3
- package/dist/client/vinext-next-data.js +50 -1
- package/dist/client/vinext-next-data.js.map +1 -0
- package/dist/client/window-next.d.ts +10 -2
- package/dist/client/window-next.js.map +1 -1
- package/dist/cloudflare/kv-cache-handler.js +2 -1
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/cloudflare/tpr.js +1 -1
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.d.ts +63 -16
- package/dist/config/config-matchers.js +145 -9
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.d.ts +32 -5
- package/dist/config/next-config.js +55 -15
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +130 -46
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.js +9 -3
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +4 -2
- package/dist/entries/app-rsc-entry.js +76 -16
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +1 -0
- package/dist/entries/app-rsc-manifest.js +53 -6
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +3 -3
- package/dist/entries/app-ssr-entry.js +4 -4
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.js +40 -3
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +261 -31
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +2 -1
- package/dist/entries/runtime-entry-module.js +9 -3
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +161 -46
- package/dist/index.js.map +1 -1
- package/dist/plugins/css-data-url.d.ts +7 -0
- package/dist/plugins/css-data-url.js +81 -0
- package/dist/plugins/css-data-url.js.map +1 -0
- package/dist/plugins/fonts.js +30 -5
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/middleware-server-only.d.ts +54 -0
- package/dist/plugins/middleware-server-only.js +91 -0
- package/dist/plugins/middleware-server-only.js.map +1 -0
- package/dist/plugins/optimize-imports.js +4 -4
- package/dist/plugins/optimize-imports.js.map +1 -1
- package/dist/plugins/strip-server-exports.js +5 -8
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +20 -1
- package/dist/routing/app-route-graph.js +58 -6
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -2
- package/dist/routing/app-router.js +2 -2
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/route-trie.js +13 -18
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/routing/utils.d.ts +12 -1
- package/dist/routing/utils.js +18 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +153 -42
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +16 -1
- package/dist/server/app-browser-action-result.js +15 -1
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +309 -155
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +32 -0
- package/dist/server/app-browser-interception-context.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +3 -1
- package/dist/server/app-browser-navigation-controller.js +5 -1
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.js +2 -2
- package/dist/server/app-browser-rsc-redirect.js.map +1 -1
- package/dist/server/app-browser-state.d.ts +18 -1
- package/dist/server/app-browser-state.js +19 -1
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +5 -14
- package/dist/server/app-browser-stream.js +13 -7
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +2 -1
- package/dist/server/app-browser-visible-commit.js +1 -0
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +10 -5
- package/dist/server/app-elements-wire.js +84 -2
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +3 -2
- package/dist/server/app-elements.js +3 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.d.ts +12 -3
- package/dist/server/app-fallback-renderer.js +15 -8
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-history-state.js +6 -2
- package/dist/server/app-history-state.js.map +1 -1
- package/dist/server/app-interception-context-header.d.ts +33 -0
- package/dist/server/app-interception-context-header.js +44 -0
- package/dist/server/app-interception-context-header.js.map +1 -0
- package/dist/server/app-middleware.d.ts +13 -0
- package/dist/server/app-middleware.js +3 -1
- package/dist/server/app-middleware.js.map +1 -1
- package/dist/server/app-mounted-slots-header.d.ts +19 -0
- package/dist/server/app-mounted-slots-header.js +40 -1
- package/dist/server/app-mounted-slots-header.js.map +1 -1
- package/dist/server/app-optimistic-routing.d.ts +54 -0
- package/dist/server/app-optimistic-routing.js +208 -0
- package/dist/server/app-optimistic-routing.js.map +1 -0
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +2 -0
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +1 -0
- package/dist/server/app-page-boundary.js +2 -0
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +15 -1
- package/dist/server/app-page-cache.js +68 -7
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +5 -0
- package/dist/server/app-page-dispatch.js +39 -5
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +7 -3
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +29 -1
- package/dist/server/app-page-execution.js +91 -4
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +1 -0
- package/dist/server/app-page-head.js +29 -2
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render-observation.js +1 -1
- package/dist/server/app-page-render.d.ts +3 -0
- package/dist/server/app-page-render.js +7 -3
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-response.d.ts +11 -1
- package/dist/server/app-page-response.js +18 -5
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +1 -0
- package/dist/server/app-page-route-wiring.js +35 -15
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +4 -0
- package/dist/server/app-page-stream.js +3 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +44 -8
- package/dist/server/app-prerender-static-params.js.map +1 -1
- package/dist/server/app-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +3 -2
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +7 -1
- package/dist/server/app-route-handler-dispatch.js +4 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +18 -2
- package/dist/server/app-route-handler-execution.js +1 -0
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +6 -5
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-router-entry.js +6 -2
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +11 -1
- package/dist/server/app-rsc-handler.js +48 -21
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +4 -3
- package/dist/server/app-rsc-render-mode.js +7 -1
- package/dist/server/app-rsc-render-mode.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +4 -1
- package/dist/server/app-rsc-request-normalization.js +6 -2
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +8 -1
- package/dist/server/app-rsc-response-finalizer.js +10 -3
- package/dist/server/app-rsc-response-finalizer.js.map +1 -1
- package/dist/server/app-rsc-route-matching.js +2 -2
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-segment-config.d.ts +4 -1
- package/dist/server/app-segment-config.js +6 -1
- package/dist/server/app-segment-config.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +1 -0
- package/dist/server/app-server-action-execution.js +5 -1
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +92 -55
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +30 -2
- package/dist/server/app-ssr-stream.js +95 -8
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/app-static-generation.d.ts +1 -0
- package/dist/server/app-static-generation.js +2 -1
- package/dist/server/app-static-generation.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +1 -1
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-headers.d.ts +7 -0
- package/dist/server/cache-headers.js +19 -0
- package/dist/server/cache-headers.js.map +1 -0
- package/dist/server/cache-proof.d.ts +49 -3
- package/dist/server/cache-proof.js +78 -22
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/client-reuse-manifest.d.ts +99 -0
- package/dist/server/client-reuse-manifest.js +212 -0
- package/dist/server/client-reuse-manifest.js.map +1 -0
- package/dist/server/default-global-error-module.d.ts +20 -0
- package/dist/server/default-global-error-module.js +20 -0
- package/dist/server/default-global-error-module.js.map +1 -0
- package/dist/server/default-not-found-module.d.ts +20 -0
- package/dist/server/default-not-found-module.js +20 -0
- package/dist/server/default-not-found-module.js.map +1 -0
- package/dist/server/dev-server.d.ts +10 -2
- package/dist/server/dev-server.js +99 -36
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/edge-api-runtime.d.ts +5 -0
- package/dist/server/edge-api-runtime.js +8 -0
- package/dist/server/edge-api-runtime.js.map +1 -0
- package/dist/server/headers.d.ts +22 -1
- package/dist/server/headers.js +22 -1
- package/dist/server/headers.js.map +1 -1
- package/dist/server/http-error-responses.d.ts +16 -1
- package/dist/server/http-error-responses.js +21 -1
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/image-optimization.d.ts +13 -4
- package/dist/server/image-optimization.js +15 -4
- package/dist/server/image-optimization.js.map +1 -1
- package/dist/server/isr-cache.d.ts +6 -2
- package/dist/server/isr-cache.js +20 -4
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +15 -0
- package/dist/server/middleware-runtime.js +59 -7
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js +5 -3
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +9 -3
- package/dist/server/navigation-planner.js +98 -25
- package/dist/server/navigation-planner.js.map +1 -1
- package/dist/server/navigation-trace.d.ts +2 -1
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +45 -1
- package/dist/server/pages-api-route.js +27 -4
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-body-parser-config.d.ts +60 -0
- package/dist/server/pages-body-parser-config.js +79 -0
- package/dist/server/pages-body-parser-config.js.map +1 -0
- package/dist/server/pages-data-route.d.ts +77 -0
- package/dist/server/pages-data-route.js +98 -0
- package/dist/server/pages-data-route.js.map +1 -0
- package/dist/server/pages-default-404.d.ts +31 -0
- package/dist/server/pages-default-404.js +40 -0
- package/dist/server/pages-default-404.js.map +1 -0
- package/dist/server/pages-i18n.d.ts +51 -1
- package/dist/server/pages-i18n.js +61 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-node-compat.d.ts +10 -0
- package/dist/server/pages-node-compat.js +12 -1
- package/dist/server/pages-node-compat.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +69 -2
- package/dist/server/pages-page-data.js +47 -31
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +13 -1
- package/dist/server/pages-page-response.js +16 -11
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prerender-route-params.d.ts +14 -0
- package/dist/server/prerender-route-params.js +94 -0
- package/dist/server/prerender-route-params.js.map +1 -0
- package/dist/server/prod-server.d.ts +15 -37
- package/dist/server/prod-server.js +143 -107
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/proxy-trust.d.ts +41 -0
- package/dist/server/proxy-trust.js +70 -0
- package/dist/server/proxy-trust.js.map +1 -0
- package/dist/server/request-pipeline.d.ts +13 -4
- package/dist/server/request-pipeline.js +32 -14
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.d.ts +12 -31
- package/dist/server/seed-cache.js +30 -37
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.js +8 -3
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/skip-cache-proof.d.ts +41 -0
- package/dist/server/skip-cache-proof.js +101 -0
- package/dist/server/skip-cache-proof.js.map +1 -0
- package/dist/server/static-file-cache.d.ts +1 -1
- package/dist/server/static-file-cache.js +8 -7
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/server/streaming-metadata.d.ts +5 -0
- package/dist/server/streaming-metadata.js +10 -0
- package/dist/server/streaming-metadata.js.map +1 -0
- package/dist/shims/app-router-scroll-state.d.ts +12 -0
- package/dist/shims/app-router-scroll-state.js +38 -0
- package/dist/shims/app-router-scroll-state.js.map +1 -0
- package/dist/shims/app-router-scroll.d.ts +14 -0
- package/dist/shims/app-router-scroll.js +100 -0
- package/dist/shims/app-router-scroll.js.map +1 -0
- package/dist/shims/before-interactive-context.d.ts +30 -0
- package/dist/shims/before-interactive-context.js +10 -0
- package/dist/shims/before-interactive-context.js.map +1 -0
- package/dist/shims/cache-runtime.d.ts +1 -1
- package/dist/shims/cache-runtime.js +14 -1
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/client-locale.d.ts +15 -0
- package/dist/shims/client-locale.js +13 -0
- package/dist/shims/client-locale.js.map +1 -0
- package/dist/shims/default-global-error.d.ts +32 -0
- package/dist/shims/default-global-error.js +181 -0
- package/dist/shims/default-global-error.js.map +1 -0
- package/dist/shims/default-not-found.d.ts +12 -0
- package/dist/shims/default-not-found.js +61 -0
- package/dist/shims/default-not-found.js.map +1 -0
- package/dist/shims/document.d.ts +59 -3
- package/dist/shims/document.js +36 -5
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +2 -2
- package/dist/shims/font-local.d.ts +5 -0
- package/dist/shims/font-local.js +6 -2
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/form.js +13 -6
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/head.js +4 -4
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +6 -2
- package/dist/shims/headers.js +64 -21
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts +1 -1
- package/dist/shims/image.js +4 -4
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/pages-data-target.d.ts +58 -0
- package/dist/shims/internal/pages-data-target.js +91 -0
- package/dist/shims/internal/pages-data-target.js.map +1 -0
- package/dist/shims/internal/pages-data-url.d.ts +42 -0
- package/dist/shims/internal/pages-data-url.js +73 -0
- package/dist/shims/internal/pages-data-url.js.map +1 -0
- package/dist/shims/link.d.ts +21 -3
- package/dist/shims/link.js +189 -30
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +2 -1
- package/dist/shims/metadata.js +65 -6
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +8 -2
- package/dist/shims/navigation.js +67 -23
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/og.d.ts +18 -2
- package/dist/shims/og.js +49 -1
- package/dist/shims/og.js.map +1 -0
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +11 -3
- package/dist/shims/root-params.js.map +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +12 -5
- package/dist/shims/router.js +535 -86
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.js +86 -12
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts +21 -4
- package/dist/shims/server.js +30 -9
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.js +5 -1
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/url-safety.d.ts +23 -1
- package/dist/shims/url-safety.js +29 -2
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +2 -1
- package/dist/shims/url-utils.js +15 -4
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/typegen.d.ts +10 -0
- package/dist/typegen.js +242 -0
- package/dist/typegen.js.map +1 -0
- package/dist/utils/asset-prefix.d.ts +33 -5
- package/dist/utils/asset-prefix.js +39 -6
- package/dist/utils/asset-prefix.js.map +1 -1
- package/dist/utils/cache-control-metadata.d.ts +2 -1
- package/dist/utils/cache-control-metadata.js +1 -3
- package/dist/utils/cache-control-metadata.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +2 -1
- package/dist/utils/domain-locale.js +9 -1
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/html-limited-bots.d.ts +5 -0
- package/dist/utils/html-limited-bots.js +15 -0
- package/dist/utils/html-limited-bots.js.map +1 -0
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/prerender-output-paths.d.ts +15 -0
- package/dist/utils/prerender-output-paths.js +24 -0
- package/dist/utils/prerender-output-paths.js.map +1 -0
- package/dist/utils/query.d.ts +23 -1
- package/dist/utils/query.js +46 -2
- package/dist/utils/query.js.map +1 -1
- package/dist/utils/record.d.ts +5 -0
- package/dist/utils/record.js +8 -0
- package/dist/utils/record.js.map +1 -0
- package/package.json +11 -3
|
@@ -18,6 +18,8 @@ const _routeTriePath = resolveEntryPath("../routing/route-trie.js", import.meta.
|
|
|
18
18
|
const _pagesI18nPath = resolveEntryPath("../server/pages-i18n.js", import.meta.url);
|
|
19
19
|
const _pagesPageResponsePath = resolveEntryPath("../server/pages-page-response.js", import.meta.url);
|
|
20
20
|
const _pagesPageDataPath = resolveEntryPath("../server/pages-page-data.js", import.meta.url);
|
|
21
|
+
const _pagesDataRoutePath = resolveEntryPath("../server/pages-data-route.js", import.meta.url);
|
|
22
|
+
const _pagesDefault404Path = resolveEntryPath("../server/pages-default-404.js", import.meta.url);
|
|
21
23
|
const _pagesNodeCompatPath = resolveEntryPath("../server/pages-node-compat.js", import.meta.url);
|
|
22
24
|
const _pagesApiRoutePath = resolveEntryPath("../server/pages-api-route.js", import.meta.url);
|
|
23
25
|
const _isrCachePath = resolveEntryPath("../server/isr-cache.js", import.meta.url);
|
|
@@ -45,9 +47,12 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
45
47
|
const apiRouteEntries = apiRoutes.map((r, i) => ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`);
|
|
46
48
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
47
49
|
const docFilePath = findFileWithExts(pagesDir, "_document", fileMatcher);
|
|
50
|
+
const errorFilePath = findFileWithExts(pagesDir, "_error", fileMatcher);
|
|
48
51
|
const appAssetPathJson = appFilePath !== null ? JSON.stringify(normalizePathSeparators(appFilePath)) : "null";
|
|
49
52
|
const appImportCode = appFilePath !== null ? `import { default as AppComponent } from ${JSON.stringify(normalizePathSeparators(appFilePath))};` : `const AppComponent = null;`;
|
|
50
53
|
const docImportCode = docFilePath !== null ? `import { default as DocumentComponent } from ${JSON.stringify(normalizePathSeparators(docFilePath))};` : `const DocumentComponent = null;`;
|
|
54
|
+
const errorAssetPathJson = errorFilePath !== null ? JSON.stringify(normalizePathSeparators(errorFilePath)) : "null";
|
|
55
|
+
const errorImportCode = errorFilePath !== null ? `import * as ErrorPageModule from ${JSON.stringify(normalizePathSeparators(errorFilePath))};` : `const ErrorPageModule = null;`;
|
|
51
56
|
const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
|
|
52
57
|
locales: nextConfig.i18n.locales,
|
|
53
58
|
defaultLocale: nextConfig.i18n.defaultLocale,
|
|
@@ -91,18 +96,45 @@ if (typeof _instrumentation.onRequestError === "function") {
|
|
|
91
96
|
}` : "";
|
|
92
97
|
const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};` : "";
|
|
93
98
|
const middlewareExportCode = middlewarePath ? `
|
|
94
|
-
export async function runMiddleware(request, ctx) {
|
|
95
|
-
|
|
99
|
+
export async function runMiddleware(request, ctx, options) {
|
|
100
|
+
// Auto-detect /_next/data/<buildId>/<page>.json requests so user-written
|
|
101
|
+
// worker entries don't need to know about the data endpoint protocol.
|
|
102
|
+
// Mismatched buildId → JSON 404 short-circuit. Matched → middleware sees
|
|
103
|
+
// the normalized page path via the request URL, and the worker sees the
|
|
104
|
+
// normalized URL via result.rewriteUrl (if middleware didn't already
|
|
105
|
+
// rewrite to something else).
|
|
106
|
+
const __dataNorm = __normalizePagesDataRequest(request);
|
|
107
|
+
if (__dataNorm.notFoundResponse) {
|
|
108
|
+
return { continue: false, response: __dataNorm.notFoundResponse };
|
|
109
|
+
}
|
|
110
|
+
const __result = await __runGeneratedMiddleware({
|
|
96
111
|
basePath: vinextConfig.basePath,
|
|
97
112
|
ctx,
|
|
98
113
|
i18nConfig,
|
|
114
|
+
isDataRequest: options?.isDataRequest === true || __dataNorm.isDataReq,
|
|
99
115
|
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
100
116
|
module: middlewareModule,
|
|
101
|
-
request,
|
|
117
|
+
request: __dataNorm.request,
|
|
118
|
+
trailingSlash: vinextConfig.trailingSlash,
|
|
102
119
|
});
|
|
120
|
+
if (__dataNorm.isDataReq && __result.continue && !__result.rewriteUrl && !__result.redirectUrl) {
|
|
121
|
+
return { ...__result, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };
|
|
122
|
+
}
|
|
123
|
+
return __result;
|
|
103
124
|
}
|
|
104
125
|
` : `
|
|
105
|
-
export async function runMiddleware() {
|
|
126
|
+
export async function runMiddleware(request) {
|
|
127
|
+
// Even without user middleware, the data-endpoint URL must be normalized so
|
|
128
|
+
// the worker pipeline sees the page path. Mismatched buildId → JSON 404.
|
|
129
|
+
const __dataNorm = __normalizePagesDataRequest(request);
|
|
130
|
+
if (__dataNorm.notFoundResponse) {
|
|
131
|
+
return { continue: false, response: __dataNorm.notFoundResponse };
|
|
132
|
+
}
|
|
133
|
+
if (__dataNorm.isDataReq) {
|
|
134
|
+
return { continue: true, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };
|
|
135
|
+
}
|
|
136
|
+
return { continue: true };
|
|
137
|
+
}
|
|
106
138
|
`;
|
|
107
139
|
return `
|
|
108
140
|
import ${JSON.stringify(_serverGlobalsPath)};
|
|
@@ -139,6 +171,8 @@ import {
|
|
|
139
171
|
} from ${JSON.stringify(_isrCachePath)};
|
|
140
172
|
import { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};
|
|
141
173
|
import { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};
|
|
174
|
+
import { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse, isNextDataPathname as __isNextDataPathname, parseNextDataPathname as __parseNextDataPathname } from ${JSON.stringify(_pagesDataRoutePath)};
|
|
175
|
+
import { buildDefaultPagesNotFoundResponse as __buildDefaultPagesNotFoundResponse } from ${JSON.stringify(_pagesDefault404Path)};
|
|
142
176
|
import { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};
|
|
143
177
|
${instrumentationImportCode}
|
|
144
178
|
${middlewareImportCode}
|
|
@@ -148,8 +182,11 @@ ${instrumentationInitCode}
|
|
|
148
182
|
// i18n config (embedded at build time)
|
|
149
183
|
const i18nConfig = ${i18nConfigJson};
|
|
150
184
|
|
|
151
|
-
// Build ID (embedded at build time)
|
|
152
|
-
|
|
185
|
+
// Build ID (embedded at build time). Exported so the production server can
|
|
186
|
+
// match _next/data requests against the embedded buildId without needing
|
|
187
|
+
// to load next.config.js at runtime.
|
|
188
|
+
export const buildId = ${buildIdJson};
|
|
189
|
+
const __hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};
|
|
153
190
|
|
|
154
191
|
// Full resolved config for production server (embedded at build time)
|
|
155
192
|
export const vinextConfig = ${vinextConfigJson};
|
|
@@ -172,6 +209,40 @@ function isrCacheKey(router, pathname) {
|
|
|
172
209
|
return __sharedIsrCacheKey(router, pathname, buildId || undefined);
|
|
173
210
|
}
|
|
174
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Detect and normalize /_next/data/<buildId>/<page>.json requests in one
|
|
214
|
+
* place so user-written worker entries don't need to know about the data
|
|
215
|
+
* endpoint protocol. Returns the normalized request (with the page path as
|
|
216
|
+
* its URL), an isDataReq flag, and notFoundResponse when the buildId in
|
|
217
|
+
* the URL does not match this server's buildId — callers should return that
|
|
218
|
+
* response immediately so a stale client falls back to a hard navigation.
|
|
219
|
+
*/
|
|
220
|
+
function __normalizePagesDataRequest(request) {
|
|
221
|
+
const reqUrl = new URL(request.url);
|
|
222
|
+
if (!__isNextDataPathname(reqUrl.pathname)) {
|
|
223
|
+
return { isDataReq: false, request, normalizedPathname: null, search: "", notFoundResponse: null };
|
|
224
|
+
}
|
|
225
|
+
const dataMatch = buildId ? __parseNextDataPathname(reqUrl.pathname, buildId) : null;
|
|
226
|
+
if (!dataMatch) {
|
|
227
|
+
return {
|
|
228
|
+
isDataReq: false,
|
|
229
|
+
request,
|
|
230
|
+
normalizedPathname: null,
|
|
231
|
+
search: "",
|
|
232
|
+
notFoundResponse: __buildNextDataNotFoundResponse(),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
const normalizedUrl = new URL(reqUrl);
|
|
236
|
+
normalizedUrl.pathname = dataMatch.pagePathname;
|
|
237
|
+
return {
|
|
238
|
+
isDataReq: true,
|
|
239
|
+
request: new Request(normalizedUrl, request),
|
|
240
|
+
normalizedPathname: dataMatch.pagePathname,
|
|
241
|
+
search: reqUrl.search,
|
|
242
|
+
notFoundResponse: null,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
175
246
|
async function renderToStringAsync(element) {
|
|
176
247
|
const stream = await renderToReadableStream(element);
|
|
177
248
|
await stream.allReady;
|
|
@@ -198,11 +269,22 @@ ${apiImports.join("\n")}
|
|
|
198
269
|
|
|
199
270
|
${appImportCode}
|
|
200
271
|
${docImportCode}
|
|
272
|
+
${errorImportCode}
|
|
201
273
|
|
|
202
274
|
export const pageRoutes = [
|
|
203
275
|
${pageRouteEntries.join(",\n")}
|
|
204
276
|
];
|
|
205
277
|
const _pageRouteTrie = _buildRouteTrie(pageRoutes);
|
|
278
|
+
const _errorPageRoute = ErrorPageModule
|
|
279
|
+
? {
|
|
280
|
+
pattern: "/_error",
|
|
281
|
+
patternParts: ["_error"],
|
|
282
|
+
isDynamic: false,
|
|
283
|
+
params: [],
|
|
284
|
+
module: ErrorPageModule,
|
|
285
|
+
filePath: ${errorAssetPathJson},
|
|
286
|
+
}
|
|
287
|
+
: null;
|
|
206
288
|
|
|
207
289
|
const apiRoutes = [
|
|
208
290
|
${apiRouteEntries.join(",\n")}
|
|
@@ -234,7 +316,14 @@ export function matchPageRoute(url, request) {
|
|
|
234
316
|
}
|
|
235
317
|
|
|
236
318
|
function parseQuery(url) {
|
|
237
|
-
|
|
319
|
+
// Per RFC 3986 only the first "?" separates path from query, so additional
|
|
320
|
+
// "?" chars belong to the query string (e.g. /linker?href=/about?hello=world
|
|
321
|
+
// has query "href=/about?hello=world"). split("?")[1] would drop everything
|
|
322
|
+
// after the second "?" and strip embedded query strings from values.
|
|
323
|
+
const queryIndex = url.indexOf("?");
|
|
324
|
+
if (queryIndex === -1) return {};
|
|
325
|
+
const hashIndex = url.indexOf("#", queryIndex + 1);
|
|
326
|
+
const qs = hashIndex === -1 ? url.slice(queryIndex + 1) : url.slice(queryIndex + 1, hashIndex);
|
|
238
327
|
if (!qs) return {};
|
|
239
328
|
const p = new URLSearchParams(qs);
|
|
240
329
|
const q = {};
|
|
@@ -262,11 +351,29 @@ function patternToNextFormat(pattern) {
|
|
|
262
351
|
.replace(/:([^\\/]+?)(?=\\/|$)/g, "[$1]");
|
|
263
352
|
}
|
|
264
353
|
|
|
265
|
-
function
|
|
354
|
+
function resolveSsrManifest(manifest) {
|
|
266
355
|
// Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)
|
|
267
|
-
|
|
356
|
+
return (manifest && Object.keys(manifest).length > 0)
|
|
268
357
|
? manifest
|
|
269
358
|
: (typeof globalThis !== "undefined" && globalThis.__VINEXT_SSR_MANIFEST__) || null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function getManifestFilesForModule(manifest, moduleId) {
|
|
362
|
+
if (!manifest || !moduleId) return null;
|
|
363
|
+
|
|
364
|
+
var files = manifest[moduleId];
|
|
365
|
+
if (files) return files;
|
|
366
|
+
|
|
367
|
+
for (var key in manifest) {
|
|
368
|
+
if (moduleId.endsWith("/" + key) || moduleId === key) {
|
|
369
|
+
return manifest[key];
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function collectAssetTags(manifest, moduleIds, scriptNonce) {
|
|
376
|
+
const m = resolveSsrManifest(manifest);
|
|
270
377
|
const tags = [];
|
|
271
378
|
const seen = new Set();
|
|
272
379
|
const nonceAttr = __createNonceAttribute(scriptNonce);
|
|
@@ -299,18 +406,7 @@ function collectAssetTags(manifest, moduleIds, scriptNonce) {
|
|
|
299
406
|
// Collect assets for the requested page modules
|
|
300
407
|
for (var mi = 0; mi < moduleIds.length; mi++) {
|
|
301
408
|
var id = moduleIds[mi];
|
|
302
|
-
var files = m
|
|
303
|
-
if (!files) {
|
|
304
|
-
// Absolute path didn't match — try matching by suffix.
|
|
305
|
-
// Manifest keys are relative (e.g. "pages/about.tsx") while
|
|
306
|
-
// moduleIds may be absolute (e.g. "/home/.../pages/about.tsx").
|
|
307
|
-
for (var mk in m) {
|
|
308
|
-
if (id.endsWith("/" + mk) || id === mk) {
|
|
309
|
-
files = m[mk];
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
409
|
+
var files = getManifestFilesForModule(m, id);
|
|
314
410
|
if (files) {
|
|
315
411
|
for (var fi = 0; fi < files.length; fi++) allFiles.push(files[fi]);
|
|
316
412
|
}
|
|
@@ -371,12 +467,43 @@ function collectAssetTags(manifest, moduleIds, scriptNonce) {
|
|
|
371
467
|
return tags.join("\\n ");
|
|
372
468
|
}
|
|
373
469
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
470
|
+
function resolveClientModuleUrl(manifest, moduleId) {
|
|
471
|
+
const files = getManifestFilesForModule(resolveSsrManifest(manifest), moduleId);
|
|
472
|
+
if (!files) return undefined;
|
|
473
|
+
for (var i = 0; i < files.length; i++) {
|
|
474
|
+
var file = files[i];
|
|
475
|
+
if (!file || !file.endsWith(".js")) continue;
|
|
476
|
+
if (file.charAt(0) !== "/") file = "/" + file;
|
|
477
|
+
return file;
|
|
478
|
+
}
|
|
479
|
+
return undefined;
|
|
377
480
|
}
|
|
378
481
|
|
|
379
|
-
async function
|
|
482
|
+
export async function renderPage(request, url, manifest, ctx, middlewareHeaders, options) {
|
|
483
|
+
if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders, options));
|
|
484
|
+
return _renderPage(request, url, manifest, middlewareHeaders, options);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
async function _renderPage(request, url, manifest, middlewareHeaders, options) {
|
|
488
|
+
let isDataReq = !!(options && options.isDataReq);
|
|
489
|
+
// Auto-detect /_next/data/... requests by inspecting the incoming request
|
|
490
|
+
// URL. The worker pipeline does not need to know about the data endpoint
|
|
491
|
+
// protocol — when it forwards an unrewritten data URL as the url arg, we
|
|
492
|
+
// normalize it to the page path here.
|
|
493
|
+
if (!isDataReq) {
|
|
494
|
+
const __dataNorm = __normalizePagesDataRequest(request);
|
|
495
|
+
if (__dataNorm.notFoundResponse) return __dataNorm.notFoundResponse;
|
|
496
|
+
if (__dataNorm.isDataReq) {
|
|
497
|
+
isDataReq = true;
|
|
498
|
+
if (url && url.startsWith("/_next/data/")) {
|
|
499
|
+
const __qs = url.includes("?") ? url.slice(url.indexOf("?")) : "";
|
|
500
|
+
url = __dataNorm.normalizedPathname + __qs;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const statusCode = options && typeof options.statusCode === "number" ? options.statusCode : undefined;
|
|
505
|
+
const asPath = options && typeof options.asPath === "string" ? options.asPath : undefined;
|
|
506
|
+
const renderErrorPageOnMiss = !(options && options.renderErrorPageOnMiss === false);
|
|
380
507
|
const localeInfo = i18nConfig
|
|
381
508
|
? resolvePagesI18nRequest(
|
|
382
509
|
url,
|
|
@@ -398,10 +525,29 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
398
525
|
return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });
|
|
399
526
|
}
|
|
400
527
|
|
|
401
|
-
|
|
528
|
+
let match = matchRoute(routeUrl, pageRoutes);
|
|
529
|
+
let renderStatusCodeOverride = statusCode;
|
|
530
|
+
let renderAsPath = asPath;
|
|
402
531
|
if (!match) {
|
|
403
|
-
|
|
404
|
-
|
|
532
|
+
if (isDataReq) {
|
|
533
|
+
return __buildNextDataNotFoundResponse();
|
|
534
|
+
}
|
|
535
|
+
if (!renderErrorPageOnMiss) {
|
|
536
|
+
return __buildDefaultPagesNotFoundResponse();
|
|
537
|
+
}
|
|
538
|
+
const notFoundMatch = matchRoute("/404", pageRoutes);
|
|
539
|
+
// matchRoute may match a catch-all (e.g. [...slug]); only use the explicit pages/404 route.
|
|
540
|
+
if (notFoundMatch && notFoundMatch.route.pattern === "/404") {
|
|
541
|
+
match = notFoundMatch;
|
|
542
|
+
renderStatusCodeOverride = 404;
|
|
543
|
+
renderAsPath = routeUrl;
|
|
544
|
+
} else if (_errorPageRoute) {
|
|
545
|
+
match = { route: _errorPageRoute, params: {} };
|
|
546
|
+
renderStatusCodeOverride = 404;
|
|
547
|
+
renderAsPath = routeUrl;
|
|
548
|
+
} else {
|
|
549
|
+
return __buildDefaultPagesNotFoundResponse();
|
|
550
|
+
}
|
|
405
551
|
}
|
|
406
552
|
|
|
407
553
|
const { route, params } = match;
|
|
@@ -412,12 +558,13 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
412
558
|
ensureFetchPatch();
|
|
413
559
|
try {
|
|
414
560
|
const routePattern = patternToNextFormat(route.pattern);
|
|
561
|
+
const renderStatusCode = renderStatusCodeOverride ?? (routePattern === "/404" ? 404 : undefined);
|
|
415
562
|
const query = mergeRouteParamsIntoQuery(parseQuery(routeUrl), params);
|
|
416
563
|
if (typeof setSSRContext === "function") {
|
|
417
564
|
setSSRContext({
|
|
418
565
|
pathname: routePattern,
|
|
419
566
|
query,
|
|
420
|
-
asPath: routeUrl,
|
|
567
|
+
asPath: renderAsPath || routeUrl,
|
|
421
568
|
locale: locale,
|
|
422
569
|
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
423
570
|
defaultLocale: currentDefaultLocale,
|
|
@@ -440,6 +587,8 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
440
587
|
if (!PageComponent) {
|
|
441
588
|
return new Response("Page has no default export", { status: 500 });
|
|
442
589
|
}
|
|
590
|
+
const pageModuleUrl = resolveClientModuleUrl(manifest, route.filePath);
|
|
591
|
+
const appModuleUrl = resolveClientModuleUrl(manifest, _appAssetPath);
|
|
443
592
|
const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);
|
|
444
593
|
// Build font Link header early so it's available for ISR cached responses too.
|
|
445
594
|
// Font preloads are module-level state populated at import time and persist across requests.
|
|
@@ -454,12 +603,13 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
454
603
|
}
|
|
455
604
|
} catch (e) { /* font preloads not available */ }
|
|
456
605
|
const pageDataResult = await __resolvePagesPageData({
|
|
606
|
+
isDataReq,
|
|
457
607
|
applyRequestContexts() {
|
|
458
608
|
if (typeof setSSRContext === "function") {
|
|
459
609
|
setSSRContext({
|
|
460
610
|
pathname: routePattern,
|
|
461
611
|
query,
|
|
462
|
-
asPath: routeUrl,
|
|
612
|
+
asPath: renderAsPath || routeUrl,
|
|
463
613
|
locale: locale,
|
|
464
614
|
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
465
615
|
defaultLocale: currentDefaultLocale,
|
|
@@ -497,6 +647,13 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
497
647
|
isrGet,
|
|
498
648
|
isrSet,
|
|
499
649
|
expireSeconds: vinextConfig.expireTime,
|
|
650
|
+
// The vinext build phase boots the prod server with VINEXT_PRERENDER=1
|
|
651
|
+
// and fetches every statically-generated page through it. That hit is
|
|
652
|
+
// the "build" prerender for revalidateReason; runtime hits are not.
|
|
653
|
+
// Mirrors Next.js's \`renderOpts.isBuildTimePrerendering\`. See
|
|
654
|
+
// \`.nextjs-ref/packages/next/src/server/render.tsx\` and
|
|
655
|
+
// \`packages/vinext/src/build/prerender.ts\`.
|
|
656
|
+
isBuildTimePrerendering: typeof process !== "undefined" && process.env && process.env.VINEXT_PRERENDER === "1",
|
|
500
657
|
pageModule,
|
|
501
658
|
params,
|
|
502
659
|
query,
|
|
@@ -518,14 +675,79 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
518
675
|
safeJsonStringify,
|
|
519
676
|
sanitizeDestination: sanitizeDestinationLocal,
|
|
520
677
|
scriptNonce,
|
|
678
|
+
statusCode: renderStatusCode,
|
|
521
679
|
triggerBackgroundRegeneration,
|
|
680
|
+
vinext: {
|
|
681
|
+
pageModuleUrl,
|
|
682
|
+
appModuleUrl,
|
|
683
|
+
hasMiddleware: __hasMiddleware,
|
|
684
|
+
},
|
|
522
685
|
});
|
|
523
686
|
if (pageDataResult.kind === "response") {
|
|
524
687
|
return pageDataResult.response;
|
|
525
688
|
}
|
|
526
689
|
let pageProps = pageDataResult.pageProps;
|
|
690
|
+
if (routePattern === "/_error" && typeof renderStatusCode === "number") {
|
|
691
|
+
pageProps = { ...pageProps, statusCode: renderStatusCode };
|
|
692
|
+
}
|
|
527
693
|
var gsspRes = pageDataResult.gsspRes;
|
|
528
694
|
let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;
|
|
695
|
+
const isFallbackRender = pageDataResult.isFallback === true;
|
|
696
|
+
|
|
697
|
+
// Republish the SSR context with isFallback flipped on so the page's
|
|
698
|
+
// \`useRouter().isFallback\` returns true during render, matching Next.js's
|
|
699
|
+
// \`render.tsx\` fallback shell. Without this, the page would still see
|
|
700
|
+
// \`isFallback: false\` and run the non-fallback branch.
|
|
701
|
+
if (isFallbackRender && typeof setSSRContext === "function") {
|
|
702
|
+
setSSRContext({
|
|
703
|
+
pathname: routePattern,
|
|
704
|
+
query,
|
|
705
|
+
asPath: renderAsPath || routeUrl,
|
|
706
|
+
locale: locale,
|
|
707
|
+
locales: i18nConfig ? i18nConfig.locales : undefined,
|
|
708
|
+
defaultLocale: currentDefaultLocale,
|
|
709
|
+
domainLocales: domainLocales,
|
|
710
|
+
isFallback: true,
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// ── _next/data JSON envelope short-circuit ───────────────────────
|
|
715
|
+
// For client-side navigations Next.js fetches /_next/data/<buildId>/<page>.json
|
|
716
|
+
// and expects { pageProps } as JSON instead of the full HTML page. Skip
|
|
717
|
+
// rendering the React tree and emit the JSON envelope directly via the
|
|
718
|
+
// typed helper so the envelope shape stays in one place. Headers and
|
|
719
|
+
// cookies set on the gsspRes by getServerSideProps are forwarded so
|
|
720
|
+
// middleware/auth flows work the same as the HTML page.
|
|
721
|
+
if (isDataReq) {
|
|
722
|
+
const init = { headers: {} };
|
|
723
|
+
if (gsspRes && typeof gsspRes.getHeaders === "function") {
|
|
724
|
+
const gsspHeaders = gsspRes.getHeaders();
|
|
725
|
+
for (const k of Object.keys(gsspHeaders)) {
|
|
726
|
+
const v = gsspHeaders[k];
|
|
727
|
+
if (v === undefined || v === null) continue;
|
|
728
|
+
init.headers[k] = Array.isArray(v) ? v.join(", ") : String(v);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
if (gsspRes) {
|
|
732
|
+
// Default Cache-Control for gSSP-driven _next/data responses,
|
|
733
|
+
// matching Next.js's pages-handler.ts (revalidate: 0 →
|
|
734
|
+
// getCacheControlHeader). Skip when gSSP already set one via
|
|
735
|
+
// res.setHeader (case-insensitive). Mirrors the HTML branch in
|
|
736
|
+
// pages-page-response.ts and the dev-server branch. Fixes #1461.
|
|
737
|
+
var hasUserCacheControl = false;
|
|
738
|
+
for (const headerKey of Object.keys(init.headers)) {
|
|
739
|
+
if (headerKey.toLowerCase() === "cache-control") {
|
|
740
|
+
hasUserCacheControl = true;
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (!hasUserCacheControl) {
|
|
745
|
+
init.headers["Cache-Control"] =
|
|
746
|
+
"private, no-cache, no-store, max-age=0, must-revalidate";
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
return __buildNextDataJsonResponse(pageProps, safeJsonStringify, init);
|
|
750
|
+
}
|
|
529
751
|
|
|
530
752
|
// Include both the matched page module and the global _app module
|
|
531
753
|
// (if present). _app is wrapped around every page in Pages Router,
|
|
@@ -587,6 +809,7 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
587
809
|
defaultLocale: currentDefaultLocale,
|
|
588
810
|
domainLocales: domainLocales,
|
|
589
811
|
},
|
|
812
|
+
isFallback: isFallbackRender,
|
|
590
813
|
pageProps,
|
|
591
814
|
params,
|
|
592
815
|
renderDocumentToString(element) {
|
|
@@ -600,6 +823,12 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
600
823
|
routeUrl,
|
|
601
824
|
safeJsonStringify,
|
|
602
825
|
scriptNonce,
|
|
826
|
+
statusCode: renderStatusCode,
|
|
827
|
+
vinext: {
|
|
828
|
+
pageModuleUrl,
|
|
829
|
+
appModuleUrl,
|
|
830
|
+
hasMiddleware: __hasMiddleware,
|
|
831
|
+
},
|
|
603
832
|
});
|
|
604
833
|
} catch (e) {
|
|
605
834
|
console.error("[vinext] SSR error:", e);
|
|
@@ -613,9 +842,10 @@ async function _renderPage(request, url, manifest, middlewareHeaders) {
|
|
|
613
842
|
});
|
|
614
843
|
}
|
|
615
844
|
|
|
616
|
-
export async function handleApiRoute(request, url) {
|
|
845
|
+
export async function handleApiRoute(request, url, ctx) {
|
|
617
846
|
const match = matchRoute(url, apiRoutes);
|
|
618
847
|
return __handlePagesApiRoute({
|
|
848
|
+
ctx,
|
|
619
849
|
match,
|
|
620
850
|
request,
|
|
621
851
|
url,
|