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
package/dist/shims/navigation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stripBasePath } from "../utils/base-path.js";
|
|
2
|
-
import { VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER, VINEXT_RENDERED_PATH_AND_SEARCH_HEADER } from "../server/headers.js";
|
|
2
|
+
import { NEXT_ROUTER_PREFETCH_HEADER, NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, NEXT_ROUTER_STALE_TIME_HEADER, VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER, VINEXT_RENDERED_PATH_AND_SEARCH_HEADER, VINEXT_RSC_COMPLETION_METADATA_HEADER, VINEXT_STALE_TIME_PENDING_HEADER } from "../server/headers.js";
|
|
3
3
|
import { assertSafeNavigationUrl } from "./url-safety.js";
|
|
4
4
|
import { isExternalUrl } from "../utils/external-url.js";
|
|
5
5
|
import { AppElementsWire } from "../server/app-elements-wire.js";
|
|
@@ -7,24 +7,25 @@ import "../server/app-elements.js";
|
|
|
7
7
|
import { markPprFallbackShellDynamicBoundary } from "./ppr-fallback-shell.js";
|
|
8
8
|
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
9
9
|
import { resolveDirectHybridClientRouteOwner } from "./internal/hybrid-client-route-owner-direct.js";
|
|
10
|
-
import { toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
|
|
11
|
-
import { retryScrollTo, scrollToHashTarget } from "./hash-scroll.js";
|
|
10
|
+
import { isHashOnlyBrowserUrlChange, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
|
|
11
|
+
import { retryScrollTo, scrollToHashTarget, scrollToHashTargetOnNextFrame } from "./hash-scroll.js";
|
|
12
12
|
import { isBotUserAgent } from "../utils/html-limited-bots.js";
|
|
13
13
|
import { GLOBAL_ACCESSORS_KEY, ServerInsertedHTMLContext, _registerStateAccessors, clearClientHydrationContext, clearServerInsertedHTML, flushServerInsertedHTML, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getLayoutSegmentContext, getNavigationContext, registerServerInsertedHTMLCallback, renderServerInsertedHTML, setNavigationContext } from "./navigation-context-state.js";
|
|
14
14
|
import { BailoutToCSRError, DynamicServerError, HTTP_ERROR_FALLBACK_ERROR_CODE, RedirectType, decodeRedirectError, forbidden, getAccessFallbackHTTPStatus, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, notFound, permanentRedirect, redirect, unauthorized, unstable_rethrow } from "./navigation-errors.js";
|
|
15
15
|
import { clearAppNavigationFailureTarget, stageAppNavigationFailureTarget } from "../client/app-nav-failure-handler.js";
|
|
16
|
-
import { beginAppRouterScrollIntent, clearAppRouterScrollIntent, consumeAppRouterScrollIntent, getPendingAppRouterScrollIntent } from "./app-router-scroll-state.js";
|
|
16
|
+
import { beginAppRouterScrollIntent, clearAppRouterScrollIntent, consumeAppRouterScrollIntent, getPendingAppRouterScrollIntent, isLatestAppRouterScrollIntent } from "./app-router-scroll-state.js";
|
|
17
17
|
import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, createRscRequestHeaders, createRscRequestUrl, stripRscCacheBustingSearchParam, stripRscSuffix } from "../server/app-rsc-cache-busting.js";
|
|
18
18
|
import { getNavigationRuntime, hasAppNavigationRuntime } from "../client/navigation-runtime.js";
|
|
19
19
|
import { notifyAppRouterTransitionStart } from "../client/instrumentation-client-state.js";
|
|
20
20
|
import { PUBLIC_INITIAL_BFCACHE_ID } from "../server/app-bfcache-id.js";
|
|
21
|
-
import { resolveManifestNavigationInterceptionContext } from "../server/app-browser-interception-context.js";
|
|
22
21
|
import { createExternalHistoryStatePreservingMetadata, createHashOnlyHistoryStatePreservingNavigationMetadata } from "../server/app-history-state.js";
|
|
22
|
+
import { resolveManifestNavigationInterceptionContext } from "../server/app-browser-interception-context.js";
|
|
23
23
|
import { hasPendingAppRouterPageRedirect } from "../server/app-browser-mpa-navigation.js";
|
|
24
|
+
import { extractRscCompletionMetadata } from "../server/rsc-completion-metadata.js";
|
|
24
25
|
import { navigationPlanner } from "../server/navigation-planner.js";
|
|
25
26
|
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
26
27
|
import { getPagesNavigationContext } from "./internal/pages-router-accessor.js";
|
|
27
|
-
import { releaseAppPrefetchFetchSlot, scheduleAppPrefetchFetch } from "./internal/app-prefetch-fetch-queue.js";
|
|
28
|
+
import { cancelAppPrefetchFetch, promoteAppPrefetchFetch, releaseAppPrefetchFetchSlot, scheduleAppPrefetchFetch } from "./internal/app-prefetch-fetch-queue.js";
|
|
28
29
|
import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
|
|
29
30
|
import * as React$1 from "react";
|
|
30
31
|
//#region src/shims/navigation.ts
|
|
@@ -36,6 +37,7 @@ import * as React$1 from "react";
|
|
|
36
37
|
* Client-side: reads from browser Location API and provides navigation.
|
|
37
38
|
*/
|
|
38
39
|
const HAS_PAGES_ROUTER = process.env.__VINEXT_HAS_PAGES_ROUTER !== "false";
|
|
40
|
+
const HAS_CLIENT_REWRITES = process.env.__VINEXT_HAS_CLIENT_REWRITES !== "false";
|
|
39
41
|
let hybridClientRouteOwnerModule = null;
|
|
40
42
|
let hybridClientRouteOwnerModulePromise = null;
|
|
41
43
|
/** Load rewrite-aware hybrid route ownership before navigation becomes interactive. */
|
|
@@ -72,6 +74,8 @@ const PAGES_NAVIGATION_NOTIFY_KEY = Symbol.for("vinext.navigation.pagesNavigatio
|
|
|
72
74
|
const isServer = typeof window === "undefined";
|
|
73
75
|
/** basePath from next.config.js, injected by the plugin at build time */
|
|
74
76
|
const __basePath = process.env.__NEXT_ROUTER_BASEPATH ?? "";
|
|
77
|
+
/** prefetch inlining (Segment Cache wire mode), injected by the plugin at build time */
|
|
78
|
+
const __prefetchInlining = process.env.__VINEXT_PREFETCH_INLINING === "true";
|
|
75
79
|
/** Maximum buffered bytes in the RSC prefetch cache. Mirrors Next.js' 50 MB LRU. */
|
|
76
80
|
const MAX_PREFETCH_CACHE_SIZE = 50 * 1024 * 1024;
|
|
77
81
|
const PREFETCH_CACHE_EVICTION_TARGET_SIZE = MAX_PREFETCH_CACHE_SIZE * .9;
|
|
@@ -97,7 +101,13 @@ function resolveClientRouterStaleTime(raw, fallbackMs) {
|
|
|
97
101
|
}
|
|
98
102
|
const DYNAMIC_NAVIGATION_CACHE_TTL = resolveClientRouterStaleTime(process.env.__NEXT_CLIENT_ROUTER_DYNAMIC_STALETIME, 3e4);
|
|
99
103
|
const PREFETCH_CACHE_TTL = resolveClientRouterStaleTime(process.env.__NEXT_CLIENT_ROUTER_STATIC_STALETIME, 3e4);
|
|
100
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Floor for any server-declared `cacheLife` stale time, mirroring Next.js's
|
|
106
|
+
* `getStaleTimeMs` (`Math.max(staleTimeSeconds, 30) * 1000`). One rule for
|
|
107
|
+
* both client caches, so behavior does not depend on which cache a route hit.
|
|
108
|
+
*/
|
|
109
|
+
const MIN_SERVER_STALE_TIME_SECONDS = 30;
|
|
110
|
+
const MIN_PREFETCH_STALE_TIME_MS = MIN_SERVER_STALE_TIME_SECONDS * 1e3;
|
|
101
111
|
function getCurrentInterceptionContext() {
|
|
102
112
|
if (isServer) return null;
|
|
103
113
|
return stripBasePath(window.location.pathname, __basePath);
|
|
@@ -121,6 +131,15 @@ function getCurrentNextUrl() {
|
|
|
121
131
|
if (isServer) return "/";
|
|
122
132
|
return window.location.pathname + window.location.search;
|
|
123
133
|
}
|
|
134
|
+
function createAppPrefetchRequestHeaders(options) {
|
|
135
|
+
const prefetchRouterState = getNavigationRuntime()?.functions.getPrefetchRouterState?.() ?? null;
|
|
136
|
+
return createRscRequestHeaders({
|
|
137
|
+
...options,
|
|
138
|
+
nextUrl: getCurrentNextUrl(),
|
|
139
|
+
includePrefetchHeader: options.prefetchKind !== "full",
|
|
140
|
+
prefetchRouterState
|
|
141
|
+
});
|
|
142
|
+
}
|
|
124
143
|
/** Get or create the shared in-memory RSC prefetch cache on window. */
|
|
125
144
|
function getPrefetchCache() {
|
|
126
145
|
if (isServer) return /* @__PURE__ */ new Map();
|
|
@@ -136,31 +155,56 @@ function getPrefetchedUrls() {
|
|
|
136
155
|
if (!window.__VINEXT_RSC_PREFETCHED_URLS__) window.__VINEXT_RSC_PREFETCHED_URLS__ = /* @__PURE__ */ new Set();
|
|
137
156
|
return window.__VINEXT_RSC_PREFETCHED_URLS__;
|
|
138
157
|
}
|
|
139
|
-
function
|
|
158
|
+
function isStaleTimeSeconds(value) {
|
|
140
159
|
return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value >= 0;
|
|
141
160
|
}
|
|
142
161
|
function isCacheExpiresAt(value) {
|
|
143
162
|
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
144
163
|
}
|
|
145
|
-
function
|
|
164
|
+
function parseStaleTimeSecondsHeader(value) {
|
|
146
165
|
if (value === null || value === "") return void 0;
|
|
147
166
|
const seconds = Number(value);
|
|
148
|
-
return
|
|
167
|
+
return isStaleTimeSeconds(seconds) ? seconds : void 0;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The floor a `cacheLife` claim licenses. A pending claim contributes exactly
|
|
171
|
+
* the floor — the least any resolution of it could have granted.
|
|
172
|
+
*/
|
|
173
|
+
function serverStaleTimeSeconds(server) {
|
|
174
|
+
if (server === void 0) return void 0;
|
|
175
|
+
if (server.kind === "pending") return MIN_SERVER_STALE_TIME_SECONDS;
|
|
176
|
+
return Math.max(server.seconds, MIN_SERVER_STALE_TIME_SECONDS);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Min-combine the two independent staleness lattices a response can carry:
|
|
180
|
+
* `dynamicStaleTimeSeconds` (from `experimental.staleTimes` config) and
|
|
181
|
+
* `serverStaleTime` (from the render's `cacheLife`) — neither may override
|
|
182
|
+
* the other. The cacheLife value is floored *before* the min so the floor
|
|
183
|
+
* never raises the config bound. Undefined = no signal; the caller's
|
|
184
|
+
* fallback TTL stays in force.
|
|
185
|
+
*/
|
|
186
|
+
function resolveRscResponseStaleTimeSeconds(cached) {
|
|
187
|
+
const dynamic = cached.dynamicStaleTimeSeconds;
|
|
188
|
+
const server = serverStaleTimeSeconds(cached.serverStaleTime);
|
|
189
|
+
if (!isStaleTimeSeconds(dynamic)) return server;
|
|
190
|
+
return server === void 0 ? dynamic : Math.min(dynamic, server);
|
|
149
191
|
}
|
|
150
192
|
function resolveCachedRscResponseTtlMs(cached, fallbackTtlMs) {
|
|
151
|
-
const seconds = cached
|
|
152
|
-
if (
|
|
193
|
+
const seconds = resolveRscResponseStaleTimeSeconds(cached);
|
|
194
|
+
if (seconds === void 0) return fallbackTtlMs;
|
|
153
195
|
return seconds * 1e3;
|
|
154
196
|
}
|
|
155
197
|
function resolveCachedRscResponseExpiresAt(timestamp, cached, fallbackTtlMs) {
|
|
156
198
|
if (isCacheExpiresAt(cached.expiresAt)) return cached.expiresAt;
|
|
157
199
|
return timestamp + resolveCachedRscResponseTtlMs(cached, fallbackTtlMs);
|
|
158
200
|
}
|
|
159
|
-
function resolvePrefetchedRscResponseExpiresAt(timestamp, cached, fallbackTtlMs) {
|
|
201
|
+
function resolvePrefetchedRscResponseExpiresAt(timestamp, cached, fallbackTtlMs, honorDynamicStaleTime) {
|
|
160
202
|
if (isCacheExpiresAt(cached.expiresAt)) return cached.expiresAt;
|
|
161
|
-
const
|
|
162
|
-
if (
|
|
163
|
-
|
|
203
|
+
const serverSeconds = serverStaleTimeSeconds(cached.serverStaleTime);
|
|
204
|
+
if (serverSeconds !== void 0) return timestamp + serverSeconds * 1e3;
|
|
205
|
+
const seconds = isStaleTimeSeconds(cached.dynamicStaleTimeSeconds) ? cached.dynamicStaleTimeSeconds : void 0;
|
|
206
|
+
if (seconds === void 0) return timestamp + Math.max(fallbackTtlMs, MIN_PREFETCH_STALE_TIME_MS);
|
|
207
|
+
return honorDynamicStaleTime ? timestamp + seconds * 1e3 : timestamp + Math.max(seconds * 1e3, MIN_PREFETCH_STALE_TIME_MS);
|
|
164
208
|
}
|
|
165
209
|
function resolvePrefetchCacheEntryExpiresAt(entry) {
|
|
166
210
|
if (entry.expiresAt !== void 0) return entry.expiresAt;
|
|
@@ -232,12 +276,9 @@ function findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mounte
|
|
|
232
276
|
function hasPrefetchCacheEntryForNavigation(rscUrl, interceptionContext = null, mountedSlotsHeader = null, options = {}) {
|
|
233
277
|
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader, options.additionalRscUrls);
|
|
234
278
|
if (match === null) return false;
|
|
235
|
-
if (match.entry.pending !== void 0) {
|
|
236
|
-
touchPrefetchCacheEntry(getPrefetchCache(), match.cacheKey, match.entry);
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
if (resolvePrefetchCacheEntryExpiresAt(match.entry) > Date.now()) {
|
|
279
|
+
if (match.entry.pending !== void 0 || resolvePrefetchCacheEntryExpiresAt(match.entry) > Date.now()) {
|
|
240
280
|
touchPrefetchCacheEntry(getPrefetchCache(), match.cacheKey, match.entry);
|
|
281
|
+
attachPrefetchInvalidationToEntry(match.cacheKey, match.entry, options.onInvalidate);
|
|
241
282
|
return true;
|
|
242
283
|
}
|
|
243
284
|
deletePrefetchCacheEntry(getPrefetchCache(), getPrefetchedUrls(), match.cacheKey, match.entry, options.notifyInvalidation ?? true);
|
|
@@ -328,31 +369,88 @@ function evictPrefetchCacheIfNeeded() {
|
|
|
328
369
|
} else break;
|
|
329
370
|
}
|
|
330
371
|
}
|
|
372
|
+
const pendingPrefetchSetups = /* @__PURE__ */ new Set();
|
|
373
|
+
function beginPrefetchSetup(destination) {
|
|
374
|
+
const setup = {
|
|
375
|
+
destination,
|
|
376
|
+
cancelled: false
|
|
377
|
+
};
|
|
378
|
+
pendingPrefetchSetups.add(setup);
|
|
379
|
+
return setup;
|
|
380
|
+
}
|
|
381
|
+
/** Passing `null` cancels every pending setup regardless of destination. */
|
|
382
|
+
function cancelPendingPrefetchSetups(destination) {
|
|
383
|
+
for (const setup of pendingPrefetchSetups) if (destination === null || setup.destination === destination) setup.cancelled = true;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Normalize a navigation or prefetch target to the browser href both sides
|
|
387
|
+
* compare on. Returns null when the target is not same-origin — no same-origin
|
|
388
|
+
* prefetch can be a duplicate of it — and on the server, where
|
|
389
|
+
* `navigateClientSide` can still be reached but there is nothing to cancel.
|
|
390
|
+
*/
|
|
391
|
+
function toAppPrefetchDestination(href) {
|
|
392
|
+
if (isServer) return null;
|
|
393
|
+
let localHref = href;
|
|
394
|
+
if (isExternalUrl(href)) {
|
|
395
|
+
const localPath = toSameOriginAppPath(href, __basePath);
|
|
396
|
+
if (localPath == null) return null;
|
|
397
|
+
localHref = localPath;
|
|
398
|
+
}
|
|
399
|
+
const browserHref = toBrowserNavigationHref(localHref, window.location.href, __basePath);
|
|
400
|
+
try {
|
|
401
|
+
const url = new URL(browserHref, window.location.href);
|
|
402
|
+
return `${url.pathname}${url.search}`;
|
|
403
|
+
} catch {
|
|
404
|
+
return browserHref.split("#", 1)[0];
|
|
405
|
+
}
|
|
406
|
+
}
|
|
331
407
|
function clearPrefetchInvalidation(entry) {
|
|
332
408
|
if (entry.invalidationTimer !== void 0) {
|
|
333
409
|
clearTimeout(entry.invalidationTimer);
|
|
334
410
|
entry.invalidationTimer = void 0;
|
|
335
411
|
}
|
|
336
412
|
}
|
|
337
|
-
function
|
|
338
|
-
|
|
339
|
-
const callbacks = entry.onInvalidateCallbacks;
|
|
340
|
-
entry.onInvalidateCallbacks = void 0;
|
|
341
|
-
if (callbacks === void 0) return;
|
|
342
|
-
for (const onInvalidate of callbacks) try {
|
|
413
|
+
function runInvalidationCallback(onInvalidate) {
|
|
414
|
+
try {
|
|
343
415
|
onInvalidate();
|
|
344
416
|
} catch (error) {
|
|
345
417
|
if (typeof reportError === "function") reportError(error);
|
|
346
418
|
else console.error(error);
|
|
347
419
|
}
|
|
348
420
|
}
|
|
421
|
+
function notifyPrefetchInvalidated(entry) {
|
|
422
|
+
clearPrefetchInvalidation(entry);
|
|
423
|
+
const callbacks = entry.onInvalidateCallbacks;
|
|
424
|
+
entry.onInvalidateCallbacks = void 0;
|
|
425
|
+
if (callbacks === void 0) return;
|
|
426
|
+
for (const onInvalidate of callbacks) runInvalidationCallback(onInvalidate);
|
|
427
|
+
}
|
|
428
|
+
const retainedPrefetchInvalidations = /* @__PURE__ */ new Set();
|
|
429
|
+
function retainPrefetchInvalidationAfterConsume(entry) {
|
|
430
|
+
const callbacks = entry.onInvalidateCallbacks;
|
|
431
|
+
if (callbacks === void 0 || callbacks.size === 0) return;
|
|
432
|
+
const delay = Math.max(0, resolvePrefetchCacheEntryExpiresAt(entry) - Date.now());
|
|
433
|
+
const retained = {
|
|
434
|
+
callbacks,
|
|
435
|
+
timer: setTimeout(() => fireRetainedPrefetchInvalidation(retained), delay)
|
|
436
|
+
};
|
|
437
|
+
retainedPrefetchInvalidations.add(retained);
|
|
438
|
+
}
|
|
439
|
+
function fireRetainedPrefetchInvalidation(retained) {
|
|
440
|
+
if (!retainedPrefetchInvalidations.delete(retained)) return;
|
|
441
|
+
clearTimeout(retained.timer);
|
|
442
|
+
for (const onInvalidate of retained.callbacks) runInvalidationCallback(onInvalidate);
|
|
443
|
+
}
|
|
349
444
|
function deletePrefetchCacheEntry(cache, prefetched, cacheKey, entry, notify) {
|
|
350
|
-
adjustPrefetchCacheByteSize(cache, -getPrefetchCacheEntrySize(entry));
|
|
351
445
|
const cacheKeys = entry.cacheKeys ?? /* @__PURE__ */ new Set([cacheKey]);
|
|
352
|
-
|
|
353
|
-
|
|
446
|
+
let removedOwnedKey = false;
|
|
447
|
+
for (const key of cacheKeys) if (cache.get(key) === entry) {
|
|
448
|
+
cache.delete(key);
|
|
354
449
|
prefetched.delete(key);
|
|
450
|
+
removedOwnedKey = true;
|
|
355
451
|
}
|
|
452
|
+
if (!removedOwnedKey) return;
|
|
453
|
+
adjustPrefetchCacheByteSize(cache, -getPrefetchCacheEntrySize(entry));
|
|
356
454
|
entry.cacheKeys = void 0;
|
|
357
455
|
if (notify) notifyPrefetchInvalidated(entry);
|
|
358
456
|
else {
|
|
@@ -360,6 +458,25 @@ function deletePrefetchCacheEntry(cache, prefetched, cacheKey, entry, notify) {
|
|
|
360
458
|
entry.onInvalidateCallbacks = void 0;
|
|
361
459
|
}
|
|
362
460
|
}
|
|
461
|
+
function discardLearningOnlyPrefetchCacheEntry(rscUrl, interceptionContext = null) {
|
|
462
|
+
const cache = getPrefetchCache();
|
|
463
|
+
const prefetched = getPrefetchedUrls();
|
|
464
|
+
const normalizedTarget = normalizeRscCacheLookupUrl(rscUrl);
|
|
465
|
+
if (normalizedTarget === null) return false;
|
|
466
|
+
const superseded = [];
|
|
467
|
+
for (const [cacheKey, entry] of cache) {
|
|
468
|
+
if (entry.cacheForNavigation !== false || entry.prefetchKind !== "navigation") continue;
|
|
469
|
+
const source = parsePrefetchCacheKey(cacheKey);
|
|
470
|
+
if (source.interceptionContext !== interceptionContext) continue;
|
|
471
|
+
if (normalizeRscCacheLookupUrl(source.rscUrl) !== normalizedTarget) continue;
|
|
472
|
+
superseded.push([cacheKey, entry]);
|
|
473
|
+
}
|
|
474
|
+
for (const [cacheKey, entry] of superseded) {
|
|
475
|
+
cancelAppPrefetchFetch(entry.fetchPromise);
|
|
476
|
+
deletePrefetchCacheEntry(cache, prefetched, cacheKey, entry, true);
|
|
477
|
+
}
|
|
478
|
+
return superseded.length > 0;
|
|
479
|
+
}
|
|
363
480
|
function invalidatePrefetchCacheEntry(cacheKey) {
|
|
364
481
|
const cache = getPrefetchCache();
|
|
365
482
|
const entry = cache.get(cacheKey);
|
|
@@ -379,18 +496,29 @@ function addPrefetchInvalidationCallback(entry, onInvalidate) {
|
|
|
379
496
|
if (entry.onInvalidateCallbacks === void 0) entry.onInvalidateCallbacks = /* @__PURE__ */ new Set();
|
|
380
497
|
entry.onInvalidateCallbacks.add(onInvalidate);
|
|
381
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Attach `onInvalidate` to an entry the caller already holds. A settled entry
|
|
501
|
+
* needs its invalidation timer started here — nothing else will schedule one
|
|
502
|
+
* once `prefetchRscResponse` has finished with it.
|
|
503
|
+
*/
|
|
504
|
+
function attachPrefetchInvalidationToEntry(cacheKey, entry, onInvalidate) {
|
|
505
|
+
if (onInvalidate === void 0) return;
|
|
506
|
+
addPrefetchInvalidationCallback(entry, onInvalidate);
|
|
507
|
+
if (entry.outcome === "cache-seeded") schedulePrefetchInvalidation(cacheKey, entry);
|
|
508
|
+
}
|
|
382
509
|
function attachPrefetchInvalidationCallback(cacheKey, onInvalidate) {
|
|
383
510
|
if (onInvalidate === void 0) return;
|
|
384
511
|
const entry = getPrefetchCache().get(cacheKey);
|
|
385
512
|
if (!entry) return;
|
|
386
|
-
|
|
387
|
-
if (entry.outcome === "cache-seeded") schedulePrefetchInvalidation(cacheKey, entry);
|
|
513
|
+
attachPrefetchInvalidationToEntry(cacheKey, entry, onInvalidate);
|
|
388
514
|
}
|
|
389
515
|
function invalidatePrefetchCache() {
|
|
516
|
+
cancelPendingPrefetchSetups(null);
|
|
390
517
|
const cache = getPrefetchCache();
|
|
391
518
|
const prefetched = getPrefetchedUrls();
|
|
392
519
|
for (const [cacheKey, entry] of cache) deletePrefetchCacheEntry(cache, prefetched, cacheKey, entry, true);
|
|
393
520
|
prefetched.clear();
|
|
521
|
+
for (const retained of retainedPrefetchInvalidations) fireRetainedPrefetchInvalidation(retained);
|
|
394
522
|
if (!isServer) getNavigationRuntime()?.functions.pingVisibleLinks?.();
|
|
395
523
|
}
|
|
396
524
|
function seedPrefetchResponseSnapshot(rscUrl, snapshot, interceptionContext = null, mountedSlotsHeader = null, fallbackTtlMs = DYNAMIC_NAVIGATION_CACHE_TTL) {
|
|
@@ -473,18 +601,42 @@ function storePrefetchResponse(rscUrl, response, interceptionContext = null, opt
|
|
|
473
601
|
cache.set(cacheKey, entry);
|
|
474
602
|
}
|
|
475
603
|
function createCachedRscResponseSnapshot(response, buffer, responseUrl = null) {
|
|
476
|
-
const
|
|
604
|
+
const headerDynamicStaleTimeSeconds = parseStaleTimeSecondsHeader(response.headers.get(VINEXT_DYNAMIC_STALE_TIME_HEADER));
|
|
605
|
+
const completionMode = response.headers.get(VINEXT_RSC_COMPLETION_METADATA_HEADER);
|
|
606
|
+
const extracted = completionMode === "1" ? extractRscCompletionMetadata(buffer) : { buffer };
|
|
607
|
+
const completedDynamicStaleTimeSeconds = completionMode === "resolved" ? headerDynamicStaleTimeSeconds : extracted.metadata?.dynamicStaleTimeSeconds ?? headerDynamicStaleTimeSeconds;
|
|
608
|
+
const dynamicStaleTimeSeconds = completedDynamicStaleTimeSeconds ?? headerDynamicStaleTimeSeconds;
|
|
609
|
+
const parsedServerStaleTime = parseServerStaleTimeHeaders(response.headers);
|
|
610
|
+
const serverStaleTime = extracted.metadata !== void 0 && Object.hasOwn(extracted.metadata, "serverStaleTimeSeconds") ? extracted.metadata?.serverStaleTimeSeconds === null ? void 0 : {
|
|
611
|
+
kind: "resolved",
|
|
612
|
+
seconds: extracted.metadata.serverStaleTimeSeconds
|
|
613
|
+
} : parsedServerStaleTime;
|
|
477
614
|
return {
|
|
478
615
|
compatibilityIdHeader: response.headers.get(VINEXT_RSC_COMPATIBILITY_ID_HEADER),
|
|
479
|
-
buffer,
|
|
616
|
+
buffer: extracted.buffer,
|
|
617
|
+
...completedDynamicStaleTimeSeconds !== void 0 ? { completedDynamicStaleTimeSeconds } : {},
|
|
480
618
|
contentType: response.headers.get("content-type") ?? "text/x-component",
|
|
481
619
|
...dynamicStaleTimeSeconds !== void 0 ? { dynamicStaleTimeSeconds } : {},
|
|
482
620
|
mountedSlotsHeader: response.headers.get(VINEXT_MOUNTED_SLOTS_HEADER),
|
|
483
621
|
paramsHeader: response.headers.get(VINEXT_PARAMS_HEADER),
|
|
484
622
|
renderedPathAndSearch: parseRenderedPathAndSearchHeader(response.headers.get(VINEXT_RENDERED_PATH_AND_SEARCH_HEADER)),
|
|
623
|
+
...serverStaleTime === void 0 ? {} : { serverStaleTime },
|
|
485
624
|
url: responseUrl ?? response.url
|
|
486
625
|
};
|
|
487
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* Collapse the two mutually-exclusive wire headers into one state. A pending
|
|
629
|
+
* marker wins: it says the render committed headers before `cacheLife` settled,
|
|
630
|
+
* so any resolved value alongside it cannot describe the completed render.
|
|
631
|
+
*/
|
|
632
|
+
function parseServerStaleTimeHeaders(headers) {
|
|
633
|
+
if (headers.get("X-Vinext-Stale-Time-Pending") === "1") return { kind: "pending" };
|
|
634
|
+
const seconds = parseStaleTimeSecondsHeader(headers.get(NEXT_ROUTER_STALE_TIME_HEADER));
|
|
635
|
+
return seconds === void 0 ? void 0 : {
|
|
636
|
+
kind: "resolved",
|
|
637
|
+
seconds
|
|
638
|
+
};
|
|
639
|
+
}
|
|
488
640
|
function parseRenderedPathAndSearchHeader(value) {
|
|
489
641
|
if (value === null || value === "") return null;
|
|
490
642
|
try {
|
|
@@ -524,7 +676,10 @@ function restoreRscResponse(cached, copy = true) {
|
|
|
524
676
|
const headers = new Headers({ "content-type": cached.contentType });
|
|
525
677
|
if (cached.mountedSlotsHeader != null) headers.set(VINEXT_MOUNTED_SLOTS_HEADER, cached.mountedSlotsHeader);
|
|
526
678
|
if (cached.compatibilityIdHeader != null) headers.set(VINEXT_RSC_COMPATIBILITY_ID_HEADER, cached.compatibilityIdHeader);
|
|
527
|
-
if (
|
|
679
|
+
if (isStaleTimeSeconds(cached.dynamicStaleTimeSeconds)) headers.set(VINEXT_DYNAMIC_STALE_TIME_HEADER, String(cached.dynamicStaleTimeSeconds));
|
|
680
|
+
if (isStaleTimeSeconds(cached.completedDynamicStaleTimeSeconds)) headers.set(VINEXT_RSC_COMPLETION_METADATA_HEADER, "resolved");
|
|
681
|
+
if (cached.serverStaleTime?.kind === "pending") headers.set(VINEXT_STALE_TIME_PENDING_HEADER, "1");
|
|
682
|
+
else if (cached.serverStaleTime !== void 0) headers.set(NEXT_ROUTER_STALE_TIME_HEADER, String(cached.serverStaleTime.seconds));
|
|
528
683
|
if (cached.paramsHeader != null) headers.set(VINEXT_PARAMS_HEADER, cached.paramsHeader);
|
|
529
684
|
if (cached.renderedPathAndSearch != null) headers.set(VINEXT_RENDERED_PATH_AND_SEARCH_HEADER, encodeURIComponent(cached.renderedPathAndSearch));
|
|
530
685
|
return new Response(copy ? cached.buffer.slice(0) : cached.buffer, {
|
|
@@ -533,6 +688,17 @@ function restoreRscResponse(cached, copy = true) {
|
|
|
533
688
|
});
|
|
534
689
|
}
|
|
535
690
|
/**
|
|
691
|
+
* `prefetchRscResponse`'s `prepareSnapshot` for navigation-reusable entries:
|
|
692
|
+
* decode the cached payload through the App Router runtime so a later
|
|
693
|
+
* navigation can commit it without re-parsing. Shared by `<Link>` and
|
|
694
|
+
* `router.prefetch()`.
|
|
695
|
+
*/
|
|
696
|
+
async function prepareNavigationPrefetchSnapshot(snapshot) {
|
|
697
|
+
const preparePrefetchResponse = getNavigationRuntime()?.functions.preparePrefetchResponse;
|
|
698
|
+
if (!preparePrefetchResponse) throw new Error("App Router prefetch preparation is unavailable");
|
|
699
|
+
return await preparePrefetchResponse(restoreRscResponse(snapshot));
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
536
702
|
* Prefetch an RSC response and snapshot it for later consumption.
|
|
537
703
|
* Stores the in-flight promise so immediate clicks can await it instead
|
|
538
704
|
* of firing a duplicate fetch.
|
|
@@ -557,6 +723,7 @@ function prefetchRscResponse(rscUrl, fetchPromise, interceptionContext = null, m
|
|
|
557
723
|
timestamp: now
|
|
558
724
|
};
|
|
559
725
|
addPrefetchInvalidationCallback(entry, options?.onInvalidate);
|
|
726
|
+
entry.fetchPromise = fetchPromise;
|
|
560
727
|
entry.pending = fetchPromise.then(async (response) => {
|
|
561
728
|
if (response.ok) {
|
|
562
729
|
const snapshot = await snapshotRscResponse(response);
|
|
@@ -565,7 +732,12 @@ function prefetchRscResponse(rscUrl, fetchPromise, interceptionContext = null, m
|
|
|
565
732
|
entry.snapshot = snapshot;
|
|
566
733
|
entry.size = snapshot.buffer.byteLength;
|
|
567
734
|
adjustPrefetchCacheByteSize(cache, entry.size - previousSize);
|
|
568
|
-
entry.expiresAt = resolvePrefetchedRscResponseExpiresAt(entry.timestamp, entry.snapshot, behavior.fallbackTtlMs ?? PREFETCH_CACHE_TTL);
|
|
735
|
+
entry.expiresAt = resolvePrefetchedRscResponseExpiresAt(entry.timestamp, entry.snapshot, behavior.fallbackTtlMs ?? PREFETCH_CACHE_TTL, behavior.honorDynamicStaleTime !== false && behavior.searchAgnosticShell !== true);
|
|
736
|
+
if (behavior.prepareSnapshot) try {
|
|
737
|
+
const preparedElements = await behavior.prepareSnapshot(snapshot);
|
|
738
|
+
if (cache.get(cacheKey) !== entry) return;
|
|
739
|
+
entry.preparedElements = preparedElements;
|
|
740
|
+
} catch {}
|
|
569
741
|
addRenderedPathAndSearchPrefetchAlias(cache, prefetched, cacheKey, entry);
|
|
570
742
|
evictPrefetchCacheIfNeeded();
|
|
571
743
|
} else {
|
|
@@ -577,6 +749,7 @@ function prefetchRscResponse(rscUrl, fetchPromise, interceptionContext = null, m
|
|
|
577
749
|
}).finally(() => {
|
|
578
750
|
if (cache.get(cacheKey) !== entry) return;
|
|
579
751
|
entry.pending = void 0;
|
|
752
|
+
entry.fetchPromise = void 0;
|
|
580
753
|
if (entry.snapshot) {
|
|
581
754
|
entry.outcome = "cache-seeded";
|
|
582
755
|
schedulePrefetchInvalidation(cacheKey, entry);
|
|
@@ -599,8 +772,8 @@ function addRenderedPathAndSearchPrefetchAlias(cache, prefetched, primaryCacheKe
|
|
|
599
772
|
cache.set(aliasCacheKey, entry);
|
|
600
773
|
prefetched.add(aliasCacheKey);
|
|
601
774
|
}
|
|
602
|
-
function peekPrefetchResponseForNavigation(rscUrl, interceptionContext = null, mountedSlotsHeader = null) {
|
|
603
|
-
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader);
|
|
775
|
+
function peekPrefetchResponseForNavigation(rscUrl, interceptionContext = null, mountedSlotsHeader = null, options) {
|
|
776
|
+
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader, options?.additionalRscUrls);
|
|
604
777
|
if (!match) return null;
|
|
605
778
|
const { cacheKey, entry } = match;
|
|
606
779
|
if (entry.pending || entry.outcome !== "cache-seeded") return null;
|
|
@@ -620,28 +793,38 @@ function peekPrefetchResponseForNavigation(rscUrl, interceptionContext = null, m
|
|
|
620
793
|
* Only returns settled (non-pending) snapshots synchronously.
|
|
621
794
|
* Returns null if the entry is still in flight or doesn't exist.
|
|
622
795
|
*/
|
|
623
|
-
function consumePrefetchResponse(rscUrl, interceptionContext = null, mountedSlotsHeader = null) {
|
|
796
|
+
function consumePrefetchResponse(rscUrl, interceptionContext = null, mountedSlotsHeader = null, options) {
|
|
624
797
|
const cache = getPrefetchCache();
|
|
625
798
|
const exactCacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);
|
|
626
799
|
const exactEntry = cache.get(exactCacheKey);
|
|
627
800
|
if (exactEntry && exactEntry.cacheForNavigation !== false && !isPrefetchCacheEntryCompatibleWithMountedSlots(exactEntry, mountedSlotsHeader)) deletePrefetchCacheEntry(cache, getPrefetchedUrls(), exactCacheKey, exactEntry, false);
|
|
628
|
-
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader);
|
|
801
|
+
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader, options?.additionalRscUrls);
|
|
629
802
|
if (!match) return null;
|
|
630
803
|
const { cacheKey, entry } = match;
|
|
631
804
|
return consumeMatchedPrefetchResponse(cacheKey, entry, mountedSlotsHeader);
|
|
632
805
|
}
|
|
633
|
-
function consumeMatchedPrefetchResponse(cacheKey, entry, mountedSlotsHeader) {
|
|
806
|
+
function consumeMatchedPrefetchResponse(cacheKey, entry, mountedSlotsHeader, allowExpiredInFlightHandoff = false) {
|
|
807
|
+
const cache = getPrefetchCache();
|
|
634
808
|
if (entry.pending || entry.outcome !== "cache-seeded") return null;
|
|
635
809
|
if (entry.cacheForNavigation === false) return null;
|
|
636
|
-
deletePrefetchCacheEntry(getPrefetchCache(), getPrefetchedUrls(), cacheKey, entry, false);
|
|
637
810
|
if (entry.snapshot) {
|
|
638
811
|
if (!isPrefetchCacheEntryCompatibleWithMountedSlots(entry, mountedSlotsHeader)) return null;
|
|
639
|
-
if (resolvePrefetchCacheEntryExpiresAt(entry) <= Date.now())
|
|
812
|
+
if (!allowExpiredInFlightHandoff && resolvePrefetchCacheEntryExpiresAt(entry) <= Date.now()) {
|
|
813
|
+
deletePrefetchCacheEntry(cache, getPrefetchedUrls(), cacheKey, entry, true);
|
|
814
|
+
return null;
|
|
815
|
+
}
|
|
816
|
+
retainPrefetchInvalidationAfterConsume(entry);
|
|
817
|
+
deletePrefetchCacheEntry(cache, getPrefetchedUrls(), cacheKey, entry, false);
|
|
818
|
+
const snapshot = entry.snapshot;
|
|
640
819
|
if (entry.expiresAt !== void 0 || entry.snapshot.expiresAt !== void 0) return {
|
|
641
|
-
...
|
|
642
|
-
expiresAt: resolvePrefetchCacheEntryExpiresAt(entry)
|
|
820
|
+
...snapshot,
|
|
821
|
+
expiresAt: resolvePrefetchCacheEntryExpiresAt(entry),
|
|
822
|
+
...entry.preparedElements ? { preparedElements: entry.preparedElements } : {}
|
|
643
823
|
};
|
|
644
|
-
return entry.
|
|
824
|
+
return entry.preparedElements ? {
|
|
825
|
+
...snapshot,
|
|
826
|
+
preparedElements: entry.preparedElements
|
|
827
|
+
} : snapshot;
|
|
645
828
|
}
|
|
646
829
|
return null;
|
|
647
830
|
}
|
|
@@ -650,12 +833,15 @@ async function consumePrefetchResponseForNavigation(rscUrl, interceptionContext
|
|
|
650
833
|
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader, options?.additionalRscUrls);
|
|
651
834
|
if (!match) return null;
|
|
652
835
|
const { cacheKey, entry } = match;
|
|
836
|
+
if (options?.shouldConsume?.() === false) return null;
|
|
837
|
+
const allowExpiredInFlightHandoff = entry.pending !== void 0;
|
|
653
838
|
if (entry.pending !== void 0) {
|
|
839
|
+
promoteAppPrefetchFetch(entry.fetchPromise);
|
|
654
840
|
await entry.pending.catch(() => {});
|
|
655
841
|
if (cache.get(cacheKey) !== entry) return null;
|
|
842
|
+
if (options?.shouldConsume?.() === false) return null;
|
|
656
843
|
}
|
|
657
|
-
|
|
658
|
-
return consumeMatchedPrefetchResponse(cacheKey, entry, mountedSlotsHeader);
|
|
844
|
+
return consumeMatchedPrefetchResponse(cacheKey, entry, mountedSlotsHeader, allowExpiredInFlightHandoff);
|
|
659
845
|
}
|
|
660
846
|
const _CLIENT_NAV_STATE_KEY = Symbol.for("vinext.clientNavigationState");
|
|
661
847
|
const _MOUNTED_SLOTS_HEADER_KEY = Symbol.for("vinext.mountedSlotsHeader");
|
|
@@ -1036,7 +1222,7 @@ function commitHashOnlyHistoryState(href, mode, scroll) {
|
|
|
1036
1222
|
function applyAppRouterScrollFallback(intent) {
|
|
1037
1223
|
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
1038
1224
|
if (intent.hash !== null) {
|
|
1039
|
-
|
|
1225
|
+
scrollToHashTargetOnNextFrame(intent.hash, () => isLatestAppRouterScrollIntent(intent));
|
|
1040
1226
|
return;
|
|
1041
1227
|
}
|
|
1042
1228
|
if (intent.targetHoistedInHead) return;
|
|
@@ -1085,10 +1271,43 @@ function hardNavigateTo(fullHref, mode) {
|
|
|
1085
1271
|
else window.location.assign(fullHref);
|
|
1086
1272
|
}
|
|
1087
1273
|
/**
|
|
1274
|
+
* Reset any link still showing a `useLinkStatus()` pending state that did not
|
|
1275
|
+
* initiate the navigation now starting (e.g. a programmatic router.push, a form
|
|
1276
|
+
* submit, or a raw history update). A <Link> click registers itself first, so
|
|
1277
|
+
* the hook keeps that link pending.
|
|
1278
|
+
*/
|
|
1279
|
+
function resetStaleLinkStatus() {
|
|
1280
|
+
getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Signal that a navigation to `href` is starting, for the callers that will
|
|
1284
|
+
* fetch the destination. Separate from `resetStaleLinkStatus()` because a raw
|
|
1285
|
+
* `history.pushState` also supersedes a pending link but issues no request —
|
|
1286
|
+
* cancelling a prefetch there would drop it with nothing to take its place.
|
|
1287
|
+
*/
|
|
1288
|
+
function notifyAppNavigationStart(href) {
|
|
1289
|
+
const destination = toAppPrefetchDestination(href);
|
|
1290
|
+
if (destination !== null && !isHashOnlyBrowserUrlChange(href, window.location.href, __basePath)) cancelPendingPrefetchSetups(destination);
|
|
1291
|
+
resetStaleLinkStatus();
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* popstate variant. The browser has already applied the history entry by the
|
|
1295
|
+
* time this runs, so the pre-navigation URL that `isHashOnlyBrowserUrlChange`
|
|
1296
|
+
* needs is gone. Back/forward across a route boundary does drive an RSC fetch
|
|
1297
|
+
* (`app-browser-entry.ts`'s popstate handler), so cancelling by destination is
|
|
1298
|
+
* right; a hash-only entry over-cancels, which costs one re-prefetch and can
|
|
1299
|
+
* never cause a duplicate request.
|
|
1300
|
+
*/
|
|
1301
|
+
function notifyAppPopstateNavigationStart() {
|
|
1302
|
+
const destination = toAppPrefetchDestination(window.location.href);
|
|
1303
|
+
if (destination !== null) cancelPendingPrefetchSetups(destination);
|
|
1304
|
+
resetStaleLinkStatus();
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1088
1307
|
* Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.
|
|
1089
1308
|
*/
|
|
1090
1309
|
async function navigateClientSide(href, mode, scroll, programmaticTransition = false, visibleCommitMode = "transition") {
|
|
1091
|
-
|
|
1310
|
+
notifyAppNavigationStart(href);
|
|
1092
1311
|
let normalizedHref = href;
|
|
1093
1312
|
if (isExternalUrl(href)) {
|
|
1094
1313
|
const localPath = toSameOriginAppPath(href, __basePath);
|
|
@@ -1191,7 +1410,7 @@ const _appRouter = {
|
|
|
1191
1410
|
push(href, options) {
|
|
1192
1411
|
assertSafeNavigationUrl(href);
|
|
1193
1412
|
if (isServer) return;
|
|
1194
|
-
|
|
1413
|
+
notifyAppNavigationStart(href);
|
|
1195
1414
|
const releaseNavigation = trackScheduledAppRouterNavigation();
|
|
1196
1415
|
try {
|
|
1197
1416
|
React$1.startTransition(() => {
|
|
@@ -1206,7 +1425,7 @@ const _appRouter = {
|
|
|
1206
1425
|
replace(href, options) {
|
|
1207
1426
|
assertSafeNavigationUrl(href);
|
|
1208
1427
|
if (isServer) return;
|
|
1209
|
-
|
|
1428
|
+
notifyAppNavigationStart(href);
|
|
1210
1429
|
const releaseNavigation = trackScheduledAppRouterNavigation();
|
|
1211
1430
|
try {
|
|
1212
1431
|
React$1.startTransition(() => {
|
|
@@ -1247,35 +1466,68 @@ const _appRouter = {
|
|
|
1247
1466
|
} catch {
|
|
1248
1467
|
throw new Error(`Cannot prefetch '${href}' because it cannot be converted to a URL.`);
|
|
1249
1468
|
}
|
|
1469
|
+
const prefetchHref = isExternalUrl(href) ? toSameOriginAppPath(href, __basePath) : href;
|
|
1470
|
+
if (prefetchHref == null) return;
|
|
1471
|
+
const fullHref = toAppPrefetchDestination(prefetchHref);
|
|
1472
|
+
if (fullHref === null) return;
|
|
1473
|
+
const interceptionContext = getPrefetchInterceptionContext(fullHref);
|
|
1474
|
+
const mountedSlotsHeader = getMountedSlotsHeader();
|
|
1475
|
+
const headers = createAppPrefetchRequestHeaders({
|
|
1476
|
+
fetchPriority: "low",
|
|
1477
|
+
interceptionContext,
|
|
1478
|
+
mountedSlotsHeader: mountedSlotsHeader || null
|
|
1479
|
+
});
|
|
1480
|
+
const setup = beginPrefetchSetup(fullHref);
|
|
1250
1481
|
(async () => {
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
const localPath = toSameOriginAppPath(href, __basePath);
|
|
1254
|
-
if (localPath == null) return;
|
|
1255
|
-
prefetchHref = localPath;
|
|
1256
|
-
}
|
|
1257
|
-
const hybridOwner = resolveHybridClientRouteOwner(prefetchHref);
|
|
1482
|
+
if (HAS_CLIENT_REWRITES) await preloadHybridClientRouteOwner();
|
|
1483
|
+
const hybridOwner = resolveHybridClientRouteOwner(fullHref);
|
|
1258
1484
|
if (hybridOwner === "pages" || hybridOwner === "document") return;
|
|
1259
|
-
const
|
|
1260
|
-
const
|
|
1261
|
-
const
|
|
1262
|
-
const
|
|
1263
|
-
|
|
1264
|
-
|
|
1485
|
+
const rewrittenPrefetchHref = HAS_CLIENT_REWRITES ? resolveLoadedHybridClientRewriteHref(fullHref, __basePath) : null;
|
|
1486
|
+
const kind = options?.kind === "full" ? "full" : "auto";
|
|
1487
|
+
const { resolveAutoAppRoutePrefetch, resolveFullAppRoutePrefetch } = await import("./internal/app-route-prefetch-policy.js");
|
|
1488
|
+
const policy = kind === "full" ? resolveFullAppRoutePrefetch() : resolveAutoAppRoutePrefetch(rewrittenPrefetchHref ?? fullHref);
|
|
1489
|
+
const reusable = policy.shouldPrefetch && policy.cacheForNavigation;
|
|
1490
|
+
if (reusable && kind === "full") headers.delete(NEXT_ROUTER_PREFETCH_HEADER);
|
|
1491
|
+
if (reusable && kind === "auto") {
|
|
1492
|
+
headers.set(NEXT_ROUTER_PREFETCH_HEADER, "1");
|
|
1493
|
+
headers.set(NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, __prefetchInlining ? "/__PAGE__" : "1");
|
|
1494
|
+
}
|
|
1495
|
+
const [rscUrl, ...additionalRscUrls] = await Promise.all([createRscRequestUrl(fullHref, headers), ...rewrittenPrefetchHref !== null && rewrittenPrefetchHref !== fullHref ? [createRscRequestUrl(rewrittenPrefetchHref, headers)] : []]);
|
|
1496
|
+
if (setup.cancelled) return;
|
|
1265
1497
|
const cacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);
|
|
1266
1498
|
const prefetched = getPrefetchedUrls();
|
|
1267
|
-
if (
|
|
1499
|
+
if (reusable) {
|
|
1500
|
+
discardLearningOnlyPrefetchCacheEntry(rscUrl, interceptionContext);
|
|
1501
|
+
if (hasPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader, {
|
|
1502
|
+
additionalRscUrls,
|
|
1503
|
+
onInvalidate: options?.onInvalidate
|
|
1504
|
+
})) return;
|
|
1505
|
+
} else if (prefetched.has(cacheKey)) {
|
|
1268
1506
|
attachPrefetchInvalidationCallback(cacheKey, options?.onInvalidate);
|
|
1269
1507
|
return;
|
|
1270
1508
|
}
|
|
1271
1509
|
prefetched.add(cacheKey);
|
|
1272
|
-
prefetchRscResponse(rscUrl, scheduleAppPrefetchFetch(() => fetch(rscUrl, {
|
|
1510
|
+
prefetchRscResponse(rscUrl, scheduleAppPrefetchFetch((signal) => fetch(rscUrl, {
|
|
1273
1511
|
headers,
|
|
1274
1512
|
credentials: "include",
|
|
1275
|
-
priority: "low"
|
|
1276
|
-
|
|
1513
|
+
priority: "low",
|
|
1514
|
+
signal
|
|
1515
|
+
}), "low"), interceptionContext, mountedSlotsHeader, options, reusable ? {
|
|
1516
|
+
cacheForNavigation: true,
|
|
1517
|
+
fallbackTtlMs: policy.fallbackTtl === "dynamic" ? DYNAMIC_NAVIGATION_CACHE_TTL : PREFETCH_CACHE_TTL,
|
|
1518
|
+
honorDynamicStaleTime: policy.honorDynamicStaleTime,
|
|
1519
|
+
optimisticRouteShell: false,
|
|
1520
|
+
prefetchKind: "navigation",
|
|
1521
|
+
prepareSnapshot: prepareNavigationPrefetchSnapshot
|
|
1522
|
+
} : {
|
|
1523
|
+
cacheForNavigation: false,
|
|
1524
|
+
optimisticRouteShell: true,
|
|
1525
|
+
prefetchKind: "navigation"
|
|
1526
|
+
});
|
|
1277
1527
|
})().catch((error) => {
|
|
1278
1528
|
console.error("[vinext] RSC prefetch setup error:", error);
|
|
1529
|
+
}).finally(() => {
|
|
1530
|
+
pendingPrefetchSetups.delete(setup);
|
|
1279
1531
|
});
|
|
1280
1532
|
}
|
|
1281
1533
|
};
|
|
@@ -1387,7 +1639,7 @@ if (!isServer) {
|
|
|
1387
1639
|
if (state && !state.patchInstalled) {
|
|
1388
1640
|
state.patchInstalled = true;
|
|
1389
1641
|
window.addEventListener("popstate", () => {
|
|
1390
|
-
|
|
1642
|
+
notifyAppPopstateNavigationStart();
|
|
1391
1643
|
});
|
|
1392
1644
|
window.addEventListener("popstate", (event) => {
|
|
1393
1645
|
if (!hasAppNavigationRuntime()) {
|
|
@@ -1398,18 +1650,18 @@ if (!isServer) {
|
|
|
1398
1650
|
window.history.pushState = function patchedPushState(data, unused, url) {
|
|
1399
1651
|
state.originalPushState.call(window.history, createExternalHistoryStatePreservingMetadata(data, window.history.state), unused, url);
|
|
1400
1652
|
if (state.suppressUrlNotifyCount === 0) {
|
|
1401
|
-
|
|
1653
|
+
resetStaleLinkStatus();
|
|
1402
1654
|
commitClientNavigationState();
|
|
1403
1655
|
}
|
|
1404
1656
|
};
|
|
1405
1657
|
window.history.replaceState = function patchedReplaceState(data, unused, url) {
|
|
1406
1658
|
state.originalReplaceState.call(window.history, createExternalHistoryStatePreservingMetadata(data, window.history.state), unused, url);
|
|
1407
1659
|
if (state.suppressUrlNotifyCount === 0) {
|
|
1408
|
-
|
|
1660
|
+
resetStaleLinkStatus();
|
|
1409
1661
|
commitClientNavigationState();
|
|
1410
1662
|
}
|
|
1411
1663
|
};
|
|
1412
1664
|
}
|
|
1413
1665
|
}
|
|
1414
1666
|
//#endregion
|
|
1415
|
-
export { BailoutToCSRError, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, preloadHybridClientRouteOwner, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolveLoadedHybridClientRewriteHref, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
1667
|
+
export { BailoutToCSRError, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createAppPrefetchRequestHeaders, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, discardLearningOnlyPrefetchCacheEntry, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, preloadHybridClientRouteOwner, prepareNavigationPrefetchSnapshot, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolveLoadedHybridClientRewriteHref, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|