added fonts
This commit is contained in:
1 parent
4134e3a234
commit
142d2986b6
9079 files changed
+1498421
-2
No files matched your search
+17
@@ -0,0 +1,17 @@
|
||||
import type { ResponseCacheEntry, ResponseGenerator, ResponseCacheBase, IncrementalResponseCache } from './types';
|
||||
import type { RouteKind } from '../route-kind';
|
||||
export * from './types';
|
||||
export default class ResponseCache implements ResponseCacheBase {
|
||||
private readonly batcher;
|
||||
private previousCacheItem?;
|
||||
private minimalMode?;
|
||||
constructor(minimalMode: boolean);
|
||||
get(key: string | null, responseGenerator: ResponseGenerator, context: {
|
||||
routeKind: RouteKind;
|
||||
isOnDemandRevalidate?: boolean;
|
||||
isPrefetch?: boolean;
|
||||
incrementalCache: IncrementalResponseCache;
|
||||
isRoutePPREnabled?: boolean;
|
||||
isFallback?: boolean;
|
||||
}): Promise<ResponseCacheEntry | null>;
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ResponseCache;
|
||||
}
|
||||
});
|
||||
0 && __export(require("./types"));
|
||||
const _batcher = require("../../lib/batcher");
|
||||
const _scheduler = require("../../lib/scheduler");
|
||||
const _utils = require("./utils");
|
||||
_export_star(require("./types"), exports);
|
||||
function _export_star(from, to) {
|
||||
Object.keys(from).forEach(function(k) {
|
||||
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
||||
Object.defineProperty(to, k, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return from[k];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return from;
|
||||
}
|
||||
class ResponseCache {
|
||||
constructor(minimalMode){
|
||||
this.batcher = _batcher.Batcher.create({
|
||||
// Ensure on-demand revalidate doesn't block normal requests, it should be
|
||||
// safe to run an on-demand revalidate for the same key as a normal request.
|
||||
cacheKeyFn: ({ key, isOnDemandRevalidate })=>`${key}-${isOnDemandRevalidate ? '1' : '0'}`,
|
||||
// We wait to do any async work until after we've added our promise to
|
||||
// `pendingResponses` to ensure that any any other calls will reuse the
|
||||
// same promise until we've fully finished our work.
|
||||
schedulerFn: _scheduler.scheduleOnNextTick
|
||||
});
|
||||
// this is a hack to avoid Webpack knowing this is equal to this.minimalMode
|
||||
// because we replace this.minimalMode to true in production bundles.
|
||||
const minimalModeKey = 'minimalMode';
|
||||
this[minimalModeKey] = minimalMode;
|
||||
}
|
||||
async get(key, responseGenerator, context) {
|
||||
// If there is no key for the cache, we can't possibly look this up in the
|
||||
// cache so just return the result of the response generator.
|
||||
if (!key) {
|
||||
return responseGenerator({
|
||||
hasResolved: false,
|
||||
previousCacheEntry: null
|
||||
});
|
||||
}
|
||||
const { incrementalCache, isOnDemandRevalidate = false, isFallback = false, isRoutePPREnabled = false } = context;
|
||||
const response = await this.batcher.batch({
|
||||
key,
|
||||
isOnDemandRevalidate
|
||||
}, async (cacheKey, resolve)=>{
|
||||
var _this_previousCacheItem;
|
||||
// We keep the previous cache entry around to leverage when the
|
||||
// incremental cache is disabled in minimal mode.
|
||||
if (this.minimalMode && ((_this_previousCacheItem = this.previousCacheItem) == null ? void 0 : _this_previousCacheItem.key) === cacheKey && this.previousCacheItem.expiresAt > Date.now()) {
|
||||
return this.previousCacheItem.entry;
|
||||
}
|
||||
// Coerce the kindHint into a given kind for the incremental cache.
|
||||
const kind = (0, _utils.routeKindToIncrementalCacheKind)(context.routeKind);
|
||||
let resolved = false;
|
||||
let cachedResponse = null;
|
||||
try {
|
||||
cachedResponse = !this.minimalMode ? await incrementalCache.get(key, {
|
||||
kind,
|
||||
isRoutePPREnabled: context.isRoutePPREnabled,
|
||||
isFallback
|
||||
}) : null;
|
||||
if (cachedResponse && !isOnDemandRevalidate) {
|
||||
resolve(cachedResponse);
|
||||
resolved = true;
|
||||
if (!cachedResponse.isStale || context.isPrefetch) {
|
||||
// The cached value is still valid, so we don't need
|
||||
// to update it yet.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
const cacheEntry = await responseGenerator({
|
||||
hasResolved: resolved,
|
||||
previousCacheEntry: cachedResponse,
|
||||
isRevalidating: true
|
||||
});
|
||||
// If the cache entry couldn't be generated, we don't want to cache
|
||||
// the result.
|
||||
if (!cacheEntry) {
|
||||
// Unset the previous cache item if it was set.
|
||||
if (this.minimalMode) this.previousCacheItem = undefined;
|
||||
return null;
|
||||
}
|
||||
const resolveValue = await (0, _utils.fromResponseCacheEntry)({
|
||||
...cacheEntry,
|
||||
isMiss: !cachedResponse
|
||||
});
|
||||
if (!resolveValue) {
|
||||
// Unset the previous cache item if it was set.
|
||||
if (this.minimalMode) this.previousCacheItem = undefined;
|
||||
return null;
|
||||
}
|
||||
// For on-demand revalidate wait to resolve until cache is set.
|
||||
// Otherwise resolve now.
|
||||
if (!isOnDemandRevalidate && !resolved) {
|
||||
resolve(resolveValue);
|
||||
resolved = true;
|
||||
}
|
||||
// We want to persist the result only if it has a cache control value
|
||||
// defined.
|
||||
if (resolveValue.cacheControl) {
|
||||
if (this.minimalMode) {
|
||||
this.previousCacheItem = {
|
||||
key: cacheKey,
|
||||
entry: resolveValue,
|
||||
expiresAt: Date.now() + 1000
|
||||
};
|
||||
} else {
|
||||
await incrementalCache.set(key, resolveValue.value, {
|
||||
cacheControl: resolveValue.cacheControl,
|
||||
isRoutePPREnabled,
|
||||
isFallback
|
||||
});
|
||||
}
|
||||
}
|
||||
return resolveValue;
|
||||
} catch (err) {
|
||||
// When a path is erroring we automatically re-set the existing cache
|
||||
// with new revalidate and expire times to prevent non-stop retrying.
|
||||
if (cachedResponse == null ? void 0 : cachedResponse.cacheControl) {
|
||||
const newRevalidate = Math.min(Math.max(cachedResponse.cacheControl.revalidate || 3, 3), 30);
|
||||
const newExpire = cachedResponse.cacheControl.expire === undefined ? undefined : Math.max(newRevalidate + 3, cachedResponse.cacheControl.expire);
|
||||
await incrementalCache.set(key, cachedResponse.value, {
|
||||
cacheControl: {
|
||||
revalidate: newRevalidate,
|
||||
expire: newExpire
|
||||
},
|
||||
isRoutePPREnabled,
|
||||
isFallback
|
||||
});
|
||||
}
|
||||
// While revalidating in the background we can't reject as we already
|
||||
// resolved the cache entry so log the error here.
|
||||
if (resolved) {
|
||||
console.error(err);
|
||||
return null;
|
||||
}
|
||||
// We haven't resolved yet, so let's throw to indicate an error.
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
return (0, _utils.toResponseCacheEntry)(response);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/response-cache/index.ts"],"sourcesContent":["import type {\n ResponseCacheEntry,\n ResponseGenerator,\n ResponseCacheBase,\n IncrementalResponseCacheEntry,\n IncrementalResponseCache,\n} from './types'\n\nimport { Batcher } from '../../lib/batcher'\nimport { scheduleOnNextTick } from '../../lib/scheduler'\nimport {\n fromResponseCacheEntry,\n routeKindToIncrementalCacheKind,\n toResponseCacheEntry,\n} from './utils'\nimport type { RouteKind } from '../route-kind'\n\nexport * from './types'\n\nexport default class ResponseCache implements ResponseCacheBase {\n private readonly batcher = Batcher.create<\n { key: string; isOnDemandRevalidate: boolean },\n IncrementalResponseCacheEntry | null,\n string\n >({\n // Ensure on-demand revalidate doesn't block normal requests, it should be\n // safe to run an on-demand revalidate for the same key as a normal request.\n cacheKeyFn: ({ key, isOnDemandRevalidate }) =>\n `${key}-${isOnDemandRevalidate ? '1' : '0'}`,\n // We wait to do any async work until after we've added our promise to\n // `pendingResponses` to ensure that any any other calls will reuse the\n // same promise until we've fully finished our work.\n schedulerFn: scheduleOnNextTick,\n })\n\n private previousCacheItem?: {\n key: string\n entry: IncrementalResponseCacheEntry | null\n expiresAt: number\n }\n\n private minimalMode?: boolean\n\n constructor(minimalMode: boolean) {\n // this is a hack to avoid Webpack knowing this is equal to this.minimalMode\n // because we replace this.minimalMode to true in production bundles.\n const minimalModeKey = 'minimalMode'\n this[minimalModeKey] = minimalMode\n }\n\n public async get(\n key: string | null,\n responseGenerator: ResponseGenerator,\n context: {\n routeKind: RouteKind\n isOnDemandRevalidate?: boolean\n isPrefetch?: boolean\n incrementalCache: IncrementalResponseCache\n isRoutePPREnabled?: boolean\n isFallback?: boolean\n }\n ): Promise<ResponseCacheEntry | null> {\n // If there is no key for the cache, we can't possibly look this up in the\n // cache so just return the result of the response generator.\n if (!key) {\n return responseGenerator({ hasResolved: false, previousCacheEntry: null })\n }\n\n const {\n incrementalCache,\n isOnDemandRevalidate = false,\n isFallback = false,\n isRoutePPREnabled = false,\n } = context\n\n const response = await this.batcher.batch(\n { key, isOnDemandRevalidate },\n async (cacheKey, resolve) => {\n // We keep the previous cache entry around to leverage when the\n // incremental cache is disabled in minimal mode.\n if (\n this.minimalMode &&\n this.previousCacheItem?.key === cacheKey &&\n this.previousCacheItem.expiresAt > Date.now()\n ) {\n return this.previousCacheItem.entry\n }\n\n // Coerce the kindHint into a given kind for the incremental cache.\n const kind = routeKindToIncrementalCacheKind(context.routeKind)\n\n let resolved = false\n let cachedResponse: IncrementalResponseCacheEntry | null = null\n try {\n cachedResponse = !this.minimalMode\n ? await incrementalCache.get(key, {\n kind,\n isRoutePPREnabled: context.isRoutePPREnabled,\n isFallback,\n })\n : null\n\n if (cachedResponse && !isOnDemandRevalidate) {\n resolve(cachedResponse)\n resolved = true\n\n if (!cachedResponse.isStale || context.isPrefetch) {\n // The cached value is still valid, so we don't need\n // to update it yet.\n return null\n }\n }\n\n const cacheEntry = await responseGenerator({\n hasResolved: resolved,\n previousCacheEntry: cachedResponse,\n isRevalidating: true,\n })\n\n // If the cache entry couldn't be generated, we don't want to cache\n // the result.\n if (!cacheEntry) {\n // Unset the previous cache item if it was set.\n if (this.minimalMode) this.previousCacheItem = undefined\n return null\n }\n\n const resolveValue = await fromResponseCacheEntry({\n ...cacheEntry,\n isMiss: !cachedResponse,\n })\n if (!resolveValue) {\n // Unset the previous cache item if it was set.\n if (this.minimalMode) this.previousCacheItem = undefined\n return null\n }\n\n // For on-demand revalidate wait to resolve until cache is set.\n // Otherwise resolve now.\n if (!isOnDemandRevalidate && !resolved) {\n resolve(resolveValue)\n resolved = true\n }\n\n // We want to persLine truncated
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
import type { OutgoingHttpHeaders } from 'http';
|
||||
import type RenderResult from '../render-result';
|
||||
import type { CacheControl, Revalidate } from '../lib/cache-control';
|
||||
import type { RouteKind } from '../route-kind';
|
||||
export interface ResponseCacheBase {
|
||||
get(key: string | null, responseGenerator: ResponseGenerator, context: {
|
||||
isOnDemandRevalidate?: boolean;
|
||||
isPrefetch?: boolean;
|
||||
incrementalCache: IncrementalCache;
|
||||
/**
|
||||
* This is a hint to the cache to help it determine what kind of route
|
||||
* this is so it knows where to look up the cache entry from. If not
|
||||
* provided it will test the filesystem to check.
|
||||
*/
|
||||
routeKind: RouteKind;
|
||||
/**
|
||||
* True if this is a fallback request.
|
||||
*/
|
||||
isFallback?: boolean;
|
||||
/**
|
||||
* True if the route is enabled for PPR.
|
||||
*/
|
||||
isRoutePPREnabled?: boolean;
|
||||
}): Promise<ResponseCacheEntry | null>;
|
||||
}
|
||||
export interface ServerComponentsHmrCache {
|
||||
get(key: string): CachedFetchData | undefined;
|
||||
set(key: string, data: CachedFetchData): void;
|
||||
}
|
||||
export type CachedFetchData = {
|
||||
headers: Record<string, string>;
|
||||
body: string;
|
||||
url: string;
|
||||
status?: number;
|
||||
};
|
||||
export declare const enum CachedRouteKind {
|
||||
APP_PAGE = "APP_PAGE",
|
||||
APP_ROUTE = "APP_ROUTE",
|
||||
PAGES = "PAGES",
|
||||
FETCH = "FETCH",
|
||||
REDIRECT = "REDIRECT",
|
||||
IMAGE = "IMAGE"
|
||||
}
|
||||
export interface CachedFetchValue {
|
||||
kind: CachedRouteKind.FETCH;
|
||||
data: CachedFetchData;
|
||||
tags?: string[];
|
||||
revalidate: number;
|
||||
}
|
||||
export interface CachedRedirectValue {
|
||||
kind: CachedRouteKind.REDIRECT;
|
||||
props: Object;
|
||||
}
|
||||
export interface CachedAppPageValue {
|
||||
kind: CachedRouteKind.APP_PAGE;
|
||||
html: RenderResult;
|
||||
rscData: Buffer | undefined;
|
||||
status: number | undefined;
|
||||
postponed: string | undefined;
|
||||
headers: OutgoingHttpHeaders | undefined;
|
||||
segmentData: Map<string, Buffer> | undefined;
|
||||
}
|
||||
export interface CachedPageValue {
|
||||
kind: CachedRouteKind.PAGES;
|
||||
html: RenderResult;
|
||||
pageData: Object;
|
||||
status: number | undefined;
|
||||
headers: OutgoingHttpHeaders | undefined;
|
||||
}
|
||||
export interface CachedRouteValue {
|
||||
kind: CachedRouteKind.APP_ROUTE;
|
||||
body: Buffer;
|
||||
status: number;
|
||||
headers: OutgoingHttpHeaders;
|
||||
}
|
||||
export interface CachedImageValue {
|
||||
kind: CachedRouteKind.IMAGE;
|
||||
etag: string;
|
||||
upstreamEtag: string;
|
||||
buffer: Buffer;
|
||||
extension: string;
|
||||
isMiss?: boolean;
|
||||
isStale?: boolean;
|
||||
}
|
||||
export interface IncrementalCachedAppPageValue {
|
||||
kind: CachedRouteKind.APP_PAGE;
|
||||
html: string;
|
||||
rscData: Buffer | undefined;
|
||||
headers: OutgoingHttpHeaders | undefined;
|
||||
postponed: string | undefined;
|
||||
status: number | undefined;
|
||||
segmentData: Map<string, Buffer> | undefined;
|
||||
}
|
||||
export interface IncrementalCachedPageValue {
|
||||
kind: CachedRouteKind.PAGES;
|
||||
html: string;
|
||||
pageData: Object;
|
||||
headers: OutgoingHttpHeaders | undefined;
|
||||
status: number | undefined;
|
||||
}
|
||||
export interface IncrementalResponseCacheEntry {
|
||||
cacheControl?: CacheControl;
|
||||
/**
|
||||
* timestamp in milliseconds to revalidate after
|
||||
*/
|
||||
revalidateAfter?: Revalidate;
|
||||
/**
|
||||
* `-1` here dictates a blocking revalidate should be used
|
||||
*/
|
||||
isStale?: boolean | -1;
|
||||
isMiss?: boolean;
|
||||
isFallback: boolean | undefined;
|
||||
value: Exclude<IncrementalCacheValue, CachedFetchValue> | null;
|
||||
}
|
||||
export interface IncrementalFetchCacheEntry {
|
||||
/**
|
||||
* `-1` here dictates a blocking revalidate should be used
|
||||
*/
|
||||
isStale?: boolean | -1;
|
||||
value: CachedFetchValue;
|
||||
}
|
||||
export type IncrementalCacheEntry = IncrementalResponseCacheEntry | IncrementalFetchCacheEntry;
|
||||
export type IncrementalCacheValue = CachedRedirectValue | IncrementalCachedPageValue | IncrementalCachedAppPageValue | CachedImageValue | CachedFetchValue | CachedRouteValue;
|
||||
export type ResponseCacheValue = CachedRedirectValue | CachedPageValue | CachedAppPageValue | CachedImageValue | CachedRouteValue;
|
||||
export type ResponseCacheEntry = {
|
||||
cacheControl?: CacheControl;
|
||||
value: ResponseCacheValue | null;
|
||||
isStale?: boolean | -1;
|
||||
isMiss?: boolean;
|
||||
isFallback: boolean | undefined;
|
||||
};
|
||||
/**
|
||||
* @param hasResolved whether the responseGenerator has resolved it's promise
|
||||
* @param previousCacheEntry the previous cache entry if it exists or the current
|
||||
*/
|
||||
export type ResponseGenerator = (state: {
|
||||
hasResolved: boolean;
|
||||
previousCacheEntry?: IncrementalResponseCacheEntry | null;
|
||||
isRevalidating?: boolean;
|
||||
}) => Promise<ResponseCacheEntry | null>;
|
||||
export declare const enum IncrementalCacheKind {
|
||||
APP_PAGE = "APP_PAGE",
|
||||
APP_ROUTE = "APP_ROUTE",
|
||||
PAGES = "PAGES",
|
||||
FETCH = "FETCH",
|
||||
IMAGE = "IMAGE"
|
||||
}
|
||||
export interface GetIncrementalFetchCacheContext {
|
||||
kind: IncrementalCacheKind.FETCH;
|
||||
revalidate?: Revalidate;
|
||||
fetchUrl?: string;
|
||||
fetchIdx?: number;
|
||||
tags?: string[];
|
||||
softTags?: string[];
|
||||
}
|
||||
export interface GetIncrementalResponseCacheContext {
|
||||
kind: Exclude<IncrementalCacheKind, IncrementalCacheKind.FETCH>;
|
||||
/**
|
||||
* True if the route is enabled for PPR.
|
||||
*/
|
||||
isRoutePPREnabled?: boolean;
|
||||
/**
|
||||
* True if this is a fallback request.
|
||||
*/
|
||||
isFallback: boolean;
|
||||
}
|
||||
export interface SetIncrementalFetchCacheContext {
|
||||
fetchCache: true;
|
||||
fetchUrl?: string;
|
||||
fetchIdx?: number;
|
||||
tags?: string[];
|
||||
}
|
||||
export interface SetIncrementalResponseCacheContext {
|
||||
fetchCache?: false;
|
||||
cacheControl?: CacheControl;
|
||||
/**
|
||||
* True if the route is enabled for PPR.
|
||||
*/
|
||||
isRoutePPREnabled?: boolean;
|
||||
/**
|
||||
* True if this is a fallback request.
|
||||
*/
|
||||
isFallback?: boolean;
|
||||
}
|
||||
export interface IncrementalResponseCache {
|
||||
get(cacheKey: string, ctx: GetIncrementalResponseCacheContext): Promise<IncrementalResponseCacheEntry | null>;
|
||||
set(key: string, data: Exclude<IncrementalCacheValue, CachedFetchValue> | null, ctx: SetIncrementalResponseCacheContext): Promise<void>;
|
||||
}
|
||||
export interface IncrementalCache extends IncrementalResponseCache {
|
||||
get(cacheKey: string, ctx: GetIncrementalFetchCacheContext): Promise<IncrementalFetchCacheEntry | null>;
|
||||
get(cacheKey: string, ctx: GetIncrementalResponseCacheContext): Promise<IncrementalResponseCacheEntry | null>;
|
||||
set(key: string, data: CachedFetchValue | null, ctx: SetIncrementalFetchCacheContext): Promise<void>;
|
||||
set(key: string, data: Exclude<IncrementalCacheValue, CachedFetchValue> | null, ctx: SetIncrementalResponseCacheContext): Promise<void>;
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
CachedRouteKind: null,
|
||||
IncrementalCacheKind: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
CachedRouteKind: function() {
|
||||
return CachedRouteKind;
|
||||
},
|
||||
IncrementalCacheKind: function() {
|
||||
return IncrementalCacheKind;
|
||||
}
|
||||
});
|
||||
var CachedRouteKind = /*#__PURE__*/ function(CachedRouteKind) {
|
||||
CachedRouteKind["APP_PAGE"] = "APP_PAGE";
|
||||
CachedRouteKind["APP_ROUTE"] = "APP_ROUTE";
|
||||
CachedRouteKind["PAGES"] = "PAGES";
|
||||
CachedRouteKind["FETCH"] = "FETCH";
|
||||
CachedRouteKind["REDIRECT"] = "REDIRECT";
|
||||
CachedRouteKind["IMAGE"] = "IMAGE";
|
||||
return CachedRouteKind;
|
||||
}({});
|
||||
var IncrementalCacheKind = /*#__PURE__*/ function(IncrementalCacheKind) {
|
||||
IncrementalCacheKind["APP_PAGE"] = "APP_PAGE";
|
||||
IncrementalCacheKind["APP_ROUTE"] = "APP_ROUTE";
|
||||
IncrementalCacheKind["PAGES"] = "PAGES";
|
||||
IncrementalCacheKind["FETCH"] = "FETCH";
|
||||
IncrementalCacheKind["IMAGE"] = "IMAGE";
|
||||
return IncrementalCacheKind;
|
||||
}({});
|
||||
|
||||
//# sourceMappingURL=types.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/response-cache/types.ts"],"sourcesContent":["import type { OutgoingHttpHeaders } from 'http'\nimport type RenderResult from '../render-result'\nimport type { CacheControl, Revalidate } from '../lib/cache-control'\nimport type { RouteKind } from '../route-kind'\n\nexport interface ResponseCacheBase {\n get(\n key: string | null,\n responseGenerator: ResponseGenerator,\n context: {\n isOnDemandRevalidate?: boolean\n isPrefetch?: boolean\n incrementalCache: IncrementalCache\n /**\n * This is a hint to the cache to help it determine what kind of route\n * this is so it knows where to look up the cache entry from. If not\n * provided it will test the filesystem to check.\n */\n routeKind: RouteKind\n\n /**\n * True if this is a fallback request.\n */\n isFallback?: boolean\n\n /**\n * True if the route is enabled for PPR.\n */\n isRoutePPREnabled?: boolean\n }\n ): Promise<ResponseCacheEntry | null>\n}\n\n// The server components HMR cache might store other data as well in the future,\n// at which point this should be refactored to a discriminated union type.\nexport interface ServerComponentsHmrCache {\n get(key: string): CachedFetchData | undefined\n set(key: string, data: CachedFetchData): void\n}\n\nexport type CachedFetchData = {\n headers: Record<string, string>\n body: string\n url: string\n status?: number\n}\n\nexport const enum CachedRouteKind {\n APP_PAGE = 'APP_PAGE',\n APP_ROUTE = 'APP_ROUTE',\n PAGES = 'PAGES',\n FETCH = 'FETCH',\n REDIRECT = 'REDIRECT',\n IMAGE = 'IMAGE',\n}\n\nexport interface CachedFetchValue {\n kind: CachedRouteKind.FETCH\n data: CachedFetchData\n // tags are only present with file-system-cache\n // fetch cache stores tags outside of cache entry\n tags?: string[]\n revalidate: number\n}\n\nexport interface CachedRedirectValue {\n kind: CachedRouteKind.REDIRECT\n props: Object\n}\n\nexport interface CachedAppPageValue {\n kind: CachedRouteKind.APP_PAGE\n // this needs to be a RenderResult so since renderResponse\n // expects that type instead of a string\n html: RenderResult\n rscData: Buffer | undefined\n status: number | undefined\n postponed: string | undefined\n headers: OutgoingHttpHeaders | undefined\n segmentData: Map<string, Buffer> | undefined\n}\n\nexport interface CachedPageValue {\n kind: CachedRouteKind.PAGES\n // this needs to be a RenderResult so since renderResponse\n // expects that type instead of a string\n html: RenderResult\n pageData: Object\n status: number | undefined\n headers: OutgoingHttpHeaders | undefined\n}\n\nexport interface CachedRouteValue {\n kind: CachedRouteKind.APP_ROUTE\n // this needs to be a RenderResult so since renderResponse\n // expects that type instead of a string\n body: Buffer\n status: number\n headers: OutgoingHttpHeaders\n}\n\nexport interface CachedImageValue {\n kind: CachedRouteKind.IMAGE\n etag: string\n upstreamEtag: string\n buffer: Buffer\n extension: string\n isMiss?: boolean\n isStale?: boolean\n}\n\nexport interface IncrementalCachedAppPageValue {\n kind: CachedRouteKind.APP_PAGE\n // this needs to be a string since the cache expects to store\n // the string value\n html: string\n rscData: Buffer | undefined\n headers: OutgoingHttpHeaders | undefined\n postponed: string | undefined\n status: number | undefined\n segmentData: Map<string, Buffer> | undefined\n}\n\nexport interface IncrementalCachedPageValue {\n kind: CachedRouteKind.PAGES\n // this needs to be a string since the cache expects to store\n // the string value\n html: string\n pageData: Object\n headers: OutgoingHttpHeaders | undefined\n status: number | undefined\n}\n\nexport interface IncrementalResponseCacheEntry {\n cacheControl?: CacheControl\n /**\n * timestamp in milliseconds to revalidate after\n */\n revalidateAfter?: Revalidate\n /**\n * `-1` here dictates a blocking revalidate should be used\n */\n isStale?: boolean | -1\n isMiss?: boolean\n isFallback: boolean | undefined\n value: Exclude<IncrementalCacheValue, CachedFetchValue> | null\n}\n\nexport interface IncrementalFetchCacheEntry {\n /**\n * `-1` here dictates a blocking revalidate should be used\n */\n isStale?: boolean | -1\n value: CachedFetchValue\n}\n\nexport type IncrementalCacheEntry =\n | IncrementalResponseCacheEntry\n | IncrementalFetchCacheEntry\n\nexport type IncrementalCacheValue =\n | CachedRedirectValue\n | IncrementalCachedPageValue\n | IncrementalCachedAppPageValue\n | CachedImageValue\n | CachedFetchValue\n | CachedRouteValue\n\nexport type ResponseCacheValue =\n | CachedRedirectValue\n | CachedPageValue\n | CachedAppPageValue\n | CachedImageValue\n | CachedRouteValue\n\nexport type ResponseCacheEntry = {\n cacheControl?: CacheControl\n value: ResponseCacheValue | null\n isStale?: boolean | -1\n isMiss?: boolean\n isFLine truncated
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { IncrementalCacheKind, type IncrementalResponseCacheEntry, type ResponseCacheEntry } from './types';
|
||||
import { RouteKind } from '../route-kind';
|
||||
export declare function fromResponseCacheEntry(cacheEntry: ResponseCacheEntry): Promise<IncrementalResponseCacheEntry>;
|
||||
export declare function toResponseCacheEntry(response: IncrementalResponseCacheEntry | null): Promise<ResponseCacheEntry | null>;
|
||||
export declare function routeKindToIncrementalCacheKind(routeKind: RouteKind): Exclude<IncrementalCacheKind, IncrementalCacheKind.FETCH>;
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
fromResponseCacheEntry: null,
|
||||
routeKindToIncrementalCacheKind: null,
|
||||
toResponseCacheEntry: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
fromResponseCacheEntry: function() {
|
||||
return fromResponseCacheEntry;
|
||||
},
|
||||
routeKindToIncrementalCacheKind: function() {
|
||||
return routeKindToIncrementalCacheKind;
|
||||
},
|
||||
toResponseCacheEntry: function() {
|
||||
return toResponseCacheEntry;
|
||||
}
|
||||
});
|
||||
const _types = require("./types");
|
||||
const _renderresult = /*#__PURE__*/ _interop_require_default(require("../render-result"));
|
||||
const _routekind = require("../route-kind");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
async function fromResponseCacheEntry(cacheEntry) {
|
||||
var _cacheEntry_value, _cacheEntry_value1;
|
||||
return {
|
||||
...cacheEntry,
|
||||
value: ((_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) === _types.CachedRouteKind.PAGES ? {
|
||||
kind: _types.CachedRouteKind.PAGES,
|
||||
html: await cacheEntry.value.html.toUnchunkedString(true),
|
||||
pageData: cacheEntry.value.pageData,
|
||||
headers: cacheEntry.value.headers,
|
||||
status: cacheEntry.value.status
|
||||
} : ((_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind) === _types.CachedRouteKind.APP_PAGE ? {
|
||||
kind: _types.CachedRouteKind.APP_PAGE,
|
||||
html: await cacheEntry.value.html.toUnchunkedString(true),
|
||||
postponed: cacheEntry.value.postponed,
|
||||
rscData: cacheEntry.value.rscData,
|
||||
headers: cacheEntry.value.headers,
|
||||
status: cacheEntry.value.status,
|
||||
segmentData: cacheEntry.value.segmentData
|
||||
} : cacheEntry.value
|
||||
};
|
||||
}
|
||||
async function toResponseCacheEntry(response) {
|
||||
var _response_value, _response_value1;
|
||||
if (!response) return null;
|
||||
return {
|
||||
isMiss: response.isMiss,
|
||||
isStale: response.isStale,
|
||||
cacheControl: response.cacheControl,
|
||||
isFallback: response.isFallback,
|
||||
value: ((_response_value = response.value) == null ? void 0 : _response_value.kind) === _types.CachedRouteKind.PAGES ? {
|
||||
kind: _types.CachedRouteKind.PAGES,
|
||||
html: _renderresult.default.fromStatic(response.value.html),
|
||||
pageData: response.value.pageData,
|
||||
headers: response.value.headers,
|
||||
status: response.value.status
|
||||
} : ((_response_value1 = response.value) == null ? void 0 : _response_value1.kind) === _types.CachedRouteKind.APP_PAGE ? {
|
||||
kind: _types.CachedRouteKind.APP_PAGE,
|
||||
html: _renderresult.default.fromStatic(response.value.html),
|
||||
rscData: response.value.rscData,
|
||||
headers: response.value.headers,
|
||||
status: response.value.status,
|
||||
postponed: response.value.postponed,
|
||||
segmentData: response.value.segmentData
|
||||
} : response.value
|
||||
};
|
||||
}
|
||||
function routeKindToIncrementalCacheKind(routeKind) {
|
||||
switch(routeKind){
|
||||
case _routekind.RouteKind.PAGES:
|
||||
return _types.IncrementalCacheKind.PAGES;
|
||||
case _routekind.RouteKind.APP_PAGE:
|
||||
return _types.IncrementalCacheKind.APP_PAGE;
|
||||
case _routekind.RouteKind.IMAGE:
|
||||
return _types.IncrementalCacheKind.IMAGE;
|
||||
case _routekind.RouteKind.APP_ROUTE:
|
||||
return _types.IncrementalCacheKind.APP_ROUTE;
|
||||
default:
|
||||
throw Object.defineProperty(new Error(`Unexpected route kind ${routeKind}`), "__NEXT_ERROR_CODE", {
|
||||
value: "E64",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=utils.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/response-cache/utils.ts"],"sourcesContent":["import {\n CachedRouteKind,\n IncrementalCacheKind,\n type CachedAppPageValue,\n type CachedPageValue,\n type IncrementalResponseCacheEntry,\n type ResponseCacheEntry,\n} from './types'\n\nimport RenderResult from '../render-result'\nimport { RouteKind } from '../route-kind'\n\nexport async function fromResponseCacheEntry(\n cacheEntry: ResponseCacheEntry\n): Promise<IncrementalResponseCacheEntry> {\n return {\n ...cacheEntry,\n value:\n cacheEntry.value?.kind === CachedRouteKind.PAGES\n ? {\n kind: CachedRouteKind.PAGES,\n html: await cacheEntry.value.html.toUnchunkedString(true),\n pageData: cacheEntry.value.pageData,\n headers: cacheEntry.value.headers,\n status: cacheEntry.value.status,\n }\n : cacheEntry.value?.kind === CachedRouteKind.APP_PAGE\n ? {\n kind: CachedRouteKind.APP_PAGE,\n html: await cacheEntry.value.html.toUnchunkedString(true),\n postponed: cacheEntry.value.postponed,\n rscData: cacheEntry.value.rscData,\n headers: cacheEntry.value.headers,\n status: cacheEntry.value.status,\n segmentData: cacheEntry.value.segmentData,\n }\n : cacheEntry.value,\n }\n}\n\nexport async function toResponseCacheEntry(\n response: IncrementalResponseCacheEntry | null\n): Promise<ResponseCacheEntry | null> {\n if (!response) return null\n\n return {\n isMiss: response.isMiss,\n isStale: response.isStale,\n cacheControl: response.cacheControl,\n isFallback: response.isFallback,\n value:\n response.value?.kind === CachedRouteKind.PAGES\n ? ({\n kind: CachedRouteKind.PAGES,\n html: RenderResult.fromStatic(response.value.html),\n pageData: response.value.pageData,\n headers: response.value.headers,\n status: response.value.status,\n } satisfies CachedPageValue)\n : response.value?.kind === CachedRouteKind.APP_PAGE\n ? ({\n kind: CachedRouteKind.APP_PAGE,\n html: RenderResult.fromStatic(response.value.html),\n rscData: response.value.rscData,\n headers: response.value.headers,\n status: response.value.status,\n postponed: response.value.postponed,\n segmentData: response.value.segmentData,\n } satisfies CachedAppPageValue)\n : response.value,\n }\n}\n\nexport function routeKindToIncrementalCacheKind(\n routeKind: RouteKind\n): Exclude<IncrementalCacheKind, IncrementalCacheKind.FETCH> {\n switch (routeKind) {\n case RouteKind.PAGES:\n return IncrementalCacheKind.PAGES\n case RouteKind.APP_PAGE:\n return IncrementalCacheKind.APP_PAGE\n case RouteKind.IMAGE:\n return IncrementalCacheKind.IMAGE\n case RouteKind.APP_ROUTE:\n return IncrementalCacheKind.APP_ROUTE\n default:\n throw new Error(`Unexpected route kind ${routeKind}`)\n }\n}\n"],"names":["fromResponseCacheEntry","routeKindToIncrementalCacheKind","toResponseCacheEntry","cacheEntry","value","kind","CachedRouteKind","PAGES","html","toUnchunkedString","pageData","headers","status","APP_PAGE","postponed","rscData","segmentData","response","isMiss","isStale","cacheControl","isFallback","RenderResult","fromStatic","routeKind","RouteKind","IncrementalCacheKind","IMAGE","APP_ROUTE","Error"],"mappings":";;;;;;;;;;;;;;;;IAYsBA,sBAAsB;eAAtBA;;IA6DNC,+BAA+B;eAA/BA;;IAjCMC,oBAAoB;eAApBA;;;uBAjCf;qEAEkB;2BACC;;;;;;AAEnB,eAAeF,uBACpBG,UAA8B;QAK1BA,mBAQIA;IAXR,OAAO;QACL,GAAGA,UAAU;QACbC,OACED,EAAAA,oBAAAA,WAAWC,KAAK,qBAAhBD,kBAAkBE,IAAI,MAAKC,sBAAe,CAACC,KAAK,GAC5C;YACEF,MAAMC,sBAAe,CAACC,KAAK;YAC3BC,MAAM,MAAML,WAAWC,KAAK,CAACI,IAAI,CAACC,iBAAiB,CAAC;YACpDC,UAAUP,WAAWC,KAAK,CAACM,QAAQ;YACnCC,SAASR,WAAWC,KAAK,CAACO,OAAO;YACjCC,QAAQT,WAAWC,KAAK,CAACQ,MAAM;QACjC,IACAT,EAAAA,qBAAAA,WAAWC,KAAK,qBAAhBD,mBAAkBE,IAAI,MAAKC,sBAAe,CAACO,QAAQ,GACjD;YACER,MAAMC,sBAAe,CAACO,QAAQ;YAC9BL,MAAM,MAAML,WAAWC,KAAK,CAACI,IAAI,CAACC,iBAAiB,CAAC;YACpDK,WAAWX,WAAWC,KAAK,CAACU,SAAS;YACrCC,SAASZ,WAAWC,KAAK,CAACW,OAAO;YACjCJ,SAASR,WAAWC,KAAK,CAACO,OAAO;YACjCC,QAAQT,WAAWC,KAAK,CAACQ,MAAM;YAC/BI,aAAab,WAAWC,KAAK,CAACY,WAAW;QAC3C,IACAb,WAAWC,KAAK;IAC1B;AACF;AAEO,eAAeF,qBACpBe,QAA8C;QAU1CA,iBAQIA;IAhBR,IAAI,CAACA,UAAU,OAAO;IAEtB,OAAO;QACLC,QAAQD,SAASC,MAAM;QACvBC,SAASF,SAASE,OAAO;QACzBC,cAAcH,SAASG,YAAY;QACnCC,YAAYJ,SAASI,UAAU;QAC/BjB,OACEa,EAAAA,kBAAAA,SAASb,KAAK,qBAAda,gBAAgBZ,IAAI,MAAKC,sBAAe,CAACC,KAAK,GACzC;YACCF,MAAMC,sBAAe,CAACC,KAAK;YAC3BC,MAAMc,qBAAY,CAACC,UAAU,CAACN,SAASb,KAAK,CAACI,IAAI;YACjDE,UAAUO,SAASb,KAAK,CAACM,QAAQ;YACjCC,SAASM,SAASb,KAAK,CAACO,OAAO;YAC/BC,QAAQK,SAASb,KAAK,CAACQ,MAAM;QAC/B,IACAK,EAAAA,mBAAAA,SAASb,KAAK,qBAAda,iBAAgBZ,IAAI,MAAKC,sBAAe,CAACO,QAAQ,GAC9C;YACCR,MAAMC,sBAAe,CAACO,QAAQ;YAC9BL,MAAMc,qBAAY,CAACC,UAAU,CLine truncated
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import type { ResponseCacheEntry, ResponseGenerator } from './types';
|
||||
/**
|
||||
* In the web server, there is currently no incremental cache provided and we
|
||||
* always SSR the page.
|
||||
*/
|
||||
export default class WebResponseCache {
|
||||
pendingResponses: Map<string, Promise<ResponseCacheEntry | null>>;
|
||||
previousCacheItem?: {
|
||||
key: string;
|
||||
entry: ResponseCacheEntry | null;
|
||||
expiresAt: number;
|
||||
};
|
||||
minimalMode?: boolean;
|
||||
constructor(minimalMode: boolean);
|
||||
get(key: string | null, responseGenerator: ResponseGenerator, context: {
|
||||
isOnDemandRevalidate?: boolean;
|
||||
isPrefetch?: boolean;
|
||||
incrementalCache: any;
|
||||
}): Promise<ResponseCacheEntry | null>;
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, /**
|
||||
* In the web server, there is currently no incremental cache provided and we
|
||||
* always SSR the page.
|
||||
*/ "default", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return WebResponseCache;
|
||||
}
|
||||
});
|
||||
const _detachedpromise = require("../../lib/detached-promise");
|
||||
class WebResponseCache {
|
||||
constructor(minimalMode){
|
||||
this.pendingResponses = new Map();
|
||||
// this is a hack to avoid Webpack knowing this is equal to this.minimalMode
|
||||
// because we replace this.minimalMode to true in production bundles.
|
||||
Object.assign(this, {
|
||||
minimalMode
|
||||
});
|
||||
}
|
||||
get(key, responseGenerator, context) {
|
||||
var _this_previousCacheItem;
|
||||
// ensure on-demand revalidate doesn't block normal requests
|
||||
const pendingResponseKey = key ? `${key}-${context.isOnDemandRevalidate ? '1' : '0'}` : null;
|
||||
const pendingResponse = pendingResponseKey ? this.pendingResponses.get(pendingResponseKey) : null;
|
||||
if (pendingResponse) {
|
||||
return pendingResponse;
|
||||
}
|
||||
const { promise, resolve: resolver, reject: rejecter } = new _detachedpromise.DetachedPromise();
|
||||
if (pendingResponseKey) {
|
||||
this.pendingResponses.set(pendingResponseKey, promise);
|
||||
}
|
||||
let hasResolved = false;
|
||||
const resolve = (cacheEntry)=>{
|
||||
if (pendingResponseKey) {
|
||||
// Ensure all reads from the cache get the latest value.
|
||||
this.pendingResponses.set(pendingResponseKey, Promise.resolve(cacheEntry));
|
||||
}
|
||||
if (!hasResolved) {
|
||||
hasResolved = true;
|
||||
resolver(cacheEntry);
|
||||
}
|
||||
};
|
||||
// we keep the previous cache entry around to leverage
|
||||
// when the incremental cache is disabled in minimal mode
|
||||
if (pendingResponseKey && this.minimalMode && ((_this_previousCacheItem = this.previousCacheItem) == null ? void 0 : _this_previousCacheItem.key) === pendingResponseKey && this.previousCacheItem.expiresAt > Date.now()) {
|
||||
resolve(this.previousCacheItem.entry);
|
||||
this.pendingResponses.delete(pendingResponseKey);
|
||||
return promise;
|
||||
}
|
||||
// We wait to do any async work until after we've added our promise to
|
||||
// `pendingResponses` to ensure that any any other calls will reuse the
|
||||
// same promise until we've fully finished our work.
|
||||
;
|
||||
(async ()=>{
|
||||
try {
|
||||
const cacheEntry = await responseGenerator({
|
||||
hasResolved
|
||||
});
|
||||
const resolveValue = cacheEntry === null ? null : {
|
||||
...cacheEntry,
|
||||
isMiss: true
|
||||
};
|
||||
// for on-demand revalidate wait to resolve until cache is set
|
||||
if (!context.isOnDemandRevalidate) {
|
||||
resolve(resolveValue);
|
||||
}
|
||||
if (key && cacheEntry && cacheEntry.cacheControl) {
|
||||
this.previousCacheItem = {
|
||||
key: pendingResponseKey || key,
|
||||
entry: cacheEntry,
|
||||
expiresAt: Date.now() + 1000
|
||||
};
|
||||
} else {
|
||||
this.previousCacheItem = undefined;
|
||||
}
|
||||
if (context.isOnDemandRevalidate) {
|
||||
resolve(resolveValue);
|
||||
}
|
||||
} catch (err) {
|
||||
// while revalidating in the background we can't reject as
|
||||
// we already resolved the cache entry so log the error here
|
||||
if (hasResolved) {
|
||||
console.error(err);
|
||||
} else {
|
||||
rejecter(err);
|
||||
}
|
||||
} finally{
|
||||
if (pendingResponseKey) {
|
||||
this.pendingResponses.delete(pendingResponseKey);
|
||||
}
|
||||
}
|
||||
})();
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=web.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/response-cache/web.ts"],"sourcesContent":["import { DetachedPromise } from '../../lib/detached-promise'\nimport type { ResponseCacheEntry, ResponseGenerator } from './types'\n\n/**\n * In the web server, there is currently no incremental cache provided and we\n * always SSR the page.\n */\nexport default class WebResponseCache {\n pendingResponses: Map<string, Promise<ResponseCacheEntry | null>>\n previousCacheItem?: {\n key: string\n entry: ResponseCacheEntry | null\n expiresAt: number\n }\n minimalMode?: boolean\n\n constructor(minimalMode: boolean) {\n this.pendingResponses = new Map()\n // this is a hack to avoid Webpack knowing this is equal to this.minimalMode\n // because we replace this.minimalMode to true in production bundles.\n Object.assign(this, { minimalMode })\n }\n\n public get(\n key: string | null,\n responseGenerator: ResponseGenerator,\n context: {\n isOnDemandRevalidate?: boolean\n isPrefetch?: boolean\n incrementalCache: any\n }\n ): Promise<ResponseCacheEntry | null> {\n // ensure on-demand revalidate doesn't block normal requests\n const pendingResponseKey = key\n ? `${key}-${context.isOnDemandRevalidate ? '1' : '0'}`\n : null\n\n const pendingResponse = pendingResponseKey\n ? this.pendingResponses.get(pendingResponseKey)\n : null\n if (pendingResponse) {\n return pendingResponse\n }\n\n const {\n promise,\n resolve: resolver,\n reject: rejecter,\n } = new DetachedPromise<ResponseCacheEntry | null>()\n if (pendingResponseKey) {\n this.pendingResponses.set(pendingResponseKey, promise)\n }\n\n let hasResolved = false\n const resolve = (cacheEntry: ResponseCacheEntry | null) => {\n if (pendingResponseKey) {\n // Ensure all reads from the cache get the latest value.\n this.pendingResponses.set(\n pendingResponseKey,\n Promise.resolve(cacheEntry)\n )\n }\n if (!hasResolved) {\n hasResolved = true\n resolver(cacheEntry)\n }\n }\n\n // we keep the previous cache entry around to leverage\n // when the incremental cache is disabled in minimal mode\n if (\n pendingResponseKey &&\n this.minimalMode &&\n this.previousCacheItem?.key === pendingResponseKey &&\n this.previousCacheItem.expiresAt > Date.now()\n ) {\n resolve(this.previousCacheItem.entry)\n this.pendingResponses.delete(pendingResponseKey)\n return promise\n }\n\n // We wait to do any async work until after we've added our promise to\n // `pendingResponses` to ensure that any any other calls will reuse the\n // same promise until we've fully finished our work.\n ;(async () => {\n try {\n const cacheEntry = await responseGenerator({ hasResolved })\n const resolveValue =\n cacheEntry === null\n ? null\n : {\n ...cacheEntry,\n isMiss: true,\n }\n\n // for on-demand revalidate wait to resolve until cache is set\n if (!context.isOnDemandRevalidate) {\n resolve(resolveValue)\n }\n\n if (key && cacheEntry && cacheEntry.cacheControl) {\n this.previousCacheItem = {\n key: pendingResponseKey || key,\n entry: cacheEntry,\n expiresAt: Date.now() + 1000,\n }\n } else {\n this.previousCacheItem = undefined\n }\n\n if (context.isOnDemandRevalidate) {\n resolve(resolveValue)\n }\n } catch (err) {\n // while revalidating in the background we can't reject as\n // we already resolved the cache entry so log the error here\n if (hasResolved) {\n console.error(err)\n } else {\n rejecter(err as Error)\n }\n } finally {\n if (pendingResponseKey) {\n this.pendingResponses.delete(pendingResponseKey)\n }\n }\n })()\n return promise\n }\n}\n"],"names":["WebResponseCache","constructor","minimalMode","pendingResponses","Map","Object","assign","get","key","responseGenerator","context","pendingResponseKey","isOnDemandRevalidate","pendingResponse","promise","resolve","resolver","reject","rejecter","DetachedPromise","set","hasResolved","cacheEntry","Promise","previousCacheItem","expiresAt","Date","now","entry","delete","resolveValue","isMiss","cacheControl","undefined","err","console","error"],"mappings":";;;;+BAGA;;;CAGC,GACD;;;eAAqBA;;;iCAPW;AAOjB,MAAMA;IASnBC,YAAYC,WAAoB,CAAE;QAChC,IAAI,CAACC,gBAAgB,GAAG,IAAIC;QAC5B,4EAA4E;QAC5E,qEAAqE;QACrEC,OAAOC,MAAM,CAAC,IAAI,EAAE;YAAEJ;QAAY;IACpC;IAEOK,IACLC,GAAkB,EAClBC,iBAAoC,EACpCC,OAIC,EACmC;YA0ClC;QAzCF,4DAA4D;QAC5D,MAAMC,qBAAqBH,MACvB,GAAGA,IAAI,CAAC,EAAEE,QAAQE,oBAAoB,GAAG,MAAM,KAAK,GACpD;QAEJ,MAAMC,kBAAkBF,qBACpB,IAAI,CAACR,gBAAgB,CAACI,GAAG,CAACI,sBAC1B;QACJ,IAAIE,iBAAiB;YACnB,OAAOA;QACT;Line truncated
|
||||
Reference in new issue
Block a user