@flyfish-dev/cad-viewer 0.5.3 → 0.6.1

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/NOTICE CHANGED
@@ -1,11 +1,9 @@
1
1
  @flyfish-dev/cad-viewer
2
2
 
3
- This project is licensed under AGPL-3.0-only.
4
-
5
- This project includes optional/default integrations with third-party open-source projects:
3
+ This project integrates third-party open-source projects for CAD parsing and rendering:
6
4
 
7
5
  - @mlightcad/libredwg-web: DWG parsing in the browser through LibreDWG WebAssembly. License: GPL-3.0-only.
8
6
  - dxf-parser: DXF parser for JavaScript. License: MIT.
9
- - fflate: ZIP/DEFLATE utilities for DWFx/XPS package parsing. License: MIT.
7
+ - dwf-viewer 0.6.x: native frontend DWF/DWFx/XPS renderer for DWF 6+ ZIP containers, DWFx/OPC/XPS, WHIP/W2D 2D sheets, W3D/HSF eModel content, embedded XPS fonts and optional WASM fallback. License: AGPL-3.0-only.
10
8
 
11
- Classic DWF support is intentionally limited to package detection and DWFx/XPS-compatible 2D content. Full classic DWF WHIP/W2D coverage normally requires Autodesk/ODA DWF Toolkit or an equivalent implementation.
9
+ The combined package is distributed under AGPL-3.0-only. Keep attribution and license notices when redistributing, modifying, embedding, or using this package as part of another application.
package/README.md CHANGED
@@ -8,10 +8,27 @@ A professional, lightweight, extensible **frontend CAD viewer** for modern brows
8
8
  **Live demo:** [cad-viewer-iys.pages.dev](https://cad-viewer-iys.pages.dev)
9
9
  **Source:** [github.com/flyfish-dev/cad-viewer](https://github.com/flyfish-dev/cad-viewer)
10
10
 
11
- The project provides a clean loader architecture for **DWG**, **DXF** and **DWFx/XPS-compatible DWF preview**, normalizes format-specific data into a common `CadDocument`, and renders it through a retained WebGL pipeline with a lightweight Canvas overlay for text and images. Files are read locally in the browser; the viewer does not upload drawings to a backend.
11
+ The project provides a clean loader architecture for **DWG**, **DXF**, **DWF**, **DWFx** and **XPS**. DWG/DXF are normalized into a common `CadDocument` and rendered through retained WebGL with a lightweight Canvas overlay; DWF/DWFx/XPS are delegated to the native `dwf-viewer` renderer for WebGL-accelerated W2D and XPS/DWFx vectors, W3D/HSF eModel geometry, embedded XPS fonts and optional WASM fallback. Files are read locally in the browser; the viewer does not upload drawings to a backend.
12
12
 
13
- > DWG support uses `@mlightcad/libredwg-web` / LibreDWG WebAssembly. DXF support uses JavaScript parsing plus a built-in fallback parser. DWFx support parses XPS `FixedPage` vector pages. Classic `.dwf` WHIP/W2D/W3D streams are detected and reported clearly, but full classic DWF decoding still requires a dedicated WHIP decoder or DWF Toolkit/WASM implementation.
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.1
16
+
17
+ - Updated the native DWF path to `dwf-viewer` 0.6.1.
18
+ - Adopted the current renderer behavior for WebGL-accelerated XPS/DWFx and W2D 2D vector rendering, W3D/HSF 3D rendering, embedded XPS font loading and optional WASM raster fallback.
19
+ - Exposed DWF/XPS overview tuning through `dwfLineWeightMode`, `dwfMinStrokeCssPx`, `dwfMaxOverviewStrokeCssPx`, `dwfMinTextCssPx` and `dwfMinFilledAreaCssPx`.
20
+ - Refreshed README, format notes, architecture notes and package metadata for the latest DWF support.
21
+
22
+ ## What changed in 0.6.0
23
+
24
+ - Replaced the previous DWFx/XPS subset parser with the published `dwf-viewer` native renderer.
25
+ - DWF/DWFx/XPS files now mount a dedicated native viewer path instead of being forced into the DWG/DXF `CadDocument` renderer.
26
+ - Added support for DWF 6+ ZIP packages, WHIP/W2D 2D sheets, W3D/HSF 3D eModel pages, DWFx/OPC/XPS pages and dwf-viewer's WebGL/WASM render backends.
27
+ - Added `CadNativeRenderableLoader`, allowing loaders to mount an optimized DOM/WebGL viewer when a format needs more than the normalized 2D scene model.
28
+ - Added `dwfWasmUrl`, `dwfPreferWebgl`, `dwfPreferWasm`, `dwfMaxCanvasPixels`, `dwfMaxGpuCacheBytes` and related production options.
29
+ - Runtime asset scripts now copy and validate both `libredwg-web.wasm` and `dwfv-render.wasm`.
30
+ - Removed the old classic-DWF warning path and the `fflate` dependency from this package.
31
+ - Updated package licensing to AGPL-3.0-only to match the integrated DWF renderer.
15
32
 
16
33
  ## What changed in 0.5.3
17
34
 
@@ -49,10 +66,10 @@ The project provides a clean loader architecture for **DWG**, **DXF** and **DWFx
49
66
  ## Features
50
67
 
51
68
  - **Pure frontend viewer component**: `new CadViewer({ container })` or `new CadViewer({ canvas })`.
52
- - **Loader registry**: DWG, DXF and DWF loaders are independent and replaceable.
69
+ - **Loader registry**: DWG, DXF and DWF loaders are independent and replaceable; native-renderable loaders can mount their own optimized viewer.
53
70
  - **DWG preview**: browser-local parsing through LibreDWG WebAssembly, executed in a Web Worker by default.
54
71
  - **DXF preview**: JavaScript parser path with fallback support for common ASCII DXF `ENTITIES`.
55
- - **DWF/DWFx preview**: DWFx/XPS 2D `FixedPage` rendering for paths, glyphs and images.
72
+ - **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.
56
73
  - **CAD color handling**: ACI, BYLAYER, BYBLOCK inheritance, DWG layer colors, true color, fill color, opacity and adaptive contrast.
57
74
  - **High-performance WebGL viewport controls**: retained GPU buffers, spatial culling, zoom, pan, fit-to-view, cursor world coordinates and zoom percentage.
58
75
  - **Professional demo UI**: drag-and-drop, compact toolbar, status strip, parse/render timing, entity summary and warnings.
@@ -71,16 +88,16 @@ npm install
71
88
  npm run dev
72
89
  ```
73
90
 
74
- The DWG loader needs LibreDWG WASM assets in a public directory. This repository copies and validates them for the demo:
91
+ The DWG and DWF render paths need runtime WASM assets in a public directory. This repository copies and validates them for the demo:
75
92
 
76
93
  ```bash
77
94
  npm run copy:wasm
78
95
  npm run check:wasm
79
96
  ```
80
97
 
81
- The demo resolves `wasmPath` to an absolute URL before sending it to the worker. In your own app, prefer an absolute path or URL, for example `/wasm` or `new URL('wasm/', document.baseURI).href`. Avoid passing a worker-relative path such as `./wasm` unless it is resolved on the UI thread first.
98
+ The demo resolves `wasmPath` to an absolute URL before sending it to the DWG worker and uses the same directory for `dwfv-render.wasm`. In your own app, prefer an absolute path or URL, for example `/wasm` or `new URL('wasm/', document.baseURI).href`. Avoid passing a worker-relative path such as `./wasm` unless it is resolved on the UI thread first.
82
99
 
83
- When publishing the npm package, `build:lib` also copies these files into `dist/wasm` and exposes them as package subpaths. Applications still need to serve the `.wasm` from a public URL and pass that directory as `wasmPath`.
100
+ When publishing the npm package, `build:lib` copies these files into `dist/wasm` and exposes them as package subpaths. Applications still need to serve the `.wasm` files from a public URL and pass that directory as `wasmPath`, or pass `dwfWasmUrl` explicitly.
84
101
 
85
102
 
86
103
  ## Demo startup notes
@@ -110,6 +127,7 @@ const viewer = new CadViewer({
110
127
  container: document.querySelector('#viewer')!,
111
128
  renderer: 'auto', // WebGL first, Canvas2D fallback
112
129
  wasmPath: new URL('wasm/', document.baseURI).href,
130
+ dwfWasmUrl: new URL('wasm/dwfv-render.wasm', document.baseURI).href,
113
131
  canvasOptions: {
114
132
  background: '#05070d',
115
133
  foreground: '#f8fafc',
@@ -177,6 +195,7 @@ const controller = new AbortController();
177
195
  const viewer = new CadViewer({
178
196
  container,
179
197
  wasmPath: new URL('wasm/', document.baseURI).href,
198
+ dwfWasmUrl: new URL('wasm/dwfv-render.wasm', document.baseURI).href,
180
199
  useWorker: true,
181
200
  workerTimeoutMs: 120_000,
182
201
  onLoadProgress(progress) {
@@ -197,6 +216,7 @@ Advanced deployments can override the worker constructor when the bundler or CDN
197
216
  new CadViewer({
198
217
  container,
199
218
  wasmPath: new URL('wasm/', document.baseURI).href,
219
+ dwfWasmUrl: new URL('wasm/dwfv-render.wasm', document.baseURI).href,
200
220
  workerUrl: new URL('/assets/dwg-worker.js', window.location.origin)
201
221
  });
202
222
  ```
@@ -210,7 +230,8 @@ const viewer = new CadViewer({
210
230
  container, // HTMLElement; creates a canvas inside
211
231
  canvas, // optional existing HTMLCanvasElement
212
232
  renderer: 'auto', // 'auto' | 'webgl' | 'canvas2d'
213
- wasmPath: '/wasm', // LibreDWG WebAssembly asset path. Absolute URL/path recommended for workers
233
+ wasmPath: '/wasm', // directory containing libredwg-web.wasm and dwfv-render.wasm
234
+ dwfWasmUrl: '/wasm/dwfv-render.wasm',
214
235
  autoFit: true,
215
236
  canvasOptions: {
216
237
  background: '#05070d',
@@ -229,6 +250,12 @@ const viewer = new CadViewer({
229
250
  },
230
251
  useWorker: true, // default for DWG
231
252
  workerTimeoutMs: 0, // 0 = disabled
253
+ dwfPreferWebgl: true,
254
+ dwfPreferWasm: true,
255
+ dwfMaxCanvasPixels: 16_777_216,
256
+ dwfLineWeightMode: 'adaptive', // 'adaptive' | 'physical' | 'hairline'
257
+ dwfMinStrokeCssPx: 0.42,
258
+ dwfMinTextCssPx: 1.05,
232
259
  onLoadProgress(progress) {},
233
260
  onLoad(result) {},
234
261
  onError(error) {},
@@ -256,11 +283,8 @@ CadLoaderRegistry
256
283
 
257
284
  DwgLoader | DxfLoader | DwfLoader | custom loader
258
285
 
259
- CadDocument
260
-
261
- CadWebGLRenderer | CadCanvasRenderer fallback
262
-
263
- WebGL preview + Canvas overlay
286
+ DWG/DXF: CadDocument → CadWebGLRenderer | CadCanvasRenderer fallback
287
+ DWF/DWFx/XPS: DwfLoader.mount() → dwf-viewer native WebGL vectors / 3D / WASM fallback
264
288
  ```
265
289
 
266
290
  Each loader returns a normalized `CadDocument`:
@@ -312,8 +336,8 @@ viewer.registerLoader({
312
336
  |---|---|---|
313
337
  | DWG | `DwgLoader` | Uses LibreDWG WebAssembly. Rendering coverage depends on the entities exposed by LibreDWG conversion. |
314
338
  | DXF | `DxfLoader` | Uses `dxf-parser` plus fallback parsing. Supports core entities, blocks/inserts, colors/layers, polylines, text, hatch boundaries and splines as preview polylines. |
315
- | DWFx / XPS | `DwfLoader` | Parses ZIP/OPC packages and renders 2D `FixedPage` path/glyph/image content. |
316
- | Classic DWF | `DwfLoader` detection | Detects WHIP/W2D/W3D package content and returns a clear unsupported error. Full classic DWF requires a dedicated WHIP decoder or DWF Toolkit/WASM. |
339
+ | 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. |
340
+ | 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. |
317
341
 
318
342
  ## Color handling
319
343
 
@@ -357,7 +381,7 @@ npm run pack:dry
357
381
 
358
382
  ```bash
359
383
  npm login
360
- npm publish --access public
384
+ npm publish --access public --auth-type=web
361
385
  ```
362
386
 
363
387
  The package also exposes:
@@ -400,12 +424,10 @@ src/
400
424
  viewer/ CadViewer component and Canvas renderer
401
425
  demo/ professional Vite demo UI
402
426
  docs/ English and Chinese architecture / format notes
403
- scripts/ clean and LibreDWG WASM copy helpers
427
+ scripts/ clean and runtime WASM copy/validation helpers
404
428
  public/wasm/ demo WASM asset output directory
405
429
  ```
406
430
 
407
431
  ## License
408
432
 
409
- AGPL-3.0-only. This is a strict copyleft license: if you distribute modified versions or offer modified versions over a network, review your source-code disclosure obligations carefully.
410
-
411
- The default DWG loader depends on `@mlightcad/libredwg-web`, which is GPL-3.0-only. For closed-source commercial use, replace the DWG loader with a properly licensed parser/converter and review all dependency licenses.
433
+ AGPL-3.0-only. The default DWG loader integrates `@mlightcad/libredwg-web` / LibreDWG, and the DWF renderer integrates `dwf-viewer`. Keep attribution and license notices when redistributing, modifying, embedding or using this package as part of another application. For closed-source commercial products, review all dependency licenses and replace loaders where your licensing model requires it.
package/README.zh-CN.md CHANGED
@@ -8,10 +8,27 @@
8
8
  **在线 Demo:** [cad-viewer-iys.pages.dev](https://cad-viewer-iys.pages.dev)
9
9
  **源码仓库:** [github.com/flyfish-dev/cad-viewer](https://github.com/flyfish-dev/cad-viewer)
10
10
 
11
- 本仓库提供面向浏览器的 loader 架构,支持 **DWG**、**DXF**、以及 **DWFx/XPS 兼容 DWF 预览**,将不同 CAD 格式归一化为统一 `CadDocument`,并通过 WebGL retained-mode 渲染,文字/图片使用轻量 Canvas overlay。文件在浏览器本地读取,组件不会把图纸上传到服务端。
11
+ 本仓库提供面向浏览器的 loader 架构,支持 **DWG**、**DXF**、**DWF**、**DWFx** **XPS**。DWG/DXF 会归一化为统一 `CadDocument` 并通过 WebGL retained-mode 渲染,文字/图片使用轻量 Canvas overlay;DWF/DWFx/XPS 交给原生 `dwf-viewer` 渲染通道处理 WebGL 加速的 W2D 与 XPS/DWFx 矢量、W3D/HSF eModel、XPS 嵌入字体和可选 WASM fallback。文件在浏览器本地读取,组件不会把图纸上传到服务端。
12
12
 
13
- > DWG 使用 `@mlightcad/libredwg-web` / LibreDWG WebAssemblyDXF 使用 JavaScript 解析器并带内置 fallback。DWFx 使用 XPS `FixedPage` 2D 页面解析。经典 `.dwf` 里的 WHIP/W2D/W3D 流会被检测并给出明确提示;若要完整解码经典 DWF,仍需要专门 WHIP 解码器或 DWF Toolkit/WASM 实现。
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.1 变更
16
+
17
+ - 原生 DWF 通道升级到 `dwf-viewer` 0.6.1。
18
+ - 同步最新 renderer 行为:WebGL 加速 XPS/DWFx 与 W2D 2D 矢量渲染、W3D/HSF 3D 渲染、XPS 嵌入字体加载和可选 WASM raster fallback。
19
+ - 新增 `dwfLineWeightMode`、`dwfMinStrokeCssPx`、`dwfMaxOverviewStrokeCssPx`、`dwfMinTextCssPx`、`dwfMinFilledAreaCssPx`,用于调节 DWF/XPS 总览渲染效果。
20
+ - 更新 README、格式说明、架构说明和 package metadata,统一最新版 DWF 支持口径。
21
+
22
+ ## 0.6.0 变更
23
+
24
+ - 使用已发布的 `dwf-viewer` 原生渲染器替换旧 DWFx/XPS 子集解析器。
25
+ - DWF/DWFx/XPS 不再强行转成普通 DWG/DXF 的 2D `CadDocument` 渲染链路,而是通过专用 native viewer 挂载。
26
+ - 新增 DWF 6+ ZIP 包、WHIP/W2D 2D 图纸、W3D/HSF 3D eModel、DWFx/OPC/XPS 页面,以及 dwf-viewer WebGL/WASM 渲染后端集成。
27
+ - 新增 `CadNativeRenderableLoader`,允许某些格式挂载自己的 DOM/WebGL 渲染器。
28
+ - 新增 `dwfWasmUrl`、`dwfPreferWebgl`、`dwfPreferWasm`、`dwfMaxCanvasPixels`、`dwfMaxGpuCacheBytes` 等生产配置。
29
+ - 运行时资源脚本现在会同时复制和校验 `libredwg-web.wasm` 与 `dwfv-render.wasm`。
30
+ - 删除旧 classic-DWF warning 逻辑,并移除本包对 `fflate` 的依赖。
31
+ - 包许可证更新为 AGPL-3.0-only,以匹配集成后的 DWF 渲染器。
15
32
 
16
33
  ## 0.5.3 变更
17
34
 
@@ -49,10 +66,10 @@
49
66
  ## 功能特性
50
67
 
51
68
  - **纯前端组件**:`new CadViewer({ container })` 或 `new CadViewer({ canvas })`。
52
- - **正确的 loader 架构**:DWG / DXF / DWF 独立 loader,可替换、可扩展。
69
+ - **正确的 loader 架构**:DWG / DXF / DWF 独立 loader,可替换、可扩展;native-renderable loader 可以挂载自己的优化渲染器。
53
70
  - **DWG 预览**:通过 LibreDWG WebAssembly 在浏览器本地解析,默认在 Web Worker 中执行。
54
71
  - **DXF 预览**:JavaScript 解析,支持常见 ASCII DXF `ENTITIES`,并带 fallback parser。
55
- - **DWF/DWFx 预览**:支持 DWFx/XPS 2D `FixedPage` Path、Glyphs、图片预览。
72
+ - **DWF/DWFx/XPS 预览**:由 `dwf-viewer` 支持 DWF ZIP 包、WebGL 加速 W2D 与 XPS/DWFx 2D 矢量、W3D/HSF eModel、XPS 嵌入字体、自适应 CAD 线宽和 raster fallback。
56
73
  - **CAD 颜色处理**:支持 ACI、BYLAYER、BYBLOCK 继承、DWG 图层颜色、true color、填充色、透明度和自适应对比度。
57
74
  - **WebGL 高性能交互**:GPU retained buffers、空间分桶、视口裁剪、缩放、平移、适配窗口、世界坐标、缩放百分比。
58
75
  - **专业 Demo**:拖拽打开、紧凑工具栏、状态条、解析/渲染耗时、实体类型统计、warnings 展示。
@@ -71,16 +88,16 @@ npm install
71
88
  npm run dev
72
89
  ```
73
90
 
74
- DWG loader 需要将 LibreDWG WASM 文件放到公开目录。Demo 使用以下命令复制并校验到 `public/wasm`:
91
+ DWG DWF 渲染链路需要将运行时 WASM 文件放到公开目录。Demo 使用以下命令复制并校验到 `public/wasm`:
75
92
 
76
93
  ```bash
77
94
  npm run copy:wasm
78
95
  npm run check:wasm
79
96
  ```
80
97
 
81
- Demo 会先把 `wasmPath` 解析为绝对 URL,再发送给 worker。你自己的应用也建议使用绝对路径或绝对 URL,例如 `/wasm` 或 `new URL('wasm/', document.baseURI).href`。不要直接把未解析的 `./wasm` 传入 worker,否则它可能会相对于 worker chunk 请求资源。
98
+ Demo 会先把 `wasmPath` 解析为绝对 URL,再发送给 DWG worker,并复用同一目录查找 `dwfv-render.wasm`。你自己的应用也建议使用绝对路径或绝对 URL,例如 `/wasm` 或 `new URL('wasm/', document.baseURI).href`。不要直接把未解析的 `./wasm` 传入 worker,否则它可能会相对于 worker chunk 请求资源。
82
99
 
83
- 发布 npm 包时,`build:lib` 也会把这些文件复制到 `dist/wasm` 并作为 package subpath 暴露出来。应用侧仍需要把 `.wasm` 放到可公开访问的 URL,并把该目录传给 `wasmPath`。
100
+ 发布 npm 包时,`build:lib` 会把这些文件复制到 `dist/wasm` 并作为 package subpath 暴露出来。应用侧仍需要把 `.wasm` 放到可公开访问的 URL,并把该目录传给 `wasmPath`,或者显式传入 `dwfWasmUrl`。
84
101
 
85
102
 
86
103
  ## Demo 启动说明
@@ -110,6 +127,7 @@ const viewer = new CadViewer({
110
127
  container: document.querySelector('#viewer')!,
111
128
  renderer: 'auto', // WebGL first, Canvas2D fallback
112
129
  wasmPath: new URL('wasm/', document.baseURI).href,
130
+ dwfWasmUrl: new URL('wasm/dwfv-render.wasm', document.baseURI).href,
113
131
  canvasOptions: {
114
132
  background: '#05070d',
115
133
  foreground: '#f8fafc',
@@ -177,6 +195,7 @@ const controller = new AbortController();
177
195
  const viewer = new CadViewer({
178
196
  container,
179
197
  wasmPath: new URL('wasm/', document.baseURI).href,
198
+ dwfWasmUrl: new URL('wasm/dwfv-render.wasm', document.baseURI).href,
180
199
  useWorker: true,
181
200
  workerTimeoutMs: 120_000,
182
201
  onLoadProgress(progress) {
@@ -197,6 +216,7 @@ controller.abort();
197
216
  new CadViewer({
198
217
  container,
199
218
  wasmPath: new URL('wasm/', document.baseURI).href,
219
+ dwfWasmUrl: new URL('wasm/dwfv-render.wasm', document.baseURI).href,
200
220
  workerUrl: new URL('/assets/dwg-worker.js', window.location.origin)
201
221
  });
202
222
  ```
@@ -211,6 +231,7 @@ const viewer = new CadViewer({
211
231
  canvas, // 也可以传入已有 canvas
212
232
  renderer: 'auto', // 'auto' | 'webgl' | 'canvas2d'
213
233
  wasmPath: '/wasm', // LibreDWG WebAssembly 资源路径。Worker 场景建议使用绝对路径/URL
234
+ dwfWasmUrl: '/wasm/dwfv-render.wasm',
214
235
  autoFit: true,
215
236
  canvasOptions: {
216
237
  background: '#05070d',
@@ -229,6 +250,12 @@ const viewer = new CadViewer({
229
250
  },
230
251
  useWorker: true, // DWG 默认开启
231
252
  workerTimeoutMs: 0, // 0 表示不限制
253
+ dwfPreferWebgl: true,
254
+ dwfPreferWasm: true,
255
+ dwfMaxCanvasPixels: 16_777_216,
256
+ dwfLineWeightMode: 'adaptive', // 'adaptive' | 'physical' | 'hairline'
257
+ dwfMinStrokeCssPx: 0.42,
258
+ dwfMinTextCssPx: 1.05,
232
259
  onLoadProgress(progress) {},
233
260
  onLoad(result) {},
234
261
  onError(error) {},
@@ -256,11 +283,8 @@ CadLoaderRegistry
256
283
 
257
284
  DwgLoader | DxfLoader | DwfLoader | 自定义 loader
258
285
 
259
- CadDocument
260
-
261
- CadWebGLRenderer | CadCanvasRenderer fallback
262
-
263
- WebGL preview + Canvas overlay
286
+ DWG/DXF:CadDocument → CadWebGLRenderer | CadCanvasRenderer fallback
287
+ DWF/DWFx/XPS:DwfLoader.mount() → dwf-viewer native WebGL 矢量 / 3D / WASM fallback
264
288
  ```
265
289
 
266
290
  所有 loader 都输出统一的 `CadDocument`:
@@ -312,8 +336,8 @@ viewer.registerLoader({
312
336
  |---|---|---|
313
337
  | DWG | `DwgLoader` | 使用 LibreDWG WebAssembly。渲染完整度取决于 LibreDWG converter 暴露出的实体。 |
314
338
  | DXF | `DxfLoader` | 使用 `dxf-parser` + 内置 fallback。支持基础实体、block/insert、颜色/图层、多段线、文字、hatch boundary、spline 预览。 |
315
- | DWFx / XPS | `DwfLoader` | 解析 ZIP/OPC 包,并渲染 2D `FixedPage` path/glyph/image 内容。 |
316
- | 经典 DWF | `DwfLoader` 检测 | 能检测 WHIP/W2D/W3D 包内容并给出明确错误。完整经典 DWF 需要专门 WHIP 解码器或 DWF Toolkit/WASM。 |
339
+ | DWF | `DwfLoader` + `dwf-viewer` | DWF 6+ ZIP 包、WHIP/W2D 2D 图纸、W3D/HSF 3D eModel、模型树元数据、WebGL 渲染和可选 WASM fallback。 |
340
+ | DWFx / XPS | `DwfLoader` + `dwf-viewer` | DWFx/OPC/XPS 页面,包含 WebGL 加速 vector path、嵌入字体、文本、图片、包内资源和自适应总览线宽,通过原生 DWF 渲染器展示。 |
317
341
 
318
342
  ## 颜色处理
319
343
 
@@ -357,7 +381,7 @@ npm run pack:dry
357
381
 
358
382
  ```bash
359
383
  npm login
360
- npm publish --access public
384
+ npm publish --access public --auth-type=web
361
385
  ```
362
386
 
363
387
  仓库内也提供:
@@ -400,12 +424,10 @@ src/
400
424
  viewer/ CadViewer 组件和 Canvas renderer
401
425
  demo/ 专业 Vite demo UI
402
426
  docs/ 中英文架构/格式文档
403
- scripts/ clean 和 LibreDWG WASM 复制脚本
427
+ scripts/ clean、运行时 WASM 复制与校验脚本
404
428
  public/wasm/ demo 的 WASM 输出目录
405
429
  ```
406
430
 
407
431
  ## 许可证
408
432
 
409
- AGPL-3.0-only。这是严格 copyleft 许可证:如果你分发修改版本,或通过网络提供修改版本服务,请认真审查源码公开义务。
410
-
411
- 默认 DWG loader 依赖 `@mlightcad/libredwg-web`,该包为 GPL-3.0-only。若用于闭源商业产品,请替换为合规授权的 DWG parser/converter,并重新审查依赖许可证。
433
+ AGPL-3.0-only。默认 DWG loader 集成 `@mlightcad/libredwg-web` / LibreDWG,DWF 渲染器集成 `dwf-viewer`。二开、分发、嵌入或作为应用组成部分使用时,请保留出处和许可证说明。闭源商用产品需要审阅所有依赖许可证,并在授权模型需要时替换对应 loader。