@flyfish-dev/cad-viewer 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,6 +12,13 @@ The project provides a clean loader architecture for **DWG**, **DXF**, **DWF**,
12
12
 
13
13
  > DWG support uses `@mlightcad/libredwg-web` / LibreDWG WebAssembly in a worker. DXF support uses JavaScript parsing plus a built-in fallback parser. DWF, DWFx and XPS support is powered by `dwf-viewer` 0.6.x, including DWF 6+ ZIP containers, WHIP/W2D 2D sheets, W3D/HSF 3D eModel geometry, DWFx/OPC/XPS pages, adaptive CAD line weights and an optional raster WASM fallback.
14
14
 
15
+ ## What changed in 0.6.5
16
+
17
+ - Preserved active DWG VPORT/header UCS saved views and applied safe planar scene transforms exactly once across geometry, text, inserts, bounds and interaction coordinates.
18
+ - Added DWG LTYPE normalization and Canvas2D/WebGL rendering for dashed, dotted, BYLAYER and BYBLOCK linetypes, including continuous polyline phase and entity/global scale handling.
19
+ - Preserved LibreDWG closed-polyline flags and added guarded fallbacks for tilted views, complex SHX linetype glyphs and pathological microscopic patterns.
20
+ - Added public line-pattern helpers, `getSourceDocument()` and an eight-case DWG normalization regression suite.
21
+
15
22
  ## What changed in 0.6.4
16
23
 
17
24
  - Added a stable package export for `@flyfish-dev/cad-viewer/wasm/dwg-worker.js`.
@@ -85,6 +92,7 @@ The project provides a clean loader architecture for **DWG**, **DXF**, **DWF**,
85
92
  - **Pure frontend viewer component**: `new CadViewer({ container })` or `new CadViewer({ canvas })`.
86
93
  - **Loader registry**: DWG, DXF and DWF loaders are independent and replaceable; native-renderable loaders can mount their own optimized viewer.
87
94
  - **DWG preview**: browser-local parsing through LibreDWG WebAssembly, executed in a Web Worker by default.
95
+ - **DWG view and linetype fidelity**: active planar saved views, closed polylines, LTYPE tables, BYLAYER/BYBLOCK inheritance, dash/dot patterns and stable pattern scaling.
88
96
  - **DXF preview**: JavaScript parser path with fallback support for common ASCII DXF `ENTITIES`.
89
97
  - **DWF/DWFx/XPS preview**: powered by `dwf-viewer` for DWF ZIP packages, WebGL-accelerated W2D and XPS/DWFx 2D vectors, W3D/HSF eModel geometry, embedded XPS fonts, adaptive CAD line weights and raster fallback.
90
98
  - **CAD color handling**: ACI, BYLAYER, BYBLOCK inheritance, DWG layer colors, true color, fill color, opacity and adaptive contrast.
@@ -291,6 +299,8 @@ viewer.zoomIn();
291
299
  viewer.zoomOut();
292
300
  await viewer.preloadDwg(); // optional DWG worker/WASM warmup
293
301
  viewer.setCanvasOptions({ background: '#f7f8fb', foreground: '#111827' });
302
+ viewer.getDocument(); // transformed render-space CadDocument
303
+ viewer.getSourceDocument(); // parser-owned WCS CadDocument
294
304
  viewer.clear();
295
305
  viewer.destroy();
296
306
  ```
@@ -355,7 +365,7 @@ viewer.registerLoader({
355
365
 
356
366
  | Format | Loader | Coverage |
357
367
  |---|---|---|
358
- | DWG | `DwgLoader` | Uses LibreDWG WebAssembly. Rendering coverage depends on the entities exposed by LibreDWG conversion. |
368
+ | DWG | `DwgLoader` | Uses LibreDWG WebAssembly. Preserves active planar saved views, closed polylines and LTYPE definitions; Canvas2D/WebGL render dash/dot patterns with BYLAYER/BYBLOCK inheritance. Complex SHX glyphs use a marker approximation. |
359
369
  | DXF | `DxfLoader` | Uses `dxf-parser` plus fallback parsing. Supports codepage-aware text decoding, CAD text escape normalization, core entities, blocks/inserts, colors/layers, polylines, hatch boundaries and splines as preview polylines. |
360
370
  | DWF | `DwfLoader` + `dwf-viewer` | DWF 6+ ZIP packages, WHIP/W2D 2D sheets, W3D/HSF 3D eModel pages, model tree metadata, WebGL rendering and optional WASM fallback. |
361
371
  | DWFx / XPS | `DwfLoader` + `dwf-viewer` | DWFx/OPC/XPS pages with WebGL-accelerated vector paths, embedded fonts, text, images, package resources and adaptive overview line weights through the native DWF renderer. |
@@ -385,6 +395,7 @@ new CadViewer({ canvasOptions: { trueColorByteOrder: 'bgr' } });
385
395
  npm install
386
396
  npm run dev # run the demo
387
397
  npm run typecheck # TypeScript validation
398
+ npm test # build the library and run DWG normalization regressions
388
399
  npm run build # library + demo
389
400
  npm run preview # preview built demo
390
401
  ```
package/README.zh-CN.md CHANGED
@@ -12,6 +12,13 @@
12
12
 
