taglib-wasm
Version:
TagLib for TypeScript platforms: Deno, Node.js, Bun, Electron, browsers, and Cloudflare Workers
64 lines • 2.26 kB
TypeScript
/**
* @fileoverview Runtime environment detection for optimal WASM binary selection
*
* Detects the current JavaScript runtime environment and determines the optimal
* WebAssembly binary to load (WASI for filesystem-heavy workloads, Emscripten
* for browser compatibility).
*
* Priority order:
* 1. Deno + WASI (optimal filesystem performance)
* 2. Node.js + WASI (when available)
* 3. Browser + Emscripten (required for web)
* 4. Node.js + Emscripten (fallback compatibility)
*/
/**
* Supported runtime environments with their optimal WASM target
*/
export type RuntimeEnvironment = "deno-wasi" | "node-wasi" | "browser" | "node-emscripten" | "worker" | "cloudflare";
/**
* WASM binary types that can be loaded
*/
export type WasmBinaryType = "wasi" | "emscripten";
/**
* Runtime detection result with optimization hints
*/
export interface RuntimeDetectionResult {
/** Detected runtime environment */
environment: RuntimeEnvironment;
/** Optimal WASM binary type for this environment */
wasmType: WasmBinaryType;
/** Whether filesystem operations are supported */
supportsFilesystem: boolean;
/** Whether streaming is supported for large files */
supportsStreaming: boolean;
/** Estimated performance tier (1=best, 3=fallback) */
performanceTier: 1 | 2 | 3;
}
/**
* Detect the current runtime environment and determine optimal WASM binary
*/
export declare function detectRuntime(): RuntimeDetectionResult;
/**
* Get human-readable description of the runtime environment
*/
export declare function getEnvironmentDescription(env: RuntimeEnvironment): string;
/**
* Check if the current environment can load a specific WASM binary type
*/
export declare function canLoadWasmType(wasmType: WasmBinaryType): boolean;
/**
* Force a specific runtime detection result (for testing)
* @internal
*/
export declare function _forceRuntime(result: RuntimeDetectionResult): void;
/**
* Clear forced runtime override (for testing)
* @internal
*/
export declare function _clearRuntimeOverride(): void;
/**
* Get the current runtime detection result, respecting test overrides
* @internal
*/
export declare function _getDetectionResult(): RuntimeDetectionResult;
//# sourceMappingURL=detector.d.ts.map