import { ServiceWorkerMessageType, AssetCacheConfig } from './types.mjs'; export { AssetLoaderConfig, AssetMetadata, AssetType, CacheEntry, CacheManifest, CacheOptions, CacheResult, Client, ClientQueryOptions, Clients, ExtendableEvent, ExtendableMessageEvent, FetchEvent, ServiceWorkerGlobalScope, WindowClient } from './types.mjs'; export { c as CACHE_FIRST_TYPES, C as CACHE_MANIFEST_PATH, D as DEFAULT_CACHE_NAME, a as DEFAULT_CACHE_TTL, b as DEFAULT_SW_SCOPE, F as FILE_EXTENSION_TO_ASSET_TYPE, M as MAX_CACHEABLE_SIZE, N as NETWORK_FIRST_TYPES, S as STALE_WHILE_REVALIDATE_TYPES } from './constants-C8ia8dxn.mjs'; export { createCacheEntry, debugLog, determineAssetType, formatSize, hasExpired, shouldCacheAsset } from './utils/index.mjs'; export { cacheFirstStrategy, cacheFirstWithCacheAPI } from './strategies/index.mjs'; export { l as AssetExpiredError, m as AssetFetchFailedError, o as AssetInvalidResponseError, A as AssetLoader, b as AssetLoaderInitResult, a as AssetLoaderState, k as AssetNotCachedError, n as AssetTooLargeError, f as CacheAPINotSupportedError, e as CacheError, d as CacheErrorCode, C as CacheManager, c as CacheManagerState, g as CacheNotInitializedError, h as CacheOpenFailedError, I as InitResult, M as ManifestNotFoundError, i as ManifestParseError, j as ManifestSaveFailedError, q as ServiceWorkerCommunicationFailedError, S as ServiceWorkerNotSupportedError, p as ServiceWorkerRegistrationFailedError, s as StorageAccessDeniedError, r as StorageQuotaExceededError, t as isQuotaExceededError, u as isStorageAccessDeniedError, w as wrapError } from './asset-loader-BHIQq2h0.mjs'; /** * Utility functions for generating content hashes */ /** * Generate a simple hash from a string * @param str String to hash * @returns Hash string */ declare function generateSimpleHash(str: string): string; /** * Generate a content hash from a Blob or File * @param content Blob or File to hash * @returns Promise resolving to hash string */ declare function generateContentHash(content: Blob): Promise; /** * Generate a version string for a URL * @param url URL to version * @param version Version string * @returns Versioned URL */ declare function addVersionToUrl(url: string, version: string): string; /** * Extract version from a URL * @param url URL with version * @returns Version string or null if not found */ declare function extractVersionFromUrl(url: string): string | null; /** * Generate a cache key from a URL * @param url URL to generate key for * @returns Cache key */ declare function generateCacheKey(url: string): string; /** * Network-first strategy for fetch requests * @param request The request to handle * @param cacheName The name of the cache to use * @param timeoutMs Timeout for network requests in milliseconds * @returns Promise resolving to the response */ declare function networkFirstStrategy(request: Request, cacheName: string, timeoutMs?: number): Promise; /** * Network-first strategy for the Cache API * @param cache The cache object * @param url The URL to fetch * @param fetchOptions Options for the fetch request * @param timeoutMs Timeout for network requests in milliseconds * @returns Promise resolving to the response */ declare function networkFirstWithCacheAPI(cache: Cache, url: string, fetchOptions?: RequestInit, timeoutMs?: number): Promise; /** * Stale-while-revalidate strategy for fetch requests * @param request The request to handle * @param cacheName The name of the cache to use * @returns Promise resolving to the response */ declare function staleWhileRevalidateStrategy(request: Request, cacheName: string): Promise; /** * Stale-while-revalidate strategy for the Cache API * @param cache The cache object * @param url The URL to fetch * @param fetchOptions Options for the fetch request * @returns Promise resolving to the response */ declare function staleWhileRevalidateWithCacheAPI(cache: Cache, url: string, fetchOptions?: RequestInit): Promise; /** * Determine if a cached response is stale based on its age * @param response The cached response * @param staleTimeMs Time in milliseconds after which a response is considered stale * @returns Whether the response is stale */ declare function isResponseStale(response: Response, staleTimeMs?: number): boolean; /** * Version manager class */ declare class VersionManager { private static deploymentId; /** * Initialize the version manager * @param deploymentId Optional deployment ID for versioning */ static init(deploymentId?: string): void; /** * Generate a deployment ID * @returns Deployment ID */ private static generateDeploymentId; /** * Get the current deployment ID * @returns Deployment ID */ static getDeploymentId(): string; /** * Create a versioned URL for an asset * @param url URL of the asset * @param version Optional version string (defaults to deployment ID) * @returns Versioned URL */ static createVersionedUrl(url: string, version?: string): string; /** * Check if an asset needs to be updated * @param url URL of the asset * @param version Current version of the asset * @returns Whether the asset needs to be updated */ static needsUpdate(url: string, version: string): Promise; /** * Update the version of an asset in the cache manifest * @param url URL of the asset * @param version New version of the asset */ static updateVersion(url: string, version: string): Promise; /** * Generate a content-based version for an asset * @param content Asset content * @returns Content hash */ static generateContentVersion(content: Blob | string): Promise; /** * Generate a content hash from a Blob * @param content Blob to hash * @returns Content hash */ private static generateContentHash; /** * Generate a simple hash from a Blob * @param content Blob to hash * @returns Simple hash */ private static generateSimpleHashFromBlob; /** * Check if a URL has a version parameter * @param url URL to check * @returns Whether the URL has a version parameter */ static hasVersion(url: string): boolean; /** * Extract the version from a URL * @param url URL to extract version from * @returns Version string or null if not found */ static getVersionFromUrl(url: string): string | null; /** * Invalidate all assets from a previous deployment * @param previousDeploymentId Previous deployment ID */ static invalidatePreviousDeployment(previousDeploymentId: string): Promise; /** * Get the cache manifest * @returns Cache manifest or null if not available */ private static getManifest; /** * Compare two versions * @param version1 First version * @param version2 Second version * @returns -1 if version1 < version2, 0 if equal, 1 if version1 > version2 */ static compareVersions(version1: string, version2: string): number; } /** * Options for service worker registration */ interface RegisterOptions { scope?: string; updateViaCache?: ServiceWorkerUpdateViaCache; immediate?: boolean; onSuccess?: () => void; onError?: (error: Error) => void; onUpdate?: (registration: ServiceWorkerRegistration) => void; } /** * Register the service worker * @param swPath Path to the service worker file * @param options Registration options * @returns Promise resolving to the service worker registration */ declare function registerServiceWorker(swPath?: string, options?: RegisterOptions): Promise; /** * Send a message to the service worker * @param type Message type * @param payload Message payload * @returns Promise resolving to the response */ declare function sendMessageToSW(type: ServiceWorkerMessageType, payload?: any): Promise; /** * Check if the service worker is active * @returns Whether the service worker is active */ declare function isServiceWorkerActive(): boolean; /** * Unregister all service workers * @returns Promise resolving when all service workers are unregistered */ declare function unregisterAllServiceWorkers(): Promise; /** * Asset Cache Initialization * * Entry point for initializing the asset caching system. * * @module @shopkit/asset-cache */ /** * Initialize the asset caching module * * Sets up the AssetLoader, VersionManager, and optionally registers * a Service Worker for offline asset caching. * * @param config - Asset cache configuration options * @returns Promise that resolves when initialization is complete * * @example * ```typescript * import { initAssetCache } from '@shopkit/asset-cache'; * * // Initialize with default settings * await initAssetCache(); * * // Initialize with custom settings * await initAssetCache({ * enabled: true, * version: '1.0.0', * storageName: 'my-store-assets', * maxSize: 50, // MB * maxAge: 86400, // 24 hours * serviceWorkerEnabled: true, * serviceWorkerPath: '/sw.js', * }); * ``` */ declare function initAssetCache(config?: AssetCacheConfig): Promise; export { AssetCacheConfig, ServiceWorkerMessageType, VersionManager, addVersionToUrl, extractVersionFromUrl, generateCacheKey, generateContentHash, generateSimpleHash, initAssetCache, isResponseStale, isServiceWorkerActive, networkFirstStrategy, networkFirstWithCacheAPI, registerServiceWorker, sendMessageToSW, staleWhileRevalidateStrategy, staleWhileRevalidateWithCacheAPI, unregisterAllServiceWorkers };