import { File } from "../file.js"; import { ReadStyle } from "../toolkit/types.js"; import type { IOStream } from "../toolkit/ioStream.js"; import { Tag } from "../tag.js"; import { XiphComment } from "../ogg/xiphComment.js"; import { ID3v1Tag } from "../mpeg/id3v1/id3v1Tag.js"; import { Id3v2Tag } from "../mpeg/id3v2/id3v2Tag.js"; import { FlacPicture } from "./flacPicture.js"; import { FlacProperties } from "./flacProperties.js"; import { type VariantMap } from "../toolkit/variant.js"; /** * Bitmask identifying which tag formats are present in a FLAC file. * Used with {@link FlacFile.strip} to select which tags to remove. */ export declare enum FlacTagTypes { /** No tag types. */ NoTags = 0, /** Matches XiphComment (Vorbis Comment) tags. */ XiphComment = 1, /** Matches ID3v1 tags. */ ID3v1 = 2, /** Matches ID3v2 tags. */ ID3v2 = 4, /** Matches all tag types. */ AllTags = 65535 } /** * FLAC file format handler. * * Supports XiphComment (Vorbis Comment), ID3v2 and ID3v1 tags as well as * FLAC picture metadata blocks and audio property reading. * * FLAC file structure: * [ID3v2] + "fLaC" + metadata blocks + audio frames + [ID3v1] */ export declare class FlacFile extends File { /** The Vorbis Comment (XiphComment) tag, populated from the VorbisComment metadata block. */ private _xiphComment; /** Whether a VorbisComment block was found on disk during parsing. */ private _hasXiphComment; /** The ID3v2 tag, present if one was found before the "fLaC" magic. */ private _id3v2Tag; /** The ID3v1 tag, present if one was found at the end of the file. */ private _id3v1Tag; /** Combined tag that delegates to the available sub-tags (priority: XiphComment > ID3v2 > ID3v1). */ private _combinedTag; /** Parsed audio properties from the STREAMINFO block. */ private _properties; /** Embedded FLAC picture blocks. */ private _pictures; /** All parsed metadata blocks (excluding Picture and Padding). */ private _blocks; /** File offset of the ID3v2 tag, or -1 if not present. */ private _id3v2Location; /** Original byte size of the ID3v2 tag (used when rewriting). */ private _id3v2OriginalSize; /** File offset of the ID3v1 tag, or -1 if not present. */ private _id3v1Location; /** File offset of the "fLaC" magic (i.e., start of FLAC metadata blocks). */ private _flacStart; /** File offset of the first audio frame (immediately after the last metadata block). */ private _streamStart; /** * Private constructor — use {@link FlacFile.open} to create instances. * @param stream The underlying I/O stream. */ private constructor(); /** * Opens a FLAC file and parses its metadata. * @param stream The I/O stream to read from. * @param readProperties Whether to parse audio properties (default `true`). * @param readStyle Accuracy / speed trade-off for property reading. * @returns A fully initialised {@link FlacFile} instance. */ static open(stream: IOStream, readProperties?: boolean, readStyle?: ReadStyle): Promise; /** * Returns the combined tag (XiphComment > ID3v2 > ID3v1) for this file. * @returns The active {@link CombinedTag}. */ tag(): Tag; /** * Returns the parsed audio properties, or `null` if properties were not read. * @returns The {@link FlacProperties} or `null`. */ audioProperties(): FlacProperties | null; /** * Writes all pending tag and picture changes back to the underlying stream. * @returns `true` on success, `false` if the file is read-only or invalid. */ save(): Promise; /** * Returns the XiphComment (Vorbis Comment) tag. * @param create - If `true` and no XiphComment exists, a new empty one is created. * @returns The {@link XiphComment}, or `null` if not present and `create` is falsy. */ xiphComment(create?: boolean): XiphComment | null; /** * Returns the ID3v2 tag. * @param create - If `true` and no ID3v2 tag exists, a new empty one is created. * @returns The {@link Id3v2Tag}, or `null` if not present and `create` is falsy. */ id3v2Tag(create?: boolean): Id3v2Tag | null; /** * Returns the ID3v1 tag. * @param create - If `true` and no ID3v1 tag exists, a new empty one is created. * @returns The {@link ID3v1Tag}, or `null` if not present and `create` is falsy. */ id3v1Tag(create?: boolean): ID3v1Tag | null; /** * Whether a VorbisComment block was present on disk when the file was opened. * @returns `true` if a XiphComment was read from the FLAC metadata blocks. */ get hasXiphComment(): boolean; /** * Whether an ID3v2 tag was present on disk when the file was opened. * @returns `true` if an ID3v2 tag was found before the "fLaC" magic. */ get hasID3v2Tag(): boolean; /** * Whether an ID3v1 tag was present on disk when the file was opened. * @returns `true` if an ID3v1 tag was found at the end of the file. */ get hasID3v1Tag(): boolean; /** * Removes the tag types indicated by `tags` from the in-memory representation. * Changes are written to disk the next time {@link save} is called. * @param tags - Bitmask of {@link FlacTagTypes} to strip (default: all). */ strip(tags?: FlacTagTypes): void; /** Returns a shallow copy of the embedded picture list. */ get pictureList(): FlacPicture[]; /** * Adds a picture to the embedded picture list. * @param picture The {@link FlacPicture} to append. */ addPicture(picture: FlacPicture): void; /** * Removes the specified picture from the embedded picture list. * @param picture The {@link FlacPicture} instance to remove. */ removePicture(picture: FlacPicture): void; /** Removes all embedded pictures from the file. */ removePictures(): void; /** * Returns the list of complex property keys supported by this file. * Includes `"PICTURE"` if any embedded pictures are present. * @returns An array of supported complex property key strings. */ complexPropertyKeys(): string[]; /** * Returns the complex properties for the given key. * For the `"PICTURE"` key, each picture block is represented as a `VariantMap`. * @param key The complex property key (case-insensitive). * @returns An array of variant maps, one per picture (or delegated to the base class). */ complexProperties(key: string): VariantMap[]; /** * Sets the complex properties for the given key. * For the `"PICTURE"` key, replaces all embedded pictures with those derived * from the provided variant maps. * @param key The complex property key (case-insensitive). * @param value An array of variant maps describing the new property values. * @returns `true` if the key was handled, `false` if delegated to the base class. */ setComplexProperties(key: string, value: VariantMap[]): boolean; /** * Orchestrates the full parse of a FLAC file: finds ID3 tags, scans FLAC * metadata blocks, and reads audio properties. * @param readProperties Whether to parse audio properties. * @param readStyle Accuracy / speed trade-off hint. */ private read; /** * Looks for an ID3v2 tag at the beginning of the file and populates * `_id3v2Tag`, `_id3v2Location`, and `_id3v2OriginalSize` if found. */ private findID3v2; /** * Looks for an ID3v1 tag at the end of the file and populates * `_id3v1Tag` and `_id3v1Location` if found. */ private findID3v1; /** * Scans all FLAC metadata blocks, populating `_blocks`, `_pictures`, * `_xiphComment`, `_flacStart`, and `_streamStart`. */ private scan; /** Rebuilds `_combinedTag` from the current set of sub-tags (XiphComment > ID3v2 > ID3v1). */ private refreshCombinedTag; } //# sourceMappingURL=flacFile.d.ts.map