/** * Backend Detection Utilities * Detects available backends and environment */ declare enum RuntimeEnvironment { BROWSER = "browser", NODE = "node", WEBWORKER = "webworker", UNKNOWN = "unknown" } declare function detectEnvironment(): RuntimeEnvironment; declare function isNode(): boolean; declare function isBrowser(): boolean; declare function isWebWorker(): boolean; interface BackendAvailability { backend: string; available: boolean; reason?: string; } declare function checkBackendAvailability(backendName: string): Promise; declare function getAllAvailableBackends(): Promise; interface BackendPriority { name: string; priority: number; description: string; } declare const BACKEND_PRIORITY: BackendPriority[]; declare function getBestAvailableBackend(availableBackends: string[]): string; /** * Backend Detector for creating instances */ declare class BackendDetector { private static instance; private constructor(); static getInstance(): BackendDetector; createBackendByName(name: string): Promise; createBackend(detectedBackend?: string): Promise; } declare const detector: BackendDetector; /** * Fallback Manager with retry logic */ interface FallbackResult { success: boolean; backend: string; data: T; errors?: { backend: string; error: Error; }[]; } declare class FallbackManager { detector: BackendDetector; private fallbackOrder; constructor(fallbackOrder?: string[]); /** * Execute operation with fallback mechanism */ execute(operation: (backend: any) => Promise): Promise>; /** * Hash with fallback mechanism */ hash(data: string): Promise>; /** * Hash binary data with fallback */ hashBinary(data: ArrayBuffer | Uint8Array): Promise>; /** * Get the best available backend */ getBestBackend(): Promise; /** * Get available backends in priority order */ getAvailableBackends(): Promise; /** * Get backend metrics for monitoring */ getMetrics(): Record; } declare const fallbackManager: FallbackManager; /** * Robust hash function with fallback support */ declare function robustHash(data: string, options?: { fallback?: boolean; reportFallback?: boolean; forceBackend?: string; }): Promise; /** * Metrics collector for backend usage */ interface BackendMetrics { success: number; fail: number; } declare class MetricsCollector { private metrics; recordSuccess(backend: string): void; recordFail(backend: string): void; getMetrics(): Record; getSummary(): string; reset(): void; } declare const metrics: MetricsCollector; export { BACKEND_PRIORITY, type BackendAvailability, BackendDetector, type BackendPriority, FallbackManager, type FallbackResult, MetricsCollector, RuntimeEnvironment, checkBackendAvailability, detectEnvironment, detector, fallbackManager, getAllAvailableBackends, getBestAvailableBackend, isBrowser, isNode, isWebWorker, metrics, robustHash };