@mlightcad/libredwg-converter 3.5.21 → 3.5.23

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 mlight-lee
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mlight-lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,53 +1,53 @@
1
- # @mlightcad/libredwg-converter
2
-
3
- The `libredwg-converter` package provides a DWG file converter for the RealDWG-Web ecosystem, enabling reading and conversion of DWG files into the AutoCAD-like drawing database structure. It is based on the [LibreDWG](https://www.gnu.org/software/libredwg/) library compiled to WebAssembly.
4
-
5
- ## Overview
6
-
7
- This package implements a DWG file converter compatible with the RealDWG-Web data model. It allows you to register DWG file support in your application and convert DWG files into the in-memory drawing database.
8
-
9
- ## Key Features
10
-
11
- - **DWG File Support**: Read and convert DWG files to the drawing database
12
- - **Integration**: Designed to work with the RealDWG-Web data model and converter manager
13
- - **WebAssembly Powered**: Uses LibreDWG compiled to WASM for fast, browser-compatible parsing
14
-
15
- ## Installation
16
-
17
- ```bash
18
- npm install @mlightcad/libredwg-converter
19
- ```
20
-
21
- > **Peer dependencies:**
22
- > - `@mlightcad/data-model`
23
- > - `@mlightcad/libredwg-web`
24
-
25
- ## Usage Example
26
-
27
- ```typescript
28
- import { AcDbDatabaseConverterManager, AcDbFileType } from '@mlightcad/data-model';
29
- import { AcDbLibreDwgConverter } from '@mlightcad/libredwg-converter';
30
-
31
- // WASM module loading (async)
32
- import('@mlightcad/libredwg-web/wasm/libredwg-web').then(libredwgModule => {
33
- const dwgConverter = new AcDbLibreDwgConverter(libredwgModule);
34
- AcDbDatabaseConverterManager.instance.register(AcDbFileType.DWG, dwgConverter);
35
- });
36
- ```
37
-
38
- ## API
39
-
40
- - **AcDbLibreDwgConverter**: Main converter class for DWG files (extends `AcDbDatabaseConverter`)
41
-
42
- ## Dependencies
43
-
44
- - **@mlightcad/data-model**: Drawing database and entity definitions
45
- - **@mlightcad/libredwg-web**: WASM wrapper for LibreDWG
46
-
47
- ## API Documentation
48
-
49
- For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
50
-
51
- ## Contributing
52
-
1
+ # @mlightcad/libredwg-converter
2
+
3
+ The `libredwg-converter` package provides a DWG file converter for the RealDWG-Web ecosystem, enabling reading and conversion of DWG files into the AutoCAD-like drawing database structure. It is based on the [LibreDWG](https://www.gnu.org/software/libredwg/) library compiled to WebAssembly.
4
+
5
+ ## Overview
6
+
7
+ This package implements a DWG file converter compatible with the RealDWG-Web data model. It allows you to register DWG file support in your application and convert DWG files into the in-memory drawing database.
8
+
9
+ ## Key Features
10
+
11
+ - **DWG File Support**: Read and convert DWG files to the drawing database
12
+ - **Integration**: Designed to work with the RealDWG-Web data model and converter manager
13
+ - **WebAssembly Powered**: Uses LibreDWG compiled to WASM for fast, browser-compatible parsing
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @mlightcad/libredwg-converter
19
+ ```
20
+
21
+ > **Peer dependencies:**
22
+ > - `@mlightcad/data-model`
23
+ > - `@mlightcad/libredwg-web`
24
+
25
+ ## Usage Example
26
+
27
+ ```typescript
28
+ import { AcDbDatabaseConverterManager, AcDbFileType } from '@mlightcad/data-model';
29
+ import { AcDbLibreDwgConverter } from '@mlightcad/libredwg-converter';
30
+
31
+ // WASM module loading (async)
32
+ import('@mlightcad/libredwg-web/wasm/libredwg-web').then(libredwgModule => {
33
+ const dwgConverter = new AcDbLibreDwgConverter(libredwgModule);
34
+ AcDbDatabaseConverterManager.instance.register(AcDbFileType.DWG, dwgConverter);
35
+ });
36
+ ```
37
+
38
+ ## API
39
+
40
+ - **AcDbLibreDwgConverter**: Main converter class for DWG files (extends `AcDbDatabaseConverter`)
41
+
42
+ ## Dependencies
43
+
44
+ - **@mlightcad/data-model**: Drawing database and entity definitions
45
+ - **@mlightcad/libredwg-web**: WASM wrapper for LibreDWG
46
+
47
+ ## API Documentation
48
+
49
+ For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
50
+
51
+ ## Contributing
52
+
53
53
  This package is part of the RealDWG-Web monorepo. Please refer to the main project README for contribution guidelines.
@@ -28,22 +28,22 @@ class C {
28
28
  );
29
29
  }
30
30
  convertEllipse(e) {
31
- const n = new D(e.majorAxisEndPoint), t = n.length();
31
+ const n = new D(e.majorAxisEndPoint), s = n.length();
32
32
  return new k(
33
33
  e.center,
34
34
  e.extrusionDirection ?? D.Z_AXIS,
35
35
  n,
36
- t,
37
- t * e.axisRatio,
36
+ s,
37
+ s * e.axisRatio,
38
38
  e.startAngle,
39
39
  e.endAngle
40
40
  );
41
41
  }
42
42
  convertLine(e) {
43
- const n = e.startPoint, t = e.endPoint;
43
+ const n = e.startPoint, s = e.endPoint;
44
44
  return new F(
45
45
  new w(n.x, n.y, n.z),
46
- new w(t.x, t.y, t.z)
46
+ new w(s.x, s.y, s.z)
47
47
  );
48
48
  }
49
49
  convertSpline(e) {
@@ -80,18 +80,20 @@ class C {
80
80
  }
81
81
  convertLWPolyline(e) {
82
82
  const n = new N();
83
- return n.closed = !!(e.flag & 512), e.vertices.forEach((t, o) => {
83
+ n.closed = !!(e.flag & 512);
84
+ const s = e.constantWidth ?? -1;
85
+ return e.vertices.forEach((o, t) => {
84
86
  n.addVertexAt(
85
- o,
86
- new b(t.x, t.y),
87
- t.bulge,
88
- t.startWidth,
89
- t.endWidth
87
+ t,
88
+ new b(o.x, o.y),
89
+ o.bulge,
90
+ o.startWidth ?? s,
91
+ o.endWidth ?? s
90
92
  );
91
93
  }), n;
92
94
  }
93
95
  convertPolyline2d(e) {
94
- const n = !!(e.flag & 1), t = !!(e.flag & 16), o = !!(e.flag & 64), s = !!(e.flag & 32), r = [], a = [], c = [];
96
+ const n = !!(e.flag & 1), s = !!(e.flag & 16), o = !!(e.flag & 64), t = !!(e.flag & 32), r = [], a = [], c = [];
95
97
  if (e.vertices.map((i) => {
96
98
  if (!(i.flag & 16))
97
99
  if (o && i.flag & 128)
@@ -111,9 +113,9 @@ class C {
111
113
  y: i.y,
112
114
  z: i.z
113
115
  }), a.push(i.bulge ?? 0);
114
- }), t) {
116
+ }), s) {
115
117
  const i = e.meshMVertexCount ?? 2, d = e.meshNVertexCount ?? 2;
116
- return new B(i, d, r, n, s);
118
+ return new B(i, d, r, n, t);
117
119
  } else {
118
120
  if (o)
119
121
  return new z(r, c);
@@ -132,30 +134,30 @@ class C {
132
134
  }
133
135
  }
134
136
  convertPolyline3d(e) {
135
- const n = !!(e.flag & 1), t = [];
136
- e.vertices.map((s) => {
137
- s.flag & 16 || t.push({
138
- x: s.x,
139
- y: s.y,
140
- z: s.z
137
+ const n = !!(e.flag & 1), s = [];
138
+ e.vertices.map((t) => {
139
+ t.flag & 16 || s.push({
140
+ x: t.x,
141
+ y: t.y,
142
+ z: t.z
141
143
  });
142
144
  });
143
145
  let o = y.SimplePoly;
144
- return e.flag & 4 && (e.smoothType == 6 ? o = y.CubicSplinePoly : e.smoothType == 5 && (o = y.QuadSplinePoly)), new W(o, t, n);
146
+ return e.flag & 4 && (e.smoothType == 6 ? o = y.CubicSplinePoly : e.smoothType == 5 && (o = y.QuadSplinePoly)), new W(o, s, n);
145
147
  }
146
148
  convertHatch(e) {
147
149
  var o;
148
150
  const n = new H();
149
- return (o = e.definitionLines) == null || o.forEach((s) => {
151
+ return (o = e.definitionLines) == null || o.forEach((t) => {
150
152
  n.definitionLines.push({
151
- angle: s.angle,
152
- base: s.base,
153
- offset: s.offset,
154
- dashLengths: s.numberOfDashLengths > 0 ? s.dashLengths : []
153
+ angle: t.angle,
154
+ base: t.base,
155
+ offset: t.offset,
156
+ dashLengths: t.numberOfDashLengths > 0 ? t.dashLengths : []
155
157
  });
156
- }), n.isSolidFill = e.solidFill == 1, n.hatchStyle = e.hatchStyle, n.patternName = e.patternName, n.patternType = e.patternType, n.patternAngle = e.patternAngle == null ? 0 : e.patternAngle, n.patternScale = e.patternScale == null ? 0 : e.patternScale, e.boundaryPaths.forEach((s) => {
157
- if (s.boundaryPathTypeFlag & 2) {
158
- const a = s, c = new X();
158
+ }), n.isSolidFill = e.solidFill == 1, n.hatchStyle = e.hatchStyle, n.patternName = e.patternName, n.patternType = e.patternType, n.patternAngle = e.patternAngle == null ? 0 : e.patternAngle, n.patternScale = e.patternScale == null ? 0 : e.patternScale, e.boundaryPaths.forEach((t) => {
159
+ if (t.boundaryPathTypeFlag & 2) {
160
+ const a = t, c = new X();
159
161
  c.closed = a.isClosed, a.vertices.forEach((i, d) => {
160
162
  c.addVertexAt(d, {
161
163
  x: i.x,
@@ -164,7 +166,7 @@ class C {
164
166
  });
165
167
  }), n.add(c);
166
168
  } else {
167
- const a = s, c = [];
169
+ const a = t, c = [];
168
170
  a.edges.forEach((d) => {
169
171
  if (d != null) {
170
172
  if (d.type == 1) {
@@ -242,11 +244,11 @@ class C {
242
244
  e.columnCount
243
245
  );
244
246
  return n.tableStyleId = e.tableStyleId, n.owningBlockRecordId = e.blockRecordHandle, e.directionVector && (n.horizontalDirection = new D(e.directionVector)), n.attachmentPoint = e.attachmentPoint, n.position.copy(e.startPoint), n.tableValueFlag = e.tableValue, n.tableOverrideFlag = e.overrideFlag, n.borderColorOverrideFlag = e.borderColorOverrideFlag, n.borderLineweightOverrideFlag = e.borderLineWeightOverrideFlag, n.borderVisibilityOverrideFlag = e.borderVisibilityOverrideFlag, e.columnWidthArr.forEach(
245
- (t, o) => n.setColumnWidth(o, t)
247
+ (s, o) => n.setColumnWidth(o, s)
246
248
  ), e.rowHeightArr.forEach(
247
- (t, o) => n.setRowHeight(o, t)
248
- ), e.cells.forEach((t, o) => {
249
- n.setCell(o, t);
249
+ (s, o) => n.setRowHeight(o, s)
250
+ ), e.cells.forEach((s, o) => {
251
+ n.setCell(o, s);
250
252
  }), n;
251
253
  }
252
254
  convertText(e) {
@@ -259,56 +261,56 @@ class C {
259
261
  }
260
262
  convertLeader(e) {
261
263
  const n = new J();
262
- return e.vertices.forEach((t) => {
263
- n.appendVertex(t);
264
+ return e.vertices.forEach((s) => {
265
+ n.appendVertex(s);
264
266
  }), n.hasArrowHead = e.isArrowheadEnabled, n.hasHookLine = e.isHooklineExists, n.isSplined = e.isSpline, n.dimensionStyle = e.styleName, n.annoType = e.leaderCreationFlag, n;
265
267
  }
266
268
  convertDimension(e) {
267
269
  if (e.subclassMarker == "AcDbAlignedDimension" || e.subclassMarker == "AcDbRotatedDimension") {
268
- const n = e, t = new Q(
270
+ const n = e, s = new Q(
269
271
  n.subDefinitionPoint1,
270
272
  n.subDefinitionPoint2,
271
273
  n.definitionPoint
272
274
  );
273
- return n.insertionPoint && (t.dimBlockPosition = {
275
+ return n.insertionPoint && (s.dimBlockPosition = {
274
276
  x: n.insertionPoint.x,
275
277
  y: n.insertionPoint.y,
276
278
  z: 0
277
- }), t.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, t), t;
279
+ }), s.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, s), s;
278
280
  } else if (e.subclassMarker == "AcDb3PointAngularDimension") {
279
- const n = e, t = new $(
281
+ const n = e, s = new $(
280
282
  n.centerPoint,
281
283
  n.subDefinitionPoint1,
282
284
  n.subDefinitionPoint2,
283
285
  n.definitionPoint
284
286
  );
285
- return this.processDimensionCommonAttrs(e, t), t;
287
+ return this.processDimensionCommonAttrs(e, s), s;
286
288
  } else if (e.subclassMarker == "AcDbOrdinateDimension") {
287
- const n = e, t = new ee(
289
+ const n = e, s = new ee(
288
290
  n.subDefinitionPoint1,
289
291
  n.subDefinitionPoint2
290
292
  );
291
- return this.processDimensionCommonAttrs(e, t), t;
293
+ return this.processDimensionCommonAttrs(e, s), s;
292
294
  } else if (e.subclassMarker == "AcDbRadialDimension") {
293
- const n = e, t = new ne(
295
+ const n = e, s = new ne(
294
296
  n.definitionPoint,
295
297
  n.centerPoint,
296
298
  n.leaderLength
297
299
  );
298
- return this.processDimensionCommonAttrs(e, t), t;
300
+ return this.processDimensionCommonAttrs(e, s), s;
299
301
  } else if (e.subclassMarker == "AcDbDiametricDimension") {
300
- const n = e, t = new oe(
302
+ const n = e, s = new oe(
301
303
  n.definitionPoint,
302
304
  n.centerPoint,
303
305
  n.leaderLength
304
306
  );
305
- return this.processDimensionCommonAttrs(e, t), t;
307
+ return this.processDimensionCommonAttrs(e, s), s;
306
308
  }
307
309
  return null;
308
310
  }
309
311
  processImage(e, n) {
310
- n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageSize.copy(e.imageSize), n.imageDefId = e.imageDefHandle, n.isClipped = e.clipping > 0, n.isShownClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((t) => {
311
- n.clipBoundary.push(new b(t));
312
+ n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageSize.copy(e.imageSize), n.imageDefId = e.imageDefHandle, n.isClipped = e.clipping > 0, n.isShownClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((s) => {
313
+ n.clipBoundary.push(new b(s));
312
314
  }), n.clipBoundaryType = e.clippingBoundaryType, n.width = Math.sqrt(
313
315
  e.uPixel.x ** 2 + e.uPixel.y ** 2 + e.uPixel.z ** 2
314
316
  ) * e.imageSize.x, n.height = Math.sqrt(
@@ -336,8 +338,8 @@ class C {
336
338
  return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
337
339
  }
338
340
  convertAttributeCommon(e, n) {
339
- const t = e.text;
340
- n.textString = t.text, n.styleName = t.styleName, n.height = t.textHeight, n.position.copy(t.startPoint), n.rotation = t.rotation, n.oblique = t.obliqueAngle ?? 0, n.thickness = t.thickness, n.horizontalMode = t.halign, n.verticalMode = t.valign, n.widthFactor = t.xScale ?? 1, n.tag = e.tag, n.fieldLength = e.fieldLength, n.isInvisible = (e.flags & I.Invisible) !== 0, n.isConst = (e.flags & I.Const) !== 0, n.isVerifiable = (e.flags & I.Verifiable) !== 0, n.isPreset = (e.flags & I.Preset) !== 0, n.lockPositionInBlock = e.lockPositionFlag, n.isReallyLocked = e.isReallyLocked, n.isMTextAttribute = (e.mtextFlag & M.MultiLine) !== 0, n.isConstMTextAttribute = (e.mtextFlag & M.ConstMultiLine) !== 0;
341
+ const s = e.text;
342
+ n.textString = s.text, n.styleName = s.styleName, n.height = s.textHeight, n.position.copy(s.startPoint), n.rotation = s.rotation, n.oblique = s.obliqueAngle ?? 0, n.thickness = s.thickness, n.horizontalMode = s.halign, n.verticalMode = s.valign, n.widthFactor = s.xScale ?? 1, n.tag = e.tag, n.fieldLength = e.fieldLength, n.isInvisible = (e.flags & I.Invisible) !== 0, n.isConst = (e.flags & I.Const) !== 0, n.isVerifiable = (e.flags & I.Verifiable) !== 0, n.isPreset = (e.flags & I.Preset) !== 0, n.lockPositionInBlock = e.lockPositionFlag, n.isReallyLocked = e.isReallyLocked, n.isMTextAttribute = (e.mtextFlag & M.MultiLine) !== 0, n.isConstMTextAttribute = (e.mtextFlag & M.ConstMultiLine) !== 0;
341
343
  }
342
344
  convertAttribute(e) {
343
345
  const n = new le();
@@ -349,8 +351,8 @@ class C {
349
351
  }
350
352
  convertBlockReference(e) {
351
353
  const n = new de(e.name);
352
- return e.insertionPoint && n.position.copy(e.insertionPoint), n.scaleFactors.x = e.xScale, n.scaleFactors.y = e.yScale, n.scaleFactors.z = e.zScale, n.rotation = e.rotation, n.normal.copy(e.extrusionDirection), e.attribs && e.attribs.forEach((t) => {
353
- const o = this.convertAttribute(t);
354
+ return e.insertionPoint && n.position.copy(e.insertionPoint), n.scaleFactors.x = e.xScale, n.scaleFactors.y = e.yScale, n.scaleFactors.z = e.zScale, n.rotation = e.rotation, n.normal.copy(e.extrusionDirection), e.attribs && e.attribs.forEach((s) => {
355
+ const o = this.convertAttribute(s);
354
356
  n.appendAttributes(o);
355
357
  }), n;
356
358
  }
@@ -358,9 +360,9 @@ class C {
358
360
  n.dimBlockId = e.name, n.textPosition.copy(e.textPoint), n.textRotation = e.textRotation || 0, e.textLineSpacingFactor && (n.textLineSpacingFactor = e.textLineSpacingFactor), e.textLineSpacingStyle && (n.textLineSpacingStyle = e.textLineSpacingStyle), n.dimensionStyleName = e.styleName, n.dimensionText = e.text || "", n.measurement = e.measurement;
359
361
  }
360
362
  processCommonAttrs(e, n) {
361
- if (n.layer = e.layer || "0", n.objectId = e.handle, n.ownerId = e.ownerBlockRecordSoftId, e.lineType != null && (n.lineType = e.lineType), e.lineweight != null && (n.lineWeight = e.lineweight), e.lineTypeScale != null && (n.linetypeScale = e.lineTypeScale), e.color != null && n.color.setRGBValue(e.color), e.colorIndex != null && (n.color.colorIndex = e.colorIndex), e.colorName && (n.color.colorName = e.colorName), e.isVisible != null && (n.visibility = e.isVisible), e.transparency != null) {
362
- const t = new pe();
363
- t.method = e.transparencyType, (t.isByBlock || t.isByBlock) && (t.alpha = e.transparency), n.transparency = t;
363
+ if (n.layer = e.layer || "0", n.objectId = e.handle, n.ownerId = e.ownerBlockRecordSoftId, e.lineType != null && (n.lineType = e.lineType), e.lineweight != null && (n.lineWeight = e.lineweight), e.lineTypeScale != null && (n.linetypeScale = e.lineTypeScale), e.color != null && n.color.setRGBValue(e.color), e.colorIndex != null && (e.color == null || e.colorIndex === 7) && (n.color.colorIndex = e.colorIndex), e.colorName && (n.color.colorName = e.colorName), e.isVisible != null && (n.visibility = e.isVisible), e.transparency != null) {
364
+ const s = new pe();
365
+ s.method = e.transparencyType, (s.isByBlock || s.isByBlock) && (s.alpha = e.transparency), n.transparency = s;
364
366
  }
365
367
  }
366
368
  }
@@ -370,14 +372,14 @@ class Ce extends ue {
370
372
  super(e), e.useWorker = !0, e.parserWorkerUrl || (e.parserWorkerUrl = "/assets/libredwg-parser-worker.js");
371
373
  }
372
374
  async parse(e, n) {
373
- const t = this.config, o = this.getParserWorkerTimeout(e, n);
374
- if (t.useWorker && t.parserWorkerUrl) {
375
- const s = fe({
376
- workerUrl: t.parserWorkerUrl,
375
+ const s = this.config, o = this.getParserWorkerTimeout(e, n);
376
+ if (s.useWorker && s.parserWorkerUrl) {
377
+ const t = fe({
378
+ workerUrl: s.parserWorkerUrl,
377
379
  timeout: o,
378
380
  maxConcurrentWorkers: 1
379
- }), r = await s.execute(e);
380
- if (s.destroy(), r.success)
381
+ }), r = await t.execute(e);
382
+ if (t.destroy(), r.success)
381
383
  return r.data;
382
384
  throw new Error(
383
385
  `Failed to parse drawing due to error: '${r.error}'`
@@ -390,7 +392,7 @@ class Ce extends ue {
390
392
  e.tables.BLOCK_RECORD.entries.forEach((r) => {
391
393
  n.set(r.name, r);
392
394
  });
393
- const t = /* @__PURE__ */ new Map(), o = (r) => {
395
+ const s = /* @__PURE__ */ new Map(), o = (r) => {
394
396
  if (r) {
395
397
  const a = r.lastIndexOf(".");
396
398
  return a >= 0 ? r.substring(0, a).toLowerCase() : r.toLowerCase();
@@ -399,51 +401,51 @@ class Ce extends ue {
399
401
  e.tables.STYLE.entries.forEach((r) => {
400
402
  const a = [];
401
403
  let c = o(r.font);
402
- c && a.push(c), c = o(r.bigFont), c && a.push(c), t.set(r.name, a);
404
+ c && a.push(c), c = o(r.bigFont), c && a.push(c), s.set(r.name, a);
403
405
  });
404
- const s = /* @__PURE__ */ new Set();
405
- return this.getFontsInBlock(e.entities, n, t, s), Array.from(s);
406
+ const t = /* @__PURE__ */ new Set();
407
+ return this.getFontsInBlock(e.entities, n, s, t), Array.from(t);
406
408
  }
407
- getFontsInBlock(e, n, t, o) {
408
- const s = /\\f(.*?)\|/g;
409
+ getFontsInBlock(e, n, s, o) {
410
+ const t = /\\f(.*?)\|/g;
409
411
  e.forEach((r) => {
410
412
  if (r.type == "MTEXT") {
411
413
  const a = r;
412
- [...a.text.matchAll(s)].forEach((i) => {
414
+ [...a.text.matchAll(t)].forEach((i) => {
413
415
  o.add(i[1].toLowerCase());
414
416
  });
415
- const c = t.get(a.styleName);
417
+ const c = s.get(a.styleName);
416
418
  c == null || c.forEach((i) => o.add(i));
417
419
  } else if (r.type == "TEXT") {
418
- const a = r, c = t.get(a.styleName);
420
+ const a = r, c = s.get(a.styleName);
419
421
  c == null || c.forEach((i) => o.add(i));
420
422
  } else if (r.type == "INSERT") {
421
423
  const a = r, c = n.get(a.name);
422
- c && this.getFontsInBlock(c.entities, n, t, o);
424
+ c && this.getFontsInBlock(c.entities, n, s, o);
423
425
  }
424
426
  });
425
427
  }
426
428
  processLineTypes(e, n) {
427
429
  e.tables.LTYPE.entries.forEach((o) => {
428
- const s = {
430
+ const t = {
429
431
  name: o.name,
430
432
  description: o.description,
431
433
  standardFlag: o.standardFlag,
432
434
  totalPatternLength: o.totalPatternLength,
433
435
  pattern: o.pattern
434
- }, r = new he(s);
436
+ }, r = new he(t);
435
437
  this.processCommonTableEntryAttrs(o, r), r.name = o.name, n.tables.linetypeTable.add(r);
436
438
  });
437
439
  }
438
440
  processTextStyles(e, n) {
439
441
  e.tables.STYLE.entries.forEach((o) => {
440
- const s = new ge(o);
441
- this.processCommonTableEntryAttrs(o, s), n.tables.textStyleTable.add(s);
442
+ const t = new ge(o);
443
+ this.processCommonTableEntryAttrs(o, t), n.tables.textStyleTable.add(t);
442
444
  });
443
445
  }
444
446
  processDimStyles(e, n) {
445
447
  e.tables.DIMSTYLE.entries.forEach((o) => {
446
- const s = {
448
+ const t = {
447
449
  name: o.name,
448
450
  ownerId: o.ownerHandle,
449
451
  dimpost: o.DIMPOST || "",
@@ -512,21 +514,21 @@ class Ce extends ue {
512
514
  dimblk2: o.DIMBLK2 || "",
513
515
  dimlwd: o.DIMLWD,
514
516
  dimlwe: o.DIMLWE
515
- }, r = new De(s);
517
+ }, r = new De(t);
516
518
  this.processCommonTableEntryAttrs(o, r), n.tables.dimStyleTable.add(r);
517
519
  });
518
520
  }
519
521
  processLayers(e, n) {
520
522
  e.tables.LAYER.entries.forEach((o) => {
521
- const s = new Ae();
522
- s.colorIndex = o.colorIndex;
523
+ const t = new Ae();
524
+ t.colorIndex = o.colorIndex;
523
525
  const r = new Ie({
524
526
  name: o.name,
525
527
  standardFlags: o.standardFlag,
526
528
  linetype: o.lineType,
527
529
  lineWeight: o.lineweight,
528
530
  isOff: o.off,
529
- color: s,
531
+ color: t,
530
532
  isPlottable: o.plotFlag != 0
531
533
  });
532
534
  this.processCommonTableEntryAttrs(o, r), n.tables.layerTable.add(r);
@@ -534,27 +536,27 @@ class Ce extends ue {
534
536
  }
535
537
  processViewports(e, n) {
536
538
  e.tables.VPORT.entries.forEach((o) => {
537
- const s = new ye();
538
- this.processCommonTableEntryAttrs(o, s), o.circleSides && (s.circleSides = o.circleSides), s.standardFlag = o.standardFlag, s.center.copy(o.center), s.lowerLeftCorner.copy(o.lowerLeftCorner), s.upperRightCorner.copy(o.upperRightCorner), o.snapBasePoint && s.snapBase.copy(o.snapBasePoint), o.snapRotationAngle && (s.snapAngle = o.snapRotationAngle), o.snapSpacing && s.snapIncrements.copy(o.snapSpacing), o.majorGridLines && (s.gridMajor = o.majorGridLines), o.gridSpacing && s.gridIncrements.copy(o.gridSpacing), o.backgroundObjectId && (s.backgroundObjectId = o.backgroundObjectId), s.gsView.center.copy(o.center), s.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget), s.gsView.viewTarget.copy(o.viewTarget), o.lensLength && (s.gsView.lensLength = o.lensLength), o.frontClippingPlane && (s.gsView.frontClippingPlane = o.frontClippingPlane), o.backClippingPlane && (s.gsView.backClippingPlane = o.backClippingPlane), o.viewHeight && (s.gsView.viewHeight = o.viewHeight), o.viewTwistAngle && (s.gsView.viewTwistAngle = o.viewTwistAngle), o.frozenLayers && (s.gsView.frozenLayers = o.frozenLayers), o.styleSheet && (s.gsView.styleSheet = o.styleSheet), o.renderMode && (s.gsView.renderMode = o.renderMode), o.viewMode && (s.gsView.viewMode = o.viewMode), o.ucsIconSetting && (s.gsView.ucsIconSetting = o.ucsIconSetting), o.ucsOrigin && s.gsView.ucsOrigin.copy(o.ucsOrigin), o.ucsXAxis && s.gsView.ucsXAxis.copy(o.ucsXAxis), o.ucsYAxis && s.gsView.ucsYAxis.copy(o.ucsYAxis), o.orthographicType && (s.gsView.orthographicType = o.orthographicType), o.shadePlotSetting && (s.gsView.shadePlotSetting = o.shadePlotSetting), o.shadePlotObjectId && (s.gsView.shadePlotObjectId = o.shadePlotObjectId), o.visualStyleObjectId && (s.gsView.visualStyleObjectId = o.visualStyleObjectId), o.isDefaultLightingOn && (s.gsView.isDefaultLightingOn = o.isDefaultLightingOn), o.defaultLightingType && (s.gsView.defaultLightingType = o.defaultLightingType), o.brightness && (s.gsView.brightness = o.brightness), o.contrast && (s.gsView.contrast = o.contrast), o.ambientColor && (s.gsView.ambientColor = o.ambientColor), n.tables.viewportTable.add(s);
539
+ const t = new ye();
540
+ this.processCommonTableEntryAttrs(o, t), o.circleSides && (t.circleSides = o.circleSides), t.standardFlag = o.standardFlag, t.center.copy(o.center), t.lowerLeftCorner.copy(o.lowerLeftCorner), t.upperRightCorner.copy(o.upperRightCorner), o.snapBasePoint && t.snapBase.copy(o.snapBasePoint), o.snapRotationAngle && (t.snapAngle = o.snapRotationAngle), o.snapSpacing && t.snapIncrements.copy(o.snapSpacing), o.majorGridLines && (t.gridMajor = o.majorGridLines), o.gridSpacing && t.gridIncrements.copy(o.gridSpacing), o.backgroundObjectId && (t.backgroundObjectId = o.backgroundObjectId), t.gsView.center.copy(o.center), t.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget), t.gsView.viewTarget.copy(o.viewTarget), o.lensLength && (t.gsView.lensLength = o.lensLength), o.frontClippingPlane && (t.gsView.frontClippingPlane = o.frontClippingPlane), o.backClippingPlane && (t.gsView.backClippingPlane = o.backClippingPlane), o.viewHeight && (t.gsView.viewHeight = o.viewHeight), o.viewTwistAngle && (t.gsView.viewTwistAngle = o.viewTwistAngle), o.frozenLayers && (t.gsView.frozenLayers = o.frozenLayers), o.styleSheet && (t.gsView.styleSheet = o.styleSheet), o.renderMode && (t.gsView.renderMode = o.renderMode), o.viewMode && (t.gsView.viewMode = o.viewMode), o.ucsIconSetting && (t.gsView.ucsIconSetting = o.ucsIconSetting), o.ucsOrigin && t.gsView.ucsOrigin.copy(o.ucsOrigin), o.ucsXAxis && t.gsView.ucsXAxis.copy(o.ucsXAxis), o.ucsYAxis && t.gsView.ucsYAxis.copy(o.ucsYAxis), o.orthographicType && (t.gsView.orthographicType = o.orthographicType), o.shadePlotSetting && (t.gsView.shadePlotSetting = o.shadePlotSetting), o.shadePlotObjectId && (t.gsView.shadePlotObjectId = o.shadePlotObjectId), o.visualStyleObjectId && (t.gsView.visualStyleObjectId = o.visualStyleObjectId), o.isDefaultLightingOn && (t.gsView.isDefaultLightingOn = o.isDefaultLightingOn), o.defaultLightingType && (t.gsView.defaultLightingType = o.defaultLightingType), o.brightness && (t.gsView.brightness = o.brightness), o.contrast && (t.gsView.contrast = o.contrast), o.ambientColor && (t.gsView.ambientColor = o.ambientColor), n.tables.viewportTable.add(t);
539
541
  });
540
542
  }
541
543
  processBlockTables(e, n) {
542
544
  e.tables.BLOCK_RECORD.entries.forEach((o) => {
543
- let s = n.tables.blockTable.getAt(o.name);
544
- s || (s = new we(), s.objectId = o.handle, s.name = o.name, s.ownerId = o.ownerHandle, s.origin.copy(o.basePoint), s.layoutId = o.layout, s.blockInsertUnits = o.insertionUnits, s.explodability = o.explodability, s.blockScaling = o.scalability, o.bmpPreview && (s.bmpPreview = o.bmpPreview), n.tables.blockTable.add(s)), !s.isModelSapce && o.entities && o.entities.length > 0 && this.processEntitiesInBlock(o.entities, s);
545
+ let t = n.tables.blockTable.getAt(o.name);
546
+ t || (t = new we(), t.objectId = o.handle, t.name = o.name, t.ownerId = o.ownerHandle, t.origin.copy(o.basePoint), t.layoutId = o.layout, t.blockInsertUnits = o.insertionUnits, t.explodability = o.explodability, t.blockScaling = o.scalability, o.bmpPreview && (t.bmpPreview = o.bmpPreview), n.tables.blockTable.add(t)), !t.isModelSapce && o.entities && o.entities.length > 0 && this.processEntitiesInBlock(o.entities, t);
545
547
  });
546
548
  }
547
549
  processBlocks(e, n) {
548
550
  }
549
551
  async processEntitiesInBlock(e, n) {
550
- const t = new C(), o = e.length, s = [];
552
+ const s = new C(), o = e.length, t = [];
551
553
  for (let r = 0; r < o; r++) {
552
- const a = e[r], c = t.convert(a);
553
- c && s.push(c);
554
+ const a = e[r], c = s.convert(a);
555
+ c && t.push(c);
554
556
  }
555
- n.appendEntity(s);
557
+ n.appendEntity(t);
556
558
  }
557
- async processEntities(e, n, t, o, s) {
559
+ async processEntities(e, n, s, o, t) {
558
560
  const r = new C();
559
561
  let a = [];
560
562
  e.tables.BLOCK_RECORD.entries.forEach((l) => {
@@ -563,7 +565,7 @@ class Ce extends ue {
563
565
  const c = a.length, i = new Te(
564
566
  c,
565
567
  100 - o.value,
566
- t
568
+ s
567
569
  );
568
570
  this.config.convertByEntityType && (a = this.groupAndFlattenByType(a));
569
571
  const d = n.tables.blockTable.modelSpace;
@@ -573,15 +575,15 @@ class Ce extends ue {
573
575
  const f = a[u], g = r.convert(f);
574
576
  g && p.push(g);
575
577
  }
576
- if (d.appendEntity(p), s) {
578
+ if (d.appendEntity(p), t) {
577
579
  let u = o.value + h / c * (100 - o.value);
578
- u > 100 && (u = 100), await s(u, "ENTITY", "IN-PROGRESS");
580
+ u > 100 && (u = 100), await t(u, "ENTITY", "IN-PROGRESS");
579
581
  }
580
582
  });
581
583
  }
582
584
  processHeader(e, n) {
583
- const t = e.header;
584
- t.CECOLOR && (t.CECOLOR.index >= 0 && t.CECOLOR.index <= 256 ? n.cecolor.colorIndex = t.CECOLOR.index : n.cecolor.setRGBValue(t.CECOLOR.rgb)), n.angBase = t.ANGBASE ?? 0, n.angDir = t.ANGDIR ?? 0, n.aunits = t.AUNITS ?? 0, n.celtype = t.CELTYPE ?? be, n.celtscale = t.CELTSCALE ?? 1, n.ltscale = t.LTSCALE ?? 1, t.EXTMAX && (n.extmax = t.EXTMAX), t.EXTMIN && (n.extmin = t.EXTMIN), n.insunits = t.INSUNITS ?? 1, n.pdmode = t.PDMODE ?? 0, n.pdsize = t.PDSIZE ?? 0, n.textstyle = t.TEXTSTYLE ?? L;
585
+ const s = e.header;
586
+ s.CECOLOR && (s.CECOLOR.index >= 0 && s.CECOLOR.index <= 256 ? n.cecolor.colorIndex = s.CECOLOR.index : n.cecolor.setRGBValue(s.CECOLOR.rgb)), n.angBase = s.ANGBASE ?? 0, n.angDir = s.ANGDIR ?? 0, n.aunits = s.AUNITS ?? 0, n.celtype = s.CELTYPE ?? be, n.celtscale = s.CELTSCALE ?? 1, n.ltscale = s.LTSCALE ?? 1, s.EXTMAX && (n.extmax = s.EXTMAX), s.EXTMIN && (n.extmin = s.EXTMIN), n.insunits = s.INSUNITS ?? 1, n.pdmode = s.PDMODE ?? 0, n.pdsize = s.PDSIZE ?? 0, n.textstyle = s.TEXTSTYLE ?? L;
585
587
  }
586
588
  processCommonTableEntryAttrs(e, n) {
587
589
  n.name = e.name, n.objectId = e.handle, n.ownerId = e.ownerHandle;
@@ -590,35 +592,35 @@ class Ce extends ue {
590
592
  this.processLayouts(e, n), this.processImageDefs(e, n);
591
593
  }
592
594
  processLayouts(e, n) {
593
- const t = n.objects.layout;
594
- e.objects.LAYOUT.forEach((s) => {
595
+ const s = n.objects.layout;
596
+ e.objects.LAYOUT.forEach((t) => {
595
597
  const r = new Pe();
596
- r.layoutName = s.layoutName, r.tabOrder = s.tabOrder;
598
+ r.layoutName = t.layoutName, r.tabOrder = t.tabOrder;
597
599
  const a = n.tables.blockTable.newIterator();
598
- r.objectId = s.handle;
600
+ r.objectId = t.handle;
599
601
  for (const c of a)
600
602
  if (c.layoutId === r.objectId) {
601
603
  r.blockTableRecordId = c.objectId;
602
604
  break;
603
605
  }
604
- r.blockTableRecordId || s.layoutName === "Model" && (r.blockTableRecordId = n.tables.blockTable.modelSpace.objectId), r.limits.min.copy(s.minLimit), r.limits.max.copy(s.maxLimit), r.extents.min.copy(s.minExtent), r.extents.max.copy(s.maxExtent), s.viewportId && r.viewportArray.push(s.viewportId), this.processCommonObjectAttrs(s, r), t.setAt(r.layoutName, r);
606
+ r.blockTableRecordId || t.layoutName === "Model" && (r.blockTableRecordId = n.tables.blockTable.modelSpace.objectId), r.limits.min.copy(t.minLimit), r.limits.max.copy(t.maxLimit), r.extents.min.copy(t.minExtent), r.extents.max.copy(t.maxExtent), t.viewportId && r.viewportArray.push(t.viewportId), this.processCommonObjectAttrs(t, r), s.setAt(r.layoutName, r);
605
607
  });
606
608
  }
607
609
  processImageDefs(e, n) {
608
- const t = n.objects.imageDefinition;
609
- e.objects.IMAGEDEF.forEach((s) => {
610
+ const s = n.objects.imageDefinition;
611
+ e.objects.IMAGEDEF.forEach((t) => {
610
612
  const r = new Ee();
611
- r.sourceFileName = s.fileName, this.processCommonObjectAttrs(s, r), t.setAt(r.objectId, r);
613
+ r.sourceFileName = t.fileName, this.processCommonObjectAttrs(t, r), s.setAt(r.objectId, r);
612
614
  });
613
615
  }
614
616
  processCommonObjectAttrs(e, n) {
615
617
  n.objectId = e.handle, n.ownerId = e.ownerHandle;
616
618
  }
617
619
  groupAndFlattenByType(e) {
618
- const n = {}, t = [];
620
+ const n = {}, s = [];
619
621
  for (const o of e)
620
- n[o.type] || (n[o.type] = [], t.push(o.type)), n[o.type].push(o);
621
- return t.flatMap((o) => n[o]);
622
+ n[o.type] || (n[o.type] = [], s.push(o.type)), n[o.type].push(o);
623
+ return s.flatMap((o) => n[o]);
622
624
  }
623
625
  isModelSpace(e) {
624
626
  return e && e.toUpperCase() == Me;