/** * WidgetCacheManager — In-memory cache with IndexedDB persistence for widget data. * * Architecture: * - **Reads** are synchronous from in-memory Maps (fastest possible lookup). * - **Writes** update the in-memory Map immediately, then persist to IndexedDB * in the background (fire-and-forget) so data survives page reloads. * - **On startup**, `init()` loads all persisted data from IndexedDB into the Maps. * * This gives us the speed of in-memory access (no async overhead, no JSON.parse) * with the durability of IndexedDB (no 5 MB limit, survives reloads). * * Three separate caches are maintained: * - **widgetMap** — standard widget data keyed by widget ID * - **latestMap** — latest published version keyed by origin ID * - **recentMap** — recent published version keyed by origin ID */ export declare class WidgetCacheManager { /** In-memory cache for standard widget data */ private static widgetMap; /** In-memory cache for latest-version widget data */ private static latestMap; /** In-memory cache for recent-version widget data */ private static recentMap; /** * Loads all persisted widget cache data from IndexedDB into memory. * Called automatically during `init()` / `initConceptConnection()`. * Safe to call multiple times — just overwrites the Maps. * * Skips entirely when `Environments.getValue('enableCache', true)` is `false`, * keeping all three maps empty so no stale data is ever served. */ static init(): Promise; /** * Retrieves cached widget data by widget ID (synchronous, from memory). * Returns `null` when cache is disabled via `Environments.setValue('enableCache', false)`, * causing `BuildWidgetFromId` to always fetch fresh from the backend. * @param id - The widget ID to look up * @returns The cached data object, or null if not cached or cache is disabled */ static getWidget(id: number): any | null; /** * Stores widget data in memory and persists to IndexedDB in the background. * No-ops when cache is disabled via `Environments.setValue('enableCache', false)`. * Skips if data is identical to what's already cached (dedup guard). * @param id - The widget ID * @param data - The widget data object to cache */ static setWidget(id: number, data: any): void; /** * Removes a single widget entry from memory and IndexedDB. * @param id - The widget ID to remove */ static removeWidget(id: number): void; /** * Retrieves cached latest-version widget data (synchronous, from memory). * Returns `null` when cache is disabled, causing a live backend fetch. * @param id - The origin widget ID * @returns The cached data object, or null if not cached or cache is disabled */ static getLatest(id: number): any | null; /** * Stores latest-version widget data in memory and persists to IndexedDB. * No-ops when cache is disabled. Skips if data is identical to what's already cached. * @param id - The origin widget ID * @param data - The latest widget data to cache */ static setLatest(id: number, data: any): void; /** * Removes a single latest-version entry from memory and IndexedDB. * @param id - The origin widget ID to remove */ static removeLatest(id: number): void; /** * Retrieves cached recent-version widget data (synchronous, from memory). * Returns `null` when cache is disabled, causing a live backend fetch. * @param id - The origin widget ID * @returns The cached data object, or null if not cached or cache is disabled */ static getRecent(id: number): any | null; /** * Stores recent-version widget data in memory and persists to IndexedDB. * No-ops when cache is disabled. Skips if data is identical to what's already cached. * @param id - The origin widget ID * @param data - The recent widget data to cache */ static setRecent(id: number, data: any): void; /** * Removes a single recent-version entry from memory and IndexedDB. * @param id - The origin widget ID to remove */ static removeRecent(id: number): void; /** * Clears all three widget caches from both memory and IndexedDB. * Useful for cache invalidation on logout or environment switch. */ static clearAll(): void; /** * Checks if the new data is identical to what's already in the Map. * Prevents unnecessary IndexedDB writes when data hasn't changed. * * @param map - The in-memory Map to check against * @param id - The key to check * @param data - The new data to compare * @returns true if data is a duplicate (should be skipped) */ private static _isDuplicate; }