UNPKG

@runejs/filestore

Version:

Tools for managing the RuneJS filestore.

99 lines (98 loc) 3.73 kB
import { Archive } from './archive'; import { FileData } from './file-data'; import { type FilestoreChannels } from './data'; /** * String representations of numeric index ids. */ export type IndexId = 'configs' | 'sprites' | 'music' | 'jingles' | 'sounds' | 'binary' | 'widgets' | 'regions' | 'models' | 'textures' | 'scripts' | 'frames' | 'skeletons'; /** * A map of unique index keys to numeric ids. */ export declare const indexIdMap: { [key: string]: number; }; /** * Finds the corresponding string index key for the given numeric id. * @param index The numeric index id to find the name of. */ export declare const getIndexId: (index: number) => IndexId; export declare class FileIndex { /** * The ID of this File Index. */ readonly indexId: number; /** * The file format used by the File Index. */ format: number; /** * The current version of the File Index, if versioned. */ version: number; /** * The method used by the File Index for data compression. */ compression: number; /** * Additional settings and information about the File Index (name & whirlpool information). */ settings: number; /** * A map of all files housed within this File Index. Values are either an `Archive` or `FileData` object. */ files: Map<number, Archive | FileData>; private readonly filestoreChannels; /** * Creates a new File Index with the specified index ID and filestore channel. * @param indexId The ID of this File Index. * @param filestoreChannels The main filestore channel for data access. */ constructor(indexId: number, filestoreChannels: FilestoreChannels); /** * Fetches a single file from this index. * @param fileId The ID of the file to fetch. * @returns The requested FileData object, or null if no matching file was found. */ getFile(fileId: number): FileData | null; /** * Fetches a single file from this index. * @param fileName The name of the file to fetch. * @returns The requested FileData object, or null if no matching file was found. */ getFile(fileName: string): FileData | null; /** * Fetches a single file from this index. * @param fileIdOrName The ID or name of the file to fetch. * @param keys The XTEA keys. * @returns The requested FileData object, or null if no matching file was found. */ getFile(fileIdOrName: number | string, keys?: number[]): FileData | null; /** * Fetches an archive from this index. * @param archiveId The ID of the archive to fetch. * @returns The requested Archive object, or null if no Archive was found. */ getArchive(archiveId: number): Archive | null; /** * Fetches an archive from this index. * @param archiveName The name of the archive to fetch. * @returns The requested Archive object, or null if no Archive was found. */ getArchive(archiveName: string): Archive | null; /** * Fetches an archive from this index. * @param archiveIdOrName The ID or name of the archive to fetch. * @returns The requested Archive object, or null if no Archive was found. */ getArchive(archiveIdOrName: number | string): Archive | null; /** * Fetches an archive or file from this index by name. * @param fileName The name of the archive or file to search for. * @returns An Archive or FileData object, or null if no matching files were found with the specified name. */ findByName(fileName: string): Archive | FileData | null; /** * Decodes the packed index file data from the filestore on disk. */ decodeIndex(): void; }