@mlightcad/libredwg-web 0.7.6 → 0.7.8

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.
Files changed (50) hide show
  1. package/dist/libredwg-web.js +217 -5
  2. package/dist/libredwg-web.umd.cjs +217 -5
  3. package/lib/converter/converter.d.ts +3 -0
  4. package/lib/converter/converter.js +76 -1
  5. package/lib/converter/entityConverter.d.ts +2 -0
  6. package/lib/converter/entityConverter.js +79 -5
  7. package/lib/converter/mleaderColorCodec.d.ts +9 -0
  8. package/lib/converter/mleaderColorCodec.js +52 -0
  9. package/lib/converter/stringConverter.d.ts +3 -0
  10. package/lib/converter/stringConverter.js +7 -0
  11. package/lib/converter/utils.d.ts +21 -0
  12. package/lib/converter/utils.js +27 -0
  13. package/lib/database/database.d.ts +4 -1
  14. package/lib/database/entities/dimension.d.ts +1 -1
  15. package/lib/database/entities/index.d.ts +1 -0
  16. package/lib/database/entities/index.js +1 -0
  17. package/lib/database/entities/solid3d.d.ts +32 -0
  18. package/lib/database/entities/solid3d.js +2 -0
  19. package/lib/database/entities/unknown.d.ts +7 -0
  20. package/lib/database/entities/unknown.js +2 -0
  21. package/lib/database/objects/index.d.ts +3 -0
  22. package/lib/database/objects/index.js +3 -0
  23. package/lib/database/objects/layerFilter.d.ts +12 -0
  24. package/lib/database/objects/layerFilter.js +2 -0
  25. package/lib/database/objects/layerIndex.d.ts +18 -0
  26. package/lib/database/objects/layerIndex.js +2 -0
  27. package/lib/database/objects/unknown.d.ts +7 -0
  28. package/lib/database/objects/unknown.js +2 -0
  29. package/lib/database/objects/xrecord.d.ts +30 -0
  30. package/lib/database/objects/xrecord.js +2 -0
  31. package/lib/debug.d.ts +13 -0
  32. package/lib/debug.js +48 -0
  33. package/lib/libredwg-core.d.ts +740 -0
  34. package/lib/libredwg-core.js +1121 -0
  35. package/lib/libredwg-web.d.ts +3 -0
  36. package/lib/libredwg-web.js +2318 -0
  37. package/lib/libredwg.d.ts +30 -1
  38. package/lib/libredwg.js +44 -0
  39. package/lib/memory64/index.d.ts +4 -0
  40. package/lib/memory64/index.js +4 -0
  41. package/lib/memory64/libredwg.d.ts +13 -0
  42. package/lib/memory64/libredwg.js +23 -0
  43. package/lib/types/common.d.ts +2 -0
  44. package/lib/utils/common.d.ts +4 -0
  45. package/lib/utils/common.js +12 -0
  46. package/lib/utils/index.d.ts +2 -0
  47. package/lib/utils/index.js +2 -0
  48. package/package.json +2 -2
  49. package/wasm/libredwg-web.d.ts +548 -544
  50. package/wasm/libredwg-web.wasm +0 -0
