UNPKG

taglib-wasm

Version:

TagLib for TypeScript platforms: Deno, Node.js, Bun, Electron, browsers, and Cloudflare Workers

75 lines 2.53 kB
/** * @fileoverview Unified loader that selects optimal WASM implementation * * Automatically detects the runtime environment and loads either: * - WASI-based implementation for Deno/Node.js (faster filesystem access) * - Emscripten-based implementation for browsers (universal compatibility) * * Addresses code review issues: * - Reduced cyclomatic complexity * - No circular dependencies * - Proper error handling with branded types * - Functions under 50 lines * - Clean async/await patterns */ import { type RuntimeDetectionResult } from "./detector.ts"; import type { TagLibModule } from "../wasm.ts"; export declare class UnifiedLoaderError extends Error { readonly code: "UNIFIED_LOADER_ERROR"; constructor(message: string, cause?: unknown); } export declare class ModuleLoadError extends Error { readonly wasmType: "wasi" | "emscripten"; readonly code: "MODULE_LOAD_ERROR"; constructor(message: string, wasmType: "wasi" | "emscripten", cause?: unknown); } /** * Unified module configuration */ export interface UnifiedLoaderOptions { /** Force specific WASM type */ forceWasmType?: "wasi" | "emscripten"; /** Disable optimizations for debugging */ disableOptimizations?: boolean; /** Custom WASM binary path or data */ wasmBinary?: ArrayBuffer | Uint8Array; /** Custom WASM URL */ wasmUrl?: string; /** Enable debug output */ debug?: boolean; /** Use inline WASM for bundling */ useInlineWasm?: boolean; } /** * Extended TagLib module with runtime info */ export interface UnifiedTagLibModule extends TagLibModule { /** Runtime environment info */ runtime: RuntimeDetectionResult; /** Whether using WASI implementation */ isWasi: boolean; /** Whether using Emscripten implementation */ isEmscripten: boolean; /** Get performance metrics */ getPerformanceMetrics?: () => PerformanceMetrics; } interface PerformanceMetrics { initTime: number; wasmType: "wasi" | "emscripten"; environment: string; memoryUsage?: number; } /** * Main unified loader with reduced complexity */ export declare function loadUnifiedTagLibModule(options?: UnifiedLoaderOptions): Promise<UnifiedTagLibModule>; /** * Check if WASI is available in the current environment */ export declare function isWasiAvailable(): boolean; /** * Get recommended configuration for current environment */ export declare function getRecommendedConfig(): UnifiedLoaderOptions; export {}; //# sourceMappingURL=unified-loader.d.ts.map