import { default as React, ComponentType, ReactNode } from 'react'; import { FeatureRegistryEntry } from './types'; /** * Preload priority levels */ export type PreloadPriority = 'critical' | 'high' | 'medium' | 'low' | 'idle'; /** * Preload trigger types */ export type PreloadTrigger = 'immediate' | 'hover' | 'visible' | 'idle' | 'route'; /** * Preload configuration for a feature */ export interface PreloadConfig { featureId: string; priority: PreloadPriority; trigger: PreloadTrigger; /** Delay in ms before preloading (for debouncing) */ delay?: number; } /** * Feature chunk metadata */ export interface FeatureChunkInfo { featureId: string; isLoaded: boolean; isLoading: boolean; loadTime?: number; error?: Error; } /** * Lazy component with preload support */ export type PreloadableLazyComponent> = React.LazyExoticComponent & { preload: () => Promise; }; /** * Create a lazy-loaded feature component with preloading support */ export declare function createLazyFeatureComponent>(_featureId: string, importFn: () => Promise<{ default: T; }>): PreloadableLazyComponent; /** * Create a lazy feature component with automatic retry on failure */ export declare function createResilientLazyComponent>(featureId: string, importFn: () => Promise<{ default: T; }>, options?: { maxRetries?: number; retryDelay?: number; onError?: (error: Error, retryCount: number) => void; }): PreloadableLazyComponent; /** * Feature chunk manager for coordinated loading */ export declare class FeatureChunkManager { private loadedFeatures; private loadingFeatures; private featureLoaders; private loadTimes; private errors; private preloadConfigs; /** * Register a feature loader */ registerLoader(featureId: string, loader: () => Promise): void; /** * Register preload configuration for a feature */ configurePreload(config: PreloadConfig): void; /** * Preload a feature */ preload(featureId: string): Promise; /** * Preload multiple features */ preloadAll(featureIds: string[]): Promise; /** * Preload features by priority */ preloadByPriority(priority: PreloadPriority): Promise; /** * Check if a feature is loaded */ isLoaded(featureId: string): boolean; /** * Check if a feature is loading */ isLoading(featureId: string): boolean; /** * Get feature chunk info */ getChunkInfo(featureId: string): FeatureChunkInfo; /** * Get all chunk info */ getAllChunkInfo(): FeatureChunkInfo[]; /** * Preload features during idle time */ preloadOnIdle(featureIds: string[]): void; /** * Preload features with idle priority */ preloadIdlePriorityFeatures(): void; /** * Clear loaded state (useful for testing) */ reset(): void; } /** * Global chunk manager instance */ export declare const featureChunkManager: FeatureChunkManager; /** * Hook for feature preloading on hover/focus */ export declare function useFeaturePreload(featureId: string): { onMouseEnter: () => void; onFocus: () => void; preload: () => void; }; /** * Hook to get feature chunk status */ export declare function useFeatureChunkStatus(featureId: string): FeatureChunkInfo; /** * Hook to preload features when component becomes visible */ export declare function usePreloadOnVisible(featureIds: string[], options?: IntersectionObserverInit): React.RefObject; /** * Props for the feature suspense wrapper */ interface FeatureSuspenseProps { fallback?: ReactNode; errorFallback?: ReactNode | ((error: Error) => ReactNode); } /** * HOC to wrap feature with Suspense and error handling */ export declare function withFeatureSuspense

(WrappedComponent: ComponentType

, options: FeatureSuspenseProps & { featureId: string; }): ComponentType

; /** * Feature route configuration */ export interface FeatureRoute { path: string; featureId: string; preloadOn?: PreloadTrigger; preloadPriority?: PreloadPriority; } /** * Generate routes with automatic code splitting */ export declare function generateSplitRoutes(features: FeatureRegistryEntry[], options?: { preloadStrategy?: 'eager' | 'lazy' | 'idle'; fallback?: ReactNode; }): Array<{ path: string; element: ReactNode; preload?: () => Promise; }>; /** * Initialize preloading based on configured priorities */ export declare function initializeFeaturePreloading(): void; export {};