/home/techb158/balavpn.abdallabala.com/node_modules/next/dist/esm/client/components
NameSizeModeActions
builtin/-0777rm
errors/-0777rm
http-access-fallback/-0777rm
metadata/-0777rm
router-reducer/-0777rm
segment-cache-impl/-0777rm
styles/-0777rm
app-router-announcer.js27570666editdlrm
app-router-announcer.js.map46600666editdlrm
app-router-headers.js16750666editdlrm
app-router-headers.js.map30140666editdlrm
app-router-instance.js130370666editdlrm
app-router-instance.js.map211310666editdlrm
app-router.js230670666editdlrm
app-router.js.map350120666editdlrm
bailout-to-client-rendering.js12360666editdlrm
bailout-to-client-rendering.js.map17060666editdlrm
bfcache.js45680666editdlrm
bfcache.js.map63940666editdlrm
client-page.js25190666editdlrm
client-page.js.map39190666editdlrm
client-segment.js21060666editdlrm
client-segment.js.map30990666editdlrm
dev-root-http-access-fallback-boundary.js9010666editdlrm
dev-root-http-access-fallback-boundary.js.map12920666editdlrm
error-boundary.js47300666editdlrm
error-boundary.js.map74540666editdlrm
forbidden.js15430666editdlrm
forbidden.js.map19880666editdlrm
handle-isr-error.js7090666editdlrm
handle-isr-error.js.map13160666editdlrm
hooks-server-context.js5340666editdlrm
hooks-server-context.js.map11330666editdlrm
is-next-router-error.js4810666editdlrm
is-next-router-error.js.map9220666editdlrm
layout-router.js264060666editdlrm
layout-router.js.map378500666editdlrm
links.js125330666editdlrm
links.js.map210600666editdlrm
match-segments.js5240666editdlrm
match-segments.js.map10340666editdlrm
nav-failure-handler.js16140666editdlrm
nav-failure-handler.js.map28270666editdlrm
navigation-untracked.js23970666editdlrm
navigation-untracked.js.map33740666editdlrm
navigation.js91180666editdlrm
navigation.js.map128070666editdlrm
navigation.react-server.js19440666editdlrm
navigation.react-server.js.map27680666editdlrm
noop-head.js940666editdlrm
noop-head.js.map2330666editdlrm
not-found.js13560666editdlrm
not-found.js.map17520666editdlrm
promise-queue.js37120666editdlrm
promise-queue.js.map35910666editdlrm
redirect-boundary.js22220666editdlrm
redirect-boundary.js.map39400666editdlrm
redirect-error.js11230666editdlrm
redirect-error.js.map21030666editdlrm
redirect-status-code.js4250666editdlrm
redirect-status-code.js.map3190666editdlrm
redirect.js38220666editdlrm
redirect.js.map58370666editdlrm
render-from-template-context.js4560666editdlrm
render-from-template-context.js.map6670666editdlrm
segment-cache.js60040666editdlrm
segment-cache.js.map88230666editdlrm
static-generation-bailout.js4660666editdlrm
static-generation-bailout.js.map8770666editdlrm
unauthorized.js15700666editdlrm
unauthorized.js.map20200666editdlrm
unrecognized-action-error.js9230666editdlrm
unrecognized-action-error.js.map14780666editdlrm
unresolved-thenable.js2270666editdlrm
unresolved-thenable.js.map4410666editdlrm
unstable-rethrow.browser.js4330666editdlrm
unstable-rethrow.browser.js.map8410666editdlrm
unstable-rethrow.js7120666editdlrm
unstable-rethrow.js.map11120666editdlrm
unstable-rethrow.server.js8540666editdlrm
unstable-rethrow.server.js.map15660666editdlrm
use-action-queue.js19210666editdlrm
use-action-queue.js.map32730666editdlrm
Edit: /home/techb158/balavpn.abdallabala.com/node_modules/next/dist/esm/client/components/bfcache.js (4568B)
import { useState } from 'react'; // When the flag is disabled, only track the currently active tree const MAX_BF_CACHE_ENTRIES = process.env.__NEXT_ROUTER_BF_CACHE ? 3 : 1; /** * Keeps track of the most recent N trees (FlightRouterStates) that were active * at a certain segment level. E.g. for a segment "/a/b/[param]", this hook * tracks the last N param values that the router rendered for N. * * The result of this hook precisely determines the number and order of * trees that are rendered in parallel at their segment level. * * The purpose of this cache is to we can preserve the React and DOM state of * some number of inactive trees, by rendering them in an boundary. * That means it would not make sense for the the lifetime of the cache to be * any longer than the lifetime of the React tree; e.g. if the hook were * unmounted, then the React tree would be, too. So, we use React state to * manage it. * * Note that we don't store the RSC data for the cache entries in this hook — * the data for inactive segments is stored in the parent CacheNode, which * *does* have a longer lifetime than the React tree. This hook only determines * which of those trees should have their *state* preserved, by . */ export function useRouterBFCache(activeTree, activeStateKey) { // The currently active entry. The entries form a linked list, sorted in // order of most recently active. This allows us to reuse parts of the list // without cloning, unless there's a reordering or removal. // TODO: Once we start tracking back/forward history at each route level, // we should use the history order instead. In other words, when traversing // to an existing entry as a result of a popstate event, we should maintain // the existing order instead of moving it to the front of the list. I think // an initial implementation of this could be to pass an incrementing id // to history.pushState/replaceState, then use that here for ordering. const [prevActiveEntry, setPrevActiveEntry] = useState(()=>{ const initialEntry = { tree: activeTree, stateKey: activeStateKey, next: null }; return initialEntry; }); if (prevActiveEntry.tree === activeTree) { // Fast path. The active tree hasn't changed, so we can reuse the // existing state. return prevActiveEntry; } // The route tree changed. Note that this doesn't mean that the tree changed // *at this level* — the change may be due to a child route. Either way, we // need to either add or update the router tree in the bfcache. // // The rest of the code looks more complicated than it actually is because we // can't mutate the state in place; we have to copy-on-write. // Create a new entry for the active cache key. This is the head of the new // linked list. const newActiveEntry = { tree: activeTree, stateKey: activeStateKey, next: null }; // We need to append the old list onto the new list. If the head of the new // list was already present in the cache, then we'll need to clone everything // that came before it. Then we can reuse the rest. let n = 1; let oldEntry = prevActiveEntry; let clonedEntry = newActiveEntry; while(oldEntry !== null && n < MAX_BF_CACHE_ENTRIES){ if (oldEntry.stateKey === activeStateKey) { // Fast path. This entry in the old list that corresponds to the key that // is now active. We've already placed a clone of this entry at the front // of the new list. We can reuse the rest of the old list without cloning. // NOTE: We don't need to worry about eviction in this case because we // haven't increased the size of the cache, and we assume the max size // is constant across renders. If we were to change it to a dynamic limit, // then the implementation would need to account for that. clonedEntry.next = oldEntry.next; break; } else { // Clone the entry and append it to the list. n++; const entry = { tree: oldEntry.tree, stateKey: oldEntry.stateKey, next: null }; clonedEntry.next = entry; clonedEntry = entry; } oldEntry = oldEntry.next; } setPrevActiveEntry(newActiveEntry); return newActiveEntry; } //# sourceMappingURL=bfcache.js.map