vinext 0.0.53 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/build/inline-css.d.ts +7 -0
- package/dist/build/inline-css.js +50 -0
- package/dist/build/inline-css.js.map +1 -0
- package/dist/build/prerender.js +2 -1
- package/dist/build/prerender.js.map +1 -1
- package/dist/check.js +19 -3
- package/dist/check.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +3 -1
- package/dist/client/navigation-runtime.js +1 -1
- package/dist/client/navigation-runtime.js.map +1 -1
- package/dist/client/window-next.d.ts +7 -0
- package/dist/client/window-next.js.map +1 -1
- package/dist/config/next-config.d.ts +97 -2
- package/dist/config/next-config.js +155 -6
- package/dist/config/next-config.js.map +1 -1
- package/dist/config/tsconfig-paths.d.ts +12 -3
- package/dist/config/tsconfig-paths.js +55 -24
- package/dist/config/tsconfig-paths.js.map +1 -1
- package/dist/deploy.js +13 -0
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +11 -1
- package/dist/entries/app-browser-entry.js +16 -6
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +9 -1
- package/dist/entries/app-rsc-entry.js +30 -5
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +21 -1
- package/dist/entries/app-rsc-manifest.js +28 -9
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/pages-client-entry.d.ts +4 -1
- package/dist/entries/pages-client-entry.js +18 -2
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +123 -8
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +1 -10
- package/dist/entries/runtime-entry-module.js +2 -12
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +144 -44
- package/dist/index.js.map +1 -1
- package/dist/plugins/import-meta-url.d.ts +16 -0
- package/dist/plugins/import-meta-url.js +193 -0
- package/dist/plugins/import-meta-url.js.map +1 -0
- package/dist/plugins/remove-console.d.ts +16 -0
- package/dist/plugins/remove-console.js +176 -0
- package/dist/plugins/remove-console.js.map +1 -0
- package/dist/routing/app-route-graph.d.ts +24 -1
- package/dist/routing/app-route-graph.js +52 -4
- 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/file-matcher.d.ts +21 -1
- package/dist/routing/file-matcher.js +39 -1
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.d.ts +1 -1
- package/dist/routing/pages-router.js +10 -3
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-browser-action-result.d.ts +9 -16
- package/dist/server/app-browser-action-result.js +25 -14
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +195 -60
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-mpa-navigation.d.ts +16 -0
- package/dist/server/app-browser-mpa-navigation.js +36 -0
- package/dist/server/app-browser-mpa-navigation.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +2 -0
- package/dist/server/app-browser-navigation-controller.js +4 -0
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-popstate.d.ts +3 -1
- package/dist/server/app-browser-popstate.js +15 -1
- package/dist/server/app-browser-popstate.js.map +1 -1
- package/dist/server/app-browser-state.js +2 -1
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +13 -4
- package/dist/server/app-elements-wire.js +10 -1
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.d.ts +15 -5
- package/dist/server/app-fallback-renderer.js +10 -4
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-inline-css-client.d.ts +7 -0
- package/dist/server/app-inline-css-client.js +37 -0
- package/dist/server/app-inline-css-client.js.map +1 -0
- package/dist/server/app-layout-param-observation.d.ts +30 -0
- package/dist/server/app-layout-param-observation.js +130 -0
- package/dist/server/app-layout-param-observation.js.map +1 -0
- package/dist/server/app-page-boundary-render.js +2 -2
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +21 -1
- package/dist/server/app-page-boundary.js +28 -3
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +7 -3
- package/dist/server/app-page-cache.js +7 -7
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +10 -1
- package/dist/server/app-page-dispatch.js +126 -79
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.js +12 -28
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-params.d.ts +2 -1
- package/dist/server/app-page-params.js +14 -1
- package/dist/server/app-page-params.js.map +1 -1
- package/dist/server/app-page-probe.d.ts +12 -1
- package/dist/server/app-page-probe.js +116 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render-identity.d.ts +22 -0
- package/dist/server/app-page-render-identity.js +42 -0
- package/dist/server/app-page-render-identity.js.map +1 -0
- package/dist/server/app-page-render.d.ts +8 -1
- package/dist/server/app-page-render.js +4 -1
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +6 -3
- package/dist/server/app-page-request.js +5 -2
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.js +2 -2
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +15 -0
- package/dist/server/app-page-route-wiring.js +7 -5
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +11 -0
- package/dist/server/app-page-stream.js +1 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-route-handler-response.js +37 -5
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +3 -2
- package/dist/server/app-rsc-cache-busting.js +9 -7
- package/dist/server/app-rsc-cache-busting.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +14 -3
- package/dist/server/app-rsc-handler.js +56 -6
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +2 -1
- package/dist/server/app-rsc-request-normalization.js +3 -2
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-segment-config.d.ts +1 -1
- package/dist/server/app-segment-config.js +4 -1
- package/dist/server/app-segment-config.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +26 -3
- package/dist/server/app-server-action-execution.js +240 -29
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +6 -0
- package/dist/server/app-ssr-entry.js +22 -7
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-error-meta.js +3 -3
- package/dist/server/app-ssr-error-meta.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +2 -1
- package/dist/server/app-ssr-stream.js +176 -31
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +2 -1
- package/dist/server/artifact-compatibility.js +10 -1
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/client-reuse-manifest.d.ts +9 -4
- package/dist/server/client-reuse-manifest.js +2 -1
- package/dist/server/client-reuse-manifest.js.map +1 -1
- package/dist/server/client-trace-metadata.d.ts +31 -0
- package/dist/server/client-trace-metadata.js +83 -0
- package/dist/server/client-trace-metadata.js.map +1 -0
- package/dist/server/cookie-utils.d.ts +13 -0
- package/dist/server/cookie-utils.js +20 -0
- package/dist/server/cookie-utils.js.map +1 -0
- package/dist/server/dev-server.d.ts +8 -1
- package/dist/server/dev-server.js +83 -12
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/document-initial-head.d.ts +7 -0
- package/dist/server/document-initial-head.js +35 -0
- package/dist/server/document-initial-head.js.map +1 -0
- package/dist/server/html.d.ts +2 -1
- package/dist/server/html.js +6 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/isr-cache.d.ts +7 -5
- package/dist/server/isr-cache.js +17 -6
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/middleware-runtime.js +1 -2
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/pages-document-initial-props.d.ts +89 -0
- package/dist/server/pages-document-initial-props.js +140 -0
- package/dist/server/pages-document-initial-props.js.map +1 -0
- package/dist/server/pages-node-compat.js +1 -1
- package/dist/server/pages-page-data.js +3 -0
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-method.d.ts +48 -0
- package/dist/server/pages-page-method.js +19 -0
- package/dist/server/pages-page-method.js.map +1 -0
- package/dist/server/pages-page-response.d.ts +20 -0
- package/dist/server/pages-page-response.js +37 -7
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/pages-serializable-props.d.ts +25 -0
- package/dist/server/pages-serializable-props.js +69 -0
- package/dist/server/pages-serializable-props.js.map +1 -0
- package/dist/server/prod-server.js +16 -6
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/server-action-not-found.js +3 -2
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/skip-cache-proof.d.ts +23 -2
- package/dist/server/skip-cache-proof.js +81 -12
- package/dist/server/skip-cache-proof.js.map +1 -1
- package/dist/server/static-file-cache.js +2 -1
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/server/static-layout-client-reuse-proof.d.ts +16 -0
- package/dist/server/static-layout-client-reuse-proof.js +35 -0
- package/dist/server/static-layout-client-reuse-proof.js.map +1 -0
- package/dist/shims/app-router-scroll-state.d.ts +4 -2
- package/dist/shims/app-router-scroll-state.js +16 -3
- package/dist/shims/app-router-scroll-state.js.map +1 -1
- package/dist/shims/app-router-scroll.d.ts +16 -2
- package/dist/shims/app-router-scroll.js +18 -3
- package/dist/shims/app-router-scroll.js.map +1 -1
- package/dist/shims/cache.d.ts +27 -1
- package/dist/shims/cache.js +108 -6
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/document.d.ts +6 -0
- package/dist/shims/document.js +7 -8
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +4 -4
- package/dist/shims/error-boundary.js +27 -28
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.js +3 -0
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +16 -5
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/hash-scroll.d.ts +4 -1
- package/dist/shims/hash-scroll.js +13 -1
- package/dist/shims/hash-scroll.js.map +1 -1
- package/dist/shims/head-state.d.ts +1 -0
- package/dist/shims/head-state.js +18 -3
- package/dist/shims/head-state.js.map +1 -1
- package/dist/shims/head.d.ts +35 -1
- package/dist/shims/head.js +113 -14
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +7 -0
- package/dist/shims/headers.js +9 -1
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/internal/app-route-detection.d.ts +37 -0
- package/dist/shims/internal/app-route-detection.js +69 -0
- package/dist/shims/internal/app-route-detection.js.map +1 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +56 -0
- package/dist/shims/internal/pages-data-fetch-dedup.js +70 -0
- package/dist/shims/internal/pages-data-fetch-dedup.js.map +1 -0
- package/dist/shims/link.d.ts +18 -2
- package/dist/shims/link.js +98 -8
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +7 -6
- package/dist/shims/metadata.js +9 -5
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +40 -3
- package/dist/shims/navigation.js +124 -25
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/router.d.ts +5 -0
- package/dist/shims/router.js +51 -21
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.d.ts +11 -1
- package/dist/shims/script.js +75 -6
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/thenable-params.d.ts +5 -2
- package/dist/shims/thenable-params.js +25 -1
- package/dist/shims/thenable-params.js.map +1 -1
- package/dist/shims/unified-request-context.js +3 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/utils/client-build-manifest.d.ts +15 -0
- package/dist/utils/client-build-manifest.js +54 -0
- package/dist/utils/client-build-manifest.js.map +1 -0
- package/dist/utils/hash.js +1 -1
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/path.d.ts +13 -0
- package/dist/utils/path.js +16 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/vite-version.d.ts +11 -0
- package/dist/utils/vite-version.js +36 -0
- package/dist/utils/vite-version.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,25 +1,28 @@
|
|
|
1
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
|
+
import { ACTION_REDIRECT_HEADER, ACTION_REDIRECT_STATUS_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER, VINEXT_RSC_REDIRECT_HEADER } from "./headers.js";
|
|
3
3
|
import { DANGEROUS_URL_BLOCK_MESSAGE, isDangerousScheme } from "../shims/url-safety.js";
|
|
4
4
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
5
5
|
import { APP_RSC_RENDER_MODE_REFRESH_PRESERVE_UI } from "./app-rsc-render-mode.js";
|
|
6
|
+
import { getMountedSlotIdsHeader, resolveVisitedResponseInterceptionContext } from "./app-elements.js";
|
|
7
|
+
import { AppRouterContext } from "../shims/internal/app-router-context.js";
|
|
6
8
|
import { installWindowNext } from "../client/window-next.js";
|
|
7
|
-
import { scrollToHashTargetOnNextFrame } from "../shims/hash-scroll.js";
|
|
9
|
+
import { retryScrollTo, scrollToHashTargetOnNextFrame } from "../shims/hash-scroll.js";
|
|
8
10
|
import { getNavigationRuntime, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions } from "../client/navigation-runtime.js";
|
|
9
11
|
import { notifyAppRouterTransitionStart } from "../client/instrumentation-client-state.js";
|
|
10
|
-
import { getMountedSlotIdsHeader, resolveVisitedResponseInterceptionContext } from "./app-elements.js";
|
|
11
12
|
import { resolveManifestNavigationInterceptionContext } from "./app-browser-interception-context.js";
|
|
12
13
|
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 {
|
|
15
|
-
import { __basePath, appRouterInstance, commitClientNavigationState,
|
|
14
|
+
import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, createRscRequestHeaders, createRscRequestUrl, createServerActionRequestUrl, getVinextRscCompatibilityId, resolveHardNavigationTargetFromRscResponse, resolveRscCompatibilityNavigationDecision } from "./app-rsc-cache-busting.js";
|
|
15
|
+
import { beginAppRouterScrollIntent, consumeAppRouterScrollIntent } from "../shims/app-router-scroll-state.js";
|
|
16
|
+
import { __basePath, appRouterInstance, commitClientNavigationState, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, decodeRedirectError, getClientNavigationRenderContext, getPrefetchCache, invalidatePrefetchCache, isRedirectError, pushHistoryStateWithoutNotify, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, useRouter } from "../shims/navigation.js";
|
|
16
17
|
import { DevRecoveryBoundary, RedirectBoundary } from "../shims/error-boundary.js";
|
|
18
|
+
import { AppRouterScrollCommitProvider } from "../shims/app-router-scroll.js";
|
|
17
19
|
import { ElementsContext, Slot } from "../shims/slot.js";
|
|
18
20
|
import "../client/instrumentation-client.js";
|
|
19
|
-
import { createDiscardedServerActionRefreshScheduler, createServerActionInitiationSnapshot, isServerActionResult, parseServerActionRevalidationHeader,
|
|
21
|
+
import { createDiscardedServerActionRefreshScheduler, createServerActionInitiationSnapshot, isServerActionResult, normalizeServerActionThrownValue, parseServerActionRevalidationHeader, readInvalidServerActionResponseError, resolveServerActionRedirectCompatibilityHardNavigationTarget, shouldCheckRscCompatibilityForServerActionResponse, shouldClearClientNavigationCachesForServerActionResult } from "./app-browser-action-result.js";
|
|
20
22
|
import { chunksToReadableStream, createProgressiveRscStream, getVinextBrowserGlobal } from "./app-browser-stream.js";
|
|
21
23
|
import { FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, VISITED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, isCacheRestorableAppPayloadMetadata, resolveInterceptionContextFromPreviousNextUrl, resolveServerActionRequestState } from "./app-browser-state.js";
|
|
22
24
|
import { clearHardNavigationLoopGuard, createAppBrowserNavigationController } from "./app-browser-navigation-controller.js";
|
|
25
|
+
import { AppBrowserMpaNavigationScheduler } from "./app-browser-mpa-navigation.js";
|
|
23
26
|
import { consumeInitialFormState, createVinextHydrateRootOptions, hydrateRootInTransition } from "./app-browser-hydration.js";
|
|
24
27
|
import { createPopstateRestoreHandler } from "./app-browser-popstate.js";
|
|
25
28
|
import { createOnUncaughtError } from "./app-browser-error.js";
|
|
@@ -28,7 +31,8 @@ import { devOnCaughtError, devOnUncaughtError, installDevErrorOverlay } from "./
|
|
|
28
31
|
import { throwOnServerActionNotFound } from "./server-action-not-found.js";
|
|
29
32
|
import { resolveRscRedirectLifecycleHop } from "./app-browser-rsc-redirect.js";
|
|
30
33
|
import { createOptimisticRouteTemplate, getOptimisticPrefetchSourceKey, getOptimisticRouteTemplateKey, resolveOptimisticNavigationPayload } from "./app-optimistic-routing.js";
|
|
31
|
-
import {
|
|
34
|
+
import { removeStylesheetLinksCoveredByInlineCss } from "./app-inline-css-client.js";
|
|
35
|
+
import { createElement, startTransition, use, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
32
36
|
import { createFromFetch, createFromReadableStream, createTemporaryReferenceSet, encodeReply, setServerCallback } from "@vitejs/plugin-rsc/browser";
|
|
33
37
|
import { hydrateRoot } from "react-dom/client";
|
|
34
38
|
//#region src/server/app-browser-entry.ts
|
|
@@ -62,6 +66,16 @@ const discardedServerActionRefreshScheduler = createDiscardedServerActionRefresh
|
|
|
62
66
|
getNavigationRuntime()?.functions.navigate?.(window.location.href, 0, "refresh", void 0, void 0, true);
|
|
63
67
|
} });
|
|
64
68
|
const NavigationCommitSignal = browserNavigationController.NavigationCommitSignal;
|
|
69
|
+
const ACTION_HTTP_FALLBACK_ROBOTS_META_ATTR = "data-vinext-action-http-fallback";
|
|
70
|
+
function syncServerActionHttpFallbackHead(status) {
|
|
71
|
+
document.head.querySelectorAll(`meta[${ACTION_HTTP_FALLBACK_ROBOTS_META_ATTR}="robots"]`).forEach((node) => node.remove());
|
|
72
|
+
if (status !== 404) return;
|
|
73
|
+
const robots = document.createElement("meta");
|
|
74
|
+
robots.name = "robots";
|
|
75
|
+
robots.content = "noindex";
|
|
76
|
+
robots.setAttribute(ACTION_HTTP_FALLBACK_ROBOTS_META_ATTR, "robots");
|
|
77
|
+
document.head.appendChild(robots);
|
|
78
|
+
}
|
|
65
79
|
function parseEncodedJsonHeader(value) {
|
|
66
80
|
if (!value) return null;
|
|
67
81
|
try {
|
|
@@ -77,6 +91,8 @@ let latestClientParams = {};
|
|
|
77
91
|
const visitedResponseCache = /* @__PURE__ */ new Map();
|
|
78
92
|
let browserRouterStateHasEverCommitted = false;
|
|
79
93
|
let pendingNavigationRecoveryHref = null;
|
|
94
|
+
const mpaNavigationScheduler = new AppBrowserMpaNavigationScheduler();
|
|
95
|
+
const unresolvedMpaNavigation = new Promise(() => {});
|
|
80
96
|
let currentHistoryTraversalIndex = readHistoryStateTraversalIndex(window.history.state) ?? 0;
|
|
81
97
|
let nextHistoryTraversalIndex = currentHistoryTraversalIndex;
|
|
82
98
|
function allocateNavigationHistoryTraversalIndex(historyUpdateMode) {
|
|
@@ -267,7 +283,8 @@ function createNavigationCommitEffect(options) {
|
|
|
267
283
|
commitClientNavigationState(navId);
|
|
268
284
|
};
|
|
269
285
|
}
|
|
270
|
-
async function renderNavigationPayload(payload, navigationSnapshot, targetHref, navId, historyUpdateMode, params, previousNextUrl, pendingRouterState, payloadOrigin, actionType = "navigate", operationLane = "navigation", traversalIntent = null) {
|
|
286
|
+
async function renderNavigationPayload(payload, navigationSnapshot, targetHref, navId, historyUpdateMode, params, previousNextUrl, pendingRouterState, payloadOrigin, actionType = "navigate", operationLane = "navigation", traversalIntent = null, scrollIntent = null) {
|
|
287
|
+
syncServerActionHttpFallbackHead(null);
|
|
271
288
|
try {
|
|
272
289
|
return await browserNavigationController.renderNavigationPayload({
|
|
273
290
|
actionType,
|
|
@@ -283,6 +300,7 @@ async function renderNavigationPayload(payload, navigationSnapshot, targetHref,
|
|
|
283
300
|
params,
|
|
284
301
|
pendingRouterState,
|
|
285
302
|
previousNextUrl,
|
|
303
|
+
scrollIntent,
|
|
286
304
|
targetHistoryIndex: traversalIntent === null ? void 0 : traversalIntent.targetHistoryIndex,
|
|
287
305
|
targetHref,
|
|
288
306
|
navId
|
|
@@ -292,6 +310,52 @@ async function renderNavigationPayload(payload, navigationSnapshot, targetHref,
|
|
|
292
310
|
throw error;
|
|
293
311
|
}
|
|
294
312
|
}
|
|
313
|
+
function resolveActionRedirectTarget(response) {
|
|
314
|
+
const actionRedirect = response.headers.get(ACTION_REDIRECT_HEADER);
|
|
315
|
+
if (!actionRedirect) return null;
|
|
316
|
+
if (isDangerousScheme(actionRedirect)) {
|
|
317
|
+
console.error(DANGEROUS_URL_BLOCK_MESSAGE);
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
try {
|
|
321
|
+
let redirectUrl;
|
|
322
|
+
if (actionRedirect.startsWith("/") || /^[a-z]+:/i.test(actionRedirect)) redirectUrl = new URL(actionRedirect, window.location.href);
|
|
323
|
+
else {
|
|
324
|
+
const baseParsed = new URL(window.location.href);
|
|
325
|
+
let baseDir = baseParsed.pathname;
|
|
326
|
+
if (!baseDir.endsWith("/")) baseDir = baseDir + "/";
|
|
327
|
+
redirectUrl = new URL(actionRedirect, `${baseParsed.origin}${baseDir}${baseParsed.search}`);
|
|
328
|
+
}
|
|
329
|
+
if (redirectUrl.origin !== window.location.origin) {
|
|
330
|
+
browserNavigationController.performHardNavigation(actionRedirect);
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
const statusHeader = response.headers.get(ACTION_REDIRECT_STATUS_HEADER);
|
|
334
|
+
const status = statusHeader ? parseInt(statusHeader, 10) : 307;
|
|
335
|
+
return {
|
|
336
|
+
href: redirectUrl.href,
|
|
337
|
+
type: response.headers.get("x-action-redirect-type") ?? "push",
|
|
338
|
+
status
|
|
339
|
+
};
|
|
340
|
+
} catch {
|
|
341
|
+
browserNavigationController.performHardNavigation(actionRedirect);
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
var ServerActionRedirectError = class extends Error {
|
|
346
|
+
digest;
|
|
347
|
+
handled = true;
|
|
348
|
+
constructor(target) {
|
|
349
|
+
super("NEXT_REDIRECT");
|
|
350
|
+
const redirectUrl = new URL(target.href, window.location.href);
|
|
351
|
+
const redirectHref = redirectUrl.pathname + redirectUrl.search + redirectUrl.hash;
|
|
352
|
+
const redirectType = target.type === "push" ? "push" : "replace";
|
|
353
|
+
this.digest = `NEXT_REDIRECT;${redirectType};${encodeURIComponent(redirectHref)};${target.status};`;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
function createServerActionRedirectError(target) {
|
|
357
|
+
return new ServerActionRedirectError(target);
|
|
358
|
+
}
|
|
295
359
|
async function commitSameUrlNavigatePayload(nextElements, actionInitiation, returnValue, revalidation = "none") {
|
|
296
360
|
const navigationSnapshot = createClientNavigationRenderSnapshot(actionInitiation.href, actionInitiation.routerState.navigationSnapshot.params);
|
|
297
361
|
return browserNavigationController.commitSameUrlNavigatePayload(nextElements, navigationSnapshot, returnValue, actionInitiation.routerState, {
|
|
@@ -395,6 +459,35 @@ function getRequestState(navigationKind, targetPathname, previousNextUrlOverride
|
|
|
395
459
|
function handleDevRecoveryBoundaryCatch(resetKey) {
|
|
396
460
|
browserNavigationController.drainPrePaintEffects(resetKey);
|
|
397
461
|
}
|
|
462
|
+
function isMpaNavigationState(value) {
|
|
463
|
+
return value !== null && typeof value === "object" && "kind" in value && value.kind === "mpa-navigation";
|
|
464
|
+
}
|
|
465
|
+
function performMpaNavigation(href, historyUpdateMode) {
|
|
466
|
+
mpaNavigationScheduler.navigate(window, href, historyUpdateMode);
|
|
467
|
+
}
|
|
468
|
+
function AppRouterRedirectBridge({ children }) {
|
|
469
|
+
const router = useRouter();
|
|
470
|
+
useEffect(() => {
|
|
471
|
+
const handleUnhandledRedirect = (event) => {
|
|
472
|
+
const error = "reason" in event ? event.reason : event.error;
|
|
473
|
+
if (!isRedirectError(error)) return;
|
|
474
|
+
const result = decodeRedirectError(error.digest);
|
|
475
|
+
if (!result) return;
|
|
476
|
+
event.preventDefault();
|
|
477
|
+
startTransition(() => {
|
|
478
|
+
if (result.type === "push") router.push(result.url);
|
|
479
|
+
else router.replace(result.url);
|
|
480
|
+
});
|
|
481
|
+
};
|
|
482
|
+
window.addEventListener("error", handleUnhandledRedirect);
|
|
483
|
+
window.addEventListener("unhandledrejection", handleUnhandledRedirect);
|
|
484
|
+
return () => {
|
|
485
|
+
window.removeEventListener("error", handleUnhandledRedirect);
|
|
486
|
+
window.removeEventListener("unhandledrejection", handleUnhandledRedirect);
|
|
487
|
+
};
|
|
488
|
+
}, [router]);
|
|
489
|
+
return children ?? null;
|
|
490
|
+
}
|
|
398
491
|
function decodeAppElementsPromise(payload) {
|
|
399
492
|
return Promise.resolve(payload).then((elements) => AppElementsWire.decode(elements));
|
|
400
493
|
}
|
|
@@ -416,11 +509,26 @@ function BrowserRoot({ initialElements, initialNavigationSnapshot }) {
|
|
|
416
509
|
slotBindings: initialMetadata.slotBindings,
|
|
417
510
|
visibleCommitVersion: 0
|
|
418
511
|
});
|
|
512
|
+
if (isMpaNavigationState(treeStateValue)) {
|
|
513
|
+
performMpaNavigation(treeStateValue.href, treeStateValue.historyUpdateMode);
|
|
514
|
+
throw unresolvedMpaNavigation;
|
|
515
|
+
}
|
|
419
516
|
const treeState = isRouterStatePromise(treeStateValue) ? use(treeStateValue) : treeStateValue;
|
|
420
517
|
const stateRef = useRef(treeState);
|
|
421
518
|
stateRef.current = treeState;
|
|
422
519
|
useLayoutEffect(() => {
|
|
423
|
-
const
|
|
520
|
+
const setAppRouterStateValue = (value) => {
|
|
521
|
+
setTreeStateValue(value);
|
|
522
|
+
};
|
|
523
|
+
const detach = browserNavigationController.attachBrowserRouterState(setAppRouterStateValue, stateRef);
|
|
524
|
+
registerNavigationRuntimeFunctions({ navigateExternal: (href, historyUpdateMode) => {
|
|
525
|
+
setTreeStateValue({
|
|
526
|
+
href,
|
|
527
|
+
historyUpdateMode,
|
|
528
|
+
kind: "mpa-navigation"
|
|
529
|
+
});
|
|
530
|
+
return new Promise(() => {});
|
|
531
|
+
} });
|
|
424
532
|
browserRouterStateHasEverCommitted = true;
|
|
425
533
|
const hydratedAt = performance.now();
|
|
426
534
|
window.__VINEXT_HYDRATED_AT = hydratedAt;
|
|
@@ -428,12 +536,14 @@ function BrowserRoot({ initialElements, initialNavigationSnapshot }) {
|
|
|
428
536
|
window.__NEXT_HYDRATED_AT = hydratedAt;
|
|
429
537
|
window.__NEXT_HYDRATED_CB?.();
|
|
430
538
|
return () => {
|
|
539
|
+
registerNavigationRuntimeFunctions({ navigateExternal: void 0 });
|
|
431
540
|
detach();
|
|
432
541
|
setMountedSlotsHeader(null);
|
|
433
542
|
};
|
|
434
543
|
}, [setTreeStateValue]);
|
|
435
544
|
useLayoutEffect(() => {
|
|
436
545
|
setMountedSlotsHeader(getMountedSlotIdsHeader(stateRef.current.elements));
|
|
546
|
+
removeStylesheetLinksCoveredByInlineCss();
|
|
437
547
|
getNavigationRuntime()?.functions.pingVisibleLinks?.();
|
|
438
548
|
}, [treeState.elements]);
|
|
439
549
|
useLayoutEffect(() => {
|
|
@@ -444,14 +554,15 @@ function BrowserRoot({ initialElements, initialNavigationSnapshot }) {
|
|
|
444
554
|
}), "", window.location.href);
|
|
445
555
|
}, [treeState.previousNextUrl, treeState.renderId]);
|
|
446
556
|
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;
|
|
557
|
+
const innerTree = AppRouterContext ? createElement(AppRouterContext.Provider, { value: appRouterInstance }, createElement(AppRouterRedirectBridge, null, routeTree)) : routeTree;
|
|
448
558
|
const committedTree = import.meta.env.DEV ? createElement(DevRecoveryBoundary, {
|
|
449
559
|
resetKey: treeState.renderId,
|
|
450
560
|
onCatch: handleDevRecoveryBoundaryCatch
|
|
451
561
|
}, innerTree) : innerTree;
|
|
562
|
+
const scrollScopedTree = createElement(AppRouterScrollCommitProvider, { commitId: treeState.renderId }, committedTree);
|
|
452
563
|
const ClientNavigationRenderContext = getClientNavigationRenderContext();
|
|
453
|
-
if (!ClientNavigationRenderContext) return
|
|
454
|
-
return createElement(ClientNavigationRenderContext.Provider, { value: treeState.navigationSnapshot },
|
|
564
|
+
if (!ClientNavigationRenderContext) return scrollScopedTree;
|
|
565
|
+
return createElement(ClientNavigationRenderContext.Provider, { value: treeState.navigationSnapshot }, scrollScopedTree);
|
|
455
566
|
}
|
|
456
567
|
function restoreHydrationNavigationContext(pathname, searchParams, params) {
|
|
457
568
|
setNavigationContext({
|
|
@@ -460,16 +571,15 @@ function restoreHydrationNavigationContext(pathname, searchParams, params) {
|
|
|
460
571
|
params
|
|
461
572
|
});
|
|
462
573
|
}
|
|
463
|
-
function restorePopstateScrollPosition(state) {
|
|
574
|
+
function restorePopstateScrollPosition(state, options) {
|
|
575
|
+
const shouldContinue = options?.shouldContinue ?? (() => true);
|
|
576
|
+
if (!shouldContinue()) return;
|
|
464
577
|
if (!(state && typeof state === "object" && "__vinext_scrollY" in state)) {
|
|
465
578
|
if (window.location.hash) scrollToHashTargetOnNextFrame(window.location.hash);
|
|
466
579
|
return;
|
|
467
580
|
}
|
|
468
581
|
const y = Number(state.__vinext_scrollY);
|
|
469
|
-
|
|
470
|
-
requestAnimationFrame(() => {
|
|
471
|
-
window.scrollTo(x, y);
|
|
472
|
-
});
|
|
582
|
+
retryScrollTo("__vinext_scrollX" in state ? Number(state.__vinext_scrollX) : 0, y, { shouldContinue });
|
|
473
583
|
}
|
|
474
584
|
function isSameAppRoutePopstateTarget(href) {
|
|
475
585
|
if (!hasBrowserRouterState()) return false;
|
|
@@ -560,6 +670,7 @@ function applyRuntimeRscBootstrap(rsc) {
|
|
|
560
670
|
}
|
|
561
671
|
function registerServerActionCallback() {
|
|
562
672
|
setServerCallback(async (id, args) => {
|
|
673
|
+
syncServerActionHttpFallbackHead(null);
|
|
563
674
|
const temporaryReferences = createTemporaryReferenceSet();
|
|
564
675
|
const actionInitiation = createActionInitiationSnapshot();
|
|
565
676
|
syncCurrentHistoryStatePreviousNextUrl(actionInitiation.routerState.previousNextUrl);
|
|
@@ -570,39 +681,26 @@ function registerServerActionCallback() {
|
|
|
570
681
|
elements: actionInitiation.routerState.elements,
|
|
571
682
|
previousNextUrl: actionInitiation.routerState.previousNextUrl
|
|
572
683
|
});
|
|
573
|
-
const fetchResponse = await fetch(
|
|
684
|
+
const fetchResponse = await fetch(createServerActionRequestUrl(actionInitiation.path), {
|
|
574
685
|
method: "POST",
|
|
575
686
|
headers,
|
|
576
687
|
body
|
|
577
688
|
});
|
|
578
689
|
throwOnServerActionNotFound(fetchResponse, id);
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
try {
|
|
589
|
-
redirectLocation = resolveServerActionRedirectLocation({
|
|
590
|
-
currentHref: actionInitiation.href,
|
|
591
|
-
location: actionRedirect,
|
|
592
|
-
origin: window.location.origin
|
|
593
|
-
});
|
|
594
|
-
} catch {
|
|
595
|
-
clearClientNavigationCaches();
|
|
596
|
-
browserNavigationController.performHardNavigation(actionRedirect, hardNavigationMode);
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
690
|
+
const hasActionRedirect = fetchResponse.headers.has(ACTION_REDIRECT_HEADER);
|
|
691
|
+
const actionRedirectTarget = resolveActionRedirectTarget(fetchResponse);
|
|
692
|
+
if (hasActionRedirect && !actionRedirectTarget) return;
|
|
693
|
+
const actionRedirectCompatibilityHardNavigationTarget = resolveServerActionRedirectCompatibilityHardNavigationTarget({
|
|
694
|
+
actionRedirectHref: actionRedirectTarget?.href ?? null,
|
|
695
|
+
clientCompatibilityId: CLIENT_RSC_COMPATIBILITY_ID,
|
|
696
|
+
response: fetchResponse
|
|
697
|
+
});
|
|
698
|
+
if (actionRedirectCompatibilityHardNavigationTarget) {
|
|
599
699
|
clearClientNavigationCaches();
|
|
600
|
-
|
|
601
|
-
navigateClientSide(redirectLocation.href, historyUpdateMode, true, true);
|
|
602
|
-
});
|
|
700
|
+
browserNavigationController.performHardNavigation(actionRedirectCompatibilityHardNavigationTarget, actionRedirectTarget?.type === "push" ? "assign" : "replace");
|
|
603
701
|
return;
|
|
604
702
|
}
|
|
605
|
-
if (resolveRscCompatibilityNavigationDecision({
|
|
703
|
+
if (!actionRedirectTarget && shouldCheckRscCompatibilityForServerActionResponse(fetchResponse) && resolveRscCompatibilityNavigationDecision({
|
|
606
704
|
clientCompatibilityId: CLIENT_RSC_COMPATIBILITY_ID,
|
|
607
705
|
currentHref: actionInitiation.href,
|
|
608
706
|
origin: window.location.origin,
|
|
@@ -613,12 +711,44 @@ function registerServerActionCallback() {
|
|
|
613
711
|
return;
|
|
614
712
|
}
|
|
615
713
|
const revalidation = parseServerActionRevalidationHeader(fetchResponse.headers);
|
|
616
|
-
const
|
|
714
|
+
const invalidResponseError = await readInvalidServerActionResponseError(fetchResponse.clone(), actionRedirectTarget !== null);
|
|
715
|
+
if (invalidResponseError) throw invalidResponseError;
|
|
716
|
+
if (actionRedirectTarget && !shouldCheckRscCompatibilityForServerActionResponse(fetchResponse)) {
|
|
717
|
+
browserNavigationController.performHardNavigation(actionRedirectTarget.href);
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
const flightResponse = fetchResponse.status === 303 ? new Response(fetchResponse.body, {
|
|
721
|
+
headers: fetchResponse.headers,
|
|
722
|
+
status: 200,
|
|
723
|
+
statusText: "OK"
|
|
724
|
+
}) : fetchResponse;
|
|
725
|
+
const result = await createFromFetch(Promise.resolve(flightResponse), { temporaryReferences });
|
|
617
726
|
if (shouldClearClientNavigationCachesForServerActionResult(result, revalidation)) clearClientNavigationCaches();
|
|
727
|
+
if (actionRedirectTarget) {
|
|
728
|
+
if (isServerActionResult(result) && result.root !== void 0) {
|
|
729
|
+
const decoded = AppElementsWire.decode(result.root);
|
|
730
|
+
const hashIdx = actionRedirectTarget.href.indexOf("#");
|
|
731
|
+
const actionScrollIntent = beginAppRouterScrollIntent((hashIdx !== -1 ? actionRedirectTarget.href.slice(hashIdx) : "") || null);
|
|
732
|
+
if (actionRedirectTarget.type === "push") saveScrollPosition();
|
|
733
|
+
renderNavigationPayload(Promise.resolve(decoded), createClientNavigationRenderSnapshot(actionRedirectTarget.href, actionInitiation.routerState.navigationSnapshot.params), actionRedirectTarget.href, actionInitiation.navigationId, actionRedirectTarget.type === "push" ? "push" : "replace", {}, null, null, FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, actionRedirectTarget.type === "push" ? "navigate" : "replace", "server-action", null, actionScrollIntent).catch(() => {
|
|
734
|
+
browserNavigationController.performHardNavigation(actionRedirectTarget.href);
|
|
735
|
+
});
|
|
736
|
+
throw createServerActionRedirectError(actionRedirectTarget);
|
|
737
|
+
}
|
|
738
|
+
browserNavigationController.performHardNavigation(actionRedirectTarget.href);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
syncServerActionHttpFallbackHead(isServerActionResult(result) && result.root !== void 0 ? null : fetchResponse.status);
|
|
618
742
|
if (isServerActionResult(result)) {
|
|
619
|
-
if (result.root !== void 0)
|
|
743
|
+
if (result.root !== void 0) {
|
|
744
|
+
const returnValue = result.returnValue && !result.returnValue.ok ? {
|
|
745
|
+
ok: false,
|
|
746
|
+
data: normalizeServerActionThrownValue(result.returnValue.data, fetchResponse.status)
|
|
747
|
+
} : result.returnValue;
|
|
748
|
+
return commitSameUrlNavigatePayload(Promise.resolve(AppElementsWire.decode(result.root)), actionInitiation, returnValue, revalidation);
|
|
749
|
+
}
|
|
620
750
|
if (result.returnValue) {
|
|
621
|
-
if (!result.returnValue.ok) throw result.returnValue.data;
|
|
751
|
+
if (!result.returnValue.ok) throw normalizeServerActionThrownValue(result.returnValue.data, fetchResponse.status);
|
|
622
752
|
return result.returnValue.data;
|
|
623
753
|
}
|
|
624
754
|
return;
|
|
@@ -663,7 +793,7 @@ function bootstrapHydration(rscStream) {
|
|
|
663
793
|
registerNavigationRuntimeFunctions({
|
|
664
794
|
clearNavigationCaches: clearClientNavigationCaches,
|
|
665
795
|
commitHashNavigation: commitHashOnlyNavigation,
|
|
666
|
-
navigate: async function navigateRsc(href, redirectDepth = 0, navigationKind = "navigate", historyUpdateMode, previousNextUrlOverride, programmaticTransition = false, traversalIntent) {
|
|
796
|
+
navigate: async function navigateRsc(href, redirectDepth = 0, navigationKind = "navigate", historyUpdateMode, previousNextUrlOverride, programmaticTransition = false, traversalIntent, scrollIntent) {
|
|
667
797
|
let pendingRouterState = null;
|
|
668
798
|
const navId = browserNavigationController.beginNavigation();
|
|
669
799
|
discardedServerActionRefreshScheduler.markNavigationStart();
|
|
@@ -676,6 +806,10 @@ function bootstrapHydration(rscStream) {
|
|
|
676
806
|
currentHistoryIndex: currentHistoryTraversalIndex,
|
|
677
807
|
historyState: window.history.state
|
|
678
808
|
}) : null;
|
|
809
|
+
const performHardNavigationForScrollIntent = (targetHref) => {
|
|
810
|
+
consumeAppRouterScrollIntent(scrollIntent ?? null);
|
|
811
|
+
return browserNavigationController.performHardNavigation(targetHref);
|
|
812
|
+
};
|
|
679
813
|
try {
|
|
680
814
|
const shouldUsePendingRouterState = programmaticTransition;
|
|
681
815
|
if (shouldUsePendingRouterState && hasBrowserRouterState()) pendingRouterState = beginPendingBrowserRouterState();
|
|
@@ -709,7 +843,7 @@ function bootstrapHydration(rscStream) {
|
|
|
709
843
|
responseUrl: cachedRoute.response.url
|
|
710
844
|
});
|
|
711
845
|
if (compatibilityDecision.kind === "hard-navigate") {
|
|
712
|
-
|
|
846
|
+
performHardNavigationForScrollIntent(compatibilityDecision.hardNavigationTarget);
|
|
713
847
|
return;
|
|
714
848
|
}
|
|
715
849
|
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
@@ -717,13 +851,14 @@ function bootstrapHydration(rscStream) {
|
|
|
717
851
|
const cachedNavigationSnapshot = createClientNavigationRenderSnapshot(currentHref, cachedParams);
|
|
718
852
|
const cachedPayload = decodeAppElementsPromise(createFromFetch(Promise.resolve(restoreRscResponse(cachedRoute.response))));
|
|
719
853
|
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
720
|
-
await renderNavigationPayload(cachedPayload, cachedNavigationSnapshot, currentHref, navId, currentHistoryMode, cachedParams, requestPreviousNextUrl, detachedNavigationCommits ? null : pendingRouterState, VISITED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, toActionType(navigationKind), toOperationLane(navigationKind), activeTraversalIntent);
|
|
854
|
+
await renderNavigationPayload(cachedPayload, cachedNavigationSnapshot, currentHref, navId, currentHistoryMode, cachedParams, requestPreviousNextUrl, detachedNavigationCommits ? null : pendingRouterState, VISITED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, toActionType(navigationKind), toOperationLane(navigationKind), activeTraversalIntent, scrollIntent);
|
|
721
855
|
return;
|
|
722
856
|
}
|
|
723
857
|
let navResponse;
|
|
724
858
|
let navResponseUrl = null;
|
|
725
859
|
if (navigationKind !== "refresh") {
|
|
726
|
-
const prefetchedResponse =
|
|
860
|
+
const prefetchedResponse = await consumePrefetchResponseForNavigation(rscUrl, requestInterceptionContext, mountedSlotsHeader, { shouldConsume: () => browserNavigationController.isCurrentNavigation(navId) });
|
|
861
|
+
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
727
862
|
if (prefetchedResponse) {
|
|
728
863
|
navResponse = restoreRscResponse(prefetchedResponse, false);
|
|
729
864
|
navResponseUrl = prefetchedResponse.url;
|
|
@@ -749,7 +884,7 @@ function bootstrapHydration(rscStream) {
|
|
|
749
884
|
if (optimisticPayload !== null) {
|
|
750
885
|
detachedNavigationCommits = true;
|
|
751
886
|
const optimisticNavigationSnapshot = createClientNavigationRenderSnapshot(currentHref, optimisticPayload.params);
|
|
752
|
-
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) => {
|
|
887
|
+
renderNavigationPayload(Promise.resolve(optimisticPayload.elements), optimisticNavigationSnapshot, currentHref, navId, currentHistoryMode, optimisticPayload.params, requestPreviousNextUrl, null, FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, toActionType(navigationKind), toOperationLane(navigationKind), activeTraversalIntent, scrollIntent).catch((error) => {
|
|
753
888
|
if (browserNavigationController.isCurrentNavigation(navId)) console.error("[vinext] Optimistic RSC navigation error:", error);
|
|
754
889
|
});
|
|
755
890
|
}
|
|
@@ -762,8 +897,7 @@ function bootstrapHydration(rscStream) {
|
|
|
762
897
|
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
763
898
|
const isRscResponse = (navResponse.headers.get("content-type") ?? "").startsWith("text/x-component");
|
|
764
899
|
if (!navResponse.ok || !isRscResponse || !navResponse.body) {
|
|
765
|
-
|
|
766
|
-
browserNavigationController.performHardNavigation(resolveHardNavigationTargetFromRscResponse(responseUrl, currentHref, window.location.origin));
|
|
900
|
+
performHardNavigationForScrollIntent(resolveHardNavigationTargetFromRscResponse(navResponseUrl ?? navResponse.url, currentHref, window.location.origin));
|
|
767
901
|
return;
|
|
768
902
|
}
|
|
769
903
|
const compatibilityDecision = resolveRscCompatibilityNavigationDecision({
|
|
@@ -774,7 +908,7 @@ function bootstrapHydration(rscStream) {
|
|
|
774
908
|
responseUrl: navResponseUrl ?? navResponse.url
|
|
775
909
|
});
|
|
776
910
|
if (compatibilityDecision.kind === "hard-navigate") {
|
|
777
|
-
|
|
911
|
+
performHardNavigationForScrollIntent(compatibilityDecision.hardNavigationTarget);
|
|
778
912
|
return;
|
|
779
913
|
}
|
|
780
914
|
const redirectDecision = resolveRscRedirectLifecycleHop({
|
|
@@ -787,7 +921,7 @@ function bootstrapHydration(rscStream) {
|
|
|
787
921
|
});
|
|
788
922
|
if (redirectDecision.kind === "terminal-hard-navigation") {
|
|
789
923
|
if (redirectDecision.reason === "maxRedirectsExceeded") console.error("[vinext] Too many RSC redirects — aborting navigation to prevent infinite loop.");
|
|
790
|
-
|
|
924
|
+
performHardNavigationForScrollIntent(redirectDecision.href);
|
|
791
925
|
return;
|
|
792
926
|
}
|
|
793
927
|
if (redirectDecision.kind === "follow") {
|
|
@@ -802,12 +936,12 @@ function bootstrapHydration(rscStream) {
|
|
|
802
936
|
navResponse.body?.cancel().catch(() => {});
|
|
803
937
|
const resolvedTarget = new URL(flightRedirectTarget, window.location.origin);
|
|
804
938
|
if (resolvedTarget.origin !== window.location.origin) {
|
|
805
|
-
|
|
939
|
+
performHardNavigationForScrollIntent(resolvedTarget.href);
|
|
806
940
|
return;
|
|
807
941
|
}
|
|
808
942
|
if (redirectCount >= 10) {
|
|
809
943
|
console.error("[vinext] Too many RSC redirects — aborting navigation to prevent infinite loop.");
|
|
810
|
-
|
|
944
|
+
performHardNavigationForScrollIntent(resolvedTarget.href);
|
|
811
945
|
return;
|
|
812
946
|
}
|
|
813
947
|
currentHref = `${resolvedTarget.pathname}${resolvedTarget.search}${resolvedTarget.hash}`;
|
|
@@ -827,7 +961,7 @@ function bootstrapHydration(rscStream) {
|
|
|
827
961
|
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
828
962
|
const rscPayload = decodeAppElementsPromise(createFromFetch(Promise.resolve(reactResponse)));
|
|
829
963
|
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
830
|
-
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;
|
|
964
|
+
if (await renderNavigationPayload(rscPayload, navigationSnapshot, currentHref, navId, currentHistoryMode, navParams, requestPreviousNextUrl, detachedNavigationCommits ? null : pendingRouterState, FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, toActionType(navigationKind), toOperationLane(navigationKind), activeTraversalIntent, scrollIntent) !== "committed") return;
|
|
831
965
|
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
832
966
|
const resolvedElements = await rscPayload;
|
|
833
967
|
const metadata = AppElementsWire.readMetadata(resolvedElements);
|
|
@@ -843,7 +977,7 @@ function bootstrapHydration(rscStream) {
|
|
|
843
977
|
} catch (error) {
|
|
844
978
|
if (!browserNavigationController.isCurrentNavigation(navId)) return;
|
|
845
979
|
if (!isPageUnloading) console.error("[vinext] RSC navigation error:", error);
|
|
846
|
-
|
|
980
|
+
performHardNavigationForScrollIntent(currentHref);
|
|
847
981
|
} finally {
|
|
848
982
|
browserNavigationController.finalizeNavigation(navId, pendingRouterState);
|
|
849
983
|
discardedServerActionRefreshScheduler.markNavigationSettled();
|
|
@@ -905,8 +1039,9 @@ if (typeof document !== "undefined") {
|
|
|
905
1039
|
window.addEventListener("pagehide", () => {
|
|
906
1040
|
isPageUnloading = true;
|
|
907
1041
|
});
|
|
908
|
-
window.addEventListener("pageshow", () => {
|
|
1042
|
+
window.addEventListener("pageshow", (event) => {
|
|
909
1043
|
isPageUnloading = false;
|
|
1044
|
+
if (event.persisted) mpaNavigationScheduler.reset();
|
|
910
1045
|
});
|
|
911
1046
|
main();
|
|
912
1047
|
}
|