main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
import { fetchServerResponse } from "../fetch-server-response";
import { createRecordFromThenable } from "../create-record-from-thenable";
import { readRecordValue } from "../read-record-value";
import { createHrefFromUrl } from "../create-href-from-url";
import { applyRouterStatePatchToTree } from "../apply-router-state-patch-to-tree";
import { isNavigatingToNewRootLayout } from "../is-navigating-to-new-root-layout";
import { handleExternalUrl } from "./navigate-reducer";
import { handleMutable } from "../handle-mutable";
import { applyFlightData } from "../apply-flight-data";
// A version of refresh reducer that keeps the cache around instead of wiping all of it.
function fastRefreshReducerImpl(state, action) {
const { cache, mutable, origin } = action;
const href = state.canonicalUrl;
const isForCurrentTree = JSON.stringify(mutable.previousTree) === JSON.stringify(state.tree);
if (isForCurrentTree) {
return handleMutable(state, mutable);
}
if (!cache.data) {
// TODO-APP: verify that `href` is not an external url.
// Fetch data from the root of the tree.
cache.data = createRecordFromThenable(fetchServerResponse(new URL(href, origin), [
state.tree[0],
state.tree[1],
state.tree[2],
"refetch"
], state.nextUrl, state.buildId));
}
const [flightData, canonicalUrlOverride] = readRecordValue(cache.data);
// Handle case when navigating to page in `pages` from `app`
if (typeof flightData === "string") {
return handleExternalUrl(state, mutable, flightData, state.pushRef.pendingPush);
}
// Remove cache.data as it has been resolved at this point.
cache.data = null;
let currentTree = state.tree;
let currentCache = state.cache;
for (const flightDataPath of flightData){
// FlightDataPath with more than two items means unexpected Flight data was returned
if (flightDataPath.length !== 3) {
// TODO-APP: handle this case better
console.log("REFRESH FAILED");
return state;
}
// Given the path can only have two items the items are only the router state and subTreeData for the root.
const [treePatch] = flightDataPath;
const newTree = applyRouterStatePatchToTree(// TODO-APP: remove ''
[
""
], currentTree, treePatch);
if (newTree === null) {
throw new Error("SEGMENT MISMATCH");
}
if (isNavigatingToNewRootLayout(currentTree, newTree)) {
return handleExternalUrl(state, mutable, href, state.pushRef.pendingPush);
}
const canonicalUrlOverrideHref = canonicalUrlOverride ? createHrefFromUrl(canonicalUrlOverride) : undefined;
if (canonicalUrlOverride) {
mutable.canonicalUrl = canonicalUrlOverrideHref;
}
const applied = applyFlightData(currentCache, cache, flightDataPath);
if (applied) {
mutable.cache = cache;
currentCache = cache;
}
mutable.previousTree = currentTree;
mutable.patchedTree = newTree;
mutable.canonicalUrl = href;
currentTree = newTree;
}
return handleMutable(state, mutable);
}
function fastRefreshReducerNoop(state, _action) {
return state;
}
export const fastRefreshReducer = process.env.NODE_ENV === "production" ? fastRefreshReducerNoop : fastRefreshReducerImpl;
//# sourceMappingURL=fast-refresh-reducer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/fast-refresh-reducer.ts"],"names":["fetchServerResponse","createRecordFromThenable","readRecordValue","createHrefFromUrl","applyRouterStatePatchToTree","isNavigatingToNewRootLayout","handleExternalUrl","handleMutable","applyFlightData","fastRefreshReducerImpl","state","action","cache","mutable","origin","href","canonicalUrl","isForCurrentTree","JSON","stringify","previousTree","tree","data","URL","nextUrl","buildId","flightData","canonicalUrlOverride","pushRef","pendingPush","currentTree","currentCache","flightDataPath","length","console","log","treePatch","newTree","Error","canonicalUrlOverrideHref","undefined","applied","patchedTree","fastRefreshReducerNoop","_action","fastRefreshReducer","process","env","NODE_ENV"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,wBAAwB,QAAQ,iCAAgC;AACzE,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,2BAA2B,QAAQ,sCAAqC;AACjF,SAASC,2BAA2B,QAAQ,sCAAqC;AAMjF,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,aAAa,QAAQ,oBAAmB;AACjD,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,wFAAwF;AACxF,SAASC,uBACPC,KAA2B,EAC3B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kBAAkBI,OAAOG,SAASE,MAAML,MAAMkB,OAAO,CAACC,WAAW;QAC1E;QAEA,MAAMU,2BAA2BZ,uBAC7BxB,kBAAkBwB,wBAClBa;QAEJ,IAAIb,sBAAsB;YACxBd,QAAQG,YAAY,GAAGuB;QACzB;QACA,MAAME,UAAUjC,gBAAgBuB,cAAcnB,OAAOoB;QAErD,IAAIS,SAAS;YACX5B,QAAQD,KAAK,GAAGA;YAChBmB,eAAenB;QACjB;QAEAC,QAAQO,YAAY,GAAGU;QACvBjB,QAAQ6B,WAAW,GAAGL;QACtBxB,QAAQG,YAAY,GAAGD;QAEvBe,cAAcO;IAChB;IACA,OAAO9B,cAAcG,OAAOG;AAC9B;AAEA,SAAS8B,uBACPjC,KAA2B,EAC3BkC,OAA0B;IAE1B,OAAOlC;AACT;AAEA,OAAO,MAAMmC,qBACXC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eACrBL,yBACAlC,uBAAsB"}

View File

