/** * Asset Cache Type Definitions * Centralized type definitions for the entire asset cache system */ /** * Asset types that can be cached */ declare enum AssetType { IMAGE = "image", VIDEO = "video", FONT = "font", AUDIO = "audio", OTHER = "other" } /** * Options for asset cache operations */ interface CacheOptions { ttl?: number; revalidate?: boolean; tags?: string[]; priority?: "high" | "medium" | "low"; } /** * Cache entry with metadata */ interface CacheEntry { data: T; timestamp: number; expires?: number; type: AssetType; tags?: string[]; version?: string; } /** * Result of a cache operation */ interface CacheResult { success: boolean; data?: T; fromCache: boolean; error?: Error; } /** * Asset metadata for cache manifest */ interface AssetMetadata { url: string; type: AssetType; version: string; lastModified: string; size?: number; tags?: string[]; } /** * Cache manifest structure */ interface CacheManifest { version: string; generatedAt: string; assets: Record; } /** * Service worker message types */ declare enum ServiceWorkerMessageType { CACHE_ASSET = "CACHE_ASSET", INVALIDATE_ASSET = "INVALIDATE_ASSET", INVALIDATE_TAG = "INVALIDATE_TAG", CLEAR_CACHE = "CLEAR_CACHE", UPDATE_MANIFEST = "UPDATE_MANIFEST", CHECK_ASSET = "CHECK_ASSET" } interface ExtendableEvent extends Event { waitUntil(promise: Promise): void; } interface FetchEvent extends ExtendableEvent { request: Request; respondWith(response: Promise | Response): void; } interface ExtendableMessageEvent extends ExtendableEvent { data: any; source: Client | MessagePort | ServiceWorker | null; } interface ServiceWorkerGlobalScope { caches: CacheStorage; clients: Clients; registration: ServiceWorkerRegistration; location: Location; addEventListener(type: "install", listener: (event: ExtendableEvent) => void): void; addEventListener(type: "activate", listener: (event: ExtendableEvent) => void): void; addEventListener(type: "fetch", listener: (event: FetchEvent) => void): void; addEventListener(type: "message", listener: (event: ExtendableMessageEvent) => void): void; skipWaiting(): Promise; } interface Client { id: string; type: "window" | "worker" | "sharedworker"; url: string; postMessage(message: any, transfer?: Transferable[]): void; } interface Clients { get(id: string): Promise; matchAll(options?: ClientQueryOptions): Promise; openWindow(url: string): Promise; claim(): Promise; } interface ClientQueryOptions { includeUncontrolled?: boolean; type?: "window" | "worker" | "sharedworker" | "all"; } interface WindowClient extends Client { focused: boolean; visibilityState: "hidden" | "visible" | "prerender" | "unloaded"; focus(): Promise; navigate(url: string): Promise; } /** * Asset Cache Configuration Interface * Simplified configuration interface containing only implemented features */ interface AssetCacheConfig { /** Enable or disable the asset cache system */ enabled?: boolean; /** Cache version for invalidation */ version?: string; /** Enable debug logging */ debug?: boolean; /** * Name of the cache storage (used with browser Cache API) * Should be a unique identifier for your application's cache * Examples: "my-app-cache-v1", "storefront-assets", "asset-cache-prod" */ storageName?: string; /** Maximum cache size in MB */ maxSize?: number; /** Maximum age for cached assets in seconds */ maxAge?: number; /** Enable service worker for caching */ serviceWorkerEnabled?: boolean; /** Service worker file path */ serviceWorkerPath?: string; /** Cache manifest file path */ manifestPath?: string; } /** * Asset loader configuration */ interface AssetLoaderConfig { cacheName?: string; defaultTTL?: number; maxSize?: number; enableServiceWorker?: boolean; manifestPath?: string; debug?: boolean; } export { type AssetCacheConfig, type AssetLoaderConfig, type AssetMetadata, AssetType, type CacheEntry, type CacheManifest, type CacheOptions, type CacheResult, type Client, type ClientQueryOptions, type Clients, type ExtendableEvent, type ExtendableMessageEvent, type FetchEvent, type ServiceWorkerGlobalScope, ServiceWorkerMessageType, type WindowClient };