/** * acadrust DWG parser wrapper — loads the wasm built from rust/dwg-wasm * (wasm-pack --target web, committed under ./acadrust-dwg). */ import init, { parse_dwg } from './acadrust-dwg/acadrust_dwg.js'; import wasmUrl from './acadrust-dwg/acadrust_dwg_bg.wasm?url'; import type { CadParseResult } from './dwgParser'; let ready: Promise | null = null; /** Initialize the acadrust WASM module once (idempotent). */ export function initAcadrustParser(): Promise { if (!ready) ready = init({ module_or_path: wasmUrl }).then(() => undefined); return ready; } /** Parse a DWG buffer. Requires initAcadrustParser() first. */ export function parseDwgAcadrust(bytes: Uint8Array): CadParseResult { return parse_dwg(bytes) as CadParseResult; }