vinext 0.0.50 → 0.0.52
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/dist/build/google-fonts/fallback-metrics-data.js +14031 -0
- package/dist/build/google-fonts/fallback-metrics-data.js.map +1 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +13 -0
- package/dist/build/google-fonts/fallback-metrics.js +46 -0
- package/dist/build/google-fonts/fallback-metrics.js.map +1 -0
- package/dist/build/precompress.d.ts +13 -2
- package/dist/build/precompress.js +23 -13
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +4 -15
- package/dist/build/prerender.js +83 -53
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/report.d.ts +5 -4
- package/dist/build/report.js +196 -348
- package/dist/build/report.js.map +1 -1
- package/dist/check.js +5 -0
- package/dist/check.js.map +1 -1
- package/dist/cli-args.d.ts +1 -0
- package/dist/cli-args.js +5 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli.js +99 -3
- package/dist/cli.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +47 -0
- package/dist/client/navigation-runtime.js +156 -0
- package/dist/client/navigation-runtime.js.map +1 -0
- package/dist/client/pages-router-link-navigation.d.ts +26 -0
- package/dist/client/pages-router-link-navigation.js +14 -0
- package/dist/client/pages-router-link-navigation.js.map +1 -0
- package/dist/client/vinext-next-data.d.ts +12 -2
- package/dist/client/vinext-next-data.js +50 -1
- package/dist/client/vinext-next-data.js.map +1 -0
- package/dist/client/window-next.d.ts +3 -1
- package/dist/client/window-next.js.map +1 -1
- package/dist/cloudflare/kv-cache-handler.js +2 -1
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/config/config-matchers.d.ts +63 -16
- package/dist/config/config-matchers.js +143 -8
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.d.ts +11 -1
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +107 -5
- package/dist/config/next-config.js +233 -7
- package/dist/config/next-config.js.map +1 -1
- package/dist/config/tsconfig-paths.d.ts +13 -0
- package/dist/config/tsconfig-paths.js +117 -0
- package/dist/config/tsconfig-paths.js.map +1 -0
- package/dist/deploy.js +104 -41
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +2 -2
- package/dist/entries/app-browser-entry.js +34 -3
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +19 -1
- package/dist/entries/app-rsc-entry.js +89 -23
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +10 -0
- package/dist/entries/app-rsc-manifest.js +57 -7
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +3 -3
- package/dist/entries/app-ssr-entry.js +4 -4
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.js +21 -7
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +77 -9
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +2 -1
- package/dist/entries/runtime-entry-module.js +9 -3
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +260 -75
- package/dist/index.js.map +1 -1
- package/dist/plugins/client-reference-dedup.d.ts +15 -2
- package/dist/plugins/client-reference-dedup.js +138 -16
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/plugins/css-data-url.d.ts +7 -0
- package/dist/plugins/css-data-url.js +81 -0
- package/dist/plugins/css-data-url.js.map +1 -0
- package/dist/plugins/fonts.d.ts +2 -2
- package/dist/plugins/fonts.js +20 -9
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/middleware-server-only.d.ts +54 -0
- package/dist/plugins/middleware-server-only.js +91 -0
- package/dist/plugins/middleware-server-only.js.map +1 -0
- package/dist/plugins/optimize-imports.js +4 -4
- package/dist/plugins/optimize-imports.js.map +1 -1
- package/dist/plugins/sass.d.ts +34 -0
- package/dist/plugins/sass.js +22 -0
- package/dist/plugins/sass.js.map +1 -0
- package/dist/plugins/strip-server-exports.js +5 -8
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +50 -2
- package/dist/routing/app-route-graph.js +140 -16
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -2
- package/dist/routing/app-router.js +2 -2
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/route-pattern.d.ts +56 -1
- package/dist/routing/route-pattern.js +60 -1
- package/dist/routing/route-pattern.js.map +1 -1
- package/dist/routing/utils.d.ts +2 -1
- package/dist/routing/utils.js +4 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +139 -37
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +27 -2
- package/dist/server/app-browser-action-result.js +63 -2
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +493 -195
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-hydration.d.ts +13 -1
- package/dist/server/app-browser-hydration.js +9 -1
- package/dist/server/app-browser-hydration.js.map +1 -1
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +32 -0
- package/dist/server/app-browser-interception-context.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +17 -2
- package/dist/server/app-browser-navigation-controller.js +33 -10
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-popstate.d.ts +16 -0
- package/dist/server/app-browser-popstate.js +17 -0
- package/dist/server/app-browser-popstate.js.map +1 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +29 -0
- package/dist/server/app-browser-rsc-redirect.js +37 -0
- package/dist/server/app-browser-rsc-redirect.js.map +1 -0
- package/dist/server/app-browser-state.d.ts +28 -7
- package/dist/server/app-browser-state.js +63 -27
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +9 -17
- package/dist/server/app-browser-stream.js +18 -13
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +7 -1
- package/dist/server/app-browser-visible-commit.js +39 -5
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +43 -6
- package/dist/server/app-elements-wire.js +189 -7
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +3 -2
- package/dist/server/app-elements.js +3 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.d.ts +10 -1
- package/dist/server/app-fallback-renderer.js +41 -3
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-history-state.d.ts +26 -0
- package/dist/server/app-history-state.js +53 -0
- package/dist/server/app-history-state.js.map +1 -0
- package/dist/server/app-middleware.d.ts +13 -0
- package/dist/server/app-middleware.js +3 -1
- package/dist/server/app-middleware.js.map +1 -1
- package/dist/server/app-optimistic-routing.d.ts +54 -0
- package/dist/server/app-optimistic-routing.js +200 -0
- package/dist/server/app-optimistic-routing.js.map +1 -0
- package/dist/server/app-page-boundary-render.d.ts +10 -1
- package/dist/server/app-page-boundary-render.js +13 -6
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.js +3 -2
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +26 -1
- package/dist/server/app-page-cache.js +86 -14
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +7 -0
- package/dist/server/app-page-dispatch.js +96 -12
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +7 -0
- package/dist/server/app-page-element-builder.js +34 -5
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +28 -1
- package/dist/server/app-page-execution.js +91 -7
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +7 -0
- package/dist/server/app-page-head.js +23 -3
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-probe.d.ts +23 -1
- package/dist/server/app-page-probe.js +29 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render-observation.d.ts +35 -0
- package/dist/server/app-page-render-observation.js +68 -0
- package/dist/server/app-page-render-observation.js.map +1 -0
- package/dist/server/app-page-render.d.ts +7 -1
- package/dist/server/app-page-render.js +81 -4
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +1 -0
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.js +7 -5
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +3 -1
- package/dist/server/app-page-route-wiring.js +59 -24
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +5 -0
- package/dist/server/app-page-stream.js +2 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +44 -8
- package/dist/server/app-prerender-static-params.js.map +1 -1
- package/dist/server/app-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +3 -2
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +6 -1
- package/dist/server/app-route-handler-dispatch.js +1 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +17 -2
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +5 -4
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-router-entry.js +7 -15
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +19 -1
- package/dist/server/app-rsc-cache-busting.js +36 -1
- package/dist/server/app-rsc-cache-busting.js.map +1 -1
- package/dist/server/app-rsc-embedded-chunks.d.ts +9 -0
- package/dist/server/app-rsc-embedded-chunks.js +34 -0
- package/dist/server/app-rsc-embedded-chunks.js.map +1 -0
- package/dist/server/app-rsc-errors.d.ts +4 -1
- package/dist/server/app-rsc-errors.js +1 -1
- package/dist/server/app-rsc-errors.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +21 -5
- package/dist/server/app-rsc-handler.js +38 -15
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +4 -3
- package/dist/server/app-rsc-render-mode.js +7 -1
- package/dist/server/app-rsc-render-mode.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +4 -1
- package/dist/server/app-rsc-request-normalization.js +4 -1
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +8 -1
- package/dist/server/app-rsc-response-finalizer.js +10 -3
- package/dist/server/app-rsc-response-finalizer.js.map +1 -1
- package/dist/server/app-rsc-route-matching.d.ts +23 -0
- package/dist/server/app-rsc-route-matching.js +47 -25
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +35 -3
- package/dist/server/app-server-action-execution.js +87 -33
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +3 -0
- package/dist/server/app-ssr-entry.js +83 -58
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-error-meta.d.ts +14 -0
- package/dist/server/app-ssr-error-meta.js +50 -0
- package/dist/server/app-ssr-error-meta.js.map +1 -0
- package/dist/server/app-ssr-stream.d.ts +7 -2
- package/dist/server/app-ssr-stream.js +26 -15
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +13 -3
- package/dist/server/artifact-compatibility.js +12 -8
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-headers.d.ts +7 -0
- package/dist/server/cache-headers.js +19 -0
- package/dist/server/cache-headers.js.map +1 -0
- package/dist/server/cache-proof.d.ts +170 -5
- package/dist/server/cache-proof.js +472 -18
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/client-reuse-manifest.d.ts +99 -0
- package/dist/server/client-reuse-manifest.js +212 -0
- package/dist/server/client-reuse-manifest.js.map +1 -0
- package/dist/server/default-global-error-module.d.ts +20 -0
- package/dist/server/default-global-error-module.js +20 -0
- package/dist/server/default-global-error-module.js.map +1 -0
- package/dist/server/dev-lockfile.d.ts +110 -0
- package/dist/server/dev-lockfile.js +180 -0
- package/dist/server/dev-lockfile.js.map +1 -0
- package/dist/server/dev-server.d.ts +9 -1
- package/dist/server/dev-server.js +76 -19
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/edge-api-runtime.d.ts +5 -0
- package/dist/server/edge-api-runtime.js +8 -0
- package/dist/server/edge-api-runtime.js.map +1 -0
- package/dist/server/file-based-metadata.d.ts +13 -0
- package/dist/server/file-based-metadata.js +49 -2
- package/dist/server/file-based-metadata.js.map +1 -1
- package/dist/server/headers.d.ts +20 -1
- package/dist/server/headers.js +22 -2
- package/dist/server/headers.js.map +1 -1
- package/dist/server/html.js +1 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/http-error-responses.d.ts +26 -1
- package/dist/server/http-error-responses.js +32 -2
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/isr-cache.d.ts +8 -3
- package/dist/server/isr-cache.js +24 -6
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-route-response.js +22 -5
- package/dist/server/metadata-route-response.js.map +1 -1
- package/dist/server/metadata-routes.js +27 -8
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +15 -0
- package/dist/server/middleware-runtime.js +60 -7
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.d.ts +13 -1
- package/dist/server/middleware.js +16 -2
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +26 -6
- package/dist/server/navigation-planner.js +358 -24
- package/dist/server/navigation-planner.js.map +1 -1
- package/dist/server/navigation-trace.d.ts +9 -1
- package/dist/server/navigation-trace.js +8 -0
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/normalize-path.d.ts +2 -1
- package/dist/server/normalize-path.js +4 -1
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +27 -1
- package/dist/server/pages-api-route.js +25 -3
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-data-route.d.ts +77 -0
- package/dist/server/pages-data-route.js +97 -0
- package/dist/server/pages-data-route.js.map +1 -0
- package/dist/server/pages-i18n.d.ts +51 -1
- package/dist/server/pages-i18n.js +61 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +32 -4
- package/dist/server/pages-page-data.js +52 -19
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +11 -1
- package/dist/server/pages-page-response.js +6 -4
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prod-server.d.ts +26 -1
- package/dist/server/prod-server.js +150 -44
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +11 -2
- package/dist/server/request-pipeline.js +28 -11
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.d.ts +12 -31
- package/dist/server/seed-cache.js +22 -35
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.d.ts +16 -3
- package/dist/server/server-action-not-found.js +27 -4
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/server-globals.d.ts +5 -0
- package/dist/server/server-globals.js +37 -0
- package/dist/server/server-globals.js.map +1 -0
- package/dist/server/skip-cache-proof.d.ts +41 -0
- package/dist/server/skip-cache-proof.js +101 -0
- package/dist/server/skip-cache-proof.js.map +1 -0
- package/dist/server/static-file-cache.d.ts +1 -1
- package/dist/server/static-file-cache.js +7 -6
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/cache-runtime.d.ts +19 -2
- package/dist/shims/cache-runtime.js +67 -11
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +5 -18
- package/dist/shims/cache.js +2 -0
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-locale.d.ts +15 -0
- package/dist/shims/client-locale.js +13 -0
- package/dist/shims/client-locale.js.map +1 -0
- package/dist/shims/default-global-error.d.ts +32 -0
- package/dist/shims/default-global-error.js +181 -0
- package/dist/shims/default-global-error.js.map +1 -0
- package/dist/shims/document.d.ts +59 -3
- package/dist/shims/document.js +36 -5
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +2 -2
- package/dist/shims/error-boundary.js +6 -8
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.d.ts +18 -1
- package/dist/shims/error.js +56 -1
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +4 -1
- package/dist/shims/fetch-cache.js +40 -5
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +22 -8
- package/dist/shims/font-google-base.js +41 -71
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-local.d.ts +3 -20
- package/dist/shims/font-local.js +23 -75
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/font-utils.d.ts +51 -0
- package/dist/shims/font-utils.js +97 -0
- package/dist/shims/font-utils.js.map +1 -0
- package/dist/shims/form.js +13 -6
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/hash-scroll.d.ts +7 -0
- package/dist/shims/hash-scroll.js +30 -0
- package/dist/shims/hash-scroll.js.map +1 -0
- package/dist/shims/headers.d.ts +8 -11
- package/dist/shims/headers.js +22 -2
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts +1 -0
- package/dist/shims/image.js +144 -78
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/app-router-context.d.ts +6 -6
- package/dist/shims/internal/app-router-context.js +17 -6
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/link-prefetch.d.ts +9 -1
- package/dist/shims/link-prefetch.js +11 -6
- package/dist/shims/link-prefetch.js.map +1 -1
- package/dist/shims/link.d.ts +33 -5
- package/dist/shims/link.js +205 -50
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +16 -30
- package/dist/shims/metadata.js +91 -32
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +164 -17
- package/dist/shims/navigation.js +355 -84
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/navigation.react-server.d.ts +3 -2
- package/dist/shims/navigation.react-server.js +5 -2
- package/dist/shims/navigation.react-server.js.map +1 -1
- package/dist/shims/og.d.ts +18 -2
- package/dist/shims/og.js +49 -1
- package/dist/shims/og.js.map +1 -0
- package/dist/shims/pages-router-runtime.d.ts +7 -0
- package/dist/shims/pages-router-runtime.js +16 -0
- package/dist/shims/pages-router-runtime.js.map +1 -0
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +11 -3
- package/dist/shims/root-params.js.map +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +40 -7
- package/dist/shims/router.js +355 -250
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.js +110 -32
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts +21 -4
- package/dist/shims/server.js +31 -10
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.d.ts +1 -0
- package/dist/shims/slot.js +45 -1
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/unrecognized-action-error.d.ts +35 -0
- package/dist/shims/unrecognized-action-error.js +41 -0
- package/dist/shims/unrecognized-action-error.js.map +1 -0
- package/dist/shims/url-safety.d.ts +23 -1
- package/dist/shims/url-safety.js +29 -2
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +21 -1
- package/dist/shims/url-utils.js +67 -3
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/typegen.d.ts +10 -0
- package/dist/typegen.js +242 -0
- package/dist/typegen.js.map +1 -0
- package/dist/utils/asset-prefix.d.ts +97 -0
- package/dist/utils/asset-prefix.js +124 -0
- package/dist/utils/asset-prefix.js.map +1 -0
- package/dist/utils/base-path.d.ts +7 -1
- package/dist/utils/base-path.js +10 -1
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/cache-control-metadata.d.ts +2 -1
- package/dist/utils/cache-control-metadata.js +1 -3
- package/dist/utils/cache-control-metadata.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +2 -1
- package/dist/utils/domain-locale.js +9 -1
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/navigation-signal.d.ts +1 -2
- package/dist/utils/navigation-signal.js +1 -1
- package/dist/utils/navigation-signal.js.map +1 -1
- package/dist/utils/prerender-output-paths.d.ts +15 -0
- package/dist/utils/prerender-output-paths.js +24 -0
- package/dist/utils/prerender-output-paths.js.map +1 -0
- package/dist/utils/query.d.ts +17 -1
- package/dist/utils/query.js +36 -1
- package/dist/utils/query.js.map +1 -1
- package/dist/utils/record.d.ts +5 -0
- package/dist/utils/record.js +8 -0
- package/dist/utils/record.js.map +1 -0
- package/dist/utils/sorted-array.d.ts +9 -0
- package/dist/utils/sorted-array.js +22 -0
- package/dist/utils/sorted-array.js.map +1 -0
- package/package.json +13 -5
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stripBasePath } from "../utils/base-path.js";
|
|
2
|
+
import { ACTION_REDIRECT_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER, VINEXT_RSC_REDIRECT_HEADER } from "./headers.js";
|
|
2
3
|
import { DANGEROUS_URL_BLOCK_MESSAGE, isDangerousScheme } from "../shims/url-safety.js";
|
|
3
4
|
import { APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI } from "./app-rsc-render-mode.js";
|
|
4
5
|
import { installWindowNext } from "../client/window-next.js";
|
|
6
|
+
import { scrollToHashTargetOnNextFrame } from "../shims/hash-scroll.js";
|
|
7
|
+
import { getNavigationRuntime, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions } from "../client/navigation-runtime.js";
|
|
5
8
|
import { notifyAppRouterTransitionStart } from "../client/instrumentation-client-state.js";
|
|
6
9
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
7
10
|
import { getMountedSlotIdsHeader, resolveVisitedResponseInterceptionContext } from "./app-elements.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
11
|
+
import { resolveManifestNavigationInterceptionContext } from "./app-browser-interception-context.js";
|
|
12
|
+
import { createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveHistoryTraversalIntent } from "./app-history-state.js";
|
|
13
|
+
import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, createRscRequestHeaders, createRscRequestUrl, getVinextRscCompatibilityId, resolveHardNavigationTargetFromRscResponse, resolveRscCompatibilityNavigationDecision } from "./app-rsc-cache-busting.js";
|
|
14
|
+
import { AppRouterContext } from "../shims/internal/app-router-context.js";
|
|
15
|
+
import { __basePath, appRouterInstance, commitClientNavigationState, consumePrefetchResponse, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, getClientNavigationRenderContext, getPrefetchCache, invalidatePrefetchCache, pushHistoryStateWithoutNotify, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, restoreRscResponse, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname } from "../shims/navigation.js";
|
|
10
16
|
import { DevRecoveryBoundary, RedirectBoundary } from "../shims/error-boundary.js";
|
|
11
17
|
import { ElementsContext, Slot } from "../shims/slot.js";
|
|
12
18
|
import "../client/instrumentation-client.js";
|
|
13
|
-
import { isServerActionResult, shouldClearClientNavigationCachesForServerActionResult } from "./app-browser-action-result.js";
|
|
19
|
+
import { createDiscardedServerActionRefreshScheduler, createServerActionInitiationSnapshot, isServerActionResult, parseServerActionRevalidationHeader, shouldClearClientNavigationCachesForServerActionResult } from "./app-browser-action-result.js";
|
|
14
20
|
import { chunksToReadableStream, createProgressiveRscStream, getVinextBrowserGlobal } from "./app-browser-stream.js";
|
|
15
|
-
import {
|
|
21
|
+
import { FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, VISITED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, isCacheRestorableAppPayloadMetadata, resolveInterceptionContextFromPreviousNextUrl, resolveServerActionRequestState } from "./app-browser-state.js";
|
|
16
22
|
import { clearHardNavigationLoopGuard, createAppBrowserNavigationController } from "./app-browser-navigation-controller.js";
|
|
17
|
-
import { consumeInitialFormState, createVinextHydrateRootOptions } from "./app-browser-hydration.js";
|
|
23
|
+
import { consumeInitialFormState, createVinextHydrateRootOptions, hydrateRootInTransition } from "./app-browser-hydration.js";
|
|
24
|
+
import { createPopstateRestoreHandler } from "./app-browser-popstate.js";
|
|
18
25
|
import { createOnUncaughtError } from "./app-browser-error.js";
|
|
19
26
|
import { dismissOverlay } from "./dev-error-overlay-store.js";
|
|
20
27
|
import { devOnCaughtError, devOnUncaughtError, installDevErrorOverlay } from "./dev-error-overlay.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
28
|
+
import { throwOnServerActionNotFound } from "./server-action-not-found.js";
|
|
29
|
+
import { resolveRscRedirectLifecycleHop } from "./app-browser-rsc-redirect.js";
|
|
30
|
+
import { createOptimisticRouteTemplate, getOptimisticPrefetchSourceKey, getOptimisticRouteTemplateKey, resolveOptimisticNavigationPayload } from "./app-optimistic-routing.js";
|
|
31
|
+
import { createElement, startTransition, use, useLayoutEffect, useRef, useState } from "react";
|
|
23
32
|
import { createFromFetch, createFromReadableStream, createTemporaryReferenceSet, encodeReply, setServerCallback } from "@vitejs/plugin-rsc/browser";
|
|
24
33
|
import { hydrateRoot } from "react-dom/client";
|
|
25
34
|
//#region src/server/app-browser-entry.ts
|
|
@@ -37,7 +46,21 @@ function toOperationLane(kind) {
|
|
|
37
46
|
const MAX_VISITED_RESPONSE_CACHE_SIZE = 50;
|
|
38
47
|
const VISITED_RESPONSE_CACHE_TTL = 5 * 6e4;
|
|
39
48
|
const MAX_TRAVERSAL_CACHE_TTL = 30 * 6e4;
|
|
40
|
-
const
|
|
49
|
+
const CLIENT_RSC_COMPATIBILITY_ID = getVinextRscCompatibilityId();
|
|
50
|
+
const optimisticRouteTemplates = /* @__PURE__ */ new Map();
|
|
51
|
+
const optimisticRouteTemplateSources = /* @__PURE__ */ new Set();
|
|
52
|
+
const optimisticRouteTemplateLearning = /* @__PURE__ */ new Map();
|
|
53
|
+
function getBrowserRouteManifest() {
|
|
54
|
+
return getNavigationRuntime()?.bootstrap.routeManifest ?? null;
|
|
55
|
+
}
|
|
56
|
+
const browserNavigationController = createAppBrowserNavigationController({
|
|
57
|
+
getRouteManifest: getBrowserRouteManifest,
|
|
58
|
+
syncHistoryStatePreviousNextUrl: syncCurrentHistoryStatePreviousNextUrl
|
|
59
|
+
});
|
|
60
|
+
const discardedServerActionRefreshScheduler = createDiscardedServerActionRefreshScheduler({ runRefresh() {
|
|
61
|
+
clearClientNavigationCaches();
|
|
62
|
+
getNavigationRuntime()?.functions.navigate?.(window.location.href, 0, "refresh", void 0, void 0, true);
|
|
63
|
+
} });
|
|
41
64
|
const NavigationCommitSignal = browserNavigationController.NavigationCommitSignal;
|
|
42
65
|
function parseEncodedJsonHeader(value) {
|
|
43
66
|
if (!value) return null;
|
|
@@ -54,6 +77,47 @@ let latestClientParams = {};
|
|
|
54
77
|
const visitedResponseCache = /* @__PURE__ */ new Map();
|
|
55
78
|
let browserRouterStateHasEverCommitted = false;
|
|
56
79
|
let pendingNavigationRecoveryHref = null;
|
|
80
|
+
let currentHistoryTraversalIndex = readHistoryStateTraversalIndex(window.history.state) ?? 0;
|
|
81
|
+
let nextHistoryTraversalIndex = currentHistoryTraversalIndex;
|
|
82
|
+
function allocateNavigationHistoryTraversalIndex(historyUpdateMode) {
|
|
83
|
+
switch (historyUpdateMode) {
|
|
84
|
+
case "push": return nextHistoryTraversalIndex + 1;
|
|
85
|
+
case "replace": return currentHistoryTraversalIndex;
|
|
86
|
+
case void 0: return null;
|
|
87
|
+
default: throw new Error("[vinext] Unknown history update mode: " + String(historyUpdateMode));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function commitHistoryTraversalIndex(index) {
|
|
91
|
+
currentHistoryTraversalIndex = index;
|
|
92
|
+
if (index !== null) nextHistoryTraversalIndex = Math.max(nextHistoryTraversalIndex, index);
|
|
93
|
+
}
|
|
94
|
+
function commitHashOnlyNavigation(href, historyUpdateMode, scroll) {
|
|
95
|
+
const navigationHistoryIndex = allocateNavigationHistoryTraversalIndex(historyUpdateMode);
|
|
96
|
+
const previousNextUrl = hasBrowserRouterState() ? getBrowserRouterState().previousNextUrl : readHistoryStatePreviousNextUrl(window.history.state);
|
|
97
|
+
const historyState = createHistoryStateWithNavigationMetadata(createHashOnlyNavigationBaseHistoryState(historyUpdateMode, scroll), {
|
|
98
|
+
previousNextUrl,
|
|
99
|
+
traversalIndex: navigationHistoryIndex
|
|
100
|
+
});
|
|
101
|
+
if (historyUpdateMode === "replace") replaceHistoryStateWithoutNotify(historyState, "", href);
|
|
102
|
+
else pushHistoryStateWithoutNotify(historyState, "", href);
|
|
103
|
+
commitHistoryTraversalIndex(navigationHistoryIndex);
|
|
104
|
+
}
|
|
105
|
+
function createHashOnlyNavigationBaseHistoryState(historyUpdateMode, scroll) {
|
|
106
|
+
if (historyUpdateMode !== "replace") return null;
|
|
107
|
+
return scroll ? stripVinextScrollState(window.history.state) : window.history.state;
|
|
108
|
+
}
|
|
109
|
+
function stripVinextScrollState(state) {
|
|
110
|
+
if (!state || typeof state !== "object") return state;
|
|
111
|
+
const nextState = {};
|
|
112
|
+
for (const [key, value] of Object.entries(state)) {
|
|
113
|
+
if (key === "__vinext_scrollX" || key === "__vinext_scrollY") continue;
|
|
114
|
+
nextState[key] = value;
|
|
115
|
+
}
|
|
116
|
+
return Object.keys(nextState).length > 0 ? nextState : null;
|
|
117
|
+
}
|
|
118
|
+
function commitTraversalIndexFromHistoryState(historyState) {
|
|
119
|
+
commitHistoryTraversalIndex(readHistoryStateTraversalIndex(historyState));
|
|
120
|
+
}
|
|
57
121
|
function getBrowserRouterState() {
|
|
58
122
|
return browserNavigationController.getBrowserRouterState();
|
|
59
123
|
}
|
|
@@ -78,30 +142,132 @@ function clearVisitedResponseCache() {
|
|
|
78
142
|
visitedResponseCache.clear();
|
|
79
143
|
}
|
|
80
144
|
function clearPrefetchState() {
|
|
81
|
-
|
|
82
|
-
|
|
145
|
+
invalidatePrefetchCache();
|
|
146
|
+
optimisticRouteTemplates.clear();
|
|
147
|
+
optimisticRouteTemplateSources.clear();
|
|
148
|
+
optimisticRouteTemplateLearning.clear();
|
|
83
149
|
}
|
|
84
150
|
function clearClientNavigationCaches() {
|
|
85
151
|
clearVisitedResponseCache();
|
|
86
152
|
clearPrefetchState();
|
|
87
153
|
}
|
|
154
|
+
function isSettledPrefetchCacheEntry(entry) {
|
|
155
|
+
return entry.outcome === "cache-seeded" && entry.pending === void 0 && entry.snapshot !== void 0;
|
|
156
|
+
}
|
|
157
|
+
function parsePrefetchCacheKey(cacheKey) {
|
|
158
|
+
const separatorIndex = cacheKey.indexOf("\0");
|
|
159
|
+
if (separatorIndex === -1) return {
|
|
160
|
+
interceptionContext: null,
|
|
161
|
+
rscUrl: cacheKey
|
|
162
|
+
};
|
|
163
|
+
return {
|
|
164
|
+
interceptionContext: cacheKey.slice(separatorIndex + 1),
|
|
165
|
+
rscUrl: cacheKey.slice(0, separatorIndex)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
async function learnOptimisticRouteTemplateFromPrefetch(options) {
|
|
169
|
+
const source = parsePrefetchCacheKey(options.cacheKey);
|
|
170
|
+
if (source.interceptionContext !== options.interceptionContext) return false;
|
|
171
|
+
if ((options.entry.snapshot.mountedSlotsHeader ?? null) !== options.mountedSlotsHeader) return false;
|
|
172
|
+
if (options.interceptionContext !== null) return false;
|
|
173
|
+
const elements = await decodeAppElementsPromise(createFromFetch(Promise.resolve(restoreRscResponse(options.entry.snapshot))));
|
|
174
|
+
const template = createOptimisticRouteTemplate({
|
|
175
|
+
allowLoadingShell: options.entry.optimisticRouteShell === true,
|
|
176
|
+
basePath: __basePath,
|
|
177
|
+
elements,
|
|
178
|
+
href: options.entry.snapshot.url || source.rscUrl,
|
|
179
|
+
interceptionContext: options.interceptionContext,
|
|
180
|
+
mountedSlotsHeader: options.mountedSlotsHeader,
|
|
181
|
+
routeManifest: options.routeManifest
|
|
182
|
+
});
|
|
183
|
+
if (template === null) return false;
|
|
184
|
+
optimisticRouteTemplates.set(getOptimisticRouteTemplateKey({
|
|
185
|
+
interceptionContext: options.interceptionContext,
|
|
186
|
+
mountedSlotsHeader: options.mountedSlotsHeader,
|
|
187
|
+
routeId: template.routeId
|
|
188
|
+
}), template);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
async function learnOptimisticRouteTemplatesFromPrefetchCache(options) {
|
|
192
|
+
if (options.routeManifest === null) return;
|
|
193
|
+
const learning = [...optimisticRouteTemplateLearning.values()];
|
|
194
|
+
for (const [cacheKey, entry] of getPrefetchCache()) {
|
|
195
|
+
const sourceKey = getOptimisticPrefetchSourceKey({
|
|
196
|
+
cacheKey,
|
|
197
|
+
interceptionContext: options.interceptionContext,
|
|
198
|
+
mountedSlotsHeader: options.mountedSlotsHeader
|
|
199
|
+
});
|
|
200
|
+
if (optimisticRouteTemplateSources.has(sourceKey)) continue;
|
|
201
|
+
if (optimisticRouteTemplateLearning.has(sourceKey)) continue;
|
|
202
|
+
if (!isSettledPrefetchCacheEntry(entry)) continue;
|
|
203
|
+
const promise = learnOptimisticRouteTemplateFromPrefetch({
|
|
204
|
+
cacheKey,
|
|
205
|
+
entry,
|
|
206
|
+
interceptionContext: options.interceptionContext,
|
|
207
|
+
mountedSlotsHeader: options.mountedSlotsHeader,
|
|
208
|
+
routeManifest: options.routeManifest
|
|
209
|
+
}).then((learned) => {
|
|
210
|
+
if (learned) optimisticRouteTemplateSources.add(sourceKey);
|
|
211
|
+
}).finally(() => {
|
|
212
|
+
optimisticRouteTemplateLearning.delete(sourceKey);
|
|
213
|
+
});
|
|
214
|
+
optimisticRouteTemplateLearning.set(sourceKey, promise);
|
|
215
|
+
learning.push(promise);
|
|
216
|
+
}
|
|
217
|
+
if (learning.length === 0) return;
|
|
218
|
+
await Promise.allSettled(learning);
|
|
219
|
+
}
|
|
220
|
+
function syncCurrentHistoryStatePreviousNextUrl(previousNextUrl) {
|
|
221
|
+
if (readHistoryStatePreviousNextUrl(window.history.state) === previousNextUrl) return;
|
|
222
|
+
const nextHistoryState = createHistoryStateWithPreviousNextUrl(window.history.state, previousNextUrl);
|
|
223
|
+
replaceHistoryStateWithoutNotify(nextHistoryState, "", window.location.href);
|
|
224
|
+
if (readHistoryStatePreviousNextUrl(window.history.state) === previousNextUrl) return;
|
|
225
|
+
window.history.replaceState(nextHistoryState, "", window.location.href);
|
|
226
|
+
}
|
|
227
|
+
function createActionInitiationSnapshot() {
|
|
228
|
+
const routerState = getBrowserRouterState();
|
|
229
|
+
return createServerActionInitiationSnapshot({
|
|
230
|
+
href: window.location.href,
|
|
231
|
+
navigationId: browserNavigationController.getActiveNavigationId(),
|
|
232
|
+
routerState
|
|
233
|
+
});
|
|
234
|
+
}
|
|
88
235
|
function createNavigationCommitEffect(options) {
|
|
89
|
-
const { href, historyUpdateMode, navId, params, previousNextUrl } = options;
|
|
236
|
+
const { href, historyUpdateMode, navId, params, previousNextUrl, targetHistoryIndex } = options;
|
|
90
237
|
return () => {
|
|
91
238
|
if (!browserNavigationController.isCurrentNavigation(navId)) {
|
|
92
239
|
commitClientNavigationState(void 0, { releaseSnapshot: true });
|
|
93
240
|
return;
|
|
94
241
|
}
|
|
95
242
|
const targetHref = new URL(href, window.location.origin).href;
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
243
|
+
const preserveExistingState = historyUpdateMode === "replace";
|
|
244
|
+
const navigationHistoryIndex = targetHistoryIndex !== void 0 ? targetHistoryIndex : allocateNavigationHistoryTraversalIndex(historyUpdateMode);
|
|
245
|
+
const historyState = createHistoryStateWithNavigationMetadata(preserveExistingState ? window.history.state : null, {
|
|
246
|
+
previousNextUrl,
|
|
247
|
+
traversalIndex: navigationHistoryIndex
|
|
248
|
+
});
|
|
249
|
+
let wroteHistoryState = false;
|
|
250
|
+
if (historyUpdateMode === "replace" && window.location.href !== targetHref) {
|
|
251
|
+
stageClientParams(params);
|
|
252
|
+
replaceHistoryStateWithoutNotify(historyState, "", href);
|
|
253
|
+
wroteHistoryState = true;
|
|
254
|
+
commitHistoryTraversalIndex(navigationHistoryIndex);
|
|
255
|
+
} else if (historyUpdateMode === "push" && window.location.href !== targetHref) {
|
|
256
|
+
stageClientParams(params);
|
|
257
|
+
pushHistoryStateWithoutNotify(historyState, "", href);
|
|
258
|
+
wroteHistoryState = true;
|
|
259
|
+
commitHistoryTraversalIndex(navigationHistoryIndex);
|
|
260
|
+
}
|
|
261
|
+
if (!wroteHistoryState) {
|
|
262
|
+
syncCurrentHistoryStatePreviousNextUrl(previousNextUrl);
|
|
263
|
+
stageClientParams(params);
|
|
264
|
+
if (targetHistoryIndex !== void 0) commitHistoryTraversalIndex(targetHistoryIndex);
|
|
265
|
+
}
|
|
100
266
|
pendingNavigationRecoveryHref = null;
|
|
101
267
|
commitClientNavigationState(navId);
|
|
102
268
|
};
|
|
103
269
|
}
|
|
104
|
-
async function renderNavigationPayload(payload, navigationSnapshot, targetHref, navId, historyUpdateMode, params, previousNextUrl, pendingRouterState, actionType = "navigate", operationLane = "navigation") {
|
|
270
|
+
async function renderNavigationPayload(payload, navigationSnapshot, targetHref, navId, historyUpdateMode, params, previousNextUrl, pendingRouterState, payloadOrigin, actionType = "navigate", operationLane = "navigation", traversalIntent = null) {
|
|
105
271
|
try {
|
|
106
272
|
return await browserNavigationController.renderNavigationPayload({
|
|
107
273
|
actionType,
|
|
@@ -113,9 +279,11 @@ async function renderNavigationPayload(payload, navigationSnapshot, targetHref,
|
|
|
113
279
|
navigationSnapshot,
|
|
114
280
|
nextElements: payload,
|
|
115
281
|
operationLane,
|
|
282
|
+
payloadOrigin,
|
|
116
283
|
params,
|
|
117
284
|
pendingRouterState,
|
|
118
285
|
previousNextUrl,
|
|
286
|
+
targetHistoryIndex: traversalIntent === null ? void 0 : traversalIntent.targetHistoryIndex,
|
|
119
287
|
targetHref,
|
|
120
288
|
navId
|
|
121
289
|
});
|
|
@@ -124,9 +292,16 @@ async function renderNavigationPayload(payload, navigationSnapshot, targetHref,
|
|
|
124
292
|
throw error;
|
|
125
293
|
}
|
|
126
294
|
}
|
|
127
|
-
async function commitSameUrlNavigatePayload(nextElements, returnValue,
|
|
128
|
-
const navigationSnapshot = createClientNavigationRenderSnapshot(
|
|
129
|
-
return browserNavigationController.commitSameUrlNavigatePayload(nextElements, navigationSnapshot, returnValue,
|
|
295
|
+
async function commitSameUrlNavigatePayload(nextElements, actionInitiation, returnValue, revalidation = "none") {
|
|
296
|
+
const navigationSnapshot = createClientNavigationRenderSnapshot(actionInitiation.href, actionInitiation.routerState.navigationSnapshot.params);
|
|
297
|
+
return browserNavigationController.commitSameUrlNavigatePayload(nextElements, navigationSnapshot, returnValue, actionInitiation.routerState, {
|
|
298
|
+
onDiscardedRevalidation() {
|
|
299
|
+
discardedServerActionRefreshScheduler.schedule();
|
|
300
|
+
},
|
|
301
|
+
revalidation,
|
|
302
|
+
startedNavigationId: actionInitiation.navigationId,
|
|
303
|
+
targetHref: actionInitiation.href
|
|
304
|
+
});
|
|
130
305
|
}
|
|
131
306
|
function evictVisitedResponseCacheIfNeeded() {
|
|
132
307
|
while (visitedResponseCache.size >= MAX_VISITED_RESPONSE_CACHE_SIZE) {
|
|
@@ -173,18 +348,35 @@ function storeVisitedResponseSnapshot(rscUrl, interceptionContext, snapshot, par
|
|
|
173
348
|
response: snapshot
|
|
174
349
|
});
|
|
175
350
|
}
|
|
176
|
-
function getRequestState(navigationKind, previousNextUrlOverride) {
|
|
351
|
+
function getRequestState(navigationKind, targetPathname, previousNextUrlOverride, traverseHistoryState) {
|
|
177
352
|
if (previousNextUrlOverride !== void 0) return {
|
|
178
353
|
interceptionContext: resolveInterceptionContextFromPreviousNextUrl(previousNextUrlOverride, __basePath),
|
|
179
354
|
previousNextUrl: previousNextUrlOverride
|
|
180
355
|
};
|
|
181
356
|
switch (navigationKind) {
|
|
182
|
-
case "navigate":
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
357
|
+
case "navigate": {
|
|
358
|
+
const currentPreviousNextUrl = getBrowserRouterState().previousNextUrl;
|
|
359
|
+
if (currentPreviousNextUrl !== null) return {
|
|
360
|
+
interceptionContext: resolveInterceptionContextFromPreviousNextUrl(currentPreviousNextUrl, __basePath),
|
|
361
|
+
previousNextUrl: currentPreviousNextUrl
|
|
362
|
+
};
|
|
363
|
+
const manifestInterceptionContext = resolveManifestNavigationInterceptionContext({
|
|
364
|
+
basePath: __basePath,
|
|
365
|
+
currentPathname: window.location.pathname,
|
|
366
|
+
routeManifest: getBrowserRouteManifest(),
|
|
367
|
+
targetPathname
|
|
368
|
+
});
|
|
369
|
+
if (manifestInterceptionContext !== null) return {
|
|
370
|
+
interceptionContext: manifestInterceptionContext,
|
|
371
|
+
previousNextUrl: window.location.pathname + window.location.search
|
|
372
|
+
};
|
|
373
|
+
return {
|
|
374
|
+
interceptionContext: null,
|
|
375
|
+
previousNextUrl: null
|
|
376
|
+
};
|
|
377
|
+
}
|
|
186
378
|
case "traverse": {
|
|
187
|
-
const previousNextUrl = readHistoryStatePreviousNextUrl(window.history.state);
|
|
379
|
+
const previousNextUrl = readHistoryStatePreviousNextUrl(traverseHistoryState ?? window.history.state);
|
|
188
380
|
return {
|
|
189
381
|
interceptionContext: resolveInterceptionContextFromPreviousNextUrl(previousNextUrl, __basePath),
|
|
190
382
|
previousNextUrl
|
|
@@ -212,6 +404,7 @@ function BrowserRoot({ initialElements, initialNavigationSnapshot }) {
|
|
|
212
404
|
const [treeStateValue, setTreeStateValue] = useState({
|
|
213
405
|
activeOperation: null,
|
|
214
406
|
elements: resolvedElements,
|
|
407
|
+
interception: initialMetadata.interception,
|
|
215
408
|
interceptionContext: initialMetadata.interceptionContext,
|
|
216
409
|
layoutIds: initialMetadata.layoutIds,
|
|
217
410
|
layoutFlags: initialMetadata.layoutFlags,
|
|
@@ -220,6 +413,7 @@ function BrowserRoot({ initialElements, initialNavigationSnapshot }) {
|
|
|
220
413
|
renderId: 0,
|
|
221
414
|
rootLayoutTreePath: initialMetadata.rootLayoutTreePath,
|
|
222
415
|
routeId: initialMetadata.routeId,
|
|
416
|
+
slotBindings: initialMetadata.slotBindings,
|
|
223
417
|
visibleCommitVersion: 0
|
|
224
418
|
});
|
|
225
419
|
const treeState = isRouterStatePromise(treeStateValue) ? use(treeStateValue) : treeStateValue;
|
|
@@ -228,6 +422,11 @@ function BrowserRoot({ initialElements, initialNavigationSnapshot }) {
|
|
|
228
422
|
useLayoutEffect(() => {
|
|
229
423
|
const detach = browserNavigationController.attachBrowserRouterState(setTreeStateValue, stateRef);
|
|
230
424
|
browserRouterStateHasEverCommitted = true;
|
|
425
|
+
const hydratedAt = performance.now();
|
|
426
|
+
window.__VINEXT_HYDRATED_AT = hydratedAt;
|
|
427
|
+
window.__NEXT_HYDRATED = true;
|
|
428
|
+
window.__NEXT_HYDRATED_AT = hydratedAt;
|
|
429
|
+
window.__NEXT_HYDRATED_CB?.();
|
|
231
430
|
return () => {
|
|
232
431
|
detach();
|
|
233
432
|
setMountedSlotsHeader(null);
|
|
@@ -235,12 +434,17 @@ function BrowserRoot({ initialElements, initialNavigationSnapshot }) {
|
|
|
235
434
|
}, [setTreeStateValue]);
|
|
236
435
|
useLayoutEffect(() => {
|
|
237
436
|
setMountedSlotsHeader(getMountedSlotIdsHeader(stateRef.current.elements));
|
|
437
|
+
getNavigationRuntime()?.functions.pingVisibleLinks?.();
|
|
238
438
|
}, [treeState.elements]);
|
|
239
439
|
useLayoutEffect(() => {
|
|
240
440
|
if (treeState.renderId !== 0) return;
|
|
241
|
-
replaceHistoryStateWithoutNotify(
|
|
441
|
+
replaceHistoryStateWithoutNotify(createHistoryStateWithNavigationMetadata(window.history.state, {
|
|
442
|
+
previousNextUrl: treeState.previousNextUrl,
|
|
443
|
+
traversalIndex: currentHistoryTraversalIndex
|
|
444
|
+
}), "", window.location.href);
|
|
242
445
|
}, [treeState.previousNextUrl, treeState.renderId]);
|
|
243
|
-
const
|
|
446
|
+
const routeTree = createElement(RedirectBoundary, null, createElement(NavigationCommitSignal, { renderId: treeState.renderId }, createElement(ElementsContext.Provider, { value: treeState.elements }, createElement(Slot, { id: treeState.routeId }))));
|
|
447
|
+
const innerTree = AppRouterContext ? createElement(AppRouterContext.Provider, { value: appRouterInstance }, routeTree) : routeTree;
|
|
244
448
|
const committedTree = import.meta.env.DEV ? createElement(DevRecoveryBoundary, {
|
|
245
449
|
resetKey: treeState.renderId,
|
|
246
450
|
onCatch: handleDevRecoveryBoundaryCatch
|
|
@@ -256,31 +460,9 @@ function restoreHydrationNavigationContext(pathname, searchParams, params) {
|
|
|
256
460
|
params
|
|
257
461
|
});
|
|
258
462
|
}
|
|
259
|
-
function decodeHashFragment(fragment) {
|
|
260
|
-
try {
|
|
261
|
-
return decodeURIComponent(fragment);
|
|
262
|
-
} catch {
|
|
263
|
-
return fragment;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
function scrollToHashTarget(hash) {
|
|
267
|
-
const fragment = decodeHashFragment(hash.startsWith("#") ? hash.slice(1) : hash);
|
|
268
|
-
requestAnimationFrame(() => {
|
|
269
|
-
if (fragment === "" || fragment === "top") {
|
|
270
|
-
window.scrollTo(0, 0);
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
const idElement = document.getElementById(fragment);
|
|
274
|
-
if (idElement) {
|
|
275
|
-
idElement.scrollIntoView({ behavior: "auto" });
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
document.getElementsByName(fragment)[0]?.scrollIntoView({ behavior: "auto" });
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
463
|
function restorePopstateScrollPosition(state) {
|
|
282
464
|
if (!(state && typeof state === "object" && "__vinext_scrollY" in state)) {
|
|
283
|
-
if (window.location.hash)
|
|
465
|
+
if (window.location.hash) scrollToHashTargetOnNextFrame(window.location.hash);
|
|
284
466
|
return;
|
|
285
467
|
}
|
|
286
468
|
const y = Number(state.__vinext_scrollY);
|
|
@@ -289,6 +471,15 @@ function restorePopstateScrollPosition(state) {
|
|
|
289
471
|
window.scrollTo(x, y);
|
|
290
472
|
});
|
|
291
473
|
}
|
|
474
|
+
function isSameAppRoutePopstateTarget(href) {
|
|
475
|
+
if (!hasBrowserRouterState()) return false;
|
|
476
|
+
const target = new URL(href, window.location.origin);
|
|
477
|
+
const routerState = getBrowserRouterState();
|
|
478
|
+
const targetPathname = stripBasePath(target.pathname, __basePath);
|
|
479
|
+
const targetSearch = new URLSearchParams(target.search).toString();
|
|
480
|
+
const currentSearch = routerState.navigationSnapshot.searchParams.toString();
|
|
481
|
+
return targetPathname === routerState.navigationSnapshot.pathname && targetSearch === currentSearch;
|
|
482
|
+
}
|
|
292
483
|
let isPageUnloading = false;
|
|
293
484
|
const RSC_RELOAD_KEY = "__vinext_rsc_initial_reload__";
|
|
294
485
|
function readReloadFlag() {
|
|
@@ -326,16 +517,17 @@ function recoverFromBadInitialRscResponse(reason) {
|
|
|
326
517
|
}
|
|
327
518
|
async function readInitialRscStream() {
|
|
328
519
|
const vinext = getVinextBrowserGlobal();
|
|
329
|
-
|
|
520
|
+
const runtimeRsc = getNavigationRuntime()?.bootstrap.rsc;
|
|
521
|
+
if (runtimeRsc || vinext.__VINEXT_RSC_CHUNKS__ || vinext.__VINEXT_RSC_DONE__) {
|
|
330
522
|
clearReloadFlag();
|
|
331
523
|
clearHardNavigationLoopGuard();
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
return
|
|
524
|
+
if (runtimeRsc) {
|
|
525
|
+
applyRuntimeRscBootstrap(runtimeRsc);
|
|
526
|
+
if (runtimeRsc.done) {
|
|
527
|
+
registerNavigationRuntimeBootstrap({ rsc: void 0 });
|
|
528
|
+
return chunksToReadableStream(runtimeRsc.rsc);
|
|
529
|
+
}
|
|
530
|
+
return createProgressiveRscStream();
|
|
339
531
|
}
|
|
340
532
|
const params = vinext.__VINEXT_RSC_PARAMS__ ?? {};
|
|
341
533
|
if (vinext.__VINEXT_RSC_PARAMS__) applyClientParams(vinext.__VINEXT_RSC_PARAMS__);
|
|
@@ -361,23 +553,29 @@ async function readInitialRscStream() {
|
|
|
361
553
|
restoreHydrationNavigationContext(window.location.pathname, window.location.search, params);
|
|
362
554
|
return rscResponse.body;
|
|
363
555
|
}
|
|
556
|
+
function applyRuntimeRscBootstrap(rsc) {
|
|
557
|
+
const params = rsc.params ?? {};
|
|
558
|
+
if (rsc.params) applyClientParams(rsc.params);
|
|
559
|
+
if (rsc.nav) restoreHydrationNavigationContext(rsc.nav.pathname, rsc.nav.searchParams, params);
|
|
560
|
+
}
|
|
364
561
|
function registerServerActionCallback() {
|
|
365
562
|
setServerCallback(async (id, args) => {
|
|
366
563
|
const temporaryReferences = createTemporaryReferenceSet();
|
|
564
|
+
const actionInitiation = createActionInitiationSnapshot();
|
|
565
|
+
syncCurrentHistoryStatePreviousNextUrl(actionInitiation.routerState.previousNextUrl);
|
|
367
566
|
const body = await encodeReply(args, { temporaryReferences });
|
|
368
|
-
const currentState = getBrowserRouterState();
|
|
369
567
|
const { headers } = resolveServerActionRequestState({
|
|
370
568
|
actionId: id,
|
|
371
569
|
basePath: __basePath,
|
|
372
|
-
elements:
|
|
373
|
-
previousNextUrl:
|
|
570
|
+
elements: actionInitiation.routerState.elements,
|
|
571
|
+
previousNextUrl: actionInitiation.routerState.previousNextUrl
|
|
374
572
|
});
|
|
375
|
-
const fetchResponse = await fetch(await createRscRequestUrl(
|
|
573
|
+
const fetchResponse = await fetch(await createRscRequestUrl(actionInitiation.path, headers), {
|
|
376
574
|
method: "POST",
|
|
377
575
|
headers,
|
|
378
576
|
body
|
|
379
577
|
});
|
|
380
|
-
|
|
578
|
+
throwOnServerActionNotFound(fetchResponse, id);
|
|
381
579
|
const actionRedirect = fetchResponse.headers.get(ACTION_REDIRECT_HEADER);
|
|
382
580
|
if (actionRedirect) {
|
|
383
581
|
if (isDangerousScheme(actionRedirect)) {
|
|
@@ -386,26 +584,37 @@ function registerServerActionCallback() {
|
|
|
386
584
|
}
|
|
387
585
|
try {
|
|
388
586
|
if (new URL(actionRedirect, window.location.origin).origin !== window.location.origin) {
|
|
389
|
-
|
|
587
|
+
browserNavigationController.performHardNavigation(actionRedirect);
|
|
390
588
|
return;
|
|
391
589
|
}
|
|
392
590
|
} catch {}
|
|
393
591
|
clearClientNavigationCaches();
|
|
394
|
-
if ((fetchResponse.headers.get("x-action-redirect-type") ?? "replace") === "push")
|
|
395
|
-
else
|
|
592
|
+
if ((fetchResponse.headers.get("x-action-redirect-type") ?? "replace") === "push") browserNavigationController.performHardNavigation(actionRedirect, "assign");
|
|
593
|
+
else browserNavigationController.performHardNavigation(actionRedirect, "replace");
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
if (resolveRscCompatibilityNavigationDecision({
|
|
597
|
+
clientCompatibilityId: CLIENT_RSC_COMPATIBILITY_ID,
|
|
598
|
+
currentHref: actionInitiation.href,
|
|
599
|
+
origin: window.location.origin,
|
|
600
|
+
responseCompatibilityId: fetchResponse.headers.get("X-Vinext-RSC-Compatibility-Id"),
|
|
601
|
+
responseUrl: fetchResponse.url
|
|
602
|
+
}).kind === "hard-navigate") {
|
|
603
|
+
browserNavigationController.performHardNavigation(actionInitiation.href);
|
|
396
604
|
return;
|
|
397
605
|
}
|
|
606
|
+
const revalidation = parseServerActionRevalidationHeader(fetchResponse.headers);
|
|
398
607
|
const result = await createFromFetch(Promise.resolve(fetchResponse), { temporaryReferences });
|
|
399
|
-
if (shouldClearClientNavigationCachesForServerActionResult(result)) clearClientNavigationCaches();
|
|
608
|
+
if (shouldClearClientNavigationCachesForServerActionResult(result, revalidation)) clearClientNavigationCaches();
|
|
400
609
|
if (isServerActionResult(result)) {
|
|
401
|
-
if (result.root !== void 0) return commitSameUrlNavigatePayload(Promise.resolve(AppElementsWire.decode(result.root)), result.returnValue,
|
|
610
|
+
if (result.root !== void 0) return commitSameUrlNavigatePayload(Promise.resolve(AppElementsWire.decode(result.root)), actionInitiation, result.returnValue, revalidation);
|
|
402
611
|
if (result.returnValue) {
|
|
403
612
|
if (!result.returnValue.ok) throw result.returnValue.data;
|
|
404
613
|
return result.returnValue.data;
|
|
405
614
|
}
|
|
406
615
|
return;
|
|
407
616
|
}
|
|
408
|
-
return commitSameUrlNavigatePayload(Promise.resolve(AppElementsWire.decode(result)), void 0,
|
|
617
|
+
return commitSameUrlNavigatePayload(Promise.resolve(AppElementsWire.decode(result)), actionInitiation, void 0, revalidation);
|
|
409
618
|
});
|
|
410
619
|
}
|
|
411
620
|
async function main() {
|
|
@@ -418,7 +627,10 @@ function bootstrapHydration(rscStream) {
|
|
|
418
627
|
if (import.meta.env.DEV) installDevErrorOverlay();
|
|
419
628
|
const root = decodeAppElementsPromise(createFromReadableStream(rscStream));
|
|
420
629
|
const initialNavigationSnapshot = createClientNavigationRenderSnapshot(window.location.href, latestClientParams);
|
|
421
|
-
replaceHistoryStateWithoutNotify(
|
|
630
|
+
replaceHistoryStateWithoutNotify(createHistoryStateWithNavigationMetadata(window.history.state, {
|
|
631
|
+
previousNextUrl: null,
|
|
632
|
+
traversalIndex: currentHistoryTraversalIndex
|
|
633
|
+
}), "", window.location.href);
|
|
422
634
|
const onUncaughtError = import.meta.env.DEV ? devOnUncaughtError : createOnUncaughtError(() => pendingNavigationRecoveryHref);
|
|
423
635
|
const formState = consumeInitialFormState(getVinextBrowserGlobal());
|
|
424
636
|
const hydrateRootOptions = import.meta.env.DEV ? createVinextHydrateRootOptions({
|
|
@@ -429,142 +641,228 @@ function bootstrapHydration(rscStream) {
|
|
|
429
641
|
formState,
|
|
430
642
|
onUncaughtError
|
|
431
643
|
});
|
|
432
|
-
window.__VINEXT_RSC_ROOT__ =
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
setPendingPathname(url.pathname, navId);
|
|
464
|
-
const elementsAtNavStart = getBrowserRouterState().elements;
|
|
465
|
-
const mountedSlotsHeader = getMountedSlotIdsHeader(elementsAtNavStart);
|
|
466
|
-
const requestHeaders = createRscRequestHeaders({
|
|
467
|
-
interceptionContext: requestInterceptionContext,
|
|
468
|
-
renderMode: navigationKind === "refresh" ? APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI : void 0
|
|
469
|
-
});
|
|
470
|
-
if (mountedSlotsHeader) requestHeaders.set(VINEXT_MOUNTED_SLOTS_HEADER, mountedSlotsHeader);
|
|
471
|
-
const rscUrl = await createRscRequestUrl(url.pathname + url.search, requestHeaders);
|
|
472
|
-
const cachedRoute = getVisitedResponse(rscUrl, requestInterceptionContext, mountedSlotsHeader, navigationKind);
|
|
473
|
-
if (cachedRoute) {
|
|
474
|
-
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
475
|
-
const cachedParams = cachedRoute.params;
|
|
476
|
-
const cachedNavigationSnapshot = createClientNavigationRenderSnapshot(currentHref, cachedParams);
|
|
477
|
-
const cachedPayload = decodeAppElementsPromise(createFromFetch(Promise.resolve(restoreRscResponse(cachedRoute.response))));
|
|
644
|
+
window.__VINEXT_RSC_ROOT__ = hydrateRootInTransition({
|
|
645
|
+
children: createElement(BrowserRoot, {
|
|
646
|
+
initialElements: root,
|
|
647
|
+
initialNavigationSnapshot
|
|
648
|
+
}),
|
|
649
|
+
container: document,
|
|
650
|
+
hydrateRoot,
|
|
651
|
+
options: hydrateRootOptions,
|
|
652
|
+
startTransition
|
|
653
|
+
});
|
|
654
|
+
registerNavigationRuntimeFunctions({
|
|
655
|
+
clearNavigationCaches: clearClientNavigationCaches,
|
|
656
|
+
commitHashNavigation: commitHashOnlyNavigation,
|
|
657
|
+
navigate: async function navigateRsc(href, redirectDepth = 0, navigationKind = "navigate", historyUpdateMode, previousNextUrlOverride, programmaticTransition = false, traversalIntent) {
|
|
658
|
+
let pendingRouterState = null;
|
|
659
|
+
const navId = browserNavigationController.beginNavigation();
|
|
660
|
+
discardedServerActionRefreshScheduler.markNavigationStart();
|
|
661
|
+
let currentHref = href;
|
|
662
|
+
let currentHistoryMode = historyUpdateMode;
|
|
663
|
+
let currentPrevNextUrl = previousNextUrlOverride;
|
|
664
|
+
let redirectCount = redirectDepth;
|
|
665
|
+
let detachedNavigationCommits = false;
|
|
666
|
+
const activeTraversalIntent = navigationKind === "traverse" ? traversalIntent ?? resolveHistoryTraversalIntent({
|
|
667
|
+
currentHistoryIndex: currentHistoryTraversalIndex,
|
|
668
|
+
historyState: window.history.state
|
|
669
|
+
}) : null;
|
|
670
|
+
try {
|
|
671
|
+
const shouldUsePendingRouterState = programmaticTransition;
|
|
672
|
+
if (shouldUsePendingRouterState && hasBrowserRouterState()) pendingRouterState = beginPendingBrowserRouterState();
|
|
673
|
+
else {
|
|
674
|
+
await waitForBrowserRouterStateReady();
|
|
478
675
|
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
479
|
-
|
|
480
|
-
return;
|
|
676
|
+
if (shouldUsePendingRouterState) pendingRouterState = beginPendingBrowserRouterState();
|
|
481
677
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
678
|
+
while (true) {
|
|
679
|
+
const url = new URL(currentHref, window.location.origin);
|
|
680
|
+
const requestState = getRequestState(navigationKind, url.pathname, currentPrevNextUrl, activeTraversalIntent?.historyState);
|
|
681
|
+
const requestInterceptionContext = requestState.interceptionContext;
|
|
682
|
+
const requestPreviousNextUrl = requestState.previousNextUrl;
|
|
683
|
+
if (navigationKind === "refresh") syncCurrentHistoryStatePreviousNextUrl(requestPreviousNextUrl);
|
|
684
|
+
setPendingPathname(url.pathname, navId);
|
|
685
|
+
const elementsAtNavStart = getBrowserRouterState().elements;
|
|
686
|
+
const mountedSlotsHeader = getMountedSlotIdsHeader(elementsAtNavStart);
|
|
687
|
+
const requestHeaders = createRscRequestHeaders({
|
|
688
|
+
interceptionContext: requestInterceptionContext,
|
|
689
|
+
renderMode: navigationKind === "refresh" ? APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI : void 0
|
|
690
|
+
});
|
|
691
|
+
if (mountedSlotsHeader) requestHeaders.set(VINEXT_MOUNTED_SLOTS_HEADER, mountedSlotsHeader);
|
|
692
|
+
const rscUrl = await createRscRequestUrl(url.pathname + url.search, requestHeaders);
|
|
693
|
+
const cachedRoute = getVisitedResponse(rscUrl, requestInterceptionContext, mountedSlotsHeader, navigationKind);
|
|
694
|
+
if (cachedRoute) {
|
|
695
|
+
const compatibilityDecision = resolveRscCompatibilityNavigationDecision({
|
|
696
|
+
clientCompatibilityId: CLIENT_RSC_COMPATIBILITY_ID,
|
|
697
|
+
currentHref,
|
|
698
|
+
origin: window.location.origin,
|
|
699
|
+
responseCompatibilityId: cachedRoute.response.compatibilityIdHeader,
|
|
700
|
+
responseUrl: cachedRoute.response.url
|
|
701
|
+
});
|
|
702
|
+
if (compatibilityDecision.kind === "hard-navigate") {
|
|
703
|
+
browserNavigationController.performHardNavigation(compatibilityDecision.hardNavigationTarget);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
707
|
+
const cachedParams = cachedRoute.params;
|
|
708
|
+
const cachedNavigationSnapshot = createClientNavigationRenderSnapshot(currentHref, cachedParams);
|
|
709
|
+
const cachedPayload = decodeAppElementsPromise(createFromFetch(Promise.resolve(restoreRscResponse(cachedRoute.response))));
|
|
710
|
+
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
711
|
+
await renderNavigationPayload(cachedPayload, cachedNavigationSnapshot, currentHref, navId, currentHistoryMode, cachedParams, requestPreviousNextUrl, detachedNavigationCommits ? null : pendingRouterState, VISITED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, toActionType(navigationKind), toOperationLane(navigationKind), activeTraversalIntent);
|
|
712
|
+
return;
|
|
489
713
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (
|
|
714
|
+
let navResponse;
|
|
715
|
+
let navResponseUrl = null;
|
|
716
|
+
if (navigationKind !== "refresh") {
|
|
717
|
+
const prefetchedResponse = consumePrefetchResponse(rscUrl, requestInterceptionContext, mountedSlotsHeader);
|
|
718
|
+
if (prefetchedResponse) {
|
|
719
|
+
navResponse = restoreRscResponse(prefetchedResponse, false);
|
|
720
|
+
navResponseUrl = prefetchedResponse.url;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
if (!navResponse && navigationKind === "navigate") {
|
|
724
|
+
const routeManifest = getBrowserRouteManifest();
|
|
725
|
+
await learnOptimisticRouteTemplatesFromPrefetchCache({
|
|
726
|
+
interceptionContext: requestInterceptionContext,
|
|
727
|
+
mountedSlotsHeader,
|
|
728
|
+
routeManifest
|
|
729
|
+
});
|
|
730
|
+
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
731
|
+
if (routeManifest !== null) {
|
|
732
|
+
const optimisticPayload = resolveOptimisticNavigationPayload({
|
|
733
|
+
basePath: __basePath,
|
|
734
|
+
href: currentHref,
|
|
735
|
+
interceptionContext: requestInterceptionContext,
|
|
736
|
+
mountedSlotsHeader,
|
|
737
|
+
routeManifest,
|
|
738
|
+
templates: optimisticRouteTemplates
|
|
739
|
+
});
|
|
740
|
+
if (optimisticPayload !== null) {
|
|
741
|
+
detachedNavigationCommits = true;
|
|
742
|
+
const optimisticNavigationSnapshot = createClientNavigationRenderSnapshot(currentHref, optimisticPayload.params);
|
|
743
|
+
renderNavigationPayload(Promise.resolve(optimisticPayload.elements), optimisticNavigationSnapshot, currentHref, navId, currentHistoryMode, optimisticPayload.params, requestPreviousNextUrl, null, FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, toActionType(navigationKind), toOperationLane(navigationKind), activeTraversalIntent).catch((error) => {
|
|
744
|
+
if (browserNavigationController.isCurrentNavigation(navId)) console.error("[vinext] Optimistic RSC navigation error:", error);
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (!navResponse) navResponse = await fetch(rscUrl, {
|
|
750
|
+
headers: requestHeaders,
|
|
751
|
+
credentials: "include"
|
|
752
|
+
});
|
|
753
|
+
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
754
|
+
const isRscResponse = (navResponse.headers.get("content-type") ?? "").startsWith("text/x-component");
|
|
755
|
+
if (!navResponse.ok || !isRscResponse || !navResponse.body) {
|
|
756
|
+
const responseUrl = navResponseUrl ?? navResponse.url;
|
|
757
|
+
browserNavigationController.performHardNavigation(resolveHardNavigationTargetFromRscResponse(responseUrl, currentHref, window.location.origin));
|
|
758
|
+
return;
|
|
508
759
|
}
|
|
509
|
-
|
|
760
|
+
const compatibilityDecision = resolveRscCompatibilityNavigationDecision({
|
|
761
|
+
clientCompatibilityId: CLIENT_RSC_COMPATIBILITY_ID,
|
|
762
|
+
currentHref,
|
|
763
|
+
origin: window.location.origin,
|
|
764
|
+
responseCompatibilityId: navResponse.headers.get(VINEXT_RSC_COMPATIBILITY_ID_HEADER),
|
|
765
|
+
responseUrl: navResponseUrl ?? navResponse.url
|
|
766
|
+
});
|
|
767
|
+
if (compatibilityDecision.kind === "hard-navigate") {
|
|
768
|
+
browserNavigationController.performHardNavigation(compatibilityDecision.hardNavigationTarget);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
const redirectDecision = resolveRscRedirectLifecycleHop({
|
|
772
|
+
currentHref,
|
|
773
|
+
historyUpdateMode: currentHistoryMode ?? "replace",
|
|
774
|
+
origin: window.location.origin,
|
|
775
|
+
redirectDepth: redirectCount,
|
|
776
|
+
requestPreviousNextUrl,
|
|
777
|
+
responseUrl: navResponseUrl ?? navResponse.url
|
|
778
|
+
});
|
|
779
|
+
if (redirectDecision.kind === "terminal-hard-navigation") {
|
|
780
|
+
if (redirectDecision.reason === "maxRedirectsExceeded") console.error("[vinext] Too many RSC redirects — aborting navigation to prevent infinite loop.");
|
|
781
|
+
browserNavigationController.performHardNavigation(redirectDecision.href);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
if (redirectDecision.kind === "follow") {
|
|
785
|
+
currentHref = redirectDecision.href;
|
|
786
|
+
currentHistoryMode = redirectDecision.historyUpdateMode;
|
|
787
|
+
currentPrevNextUrl = redirectDecision.previousNextUrl;
|
|
788
|
+
redirectCount = redirectDecision.redirectDepth;
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
const flightRedirectTarget = navResponse.headers.get(VINEXT_RSC_REDIRECT_HEADER);
|
|
792
|
+
if (flightRedirectTarget) {
|
|
793
|
+
navResponse.body?.cancel().catch(() => {});
|
|
794
|
+
const resolvedTarget = new URL(flightRedirectTarget, window.location.origin);
|
|
795
|
+
if (resolvedTarget.origin !== window.location.origin) {
|
|
796
|
+
browserNavigationController.performHardNavigation(resolvedTarget.href);
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
if (redirectCount >= 10) {
|
|
800
|
+
console.error("[vinext] Too many RSC redirects — aborting navigation to prevent infinite loop.");
|
|
801
|
+
browserNavigationController.performHardNavigation(resolvedTarget.href);
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
currentHref = `${resolvedTarget.pathname}${resolvedTarget.search}${resolvedTarget.hash}`;
|
|
805
|
+
redirectCount += 1;
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
const navParams = parseEncodedJsonHeader(navResponse.headers.get("X-Vinext-Params")) ?? {};
|
|
809
|
+
const navigationSnapshot = createClientNavigationRenderSnapshot(currentHref, navParams);
|
|
810
|
+
const navBody = navResponse.body;
|
|
811
|
+
if (!navBody) return;
|
|
812
|
+
const [reactBranch, cacheBranch] = navBody.tee();
|
|
813
|
+
const reactResponse = new Response(reactBranch, {
|
|
814
|
+
status: navResponse.status,
|
|
815
|
+
headers: navResponse.headers
|
|
816
|
+
});
|
|
817
|
+
const cacheBufferPromise = new Response(cacheBranch).arrayBuffer();
|
|
818
|
+
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
819
|
+
const rscPayload = decodeAppElementsPromise(createFromFetch(Promise.resolve(reactResponse)));
|
|
820
|
+
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
821
|
+
if (await renderNavigationPayload(rscPayload, navigationSnapshot, currentHref, navId, currentHistoryMode, navParams, requestPreviousNextUrl, detachedNavigationCommits ? null : pendingRouterState, FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, toActionType(navigationKind), toOperationLane(navigationKind), activeTraversalIntent) !== "committed") return;
|
|
822
|
+
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
823
|
+
const resolvedElements = await rscPayload;
|
|
824
|
+
const metadata = AppElementsWire.readMetadata(resolvedElements);
|
|
825
|
+
if (!isCacheRestorableAppPayloadMetadata(metadata)) {
|
|
826
|
+
cacheBufferPromise.catch(() => {});
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
const cacheBuffer = await cacheBufferPromise;
|
|
830
|
+
storeVisitedResponseSnapshot(rscUrl, resolveVisitedResponseInterceptionContext(requestInterceptionContext, metadata.interceptionContext), createCachedRscResponseSnapshot(navResponse, cacheBuffer, navResponseUrl), navParams);
|
|
510
831
|
return;
|
|
511
832
|
}
|
|
512
|
-
|
|
513
|
-
stripRscCacheBustingSearchParam(finalUrl);
|
|
514
|
-
const requestedUrl = new URL(rscUrl, window.location.origin);
|
|
515
|
-
if (finalUrl.pathname !== requestedUrl.pathname) {
|
|
516
|
-
const destinationPath = stripRscSuffix(finalUrl.pathname) + finalUrl.search;
|
|
517
|
-
replaceHistoryStateWithoutNotify(createHistoryStateWithPreviousNextUrl(null, requestPreviousNextUrl), "", destinationPath);
|
|
518
|
-
currentHref = destinationPath;
|
|
519
|
-
currentHistoryMode = void 0;
|
|
520
|
-
currentPrevNextUrl = requestPreviousNextUrl;
|
|
521
|
-
redirectCount += 1;
|
|
522
|
-
continue;
|
|
523
|
-
}
|
|
524
|
-
const navParams = parseEncodedJsonHeader(navResponse.headers.get("X-Vinext-Params")) ?? {};
|
|
525
|
-
const navigationSnapshot = createClientNavigationRenderSnapshot(currentHref, navParams);
|
|
526
|
-
const navBody = navResponse.body;
|
|
527
|
-
if (!navBody) return;
|
|
528
|
-
const [reactBranch, cacheBranch] = navBody.tee();
|
|
529
|
-
const reactResponse = new Response(reactBranch, {
|
|
530
|
-
status: navResponse.status,
|
|
531
|
-
headers: navResponse.headers
|
|
532
|
-
});
|
|
533
|
-
const cacheBufferPromise = new Response(cacheBranch).arrayBuffer();
|
|
534
|
-
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
535
|
-
const rscPayload = decodeAppElementsPromise(createFromFetch(Promise.resolve(reactResponse)));
|
|
536
|
-
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
537
|
-
if (await renderNavigationPayload(rscPayload, navigationSnapshot, currentHref, navId, currentHistoryMode, navParams, requestPreviousNextUrl, pendingRouterState, toActionType(navigationKind), toOperationLane(navigationKind)) !== "committed") return;
|
|
833
|
+
} catch (error) {
|
|
538
834
|
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
contentType: navResponse.headers.get("content-type") ?? "text/x-component",
|
|
545
|
-
mountedSlotsHeader: navResponse.headers.get(VINEXT_MOUNTED_SLOTS_HEADER),
|
|
546
|
-
paramsHeader: navResponse.headers.get(VINEXT_PARAMS_HEADER),
|
|
547
|
-
url: navResponse.url
|
|
548
|
-
}, navParams);
|
|
549
|
-
return;
|
|
835
|
+
if (!isPageUnloading) console.error("[vinext] RSC navigation error:", error);
|
|
836
|
+
browserNavigationController.performHardNavigation(currentHref);
|
|
837
|
+
} finally {
|
|
838
|
+
browserNavigationController.finalizeNavigation(navId, pendingRouterState);
|
|
839
|
+
discardedServerActionRefreshScheduler.markNavigationSettled();
|
|
550
840
|
}
|
|
551
|
-
} catch (error) {
|
|
552
|
-
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
553
|
-
if (!isPageUnloading) console.error("[vinext] RSC navigation error:", error);
|
|
554
|
-
window.location.href = currentHref;
|
|
555
|
-
} finally {
|
|
556
|
-
browserNavigationController.finalizeNavigation(navId, pendingRouterState);
|
|
557
841
|
}
|
|
558
|
-
};
|
|
842
|
+
});
|
|
559
843
|
if ("scrollRestoration" in history) history.scrollRestoration = "manual";
|
|
844
|
+
const handlePopstate = createPopstateRestoreHandler({
|
|
845
|
+
getActiveNavigationId: browserNavigationController.getActiveNavigationId.bind(browserNavigationController),
|
|
846
|
+
getPendingNavigation: () => window.__VINEXT_RSC_PENDING__,
|
|
847
|
+
getNavigate: () => getNavigationRuntime()?.functions.navigate,
|
|
848
|
+
isCurrentNavigation: browserNavigationController.isCurrentNavigation.bind(browserNavigationController),
|
|
849
|
+
notifyAppRouterTransitionStart: (href) => {
|
|
850
|
+
notifyAppRouterTransitionStart(href, "traverse");
|
|
851
|
+
},
|
|
852
|
+
restorePopstateScrollPosition,
|
|
853
|
+
setPendingNavigation: (pendingNavigation) => {
|
|
854
|
+
window.__VINEXT_RSC_PENDING__ = pendingNavigation;
|
|
855
|
+
}
|
|
856
|
+
});
|
|
560
857
|
window.addEventListener("popstate", (event) => {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
858
|
+
const href = window.location.href;
|
|
859
|
+
if (isSameAppRoutePopstateTarget(href)) {
|
|
860
|
+
notifyAppRouterTransitionStart(href, "traverse");
|
|
861
|
+
commitTraversalIndexFromHistoryState(event.state);
|
|
565
862
|
restorePopstateScrollPosition(event.state);
|
|
566
|
-
|
|
567
|
-
}
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
handlePopstate(event);
|
|
568
866
|
});
|
|
569
867
|
if (import.meta.hot) {
|
|
570
868
|
const handleRscUpdate = async () => {
|