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>
1 line
No EOL
7.6 KiB
Text
1 line
No EOL
7.6 KiB
Text
{"version":3,"sources":["../../../../src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts"],"sourcesContent":["import type { CacheNode, Segment } from '../../../shared/lib/app-router-types'\nimport { invalidateCacheByRouterState } from './invalidate-cache-by-router-state'\nimport { fillLazyItemsTillLeafWithHead } from './fill-lazy-items-till-leaf-with-head'\nimport { createRouterCacheKey } from './create-router-cache-key'\nimport { PAGE_SEGMENT_KEY } from '../../../shared/lib/segment'\nimport type { NormalizedFlightData } from '../../flight-data-helpers'\n\n/**\n * Common logic for filling cache with new sub tree data.\n */\nfunction fillCacheHelper(\n navigatedAt: number,\n newCache: CacheNode,\n existingCache: CacheNode,\n flightData: NormalizedFlightData,\n fillLazyItems: boolean\n): void {\n const {\n segmentPath,\n seedData: cacheNodeSeedData,\n tree: treePatch,\n head,\n } = flightData\n let newCacheNode = newCache\n let existingCacheNode = existingCache\n\n for (let i = 0; i < segmentPath.length; i += 2) {\n const parallelRouteKey: string = segmentPath[i]\n const segment: Segment = segmentPath[i + 1]\n\n // segmentPath is a repeating tuple of parallelRouteKey and segment\n // we know we've hit the last entry we've reached our final pair\n const isLastEntry = i === segmentPath.length - 2\n const cacheKey = createRouterCacheKey(segment)\n\n const existingChildSegmentMap =\n existingCacheNode.parallelRoutes.get(parallelRouteKey)\n\n if (!existingChildSegmentMap) {\n // Bailout because the existing cache does not have the path to the leaf node\n // Will trigger lazy fetch in layout-router because of missing segment\n continue\n }\n\n let childSegmentMap = newCacheNode.parallelRoutes.get(parallelRouteKey)\n if (!childSegmentMap || childSegmentMap === existingChildSegmentMap) {\n childSegmentMap = new Map(existingChildSegmentMap)\n newCacheNode.parallelRoutes.set(parallelRouteKey, childSegmentMap)\n }\n\n const existingChildCacheNode = existingChildSegmentMap.get(cacheKey)\n let childCacheNode = childSegmentMap.get(cacheKey)\n\n if (isLastEntry) {\n if (\n cacheNodeSeedData &&\n (!childCacheNode ||\n !childCacheNode.lazyData ||\n childCacheNode === existingChildCacheNode)\n ) {\n const rsc = cacheNodeSeedData[0]\n const loading = cacheNodeSeedData[2]\n\n childCacheNode = {\n lazyData: null,\n // When `fillLazyItems` is false, we only want to fill the RSC data for the layout,\n // not the page segment.\n rsc: fillLazyItems || segment !== PAGE_SEGMENT_KEY ? rsc : null,\n prefetchRsc: null,\n head: null,\n prefetchHead: null,\n loading,\n parallelRoutes:\n fillLazyItems && existingChildCacheNode\n ? new Map(existingChildCacheNode.parallelRoutes)\n : new Map(),\n navigatedAt,\n }\n\n if (existingChildCacheNode && fillLazyItems) {\n invalidateCacheByRouterState(\n childCacheNode,\n existingChildCacheNode,\n treePatch\n )\n }\n if (fillLazyItems) {\n fillLazyItemsTillLeafWithHead(\n navigatedAt,\n childCacheNode,\n existingChildCacheNode,\n treePatch,\n cacheNodeSeedData,\n head\n )\n }\n\n childSegmentMap.set(cacheKey, childCacheNode)\n }\n continue\n }\n\n if (!childCacheNode || !existingChildCacheNode) {\n // Bailout because the existing cache does not have the path to the leaf node\n // Will trigger lazy fetch in layout-router because of missing segment\n continue\n }\n\n if (childCacheNode === existingChildCacheNode) {\n childCacheNode = {\n lazyData: childCacheNode.lazyData,\n rsc: childCacheNode.rsc,\n prefetchRsc: childCacheNode.prefetchRsc,\n head: childCacheNode.head,\n prefetchHead: childCacheNode.prefetchHead,\n parallelRoutes: new Map(childCacheNode.parallelRoutes),\n loading: childCacheNode.loading,\n } as CacheNode\n childSegmentMap.set(cacheKey, childCacheNode)\n }\n\n // Move deeper into the cache nodes\n newCacheNode = childCacheNode\n existingCacheNode = existingChildCacheNode\n }\n}\n\n/**\n * Fill cache with rsc based on flightDataPath\n */\nexport function fillCacheWithNewSubTreeData(\n navigatedAt: number,\n newCache: CacheNode,\n existingCache: CacheNode,\n flightData: NormalizedFlightData\n): void {\n fillCacheHelper(navigatedAt, newCache, existingCache, flightData, true)\n}\n\nexport function fillCacheWithNewSubTreeDataButOnlyLoading(\n navigatedAt: number,\n newCache: CacheNode,\n existingCache: CacheNode,\n flightData: NormalizedFlightData\n): void {\n fillCacheHelper(navigatedAt, newCache, existingCache, flightData, false)\n}\n"],"names":["fillCacheWithNewSubTreeData","fillCacheWithNewSubTreeDataButOnlyLoading","fillCacheHelper","navigatedAt","newCache","existingCache","flightData","fillLazyItems","segmentPath","seedData","cacheNodeSeedData","tree","treePatch","head","newCacheNode","existingCacheNode","i","length","parallelRouteKey","segment","isLastEntry","cacheKey","createRouterCacheKey","existingChildSegmentMap","parallelRoutes","get","childSegmentMap","Map","set","existingChildCacheNode","childCacheNode","lazyData","rsc","loading","PAGE_SEGMENT_KEY","prefetchRsc","prefetchHead","invalidateCacheByRouterState","fillLazyItemsTillLeafWithHead"],"mappings":";;;;;;;;;;;;;;;IAkIgBA,2BAA2B;eAA3BA;;IASAC,yCAAyC;eAAzCA;;;8CA1I6B;+CACC;sCACT;yBACJ;AAGjC;;CAEC,GACD,SAASC,gBACPC,WAAmB,EACnBC,QAAmB,EACnBC,aAAwB,EACxBC,UAAgC,EAChCC,aAAsB;IAEtB,MAAM,EACJC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,MAAMC,SAAS,EACfC,IAAI,EACL,GAAGP;IACJ,IAAIQ,eAAeV;IACnB,IAAIW,oBAAoBV;IAExB,IAAK,IAAIW,IAAI,GAAGA,IAAIR,YAAYS,MAAM,EAAED,KAAK,EAAG;QAC9C,MAAME,mBAA2BV,WAAW,CAACQ,EAAE;QAC/C,MAAMG,UAAmBX,WAAW,CAACQ,IAAI,EAAE;QAE3C,mEAAmE;QACnE,gEAAgE;QAChE,MAAMI,cAAcJ,MAAMR,YAAYS,MAAM,GAAG;QAC/C,MAAMI,WAAWC,IAAAA,0CAAoB,EAACH;QAEtC,MAAMI,0BACJR,kBAAkBS,cAAc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