@@ -0,0 +1,26 @@
import { createRouterCacheKey } from "../create-router-cache-key";
export function findHeadInCache(cache, parallelRoutes) {
const isLastItem = Object.keys(parallelRoutes).length === 0;
if (isLastItem) {
return cache.head;
}
for(const key in parallelRoutes){
const [segment, childParallelRoutes] = parallelRoutes[key];
const childSegmentMap = cache.parallelRoutes.get(key);
if (!childSegmentMap) {
continue;
}
const cacheKey = createRouterCacheKey(segment);
const cacheNode = childSegmentMap.get(cacheKey);
if (!cacheNode) {
continue;
}
const item = findHeadInCache(cacheNode, childParallelRoutes);
if (item) {
return item;
}
}
return undefined;
}
//# sourceMappingURL=find-head-in-cache.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/find-head-in-cache.ts"],"names":["createRouterCacheKey","findHeadInCache","cache","parallelRoutes","isLastItem","Object","keys","length","head","key","segment","childParallelRoutes","childSegmentMap","get","cacheKey","cacheNode","item","undefined"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,6BAA4B;AAEjE,OAAO,SAASC,gBACdC,KAAgB,EAChBC,cAAoC;IAEpC,MAAMC,aAAaC,OAAOC,IAAI,CAACH,gBAAgBI,MAAM,KAAK;IAC1D,IAAIH,YAAY;QACd,OAAOF,MAAMM,IAAI;IACnB;IACA,IAAK,MAAMC,OAAON,eAAgB;QAChC,MAAM,CAACO,SAASC,oBAAoB,GAAGR,cAAc,CAACM,IAAI;QAC1D,MAAMG,kBAAkBV,MAAMC,cAAc,CAACU,GAAG,CAACJ;QACjD,IAAI,CAACG,iBAAiB;YACpB;QACF;QAEA,MAAME,WAAWd,qBAAqBU;QAEtC,MAAMK,YAAYH,gBAAgBC,GAAG,CAACC;QACtC,IAAI,CAACC,WAAW;YACd;QACF;QAEA,MAAMC,OAAOf,gBAAgBc,WAAWJ;QACxC,IAAIK,MAAM;YACR,OAAOA;QACT;IACF;IAEA,OAAOC;AACT"}

View File

@@ -0,0 +1,5 @@
export function getSegmentValue(segment) {
return Array.isArray(segment) ? segment[1] : segment;
}
//# sourceMappingURL=get-segment-value.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/get-segment-value.ts"],"names":["getSegmentValue","segment","Array","isArray"],"mappings":"AAEA,OAAO,SAASA,gBAAgBC,OAAgB;IAC9C,OAAOC,MAAMC,OAAO,CAACF,WAAWA,OAAO,CAAC,EAAE,GAAGA;AAC/C"}

View File

