| 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 : |
//#region src/server/app-segment-config.ts
const DYNAMIC_VALUES = new Set([
"auto",
"error",
"force-dynamic",
"force-static"
]);
const FETCH_CACHE_VALUES = new Set([
"auto",
"default-cache",
"default-no-store",
"force-cache",
"force-no-store",
"only-cache",
"only-no-store"
]);
function isRouteSegmentDynamic(value) {
return DYNAMIC_VALUES.has(value);
}
function isRouteSegmentFetchCache(value) {
return FETCH_CACHE_VALUES.has(value);
}
function resolveRevalidateSeconds(current, value) {
if (value === false) {
if (current === null) return Infinity;
return current === Infinity ? Infinity : current;
}
if (typeof value !== "number") return current;
if (current === null) return value;
return value < current ? value : current;
}
function isCacheFetchCacheMode(value) {
return value === "default-cache" || value === "force-cache" || value === "only-cache";
}
function describeFetchCacheConflict(value) {
return `Route segment config has incompatible fetchCache values including "${value}".`;
}
/**
* Resolve the route segment config that applies to an App page route.
*
* Next.js collects config from every segment in the loader tree and reduces it
* into the effective route config. The generated vinext entry already knows
* the concrete layout/page modules for a route, so it should only describe
* those modules and delegate the behavior to this helper.
*/
function resolveAppPageSegmentConfig(options) {
const segments = [...options.layouts ?? [], options.page];
const config = { revalidateSeconds: null };
let hasForceCache = false;
let hasForceNoStore = false;
let hasOnlyCache = false;
let hasOnlyNoStore = false;
let hasParentDefaultNoStore = false;
for (const segment of segments) {
if (!segment) continue;
if (isRouteSegmentDynamic(segment.dynamic)) config.dynamicConfig = segment.dynamic;
if (segment.dynamicParams === false) config.dynamicParamsConfig = false;
else if (segment.dynamicParams === true && config.dynamicParamsConfig !== false) config.dynamicParamsConfig = true;
if (isRouteSegmentFetchCache(segment.fetchCache)) {
const fetchCache = segment.fetchCache;
if (hasParentDefaultNoStore && (fetchCache === "auto" || isCacheFetchCacheMode(fetchCache))) throw new Error(describeFetchCacheConflict(fetchCache));
if (fetchCache === "force-cache") hasForceCache = true;
if (fetchCache === "force-no-store") hasForceNoStore = true;
if (fetchCache === "only-cache") hasOnlyCache = true;
if (fetchCache === "only-no-store") hasOnlyNoStore = true;
if ((hasForceCache || hasOnlyCache) && (hasForceNoStore || hasOnlyNoStore)) throw new Error(describeFetchCacheConflict(fetchCache));
if (fetchCache === "default-no-store") hasParentDefaultNoStore = true;
if (hasForceCache) config.fetchCache = "force-cache";
else if (hasForceNoStore) config.fetchCache = "force-no-store";
else if (hasOnlyCache) config.fetchCache = "only-cache";
else if (hasOnlyNoStore) config.fetchCache = "only-no-store";
else config.fetchCache = fetchCache;
}
config.revalidateSeconds = resolveRevalidateSeconds(config.revalidateSeconds, segment.revalidate);
}
if (config.dynamicConfig === "force-dynamic") config.revalidateSeconds = 0;
if (config.fetchCache === void 0) {
if (config.dynamicConfig === "force-dynamic") config.fetchCache = "force-no-store";
else if (config.dynamicConfig === "error") config.fetchCache = "only-cache";
}
if (config.dynamicParamsConfig === void 0 && (config.dynamicConfig === "error" || config.dynamicConfig === "force-static")) config.dynamicParamsConfig = false;
return config;
}
function resolveAppPageFetchCacheMode(options) {
return resolveAppPageSegmentConfig(options).fetchCache ?? null;
}
//#endregion
export { resolveAppPageFetchCacheMode, resolveAppPageSegmentConfig };
//# sourceMappingURL=app-segment-config.js.map