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
5.6 KiB
Text
1 line
No EOL
5.6 KiB
Text
{"version":3,"sources":["../../../src/server/lib/implicit-tags.ts"],"sourcesContent":["import { NEXT_CACHE_IMPLICIT_TAG_ID } from '../../lib/constants'\nimport type { OpaqueFallbackRouteParams } from '../request/fallback-params'\nimport { getCacheHandlerEntries } from '../use-cache/handlers'\nimport { createLazyResult, type LazyResult } from './lazy-result'\n\nexport interface ImplicitTags {\n /**\n * For legacy usage, the implicit tags are passed to the incremental cache\n * handler in `get` calls.\n */\n readonly tags: string[]\n\n /**\n * Modern cache handlers don't receive implicit tags. Instead, the implicit\n * tags' expirations are stored in the work unit store, and used to compare\n * with a cache entry's timestamp.\n *\n * Note: This map contains lazy results so that we can evaluate them when the\n * first cache entry is read. It allows us to skip fetching the expiration\n * values if no caches are read at all.\n */\n readonly expirationsByCacheKind: Map<string, LazyResult<number>>\n}\n\nconst getDerivedTags = (pathname: string): string[] => {\n const derivedTags: string[] = [`/layout`]\n\n // we automatically add the current path segments as tags\n // for revalidatePath handling\n if (pathname.startsWith('/')) {\n const pathnameParts = pathname.split('/')\n\n for (let i = 1; i < pathnameParts.length + 1; i++) {\n let curPathname = pathnameParts.slice(0, i).join('/')\n\n if (curPathname) {\n // all derived tags other than the page are layout tags\n if (!curPathname.endsWith('/page') && !curPathname.endsWith('/route')) {\n curPathname = `${curPathname}${\n !curPathname.endsWith('/') ? '/' : ''\n }layout`\n }\n derivedTags.push(curPathname)\n }\n }\n }\n return derivedTags\n}\n\n/**\n * Creates a map with lazy results that fetch the expiration value for the given\n * tags and respective cache kind when they're awaited for the first time.\n */\nfunction createTagsExpirationsByCacheKind(\n tags: string[]\n): Map<string, LazyResult<number>> {\n const expirationsByCacheKind = new Map<string, LazyResult<number>>()\n const cacheHandlers = getCacheHandlerEntries()\n\n if (cacheHandlers) {\n for (const [kind, cacheHandler] of cacheHandlers) {\n if ('getExpiration' in cacheHandler) {\n expirationsByCacheKind.set(\n kind,\n createLazyResult(async () => cacheHandler.getExpiration(tags))\n )\n }\n }\n }\n\n return expirationsByCacheKind\n}\n\nexport async function getImplicitTags(\n page: string,\n url: {\n pathname: string\n search?: string\n },\n fallbackRouteParams: null | OpaqueFallbackRouteParams\n): Promise<ImplicitTags> {\n const tags = new Set<string>()\n\n // Add the derived tags from the page.\n const derivedTags = getDerivedTags(page)\n for (let tag of derivedTags) {\n tag = `${NEXT_CACHE_IMPLICIT_TAG_ID}${tag}`\n tags.add(tag)\n }\n\n // Add the tags from the pathname. If the route has unknown params, we don't\n // want to add the pathname as a tag, as it will be invalid.\n if (\n url.pathname &&\n (!fallbackRouteParams || fallbackRouteParams.size === 0)\n ) {\n const tag = `${NEXT_CACHE_IMPLICIT_TAG_ID}${url.pathname}`\n tags.add(tag)\n }\n\n if (tags.has(`${NEXT_CACHE_IMPLICIT_TAG_ID}/`)) {\n tags.add(`${NEXT_CACHE_IMPLICIT_TAG_ID}/index`)\n }\n\n if (tags.has(`${NEXT_CACHE_IMPLICIT_TAG_ID}/index`)) {\n tags.add(`${NEXT_CACHE_IMPLICIT_TAG_ID}/`)\n }\n\n const tagsArray = Array.from(tags)\n return {\n tags: tagsArray,\n expirationsByCacheKind: createTagsExpirationsByCacheKind(tagsArray),\n }\n}\n"],"names":["getImplicitTags","getDerivedTags","pathname","derivedTags","startsWith","pathnameParts","split","i","length","curPathname","slice","join","endsWith","push","createTagsExpirationsByCacheKind","tags","expirationsByCacheKind","Map","cacheHandlers","getCacheHandlerEntries","kind","cacheHandler","set","createLazyResult","getExpiration","page","url","fallbackRouteParams","Set","tag","NEXT_CACHE_IMPLICIT_TAG_ID","add","size","has","tagsArray","Array","from"],"mappings":";;;;+BAyEsBA;;;eAAAA;;;2BAzEqB;0BAEJ;4BACW;AAqBlD,MAAMC,iBAAiB,CAACC;I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