@mlightcad/libredwg-converter 3.5.21 → 3.5.22

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.
@@ -1,4 +1,4 @@
1
- import { AcDbFace as v, AcDbArc as O, AcGeVector3d as D, AcDbCircle as m, AcDbEllipse as k, AcDbLine as F, AcGePoint3d as w, AcDbSpline as T, AcDbPoint as R, AcDbTrace as V, AcDbPolyline as N, AcGePoint2d as b, AcDbPolygonMesh as B, AcDbPolyFaceMesh as z, AcDbPoly2dType as A, AcDb2dPolyline as j, AcDbPoly3dType as y, AcDb3dPolyline as W, AcDbHatch as H, AcGePolyline2d as X, AcGeLine2d as U, AcGeCircArc2d as G, AcGeVector2d as Y, AcGeEllipseArc2d as _, AcGeSpline3d as P, AcGeLoop2d as E, AcDbTable as Z, AcDbText as K, AcDbMText as q, AcDbLeader as J, AcDbAlignedDimension as Q, AcDb3PointAngularDimension as $, AcDbOrdinateDimension as ee, AcDbRadialDimension as ne, AcDbDiametricDimension as oe, AcDbRasterImage as te, AcDbWipeout as se, AcDbViewport as re, AcDbRay as ie, AcDbXline as ce, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as M, AcDbAttribute as le, AcDbAttributeDefinition as ae, AcDbBlockReference as de, AcCmTransparency as pe, AcDbDatabaseConverter as ue, createWorkerApi as fe, AcDbLinetypeTableRecord as he, AcDbTextStyleTableRecord as ge, DEFAULT_TEXT_STYLE as L, AcDbDimStyleTableRecord as De, AcCmColor as Ae, AcDbLayerTableRecord as Ie, AcDbViewportTableRecord as ye, AcDbBlockTableRecord as we, AcDbBatchProcessing as Te, ByLayer as be, AcDbLayout as Pe, AcDbRasterImageDef as Ee } from "@mlightcad/data-model";
1
+ import { AcDbFace as v, AcDbArc as O, AcGeVector3d as D, AcDbCircle as m, AcDbEllipse as k, AcDbLine as F, AcGePoint3d as w, AcDbSpline as T, AcDbPoint as R, AcDbTrace as V, AcDbPolyline as N, AcGePoint2d as b, AcDbPolygonMesh as B, AcDbPolyFaceMesh as z, AcDbPoly2dType as A, AcDb2dPolyline as j, AcDbPoly3dType as y, AcDb3dPolyline as W, AcDbHatch as H, AcGePolyline2d as X, AcGeLine2d as U, AcGeCircArc2d as G, AcGeVector2d as Y, AcGeEllipseArc2d as _, AcGeSpline3d as P, AcGeLoop2d as E, AcDbTable as Z, AcDbText as K, AcDbMText as q, AcDbLeader as J, AcDbAlignedDimension as Q, AcDb3PointAngularDimension as $, AcDbOrdinateDimension as ee, AcDbRadialDimension as ne, AcDbDiametricDimension as oe, AcDbRasterImage as te, AcDbWipeout as se, AcDbViewport as re, AcDbRay as ie, AcDbXline as ce, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as M, AcDbAttribute as ae, AcDbAttributeDefinition as le, AcDbBlockReference as de, AcCmTransparency as pe, AcDbDatabaseConverter as ue, createWorkerApi as fe, AcDbLinetypeTableRecord as he, AcDbTextStyleTableRecord as ge, DEFAULT_TEXT_STYLE as L, AcDbDimStyleTableRecord as De, AcCmColor as Ae, AcDbLayerTableRecord as Ie, AcDbViewportTableRecord as ye, AcDbBlockTableRecord as we, AcDbBatchProcessing as Te, ByLayer as be, AcDbLayout as Pe, AcDbRasterImageDef as Ee } from "@mlightcad/data-model";
2
2
  class C {
3
3
  convert(e) {
4
4
  const n = this.createEntity(e);
@@ -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 = [], l = [], c = [];
95
97
  if (e.vertices.map((i) => {
96
98
  if (!(i.flag & 16))
97
99
  if (o && i.flag & 128)
@@ -100,7 +102,7 @@ class C {
100
102
  x: i.x,
101
103
  y: i.y,
102
104
  z: i.z
103
- }), a.push(i.bulge ?? 0);
105
+ }), l.push(i.bulge ?? 0);
104
106
  else {
105
107
  const d = [];
106
108
  i.polyfaceIndex0 != null && i.polyfaceIndex0 != 0 && d.push(Math.abs(i.polyfaceIndex0) - 1), i.polyfaceIndex1 != null && i.polyfaceIndex1 != 0 && d.push(Math.abs(i.polyfaceIndex1) - 1), i.polyfaceIndex2 != null && i.polyfaceIndex2 != 0 && d.push(Math.abs(i.polyfaceIndex2) - 1), i.polyfaceIndex3 != null && i.polyfaceIndex3 != 0 && d.push(Math.abs(i.polyfaceIndex3) - 1), d.length >= 3 && c.push(d);
@@ -110,10 +112,10 @@ class C {
110
112
  x: i.x,
111
113
  y: i.y,
112
114
  z: i.z
113
- }), a.push(i.bulge ?? 0);
114
- }), t) {
115
+ }), l.push(i.bulge ?? 0);
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);
@@ -126,37 +128,37 @@ class C {
126
128
  n,
127
129
  e.startWidth,
128
130
  e.endWidth,
129
- a
131
+ l
130
132
  );
