The shipped wasm was built from a vendored acadrust 0.4.1 carrying local changes in two files (read_mesh array bounds, OLE2FRAME corner decoding), and the published read_mesh patch did not even apply to the pristine crate, so the notice could not reproduce the source compiled into the wasm (MPL-2.0 3.2). acadrust 0.6.5 already does both on its own: the road-surface MESH and the C0060203 OLE2FRAME come out identical to the patched build, so the parser now uses the crate exactly as crates.io serves it. The notices name 0.6.5, its upstream commit and the crate SHA-256 (equal to the Cargo.lock checksum the build used), the stale patch file is removed, and the page links to the crate source instead. Verified on 22 samples, loading each with the old and the new wasm in Chrome: all load, 17 render pixel-identical, and the 5 that differ are 0.4.1 misreads that 0.6.5 corrects. The wrapper changes this needed live in hmwebviewer rust/dwg-wasm (branch chore/acadrust-0.6.5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
/**
|
|
* DWG parser — rust/dwg-wasm wrapper around the acadrust crate (MPL-2.0,
|
|
* 0.6.5 from crates.io, unmodified; see hmwebviewer rust/dwg-wasm). Emits
|
|
* the parseResult shape Viewer2D.load() consumes. Lazy-imported so the wasm is
|
|
* only fetched when a DWG is actually opened.
|
|
*
|
|
* History: until 2026-07-10 this module selected between acadrust and
|
|
* @horu2day/pure-cad-parser (?dwgparser= toggle). The old parser was removed
|
|
* after side-by-side validation (PROGRESS.md Phase 15).
|
|
*
|
|
* Post-process: fixDwgKoreanText repairs CP949→Latin-1 mojibake common in
|
|
* older Korean DWGs (see fixDwgKoreanText.ts). Unicode-correct drawings
|
|
* (e.g. BasicSample) are left unchanged.
|
|
*/
|
|
|
|
import { fixDwgKoreanText } from './fixDwgKoreanText';
|
|
|
|
export type CadParseResult = {
|
|
version?: string;
|
|
vars?: Record<string, unknown>;
|
|
entities?: unknown[];
|
|
tables?: Record<string, unknown>;
|
|
stats?: Record<string, unknown>;
|
|
};
|
|
|
|
/** Parse a DWG buffer. Returns a parseResult for Viewer2D.load(). */
|
|
export async function parseDwgBuffer(bytes: Uint8Array): Promise<CadParseResult> {
|
|
const { initAcadrustParser, parseDwgAcadrust } = await import('./acadrustParser');
|
|
await initAcadrustParser();
|
|
return fixDwgKoreanText(parseDwgAcadrust(bytes));
|
|
}
|