@@ -42,9 +42,12 @@ export class LibreDwgConverter {
42
42
  objects: {
43
43
  DICTIONARY: [],
44
44
  IMAGEDEF: [],
45
+ LAYER_FILTER: [],
46
+ LAYER_INDEX: [],
45
47
  LAYOUT: [],
46
48
  MLEADERSTYLE: [],
47
- SPATIAL_FILTER: []
49
+ SPATIAL_FILTER: [],
50
+ XRECORD: []
48
51
  },
49
52
  header: {},
50
53
  entities: [],
@@ -127,6 +130,12 @@ export class LibreDwgConverter {
127
130
  case Dwg_Object_Type.DWG_TYPE_IMAGEDEF:
128
131
  db.objects.IMAGEDEF.push(this.convertImageDef(tio, obj));
129
132
  break;
133
+ case Dwg_Object_Type.DWG_TYPE_LAYERFILTER:
134
+ db.objects.LAYER_FILTER.push(this.convertLayerFilter(tio, obj));
135
+ break;
136
+ case Dwg_Object_Type.DWG_TYPE_LAYER_INDEX:
137
+ db.objects.LAYER_INDEX.push(this.convertLayerIndex(tio, obj));
138
+ break;
130
139
  case Dwg_Object_Type.DWG_TYPE_LAYOUT:
131
140
  db.objects.LAYOUT.push(this.convertLayout(tio, obj));
132
141
  break;
@@ -136,6 +145,9 @@ export class LibreDwgConverter {
136
145
  case Dwg_Object_Type.DWG_TYPE_SPATIAL_FILTER:
137
146
  db.objects.SPATIAL_FILTER.push(this.convertSpatialFilter(tio, obj));
138
147
  break;
148
+ case Dwg_Object_Type.DWG_TYPE_XRECORD:
149
+ db.objects.XRECORD.push(this.convertXRecord(tio, obj));
150
+ break;
139
151
  default:
140
152
  break;
141
153
  }
@@ -741,6 +753,50 @@ export class LibreDwgConverter {
741
753
  resolutionUnits: resolutionUnits
742
754
  };
743
755
  }
756
+ convertLayerFilter(item, obj) {
757
+ const libredwg = this.libredwg;
758
+ const commonAttrs = this.getCommonObjectAttrs(obj);
759
+ const numNames = libredwg.dwg_dynapi_entity_data(item, 'num_names') ?? 0;
760
+ const namesPtr = libredwg.dwg_dynapi_entity_data(item, 'names');
761
+ const layerNames = namesPtr && numNames > 0
762
+ ? libredwg
763
+ .dwg_ptr_to_wchar_string_array(namesPtr, numNames)
764
+ .filter((name) => name != null && name !== '')
765
+ : [];
766
+ return {
767
+ ...commonAttrs,
768
+ ...(layerNames.length ? { layerNames } : {})
769
+ };
770
+ }
771
+ convertLayerIndex(item, obj) {
772
+ const libredwg = this.libredwg;
773
+ const commonAttrs = this.getCommonObjectAttrs(obj);
774
+ const timeStamp = libredwg.dwg_dynapi_entity_data(item, 'last_updated');
775
+ const numEntries = libredwg.dwg_dynapi_entity_data(item, 'num_entries') ?? 0;
776
+ const entriesPtr = libredwg.dwg_dynapi_entity_data(item, 'entries');
777
+ const entrySize = libredwg.dwg_dynapi_subclass_size('LAYER_entry');
778
+ const layerNames = [];
779
+ const idBufferIds = [];
780
+ const idBufferEntryCounts = [];
781
+ if (entriesPtr && entrySize > 0) {
782
+ for (let i = 0; i < numEntries; i++) {
783
+ const entryPtr = entriesPtr + i * entrySize;
784
+ const name = libredwg.dwg_dynapi_subclass_data(entryPtr, 'LAYER_entry', 'name');
785
+ // Keep parallel arrays aligned with entries even when name is absent.
786
+ layerNames.push(name ?? '');
787
+ const handleRef = libredwg.dwg_dynapi_subclass_data(entryPtr, 'LAYER_entry', 'handle');
788
+ idBufferIds.push(handleRef ? (libredwg.dwg_ref_get_id(handleRef) ?? '') : '');
789
+ idBufferEntryCounts.push(libredwg.dwg_dynapi_subclass_data(entryPtr, 'LAYER_entry', 'numlayers') ?? 0);
790
+ }
791
+ }
792
+ return {
793
+ ...commonAttrs,
794
+ ...(timeStamp != null ? { timeStamp } : {}),
795
+ ...(layerNames.length ? { layerNames } : {}),
796
+ ...(idBufferIds.length ? { idBufferIds } : {}),
797
+ ...(idBufferEntryCounts.length ? { idBufferEntryCounts } : {})
798
+ };
799
+ }
744
800
  convertLayout(item, obj) {
745
801
  const libredwg = this.libredwg;
746
802
  const commonAttrs = this.getCommonObjectAttrs(obj);
@@ -879,6 +935,25 @@ export class LibreDwgConverter {
879
935
  invertBlockMatrix: invertBlockMatrix
880
936
  };
881
937
  }
938
+ convertXRecord(item, obj) {
939
+ const libredwg = this.libredwg;
940
+ const commonAttrs = this.getCommonObjectAttrs(obj);
941
+ const cloning = libredwg.dwg_dynapi_entity_data(item, 'cloning');
942
+ const data = libredwg.dwg_object_xrecord_get_xdata(item) ?? [];
943
+ const objectObj = libredwg.dwg_object_get_tio(obj);
944
+ const xdic = objectObj
945
+ ? libredwg.dwg_object_object_get_xdicobjhandle_object(objectObj)
946
+ : null;
947
+ const extensionDictionary = xdic && xdic.absolute_ref
948
+ ? idToString(xdic.absolute_ref)
949
+ : undefined;
950
+ return {
951
+ ...commonAttrs,
952
+ ...(cloning != null ? { cloning } : {}),
953
+ ...(extensionDictionary ? { extensionDictionary } : {}),
954
+ data
955
+ };
956
+ }
882
957
  getCommonObjectAttrs(obj) {
883
958
  const libredwg = this.libredwg;
884
959
  const object_tio = libredwg.dwg_object_get_tio(obj);
@@ -13,6 +13,7 @@ export declare class LibreEntityConverter {
13
13
  clear(): void;
14
14
  convert(object_ptr: Dwg_Object_Ptr): DwgEntity | undefined;
15
15
  private convert3dFace;
16
+ private convert3dSolid;
16
17
  private convertArc;
17
18
  private convertEmbeddedMText;
18
19
  private convertAttdef;
@@ -20,6 +21,7 @@ export declare class LibreEntityConverter {
20
21
  private convertCircle;
21
22
  private convertAlignedDimension;
22
23
  private convert3PointAngularDimension;
24
+ private convert2LineAngularDimension;
23
25
  private convertDiameterDimension;
24
26
  private convertOrdinateDimension;
25
27
  private convertRadiusDimension;
@@ -1,7 +1,7 @@
1
1
  import { DwgBoundaryPathEdgeType, DwgHatchAssociativity, DwgHatchGradientColorFlag, DwgHatchGradientFlag, DwgHatchSolidFill } from '../database';
2
2
  import { Dwg_Hatch_Edge_Type, Dwg_Object_Type } from '../types';
3
3
  import { dwgColorToMLeaderRawColor } from './dwgColorToMLeaderRawColor';
4
- import { idToString, uint8ArrayToHexString } from './utils';
4
+ import { decodeOle2FrameCornersFromData, idToString, uint8ArrayToHexString } from './utils';
5
5
  export class LibreEntityConverter {
6
6
  libredwg;
7
7
  layers = new Map();
@@ -49,6 +49,9 @@ export class LibreEntityConverter {
49
49
  if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DFACE) {
50
50
  return this.convert3dFace(entity_tio, commonAttrs);
51
51
  }
52
+ else if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DSOLID) {
53
+ return this.convert3dSolid(entity_tio, commonAttrs);
54
+ }
52
55
  else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARC) {
53
56
  return this.convertArc(entity_tio, commonAttrs);
54
57
  }
@@ -69,6 +72,9 @@ export class LibreEntityConverter {
69
72
  else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG3PT) {
70
73
  return this.convert3PointAngularDimension(entity_tio, commonAttrs);
71
74
  }
75
+ else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG2LN) {
76
+ return this.convert2LineAngularDimension(entity_tio, commonAttrs);
77
+ }
72
78
  else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_DIAMETER) {
73
79
  return this.convertDiameterDimension(entity_tio, commonAttrs);
74
80
  }
@@ -182,6 +188,40 @@ export class LibreEntityConverter {
182
188
  flag: flag
183
189
  };
184
190
  }
