{"version":3,"sources":["../../src/config/constants.ts","../../src/config/defaults.ts","../../src/config/types.ts","../../src/config/config.ts","../../src/config/index.ts"],"names":["AssetType","ServiceWorkerMessageType","getDefaultAssetCacheConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAYa,oBAMA,iBAAA,CAAA,CAMA,kBAAA,CAAA,CAKA,qBASA,gBAAA,CAAA,CAUA,iBAAA,CAAA,CAgBA,qBAWA,4BAAA,CAAA,CAcA;AAzFb,IAAA,cAAA,GAAA,KAAA,CAAA;AAAA,EAAA,yBAAA,GAAA;AAYO,IAAM,kBAAA,GAAqB,gBAAA;AAM3B,IAAM,iBAAA,GAAoB,CAAA,GAAI,EAAA,GAAK,EAAA,GAAK,EAAA;AAMxC,IAAM,kBAAA,GAAqB,KAAK,IAAA,GAAO,IAAA;AAKvC,IAAM,mBAAA,GAAsB,gBAAA;AAS5B,IAAM,gBAAA,GAAmB,GAAA;AAUzB,IAAM,iBAAA,GAAoB;AAAA,MAC/B,YAAA;AAAA,MACA,WAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAA;AAAA,MACA,eAAA;AAAA,MACA,WAAA;AAAA,MACA,YAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF;AAMO,IAAM,mBAAA,GAAsB;AAAA,MACjC,WAAA;AAAA,MACA,YAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACF;AAMO,IAAM,4BAAA,GAA+B;AAAA,MAC1C,wBAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF;AAUO,IAAM,4BAAA,GAAuD;AAAA;AAAA,MAElE,GAAA,EAAK,YAAA;AAAA,MACL,IAAA,EAAM,YAAA;AAAA,MACN,GAAA,EAAK,WAAA;AAAA,MACL,GAAA,EAAK,WAAA;AAAA,MACL,IAAA,EAAM,YAAA;AAAA,MACN,GAAA,EAAK,eAAA;AAAA,MACL,GAAA,EAAK,cAAA;AAAA,MACL,IAAA,EAAM,YAAA;AAAA,MACN,GAAA,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AAG;AACvD,IAAA,MAAM,IAAI,MAAM,gCAAgC,CAAA;AAAA,EAClD;AAEA,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,MAAA,IAAa,MAAA,CAAO,UAAU,CAAA,EAAG;AACrD,IAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAAA,EACjD;AACF;;;ACvBA,aAAA,EAAA;AAMA,cAAA,EAAA;AA+BA,aAAA,EAAA","file":"index.mjs","sourcesContent":["/**\n * Constants for the asset caching module\n * This file contains all constant values used throughout the asset cache system\n */\n\n// ============================================================================\n// CACHE CONFIGURATION CONSTANTS\n// ============================================================================\n\n/**\n * Default cache name for the Cache Storage API\n */\nexport const DEFAULT_CACHE_NAME = \"asset-cache-v1\";\n\n/**\n * Default time to live for cached assets (in seconds)\n * 7 days\n */\nexport const DEFAULT_CACHE_TTL = 7 * 24 * 60 * 60;\n\n/**\n * Maximum size for cacheable assets (in bytes)\n * 50MB\n */\nexport const MAX_CACHEABLE_SIZE = 50 * 1024 * 1024;\n\n/**\n * Path to the cache manifest file\n */\nexport const CACHE_MANIFEST_PATH = \"/manifest.json\";\n\n// ============================================================================\n// SERVICE WORKER CONSTANTS\n// ============================================================================\n\n/**\n * Default service worker scope\n */\nexport const DEFAULT_SW_SCOPE = \"/\";\n\n// ============================================================================\n// CACHE STRATEGY MAPPINGS\n// ============================================================================\n\n/**\n * Asset types that should use a cache-first strategy\n * These are typically static assets that don't change frequently\n */\nexport const CACHE_FIRST_TYPES = [\n  \"image/jpeg\",\n  \"image/png\",\n  \"image/webp\",\n  \"image/gif\",\n  \"image/svg+xml\",\n  \"font/woff\",\n  \"font/woff2\",\n  \"font/ttf\",\n  \"font/otf\",\n];\n\n/**\n * Asset types that should use a network-first strategy\n * These are typically large media files that benefit from fresh content\n */\nexport const NETWORK_FIRST_TYPES = [\n  \"video/mp4\",\n  \"video/webm\",\n  \"audio/mpeg\",\n  \"audio/ogg\",\n];\n\n/**\n * Asset types that should use a stale-while-revalidate strategy\n * These are assets that can be served stale while being updated in background\n */\nexport const STALE_WHILE_REVALIDATE_TYPES = [\n  \"application/javascript\",\n  \"text/css\",\n  \"application/json\",\n];\n\n// ============================================================================\n// FILE TYPE MAPPINGS\n// ============================================================================\n\n/**\n * File extensions to MIME type mapping\n * Used to determine the correct content type for cached assets\n */\nexport const FILE_EXTENSION_TO_ASSET_TYPE: Record<string, string> = {\n  // Images\n  jpg: \"image/jpeg\",\n  jpeg: \"image/jpeg\",\n  png: \"image/png\",\n  gif: \"image/gif\",\n  webp: \"image/webp\",\n  svg: \"image/svg+xml\",\n  ico: \"image/x-icon\",\n  avif: \"image/avif\",\n  bmp: \"image/bmp\",\n\n  // Fonts\n  woff: \"font/woff\",\n  woff2: \"font/woff2\",\n  ttf: \"font/ttf\",\n  otf: \"font/otf\",\n  eot: \"application/vnd.ms-fontobject\",\n\n  // Videos\n  mp4: \"video/mp4\",\n  webm: \"video/webm\",\n  ogg: \"video/ogg\",\n  avi: \"video/x-msvideo\",\n  mov: \"video/quicktime\",\n\n  // Audio\n  mp3: \"audio/mpeg\",\n  wav: \"audio/wav\",\n  oga: \"audio/ogg\",\n  flac: \"audio/flac\",\n  aac: \"audio/aac\",\n\n  // Scripts and Styles\n  js: \"application/javascript\",\n  mjs: \"application/javascript\",\n  css: \"text/css\",\n  json: \"application/json\",\n\n  // Documents\n  pdf: \"application/pdf\",\n  txt: \"text/plain\",\n  html: \"text/html\",\n  xml: \"application/xml\",\n};\n","/**\n * Asset Cache Default Configuration\n * This file contains default configuration values for the simplified asset cache system\n */\n\nimport {\n  DEFAULT_CACHE_NAME,\n  DEFAULT_CACHE_TTL,\n  MAX_CACHEABLE_SIZE,\n} from \"./constants\";\nimport type { AssetCacheConfig } from \"./types\";\n\n// ============================================================================\n// DEFAULT CONFIGURATION VALUES\n// ============================================================================\n\n/**\n * Get default asset cache configuration\n * This provides sensible defaults for all implemented configuration options\n */\nexport function getDefaultAssetCacheConfig(): Required<AssetCacheConfig> {\n  return {\n    enabled: true,\n    version: \"1.0.0\",\n    debug: false,\n    storageName: DEFAULT_CACHE_NAME,\n    maxSize: MAX_CACHEABLE_SIZE, // 50 MB\n    maxAge: DEFAULT_CACHE_TTL, // 7 days\n    serviceWorkerEnabled: true,\n    serviceWorkerPath: \"/sw.js\",\n    manifestPath: \"/manifest.json\",\n  };\n}\n","/**\n * Asset Cache Type Definitions\n * Centralized type definitions for the entire asset cache system\n */\n\n// ============================================================================\n// CORE ASSET TYPES\n// ============================================================================\n\n/**\n * Asset types that can be cached\n */\nexport enum AssetType {\n  IMAGE = \"image\",\n  VIDEO = \"video\",\n  FONT = \"font\",\n  AUDIO = \"audio\",\n  OTHER = \"other\",\n}\n\n// ============================================================================\n// CACHE OPERATION TYPES\n// ============================================================================\n\n/**\n * Options for asset cache operations\n */\nexport interface CacheOptions {\n  ttl?: number; // Time to live in seconds\n  revalidate?: boolean; // Whether to revalidate on access\n  tags?: string[]; // Cache tags for invalidation\n  priority?: \"high\" | \"medium\" | \"low\"; // Priority for preloading\n}\n\n/**\n * Cache entry with metadata\n */\nexport interface CacheEntry<T> {\n  data: T;\n  timestamp: number;\n  expires?: number;\n  type: AssetType;\n  tags?: string[];\n  version?: string;\n}\n\n/**\n * Result of a cache operation\n */\nexport interface CacheResult<T> {\n  success: boolean;\n  data?: T;\n  fromCache: boolean;\n  error?: Error;\n}\n\n/**\n * Asset metadata for cache manifest\n */\nexport interface AssetMetadata {\n  url: string;\n  type: AssetType;\n  version: string;\n  lastModified: string;\n  size?: number;\n  tags?: string[];\n}\n\n/**\n * Cache manifest structure\n */\nexport interface CacheManifest {\n  version: string;\n  generatedAt: string;\n  assets: Record<string, AssetMetadata>;\n}\n\n// ============================================================================\n// SERVICE WORKER TYPES\n// ============================================================================\n\n/**\n * Service worker message types\n */\nexport enum ServiceWorkerMessageType {\n  CACHE_ASSET = \"CACHE_ASSET\",\n  INVALIDATE_ASSET = \"INVALIDATE_ASSET\",\n  INVALIDATE_TAG = \"INVALIDATE_TAG\",\n  CLEAR_CACHE = \"CLEAR_CACHE\",\n  UPDATE_MANIFEST = \"UPDATE_MANIFEST\",\n  CHECK_ASSET = \"CHECK_ASSET\",\n}\n\n// Service Worker Global Scope Types (simplified to avoid DOM conflicts)\nexport interface ExtendableEvent extends Event {\n  waitUntil(promise: Promise<any>): void;\n}\n\nexport interface FetchEvent extends ExtendableEvent {\n  request: Request;\n  respondWith(response: Promise<Response> | Response): void;\n}\n\nexport interface ExtendableMessageEvent extends ExtendableEvent {\n  data: any;\n  source: Client | MessagePort | ServiceWorker | null;\n}\n\nexport interface ServiceWorkerGlobalScope {\n  caches: CacheStorage;\n  clients: Clients;\n  registration: ServiceWorkerRegistration;\n  location: Location;\n  addEventListener(\n    type: \"install\",\n    listener: (event: ExtendableEvent) => void\n  ): void;\n  addEventListener(\n    type: \"activate\",\n    listener: (event: ExtendableEvent) => void\n  ): void;\n  addEventListener(type: \"fetch\", listener: (event: FetchEvent) => void): void;\n  addEventListener(\n    type: \"message\",\n    listener: (event: ExtendableMessageEvent) => void\n  ): void;\n  skipWaiting(): Promise<void>;\n}\n\nexport interface Client {\n  id: string;\n  type: \"window\" | \"worker\" | \"sharedworker\";\n  url: string;\n  postMessage(message: any, transfer?: Transferable[]): void;\n}\n\nexport interface Clients {\n  get(id: string): Promise<Client | undefined>;\n  matchAll(options?: ClientQueryOptions): Promise<Client[]>;\n  openWindow(url: string): Promise<WindowClient | null>;\n  claim(): Promise<void>;\n}\n\nexport interface ClientQueryOptions {\n  includeUncontrolled?: boolean;\n  type?: \"window\" | \"worker\" | \"sharedworker\" | \"all\";\n}\n\nexport interface WindowClient extends Client {\n  focused: boolean;\n  visibilityState: \"hidden\" | \"visible\" | \"prerender\" | \"unloaded\";\n  focus(): Promise<WindowClient>;\n  navigate(url: string): Promise<WindowClient | null>;\n}\n\n// ============================================================================\n// CONFIGURATION TYPES\n// ============================================================================\n\n/**\n * Asset Cache Configuration Interface\n * Simplified configuration interface containing only implemented features\n */\nexport interface AssetCacheConfig {\n  /** Enable or disable the asset cache system */\n  enabled?: boolean;\n  /** Cache version for invalidation */\n  version?: string;\n  /** Enable debug logging */\n  debug?: boolean;\n  /**\n   * Name of the cache storage (used with browser Cache API)\n   * Should be a unique identifier for your application's cache\n   * Examples: \"my-app-cache-v1\", \"storefront-assets\", \"asset-cache-prod\"\n   */\n  storageName?: string;\n  /** Maximum cache size in MB */\n  maxSize?: number;\n  /** Maximum age for cached assets in seconds */\n  maxAge?: number;\n  /** Enable service worker for caching */\n  serviceWorkerEnabled?: boolean;\n  /** Service worker file path */\n  serviceWorkerPath?: string;\n  /** Cache manifest file path */\n  manifestPath?: string;\n}\n\n/**\n * Asset loader configuration\n */\nexport interface AssetLoaderConfig {\n  cacheName?: string;\n  defaultTTL?: number;\n  maxSize?: number; // Maximum size in bytes for cacheable assets\n  enableServiceWorker?: boolean;\n  manifestPath?: string;\n  debug?: boolean;\n}\n","/**\n * Asset Cache Configuration\n * This file contains configuration utility functions\n */\n\nimport type { AssetCacheConfig } from \"./types\";\n\n// ============================================================================\n// CONFIGURATION UTILITY FUNCTIONS\n// ============================================================================\n\n/**\n * Merge user configuration with defaults\n * Simple merge of user-provided configuration with default values\n */\nexport function mergeAssetCacheConfig(\n  userConfig: AssetCacheConfig = {}\n): Required<AssetCacheConfig> {\n  // Validate user configuration first\n  validateAssetCacheConfig(userConfig);\n\n  // Import defaults here to avoid circular dependency\n  const { getDefaultAssetCacheConfig } = require(\"./defaults\");\n  const defaults = getDefaultAssetCacheConfig();\n\n  return {\n    ...defaults,\n    ...userConfig,\n  };\n}\n\n/**\n * Validate asset cache configuration\n * Validates user-provided configuration and throws errors for invalid values\n */\nexport function validateAssetCacheConfig(config: AssetCacheConfig): void {\n  // Validate numeric values\n  if (config.maxSize !== undefined && config.maxSize <= 0) {\n    throw new Error(\"maxSize must be greater than 0\");\n  }\n\n  if (config.maxAge !== undefined && config.maxAge <= 0) {\n    throw new Error(\"maxAge must be greater than 0\");\n  }\n}\n","/**\n * Asset Cache Configuration Module\n * Centralized exports for all configuration-related functionality\n */\n\n// ============================================================================\n// TYPE DEFINITIONS\n// ============================================================================\n\nexport * from \"./types\";\n\n// ============================================================================\n// CONFIGURATION INTERFACES AND FUNCTIONS\n// ============================================================================\n\nexport * from \"./config\";\n\n// ============================================================================\n// DEFAULT CONFIGURATIONS AND PRESETS\n// ============================================================================\n\nexport * from \"./defaults\";\n\n// ============================================================================\n// CONSTANTS AND MAPPINGS\n// ============================================================================\n\nexport * from \"./constants\";\n\n// ============================================================================\n// EXPLICIT TYPE EXPORTS (for better IDE support)\n// ============================================================================\n\nexport type {\n  AssetCacheConfig,\n  // Core types\n  AssetType,\n\n  // Cache operation types\n  CacheOptions,\n  CacheEntry,\n  CacheResult,\n  AssetMetadata,\n  CacheManifest,\n\n  // Service worker types\n  ServiceWorkerMessageType,\n\n  // Asset loader configuration\n  AssetLoaderConfig,\n} from \"./types\";\n\n// ============================================================================\n// UTILITY FUNCTIONS\n// ============================================================================\n\nexport { mergeAssetCacheConfig, validateAssetCacheConfig } from \"./config\";\n\nexport { getDefaultAssetCacheConfig } from \"./defaults\";\n"]}