| 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-policy.js","names":[],"sources":["../../src/server/app-route-handler-policy.ts"],"sourcesContent":["import {\n buildRouteHandlerAllowHeader,\n collectRouteHandlerMethods,\n type RouteHandlerHttpMethod,\n type RouteHandlerModule,\n} from \"./app-route-handler-runtime.js\";\nimport { NEXT_ACTION_HEADER, RSC_ACTION_HEADER } from \"./headers.js\";\nimport { parseNextHttpErrorDigest, parseNextRedirectDigest } from \"./next-error-digest.js\";\n\nexport type AppRouteHandlerModule = {\n dynamic?: string;\n revalidate?: unknown;\n} & RouteHandlerModule;\n\ntype AppRouteHandlerFunction = (...args: unknown[]) => unknown;\n\ntype ResolvedAppRouteHandlerMethod = {\n allowHeaderForOptions: string;\n exportedMethods: RouteHandlerHttpMethod[];\n handlerFn: AppRouteHandlerFunction | undefined;\n isAutoHead: boolean;\n shouldAutoRespondToOptions: boolean;\n};\n\ntype AppRouteHandlerCacheReadOptions = {\n dynamicConfig?: string;\n handlerFn: unknown;\n isAutoHead: boolean;\n isKnownDynamic: boolean;\n isProduction: boolean;\n method: string;\n revalidateSeconds: number | null;\n};\n\ntype AppRouteHandlerResponseCacheOptions = {\n dynamicConfig?: string;\n dynamicUsedInHandler: boolean;\n handlerSetCacheControl: boolean;\n isAutoHead: boolean;\n isProduction: boolean;\n method: string;\n revalidateSeconds: number | null;\n};\n\ntype AppRouteHandlerSpecialError =\n | {\n kind: \"redirect\";\n location: string;\n statusCode: number;\n }\n | {\n kind: \"status\";\n statusCode: number;\n };\n\ntype AppRouteHandlerSpecialErrorOptions = {\n isAction: boolean;\n};\n\nexport function isPossibleAppRouteActionRequest(\n request: Pick<Request, \"headers\" | \"method\">,\n): boolean {\n if (request.method.toUpperCase() !== \"POST\") return false;\n\n const contentType = request.headers.get(\"content-type\");\n return (\n request.headers.has(RSC_ACTION_HEADER) ||\n request.headers.has(NEXT_ACTION_HEADER) ||\n // Next.js uses strict equality here, so charset variants intentionally do\n // not classify as action requests even though they are valid form posts.\n contentType === \"application/x-www-form-urlencoded\" ||\n contentType?.startsWith(\"multipart/form-data\") === true\n );\n}\n\nexport function getAppRouteHandlerRevalidateSeconds(\n handler: Pick<AppRouteHandlerModule, \"revalidate\">,\n): number | null {\n // 0 is a meaningful value (\"never cache\") and must be preserved so the\n // header path can emit a no-store Cache-Control.\n // revalidate = false means \"cache indefinitely\" (Next.js segment config\n // parity) — return Infinity to signal the cache-later path.\n const { revalidate } = handler;\n if (revalidate === false) return Infinity;\n if (typeof revalidate !== \"number\" || !Number.isFinite(revalidate) || revalidate < 0) {\n return null;\n }\n return revalidate;\n}\n\nexport function hasAppRouteHandlerDefaultExport(handler: RouteHandlerModule): boolean {\n return typeof handler.default === \"function\";\n}\n\nexport function resolveAppRouteHandlerMethod(\n handler: AppRouteHandlerModule,\n method: string,\n): ResolvedAppRouteHandlerMethod {\n const exportedMethods = collectRouteHandlerMethods(handler);\n const allowHeaderForOptions = buildRouteHandlerAllowHeader(exportedMethods);\n const shouldAutoRespondToOptions = method === \"OPTIONS\" && typeof handler.OPTIONS !== \"function\";\n\n let handlerFn =\n typeof handler[method as RouteHandlerHttpMethod] === \"function\"\n ? (handler[method as RouteHandlerHttpMethod] as AppRouteHandlerFunction)\n : undefined;\n let isAutoHead = false;\n\n if (\n method === \"HEAD\" &&\n typeof handler.HEAD !== \"function\" &&\n typeof handler.GET === \"function\"\n ) {\n handlerFn = handler.GET as AppRouteHandlerFunction;\n isAutoHead = true;\n }\n\n return {\n allowHeaderForOptions,\n exportedMethods,\n handlerFn,\n isAutoHead,\n shouldAutoRespondToOptions,\n };\n}\n\nexport function shouldReadAppRouteHandlerCache(options: AppRouteHandlerCacheReadOptions): boolean {\n // revalidateSeconds === 0 means \"never cache\" and must skip the ISR read.\n // A previously written entry (e.g. from before the handler opted out)\n // must never be replayed once the author set revalidate = 0.\n return (\n options.isProduction &&\n options.revalidateSeconds !== null &&\n options.revalidateSeconds > 0 &&\n options.revalidateSeconds !== Infinity &&\n options.dynamicConfig !== \"force-dynamic\" &&\n !options.isKnownDynamic &&\n (options.method === \"GET\" || options.isAutoHead) &&\n typeof options.handlerFn === \"function\"\n );\n}\n\nexport function shouldApplyAppRouteHandlerRevalidateHeader(\n options: Omit<AppRouteHandlerResponseCacheOptions, \"dynamicConfig\" | \"isProduction\">,\n): boolean {\n // Includes revalidateSeconds === 0. That case emits the no-store\n // Cache-Control, which is exactly the header a never-cache handler\n // needs to suppress heuristic caching.\n return (\n options.revalidateSeconds !== null &&\n !options.dynamicUsedInHandler &&\n (options.method === \"GET\" || options.isAutoHead) &&\n !options.handlerSetCacheControl\n );\n}\n\nexport function shouldWriteAppRouteHandlerCache(\n options: AppRouteHandlerResponseCacheOptions,\n): boolean {\n // Excludes revalidateSeconds === 0. A never-cache response must not be\n // persisted to ISR, even though it still needs a Cache-Control header.\n return (\n options.isProduction &&\n options.revalidateSeconds !== null &&\n options.revalidateSeconds > 0 &&\n options.revalidateSeconds !== Infinity &&\n options.dynamicConfig !== \"force-dynamic\" &&\n shouldApplyAppRouteHandlerRevalidateHeader(options)\n );\n}\n\nexport function resolveAppRouteHandlerSpecialError(\n error: unknown,\n requestUrl: string,\n options?: AppRouteHandlerSpecialErrorOptions,\n): AppRouteHandlerSpecialError | null {\n if (!(error && typeof error === \"object\" && \"digest\" in error)) {\n return null;\n }\n\n const digest = String(error.digest);\n const redirect = parseNextRedirectDigest(digest);\n if (redirect) {\n return {\n kind: \"redirect\",\n location: new URL(redirect.url, requestUrl).toString(),\n statusCode: options?.isAction ? 303 : redirect.status,\n };\n }\n\n const httpError = parseNextHttpErrorDigest(digest);\n if (httpError) {\n return {\n kind: \"status\",\n statusCode: httpError.status,\n };\n }\n\n return null;\n}\n"],"mappings":";;;;AA2DA,SAAgB,gCACd,SACS;CACT,IAAI,QAAQ,OAAO,aAAa,KAAK,QAAQ,OAAO;CAEpD,MAAM,cAAc,QAAQ,QAAQ,IAAI,eAAe;CACvD,OACE,QAAQ,QAAQ,IAAA,eAAsB,IACtC,QAAQ,QAAQ,IAAA,cAAuB,IAGvC,gBAAgB,uCAChB,aAAa,WAAW,sBAAsB,KAAK;;AAIvD,SAAgB,oCACd,SACe;CAKf,MAAM,EAAE,eAAe;CACvB,IAAI,eAAe,OAAO,OAAO;CACjC,IAAI,OAAO,eAAe,YAAY,CAAC,OAAO,SAAS,WAAW,IAAI,aAAa,GACjF,OAAO;CAET,OAAO;;AAGT,SAAgB,gCAAgC,SAAsC;CACpF,OAAO,OAAO,QAAQ,YAAY;;AAGpC,SAAgB,6BACd,SACA,QAC+B;CAC/B,MAAM,kBAAkB,2BAA2B,QAAQ;CAC3D,MAAM,wBAAwB,6BAA6B,gBAAgB;CAC3E,MAAM,6BAA6B,WAAW,aAAa,OAAO,QAAQ,YAAY;CAEtF,IAAI,YACF,OAAO,QAAQ,YAAsC,aAChD,QAAQ,UACT,KAAA;CACN,IAAI,aAAa;CAEjB,IACE,WAAW,UACX,OAAO,QAAQ,SAAS,cACxB,OAAO,QAAQ,QAAQ,YACvB;EACA,YAAY,QAAQ;EACpB,aAAa;;CAGf,OAAO;EACL;EACA;EACA;EACA;EACA;EACD;;AAGH,SAAgB,+BAA+B,SAAmD;CAIhG,OACE,QAAQ,gBACR,QAAQ,sBAAsB,QAC9B,QAAQ,oBAAoB,KAC5B,QAAQ,sBAAsB,YAC9B,QAAQ,kBAAkB,mBAC1B,CAAC,QAAQ,mBACR,QAAQ,WAAW,SAAS,QAAQ,eACrC,OAAO,QAAQ,cAAc;;AAIjC,SAAgB,2CACd,SACS;CAIT,OACE,QA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