@@ -0,0 +1,237 @@
import { CacheStates } from "../../../../shared/lib/app-router-context.shared-runtime";
import { fetchServerResponse } from "../fetch-server-response";
import { createRecordFromThenable } from "../create-record-from-thenable";
import { readRecordValue } from "../read-record-value";
import { createHrefFromUrl } from "../create-href-from-url";
import { invalidateCacheBelowFlightSegmentPath } from "../invalidate-cache-below-flight-segmentpath";
import { fillCacheWithDataProperty } from "../fill-cache-with-data-property";
import { createOptimisticTree } from "../create-optimistic-tree";
import { applyRouterStatePatchToTree } from "../apply-router-state-patch-to-tree";
import { shouldHardNavigate } from "../should-hard-navigate";
import { isNavigatingToNewRootLayout } from "../is-navigating-to-new-root-layout";
import { PrefetchKind } from "../router-reducer-types";
import { handleMutable } from "../handle-mutable";
import { applyFlightData } from "../apply-flight-data";
import { PrefetchCacheEntryStatus, getPrefetchEntryCacheStatus } from "../get-prefetch-cache-entry-status";
import { prunePrefetchCache } from "./prune-prefetch-cache";
import { prefetchQueue } from "./prefetch-reducer";
export function handleExternalUrl(state, mutable, url, pendingPush) {
mutable.previousTree = state.tree;
mutable.mpaNavigation = true;
mutable.canonicalUrl = url;
mutable.pendingPush = pendingPush;
mutable.scrollableSegments = undefined;
return handleMutable(state, mutable);
}
function generateSegmentsFromPatch(flightRouterPatch) {
const segments = [];
const [segment, parallelRoutes] = flightRouterPatch;
if (Object.keys(parallelRoutes).length === 0) {
return [
[
segment
]
];
}
for (const [parallelRouteKey, parallelRoute] of Object.entries(parallelRoutes)){
for (const childSegment of generateSegmentsFromPatch(parallelRoute)){
// If the segment is empty, it means we are at the root of the tree
if (segment === "") {
segments.push([
parallelRouteKey,
...childSegment
]);
} else {
segments.push([
segment,
parallelRouteKey,
...childSegment
]);
}
}
}
return segments;
}
function addRefetchToLeafSegments(newCache, currentCache, flightSegmentPath, treePatch, data) {
let appliedPatch = false;
newCache.status = CacheStates.READY;
newCache.subTreeData = currentCache.subTreeData;
newCache.parallelRoutes = new Map(currentCache.parallelRoutes);
const segmentPathsToFill = generateSegmentsFromPatch(treePatch).map((segment)=>[
...flightSegmentPath,
...segment
]);
for (const segmentPaths of segmentPathsToFill){
const res = fillCacheWithDataProperty(newCache, currentCache, segmentPaths, data);
if (!(res == null ? void 0 : res.bailOptimistic)) {
appliedPatch = true;
}
}
return appliedPatch;
}
export function navigateReducer(state, action) {
const { url, isExternalUrl, navigateType, cache, mutable, forceOptimisticNavigation, shouldScroll } = action;
const { pathname, hash } = url;
const href = createHrefFromUrl(url);
const pendingPush = navigateType === "push";
// we want to prune the prefetch cache on every navigation to avoid it growing too large
prunePrefetchCache(state.prefetchCache);
const isForCurrentTree = JSON.stringify(mutable.previousTree) === JSON.stringify(state.tree);
if (isForCurrentTree) {
return handleMutable(state, mutable);
}
if (isExternalUrl) {
return handleExternalUrl(state, mutable, url.toString(), pendingPush);
}
let prefetchValues = state.prefetchCache.get(createHrefFromUrl(url, false));
if (forceOptimisticNavigation && (prefetchValues == null ? void 0 : prefetchValues.kind) !== PrefetchKind.TEMPORARY) {
const segments = pathname.split("/");
// TODO-APP: figure out something better for index pages
segments.push("__PAGE__");
// Optimistic tree case.
// If the optimistic tree is deeper than the current state leave that deeper part out of the fetch
const optimisticTree = createOptimisticTree(segments, state.tree, false);
// we need a copy of the cache in case we need to revert to it
const temporaryCacheNode = {
...cache
};
// Copy subTreeData for the root node of the cache.
// Note: didn't do it above because typescript doesn't like it.
temporaryCacheNode.status = CacheStates.READY;
temporaryCacheNode.subTreeData = state.cache.subTreeData;
temporaryCacheNode.parallelRoutes = new Map(state.cache.parallelRoutes);
let data;
const fetchResponse = ()=>{
if (!data) {
data = createRecordFromThenable(fetchServerResponse(url, optimisticTree, state.nextUrl, state.buildId));
}
return data;
};
// TODO-APP: segments.slice(1) strips '', we can get rid of '' altogether.
// TODO-APP: re-evaluate if we need to strip the last segment
const optimisticFlightSegmentPath = segments.slice(1).map((segment)=>[
"children",
segment
]).flat();
// Copy existing cache nodes as far as possible and fill in `data` property with the started data fetch.
// The `data` property is used to suspend in layout-router during render if it hasn't resolved yet by the time it renders.
const res = fillCacheWithDataProperty(temporaryCacheNode, state.cache, optimisticFlightSegmentPath, fetchResponse, true);
// If optimistic fetch couldn't happen it falls back to the non-optimistic case.
if (!(res == null ? void 0 : res.bailOptimistic)) {
mutable.previousTree = state.tree;
mutable.patchedTree = optimisticTree;
mutable.pendingPush = pendingPush;
mutable.hashFragment = hash;
mutable.shouldScroll = shouldScroll;
mutable.scrollableSegments = [];
mutable.cache = temporaryCacheNode;
mutable.canonicalUrl = href;
state.prefetchCache.set(createHrefFromUrl(url, false), {
data: createRecordFromThenable(Promise.resolve(data)),
// this will make sure that the entry will be discarded after 30s
kind: PrefetchKind.TEMPORARY,
prefetchTime: Date.now(),
treeAtTimeOfPrefetch: state.tree,
lastUsedTime: Date.now()
});
return handleMutable(state, mutable);
}
}
// If we don't have a prefetch value, we need to create one
if (!prefetchValues) {
const data = createRecordFromThenable(fetchServerResponse(url, state.tree, state.nextUrl, state.buildId, // in dev, there's never gonna be a prefetch entry so we want to prefetch here
// in order to simulate the behavior of the prefetch cache
process.env.NODE_ENV === "development" ? PrefetchKind.AUTO : undefined));
const newPrefetchValue = {
data: createRecordFromThenable(Promise.resolve(data)),
// this will make sure that the entry will be discarded after 30s
kind: process.env.NODE_ENV === "development" ? PrefetchKind.AUTO : PrefetchKind.TEMPORARY,
prefetchTime: Date.now(),
treeAtTimeOfPrefetch: state.tree,
lastUsedTime: null
};
state.prefetchCache.set(createHrefFromUrl(url, false), newPrefetchValue);
prefetchValues = newPrefetchValue;
}
const prefetchEntryCacheStatus = getPrefetchEntryCacheStatus(prefetchValues);
// The one before last item is the router state tree patch
const { treeAtTimeOfPrefetch, data } = prefetchValues;
prefetchQueue.bump(data);
// Unwrap cache data with `use` to suspend here (in the reducer) until the fetch resolves.
const [flightData, canonicalUrlOverride] = readRecordValue(data);
// we only want to mark this once
if (!prefetchValues.lastUsedTime) {
// important: we should only mark the cache node as dirty after we unsuspend from the call above
prefetchValues.lastUsedTime = Date.now();
}
// Handle case when navigating to page in `pages` from `app`
if (typeof flightData === "string") {
return handleExternalUrl(state, mutable, flightData, pendingPush);
}
let currentTree = state.tree;
let currentCache = state.cache;
let scrollableSegments = [];
for (const flightDataPath of flightData){
const flightSegmentPath = flightDataPath.slice(0, -4);
// The one before last item is the router state tree patch
const treePatch = flightDataPath.slice(-3)[0];
// TODO-APP: remove ''
const flightSegmentPathWithLeadingEmpty = [
"",
...flightSegmentPath
];
// Create new tree based on the flightSegmentPath and router state patch
let newTree = applyRouterStatePatchToTree(// TODO-APP: remove ''
flightSegmentPathWithLeadingEmpty, currentTree, treePatch);
// If the tree patch can't be applied to the current tree then we use the tree at time of prefetch
// TODO-APP: This should instead fill in the missing pieces in `currentTree` with the data from `treeAtTimeOfPrefetch`, then apply the patch.
if (newTree === null) {
newTree = applyRouterStatePatchToTree(// TODO-APP: remove ''
flightSegmentPathWithLeadingEmpty, treeAtTimeOfPrefetch, treePatch);
}
if (newTree !== null) {
if (isNavigatingToNewRootLayout(currentTree, newTree)) {
return handleExternalUrl(state, mutable, href, pendingPush);
}
let applied = applyFlightData(currentCache, cache, flightDataPath, prefetchValues.kind === "auto" && prefetchEntryCacheStatus === PrefetchCacheEntryStatus.reusable);
if (!applied && prefetchEntryCacheStatus === PrefetchCacheEntryStatus.stale) {
applied = addRefetchToLeafSegments(cache, currentCache, flightSegmentPath, treePatch, // eslint-disable-next-line no-loop-func
()=>fetchServerResponse(url, currentTree, state.nextUrl, state.buildId));
}
const hardNavigate = shouldHardNavigate(// TODO-APP: remove ''
flightSegmentPathWithLeadingEmpty, currentTree);
if (hardNavigate) {
cache.status = CacheStates.READY;
// Copy subTreeData for the root node of the cache.
cache.subTreeData = currentCache.subTreeData;
invalidateCacheBelowFlightSegmentPath(cache, currentCache, flightSegmentPath);
// Ensure the existing cache value is used when the cache was not invalidated.
mutable.cache = cache;
} else if (applied) {
mutable.cache = cache;
}
currentCache = cache;
currentTree = newTree;
for (const subSegment of generateSegmentsFromPatch(treePatch)){
const scrollableSegmentPath = [
...flightSegmentPath,
...subSegment
];
// Filter out the __DEFAULT__ paths as they shouldn't be scrolled to in this case.
if (scrollableSegmentPath[scrollableSegmentPath.length - 1] !== "__DEFAULT__") {
scrollableSegments.push(scrollableSegmentPath);
}
}
}
}
mutable.previousTree = state.tree;
mutable.patchedTree = currentTree;
mutable.canonicalUrl = canonicalUrlOverride ? createHrefFromUrl(canonicalUrlOverride) : href;
mutable.pendingPush = pendingPush;
mutable.scrollableSegments = scrollableSegments;
mutable.hashFragment = hash;
mutable.shouldScroll = shouldScroll;
return handleMutable(state, mutable);
}
//# sourceMappingURL=navigate-reducer.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,49 @@
import { createHrefFromUrl } from "../create-href-from-url";
import { fetchServerResponse } from "../fetch-server-response";
import { PrefetchKind } from "../router-reducer-types";
import { createRecordFromThenable } from "../create-record-from-thenable";
import { prunePrefetchCache } from "./prune-prefetch-cache";
import { NEXT_RSC_UNION_QUERY } from "../../app-router-headers";
import { PromiseQueue } from "../../promise-queue";
export const prefetchQueue = new PromiseQueue(5);
export function prefetchReducer(state, action) {
// let's prune the prefetch cache before we do anything else
prunePrefetchCache(state.prefetchCache);
const { url } = action;
url.searchParams.delete(NEXT_RSC_UNION_QUERY);
const href = createHrefFromUrl(url, // Ensures the hash is not part of the cache key as it does not affect fetching the server
false);
const cacheEntry = state.prefetchCache.get(href);
if (cacheEntry) {
/**
* If the cache entry present was marked as temporary, it means that we prefetched it from the navigate reducer,
* where we didn't have the prefetch intent. We want to update it to the new, more accurate, kind here.
*/ if (cacheEntry.kind === PrefetchKind.TEMPORARY) {
state.prefetchCache.set(href, {
...cacheEntry,
kind: action.kind
});
}
/**
* if the prefetch action was a full prefetch and that the current cache entry wasn't one, we want to re-prefetch,
* otherwise we can re-use the current cache entry
**/ if (!(cacheEntry.kind === PrefetchKind.AUTO && action.kind === PrefetchKind.FULL)) {
return state;
}
}
// fetchServerResponse is intentionally not awaited so that it can be unwrapped in the navigate-reducer
const serverResponse = createRecordFromThenable(prefetchQueue.enqueue(()=>fetchServerResponse(url, // initialTree is used when history.state.tree is missing because the history state is set in `useEffect` below, it being missing means this is the hydration case.
state.tree, state.nextUrl, state.buildId, action.kind)));
// Create new tree based on the flightSegmentPath and router state patch
state.prefetchCache.set(href, {
// Create new tree based on the flightSegmentPath and router state patch
treeAtTimeOfPrefetch: state.tree,
data: serverResponse,
kind: action.kind,
prefetchTime: Date.now(),
lastUsedTime: null
});
return state;
}
//# sourceMappingURL=prefetch-reducer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/prefetch-reducer.ts"],"names":["createHrefFromUrl","fetchServerResponse","PrefetchKind","createRecordFromThenable","prunePrefetchCache","NEXT_RSC_UNION_QUERY","PromiseQueue","prefetchQueue","prefetchReducer","state","action","prefetchCache","url","searchParams","delete","href","cacheEntry","get","kind","TEMPORARY","set","AUTO","FULL","serverResponse","enqueue","tree","nextUrl","buildId","treeAtTimeOfPrefetch","data","prefetchTime","Date","now","lastUsedTime"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAIEC,YAAY,QACP,0BAAyB;AAChC,SAASC,wBAAwB,QAAQ,iCAAgC;AACzE,SAASC,kBAAkB,QAAQ,yBAAwB;AAC3D,SAASC,oBAAoB,QAAQ,2BAA0B;AAC/D,SAASC,YAAY,QAAQ,sBAAqB;AAElD,OAAO,MAAMC,gBAAgB,IAAID,aAAa,GAAE;AAEhD,OAAO,SAASE,gBACdC,KAA2B,EAC3BC,MAAsB;IAEtB,4DAA4D;IAC5DN,mBAAmBK,MAAME,aAAa;IAEtC,MAAM,EAAEC,GAAG,EAAE,GAAGF;IAChBE,IAAIC,YAAY,CAACC,MAAM,CAACT;IAExB,MAAMU,OAAOf,kBACXY,KACA,0FAA0F;IAC1F;IAGF,MAAMI,aAAaP,MAAME,aAAa,CAACM,GAAG,CAACF;IAC3C,IAAIC,YAAY;QACd;;;KAGC,GACD,IAAIA,WAAWE,IAAI,KAAKhB,aAAaiB,SAAS,EAAE;YAC9CV,MAAME,aAAa,CAACS,GAAG,CAACL,MAAM;gBAC5B,GAAGC,UAAU;gBACbE,MAAMR,OAAOQ,IAAI;YACnB;QACF;QAEA;;;MAGE,GACF,IACE,CACEF,CAAAA,WAAWE,IAAI,KAAKhB,aAAamB,IAAI,IACrCX,OAAOQ,IAAI,KAAKhB,aAAaoB,IAAI,AAAD,GAElC;YACA,OAAOb;QACT;IACF;IAEA,uGAAuG;IACvG,MAAMc,iBAAiBpB,yBACrBI,cAAciB,OAAO,CAAC,IACpBvB,oBACEW,KACA,mKAAmK;QACnKH,MAAMgB,IAAI,EACVhB,MAAMiB,OAAO,EACbjB,MAAMkB,OAAO,EACbjB,OAAOQ,IAAI;IAKjB,wEAAwE;IACxET,MAAME,aAAa,CAACS,GAAG,CAACL,MAAM;QAC5B,wEAAwE;QACxEa,sBAAsBnB,MAAMgB,IAAI;QAChCI,MAAMN;QACNL,MAAMR,OAAOQ,IAAI;QACjBY,cAAcC,KAAKC,GAAG;QACtBC,cAAc;IAChB;IAEA,OAAOxB;AACT"}

