| Server IP : 159.203.156.69 / Your IP : 216.73.217.172 Web Server : nginx/1.24.0 System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/tanviranik.com/node_modules/vinext/dist/server/ |
Upload File : |
{"version":3,"file":"app-route-handler-cache.js","names":[],"sources":["../../src/server/app-route-handler-cache.ts"],"sourcesContent":["import type { NextI18nConfig } from \"../config/next-config.js\";\nimport type { HeadersAccessPhase } from \"vinext/shims/headers\";\nimport type { ISRCacheEntry } from \"./isr-cache.js\";\nimport type { RouteHandlerMiddlewareContext } from \"./app-route-handler-response.js\";\nimport {\n applyRouteHandlerMiddlewareContext,\n assertSupportedAppRouteHandlerResponse,\n buildAppRouteCacheValue,\n buildRouteHandlerCachedResponse,\n} from \"./app-route-handler-response.js\";\nimport { markKnownDynamicAppRoute } from \"./app-route-handler-runtime.js\";\nimport { makeThenableParams } from \"vinext/shims/thenable-params\";\nimport {\n runAppRouteHandler,\n type AppRouteDebugLogger,\n type AppRouteDynamicUsageFn,\n type AppRouteHandlerFunction,\n type AppRouteParams,\n type MarkAppRouteDynamicUsageFn,\n type RouteHandlerCacheSetter,\n} from \"./app-route-handler-execution.js\";\n\ntype RouteHandlerCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;\ntype RouteHandlerBackgroundRegenerator = (key: string, renderFn: () => Promise<void>) => void;\ntype RouteHandlerRevalidationContextRunner = (renderFn: () => Promise<void>) => Promise<void>;\n\ntype ReadAppRouteHandlerCacheOptions = {\n basePath?: string;\n buildPageCacheTags: (pathname: string, extraTags: string[]) => string[];\n cleanPathname: string;\n clearRequestContext: () => void;\n consumeDynamicUsage: AppRouteDynamicUsageFn;\n dynamicConfig?: string;\n getCollectedFetchTags: () => string[];\n handlerFn: AppRouteHandlerFunction;\n i18n?: NextI18nConfig | null;\n isAutoHead: boolean;\n isrDebug?: AppRouteDebugLogger;\n isrGet: RouteHandlerCacheGetter;\n isrRouteKey: (pathname: string) => string;\n isrSet: RouteHandlerCacheSetter;\n markDynamicUsage: MarkAppRouteDynamicUsageFn;\n middlewareContext: RouteHandlerMiddlewareContext;\n params: AppRouteParams;\n requestUrl: string;\n revalidateSearchParams: URLSearchParams;\n expireSeconds?: number;\n revalidateSeconds: number;\n routePattern: string;\n runInRevalidationContext: RouteHandlerRevalidationContextRunner;\n scheduleBackgroundRegeneration: RouteHandlerBackgroundRegenerator;\n setHeadersAccessPhase: (phase: HeadersAccessPhase) => HeadersAccessPhase;\n setNavigationContext: (\n context: {\n pathname: string;\n searchParams: URLSearchParams;\n params: AppRouteParams;\n } | null,\n ) => void;\n};\n\nfunction getCachedAppRouteValue(entry: ISRCacheEntry | null) {\n return entry?.value.value && entry.value.value.kind === \"APP_ROUTE\" ? entry.value.value : null;\n}\n\nexport async function readAppRouteHandlerCacheResponse(\n options: ReadAppRouteHandlerCacheOptions,\n): Promise<Response | null> {\n const routeKey = options.isrRouteKey(options.cleanPathname);\n\n try {\n const cached = await options.isrGet(routeKey);\n const cachedValue = getCachedAppRouteValue(cached);\n\n if (cachedValue && !cached?.isStale) {\n options.isrDebug?.(\"HIT (route)\", options.cleanPathname);\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n buildRouteHandlerCachedResponse(cachedValue, {\n cacheState: \"HIT\",\n cacheControl: cached?.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isHead: options.isAutoHead,\n revalidateSeconds: options.revalidateSeconds,\n }),\n options.middlewareContext,\n );\n }\n\n if (cached?.isStale && cachedValue) {\n const staleValue = cachedValue;\n const revalidateSearchParams = new URLSearchParams(options.revalidateSearchParams);\n\n options.scheduleBackgroundRegeneration(routeKey, async () => {\n await options.runInRevalidationContext(async () => {\n options.setNavigationContext({\n pathname: options.cleanPathname,\n searchParams: revalidateSearchParams,\n params: options.params,\n });\n\n const { dynamicUsedInHandler, response } = await runAppRouteHandler({\n basePath: options.basePath,\n consumeDynamicUsage: options.consumeDynamicUsage,\n dynamicConfig: options.dynamicConfig,\n handlerFn: options.handlerFn,\n i18n: options.i18n,\n markDynamicUsage: options.markDynamicUsage,\n params: makeThenableParams(options.params),\n request: new Request(options.requestUrl, { method: \"GET\" }),\n routePattern: options.routePattern,\n setHeadersAccessPhase: options.setHeadersAccessPhase,\n });\n\n options.setNavigationContext(null);\n assertSupportedAppRouteHandlerResponse(response);\n\n if (dynamicUsedInHandler) {\n markKnownDynamicAppRoute(options.routePattern);\n options.isrDebug?.(\"route regen skipped (dynamic usage)\", options.cleanPathname);\n return;\n }\n\n const routeTags = options.buildPageCacheTags(\n options.cleanPathname,\n options.getCollectedFetchTags(),\n );\n const routeCacheValue = await buildAppRouteCacheValue(response);\n await options.isrSet(\n routeKey,\n routeCacheValue,\n options.revalidateSeconds,\n routeTags,\n options.expireSeconds,\n );\n options.isrDebug?.(\"route regen complete\", routeKey);\n });\n });\n\n options.isrDebug?.(\"STALE (route)\", options.cleanPathname);\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n buildRouteHandlerCachedResponse(staleValue, {\n cacheState: \"STALE\",\n cacheControl: cached.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isHead: options.isAutoHead,\n revalidateSeconds: options.revalidateSeconds,\n }),\n options.middlewareContext,\n );\n }\n } catch (routeCacheError) {\n console.error(\"[vinext] ISR route cache read error:\", routeCacheError);\n }\n\n return null;\n}\n"],"mappings":";;;;;AA6DA,SAAS,uBAAuB,OAA6B;CAC3D,OAAO,OAAO,MAAM,SAAS,MAAM,MAAM,MAAM,SAAS,cAAc,MAAM,MAAM,QAAQ;;AAG5F,eAAsB,iCACpB,SAC0B;CAC1B,MAAM,WAAW,QAAQ,YAAY,QAAQ,cAAc;CAE3D,IAAI;EACF,MAAM,SAAS,MAAM,QAAQ,OAAO,SAAS;EAC7C,MAAM,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