13
13
  > DWG 使用 `@mlightcad/libredwg-web` / LibreDWG WebAssembly,并默认运行在 Worker 中。DXF 使用 JavaScript 解析器并带内置 fallback。DWF、DWFx、XPS 由 `dwf-viewer` 0.6.x 驱动,覆盖 DWF 6+ ZIP 包、WHIP/W2D 2D 图纸、W3D/HSF 3D eModel、DWFx/OPC/XPS 页面、自适应 CAD 线宽和可选 raster WASM fallback。
14
14
 
15
+ ## 0.6.5 变更
16
+
17
+ - 保留 DWG active VPORT/header UCS saved view,并将安全的平面场景变换只应用一次,统一覆盖几何、文字、INSERT、bounds 和交互坐标。
18
+ - 新增 DWG LTYPE 归一化与 Canvas2D/WebGL 线型渲染,支持虚线、点线、BYLAYER、BYBLOCK、多段线连续相位以及实体/全局缩放。
19
+ - 保留 LibreDWG 的闭合多段线标志;对倾斜视图、复杂 SHX 线型 glyph 和异常微小 pattern 提供明确降级策略。
20
+ - 新增公开线型工具、`getSourceDocument()` 和 8 项 DWG normalization 回归测试。
21
+
15
22
  ## 0.6.4 变更
16
23
 
17
24
  - 新增稳定的 package subpath:`@flyfish-dev/cad-viewer/wasm/dwg-worker.js`。
@@ -85,6 +92,7 @@
85
92
  - **纯前端组件**:`new CadViewer({ container })` 或 `new CadViewer({ canvas })`。
86
93
  - **正确的 loader 架构**:DWG / DXF / DWF 独立 loader,可替换、可扩展;native-renderable loader 可以挂载自己的优化渲染器。
87
94
  - **DWG 预览**:通过 LibreDWG WebAssembly 在浏览器本地解析,默认在 Web Worker 中执行。
95
+ - **DWG 视图与线型保真**:active 平面 saved view、闭合多段线、LTYPE 表、BYLAYER/BYBLOCK 继承、dash/dot pattern 和稳定线型缩放。
88
96
  - **DXF 预览**:JavaScript 解析,支持常见 ASCII DXF `ENTITIES`,并带 fallback parser。
89
97
  - **DWF/DWFx/XPS 预览**:由 `dwf-viewer` 支持 DWF ZIP 包、WebGL 加速 W2D 与 XPS/DWFx 2D 矢量、W3D/HSF eModel、XPS 嵌入字体、自适应 CAD 线宽和 raster fallback。
90
98
  - **CAD 颜色处理**:支持 ACI、BYLAYER、BYBLOCK 继承、DWG 图层颜色、true color、填充色、透明度和自适应对比度。
@@ -291,6 +299,8 @@ viewer.zoomIn();
291
299
  viewer.zoomOut();
292
300
  await viewer.preloadDwg(); // 可选 DWG worker/WASM 预热
293
301
  viewer.setCanvasOptions({ background: '#f7f8fb', foreground: '#111827' });
302
+ viewer.getDocument(); // 已应用 saved view 的渲染场景 CadDocument
303
+ viewer.getSourceDocument(); // parser 保留的原始 WCS CadDocument
294
304
  viewer.clear();
295
305
  viewer.destroy();
296
306
  ```
@@ -355,7 +365,7 @@ viewer.registerLoader({
355
365
 
356
366
  | 格式 | Loader | 支持范围 |
357
367
  |---|---|---|
358
- | DWG | `DwgLoader` | 使用 LibreDWG WebAssembly。渲染完整度取决于 LibreDWG converter 暴露出的实体。 |
368
+ | DWG | `DwgLoader` | 使用 LibreDWG WebAssembly。保留 active 平面 saved view、闭合多段线和 LTYPE 定义;Canvas2D/WebGL 支持 dash/dot 与 BYLAYER/BYBLOCK 继承,复杂 SHX glyph 使用 marker 近似。 |
359
369
  | DXF | `DxfLoader` | 使用 `dxf-parser` + 内置 fallback。支持 codepage-aware 文本解码、CAD 文本转义归一化、基础实体、block/insert、颜色/图层、多段线、hatch boundary、spline 预览。 |
360
370
  | DWF | `DwfLoader` + `dwf-viewer` | DWF 6+ ZIP 包、WHIP/W2D 2D 图纸、W3D/HSF 3D eModel、模型树元数据、WebGL 渲染和可选 WASM fallback。 |
361
371
  | DWFx / XPS | `DwfLoader` + `dwf-viewer` | DWFx/OPC/XPS 页面,包含 WebGL 加速 vector path、嵌入字体、文本、图片、包内资源和自适应总览线宽,通过原生 DWF 渲染器展示。 |
@@ -385,6 +395,7 @@ new CadViewer({ canvasOptions: { trueColorByteOrder: 'bgr' } });
385
395
  npm install
386
396
  npm run dev # 运行 demo
387
397
  npm run typecheck # TypeScript 检查
398
+ npm test # 构建 library 并运行 DWG normalization 回归测试
388
399
  npm run build # 构建 library + demo
389
400
  npm run preview # 预览构建后的 demo
390
401
  ```