View File

@@ -0,0 +1,10 @@
import { PrefetchCacheEntryStatus, getPrefetchEntryCacheStatus } from "../get-prefetch-cache-entry-status";
export function prunePrefetchCache(prefetchCache) {
for (const [href, prefetchCacheEntry] of prefetchCache){
if (getPrefetchEntryCacheStatus(prefetchCacheEntry) === PrefetchCacheEntryStatus.expired) {
prefetchCache.delete(href);
}
}
}
//# sourceMappingURL=prune-prefetch-cache.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/prune-prefetch-cache.ts"],"names":["PrefetchCacheEntryStatus","getPrefetchEntryCacheStatus","prunePrefetchCache","prefetchCache","href","prefetchCacheEntry","expired","delete"],"mappings":"AACA,SACEA,wBAAwB,EACxBC,2BAA2B,QACtB,qCAAoC;AAE3C,OAAO,SAASC,mBACdC,aAA4C;IAE5C,KAAK,MAAM,CAACC,MAAMC,mBAAmB,IAAIF,cAAe;QACtD,IACEF,4BAA4BI,wBAC5BL,yBAAyBM,OAAO,EAChC;YACAH,cAAcI,MAAM,CAACH;QACvB;IACF;AACF"}

View File

@@ -0,0 +1,78 @@
import { fetchServerResponse } from "../fetch-server-response";
import { createRecordFromThenable } from "../create-record-from-thenable";
import { readRecordValue } from "../read-record-value";
import { createHrefFromUrl } from "../create-href-from-url";
import { applyRouterStatePatchToTree } from "../apply-router-state-patch-to-tree";
import { isNavigatingToNewRootLayout } from "../is-navigating-to-new-root-layout";
import { handleExternalUrl } from "./navigate-reducer";
import { handleMutable } from "../handle-mutable";
import { CacheStates } from "../../../../shared/lib/app-router-context.shared-runtime";
import { fillLazyItemsTillLeafWithHead } from "../fill-lazy-items-till-leaf-with-head";
export function refreshReducer(state, action) {
const { cache, mutable, origin } = action;
const href = state.canonicalUrl;
let currentTree = state.tree;
const isForCurrentTree = JSON.stringify(mutable.previousTree) === JSON.stringify(currentTree);
if (isForCurrentTree) {
return handleMutable(state, mutable);
}
if (!cache.data) {
// TODO-APP: verify that `href` is not an external url.
// Fetch data from the root of the tree.
cache.data = createRecordFromThenable(fetchServerResponse(new URL(href, origin), [
currentTree[0],
currentTree[1],
currentTree[2],
"refetch"
], state.nextUrl, state.buildId));
}
const [flightData, canonicalUrlOverride] = readRecordValue(cache.data);
// Handle case when navigating to page in `pages` from `app`
if (typeof flightData === "string") {
return handleExternalUrl(state, mutable, flightData, state.pushRef.pendingPush);
}
// Remove cache.data as it has been resolved at this point.
cache.data = null;
for (const flightDataPath of flightData){
// FlightDataPath with more than two items means unexpected Flight data was returned
if (flightDataPath.length !== 3) {
// TODO-APP: handle this case better
console.log("REFRESH FAILED");
return state;
}
// Given the path can only have two items the items are only the router state and subTreeData for the root.
const [treePatch] = flightDataPath;
const newTree = applyRouterStatePatchToTree(// TODO-APP: remove ''
[
""
], currentTree, treePatch);
if (newTree === null) {
throw new Error("SEGMENT MISMATCH");
}
if (isNavigatingToNewRootLayout(currentTree, newTree)) {
return handleExternalUrl(state, mutable, href, state.pushRef.pendingPush);
}
const canonicalUrlOverrideHref = canonicalUrlOverride ? createHrefFromUrl(canonicalUrlOverride) : undefined;
if (canonicalUrlOverride) {
mutable.canonicalUrl = canonicalUrlOverrideHref;
}
// The one before last item is the router state tree patch
const [subTreeData, head] = flightDataPath.slice(-2);
// Handles case where prefetch only returns the router tree patch without rendered components.
if (subTreeData !== null) {
cache.status = CacheStates.READY;
cache.subTreeData = subTreeData;
fillLazyItemsTillLeafWithHead(cache, // Existing cache is not passed in as `router.refresh()` has to invalidate the entire cache.
undefined, treePatch, head);
mutable.cache = cache;
mutable.prefetchCache = new Map();
}
mutable.previousTree = currentTree;
mutable.patchedTree = newTree;
mutable.canonicalUrl = href;
currentTree = newTree;
}
return handleMutable(state, mutable);
}
//# sourceMappingURL=refresh-reducer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/refresh-reducer.ts"],"names":["fetchServerResponse","createRecordFromThenable","readRecordValue","createHrefFromUrl","applyRouterStatePatchToTree","isNavigatingToNewRootLayout","handleExternalUrl","handleMutable","CacheStates","fillLazyItemsTillLeafWithHead","refreshReducer","state","action","cache","mutable","origin","href","canonicalUrl","currentTree","tree","isForCurrentTree","JSON","stringify","previousTree","data","URL","nextUrl","buildId","flightData","canonicalUrlOverride","pushRef","pendingPush","flightDataPath","length","console","log","treePatch","newTree","Error","canonicalUrlOverrideHref","undefined","subTreeData","head","slice","status","READY","prefetchCache","Map","patchedTree"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,wBAAwB,QAAQ,iCAAgC;AACzE,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,2BAA2B,QAAQ,sCAAqC;AACjF,SAASC,2BAA2B,QAAQ,sCAAqC;AAMjF,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,aAAa,QAAQ,oBAAmB;AACjD,SAASC,WAAW,QAAQ,2DAA0D;AACtF,SAASC,6BAA6B,QAAQ,yCAAwC;AAEtF,OAAO,SAASC,eACdC,KAA2B,EAC3BC,MAAqB;IAErB,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGH;IACnC,MAAMI,OAAOL,MAAMM,YAAY;IAE/B,IAAIC,cAAcP,MAAMQ,IAAI;IAE5B,MAAMC,mBACJC,KAAKC,SAAS,CAACR,QAAQS,YAAY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AC9F,IAAIF,gBAAgB,MAAM;YACxB5B,MAAM+B,MAAM,GAAGpC,YAAYqC,KAAK;YAChChC,MAAM4B,WAAW,GAAGA;YACpBhC,8BACEI,OACA,4FAA4F;YAC5F2B,WACAJ,WACAM;YAEF5B,QAAQD,KAAK,GAAGA;YAChBC,QAAQgC,aAAa,GAAG,IAAIC;QAC9B;QAEAjC,QAAQS,YAAY,GAAGL;QACvBJ,QAAQkC,WAAW,GAAGX;QACtBvB,QAAQG,YAAY,GAAGD;QAEvBE,cAAcmB;IAChB;IAEA,OAAO9B,cAAcI,OAAOG;AAC9B"}

