taglib-wasm
Version:
TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps
65 lines • 3.4 kB
TypeScript
import type { WasmModule } from "../wasm.js";
import type { AudioFileInput, OpenOptions, TagInput } from "../types.js";
import type { LoadTagLibOptions } from "../runtime/loader-types.js";
import { type NamedAudioInput } from "../types/audio-formats.js";
import type { AudioFile } from "./audio-file-interface.js";
/**
* Main TagLib interface for audio metadata operations.
*/
export declare class TagLib {
private readonly module;
constructor(module: WasmModule);
/**
* Initialize the TagLib Wasm module and return a ready-to-use instance.
* @param options - Wasm loading configuration (binary, URL, backend selection).
* @returns A configured TagLib instance.
* @throws {TagLibInitializationError} If the Wasm module fails to load.
*/
static initialize(options?: LoadTagLibOptions): Promise<TagLib>;
/**
* Open an audio file for reading and writing metadata.
* @param input - File path, Uint8Array, ArrayBuffer, File object, or NamedAudioInput.
* @param options - Partial-loading options for large files.
* @returns An AudioFile instance (use `using` for automatic cleanup).
* @throws {TagLibInitializationError} If the module is not properly initialized.
* @throws {InvalidFormatError} If the file is corrupted or unsupported.
*/
open(input: AudioFileInput, options?: OpenOptions): Promise<AudioFile>;
/**
* Open, modify, and save an audio file in one operation.
*
* With a file path, edits in place on disk. With a buffer/File, returns the modified data.
* @param input - File path for in-place editing, or buffer/File for buffer-based editing.
* @param fn - Callback receiving the AudioFile. Changes are auto-saved after it returns.
* @returns Nothing for file paths; modified Uint8Array for buffers.
* @throws {InvalidFormatError} If the file is corrupted or unsupported.
* @throws {FileOperationError} If saving to disk fails.
*/
edit(input: string, fn: (file: AudioFile) => void | Promise<void>): Promise<void>;
edit(input: Uint8Array | ArrayBuffer | File | NamedAudioInput, fn: (file: AudioFile) => void | Promise<void>): Promise<Uint8Array>;
/**
* Update tags in a file and save to disk in one operation.
* @param path - Path to the audio file.
* @param tags - Tag fields to update (partial update supported).
* @throws {InvalidFormatError} If the file is corrupted or unsupported.
* @throws {FileOperationError} If saving to disk fails.
*/
updateFile(path: string, tags: Partial<TagInput>): Promise<void>;
/**
* Copy an audio file to a new path with updated tags.
* @param sourcePath - Path to the source audio file.
* @param destPath - Destination path for the tagged copy.
* @param tags - Tag fields to set on the copy.
* @throws {InvalidFormatError} If the source file is corrupted or unsupported.
* @throws {FileOperationError} If reading or writing fails.
*/
copyWithTags(sourcePath: string, destPath: string, tags: Partial<TagInput>): Promise<void>;
/** Returns the taglib-wasm version with embedded TagLib version. */
version(): string;
private taglibVersion;
}
/**
* Create a TagLib instance from a pre-loaded Wasm module.
*/
export declare function createTagLib(module: WasmModule): Promise<TagLib>;
//# sourceMappingURL=taglib-class.d.ts.map