{"version":3,"file":"codeSplitting.mjs","sources":["../../../src/lib/feature/codeSplitting.tsx"],"sourcesContent":["/**\n * @file Feature Code Splitting\n * @description Advanced code splitting utilities for features with preloading support\n */\n\nimport React, {\n  Suspense,\n  type ComponentType,\n  lazy,\n  useState,\n  useEffect,\n  useCallback,\n  type ReactNode,\n} from 'react';\nimport type { FeatureRegistryEntry } from './types';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Preload priority levels\n */\nexport type PreloadPriority = 'critical' | 'high' | 'medium' | 'low' | 'idle';\n\n/**\n * Preload trigger types\n */\nexport type PreloadTrigger = 'immediate' | 'hover' | 'visible' | 'idle' | 'route';\n\n/**\n * Preload configuration for a feature\n */\nexport interface PreloadConfig {\n  featureId: string;\n  priority: PreloadPriority;\n  trigger: PreloadTrigger;\n  /** Delay in ms before preloading (for debouncing) */\n  delay?: number;\n}\n\n/**\n * Feature chunk metadata\n */\nexport interface FeatureChunkInfo {\n  featureId: string;\n  isLoaded: boolean;\n  isLoading: boolean;\n  loadTime?: number;\n  error?: Error;\n}\n\n/**\n * Lazy component with preload support\n */\nexport type PreloadableLazyComponent<T extends ComponentType<unknown>> =\n  React.LazyExoticComponent<T> & {\n    preload: () => Promise<void>;\n  };\n\n// ============================================================================\n// Lazy Component Factory\n// ============================================================================\n\n/**\n * Create a lazy-loaded feature component with preloading support\n */\nexport function createLazyFeatureComponent<T extends ComponentType<unknown>>(\n  _featureId: string,\n  importFn: () => Promise<{ default: T }>\n): PreloadableLazyComponent<T> {\n  let loadPromise: Promise<{ default: T }> | null = null;\n  let hasLoaded = false;\n\n  const load = async (): Promise<{ default: T }> => {\n    loadPromise ??= importFn().then((module) => {\n      hasLoaded = true;\n      return module;\n    });\n    return loadPromise;\n  };\n\n  const LazyComponent = lazy(load) as PreloadableLazyComponent<T>;\n\n  // Add preload method\n  LazyComponent.preload = async (): Promise<void> => {\n    if (hasLoaded) return;\n    await load();\n  };\n\n  return LazyComponent;\n}\n\n/**\n * Create a lazy feature component with automatic retry on failure\n */\nexport function createResilientLazyComponent<T extends ComponentType<unknown>>(\n  featureId: string,\n  importFn: () => Promise<{ default: T }>,\n  options: {\n    maxRetries?: number;\n    retryDelay?: number;\n    onError?: (error: Error, retryCount: number) => void;\n  } = {}\n): PreloadableLazyComponent<T> {\n  const { maxRetries = 3, retryDelay = 1000, onError } = options;\n\n  const loadWithRetry = async (): Promise<{ default: T }> => {\n    let lastError: Error = new Error('Unknown error');\n\n    for (let attempt = 0; attempt <= maxRetries; attempt++) {\n      try {\n        return await importFn();\n      } catch (error) {\n        lastError = error instanceof Error ? error : new Error(String(error));\n        onError?.(lastError, attempt);\n\n        if (attempt < maxRetries) {\n          await new Promise((resolve) => setTimeout(resolve, retryDelay * Math.pow(2, attempt)));\n        }\n      }\n    }\n\n    throw new Error(lastError.message, { cause: lastError });\n  };\n\n  return createLazyFeatureComponent(featureId, loadWithRetry);\n}\n\n// ============================================================================\n// Feature Chunk Manager\n// ============================================================================\n\n/**\n * Feature chunk manager for coordinated loading\n */\nexport class FeatureChunkManager {\n  private loadedFeatures = new Set<string>();\n  private loadingFeatures = new Map<string, Promise<void>>();\n  private featureLoaders = new Map<string, () => Promise<void>>();\n  private loadTimes = new Map<string, number>();\n  private errors = new Map<string, Error>();\n  private preloadConfigs = new Map<string, PreloadConfig>();\n\n  /**\n   * Register a feature loader\n   */\n  registerLoader(featureId: string, loader: () => Promise<void>): void {\n    this.featureLoaders.set(featureId, loader);\n  }\n\n  /**\n   * Register preload configuration for a feature\n   */\n  configurePreload(config: PreloadConfig): void {\n    this.preloadConfigs.set(config.featureId, config);\n  }\n\n  /**\n   * Preload a feature\n   */\n  async preload(featureId: string): Promise<void> {\n    if (this.loadedFeatures.has(featureId)) {\n      return;\n    }\n\n    if (this.loadingFeatures.has(featureId)) {\n      return this.loadingFeatures.get(featureId);\n    }\n\n    const loader = this.featureLoaders.get(featureId);\n    if (!loader) {\n      console.warn(`[FeatureChunkManager] No loader registered for: ${featureId}`);\n      return;\n    }\n\n    const startTime = performance.now();\n\n    const loadPromise = loader()\n      .then(() => {\n        this.loadedFeatures.add(featureId);\n        this.loadTimes.set(featureId, performance.now() - startTime);\n        this.loadingFeatures.delete(featureId);\n        this.errors.delete(featureId);\n      })\n      .catch((error) => {\n        this.errors.set(featureId, error instanceof Error ? error : new Error(String(error)));\n        this.loadingFeatures.delete(featureId);\n        throw error;\n      });\n\n    this.loadingFeatures.set(featureId, loadPromise);\n    return loadPromise;\n  }\n\n  /**\n   * Preload multiple features\n   */\n  async preloadAll(featureIds: string[]): Promise<void> {\n    await Promise.all(featureIds.map(async (id) => this.preload(id)));\n  }\n\n  /**\n   * Preload features by priority\n   */\n  async preloadByPriority(priority: PreloadPriority): Promise<void> {\n    const configs = Array.from(this.preloadConfigs.values()).filter(\n      (config) => config.priority === priority\n    );\n    await this.preloadAll(configs.map((c) => c.featureId));\n  }\n\n  /**\n   * Check if a feature is loaded\n   */\n  isLoaded(featureId: string): boolean {\n    return this.loadedFeatures.has(featureId);\n  }\n\n  /**\n   * Check if a feature is loading\n   */\n  isLoading(featureId: string): boolean {\n    return this.loadingFeatures.has(featureId);\n  }\n\n  /**\n   * Get feature chunk info\n   */\n  getChunkInfo(featureId: string): FeatureChunkInfo {\n    return {\n      featureId,\n      isLoaded: this.loadedFeatures.has(featureId),\n      isLoading: this.loadingFeatures.has(featureId),\n      loadTime: this.loadTimes.get(featureId),\n      error: this.errors.get(featureId),\n    };\n  }\n\n  /**\n   * Get all chunk info\n   */\n  getAllChunkInfo(): FeatureChunkInfo[] {\n    const allFeatureIds = new Set([\n      ...this.featureLoaders.keys(),\n      ...this.loadedFeatures,\n      ...this.loadingFeatures.keys(),\n    ]);\n\n    return Array.from(allFeatureIds).map((id) => this.getChunkInfo(id));\n  }\n\n  /**\n   * Preload features during idle time\n   */\n  preloadOnIdle(featureIds: string[]): void {\n    if ('requestIdleCallback' in window) {\n      (\n        window as Window & { requestIdleCallback: (cb: IdleRequestCallback) => number }\n      ).requestIdleCallback(\n        () => {\n          void this.preloadAll(featureIds);\n        },\n        { timeout: 5000 }\n      );\n    } else {\n      // Fallback for browsers without requestIdleCallback\n      setTimeout(() => {\n        void this.preloadAll(featureIds);\n      }, 1000);\n    }\n  }\n\n  /**\n   * Preload features with idle priority\n   */\n  preloadIdlePriorityFeatures(): void {\n    const idleFeatures = Array.from(this.preloadConfigs.values())\n      .filter((config) => config.trigger === 'idle' || config.priority === 'idle')\n      .map((config) => config.featureId);\n\n    this.preloadOnIdle(idleFeatures);\n  }\n\n  /**\n   * Clear loaded state (useful for testing)\n   */\n  reset(): void {\n    this.loadedFeatures.clear();\n    this.loadingFeatures.clear();\n    this.loadTimes.clear();\n    this.errors.clear();\n  }\n}\n\n/**\n * Global chunk manager instance\n */\nexport const featureChunkManager = new FeatureChunkManager();\n\n// ============================================================================\n// React Hooks\n// ============================================================================\n\n/**\n * Hook for feature preloading on hover/focus\n */\nexport function useFeaturePreload(featureId: string): {\n  onMouseEnter: () => void;\n  onFocus: () => void;\n  preload: () => void;\n} {\n  const preload = useCallback(() => {\n    void featureChunkManager.preload(featureId);\n  }, [featureId]);\n\n  return {\n    onMouseEnter: preload,\n    onFocus: preload,\n    preload,\n  };\n}\n\n/**\n * Hook to get feature chunk status\n */\nexport function useFeatureChunkStatus(featureId: string): FeatureChunkInfo {\n  const [info, setInfo] = useState<FeatureChunkInfo>(() =>\n    featureChunkManager.getChunkInfo(featureId)\n  );\n\n  useEffect(() => {\n    // Update status when chunk manager changes\n    const interval = setInterval(() => {\n      const newInfo = featureChunkManager.getChunkInfo(featureId);\n      if (newInfo.isLoaded !== info.isLoaded || newInfo.isLoading !== info.isLoading) {\n        setInfo(newInfo);\n      }\n    }, 100);\n\n    return () => clearInterval(interval);\n  }, [featureId, info.isLoaded, info.isLoading]);\n\n  return info;\n}\n\n/**\n * Hook to preload features when component becomes visible\n */\nexport function usePreloadOnVisible(\n  featureIds: string[],\n  options: IntersectionObserverInit = {}\n): React.RefObject<HTMLDivElement | null> {\n  const ref = React.useRef<HTMLDivElement | null>(null);\n  const [hasPreloaded, setHasPreloaded] = useState(false);\n\n  useEffect(() => {\n    if (hasPreloaded || !ref.current) return;\n\n    const observer = new IntersectionObserver(\n      ([entry]) => {\n        if (entry && entry.isIntersecting && !hasPreloaded) {\n          void featureChunkManager.preloadAll(featureIds);\n          setHasPreloaded(true);\n          observer.disconnect();\n        }\n      },\n      { threshold: 0.1, ...options }\n    );\n\n    observer.observe(ref.current);\n\n    return () => observer.disconnect();\n  }, [featureIds, hasPreloaded, options]);\n\n  return ref;\n}\n\n// ============================================================================\n// Higher-Order Components\n// ============================================================================\n\n/**\n * Props for the feature suspense wrapper\n */\ninterface FeatureSuspenseProps {\n  fallback?: ReactNode;\n  errorFallback?: ReactNode | ((error: Error) => ReactNode);\n}\n\n/**\n * HOC to wrap feature with Suspense and error handling\n */\nexport function withFeatureSuspense<P extends object>(\n  WrappedComponent: ComponentType<P>,\n  options: FeatureSuspenseProps & { featureId: string }\n): ComponentType<P> {\n  const { fallback = <div>Loading...</div>, featureId } = options;\n\n  function FeatureWithSuspense(props: P): React.JSX.Element {\n    return (\n      <Suspense fallback={fallback}>\n        <WrappedComponent {...props} />\n      </Suspense>\n    );\n  }\n\n  FeatureWithSuspense.displayName = `FeatureSuspense(${featureId})`;\n\n  return FeatureWithSuspense;\n}\n\n// ============================================================================\n// Route Integration\n// ============================================================================\n\n/**\n * Feature route configuration\n */\nexport interface FeatureRoute {\n  path: string;\n  featureId: string;\n  preloadOn?: PreloadTrigger;\n  preloadPriority?: PreloadPriority;\n}\n\n/**\n * Generate routes with automatic code splitting\n */\nexport function generateSplitRoutes(\n  features: FeatureRegistryEntry[],\n  options: {\n    preloadStrategy?: 'eager' | 'lazy' | 'idle';\n    fallback?: ReactNode;\n  } = {}\n): Array<{\n  path: string;\n  element: ReactNode;\n  preload?: () => Promise<void>;\n}> {\n  const { preloadStrategy = 'lazy', fallback = null } = options;\n\n  return features.map((feature) => {\n    const { config, component: Component } = feature;\n    const { preload } = Component as unknown as { preload?: () => Promise<void> };\n\n    // Register loader with chunk manager\n    if (preload) {\n      featureChunkManager.registerLoader(config.metadata.id, preload);\n\n      // Configure preload based on strategy\n      if (preloadStrategy !== 'lazy') {\n        featureChunkManager.configurePreload({\n          featureId: config.metadata.id,\n          priority: preloadStrategy === 'eager' ? 'high' : 'idle',\n          trigger: preloadStrategy === 'eager' ? 'immediate' : 'idle',\n        });\n      }\n    }\n\n    return {\n      path: config.metadata.id,\n      element: (\n        <Suspense fallback={config.loadingFallback ?? fallback}>\n          <Component />\n        </Suspense>\n      ),\n      preload,\n    };\n  });\n}\n\n// ============================================================================\n// Preload Initialization\n// ============================================================================\n\n/**\n * Initialize preloading based on configured priorities\n */\nexport function initializeFeaturePreloading(): void {\n  // Preload critical features immediately\n  void featureChunkManager.preloadByPriority('critical');\n\n  // Preload high priority features after initial render\n  requestAnimationFrame(() => {\n    void featureChunkManager.preloadByPriority('high');\n  });\n\n  // Preload idle features during idle time\n  featureChunkManager.preloadIdlePriorityFeatures();\n}\n"],"names":["createLazyFeatureComponent","_featureId","importFn","loadPromise","hasLoaded","load","module","LazyComponent","lazy","createResilientLazyComponent","featureId","options","maxRetries","retryDelay","onError","lastError","attempt","error","resolve","FeatureChunkManager","loader","config","startTime","featureIds","id","priority","configs","c","allFeatureIds","idleFeatures","featureChunkManager","useFeaturePreload","preload","useCallback","useFeatureChunkStatus","info","setInfo","useState","useEffect","interval","newInfo","usePreloadOnVisible","ref","React","hasPreloaded","setHasPreloaded","observer","entry","withFeatureSuspense","WrappedComponent","fallback","jsx","FeatureWithSuspense","props","Suspense","generateSplitRoutes","features","preloadStrategy","feature","Component","initializeFeaturePreloading"],"mappings":";;AAmEO,SAASA,EACdC,GACAC,GAC6B;AAC7B,MAAIC,IAA8C,MAC9CC,IAAY;AAEhB,QAAMC,IAAO,aACXF,MAAgBD,EAAA,EAAW,KAAK,CAACI,OAC/BF,IAAY,IACLE,EACR,GACMH,IAGHI,IAAgBC,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