@timber-js/app 0.2.0-alpha.165 → 0.2.0-alpha.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{actions-CSDD6x7U.js → actions-TSxpXLHJ.js} +3 -3
- package/dist/_chunks/{actions-CSDD6x7U.js.map → actions-TSxpXLHJ.js.map} +1 -1
- package/dist/_chunks/{cache-api-eb1gydM7.js → cache-api-DzpQQOEx.js} +53 -49
- package/dist/_chunks/{cache-api-eb1gydM7.js.map → cache-api-DzpQQOEx.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-mGfRbjh2.js → cli-schema-sync-wX-i90Og.js} +6 -4
- package/dist/_chunks/cli-schema-sync-wX-i90Og.js.map +1 -0
- package/dist/_chunks/cloudflare-AHoWYTYr.js +1188 -0
- package/dist/_chunks/cloudflare-AHoWYTYr.js.map +1 -0
- package/dist/_chunks/{define-CFmvb4Bt.js → define-COtkxMRT.js} +16 -28
- package/dist/_chunks/define-COtkxMRT.js.map +1 -0
- package/dist/_chunks/{define-Bssfp6ot.js → define-c4au4I9R.js} +2 -2
- package/dist/_chunks/{define-Bssfp6ot.js.map → define-c4au4I9R.js.map} +1 -1
- package/dist/_chunks/{logger-B_O6-mdJ.js → logger-t3uxAmbX.js} +3 -3
- package/dist/_chunks/logger-t3uxAmbX.js.map +1 -0
- package/dist/_chunks/{plugin-context-BnaiU_cF.js → plugin-context---kTF5v8.js} +2 -2
- package/dist/_chunks/{plugin-context-BnaiU_cF.js.map → plugin-context---kTF5v8.js.map} +1 -1
- package/dist/_chunks/{resolve-schema-3iUvBV5T.js → resolve-schema-Dz3fcFUo.js} +2 -2
- package/dist/_chunks/{resolve-schema-3iUvBV5T.js.map → resolve-schema-Dz3fcFUo.js.map} +1 -1
- package/dist/_chunks/{schema-bridge-BY3QLBL7.js → schema-bridge-DT_Tn0Xf.js} +2 -2
- package/dist/_chunks/{schema-bridge-BY3QLBL7.js.map → schema-bridge-DT_Tn0Xf.js.map} +1 -1
- package/dist/_chunks/{use-query-states-CbeQmext.js → use-query-states-DFvWd-EA.js} +65 -7
- package/dist/_chunks/use-query-states-DFvWd-EA.js.map +1 -0
- package/dist/_chunks/{walkers-BL3MCMgO.js → walkers-Cfwvl-UC.js} +3 -3
- package/dist/_chunks/{walkers-BL3MCMgO.js.map → walkers-Cfwvl-UC.js.map} +1 -1
- package/dist/adapters/cloudflare-dev.js +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/adapters/cloudflare.d.ts +12 -1
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +2 -461
- package/dist/adapters/nitro.js +1 -1
- package/dist/adapters/types.d.ts +2 -0
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/cache/cache-api.d.ts +33 -11
- package/dist/cache/cache-api.d.ts.map +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/client/browser-entry/post-hydration.d.ts.map +1 -1
- package/dist/client/history.d.ts +10 -0
- package/dist/client/history.d.ts.map +1 -1
- package/dist/client/internal.js +139 -115
- package/dist/client/internal.js.map +1 -1
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/use-query-states.d.ts.map +1 -1
- package/dist/codec.js +1 -1
- package/dist/cookies/index.js +1 -1
- package/dist/dev-tools/logs.d.ts +15 -1
- package/dist/dev-tools/logs.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +138 -45
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +1 -1
- package/dist/plugins/adapter-build.d.ts.map +1 -1
- package/dist/plugins/cache.d.ts +8 -8
- package/dist/plugins/cache.d.ts.map +1 -1
- package/dist/routing/index.js +2 -2
- package/dist/schema-bridge.d.ts.map +1 -1
- package/dist/search-params/define.d.ts +35 -4
- package/dist/search-params/define.d.ts.map +1 -1
- package/dist/search-params/index.js +3 -7
- package/dist/search-params/index.js.map +1 -1
- package/dist/search-params/wrappers.d.ts +2 -2
- package/dist/search-params/wrappers.d.ts.map +1 -1
- package/dist/segment-params/index.js +1 -1
- package/dist/server/als-registry.d.ts +7 -0
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/deny-boundary.d.ts +3 -1
- package/dist/server/deny-boundary.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/internal.js +12 -7
- package/dist/server/internal.js.map +1 -1
- package/dist/server/route-element-builder.d.ts +9 -0
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +8 -0
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/stream-utils.d.ts.map +1 -1
- package/docs/api/32-api-cache.mdx +4 -4
- package/docs/api/33-api-search-params.mdx +13 -0
- package/docs/learn/00-introduction.mdx +1 -2
- package/docs/learn/09-caching.mdx +5 -5
- package/docs/more/03-coming-from-nextjs.mdx +2 -2
- package/docs/more/50-ai-agent-instructions.mdx +5 -5
- package/package.json +10 -8
- package/src/adapters/cloudflare.ts +63 -25
- package/src/adapters/types.ts +2 -0
- package/src/cache/cache-api.ts +84 -84
- package/src/cli.ts +0 -0
- package/src/client/browser-entry/post-hydration.ts +16 -9
- package/src/client/history.ts +11 -0
- package/src/client/router.ts +212 -206
- package/src/client/use-query-states.ts +99 -7
- package/src/dev-tools/logs.ts +119 -34
- package/src/index.ts +14 -1
- package/src/plugins/adapter-build.ts +1 -0
- package/src/plugins/cache.ts +45 -30
- package/src/routing/scanner.ts +7 -0
- package/src/schema-bridge.ts +4 -3
- package/src/search-params/define.ts +57 -51
- package/src/search-params/wrappers.ts +17 -26
- package/src/server/als-registry.ts +7 -0
- package/src/server/deny-boundary.ts +6 -3
- package/src/server/route-element-builder.ts +49 -8
- package/src/server/rsc-entry/render-route.ts +3 -1
- package/src/server/rsc-entry/rsc-payload.ts +21 -4
- package/src/server/rsc-entry/rsc-stream.ts +8 -0
- package/src/server/stream-utils.ts +8 -6
- package/LICENSE +0 -8
- package/dist/_chunks/cli-schema-sync-mGfRbjh2.js.map +0 -1
- package/dist/_chunks/define-CFmvb4Bt.js.map +0 -1
- package/dist/_chunks/logger-B_O6-mdJ.js.map +0 -1
- package/dist/_chunks/use-query-states-CbeQmext.js.map +0 -1
- package/dist/adapters/cloudflare.js.map +0 -1
package/dist/client/history.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SegmentInfo } from './segment-cache';
|
|
1
2
|
export interface HistoryEntry {
|
|
2
3
|
/** The complete segment tree payload at the time of navigation */
|
|
3
4
|
payload: unknown;
|
|
@@ -8,6 +9,15 @@ export interface HistoryEntry {
|
|
|
8
9
|
* and revalidation overwrites preserve the current state (TIM-1037).
|
|
9
10
|
*/
|
|
10
11
|
params?: Record<string, string | string[]> | null;
|
|
12
|
+
/**
|
|
13
|
+
* Segment metadata for this page's route. Restored into the segment cache
|
|
14
|
+
* on popstate cached replay so the next forward navigation computes a
|
|
15
|
+
* correct state tree. Without this, the segment cache retains the
|
|
16
|
+
* *previous* page's segments after back-button, causing the server to
|
|
17
|
+
* skip segments that aren't mounted — and the partial payload targets
|
|
18
|
+
* a non-existent outlet.
|
|
19
|
+
*/
|
|
20
|
+
segmentInfo?: SegmentInfo[] | null;
|
|
11
21
|
}
|
|
12
22
|
/**
|
|
13
23
|
* Session-lived history stack keyed by URL. Enables instant back/forward
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/client/history.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/client/history.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;IAClD;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;CACpC;AAID;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAmC;IAElD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;IAI5C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI1C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAG1B"}
|
package/dist/client/internal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as bindUseQueryStates } from "../_chunks/use-query-states-
|
|
1
|
+
import { t as bindUseQueryStates } from "../_chunks/use-query-states-DFvWd-EA.js";
|
|
2
2
|
import { c as cachedSearchParams, i as _setCachedSearch, n as getSsrData, r as setSsrData, s as cachedSearch, t as clearSsrData } from "../_chunks/ssr-data-BOWsq18U.js";
|
|
3
3
|
import { a as setNavigationState, i as getNavigationState, o as useNavigationContext, r as NavigationProvider, t as setCurrentParams } from "../_chunks/use-segment-params-D1CzlgBo.js";
|
|
4
4
|
import { n as getRouterOrNull, r as setGlobalRouter, t as getRouter } from "../_chunks/router-ref-CtmF-aPv.js";
|
|
@@ -458,6 +458,59 @@ function createRouter(deps) {
|
|
|
458
458
|
function renderPayload(payload, navState) {
|
|
459
459
|
if (deps.renderRoot) deps.renderRoot(payload, navState);
|
|
460
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Atomically update all navigation-owned state for a new page. Every
|
|
463
|
+
* code path that changes the "current page" must go through this
|
|
464
|
+
* function — making "forgot a field" impossible by construction.
|
|
465
|
+
*
|
|
466
|
+
* The three operations:
|
|
467
|
+
* 1. Segment cache — update from server-provided segment metadata
|
|
468
|
+
* 2. Navigation state — params + pathname for useSegmentParams/usePathname
|
|
469
|
+
* 3. History stack — store the payload for instant back/forward replay
|
|
470
|
+
*/
|
|
471
|
+
function commitNavigation(url, opts) {
|
|
472
|
+
if (opts.segmentInfo && opts.segmentInfo.length > 0) updateSegmentCache(opts.segmentInfo);
|
|
473
|
+
else if (opts.clearSegmentCacheOnEmpty) segmentCache.clear();
|
|
474
|
+
const navState = updateNavigationState(opts.params, url);
|
|
475
|
+
historyStack.push(url, {
|
|
476
|
+
payload: opts.payload,
|
|
477
|
+
params: navState.params,
|
|
478
|
+
segmentInfo: opts.segmentInfo
|
|
479
|
+
});
|
|
480
|
+
return navState;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Wrap a navigation in the standard abort/pending/cleanup lifecycle.
|
|
484
|
+
* Consolidates the createNavAbort + setPending + staleness-guarded
|
|
485
|
+
* finally that was duplicated across navigate, refresh, and both
|
|
486
|
+
* handlePopState paths. AbortErrors are swallowed (not application
|
|
487
|
+
* errors); all other errors propagate to the caller.
|
|
488
|
+
*/
|
|
489
|
+
async function runNavigation(url, fn, externalSignal) {
|
|
490
|
+
const navAbort = createNavAbort(externalSignal);
|
|
491
|
+
setPending(true, url);
|
|
492
|
+
try {
|
|
493
|
+
await fn(navAbort);
|
|
494
|
+
} catch (error) {
|
|
495
|
+
if (isAbortError(error)) return;
|
|
496
|
+
throw error;
|
|
497
|
+
} finally {
|
|
498
|
+
if (currentNavAbort === navAbort) {
|
|
499
|
+
currentNavAbort = null;
|
|
500
|
+
setPending(false);
|
|
501
|
+
deps.completeRouterNavigation?.();
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Resolve thenable payloads in the test/fallback path (no navigateTransition).
|
|
507
|
+
* In production, React handles thenables from createFromFetch directly via
|
|
508
|
+
* Suspense. In tests, renderRoot is a plain mock that expects resolved values.
|
|
509
|
+
*/
|
|
510
|
+
async function resolveForFallback(payload) {
|
|
511
|
+
if (!deps.navigateTransition && payload != null && typeof payload === "object" && "then" in payload) return await payload;
|
|
512
|
+
return payload;
|
|
513
|
+
}
|
|
461
514
|
function isPartialNavigation(skippedSegments) {
|
|
462
515
|
return skippedSegments != null && skippedSegments.length > 0;
|
|
463
516
|
}
|
|
@@ -499,9 +552,11 @@ function createRouter(deps) {
|
|
|
499
552
|
}
|
|
500
553
|
/**
|
|
501
554
|
* Render a payload via navigateTransition (production) or renderRoot (tests).
|
|
502
|
-
* The perform callback should fetch data,
|
|
503
|
-
* FetchResult plus the NavigationState
|
|
504
|
-
*
|
|
555
|
+
* The perform callback should fetch data, call commitNavigation, and return
|
|
556
|
+
* the FetchResult plus the NavigationState.
|
|
557
|
+
*
|
|
558
|
+
* State management (segmentCache, navState, historyStack) is handled by
|
|
559
|
+
* commitNavigation inside perform — this function only handles rendering.
|
|
505
560
|
*/
|
|
506
561
|
async function renderViaTransition(url, perform) {
|
|
507
562
|
if (deps.navigateTransition) {
|
|
@@ -509,19 +564,11 @@ function createRouter(deps) {
|
|
|
509
564
|
const result = await perform();
|
|
510
565
|
if (isPartialNavigation(result.skippedSegments)) {
|
|
511
566
|
const segmentUpdates = buildSegmentUpdates(result);
|
|
512
|
-
historyStack.push(url, {
|
|
513
|
-
payload: null,
|
|
514
|
-
params: result.params
|
|
515
|
-
});
|
|
516
567
|
return {
|
|
517
568
|
element: wrapPayload(deps._getCurrentPayload?.() ?? result.payload, result.navState, segmentUpdates),
|
|
518
569
|
decodePromise: result.decodePromise
|
|
519
570
|
};
|
|
520
571
|
}
|
|
521
|
-
historyStack.push(url, {
|
|
522
|
-
payload: result.payload,
|
|
523
|
-
params: result.params
|
|
524
|
-
});
|
|
525
572
|
return {
|
|
526
573
|
element: wrapPayload(result.payload, result.navState),
|
|
527
574
|
decodePromise: result.decodePromise
|
|
@@ -530,18 +577,7 @@ function createRouter(deps) {
|
|
|
530
577
|
return;
|
|
531
578
|
}
|
|
532
579
|
const result = await perform();
|
|
533
|
-
if (isPartialNavigation(result.skippedSegments))
|
|
534
|
-
payload: null,
|
|
535
|
-
params: result.params
|
|
536
|
-
});
|
|
537
|
-
else {
|
|
538
|
-
const payload = result.payload != null && typeof result.payload === "object" && "then" in result.payload ? await result.payload : result.payload;
|
|
539
|
-
historyStack.push(url, {
|
|
540
|
-
payload,
|
|
541
|
-
params: result.params
|
|
542
|
-
});
|
|
543
|
-
renderPayload(payload, result.navState);
|
|
544
|
-
}
|
|
580
|
+
if (!isPartialNavigation(result.skippedSegments)) renderPayload(result.payload, result.navState);
|
|
545
581
|
}
|
|
546
582
|
/** Run a callback after the next paint (after React commit). */
|
|
547
583
|
function afterPaint(callback) {
|
|
@@ -601,10 +637,15 @@ function createRouter(deps) {
|
|
|
601
637
|
}, "", commitUrl);
|
|
602
638
|
deps.setRouterNavigating?.(false);
|
|
603
639
|
}
|
|
604
|
-
|
|
605
|
-
const navState =
|
|
640
|
+
const payload = await resolveForFallback(result.payload);
|
|
641
|
+
const navState = commitNavigation(url, {
|
|
642
|
+
payload: isPartialNavigation(result.skippedSegments) ? null : payload,
|
|
643
|
+
params: result.params,
|
|
644
|
+
segmentInfo: result.segmentInfo
|
|
645
|
+
});
|
|
606
646
|
return {
|
|
607
647
|
...result,
|
|
648
|
+
payload,
|
|
608
649
|
navState
|
|
609
650
|
};
|
|
610
651
|
}
|
|
@@ -616,7 +657,6 @@ function createRouter(deps) {
|
|
|
616
657
|
const hashIndex = url.indexOf("#");
|
|
617
658
|
const hash = hashIndex === -1 ? "" : url.slice(hashIndex);
|
|
618
659
|
const fetchUrl = hashIndex === -1 ? url : url.slice(0, hashIndex);
|
|
619
|
-
const navAbort = createNavAbort(externalSignal);
|
|
620
660
|
const currentScrollY = deps.getScrollY();
|
|
621
661
|
if (deps.saveNavigationEntryScroll) deps.saveNavigationEntryScroll(currentScrollY);
|
|
622
662
|
else deps.replaceState({
|
|
@@ -624,107 +664,91 @@ function createRouter(deps) {
|
|
|
624
664
|
scrollY: currentScrollY
|
|
625
665
|
}, "", deps.getCurrentUrl());
|
|
626
666
|
let effectiveSkipHistory = skipHistory;
|
|
627
|
-
|
|
628
|
-
deps.
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
setPending(true, url);
|
|
634
|
-
try {
|
|
635
|
-
await renderViaTransition(fetchUrl, () => performNavigationFetch(fetchUrl, {
|
|
636
|
-
replace,
|
|
637
|
-
commitUrl: url,
|
|
638
|
-
signal: navAbort.signal,
|
|
639
|
-
skipHistory: effectiveSkipHistory
|
|
640
|
-
}));
|
|
641
|
-
window.dispatchEvent(new Event("timber:navigation-end"));
|
|
642
|
-
if (scroll && hash) scrollToHashAfterPaint(hash);
|
|
643
|
-
else restoreScrollAfterPaint(scroll ? 0 : currentScrollY);
|
|
644
|
-
} catch (error) {
|
|
645
|
-
if (error instanceof VersionSkewError) {
|
|
646
|
-
setHardNavigating(true);
|
|
647
|
-
window.location.reload();
|
|
648
|
-
return new Promise(() => {});
|
|
649
|
-
}
|
|
650
|
-
if (error instanceof RedirectError) {
|
|
651
|
-
if (currentNavAbort !== navAbort) return;
|
|
652
|
-
await navigate(error.redirectUrl, { replace: true });
|
|
653
|
-
return;
|
|
667
|
+
await runNavigation(url, async (navAbort) => {
|
|
668
|
+
if (!effectiveSkipHistory && deps.navigationNavigate) {
|
|
669
|
+
deps.setRouterNavigating?.(true);
|
|
670
|
+
deps.navigationNavigate(url, replace);
|
|
671
|
+
deps.setRouterNavigating?.(false);
|
|
672
|
+
effectiveSkipHistory = true;
|
|
654
673
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
674
|
+
try {
|
|
675
|
+
await renderViaTransition(fetchUrl, () => performNavigationFetch(fetchUrl, {
|
|
676
|
+
replace,
|
|
677
|
+
commitUrl: url,
|
|
678
|
+
signal: navAbort.signal,
|
|
679
|
+
skipHistory: effectiveSkipHistory
|
|
680
|
+
}));
|
|
681
|
+
window.dispatchEvent(new Event("timber:navigation-end"));
|
|
682
|
+
if (scroll && hash) scrollToHashAfterPaint(hash);
|
|
683
|
+
else restoreScrollAfterPaint(scroll ? 0 : currentScrollY);
|
|
684
|
+
} catch (error) {
|
|
685
|
+
if (error instanceof VersionSkewError) {
|
|
686
|
+
setHardNavigating(true);
|
|
687
|
+
window.location.reload();
|
|
688
|
+
await new Promise(() => {});
|
|
689
|
+
}
|
|
690
|
+
if (error instanceof RedirectError) {
|
|
691
|
+
if (currentNavAbort !== navAbort) return;
|
|
692
|
+
await navigate(error.redirectUrl, { replace: true });
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (error instanceof ServerErrorResponse) {
|
|
696
|
+
setHardNavigating(true);
|
|
697
|
+
window.location.href = error.url;
|
|
698
|
+
await new Promise(() => {});
|
|
699
|
+
}
|
|
700
|
+
throw error;
|
|
667
701
|
}
|
|
668
|
-
}
|
|
702
|
+
}, externalSignal);
|
|
669
703
|
}
|
|
670
704
|
async function refresh() {
|
|
671
705
|
const currentUrl = deps.getCurrentUrl();
|
|
672
|
-
|
|
673
|
-
setPending(true, currentUrl);
|
|
674
|
-
try {
|
|
706
|
+
await runNavigation(currentUrl, async (navAbort) => {
|
|
675
707
|
await renderViaTransition(currentUrl, async () => {
|
|
676
708
|
const result = await fetchRscPayload(currentUrl, deps, void 0, void 0, navAbort.signal);
|
|
677
|
-
|
|
678
|
-
const navState =
|
|
709
|
+
const payload = await resolveForFallback(result.payload);
|
|
710
|
+
const navState = commitNavigation(currentUrl, {
|
|
711
|
+
payload,
|
|
712
|
+
params: result.params,
|
|
713
|
+
segmentInfo: result.segmentInfo
|
|
714
|
+
});
|
|
679
715
|
return {
|
|
680
716
|
...result,
|
|
717
|
+
payload,
|
|
681
718
|
navState
|
|
682
719
|
};
|
|
683
720
|
});
|
|
684
|
-
}
|
|
685
|
-
if (isAbortError(error)) return;
|
|
686
|
-
throw error;
|
|
687
|
-
} finally {
|
|
688
|
-
if (currentNavAbort === navAbort) {
|
|
689
|
-
currentNavAbort = null;
|
|
690
|
-
setPending(false);
|
|
691
|
-
deps.completeRouterNavigation?.();
|
|
692
|
-
}
|
|
693
|
-
}
|
|
721
|
+
});
|
|
694
722
|
}
|
|
695
723
|
async function handlePopState(url, scrollY = 0, externalSignal) {
|
|
696
724
|
const entry = historyStack.get(url);
|
|
697
|
-
if (entry && entry.payload !== null) {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
725
|
+
if (entry && entry.payload !== null) await runNavigation(url, async () => {
|
|
726
|
+
const navState = commitNavigation(url, {
|
|
727
|
+
payload: entry.payload,
|
|
728
|
+
params: entry.params,
|
|
729
|
+
segmentInfo: entry.segmentInfo,
|
|
730
|
+
clearSegmentCacheOnEmpty: true
|
|
731
|
+
});
|
|
702
732
|
renderPayload(entry.payload, navState);
|
|
703
733
|
restoreScrollAfterPaint(scrollY);
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
...result,
|
|
714
|
-
navState
|
|
715
|
-
};
|
|
734
|
+
}, externalSignal);
|
|
735
|
+
else await runNavigation(url, async (navAbort) => {
|
|
736
|
+
await renderViaTransition(url, async () => {
|
|
737
|
+
const result = await fetchRscPayload(url, deps, segmentCache.serializeStateTree(), void 0, navAbort.signal);
|
|
738
|
+
const payload = await resolveForFallback(result.payload);
|
|
739
|
+
const navState = commitNavigation(url, {
|
|
740
|
+
payload,
|
|
741
|
+
params: result.params,
|
|
742
|
+
segmentInfo: result.segmentInfo
|
|
716
743
|
});
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
744
|
+
return {
|
|
745
|
+
...result,
|
|
746
|
+
payload,
|
|
747
|
+
navState
|
|
748
|
+
};
|
|
749
|
+
});
|
|
750
|
+
restoreScrollAfterPaint(scrollY);
|
|
751
|
+
}, externalSignal);
|
|
728
752
|
}
|
|
729
753
|
/**
|
|
730
754
|
* Prefetch an RSC payload for a URL and store it in the prefetch cache.
|
|
@@ -753,12 +777,12 @@ function createRouter(deps) {
|
|
|
753
777
|
prefetch,
|
|
754
778
|
applyRevalidation(element) {
|
|
755
779
|
const currentUrl = deps.getCurrentUrl();
|
|
756
|
-
const
|
|
757
|
-
|
|
780
|
+
const existingEntry = historyStack.get(currentUrl);
|
|
781
|
+
renderPayload(element, commitNavigation(currentUrl, {
|
|
758
782
|
payload: element,
|
|
759
|
-
params:
|
|
760
|
-
|
|
761
|
-
|
|
783
|
+
params: getNavigationState().params,
|
|
784
|
+
segmentInfo: existingEntry?.segmentInfo
|
|
785
|
+
}));
|
|
762
786
|
},
|
|
763
787
|
initSegmentCache: (segments) => updateSegmentCache(segments),
|
|
764
788
|
segmentCache,
|