UNPKG

taglib-wasm

Version:

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

69 lines 2.46 kB
/** * @fileoverview Modern WASI loader using @wasmer/sdk for Deno 2+ * * Implements actual WASI functionality using Wasmer SDK with proper * file system mounting, memory management, and error handling. */ import { Directory } from "@wasmer/sdk"; export declare class WasmerInitError extends Error { readonly code: "WASMER_INIT_ERROR"; constructor(message: string, cause?: unknown); } export declare class WasmerLoadError extends Error { readonly code: "WASMER_LOAD_ERROR"; constructor(message: string, cause?: unknown); } export declare class WasmerExecutionError extends Error { readonly code: "WASMER_EXECUTION_ERROR"; constructor(message: string, cause?: unknown); } /** * WASI module interface matching our C API exports */ export interface WasiModule { tl_version(): string; tl_api_version(): number; malloc(size: number): number; free(ptr: number): void; tl_read_tags(pathPtr: number, bufPtr: number, len: number, outSizePtr: number): number; tl_write_tags(pathPtr: number, bufPtr: number, len: number, tagsPtr: number, tagsSize: number, outBufPtr: number, outSizePtr: number): number; tl_get_last_error(): number; tl_get_last_error_code(): number; tl_clear_error(): void; memory: WebAssembly.Memory; } /** * Configuration for Wasmer SDK loader */ export interface WasmerLoaderConfig { /** Path to WASI WASM binary */ wasmPath?: string; /** Use inline WASM for bundling */ useInlineWasm?: boolean; /** Initial file system mounts */ mounts?: Record<string, Directory>; /** Environment variables */ env?: Record<string, string>; /** Arguments to pass to WASI module */ args?: string[]; /** Enable debug output */ debug?: boolean; } /** * Initialize Wasmer SDK (must be called once before any Wasmer APIs) */ export declare function initializeWasmer(useInline?: boolean): Promise<void>; /** * Load WASI module using Wasmer SDK */ export declare function loadWasmerWasi(config?: WasmerLoaderConfig): Promise<WasiModule>; /** * High-level API for reading tags from audio files using WASI * Uses RAII pattern with automatic memory cleanup */ export declare function readTagsWithWasi(audioBuffer: Uint8Array, wasiModule: WasiModule): Promise<Uint8Array>; /** * Check if Wasmer SDK is available and can be initialized */ export declare function isWasmerAvailable(): Promise<boolean>; //# sourceMappingURL=wasmer-sdk-loader.d.ts.map