@mlightcad/libredwg-web 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libredwg-web.js +40 -17
- package/dist/libredwg-web.umd.cjs +40 -17
- package/lib/converter/entityConverter.d.ts +1 -0
- package/lib/converter/entityConverter.js +52 -30
- package/lib/database/entities/dimension.d.ts +1 -1
- package/lib/svg/svgConverter.js +1 -0
- package/package.json +2 -2
- package/wasm/libredwg-web.wasm +0 -0
package/dist/libredwg-web.js
CHANGED
|
@@ -1277,6 +1277,8 @@ class LibreEntityConverter {
|
|
|
1277
1277
|
return this.convertAlignedDimension(entity_tio, commonAttrs);
|
|
1278
1278
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG3PT) {
|
|
1279
1279
|
return this.convert3PointAngularDimension(entity_tio, commonAttrs);
|
|
1280
|
+
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG2LN) {
|
|
1281
|
+
return this.convert2LineAngularDimension(entity_tio, commonAttrs);
|
|
1280
1282
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_DIAMETER) {
|
|
1281
1283
|
return this.convertDiameterDimension(entity_tio, commonAttrs);
|
|
1282
1284
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ORDINATE) {
|
|
@@ -1524,6 +1526,27 @@ class LibreEntityConverter {
|
|
|
1524
1526
|
arcPoint
|
|
1525
1527
|
};
|
|
1526
1528
|
}
|
|
1529
|
+
convert2LineAngularDimension(entity, commonAttrs) {
|
|
1530
|
+
const libredwg = this.libredwg;
|
|
1531
|
+
const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
|
|
1532
|
+
const xline1Start = libredwg.dwg_dynapi_entity_data(entity, "xline1start_pt");
|
|
1533
|
+
const xline1End = libredwg.dwg_dynapi_entity_data(entity, "xline1end_pt");
|
|
1534
|
+
const xline2Start = libredwg.dwg_dynapi_entity_data(entity, "xline2start_pt");
|
|
1535
|
+
const xline2End = libredwg.dwg_dynapi_entity_data(entity, "xline2end_pt");
|
|
1536
|
+
const vertexPoint = libredwg.dwg_dynapi_entity_data(entity, "def_pt");
|
|
1537
|
+
if (xline2End) {
|
|
1538
|
+
dimensionCommonAttrs.definitionPoint = xline2End;
|
|
1539
|
+
}
|
|
1540
|
+
return {
|
|
1541
|
+
subclassMarker: "AcDb2LineAngularDimension",
|
|
1542
|
+
...commonAttrs,
|
|
1543
|
+
...dimensionCommonAttrs,
|
|
1544
|
+
subDefinitionPoint1: xline1Start ?? xline1End ?? vertexPoint ?? xline2End,
|
|
1545
|
+
subDefinitionPoint2: xline2Start ?? xline2End ?? vertexPoint ?? xline1End,
|
|
1546
|
+
centerPoint: vertexPoint ?? xline2Start ?? xline1End ?? xline2End,
|
|
1547
|
+
arcPoint: xline2End ?? dimensionCommonAttrs.definitionPoint
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1527
1550
|
convertDiameterDimension(entity, commonAttrs) {
|
|
1528
1551
|
const libredwg = this.libredwg;
|
|
1529
1552
|
const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
|
|
@@ -2934,37 +2957,36 @@ class LibreEntityConverter {
|
|
|
2934
2957
|
};
|
|
2935
2958
|
}
|
|
2936
2959
|
convertTableCells(cells) {
|
|
2937
|
-
|
|
2938
|
-
|
|
2960
|
+
return cells.map((cell) => {
|
|
2961
|
+
var _a, _b;
|
|
2939
2962
|
return {
|
|
2940
2963
|
text: cell.text_value,
|
|
2941
2964
|
attachmentPoint: cell.cell_alignment,
|
|
2942
|
-
textStyle: cell.text_style,
|
|
2943
|
-
// TODO: Set the text style name instead of handle
|
|
2965
|
+
textStyle: cell.text_style ? String(cell.text_style) : void 0,
|
|
2944
2966
|
rotation: cell.rotation,
|
|
2945
2967
|
cellType: cell.type,
|
|
2946
2968
|
flagValue: cell.flags,
|
|
2947
2969
|
mergedValue: cell.is_merged_value,
|
|
2948
2970
|
autoFit: cell.is_autofit_flag,
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
leftBorderVisibility: cell.left_visibility,
|
|
2954
|
-
rightBorderVisibility: cell.right_visibility,
|
|
2971
|
+
topBorderVisibility: !!cell.top_visibility,
|
|
2972
|
+
bottomBorderVisibility: !!cell.bottom_visibility,
|
|
2973
|
+
leftBorderVisibility: !!cell.left_visibility,
|
|
2974
|
+
rightBorderVisibility: !!cell.right_visibility,
|
|
2955
2975
|
overrideFlag: cell.cell_flag_override,
|
|
2956
2976
|
virtualEdgeFlag: cell.virtual_edge_flag,
|
|
2957
|
-
|
|
2958
|
-
blockTableRecordI: cell.block_handle.absolute_ref,
|
|
2977
|
+
blockTableRecordId: cell.block_handle ? String(cell.block_handle.absolute_ref ?? "") : void 0,
|
|
2959
2978
|
blockScale: cell.block_scale,
|
|
2960
|
-
blockAttrNum: cell.attr_defs.length,
|
|
2961
|
-
attrDefineId: cell.attr_defs
|
|
2962
|
-
|
|
2963
|
-
|
|
2979
|
+
blockAttrNum: ((_a = cell.attr_defs) == null ? void 0 : _a.length) ?? 0,
|
|
2980
|
+
attrDefineId: (_b = cell.attr_defs) == null ? void 0 : _b.map(
|
|
2981
|
+
(value) => {
|
|
2982
|
+
var _a2;
|
|
2983
|
+
return String(((_a2 = value.attdef) == null ? void 0 : _a2.absolute_ref) ?? "");
|
|
2984
|
+
}
|
|
2985
|
+
),
|
|
2986
|
+
textHeight: cell.text_height ?? 0,
|
|
2964
2987
|
extendedCellFlags: cell.additional_data_flag
|
|
2965
2988
|
};
|
|
2966
2989
|
});
|
|
2967
|
-
return converted;
|
|
2968
2990
|
}
|
|
2969
2991
|
convertTextBase(entity) {
|
|
2970
2992
|
const libredwg = this.libredwg;
|
|
@@ -5389,6 +5411,7 @@ class SvgConverter {
|
|
|
5389
5411
|
result = this.ray(entity);
|
|
5390
5412
|
break;
|
|
5391
5413
|
case "TABLE":
|
|
5414
|
+
case "ACAD_TABLE":
|
|
5392
5415
|
result = this.table(entity);
|
|
5393
5416
|
break;
|
|
5394
5417
|
case "TEXT":
|
|
@@ -1279,6 +1279,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1279
1279
|
return this.convertAlignedDimension(entity_tio, commonAttrs);
|
|
1280
1280
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG3PT) {
|
|
1281
1281
|
return this.convert3PointAngularDimension(entity_tio, commonAttrs);
|
|
1282
|
+
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG2LN) {
|
|
1283
|
+
return this.convert2LineAngularDimension(entity_tio, commonAttrs);
|
|
1282
1284
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_DIAMETER) {
|
|
1283
1285
|
return this.convertDiameterDimension(entity_tio, commonAttrs);
|
|
1284
1286
|
} else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ORDINATE) {
|
|
@@ -1526,6 +1528,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1526
1528
|
arcPoint
|
|
1527
1529
|
};
|
|
1528
1530
|
}
|
|
1531
|
+
convert2LineAngularDimension(entity, commonAttrs) {
|
|
1532
|
+
const libredwg = this.libredwg;
|
|
1533
|
+
const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
|
|
1534
|
+
const xline1Start = libredwg.dwg_dynapi_entity_data(entity, "xline1start_pt");
|
|
1535
|
+
const xline1End = libredwg.dwg_dynapi_entity_data(entity, "xline1end_pt");
|
|
1536
|
+
const xline2Start = libredwg.dwg_dynapi_entity_data(entity, "xline2start_pt");
|
|
1537
|
+
const xline2End = libredwg.dwg_dynapi_entity_data(entity, "xline2end_pt");
|
|
1538
|
+
const vertexPoint = libredwg.dwg_dynapi_entity_data(entity, "def_pt");
|
|
1539
|
+
if (xline2End) {
|
|
1540
|
+
dimensionCommonAttrs.definitionPoint = xline2End;
|
|
1541
|
+
}
|
|
1542
|
+
return {
|
|
1543
|
+
subclassMarker: "AcDb2LineAngularDimension",
|
|
1544
|
+
...commonAttrs,
|
|
1545
|
+
...dimensionCommonAttrs,
|
|
1546
|
+
subDefinitionPoint1: xline1Start ?? xline1End ?? vertexPoint ?? xline2End,
|
|
1547
|
+
subDefinitionPoint2: xline2Start ?? xline2End ?? vertexPoint ?? xline1End,
|
|
1548
|
+
centerPoint: vertexPoint ?? xline2Start ?? xline1End ?? xline2End,
|
|
1549
|
+
arcPoint: xline2End ?? dimensionCommonAttrs.definitionPoint
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1529
1552
|
convertDiameterDimension(entity, commonAttrs) {
|
|
1530
1553
|
const libredwg = this.libredwg;
|
|
1531
1554
|
const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
|
|
@@ -2936,37 +2959,36 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2936
2959
|
};
|
|
2937
2960
|
}
|
|
2938
2961
|
convertTableCells(cells) {
|
|
2939
|
-
|
|
2940
|
-
|
|
2962
|
+
return cells.map((cell) => {
|
|
2963
|
+
var _a, _b;
|
|
2941
2964
|
return {
|
|
2942
2965
|
text: cell.text_value,
|
|
2943
2966
|
attachmentPoint: cell.cell_alignment,
|
|
2944
|
-
textStyle: cell.text_style,
|
|
2945
|
-
// TODO: Set the text style name instead of handle
|
|
2967
|
+
textStyle: cell.text_style ? String(cell.text_style) : void 0,
|
|
2946
2968
|
rotation: cell.rotation,
|
|
2947
2969
|
cellType: cell.type,
|
|
2948
2970
|
flagValue: cell.flags,
|
|
2949
2971
|
mergedValue: cell.is_merged_value,
|
|
2950
2972
|
autoFit: cell.is_autofit_flag,
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
leftBorderVisibility: cell.left_visibility,
|
|
2956
|
-
rightBorderVisibility: cell.right_visibility,
|
|
2973
|
+
topBorderVisibility: !!cell.top_visibility,
|
|
2974
|
+
bottomBorderVisibility: !!cell.bottom_visibility,
|
|
2975
|
+
leftBorderVisibility: !!cell.left_visibility,
|
|
2976
|
+
rightBorderVisibility: !!cell.right_visibility,
|
|
2957
2977
|
overrideFlag: cell.cell_flag_override,
|
|
2958
2978
|
virtualEdgeFlag: cell.virtual_edge_flag,
|
|
2959
|
-
|
|
2960
|
-
blockTableRecordI: cell.block_handle.absolute_ref,
|
|
2979
|
+
blockTableRecordId: cell.block_handle ? String(cell.block_handle.absolute_ref ?? "") : void 0,
|
|
2961
2980
|
blockScale: cell.block_scale,
|
|
2962
|
-
blockAttrNum: cell.attr_defs.length,
|
|
2963
|
-
attrDefineId: cell.attr_defs
|
|
2964
|
-
|
|
2965
|
-
|
|
2981
|
+
blockAttrNum: ((_a = cell.attr_defs) == null ? void 0 : _a.length) ?? 0,
|
|
2982
|
+
attrDefineId: (_b = cell.attr_defs) == null ? void 0 : _b.map(
|
|
2983
|
+
(value) => {
|
|
2984
|
+
var _a2;
|
|
2985
|
+
return String(((_a2 = value.attdef) == null ? void 0 : _a2.absolute_ref) ?? "");
|
|
2986
|
+
}
|
|
2987
|
+
),
|
|
2988
|
+
textHeight: cell.text_height ?? 0,
|
|
2966
2989
|
extendedCellFlags: cell.additional_data_flag
|
|
2967
2990
|
};
|
|
2968
2991
|
});
|
|
2969
|
-
return converted;
|
|
2970
2992
|
}
|
|
2971
2993
|
convertTextBase(entity) {
|
|
2972
2994
|
const libredwg = this.libredwg;
|
|
@@ -5391,6 +5413,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5391
5413
|
result = this.ray(entity);
|
|
5392
5414
|
break;
|
|
5393
5415
|
case "TABLE":
|
|
5416
|
+
case "ACAD_TABLE":
|
|
5394
5417
|
result = this.table(entity);
|
|
5395
5418
|
break;
|
|
5396
5419
|
case "TEXT":
|
|
@@ -20,6 +20,7 @@ export declare class LibreEntityConverter {
|
|
|
20
20
|
private convertCircle;
|
|
21
21
|
private convertAlignedDimension;
|
|
22
22
|
private convert3PointAngularDimension;
|
|
23
|
+
private convert2LineAngularDimension;
|
|
23
24
|
private convertDiameterDimension;
|
|
24
25
|
private convertOrdinateDimension;
|
|
25
26
|
private convertRadiusDimension;
|
|
@@ -69,6 +69,9 @@ export class LibreEntityConverter {
|
|
|
69
69
|
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG3PT) {
|
|
70
70
|
return this.convert3PointAngularDimension(entity_tio, commonAttrs);
|
|
71
71
|
}
|
|
72
|
+
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_ANG2LN) {
|
|
73
|
+
return this.convert2LineAngularDimension(entity_tio, commonAttrs);
|
|
74
|
+
}
|
|
72
75
|
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_DIMENSION_DIAMETER) {
|
|
73
76
|
return this.convertDiameterDimension(entity_tio, commonAttrs);
|
|
74
77
|
}
|
|
@@ -376,6 +379,29 @@ export class LibreEntityConverter {
|
|
|
376
379
|
arcPoint: arcPoint
|
|
377
380
|
};
|
|
378
381
|
}
|
|
382
|
+
convert2LineAngularDimension(entity, commonAttrs) {
|
|
383
|
+
const libredwg = this.libredwg;
|
|
384
|
+
const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
|
|
385
|
+
const xline1Start = libredwg.dwg_dynapi_entity_data(entity, 'xline1start_pt');
|
|
386
|
+
const xline1End = libredwg.dwg_dynapi_entity_data(entity, 'xline1end_pt');
|
|
387
|
+
const xline2Start = libredwg.dwg_dynapi_entity_data(entity, 'xline2start_pt');
|
|
388
|
+
const xline2End = libredwg.dwg_dynapi_entity_data(entity, 'xline2end_pt');
|
|
389
|
+
const vertexPoint = libredwg.dwg_dynapi_entity_data(entity, 'def_pt');
|
|
390
|
+
// For 2-line angular dimensions DXF group 10 is the arc location (xline2end_pt),
|
|
391
|
+
// not def_pt which stores the dimension line location (DXF group 16).
|
|
392
|
+
if (xline2End) {
|
|
393
|
+
dimensionCommonAttrs.definitionPoint = xline2End;
|
|
394
|
+
}
|
|
395
|
+
return {
|
|
396
|
+
subclassMarker: 'AcDb2LineAngularDimension',
|
|
397
|
+
...commonAttrs,
|
|
398
|
+
...dimensionCommonAttrs,
|
|
399
|
+
subDefinitionPoint1: xline1Start ?? xline1End ?? vertexPoint ?? xline2End,
|
|
400
|
+
subDefinitionPoint2: xline2Start ?? xline2End ?? vertexPoint ?? xline1End,
|
|
401
|
+
centerPoint: vertexPoint ?? xline2Start ?? xline1End ?? xline2End,
|
|
402
|
+
arcPoint: xline2End ?? dimensionCommonAttrs.definitionPoint
|
|
403
|
+
};
|
|
404
|
+
}
|
|
379
405
|
convertDiameterDimension(entity, commonAttrs) {
|
|
380
406
|
const libredwg = this.libredwg;
|
|
381
407
|
const dimensionCommonAttrs = this.getDimensionCommonAttrs(entity);
|
|
@@ -1561,36 +1587,32 @@ export class LibreEntityConverter {
|
|
|
1561
1587
|
};
|
|
1562
1588
|
}
|
|
1563
1589
|
convertTableCells(cells) {
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
extendedCellFlags: cell.additional_data_flag
|
|
1591
|
-
};
|
|
1592
|
-
});
|
|
1593
|
-
return converted;
|
|
1590
|
+
return cells.map(cell => ({
|
|
1591
|
+
text: cell.text_value,
|
|
1592
|
+
attachmentPoint: cell.cell_alignment,
|
|
1593
|
+
textStyle: cell.text_style
|
|
1594
|
+
? String(cell.text_style)
|
|
1595
|
+
: undefined,
|
|
1596
|
+
rotation: cell.rotation,
|
|
1597
|
+
cellType: cell.type,
|
|
1598
|
+
flagValue: cell.flags,
|
|
1599
|
+
mergedValue: cell.is_merged_value,
|
|
1600
|
+
autoFit: cell.is_autofit_flag,
|
|
1601
|
+
topBorderVisibility: !!cell.top_visibility,
|
|
1602
|
+
bottomBorderVisibility: !!cell.bottom_visibility,
|
|
1603
|
+
leftBorderVisibility: !!cell.left_visibility,
|
|
1604
|
+
rightBorderVisibility: !!cell.right_visibility,
|
|
1605
|
+
overrideFlag: cell.cell_flag_override,
|
|
1606
|
+
virtualEdgeFlag: cell.virtual_edge_flag,
|
|
1607
|
+
blockTableRecordId: cell.block_handle
|
|
1608
|
+
? String(cell.block_handle.absolute_ref ?? '')
|
|
1609
|
+
: undefined,
|
|
1610
|
+
blockScale: cell.block_scale,
|
|
1611
|
+
blockAttrNum: cell.attr_defs?.length ?? 0,
|
|
1612
|
+
attrDefineId: cell.attr_defs?.map(value => String(value.attdef?.absolute_ref ?? '')),
|
|
1613
|
+
textHeight: cell.text_height ?? 0,
|
|
1614
|
+
extendedCellFlags: cell.additional_data_flag
|
|
1615
|
+
}));
|
|
1594
1616
|
}
|
|
1595
1617
|
convertTextBase(entity) {
|
|
1596
1618
|
const libredwg = this.libredwg;
|
|
@@ -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
|
*/
|
package/lib/svg/svgConverter.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A DWG/DXF JavaScript parser based on libredwg",
|
|
4
4
|
"license": "GPL-3.0",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "0.7.
|
|
6
|
+
"version": "0.7.7",
|
|
7
7
|
"author": "MLight Lee <mlight.lee@outlook.com>",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"engines": {
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"demo": "live-server examples --entry-file=index.html",
|
|
75
75
|
"doc": "typedoc",
|
|
76
76
|
"build": "tsc && vite build && cp -rf wasm examples/ && cp -rf dist examples/",
|
|
77
|
-
"build:prepare": "mkdir -p ../../build-wasm && cd ../../build-wasm && emconfigure ../configure CFLAGS=\"-O2 -sUSE_ZLIB=1 -DNDEBUG\" CC=emcc --enable-release --disable-docs --disable-write --disable-python --disable-bindings --disable-shared --disable-json
|
|
77
|
+
"build:prepare": "mkdir -p ../../build-wasm && cd ../../build-wasm && emconfigure ../configure CFLAGS=\"-O2 -sUSE_ZLIB=1 -DNDEBUG\" CC=emcc --enable-release --enable-debug --disable-docs --disable-write --disable-python --disable-bindings --disable-shared --disable-json",
|
|
78
78
|
"build:obj": "cd ../../build-wasm && emmake make",
|
|
79
79
|
"build:wasm": "cd ../../build-wasm && emcc ../bindings/javascript/embind/*.cpp src/*.o -O2 -lembind -std=c++17 -Isrc -I../src -I../include -o libredwg-web.js -s ALLOW_MEMORY_GROWTH=1 -s INITIAL_MEMORY=1GB -s MAXIMUM_MEMORY=4GB -s MALLOC=mimalloc -s EXPORT_ES6=1 -s MODULARIZE=1 -s EXPORT_NAME=\"createModule\" -sEXPORTED_RUNTIME_METHODS=FS,ENV,ccall,cwrap,UTF8ToString,stringToNewUTF8,setValue --emit-tsd libredwg-web.d.ts",
|
|
80
80
|
"clean": "rm -rf ../../build-wasm ./docs ./dist ./lib",
|
package/wasm/libredwg-web.wasm
CHANGED
|
Binary file
|