/// import { EventEmitter } from 'events'; export declare class Header { /** Size of sectors */ secSize: number; /** Number of sectors used for the Sector Allocation Table */ SATSize: number; /** Number of sectors used for the Master Sector Allocation Table */ MSATSize: number; /** Starting Sec ID of the Master Sector Allocation Table */ MSATSecId: number; /** Size of short sectors */ shortSecSize: number; /** Maximum size of a short stream */ shortStreamMax: number; /** Number of sectors used for the Short Sector Allocation Table */ SSATSize: number; /** Starting Sec ID of the Short Sector Allocation Table */ SSATSecId: number; /** Starting Sec ID of the directory stream */ dirSecId: number; partialMSAT: number[]; private readonly oleId; private constructor(); static load(buffer: Buffer): Header; } export declare class AllocationTable { private static SecIdFree; private static SecIdEndOfChain; private static SecIdSAT; private static SecIdMSAT; private readonly doc; private readonly table; private constructor(); static load(doc: OleCompoundDoc, secIds: number[]): Promise; getSecIdChain(startSecId: number): number[]; } export interface StorageEntry { name: string; type: number; nodeColor: number; left: number; right: number; storageDirId: number; secId: number; size: number; storages: { [key: string]: StorageEntry; }; streams: { [key: string]: StorageEntry; }; } export declare class DirectoryTree { private static EntryTypeEmpty; private static EntryTypeStorage; private static EntryTypeStream; private static EntryTypeRoot; private static NodeColorRed; private static NodeColorBlack; private static Leaf; readonly root: StorageEntry; private readonly doc; private readonly entries; static load(doc: OleCompoundDoc, secIds: number[]): Promise; private constructor(); private buildHierarchy; private getChildIds; private visit; } export declare class Storage { private readonly doc; private dirEntry; constructor(doc: OleCompoundDoc, dirEntry: StorageEntry); storage(storageName: string): Storage; getStreams(): string[]; stream(streamName: string, offset?: number, bytesToRead?: number): any; /** * This streams a storage blob to a callback function but skips bytes * depending on the function's result. * * The goal is not to read large streams but only get the position of the * data. * * It works like this: The callback function returns the number of bytes to * skip. There is a sliding buffer that contains two consequent sectors. * As soon as the skipped bytes go into the second sector, the sliding * buffer is shifted, i.e. the next sector is read and the first sector is * discarded. If the number of skipped bytes is greater than what's * currently in the sliding buffer, the sliding buffer is discarded and * re-read from the position of the skipped bytes. * * That means: * * - Disk reads are only done when necessary * - Read data is cached for further chunks * - Disk reads are quite efficient in size, usually 4k which is usually * a disk sector * * @param streamName Name to stream * @param offset Where to start reading in the stream * @param next Callback taking in the data and returning the next position */ streamFiltered(streamName: string, offset: number, next: (data: ReadResult) => Promise): Promise; /** * Reads a given stream from a given storage. * * @param key Key within the storage * @param offset Offset within the storage * @param bytesToRead Number of bytes to read, 0 for entire storage * @return {Promise} Read data */ read(key: string, offset?: number, bytesToRead?: number): Promise; } export declare class OleCompoundDoc extends EventEmitter { header: Header; SAT: AllocationTable; SSAT: AllocationTable; private readonly reader; private skipBytes; private rootStorage; private MSAT; private shortStreamSecIds; private directoryTree; private constructor(); static load(reader: IBinaryReader): Promise; readWithCustomHeader(size: number): Promise; reopen(): Promise; storage(storageName: string): Storage; readSector(secId: number, offset?: number, bytesToRead?: number): Promise; readSectors(secIds: number[], offset?: number, bytesToRead?: number): Promise; readShortSector(secId: number, offset?: number, bytesToRead?: number): Promise; readShortSectors(secIds: number[], offset?: number, bytesToRead?: number): Promise; close(): Promise; private assertLoaded; private openFile; private readCustomHeader; private readHeader; private readMSAT; private readSAT; private readSSAT; private readDirectoryTree; private getFileOffsetForSec; private getFileOffsetForShortSec; } export interface ReadResult { data: Buffer; storageOffset: number; } export interface IBinaryReader { /** * Reads data into a buffer. * * @param buffer Buffer that the data will be written to. * @param offset Offset in the buffer to start writing at. * @param length Integer specifying the number of bytes to read. * @param position At which offset to start reading * @returns [ number of bytes read, data read ] */ read(buffer: Buffer, offset: number, length: number, position: number): Promise<[number, Buffer]>; /** * Opens the data source. */ open(): Promise; /** * Closes the data source. */ close(): Promise; /** * Returns whether the data source is opened. */ isOpen(): boolean; }