import { PrefetchQueue, PrefetchPriority } from './prefetch-queue'; /** * Asset type */ export type AssetType = 'image' | 'font' | 'script' | 'style' | 'video' | 'audio' | 'document'; /** * Asset definition */ export interface Asset { url: string; type: AssetType; priority?: PrefetchPriority; crossOrigin?: 'anonymous' | 'use-credentials'; as?: string; media?: string; sizes?: string; srcset?: string; } /** * Image asset with responsive support */ export interface ResponsiveImage { src: string; srcset?: Array<{ url: string; width: number; }>; sizes?: string; alt?: string; priority?: PrefetchPriority; } /** * Font asset configuration */ export interface FontAsset { url: string; family: string; weight?: string | number; style?: 'normal' | 'italic'; display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional'; unicodeRange?: string; priority?: PrefetchPriority; } /** * Asset prefetch configuration */ export interface AssetPrefetchConfig { /** Enable asset prefetching */ enabled: boolean; /** Network quality awareness */ networkAware: boolean; /** Minimum network quality for prefetch */ minNetworkQuality: '4g' | '3g' | '2g' | 'slow-2g'; /** Maximum concurrent prefetches */ maxConcurrent: number; /** Prefetch images by default */ prefetchImages: boolean; /** Prefetch fonts by default */ prefetchFonts: boolean; /** Use responsive image prefetching */ responsiveImages: boolean; /** Default image priority */ defaultImagePriority: PrefetchPriority; /** Default font priority */ defaultFontPriority: PrefetchPriority; /** Debug mode */ debug: boolean; } /** * Prefetch result */ export interface AssetPrefetchResult { url: string; type: AssetType; success: boolean; duration: number; size?: number; error?: Error; } /** * Manages asset prefetching */ export declare class AssetPrefetchManager { private config; private queue; private prefetchedAssets; private loadedFonts; constructor(config?: Partial); /** * Prefetch an asset */ prefetch(asset: Asset): Promise; /** * Prefetch multiple assets */ prefetchMany(assets: Asset[]): Promise; /** * Prefetch an image with responsive support */ prefetchImage(image: ResponsiveImage): Promise; /** * Prefetch multiple images */ prefetchImages(images: Array): Promise; /** * Prefetch a font */ prefetchFont(font: FontAsset): Promise; /** * Prefetch multiple fonts */ prefetchFonts(fonts: FontAsset[]): Promise; /** * Prefetch a script */ prefetchScript(url: string, priority?: PrefetchPriority): void; /** * Prefetch a stylesheet */ prefetchStyle(url: string, priority?: PrefetchPriority): void; /** * Preload a critical asset */ preload(url: string, as: string, options?: { crossOrigin?: 'anonymous' | 'use-credentials'; type?: string; media?: string; }): HTMLLinkElement; /** * Create DNS prefetch hint */ dnsPrefetch(hostname: string): void; /** * Create preconnect hint */ preconnect(origin: string, crossOrigin?: boolean): void; /** * Check if asset was prefetched */ isPrefetched(url: string): boolean; /** * Get prefetch statistics */ getStats(): { prefetchedAssets: number; loadedFonts: number; queueStats: ReturnType; }; /** * Clear prefetch tracking */ clear(): void; private prefetchByType; private prefetchImageUrl; private selectResponsiveSource; private createPreloadLink; private createPrefetchLink; private shouldPrefetch; private getNetworkInfo; private log; } /** * Get or create the global asset prefetch manager */ export declare function getAssetPrefetchManager(config?: Partial): AssetPrefetchManager; /** * Reset the manager instance */ export declare function resetAssetPrefetchManager(): void; /** * Prefetch an image */ export declare function prefetchImage(url: string, priority?: PrefetchPriority): Promise; /** * Prefetch images */ export declare function prefetchImages(urls: string[]): Promise; /** * Prefetch a font */ export declare function prefetchFont(font: FontAsset): Promise; /** * Create DNS prefetch hint */ export declare function dnsPrefetch(hostname: string): void; /** * Create preconnect hint */ export declare function preconnect(origin: string, crossOrigin?: boolean): void; /** * Preload a critical asset */ export declare function preloadAsset(url: string, as: string, options?: Parameters[2]): HTMLLinkElement;