vinext 1.0.0-beta.3 → 1.0.0-beta.5
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 +44 -3
- package/dist/build/client-build-config.d.ts +0 -1
- package/dist/build/css-url-assets.d.ts +0 -1
- package/dist/build/google-fonts/build-url.d.ts +5 -2
- package/dist/build/google-fonts/font-metadata.d.ts +7 -3
- package/dist/build/google-fonts/get-axes.d.ts +0 -1
- package/dist/build/layout-classification.d.ts +7 -4
- package/dist/build/next-client-runtime-manifests.d.ts +0 -1
- package/dist/build/next-client-runtime-manifests.js +2 -19
- package/dist/build/nitro-route-rules.d.ts +0 -1
- package/dist/build/pages-client-assets-module.d.ts +0 -1
- package/dist/build/precompress.d.ts +7 -2
- package/dist/build/precompress.js +42 -8
- package/dist/build/prerender-paths.d.ts +2 -2
- package/dist/build/prerender-server-entry.d.ts +1 -1
- package/dist/build/prerender-server-pool.d.ts +4 -2
- package/dist/build/prerender.d.ts +36 -32
- package/dist/build/prerender.js +18 -3
- package/dist/build/public-dir-conflict.d.ts +14 -0
- package/dist/build/public-dir-conflict.js +25 -0
- package/dist/build/report.d.ts +2 -2
- package/dist/build/route-classification-injector.d.ts +0 -1
- package/dist/build/route-classification-manifest.d.ts +5 -3
- package/dist/build/run-prerender.d.ts +3 -2
- package/dist/build/static-export.d.ts +23 -12
- package/dist/cache/cache-adapters-virtual.d.ts +5 -2
- package/dist/check.js +4 -4
- package/dist/cli-args.d.ts +2 -1
- package/dist/cli-args.js +10 -0
- package/dist/cli-dev-config.d.ts +0 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +14 -8
- package/dist/client/client-rewrite-matcher.d.ts +12 -0
- package/dist/client/client-rewrite-matcher.js +20 -0
- package/dist/client/client-rewrites.d.ts +31 -0
- package/dist/client/client-rewrites.js +41 -0
- package/dist/client/dev-error-overlay.d.ts +0 -1
- package/dist/client/empty-module.d.ts +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/instrumentation-client-state.d.ts +0 -1
- package/dist/client/navigation-runtime.d.ts +12 -1
- package/dist/client/navigation-runtime.js +6 -2
- package/dist/client/pages-router-link-navigation.d.ts +3 -21
- package/dist/client/react-instance-bootstrap.d.ts +1 -0
- package/dist/client/react-instance-bootstrap.js +7 -0
- package/dist/client/react-instance.d.ts +13 -0
- package/dist/client/react-instance.js +20 -0
- package/dist/client/vinext-next-data.d.ts +11 -6
- package/dist/client/window-next.d.ts +5 -2
- package/dist/config/config-matchers.d.ts +3 -5
- package/dist/config/config-matchers.js +7 -6
- package/dist/config/dotenv.d.ts +4 -9
- package/dist/config/dotenv.js +30 -22
- package/dist/config/next-config.d.ts +113 -52
- package/dist/config/next-config.js +6 -0
- package/dist/config/prerender.d.ts +0 -1
- package/dist/entries/app-browser-entry.d.ts +0 -1
- package/dist/entries/app-browser-entry.js +7 -3
- package/dist/entries/app-rsc-entry.d.ts +30 -16
- package/dist/entries/app-rsc-entry.js +40 -12
- package/dist/entries/app-rsc-manifest.d.ts +0 -1
- package/dist/entries/app-rsc-manifest.js +1 -0
- package/dist/entries/pages-client-entry.d.ts +0 -1
- package/dist/entries/pages-client-entry.js +7 -2
- package/dist/entries/pages-server-entry.d.ts +1 -2
- package/dist/entries/pages-server-entry.js +25 -6
- package/dist/image/image-adapters-virtual.d.ts +4 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +257 -75
- package/dist/init-cloudflare.d.ts +0 -1
- package/dist/init-platform.d.ts +0 -1
- package/dist/init.d.ts +40 -20
- package/dist/plugins/ast-scope.d.ts +0 -1
- package/dist/plugins/async-hooks-stub.d.ts +0 -1
- package/dist/plugins/client-reference-dedup.d.ts +0 -1
- package/dist/plugins/client-reference-dedup.js +7 -5
- package/dist/plugins/css-data-url.d.ts +0 -1
- package/dist/plugins/css-module-imports.d.ts +0 -1
- package/dist/plugins/dynamic-preload-metadata.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.d.ts +0 -1
- package/dist/plugins/extensionless-dynamic-import.js +352 -13
- package/dist/plugins/fonts.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.d.ts +0 -1
- package/dist/plugins/ignore-dynamic-requests.js +28 -4
- package/dist/plugins/import-meta-url.d.ts +0 -1
- package/dist/plugins/instrumentation-client.d.ts +0 -1
- package/dist/plugins/middleware-server-only.d.ts +0 -1
- package/dist/plugins/og-asset-ownership.d.ts +0 -1
- package/dist/plugins/og-assets.d.ts +0 -1
- package/dist/plugins/optimize-imports.d.ts +0 -1
- package/dist/plugins/remove-console.d.ts +0 -1
- package/dist/plugins/require-context.d.ts +0 -1
- package/dist/plugins/require-context.js +143 -26
- package/dist/plugins/rsc-client-reference-loaders.d.ts +0 -1
- package/dist/plugins/rsc-reference-validation-normalizer.d.ts +0 -1
- package/dist/plugins/sass.d.ts +30 -2
- package/dist/plugins/sass.js +67 -5
- package/dist/plugins/server-externals-manifest.d.ts +0 -1
- package/dist/plugins/strip-server-exports.d.ts +0 -1
- package/dist/plugins/styled-jsx.d.ts +0 -1
- package/dist/plugins/wasm-module-import.d.ts +0 -1
- package/dist/routing/app-route-graph.d.ts +115 -56
- package/dist/routing/app-route-graph.js +2 -1
- package/dist/routing/app-router.d.ts +0 -1
- package/dist/routing/pages-router.d.ts +9 -5
- package/dist/routing/route-matching.d.ts +0 -1
- package/dist/routing/utils.d.ts +1 -23
- package/dist/routing/utils.js +1 -30
- package/dist/server/accept-encoding.d.ts +0 -1
- package/dist/server/api-handler.d.ts +0 -1
- package/dist/server/api-handler.js +4 -3
- package/dist/server/app-bfcache-identity.d.ts +9 -10
- package/dist/server/app-bfcache-identity.js +27 -102
- package/dist/server/app-browser-action-result.d.ts +0 -1
- package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -1
- package/dist/server/app-browser-entry.d.ts +1 -1
- package/dist/server/app-browser-entry.js +106 -66
- package/dist/server/app-browser-history-controller.d.ts +8 -5
- package/dist/server/app-browser-hydration.d.ts +0 -1
- package/dist/server/app-browser-interception-context.d.ts +0 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +0 -1
- package/dist/server/app-browser-navigation-controller.d.ts +3 -6
- package/dist/server/app-browser-navigation-controller.js +29 -4
- package/dist/server/app-browser-popstate.d.ts +0 -1
- package/dist/server/app-browser-prefetch-response.d.ts +25 -0
- package/dist/server/app-browser-prefetch-response.js +54 -0
- package/dist/server/app-browser-server-action-client.d.ts +1 -1
- package/dist/server/app-browser-server-action-client.js +3 -2
- package/dist/server/app-browser-server-action-navigation.d.ts +0 -1
- package/dist/server/app-browser-state.d.ts +11 -5
- package/dist/server/app-browser-state.js +10 -6
- package/dist/server/app-browser-stream.d.ts +0 -1
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-browser-visible-commit.js +6 -2
- package/dist/server/app-elements-wire.d.ts +16 -13
- package/dist/server/app-elements-wire.js +37 -10
- package/dist/server/app-elements.d.ts +2 -3
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-fallback-renderer.d.ts +8 -4
- package/dist/server/app-fallback-renderer.js +2 -1
- package/dist/server/app-history-state.d.ts +2 -2
- package/dist/server/app-history-state.js +1 -1
- package/dist/server/app-hook-warning-suppression.d.ts +0 -1
- package/dist/server/app-layout-param-observation.d.ts +0 -1
- package/dist/server/app-layout-param-observation.js +1 -1
- package/dist/server/app-middleware.d.ts +5 -1
- package/dist/server/app-middleware.js +96 -31
- package/dist/server/app-optimistic-routing.d.ts +1 -0
- package/dist/server/app-page-boundary-render.d.ts +8 -4
- package/dist/server/app-page-cache-finalizer.d.ts +2 -3
- package/dist/server/app-page-cache-finalizer.js +47 -17
- package/dist/server/app-page-cache-render.d.ts +2 -2
- package/dist/server/app-page-cache-render.js +2 -1
- package/dist/server/app-page-cache.d.ts +1 -3
- package/dist/server/app-page-cache.js +22 -11
- package/dist/server/app-page-dispatch.d.ts +12 -6
- package/dist/server/app-page-dispatch.js +14 -6
- package/dist/server/app-page-element-builder.d.ts +63 -20
- package/dist/server/app-page-element-builder.js +114 -43
- package/dist/server/app-page-execution.d.ts +12 -5
- package/dist/server/app-page-execution.js +1 -1
- package/dist/server/app-page-head.d.ts +2 -2
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +2 -2
- package/dist/server/app-page-params.d.ts +0 -1
- package/dist/server/app-page-ppr-runtime.d.ts +0 -1
- package/dist/server/app-page-probe.d.ts +4 -3
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-observation.d.ts +0 -1
- package/dist/server/app-page-render.d.ts +7 -5
- package/dist/server/app-page-render.js +59 -24
- package/dist/server/app-page-request.d.ts +3 -2
- package/dist/server/app-page-request.js +6 -46
- package/dist/server/app-page-response.d.ts +15 -3
- package/dist/server/app-page-response.js +21 -3
- package/dist/server/app-page-route-wiring.d.ts +30 -7
- package/dist/server/app-page-route-wiring.js +163 -63
- package/dist/server/app-page-search-params-observation.d.ts +0 -1
- package/dist/server/app-page-segment-plan.d.ts +56 -0
- package/dist/server/app-page-segment-plan.js +177 -0
- package/dist/server/app-page-segment-state.d.ts +18 -2
- package/dist/server/app-page-segment-state.js +23 -4
- package/dist/server/app-page-stream.d.ts +19 -10
- package/dist/server/app-pages-bridge.d.ts +2 -2
- package/dist/server/app-pages-bridge.js +14 -2
- package/dist/server/app-post-middleware-context.d.ts +0 -1
- package/dist/server/app-ppr-fallback-shell-render.d.ts +0 -1
- package/dist/server/app-prerender-endpoints.d.ts +0 -1
- package/dist/server/app-prerender-static-params.d.ts +0 -1
- package/dist/server/app-render-dependency.d.ts +11 -4
- package/dist/server/app-render-dependency.js +59 -9
- package/dist/server/app-request-context.d.ts +1 -0
- package/dist/server/app-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +5 -1
- package/dist/server/app-route-handler-dispatch.d.ts +0 -1
- package/dist/server/app-route-handler-execution.d.ts +2 -2
- package/dist/server/app-route-handler-execution.js +5 -1
- package/dist/server/app-route-handler-policy.d.ts +0 -1
- package/dist/server/app-route-handler-response.d.ts +0 -1
- package/dist/server/app-route-handler-runtime.d.ts +0 -1
- package/dist/server/app-route-handler-runtime.js +1 -2
- package/dist/server/app-route-module-loader.d.ts +32 -6
- package/dist/server/app-route-module-loader.js +73 -3
- package/dist/server/app-router-entry.d.ts +0 -1
- package/dist/server/app-router-entry.js +2 -2
- package/dist/server/app-rsc-cache-busting.d.ts +7 -1
- package/dist/server/app-rsc-cache-busting.js +6 -0
- package/dist/server/app-rsc-handler.d.ts +9 -2
- package/dist/server/app-rsc-handler.js +173 -41
- package/dist/server/app-rsc-redirect-flight.d.ts +0 -1
- package/dist/server/app-rsc-render-mode.d.ts +3 -2
- package/dist/server/app-rsc-render-mode.js +4 -1
- package/dist/server/app-rsc-request-normalization.d.ts +19 -10
- package/dist/server/app-rsc-request-normalization.js +65 -4
- package/dist/server/app-rsc-response-finalizer.d.ts +5 -2
- package/dist/server/app-rsc-response-finalizer.js +31 -18
- package/dist/server/app-rsc-route-matching.d.ts +6 -1
- package/dist/server/app-rsc-route-matching.js +47 -2
- package/dist/server/app-segment-config.d.ts +0 -1
- package/dist/server/app-server-action-execution.d.ts +42 -9
- package/dist/server/app-server-action-execution.js +189 -111
- package/dist/server/app-ssr-entry.d.ts +5 -3
- package/dist/server/app-ssr-entry.js +4 -5
- package/dist/server/app-ssr-router-instance.d.ts +0 -1
- package/dist/server/app-ssr-stream.d.ts +7 -1
- package/dist/server/app-ssr-stream.js +2 -1
- package/dist/server/app-static-generation.d.ts +0 -1
- package/dist/server/app-visited-response-cache.d.ts +7 -2
- package/dist/server/app-visited-response-cache.js +49 -1
- package/dist/server/before-interactive-head.d.ts +0 -1
- package/dist/server/before-interactive-head.js +2 -0
- package/dist/server/bfcache-identity.d.ts +45 -0
- package/dist/server/bfcache-identity.js +52 -0
- package/dist/server/cache-control.d.ts +3 -3
- package/dist/server/cache-control.js +3 -2
- package/dist/server/cache-proof.d.ts +0 -1
- package/dist/server/client-reuse-manifest.d.ts +0 -1
- package/dist/server/config-headers.d.ts +2 -2
- package/dist/server/csp.d.ts +0 -1
- package/dist/server/default-global-error-module.d.ts +0 -1
- package/dist/server/default-global-not-found-module.d.ts +0 -1
- package/dist/server/default-not-found-module.d.ts +0 -1
- package/dist/server/dev-lockfile.d.ts +21 -9
- package/dist/server/dev-module-runner.d.ts +0 -1
- package/dist/server/dev-route-files.d.ts +0 -1
- package/dist/server/dev-server.d.ts +4 -8
- package/dist/server/dev-server.js +86 -131
- package/dist/server/dev-stack-sourcemap.d.ts +0 -1
- package/dist/server/document-initial-head.d.ts +12 -2
- package/dist/server/document-initial-head.js +17 -2
- package/dist/server/edge-api-runtime.d.ts +10 -1
- package/dist/server/edge-api-runtime.js +29 -1
- package/dist/server/file-based-metadata.d.ts +0 -1
- package/dist/server/headers.d.ts +17 -2
- package/dist/server/headers.js +17 -1
- package/dist/server/http-conditional.d.ts +22 -0
- package/dist/server/http-conditional.js +117 -0
- package/dist/server/http-date.d.ts +5 -0
- package/dist/server/http-date.js +73 -0
- package/dist/server/http-error-responses.d.ts +2 -1
- package/dist/server/http-error-responses.js +14 -2
- package/dist/server/http-range.d.ts +25 -0
- package/dist/server/http-range.js +67 -0
- package/dist/server/image-optimization.d.ts +14 -6
- package/dist/server/image-optimization.js +0 -1
- package/dist/server/instrumentation.d.ts +7 -4
- package/dist/server/isr-cache.d.ts +28 -6
- package/dist/server/isr-cache.js +19 -13
- package/dist/server/isr-decision.d.ts +6 -4
- package/dist/server/metadata-route-build-data.d.ts +0 -1
- package/dist/server/metadata-route-response.d.ts +0 -1
- package/dist/server/metadata-route-response.js +7 -6
- package/dist/server/metadata-routes.d.ts +34 -16
- package/dist/server/middleware-matcher-pattern.d.ts +0 -1
- package/dist/server/middleware-matcher.d.ts +8 -3
- package/dist/server/middleware-matcher.js +23 -18
- package/dist/server/middleware-runtime.d.ts +6 -1
- package/dist/server/middleware-runtime.js +91 -28
- package/dist/server/middleware.d.ts +0 -1
- package/dist/server/navigation-planner.d.ts +1 -1
- package/dist/server/next-error-digest.d.ts +0 -1
- package/dist/server/pages-api-route.d.ts +2 -1
- package/dist/server/pages-api-route.js +32 -7
- package/dist/server/pages-asset-tags.d.ts +3 -1
- package/dist/server/pages-asset-tags.js +6 -4
- package/dist/server/pages-data-route.d.ts +14 -6
- package/dist/server/pages-data-route.js +19 -10
- package/dist/server/pages-dev-hydration.js +3 -0
- package/dist/server/pages-dev-stylesheets.d.ts +10 -0
- package/dist/server/pages-dev-stylesheets.js +150 -0
- package/dist/server/pages-document-asset-props.d.ts +26 -0
- package/dist/server/pages-document-asset-props.js +69 -0
- package/dist/server/pages-document-initial-props.d.ts +10 -6
- package/dist/server/pages-get-initial-props.d.ts +2 -2
- package/dist/server/pages-i18n.d.ts +1 -7
- package/dist/server/pages-node-compat.d.ts +11 -2
- package/dist/server/pages-node-compat.js +52 -5
- package/dist/server/pages-page-data.d.ts +21 -9
- package/dist/server/pages-page-data.js +109 -30
- package/dist/server/pages-page-handler.d.ts +70 -32
- package/dist/server/pages-page-handler.js +25 -6
- package/dist/server/pages-page-response.d.ts +9 -13
- package/dist/server/pages-page-response.js +25 -26
- package/dist/server/pages-readiness.d.ts +0 -1
- package/dist/server/pages-request-pipeline.d.ts +20 -6
- package/dist/server/pages-request-pipeline.js +40 -20
- package/dist/server/pages-revalidate.d.ts +0 -1
- package/dist/server/pages-revalidate.js +1 -1
- package/dist/server/pages-router-entry.js +14 -10
- package/dist/server/prerender-manifest.d.ts +7 -0
- package/dist/server/prod-server.d.ts +13 -7
- package/dist/server/prod-server.js +276 -83
- package/dist/server/proxy-trust.d.ts +0 -1
- package/dist/server/request-log.d.ts +7 -11
- package/dist/server/request-pipeline.d.ts +13 -4
- package/dist/server/request-pipeline.js +28 -20
- package/dist/server/revalidation-host.d.ts +0 -1
- package/dist/server/revalidation-host.js +1 -1
- package/dist/server/rsc-completion-metadata.d.ts +15 -0
- package/dist/server/rsc-completion-metadata.js +183 -0
- package/dist/server/seed-cache.d.ts +2 -1
- package/dist/server/seed-cache.js +8 -5
- package/dist/server/skip-cache-proof.d.ts +0 -1
- package/dist/server/static-file-cache.d.ts +23 -9
- package/dist/server/static-file-cache.js +47 -23
- package/dist/server/static-layout-client-reuse-proof.d.ts +0 -1
- package/dist/server/worker-revalidation-context.d.ts +0 -1
- package/dist/server/worker-revalidation-context.js +1 -0
- package/dist/server/worker-utils.d.ts +3 -1
- package/dist/server/worker-utils.js +11 -2
- package/dist/shims/app-router-scroll-state.d.ts +2 -1
- package/dist/shims/app-router-scroll-state.js +7 -2
- package/dist/shims/app-router-scroll.d.ts +2 -8
- package/dist/shims/app.d.ts +1 -5
- package/dist/shims/before-interactive-context.d.ts +5 -3
- package/dist/shims/cache-handler.d.ts +6 -1
- package/dist/shims/cache-handler.js +4 -2
- package/dist/shims/cache-request-state.d.ts +12 -1
- package/dist/shims/cache-request-state.js +22 -1
- package/dist/shims/cache-runtime.d.ts +9 -5
- package/dist/shims/cache-runtime.js +16 -6
- package/dist/shims/cache.d.ts +2 -3
- package/dist/shims/cache.js +2 -2
- package/dist/shims/cdn-cache.d.ts +0 -1
- package/dist/shims/client-locale.d.ts +1 -6
- package/dist/shims/client-only.d.ts +1 -1
- package/dist/shims/compat-router.d.ts +0 -1
- package/dist/shims/constants.d.ts +1 -1
- package/dist/shims/default-global-error.d.ts +1 -4
- package/dist/shims/default-not-found.d.ts +0 -1
- package/dist/shims/document.d.ts +0 -1
- package/dist/shims/document.js +17 -3
- package/dist/shims/dynamic-preload-chunks.d.ts +0 -1
- package/dist/shims/dynamic.d.ts +0 -1
- package/dist/shims/error-boundary-navigation.d.ts +0 -1
- package/dist/shims/error-boundary.d.ts +7 -32
- package/dist/shims/error.d.ts +1 -6
- package/dist/shims/fetch-cache.js +112 -63
- package/dist/shims/font-google-base.d.ts +0 -1
- package/dist/shims/font-local.d.ts +0 -1
- package/dist/shims/form.d.ts +5 -3
- package/dist/shims/hash-scroll.d.ts +1 -1
- package/dist/shims/hash-scroll.js +2 -1
- package/dist/shims/head-state.d.ts +0 -1
- package/dist/shims/head.d.ts +1 -4
- package/dist/shims/headers.d.ts +2 -2
- package/dist/shims/headers.js +1 -1
- package/dist/shims/i18n-context.d.ts +0 -1
- package/dist/shims/i18n-state.d.ts +0 -1
- package/dist/shims/image.d.ts +0 -1
- package/dist/shims/image.js +1 -2
- package/dist/shims/internal/als-registry.d.ts +31 -2
- package/dist/shims/internal/als-registry.js +50 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +17 -2
- package/dist/shims/internal/app-prefetch-fetch-queue.js +69 -7
- package/dist/shims/internal/app-route-detection.d.ts +0 -1
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +31 -0
- package/dist/shims/internal/app-route-prefetch-policy.js +57 -0
- package/dist/shims/internal/app-router-context.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +1 -5
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +0 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +6 -8
- package/dist/shims/internal/interpolate-as.d.ts +3 -2
- package/dist/shims/internal/pages-data-target.d.ts +21 -10
- package/dist/shims/internal/pages-data-target.js +1 -1
- package/dist/shims/internal/pages-data-url.d.ts +3 -1
- package/dist/shims/internal/router-context.d.ts +0 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts +4 -3
- package/dist/shims/internal/work-unit-async-storage.js +2 -0
- package/dist/shims/layout-segment-context.d.ts +2 -6
- package/dist/shims/legacy-image.d.ts +0 -1
- package/dist/shims/link.d.ts +29 -21
- package/dist/shims/link.js +52 -97
- package/dist/shims/metadata.d.ts +11 -25
- package/dist/shims/metadata.js +24 -32
- package/dist/shims/navigation-context-state.d.ts +0 -1
- package/dist/shims/navigation-state.d.ts +1 -0
- package/dist/shims/navigation.d.ts +54 -6
- package/dist/shims/navigation.js +325 -73
- package/dist/shims/navigation.react-server.d.ts +1 -0
- package/dist/shims/og.d.ts +0 -1
- package/dist/shims/request-context.d.ts +8 -3
- package/dist/shims/request-state-types.d.ts +1 -0
- package/dist/shims/router.d.ts +44 -23
- package/dist/shims/router.js +8 -7
- package/dist/shims/script-nonce-context.d.ts +0 -1
- package/dist/shims/script.d.ts +25 -13
- package/dist/shims/server-only.d.ts +1 -1
- package/dist/shims/server.d.ts +1 -3
- package/dist/shims/server.js +5 -6
- package/dist/shims/slot.d.ts +23 -11
- package/dist/shims/slot.js +103 -19
- package/dist/shims/streamed-icons.d.ts +7 -0
- package/dist/shims/streamed-icons.js +33 -0
- package/dist/shims/unified-request-context.d.ts +44 -4
- package/dist/shims/unified-request-context.js +56 -2
- package/dist/shims/use-merged-ref.d.ts +0 -1
- package/dist/shims/web-vitals.d.ts +0 -1
- package/dist/typegen.d.ts +1 -2
- package/dist/typegen.js +1 -1
- package/dist/utils/cache-control-metadata.d.ts +13 -1
- package/dist/utils/cache-control-metadata.js +17 -1
- package/dist/utils/client-build-manifest.d.ts +0 -1
- package/dist/utils/domain-locale.d.ts +1 -5
- package/dist/utils/html-limited-bots.js +1 -1
- package/dist/utils/middleware-request-headers.d.ts +17 -5
- package/dist/utils/middleware-request-headers.js +32 -23
- package/dist/utils/precompressed-variant.d.ts +9 -0
- package/dist/utils/precompressed-variant.js +15 -0
- package/dist/utils/project.d.ts +12 -7
- package/dist/utils/public-file-path.d.ts +5 -0
- package/dist/utils/public-file-path.js +12 -0
- package/dist/utils/public-routes.d.ts +1 -1
- package/dist/utils/public-routes.js +6 -5
- package/package.json +7 -3
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { ValidFileMatcher } from "./file-matcher.js";
|
|
2
2
|
import { isInvisibleSegment } from "./utils.js";
|
|
3
|
-
|
|
4
3
|
//#region src/routing/app-route-graph.d.ts
|
|
5
4
|
type InterceptingRoute = {
|
|
6
|
-
/**
|
|
5
|
+
/** Graph-owned identity for this interception edge. */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** The interception convention: "." | ".." | "../.." | "..." */
|
|
8
|
+
convention: string;
|
|
9
|
+
/** The URL pattern this intercepts (e.g. "/photos/:id") */
|
|
7
10
|
targetPattern: string;
|
|
8
11
|
/**
|
|
9
12
|
* URL pattern of the *intercepting route* — the path that owns the slot
|
|
@@ -20,17 +23,28 @@ type InterceptingRoute = {
|
|
|
20
23
|
* @see https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/generate-interception-routes-rewrites.ts
|
|
21
24
|
* @see https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/router/utils/interception-routes.ts
|
|
22
25
|
*/
|
|
23
|
-
sourceMatchPattern: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
sourceMatchPattern: string;
|
|
27
|
+
/** Absolute path to the intercepting page component */
|
|
28
|
+
pagePath: string;
|
|
29
|
+
/** Filesystem segments from app/ root to the intercepting page directory. */
|
|
30
|
+
sourcePageSegments?: string[];
|
|
31
|
+
/** Absolute layout paths inside the intercepting route tree, outermost to innermost */
|
|
32
|
+
layoutPaths: string[];
|
|
33
|
+
/** Normalized branch segments accumulated at each intercept layout. */
|
|
34
|
+
layoutSegments?: string[][];
|
|
35
|
+
/** Loading conventions inside the intercepted branch, outermost to innermost. */
|
|
36
|
+
loadingPaths?: string[];
|
|
37
|
+
/** Tree positions for loadingPaths in the normalized interception branch. */
|
|
38
|
+
loadingTreePositions?: number[];
|
|
39
|
+
/** Full normalized interception branch segments through the page. */
|
|
40
|
+
branchSegments?: string[];
|
|
41
|
+
/** Nearest not-found convention inside the interception branch. */
|
|
42
|
+
notFoundPath?: string | null;
|
|
43
|
+
/** Slot-root-relative branch segments used to scope not-found params. */
|
|
44
|
+
notFoundBranchSegments?: string[];
|
|
45
|
+
/** Tree position relative to the normalized interception branch. */
|
|
46
|
+
notFoundTreePosition?: number | null;
|
|
47
|
+
/** Parameter names for dynamic segments */
|
|
34
48
|
params: string[];
|
|
35
49
|
/**
|
|
36
50
|
* Synthetic page-carrier slot id for sibling (slot-less) interception.
|
|
@@ -39,24 +53,43 @@ type InterceptingRoute = {
|
|
|
39
53
|
slotId?: string;
|
|
40
54
|
};
|
|
41
55
|
type ParallelSlot = {
|
|
42
|
-
/** Graph-owned semantic slot identity. Required on AppRouteGraphParallelSlot. */
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
/** Graph-owned semantic slot identity. Required on AppRouteGraphParallelSlot. */
|
|
57
|
+
id?: string;
|
|
58
|
+
/** Stable slot identity (name + owning directory), used for route serialization keys. */
|
|
59
|
+
key: string;
|
|
60
|
+
/** Slot name (e.g. "team" from @team) */
|
|
61
|
+
name: string;
|
|
62
|
+
/** Absolute path to the @slot directory that owns this slot. Internal routing metadata. */
|
|
63
|
+
ownerDir: string;
|
|
64
|
+
/** Stable tree path for the directory whose layout owns this slot. */
|
|
65
|
+
ownerTreePath: string;
|
|
66
|
+
/** Directory depth of the slot owner from app/ root. */
|
|
67
|
+
ownerTreePosition?: number;
|
|
68
|
+
/** Whether the slot owner directory declares its own page component. */
|
|
69
|
+
hasPage: boolean;
|
|
70
|
+
/** Absolute path to the slot's page component */
|
|
71
|
+
pagePath: string | null;
|
|
72
|
+
/** Absolute path to the slot's default.tsx fallback */
|
|
73
|
+
defaultPath: string | null;
|
|
74
|
+
/** Absolute path to the slot's layout component (wraps slot content) */
|
|
75
|
+
layoutPath: string | null;
|
|
76
|
+
/** Nested active-branch layouts whose exports contribute route config. */
|
|
77
|
+
configLayoutPaths?: string[];
|
|
78
|
+
/** Tree positions of configLayoutPaths relative to the slot root. */
|
|
79
|
+
configLayoutTreePositions?: number[];
|
|
80
|
+
/** Absolute path to the slot's loading component */
|
|
81
|
+
loadingPath: string | null;
|
|
82
|
+
/** Per-segment loading components from the slot root to its active page. */
|
|
83
|
+
loadingPaths?: string[];
|
|
84
|
+
/** Slot-root-relative tree positions aligned with loadingPaths. */
|
|
85
|
+
loadingTreePositions?: number[];
|
|
86
|
+
/** Absolute path to the slot's error component */
|
|
87
|
+
errorPath: string | null;
|
|
88
|
+
/** Nearest not-found convention for the slot's active branch. */
|
|
89
|
+
notFoundPath?: string | null;
|
|
90
|
+
/** Tree position of that convention relative to the slot root. */
|
|
91
|
+
notFoundTreePosition?: number | null;
|
|
92
|
+
/** Intercepting routes within this slot */
|
|
60
93
|
interceptingRoutes: InterceptingRoute[];
|
|
61
94
|
/**
|
|
62
95
|
* The layout index (0-based, in route.layouts[]) that this slot belongs to.
|
|
@@ -87,13 +120,21 @@ type ParallelSlot = {
|
|
|
87
120
|
slotParamNames?: string[];
|
|
88
121
|
};
|
|
89
122
|
type AppRoute = {
|
|
90
|
-
/** Graph-owned semantic identities. Required on AppRouteGraphRoute. */
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
123
|
+
/** Graph-owned semantic identities. Required on AppRouteGraphRoute. */
|
|
124
|
+
ids?: AppRouteSemanticIds;
|
|
125
|
+
/** URL pattern, e.g. "/" or "/about" or "/blog/:slug" */
|
|
126
|
+
pattern: string;
|
|
127
|
+
/** Absolute file path to the page component */
|
|
128
|
+
pagePath: string | null;
|
|
129
|
+
/** Absolute file path to the route handler (route.ts) */
|
|
130
|
+
routePath: string | null;
|
|
131
|
+
/** Ordered list of layout files from root to leaf */
|
|
132
|
+
layouts: string[];
|
|
133
|
+
/** Ordered list of all discovered template files from root to leaf (not necessarily aligned 1:1 with layouts) */
|
|
134
|
+
templates: string[];
|
|
135
|
+
/** Parallel route slots (from @slot directories at the route's directory level) */
|
|
136
|
+
parallelSlots: ParallelSlot[];
|
|
137
|
+
/** Stable implicit children-slot identity for parallel-slot sub-route families. */
|
|
97
138
|
childrenSlot?: {
|
|
98
139
|
id: string;
|
|
99
140
|
ownerTreePath: string;
|
|
@@ -104,20 +145,28 @@ type AppRoute = {
|
|
|
104
145
|
* On soft-nav, the intercepting page replaces the entire page response.
|
|
105
146
|
* Empty array when there are no sibling-style interception markers.
|
|
106
147
|
*/
|
|
107
|
-
siblingIntercepts: InterceptingRoute[];
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
148
|
+
siblingIntercepts: InterceptingRoute[];
|
|
149
|
+
/** Loading component path (leaf directory only) */
|
|
150
|
+
loadingPath: string | null;
|
|
151
|
+
/** Per-segment loading component paths, aligned with loadingTreePositions. */
|
|
152
|
+
loadingPaths?: string[];
|
|
153
|
+
/** Tree position (directory depth from app/ root) for each loading boundary. */
|
|
154
|
+
loadingTreePositions?: number[];
|
|
155
|
+
/** Error component path (leaf directory only) */
|
|
111
156
|
errorPath: string | null;
|
|
112
157
|
/**
|
|
113
158
|
* Per-layout error boundary paths, aligned with the layouts array.
|
|
114
159
|
* Each entry is the error.tsx at the same directory level as the
|
|
115
160
|
* corresponding layout (or null if that level has no error.tsx).
|
|
116
161
|
*/
|
|
117
|
-
layoutErrorPaths: (string | null)[];
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
162
|
+
layoutErrorPaths: (string | null)[];
|
|
163
|
+
/** Per-segment error boundary paths, aligned with errorTreePositions. */
|
|
164
|
+
errorPaths?: string[];
|
|
165
|
+
/** Tree position (directory depth from app/ root) for each error boundary. */
|
|
166
|
+
errorTreePositions?: number[];
|
|
167
|
+
/** Not-found component path (nearest, walking up from page dir) */
|
|
168
|
+
notFoundPath: string | null;
|
|
169
|
+
/** Tree position of the nearest not-found component's owning segment. */
|
|
121
170
|
notFoundTreePosition?: number | null;
|
|
122
171
|
/**
|
|
123
172
|
* Not-found component paths per layout level (aligned with layouts array).
|
|
@@ -131,11 +180,16 @@ type AppRoute = {
|
|
|
131
180
|
* Each entry is the forbidden.tsx at that layout's directory, or null.
|
|
132
181
|
* Used to create per-layout ForbiddenBoundary.
|
|
133
182
|
*/
|
|
134
|
-
forbiddenPaths: (string | null)[];
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
183
|
+
forbiddenPaths: (string | null)[];
|
|
184
|
+
/** Forbidden component path (403) at the route's directory level */
|
|
185
|
+
forbiddenPath: string | null;
|
|
186
|
+
/** Tree position of the nearest forbidden component's owning segment. */
|
|
187
|
+
forbiddenTreePosition?: number | null;
|
|
188
|
+
/** Unauthorized component path (401) at the route's directory level */
|
|
189
|
+
unauthorizedPath: string | null;
|
|
190
|
+
/** Tree position of the nearest unauthorized component's owning segment. */
|
|
191
|
+
unauthorizedTreePosition?: number | null;
|
|
192
|
+
/** Unauthorized component paths per layout level (aligned with layouts array). */
|
|
139
193
|
unauthorizedPaths: (string | null)[];
|
|
140
194
|
/**
|
|
141
195
|
* Filesystem segments from app/ root to the route's directory.
|
|
@@ -151,7 +205,8 @@ type AppRoute = {
|
|
|
151
205
|
* but their children slot renders the parent's default.tsx. In that case the
|
|
152
206
|
* active children segments remain at the parent route.
|
|
153
207
|
*/
|
|
154
|
-
childrenRouteSegments?: string[];
|
|
208
|
+
childrenRouteSegments?: string[];
|
|
209
|
+
/** Tree position (directory depth from app/ root) for each template. */
|
|
155
210
|
templateTreePositions?: number[];
|
|
156
211
|
/**
|
|
157
212
|
* Tree position (directory depth from app/ root) for each layout.
|
|
@@ -160,10 +215,14 @@ type AppRoute = {
|
|
|
160
215
|
* Unlike the old layoutSegmentDepths, this counts ALL directory levels including
|
|
161
216
|
* route groups and parallel slots.
|
|
162
217
|
*/
|
|
163
|
-
layoutTreePositions: number[];
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
218
|
+
layoutTreePositions: number[];
|
|
219
|
+
/** Whether this is a dynamic route */
|
|
220
|
+
isDynamic: boolean;
|
|
221
|
+
/** Parameter names for dynamic segments */
|
|
222
|
+
params: string[];
|
|
223
|
+
/** Dynamic parameter names captured by the route's root layout. */
|
|
224
|
+
rootParamNames?: string[];
|
|
225
|
+
/** Pre-split pattern segments (computed once at scan time, reused per request) */
|
|
167
226
|
patternParts: string[];
|
|
168
227
|
};
|
|
169
228
|
type AppRouteSemanticIds = {
|
|
@@ -201,7 +201,7 @@ function createStaticSegmentGraph(routes) {
|
|
|
201
201
|
}
|
|
202
202
|
for (const ir of route.siblingIntercepts) {
|
|
203
203
|
if (!ir.slotId) continue;
|
|
204
|
-
const id = createAppRouteGraphInterceptionId(ir.slotId, ir.sourceMatchPattern, ir.targetPattern);
|
|
204
|
+
const id = ir.id ?? createAppRouteGraphInterceptionId(ir.slotId, ir.sourceMatchPattern, ir.targetPattern);
|
|
205
205
|
interceptions.set(id, {
|
|
206
206
|
id,
|
|
207
207
|
sourcePattern: ir.sourceMatchPattern,
|
|
@@ -1386,6 +1386,7 @@ function discoverSiblingInterceptingRoutes(routes, appDir, matcher) {
|
|
|
1386
1386
|
collectInterceptingPages(childDir, childDir, marker.convention, restOfName, parentDir, appDir, parentDir, null, results, matcher);
|
|
1387
1387
|
for (const ir of results) {
|
|
1388
1388
|
ir.slotId = createAppRouteGraphSiblingInterceptSlotId(ir.sourceMatchPattern);
|
|
1389
|
+
ir.id = createAppRouteGraphInterceptionId(ir.slotId, ir.sourceMatchPattern, ir.targetPattern);
|
|
1389
1390
|
const owner = findOwnerRouteForDir(parentDir, appDir, routes, routesByDir);
|
|
1390
1391
|
if (owner) owner.siblingIntercepts.push(ir);
|
|
1391
1392
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ValidFileMatcher } from "./file-matcher.js";
|
|
2
2
|
import { AppRoute, AppRouteGraphRoute, RouteManifest, computeAppRouteStaticSiblings, computeRootParamNames, convertSegmentsToRouteParts } from "./app-route-graph.js";
|
|
3
|
-
|
|
4
3
|
//#region src/routing/app-router.d.ts
|
|
5
4
|
type AppRouteGraph = {
|
|
6
5
|
routes: AppRouteGraphRoute[];
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { ValidFileMatcher } from "./file-matcher.js";
|
|
2
2
|
import { patternToNextFormat } from "./route-validation.js";
|
|
3
|
-
|
|
4
3
|
//#region src/routing/pages-router.d.ts
|
|
5
4
|
type Route = {
|
|
6
|
-
/** URL pattern, e.g. "/" or "/about" or "/posts/:id" */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/** URL pattern, e.g. "/" or "/about" or "/posts/:id" */
|
|
6
|
+
pattern: string;
|
|
7
|
+
/** Pre-split pattern segments (computed once at scan time, reused per request) */
|
|
8
|
+
patternParts: string[];
|
|
9
|
+
/** Absolute file path to the page component */
|
|
10
|
+
filePath: string;
|
|
11
|
+
/** Whether this is a dynamic route */
|
|
12
|
+
isDynamic: boolean;
|
|
13
|
+
/** Parameter names for dynamic segments */
|
|
10
14
|
params: string[];
|
|
11
15
|
};
|
|
12
16
|
/**
|
package/dist/routing/utils.d.ts
CHANGED
|
@@ -91,27 +91,5 @@ declare function isCatchAllSegment(segment: string): boolean;
|
|
|
91
91
|
* this matches zero or more URL segments.
|
|
92
92
|
*/
|
|
93
93
|
declare function isOptionalCatchAllSegment(segment: string): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Count how many pathname segments a tree path's *visible* segments consume,
|
|
96
|
-
* given the total number of pathname segments available.
|
|
97
|
-
*
|
|
98
|
-
* This is the minimal pure slice of the canonical filesystem-segment →
|
|
99
|
-
* URL-segment mapping in `app-route-graph.ts` (`convertSegmentsToRouteParts`),
|
|
100
|
-
* extracted here so browser-side bfcache identity logic can share it without
|
|
101
|
-
* importing the Node-bound route graph module. `convertSegmentsToRouteParts`
|
|
102
|
-
* remains the source of truth for how each segment kind maps to a URL part.
|
|
103
|
-
*
|
|
104
|
-
* Each ordinary visible segment (static or `[x]`) consumes exactly one pathname
|
|
105
|
-
* segment. A catch-all (`[...x]`) is terminal and consumes every remaining
|
|
106
|
-
* pathname segment. An optional-catch-all (`[[...x]]`) is also terminal but may
|
|
107
|
-
* match zero segments, so it consumes only the remaining pathname segments
|
|
108
|
-
* (which is zero once preceding segments have already consumed the pathname) —
|
|
109
|
-
* never more than are actually present.
|
|
110
|
-
*
|
|
111
|
-
* @param visibleTreePathSegments URL-visible tree-path segments (callers must
|
|
112
|
-
* pre-filter invisible segments via `isInvisibleSegment`).
|
|
113
|
-
* @param pathnameSegmentCount Total number of pathname segments available.
|
|
114
|
-
*/
|
|
115
|
-
declare function countConsumedPathnameSegments(visibleTreePathSegments: readonly string[], pathnameSegmentCount: number): number;
|
|
116
94
|
//#endregion
|
|
117
|
-
export { buildParams, compareHybridRoutePatterns,
|
|
95
|
+
export { buildParams, compareHybridRoutePatterns, decodeMatchedParams, decodeRouteSegment, isCatchAllSegment, isInvisibleSegment, isOptionalCatchAllSegment, normalizePathnameForRouteMatch, normalizePathnameForRouteMatchStrict, sortRoutes, splitPathSegments, splitPathnameForRouteMatch };
|
package/dist/routing/utils.js
CHANGED
|
@@ -209,34 +209,5 @@ function isCatchAllSegment(segment) {
|
|
|
209
209
|
function isOptionalCatchAllSegment(segment) {
|
|
210
210
|
return segment.startsWith("[[...") && segment.endsWith("]]") && segment.length > 7;
|
|
211
211
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Count how many pathname segments a tree path's *visible* segments consume,
|
|
214
|
-
* given the total number of pathname segments available.
|
|
215
|
-
*
|
|
216
|
-
* This is the minimal pure slice of the canonical filesystem-segment →
|
|
217
|
-
* URL-segment mapping in `app-route-graph.ts` (`convertSegmentsToRouteParts`),
|
|
218
|
-
* extracted here so browser-side bfcache identity logic can share it without
|
|
219
|
-
* importing the Node-bound route graph module. `convertSegmentsToRouteParts`
|
|
220
|
-
* remains the source of truth for how each segment kind maps to a URL part.
|
|
221
|
-
*
|
|
222
|
-
* Each ordinary visible segment (static or `[x]`) consumes exactly one pathname
|
|
223
|
-
* segment. A catch-all (`[...x]`) is terminal and consumes every remaining
|
|
224
|
-
* pathname segment. An optional-catch-all (`[[...x]]`) is also terminal but may
|
|
225
|
-
* match zero segments, so it consumes only the remaining pathname segments
|
|
226
|
-
* (which is zero once preceding segments have already consumed the pathname) —
|
|
227
|
-
* never more than are actually present.
|
|
228
|
-
*
|
|
229
|
-
* @param visibleTreePathSegments URL-visible tree-path segments (callers must
|
|
230
|
-
* pre-filter invisible segments via `isInvisibleSegment`).
|
|
231
|
-
* @param pathnameSegmentCount Total number of pathname segments available.
|
|
232
|
-
*/
|
|
233
|
-
function countConsumedPathnameSegments(visibleTreePathSegments, pathnameSegmentCount) {
|
|
234
|
-
let consumed = 0;
|
|
235
|
-
for (const segment of visibleTreePathSegments) {
|
|
236
|
-
if (isCatchAllSegment(segment) || isOptionalCatchAllSegment(segment)) return Math.max(consumed, pathnameSegmentCount);
|
|
237
|
-
consumed += 1;
|
|
238
|
-
}
|
|
239
|
-
return consumed;
|
|
240
|
-
}
|
|
241
212
|
//#endregion
|
|
242
|
-
export { buildParams, compareHybridRoutePatterns,
|
|
213
|
+
export { buildParams, compareHybridRoutePatterns, decodeMatchedParams, decodeRouteSegment, isCatchAllSegment, isInvisibleSegment, isOptionalCatchAllSegment, normalizePathnameForRouteMatch, normalizePathnameForRouteMatchStrict, sortRoutes, splitPathSegments, splitPathnameForRouteMatch };
|
|
@@ -2,7 +2,6 @@ import { NextI18nConfig } from "../config/next-config.js";
|
|
|
2
2
|
import { Route } from "../routing/pages-router.js";
|
|
3
3
|
import { ModuleImporter } from "./instrumentation.js";
|
|
4
4
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
5
|
-
|
|
6
5
|
//#region src/server/api-handler.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Handle an API route request.
|
|
@@ -9,7 +9,7 @@ import { PagesBodyParseError, getMediaType, isJsonMediaType } from "./pages-medi
|
|
|
9
9
|
import { resolveRequestHost, resolveRequestProtocol } from "./proxy-trust.js";
|
|
10
10
|
import { performOnDemandRevalidate } from "./pages-revalidate.js";
|
|
11
11
|
import { attachPagesPreviewApi, attachPagesRequestCookies } from "./pages-node-compat.js";
|
|
12
|
-
import { isEdgeApiRuntime } from "./edge-api-runtime.js";
|
|
12
|
+
import { finalizeEdgeApiResponse, isEdgeApiRuntime } from "./edge-api-runtime.js";
|
|
13
13
|
import { decode } from "node:querystring";
|
|
14
14
|
import { Buffer } from "node:buffer";
|
|
15
15
|
//#region src/server/api-handler.ts
|
|
@@ -227,8 +227,9 @@ async function handleApiRoute(runner, req, res, url, apiRoutes, nextConfig) {
|
|
|
227
227
|
i18n: nextConfig.i18n ?? void 0,
|
|
228
228
|
trailingSlash: nextConfig.trailingSlash
|
|
229
229
|
} } : void 0);
|
|
230
|
-
const
|
|
231
|
-
if (!(
|
|
230
|
+
const handlerResponse = await apiModule.default(nextRequest);
|
|
231
|
+
if (!(handlerResponse instanceof Response)) throw new Error("Edge API route did not return a Response");
|
|
232
|
+
const response = finalizeEdgeApiResponse(handlerResponse, "node");
|
|
232
233
|
res.statusCode = response.status;
|
|
233
234
|
res.statusMessage = response.statusText;
|
|
234
235
|
const setCookieHeaders = response.headers.getSetCookie();
|
|
@@ -1,29 +1,26 @@
|
|
|
1
|
+
import { BfcacheSegmentIdentity } from "./bfcache-identity.js";
|
|
1
2
|
import { AppElements, AppElementsWire } from "./app-elements-wire.js";
|
|
3
|
+
import "./app-elements.js";
|
|
2
4
|
import { BfcacheIdMap } from "./app-history-state.js";
|
|
3
|
-
|
|
4
5
|
//#region src/server/app-bfcache-identity.d.ts
|
|
5
|
-
type
|
|
6
|
+
type BfcacheSegmentIdentityMap = Readonly<Record<string, BfcacheSegmentIdentity>>;
|
|
6
7
|
type InitialBfcacheMaps = Readonly<{
|
|
7
8
|
bfcacheIds: BfcacheIdMap;
|
|
8
|
-
|
|
9
|
+
identities: BfcacheSegmentIdentityMap;
|
|
9
10
|
}>;
|
|
10
11
|
type AppElementsMetadata = ReturnType<typeof AppElementsWire.readMetadata>;
|
|
11
12
|
declare function createInitialBfcacheIdMap(elements: AppElements): BfcacheIdMap;
|
|
12
|
-
declare function
|
|
13
|
+
declare function createBfcacheSegmentIdentityMap(options: {
|
|
13
14
|
elements: AppElements;
|
|
14
|
-
|
|
15
|
-
}): BfcacheStateKeyMap;
|
|
15
|
+
}): BfcacheSegmentIdentityMap;
|
|
16
16
|
declare function createInitialBfcacheMaps(options: {
|
|
17
17
|
elements: AppElements;
|
|
18
18
|
metadata: AppElementsMetadata;
|
|
19
|
-
pathname: string;
|
|
20
19
|
}): InitialBfcacheMaps;
|
|
21
20
|
declare function createNextBfcacheIdMap(options: {
|
|
22
21
|
current: BfcacheIdMap;
|
|
23
22
|
currentElements: AppElements;
|
|
24
|
-
currentPathname: string;
|
|
25
23
|
elements: AppElements;
|
|
26
|
-
nextPathname: string;
|
|
27
24
|
restored?: BfcacheIdMap | null;
|
|
28
25
|
reuseCurrent?: boolean;
|
|
29
26
|
}): BfcacheIdMap;
|
|
@@ -31,6 +28,8 @@ declare function preserveBfcacheIdsForMergedElements(options: {
|
|
|
31
28
|
elements: AppElements;
|
|
32
29
|
next: BfcacheIdMap;
|
|
33
30
|
previous: BfcacheIdMap;
|
|
31
|
+
preservedElementIds?: readonly string[];
|
|
32
|
+
preservePreviousIds?: readonly string[];
|
|
34
33
|
}): BfcacheIdMap;
|
|
35
34
|
//#endregion
|
|
36
|
-
export {
|
|
35
|
+
export { BfcacheSegmentIdentityMap, InitialBfcacheMaps, createBfcacheSegmentIdentityMap, createInitialBfcacheIdMap, createInitialBfcacheMaps, createNextBfcacheIdMap, preserveBfcacheIdsForMergedElements };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { countConsumedPathnameSegments, isInvisibleSegment, normalizePathnameForRouteMatch, splitPathSegments } from "../routing/utils.js";
|
|
2
|
-
import { normalizePath } from "./normalize-path.js";
|
|
3
1
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
4
2
|
import "./app-elements.js";
|
|
3
|
+
import { isNestedBfcacheSlotSegmentIdFor } from "./bfcache-identity.js";
|
|
5
4
|
import "./app-bfcache-id.js";
|
|
5
|
+
import { isBfcacheSegmentId } from "./app-history-state.js";
|
|
6
6
|
//#region src/server/app-bfcache-identity.ts
|
|
7
7
|
let nextBfcacheId = 0;
|
|
8
8
|
function rememberBfcacheId(value) {
|
|
@@ -14,106 +14,35 @@ function mintBfcacheId() {
|
|
|
14
14
|
nextBfcacheId += 1;
|
|
15
15
|
return `_b_${nextBfcacheId}_`;
|
|
16
16
|
}
|
|
17
|
-
function getVisibleTreePathSegments(treePath) {
|
|
18
|
-
return splitPathSegments(treePath).filter((segment) => !isInvisibleSegment(segment));
|
|
19
|
-
}
|
|
20
|
-
function getTreePathIdentityPrefix(pathname, treePath) {
|
|
21
|
-
const pathnameSegments = splitPathSegments(pathname);
|
|
22
|
-
const consumedPathnameSegments = countConsumedPathnameSegments(getVisibleTreePathSegments(treePath), pathnameSegments.length);
|
|
23
|
-
if (consumedPathnameSegments === 0) return "/";
|
|
24
|
-
return `/${pathnameSegments.slice(0, consumedPathnameSegments).join("/")}`;
|
|
25
|
-
}
|
|
26
|
-
function indexAppElementsMetadata(metadata) {
|
|
27
|
-
const slotBindingsBySlotId = /* @__PURE__ */ new Map();
|
|
28
|
-
for (const binding of metadata.slotBindings) slotBindingsBySlotId.set(binding.slotId, binding);
|
|
29
|
-
return {
|
|
30
|
-
metadata,
|
|
31
|
-
slotBindingsBySlotId
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
17
|
function readAppElementsMetadata(elements) {
|
|
35
|
-
let metadata;
|
|
36
18
|
try {
|
|
37
|
-
|
|
19
|
+
return AppElementsWire.readMetadata(elements);
|
|
38
20
|
} catch {
|
|
39
21
|
return null;
|
|
40
22
|
}
|
|
41
|
-
return indexAppElementsMetadata(metadata);
|
|
42
|
-
}
|
|
43
|
-
function parseBfcacheSegmentKey(id) {
|
|
44
|
-
const parsed = AppElementsWire.parseElementKey(id);
|
|
45
|
-
return parsed !== null && parsed.kind !== "route" ? parsed : null;
|
|
46
|
-
}
|
|
47
|
-
function createActiveSlotIdentity(id, parsed) {
|
|
48
|
-
const activeSlotBinding = parsed?.slotBindingsBySlotId.get(id);
|
|
49
|
-
if (activeSlotBinding?.activeRouteId != null) return `${id}@${activeSlotBinding.activeRouteId}`;
|
|
50
|
-
const interception = parsed?.metadata.interception;
|
|
51
|
-
if (interception?.slotId !== id) return null;
|
|
52
|
-
return `${id}@${interception.targetRouteId}`;
|
|
53
23
|
}
|
|
54
|
-
|
|
55
|
-
* Derive BFCache identity from AppElements wire keys. Keep wire-key parsing
|
|
56
|
-
* contained here until vinext has a route-manifest authority equivalent to
|
|
57
|
-
* Next.js CacheNode or segment-cache state.
|
|
58
|
-
*/
|
|
59
|
-
function createBfcacheSegmentIdentity(id, parsed, options) {
|
|
60
|
-
if (parsed.kind === "page") return `${id}@${options.pathname}`;
|
|
61
|
-
if (parsed.kind === "slot") {
|
|
62
|
-
const activeSlotIdentity = createActiveSlotIdentity(id, options.metadata);
|
|
63
|
-
if (activeSlotIdentity !== null) return activeSlotIdentity;
|
|
64
|
-
return `${id}@${getTreePathIdentityPrefix(options.pathname, parsed.treePath)}`;
|
|
65
|
-
}
|
|
66
|
-
if (parsed.kind === "layout" || parsed.kind === "template") return `${id}@${getTreePathIdentityPrefix(options.pathname, parsed.treePath)}`;
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
function collectBfcacheSegmentIdCandidates(elements, metadata = readAppElementsMetadata(elements)) {
|
|
24
|
+
function collectBfcacheSegmentIds(elements, metadata) {
|
|
70
25
|
const ids = new Set(Object.keys(elements));
|
|
71
|
-
|
|
72
|
-
|
|
26
|
+
const parsedMetadata = metadata === void 0 ? readAppElementsMetadata(elements) : metadata;
|
|
27
|
+
for (const layoutId of parsedMetadata?.layoutIds ?? []) ids.add(layoutId);
|
|
28
|
+
for (const identityId of Object.keys(parsedMetadata?.bfcacheSegmentIdentities ?? {})) ids.add(identityId);
|
|
29
|
+
return Array.from(ids).filter(isBfcacheSegmentId);
|
|
73
30
|
}
|
|
74
31
|
function createInitialBfcacheIdMap(elements) {
|
|
75
32
|
const bfcacheIds = {};
|
|
76
|
-
for (const id of
|
|
33
|
+
for (const id of collectBfcacheSegmentIds(elements)) bfcacheIds[id] = "0";
|
|
77
34
|
return bfcacheIds;
|
|
78
35
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
return normalized.length > 1 ? normalized.replace(/\/$/, "") : normalized;
|
|
82
|
-
}
|
|
83
|
-
function createBfcacheSegmentStateKeyMap(options) {
|
|
84
|
-
const metadata = readAppElementsMetadata(options.elements);
|
|
85
|
-
const normalizedPathname = normalizeBfcachePathname(options.pathname);
|
|
86
|
-
const stateKeys = {};
|
|
87
|
-
for (const id of collectBfcacheSegmentIdCandidates(options.elements, metadata)) {
|
|
88
|
-
const parsed = parseBfcacheSegmentKey(id);
|
|
89
|
-
if (parsed === null) continue;
|
|
90
|
-
const stateKey = createBfcacheSegmentIdentity(id, parsed, {
|
|
91
|
-
metadata,
|
|
92
|
-
pathname: normalizedPathname
|
|
93
|
-
});
|
|
94
|
-
if (stateKey !== null) stateKeys[id] = stateKey;
|
|
95
|
-
}
|
|
96
|
-
return stateKeys;
|
|
36
|
+
function createBfcacheSegmentIdentityMap(options) {
|
|
37
|
+
return readAppElementsMetadata(options.elements)?.bfcacheSegmentIdentities ?? {};
|
|
97
38
|
}
|
|
98
39
|
function createInitialBfcacheMaps(options) {
|
|
99
|
-
const metadata =
|
|
100
|
-
const ids = collectBfcacheSegmentIdCandidates(options.elements, metadata);
|
|
101
|
-
const normalizedPathname = normalizeBfcachePathname(options.pathname);
|
|
40
|
+
const metadata = options.metadata;
|
|
102
41
|
const bfcacheIds = {};
|
|
103
|
-
const
|
|
104
|
-
for (const id of ids) {
|
|
105
|
-
const parsed = parseBfcacheSegmentKey(id);
|
|
106
|
-
if (parsed === null) continue;
|
|
107
|
-
bfcacheIds[id] = "0";
|
|
108
|
-
const stateKey = createBfcacheSegmentIdentity(id, parsed, {
|
|
109
|
-
metadata,
|
|
110
|
-
pathname: normalizedPathname
|
|
111
|
-
});
|
|
112
|
-
if (stateKey !== null) stateKeys[id] = stateKey;
|
|
113
|
-
}
|
|
42
|
+
for (const id of collectBfcacheSegmentIds(options.elements, metadata)) bfcacheIds[id] = "0";
|
|
114
43
|
return {
|
|
115
44
|
bfcacheIds,
|
|
116
|
-
|
|
45
|
+
identities: metadata.bfcacheSegmentIdentities
|
|
117
46
|
};
|
|
118
47
|
}
|
|
119
48
|
function createNextBfcacheIdMap(options) {
|
|
@@ -122,20 +51,12 @@ function createNextBfcacheIdMap(options) {
|
|
|
122
51
|
for (const value of Object.values(options.restored ?? {})) rememberBfcacheId(value);
|
|
123
52
|
const currentMetadata = readAppElementsMetadata(options.currentElements);
|
|
124
53
|
const nextMetadata = readAppElementsMetadata(options.elements);
|
|
125
|
-
const currentPathname = normalizeBfcachePathname(options.currentPathname);
|
|
126
|
-
const nextPathname = normalizeBfcachePathname(options.nextPathname);
|
|
127
54
|
const ids = {};
|
|
128
|
-
for (const id of
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
const currentValue =
|
|
132
|
-
|
|
133
|
-
pathname: currentPathname
|
|
134
|
-
}) === createBfcacheSegmentIdentity(id, parsed, {
|
|
135
|
-
metadata: nextMetadata,
|
|
136
|
-
pathname: nextPathname
|
|
137
|
-
}) ? current[id] : void 0;
|
|
138
|
-
const value = options.restored?.[id] ?? currentValue ?? mintBfcacheId();
|
|
55
|
+
for (const id of collectBfcacheSegmentIds(options.elements, nextMetadata)) {
|
|
56
|
+
const currentIdentity = currentMetadata?.bfcacheSegmentIdentities[id];
|
|
57
|
+
const nextIdentity = nextMetadata?.bfcacheSegmentIdentities[id];
|
|
58
|
+
const currentValue = currentIdentity !== void 0 && currentIdentity === nextIdentity ? current[id] : void 0;
|
|
59
|
+
const value = (nextIdentity === void 0 ? void 0 : options.restored?.[id]) ?? currentValue ?? mintBfcacheId();
|
|
139
60
|
ids[id] = value;
|
|
140
61
|
rememberBfcacheId(value);
|
|
141
62
|
}
|
|
@@ -143,9 +64,13 @@ function createNextBfcacheIdMap(options) {
|
|
|
143
64
|
}
|
|
144
65
|
function preserveBfcacheIdsForMergedElements(options) {
|
|
145
66
|
const ids = {};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
67
|
+
const preservePreviousIds = new Set(options.preservePreviousIds ?? []);
|
|
68
|
+
const preservedElementIds = new Set(options.preservedElementIds ?? []);
|
|
69
|
+
const preservedParentIds = [...preservedElementIds];
|
|
70
|
+
const identities = createBfcacheSegmentIdentityMap({ elements: options.elements });
|
|
71
|
+
for (const id of collectBfcacheSegmentIds(options.elements)) {
|
|
72
|
+
const isPreservedNestedSegment = preservedParentIds.some((parentId) => isNestedBfcacheSlotSegmentIdFor(id, parentId));
|
|
73
|
+
const value = (preservedElementIds.has(id) || isPreservedNestedSegment) && identities[id] === void 0 ? mintBfcacheId() : preservePreviousIds.has(id) || isPreservedNestedSegment ? options.previous[id] ?? options.next[id] : options.next[id] ?? options.previous[id];
|
|
149
74
|
if (value === void 0) continue;
|
|
150
75
|
ids[id] = value;
|
|
151
76
|
rememberBfcacheId(value);
|
|
@@ -153,4 +78,4 @@ function preserveBfcacheIdsForMergedElements(options) {
|
|
|
153
78
|
return ids;
|
|
154
79
|
}
|
|
155
80
|
//#endregion
|
|
156
|
-
export {
|
|
81
|
+
export { createBfcacheSegmentIdentityMap, createInitialBfcacheIdMap, createInitialBfcacheMaps, createNextBfcacheIdMap, preserveBfcacheIdsForMergedElements };
|