@toast-studios/asset-manager
Version:
A React Native asset management library with intelligent caching and loading strategies
66 lines (65 loc) • 1.9 kB
TypeScript
/**
* Device performance metrics interface
*/
export interface DeviceMetrics {
totalMemory: number;
availableMemory: number;
cpuCores: number;
isLowEnd: boolean;
batteryLevel?: number;
isCharging?: boolean;
thermalState?: 'nominal' | 'fair' | 'serious' | 'critical';
deviceType?: 'phone' | 'tablet' | 'tv' | 'unknown';
}
/**
* Device capability detector and performance analyzer
*/
export declare class DeviceDetector {
private static cachedMetrics?;
private static lastUpdateTime?;
private static readonly CACHE_DURATION;
/**
* Get comprehensive device metrics with caching
*/
static getDeviceMetrics(): Promise<DeviceMetrics>;
/**
* Get cached device metrics synchronously (returns defaults if not cached)
*/
static getDeviceMetricsSync(): DeviceMetrics;
/**
* Check if device is suitable for heavy asset downloads
*/
static canHandleHeavyDownloads(): Promise<boolean>;
/**
* Get optimal download concurrency based on device capabilities
*/
static getOptimalConcurrency(): Promise<number>;
/**
* Check if device should use conservative download settings
*/
static shouldUseConservativeSettings(): Promise<boolean>;
/**
* Invalidate cache to force fresh device metrics
*/
static invalidateCache(): void;
/**
* Get device info from React Native modules
*/
private static getReactNativeDeviceInfo;
/**
* Conservative device defaults for fallback
*/
private static getConservativeDefaults;
/**
* Estimate CPU cores based on device info
*/
private static estimateCpuCores;
/**
* Determine if device is low-end based on comprehensive metrics
*/
private static isLowEndDevice;
/**
* Detect device type from available info
*/
private static detectDeviceType;
}