UNPKG

next

Version:

The React Framework

67 lines (66 loc) • 2.91 kB
import type { CachedFetchValue } from '../response-cache/types'; import type { CollectedCacheResult } from '../use-cache/use-cache-wrapper'; /** * A generic cache store type that provides a subset of Map functionality */ type CacheStore<T> = Pick<Map<string, T>, 'entries' | 'keys' | 'size' | 'get' | 'set' | 'has' | typeof Symbol.iterator>; /** * A cache store specifically for fetch cache values */ export type FetchCacheStore = CacheStore<CachedFetchValue>; /** * A cache store for encrypted bound args of inline server functions. */ export type EncryptedBoundArgsCacheStore = CacheStore<string>; /** * An in-memory-only cache store for decrypted bound args of inline server * functions. */ export type DecryptedBoundArgsCacheStore = CacheStore<string>; /** * An in-memory-only cache store for rendered `ImageResponse` array buffers, * keyed by a serialization of the `ImageResponse` constructor args. This lets * the prospective prerender render the image once and hand the array buffer to * the final prerender within microtasks, so that metadata image routes can be * statically prerendered under Cache Components. Never serialized into the * resume store. */ export type ImageResponseCacheStore = CacheStore<Promise<ArrayBuffer>>; /** * Serialized format for "use cache" entries */ export interface UseCacheCacheStoreSerialized { entry: { value: string; tags: string[]; stale: number; timestamp: number; expire: number; revalidate: number; }; hasExplicitRevalidate: boolean | undefined; hasExplicitExpire: boolean | undefined; readRootParamNames: string[] | undefined; } export declare const FALLBACK_PARAMS: unique symbol; export declare const RUNTIME_DATA: unique symbol; export declare const SESSION_DATA: unique symbol; type UseCacheCacheStoreValue = Promise<CollectedCacheResult> | typeof FALLBACK_PARAMS | typeof RUNTIME_DATA | typeof SESSION_DATA; /** * A cache store for "use cache" results, or markers explaining why an entry * could not be included in this prerender. */ export type UseCacheCacheStore = CacheStore<UseCacheCacheStoreValue>; /** * Parses serialized cache entries into a UseCacheCacheStore * @param entries - The serialized entries to parse * @returns A new UseCacheCacheStore containing the parsed entries */ export declare function parseUseCacheCacheStore(entries: Iterable<[string, UseCacheCacheStoreSerialized]>): UseCacheCacheStore; /** * Serializes UseCacheCacheStore entries into an array of key-value pairs * @param entries - The store entries to stringify * @returns A promise that resolves to an array of key-value pairs with serialized values */ export declare function serializeUseCacheCacheStore(entries: IterableIterator<[string, UseCacheCacheStoreValue]>, isCacheComponentsEnabled: boolean): Promise<Array<[string, UseCacheCacheStoreSerialized] | null>>; export {};