vinext 0.1.1 → 0.1.3
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 +2 -5
- package/dist/build/client-build-config.d.ts +7 -1
- package/dist/build/client-build-config.js +9 -1
- package/dist/build/prerender.d.ts +9 -1
- package/dist/build/prerender.js +41 -12
- package/dist/build/run-prerender.d.ts +10 -2
- package/dist/build/run-prerender.js +15 -1
- package/dist/check.js +4 -3
- package/dist/client/app-nav-failure-handler.d.ts +8 -0
- package/dist/client/app-nav-failure-handler.js +44 -0
- package/dist/client/navigation-runtime.d.ts +3 -2
- package/dist/client/vinext-next-data.d.ts +18 -1
- package/dist/client/window-next.d.ts +8 -5
- package/dist/client/window-next.js +12 -1
- package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +6 -1
- package/dist/config/config-matchers.d.ts +11 -4
- package/dist/config/config-matchers.js +88 -16
- package/dist/config/next-config.d.ts +59 -4
- package/dist/config/next-config.js +149 -48
- package/dist/deploy.d.ts +30 -11
- package/dist/deploy.js +189 -101
- package/dist/entries/app-browser-entry.d.ts +9 -3
- package/dist/entries/app-browser-entry.js +21 -3
- package/dist/entries/app-rsc-entry.d.ts +2 -0
- package/dist/entries/app-rsc-entry.js +71 -6
- package/dist/entries/app-rsc-manifest.js +2 -0
- package/dist/entries/app-ssr-entry.js +1 -1
- package/dist/entries/pages-client-entry.js +54 -9
- package/dist/entries/pages-server-entry.js +48 -11
- package/dist/index.d.ts +0 -2
- package/dist/index.js +285 -139
- package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
- package/dist/plugins/dynamic-preload-metadata.js +415 -0
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +152 -0
- package/dist/plugins/og-assets.js +2 -2
- package/dist/plugins/optimize-imports.d.ts +10 -5
- package/dist/plugins/optimize-imports.js +27 -21
- package/dist/plugins/postcss.js +7 -7
- package/dist/plugins/sass.d.ts +53 -24
- package/dist/plugins/sass.js +249 -1
- package/dist/plugins/typeof-window.d.ts +14 -0
- package/dist/plugins/typeof-window.js +150 -0
- package/dist/plugins/wasm-module-import.d.ts +15 -0
- package/dist/plugins/wasm-module-import.js +50 -0
- package/dist/routing/app-route-graph.d.ts +25 -2
- package/dist/routing/app-route-graph.js +91 -22
- package/dist/routing/file-matcher.d.ts +10 -1
- package/dist/routing/file-matcher.js +23 -2
- package/dist/routing/pages-router.js +3 -3
- package/dist/routing/utils.d.ts +35 -6
- package/dist/routing/utils.js +59 -7
- package/dist/server/api-handler.d.ts +6 -1
- package/dist/server/api-handler.js +21 -15
- package/dist/server/app-browser-action-result.d.ts +19 -6
- package/dist/server/app-browser-action-result.js +19 -10
- package/dist/server/app-browser-entry.js +269 -297
- package/dist/server/app-browser-error.d.ts +10 -3
- package/dist/server/app-browser-error.js +47 -6
- package/dist/server/app-browser-history-controller.d.ts +104 -0
- package/dist/server/app-browser-history-controller.js +210 -0
- package/dist/server/app-browser-hydration.d.ts +2 -0
- package/dist/server/app-browser-hydration.js +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +7 -4
- package/dist/server/app-browser-navigation-controller.js +33 -9
- package/dist/server/app-browser-rsc-redirect.d.ts +11 -2
- package/dist/server/app-browser-rsc-redirect.js +30 -8
- package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
- package/dist/server/app-browser-server-action-navigation.js +9 -0
- package/dist/server/app-browser-state.js +4 -7
- package/dist/server/app-browser-stream.js +86 -43
- package/dist/server/app-browser-visible-commit.js +1 -1
- package/dist/server/app-elements-wire.d.ts +6 -1
- package/dist/server/app-elements-wire.js +14 -4
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-fallback-renderer.d.ts +3 -1
- package/dist/server/app-fallback-renderer.js +6 -2
- package/dist/server/app-middleware.js +1 -0
- package/dist/server/app-optimistic-routing.js +24 -3
- package/dist/server/app-page-boundary-render.d.ts +3 -1
- package/dist/server/app-page-boundary-render.js +31 -16
- package/dist/server/app-page-cache-render.d.ts +53 -0
- package/dist/server/app-page-cache-render.js +91 -0
- package/dist/server/app-page-cache.d.ts +16 -2
- package/dist/server/app-page-cache.js +71 -8
- package/dist/server/app-page-dispatch.d.ts +34 -0
- package/dist/server/app-page-dispatch.js +167 -97
- package/dist/server/app-page-element-builder.d.ts +23 -2
- package/dist/server/app-page-element-builder.js +42 -10
- package/dist/server/app-page-execution.d.ts +7 -2
- package/dist/server/app-page-execution.js +53 -18
- package/dist/server/app-page-probe.d.ts +1 -0
- package/dist/server/app-page-probe.js +4 -0
- package/dist/server/app-page-render-observation.d.ts +3 -1
- package/dist/server/app-page-render-observation.js +17 -1
- package/dist/server/app-page-render.d.ts +13 -2
- package/dist/server/app-page-render.js +48 -17
- package/dist/server/app-page-request.d.ts +3 -0
- package/dist/server/app-page-request.js +5 -3
- package/dist/server/app-page-response.js +1 -1
- package/dist/server/app-page-route-wiring.d.ts +5 -1
- package/dist/server/app-page-route-wiring.js +21 -11
- package/dist/server/app-page-stream.d.ts +16 -9
- package/dist/server/app-page-stream.js +12 -9
- package/dist/server/app-pages-bridge.d.ts +18 -0
- package/dist/server/app-pages-bridge.js +22 -5
- package/dist/server/app-ppr-fallback-shell-render.d.ts +17 -0
- package/dist/server/app-ppr-fallback-shell-render.js +26 -0
- package/dist/server/app-ppr-fallback-shell.d.ts +13 -1
- package/dist/server/app-ppr-fallback-shell.js +8 -1
- package/dist/server/app-route-handler-dispatch.js +9 -2
- package/dist/server/app-route-handler-policy.d.ts +1 -0
- package/dist/server/app-route-handler-response.js +11 -10
- package/dist/server/app-route-handler-runtime.js +12 -1
- package/dist/server/app-router-entry.js +5 -0
- package/dist/server/app-rsc-cache-busting.js +2 -0
- package/dist/server/app-rsc-handler.d.ts +25 -0
- package/dist/server/app-rsc-handler.js +153 -53
- package/dist/server/app-rsc-response-finalizer.js +1 -1
- package/dist/server/app-rsc-route-matching.d.ts +3 -0
- package/dist/server/app-rsc-route-matching.js +2 -0
- package/dist/server/app-segment-config.d.ts +9 -1
- package/dist/server/app-segment-config.js +12 -3
- package/dist/server/app-server-action-execution.d.ts +12 -0
- package/dist/server/app-server-action-execution.js +47 -15
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +81 -8
- package/dist/server/app-ssr-stream.js +9 -1
- package/dist/server/cache-control.js +4 -0
- package/dist/server/dev-lockfile.js +2 -1
- package/dist/server/dev-server.d.ts +2 -2
- package/dist/server/dev-server.js +287 -63
- package/dist/server/headers.d.ts +8 -1
- package/dist/server/headers.js +8 -1
- package/dist/server/hybrid-route-priority.d.ts +22 -0
- package/dist/server/hybrid-route-priority.js +33 -0
- package/dist/server/image-optimization.d.ts +18 -9
- package/dist/server/image-optimization.js +37 -23
- package/dist/server/implicit-tags.d.ts +2 -1
- package/dist/server/implicit-tags.js +4 -1
- package/dist/server/instrumentation-runtime.d.ts +6 -0
- package/dist/server/instrumentation-runtime.js +8 -0
- package/dist/server/isr-decision.d.ts +79 -0
- package/dist/server/isr-decision.js +70 -0
- package/dist/server/metadata-route-response.js +5 -3
- package/dist/server/middleware-runtime.d.ts +13 -0
- package/dist/server/middleware-runtime.js +11 -7
- package/dist/server/middleware.js +1 -0
- package/dist/server/navigation-planner.d.ts +186 -22
- package/dist/server/navigation-planner.js +302 -0
- package/dist/server/navigation-trace.d.ts +18 -1
- package/dist/server/navigation-trace.js +18 -1
- package/dist/server/normalize-path.d.ts +0 -8
- package/dist/server/normalize-path.js +3 -1
- package/dist/server/otel-tracer-extension.d.ts +45 -0
- package/dist/server/otel-tracer-extension.js +89 -0
- package/dist/server/pages-api-route.d.ts +20 -3
- package/dist/server/pages-api-route.js +19 -3
- package/dist/server/pages-asset-tags.d.ts +16 -4
- package/dist/server/pages-asset-tags.js +22 -12
- package/dist/server/pages-data-route.d.ts +8 -1
- package/dist/server/pages-data-route.js +16 -3
- package/dist/server/pages-get-initial-props.d.ts +54 -4
- package/dist/server/pages-get-initial-props.js +43 -1
- package/dist/server/pages-node-compat.d.ts +3 -11
- package/dist/server/pages-node-compat.js +175 -122
- package/dist/server/pages-page-data.d.ts +39 -2
- package/dist/server/pages-page-data.js +261 -46
- package/dist/server/pages-page-handler.d.ts +5 -2
- package/dist/server/pages-page-handler.js +78 -25
- package/dist/server/pages-page-response.d.ts +47 -2
- package/dist/server/pages-page-response.js +73 -9
- package/dist/server/pages-readiness.d.ts +1 -1
- package/dist/server/pages-request-pipeline.d.ts +16 -1
- package/dist/server/pages-request-pipeline.js +96 -38
- package/dist/server/pregenerated-concrete-paths.d.ts +1 -17
- package/dist/server/pregenerated-concrete-paths.js +2 -19
- package/dist/server/prerender-manifest.d.ts +33 -0
- package/dist/server/prerender-manifest.js +54 -0
- package/dist/server/prerender-route-params.d.ts +1 -2
- package/dist/server/prod-server.d.ts +39 -1
- package/dist/server/prod-server.js +107 -37
- package/dist/server/request-pipeline.d.ts +3 -15
- package/dist/server/request-pipeline.js +58 -47
- package/dist/server/rsc-stream-hints.d.ts +5 -1
- package/dist/server/rsc-stream-hints.js +6 -1
- package/dist/server/seed-cache.js +10 -18
- package/dist/shims/app-router-scroll-state.d.ts +3 -1
- package/dist/shims/app-router-scroll-state.js +14 -2
- package/dist/shims/app-router-scroll.d.ts +3 -0
- package/dist/shims/app-router-scroll.js +28 -18
- package/dist/shims/cache-runtime.js +12 -4
- package/dist/shims/cache.d.ts +1 -0
- package/dist/shims/cache.js +1 -1
- package/dist/shims/cdn-cache.d.ts +5 -5
- package/dist/shims/dynamic-preload-chunks.d.ts +8 -0
- package/dist/shims/dynamic-preload-chunks.js +79 -0
- package/dist/shims/dynamic.d.ts +4 -0
- package/dist/shims/dynamic.js +4 -2
- package/dist/shims/error-boundary.d.ts +6 -4
- package/dist/shims/error-boundary.js +7 -0
- package/dist/shims/error.js +38 -11
- package/dist/shims/error.react-server.d.ts +9 -0
- package/dist/shims/error.react-server.js +6 -0
- package/dist/shims/fetch-cache.d.ts +11 -1
- package/dist/shims/fetch-cache.js +55 -20
- package/dist/shims/hash-scroll.js +6 -1
- package/dist/shims/head.js +6 -1
- package/dist/shims/headers.d.ts +16 -2
- package/dist/shims/headers.js +66 -5
- package/dist/shims/image-config.js +7 -1
- package/dist/shims/internal/als-registry.js +28 -1
- package/dist/shims/internal/app-route-detection.d.ts +6 -3
- package/dist/shims/internal/app-route-detection.js +18 -23
- package/dist/shims/internal/app-router-context.d.ts +5 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
- package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
- package/dist/shims/internal/navigation-untracked.d.ts +35 -0
- package/dist/shims/internal/navigation-untracked.js +55 -0
- package/dist/shims/internal/pages-data-target.d.ts +7 -2
- package/dist/shims/internal/pages-data-target.js +17 -8
- package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
- package/dist/shims/internal/pages-router-accessor.js +13 -0
- package/dist/shims/internal/router-context.d.ts +2 -1
- package/dist/shims/internal/router-context.js +3 -1
- package/dist/shims/link.js +12 -5
- package/dist/shims/metadata.d.ts +6 -2
- package/dist/shims/metadata.js +32 -14
- package/dist/shims/navigation.d.ts +14 -17
- package/dist/shims/navigation.js +93 -46
- package/dist/shims/ppr-fallback-shell.d.ts +5 -1
- package/dist/shims/ppr-fallback-shell.js +28 -7
- package/dist/shims/router.d.ts +13 -2
- package/dist/shims/router.js +434 -116
- package/dist/shims/script-nonce-context.d.ts +1 -1
- package/dist/shims/script-nonce-context.js +11 -3
- package/dist/shims/server.d.ts +33 -2
- package/dist/shims/server.js +75 -18
- package/dist/shims/slot.js +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/typegen.js +1 -0
- package/dist/utils/built-asset-url.d.ts +4 -0
- package/dist/utils/built-asset-url.js +11 -0
- package/dist/utils/client-build-manifest.js +15 -5
- package/dist/utils/client-runtime-metadata.d.ts +45 -0
- package/dist/utils/client-runtime-metadata.js +63 -0
- package/dist/utils/commonjs-loader.d.ts +16 -0
- package/dist/utils/commonjs-loader.js +100 -0
- package/dist/utils/deployment-id.d.ts +8 -0
- package/dist/utils/deployment-id.js +22 -0
- package/dist/utils/hash.d.ts +17 -1
- package/dist/utils/hash.js +36 -1
- package/dist/utils/html-limited-bots.d.ts +18 -1
- package/dist/utils/html-limited-bots.js +23 -1
- package/dist/utils/lazy-chunks.d.ts +27 -1
- package/dist/utils/lazy-chunks.js +65 -1
- package/dist/utils/manifest-paths.d.ts +20 -2
- package/dist/utils/manifest-paths.js +38 -3
- package/dist/utils/parse-cookie.d.ts +13 -0
- package/dist/utils/parse-cookie.js +52 -0
- package/dist/utils/path.d.ts +8 -1
- package/dist/utils/path.js +13 -1
- package/package.json +2 -2
- package/dist/shims/internal/parse-cookie-header.d.ts +0 -14
- package/dist/shims/internal/parse-cookie-header.js +0 -30
package/dist/shims/navigation.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { stripBasePath } from "../utils/base-path.js";
|
|
2
2
|
import { VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER } from "../server/headers.js";
|
|
3
3
|
import { assertSafeNavigationUrl } from "./url-safety.js";
|
|
4
|
+
import { markPprFallbackShellDynamicBoundary } from "./ppr-fallback-shell.js";
|
|
4
5
|
import { AppElementsWire } from "../server/app-elements-wire.js";
|
|
5
6
|
import "../server/app-elements.js";
|
|
6
7
|
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
7
|
-
import {
|
|
8
|
+
import { resolveHybridClientRouteOwner } from "./internal/hybrid-client-route-owner.js";
|
|
9
|
+
import { isAbsoluteOrProtocolRelativeUrl, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
|
|
8
10
|
import { retryScrollTo, scrollToHashTarget } from "./hash-scroll.js";
|
|
9
11
|
import { getNavigationRuntime, hasAppNavigationRuntime } from "../client/navigation-runtime.js";
|
|
10
12
|
import { notifyAppRouterTransitionStart } from "../client/instrumentation-client-state.js";
|
|
13
|
+
import { clearAppNavigationFailureTarget, stageAppNavigationFailureTarget } from "../client/app-nav-failure-handler.js";
|
|
11
14
|
import { PUBLIC_INITIAL_BFCACHE_ID } from "../server/app-bfcache-id.js";
|
|
12
15
|
import { resolveManifestNavigationInterceptionContext } from "../server/app-browser-interception-context.js";
|
|
13
16
|
import { createExternalHistoryStatePreservingMetadata, createHashOnlyHistoryStatePreservingNavigationMetadata } from "../server/app-history-state.js";
|
|
14
17
|
import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, createRscRequestHeaders, createRscRequestUrl, stripRscCacheBustingSearchParam } from "../server/app-rsc-cache-busting.js";
|
|
15
18
|
import { hasPendingAppRouterPageRedirect } from "../server/app-browser-mpa-navigation.js";
|
|
19
|
+
import { navigationPlanner } from "../server/navigation-planner.js";
|
|
16
20
|
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
17
|
-
import {
|
|
21
|
+
import { getPagesNavigationContext } from "./internal/pages-router-accessor.js";
|
|
22
|
+
import { beginAppRouterScrollIntent, clearAppRouterScrollIntent, consumeAppRouterScrollIntent, getPendingAppRouterScrollIntent } from "./app-router-scroll-state.js";
|
|
18
23
|
import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
|
|
19
24
|
import * as React$1 from "react";
|
|
20
25
|
//#region src/shims/navigation.ts
|
|
@@ -130,17 +135,7 @@ function _registerStateAccessors(accessors) {
|
|
|
130
135
|
_getInsertedHTMLCallbacks = accessors.getInsertedHTMLCallbacks;
|
|
131
136
|
_clearInsertedHTMLCallbacks = accessors.clearInsertedHTMLCallbacks;
|
|
132
137
|
}
|
|
133
|
-
const PAGES_NAVIGATION_ACCESSOR_KEY = Symbol.for("vinext.navigation.pagesNavigationContextAccessor");
|
|
134
138
|
const PAGES_NAVIGATION_NOTIFY_KEY = Symbol.for("vinext.navigation.pagesNavigationNotify");
|
|
135
|
-
function _getPagesNavigationContext() {
|
|
136
|
-
const accessor = globalThis[PAGES_NAVIGATION_ACCESSOR_KEY];
|
|
137
|
-
if (!accessor) return null;
|
|
138
|
-
try {
|
|
139
|
-
return accessor();
|
|
140
|
-
} catch {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
139
|
/**
|
|
145
140
|
* Get the navigation context for the current SSR/RSC render.
|
|
146
141
|
* Reads from AsyncLocalStorage when available (concurrent-safe),
|
|
@@ -298,12 +293,12 @@ function findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mounte
|
|
|
298
293
|
}
|
|
299
294
|
return null;
|
|
300
295
|
}
|
|
301
|
-
function hasPrefetchCacheEntryForNavigation(rscUrl, interceptionContext = null, mountedSlotsHeader = null) {
|
|
296
|
+
function hasPrefetchCacheEntryForNavigation(rscUrl, interceptionContext = null, mountedSlotsHeader = null, options = {}) {
|
|
302
297
|
const match = findPrefetchCacheEntryForNavigation(rscUrl, interceptionContext, mountedSlotsHeader);
|
|
303
298
|
if (match === null) return false;
|
|
304
299
|
if (match.entry.pending !== void 0) return true;
|
|
305
300
|
if (resolvePrefetchCacheEntryExpiresAt(match.entry) > Date.now()) return true;
|
|
306
|
-
deletePrefetchCacheEntry(getPrefetchCache(), getPrefetchedUrls(), match.cacheKey, match.entry, true);
|
|
301
|
+
deletePrefetchCacheEntry(getPrefetchCache(), getPrefetchedUrls(), match.cacheKey, match.entry, options.notifyInvalidation ?? true);
|
|
307
302
|
return false;
|
|
308
303
|
}
|
|
309
304
|
/**
|
|
@@ -616,7 +611,7 @@ function getReadonlyPagesSearchParams(searchParams) {
|
|
|
616
611
|
* be visible until the next commit.
|
|
617
612
|
*/
|
|
618
613
|
function getPathnameSnapshot() {
|
|
619
|
-
const pagesCtx =
|
|
614
|
+
const pagesCtx = getPagesNavigationContext();
|
|
620
615
|
if (pagesCtx) return pagesCtx.pathname;
|
|
621
616
|
return getClientNavigationState()?.cachedPathname ?? "/";
|
|
622
617
|
}
|
|
@@ -631,7 +626,7 @@ let _cachedEmptyClientSearchParams = null;
|
|
|
631
626
|
*/
|
|
632
627
|
function getSearchParamsSnapshot() {
|
|
633
628
|
if (_getServerContext()) return getServerSearchParamsSnapshot();
|
|
634
|
-
const pagesCtx =
|
|
629
|
+
const pagesCtx = getPagesNavigationContext();
|
|
635
630
|
if (pagesCtx) return getReadonlyPagesSearchParams(pagesCtx.searchParams);
|
|
636
631
|
const cached = getClientNavigationState()?.cachedReadonlySearchParams;
|
|
637
632
|
if (cached) return cached;
|
|
@@ -658,7 +653,7 @@ function syncCommittedUrlStateFromLocation() {
|
|
|
658
653
|
function getServerSearchParamsSnapshot() {
|
|
659
654
|
const ctx = _getServerContext();
|
|
660
655
|
if (!ctx) {
|
|
661
|
-
const pagesCtx =
|
|
656
|
+
const pagesCtx = getPagesNavigationContext();
|
|
662
657
|
if (pagesCtx) return getReadonlyPagesSearchParams(pagesCtx.searchParams);
|
|
663
658
|
if (_cachedEmptyServerSearchParams === null) _cachedEmptyServerSearchParams = new ReadonlyURLSearchParams();
|
|
664
659
|
return _cachedEmptyServerSearchParams;
|
|
@@ -697,6 +692,7 @@ function getClientNavigationRenderContext() {
|
|
|
697
692
|
if (!globalState[_CLIENT_NAV_RENDER_CTX_KEY]) globalState[_CLIENT_NAV_RENDER_CTX_KEY] = React$1.createContext(null);
|
|
698
693
|
return globalState[_CLIENT_NAV_RENDER_CTX_KEY] ?? null;
|
|
699
694
|
}
|
|
695
|
+
/** @internal */
|
|
700
696
|
function useClientNavigationRenderSnapshot() {
|
|
701
697
|
const ctx = getClientNavigationRenderContext();
|
|
702
698
|
if (!ctx || typeof React$1.useContext !== "function") return null;
|
|
@@ -715,6 +711,10 @@ function createClientNavigationRenderSnapshot(href, params) {
|
|
|
715
711
|
params
|
|
716
712
|
};
|
|
717
713
|
}
|
|
714
|
+
function createSnapshotPathAndSearch(snapshot) {
|
|
715
|
+
const query = snapshot.searchParams.toString();
|
|
716
|
+
return query === "" ? snapshot.pathname : `${snapshot.pathname}?${query}`;
|
|
717
|
+
}
|
|
718
718
|
let _fallbackClientParams = _EMPTY_PARAMS;
|
|
719
719
|
let _fallbackClientParamsJson = "{}";
|
|
720
720
|
function setClientParams(params) {
|
|
@@ -778,14 +778,14 @@ function getClientParamsSnapshot() {
|
|
|
778
778
|
const state = getClientNavigationState();
|
|
779
779
|
const ctx = _getServerContext();
|
|
780
780
|
if (ctx) return ctx.params;
|
|
781
|
-
const pagesCtx =
|
|
781
|
+
const pagesCtx = getPagesNavigationContext();
|
|
782
782
|
if (pagesCtx) return pagesCtx.params;
|
|
783
783
|
return state?.clientParams ?? _EMPTY_PARAMS;
|
|
784
784
|
}
|
|
785
785
|
function getServerParamsSnapshot() {
|
|
786
786
|
const ctx = _getServerContext();
|
|
787
787
|
if (ctx) return ctx.params;
|
|
788
|
-
const pagesCtx =
|
|
788
|
+
const pagesCtx = getPagesNavigationContext();
|
|
789
789
|
if (pagesCtx) return pagesCtx.params;
|
|
790
790
|
return _EMPTY_PARAMS;
|
|
791
791
|
}
|
|
@@ -803,16 +803,17 @@ function subscribeToNavigation(cb) {
|
|
|
803
803
|
*/
|
|
804
804
|
function usePathname() {
|
|
805
805
|
if (isServer) {
|
|
806
|
+
markPprFallbackShellDynamicBoundary();
|
|
806
807
|
const ctx = _getServerContext();
|
|
807
808
|
if (ctx) return ctx.pathname;
|
|
808
|
-
const pagesCtx =
|
|
809
|
+
const pagesCtx = getPagesNavigationContext();
|
|
809
810
|
return pagesCtx ? pagesCtx.pathname : "/";
|
|
810
811
|
}
|
|
811
812
|
const renderSnapshot = useClientNavigationRenderSnapshot();
|
|
812
813
|
const pathname = React$1.useSyncExternalStore(subscribeToNavigation, getPathnameSnapshot, () => {
|
|
813
814
|
const ctx = _getServerContext();
|
|
814
815
|
if (ctx) return ctx.pathname;
|
|
815
|
-
const pagesCtx =
|
|
816
|
+
const pagesCtx = getPagesNavigationContext();
|
|
816
817
|
return pagesCtx ? pagesCtx.pathname : "/";
|
|
817
818
|
});
|
|
818
819
|
if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.pathname;
|
|
@@ -822,7 +823,10 @@ function usePathname() {
|
|
|
822
823
|
* Returns the current search params as a read-only URLSearchParams.
|
|
823
824
|
*/
|
|
824
825
|
function useSearchParams() {
|
|
825
|
-
if (isServer)
|
|
826
|
+
if (isServer) {
|
|
827
|
+
markPprFallbackShellDynamicBoundary();
|
|
828
|
+
return getServerSearchParamsSnapshot();
|
|
829
|
+
}
|
|
826
830
|
const renderSnapshot = useClientNavigationRenderSnapshot();
|
|
827
831
|
const searchParams = React$1.useSyncExternalStore(subscribeToNavigation, getSearchParamsSnapshot, getServerSearchParamsSnapshot);
|
|
828
832
|
if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.searchParams;
|
|
@@ -832,7 +836,10 @@ function useSearchParams() {
|
|
|
832
836
|
* Returns the dynamic params for the current route.
|
|
833
837
|
*/
|
|
834
838
|
function useParams() {
|
|
835
|
-
if (isServer)
|
|
839
|
+
if (isServer) {
|
|
840
|
+
markPprFallbackShellDynamicBoundary();
|
|
841
|
+
return getServerParamsSnapshot();
|
|
842
|
+
}
|
|
836
843
|
const renderSnapshot = useClientNavigationRenderSnapshot();
|
|
837
844
|
const params = React$1.useSyncExternalStore(subscribeToNavigation, getClientParamsSnapshot, getServerParamsSnapshot);
|
|
838
845
|
if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.params;
|
|
@@ -844,14 +851,6 @@ function useParams() {
|
|
|
844
851
|
function isExternalUrl(href) {
|
|
845
852
|
return isAbsoluteOrProtocolRelativeUrl(href);
|
|
846
853
|
}
|
|
847
|
-
/**
|
|
848
|
-
* Check if a href is only a hash change relative to the current URL.
|
|
849
|
-
*/
|
|
850
|
-
function isHashOnlyChange(href) {
|
|
851
|
-
if (typeof window === "undefined") return false;
|
|
852
|
-
if (href.startsWith("#")) return true;
|
|
853
|
-
return isHashOnlyBrowserUrlChange(href, window.location.href, __basePath);
|
|
854
|
-
}
|
|
855
854
|
function withSuppressedUrlNotifications(fn) {
|
|
856
855
|
const state = getClientNavigationState();
|
|
857
856
|
if (!state) return fn();
|
|
@@ -933,8 +932,17 @@ function applyAppRouterScrollFallback(intent) {
|
|
|
933
932
|
scrollToHashTarget(intent.hash);
|
|
934
933
|
return;
|
|
935
934
|
}
|
|
935
|
+
if (intent.targetHoistedInHead) return;
|
|
936
936
|
document.documentElement.scrollTop = 0;
|
|
937
937
|
}
|
|
938
|
+
function scheduleAppRouterScrollFallback(intent) {
|
|
939
|
+
queueMicrotask(() => {
|
|
940
|
+
const pendingIntent = getPendingAppRouterScrollIntent();
|
|
941
|
+
if (pendingIntent === null || pendingIntent.id !== intent.id) return;
|
|
942
|
+
const fallbackIntent = consumeAppRouterScrollIntent(intent);
|
|
943
|
+
if (fallbackIntent) applyAppRouterScrollFallback(fallbackIntent);
|
|
944
|
+
});
|
|
945
|
+
}
|
|
938
946
|
/**
|
|
939
947
|
* Restore scroll position from a history state object (used on popstate).
|
|
940
948
|
*
|
|
@@ -961,9 +969,18 @@ function restoreScrollPosition(state) {
|
|
|
961
969
|
}
|
|
962
970
|
}
|
|
963
971
|
/**
|
|
972
|
+
* Hard-navigate to a URL via `window.location`, preserving push/replace
|
|
973
|
+
* semantics. Used for URLs the App Router cannot serve (Pages-owned
|
|
974
|
+
* targets in a hybrid build) and for catch-all RSC failures.
|
|
975
|
+
*/
|
|
976
|
+
function hardNavigateTo(fullHref, mode) {
|
|
977
|
+
if (mode === "replace") window.location.replace(fullHref);
|
|
978
|
+
else window.location.assign(fullHref);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
964
981
|
* Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.
|
|
965
982
|
*/
|
|
966
|
-
async function navigateClientSide(href, mode, scroll, programmaticTransition = false) {
|
|
983
|
+
async function navigateClientSide(href, mode, scroll, programmaticTransition = false, visibleCommitMode = "transition") {
|
|
967
984
|
getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
|
|
968
985
|
let normalizedHref = href;
|
|
969
986
|
if (isExternalUrl(href)) {
|
|
@@ -975,21 +992,38 @@ async function navigateClientSide(href, mode, scroll, programmaticTransition = f
|
|
|
975
992
|
await externalNavigate(href, mode);
|
|
976
993
|
return;
|
|
977
994
|
}
|
|
978
|
-
|
|
979
|
-
else window.location.assign(href);
|
|
995
|
+
hardNavigateTo(href, mode);
|
|
980
996
|
await new Promise(() => {});
|
|
981
997
|
return;
|
|
982
998
|
}
|
|
983
999
|
normalizedHref = localPath;
|
|
984
1000
|
}
|
|
1001
|
+
const hybridOwner = resolveHybridClientRouteOwner(normalizedHref, __basePath);
|
|
1002
|
+
if (hybridOwner === "pages" || hybridOwner === "document") {
|
|
1003
|
+
const fullHref = toBrowserNavigationHref(normalizedHref, window.location.href, __basePath);
|
|
1004
|
+
notifyAppRouterTransitionStart(fullHref, mode);
|
|
1005
|
+
if (mode === "push") saveScrollPosition();
|
|
1006
|
+
hardNavigateTo(fullHref, mode);
|
|
1007
|
+
await new Promise(() => {});
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
985
1010
|
const fullHref = toBrowserNavigationHref(normalizedHref, window.location.href, __basePath);
|
|
1011
|
+
stageAppNavigationFailureTarget(fullHref);
|
|
986
1012
|
notifyAppRouterTransitionStart(fullHref, mode);
|
|
987
1013
|
if (mode === "push") saveScrollPosition();
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1014
|
+
const earlyIntent = navigationPlanner.classifyEarlyNavigationIntent({
|
|
1015
|
+
basePath: __basePath,
|
|
1016
|
+
currentHref: window.location.href,
|
|
1017
|
+
mode,
|
|
1018
|
+
scroll,
|
|
1019
|
+
targetHref: fullHref
|
|
1020
|
+
});
|
|
1021
|
+
if (earlyIntent.kind === "sameDocumentScroll") {
|
|
1022
|
+
clearAppRouterScrollIntent();
|
|
1023
|
+
commitHashOnlyHistoryState(fullHref, earlyIntent.mode, earlyIntent.scroll);
|
|
1024
|
+
clearAppNavigationFailureTarget(fullHref);
|
|
991
1025
|
commitClientNavigationState();
|
|
992
|
-
if (scroll) scrollToHashTarget(hash);
|
|
1026
|
+
if (earlyIntent.scroll) scrollToHashTarget(earlyIntent.hash);
|
|
993
1027
|
return;
|
|
994
1028
|
}
|
|
995
1029
|
if (hasPendingAppRouterPageRedirect(typeof document === "undefined" ? void 0 : document)) {
|
|
@@ -998,8 +1032,7 @@ async function navigateClientSide(href, mode, scroll, programmaticTransition = f
|
|
|
998
1032
|
await mpaNavigate(fullHref, mode);
|
|
999
1033
|
return;
|
|
1000
1034
|
}
|
|
1001
|
-
|
|
1002
|
-
else window.location.assign(fullHref);
|
|
1035
|
+
hardNavigateTo(fullHref, mode);
|
|
1003
1036
|
await new Promise(() => {});
|
|
1004
1037
|
return;
|
|
1005
1038
|
}
|
|
@@ -1009,7 +1042,7 @@ async function navigateClientSide(href, mode, scroll, programmaticTransition = f
|
|
|
1009
1042
|
if (!scroll) clearAppRouterScrollIntent();
|
|
1010
1043
|
const appNavigate = getNavigationRuntime()?.functions.navigate;
|
|
1011
1044
|
try {
|
|
1012
|
-
if (appNavigate) await appNavigate(fullHref, 0, "navigate", mode, void 0, programmaticTransition, void 0, scrollIntent);
|
|
1045
|
+
if (appNavigate) await appNavigate(fullHref, 0, "navigate", mode, void 0, programmaticTransition, void 0, scrollIntent, visibleCommitMode);
|
|
1013
1046
|
else {
|
|
1014
1047
|
if (mode === "replace") replaceHistoryStateWithoutNotify(null, "", fullHref);
|
|
1015
1048
|
else pushHistoryStateWithoutNotify(null, "", fullHref);
|
|
@@ -1019,10 +1052,7 @@ async function navigateClientSide(href, mode, scroll, programmaticTransition = f
|
|
|
1019
1052
|
if (scrollIntent) consumeAppRouterScrollIntent(scrollIntent);
|
|
1020
1053
|
throw error;
|
|
1021
1054
|
}
|
|
1022
|
-
if (scrollIntent)
|
|
1023
|
-
const fallbackIntent = consumeAppRouterScrollIntent(scrollIntent);
|
|
1024
|
-
if (fallbackIntent) applyAppRouterScrollFallback(fallbackIntent);
|
|
1025
|
-
}
|
|
1055
|
+
if (scrollIntent) scheduleAppRouterScrollFallback(scrollIntent);
|
|
1026
1056
|
}
|
|
1027
1057
|
let scheduledAppRouterNavigationCount = 0;
|
|
1028
1058
|
function trackScheduledAppRouterNavigation() {
|
|
@@ -1114,6 +1144,8 @@ const _appRouter = {
|
|
|
1114
1144
|
if (localPath == null) return;
|
|
1115
1145
|
prefetchHref = localPath;
|
|
1116
1146
|
}
|
|
1147
|
+
const hybridOwner = resolveHybridClientRouteOwner(prefetchHref, __basePath);
|
|
1148
|
+
if (hybridOwner === "pages" || hybridOwner === "document") return;
|
|
1117
1149
|
const fullHref = toBrowserNavigationHref(prefetchHref, window.location.href, __basePath);
|
|
1118
1150
|
const interceptionContext = getPrefetchInterceptionContext(fullHref);
|
|
1119
1151
|
const mountedSlotsHeader = getMountedSlotsHeader();
|
|
@@ -1137,6 +1169,20 @@ const _appRouter = {
|
|
|
1137
1169
|
});
|
|
1138
1170
|
}
|
|
1139
1171
|
};
|
|
1172
|
+
if (process.env.__NEXT_GESTURE_TRANSITION) _appRouter.experimental_gesturePush = (href, options) => {
|
|
1173
|
+
assertSafeNavigationUrl(href);
|
|
1174
|
+
if (isServer) return;
|
|
1175
|
+
if (!getNavigationRuntime()?.functions.navigate) return;
|
|
1176
|
+
let appHref = href;
|
|
1177
|
+
if (isAbsoluteOrProtocolRelativeUrl(href)) {
|
|
1178
|
+
const localPath = toSameOriginAppPath(href, __basePath);
|
|
1179
|
+
if (localPath === null) return;
|
|
1180
|
+
appHref = localPath;
|
|
1181
|
+
}
|
|
1182
|
+
const releaseNavigation = trackScheduledAppRouterNavigation();
|
|
1183
|
+
navigateClientSide(appHref, "push", options?.scroll !== false, false, "synchronous");
|
|
1184
|
+
releaseScheduledAppRouterNavigationAfterCurrentTask(releaseNavigation);
|
|
1185
|
+
};
|
|
1140
1186
|
function formatPublicBfcacheId(value) {
|
|
1141
1187
|
if (!value || value === "0") return PUBLIC_INITIAL_BFCACHE_ID;
|
|
1142
1188
|
return value;
|
|
@@ -1203,6 +1249,7 @@ function useSelectedLayoutSegment(parallelRoutesKey) {
|
|
|
1203
1249
|
* @param parallelRoutesKey - Which parallel route to read (default: "children")
|
|
1204
1250
|
*/
|
|
1205
1251
|
function useSelectedLayoutSegments(parallelRoutesKey) {
|
|
1252
|
+
if (isServer) markPprFallbackShellDynamicBoundary();
|
|
1206
1253
|
return useChildSegments(parallelRoutesKey);
|
|
1207
1254
|
}
|
|
1208
1255
|
/**
|
|
@@ -1585,4 +1632,4 @@ if (!isServer) {
|
|
|
1585
1632
|
}
|
|
1586
1633
|
}
|
|
1587
1634
|
//#endregion
|
|
1588
|
-
export { BailoutToCSRError, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, decodeRedirectError, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
1635
|
+
export { BailoutToCSRError, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
//#region src/shims/ppr-fallback-shell.d.ts
|
|
2
2
|
type PprFallbackShellState = {
|
|
3
3
|
abortController: AbortController;
|
|
4
|
+
reactAbortController: AbortController;
|
|
4
5
|
cacheEpoch: number;
|
|
5
6
|
cacheReadyResolvers: Array<() => void>;
|
|
6
7
|
fallbackParamNames: ReadonlySet<string>;
|
|
7
8
|
hasDynamicBoundary: boolean;
|
|
9
|
+
isFinalRenderStarted: boolean;
|
|
8
10
|
isAbortScheduled: boolean;
|
|
9
11
|
pendingAbortCleanup: (() => void) | null;
|
|
10
12
|
pendingCacheReadyCleanup: (() => void) | null;
|
|
@@ -21,9 +23,11 @@ declare function runWithPprFallbackShellState<T>(state: PprFallbackShellState, f
|
|
|
21
23
|
declare function getPprFallbackShellState(): PprFallbackShellState | null;
|
|
22
24
|
declare function trackPprFallbackShellCacheTask<T>(fn: () => Promise<T>, cacheVariant: string): Promise<T>;
|
|
23
25
|
declare function createPprFallbackShellSuspensePromiseForState<T>(state: PprFallbackShellState, expression: string): Promise<T>;
|
|
26
|
+
declare function markPprFallbackShellDynamicBoundary(): void;
|
|
24
27
|
declare function createPprFallbackShellSuspensePromise<T>(expression: string): Promise<T> | null;
|
|
25
28
|
declare function waitForPprFallbackShellCacheReady(state: PprFallbackShellState): Promise<void>;
|
|
26
29
|
declare function preparePprFallbackShellFinalRender(state: PprFallbackShellState): void;
|
|
30
|
+
declare function beginPprFallbackShellFinalRender(state: PprFallbackShellState): void;
|
|
27
31
|
declare function isPprFallbackShellAbortError(error: unknown): boolean;
|
|
28
32
|
//#endregion
|
|
29
|
-
export { PprFallbackShellState, createPprFallbackShellState, createPprFallbackShellSuspensePromise, createPprFallbackShellSuspensePromiseForState, getPprFallbackShellState, isPprFallbackShellAbortError, preparePprFallbackShellFinalRender, runWithPprFallbackShellState, trackPprFallbackShellCacheTask, waitForPprFallbackShellCacheReady };
|
|
33
|
+
export { PprFallbackShellState, beginPprFallbackShellFinalRender, createPprFallbackShellState, createPprFallbackShellSuspensePromise, createPprFallbackShellSuspensePromiseForState, getPprFallbackShellState, isPprFallbackShellAbortError, markPprFallbackShellDynamicBoundary, preparePprFallbackShellFinalRender, runWithPprFallbackShellState, trackPprFallbackShellCacheTask, waitForPprFallbackShellCacheReady };
|
|
@@ -43,12 +43,15 @@ function scheduleCacheReadyIfSettled(state) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
function scheduleAbortIfReady(state) {
|
|
46
|
-
if (state.phase !== "final" || !state.hasDynamicBoundary || state.pendingCacheTasks > 0 || state.pendingCacheReadyCleanup !== null || state.isAbortScheduled) return;
|
|
46
|
+
if (state.phase !== "final" || !state.isFinalRenderStarted || !state.hasDynamicBoundary || state.pendingCacheTasks > 0 || state.pendingCacheReadyCleanup !== null || state.isAbortScheduled) return;
|
|
47
47
|
state.isAbortScheduled = true;
|
|
48
48
|
state.pendingAbortCleanup = scheduleAfterTask(() => {
|
|
49
49
|
state.pendingAbortCleanup = null;
|
|
50
50
|
state.isAbortScheduled = false;
|
|
51
|
-
if (state.phase === "final" && state.hasDynamicBoundary && state.pendingCacheTasks === 0 && state.pendingCacheReadyCleanup === null && !state.
|
|
51
|
+
if (state.phase === "final" && state.hasDynamicBoundary && state.pendingCacheTasks === 0 && state.pendingCacheReadyCleanup === null && !state.reactAbortController.signal.aborted) {
|
|
52
|
+
state.reactAbortController.abort();
|
|
53
|
+
state.abortController.abort();
|
|
54
|
+
}
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
57
|
function completeCacheTask(state, task) {
|
|
@@ -64,12 +67,15 @@ function ignoreCacheTask(state, task) {
|
|
|
64
67
|
completeCacheTask(state, task);
|
|
65
68
|
}
|
|
66
69
|
function createPprFallbackShellState(options) {
|
|
70
|
+
const abortController = new AbortController();
|
|
67
71
|
return {
|
|
68
|
-
abortController
|
|
72
|
+
abortController,
|
|
73
|
+
reactAbortController: abortController,
|
|
69
74
|
cacheEpoch: 0,
|
|
70
75
|
cacheReadyResolvers: [],
|
|
71
76
|
fallbackParamNames: new Set(options.fallbackParamNames),
|
|
72
77
|
hasDynamicBoundary: false,
|
|
78
|
+
isFinalRenderStarted: false,
|
|
73
79
|
isAbortScheduled: false,
|
|
74
80
|
pendingAbortCleanup: null,
|
|
75
81
|
pendingCacheReadyCleanup: null,
|
|
@@ -107,14 +113,22 @@ function trackPprFallbackShellCacheTask(fn, cacheVariant) {
|
|
|
107
113
|
});
|
|
108
114
|
}
|
|
109
115
|
function createPprFallbackShellSuspensePromiseForState(state, expression) {
|
|
110
|
-
state
|
|
111
|
-
for (const task of pprFallbackShellCacheTaskStackAls.getStore() ?? []) ignoreCacheTask(state, task);
|
|
112
|
-
scheduleCacheReadyIfSettled(state);
|
|
116
|
+
markPprFallbackShellDynamicBoundaryForState(state);
|
|
113
117
|
if (state.phase === "final") scheduleAbortIfReady(state);
|
|
114
118
|
const promise = makeHangingPromise(state.abortController.signal, state.routePattern, expression);
|
|
115
119
|
promise.catch(noop);
|
|
116
120
|
return promise;
|
|
117
121
|
}
|
|
122
|
+
function markPprFallbackShellDynamicBoundaryForState(state) {
|
|
123
|
+
state.hasDynamicBoundary = true;
|
|
124
|
+
for (const task of pprFallbackShellCacheTaskStackAls.getStore() ?? []) ignoreCacheTask(state, task);
|
|
125
|
+
scheduleCacheReadyIfSettled(state);
|
|
126
|
+
}
|
|
127
|
+
function markPprFallbackShellDynamicBoundary() {
|
|
128
|
+
const state = getPprFallbackShellState();
|
|
129
|
+
if (state === null || state.fallbackParamNames.size === 0) return;
|
|
130
|
+
markPprFallbackShellDynamicBoundaryForState(state);
|
|
131
|
+
}
|
|
118
132
|
function createPprFallbackShellSuspensePromise(expression) {
|
|
119
133
|
const state = getPprFallbackShellState();
|
|
120
134
|
if (state === null) return null;
|
|
@@ -134,16 +148,23 @@ function preparePprFallbackShellFinalRender(state) {
|
|
|
134
148
|
state.pendingAbortCleanup = null;
|
|
135
149
|
}
|
|
136
150
|
state.abortController = new AbortController();
|
|
151
|
+
state.reactAbortController = new AbortController();
|
|
137
152
|
state.cacheEpoch++;
|
|
138
153
|
state.cacheReadyResolvers.length = 0;
|
|
139
154
|
state.hasDynamicBoundary = false;
|
|
155
|
+
state.isFinalRenderStarted = false;
|
|
140
156
|
state.isAbortScheduled = false;
|
|
141
157
|
state.pendingCacheTasks = 0;
|
|
142
158
|
state.phase = "final";
|
|
143
159
|
}
|
|
160
|
+
function beginPprFallbackShellFinalRender(state) {
|
|
161
|
+
if (state.phase !== "final") return;
|
|
162
|
+
state.isFinalRenderStarted = true;
|
|
163
|
+
scheduleAbortIfReady(state);
|
|
164
|
+
}
|
|
144
165
|
function isPprFallbackShellAbortError(error) {
|
|
145
166
|
if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
|
|
146
167
|
return error instanceof Error && error.name === "HangingPromiseRejectionError";
|
|
147
168
|
}
|
|
148
169
|
//#endregion
|
|
149
|
-
export { createPprFallbackShellState, createPprFallbackShellSuspensePromise, createPprFallbackShellSuspensePromiseForState, getPprFallbackShellState, isPprFallbackShellAbortError, preparePprFallbackShellFinalRender, runWithPprFallbackShellState, trackPprFallbackShellCacheTask, waitForPprFallbackShellCacheReady };
|
|
170
|
+
export { beginPprFallbackShellFinalRender, createPprFallbackShellState, createPprFallbackShellSuspensePromise, createPprFallbackShellSuspensePromiseForState, getPprFallbackShellState, isPprFallbackShellAbortError, markPprFallbackShellDynamicBoundary, preparePprFallbackShellFinalRender, runWithPprFallbackShellState, trackPprFallbackShellCacheTask, waitForPprFallbackShellCacheReady };
|
package/dist/shims/router.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ type UrlObject = {
|
|
|
36
36
|
query?: UrlQuery;
|
|
37
37
|
};
|
|
38
38
|
type TransitionOptions = {
|
|
39
|
+
_h?: 1;
|
|
39
40
|
shallow?: boolean;
|
|
40
41
|
scroll?: boolean;
|
|
41
42
|
locale?: string | false;
|
|
@@ -108,6 +109,7 @@ type PagesNavigationContextShape = {
|
|
|
108
109
|
*/
|
|
109
110
|
declare function getPagesNavigationContext(): PagesNavigationContextShape | null;
|
|
110
111
|
declare function getPagesNavigationIsReadyFromSerializedState(routePattern: string | undefined, searchString: string, nextData?: VinextNextData): boolean;
|
|
112
|
+
declare function markPagesRouterReady(): boolean;
|
|
111
113
|
/**
|
|
112
114
|
* useRouter hook - Pages Router compatible.
|
|
113
115
|
*
|
|
@@ -122,8 +124,17 @@ declare function useRouter(): NextRouter;
|
|
|
122
124
|
* The provider owns the reactive Pages Router snapshot so next/router and
|
|
123
125
|
* next/compat/router consumers share one context value instead of each hook
|
|
124
126
|
* installing its own global URL-change listener.
|
|
127
|
+
*
|
|
128
|
+
* The PagesRouterCommitBoundary exists for client navigations: its layout
|
|
129
|
+
* callback runs scroll restoration at commit time and resolves the navigation
|
|
130
|
+
* at the same root-commit boundary Next.js awaits before routeChangeComplete.
|
|
131
|
+
* Its onError rejection drives the hard-navigation fallback in runNavigateClient.
|
|
132
|
+
* The same boundary intentionally also wraps SSR and initial hydration, where
|
|
133
|
+
* callbacks default to noopCommit: a hydration-time render error is caught
|
|
134
|
+
* here (React still console.error's it) instead of propagating, matching the
|
|
135
|
+
* navigation-path containment.
|
|
125
136
|
*/
|
|
126
|
-
declare function wrapWithRouterContext(element: ReactElement): ReactElement;
|
|
137
|
+
declare function wrapWithRouterContext(element: ReactElement, onCommit?: () => void, onError?: (error: Error) => void): ReactElement;
|
|
127
138
|
/**
|
|
128
139
|
* Props injected by `withRouter` into the wrapped component.
|
|
129
140
|
*
|
|
@@ -176,4 +187,4 @@ declare const RouterMethods: {
|
|
|
176
187
|
};
|
|
177
188
|
declare const Router: typeof RouterMethods & Omit<NextRouter, keyof typeof RouterMethods>;
|
|
178
189
|
//#endregion
|
|
179
|
-
export { ExcludeRouterProps, NextRouter, WithRouterProps, _registerRouterStateAccessors, applyNavigationLocale, Router as default, getPagesNavigationContext, getPagesNavigationIsReadyFromSerializedState, isExternalUrl, isHashOnlyChange, setSSRContext, useRouter, withRouter, wrapWithRouterContext };
|
|
190
|
+
export { ExcludeRouterProps, NextRouter, WithRouterProps, markPagesRouterReady as _markPagesRouterReady, _registerRouterStateAccessors, applyNavigationLocale, Router as default, getPagesNavigationContext, getPagesNavigationIsReadyFromSerializedState, isExternalUrl, isHashOnlyChange, setSSRContext, useRouter, withRouter, wrapWithRouterContext };
|