@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
@@ -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) {
@@ -1277,6 +1296,8 @@ class LibreEntityConverter {
1277
1296
  return this.convertAlignedDimension(entity_tio, commonAttrs);
1278
1297
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG3PT) {
1279
1298
  return this.convert3PointAngularDimension(entity_tio, commonAttrs);
1299
+ } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG2LN) {
1300
+ return this.convert2LineAngularDimension(entity_tio, commonAttrs);
1280
1301
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_DIAMETER) {
1281
1302
  return this.convertDiameterDimension(entity_tio, commonAttrs);
1282
1303
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ORDINATE) {
@@ -1360,6 +1381,43 @@ class LibreEntityConverter {
1360
1381
  flag
1361
1382
  };
1362
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
+ }
1363
1421
  convertArc(entity, commonAttrs) {
1364
1422
  const libredwg = this.libredwg;
1365
1423
  const center = libredwg.dwg_dynapi_entity_data(entity, "center");
@@ -1524,6 +1582,27 @@ class LibreEntityConverter {
1524
1582
  arcPoint
1525
1583
  };
1526
1584
  }
1585
+ convert2LineAngularDimension(entity, commonAttrs) {
1586
+ const libredwg = this.libredwg;
1587
+ const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
1588
+ const xline1Start = libredwg.dwg_dynapi_entity_data(entity, "xline1start_pt");
1589
+ const xline1End = libredwg.dwg_dynapi_entity_data(entity, "xline1end_pt");
1590
+ const xline2Start = libredwg.dwg_dynapi_entity_data(entity, "xline2start_pt");
1591
+ const xline2End = libredwg.dwg_dynapi_entity_data(entity, "xline2end_pt");
1592
+ const vertexPoint = libredwg.dwg_dynapi_entity_data(entity, "def_pt");
1593
+ if (xline2End) {
1594
+ dimensionCommonAttrs.definitionPoint = xline2End;
1595
+ }
1596
+ return {
1597
+ subclassMarker: "AcDb2LineAngularDimension",
1598
+ ...commonAttrs,
1599
+ ...dimensionCommonAttrs,
1600
+ subDefinitionPoint1: xline1Start ?? xline1End ?? vertexPoint ?? xline2End,
1601
+ subDefinitionPoint2: xline2Start ?? xline2End ?? vertexPoint ?? xline1End,
1602
+ centerPoint: vertexPoint ?? xline2Start ?? xline1End ?? xline2End,
1603
+ arcPoint: xline2End ?? dimensionCommonAttrs.definitionPoint
1604
+ };
1605
+ }
1527
1606
  convertDiameterDimension(entity, commonAttrs) {
1528
1607
  const libredwg = this.libredwg;
1529
1608
  const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
@@ -2486,12 +2565,20 @@ class LibreEntityConverter {
2486
2565
  const oleVersion = libredwg.dwg_dynapi_entity_data(entity, "oleversion");
2487
2566
  const oleClient = libredwg.dwg_dynapi_entity_data(entity, "oleclient");
2488
2567
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
2489
- const leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, "pt1");
2490
- 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");
2491
2570
  const lockAspect = libredwg.dwg_dynapi_entity_data(entity, "lock_aspect");
2492
2571
  const oleObjectType = libredwg.dwg_dynapi_entity_data(entity, "type");
2493
2572
  const tileModeDescriptor = libredwg.dwg_dynapi_entity_data(entity, "mode");
2494
- 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
+ }
2495
2582
  return {
2496
2583
  type: "OLE2FRAME",
2497
2584
  ...commonAttrs,
@@ -2511,7 +2598,8 @@ class LibreEntityConverter {
2511
2598
  const flag = libredwg.dwg_dynapi_entity_data(entity, "flag");
2512
2599
  const mode = libredwg.dwg_dynapi_entity_data(entity, "mode");
2513
2600
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
2514
- 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) : "";
2515
2603
  return {
2516
2604
  type: "OLEFRAME",
2517
2605
  ...commonAttrs,
@@ -3285,9 +3373,12 @@ class LibreDwgConverter {
3285
3373
  objects: {
3286
3374
  DICTIONARY: [],
3287
3375
  IMAGEDEF: [],
3376
+ LAYER_FILTER: [],
3377
+ LAYER_INDEX: [],
3288
3378
  LAYOUT: [],
3289
3379
  MLEADERSTYLE: [],
3290
- SPATIAL_FILTER: []
3380
+ SPATIAL_FILTER: [],
3381
+ XRECORD: []
3291
3382
  },
3292
3383
  header: {},
3293
3384
  entities: [],
@@ -3364,6 +3455,12 @@ class LibreDwgConverter {
3364
3455
  case Dwg_Object_Type.DWG_TYPE_IMAGEDEF:
3365
3456
  db.objects.IMAGEDEF.push(this.convertImageDef(tio, obj));
3366
3457
  break;
3458
+ case Dwg_Object_Type.DWG_TYPE_LAYERFILTER:
3459
+ db.objects.LAYER_FILTER.push(this.convertLayerFilter(tio, obj));
3460
+ break;
3461
+ case Dwg_Object_Type.DWG_TYPE_LAYER_INDEX:
3462
+ db.objects.LAYER_INDEX.push(this.convertLayerIndex(tio, obj));
3463
+ break;
3367
3464
  case Dwg_Object_Type.DWG_TYPE_LAYOUT:
3368
3465
  db.objects.LAYOUT.push(this.convertLayout(tio, obj));
3369
3466
  break;
@@ -3375,6 +3472,9 @@ class LibreDwgConverter {
3375
3472
  this.convertSpatialFilter(tio, obj)
3376
3473
  );
3377
3474
  break;
3475
+ case Dwg_Object_Type.DWG_TYPE_XRECORD:
3476
+ db.objects.XRECORD.push(this.convertXRecord(tio, obj));
3477
+ break;
3378
3478
  }
3379
3479
  }
3380
3480
  }
@@ -3939,6 +4039,59 @@ class LibreDwgConverter {
3939
4039
  resolutionUnits
3940
4040
  };
3941
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
+ }
3942
4095
  convertLayout(item, obj) {
3943
4096
  const libredwg = this.libredwg;
3944
4097
  const commonAttrs = this.getCommonObjectAttrs(obj);
@@ -4078,6 +4231,21 @@ class LibreDwgConverter {
4078
4231
  invertBlockMatrix
4079
4232
  };
4080
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
+ }
4081
4249
  getCommonObjectAttrs(obj) {
4082
4250
  const libredwg = this.libredwg;
4083
4251
  const object_tio = libredwg.dwg_object_get_tio(obj);
@@ -6453,6 +6621,24 @@ const _LibreDwg = class _LibreDwg {
6453
6621
  dwg_object_entity_get_xdata(ptr) {
6454
6622
  return this.wasmInstance.dwg_object_entity_get_xdata(ptr);
6455
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
+ }
6456
6642
  /**
6457
6643
  * Returns pointer to BLOCK_HEADER owner for generic entity from ent->ownerhandle.
6458
6644
  * @group Dwg_Object_Entity Methods
@@ -6551,6 +6737,32 @@ const _LibreDwg = class _LibreDwg {
6551
6737
  const result = wasm.dwg_entity_proxy_entity_get_entity_data(ptr);
6552
6738
  return (result == null ? void 0 : result.data) ?? null;
6553
6739
  }
6740
+ /**
6741
+ * Returns binary OLE payload of one Dwg_Entity_OLE2FRAME instance.
6742
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
6743
+ * @group Dwg_Entity_OLE2FRAME Methods
6744
+ */
6745
+ dwg_entity_ole2frame_get_data(ptr) {
6746
+ const wasm = this.wasmInstance;
6747
+ if (typeof wasm.dwg_entity_ole2frame_get_data !== "function") {
6748
+ return null;
6749
+ }
6750
+ const result = wasm.dwg_entity_ole2frame_get_data(ptr);
6751
+ return (result == null ? void 0 : result.data) ?? null;
6752
+ }
6753
+ /**
6754
+ * Returns binary OLE payload of one Dwg_Entity_OLEFRAME instance.
6755
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
6756
+ * @group Dwg_Entity_OLEFRAME Methods
6757
+ */
6758
+ dwg_entity_oleframe_get_data(ptr) {
6759
+ const wasm = this.wasmInstance;
6760
+ if (typeof wasm.dwg_entity_oleframe_get_data !== "function") {
6761
+ return null;
6762
+ }
6763
+ const result = wasm.dwg_entity_oleframe_get_data(ptr);
6764
+ return (result == null ? void 0 : result.data) ?? null;
6765
+ }
6554
6766
  /**
6555
6767
  * Returns the first entity owned by the block header or null
6556
6768
  * @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) {
@@ -1279,6 +1298,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1279
1298
  return this.convertAlignedDimension(entity_tio, commonAttrs);
1280
1299
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG3PT) {
1281
1300
  return this.convert3PointAngularDimension(entity_tio, commonAttrs);
1301
+ } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG2LN) {
1302
+ return this.convert2LineAngularDimension(entity_tio, commonAttrs);
1282
1303
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_DIAMETER) {
1283
1304
  return this.convertDiameterDimension(entity_tio, commonAttrs);
1284
1305
  } else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ORDINATE) {
@@ -1362,6 +1383,43 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1362
1383
  flag
1363
1384
  };
1364
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
+ }
1365
1423
  convertArc(entity, commonAttrs) {
1366
1424
  const libredwg = this.libredwg;
1367
1425
  const center = libredwg.dwg_dynapi_entity_data(entity, "center");
@@ -1526,6 +1584,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1526
1584
  arcPoint
1527
1585
  };
1528
1586
  }
1587
+ convert2LineAngularDimension(entity, commonAttrs) {
1588
+ const libredwg = this.libredwg;
1589
+ const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
1590
+ const xline1Start = libredwg.dwg_dynapi_entity_data(entity, "xline1start_pt");
1591
+ const xline1End = libredwg.dwg_dynapi_entity_data(entity, "xline1end_pt");
1592
+ const xline2Start = libredwg.dwg_dynapi_entity_data(entity, "xline2start_pt");
1593
+ const xline2End = libredwg.dwg_dynapi_entity_data(entity, "xline2end_pt");
1594
+ const vertexPoint = libredwg.dwg_dynapi_entity_data(entity, "def_pt");
1595
+ if (xline2End) {
1596
+ dimensionCommonAttrs.definitionPoint = xline2End;
1597
+ }
1598
+ return {
1599
+ subclassMarker: "AcDb2LineAngularDimension",
1600
+ ...commonAttrs,
1601
+ ...dimensionCommonAttrs,
1602
+ subDefinitionPoint1: xline1Start ?? xline1End ?? vertexPoint ?? xline2End,
1603
+ subDefinitionPoint2: xline2Start ?? xline2End ?? vertexPoint ?? xline1End,
1604
+ centerPoint: vertexPoint ?? xline2Start ?? xline1End ?? xline2End,
1605
+ arcPoint: xline2End ?? dimensionCommonAttrs.definitionPoint
1606
+ };
1607
+ }
1529
1608
  convertDiameterDimension(entity, commonAttrs) {
1530
1609
  const libredwg = this.libredwg;
1531
1610
  const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
@@ -2488,12 +2567,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2488
2567
  const oleVersion = libredwg.dwg_dynapi_entity_data(entity, "oleversion");
2489
2568
  const oleClient = libredwg.dwg_dynapi_entity_data(entity, "oleclient");
2490
2569
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
2491
- const leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, "pt1");
2492
- 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");
2493
2572
  const lockAspect = libredwg.dwg_dynapi_entity_data(entity, "lock_aspect");
2494
2573
  const oleObjectType = libredwg.dwg_dynapi_entity_data(entity, "type");
2495
2574
  const tileModeDescriptor = libredwg.dwg_dynapi_entity_data(entity, "mode");
2496
- 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
+ }
2497
2584
  return {
2498
2585
  type: "OLE2FRAME",
2499
2586
  ...commonAttrs,
@@ -2513,7 +2600,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2513
2600
  const flag = libredwg.dwg_dynapi_entity_data(entity, "flag");
2514
2601
  const mode = libredwg.dwg_dynapi_entity_data(entity, "mode");
2515
2602
  const dataSize = libredwg.dwg_dynapi_entity_data(entity, "data_size");
2516
- 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) : "";
2517
2605
  return {
2518
2606
  type: "OLEFRAME",
2519
2607
  ...commonAttrs,
@@ -3287,9 +3375,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3287
3375
  objects: {
3288
3376
  DICTIONARY: [],
3289
3377
  IMAGEDEF: [],
3378
+ LAYER_FILTER: [],
3379
+ LAYER_INDEX: [],
3290
3380
  LAYOUT: [],
3291
3381
  MLEADERSTYLE: [],
3292
- SPATIAL_FILTER: []
3382
+ SPATIAL_FILTER: [],
3383
+ XRECORD: []
3293
3384
  },
3294
3385
  header: {},
3295
3386
  entities: [],
@@ -3366,6 +3457,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3366
3457
  case Dwg_Object_Type.DWG_TYPE_IMAGEDEF:
3367
3458
  db.objects.IMAGEDEF.push(this.convertImageDef(tio, obj));
3368
3459
  break;
3460
+ case Dwg_Object_Type.DWG_TYPE_LAYERFILTER:
3461
+ db.objects.LAYER_FILTER.push(this.convertLayerFilter(tio, obj));
3462
+ break;
3463
+ case Dwg_Object_Type.DWG_TYPE_LAYER_INDEX:
3464
+ db.objects.LAYER_INDEX.push(this.convertLayerIndex(tio, obj));
3465
+ break;
3369
3466
  case Dwg_Object_Type.DWG_TYPE_LAYOUT:
3370
3467
  db.objects.LAYOUT.push(this.convertLayout(tio, obj));
3371
3468
  break;
@@ -3377,6 +3474,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3377
3474
  this.convertSpatialFilter(tio, obj)
3378
3475
  );
3379
3476
  break;
3477
+ case Dwg_Object_Type.DWG_TYPE_XRECORD:
3478
+ db.objects.XRECORD.push(this.convertXRecord(tio, obj));
3479
+ break;
3380
3480
  }
3381
3481
  }
3382
3482
  }
@@ -3941,6 +4041,59 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3941
4041
  resolutionUnits
3942
4042
  };
3943
4043
  }
4044
+ convertLayerFilter(item, obj) {
4045
+ const libredwg = this.libredwg;
4046
+ const commonAttrs = this.getCommonObjectAttrs(obj);
4047
+ const numNames = libredwg.dwg_dynapi_entity_data(item, "num_names") ?? 0;
4048
+ const namesPtr = libredwg.dwg_dynapi_entity_data(item, "names");
4049
+ const layerNames = namesPtr && numNames > 0 ? libredwg.dwg_ptr_to_wchar_string_array(namesPtr, numNames).filter((name) => name != null && name !== "") : [];
4050
+ return {
4051
+ ...commonAttrs,
4052
+ ...layerNames.length ? { layerNames } : {}
4053
+ };
4054
+ }
4055
+ convertLayerIndex(item, obj) {
4056
+ const libredwg = this.libredwg;
4057
+ const commonAttrs = this.getCommonObjectAttrs(obj);
4058
+ const timeStamp = libredwg.dwg_dynapi_entity_data(item, "last_updated");
4059
+ const numEntries = libredwg.dwg_dynapi_entity_data(item, "num_entries") ?? 0;
4060
+ const entriesPtr = libredwg.dwg_dynapi_entity_data(item, "entries");
4061
+ const entrySize = libredwg.dwg_dynapi_subclass_size("LAYER_entry");
4062
+ const layerNames = [];
4063
+ const idBufferIds = [];
4064
+ const idBufferEntryCounts = [];
4065
+ if (entriesPtr && entrySize > 0) {
4066
+ for (let i = 0; i < numEntries; i++) {
4067
+ const entryPtr = entriesPtr + i * entrySize;
4068
+ const name = libredwg.dwg_dynapi_subclass_data(
4069
+ entryPtr,
4070
+ "LAYER_entry",
4071
+ "name"
4072
+ );
4073
+ layerNames.push(name ?? "");
4074
+ const handleRef = libredwg.dwg_dynapi_subclass_data(
4075
+ entryPtr,
4076
+ "LAYER_entry",
4077
+ "handle"
4078
+ );
4079
+ idBufferIds.push(handleRef ? libredwg.dwg_ref_get_id(handleRef) ?? "" : "");
4080
+ idBufferEntryCounts.push(
4081
+ libredwg.dwg_dynapi_subclass_data(
4082
+ entryPtr,
4083
+ "LAYER_entry",
4084
+ "numlayers"
4085
+ ) ?? 0
4086
+ );
4087
+ }
4088
+ }
4089
+ return {
4090
+ ...commonAttrs,
4091
+ ...timeStamp != null ? { timeStamp } : {},
4092
+ ...layerNames.length ? { layerNames } : {},
4093
+ ...idBufferIds.length ? { idBufferIds } : {},
4094
+ ...idBufferEntryCounts.length ? { idBufferEntryCounts } : {}
4095
+ };
4096
+ }
3944
4097
  convertLayout(item, obj) {
3945
4098
  const libredwg = this.libredwg;
3946
4099
  const commonAttrs = this.getCommonObjectAttrs(obj);
@@ -4080,6 +4233,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4080
4233
  invertBlockMatrix
4081
4234
  };
4082
4235
  }
4236
+ convertXRecord(item, obj) {
4237
+ const libredwg = this.libredwg;
4238
+ const commonAttrs = this.getCommonObjectAttrs(obj);
4239
+ const cloning = libredwg.dwg_dynapi_entity_data(item, "cloning");
4240
+ const data = libredwg.dwg_object_xrecord_get_xdata(item) ?? [];
4241
+ const objectObj = libredwg.dwg_object_get_tio(obj);
4242
+ const xdic = objectObj ? libredwg.dwg_object_object_get_xdicobjhandle_object(objectObj) : null;
4243
+ const extensionDictionary = xdic && xdic.absolute_ref ? idToString(xdic.absolute_ref) : void 0;
4244
+ return {
4245
+ ...commonAttrs,
4246
+ ...cloning != null ? { cloning } : {},
4247
+ ...extensionDictionary ? { extensionDictionary } : {},
4248
+ data
4249
+ };
4250
+ }
4083
4251
  getCommonObjectAttrs(obj) {
4084
4252
  const libredwg = this.libredwg;
4085
4253
  const object_tio = libredwg.dwg_object_get_tio(obj);
@@ -6455,6 +6623,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6455
6623
  dwg_object_entity_get_xdata(ptr) {
6456
6624
  return this.wasmInstance.dwg_object_entity_get_xdata(ptr);
6457
6625
  }
6626
+ /**
6627
+ * Returns the extension dictionary handle of a Dwg_Object_Object instance.
6628
+ * @group Dwg_Object_Object Methods
6629
+ * @param ptr Pointer to one Dwg_Object_Object instance.
6630
+ * @returns Object ref for the extension dictionary, or null when absent.
6631
+ */
6632
+ dwg_object_object_get_xdicobjhandle_object(ptr) {
6633
+ return this.wasmInstance.dwg_object_object_get_xdicobjhandle_object(ptr);
6634
+ }
6635
+ /**
6636
+ * Returns XRECORD payload as DXF group-code / value pairs.
6637
+ * @group Dwg_Object_XRECORD Methods
6638
+ * @param ptr Pointer to one Dwg_Object_XRECORD instance (object tio).
6639
+ * @returns Array of `{ code, value }` groups.
6640
+ */
6641
+ dwg_object_xrecord_get_xdata(ptr) {
6642
+ return this.wasmInstance.dwg_object_xrecord_get_xdata(ptr) ?? [];
6643
+ }
6458
6644
  /**
6459
6645
  * Returns pointer to BLOCK_HEADER owner for generic entity from ent->ownerhandle.
6460
6646
  * @group Dwg_Object_Entity Methods
@@ -6553,6 +6739,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6553
6739
  const result = wasm.dwg_entity_proxy_entity_get_entity_data(ptr);
6554
6740
  return (result == null ? void 0 : result.data) ?? null;
6555
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
+ }
6556
6768
  /**
6557
6769
  * Returns the first entity owned by the block header or null
6558
6770
  * @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