You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+55-50Lines changed: 55 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,14 +22,16 @@ To support reading both DXF and DWG files (and potentially other formats in the
22
22
23
23
- Each file type (e.g., DXF, DWG) is associated with a converter class that knows how to parse and import that file format into the drawing database.
24
24
- The `AcDbDatabaseConverterManager` maintains a registry of these converters, allowing you to register or unregister converters for specific file types at runtime.
25
-
-**DXF is registered by default.**Importing `@mlightcad/data-model` registers the built-in MIT `AcDbNativeDxfConverter`. You only need to register a DXF converter if you want to replace that default (for example with `@mlightcad/dxf-json-converter`).
25
+
-**DXF is registered by default.**`AcDbDatabaseConverterManager` registers the built-in MIT `AcDbNativeDxfConverter` when the singleton is created. You only need to register a DXF converter if you want to replace that default.
26
26
-**DWG is not registered by default.** Register a DWG converter (typically `@mlightcad/libredwg-converter`) before calling `AcDbDatabase.read()` on DWG files.
27
27
28
-
`@mlightcad/dxf-json-converter` and `@mlightcad/libredwg-converter` are designed to run their parsers in a Web Worker. That is a deliberate licensing choice: their upstream parsers are copyleft (GPL/LGPL), so keeping them in a separate worker bundle helps isolate that code from the main application. The built-in `AcDbNativeDxfConverter` does **not** need a worker — it is MIT-licensed and runs on the main thread.
28
+
`@mlightcad/libredwg-converter` runs its LibreDWG parser in a Web Worker. That is a deliberate licensing choice: the upstream parser is copyleft (GPL), so keeping it in a separate worker bundle helps isolate that code from the main application. The built-in `AcDbNativeDxfConverter` does **not** need a worker — it is MIT-licensed and runs on the main thread.
29
+
30
+
Deprecated GPL converters (`@mlightcad/dxf-json-converter`, `@mlightcad/libdxfrw-converter`) have moved to the separate [dwg-dxf-converter](https://github.com/mlightcad/dwg-dxf-converter) repository and are no longer documented here.
29
31
30
32
### Registering Converters
31
33
32
-
DXF works out of the box. Register a DWG converter before reading DWG files. Optionally replace the default DXF converter:
34
+
DXF works out of the box. Register a DWG converter before reading DWG files:
Deploy `libredwg-parser-worker.js`(and `dxf-parser-worker.js` only if you use `dxf-json-converter`) from each converter package's `dist/` folder to a public URL (see [example vite config](./packages/example/vite.config.ts)).
55
+
Deploy `libredwg-parser-worker.js`from `@mlightcad/libredwg-converter`'s `dist/` folder to a public URL (see [example vite config](./packages/example/vite.config.ts)).
63
56
64
57
### Unregistering a Converter
65
58
@@ -127,30 +120,17 @@ This design ensures the system is open for extension and can easily adapt to new
127
120
128
121
AutoCAD holds an absolute dominant position in the 2D CAD field. A large number of vertical applications and third-party plugins have been developed based on AutoCAD ObjectARX, and there are many software engineers familiar with AutoCAD ObjectARX. Therefore, this project mimics the architecture of AutoCAD ObjectARX and adopts similar API interfaces to AutoCAD ObjectARX.
129
122
130
-
### libdxfrw-converter (DWG file support)
131
-
132
-
DWG support via libdxfrw lives in the separate [dwg-dxf-converter](https://github.com/mlightcad/dwg-dxf-converter) monorepo (`@mlightcad/libdxfrw-converter`). It is powered by libdxfrw compiled to WebAssembly. Note: this converter does **not** provide worker isolation — GPL libdxfrw code runs on the main thread.
133
-
134
123
### libredwg-converter (DWG file support)
135
124
136
125
This module provides a DWG file converter for the RealDWG-Web ecosystem, enabling reading and conversion of DWG files into the drawing database. It is powered by the LibreDWG library compiled to WebAssembly and is designed to be registered with the converter manager for DWG file support.
137
126
138
127
DWG parsing is provided through a dedicated Web Worker bundle (`libredwg-parser-worker.js`). Worker-only usage is a licensing choice, not a platform constraint: it keeps the copyleft LibreDWG parser separate from the main application bundle so that MIT-licensed apps can integrate DWG support more safely.
139
128
140
-
### AcDbNativeDxfConverter vs dxf-json-converter (DXF file support)
141
-
142
-
`@mlightcad/data-model` ships a built-in DXF converter, `AcDbNativeDxfConverter`. It is the **recommended** way to read DXF files. The optional GPL alternative `@mlightcad/dxf-json-converter` lives in [dwg-dxf-converter](https://github.com/mlightcad/dwg-dxf-converter).
| Where it lives |`@mlightcad/data-model`|[dwg-dxf-converter](https://github.com/mlightcad/dwg-dxf-converter)|
147
-
| License | MIT | GPL-3.0 (via `@mlightcad/dxf-json`) |
148
-
| Default registration | Yes — registered when you import `data-model`| No — must `register()` yourself (replaces the default) |
149
-
| Execution | Main thread, streaming DXF pairs into the database | Web Worker + ParsedDxf JSON intermediate |
150
-
| Worker / assets | Not required | Requires `dxf-parser-worker.js`|
151
-
| Typical use | New apps; prefer speed and MIT-only DXF | Legacy setups or apps that already depend on `dxf-json`|
131
+
`@mlightcad/data-model` ships a built-in MIT DXF converter, `AcDbNativeDxfConverter`. It is registered by default when `AcDbDatabaseConverterManager` is created, streams DXF pairs into the database on the main thread, and requires no Web Worker or extra parser assets.
152
132
153
-
`dxf-json-converter` remains available for compatibility, but new code should use the built-in `AcDbNativeDxfConverter` unless you have a specific reason to keep the GPL worker-based path.
133
+
Deprecated GPL alternatives (`@mlightcad/dxf-json-converter`, `@mlightcad/libdxfrw-converter`) live in the separate [dwg-dxf-converter](https://github.com/mlightcad/dwg-dxf-converter) repository.
154
134
155
135
## geometry-engine (AcGe classes in AutoCAD ObjectARX)
156
136
@@ -207,6 +187,40 @@ The key classes in this module are as follows.
207
187
- AcGiRenderer: Interface used to render entities to drawble objects.
208
188
- ...
209
189
190
+
## Private packages (maintainers)
191
+
192
+
`@mlightcad/dwg-converter` is **not** part of this public repository and is never
193
+
built or published by public GitHub CI. Maintainers who need it locally can clone
194
+
it into the workspace:
195
+
196
+
```bash
197
+
pnpm setup:private
198
+
pnpm install
199
+
pnpm --filter @mlightcad/dwg-converter build
200
+
```
201
+
202
+
Override the clone URL with `DWG_CONVERTER_REPO_URL` if needed. The directory
203
+
`packages/dwg-converter` is gitignored so it cannot be committed here. Local
204
+
`pnpm install` may temporarily add that package to `pnpm-lock.yaml` — **do not
205
+
commit** those lockfile changes; public CI must keep a lockfile without it.
206
+
207
+
**Customers** install the same package from GitHub Packages (not public npm). Do
208
+
not point the whole `@mlightcad` scope at GitHub Packages—only authenticate, then
Publishing `@mlightcad/dwg-converter` happens only from its private repository CI.
223
+
210
224
## Contributing
211
225
212
226
Contributions are welcome! Please open issues or pull requests for bug fixes, new features, or suggestions. For bug reports, providing a link to the problematic drawing will help in reproducing and fixing the issue.
@@ -215,61 +229,52 @@ Contributions are welcome! Please open issues or pull requests for bug fixes, ne
215
229
216
230
This project is generally licensed under the [MIT License](LICENSE). However, this license does not apply to `@mlightcad/libredwg-converter` (GPL-3.0) in this repository.
217
231
218
-
The GPL converters `@mlightcad/dxf-json-converter` and `@mlightcad/libdxfrw-converter` live in the separate [dwg-dxf-converter](https://github.com/mlightcad/dwg-dxf-converter) repository. Please refer to each package's license for details.
232
+
Deprecated GPL converters (`@mlightcad/dxf-json-converter`, `@mlightcad/libdxfrw-converter`) live in the separate [dwg-dxf-converter](https://github.com/mlightcad/dwg-dxf-converter) repository. Please refer to that repository and each package's license for details.
219
233
220
234
### Prefer the built-in DXF converter
221
235
222
-
For DXF files, use the built-in **`AcDbNativeDxfConverter`** in `@mlightcad/data-model` whenever possible:
236
+
For DXF files, use the built-in **`AcDbNativeDxfConverter`** in `@mlightcad/data-model`:
223
237
224
-
-**No GPL license issues for DXF** — it is MIT-licensed and part of the core SDK; you do not need `@mlightcad/dxf-json-converter`.
238
+
-**No GPL license issues for DXF** — it is MIT-licensed and part of the core SDK.
225
239
-**Faster and simpler** — streams DXF into the database on the main thread with no Web Worker and no extra parser assets.
226
-
-**Registered by default** — importing `@mlightcad/data-model` is enough to call `AcDbDatabase.read(..., AcDbFileType.DXF)`.
240
+
-**Registered by default** — accessing `AcDbDatabaseConverterManager` is enough to call `AcDbDatabase.read(..., AcDbFileType.DXF)`.
227
241
228
-
Reserve `@mlightcad/dxf-json-converter` for legacy apps that already depend on it. For DWG, you still need a separate converter package (prefer `@mlightcad/libredwg-converter` with worker mode).
242
+
For DWG, register a separate converter package (prefer `@mlightcad/libredwg-converter` with worker mode).
229
243
230
244
### GPL copyleft and Web Worker isolation
231
245
232
246
The MIT-licensed core (`@mlightcad/data-model`, `@mlightcad/geometry-engine`, `@mlightcad/graphic-interface`, `@mlightcad/common`) does **not** depend on any GPL parser. Reading DXF through `AcDbNativeDxfConverter` stays entirely under MIT.
233
247
234
248
GPL copyleft therefore does **not** automatically apply to your application merely because you use the RealDWG-Web SDK—**provided that any GPL parser code you do use runs only inside separate Web Worker bundles**.
235
249
236
-
If you still use `@mlightcad/dxf-json-converter` and/or`@mlightcad/libredwg-converter`, the recommended integration is:
250
+
For DWG via`@mlightcad/libredwg-converter`, the recommended integration is:
237
251
238
252
```ts
239
-
// Optional DXF replacement (not needed if you keep AcDbNativeDxfConverter)
Deploy the worker scripts (`dxf-parser-worker.js`if used, `libredwg-parser-worker.js`) from each converter package's `dist/` folder as static assets (see [example vite config](./packages/example/vite.config.ts)).
259
+
Deploy `libredwg-parser-worker.js`from `@mlightcad/libredwg-converter`'s `dist/` folder as a static asset (see [example vite config](./packages/example/vite.config.ts)).
252
260
253
261
**How this limits copyleft propagation**
254
262
255
263
| Component | License | Worker isolation |
256
264
| --- | --- | --- |
257
265
| Core SDK (`data-model`, including `AcDbNativeDxfConverter`) | MIT | N/A — no GPL dependency |
|`libredwg-parser-worker.js`| GPL | Separate bundle; loaded at runtime; communicates via `postMessage`|
261
268
262
-
When `useWorker: true` is configured and the worker scripts are deployed separately:
269
+
When `useWorker: true` is configured and the worker script is deployed separately:
263
270
264
-
1. GPL parser code is bundled only into the worker scripts, not into your main application bundle.
271
+
1. GPL parser code is bundled only into the worker script, not into your main application bundle.
265
272
2. The worker and main thread exchange data through `postMessage` (file bytes in, parsed JSON model out)—a runtime boundary rather than static linking of GPL code into the MIT core.
266
-
3. Your MIT-licensed application code can stay under MIT, while the GPL worker bundles remain separate distributable components that must comply with GPL on their own (source availability, license notice, etc.).
273
+
3. Your MIT-licensed application code can stay under MIT, while the GPL worker bundle remains a separate distributable component that must comply with GPL on its own (source availability, license notice, etc.).
267
274
268
275
**Important caveats**
269
276
270
277
-**Prefer `AcDbNativeDxfConverter` for DXF** to avoid GPL entirely for that format.
271
278
-**Worker scripts are still GPL.** You must satisfy GPL obligations for those bundles (e.g., provide corresponding source and license notices when you distribute them).
272
-
-**DXF via `dxf-json-converter` on the main thread does not isolate GPL code.** That package can parse on the main thread when `useWorker: false`; that mode links GPL parser code into the same JavaScript context as your app. Use `useWorker: true` if you must use it and want worker-based isolation.
273
279
-**DWG via LibreDWG is worker-only.**`@mlightcad/libredwg-converter` requires a Web Worker; it cannot run on the main thread.
274
-
-**`@mlightcad/libdxfrw-converter` is different.** It does not provide a worker-based parser bundle; using it loads GPL libdxfrw code on the main thread. Prefer `@mlightcad/libredwg-converter` with worker mode if copyleft isolation matters for your deployment.
275
280
-**This is an architectural description, not legal advice.** Interpretation of GPL in browser/Web Worker contexts may vary by jurisdiction and use case. Consult qualified legal counsel for your product if license compliance is critical.
0 commit comments