import TypeIndex from "../../indexing/type_index.js"; import ParsingBuffer from "../../parsing/parsing_buffer.js"; import StepVtableBuilder, { IndexMark } from "./step_vtable_builder.js"; export interface StepIndexEntryBase { address: number; length: number; typeID?: TypeIDType; expressID?: number; multiMapping?: StepIndexEntryBase[]; inlineEntities?: StepInlineIndexEntry[]; } export interface StepInlineIndexEntry extends StepIndexEntryBase { expressID?: undefined; } export interface StepIndexEntry extends StepIndexEntryBase { expressID: number; } export interface StepIndex { elements: StepIndexEntry[]; } export interface Argument { type: number; value: any; } /** * */ export declare enum ParseResult { COMPLETE = 0, INCOMPLETE = 1, SYNTAX_ERROR = 2, MISSING_TYPE = 3, INVALID_STEP = 4 } export type BlockParseResult = [ StepIndex, ParseResult ]; export type LineArgumentParseResult = [ StepIndex, ParseResult ]; /** * Byte-cursor progress callback for the data-parse loop โ€” the parse phase is * determinate in bytes (cursor position / buffer size). Kept primitive so the * parser stays decoupled from the higher-level progress event contract in * core/progress.ts (ProgressTracker maps this into a ProgressEvent). */ export type ParseProgressCallback = (cursorBytes: number) => void; export interface StepHeader { headers: Map; } export type HeaderParseResult = [ StepHeader, ParseResult ]; /** * Parser base for header parsing. */ export declare class StepHeaderParser { private static instance_?; /** * Get the singleton static instance of this. * * @return {StepHeaderParser} The singleton instance of this. */ static get instance(): StepHeaderParser; /** * Will parse the input up to data block (including the DATA token). * * @param input The input buffer to parse the header from. * @return {HeaderParseResult} The parse result for the header, plus the header values. */ parseHeader(input: ParsingBuffer): HeaderParseResult; } /** * Parses out STEP files to allow indexing and deserialization. */ export default class StepParser extends StepHeaderParser { private readonly index_; /** * Construct this with the type-index that will be used to map element types * to tokens. * * @param index_ The index. */ constructor(index_: Readonly>); /** * This uses a much lighter non correctness verifying parse to extract the locations of * the fields for an entry, using the v-table builder to * append the top level entries. * * In this case, the cursor should represent the start of the * * @param input * @param cursor * @param endCursor * @param vtableBuilder * @return {[IndexMark, number] | undefined} The vtable slice or undefined if it's not * defined due to an error. */ extractDataEntry(input: Uint8Array, cursor: number, endCursor: number, vtableBuilder: StepVtableBuilder): [ IndexMark, number, number ] | undefined; /** * Parse the data block of a step file, indexing it. * * Synchronous driver over parseDataBlockIncremental โ€” see * parseDataBlockAsync for the cooperative (repaint-friendly) variant. * * @param input The input parsing buffer, in the data section. * @param onProgress Optional byte-cursor progress callback, invoked * roughly every PARSE_PROGRESS_ELEMENT_MASK + 1 elements. * @return {BlockParseResult} The parsing result, including the index and result enum. */ parseDataBlock(input: ParsingBuffer, onProgress?: ParseProgressCallback): BlockParseResult; /** * Streaming driver over parseDataBlockIncremental: identical parse (same * generator body) but invokes `onRecordBoundary` at every top-level record * boundary so a caller feeding the parser from a moving window can slide * that window forward while the rewind stack is empty. See * streaming_index_builder.ts for the coordinator that owns the window. * * @param input The input parsing buffer, positioned at the data section. * @param onRecordBoundary Called at each top-level record boundary with the * buffer; the callback may rebase the buffer's window in place. * @param onProgress Optional byte-cursor progress callback. * @return {BlockParseResult} The parsing result, including the index and result enum. */ parseDataBlockStreamed(input: ParsingBuffer, onRecordBoundary: (input: ParsingBuffer) => void, onProgress?: ParseProgressCallback): BlockParseResult; /** * Cooperative variant of parseDataBlock: identical parse (same generator * body), but periodically awaits a macrotask so the event loop can run โ€” * browsers repaint progress UI, watchdog timers fire, and the tab is not * flagged as stalled during a large parse. Issue #301 ยง2. * * @param input The input parsing buffer, in the data section. * @param onProgress Optional byte-cursor progress callback. * @param yieldIntervalMs Minimum ms between event-loop yields. * @return {Promise} The parsing result, including the * index and result enum. */ parseDataBlockAsync(input: ParsingBuffer, onProgress?: ParseProgressCallback, yieldIntervalMs?: number): Promise>; /** * Parse the data block of a step file, indexing it, suspending with the * current byte cursor every PARSE_PROGRESS_ELEMENT_MASK + 1 elements so * drivers can report progress (and optionally yield to the event loop) * without the loop body diverging between sync and async paths. * * @param input The input parsing buffer, in the data section. * @yields {number} The current byte cursor within the input buffer. * @return {BlockParseResult} The parsing result, including the index and result enum. */ private parseDataBlockIncremental; /** * Parse arguments from a single line from a step file, indexing it., * * @param input The input parsing buffer, in the data section. * @param expressID * @return {LineArgumentParseResult} The parsing result, including the * arguments array and result enum. */ extractArguments(input: ParsingBuffer, expressID: number): [ any, ParseResult ]; } //# sourceMappingURL=step_parser.d.ts.map