.
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
export type CacheLife = {
|
||||
stale?: number;
|
||||
revalidate?: number;
|
||||
expire?: number;
|
||||
};
|
||||
type CacheLifeProfiles = 'default' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'max' | (string & {});
|
||||
export declare function cacheLife(profile: CacheLifeProfiles | CacheLife): void;
|
||||
export {};
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "cacheLife", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return cacheLife;
|
||||
}
|
||||
});
|
||||
const _invarianterror = require("../../shared/lib/invariant-error");
|
||||
const _workasyncstorageexternal = require("../app-render/work-async-storage.external");
|
||||
const _workunitasyncstorageexternal = require("../app-render/work-unit-async-storage.external");
|
||||
function validateCacheLife(profile) {
|
||||
if (profile.stale !== undefined) {
|
||||
if (profile.stale === false) {
|
||||
throw Object.defineProperty(new Error('Pass `Infinity` instead of `false` if you want to cache on the client forever ' + 'without checking with the server.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E407",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else if (typeof profile.stale !== 'number') {
|
||||
throw Object.defineProperty(new Error('The stale option must be a number of seconds.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E308",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
if (profile.revalidate !== undefined) {
|
||||
if (profile.revalidate === false) {
|
||||
throw Object.defineProperty(new Error('Pass `Infinity` instead of `false` if you do not want to revalidate by time.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E104",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else if (typeof profile.revalidate !== 'number') {
|
||||
throw Object.defineProperty(new Error('The revalidate option must be a number of seconds.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E233",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
if (profile.expire !== undefined) {
|
||||
if (profile.expire === false) {
|
||||
throw Object.defineProperty(new Error('Pass `Infinity` instead of `false` if you want to cache on the server forever ' + 'without checking with the origin.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E658",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else if (typeof profile.expire !== 'number') {
|
||||
throw Object.defineProperty(new Error('The expire option must be a number of seconds.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E3",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
if (profile.revalidate !== undefined && profile.expire !== undefined) {
|
||||
if (profile.revalidate > profile.expire) {
|
||||
throw Object.defineProperty(new Error('If providing both the revalidate and expire options, ' + 'the expire option must be greater than the revalidate option. ' + 'The expire option indicates how many seconds from the start ' + 'until it can no longer be used.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E656",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function cacheLife(profile) {
|
||||
if (!process.env.__NEXT_USE_CACHE) {
|
||||
throw Object.defineProperty(new Error('`cacheLife()` is only available with the `cacheComponents` config.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E887",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
||||
switch(workUnitStore == null ? void 0 : workUnitStore.type){
|
||||
case 'prerender':
|
||||
case 'prerender-client':
|
||||
case 'validation-client':
|
||||
case 'prerender-runtime':
|
||||
case 'prerender-ppr':
|
||||
case 'prerender-legacy':
|
||||
case 'request':
|
||||
case 'unstable-cache':
|
||||
case 'generate-static-params':
|
||||
case undefined:
|
||||
throw Object.defineProperty(new Error('`cacheLife()` can only be called inside a "use cache" function.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E818",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
case 'cache':
|
||||
case 'private-cache':
|
||||
break;
|
||||
default:
|
||||
workUnitStore;
|
||||
}
|
||||
if (typeof profile === 'string') {
|
||||
const workStore = _workasyncstorageexternal.workAsyncStorage.getStore();
|
||||
if (!workStore) {
|
||||
throw Object.defineProperty(new Error('`cacheLife()` can only be called during App Router rendering at the moment.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E820",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (!workStore.cacheLifeProfiles) {
|
||||
throw Object.defineProperty(new _invarianterror.InvariantError('`cacheLifeProfiles` should always be provided.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E817",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
// TODO: This should be globally available and not require an AsyncLocalStorage.
|
||||
const configuredProfile = workStore.cacheLifeProfiles[profile];
|
||||
if (configuredProfile === undefined) {
|
||||
if (workStore.cacheLifeProfiles[profile.trim()]) {
|
||||
throw Object.defineProperty(new Error(`Unknown \`cacheLife()\` profile "${profile}" is not configured in next.config.js\n` + `Did you mean "${profile.trim()}" without the spaces?`), "__NEXT_ERROR_CODE", {
|
||||
value: "E816",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
throw Object.defineProperty(new Error(`Unknown \`cacheLife()\` profile "${profile}" is not configured in next.config.js\n` + 'module.exports = {\n' + ' cacheLife: {\n' + ` "${profile}": ...\n` + ' }\n' + '}'), "__NEXT_ERROR_CODE", {
|
||||
value: "E888",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
profile = configuredProfile;
|
||||
} else if (typeof profile !== 'object' || profile === null || Array.isArray(profile)) {
|
||||
throw Object.defineProperty(new Error('Invalid `cacheLife()` option. Either pass a profile name or object.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E814",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else {
|
||||
validateCacheLife(profile);
|
||||
}
|
||||
if (profile.revalidate !== undefined) {
|
||||
// Track the explicit revalidate time.
|
||||
if (workUnitStore.explicitRevalidate === undefined || workUnitStore.explicitRevalidate > profile.revalidate) {
|
||||
workUnitStore.explicitRevalidate = profile.revalidate;
|
||||
}
|
||||
}
|
||||
if (profile.expire !== undefined) {
|
||||
// Track the explicit expire time.
|
||||
if (workUnitStore.explicitExpire === undefined || workUnitStore.explicitExpire > profile.expire) {
|
||||
workUnitStore.explicitExpire = profile.expire;
|
||||
}
|
||||
}
|
||||
if (profile.stale !== undefined) {
|
||||
// Track the explicit stale time.
|
||||
if (workUnitStore.explicitStale === undefined || workUnitStore.explicitStale > profile.stale) {
|
||||
workUnitStore.explicitStale = profile.stale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=cache-life.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
export declare function cacheTag(...tags: string[]): void;
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "cacheTag", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return cacheTag;
|
||||
}
|
||||
});
|
||||
const _workunitasyncstorageexternal = require("../app-render/work-unit-async-storage.external");
|
||||
const _patchfetch = require("../lib/patch-fetch");
|
||||
function cacheTag(...tags) {
|
||||
if (!process.env.__NEXT_USE_CACHE) {
|
||||
throw Object.defineProperty(new Error('`cacheTag()` is only available with the `cacheComponents` config.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E886",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
||||
switch(workUnitStore == null ? void 0 : workUnitStore.type){
|
||||
case 'prerender':
|
||||
case 'prerender-client':
|
||||
case 'validation-client':
|
||||
case 'prerender-runtime':
|
||||
case 'prerender-ppr':
|
||||
case 'prerender-legacy':
|
||||
case 'request':
|
||||
case 'unstable-cache':
|
||||
case 'generate-static-params':
|
||||
case undefined:
|
||||
throw Object.defineProperty(new Error('`cacheTag()` can only be called inside a "use cache" function.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E819",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
case 'cache':
|
||||
case 'private-cache':
|
||||
break;
|
||||
default:
|
||||
workUnitStore;
|
||||
}
|
||||
const validTags = (0, _patchfetch.validateTags)(tags, '`cacheTag()`');
|
||||
if (!workUnitStore.tags) {
|
||||
workUnitStore.tags = validTags;
|
||||
} else {
|
||||
workUnitStore.tags.push(...validTags);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=cache-tag.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/use-cache/cache-tag.ts"],"sourcesContent":["import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external'\nimport { validateTags } from '../lib/patch-fetch'\n\nexport function cacheTag(...tags: string[]): void {\n if (!process.env.__NEXT_USE_CACHE) {\n throw new Error(\n '`cacheTag()` is only available with the `cacheComponents` config.'\n )\n }\n\n const workUnitStore = workUnitAsyncStorage.getStore()\n\n switch (workUnitStore?.type) {\n case 'prerender':\n case 'prerender-client':\n case 'validation-client':\n case 'prerender-runtime':\n case 'prerender-ppr':\n case 'prerender-legacy':\n case 'request':\n case 'unstable-cache':\n case 'generate-static-params':\n case undefined:\n throw new Error(\n '`cacheTag()` can only be called inside a \"use cache\" function.'\n )\n case 'cache':\n case 'private-cache':\n break\n default:\n workUnitStore satisfies never\n }\n\n const validTags = validateTags(tags, '`cacheTag()`')\n\n if (!workUnitStore.tags) {\n workUnitStore.tags = validTags\n } else {\n workUnitStore.tags.push(...validTags)\n }\n}\n"],"names":["cacheTag","tags","process","env","__NEXT_USE_CACHE","Error","workUnitStore","workUnitAsyncStorage","getStore","type","undefined","validTags","validateTags","push"],"mappings":";;;;+BAGgBA;;;eAAAA;;;8CAHqB;4BACR;AAEtB,SAASA,SAAS,GAAGC,IAAc;IACxC,IAAI,CAACC,QAAQC,GAAG,CAACC,gBAAgB,EAAE;QACjC,MAAM,qBAEL,CAFK,IAAIC,MACR,sEADI,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,MAAMC,gBAAgBC,kDAAoB,CAACC,QAAQ;IAEnD,OAAQF,iCAAAA,cAAeG,IAAI;QACzB,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAKC;YACH,MAAM,qBAEL,CAFK,IAAIL,MACR,mEADI,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;QACF,KAAK;QACL,KAAK;YACH;QACF;YACEC;IACJ;IAEA,MAAMK,YAAYC,IAAAA,wBAAY,EAACX,MAAM;IAErC,IAAI,CAACK,cAAcL,IAAI,EAAE;QACvBK,cAAcL,IAAI,GAAGU;IACvB,OAAO;QACLL,cAAcL,IAAI,CAACY,IAAI,IAAIF;IAC7B;AACF","ignoreList":[0]}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export declare const DYNAMIC_EXPIRE = 300;
|
||||
export declare const RUNTIME_PREFETCH_DYNAMIC_STALE = 30;
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
DYNAMIC_EXPIRE: null,
|
||||
RUNTIME_PREFETCH_DYNAMIC_STALE: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
DYNAMIC_EXPIRE: function() {
|
||||
return DYNAMIC_EXPIRE;
|
||||
},
|
||||
RUNTIME_PREFETCH_DYNAMIC_STALE: function() {
|
||||
return RUNTIME_PREFETCH_DYNAMIC_STALE;
|
||||
}
|
||||
});
|
||||
const DYNAMIC_EXPIRE = 300 // 5 minutes
|
||||
;
|
||||
const RUNTIME_PREFETCH_DYNAMIC_STALE = 30 // 30 seconds
|
||||
;
|
||||
|
||||
//# sourceMappingURL=constants.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/use-cache/constants.ts"],"sourcesContent":["export const DYNAMIC_EXPIRE = 300 // 5 minutes\nexport const RUNTIME_PREFETCH_DYNAMIC_STALE = 30 // 30 seconds\n"],"names":["DYNAMIC_EXPIRE","RUNTIME_PREFETCH_DYNAMIC_STALE"],"mappings":";;;;;;;;;;;;;;;IAAaA,cAAc;eAAdA;;IACAC,8BAA8B;eAA9BA;;;AADN,MAAMD,iBAAiB,IAAI,YAAY;;AACvC,MAAMC,iCAAiC,GAAG,aAAa","ignoreList":[0]}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import type { CacheHandler } from '../lib/cache-handlers/types';
|
||||
/**
|
||||
* Initialize the cache handlers.
|
||||
* @param cacheMaxMemorySize - The maximum memory size of the cache in bytes, if
|
||||
* not provided, the default memory size will be used.
|
||||
* @returns `true` if the cache handlers were initialized, `false` if they were already initialized.
|
||||
*/
|
||||
export declare function initializeCacheHandlers(cacheMaxMemorySize: number): boolean;
|
||||
/**
|
||||
* Get a cache handler by kind.
|
||||
* @param kind - The kind of cache handler to get.
|
||||
* @returns The cache handler, or `undefined` if it does not exist.
|
||||
* @throws If the cache handlers are not initialized.
|
||||
*/
|
||||
export declare function getCacheHandler(kind: string): CacheHandler | undefined;
|
||||
/**
|
||||
* Get a set iterator over the cache handlers.
|
||||
* @returns An iterator over the cache handlers, or `undefined` if they are not
|
||||
* initialized.
|
||||
*/
|
||||
export declare function getCacheHandlers(): SetIterator<CacheHandler> | undefined;
|
||||
/**
|
||||
* Get a map iterator over the cache handlers (keyed by kind).
|
||||
* @returns An iterator over the cache handler entries, or `undefined` if they
|
||||
* are not initialized.
|
||||
* @throws If the cache handlers are not initialized.
|
||||
*/
|
||||
export declare function getCacheHandlerEntries(): MapIterator<[string, CacheHandler]> | undefined;
|
||||
/**
|
||||
* Set a cache handler by kind.
|
||||
* @param kind - The kind of cache handler to set.
|
||||
* @param cacheHandler - The cache handler to set.
|
||||
*/
|
||||
export declare function setCacheHandler(kind: string, cacheHandler: CacheHandler): void;
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
getCacheHandler: null,
|
||||
getCacheHandlerEntries: null,
|
||||
getCacheHandlers: null,
|
||||
initializeCacheHandlers: null,
|
||||
setCacheHandler: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
getCacheHandler: function() {
|
||||
return getCacheHandler;
|
||||
},
|
||||
getCacheHandlerEntries: function() {
|
||||
return getCacheHandlerEntries;
|
||||
},
|
||||
getCacheHandlers: function() {
|
||||
return getCacheHandlers;
|
||||
},
|
||||
initializeCacheHandlers: function() {
|
||||
return initializeCacheHandlers;
|
||||
},
|
||||
setCacheHandler: function() {
|
||||
return setCacheHandler;
|
||||
}
|
||||
});
|
||||
const _default = require("../lib/cache-handlers/default");
|
||||
const debug = process.env.NEXT_PRIVATE_DEBUG_CACHE ? (message, ...args)=>{
|
||||
console.log(`use-cache: ${message}`, ...args);
|
||||
} : undefined;
|
||||
const handlersSymbol = Symbol.for('@next/cache-handlers');
|
||||
const handlersMapSymbol = Symbol.for('@next/cache-handlers-map');
|
||||
const handlersSetSymbol = Symbol.for('@next/cache-handlers-set');
|
||||
/**
|
||||
* The reference to the cache handlers. We store the cache handlers on the
|
||||
* global object so that we can access the same instance across different
|
||||
* boundaries (such as different copies of the same module).
|
||||
*/ const reference = globalThis;
|
||||
function initializeCacheHandlers(cacheMaxMemorySize) {
|
||||
// If the cache handlers have already been initialized, don't do it again.
|
||||
if (reference[handlersMapSymbol]) {
|
||||
debug == null ? void 0 : debug('cache handlers already initialized');
|
||||
return false;
|
||||
}
|
||||
debug == null ? void 0 : debug('initializing cache handlers');
|
||||
reference[handlersMapSymbol] = new Map();
|
||||
// Initialize the cache from the symbol contents first.
|
||||
if (reference[handlersSymbol]) {
|
||||
let fallback;
|
||||
if (reference[handlersSymbol].DefaultCache) {
|
||||
debug == null ? void 0 : debug('setting "default" cache handler from symbol');
|
||||
fallback = reference[handlersSymbol].DefaultCache;
|
||||
} else {
|
||||
debug == null ? void 0 : debug('setting "default" cache handler from default');
|
||||
fallback = (0, _default.createDefaultCacheHandler)(cacheMaxMemorySize);
|
||||
}
|
||||
reference[handlersMapSymbol].set('default', fallback);
|
||||
if (reference[handlersSymbol].RemoteCache) {
|
||||
debug == null ? void 0 : debug('setting "remote" cache handler from symbol');
|
||||
reference[handlersMapSymbol].set('remote', reference[handlersSymbol].RemoteCache);
|
||||
} else {
|
||||
debug == null ? void 0 : debug('setting "remote" cache handler from default');
|
||||
reference[handlersMapSymbol].set('remote', fallback);
|
||||
}
|
||||
} else {
|
||||
const handler = (0, _default.createDefaultCacheHandler)(cacheMaxMemorySize);
|
||||
debug == null ? void 0 : debug('setting "default" cache handler from default');
|
||||
reference[handlersMapSymbol].set('default', handler);
|
||||
debug == null ? void 0 : debug('setting "remote" cache handler from default');
|
||||
reference[handlersMapSymbol].set('remote', handler);
|
||||
}
|
||||
// Create a set of the cache handlers.
|
||||
reference[handlersSetSymbol] = new Set(reference[handlersMapSymbol].values());
|
||||
return true;
|
||||
}
|
||||
function getCacheHandler(kind) {
|
||||
// This should never be called before initializeCacheHandlers.
|
||||
if (!reference[handlersMapSymbol]) {
|
||||
throw Object.defineProperty(new Error('Cache handlers not initialized'), "__NEXT_ERROR_CODE", {
|
||||
value: "E649",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
return reference[handlersMapSymbol].get(kind);
|
||||
}
|
||||
function getCacheHandlers() {
|
||||
if (!reference[handlersSetSymbol]) {
|
||||
return undefined;
|
||||
}
|
||||
return reference[handlersSetSymbol].values();
|
||||
}
|
||||
function getCacheHandlerEntries() {
|
||||
if (!reference[handlersMapSymbol]) {
|
||||
return undefined;
|
||||
}
|
||||
return reference[handlersMapSymbol].entries();
|
||||
}
|
||||
function setCacheHandler(kind, cacheHandler) {
|
||||
// This should never be called before initializeCacheHandlers.
|
||||
if (!reference[handlersMapSymbol] || !reference[handlersSetSymbol]) {
|
||||
throw Object.defineProperty(new Error('Cache handlers not initialized'), "__NEXT_ERROR_CODE", {
|
||||
value: "E649",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
debug == null ? void 0 : debug('setting cache handler for "%s"', kind);
|
||||
reference[handlersMapSymbol].set(kind, cacheHandler);
|
||||
reference[handlersSetSymbol].add(cacheHandler);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=handlers.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+7
@@ -0,0 +1,7 @@
|
||||
declare const USE_CACHE_TIMEOUT_ERROR_CODE = "USE_CACHE_TIMEOUT";
|
||||
export declare class UseCacheTimeoutError extends Error {
|
||||
digest: typeof USE_CACHE_TIMEOUT_ERROR_CODE;
|
||||
constructor();
|
||||
}
|
||||
export declare function isUseCacheTimeoutError(err: unknown): err is UseCacheTimeoutError;
|
||||
export {};
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
UseCacheTimeoutError: null,
|
||||
isUseCacheTimeoutError: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
UseCacheTimeoutError: function() {
|
||||
return UseCacheTimeoutError;
|
||||
},
|
||||
isUseCacheTimeoutError: function() {
|
||||
return isUseCacheTimeoutError;
|
||||
}
|
||||
});
|
||||
const USE_CACHE_TIMEOUT_ERROR_CODE = 'USE_CACHE_TIMEOUT';
|
||||
class UseCacheTimeoutError extends Error {
|
||||
constructor(){
|
||||
super('Filling a cache during prerender timed out, likely because request-specific arguments such as params, searchParams, cookies() or dynamic data were used inside "use cache".'), this.digest = USE_CACHE_TIMEOUT_ERROR_CODE;
|
||||
}
|
||||
}
|
||||
function isUseCacheTimeoutError(err) {
|
||||
if (typeof err !== 'object' || err === null || !('digest' in err) || typeof err.digest !== 'string') {
|
||||
return false;
|
||||
}
|
||||
return err.digest === USE_CACHE_TIMEOUT_ERROR_CODE;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=use-cache-errors.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/use-cache/use-cache-errors.ts"],"sourcesContent":["const USE_CACHE_TIMEOUT_ERROR_CODE = 'USE_CACHE_TIMEOUT'\n\nexport class UseCacheTimeoutError extends Error {\n digest: typeof USE_CACHE_TIMEOUT_ERROR_CODE = USE_CACHE_TIMEOUT_ERROR_CODE\n\n constructor() {\n super(\n 'Filling a cache during prerender timed out, likely because request-specific arguments such as params, searchParams, cookies() or dynamic data were used inside \"use cache\".'\n )\n }\n}\n\nexport function isUseCacheTimeoutError(\n err: unknown\n): err is UseCacheTimeoutError {\n if (\n typeof err !== 'object' ||\n err === null ||\n !('digest' in err) ||\n typeof err.digest !== 'string'\n ) {\n return false\n }\n\n return err.digest === USE_CACHE_TIMEOUT_ERROR_CODE\n}\n"],"names":["UseCacheTimeoutError","isUseCacheTimeoutError","USE_CACHE_TIMEOUT_ERROR_CODE","Error","constructor","digest","err"],"mappings":";;;;;;;;;;;;;;;IAEaA,oBAAoB;eAApBA;;IAUGC,sBAAsB;eAAtBA;;;AAZhB,MAAMC,+BAA+B;AAE9B,MAAMF,6BAA6BG;IAGxCC,aAAc;QACZ,KAAK,CACH,qLAJJC,SAA8CH;IAM9C;AACF;AAEO,SAASD,uBACdK,GAAY;IAEZ,IACE,OAAOA,QAAQ,YACfA,QAAQ,QACR,CAAE,CAAA,YAAYA,GAAE,KAChB,OAAOA,IAAID,MAAM,KAAK,UACtB;QACA,OAAO;IACT;IAEA,OAAOC,IAAID,MAAM,KAAKH;AACxB","ignoreList":[0]}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
import type { CacheEntry } from '../lib/cache-handlers/types';
|
||||
import { type SearchParams } from '../request/search-params';
|
||||
import type { Params } from '../request/params';
|
||||
export interface UseCachePageProps {
|
||||
params: Promise<Params>;
|
||||
searchParams: Promise<SearchParams>;
|
||||
$$isPage: true;
|
||||
}
|
||||
export type UseCacheLayoutProps = {
|
||||
params: Promise<Params>;
|
||||
$$isLayout: true;
|
||||
} & {
|
||||
[slot: string]: any;
|
||||
};
|
||||
export interface CollectedCacheResult {
|
||||
entry: CacheEntry;
|
||||
/**
|
||||
* Whether the revalidate value was explicitly set via `cacheLife()`.
|
||||
* - `true`: explicitly set
|
||||
* - `false`: implicit (propagated from a nested cache or implicitly using the
|
||||
* default profile)
|
||||
* - `undefined`: unknown (e.g. pre-existing entry from a cache handler)
|
||||
*/
|
||||
hasExplicitRevalidate: boolean | undefined;
|
||||
/**
|
||||
* Whether the expire value was explicitly set via `cacheLife()`.
|
||||
* - `true`: explicitly set
|
||||
* - `false`: implicit (propagated from a nested cache or implicitly using the
|
||||
* default profile)
|
||||
* - `undefined`: unknown (e.g. pre-existing entry from a cache handler)
|
||||
*/
|
||||
hasExplicitExpire: boolean | undefined;
|
||||
/**
|
||||
* The root param names that were read during cache entry generation.
|
||||
* Used to compute the specific cache key after generation completes.
|
||||
* `undefined` for pre-existing entries from cache handlers where we
|
||||
* don't have this information.
|
||||
*/
|
||||
readRootParamNames: ReadonlySet<string> | undefined;
|
||||
}
|
||||
export declare function cache(kind: string, id: string, boundArgsLength: number, originalFn: (...args: unknown[]) => Promise<unknown>, args: unknown[]): Promise<unknown>;
|
||||
+1588
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user