191
+ convert3dSolid(entity, commonAttrs) {
192
+ const libredwg = this.libredwg;
193
+ const version = libredwg.dwg_dynapi_entity_data(entity, 'version');
194
+ const satCache = libredwg.dwg_dynapi_entity_data(entity, 'acis_empty');
195
+ const data = libredwg.dwg_dynapi_entity_data(entity, 'acis_data');
196
+ const hasRevisionGuid = libredwg.dwg_dynapi_entity_data(entity, 'has_revision_guid');
197
+ const historyRef = libredwg.dwg_dynapi_entity_data(entity, 'history_id');
198
+ const historyObjectSoftId = libredwg.dwg_ref_get_id(historyRef);
199
+ const result = {
200
+ type: '3DSOLID',
201
+ subclassMarker: 'AcDb3dSolid',
202
+ ...commonAttrs
203
+ };
204
+ if (version) {
205
+ result.version = version;
206
+ }
207
+ result.satCache = satCache;
208
+ if (data) {
209
+ result.data = data;
210
+ }
211
+ if (hasRevisionGuid) {
212
+ const guidOffset = libredwg.dwg_dynapi_entity_field_offset(entity, 'revision_guid');
213
+ if (guidOffset >= 0) {
214
+ const guid = libredwg.UTF8ToString(entity + guidOffset, 38);
215
+ if (guid) {
216
+ result.guid = guid;
217
+ }
218
+ }
219
+ }
220
+ if (historyObjectSoftId) {
221
+ result.historyObjectSoftId = historyObjectSoftId;
222
+ }
223
+ return result;
224
+ }
185
225
  convertArc(entity, commonAttrs) {
186
226
  const libredwg = this.libredwg;
187
227
  const center = libredwg.dwg_dynapi_entity_data(entity, 'center');
@@ -376,6 +416,29 @@ export class LibreEntityConverter {
376
416
  arcPoint: arcPoint
377
417
  };
378
418
  }
