taglib-wasm
Version:
TagLib for TypeScript platforms: Deno, Node.js, Bun, Electron, browsers, and Cloudflare Workers
133 lines • 4.88 kB
TypeScript
/**
* @fileoverview MessagePack integration for taglib-wasm
*
* Provides high-performance binary serialization for audio metadata,
* offering 10x faster processing and 50% smaller payloads compared to JSON.
*
* This module integrates with the Phase 2.5 C API that outputs MessagePack
* data directly from TagLib operations.
*
* @example
* ```typescript
* import { decodeTagData, encodeTagData } from "./msgpack/index.ts";
*
* // Decode MessagePack data from C API
* const tagData = decodeTagData(msgpackBuffer);
* console.log(tagData.title, tagData.artist);
*
* // Encode tag data for writing back
* const encoded = encodeTagData(modifiedTags);
* ```
*/
export { decodeAudioProperties, decodeFastTagData, decodeMessagePack, decodeMessagePackAuto, decodePicture, decodePictureArray, decodePropertyMap, decodeTagData, getMessagePackInfo, isValidMessagePack, } from "./decoder.ts";
export { canEncodeToMessagePack, compareEncodingEfficiency, encodeAudioProperties, encodeBatchTagData, encodeFastTagData, encodeMessagePack, encodeMessagePackCompact, encodeMessagePackStream, encodePicture, encodePictureArray, encodePropertyMap, encodeTagData, estimateMessagePackSize, } from "./encoder.ts";
export type { AutoDetectionConfig, AutoDetectionResult, BatchProcessingResult, DecodingResult, EncodingResult, FormatComparison, FormatVersion, MessagePackCompatible, MessagePackData, MessagePackDataType, MessagePackError, MessagePackErrorInfo, MessagePackMetrics, MessagePackValue, StreamingConfig, TagLibMessagePackData, TagLibMessagePackMarker, ValidationResult, } from "./types.ts";
export { TAGLIB_MSGPACK_MARKERS } from "./types.ts";
import type { AudioProperties, ExtendedTag, Picture } from "../types.ts";
/**
* High-level MessagePack utilities for common taglib-wasm operations
*/
export declare class MessagePackUtils {
/**
* Smart decode that automatically detects the data type
*/
static decode(buffer: Uint8Array): ExtendedTag | AudioProperties | Picture | unknown;
/**
* Validate and decode tag data with error handling
*/
static safeDecodeTagData(buffer: Uint8Array): ExtendedTag | null;
/**
* Validate and decode audio properties with error handling
*/
static safeDecodeAudioProperties(buffer: Uint8Array): AudioProperties | null;
/**
* Validate and decode picture data with error handling
*/
static safeDecodePicture(buffer: Uint8Array): Picture | null;
/**
* Get performance metrics for MessagePack vs JSON
*/
static getPerformanceComparison(data: ExtendedTag): {
messagePackSize: number;
jsonSize: number;
sizeReduction: number;
estimatedSpeedImprovement: number;
};
/**
* Convert between MessagePack and JSON for debugging/comparison
*/
static toJson(buffer: Uint8Array): string;
/**
* Convert JSON back to MessagePack (for testing/migration)
*/
static fromJson(jsonString: string): Uint8Array;
/**
* Batch process multiple MessagePack buffers
*/
static batchDecode(buffers: Uint8Array[]): Array<{
success: boolean;
data?: ExtendedTag | AudioProperties | Picture | unknown;
error?: string;
}>;
/**
* Check if data is compatible with TagLib MessagePack format
*/
static isTagLibCompatible(data: unknown): boolean;
}
/**
* Create a MessagePack processor with custom configuration
*/
export declare function createMessagePackProcessor(options?: {
validateInput?: boolean;
enableMetrics?: boolean;
maxBufferSize?: number;
}): {
/**
* Decode with optional validation and metrics
*/
decode(buffer: Uint8Array): unknown;
/**
* Encode with optional metrics
*/
encode(data: ExtendedTag): Uint8Array<ArrayBufferLike>;
};
/**
* Default MessagePack processor instance with balanced settings
*/
export declare const defaultMessagePackProcessor: {
/**
* Decode with optional validation and metrics
*/
decode(buffer: Uint8Array): unknown;
/**
* Encode with optional metrics
*/
encode(data: ExtendedTag): Uint8Array<ArrayBufferLike>;
};
/**
* High-performance MessagePack processor for production use
*/
export declare const performanceMessagePackProcessor: {
/**
* Decode with optional validation and metrics
*/
decode(buffer: Uint8Array): unknown;
/**
* Encode with optional metrics
*/
encode(data: ExtendedTag): Uint8Array<ArrayBufferLike>;
};
/**
* Debug-enabled MessagePack processor for development
*/
export declare const debugMessagePackProcessor: {
/**
* Decode with optional validation and metrics
*/
decode(buffer: Uint8Array): unknown;
/**
* Encode with optional metrics
*/
encode(data: ExtendedTag): Uint8Array<ArrayBufferLike>;
};
//# sourceMappingURL=index.d.ts.map