refactor: extract viewer2d workspace package

This commit is contained in:
2026-07-29 09:03:41 +09:00
parent 95fa6a452b
commit 5e10bb1be4
27 changed files with 1588 additions and 704 deletions
+20
View File
@@ -0,0 +1,20 @@
/**
* 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<void> | null = null;
/** Initialize the acadrust WASM module once (idempotent). */
export function initAcadrustParser(): Promise<void> {
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;
}