@mlightcad/libredwg-web 0.7.7 → 0.7.9

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.
@@ -1223,6 +1223,23 @@ const uint8ArrayToHexString = (bytes) => {
1223
1223
  }
1224
1224
  return hexChars.join("");
1225
1225
  };
1226
+ const decodeOle2FrameCornersFromData = (data) => {
1227
+ if (!data || data.length < 98) {
1228
+ return null;
1229
+ }
1230
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
1231
+ const readPoint = (offset) => ({
1232
+ x: view.getFloat64(offset, true),
1233
+ y: view.getFloat64(offset + 8, true),
1234
+ z: view.getFloat64(offset + 16, true)
1235
+ });
1236
+ const upperLeft = readPoint(2);
1237
+ const lowerRight = readPoint(2 + 48);
1238
+ if (![upperLeft.x, upperLeft.y, upperLeft.z, lowerRight.x, lowerRight.y, lowerRight.z].every(Number.isFinite)) {
1239
+ return null;
1240
+ }
1241
+ return { upperLeft, lowerRight };
1242
+ };
1226
1243
  class LibreEntityConverter {
1227
1244
  constructor(instance) {
1228
1245
  __publicField(this, "libredwg");
@@ -1267,6 +1284,8 @@ class LibreEntityConverter {
1267
1284
  const fixedtype = libredwg.dwg_object_get_fixedtype(object_ptr);
1268
1285
  if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DFACE) {
1269
1286
  return this.convert3dFace(entity_tio, commonAttrs);
1287
+ } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DSOLID) {
1288
+ return this.convert3dSolid(entity_tio, commonAttrs);
1270
1289
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARC) {
1271
1290
  return this.convertArc(entity_tio, commonAttrs);
1272
1291
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ATTDEF) {
@@ -1362,6 +1381,43 @@ class LibreEntityConverter {
1362
1381
  flag
1363
1382
  };
1364
1383
  }
1384
+ convert3dSolid(entity, commonAttrs) {
1385
+ const libredwg = this.libredwg;
1386
+ const version = libredwg.dwg_dynapi_entity_data(entity, "version");
1387
+ const satCache = libredwg.dwg_dynapi_entity_data(entity, "acis_empty");
1388
+ const data = libredwg.dwg_dynapi_entity_data(entity, "acis_data");
1389
+ const hasRevisionGuid = libredwg.dwg_dynapi_entity_data(
1390
+ entity,
1391
+ "has_revision_guid"
1392
+ );
1393
+ const historyRef = libredwg.dwg_dynapi_entity_data(entity, "history_id");
1394
+ const historyObjectSoftId = libredwg.dwg_ref_get_id(historyRef);
1395
+ const result = {
1396
+ type: "3DSOLID",
1397
+ subclassMarker: "AcDb3dSolid",
1398
+ ...commonAttrs
1399
+ };
1400
+ if (version) {
1401
+ result.version = version;
1402
+ }
1403
+ result.satCache = satCache;
1404
+ if (data) {
1405
+ result.data = data;
1406
+ }
1407
+ if (hasRevisionGuid) {
1408
+ const guidOffset = libredwg.dwg_dynapi_entity_field_offset(entity, "revision_guid");
1409
+ if (guidOffset >= 0) {
1410
+ const guid = libredwg.UTF8ToString(entity + guidOffset, 38);
1411
+ if (guid) {
1412
+ result.guid = guid;
1413
+ }
1414
+ }
1415
+ }
1416
+ if (historyObjectSoftId) {
1417
+ result.historyObjectSoftId = historyObjectSoftId;
1418
+ }
1419
+ return result;
1420
+ }
1365
1421
  convertArc(entity, commonAttrs) {
1366
1422
  const libredwg = this.libredwg;
1367
1423
  const center = libredwg.dwg_dynapi_entity_data(entity, "center");
@@ -2509,12 +2565,20 @@ class LibreEntityConverter {
2509
2565
  const oleVersion = libredwg.dwg_dynapi_entity_data(entity, "oleversion");
2510
2566
  const oleClient = libredwg.dwg_dynapi_entity_data(entity, "oleclient");
2511
2567
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
2512
- const leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, "pt1");
2513
- const rightDownPoint = libredwg.dwg_dynapi_entity_data(entity, "pt2");
2568
+ let leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, "pt1");
2569
+ let rightDownPoint = libredwg.dwg_dynapi_entity_data(entity, "pt2");
2514
2570
  const lockAspect = libredwg.dwg_dynapi_entity_data(entity, "lock_aspect");
2515
2571
  const oleObjectType = libredwg.dwg_dynapi_entity_data(entity, "type");
2516
2572
  const tileModeDescriptor = libredwg.dwg_dynapi_entity_data(entity, "mode");
2517
- const binaryData = libredwg.dwg_dynapi_entity_data(entity, "data");
2573
+ const dataBytes = libredwg.dwg_entity_ole2frame_get_data(entity);
2574
+ const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : "";
2575
+ if (dataBytes) {
2576
+ const corners = decodeOle2FrameCornersFromData(dataBytes);
2577
+ if (corners) {
2578
+ leftUpPoint = corners.upperLeft;
2579
+ rightDownPoint = corners.lowerRight;
2580
+ }
2581
+ }
2518
2582
  return {
2519
2583
  type: "OLE2FRAME",
2520
2584
  ...commonAttrs,
@@ -2534,7 +2598,8 @@ class LibreEntityConverter {
2534
2598
  const flag = libredwg.dwg_dynapi_entity_data(entity, "flag");
2535
2599
  const mode = libredwg.dwg_dynapi_entity_data(entity, "mode");
2536
2600
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
2537
- const binaryData = libredwg.dwg_dynapi_entity_data(entity, "data");
2601
+ const dataBytes = libredwg.dwg_entity_oleframe_get_data(entity);
2602
+ const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : "";
2538
2603
  return {
2539
2604
  type: "OLEFRAME",
2540
2605
  ...commonAttrs,
@@ -3280,6 +3345,7 @@ class LibreDwgConverter {
3280
3345
  this.entityConverter = new LibreEntityConverter(instance);
3281
3346
  }
3282
3347
  convert(data) {
3348
+ var _a;
3283
3349
  this.entityConverter.clear();
3284
3350
  const db = {
3285
3351
  tables: {
@@ -3308,9 +3374,12 @@ class LibreDwgConverter {
3308
3374
  objects: {
3309
3375
  DICTIONARY: [],
3310
3376
  IMAGEDEF: [],
3377
+ LAYER_FILTER: [],
3378
+ LAYER_INDEX: [],
3311
3379
  LAYOUT: [],
3312
3380
  MLEADERSTYLE: [],
3313
- SPATIAL_FILTER: []
3381
+ SPATIAL_FILTER: [],
3382
+ XRECORD: []
3314
3383
  },
3315
3384
  header: {},
3316
3385
  entities: [],
@@ -3387,6 +3456,12 @@ class LibreDwgConverter {
3387
3456
  case Dwg_Object_Type.DWG_TYPE_IMAGEDEF:
3388
3457
  db.objects.IMAGEDEF.push(this.convertImageDef(tio, obj));
3389
3458
  break;
3459
+ case Dwg_Object_Type.DWG_TYPE_LAYERFILTER:
3460
+ db.objects.LAYER_FILTER.push(this.convertLayerFilter(tio, obj));
3461
+ break;
3462
+ case Dwg_Object_Type.DWG_TYPE_LAYER_INDEX:
3463
+ db.objects.LAYER_INDEX.push(this.convertLayerIndex(tio, obj));
3464
+ break;
3390
3465
  case Dwg_Object_Type.DWG_TYPE_LAYOUT:
3391
3466
  db.objects.LAYOUT.push(this.convertLayout(tio, obj));
3392
3467
  break;
@@ -3398,6 +3473,9 @@ class LibreDwgConverter {
3398
3473
  this.convertSpatialFilter(tio, obj)
3399
3474
  );
3400
3475
  break;
3476
+ case Dwg_Object_Type.DWG_TYPE_XRECORD:
3477
+ db.objects.XRECORD.push(this.convertXRecord(tio, obj));
3478
+ break;
3401
3479
  }
3402
3480
  }
3403
3481
  }
@@ -3413,6 +3491,10 @@ class LibreDwgConverter {
3413
3491
  viewportEntities.forEach((viewport, index) => {
3414
3492
  viewport.viewportId = index + 1;
3415
3493
  });
3494
+ const thumbnail = libredwg.dwg_bmp(data);
3495
+ if ((_a = thumbnail == null ? void 0 : thumbnail.data) == null ? void 0 : _a.length) {
3496
+ db.thumbnailImage = thumbnail.data;
3497
+ }
3416
3498
  return db;
3417
3499
  }
3418
3500
  getConversionStats() {
@@ -3491,17 +3573,10 @@ class LibreDwgConverter {
3491
3573
  const scalability = libredwg.dwg_dynapi_entity_data(item, "block_scaling");
3492
3574
  const layout_ptr = libredwg.dwg_dynapi_entity_data(item, "layout");
3493
3575
  const layout = libredwg.dwg_ref_get_id(layout_ptr) ?? "";
3494
- let bmpPreview = "";
3495
- const uint8ArrayToHexString2 = (bytes) => {
3496
- const hexChars = new Array(bytes.length);
3497
- for (let i = 0; i < bytes.length; i++) {
3498
- hexChars[i] = bytes[i].toString(16).toUpperCase();
3499
- }
3500
- return hexChars.join("");
3501
- };
3576
+ let bmpPreview;
3502
3577
  const bmpPreviewBinaryData = libredwg.dwg_entity_block_header_get_preview(item);
3503
3578
  if (bmpPreviewBinaryData && bmpPreviewBinaryData.length > 0) {
3504
- bmpPreview = uint8ArrayToHexString2(bmpPreviewBinaryData);
3579
+ bmpPreview = uint8ArrayToHexString(bmpPreviewBinaryData);
3505
3580
  }
3506
3581
  let entities = this.convertEntities(obj, commonAttrs.handle);
3507
3582
  if (!entities || entities.length == 0) {
@@ -3962,6 +4037,59 @@ class LibreDwgConverter {
3962
4037
  resolutionUnits
3963
4038
  };
3964
4039
  }
4040
+ convertLayerFilter(item, obj) {
4041
+ const libredwg = this.libredwg;
4042
+ const commonAttrs = this.getCommonObjectAttrs(obj);
4043
+ const numNames = libredwg.dwg_dynapi_entity_data(item, "num_names") ?? 0;
4044
+ const namesPtr = libredwg.dwg_dynapi_entity_data(item, "names");
4045
+ const layerNames = namesPtr && numNames > 0 ? libredwg.dwg_ptr_to_wchar_string_array(namesPtr, numNames).filter((name) => name != null && name !== "") : [];
4046
+ return {
4047
+ ...commonAttrs,
4048
+ ...layerNames.length ? { layerNames } : {}
4049
+ };
4050
+ }
4051
+ convertLayerIndex(item, obj) {
4052
+ const libredwg = this.libredwg;
4053
+ const commonAttrs = this.getCommonObjectAttrs(obj);
4054
+ const timeStamp = libredwg.dwg_dynapi_entity_data(item, "last_updated");
4055
+ const numEntries = libredwg.dwg_dynapi_entity_data(item, "num_entries") ?? 0;
4056
+ const entriesPtr = libredwg.dwg_dynapi_entity_data(item, "entries");
4057
+ const entrySize = libredwg.dwg_dynapi_subclass_size("LAYER_entry");
4058
+ const layerNames = [];
4059
+ const idBufferIds = [];
4060
+ const idBufferEntryCounts = [];
4061
+ if (entriesPtr && entrySize > 0) {
4062
+ for (let i = 0; i < numEntries; i++) {
4063
+ const entryPtr = entriesPtr + i * entrySize;
4064
+ const name = libredwg.dwg_dynapi_subclass_data(
4065
+ entryPtr,
4066
+ "LAYER_entry",
4067
+ "name"
4068
+ );
4069
+ layerNames.push(name ?? "");
4070
+ const handleRef = libredwg.dwg_dynapi_subclass_data(
4071
+ entryPtr,
4072
+ "LAYER_entry",
4073
+ "handle"
4074
+ );
4075
+ idBufferIds.push(handleRef ? libredwg.dwg_ref_get_id(handleRef) ?? "" : "");
4076
+ idBufferEntryCounts.push(
4077
+ libredwg.dwg_dynapi_subclass_data(
4078
+ entryPtr,
4079
+ "LAYER_entry",
4080
+ "numlayers"
4081
+ ) ?? 0
4082
+ );
4083
+ }
4084
+ }
4085
+ return {
4086
+ ...commonAttrs,
4087
+ ...timeStamp != null ? { timeStamp } : {},
4088
+ ...layerNames.length ? { layerNames } : {},
4089
+ ...idBufferIds.length ? { idBufferIds } : {},
4090
+ ...idBufferEntryCounts.length ? { idBufferEntryCounts } : {}
4091
+ };
4092
+ }
3965
4093
  convertLayout(item, obj) {
3966
4094
  const libredwg = this.libredwg;
3967
4095
  const commonAttrs = this.getCommonObjectAttrs(obj);
@@ -4101,6 +4229,21 @@ class LibreDwgConverter {
4101
4229
  invertBlockMatrix
4102
4230
  };
4103
4231
  }
4232
+ convertXRecord(item, obj) {
4233
+ const libredwg = this.libredwg;
4234
+ const commonAttrs = this.getCommonObjectAttrs(obj);
4235
+ const cloning = libredwg.dwg_dynapi_entity_data(item, "cloning");
4236
+ const data = libredwg.dwg_object_xrecord_get_xdata(item) ?? [];
4237
+ const objectObj = libredwg.dwg_object_get_tio(obj);
4238
+ const xdic = objectObj ? libredwg.dwg_object_object_get_xdicobjhandle_object(objectObj) : null;
4239
+ const extensionDictionary = xdic && xdic.absolute_ref ? idToString(xdic.absolute_ref) : void 0;
4240
+ return {
4241
+ ...commonAttrs,
4242
+ ...cloning != null ? { cloning } : {},
4243
+ ...extensionDictionary ? { extensionDictionary } : {},
4244
+ data
4245
+ };
4246
+ }
4104
4247
  getCommonObjectAttrs(obj) {
4105
4248
  const libredwg = this.libredwg;
4106
4249
  const object_tio = libredwg.dwg_object_get_tio(obj);
@@ -6476,6 +6619,24 @@ const _LibreDwg = class _LibreDwg {
6476
6619
  dwg_object_entity_get_xdata(ptr) {
6477
6620
  return this.wasmInstance.dwg_object_entity_get_xdata(ptr);
6478
6621
  }
6622
+ /**
6623
+ * Returns the extension dictionary handle of a Dwg_Object_Object instance.
6624
+ * @group Dwg_Object_Object Methods
6625
+ * @param ptr Pointer to one Dwg_Object_Object instance.
6626
+ * @returns Object ref for the extension dictionary, or null when absent.
6627
+ */
6628
+ dwg_object_object_get_xdicobjhandle_object(ptr) {
6629
+ return this.wasmInstance.dwg_object_object_get_xdicobjhandle_object(ptr);
6630
+ }
6631
+ /**
6632
+ * Returns XRECORD payload as DXF group-code / value pairs.
6633
+ * @group Dwg_Object_XRECORD Methods
6634
+ * @param ptr Pointer to one Dwg_Object_XRECORD instance (object tio).
6635
+ * @returns Array of `{ code, value }` groups.
6636
+ */
6637
+ dwg_object_xrecord_get_xdata(ptr) {
6638
+ return this.wasmInstance.dwg_object_xrecord_get_xdata(ptr) ?? [];
6639
+ }
6479
6640
  /**
6480
6641
  * Returns pointer to BLOCK_HEADER owner for generic entity from ent->ownerhandle.
6481
6642
  * @group Dwg_Object_Entity Methods
@@ -6545,8 +6706,12 @@ const _LibreDwg = class _LibreDwg {
6545
6706
  * @returns Returns preview image of the block pointed by the specified block header.
6546
6707
  */
6547
6708
  dwg_entity_block_header_get_preview(ptr) {
6548
- const wasmInstance = this.wasmInstance;
6549
- return wasmInstance.dwg_entity_block_header_get_preview(ptr).data;
6709
+ const wasm = this.wasmInstance;
6710
+ if (typeof wasm.dwg_entity_block_header_get_preview !== "function") {
6711
+ return null;
6712
+ }
6713
+ const result = wasm.dwg_entity_block_header_get_preview(ptr);
6714
+ return (result == null ? void 0 : result.data) ?? null;
6550
6715
  }
6551
6716
  /**
6552
6717
  * Returns preview binary data of one entity (common entity preview field).
@@ -6574,6 +6739,32 @@ const _LibreDwg = class _LibreDwg {
6574
6739
  const result = wasm.dwg_entity_proxy_entity_get_entity_data(ptr);
6575
6740
  return (result == null ? void 0 : result.data) ?? null;
6576
6741
  }
6742
+ /**
6743
+ * Returns binary OLE payload of one Dwg_Entity_OLE2FRAME instance.
6744
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
6745
+ * @group Dwg_Entity_OLE2FRAME Methods
6746
+ */
6747
+ dwg_entity_ole2frame_get_data(ptr) {
6748
+ const wasm = this.wasmInstance;
6749
+ if (typeof wasm.dwg_entity_ole2frame_get_data !== "function") {
6750
+ return null;
6751
+ }
6752
+ const result = wasm.dwg_entity_ole2frame_get_data(ptr);
6753
+ return (result == null ? void 0 : result.data) ?? null;
6754
+ }
6755
+ /**
6756
+ * Returns binary OLE payload of one Dwg_Entity_OLEFRAME instance.
6757
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
6758
+ * @group Dwg_Entity_OLEFRAME Methods
6759
+ */
6760
+ dwg_entity_oleframe_get_data(ptr) {
6761
+ const wasm = this.wasmInstance;
6762
+ if (typeof wasm.dwg_entity_oleframe_get_data !== "function") {
6763
+ return null;
6764
+ }
6765
+ const result = wasm.dwg_entity_oleframe_get_data(ptr);
6766
+ return (result == null ? void 0 : result.data) ?? null;
6767
+ }
6577
6768
  /**
6578
6769
  * Returns the first entity owned by the block header or null
6579
6770
  * @group Dwg_Entity_BLOCK_HEADER Methods
@@ -1225,6 +1225,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1225
1225
  }
1226
1226
  return hexChars.join("");
1227
1227
  };
1228
+ const decodeOle2FrameCornersFromData = (data) => {
1229
+ if (!data || data.length < 98) {
1230
+ return null;
1231
+ }
1232
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
1233
+ const readPoint = (offset) => ({
1234
+ x: view.getFloat64(offset, true),
1235
+ y: view.getFloat64(offset + 8, true),
1236
+ z: view.getFloat64(offset + 16, true)
1237
+ });
1238
+ const upperLeft = readPoint(2);
1239
+ const lowerRight = readPoint(2 + 48);
1240
+ if (![upperLeft.x, upperLeft.y, upperLeft.z, lowerRight.x, lowerRight.y, lowerRight.z].every(Number.isFinite)) {
1241
+ return null;
1242
+ }
1243
+ return { upperLeft, lowerRight };
1244
+ };
1228
1245
  class LibreEntityConverter {
1229
1246
  constructor(instance) {
1230
1247
  __publicField(this, "libredwg");
@@ -1269,6 +1286,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1269
1286
  const fixedtype = libredwg.dwg_object_get_fixedtype(object_ptr);
1270
1287
  if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DFACE) {
1271
1288
  return this.convert3dFace(entity_tio, commonAttrs);
1289
+ } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DSOLID) {
1290
+ return this.convert3dSolid(entity_tio, commonAttrs);
1272
1291
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARC) {
1273
1292
  return this.convertArc(entity_tio, commonAttrs);
1274
1293
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ATTDEF) {
@@ -1364,6 +1383,43 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1364
1383
  flag
1365
1384
  };
1366
1385
  }
1386
+ convert3dSolid(entity, commonAttrs) {
1387
+ const libredwg = this.libredwg;
1388
+ const version = libredwg.dwg_dynapi_entity_data(entity, "version");
1389
+ const satCache = libredwg.dwg_dynapi_entity_data(entity, "acis_empty");
1390
+ const data = libredwg.dwg_dynapi_entity_data(entity, "acis_data");
1391
+ const hasRevisionGuid = libredwg.dwg_dynapi_entity_data(
1392
+ entity,
1393
+ "has_revision_guid"
1394
+ );
1395
+ const historyRef = libredwg.dwg_dynapi_entity_data(entity, "history_id");
1396
+ const historyObjectSoftId = libredwg.dwg_ref_get_id(historyRef);
1397
+ const result = {
1398
+ type: "3DSOLID",
1399
+ subclassMarker: "AcDb3dSolid",
1400
+ ...commonAttrs
1401
+ };
1402
+ if (version) {
1403
+ result.version = version;
1404
+ }
1405
+ result.satCache = satCache;
1406
+ if (data) {
1407
+ result.data = data;
1408
+ }
1409
+ if (hasRevisionGuid) {
1410
+ const guidOffset = libredwg.dwg_dynapi_entity_field_offset(entity, "revision_guid");
1411
+ if (guidOffset >= 0) {
1412
+ const guid = libredwg.UTF8ToString(entity + guidOffset, 38);
1413
+ if (guid) {
1414
+ result.guid = guid;
1415
+ }
1416
+ }
1417
+ }
1418
+ if (historyObjectSoftId) {
1419
+ result.historyObjectSoftId = historyObjectSoftId;
1420
+ }
1421
+ return result;
1422
+ }
1367
1423
  convertArc(entity, commonAttrs) {
1368
1424
  const libredwg = this.libredwg;
1369
1425
  const center = libredwg.dwg_dynapi_entity_data(entity, "center");
@@ -2511,12 +2567,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2511
2567
  const oleVersion = libredwg.dwg_dynapi_entity_data(entity, "oleversion");
2512
2568
  const oleClient = libredwg.dwg_dynapi_entity_data(entity, "oleclient");
2513
2569
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
2514
- const leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, "pt1");
2515
- const rightDownPoint = libredwg.dwg_dynapi_entity_data(entity, "pt2");
2570
+ let leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, "pt1");
2571
+ let rightDownPoint = libredwg.dwg_dynapi_entity_data(entity, "pt2");
2516
2572
  const lockAspect = libredwg.dwg_dynapi_entity_data(entity, "lock_aspect");
2517
2573
  const oleObjectType = libredwg.dwg_dynapi_entity_data(entity, "type");
2518
2574
  const tileModeDescriptor = libredwg.dwg_dynapi_entity_data(entity, "mode");
2519
- const binaryData = libredwg.dwg_dynapi_entity_data(entity, "data");
2575
+ const dataBytes = libredwg.dwg_entity_ole2frame_get_data(entity);
2576
+ const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : "";
2577
+ if (dataBytes) {
2578
+ const corners = decodeOle2FrameCornersFromData(dataBytes);
2579
+ if (corners) {
2580
+ leftUpPoint = corners.upperLeft;
2581
+ rightDownPoint = corners.lowerRight;
2582
+ }
2583
+ }
2520
2584
  return {
2521
2585
  type: "OLE2FRAME",
2522
2586
  ...commonAttrs,
@@ -2536,7 +2600,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2536
2600
  const flag = libredwg.dwg_dynapi_entity_data(entity, "flag");
2537
2601
  const mode = libredwg.dwg_dynapi_entity_data(entity, "mode");
2538
2602
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
2539
- const binaryData = libredwg.dwg_dynapi_entity_data(entity, "data");
2603
+ const dataBytes = libredwg.dwg_entity_oleframe_get_data(entity);
2604
+ const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : "";
2540
2605
  return {
2541
2606
  type: "OLEFRAME",
2542
2607
  ...commonAttrs,
@@ -3282,6 +3347,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3282
3347
  this.entityConverter = new LibreEntityConverter(instance);
3283
3348
  }
3284
3349
  convert(data) {
3350
+ var _a;
3285
3351
  this.entityConverter.clear();
3286
3352
  const db = {
3287
3353
  tables: {
@@ -3310,9 +3376,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3310
3376
  objects: {
3311
3377
  DICTIONARY: [],
3312
3378
  IMAGEDEF: [],
3379
+ LAYER_FILTER: [],
3380
+ LAYER_INDEX: [],
3313
3381
  LAYOUT: [],
3314
3382
  MLEADERSTYLE: [],
3315
- SPATIAL_FILTER: []
3383
+ SPATIAL_FILTER: [],
3384
+ XRECORD: []
3316
3385
  },
3317
3386
  header: {},
3318
3387
  entities: [],
@@ -3389,6 +3458,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3389
3458
  case Dwg_Object_Type.DWG_TYPE_IMAGEDEF:
3390
3459
  db.objects.IMAGEDEF.push(this.convertImageDef(tio, obj));
3391
3460
  break;
3461
+ case Dwg_Object_Type.DWG_TYPE_LAYERFILTER:
3462
+ db.objects.LAYER_FILTER.push(this.convertLayerFilter(tio, obj));
3463
+ break;
3464
+ case Dwg_Object_Type.DWG_TYPE_LAYER_INDEX:
3465
+ db.objects.LAYER_INDEX.push(this.convertLayerIndex(tio, obj));
3466
+ break;
3392
3467
  case Dwg_Object_Type.DWG_TYPE_LAYOUT:
3393
3468
  db.objects.LAYOUT.push(this.convertLayout(tio, obj));
3394
3469
  break;
@@ -3400,6 +3475,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3400
3475
  this.convertSpatialFilter(tio, obj)
3401
3476
  );
3402
3477
  break;
3478
+ case Dwg_Object_Type.DWG_TYPE_XRECORD:
3479
+ db.objects.XRECORD.push(this.convertXRecord(tio, obj));
3480
+ break;
3403
3481
  }
3404
3482
  }
3405
3483
  }
@@ -3415,6 +3493,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3415
3493
  viewportEntities.forEach((viewport, index) => {
3416
3494
  viewport.viewportId = index + 1;
3417
3495
  });
3496
+ const thumbnail = libredwg.dwg_bmp(data);
3497
+ if ((_a = thumbnail == null ? void 0 : thumbnail.data) == null ? void 0 : _a.length) {
3498
+ db.thumbnailImage = thumbnail.data;
3499
+ }
3418
3500
  return db;
3419
3501
  }
3420
3502
  getConversionStats() {
@@ -3493,17 +3575,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3493
3575
  const scalability = libredwg.dwg_dynapi_entity_data(item, "block_scaling");
3494
3576
  const layout_ptr = libredwg.dwg_dynapi_entity_data(item, "layout");
3495
3577
  const layout = libredwg.dwg_ref_get_id(layout_ptr) ?? "";
3496
- let bmpPreview = "";
3497
- const uint8ArrayToHexString2 = (bytes) => {
3498
- const hexChars = new Array(bytes.length);
3499
- for (let i = 0; i < bytes.length; i++) {
3500
- hexChars[i] = bytes[i].toString(16).toUpperCase();
3501
- }
3502
- return hexChars.join("");
3503
- };
3578
+ let bmpPreview;
3504
3579
  const bmpPreviewBinaryData = libredwg.dwg_entity_block_header_get_preview(item);
3505
3580
  if (bmpPreviewBinaryData && bmpPreviewBinaryData.length > 0) {
3506
- bmpPreview = uint8ArrayToHexString2(bmpPreviewBinaryData);
3581
+ bmpPreview = uint8ArrayToHexString(bmpPreviewBinaryData);
3507
3582
  }
3508
3583
  let entities = this.convertEntities(obj, commonAttrs.handle);
3509
3584
  if (!entities || entities.length == 0) {
@@ -3964,6 +4039,59 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3964
4039
  resolutionUnits
3965
4040
  };
3966
4041
  }
4042
+ convertLayerFilter(item, obj) {
4043
+ const libredwg = this.libredwg;
4044
+ const commonAttrs = this.getCommonObjectAttrs(obj);
4045
+ const numNames = libredwg.dwg_dynapi_entity_data(item, "num_names") ?? 0;
4046
+ const namesPtr = libredwg.dwg_dynapi_entity_data(item, "names");
4047
+ const layerNames = namesPtr && numNames > 0 ? libredwg.dwg_ptr_to_wchar_string_array(namesPtr, numNames).filter((name) => name != null && name !== "") : [];
4048
+ return {
4049
+ ...commonAttrs,
4050
+ ...layerNames.length ? { layerNames } : {}
4051
+ };
4052
+ }
4053
+ convertLayerIndex(item, obj) {
4054
+ const libredwg = this.libredwg;
4055
+ const commonAttrs = this.getCommonObjectAttrs(obj);
4056
+ const timeStamp = libredwg.dwg_dynapi_entity_data(item, "last_updated");
4057
+ const numEntries = libredwg.dwg_dynapi_entity_data(item, "num_entries") ?? 0;
4058
+ const entriesPtr = libredwg.dwg_dynapi_entity_data(item, "entries");
4059
+ const entrySize = libredwg.dwg_dynapi_subclass_size("LAYER_entry");
4060
+ const layerNames = [];
4061
+ const idBufferIds = [];
4062
+ const idBufferEntryCounts = [];
4063
+ if (entriesPtr && entrySize > 0) {
4064
+ for (let i = 0; i < numEntries; i++) {
4065
+ const entryPtr = entriesPtr + i * entrySize;
4066
+ const name = libredwg.dwg_dynapi_subclass_data(
4067
+ entryPtr,
4068
+ "LAYER_entry",
4069
+ "name"
4070
+ );
4071
+ layerNames.push(name ?? "");
4072
+ const handleRef = libredwg.dwg_dynapi_subclass_data(
4073
+ entryPtr,
4074
+ "LAYER_entry",
4075
+ "handle"
4076
+ );
4077
+ idBufferIds.push(handleRef ? libredwg.dwg_ref_get_id(handleRef) ?? "" : "");
4078
+ idBufferEntryCounts.push(
4079
+ libredwg.dwg_dynapi_subclass_data(
4080
+ entryPtr,
4081
+ "LAYER_entry",
4082
+ "numlayers"
4083
+ ) ?? 0
4084
+ );
4085
+ }
4086
+ }
4087
+ return {
4088
+ ...commonAttrs,
4089
+ ...timeStamp != null ? { timeStamp } : {},
4090
+ ...layerNames.length ? { layerNames } : {},
4091
+ ...idBufferIds.length ? { idBufferIds } : {},
4092
+ ...idBufferEntryCounts.length ? { idBufferEntryCounts } : {}
4093
+ };
4094
+ }
3967
4095
  convertLayout(item, obj) {
3968
4096
  const libredwg = this.libredwg;
3969
4097
  const commonAttrs = this.getCommonObjectAttrs(obj);
@@ -4103,6 +4231,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4103
4231
  invertBlockMatrix
4104
4232
  };
4105
4233
  }
4234
+ convertXRecord(item, obj) {
4235
+ const libredwg = this.libredwg;
4236
+ const commonAttrs = this.getCommonObjectAttrs(obj);
4237
+ const cloning = libredwg.dwg_dynapi_entity_data(item, "cloning");
4238
+ const data = libredwg.dwg_object_xrecord_get_xdata(item) ?? [];
4239
+ const objectObj = libredwg.dwg_object_get_tio(obj);
4240
+ const xdic = objectObj ? libredwg.dwg_object_object_get_xdicobjhandle_object(objectObj) : null;
4241
+ const extensionDictionary = xdic && xdic.absolute_ref ? idToString(xdic.absolute_ref) : void 0;
4242
+ return {
4243
+ ...commonAttrs,
4244
+ ...cloning != null ? { cloning } : {},
4245
+ ...extensionDictionary ? { extensionDictionary } : {},
4246
+ data
4247
+ };
4248
+ }
4106
4249
  getCommonObjectAttrs(obj) {
4107
4250
  const libredwg = this.libredwg;
4108
4251
  const object_tio = libredwg.dwg_object_get_tio(obj);
@@ -6478,6 +6621,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6478
6621
  dwg_object_entity_get_xdata(ptr) {
6479
6622
  return this.wasmInstance.dwg_object_entity_get_xdata(ptr);
6480
6623
  }
6624
+ /**
6625
+ * Returns the extension dictionary handle of a Dwg_Object_Object instance.
6626
+ * @group Dwg_Object_Object Methods
6627
+ * @param ptr Pointer to one Dwg_Object_Object instance.
6628
+ * @returns Object ref for the extension dictionary, or null when absent.
6629
+ */
6630
+ dwg_object_object_get_xdicobjhandle_object(ptr) {
6631
+ return this.wasmInstance.dwg_object_object_get_xdicobjhandle_object(ptr);
6632
+ }
6633
+ /**
6634
+ * Returns XRECORD payload as DXF group-code / value pairs.
6635
+ * @group Dwg_Object_XRECORD Methods
6636
+ * @param ptr Pointer to one Dwg_Object_XRECORD instance (object tio).
6637
+ * @returns Array of `{ code, value }` groups.
6638
+ */
6639
+ dwg_object_xrecord_get_xdata(ptr) {
6640
+ return this.wasmInstance.dwg_object_xrecord_get_xdata(ptr) ?? [];
6641
+ }
6481
6642
  /**
6482
6643
  * Returns pointer to BLOCK_HEADER owner for generic entity from ent->ownerhandle.
6483
6644
  * @group Dwg_Object_Entity Methods
@@ -6547,8 +6708,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6547
6708
  * @returns Returns preview image of the block pointed by the specified block header.
6548
6709
  */
6549
6710
  dwg_entity_block_header_get_preview(ptr) {
6550
- const wasmInstance = this.wasmInstance;
6551
- return wasmInstance.dwg_entity_block_header_get_preview(ptr).data;
6711
+ const wasm = this.wasmInstance;
6712
+ if (typeof wasm.dwg_entity_block_header_get_preview !== "function") {
6713
+ return null;
6714
+ }
6715
+ const result = wasm.dwg_entity_block_header_get_preview(ptr);
6716
+ return (result == null ? void 0 : result.data) ?? null;
6552
6717
  }
6553
6718
  /**
6554
6719
  * Returns preview binary data of one entity (common entity preview field).
@@ -6576,6 +6741,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6576
6741
  const result = wasm.dwg_entity_proxy_entity_get_entity_data(ptr);
6577
6742
  return (result == null ? void 0 : result.data) ?? null;
6578
6743
  }
6744
+ /**
6745
+ * Returns binary OLE payload of one Dwg_Entity_OLE2FRAME instance.
6746
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
6747
+ * @group Dwg_Entity_OLE2FRAME Methods
6748
+ */
6749
+ dwg_entity_ole2frame_get_data(ptr) {
6750
+ const wasm = this.wasmInstance;
6751
+ if (typeof wasm.dwg_entity_ole2frame_get_data !== "function") {
6752
+ return null;
6753
+ }
6754
+ const result = wasm.dwg_entity_ole2frame_get_data(ptr);
6755
+ return (result == null ? void 0 : result.data) ?? null;
6756
+ }
6757
+ /**
6758
+ * Returns binary OLE payload of one Dwg_Entity_OLEFRAME instance.
6759
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
6760
+ * @group Dwg_Entity_OLEFRAME Methods
6761
+ */
6762
+ dwg_entity_oleframe_get_data(ptr) {
6763
+ const wasm = this.wasmInstance;
6764
+ if (typeof wasm.dwg_entity_oleframe_get_data !== "function") {
6765
+ return null;
6766
+ }
6767
+ const result = wasm.dwg_entity_oleframe_get_data(ptr);
6768
+ return (result == null ? void 0 : result.data) ?? null;
6769
+ }
6579
6770
  /**
6580
6771
  * Returns the first entity owned by the block header or null
6581
6772
  * @group Dwg_Entity_BLOCK_HEADER Methods
@@ -27,9 +27,12 @@ export declare class LibreDwgConverter {
27
27
  private getCommonTableEntryAttrs;
28
28
  private convertDictionary;
29
29
  private convertImageDef;
30
+ private convertLayerFilter;
31
+ private convertLayerIndex;
30
32
  private convertLayout;
31
33
  private convertMLeaderStyle;
32
34
  private convertSpatialFilter;
35
+ private convertXRecord;
33
36
  private getCommonObjectAttrs;
34
37
  }
35
38
  //# sourceMappingURL=converter.d.ts.map