import { ByteVector } from "../../byteVector"; import { File } from "../../file"; import { Frame } from "./frame"; import { Id3v2FrameHeader } from "./frameHeader"; /** * Type shortcut for a method that returns a {@link Frame}. * @param data Byte vector that contains the frame * @param offset Position into the byte vector where the frame begins * @param header The header that describes the frame * @param version ID3v2 version the frame is encoded with. Must be unsigned 8-bit int */ export declare type FrameCreator = (data: ByteVector, offset: number, header: Id3v2FrameHeader, version: number) => Frame; /** * Performs the necessary operations to determine and create the correct child classes of * {@link Frame} for a given raw ID3v2 frame. * By default, this will only load frames contained in the library. To add additional frames to the * process, register a frame creator with {@link addFrameCreator}. */ export declare class Id3v2FrameFactory { private static readonly CUSTOM_FRAME_CREATORS; /** * Adds a custom frame creator to try before using standard frame creation methods. * Frame creators are used before standard methods so custom checking can be used and new * formats can be added. They are executed in reverse order in which they are added. * @param creator Frame creator function * * data: ByteVector Raw ID3v2 frame * * offset: number Offset in data at which the frame data begins (should be int) * * header: Id3v2FrameHeader Header for the frame contained in data * * version: number ID3v2 version the raw frame data is stored in (should be byte) * * returns Frame if method was able to match the frame, falsy otherwise */ static addFrameCreator(creator: FrameCreator): void; /** * Removes all custom frame creators */ static clearFrameCreators(): void; /** * Creates a {@link Frame} object by reading it from raw ID3v2 frame data. * @param data Raw ID3v2 frame * @param file File to read the frame from if `data` is falsy * @param offset Index into `file` or in `data` if truthy, at which the * frame begins. After reading, the offset where the next frame can be read is returned in * the `offset` property of the returned object * @param version ID3v2 version the frame is encoded with. Must be unsigned 8-bit int * @param alreadyUnsynced Whether or not the entire tag has already been unsynchronized * @returns * Undefined is returned if there are no more frames to read. * Object is returned if a frame was found. Object has the following properties: * * frame: {@link Frame} that was read * * offset: updated offset where the next frame starts */ static createFrame(data: ByteVector, file: File, offset: number, version: number, alreadyUnsynced: boolean): { frame: Frame; offset: number; }; }