/** * @packageDocumentation apeFile.ts * Monkey's Audio (APE) file format handler. * Reads and writes APE, ID3v1, and (detection-only) ID3v2 tags embedded * in `.ape` files and exposes audio properties parsed from the MAC header. */ import { File } from "../file.js"; import { Tag } from "../tag.js"; import { ReadStyle } from "../toolkit/types.js"; import type { IOStream } from "../toolkit/ioStream.js"; import { ID3v1Tag } from "../mpeg/id3v1/id3v1Tag.js"; import { ApeTag } from "../ape/apeTag.js"; import { ApeProperties } from "./apeProperties.js"; /** * Bitmask constants identifying the tag types that may be present in an APE * file. Used with {@link ApeFile.strip} to select which tags to remove. */ export declare enum ApeFileTagTypes { /** No tags. */ NoTags = 0, /** ID3v1 tag appended at the end of the file. */ ID3v1 = 1, /** * ID3v2 tag prepended at the start of the file. * APEv2 files should not contain ID3v2; it is detected but not parsed. */ ID3v2 = 2, /** APEv2 tag. */ APE = 4, /** All supported tag types. */ AllTags = 65535 } /** * Monkey's Audio (APE) file format handler. * * Supports APE (primary) and ID3v1 (secondary) tags. ID3v2 tags are * detected and skipped but not parsed — they are invalid in APE files. */ export declare class ApeFile extends File { private _apeTag; private _id3v1Tag; private _combinedTag; private _properties; private _apeLocation; private _apeOriginalSize; private _id3v1Location; private _id3v2Location; private _id3v2Size; private _hasId3v2; /** * Private constructor — use {@link ApeFile.open} to create instances. * @param stream - The underlying I/O stream for this file. */ private constructor(); /** * Open an APE file from the given stream and parse its metadata. * @param stream - Readable (and optionally writable) I/O stream. * @param readProperties - When `true` (default), parse audio properties. * @param readStyle - Controls parsing accuracy vs. speed trade-off. * @returns A fully initialised `ApeFile` instance. */ static open(stream: IOStream, readProperties?: boolean, readStyle?: ReadStyle): Promise; /** * Quick-check whether `stream` looks like a valid APE file. * Looks for "MAC " signature, skipping an optional ID3v2 header. */ static isSupported(stream: IOStream): Promise; /** * Return the combined tag (APE preferred over ID3v1) for this file. * @returns The {@link CombinedTag} aggregating all present tag types. */ tag(): Tag; /** * Return the audio properties parsed from the MAC header, or `null` if * `readProperties` was `false` when the file was opened. */ audioProperties(): ApeProperties | null; /** * Persist all in-memory tags back to the underlying stream. * * - An existing ID3v1 tag is updated in-place or removed if empty. * - An APE tag is written immediately before the ID3v1 tag (or at EOF). * - An ID3v2 tag, if detected, is left untouched. * @returns `true` on success, `false` if the file is read-only. */ save(): Promise; /** Get the ID3v1 tag, optionally creating one if absent. */ id3v1Tag(create?: boolean): ID3v1Tag | null; /** Get the APE tag, optionally creating one if absent. */ apeTag(create?: boolean): ApeTag | null; /** * Remove the specified tag types from the in-memory representation. * Call `save()` afterwards to persist the changes to disk. */ strip(tags?: ApeFileTagTypes): void; /** Whether the file on disk has an ID3v1 tag. */ get hasID3v1Tag(): boolean; /** Whether the file on disk has an APE tag. */ get hasAPETag(): boolean; private read; private findID3v2; private findID3v1; private findAPE; private refreshCombinedTag; } //# sourceMappingURL=apeFile.d.ts.map