import { ContentRef } from './types'; import { Storage } from '../utils/storage'; /** * A cache backend keyed by an opaque string. Both sync and async * implementations are allowed (the resolver always `await`s). The default is * in-memory; {@link storageContentCache} adapts an instance's {@link Storage} * handle so cached content persists. */ export interface ContentCache { get(key: string): Promise | string | null; set(key: string, value: string): Promise | void; } /** In-memory {@link ContentCache} — the default; scoped to one resolver. */ export declare function memoryContentCache(): ContentCache; /** * Adapt an instance {@link Storage} handle into a {@link ContentCache}. Cached * content lives in the same IndexedDB store as file content, under a reserved * `__contentref__` path prefix, so it stays isolated per instance (#95) and * survives reloads. In a `'none'` persistence instance this is just the handle's * in-memory backend, so it's still safe. */ export declare function storageContentCache(storage: Storage): ContentCache; /** Options for {@link createContentResolver}. */ export interface ResolverOptions { /** The pack's `assets` manifest (logical key → source) for `{ asset }` refs. */ assets?: Record; /** Fetches a URL's text. Defaults to the global `fetch`; SSR-safe (throws a clear error if none). */ fetcher?: (url: string) => Promise; /** Cache backend. Defaults to a private in-memory cache. */ cache?: ContentCache; /** Pack id — namespaces cache keys so two packs' `{ asset: 'x' }` never collide. */ packId?: string; } /** A resolver bound to one pack's assets/cache/fetcher. */ export interface ContentResolver { /** Resolve a ref to its text; throws {@link ContentResolveError} on failure. */ resolve(ref: ContentRef): Promise; /** Resolve a ref, returning `null` (and logging) on any failure. */ resolveOrNull(ref: ContentRef): Promise; } /** Thrown by {@link ContentResolver.resolve} when a ref can't be resolved. */ export declare class ContentResolveError extends Error { /** The ref that failed. */ readonly ref: ContentRef; /** The underlying cause, if any. */ readonly cause?: unknown | undefined; constructor(message: string, /** The ref that failed. */ ref: ContentRef, /** The underlying cause, if any. */ cause?: unknown | undefined); } /** * Create a {@link ContentResolver} for a pack's assets. The resolver caches URL * (and resolved-asset) reads so repeated access is cheap, and namespaces cache * keys by `packId` when given. */ export declare function createContentResolver(options?: ResolverOptions): ContentResolver;