419
+ convert2LineAngularDimension(entity, commonAttrs) {
420
+ const libredwg = this.libredwg;
421
+ const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
422
+ const xline1Start = libredwg.dwg_dynapi_entity_data(entity, 'xline1start_pt');
423
+ const xline1End = libredwg.dwg_dynapi_entity_data(entity, 'xline1end_pt');
424
+ const xline2Start = libredwg.dwg_dynapi_entity_data(entity, 'xline2start_pt');
425
+ const xline2End = libredwg.dwg_dynapi_entity_data(entity, 'xline2end_pt');
426
+ const vertexPoint = libredwg.dwg_dynapi_entity_data(entity, 'def_pt');
427
+ // For 2-line angular dimensions DXF group 10 is the arc location (xline2end_pt),
428
+ // not def_pt which stores the dimension line location (DXF group 16).
429
+ if (xline2End) {
430
+ dimensionCommonAttrs.definitionPoint = xline2End;
431
+ }
432
+ return {
433
+ subclassMarker: 'AcDb2LineAngularDimension',
434
+ ...commonAttrs,
435
+ ...dimensionCommonAttrs,
436
+ subDefinitionPoint1: xline1Start ?? xline1End ?? vertexPoint ?? xline2End,
437
+ subDefinitionPoint2: xline2Start ?? xline2End ?? vertexPoint ?? xline1End,
438
+ centerPoint: vertexPoint ?? xline2Start ?? xline1End ?? xline2End,
439
+ arcPoint: xline2End ?? dimensionCommonAttrs.definitionPoint
440
+ };
441
+ }
379
442
  convertDiameterDimension(entity, commonAttrs) {
380
443
  const libredwg = this.libredwg;
381
444
  const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
@@ -1124,12 +1187,22 @@ export class LibreEntityConverter {
1124
1187
  const oleVersion = libredwg.dwg_dynapi_entity_data(entity, 'oleversion');
1125
1188
  const oleClient = libredwg.dwg_dynapi_entity_data(entity, 'oleclient');
1126
1189
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, 'data_size');
1127
- const leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, 'pt1');
1128
- const rightDownPoint = libredwg.dwg_dynapi_entity_data(entity, 'pt2');
1190
+ let leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, 'pt1');
1191
+ let rightDownPoint = libredwg.dwg_dynapi_entity_data(entity, 'pt2');
1129
1192
  const lockAspect = libredwg.dwg_dynapi_entity_data(entity, 'lock_aspect');
1130
1193
  const oleObjectType = libredwg.dwg_dynapi_entity_data(entity, 'type');
1131
1194
  const tileModeDescriptor = libredwg.dwg_dynapi_entity_data(entity, 'mode');