View File

@@ -0,0 +1,19 @@
import { createHrefFromUrl } from "../create-href-from-url";
export function restoreReducer(state, action) {
const { url, tree } = action;
const href = createHrefFromUrl(url);
return {
buildId: state.buildId,
// Set canonical url
canonicalUrl: href,
pushRef: state.pushRef,
focusAndScrollRef: state.focusAndScrollRef,
cache: state.cache,
prefetchCache: state.prefetchCache,
// Restore provided tree
tree: tree,
nextUrl: url.pathname
};
}
//# sourceMappingURL=restore-reducer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/restore-reducer.ts"],"names":["createHrefFromUrl","restoreReducer","state","action","url","tree","href","buildId","canonicalUrl","pushRef","focusAndScrollRef","cache","prefetchCache","nextUrl","pathname"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,0BAAyB;AAO3D,OAAO,SAASC,eACdC,KAA2B,EAC3BC,MAAqB;IAErB,MAAM,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGF;IACtB,MAAMG,OAAON,kBAAkBI;IAE/B,OAAO;QACLG,SAASL,MAAMK,OAAO;QACtB,oBAAoB;QACpBC,cAAcF;QACdG,SAASP,MAAMO,OAAO;QACtBC,mBAAmBR,MAAMQ,iBAAiB;QAC1CC,OAAOT,MAAMS,KAAK;QAClBC,eAAeV,MAAMU,aAAa;QAClC,wBAAwB;QACxBP,MAAMA;QACNQ,SAAST,IAAIU,QAAQ;IACvB;AACF"}

