taglib-wasm
Version:
TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps
69 lines • 3.74 kB
TypeScript
import type { AudioFileInput, AudioProperties, ExtendedTag, FileType, TagInput } from "../types.js";
/**
* Reads all metadata tags from an audio file.
*
* @param file - File path, Uint8Array, ArrayBuffer, or File object
* @returns Parsed tag fields including extended metadata from the audio file
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
*/
export declare function readTags(file: AudioFileInput): Promise<ExtendedTag>;
/**
* Applies metadata tag changes to an audio file and returns the modified content as a buffer.
*
* @param file - File path, Uint8Array, ArrayBuffer, or File object
* @param tags - Partial tag fields to merge with existing metadata
* @returns Modified audio file contents with updated tags
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
* @throws {FileOperationError} If saving the modified metadata fails
*/
export declare function applyTags(file: AudioFileInput, tags: Partial<TagInput>): Promise<Uint8Array>;
/**
* Writes metadata tag changes directly to an audio file on disk.
*
* @param file - File path string; the file is updated in place
* @param tags - Partial tag fields to merge with existing metadata
* @returns Resolves when the file has been written successfully
* @throws {FileOperationError} If a non-string input is provided, saving fails, or the file write fails
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
* @throws {EnvironmentError} If the runtime does not support filesystem write access
*/
export declare function applyTagsToFile(file: string, tags: Partial<TagInput>): Promise<void>;
/**
* Reads audio properties (duration, bitrate, sample rate, channels) from an audio file.
*
* @param file - File path, Uint8Array, ArrayBuffer, or File object
* @returns Audio codec properties for the file
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
* @throws {MetadataError} If the file does not contain valid audio property data
*/
export declare function readProperties(file: AudioFileInput): Promise<AudioProperties>;
/**
* Checks whether the given input is a valid, readable audio file.
*
* @param file - File path, Uint8Array, ArrayBuffer, or File object
* @returns `true` if the file is valid and recognized by TagLib; `false` otherwise
*/
export declare function isValidAudioFile(file: AudioFileInput): Promise<boolean>;
/**
* Detects the audio format of a file.
*
* @param file - File path, Uint8Array, ArrayBuffer, or File object
* @returns The detected `FileType`, or `undefined` if the format cannot be determined
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
*/
export declare function readFormat(file: AudioFileInput): Promise<FileType | undefined>;
/**
* Removes all metadata tags and pictures from an audio file and returns the stripped content.
*
* @param file - File path, Uint8Array, ArrayBuffer, or File object
* @returns Modified audio file contents with all tags and pictures cleared
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
* @throws {FileOperationError} If saving the modified metadata fails
*/
export declare function clearTags(file: AudioFileInput): Promise<Uint8Array>;
//# sourceMappingURL=tag-operations.d.ts.map