1132
- const binaryData = libredwg.dwg_dynapi_entity_data(entity, 'data');
1195
+ // Prefer sized TF copy: dynapi TF truncates at the first embedded NUL.
1196
+ const dataBytes = libredwg.dwg_entity_ole2frame_get_data(entity);
1197
+ const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : '';
1198
+ // Prefer corners decoded from the OLE header (also fixed in dwg_decode_ole2).
1199
+ if (dataBytes) {
1200
+ const corners = decodeOle2FrameCornersFromData(dataBytes);
1201
+ if (corners) {
1202
+ leftUpPoint = corners.upperLeft;
1203
+ rightDownPoint = corners.lowerRight;
1204
+ }
1205
+ }
1133
1206
  return {
1134
1207
  type: 'OLE2FRAME',
1135
1208
  ...commonAttrs,
@@ -1149,7 +1222,8 @@ export class LibreEntityConverter {
1149
1222
  const flag = libredwg.dwg_dynapi_entity_data(entity, 'flag');
1150
1223
  const mode = libredwg.dwg_dynapi_entity_data(entity, 'mode');
1151
1224
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, 'data_size');
1152
- const binaryData = libredwg.dwg_dynapi_entity_data(entity, 'data');
1225
+ const dataBytes = libredwg.dwg_entity_oleframe_get_data(entity);
1226
+ const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : '';
1153
1227
  return {
1154
1228
  type: 'OLEFRAME',
1155
1229
  ...commonAttrs,
@@ -0,0 +1,9 @@
1
+ import { Dwg_Color } from '../types';
2
+ /**
3
+ * Encodes a LibreDWG CMC color as the packed int32 used by MLEADER / MLEADERSTYLE DXF.
4
+ *
5
+ * LibreDWG exposes {@link Dwg_Color.index} (0, 1..255, 256). DXF stores the same
6
+ * semantics in a signed 32-bit raw value whose high byte is the color type flag.
7
+ */
8
+ export declare function encodeDwgColorAsMLeaderRaw(color: Dwg_Color | undefined | null): number | undefined;
9
+ //# sourceMappingURL=mleaderColorCodec.d.ts.map
@@ -0,0 +1,52 @@
1
+ import { Dwg_Color_Method } from '../types';
2
+ /** MLEADERSTYLE DXF raw-color type flag: ByLayer (high byte). */
3
+ const RAW_COLOR_TYPE_BY_LAYER = 0xc0;
4
+ /** MLEADERSTYLE DXF raw-color type flag: ByBlock (high byte). */
5
+ const RAW_COLOR_TYPE_BY_BLOCK = 0xc1;
6
+ /** MLEADERSTYLE DXF raw-color type flag: true color (high byte). */
7
+ const RAW_COLOR_TYPE_RGB = 0xc2;
8
+ /** MLEADERSTYLE DXF raw-color type flag: ACI (high byte). */
9
+ const RAW_COLOR_TYPE_ACI = 0xc3;
10
+ /** MLEADERSTYLE DXF raw-color type flag: none / window background. */
11
+ const RAW_COLOR_TYPE_WINDOW_BG = 0xc8;
12
+ /**
13
+ * Encodes a LibreDWG CMC color as the packed int32 used by MLEADER / MLEADERSTYLE DXF.
14
+ *
15
+ * LibreDWG exposes {@link Dwg_Color.index} (0, 1..255, 256). DXF stores the same
16
+ * semantics in a signed 32-bit raw value whose high byte is the color type flag.
17
+ */
18
+ export function encodeDwgColorAsMLeaderRaw(color) {
19
+ if (color == null)
20
+ return undefined;
21
+ const colorMethod = color.method;
22
+ const method = color.method != null && colorMethod !== 0
23
+ ? colorMethod
24
+ : (color.rgb >>> 24) & 0xff;
25
+ const index = color.index;
26
+ if (method === Dwg_Color_Method.ByLayer || index === 256) {
27
+ return (RAW_COLOR_TYPE_BY_LAYER << 24) >> 0;
28
+ }
29
+ if (method === Dwg_Color_Method.ByBlock || index === 0) {
30
+ return (RAW_COLOR_TYPE_BY_BLOCK << 24) >> 0;
31
+ }
32
+ if (method === Dwg_Color_Method.None) {
33
+ return (RAW_COLOR_TYPE_WINDOW_BG << 24) >> 0;
34
+ }
35
+ if (method === Dwg_Color_Method.TrueColor) {
36
+ const rgb = color.rgb != null ? color.rgb & 0xffffff : undefined;
37
+ if (rgb != null) {
38
+ return ((RAW_COLOR_TYPE_RGB << 24) | rgb) >> 0;
39
+ }
40
+ }
41
+ if (method === Dwg_Color_Method.ForegroundColor) {
42
+ return ((RAW_COLOR_TYPE_ACI << 24) | 7) >> 0;
43
+ }
44
+ if (method === Dwg_Color_Method.Entities && index > 0 && index < 256) {
45
+ return ((RAW_COLOR_TYPE_ACI << 24) | (index & 0xff)) >> 0;
46
+ }
47
+ if (index > 0 && index < 256) {
48
+ return ((RAW_COLOR_TYPE_ACI << 24) | (index & 0xff)) >> 0;
49
+ }
50
+ return undefined;
51
+ }
52
+ //# sourceMappingURL=mleaderColorCodec.js.map
@@ -0,0 +1,3 @@
1
+ import { DwgCodePage } from "../database";
2
+ export declare const decodeString: (array: Uint8Array, codepage: DwgCodePage) => string;
3
+ //# sourceMappingURL=stringConverter.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { dwgCodePageToEncoding } from "../database";
2
+ export const decodeString = (array, codepage) => {
3
+ const encoding = dwgCodePageToEncoding(codepage);
4
+ const decoder = new TextDecoder(encoding);
5
+ return decoder.decode(array);
6
+ };
7
+ //# sourceMappingURL=stringConverter.js.map
@@ -2,4 +2,25 @@ export declare const isModelSpace: (name: string) => boolean | "";
2
2
  export declare const isPaperSpace: (name: string) => boolean | "";
3
3
  export declare const idToString: (id: number | bigint) => string;
4
4
  export declare const uint8ArrayToHexString: (bytes: Uint8Array) => string;
5
+ /**
6
+ * OLE2FRAME binary payloads begin with a 0x80-byte Autodesk header, then an
7
+ * MS-CFB compound document. Corner points for DXF groups 10/11 are stored in
8
+ * that header (also decoded by `dwg_decode_ole2`).
9
+ *
10
+ * Layout after a 2-byte unknown prefix (`0x80 0x55` in common files):
11
+ * four WCS corners as little-endian 3D doubles (upper-left, upper-right,
12
+ * lower-right, lower-left). DXF group codes 10/11 store the first and third.
13
+ */
14
+ export declare const decodeOle2FrameCornersFromData: (data: Uint8Array) => {
15
+ upperLeft: {
16
+ x: number;
17
+ y: number;
18
+ z: number;
19
+ };
20
+ lowerRight: {
21
+ x: number;
22
+ y: number;
23
+ z: number;
24
+ };
25
+ } | null;
5
26
  //# sourceMappingURL=utils.d.ts.map
@@ -16,4 +16,31 @@ export const uint8ArrayToHexString = (bytes) => {
16
16
  }
17
17
  return hexChars.join('');
18
18
  };
19
+ /**
20
+ * OLE2FRAME binary payloads begin with a 0x80-byte Autodesk header, then an
21
+ * MS-CFB compound document. Corner points for DXF groups 10/11 are stored in
22
+ * that header (also decoded by `dwg_decode_ole2`).
23
+ *
24
+ * Layout after a 2-byte unknown prefix (`0x80 0x55` in common files):
25
+ * four WCS corners as little-endian 3D doubles (upper-left, upper-right,
26
+ * lower-right, lower-left). DXF group codes 10/11 store the first and third.
27
+ */
28
+ export const decodeOle2FrameCornersFromData = (data) => {
29
+ // 2-byte prefix + 4 corners * 3 doubles * 8 bytes = 98 bytes
30
+ if (!data || data.length < 98) {
31
+ return null;
32
+ }
33
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
34
+ const readPoint = (offset) => ({
35
+ x: view.getFloat64(offset, true),
36
+ y: view.getFloat64(offset + 8, true),
37
+ z: view.getFloat64(offset + 16, true)
38
+ });
39
+ const upperLeft = readPoint(2);
40
+ const lowerRight = readPoint(2 + 48);
41
+ if (![upperLeft.x, upperLeft.y, upperLeft.z, lowerRight.x, lowerRight.y, lowerRight.z].every(Number.isFinite)) {
42
+ return null;
43
+ }
44
+ return { upperLeft, lowerRight };
45
+ };
19
46
  //# sourceMappingURL=utils.js.map
@@ -1,7 +1,7 @@
1
1
  import { DwgClass } from './classes';
2
2
  import { DwgEntity } from './entities';
3
3
  import { DwgHeader } from './header';
4
- import { DwgDictionaryObject, DwgImageDefObject, DwgLayoutObject, DwgMLeaderStyleObject, DwgSpatialFilterObject } from './objects';
4
+ import { DwgDictionaryObject, DwgImageDefObject, DwgLayerFilterObject, DwgLayerIndexObject, DwgLayoutObject, DwgMLeaderStyleObject, DwgSpatialFilterObject, DwgXRecordObject } from './objects';
5
5
  import { DwgAppIdEntry, DwgBlockRecordTableEntry, DwgDimStyleTableEntry, DwgLayerTableEntry, DwgLTypeTableEntry, DwgStyleTableEntry, DwgTable, DwgVPortTableEntry } from './tables';
6
6
  export interface DwgDatabase {
7
7
  tables: {
@@ -16,9 +16,12 @@ export interface DwgDatabase {
16
16
  objects: {
17
17
  DICTIONARY: DwgDictionaryObject[];
18
18
  IMAGEDEF: DwgImageDefObject[];
19
+ LAYER_FILTER: DwgLayerFilterObject[];
20
+ LAYER_INDEX: DwgLayerIndexObject[];
19
21
  LAYOUT: DwgLayoutObject[];
20
22
  MLEADERSTYLE: DwgMLeaderStyleObject[];
21
23
  SPATIAL_FILTER: DwgSpatialFilterObject[];
24
+ XRECORD: DwgXRecordObject[];
22
25
  };
23
26
  header: DwgHeader;
24
27
  /**
@@ -166,7 +166,7 @@ export interface DwgAngularDimensionEntity extends DwgDimensionEntityCommon {
166
166
  /**
167
167
  * Subclass marker (AcDb3PointAngularDimension)
168
168
  */
169
- subclassMarker: 'AcDb3PointAngularDimension';
169
+ subclassMarker: 'AcDb3PointAngularDimension' | 'AcDb2LineAngularDimension';
170
170
  /**
171
171
  * Definition point for linear and angular dimensions (in WCS)
172
172
  */
@@ -24,6 +24,7 @@ export * from './ray';
24
24
  export * from './section';
25
25
  export * from './shape';
26
26
  export * from './solid';
27
+ export * from './solid3d';
27
28
  export * from './spline';
28
29
  export * from './table';
29
30
  export * from './text';
@@ -24,6 +24,7 @@ export * from './ray';
24
24
  export * from './section';
25
25
  export * from './shape';
26
26
  export * from './solid';
27
+ export * from './solid3d';
27
28
  export * from './spline';
28
29
  export * from './table';
29
30
  export * from './text';
@@ -0,0 +1,32 @@
1
+ import { DwgEntity } from './entity';
2
+ export interface DwgSolid3dEntity extends DwgEntity {
3
+ /**
4
+ * Entity type
5
+ */
6
+ type: '3DSOLID';
7
+ /**
8
+ * DXF subclass marker
9
+ */
10
+ subclassMarker: 'AcDb3dSolid';
11
+ /**
12
+ * Modeler format version number (currently = 1)
13
+ */
14
+ version?: number;
15
+ /**
16
+ * SAT cache flag (group 290, R2013+)
17
+ */
18
+ satCache?: number;
19
+ /**
20
+ * GUID string (group 2, R2013+)
21
+ */
22
+ guid?: string;
23
+ /**
24
+ * Proprietary ACIS/SAT data
25
+ */
26
+ data?: string;
27
+ /**
28
+ * Soft-owner ID/handle to history object
29
+ */
30
+ historyObjectSoftId?: string;
31
+ }
32
+ //# sourceMappingURL=solid3d.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=solid3d.js.map
@@ -0,0 +1,7 @@
1
+ export interface DwgUnknownEntity {
2
+ /**
3
+ * Entity type
4
+ */
5
+ type: 'UNKNOWN_ENTITY';
6
+ }
7
+ //# sourceMappingURL=unknown.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=unknown.js.map
@@ -1,8 +1,11 @@
1
1
  export * from './common';
2
2
  export * from './dictionary';
3
3
  export * from './imageDef';
4
+ export * from './layerFilter';
5
+ export * from './layerIndex';
4
6
  export * from './layout';
5
7
  export * from './mleaderStyle';
6
8
  export * from './plotSetting';
7
9
  export * from './spatialFilter';
10
+ export * from './xrecord';
8
11
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,11 @@
1
1
  export * from './common';
2
2
  export * from './dictionary';
3
3
  export * from './imageDef';
4
+ export * from './layerFilter';
5
+ export * from './layerIndex';
4
6
  export * from './layout';
5
7
  export * from './mleaderStyle';
6
8
  export * from './plotSetting';
7
9
  export * from './spatialFilter';
10
+ export * from './xrecord';
8
11
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ import { DwgCommonObject } from './common';
2
+ /**
3
+ * DWG LAYER_FILTER / LAYERFILTER object fields.
4
+ *
5
+ * @remarks
6
+ * This shape mirrors the DXF LAYER_FILTER mapping used by ObjectARX / dxf-json.
7
+ */
8
+ export interface DwgLayerFilterObject extends DwgCommonObject {
9
+ /** Layer names included in this filter. */
10
+ layerNames?: string[];
11
+ }
12
+ //# sourceMappingURL=layerFilter.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=layerFilter.js.map
@@ -0,0 +1,18 @@
1
+ import { DwgCommonObject } from './common';
2
+ /**
3
+ * DWG LAYER_INDEX object fields.
4
+ *
5
+ * @remarks
6
+ * This shape mirrors the DXF LAYER_INDEX mapping used by ObjectARX / dxf-json.
7
+ */
8
+ export interface DwgLayerIndexObject extends DwgCommonObject {
9
+ /** Julian / last-updated timestamp. */
10
+ timeStamp?: number;
11
+ /** Layer names included in this layer index. */
12
+ layerNames?: string[];
13
+ /** Hard-owner handles to IDBUFFER objects. */
14
+ idBufferIds?: string[];
15
+ /** Number of entries in each referenced IDBUFFER. */
16
+ idBufferEntryCounts?: number[];
17
+ }
18
+ //# sourceMappingURL=layerIndex.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=layerIndex.js.map
@@ -0,0 +1,7 @@
1
+ export interface DwgUnknownObject {
2
+ /**
3
+ * Object type
4
+ */
5
+ type: 'UNKNOWN_OBJECT';
6
+ }
7
+ //# sourceMappingURL=unknown.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=unknown.js.map
@@ -0,0 +1,30 @@
1
+ import { DwgCommonObject } from './common';
2
+ /**
3
+ * One DXF group-code / value pair stored in an XRECORD.
4
+ */
5
+ export interface DwgXRecordGroup {
6
+ /** DXF group code. */
7
+ code: number;
8
+ /**
9
+ * Group value. Strings, numbers, booleans, handle hex strings, binary
10
+ * byte arrays, or `{ x, y, z }` for 3D points.
11
+ */
12
+ value: unknown;
13
+ }
14
+ /**
15
+ * DWG XRECORD object fields.
16
+ *
17
+ * @remarks
18
+ * Layer Manager filters (`ACAD_LAYERFILTERS` / `ACLYDICTIONARY`) store each
19
+ * filter node as an XRECORD under those dictionaries. The payload mirrors the
20
+ * DXF XRECORD `data` group list used by ObjectARX / dxf-json.
21
+ */
22
+ export interface DwgXRecordObject extends DwgCommonObject {
23
+ /** Duplicate record cloning flag (DXF group 280). */
24
+ cloning?: number;
25
+ /** Extension dictionary handle, when the object has one. */
26
+ extensionDictionary?: string;
27
+ /** XRecord payload as DXF group pairs. */
28
+ data: DwgXRecordGroup[];
29
+ }
30
+ //# sourceMappingURL=xrecord.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=xrecord.js.map
package/lib/debug.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ export interface LibreDwgDebugOptions {
2
+ /** Master switch for all debug output. */
3
+ enabled: boolean;
4
+ /** Log proxy entity graphics/entity data resolution. */
5
+ proxyEntity: boolean;
6
+ }
7
+ export declare function getLibreDwgDebugOptions(): Readonly<LibreDwgDebugOptions>;
8
+ export declare function setLibreDwgDebugOptions(partial: Partial<LibreDwgDebugOptions>): LibreDwgDebugOptions;
9
+ export declare function resetLibreDwgDebugOptions(): void;
10
+ export declare function isLibreDwgDebugEnabled(scope?: keyof Omit<LibreDwgDebugOptions, 'enabled'>): boolean;
11
+ export declare function libreDwgDebugLog(scope: keyof Omit<LibreDwgDebugOptions, 'enabled'>, message: string, data?: unknown): void;
12
+ export declare function hexPreview(bytes: Uint8Array | number[] | null | undefined, maxBytes?: number): string;
13
+ //# sourceMappingURL=debug.d.ts.map