import ByteReader from './ByteReader'; import Instance, { InstanceRoot } from './Instance'; /** * Types used by the binary parser. A Group holds a class name and the * instances that belong to that group. ParserResult is returned from * BinaryParser.parse() and contains the root of the instance tree and a * flat list of all instances, along with scratch arrays used during * parsing. */ export interface ParserResult { result: InstanceRoot; reader: ByteReader; instances: Instance[]; groups: Group[]; sharedStrings: any[]; meta: { [key: string]: any; }; arrays: any[][]; arrayIndex: number; } export interface Group { ClassName: string; Objects: Instance[]; } /** * BinaryParser decodes the Roblox binary model format (.rbxm/.rbxl). The * implementation is adapted from the original rbx-reader project but * stripped of attribute deserialization. Unsupported or unknown data types * are left as raw values. The parser exposes a single parse() method * which accepts an ArrayBuffer and returns a ParserResult containing the * parsed object hierarchy. */ declare const BinaryParser: { HeaderBytes: number[]; Faces: number[][]; DataTypes: (string | null)[]; /** * Parse a Roblox binary buffer and return a ParserResult. This method * throws if the header is invalid or if the format version is not * recognised. */ parse(buffer: ArrayBuffer): ParserResult; /** * Given the starting offset of a chunk, read its type and dispatch to the * appropriate handler. Unknown chunk types are ignored. */ parseChunk(parser: ParserResult, startIndex: number): void; /** * Parse the META chunk which contains arbitrary key/value string pairs. */ parseMETA(parser: ParserResult, chunk: ByteReader): void; /** * Parse the SSTR chunk which defines shared strings. Shared strings * reference large string values by an MD5 hash and are used by later * chunks to avoid duplication. The parser stores them in the * sharedStrings array. */ parseSSTR(parser: ParserResult, chunk: ByteReader): void; /** * Parse the INST chunk which declares a group of instances of a given * class. Each INST record creates one or more Instance objects and * stores them in the parser's groups list. */ parseINST(parser: ParserResult, chunk: ByteReader): void; /** * Parse the PROP chunk which assigns properties to a previously created * group of instances. Depending on the data type, values may be read * interleaved or sequentially. Unsupported types are ignored. */ parsePROP(parser: ParserResult, chunk: ByteReader): void; /** * Parse the PRNT chunk which establishes the parent/child relationships * between previously declared instances. A parentId of -1 indicates * membership at the root level. */ parsePRNT(parser: ParserResult, chunk: ByteReader): void; }; export default BinaryParser;