import { ConnectionType, EffectiveConnectionType, NetworkQuality, NetworkStats, RequestTiming } from '../network-performance'; import { NetworkTierConfig } from '../../../config/performance.config'; /** * Adaptive loading strategy */ export interface AdaptiveLoadingStrategy { /** Recommended image quality */ readonly imageQuality: 'high' | 'medium' | 'low' | 'placeholder'; /** Prefetch strategy */ readonly prefetchStrategy: 'aggressive' | 'moderate' | 'conservative' | 'none'; /** Should reduce motion/animations */ readonly shouldReduceMotion: boolean; /** Should defer non-critical resources */ readonly shouldDeferNonCritical: boolean; /** Maximum concurrent requests */ readonly maxConcurrentRequests: number; } /** * Hook options */ export interface UseNetworkQualityOptions { /** Callback on quality change */ readonly onQualityChange?: (quality: NetworkQuality) => void; /** Callback on slow request */ readonly onSlowRequest?: (request: RequestTiming) => void; /** Slow connection threshold (score 0-100) */ readonly slowConnectionThreshold?: number; /** Enable debug logging */ readonly debug?: boolean; } /** * Hook return value */ export interface UseNetworkQualityReturn { /** Current network quality */ readonly quality: NetworkQuality | null; /** Effective connection type */ readonly effectiveType: EffectiveConnectionType; /** Connection type */ readonly connectionType: ConnectionType; /** Estimated downlink speed (Mbps) */ readonly downlink: number; /** Round-trip time (ms) */ readonly rtt: number; /** Data saver enabled */ readonly saveData: boolean; /** Overall quality score (0-100) */ readonly score: number; /** Network tier configuration */ readonly tier: NetworkTierConfig | null; /** Whether on slow connection */ readonly isSlowConnection: boolean; /** Whether connection is metered */ readonly isMetered: boolean; /** Whether offline */ readonly isOffline: boolean; /** Adaptive loading strategy */ readonly loadingStrategy: AdaptiveLoadingStrategy; /** Whether should prefetch */ readonly shouldPrefetch: boolean; /** Network statistics */ readonly stats: NetworkStats | null; /** Estimated bandwidth (bytes/sec) */ readonly estimatedBandwidth: number; /** Force refresh quality */ readonly refresh: () => void; /** Get priority recommendation for a resource */ readonly getPriority: (url: string, type: string, options?: { isAboveFold?: boolean; isLCP?: boolean; isInteractive?: boolean; }) => 'highest' | 'high' | 'normal' | 'low' | 'lowest'; } /** * Hook for network quality monitoring */ export declare function useNetworkQuality(options?: UseNetworkQualityOptions): UseNetworkQualityReturn; /** * Hook that returns image quality based on network */ export declare function useAdaptiveImageQuality(): 'high' | 'medium' | 'low' | 'placeholder'; /** * Hook that conditionally loads based on network */ export declare function useNetworkConditional(fullValue: T, reducedValue: T, placeholderValue: T): T; /** * Hook for network-aware lazy loading */ export declare function useNetworkAwareLazyLoad(): { shouldLazyLoad: boolean; intersectionThreshold: number; rootMargin: string; }; /** * Hook for tracking request performance */ export declare function useRequestPerformance(url: string): { timing: RequestTiming | null; isLoading: boolean; error: Error | null; }; /** * Hook that provides network status indicator data */ export declare function useNetworkStatusIndicator(): { status: 'excellent' | 'good' | 'fair' | 'poor' | 'offline'; label: string; color: string; icon: string; }; /** * Hook for preconnect management */ export declare function usePreconnect(origins: string[]): void;