View File

@@ -0,0 +1,196 @@
import { callServer } from "../../../app-call-server";
import { ACTION, NEXT_ROUTER_STATE_TREE, NEXT_URL, RSC_CONTENT_TYPE_HEADER } from "../../app-router-headers";
import { createRecordFromThenable } from "../create-record-from-thenable";
import { readRecordValue } from "../read-record-value";
// // eslint-disable-next-line import/no-extraneous-dependencies
// import { createFromFetch } from 'react-server-dom-webpack/client'
// // eslint-disable-next-line import/no-extraneous-dependencies
// import { encodeReply } from 'react-server-dom-webpack/client'
const { createFromFetch, encodeReply } = !!process.env.NEXT_RUNTIME ? require("react-server-dom-webpack/client.edge") : require("react-server-dom-webpack/client");
import { addBasePath } from "../../../add-base-path";
import { createHrefFromUrl } from "../create-href-from-url";
import { handleExternalUrl } from "./navigate-reducer";
import { applyRouterStatePatchToTree } from "../apply-router-state-patch-to-tree";
import { isNavigatingToNewRootLayout } from "../is-navigating-to-new-root-layout";
import { CacheStates } from "../../../../shared/lib/app-router-context.shared-runtime";
import { handleMutable } from "../handle-mutable";
import { fillLazyItemsTillLeafWithHead } from "../fill-lazy-items-till-leaf-with-head";
async function fetchServerAction(state, param) {
let { actionId, actionArgs } = param;
const body = await encodeReply(actionArgs);
const res = await fetch("", {
method: "POST",
headers: {
Accept: RSC_CONTENT_TYPE_HEADER,
[ACTION]: actionId,
[NEXT_ROUTER_STATE_TREE]: encodeURIComponent(JSON.stringify(state.tree)),
...process.env.__NEXT_ACTIONS_DEPLOYMENT_ID && process.env.NEXT_DEPLOYMENT_ID ? {
"x-deployment-id": process.env.NEXT_DEPLOYMENT_ID
} : {},
...state.nextUrl ? {
[NEXT_URL]: state.nextUrl
} : {}
},
body
});
const location = res.headers.get("x-action-redirect");
let revalidatedParts;
try {
const revalidatedHeader = JSON.parse(res.headers.get("x-action-revalidated") || "[[],0,0]");
revalidatedParts = {
paths: revalidatedHeader[0] || [],
tag: !!revalidatedHeader[1],
cookie: revalidatedHeader[2]
};
} catch (e) {
revalidatedParts = {
paths: [],
tag: false,
cookie: false
};
}
const redirectLocation = location ? new URL(addBasePath(location), // Ensure relative redirects in Server Actions work, e.g. redirect('./somewhere-else')
new URL(state.canonicalUrl, window.location.href)) : undefined;
let isFlightResponse = res.headers.get("content-type") === RSC_CONTENT_TYPE_HEADER;
if (isFlightResponse) {
const response = await createFromFetch(Promise.resolve(res), {
callServer
});
if (location) {
// if it was a redirection, then result is just a regular RSC payload
const [, actionFlightData] = response != null ? response : [];
return {
actionFlightData: actionFlightData,
redirectLocation,
revalidatedParts
};
}
// otherwise it's a tuple of [actionResult, actionFlightData]
const [actionResult, [, actionFlightData]] = response != null ? response : [];
return {
actionResult,
actionFlightData,
redirectLocation,
revalidatedParts
};
}
return {
redirectLocation,
revalidatedParts
};
}
/*
* This reducer is responsible for calling the server action and processing any side-effects from the server action.
* It does not mutate the state by itself but rather delegates to other reducers to do the actual mutation.
*/ export function serverActionReducer(state, action) {
const { mutable, cache, resolve, reject } = action;
const href = state.canonicalUrl;
let currentTree = state.tree;
const isForCurrentTree = JSON.stringify(mutable.previousTree) === JSON.stringify(currentTree);
if (isForCurrentTree) {
return handleMutable(state, mutable);
}
if (mutable.inFlightServerAction) {
// unblock if a navigation event comes through
// while we've suspended on an action
if (mutable.globalMutable.pendingNavigatePath && mutable.globalMutable.pendingNavigatePath !== href) {
mutable.inFlightServerAction.then(()=>{
if (mutable.actionResultResolved) return;
// if the server action resolves after a navigation took place,
// reset ServerActionMutable values & trigger a refresh so that any stale data gets updated
mutable.inFlightServerAction = null;
mutable.globalMutable.pendingNavigatePath = undefined;
mutable.globalMutable.refresh();
mutable.actionResultResolved = true;
});
return state;
}
} else {
mutable.inFlightServerAction = createRecordFromThenable(fetchServerAction(state, action));
}
// TODO-APP: Make try/catch wrap only readRecordValue so that other errors bubble up through the reducer instead.
try {
// suspends until the server action is resolved.
const { actionResult, actionFlightData: flightData, redirectLocation } = readRecordValue(mutable.inFlightServerAction);
// Make sure the redirection is a push instead of a replace.
// Issue: https://github.com/vercel/next.js/issues/53911
if (redirectLocation) {
state.pushRef.pendingPush = true;
mutable.pendingPush = true;
}
mutable.previousTree = state.tree;
if (!flightData) {
if (!mutable.actionResultResolved) {
resolve(actionResult);
mutable.actionResultResolved = true;
}
// If there is a redirect but no flight data we need to do a mpaNavigation.
if (redirectLocation) {
return handleExternalUrl(state, mutable, redirectLocation.href, state.pushRef.pendingPush);
}
return state;
}
if (typeof flightData === "string") {
// Handle case when navigating to page in `pages` from `app`
return handleExternalUrl(state, mutable, flightData, state.pushRef.pendingPush);
}
// Remove cache.data as it has been resolved at this point.
mutable.inFlightServerAction = null;
for (const flightDataPath of flightData){
// FlightDataPath with more than two items means unexpected Flight data was returned
if (flightDataPath.length !== 3) {
// TODO-APP: handle this case better
console.log("SERVER ACTION APPLY FAILED");
return state;
}
// Given the path can only have two items the items are only the router state and subTreeData for the root.
const [treePatch] = flightDataPath;
const newTree = applyRouterStatePatchToTree(// TODO-APP: remove ''
[
""
], currentTree, treePatch);
if (newTree === null) {
throw new Error("SEGMENT MISMATCH");
}
if (isNavigatingToNewRootLayout(currentTree, newTree)) {
return handleExternalUrl(state, mutable, href, state.pushRef.pendingPush);
}
// The one before last item is the router state tree patch
const [subTreeData, head] = flightDataPath.slice(-2);
// Handles case where prefetch only returns the router tree patch without rendered components.
if (subTreeData !== null) {
cache.status = CacheStates.READY;
cache.subTreeData = subTreeData;
fillLazyItemsTillLeafWithHead(cache, // Existing cache is not passed in as `router.refresh()` has to invalidate the entire cache.
undefined, treePatch, head);
mutable.cache = cache;
mutable.prefetchCache = new Map();
}
mutable.previousTree = currentTree;
mutable.patchedTree = newTree;
mutable.canonicalUrl = href;
currentTree = newTree;
}
if (redirectLocation) {
const newHref = createHrefFromUrl(redirectLocation, false);
mutable.canonicalUrl = newHref;
}
if (!mutable.actionResultResolved) {
resolve(actionResult);
mutable.actionResultResolved = true;
}
return handleMutable(state, mutable);
} catch (e) {
if (e.status === "rejected") {
if (!mutable.actionResultResolved) {
reject(e.value);
mutable.actionResultResolved = true;
}
// When the server action is rejected we don't update the state and instead call the reject handler of the promise.
return state;
}
throw e;
}
}
//# sourceMappingURL=server-action-reducer.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,56 @@
import { createHrefFromUrl } from "../create-href-from-url";
import { applyRouterStatePatchToTree } from "../apply-router-state-patch-to-tree";
import { isNavigatingToNewRootLayout } from "../is-navigating-to-new-root-layout";
import { handleExternalUrl } from "./navigate-reducer";
import { applyFlightData } from "../apply-flight-data";
import { handleMutable } from "../handle-mutable";
export function serverPatchReducer(state, action) {
const { flightData, previousTree, overrideCanonicalUrl, cache, mutable } = action;
const isForCurrentTree = JSON.stringify(previousTree) === JSON.stringify(state.tree);
// When a fetch is slow to resolve it could be that you navigated away while the request was happening or before the reducer runs.
// In that case opt-out of applying the patch given that the data could be stale.
if (!isForCurrentTree) {
// TODO-APP: Handle tree mismatch
console.log("TREE MISMATCH");
// Keep everything as-is.
return state;
}
if (mutable.previousTree) {
return handleMutable(state, mutable);
}
// Handle case when navigating to page in `pages` from `app`
if (typeof flightData === "string") {
return handleExternalUrl(state, mutable, flightData, state.pushRef.pendingPush);
}
let currentTree = state.tree;
let currentCache = state.cache;
for (const flightDataPath of flightData){
// Slices off the last segment (which is at -4) as it doesn't exist in the tree yet
const flightSegmentPath = flightDataPath.slice(0, -4);
const [treePatch] = flightDataPath.slice(-3, -2);
const newTree = applyRouterStatePatchToTree(// TODO-APP: remove ''
[
"",
...flightSegmentPath
], currentTree, treePatch);
if (newTree === null) {
throw new Error("SEGMENT MISMATCH");
}
if (isNavigatingToNewRootLayout(currentTree, newTree)) {
return handleExternalUrl(state, mutable, state.canonicalUrl, state.pushRef.pendingPush);
}
const canonicalUrlOverrideHref = overrideCanonicalUrl ? createHrefFromUrl(overrideCanonicalUrl) : undefined;
if (canonicalUrlOverrideHref) {
mutable.canonicalUrl = canonicalUrlOverrideHref;
}
applyFlightData(currentCache, cache, flightDataPath);
mutable.previousTree = currentTree;
mutable.patchedTree = newTree;
mutable.cache = cache;
currentCache = cache;
currentTree = newTree;
}
return handleMutable(state, mutable);
}
//# sourceMappingURL=server-patch-reducer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/server-patch-reducer.ts"],"names":["createHrefFromUrl","applyRouterStatePatchToTree","isNavigatingToNewRootLayout","handleExternalUrl","applyFlightData","handleMutable","serverPatchReducer","state","action","flightData","previousTree","overrideCanonicalUrl","cache","mutable","isForCurrentTree","JSON","stringify","tree","console","log","pushRef","pendingPush","currentTree","currentCache","flightDataPath","flightSegmentPath","slice","treePatch","newTree","Error","canonicalUrl","canonicalUrlOverrideHref","undefined","patchedTree"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,2BAA2B,QAAQ,sCAAqC;AACjF,SAASC,2BAA2B,QAAQ,sCAAqC;AAMjF,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,oBAAmB;AAEjD,OAAO,SAASC,mBACdC,KAA2B,EAC3BC,MAAyB;IAEzB,MAAM,EAAEC,UAAU,EAAEC,YAAY,EAAEC,oBAAoB,EAAEC,KAAK,EAAEC,OAAO,EAAE,GACtEL;IAEF,MAAMM,mBACJC,KAAKC,SAAS,CAACN,kBAAkBK,KAAKC,SAAS,CAACT,MAAMU,IAAI;IAE5D,kIAAkI;IAClI,iFAAiF;IACjF,IAAI,CAACH,kBAAkB;QACrB,iCAAiC;QACjCI,QAAQC,GAAG,CAAC;QACZ,yBAAyB;QACzB,OAAOZ;IACT;IAEA,IAAIM,QAAQH,YAAY,EAAE;QACxB,OAAOL,cAAcE,OAAOM;IAC9B;IAEA,4DAA4D;IAC5D,IAAI,OAAOJ,eAAe,UAAU;QAClC,OAAON,kBACLI,OACAM,SACAJ,YACAF,MAAMa,OAAO,CAACC,WAAW;IAE7B;IAEA,IAAIC,cAAcf,MAAMU,IAAI;IAC5B,IAAIM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