131
133
  }
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();
159
- c.closed = a.isClosed, a.vertices.forEach((i, d) => {
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 l = t, c = new X();
161
+ c.closed = l.isClosed, l.vertices.forEach((i, d) => {
160
162
  c.addVertexAt(d, {
161
163
  x: i.x,
162
164
  y: i.y,
@@ -164,46 +166,46 @@ class C {
164
166
  });
165
167
  }), n.add(c);
166
168
  } else {
167
- const a = s, c = [];
168
- a.edges.forEach((d) => {
169
+ const l = t, c = [];
170
+ l.edges.forEach((d) => {
169
171
  if (d != null) {
170
172
  if (d.type == 1) {
171
- const l = d;
172
- c.push(new U(l.start, l.end));
173
+ const a = d;
174
+ c.push(new U(a.start, a.end));
173
175
  } else if (d.type == 2) {
174
- const l = d;
176
+ const a = d;
175
177
  c.push(
176
178
  new G(
177
- l.center,
178
- l.radius,
179
- l.startAngle,
180
- l.endAngle,
181
- !l.isCCW
179
+ a.center,
180
+ a.radius,
181
+ a.startAngle,
182
+ a.endAngle,
183
+ !a.isCCW
182
184
  )
183
185
  );
184
186
  } else if (d.type == 3) {
185
- const l = d;
186
- new Y().subVectors(l.end, l.center);
187
+ const a = d;
188
+ new Y().subVectors(a.end, a.center);
187
189
  const p = Math.sqrt(
188
- Math.pow(l.end.x, 2) + Math.pow(l.end.y, 2)
189
- ), u = p * l.lengthOfMinorAxis;
190
- let f = l.startAngle, g = l.endAngle;
191
- const x = Math.atan2(l.end.y, l.end.x);
192
- l.isCCW || (f = Math.PI * 2 - f, g = Math.PI * 2 - g), c.push(
190
+ Math.pow(a.end.x, 2) + Math.pow(a.end.y, 2)
191
+ ), u = p * a.lengthOfMinorAxis;
192
+ let f = a.startAngle, g = a.endAngle;
193
+ const x = Math.atan2(a.end.y, a.end.x);
194
+ a.isCCW || (f = Math.PI * 2 - f, g = Math.PI * 2 - g), c.push(
193
195
  new _(
194
- { ...l.center, z: 0 },
196
+ { ...a.center, z: 0 },
195
197
  p,
196
198
  u,
197
199
  f,
198
200
  g,
199
- !l.isCCW,
201
+ !a.isCCW,
200
202
  x
201
203
  )
202
204
  );
203
205
  } else if (d.type == 4) {
204
- const l = d;
205
- if (l.numberOfControlPoints > 0 && l.numberOfKnots > 0) {
206
- const h = l.controlPoints.map(
206
+ const a = d;
207
+ if (a.numberOfControlPoints > 0 && a.numberOfKnots > 0) {
208
+ const h = a.controlPoints.map(
207
209
  (f) => ({
208
210
  x: f.x,
209
211
  y: f.y,
@@ -211,16 +213,16 @@ class C {
211
213
  })
212
214
  );
213
215
  let p = !0;
214
- const u = l.controlPoints.map((f) => (f.weight == null && (p = !1), f.weight || 1));
216
+ const u = a.controlPoints.map((f) => (f.weight == null && (p = !1), f.weight || 1));
215
217
  c.push(
216
218
  new P(
217
219
  h,
218
- l.knots,
220
+ a.knots,
219
221
  p ? u : void 0
220
222
  )
221
223
  );
222
- } else if (l.numberOfFitData > 0) {
223
- const h = l.fitDatum.map((p) => ({
224
+ } else if (a.numberOfFitData > 0) {
225
+ const h = a.fitDatum.map((p) => ({
224
226
  x: p.x,
225
227
  y: p.y,
226
228
  z: 0
@@ -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,21 +338,21 @@ 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
- const n = new le();
345
+ const n = new ae();
344
346
  return this.convertAttributeCommon(e, n), n;
345
347
  }
346
348
  convertAttributeDefinition(e) {
347
- const n = new ae();
349
+ const n = new le();
348
350
  return this.convertAttributeCommon(e, n), n.prompt = e.prompt, n;
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
  }
@@ -359,8 +361,8 @@ class C {
359
361
  }
360
362
  processCommonAttrs(e, n) {
361
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 && (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;
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,60 +392,60 @@ 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
- const a = r.lastIndexOf(".");
396
- return a >= 0 ? r.substring(0, a).toLowerCase() : r.toLowerCase();
397
+ const l = r.lastIndexOf(".");
398
+ return l >= 0 ? r.substring(0, l).toLowerCase() : r.toLowerCase();
397
399
  }
398
400
  };
399
401
  e.tables.STYLE.entries.forEach((r) => {
400
- const a = [];
402
+ const l = [];
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 && l.push(c), c = o(r.bigFont), c && l.push(c), s.set(r.name, l);
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
- const a = r;
412
- [...a.text.matchAll(s)].forEach((i) => {
413
+ const l = r;
414
+ [...l.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(l.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 l = r, c = s.get(l.styleName);
419
421
  c == null || c.forEach((i) => o.add(i));
420
422
  } else if (r.type == "INSERT") {
421
- const a = r, c = n.get(a.name);
422
- c && this.getFontsInBlock(c.entities, n, t, o);
423
+ const l = r, c = n.get(l.name);
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,54 +536,54 @@ 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 l = e[r], c = s.convert(l);
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
- let a = [];
560
- e.tables.BLOCK_RECORD.entries.forEach((l) => {
561
- this.isModelSpace(l.name) && (a = l.entities);
561
+ let l = [];
562
+ e.tables.BLOCK_RECORD.entries.forEach((a) => {
563
+ this.isModelSpace(a.name) && (l = a.entities);
562
564
  });
563
- const c = a.length, i = new Te(
565
+ const c = l.length, i = new Te(
564
566
  c,
565
567
  100 - o.value,
566
- t
568
+ s
567
569
  );
568
- this.config.convertByEntityType && (a = this.groupAndFlattenByType(a));
570
+ this.config.convertByEntityType && (l = this.groupAndFlattenByType(l));
569
571
  const d = n.tables.blockTable.modelSpace;
570
- await i.processChunk(async (l, h) => {
572
+ await i.processChunk(async (a, h) => {
571
573
  const p = [];
572
- for (let u = l; u < h; u++) {
573
- const f = a[u], g = r.convert(f);
574
+ for (let u = a; u < h; u++) {
575
+ const f = l[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;
597
- const a = n.tables.blockTable.newIterator();
598
- r.objectId = s.handle;
599
- for (const c of a)
598
+ r.layoutName = t.layoutName, r.tabOrder = t.tabOrder;
599
+ const l = n.tables.blockTable.newIterator();
600
+ r.objectId = t.handle;
601
+ for (const c of l)
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;