Rocky_Mountain_Vending/.pnpm-store/v10/files/bb/4727fc1cf026b510c4a0c0e51e4255fa3c18fd5a2b6b36bdeff0db48a62a04e8a3dec391a470f1c699fbe1f2fbdffd46d760f9eff81b42a2b8cd22e0491414
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

47 lines
No EOL
2.1 KiB
Text

import { createHrefFromUrl } from '../create-href-from-url';
import { extractPathFromFlightRouterState } from '../compute-changed-path';
import { updateCacheNodeOnPopstateRestoration } from '../ppr-navigations';
export function restoreReducer(state, action) {
const { url, historyState } = action;
const href = createHrefFromUrl(url);
// This action is used to restore the router state from the history state.
// However, it's possible that the history state no longer contains the `FlightRouterState`.
// We will copy over the internal state on pushState/replaceState events, but if a history entry
// occurred before hydration, or if the user navigated to a hash using a regular anchor link,
// the history state will not contain the `FlightRouterState`.
// In this case, we'll continue to use the existing tree so the router doesn't get into an invalid state.
let treeToRestore;
let renderedSearch;
if (historyState) {
treeToRestore = historyState.tree;
renderedSearch = historyState.renderedSearch;
} else {
treeToRestore = state.tree;
renderedSearch = state.renderedSearch;
}
const oldCache = state.cache;
const newCache = process.env.__NEXT_PPR ? // data for any segment whose dynamic data was already received. This
// prevents an unnecessary flash back to PPR state during a
// back/forward navigation.
updateCacheNodeOnPopstateRestoration(oldCache, treeToRestore) : oldCache;
return {
// Set canonical url
canonicalUrl: href,
renderedSearch,
pushRef: {
pendingPush: false,
mpaNavigation: false,
// Ensures that the custom history state that was set is preserved when applying this update.
preserveCustomHistoryState: true
},
focusAndScrollRef: state.focusAndScrollRef,
cache: newCache,
// Restore provided tree
tree: treeToRestore,
nextUrl: extractPathFromFlightRouterState(treeToRestore) ?? url.pathname,
previousNextUrl: null,
debugInfo: null
};
}
//# sourceMappingURL=restore-reducer.js.map