/** * Browser-side wrapper around `parser.worker.ts`. * * Lifecycle: * 1. Caller allocates a SharedArrayBuffer for the IFC bytes (so that the * same memory can also be handed to the geometry workers without a * copy). * 2. Caller constructs a `WorkerParser` and calls `parseColumnar(sab, …)`. * 3. The worker emits `progress`, `diagnostic`, optional `partial-store`, * then `complete` (or `error`). This wrapper resolves the returned * Promise on `complete` and self-terminates afterward. * * On `partial-store` the wrapper invokes `options.onSpatialReady` so the * viewer can render the spatial-hierarchy panel before the full parse * completes (matches the in-process callback behavior). */ import type { IfcDataStore } from './columnar-parser.js'; import type { ParseOptions } from './index.js'; import { type ParserMemorySnapshot } from './data-store-transport.js'; export interface WorkerParserOptions extends ParseOptions { /** Override the worker URL. Default: bundler-resolved `parser.worker.ts`. */ workerUrl?: URL | string; /** Optional callback receiving the per-parse memory snapshot at completion. */ onMemorySnapshot?: (snapshot: ParserMemorySnapshot) => void; /** * Tell the worker to wait for `setEntityIndex` before running its WASM * scan. Enable when the streaming geometry pre-pass will hand over the * entity index — saves a duplicate 6–10 s scan on huge files. */ waitForEntityIndex?: boolean; } export declare class WorkerParser { private worker; private requestCounter; private readonly workerUrl; /** * Queued entity-index payload. If `setEntityIndex` is called before the * worker is spawned (rare — happens only if the caller races a parser * worker race condition), buffer it and flush on first parse. */ private queuedEntityIndex; /** * Returns true when this runtime can run the parser worker: * `Worker` constructor available, `SharedArrayBuffer` available, and * cross-origin-isolated. Callers should check this before allocating * a SAB and falling through to the in-process parser when it returns * false. The parser itself is SAB-decode-safe (see `utf8-decode.ts`), * so no `TextDecoder` probe is needed here. */ static isSupported(): boolean; constructor(options?: { workerUrl?: URL | string; }); /** * Parse a SharedArrayBuffer-backed IFC payload in a Web Worker. * * The buffer is shared by reference — the caller may keep a `Uint8Array` * view of the same SAB on the main thread (e.g. for the geometry worker * pre-pass). The worker neither transfers nor mutates the buffer. */ parseColumnar(source: SharedArrayBuffer, options?: WorkerParserOptions): Promise; /** * Hand the worker a pre-built entity index (typically from the streaming * geometry pre-pass). May be called before or after `parseColumnar` — * if before, the payload is queued and posted as soon as the worker is * spawned. The parser worker uses the index to skip its WASM scan. */ setEntityIndex(ids: Uint32Array, starts: Uint32Array, lengths: Uint32Array): void; /** Terminate the worker if running. Safe to call repeatedly. */ terminate(): void; } //# sourceMappingURL=worker-parser.d.ts.map