@qzsy/vinext 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +773 -0
- package/dist/build/assets-ignore.d.ts +32 -0
- package/dist/build/assets-ignore.js +48 -0
- package/dist/build/clean-output.d.ts +13 -0
- package/dist/build/clean-output.js +34 -0
- package/dist/build/client-build-config.d.ts +171 -0
- package/dist/build/client-build-config.js +270 -0
- package/dist/build/css-url-assets.d.ts +29 -0
- package/dist/build/css-url-assets.js +213 -0
- package/dist/build/google-fonts/build-url.d.ts +9 -0
- package/dist/build/google-fonts/build-url.js +28 -0
- package/dist/build/google-fonts/fallback-metrics-data.js +14029 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +12 -0
- package/dist/build/google-fonts/fallback-metrics.js +44 -0
- package/dist/build/google-fonts/find-font-files-in-css.d.ts +16 -0
- package/dist/build/google-fonts/find-font-files-in-css.js +28 -0
- package/dist/build/google-fonts/font-data.js +24983 -0
- package/dist/build/google-fonts/font-metadata.d.ts +16 -0
- package/dist/build/google-fonts/font-metadata.js +5 -0
- package/dist/build/google-fonts/get-axes.d.ts +6 -0
- package/dist/build/google-fonts/get-axes.js +37 -0
- package/dist/build/google-fonts/sort-variants.d.ts +4 -0
- package/dist/build/google-fonts/sort-variants.js +12 -0
- package/dist/build/google-fonts/validate.d.ts +27 -0
- package/dist/build/google-fonts/validate.js +54 -0
- package/dist/build/inline-css.d.ts +6 -0
- package/dist/build/inline-css.js +48 -0
- package/dist/build/layout-classification-types.d.ts +61 -0
- package/dist/build/layout-classification-types.js +1 -0
- package/dist/build/layout-classification.d.ts +59 -0
- package/dist/build/layout-classification.js +98 -0
- package/dist/build/next-client-runtime-manifests.d.ts +14 -0
- package/dist/build/next-client-runtime-manifests.js +39 -0
- package/dist/build/nitro-route-rules.d.ts +49 -0
- package/dist/build/nitro-route-rules.js +79 -0
- package/dist/build/precompress.d.ts +27 -0
- package/dist/build/precompress.js +110 -0
- package/dist/build/prerender.d.ts +209 -0
- package/dist/build/prerender.js +932 -0
- package/dist/build/report.d.ts +132 -0
- package/dist/build/report.js +504 -0
- package/dist/build/route-classification-injector.d.ts +34 -0
- package/dist/build/route-classification-injector.js +59 -0
- package/dist/build/route-classification-manifest.d.ts +52 -0
- package/dist/build/route-classification-manifest.js +143 -0
- package/dist/build/run-prerender.d.ts +61 -0
- package/dist/build/run-prerender.js +224 -0
- package/dist/build/server-manifest.d.ts +18 -0
- package/dist/build/server-manifest.js +22 -0
- package/dist/build/ssr-manifest.d.ts +18 -0
- package/dist/build/ssr-manifest.js +69 -0
- package/dist/build/standalone.d.ts +31 -0
- package/dist/build/standalone.js +203 -0
- package/dist/build/static-export.d.ts +55 -0
- package/dist/build/static-export.js +60 -0
- package/dist/cache/cache-adapters-virtual.d.ts +50 -0
- package/dist/cache/cache-adapters-virtual.js +45 -0
- package/dist/cache.d.ts +2 -0
- package/dist/cache.js +2 -0
- package/dist/check.d.ts +87 -0
- package/dist/check.js +1037 -0
- package/dist/cli-args.d.ts +33 -0
- package/dist/cli-args.js +124 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +744 -0
- package/dist/client/app-nav-failure-handler.d.ts +8 -0
- package/dist/client/app-nav-failure-handler.js +44 -0
- package/dist/client/empty-module.d.ts +1 -0
- package/dist/client/empty-module.js +1 -0
- package/dist/client/instrumentation-client-inject.d.ts +33 -0
- package/dist/client/instrumentation-client-inject.js +55 -0
- package/dist/client/instrumentation-client-state.d.ts +9 -0
- package/dist/client/instrumentation-client-state.js +17 -0
- package/dist/client/instrumentation-client.d.ts +7 -0
- package/dist/client/instrumentation-client.js +6 -0
- package/dist/client/navigation-runtime.d.ts +70 -0
- package/dist/client/navigation-runtime.js +169 -0
- package/dist/client/pages-router-link-navigation.d.ts +61 -0
- package/dist/client/pages-router-link-navigation.js +42 -0
- package/dist/client/validate-module-path.d.ts +17 -0
- package/dist/client/validate-module-path.js +24 -0
- package/dist/client/vinext-next-data.d.ts +44 -0
- package/dist/client/vinext-next-data.js +50 -0
- package/dist/client/window-next.d.ts +168 -0
- package/dist/client/window-next.js +57 -0
- package/dist/cloudflare/index.d.ts +3 -0
- package/dist/cloudflare/index.js +3 -0
- package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +102 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +126 -0
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.js +435 -0
- package/dist/cloudflare/src/utils/cache-control-metadata.js +20 -0
- package/dist/cloudflare/tpr.d.ts +82 -0
- package/dist/cloudflare/tpr.js +558 -0
- package/dist/config/config-matchers.d.ts +257 -0
- package/dist/config/config-matchers.js +1046 -0
- package/dist/config/dotenv.d.ts +56 -0
- package/dist/config/dotenv.js +88 -0
- package/dist/config/next-config.d.ts +540 -0
- package/dist/config/next-config.js +1050 -0
- package/dist/config/tsconfig-paths.d.ts +21 -0
- package/dist/config/tsconfig-paths.js +157 -0
- package/dist/deploy.d.ts +190 -0
- package/dist/deploy.js +1033 -0
- package/dist/entries/app-browser-entry.d.ts +29 -0
- package/dist/entries/app-browser-entry.js +83 -0
- package/dist/entries/app-rsc-entry.d.ts +81 -0
- package/dist/entries/app-rsc-entry.js +943 -0
- package/dist/entries/app-rsc-manifest.d.ts +53 -0
- package/dist/entries/app-rsc-manifest.js +294 -0
- package/dist/entries/app-ssr-entry.d.ts +15 -0
- package/dist/entries/app-ssr-entry.js +24 -0
- package/dist/entries/pages-client-entry.d.ts +11 -0
- package/dist/entries/pages-client-entry.js +204 -0
- package/dist/entries/pages-entry-helpers.d.ts +2 -0
- package/dist/entries/pages-entry-helpers.js +2 -0
- package/dist/entries/pages-server-entry.d.ts +11 -0
- package/dist/entries/pages-server-entry.js +398 -0
- package/dist/entries/runtime-entry-module.d.ts +25 -0
- package/dist/entries/runtime-entry-module.js +46 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +2661 -0
- package/dist/init.d.ts +69 -0
- package/dist/init.js +253 -0
- package/dist/plugins/ast-utils.d.ts +20 -0
- package/dist/plugins/ast-utils.js +78 -0
- package/dist/plugins/async-hooks-stub.d.ts +18 -0
- package/dist/plugins/async-hooks-stub.js +40 -0
- package/dist/plugins/client-reference-dedup.d.ts +35 -0
- package/dist/plugins/client-reference-dedup.js +189 -0
- package/dist/plugins/css-data-url.d.ts +6 -0
- package/dist/plugins/css-data-url.js +83 -0
- package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
- package/dist/plugins/dynamic-preload-metadata.js +413 -0
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +155 -0
- package/dist/plugins/fonts.d.ts +95 -0
- package/dist/plugins/fonts.js +711 -0
- package/dist/plugins/import-meta-url.d.ts +16 -0
- package/dist/plugins/import-meta-url.js +353 -0
- package/dist/plugins/instrumentation-client.d.ts +6 -0
- package/dist/plugins/instrumentation-client.js +27 -0
- package/dist/plugins/middleware-export-validation.d.ts +5 -0
- package/dist/plugins/middleware-export-validation.js +36 -0
- package/dist/plugins/middleware-server-only.d.ts +53 -0
- package/dist/plugins/middleware-server-only.js +90 -0
- package/dist/plugins/og-asset-ownership.d.ts +27 -0
- package/dist/plugins/og-asset-ownership.js +285 -0
- package/dist/plugins/og-assets.d.ts +50 -0
- package/dist/plugins/og-assets.js +229 -0
- package/dist/plugins/optimize-imports.d.ts +42 -0
- package/dist/plugins/optimize-imports.js +587 -0
- package/dist/plugins/postcss.d.ts +26 -0
- package/dist/plugins/postcss.js +96 -0
- package/dist/plugins/remove-console.d.ts +21 -0
- package/dist/plugins/remove-console.js +177 -0
- package/dist/plugins/require-context.d.ts +6 -0
- package/dist/plugins/require-context.js +185 -0
- package/dist/plugins/rsc-client-reference-loaders.d.ts +6 -0
- package/dist/plugins/rsc-client-reference-loaders.js +46 -0
- package/dist/plugins/rsc-client-shim-excludes.d.ts +6 -0
- package/dist/plugins/rsc-client-shim-excludes.js +35 -0
- package/dist/plugins/sass.d.ts +62 -0
- package/dist/plugins/sass.js +268 -0
- package/dist/plugins/server-externals-manifest.d.ts +26 -0
- package/dist/plugins/server-externals-manifest.js +81 -0
- package/dist/plugins/strip-server-exports.d.ts +21 -0
- package/dist/plugins/strip-server-exports.js +519 -0
- package/dist/plugins/typeof-window.d.ts +14 -0
- package/dist/plugins/typeof-window.js +150 -0
- package/dist/plugins/wasm-module-import.d.ts +15 -0
- package/dist/plugins/wasm-module-import.js +50 -0
- package/dist/routing/app-route-graph.d.ts +336 -0
- package/dist/routing/app-route-graph.js +1518 -0
- package/dist/routing/app-router.d.ts +30 -0
- package/dist/routing/app-router.js +59 -0
- package/dist/routing/file-matcher.d.ts +60 -0
- package/dist/routing/file-matcher.js +147 -0
- package/dist/routing/pages-router.d.ts +48 -0
- package/dist/routing/pages-router.js +163 -0
- package/dist/routing/route-matching.d.ts +27 -0
- package/dist/routing/route-matching.js +42 -0
- package/dist/routing/route-pattern.d.ts +64 -0
- package/dist/routing/route-pattern.js +165 -0
- package/dist/routing/route-trie.d.ts +67 -0
- package/dist/routing/route-trie.js +143 -0
- package/dist/routing/route-validation.d.ts +10 -0
- package/dist/routing/route-validation.js +101 -0
- package/dist/routing/utils.d.ts +117 -0
- package/dist/routing/utils.js +242 -0
- package/dist/server/accept-encoding.d.ts +29 -0
- package/dist/server/accept-encoding.js +95 -0
- package/dist/server/api-handler.d.ts +17 -0
- package/dist/server/api-handler.js +276 -0
- package/dist/server/app-action-request.d.ts +4 -0
- package/dist/server/app-action-request.js +9 -0
- package/dist/server/app-bfcache-id.d.ts +5 -0
- package/dist/server/app-bfcache-id.js +5 -0
- package/dist/server/app-bfcache-identity.d.ts +36 -0
- package/dist/server/app-bfcache-identity.js +156 -0
- package/dist/server/app-browser-action-result.d.ts +64 -0
- package/dist/server/app-browser-action-result.js +111 -0
- package/dist/server/app-browser-client-reuse-manifest.d.ts +12 -0
- package/dist/server/app-browser-client-reuse-manifest.js +101 -0
- package/dist/server/app-browser-entry.d.ts +1 -0
- package/dist/server/app-browser-entry.js +1087 -0
- package/dist/server/app-browser-error.d.ts +13 -0
- package/dist/server/app-browser-error.js +52 -0
- package/dist/server/app-browser-history-controller.d.ts +104 -0
- package/dist/server/app-browser-history-controller.js +210 -0
- package/dist/server/app-browser-hydration.d.ts +32 -0
- package/dist/server/app-browser-hydration.js +29 -0
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +43 -0
- package/dist/server/app-browser-mpa-navigation.d.ts +16 -0
- package/dist/server/app-browser-mpa-navigation.js +42 -0
- package/dist/server/app-browser-navigation-controller.d.ts +109 -0
- package/dist/server/app-browser-navigation-controller.js +465 -0
- package/dist/server/app-browser-popstate.d.ts +26 -0
- package/dist/server/app-browser-popstate.js +44 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +38 -0
- package/dist/server/app-browser-rsc-redirect.js +64 -0
- package/dist/server/app-browser-server-action-client.d.ts +32 -0
- package/dist/server/app-browser-server-action-client.js +128 -0
- package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
- package/dist/server/app-browser-server-action-navigation.js +9 -0
- package/dist/server/app-browser-state.d.ts +140 -0
- package/dist/server/app-browser-state.js +315 -0
- package/dist/server/app-browser-stream.d.ts +28 -0
- package/dist/server/app-browser-stream.js +122 -0
- package/dist/server/app-browser-visible-commit.d.ts +78 -0
- package/dist/server/app-browser-visible-commit.js +241 -0
- package/dist/server/app-client-reference-preloader.d.ts +14 -0
- package/dist/server/app-client-reference-preloader.js +44 -0
- package/dist/server/app-elements-wire.d.ts +192 -0
- package/dist/server/app-elements-wire.js +443 -0
- package/dist/server/app-elements.d.ts +9 -0
- package/dist/server/app-elements.js +18 -0
- package/dist/server/app-fallback-renderer.d.ts +89 -0
- package/dist/server/app-fallback-renderer.js +136 -0
- package/dist/server/app-history-state.d.ts +85 -0
- package/dist/server/app-history-state.js +223 -0
- package/dist/server/app-hook-warning-suppression.d.ts +6 -0
- package/dist/server/app-hook-warning-suppression.js +10 -0
- package/dist/server/app-inline-css-client.d.ts +6 -0
- package/dist/server/app-inline-css-client.js +35 -0
- package/dist/server/app-interception-context-header.d.ts +32 -0
- package/dist/server/app-interception-context-header.js +42 -0
- package/dist/server/app-layout-param-observation.d.ts +43 -0
- package/dist/server/app-layout-param-observation.js +168 -0
- package/dist/server/app-middleware.d.ts +46 -0
- package/dist/server/app-middleware.js +168 -0
- package/dist/server/app-mounted-slots-header.d.ts +35 -0
- package/dist/server/app-mounted-slots-header.js +58 -0
- package/dist/server/app-optimistic-routing.d.ts +53 -0
- package/dist/server/app-optimistic-routing.js +227 -0
- package/dist/server/app-page-boundary-render.d.ts +85 -0
- package/dist/server/app-page-boundary-render.js +305 -0
- package/dist/server/app-page-boundary.d.ts +102 -0
- package/dist/server/app-page-boundary.js +120 -0
- package/dist/server/app-page-cache-finalizer.d.ts +62 -0
- package/dist/server/app-page-cache-finalizer.js +122 -0
- package/dist/server/app-page-cache-render.d.ts +53 -0
- package/dist/server/app-page-cache-render.js +91 -0
- package/dist/server/app-page-cache.d.ts +83 -0
- package/dist/server/app-page-cache.js +272 -0
- package/dist/server/app-page-dispatch.d.ts +223 -0
- package/dist/server/app-page-dispatch.js +610 -0
- package/dist/server/app-page-element-builder.d.ts +96 -0
- package/dist/server/app-page-element-builder.js +205 -0
- package/dist/server/app-page-execution.d.ts +138 -0
- package/dist/server/app-page-execution.js +328 -0
- package/dist/server/app-page-head.d.ts +65 -0
- package/dist/server/app-page-head.js +228 -0
- package/dist/server/app-page-method.d.ts +15 -0
- package/dist/server/app-page-method.js +25 -0
- package/dist/server/app-page-params.d.ts +8 -0
- package/dist/server/app-page-params.js +39 -0
- package/dist/server/app-page-ppr-runtime.d.ts +7 -0
- package/dist/server/app-page-ppr-runtime.js +70 -0
- package/dist/server/app-page-probe.d.ts +134 -0
- package/dist/server/app-page-probe.js +276 -0
- package/dist/server/app-page-render-identity.d.ts +21 -0
- package/dist/server/app-page-render-identity.js +40 -0
- package/dist/server/app-page-render-observation.d.ts +36 -0
- package/dist/server/app-page-render-observation.js +82 -0
- package/dist/server/app-page-render.d.ts +111 -0
- package/dist/server/app-page-render.js +602 -0
- package/dist/server/app-page-request.d.ts +137 -0
- package/dist/server/app-page-request.js +216 -0
- package/dist/server/app-page-response.d.ts +68 -0
- package/dist/server/app-page-response.js +120 -0
- package/dist/server/app-page-route-wiring.d.ts +151 -0
- package/dist/server/app-page-route-wiring.js +452 -0
- package/dist/server/app-page-search-params-observation.d.ts +10 -0
- package/dist/server/app-page-search-params-observation.js +20 -0
- package/dist/server/app-page-segment-state.d.ts +9 -0
- package/dist/server/app-page-segment-state.js +80 -0
- package/dist/server/app-page-stream.d.ts +151 -0
- package/dist/server/app-page-stream.js +143 -0
- package/dist/server/app-pages-bridge.d.ts +63 -0
- package/dist/server/app-pages-bridge.js +63 -0
- package/dist/server/app-post-middleware-context.d.ts +15 -0
- package/dist/server/app-post-middleware-context.js +26 -0
- package/dist/server/app-ppr-fallback-shell-render.d.ts +18 -0
- package/dist/server/app-ppr-fallback-shell-render.js +26 -0
- package/dist/server/app-ppr-fallback-shell.d.ts +33 -0
- package/dist/server/app-ppr-fallback-shell.js +89 -0
- package/dist/server/app-prerender-endpoints.d.ts +18 -0
- package/dist/server/app-prerender-endpoints.js +94 -0
- package/dist/server/app-prerender-static-params.d.ts +30 -0
- package/dist/server/app-prerender-static-params.js +81 -0
- package/dist/server/app-render-dependency.d.ts +14 -0
- package/dist/server/app-render-dependency.js +41 -0
- package/dist/server/app-request-context.d.ts +20 -0
- package/dist/server/app-request-context.js +29 -0
- package/dist/server/app-route-handler-cache.d.ts +46 -0
- package/dist/server/app-route-handler-cache.js +78 -0
- package/dist/server/app-route-handler-dispatch.d.ts +49 -0
- package/dist/server/app-route-handler-dispatch.js +163 -0
- package/dist/server/app-route-handler-execution.d.ts +86 -0
- package/dist/server/app-route-handler-execution.js +128 -0
- package/dist/server/app-route-handler-policy.d.ts +55 -0
- package/dist/server/app-route-handler-policy.js +58 -0
- package/dist/server/app-route-handler-response.d.ts +28 -0
- package/dist/server/app-route-handler-response.js +145 -0
- package/dist/server/app-route-handler-runtime.d.ts +39 -0
- package/dist/server/app-route-handler-runtime.js +250 -0
- package/dist/server/app-route-module-loader.d.ts +91 -0
- package/dist/server/app-route-module-loader.js +83 -0
- package/dist/server/app-router-entry.d.ts +13 -0
- package/dist/server/app-router-entry.js +49 -0
- package/dist/server/app-rsc-cache-busting.d.ts +64 -0
- package/dist/server/app-rsc-cache-busting.js +206 -0
- package/dist/server/app-rsc-embedded-chunks.d.ts +8 -0
- package/dist/server/app-rsc-embedded-chunks.js +32 -0
- package/dist/server/app-rsc-error-handler.d.ts +20 -0
- package/dist/server/app-rsc-error-handler.js +28 -0
- package/dist/server/app-rsc-errors.d.ts +40 -0
- package/dist/server/app-rsc-errors.js +60 -0
- package/dist/server/app-rsc-handler.d.ts +201 -0
- package/dist/server/app-rsc-handler.js +538 -0
- package/dist/server/app-rsc-render-mode.d.ts +11 -0
- package/dist/server/app-rsc-render-mode.js +25 -0
- package/dist/server/app-rsc-request-normalization.d.ts +48 -0
- package/dist/server/app-rsc-request-normalization.js +75 -0
- package/dist/server/app-rsc-response-finalizer.d.ts +37 -0
- package/dist/server/app-rsc-response-finalizer.js +54 -0
- package/dist/server/app-rsc-route-matching.d.ts +93 -0
- package/dist/server/app-rsc-route-matching.js +134 -0
- package/dist/server/app-segment-config.d.ts +46 -0
- package/dist/server/app-segment-config.js +113 -0
- package/dist/server/app-server-action-execution.d.ts +219 -0
- package/dist/server/app-server-action-execution.js +767 -0
- package/dist/server/app-ssr-entry.d.ts +52 -0
- package/dist/server/app-ssr-entry.js +295 -0
- package/dist/server/app-ssr-error-meta.d.ts +13 -0
- package/dist/server/app-ssr-error-meta.js +48 -0
- package/dist/server/app-ssr-router-instance.d.ts +6 -0
- package/dist/server/app-ssr-router-instance.js +24 -0
- package/dist/server/app-ssr-stream.d.ts +60 -0
- package/dist/server/app-ssr-stream.js +408 -0
- package/dist/server/app-static-generation.d.ts +15 -0
- package/dist/server/app-static-generation.js +19 -0
- package/dist/server/app-visited-response-cache.d.ts +23 -0
- package/dist/server/app-visited-response-cache.js +19 -0
- package/dist/server/artifact-compatibility.d.ts +54 -0
- package/dist/server/artifact-compatibility.js +91 -0
- package/dist/server/before-interactive-head.d.ts +17 -0
- package/dist/server/before-interactive-head.js +35 -0
- package/dist/server/cache-control.d.ts +37 -0
- package/dist/server/cache-control.js +56 -0
- package/dist/server/cache-headers.d.ts +6 -0
- package/dist/server/cache-headers.js +17 -0
- package/dist/server/cache-proof.d.ts +364 -0
- package/dist/server/cache-proof.js +794 -0
- package/dist/server/client-reuse-manifest.d.ts +104 -0
- package/dist/server/client-reuse-manifest.js +209 -0
- package/dist/server/client-trace-metadata.d.ts +30 -0
- package/dist/server/client-trace-metadata.js +81 -0
- package/dist/server/cookie-utils.d.ts +12 -0
- package/dist/server/cookie-utils.js +18 -0
- package/dist/server/csp.d.ts +10 -0
- package/dist/server/csp.js +41 -0
- package/dist/server/default-global-error-module.d.ts +19 -0
- package/dist/server/default-global-error-module.js +18 -0
- package/dist/server/default-not-found-module.d.ts +19 -0
- package/dist/server/default-not-found-module.js +18 -0
- package/dist/server/defer-until-stream-consumed.d.ts +7 -0
- package/dist/server/defer-until-stream-consumed.js +34 -0
- package/dist/server/dev-error-overlay-store.d.ts +39 -0
- package/dist/server/dev-error-overlay-store.js +86 -0
- package/dist/server/dev-error-overlay.d.ts +51 -0
- package/dist/server/dev-error-overlay.js +1341 -0
- package/dist/server/dev-initial-server-error.d.ts +9 -0
- package/dist/server/dev-initial-server-error.js +26 -0
- package/dist/server/dev-lockfile.d.ts +109 -0
- package/dist/server/dev-lockfile.js +179 -0
- package/dist/server/dev-module-runner.d.ts +30 -0
- package/dist/server/dev-module-runner.js +91 -0
- package/dist/server/dev-origin-check.d.ts +62 -0
- package/dist/server/dev-origin-check.js +156 -0
- package/dist/server/dev-route-files.d.ts +6 -0
- package/dist/server/dev-route-files.js +71 -0
- package/dist/server/dev-server.d.ts +58 -0
- package/dist/server/dev-server.js +1114 -0
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/server/dev-stack-sourcemap-endpoint.js +4 -0
- package/dist/server/dev-stack-sourcemap.d.ts +43 -0
- package/dist/server/dev-stack-sourcemap.js +443 -0
- package/dist/server/document-initial-head.d.ts +6 -0
- package/dist/server/document-initial-head.js +33 -0
- package/dist/server/edge-api-runtime.d.ts +4 -0
- package/dist/server/edge-api-runtime.js +6 -0
- package/dist/server/file-based-metadata.d.ts +29 -0
- package/dist/server/file-based-metadata.js +401 -0
- package/dist/server/headers.d.ts +114 -0
- package/dist/server/headers.js +136 -0
- package/dist/server/html.d.ts +28 -0
- package/dist/server/html.js +41 -0
- package/dist/server/http-error-responses.d.ts +91 -0
- package/dist/server/http-error-responses.js +105 -0
- package/dist/server/hybrid-route-priority.d.ts +22 -0
- package/dist/server/hybrid-route-priority.js +33 -0
- package/dist/server/image-optimization.d.ts +130 -0
- package/dist/server/image-optimization.js +247 -0
- package/dist/server/implicit-tags.d.ts +6 -0
- package/dist/server/implicit-tags.js +44 -0
- package/dist/server/instrumentation-runtime.d.ts +49 -0
- package/dist/server/instrumentation-runtime.js +35 -0
- package/dist/server/instrumentation.d.ts +85 -0
- package/dist/server/instrumentation.js +130 -0
- package/dist/server/isr-cache.d.ts +127 -0
- package/dist/server/isr-cache.js +282 -0
- package/dist/server/isr-decision.d.ts +79 -0
- package/dist/server/isr-decision.js +70 -0
- package/dist/server/metadata-route-build-data.d.ts +24 -0
- package/dist/server/metadata-route-build-data.js +148 -0
- package/dist/server/metadata-route-response.d.ts +16 -0
- package/dist/server/metadata-route-response.js +205 -0
- package/dist/server/metadata-routes.d.ts +139 -0
- package/dist/server/metadata-routes.js +433 -0
- package/dist/server/middleware-matcher.d.ts +14 -0
- package/dist/server/middleware-matcher.js +111 -0
- package/dist/server/middleware-request-headers.d.ts +11 -0
- package/dist/server/middleware-request-headers.js +65 -0
- package/dist/server/middleware-response-headers.d.ts +12 -0
- package/dist/server/middleware-response-headers.js +42 -0
- package/dist/server/middleware-runtime.d.ts +67 -0
- package/dist/server/middleware-runtime.js +240 -0
- package/dist/server/middleware.d.ts +62 -0
- package/dist/server/middleware.js +114 -0
- package/dist/server/navigation-planner.d.ts +308 -0
- package/dist/server/navigation-planner.js +831 -0
- package/dist/server/navigation-trace.d.ts +68 -0
- package/dist/server/navigation-trace.js +71 -0
- package/dist/server/next-error-digest.d.ts +44 -0
- package/dist/server/next-error-digest.js +40 -0
- package/dist/server/normalize-path.d.ts +38 -0
- package/dist/server/normalize-path.js +70 -0
- package/dist/server/open-redirect.d.ts +12 -0
- package/dist/server/open-redirect.js +21 -0
- package/dist/server/operation-token.d.ts +40 -0
- package/dist/server/operation-token.js +85 -0
- package/dist/server/otel-tracer-extension.d.ts +45 -0
- package/dist/server/otel-tracer-extension.js +89 -0
- package/dist/server/pages-api-route.d.ts +83 -0
- package/dist/server/pages-api-route.js +75 -0
- package/dist/server/pages-asset-tags.d.ts +78 -0
- package/dist/server/pages-asset-tags.js +126 -0
- package/dist/server/pages-body-parser-config.d.ts +59 -0
- package/dist/server/pages-body-parser-config.js +77 -0
- package/dist/server/pages-data-route.d.ts +121 -0
- package/dist/server/pages-data-route.js +157 -0
- package/dist/server/pages-default-404.d.ts +30 -0
- package/dist/server/pages-default-404.js +38 -0
- package/dist/server/pages-dev-module-url.d.ts +4 -0
- package/dist/server/pages-dev-module-url.js +15 -0
- package/dist/server/pages-document-initial-props.d.ts +77 -0
- package/dist/server/pages-document-initial-props.js +109 -0
- package/dist/server/pages-get-initial-props.d.ts +67 -0
- package/dist/server/pages-get-initial-props.js +92 -0
- package/dist/server/pages-i18n.d.ts +106 -0
- package/dist/server/pages-i18n.js +183 -0
- package/dist/server/pages-media-type.d.ts +15 -0
- package/dist/server/pages-media-type.js +24 -0
- package/dist/server/pages-node-compat.d.ts +55 -0
- package/dist/server/pages-node-compat.js +235 -0
- package/dist/server/pages-page-data.d.ts +223 -0
- package/dist/server/pages-page-data.js +484 -0
- package/dist/server/pages-page-handler.d.ts +100 -0
- package/dist/server/pages-page-handler.js +403 -0
- package/dist/server/pages-page-method.d.ts +47 -0
- package/dist/server/pages-page-method.js +17 -0
- package/dist/server/pages-page-response.d.ts +138 -0
- package/dist/server/pages-page-response.js +285 -0
- package/dist/server/pages-readiness.d.ts +36 -0
- package/dist/server/pages-readiness.js +21 -0
- package/dist/server/pages-request-pipeline.d.ts +116 -0
- package/dist/server/pages-request-pipeline.js +311 -0
- package/dist/server/pages-revalidate.d.ts +15 -0
- package/dist/server/pages-revalidate.js +19 -0
- package/dist/server/pages-serializable-props.d.ts +24 -0
- package/dist/server/pages-serializable-props.js +67 -0
- package/dist/server/pregenerated-concrete-paths.d.ts +16 -0
- package/dist/server/pregenerated-concrete-paths.js +61 -0
- package/dist/server/prerender-manifest.d.ts +33 -0
- package/dist/server/prerender-manifest.js +54 -0
- package/dist/server/prerender-route-params.d.ts +23 -0
- package/dist/server/prerender-route-params.js +113 -0
- package/dist/server/prerender-work-unit-setup.d.ts +6 -0
- package/dist/server/prerender-work-unit-setup.js +28 -0
- package/dist/server/prod-server.d.ts +148 -0
- package/dist/server/prod-server.js +1136 -0
- package/dist/server/proxy-trust.d.ts +40 -0
- package/dist/server/proxy-trust.js +68 -0
- package/dist/server/request-log.d.ts +39 -0
- package/dist/server/request-log.js +56 -0
- package/dist/server/request-pipeline.d.ts +187 -0
- package/dist/server/request-pipeline.js +447 -0
- package/dist/server/rsc-stream-hints.d.ts +10 -0
- package/dist/server/rsc-stream-hints.js +41 -0
- package/dist/server/seed-cache.d.ts +29 -0
- package/dist/server/seed-cache.js +125 -0
- package/dist/server/server-action-not-found.d.ts +21 -0
- package/dist/server/server-action-not-found.js +62 -0
- package/dist/server/server-globals.d.ts +4 -0
- package/dist/server/server-globals.js +35 -0
- package/dist/server/skip-cache-proof.d.ts +61 -0
- package/dist/server/skip-cache-proof.js +168 -0
- package/dist/server/socket-error-backstop.d.ts +34 -0
- package/dist/server/socket-error-backstop.js +200 -0
- package/dist/server/static-file-cache.d.ts +56 -0
- package/dist/server/static-file-cache.js +231 -0
- package/dist/server/static-layout-client-reuse-proof.d.ts +15 -0
- package/dist/server/static-layout-client-reuse-proof.js +33 -0
- package/dist/server/streaming-metadata.d.ts +4 -0
- package/dist/server/streaming-metadata.js +8 -0
- package/dist/server/worker-utils.d.ts +7 -0
- package/dist/server/worker-utils.js +99 -0
- package/dist/shims/amp.d.ts +19 -0
- package/dist/shims/amp.js +23 -0
- package/dist/shims/app-router-scroll-state.d.ts +15 -0
- package/dist/shims/app-router-scroll-state.js +61 -0
- package/dist/shims/app-router-scroll.d.ts +29 -0
- package/dist/shims/app-router-scroll.js +141 -0
- package/dist/shims/app.d.ts +42 -0
- package/dist/shims/app.js +48 -0
- package/dist/shims/before-interactive-context.d.ts +40 -0
- package/dist/shims/before-interactive-context.js +8 -0
- package/dist/shims/cache-for-request.d.ts +57 -0
- package/dist/shims/cache-for-request.js +72 -0
- package/dist/shims/cache-handler.d.ts +106 -0
- package/dist/shims/cache-handler.js +176 -0
- package/dist/shims/cache-request-state.d.ts +47 -0
- package/dist/shims/cache-request-state.js +126 -0
- package/dist/shims/cache-runtime.d.ts +83 -0
- package/dist/shims/cache-runtime.js +452 -0
- package/dist/shims/cache.d.ts +145 -0
- package/dist/shims/cache.js +401 -0
- package/dist/shims/cdn-cache.d.ts +125 -0
- package/dist/shims/cdn-cache.js +100 -0
- package/dist/shims/client-hook-error.d.ts +13 -0
- package/dist/shims/client-hook-error.js +17 -0
- package/dist/shims/client-locale.d.ts +14 -0
- package/dist/shims/client-locale.js +11 -0
- package/dist/shims/client-only.d.ts +1 -0
- package/dist/shims/client-only.js +1 -0
- package/dist/shims/compat-router.d.ts +16 -0
- package/dist/shims/compat-router.js +25 -0
- package/dist/shims/config.d.ts +28 -0
- package/dist/shims/config.js +21 -0
- package/dist/shims/constants.d.ts +130 -0
- package/dist/shims/constants.js +167 -0
- package/dist/shims/default-global-error.d.ts +31 -0
- package/dist/shims/default-global-error.js +179 -0
- package/dist/shims/default-not-found.d.ts +11 -0
- package/dist/shims/default-not-found.js +59 -0
- package/dist/shims/document.d.ts +92 -0
- package/dist/shims/document.js +76 -0
- package/dist/shims/dynamic-preload-chunks.d.ts +8 -0
- package/dist/shims/dynamic-preload-chunks.js +79 -0
- package/dist/shims/dynamic.d.ts +35 -0
- package/dist/shims/dynamic.js +204 -0
- package/dist/shims/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +44 -0
- package/dist/shims/error-boundary.d.ts +155 -0
- package/dist/shims/error-boundary.js +342 -0
- package/dist/shims/error.d.ts +31 -0
- package/dist/shims/error.js +123 -0
- package/dist/shims/error.react-server.d.ts +9 -0
- package/dist/shims/error.react-server.js +6 -0
- package/dist/shims/fetch-cache.d.ts +136 -0
- package/dist/shims/fetch-cache.js +766 -0
- package/dist/shims/font-google-base.d.ts +83 -0
- package/dist/shims/font-google-base.js +290 -0
- package/dist/shims/font-google.d.ts +2 -0
- package/dist/shims/font-google.js +2 -0
- package/dist/shims/font-local.d.ts +50 -0
- package/dist/shims/font-local.js +195 -0
- package/dist/shims/font-utils.d.ts +56 -0
- package/dist/shims/font-utils.js +107 -0
- package/dist/shims/form.d.ts +19 -0
- package/dist/shims/form.js +236 -0
- package/dist/shims/hash-scroll.d.ts +10 -0
- package/dist/shims/hash-scroll.js +47 -0
- package/dist/shims/head-state.d.ts +16 -0
- package/dist/shims/head-state.js +43 -0
- package/dist/shims/head.d.ts +73 -0
- package/dist/shims/head.js +340 -0
- package/dist/shims/headers.d.ts +253 -0
- package/dist/shims/headers.js +754 -0
- package/dist/shims/i18n-context.d.ts +22 -0
- package/dist/shims/i18n-context.js +42 -0
- package/dist/shims/i18n-state.d.ts +14 -0
- package/dist/shims/i18n-state.js +38 -0
- package/dist/shims/image-config.d.ts +45 -0
- package/dist/shims/image-config.js +85 -0
- package/dist/shims/image.d.ts +55 -0
- package/dist/shims/image.js +582 -0
- package/dist/shims/internal/als-registry.d.ts +14 -0
- package/dist/shims/internal/als-registry.js +80 -0
- package/dist/shims/internal/api-utils.d.ts +14 -0
- package/dist/shims/internal/api-utils.js +1 -0
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -0
- package/dist/shims/internal/app-page-props-cache-key.js +16 -0
- package/dist/shims/internal/app-route-detection.d.ts +39 -0
- package/dist/shims/internal/app-route-detection.js +62 -0
- package/dist/shims/internal/app-router-context.d.ts +31 -0
- package/dist/shims/internal/app-router-context.js +28 -0
- package/dist/shims/internal/cookie-serialize.d.ts +45 -0
- package/dist/shims/internal/cookie-serialize.js +49 -0
- package/dist/shims/internal/cookies.d.ts +2 -0
- package/dist/shims/internal/cookies.js +2 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
- package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
- package/dist/shims/internal/interpolate-as.d.ts +25 -0
- package/dist/shims/internal/interpolate-as.js +196 -0
- package/dist/shims/internal/link-status-registry.d.ts +43 -0
- package/dist/shims/internal/link-status-registry.js +42 -0
- package/dist/shims/internal/make-hanging-promise.d.ts +15 -0
- package/dist/shims/internal/make-hanging-promise.js +44 -0
- package/dist/shims/internal/navigation-untracked.d.ts +35 -0
- package/dist/shims/internal/navigation-untracked.js +56 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +54 -0
- package/dist/shims/internal/pages-data-fetch-dedup.js +121 -0
- package/dist/shims/internal/pages-data-target.d.ts +62 -0
- package/dist/shims/internal/pages-data-target.js +98 -0
- package/dist/shims/internal/pages-data-url.d.ts +41 -0
- package/dist/shims/internal/pages-data-url.js +71 -0
- package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
- package/dist/shims/internal/pages-router-accessor.js +13 -0
- package/dist/shims/internal/route-pattern-for-warning.d.ts +27 -0
- package/dist/shims/internal/route-pattern-for-warning.js +40 -0
- package/dist/shims/internal/router-context.d.ts +7 -0
- package/dist/shims/internal/router-context.js +13 -0
- package/dist/shims/internal/utils.d.ts +52 -0
- package/dist/shims/internal/utils.js +27 -0
- package/dist/shims/internal/work-unit-async-storage.d.ts +30 -0
- package/dist/shims/internal/work-unit-async-storage.js +17 -0
- package/dist/shims/layout-segment-context.d.ts +24 -0
- package/dist/shims/layout-segment-context.js +39 -0
- package/dist/shims/legacy-image.d.ts +41 -0
- package/dist/shims/legacy-image.js +49 -0
- package/dist/shims/link-prefetch.d.ts +41 -0
- package/dist/shims/link-prefetch.js +43 -0
- package/dist/shims/link.d.ts +102 -0
- package/dist/shims/link.js +687 -0
- package/dist/shims/metadata.d.ts +285 -0
- package/dist/shims/metadata.js +820 -0
- package/dist/shims/navigation-context-state.d.ts +40 -0
- package/dist/shims/navigation-context-state.js +116 -0
- package/dist/shims/navigation-errors.d.ts +55 -0
- package/dist/shims/navigation-errors.js +110 -0
- package/dist/shims/navigation-server.d.ts +3 -0
- package/dist/shims/navigation-server.js +3 -0
- package/dist/shims/navigation-state.d.ts +25 -0
- package/dist/shims/navigation-state.js +66 -0
- package/dist/shims/navigation.d.ts +286 -0
- package/dist/shims/navigation.js +1206 -0
- package/dist/shims/navigation.react-server.d.ts +14 -0
- package/dist/shims/navigation.react-server.js +32 -0
- package/dist/shims/offline.d.ts +4 -0
- package/dist/shims/offline.js +15 -0
- package/dist/shims/og.d.ts +17 -0
- package/dist/shims/og.js +48 -0
- package/dist/shims/pages-router-runtime.d.ts +12 -0
- package/dist/shims/pages-router-runtime.js +24 -0
- package/dist/shims/ppr-fallback-shell.d.ts +33 -0
- package/dist/shims/ppr-fallback-shell.js +170 -0
- package/dist/shims/readonly-url-search-params.d.ts +13 -0
- package/dist/shims/readonly-url-search-params.js +26 -0
- package/dist/shims/request-context.d.ts +58 -0
- package/dist/shims/request-context.js +45 -0
- package/dist/shims/request-state-types.d.ts +12 -0
- package/dist/shims/request-state-types.js +1 -0
- package/dist/shims/root-params.d.ts +12 -0
- package/dist/shims/root-params.js +30 -0
- package/dist/shims/router-state.d.ts +32 -0
- package/dist/shims/router-state.js +39 -0
- package/dist/shims/router.d.ts +192 -0
- package/dist/shims/router.js +1786 -0
- package/dist/shims/script-nonce-context.d.ts +11 -0
- package/dist/shims/script-nonce-context.js +23 -0
- package/dist/shims/script.d.ts +43 -0
- package/dist/shims/script.js +370 -0
- package/dist/shims/server-only.d.ts +1 -0
- package/dist/shims/server-only.js +1 -0
- package/dist/shims/server.d.ts +323 -0
- package/dist/shims/server.js +729 -0
- package/dist/shims/slot.d.ts +45 -0
- package/dist/shims/slot.js +230 -0
- package/dist/shims/thenable-params.d.ts +11 -0
- package/dist/shims/thenable-params.js +176 -0
- package/dist/shims/unified-request-context.d.ts +68 -0
- package/dist/shims/unified-request-context.js +86 -0
- package/dist/shims/unrecognized-action-error.d.ts +34 -0
- package/dist/shims/unrecognized-action-error.js +39 -0
- package/dist/shims/url-safety.d.ts +34 -0
- package/dist/shims/url-safety.js +70 -0
- package/dist/shims/url-utils.d.ts +51 -0
- package/dist/shims/url-utils.js +156 -0
- package/dist/shims/use-merged-ref.d.ts +6 -0
- package/dist/shims/use-merged-ref.js +38 -0
- package/dist/shims/web-vitals.d.ts +8 -0
- package/dist/shims/web-vitals.js +22 -0
- package/dist/typegen.d.ts +9 -0
- package/dist/typegen.js +228 -0
- package/dist/utils/asset-prefix.d.ts +96 -0
- package/dist/utils/asset-prefix.js +122 -0
- package/dist/utils/base-path.d.ts +31 -0
- package/dist/utils/base-path.js +45 -0
- package/dist/utils/built-asset-url.d.ts +4 -0
- package/dist/utils/built-asset-url.js +11 -0
- package/dist/utils/cache-control-metadata.d.ts +4 -0
- package/dist/utils/cache-control-metadata.js +12 -0
- package/dist/utils/client-build-manifest.d.ts +21 -0
- package/dist/utils/client-build-manifest.js +87 -0
- package/dist/utils/client-entry-manifest.d.ts +11 -0
- package/dist/utils/client-entry-manifest.js +29 -0
- package/dist/utils/client-runtime-metadata.d.ts +45 -0
- package/dist/utils/client-runtime-metadata.js +63 -0
- package/dist/utils/commonjs-loader.d.ts +16 -0
- package/dist/utils/commonjs-loader.js +100 -0
- package/dist/utils/compare.d.ts +4 -0
- package/dist/utils/compare.js +8 -0
- package/dist/utils/deployment-id.d.ts +8 -0
- package/dist/utils/deployment-id.js +22 -0
- package/dist/utils/dev-error-recovery-event.d.ts +4 -0
- package/dist/utils/dev-error-recovery-event.js +4 -0
- package/dist/utils/domain-locale.d.ts +26 -0
- package/dist/utils/domain-locale.js +50 -0
- package/dist/utils/encode-cache-tag.d.ts +30 -0
- package/dist/utils/encode-cache-tag.js +36 -0
- package/dist/utils/error-cause.d.ts +4 -0
- package/dist/utils/error-cause.js +95 -0
- package/dist/utils/has-trailing-comma.d.ts +24 -0
- package/dist/utils/has-trailing-comma.js +62 -0
- package/dist/utils/hash.d.ts +24 -0
- package/dist/utils/hash.js +55 -0
- package/dist/utils/html-limited-bots.d.ts +21 -0
- package/dist/utils/html-limited-bots.js +35 -0
- package/dist/utils/lazy-chunks.d.ts +59 -0
- package/dist/utils/lazy-chunks.js +112 -0
- package/dist/utils/manifest-paths.d.ts +30 -0
- package/dist/utils/manifest-paths.js +66 -0
- package/dist/utils/mdx-scan.d.ts +9 -0
- package/dist/utils/mdx-scan.js +34 -0
- package/dist/utils/navigation-signal.d.ts +4 -0
- package/dist/utils/navigation-signal.js +12 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/number.js +6 -0
- package/dist/utils/parse-cookie.d.ts +13 -0
- package/dist/utils/parse-cookie.js +52 -0
- package/dist/utils/path.d.ts +22 -0
- package/dist/utils/path.js +30 -0
- package/dist/utils/prerender-output-paths.d.ts +14 -0
- package/dist/utils/prerender-output-paths.js +22 -0
- package/dist/utils/project.d.ts +76 -0
- package/dist/utils/project.js +213 -0
- package/dist/utils/promise.d.ts +4 -0
- package/dist/utils/promise.js +6 -0
- package/dist/utils/public-routes.d.ts +4 -0
- package/dist/utils/public-routes.js +48 -0
- package/dist/utils/query.d.ts +49 -0
- package/dist/utils/query.js +122 -0
- package/dist/utils/record.d.ts +4 -0
- package/dist/utils/record.js +6 -0
- package/dist/utils/regex.d.ts +4 -0
- package/dist/utils/regex.js +6 -0
- package/dist/utils/safe-json-file.d.ts +17 -0
- package/dist/utils/safe-json-file.js +23 -0
- package/dist/utils/sorted-array.d.ts +8 -0
- package/dist/utils/sorted-array.js +20 -0
- package/dist/utils/text-stream.d.ts +28 -0
- package/dist/utils/text-stream.js +64 -0
- package/dist/utils/vinext-root.d.ts +23 -0
- package/dist/utils/vinext-root.js +29 -0
- package/dist/utils/virtual-module.d.ts +5 -0
- package/dist/utils/virtual-module.js +0 -0
- package/dist/utils/vite-version.d.ts +21 -0
- package/dist/utils/vite-version.js +42 -0
- package/package.json +145 -0
|
@@ -0,0 +1,1206 @@
|
|
|
1
|
+
import { stripBasePath } from "../utils/base-path.js";
|
|
2
|
+
import { VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER } from "../server/headers.js";
|
|
3
|
+
import { assertSafeNavigationUrl } from "./url-safety.js";
|
|
4
|
+
import { AppElementsWire } from "../server/app-elements-wire.js";
|
|
5
|
+
import "../server/app-elements.js";
|
|
6
|
+
import { markPprFallbackShellDynamicBoundary } from "./ppr-fallback-shell.js";
|
|
7
|
+
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
8
|
+
import { resolveHybridClientRouteOwner } from "./internal/hybrid-client-route-owner.js";
|
|
9
|
+
import { isAbsoluteOrProtocolRelativeUrl, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
|
|
10
|
+
import { retryScrollTo, scrollToHashTarget } from "./hash-scroll.js";
|
|
11
|
+
import { GLOBAL_ACCESSORS_KEY, ServerInsertedHTMLContext, _registerStateAccessors, clearClientHydrationContext, clearServerInsertedHTML, flushServerInsertedHTML, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getLayoutSegmentContext, getNavigationContext, registerServerInsertedHTMLCallback, renderServerInsertedHTML, setNavigationContext } from "./navigation-context-state.js";
|
|
12
|
+
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";
|
|
13
|
+
import { clearAppNavigationFailureTarget, stageAppNavigationFailureTarget } from "../client/app-nav-failure-handler.js";
|
|
14
|
+
import { beginAppRouterScrollIntent, clearAppRouterScrollIntent, consumeAppRouterScrollIntent, getPendingAppRouterScrollIntent } from "./app-router-scroll-state.js";
|
|
15
|
+
import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, createRscRequestHeaders, createRscRequestUrl, stripRscCacheBustingSearchParam } from "../server/app-rsc-cache-busting.js";
|
|
16
|
+
import { getNavigationRuntime, hasAppNavigationRuntime } from "../client/navigation-runtime.js";
|
|
17
|
+
import { notifyAppRouterTransitionStart } from "../client/instrumentation-client-state.js";
|
|
18
|
+
import { PUBLIC_INITIAL_BFCACHE_ID } from "../server/app-bfcache-id.js";
|
|
19
|
+
import { resolveManifestNavigationInterceptionContext } from "../server/app-browser-interception-context.js";
|
|
20
|
+
import { createExternalHistoryStatePreservingMetadata, createHashOnlyHistoryStatePreservingNavigationMetadata } from "../server/app-history-state.js";
|
|
21
|
+
import { hasPendingAppRouterPageRedirect } from "../server/app-browser-mpa-navigation.js";
|
|
22
|
+
import { navigationPlanner } from "../server/navigation-planner.js";
|
|
23
|
+
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
24
|
+
import { getPagesNavigationContext } from "./internal/pages-router-accessor.js";
|
|
25
|
+
import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
|
|
26
|
+
import * as React$1 from "react";
|
|
27
|
+
//#region src/shims/navigation.ts
|
|
28
|
+
/**
|
|
29
|
+
* next/navigation shim
|
|
30
|
+
*
|
|
31
|
+
* App Router navigation hooks. These work on both server (RSC) and client.
|
|
32
|
+
* Server-side: reads from a request context set by the RSC handler.
|
|
33
|
+
* Client-side: reads from browser Location API and provides navigation.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Read the child segments for a parallel route below the current layout.
|
|
37
|
+
* Returns [] if no context is available (RSC environment, outside React tree)
|
|
38
|
+
* or if the requested key is not present in the segment map.
|
|
39
|
+
*/
|
|
40
|
+
function useChildSegments(parallelRoutesKey = "children") {
|
|
41
|
+
const ctx = getLayoutSegmentContext();
|
|
42
|
+
if (!ctx) return [];
|
|
43
|
+
try {
|
|
44
|
+
return React$1.useContext(ctx)[parallelRoutesKey] ?? [];
|
|
45
|
+
} catch {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const _READONLY_SEARCH_PARAMS = Symbol("vinext.navigation.readonlySearchParams");
|
|
50
|
+
const _READONLY_SEARCH_PARAMS_SOURCE = Symbol("vinext.navigation.readonlySearchParamsSource");
|
|
51
|
+
const _READONLY_SEARCH_PARAMS_SOURCE_KEY = Symbol("vinext.navigation.readonlySearchParamsSourceKey");
|
|
52
|
+
const PAGES_NAVIGATION_NOTIFY_KEY = Symbol.for("vinext.navigation.pagesNavigationNotify");
|
|
53
|
+
const isServer = typeof window === "undefined";
|
|
54
|
+
/** basePath from next.config.js, injected by the plugin at build time */
|
|
55
|
+
const __basePath = process.env.__NEXT_ROUTER_BASEPATH ?? "";
|
|
56
|
+
/** Maximum number of entries in the RSC prefetch cache. */
|
|
57
|
+
const MAX_PREFETCH_CACHE_SIZE = 50;
|
|
58
|
+
/**
|
|
59
|
+
* TTL for prefetch cache entries in ms.
|
|
60
|
+
*
|
|
61
|
+
* Mirrors Next.js' `STATIC_STALETIME_MS` derivation. The plugin injects
|
|
62
|
+
* `process.env.__NEXT_CLIENT_ROUTER_STATIC_STALETIME` from
|
|
63
|
+
* `experimental.staleTimes.static` (in seconds) at build time; we convert
|
|
64
|
+
* to ms here.
|
|
65
|
+
*
|
|
66
|
+
* Falls back to vinext's historical default of 30s when the env var is
|
|
67
|
+
* absent (e.g. unit tests that import this module without going through
|
|
68
|
+
* the plugin's `define` pipeline). When the plugin is active and the user
|
|
69
|
+
* has not set `experimental.staleTimes`, Next.js' 300s default applies
|
|
70
|
+
* (see `resolveStaleTimes` in `config/next-config.ts`).
|
|
71
|
+
*/
|
|
72
|
+
function resolvePrefetchCacheTtl() {
|
|
73
|
+
const raw = process.env.__NEXT_CLIENT_ROUTER_STATIC_STALETIME;
|
|
74
|
+
if (raw === void 0 || raw === "") return 3e4;
|
|
75
|
+
const seconds = Number(raw);
|
|
76
|
+
if (!Number.isFinite(seconds) || seconds < 0) return 3e4;
|
|
77
|
+
return seconds * 1e3;
|
|
78
|
+
}
|
|
79
|
+
const PREFETCH_CACHE_TTL = resolvePrefetchCacheTtl();
|
|
80
|
+
function getCurrentInterceptionContext() {
|
|
81
|
+
if (isServer) return null;
|
|
82
|
+
return stripBasePath(window.location.pathname, __basePath);
|
|
83
|
+
}
|
|
84
|
+
function getPrefetchInterceptionContext(targetHref) {
|
|
85
|
+
if (isServer) return null;
|
|
86
|
+
let targetUrl;
|
|
87
|
+
try {
|
|
88
|
+
targetUrl = new URL(targetHref, window.location.href);
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return resolveManifestNavigationInterceptionContext({
|
|
93
|
+
basePath: __basePath,
|
|
94
|
+
currentPathname: window.location.pathname,
|
|
95
|
+
routeManifest: getNavigationRuntime()?.bootstrap.routeManifest ?? null,
|
|
96
|
+
targetPathname: targetUrl.pathname
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function getCurrentNextUrl() {
|
|
100
|
+
if (isServer) return "/";
|
|
101
|
+
return window.location.pathname + window.location.search;
|
|
102
|
+
}
|
|
103
|
+
/** Get or create the shared in-memory RSC prefetch cache on window. */
|
|
104
|
+
function getPrefetchCache() {
|
|
105
|
+
if (isServer) return /* @__PURE__ */ new Map();
|
|
106
|
+
if (!window.__VINEXT_RSC_PREFETCH_CACHE__) window.__VINEXT_RSC_PREFETCH_CACHE__ = /* @__PURE__ */ new Map();
|
|
107
|
+
return window.__VINEXT_RSC_PREFETCH_CACHE__;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get or create the shared set of already-prefetched RSC URLs on window.
|
|
111
|
+
* Keyed by interception-aware cache key so distinct source routes do not alias.
|
|
112
|
+
*/
|
|
113
|
+
function getPrefetchedUrls() {
|
|
114
|
+
if (isServer) return /* @__PURE__ */ new Set();
|
|
115
|
+
if (!window.__VINEXT_RSC_PREFETCHED_URLS__) window.__VINEXT_RSC_PREFETCHED_URLS__ = /* @__PURE__ */ new Set();
|
|
116
|
+
return window.__VINEXT_RSC_PREFETCHED_URLS__;
|
|
117
|
+
}
|
|
118
|
+
function isDynamicStaleTimeSeconds(value) {
|
|
119
|
+
return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value >= 0;
|
|
120
|
+
}
|
|
121
|
+
function isCacheExpiresAt(value) {
|
|
122
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
123
|
+
}
|
|
124
|
+
function parseDynamicStaleTimeSeconds(value) {
|
|
125
|
+
if (value === null || value === "") return void 0;
|
|
126
|
+
const seconds = Number(value);
|
|
127
|
+
return isDynamicStaleTimeSeconds(seconds) ? seconds : void 0;
|
|
128
|
+
}
|
|
129
|
+
function resolveCachedRscResponseTtlMs(cached, fallbackTtlMs) {
|
|
130
|
+
const seconds = cached.dynamicStaleTimeSeconds;
|
|
131
|
+
if (!isDynamicStaleTimeSeconds(seconds)) return fallbackTtlMs;
|
|
132
|
+
return seconds * 1e3;
|
|
133
|
+
}
|
|
134
|
+
function resolveCachedRscResponseExpiresAt(timestamp, cached, fallbackTtlMs) {
|
|
135
|
+
if (isCacheExpiresAt(cached.expiresAt)) return cached.expiresAt;
|
|
136
|
+
return timestamp + resolveCachedRscResponseTtlMs(cached, fallbackTtlMs);
|
|
137
|
+
}
|
|
138
|
+
function resolvePrefetchCacheEntryExpiresAt(entry) {
|
|
139
|
+
if (entry.expiresAt !== void 0) return entry.expiresAt;
|
|
140
|
+
if (entry.snapshot) return resolveCachedRscResponseExpiresAt(entry.timestamp, entry.snapshot, PREFETCH_CACHE_TTL);
|
|
141
|
+
return entry.timestamp + PREFETCH_CACHE_TTL;
|
|
142
|
+
}
|
|
143
|
+
function resolvePrefetchCacheEntryMountedSlotsHeader(entry) {
|
|
144
|
+
if (entry.mountedSlotsHeader !== void 0) return entry.mountedSlotsHeader;
|
|
145
|
+
return entry.snapshot?.mountedSlotsHeader ?? null;
|
|
146
|
+
}
|
|
147
|
+
function normalizeRscCacheLookupUrl(rscUrl) {
|
|
148
|
+
try {
|
|
149
|
+
const url = new URL(rscUrl, "http://vinext.local");
|
|
150
|
+
stripRscCacheBustingSearchParam(url);
|
|
151
|
+
return `${url.pathname}${url.search}`;
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function parsePrefetchCacheKey(cacheKey) {
|
|
157
|
+
const separatorIndex = cacheKey.indexOf("\0");
|
|
158
|
+
if (separatorIndex === -1) return {
|
|
159
|
+
interceptionContext: null,
|
|
160
|
+
rscUrl: cacheKey
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
interceptionContext: cacheKey.slice(separatorIndex + 1),
|
|
164
|
+
rscUrl: cacheKey.slice(0, separatorIndex)
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function isPrefetchCacheEntryCompatibleWithMountedSlots(entry, mountedSlotsHeader) {
|
|
168
|
+
if (resolvePrefetchCacheEntryMountedSlotsHeader(entry) === mountedSlotsHeader) return true;
|
|
169
|
+
return (entry.snapshot?.mountedSlotsHeader ?? null) === mountedSlotsHeader;
|
|
170
|
+
}
|
|
171
|
+
function findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader) {
|
|
172
|
+
const exactCacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);
|
|
173
|
+
const cache = getPrefetchCache();
|
|
174
|
+
const exactEntry = cache.get(exactCacheKey);
|
|
175
|
+
if (exactEntry && exactEntry.cacheForNavigation !== false && isPrefetchCacheEntryCompatibleWithMountedSlots(exactEntry, mountedSlotsHeader)) return {
|
|
176
|
+
cacheKey: exactCacheKey,
|
|
177
|
+
entry: exactEntry
|
|
178
|
+
};
|
|
179
|
+
const normalizedTarget = normalizeRscCacheLookupUrl(rscUrl);
|
|
180
|
+
if (normalizedTarget === null) return null;
|
|
181
|
+
for (const [cacheKey, entry] of cache) {
|
|
182
|
+
if (cacheKey === exactCacheKey) continue;
|
|
183
|
+
if (entry.cacheForNavigation === false) continue;
|
|
184
|
+
const source = parsePrefetchCacheKey(cacheKey);
|
|
185
|
+
if (source.interceptionContext !== interceptionContext) continue;
|
|
186
|
+
if (normalizeRscCacheLookupUrl(source.rscUrl) !== normalizedTarget) continue;
|
|
187
|
+
if (!isPrefetchCacheEntryCompatibleWithMountedSlots(entry, mountedSlotsHeader)) continue;
|
|
188
|
+
return {
|
|
189
|
+
cacheKey,
|
|
190
|
+
entry
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
function hasPrefetchCacheEntryForNavigation(rscUrl, interceptionContext = null, mountedSlotsHeader = null, options = {}) {
|
|
196
|
+
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader);
|
|
197
|
+
if (match === null) return false;
|
|
198
|
+
if (match.entry.pending !== void 0) return true;
|
|
199
|
+
if (resolvePrefetchCacheEntryExpiresAt(match.entry) > Date.now()) return true;
|
|
200
|
+
deletePrefetchCacheEntry(getPrefetchCache(), getPrefetchedUrls(), match.cacheKey, match.entry, options.notifyInvalidation ?? true);
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Evict prefetch cache entries if at capacity.
|
|
205
|
+
* First sweeps expired entries, then falls back to FIFO eviction.
|
|
206
|
+
*/
|
|
207
|
+
function evictPrefetchCacheIfNeeded() {
|
|
208
|
+
const cache = getPrefetchCache();
|
|
209
|
+
if (cache.size < 50) return;
|
|
210
|
+
const now = Date.now();
|
|
211
|
+
const prefetched = getPrefetchedUrls();
|
|
212
|
+
for (const [key, entry] of cache) if (resolvePrefetchCacheEntryExpiresAt(entry) <= now) deletePrefetchCacheEntry(cache, prefetched, key, entry, true);
|
|
213
|
+
while (cache.size >= 50) {
|
|
214
|
+
const oldest = cache.keys().next().value;
|
|
215
|
+
if (oldest !== void 0) {
|
|
216
|
+
const entry = cache.get(oldest);
|
|
217
|
+
if (entry) deletePrefetchCacheEntry(cache, prefetched, oldest, entry, true);
|
|
218
|
+
else {
|
|
219
|
+
cache.delete(oldest);
|
|
220
|
+
prefetched.delete(oldest);
|
|
221
|
+
}
|
|
222
|
+
} else break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function clearPrefetchInvalidation(entry) {
|
|
226
|
+
if (entry.invalidationTimer !== void 0) {
|
|
227
|
+
clearTimeout(entry.invalidationTimer);
|
|
228
|
+
entry.invalidationTimer = void 0;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function notifyPrefetchInvalidated(entry) {
|
|
232
|
+
clearPrefetchInvalidation(entry);
|
|
233
|
+
const callbacks = entry.onInvalidateCallbacks;
|
|
234
|
+
entry.onInvalidateCallbacks = void 0;
|
|
235
|
+
if (callbacks === void 0) return;
|
|
236
|
+
for (const onInvalidate of callbacks) try {
|
|
237
|
+
onInvalidate();
|
|
238
|
+
} catch (error) {
|
|
239
|
+
if (typeof reportError === "function") reportError(error);
|
|
240
|
+
else console.error(error);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function deletePrefetchCacheEntry(cache, prefetched, cacheKey, entry, notify) {
|
|
244
|
+
cache.delete(cacheKey);
|
|
245
|
+
prefetched.delete(cacheKey);
|
|
246
|
+
if (notify) notifyPrefetchInvalidated(entry);
|
|
247
|
+
else {
|
|
248
|
+
clearPrefetchInvalidation(entry);
|
|
249
|
+
entry.onInvalidateCallbacks = void 0;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function invalidatePrefetchCacheEntry(cacheKey) {
|
|
253
|
+
const cache = getPrefetchCache();
|
|
254
|
+
const entry = cache.get(cacheKey);
|
|
255
|
+
if (!entry) return;
|
|
256
|
+
deletePrefetchCacheEntry(cache, getPrefetchedUrls(), cacheKey, entry, true);
|
|
257
|
+
}
|
|
258
|
+
function schedulePrefetchInvalidation(cacheKey, entry) {
|
|
259
|
+
if (entry.onInvalidateCallbacks === void 0 || entry.onInvalidateCallbacks.size === 0) return;
|
|
260
|
+
clearPrefetchInvalidation(entry);
|
|
261
|
+
const delay = Math.max(0, resolvePrefetchCacheEntryExpiresAt(entry) - Date.now());
|
|
262
|
+
entry.invalidationTimer = setTimeout(() => {
|
|
263
|
+
invalidatePrefetchCacheEntry(cacheKey);
|
|
264
|
+
}, delay);
|
|
265
|
+
}
|
|
266
|
+
function addPrefetchInvalidationCallback(entry, onInvalidate) {
|
|
267
|
+
if (onInvalidate === void 0) return;
|
|
268
|
+
if (entry.onInvalidateCallbacks === void 0) entry.onInvalidateCallbacks = /* @__PURE__ */ new Set();
|
|
269
|
+
entry.onInvalidateCallbacks.add(onInvalidate);
|
|
270
|
+
}
|
|
271
|
+
function attachPrefetchInvalidationCallback(cacheKey, onInvalidate) {
|
|
272
|
+
if (onInvalidate === void 0) return;
|
|
273
|
+
const entry = getPrefetchCache().get(cacheKey);
|
|
274
|
+
if (!entry) return;
|
|
275
|
+
addPrefetchInvalidationCallback(entry, onInvalidate);
|
|
276
|
+
if (entry.outcome === "cache-seeded") schedulePrefetchInvalidation(cacheKey, entry);
|
|
277
|
+
}
|
|
278
|
+
function invalidatePrefetchCache() {
|
|
279
|
+
const cache = getPrefetchCache();
|
|
280
|
+
const prefetched = getPrefetchedUrls();
|
|
281
|
+
for (const [cacheKey, entry] of cache) deletePrefetchCacheEntry(cache, prefetched, cacheKey, entry, true);
|
|
282
|
+
prefetched.clear();
|
|
283
|
+
if (!isServer) getNavigationRuntime()?.functions.pingVisibleLinks?.();
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Store a prefetched RSC response in the cache by snapshotting it to an
|
|
287
|
+
* ArrayBuffer. The snapshot completes asynchronously; during that window
|
|
288
|
+
* the entry is marked `pending` so consumePrefetchResponse() will skip it
|
|
289
|
+
* (the caller falls back to a fresh fetch, which is acceptable).
|
|
290
|
+
*
|
|
291
|
+
* Prefer prefetchRscResponse() for new call-sites — it handles the full
|
|
292
|
+
* prefetch lifecycle including dedup and explicit slot context.
|
|
293
|
+
* storePrefetchResponse() is kept for backward compatibility and test
|
|
294
|
+
* helpers. It is slot-unaware: the snapshot's mountedSlotsHeader comes
|
|
295
|
+
* from the response headers, not the caller, so consumePrefetchResponse
|
|
296
|
+
* may reject the entry if the caller's slot context differs.
|
|
297
|
+
*
|
|
298
|
+
* NB: Caller is responsible for managing getPrefetchedUrls() — this
|
|
299
|
+
* function only stores the response in the prefetch cache.
|
|
300
|
+
*/
|
|
301
|
+
function storePrefetchResponse(rscUrl, response, interceptionContext = null, options) {
|
|
302
|
+
const cacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);
|
|
303
|
+
evictPrefetchCacheIfNeeded();
|
|
304
|
+
const entry = {
|
|
305
|
+
mountedSlotsHeader: null,
|
|
306
|
+
outcome: "pending",
|
|
307
|
+
timestamp: Date.now()
|
|
308
|
+
};
|
|
309
|
+
addPrefetchInvalidationCallback(entry, options?.onInvalidate);
|
|
310
|
+
entry.pending = snapshotRscResponse(response).then((snapshot) => {
|
|
311
|
+
entry.mountedSlotsHeader = snapshot.mountedSlotsHeader ?? null;
|
|
312
|
+
entry.snapshot = snapshot;
|
|
313
|
+
entry.expiresAt = resolveCachedRscResponseExpiresAt(entry.timestamp, snapshot, PREFETCH_CACHE_TTL);
|
|
314
|
+
}).catch(() => {
|
|
315
|
+
deletePrefetchCacheEntry(getPrefetchCache(), getPrefetchedUrls(), cacheKey, entry, false);
|
|
316
|
+
}).finally(() => {
|
|
317
|
+
entry.pending = void 0;
|
|
318
|
+
if (entry.snapshot) {
|
|
319
|
+
entry.outcome = "cache-seeded";
|
|
320
|
+
schedulePrefetchInvalidation(cacheKey, entry);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
getPrefetchCache().set(cacheKey, entry);
|
|
324
|
+
}
|
|
325
|
+
function createCachedRscResponseSnapshot(response, buffer, responseUrl = null) {
|
|
326
|
+
const dynamicStaleTimeSeconds = parseDynamicStaleTimeSeconds(response.headers.get(VINEXT_DYNAMIC_STALE_TIME_HEADER));
|
|
327
|
+
return {
|
|
328
|
+
compatibilityIdHeader: response.headers.get(VINEXT_RSC_COMPATIBILITY_ID_HEADER),
|
|
329
|
+
buffer,
|
|
330
|
+
contentType: response.headers.get("content-type") ?? "text/x-component",
|
|
331
|
+
...dynamicStaleTimeSeconds !== void 0 ? { dynamicStaleTimeSeconds } : {},
|
|
332
|
+
mountedSlotsHeader: response.headers.get(VINEXT_MOUNTED_SLOTS_HEADER),
|
|
333
|
+
paramsHeader: response.headers.get(VINEXT_PARAMS_HEADER),
|
|
334
|
+
url: responseUrl ?? response.url
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Snapshot an RSC response to an ArrayBuffer for caching and replay.
|
|
339
|
+
* Consumes the response body and stores it with content-type and URL metadata.
|
|
340
|
+
*/
|
|
341
|
+
async function snapshotRscResponse(response) {
|
|
342
|
+
return createCachedRscResponseSnapshot(response, await response.arrayBuffer());
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Reconstruct a Response from a cached RSC snapshot.
|
|
346
|
+
* Creates a new Response with the original ArrayBuffer so createFromFetch
|
|
347
|
+
* can consume the stream from scratch.
|
|
348
|
+
*
|
|
349
|
+
* NOTE: The reconstructed Response always has `url === ""` — the Response
|
|
350
|
+
* constructor does not accept a `url` option, and `response.url` is read-only
|
|
351
|
+
* set by the fetch infrastructure. Callers that need the original URL should
|
|
352
|
+
* read it from `cached.url` directly rather than from the restored Response.
|
|
353
|
+
*
|
|
354
|
+
* @param copy - When true (default), copies the ArrayBuffer so the cached
|
|
355
|
+
* snapshot remains replayable (needed for the visited-response cache).
|
|
356
|
+
* Pass false for single-consumption paths (e.g. prefetch cache entries
|
|
357
|
+
* that are deleted after consumption) to avoid the extra allocation.
|
|
358
|
+
*/
|
|
359
|
+
function restoreRscResponse(cached, copy = true) {
|
|
360
|
+
const headers = new Headers({ "content-type": cached.contentType });
|
|
361
|
+
if (cached.mountedSlotsHeader != null) headers.set(VINEXT_MOUNTED_SLOTS_HEADER, cached.mountedSlotsHeader);
|
|
362
|
+
if (cached.compatibilityIdHeader != null) headers.set(VINEXT_RSC_COMPATIBILITY_ID_HEADER, cached.compatibilityIdHeader);
|
|
363
|
+
if (isDynamicStaleTimeSeconds(cached.dynamicStaleTimeSeconds)) headers.set(VINEXT_DYNAMIC_STALE_TIME_HEADER, String(cached.dynamicStaleTimeSeconds));
|
|
364
|
+
if (cached.paramsHeader != null) headers.set(VINEXT_PARAMS_HEADER, cached.paramsHeader);
|
|
365
|
+
return new Response(copy ? cached.buffer.slice(0) : cached.buffer, {
|
|
366
|
+
status: 200,
|
|
367
|
+
headers
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Prefetch an RSC response and snapshot it for later consumption.
|
|
372
|
+
* Stores the in-flight promise so immediate clicks can await it instead
|
|
373
|
+
* of firing a duplicate fetch.
|
|
374
|
+
* Enforces a maximum cache size to prevent unbounded memory growth on
|
|
375
|
+
* link-heavy pages.
|
|
376
|
+
*/
|
|
377
|
+
function prefetchRscResponse(rscUrl, fetchPromise, interceptionContext = null, mountedSlotsHeader = null, options, behavior = {}) {
|
|
378
|
+
const cacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);
|
|
379
|
+
const cache = getPrefetchCache();
|
|
380
|
+
const prefetched = getPrefetchedUrls();
|
|
381
|
+
const now = Date.now();
|
|
382
|
+
const entry = {
|
|
383
|
+
cacheForNavigation: behavior.cacheForNavigation ?? true,
|
|
384
|
+
mountedSlotsHeader,
|
|
385
|
+
optimisticRouteShell: behavior.optimisticRouteShell === true,
|
|
386
|
+
outcome: "pending",
|
|
387
|
+
timestamp: now
|
|
388
|
+
};
|
|
389
|
+
addPrefetchInvalidationCallback(entry, options?.onInvalidate);
|
|
390
|
+
entry.pending = fetchPromise.then(async (response) => {
|
|
391
|
+
if (response.ok) {
|
|
392
|
+
entry.snapshot = await snapshotRscResponse(response);
|
|
393
|
+
entry.expiresAt = resolveCachedRscResponseExpiresAt(entry.timestamp, entry.snapshot, PREFETCH_CACHE_TTL);
|
|
394
|
+
} else deletePrefetchCacheEntry(cache, prefetched, cacheKey, entry, false);
|
|
395
|
+
}).catch(() => {
|
|
396
|
+
deletePrefetchCacheEntry(cache, prefetched, cacheKey, entry, false);
|
|
397
|
+
}).finally(() => {
|
|
398
|
+
entry.pending = void 0;
|
|
399
|
+
if (entry.snapshot) {
|
|
400
|
+
entry.outcome = "cache-seeded";
|
|
401
|
+
schedulePrefetchInvalidation(cacheKey, entry);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
cache.set(cacheKey, entry);
|
|
405
|
+
evictPrefetchCacheIfNeeded();
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Consume a prefetched response for a given rscUrl.
|
|
409
|
+
* Only returns settled (non-pending) snapshots synchronously.
|
|
410
|
+
* Returns null if the entry is still in flight or doesn't exist.
|
|
411
|
+
*/
|
|
412
|
+
function consumePrefetchResponse(rscUrl, interceptionContext = null, mountedSlotsHeader = null) {
|
|
413
|
+
const cache = getPrefetchCache();
|
|
414
|
+
const exactCacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);
|
|
415
|
+
const exactEntry = cache.get(exactCacheKey);
|
|
416
|
+
if (exactEntry && exactEntry.cacheForNavigation !== false && !isPrefetchCacheEntryCompatibleWithMountedSlots(exactEntry, mountedSlotsHeader)) deletePrefetchCacheEntry(cache, getPrefetchedUrls(), exactCacheKey, exactEntry, false);
|
|
417
|
+
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader);
|
|
418
|
+
if (!match) return null;
|
|
419
|
+
const { cacheKey, entry } = match;
|
|
420
|
+
if (entry.pending || entry.outcome !== "cache-seeded") return null;
|
|
421
|
+
if (entry.cacheForNavigation === false) return null;
|
|
422
|
+
deletePrefetchCacheEntry(cache, getPrefetchedUrls(), cacheKey, entry, false);
|
|
423
|
+
if (entry.snapshot) {
|
|
424
|
+
if (!isPrefetchCacheEntryCompatibleWithMountedSlots(entry, mountedSlotsHeader)) return null;
|
|
425
|
+
if (resolvePrefetchCacheEntryExpiresAt(entry) <= Date.now()) return null;
|
|
426
|
+
if (entry.expiresAt !== void 0 || entry.snapshot.expiresAt !== void 0) return {
|
|
427
|
+
...entry.snapshot,
|
|
428
|
+
expiresAt: resolvePrefetchCacheEntryExpiresAt(entry)
|
|
429
|
+
};
|
|
430
|
+
return entry.snapshot;
|
|
431
|
+
}
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
async function consumePrefetchResponseForNavigation(rscUrl, interceptionContext = null, mountedSlotsHeader = null, options) {
|
|
435
|
+
const cache = getPrefetchCache();
|
|
436
|
+
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader);
|
|
437
|
+
if (!match) return null;
|
|
438
|
+
const { cacheKey, entry } = match;
|
|
439
|
+
if (entry.pending !== void 0) {
|
|
440
|
+
await entry.pending.catch(() => {});
|
|
441
|
+
if (cache.get(cacheKey) !== entry) return null;
|
|
442
|
+
}
|
|
443
|
+
if (options?.shouldConsume?.() === false) return null;
|
|
444
|
+
return consumePrefetchResponse(rscUrl, interceptionContext, mountedSlotsHeader);
|
|
445
|
+
}
|
|
446
|
+
const _CLIENT_NAV_STATE_KEY = Symbol.for("vinext.clientNavigationState");
|
|
447
|
+
const _MOUNTED_SLOTS_HEADER_KEY = Symbol.for("vinext.mountedSlotsHeader");
|
|
448
|
+
function setMountedSlotsHeader(header) {
|
|
449
|
+
if (isServer) return;
|
|
450
|
+
const globalState = window;
|
|
451
|
+
globalState[_MOUNTED_SLOTS_HEADER_KEY] = header;
|
|
452
|
+
}
|
|
453
|
+
function getMountedSlotsHeader() {
|
|
454
|
+
if (isServer) return null;
|
|
455
|
+
return window[_MOUNTED_SLOTS_HEADER_KEY] ?? null;
|
|
456
|
+
}
|
|
457
|
+
function getClientNavigationState() {
|
|
458
|
+
if (isServer) return null;
|
|
459
|
+
const globalState = window;
|
|
460
|
+
globalState[_CLIENT_NAV_STATE_KEY] ??= {
|
|
461
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
462
|
+
cachedSearch: window.location.search,
|
|
463
|
+
cachedReadonlySearchParams: new ReadonlyURLSearchParams(window.location.search),
|
|
464
|
+
cachedPathname: stripBasePath(window.location.pathname, __basePath),
|
|
465
|
+
clientParams: {},
|
|
466
|
+
clientParamsJson: "{}",
|
|
467
|
+
pendingClientParams: null,
|
|
468
|
+
pendingClientParamsJson: null,
|
|
469
|
+
pendingPathname: null,
|
|
470
|
+
pendingPathnameNavId: null,
|
|
471
|
+
originalPushState: window.history.pushState.bind(window.history),
|
|
472
|
+
originalReplaceState: window.history.replaceState.bind(window.history),
|
|
473
|
+
patchInstalled: false,
|
|
474
|
+
hasPendingNavigationUpdate: false,
|
|
475
|
+
suppressUrlNotifyCount: 0,
|
|
476
|
+
navigationSnapshotActiveCount: 0
|
|
477
|
+
};
|
|
478
|
+
return globalState[_CLIENT_NAV_STATE_KEY];
|
|
479
|
+
}
|
|
480
|
+
function notifyNavigationListeners() {
|
|
481
|
+
const state = getClientNavigationState();
|
|
482
|
+
if (!state) return;
|
|
483
|
+
for (const fn of state.listeners) fn();
|
|
484
|
+
}
|
|
485
|
+
if (!isServer) globalThis[PAGES_NAVIGATION_NOTIFY_KEY] = notifyNavigationListeners;
|
|
486
|
+
let _cachedEmptyServerSearchParams = null;
|
|
487
|
+
const _readonlyPagesSearchParamsCache = /* @__PURE__ */ new WeakMap();
|
|
488
|
+
let _cachedReadonlyPagesSearchParamsKey = null;
|
|
489
|
+
let _cachedReadonlyPagesSearchParams = null;
|
|
490
|
+
function getReadonlyPagesSearchParams(searchParams) {
|
|
491
|
+
const cached = _readonlyPagesSearchParamsCache.get(searchParams);
|
|
492
|
+
if (cached) return cached;
|
|
493
|
+
const key = searchParams.toString();
|
|
494
|
+
if (_cachedReadonlyPagesSearchParamsKey === key && _cachedReadonlyPagesSearchParams) {
|
|
495
|
+
_readonlyPagesSearchParamsCache.set(searchParams, _cachedReadonlyPagesSearchParams);
|
|
496
|
+
return _cachedReadonlyPagesSearchParams;
|
|
497
|
+
}
|
|
498
|
+
const readonly = new ReadonlyURLSearchParams(searchParams);
|
|
499
|
+
_readonlyPagesSearchParamsCache.set(searchParams, readonly);
|
|
500
|
+
_cachedReadonlyPagesSearchParamsKey = key;
|
|
501
|
+
_cachedReadonlyPagesSearchParams = readonly;
|
|
502
|
+
return readonly;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Get cached pathname snapshot for useSyncExternalStore.
|
|
506
|
+
* Note: Returns cached value from ClientNavigationState, not live window.location.
|
|
507
|
+
* The cache is updated by syncCommittedUrlStateFromLocation() after navigation commits.
|
|
508
|
+
* This ensures referential stability and prevents infinite re-renders.
|
|
509
|
+
* External pushState/replaceState while URL notifications are suppressed won't
|
|
510
|
+
* be visible until the next commit.
|
|
511
|
+
*/
|
|
512
|
+
function getPathnameSnapshot() {
|
|
513
|
+
const pagesCtx = getPagesNavigationContext();
|
|
514
|
+
if (pagesCtx) return pagesCtx.pathname;
|
|
515
|
+
return getClientNavigationState()?.cachedPathname ?? "/";
|
|
516
|
+
}
|
|
517
|
+
let _cachedEmptyClientSearchParams = null;
|
|
518
|
+
/**
|
|
519
|
+
* Get cached search params snapshot for useSyncExternalStore.
|
|
520
|
+
* Note: Returns cached value from ClientNavigationState, not live window.location.search.
|
|
521
|
+
* The cache is updated by syncCommittedUrlStateFromLocation() after navigation commits.
|
|
522
|
+
* This ensures referential stability and prevents infinite re-renders.
|
|
523
|
+
* External pushState/replaceState while URL notifications are suppressed won't
|
|
524
|
+
* be visible until the next commit.
|
|
525
|
+
*/
|
|
526
|
+
function getSearchParamsSnapshot() {
|
|
527
|
+
if (getNavigationContext()) return getServerSearchParamsSnapshot();
|
|
528
|
+
const pagesCtx = getPagesNavigationContext();
|
|
529
|
+
if (pagesCtx) return getReadonlyPagesSearchParams(pagesCtx.searchParams);
|
|
530
|
+
const cached = getClientNavigationState()?.cachedReadonlySearchParams;
|
|
531
|
+
if (cached) return cached;
|
|
532
|
+
if (_cachedEmptyClientSearchParams === null) _cachedEmptyClientSearchParams = new ReadonlyURLSearchParams();
|
|
533
|
+
return _cachedEmptyClientSearchParams;
|
|
534
|
+
}
|
|
535
|
+
function syncCommittedUrlStateFromLocation() {
|
|
536
|
+
const state = getClientNavigationState();
|
|
537
|
+
if (!state) return false;
|
|
538
|
+
let changed = false;
|
|
539
|
+
const pathname = stripBasePath(window.location.pathname, __basePath);
|
|
540
|
+
if (pathname !== state.cachedPathname) {
|
|
541
|
+
state.cachedPathname = pathname;
|
|
542
|
+
changed = true;
|
|
543
|
+
}
|
|
544
|
+
const search = window.location.search;
|
|
545
|
+
if (search !== state.cachedSearch) {
|
|
546
|
+
state.cachedSearch = search;
|
|
547
|
+
state.cachedReadonlySearchParams = new ReadonlyURLSearchParams(search);
|
|
548
|
+
changed = true;
|
|
549
|
+
}
|
|
550
|
+
return changed;
|
|
551
|
+
}
|
|
552
|
+
function getServerSearchParamsSnapshot() {
|
|
553
|
+
const ctx = getNavigationContext();
|
|
554
|
+
if (!ctx) {
|
|
555
|
+
const pagesCtx = getPagesNavigationContext();
|
|
556
|
+
if (pagesCtx) return getReadonlyPagesSearchParams(pagesCtx.searchParams);
|
|
557
|
+
if (_cachedEmptyServerSearchParams === null) _cachedEmptyServerSearchParams = new ReadonlyURLSearchParams();
|
|
558
|
+
return _cachedEmptyServerSearchParams;
|
|
559
|
+
}
|
|
560
|
+
const source = ctx.searchParams;
|
|
561
|
+
const cached = ctx[_READONLY_SEARCH_PARAMS];
|
|
562
|
+
const cachedSource = ctx[_READONLY_SEARCH_PARAMS_SOURCE];
|
|
563
|
+
if (cached && cachedSource === source) return cached;
|
|
564
|
+
const sourceKey = source.toString();
|
|
565
|
+
if (cached && ctx[_READONLY_SEARCH_PARAMS_SOURCE_KEY] === sourceKey) {
|
|
566
|
+
ctx[_READONLY_SEARCH_PARAMS_SOURCE] = source;
|
|
567
|
+
return cached;
|
|
568
|
+
}
|
|
569
|
+
const readonly = new ReadonlyURLSearchParams(source);
|
|
570
|
+
ctx[_READONLY_SEARCH_PARAMS] = readonly;
|
|
571
|
+
ctx[_READONLY_SEARCH_PARAMS_SOURCE] = source;
|
|
572
|
+
ctx[_READONLY_SEARCH_PARAMS_SOURCE_KEY] = sourceKey;
|
|
573
|
+
return readonly;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Mark a navigation snapshot as active. Called before startTransition
|
|
577
|
+
* in renderNavigationPayload. While active, hooks prefer the snapshot
|
|
578
|
+
* context value over useSyncExternalStore. Uses a counter (not boolean)
|
|
579
|
+
* to handle overlapping navigations — rapid clicks can interleave
|
|
580
|
+
* activate/deactivate if multiple transitions are in flight.
|
|
581
|
+
*/
|
|
582
|
+
function activateNavigationSnapshot() {
|
|
583
|
+
const state = getClientNavigationState();
|
|
584
|
+
if (state) state.navigationSnapshotActiveCount++;
|
|
585
|
+
}
|
|
586
|
+
const _EMPTY_PARAMS = {};
|
|
587
|
+
const _CLIENT_NAV_RENDER_CTX_KEY = Symbol.for("vinext.clientNavigationRenderContext");
|
|
588
|
+
function getClientNavigationRenderContext() {
|
|
589
|
+
if (typeof React$1.createContext !== "function") return null;
|
|
590
|
+
const globalState = globalThis;
|
|
591
|
+
if (!globalState[_CLIENT_NAV_RENDER_CTX_KEY]) globalState[_CLIENT_NAV_RENDER_CTX_KEY] = React$1.createContext(null);
|
|
592
|
+
return globalState[_CLIENT_NAV_RENDER_CTX_KEY] ?? null;
|
|
593
|
+
}
|
|
594
|
+
/** @internal */
|
|
595
|
+
function useClientNavigationRenderSnapshot() {
|
|
596
|
+
const ctx = getClientNavigationRenderContext();
|
|
597
|
+
if (!ctx || typeof React$1.useContext !== "function") return null;
|
|
598
|
+
try {
|
|
599
|
+
return React$1.useContext(ctx);
|
|
600
|
+
} catch {
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
function createClientNavigationRenderSnapshot(href, params) {
|
|
605
|
+
const origin = typeof window !== "undefined" ? window.location.origin : "http://localhost";
|
|
606
|
+
const url = new URL(href, origin);
|
|
607
|
+
return {
|
|
608
|
+
pathname: stripBasePath(url.pathname, __basePath),
|
|
609
|
+
searchParams: new ReadonlyURLSearchParams(url.search),
|
|
610
|
+
params
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function createSnapshotPathAndSearch(snapshot) {
|
|
614
|
+
const query = snapshot.searchParams.toString();
|
|
615
|
+
return query === "" ? snapshot.pathname : `${snapshot.pathname}?${query}`;
|
|
616
|
+
}
|
|
617
|
+
let _fallbackClientParams = _EMPTY_PARAMS;
|
|
618
|
+
let _fallbackClientParamsJson = "{}";
|
|
619
|
+
function setClientParams(params) {
|
|
620
|
+
const state = getClientNavigationState();
|
|
621
|
+
if (!state) {
|
|
622
|
+
const json = JSON.stringify(params);
|
|
623
|
+
if (json !== _fallbackClientParamsJson) {
|
|
624
|
+
_fallbackClientParams = params;
|
|
625
|
+
_fallbackClientParamsJson = json;
|
|
626
|
+
}
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
const json = JSON.stringify(params);
|
|
630
|
+
if (json !== state.clientParamsJson) {
|
|
631
|
+
state.clientParams = params;
|
|
632
|
+
state.clientParamsJson = json;
|
|
633
|
+
state.pendingClientParams = null;
|
|
634
|
+
state.pendingClientParamsJson = null;
|
|
635
|
+
notifyNavigationListeners();
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
function replaceClientParamsWithoutNotify(params) {
|
|
639
|
+
const state = getClientNavigationState();
|
|
640
|
+
if (!state) return;
|
|
641
|
+
const json = JSON.stringify(params);
|
|
642
|
+
if (json !== state.clientParamsJson && json !== state.pendingClientParamsJson) {
|
|
643
|
+
state.pendingClientParams = params;
|
|
644
|
+
state.pendingClientParamsJson = json;
|
|
645
|
+
state.hasPendingNavigationUpdate = true;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
/** Get the current client params (for testing referential stability). */
|
|
649
|
+
function getClientParams() {
|
|
650
|
+
return getClientNavigationState()?.clientParams ?? _fallbackClientParams;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Set the pending pathname for client-side navigation.
|
|
654
|
+
* Strips the base path before storing. Associates the pathname with the given navId
|
|
655
|
+
* so only that navigation (or a newer one) can clear it.
|
|
656
|
+
*/
|
|
657
|
+
function setPendingPathname(pathname, navId) {
|
|
658
|
+
const state = getClientNavigationState();
|
|
659
|
+
if (!state) return;
|
|
660
|
+
state.pendingPathname = stripBasePath(pathname, __basePath);
|
|
661
|
+
state.pendingPathnameNavId = navId;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Clear the pending pathname, but only if the given navId matches the one
|
|
665
|
+
* that set it, or if pendingPathnameNavId is null (no active owner).
|
|
666
|
+
* This prevents superseded navigations from clearing state belonging to newer navigations.
|
|
667
|
+
*/
|
|
668
|
+
function clearPendingPathname(navId) {
|
|
669
|
+
const state = getClientNavigationState();
|
|
670
|
+
if (!state) return;
|
|
671
|
+
if (state.pendingPathnameNavId === null || state.pendingPathnameNavId === navId) {
|
|
672
|
+
state.pendingPathname = null;
|
|
673
|
+
state.pendingPathnameNavId = null;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
function getClientParamsSnapshot() {
|
|
677
|
+
const state = getClientNavigationState();
|
|
678
|
+
const ctx = getNavigationContext();
|
|
679
|
+
if (ctx) return ctx.params;
|
|
680
|
+
const pagesCtx = getPagesNavigationContext();
|
|
681
|
+
if (pagesCtx) return pagesCtx.params;
|
|
682
|
+
return state?.clientParams ?? _EMPTY_PARAMS;
|
|
683
|
+
}
|
|
684
|
+
function getServerParamsSnapshot() {
|
|
685
|
+
const ctx = getNavigationContext();
|
|
686
|
+
if (ctx) return ctx.params;
|
|
687
|
+
const pagesCtx = getPagesNavigationContext();
|
|
688
|
+
if (pagesCtx) return pagesCtx.params;
|
|
689
|
+
return _EMPTY_PARAMS;
|
|
690
|
+
}
|
|
691
|
+
function subscribeToNavigation(cb) {
|
|
692
|
+
const state = getClientNavigationState();
|
|
693
|
+
if (!state) return () => {};
|
|
694
|
+
state.listeners.add(cb);
|
|
695
|
+
return () => {
|
|
696
|
+
state.listeners.delete(cb);
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Returns the current pathname.
|
|
701
|
+
* Server: from request context. Client: from window.location.
|
|
702
|
+
*/
|
|
703
|
+
function usePathname() {
|
|
704
|
+
if (isServer) {
|
|
705
|
+
markPprFallbackShellDynamicBoundary();
|
|
706
|
+
const ctx = getNavigationContext();
|
|
707
|
+
if (ctx) return ctx.pathname;
|
|
708
|
+
const pagesCtx = getPagesNavigationContext();
|
|
709
|
+
return pagesCtx ? pagesCtx.pathname : "/";
|
|
710
|
+
}
|
|
711
|
+
const renderSnapshot = useClientNavigationRenderSnapshot();
|
|
712
|
+
const pathname = React$1.useSyncExternalStore(subscribeToNavigation, getPathnameSnapshot, () => {
|
|
713
|
+
const ctx = getNavigationContext();
|
|
714
|
+
if (ctx) return ctx.pathname;
|
|
715
|
+
const pagesCtx = getPagesNavigationContext();
|
|
716
|
+
return pagesCtx ? pagesCtx.pathname : "/";
|
|
717
|
+
});
|
|
718
|
+
if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.pathname;
|
|
719
|
+
return pathname;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Returns the current search params as a read-only URLSearchParams.
|
|
723
|
+
*/
|
|
724
|
+
function useSearchParams() {
|
|
725
|
+
if (isServer) {
|
|
726
|
+
markPprFallbackShellDynamicBoundary();
|
|
727
|
+
return getServerSearchParamsSnapshot();
|
|
728
|
+
}
|
|
729
|
+
const renderSnapshot = useClientNavigationRenderSnapshot();
|
|
730
|
+
const searchParams = React$1.useSyncExternalStore(subscribeToNavigation, getSearchParamsSnapshot, getServerSearchParamsSnapshot);
|
|
731
|
+
if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.searchParams;
|
|
732
|
+
return searchParams;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Returns the dynamic params for the current route.
|
|
736
|
+
*/
|
|
737
|
+
function useParams() {
|
|
738
|
+
if (isServer) {
|
|
739
|
+
markPprFallbackShellDynamicBoundary();
|
|
740
|
+
return getServerParamsSnapshot();
|
|
741
|
+
}
|
|
742
|
+
const renderSnapshot = useClientNavigationRenderSnapshot();
|
|
743
|
+
const params = React$1.useSyncExternalStore(subscribeToNavigation, getClientParamsSnapshot, getServerParamsSnapshot);
|
|
744
|
+
if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.params;
|
|
745
|
+
return params;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Check if a href is an external URL (any URL scheme per RFC 3986, or protocol-relative).
|
|
749
|
+
*/
|
|
750
|
+
function isExternalUrl(href) {
|
|
751
|
+
return isAbsoluteOrProtocolRelativeUrl(href);
|
|
752
|
+
}
|
|
753
|
+
function withSuppressedUrlNotifications(fn) {
|
|
754
|
+
const state = getClientNavigationState();
|
|
755
|
+
if (!state) return fn();
|
|
756
|
+
state.suppressUrlNotifyCount += 1;
|
|
757
|
+
try {
|
|
758
|
+
return fn();
|
|
759
|
+
} finally {
|
|
760
|
+
state.suppressUrlNotifyCount -= 1;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Commit pending client navigation state to committed snapshots.
|
|
765
|
+
*
|
|
766
|
+
* navId is optional: callers that don't own pendingPathname (for example,
|
|
767
|
+
* superseded pre-paint cleanup) may pass undefined to flush URL/params state
|
|
768
|
+
* without clearing pendingPathname owned by the active navigation. Such callers
|
|
769
|
+
* must opt in explicitly if they also own an activated render snapshot.
|
|
770
|
+
*/
|
|
771
|
+
function commitClientNavigationState(navId, options) {
|
|
772
|
+
if (isServer) return;
|
|
773
|
+
const state = getClientNavigationState();
|
|
774
|
+
if (!state) return;
|
|
775
|
+
if ((navId !== void 0 || options?.releaseSnapshot === true) && state.navigationSnapshotActiveCount > 0) state.navigationSnapshotActiveCount -= 1;
|
|
776
|
+
const urlChanged = syncCommittedUrlStateFromLocation();
|
|
777
|
+
let paramsChanged = false;
|
|
778
|
+
if (state.pendingClientParams !== null && state.pendingClientParamsJson !== null) {
|
|
779
|
+
state.clientParams = state.pendingClientParams;
|
|
780
|
+
state.clientParamsJson = state.pendingClientParamsJson;
|
|
781
|
+
state.pendingClientParams = null;
|
|
782
|
+
state.pendingClientParamsJson = null;
|
|
783
|
+
paramsChanged = true;
|
|
784
|
+
}
|
|
785
|
+
if (state.pendingPathnameNavId === null || navId !== void 0 && state.pendingPathnameNavId === navId) {
|
|
786
|
+
state.pendingPathname = null;
|
|
787
|
+
state.pendingPathnameNavId = null;
|
|
788
|
+
}
|
|
789
|
+
const shouldNotify = urlChanged || state.hasPendingNavigationUpdate;
|
|
790
|
+
state.hasPendingNavigationUpdate = false;
|
|
791
|
+
if (urlChanged || paramsChanged) clearClientHydrationContext();
|
|
792
|
+
if (shouldNotify) notifyNavigationListeners();
|
|
793
|
+
}
|
|
794
|
+
function pushHistoryStateWithoutNotify(data, unused, url) {
|
|
795
|
+
withSuppressedUrlNotifications(() => {
|
|
796
|
+
getClientNavigationState()?.originalPushState.call(window.history, data, unused, url);
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
function replaceHistoryStateWithoutNotify(data, unused, url) {
|
|
800
|
+
withSuppressedUrlNotifications(() => {
|
|
801
|
+
getClientNavigationState()?.originalReplaceState.call(window.history, data, unused, url);
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Save the current scroll position into the current history state.
|
|
806
|
+
* Called before every navigation to enable scroll restoration on back/forward.
|
|
807
|
+
*
|
|
808
|
+
* Uses replaceHistoryStateWithoutNotify to avoid triggering the patched
|
|
809
|
+
* history.replaceState interception (which would cause spurious re-renders).
|
|
810
|
+
*/
|
|
811
|
+
function saveScrollPosition() {
|
|
812
|
+
replaceHistoryStateWithoutNotify({
|
|
813
|
+
...window.history.state ?? {},
|
|
814
|
+
__vinext_scrollX: window.scrollX,
|
|
815
|
+
__vinext_scrollY: window.scrollY
|
|
816
|
+
}, "");
|
|
817
|
+
}
|
|
818
|
+
function commitHashOnlyHistoryState(href, mode, scroll) {
|
|
819
|
+
const commitAppRouterHashNavigation = getNavigationRuntime()?.functions.commitHashNavigation;
|
|
820
|
+
if (commitAppRouterHashNavigation) {
|
|
821
|
+
commitAppRouterHashNavigation(href, mode, scroll);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
const historyState = createHashOnlyHistoryStatePreservingNavigationMetadata(window.history.state);
|
|
825
|
+
if (mode === "replace") replaceHistoryStateWithoutNotify(historyState, "", href);
|
|
826
|
+
else pushHistoryStateWithoutNotify(historyState, "", href);
|
|
827
|
+
}
|
|
828
|
+
function applyAppRouterScrollFallback(intent) {
|
|
829
|
+
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
830
|
+
if (intent.hash !== null) {
|
|
831
|
+
scrollToHashTarget(intent.hash);
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
if (intent.targetHoistedInHead) return;
|
|
835
|
+
document.documentElement.scrollTop = 0;
|
|
836
|
+
}
|
|
837
|
+
function scheduleAppRouterScrollFallback(intent) {
|
|
838
|
+
queueMicrotask(() => {
|
|
839
|
+
const pendingIntent = getPendingAppRouterScrollIntent();
|
|
840
|
+
if (pendingIntent === null || pendingIntent.id !== intent.id) return;
|
|
841
|
+
const fallbackIntent = consumeAppRouterScrollIntent(intent);
|
|
842
|
+
if (fallbackIntent) applyAppRouterScrollFallback(fallbackIntent);
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Restore scroll position from a history state object (used on popstate).
|
|
847
|
+
*
|
|
848
|
+
* When an RSC navigation is in flight (back/forward triggers both this
|
|
849
|
+
* handler and the browser entry's popstate handler which calls the registered
|
|
850
|
+
* navigation runtime), we must wait for the new content to render
|
|
851
|
+
* before scrolling. Otherwise the user sees old content flash at the
|
|
852
|
+
* restored scroll position.
|
|
853
|
+
*
|
|
854
|
+
* This handler fires before the browser entry's popstate handler (because
|
|
855
|
+
* navigation.ts is loaded before hydration completes), so we defer via a
|
|
856
|
+
* microtask to give the browser entry handler a chance to set
|
|
857
|
+
* __VINEXT_RSC_PENDING__. Promise.resolve() schedules a microtask
|
|
858
|
+
* that runs after all synchronous event listeners have completed.
|
|
859
|
+
*/
|
|
860
|
+
function restoreScrollPosition(state) {
|
|
861
|
+
if (state && typeof state === "object" && "__vinext_scrollY" in state) {
|
|
862
|
+
const { __vinext_scrollX: x, __vinext_scrollY: y } = state;
|
|
863
|
+
Promise.resolve().then(() => {
|
|
864
|
+
const pending = window.__VINEXT_RSC_PENDING__ ?? null;
|
|
865
|
+
if (pending) pending.then(() => retryScrollTo(x, y));
|
|
866
|
+
else retryScrollTo(x, y);
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Hard-navigate to a URL via `window.location`, preserving push/replace
|
|
872
|
+
* semantics. Used for URLs the App Router cannot serve (Pages-owned
|
|
873
|
+
* targets in a hybrid build) and for catch-all RSC failures.
|
|
874
|
+
*/
|
|
875
|
+
function hardNavigateTo(fullHref, mode) {
|
|
876
|
+
if (mode === "replace") window.location.replace(fullHref);
|
|
877
|
+
else window.location.assign(fullHref);
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.
|
|
881
|
+
*/
|
|
882
|
+
async function navigateClientSide(href, mode, scroll, programmaticTransition = false, visibleCommitMode = "transition") {
|
|
883
|
+
getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
|
|
884
|
+
let normalizedHref = href;
|
|
885
|
+
if (isExternalUrl(href)) {
|
|
886
|
+
const localPath = toSameOriginAppPath(href, __basePath);
|
|
887
|
+
if (localPath == null) {
|
|
888
|
+
notifyAppRouterTransitionStart(href, mode);
|
|
889
|
+
const externalNavigate = getNavigationRuntime()?.functions.navigateExternal;
|
|
890
|
+
if (externalNavigate) {
|
|
891
|
+
await externalNavigate(href, mode);
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
hardNavigateTo(href, mode);
|
|
895
|
+
await new Promise(() => {});
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
normalizedHref = localPath;
|
|
899
|
+
}
|
|
900
|
+
const hybridOwner = resolveHybridClientRouteOwner(normalizedHref, __basePath);
|
|
901
|
+
if (hybridOwner === "pages" || hybridOwner === "document") {
|
|
902
|
+
const fullHref = toBrowserNavigationHref(normalizedHref, window.location.href, __basePath);
|
|
903
|
+
notifyAppRouterTransitionStart(fullHref, mode);
|
|
904
|
+
if (mode === "push") saveScrollPosition();
|
|
905
|
+
hardNavigateTo(fullHref, mode);
|
|
906
|
+
await new Promise(() => {});
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
const fullHref = toBrowserNavigationHref(normalizedHref, window.location.href, __basePath);
|
|
910
|
+
stageAppNavigationFailureTarget(fullHref);
|
|
911
|
+
notifyAppRouterTransitionStart(fullHref, mode);
|
|
912
|
+
if (mode === "push") saveScrollPosition();
|
|
913
|
+
const earlyIntent = navigationPlanner.classifyEarlyNavigationIntent({
|
|
914
|
+
basePath: __basePath,
|
|
915
|
+
currentHref: window.location.href,
|
|
916
|
+
mode,
|
|
917
|
+
scroll,
|
|
918
|
+
targetHref: fullHref
|
|
919
|
+
});
|
|
920
|
+
if (earlyIntent.kind === "sameDocumentScroll") {
|
|
921
|
+
clearAppRouterScrollIntent();
|
|
922
|
+
commitHashOnlyHistoryState(fullHref, earlyIntent.mode, earlyIntent.scroll);
|
|
923
|
+
clearAppNavigationFailureTarget(fullHref);
|
|
924
|
+
commitClientNavigationState();
|
|
925
|
+
if (earlyIntent.scroll) scrollToHashTarget(earlyIntent.hash);
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
if (hasPendingAppRouterPageRedirect(typeof document === "undefined" ? void 0 : document)) {
|
|
929
|
+
const mpaNavigate = getNavigationRuntime()?.functions.navigateExternal;
|
|
930
|
+
if (mpaNavigate) {
|
|
931
|
+
await mpaNavigate(fullHref, mode);
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
hardNavigateTo(fullHref, mode);
|
|
935
|
+
await new Promise(() => {});
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
const hashIdx = fullHref.indexOf("#");
|
|
939
|
+
const hash = hashIdx !== -1 ? fullHref.slice(hashIdx) : "";
|
|
940
|
+
const scrollIntent = scroll ? beginAppRouterScrollIntent(hash || null) : null;
|
|
941
|
+
if (!scroll) clearAppRouterScrollIntent();
|
|
942
|
+
const appNavigate = getNavigationRuntime()?.functions.navigate;
|
|
943
|
+
try {
|
|
944
|
+
if (appNavigate) await appNavigate(fullHref, 0, "navigate", mode, void 0, programmaticTransition, void 0, scrollIntent, visibleCommitMode);
|
|
945
|
+
else {
|
|
946
|
+
if (mode === "replace") replaceHistoryStateWithoutNotify(null, "", fullHref);
|
|
947
|
+
else pushHistoryStateWithoutNotify(null, "", fullHref);
|
|
948
|
+
commitClientNavigationState();
|
|
949
|
+
}
|
|
950
|
+
} catch (error) {
|
|
951
|
+
if (scrollIntent) consumeAppRouterScrollIntent(scrollIntent);
|
|
952
|
+
throw error;
|
|
953
|
+
}
|
|
954
|
+
if (scrollIntent) scheduleAppRouterScrollFallback(scrollIntent);
|
|
955
|
+
}
|
|
956
|
+
let scheduledAppRouterNavigationCount = 0;
|
|
957
|
+
function trackScheduledAppRouterNavigation() {
|
|
958
|
+
scheduledAppRouterNavigationCount += 1;
|
|
959
|
+
let released = false;
|
|
960
|
+
return () => {
|
|
961
|
+
if (released) return;
|
|
962
|
+
released = true;
|
|
963
|
+
scheduledAppRouterNavigationCount = Math.max(0, scheduledAppRouterNavigationCount - 1);
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
function hasScheduledAppRouterNavigation() {
|
|
967
|
+
return scheduledAppRouterNavigationCount > 0;
|
|
968
|
+
}
|
|
969
|
+
function releaseScheduledAppRouterNavigationAfterCurrentTask(release) {
|
|
970
|
+
queueMicrotask(release);
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* App Router public router instance. Mirrors Next.js's
|
|
974
|
+
* `publicAppRouterInstance` from
|
|
975
|
+
* `packages/next/src/client/components/app-router-instance.ts`.
|
|
976
|
+
*
|
|
977
|
+
* Exported so the App Router browser entry can install it on
|
|
978
|
+
* `window.next.router` for Next.js parity (see `client/window-next.ts`).
|
|
979
|
+
* Internal callers in this file continue to use `_appRouter` for brevity.
|
|
980
|
+
*/
|
|
981
|
+
const _appRouter = {
|
|
982
|
+
bfcacheId: "0",
|
|
983
|
+
push(href, options) {
|
|
984
|
+
assertSafeNavigationUrl(href);
|
|
985
|
+
if (isServer) return;
|
|
986
|
+
getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
|
|
987
|
+
const releaseNavigation = trackScheduledAppRouterNavigation();
|
|
988
|
+
try {
|
|
989
|
+
React$1.startTransition(() => {
|
|
990
|
+
navigateClientSide(href, "push", options?.scroll !== false, true);
|
|
991
|
+
});
|
|
992
|
+
} catch (error) {
|
|
993
|
+
releaseNavigation();
|
|
994
|
+
throw error;
|
|
995
|
+
}
|
|
996
|
+
releaseScheduledAppRouterNavigationAfterCurrentTask(releaseNavigation);
|
|
997
|
+
},
|
|
998
|
+
replace(href, options) {
|
|
999
|
+
assertSafeNavigationUrl(href);
|
|
1000
|
+
if (isServer) return;
|
|
1001
|
+
getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
|
|
1002
|
+
const releaseNavigation = trackScheduledAppRouterNavigation();
|
|
1003
|
+
try {
|
|
1004
|
+
React$1.startTransition(() => {
|
|
1005
|
+
navigateClientSide(href, "replace", options?.scroll !== false, true);
|
|
1006
|
+
});
|
|
1007
|
+
} catch (error) {
|
|
1008
|
+
releaseNavigation();
|
|
1009
|
+
throw error;
|
|
1010
|
+
}
|
|
1011
|
+
releaseScheduledAppRouterNavigationAfterCurrentTask(releaseNavigation);
|
|
1012
|
+
},
|
|
1013
|
+
back() {
|
|
1014
|
+
if (isServer) return;
|
|
1015
|
+
window.history.back();
|
|
1016
|
+
},
|
|
1017
|
+
forward() {
|
|
1018
|
+
if (isServer) return;
|
|
1019
|
+
window.history.forward();
|
|
1020
|
+
},
|
|
1021
|
+
refresh() {
|
|
1022
|
+
if (isServer) return;
|
|
1023
|
+
getNavigationRuntime()?.functions.clearNavigationCaches?.();
|
|
1024
|
+
if (hasScheduledAppRouterNavigation()) return;
|
|
1025
|
+
const rscNavigate = getNavigationRuntime()?.functions.navigate;
|
|
1026
|
+
if (rscNavigate) {
|
|
1027
|
+
const navigate = () => {
|
|
1028
|
+
rscNavigate(window.location.href, 0, "refresh", void 0, void 0, true);
|
|
1029
|
+
};
|
|
1030
|
+
React$1.startTransition(navigate);
|
|
1031
|
+
}
|
|
1032
|
+
},
|
|
1033
|
+
prefetch(href, options) {
|
|
1034
|
+
assertSafeNavigationUrl(href);
|
|
1035
|
+
if (isServer) return;
|
|
1036
|
+
try {
|
|
1037
|
+
new URL(withBasePath(href, __basePath), window.location.href);
|
|
1038
|
+
} catch {
|
|
1039
|
+
throw new Error(`Cannot prefetch '${href}' because it cannot be converted to a URL.`);
|
|
1040
|
+
}
|
|
1041
|
+
(async () => {
|
|
1042
|
+
let prefetchHref = href;
|
|
1043
|
+
if (isAbsoluteOrProtocolRelativeUrl(href)) {
|
|
1044
|
+
const localPath = toSameOriginAppPath(href, __basePath);
|
|
1045
|
+
if (localPath == null) return;
|
|
1046
|
+
prefetchHref = localPath;
|
|
1047
|
+
}
|
|
1048
|
+
const hybridOwner = resolveHybridClientRouteOwner(prefetchHref, __basePath);
|
|
1049
|
+
if (hybridOwner === "pages" || hybridOwner === "document") return;
|
|
1050
|
+
const fullHref = toBrowserNavigationHref(prefetchHref, window.location.href, __basePath);
|
|
1051
|
+
const interceptionContext = getPrefetchInterceptionContext(fullHref);
|
|
1052
|
+
const mountedSlotsHeader = getMountedSlotsHeader();
|
|
1053
|
+
const headers = createRscRequestHeaders({ interceptionContext });
|
|
1054
|
+
if (mountedSlotsHeader) headers.set(VINEXT_MOUNTED_SLOTS_HEADER, mountedSlotsHeader);
|
|
1055
|
+
const rscUrl = await createRscRequestUrl(fullHref, headers);
|
|
1056
|
+
const cacheKey = AppElementsWire.encodeCacheKey(rscUrl, interceptionContext);
|
|
1057
|
+
const prefetched = getPrefetchedUrls();
|
|
1058
|
+
if (prefetched.has(cacheKey)) {
|
|
1059
|
+
attachPrefetchInvalidationCallback(cacheKey, options?.onInvalidate);
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
prefetched.add(cacheKey);
|
|
1063
|
+
prefetchRscResponse(rscUrl, fetch(rscUrl, {
|
|
1064
|
+
headers,
|
|
1065
|
+
credentials: "include",
|
|
1066
|
+
priority: "low"
|
|
1067
|
+
}), interceptionContext, mountedSlotsHeader, options);
|
|
1068
|
+
})().catch((error) => {
|
|
1069
|
+
console.error("[vinext] RSC prefetch setup error:", error);
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
if (process.env.__NEXT_GESTURE_TRANSITION) _appRouter.experimental_gesturePush = (href, options) => {
|
|
1074
|
+
assertSafeNavigationUrl(href);
|
|
1075
|
+
if (isServer) return;
|
|
1076
|
+
if (!getNavigationRuntime()?.functions.navigate) return;
|
|
1077
|
+
let appHref = href;
|
|
1078
|
+
if (isAbsoluteOrProtocolRelativeUrl(href)) {
|
|
1079
|
+
const localPath = toSameOriginAppPath(href, __basePath);
|
|
1080
|
+
if (localPath === null) return;
|
|
1081
|
+
appHref = localPath;
|
|
1082
|
+
}
|
|
1083
|
+
const releaseNavigation = trackScheduledAppRouterNavigation();
|
|
1084
|
+
navigateClientSide(appHref, "push", options?.scroll !== false, false, "synchronous");
|
|
1085
|
+
releaseScheduledAppRouterNavigationAfterCurrentTask(releaseNavigation);
|
|
1086
|
+
};
|
|
1087
|
+
function formatPublicBfcacheId(value) {
|
|
1088
|
+
if (!value || value === "0") return PUBLIC_INITIAL_BFCACHE_ID;
|
|
1089
|
+
return value;
|
|
1090
|
+
}
|
|
1091
|
+
function readBfcacheIdFromContext() {
|
|
1092
|
+
const segmentContext = getBfcacheSegmentIdContext();
|
|
1093
|
+
const idMapContext = getBfcacheIdMapContext();
|
|
1094
|
+
if (!segmentContext || !idMapContext || typeof React$1.useContext !== "function") return formatPublicBfcacheId(null);
|
|
1095
|
+
try {
|
|
1096
|
+
const segmentId = React$1.useContext(segmentContext);
|
|
1097
|
+
const idMap = React$1.useContext(idMapContext);
|
|
1098
|
+
return formatPublicBfcacheId(segmentId !== null ? idMap?.[segmentId] : null);
|
|
1099
|
+
} catch (error) {
|
|
1100
|
+
if (process.env.NODE_ENV !== "production") console.warn("[vinext] readBfcacheIdFromContext failed:", error);
|
|
1101
|
+
return formatPublicBfcacheId(null);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Public App Router instance, exposed for the browser entry so it can wire
|
|
1106
|
+
* `window.next.router` to the same singleton returned from `useRouter()`.
|
|
1107
|
+
*
|
|
1108
|
+
* Mirrors `publicAppRouterInstance` from Next.js's
|
|
1109
|
+
* `packages/next/src/client/components/app-router-instance.ts` (line 392).
|
|
1110
|
+
*/
|
|
1111
|
+
const appRouterInstance = _appRouter;
|
|
1112
|
+
/**
|
|
1113
|
+
* App Router's useRouter — returns push/replace/back/forward/refresh.
|
|
1114
|
+
* Different from Pages Router's useRouter (next/router).
|
|
1115
|
+
*
|
|
1116
|
+
* Preserves the mounted AppRouterContext router as the authority for methods
|
|
1117
|
+
* and layers the nearest segment's contextual `bfcacheId` on top.
|
|
1118
|
+
*/
|
|
1119
|
+
function useRouter() {
|
|
1120
|
+
if (!AppRouterContext || typeof React$1.useContext !== "function" || typeof React$1.useMemo !== "function") throw new Error("invariant expected app router to be mounted");
|
|
1121
|
+
const router = React$1.useContext(AppRouterContext);
|
|
1122
|
+
if (router === null) throw new Error("invariant expected app router to be mounted");
|
|
1123
|
+
const bfcacheId = readBfcacheIdFromContext();
|
|
1124
|
+
return React$1.useMemo(() => ({
|
|
1125
|
+
...router,
|
|
1126
|
+
bfcacheId
|
|
1127
|
+
}), [router, bfcacheId]);
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Returns the active child segment one level below the layout where it's called.
|
|
1131
|
+
*
|
|
1132
|
+
* Returns the first segment from the route tree below this layout, including
|
|
1133
|
+
* route groups (e.g., "(marketing)") and resolved dynamic params. Returns null
|
|
1134
|
+
* if at the leaf (no child segments).
|
|
1135
|
+
*
|
|
1136
|
+
* @param parallelRoutesKey - Which parallel route to read (default: "children")
|
|
1137
|
+
*/
|
|
1138
|
+
function useSelectedLayoutSegment(parallelRoutesKey) {
|
|
1139
|
+
const segments = useSelectedLayoutSegments(parallelRoutesKey);
|
|
1140
|
+
if (segments.length === 0) return null;
|
|
1141
|
+
return parallelRoutesKey === void 0 || parallelRoutesKey === "children" ? segments[0] : segments[segments.length - 1];
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Returns all active segments below the layout where it's called.
|
|
1145
|
+
*
|
|
1146
|
+
* Each layout in the App Router tree wraps its children with a
|
|
1147
|
+
* LayoutSegmentProvider whose value is a map of parallel route key to
|
|
1148
|
+
* segment arrays. The "children" key is the default parallel route.
|
|
1149
|
+
*
|
|
1150
|
+
* @param parallelRoutesKey - Which parallel route to read (default: "children")
|
|
1151
|
+
*/
|
|
1152
|
+
function useSelectedLayoutSegments(parallelRoutesKey) {
|
|
1153
|
+
if (isServer) markPprFallbackShellDynamicBoundary();
|
|
1154
|
+
return useChildSegments(parallelRoutesKey);
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* useServerInsertedHTML — inject HTML during SSR from client components.
|
|
1158
|
+
*
|
|
1159
|
+
* Used by CSS-in-JS libraries (styled-components, emotion, StyleX) to inject
|
|
1160
|
+
* <style> tags during SSR so styles appear in the initial HTML (no FOUC).
|
|
1161
|
+
*
|
|
1162
|
+
* The callback is called once after each SSR render pass. The returned JSX/HTML
|
|
1163
|
+
* is serialized and injected into the HTML stream.
|
|
1164
|
+
*
|
|
1165
|
+
* Usage (in a "use client" component wrapping children):
|
|
1166
|
+
* useServerInsertedHTML(() => {
|
|
1167
|
+
* const styles = sheet.getStyleElement();
|
|
1168
|
+
* sheet.instance.clearTag();
|
|
1169
|
+
* return <>{styles}</>;
|
|
1170
|
+
* });
|
|
1171
|
+
*/
|
|
1172
|
+
function useServerInsertedHTML(callback) {
|
|
1173
|
+
if (typeof document !== "undefined") return;
|
|
1174
|
+
registerServerInsertedHTMLCallback(callback);
|
|
1175
|
+
}
|
|
1176
|
+
if (!isServer) {
|
|
1177
|
+
const state = getClientNavigationState();
|
|
1178
|
+
if (state && !state.patchInstalled) {
|
|
1179
|
+
state.patchInstalled = true;
|
|
1180
|
+
window.addEventListener("popstate", () => {
|
|
1181
|
+
getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
|
|
1182
|
+
});
|
|
1183
|
+
window.addEventListener("popstate", (event) => {
|
|
1184
|
+
if (!hasAppNavigationRuntime()) {
|
|
1185
|
+
commitClientNavigationState();
|
|
1186
|
+
restoreScrollPosition(event.state);
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1189
|
+
window.history.pushState = function patchedPushState(data, unused, url) {
|
|
1190
|
+
state.originalPushState.call(window.history, createExternalHistoryStatePreservingMetadata(data, window.history.state), unused, url);
|
|
1191
|
+
if (state.suppressUrlNotifyCount === 0) {
|
|
1192
|
+
getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
|
|
1193
|
+
commitClientNavigationState();
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
window.history.replaceState = function patchedReplaceState(data, unused, url) {
|
|
1197
|
+
state.originalReplaceState.call(window.history, createExternalHistoryStatePreservingMetadata(data, window.history.state), unused, url);
|
|
1198
|
+
if (state.suppressUrlNotifyCount === 0) {
|
|
1199
|
+
getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
|
|
1200
|
+
commitClientNavigationState();
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
//#endregion
|
|
1206
|
+
export { BailoutToCSRError, 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, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|