@hadyfayed/filament-react-wrapper
Version:
Enterprise React integration for Laravel/Filament - Smart asset loading, 90%+ React-PHP function mapping, no-plugin Filament integration
117 lines • 3.37 kB
TypeScript
/**
* Advanced Code Splitting Service for React Wrapper
* Implements sophisticated strategies beyond basic lazy loading
*/
interface ChunkInfo {
id: string;
name: string;
size: number;
loadTime: number;
dependencies: string[];
priority: ChunkPriority;
lastAccessed: number;
hitCount: number;
}
interface SplitStrategy {
name: string;
condition: (componentName: string, metadata?: any) => boolean;
chunkName: (componentName: string) => string;
preload?: boolean;
priority?: ChunkPriority;
}
interface PrefetchRule {
trigger: string;
prefetch: string[];
delay?: number;
condition?: () => boolean;
}
interface BundleAnalysis {
totalChunks: number;
totalSize: number;
averageLoadTime: number;
cacheHitRate: number;
mostUsedChunks: ChunkInfo[];
leastUsedChunks: ChunkInfo[];
recommendations: BundleRecommendation[];
}
interface BundleRecommendation {
type: 'merge' | 'split' | 'preload' | 'remove';
chunks: string[];
reason: string;
estimatedSavings: number;
}
declare enum ChunkPriority {
CRITICAL = 1,// Load immediately
HIGH = 2,// Preload on idle
MEDIUM = 3,// Load on demand
LOW = 4,// Load on demand with delay
BACKGROUND = 5
}
declare class CodeSplittingService {
private chunks;
private strategies;
private prefetchRules;
private cache;
private loadingQueue;
private maxCacheSize;
private maxConcurrentLoads;
private currentLoads;
constructor();
/**
* Register a custom code splitting strategy
*/
registerStrategy(strategy: SplitStrategy): void;
/**
* Add prefetch rules for predictive loading
*/
addPrefetchRule(rule: PrefetchRule): void;
/**
* Smart component loading with strategy selection
*/
loadComponent(componentName: string, metadata?: any, forceStrategy?: string): Promise<any>;
/**
* Preload components based on priority
*/
preloadComponents(components: string[], priority?: ChunkPriority): void;
/**
* Get bundle analysis and recommendations
*/
analyzeBundles(): BundleAnalysis;
/**
* Clear cache and reset statistics
*/
clearCache(): void;
/**
* Get chunk information
*/
getChunkInfo(componentName?: string): ChunkInfo | ChunkInfo[] | null;
private initializeDefaultStrategies;
private selectStrategy;
private executeStrategy;
private executePrefetchRules;
private processLoadingQueue;
private updateChunkStats;
private manageCacheSize;
private setupIdleCallback;
private setupIntersectionObserver;
private generateRecommendations;
private isFeatureComponent;
private extractFeatureName;
private isVendorComponent;
private extractVendorName;
private isLargeComponent;
private isCriticalComponent;
/**
* Preload component for better performance
*/
preloadComponent(componentName: string): Promise<void>;
/**
* Check if component is loaded
*/
isLoaded(componentName: string): boolean;
}
export declare const codeSplittingService: CodeSplittingService;
export type { ChunkInfo, SplitStrategy, PrefetchRule, BundleAnalysis, BundleRecommendation };
export { ChunkPriority };
export default codeSplittingService;
//# sourceMappingURL=CodeSplittingService.d.ts.map