@mlightcad/libredwg-web 0.7.8 → 0.7.10
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 +15 -13
- package/dist/libredwg-web.umd.cjs +15 -13
- package/lib/converter/converter.js +6 -9
- package/lib/converter/entityConverter.js +2 -2
- package/lib/database/database.d.ts +1 -0
- package/lib/libredwg.d.ts +1 -1
- package/lib/libredwg.js +6 -3
- package/package.json +3 -2
- package/wasm/libredwg-web.d.ts +548 -548
- package/lib/converter/mleaderColorCodec.d.ts +0 -9
- package/lib/converter/mleaderColorCodec.js +0 -52
- package/lib/converter/stringConverter.d.ts +0 -3
- package/lib/converter/stringConverter.js +0 -7
- package/lib/database/entities/unknown.d.ts +0 -7
- package/lib/database/entities/unknown.js +0 -2
- package/lib/database/objects/unknown.d.ts +0 -7
- package/lib/database/objects/unknown.js +0 -2
- package/lib/debug.d.ts +0 -13
- package/lib/debug.js +0 -48
- package/lib/libredwg-core.d.ts +0 -740
- package/lib/libredwg-core.js +0 -1121
- package/lib/libredwg-web.d.ts +0 -3
- package/lib/libredwg-web.js +0 -2318
- package/lib/memory64/index.d.ts +0 -4
- package/lib/memory64/index.js +0 -4
- package/lib/memory64/libredwg.d.ts +0 -13
- package/lib/memory64/libredwg.js +0 -23
- package/lib/utils/common.d.ts +0 -4
- package/lib/utils/common.js +0 -12
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -2
package/dist/libredwg-web.js
CHANGED
|
@@ -2701,7 +2701,7 @@ class LibreEntityConverter {
|
|
|
2701
2701
|
const elevation = libredwg.dwg_dynapi_entity_data(entity, "elevation");
|
|
2702
2702
|
const thickness = libredwg.dwg_dynapi_entity_data(entity, "thickness");
|
|
2703
2703
|
const extrusionDirection = libredwg.dwg_dynapi_entity_data(entity, "extrusion");
|
|
2704
|
-
const vertices = libredwg.dwg_entity_polyline_2d_get_vertices(object);
|
|
2704
|
+
const vertices = libredwg.dwg_entity_polyline_2d_get_vertices(object) ?? [];
|
|
2705
2705
|
return {
|
|
2706
2706
|
type: "POLYLINE2D",
|
|
2707
2707
|
...commonAttrs,
|
|
@@ -2737,7 +2737,7 @@ class LibreEntityConverter {
|
|
|
2737
2737
|
const startWidth = libredwg.dwg_dynapi_entity_data(entity, "start_width");
|
|
2738
2738
|
const endWidth = libredwg.dwg_dynapi_entity_data(entity, "end_width");
|
|
2739
2739
|
const extrusionDirection = libredwg.dwg_dynapi_entity_data(entity, "extrusion");
|
|
2740
|
-
const vertices = libredwg.dwg_entity_polyline_3d_get_vertices(object);
|
|
2740
|
+
const vertices = libredwg.dwg_entity_polyline_3d_get_vertices(object) ?? [];
|
|
2741
2741
|
return {
|
|
2742
2742
|
type: "POLYLINE3D",
|
|
2743
2743
|
...commonAttrs,
|
|
@@ -3345,6 +3345,7 @@ class LibreDwgConverter {
|
|
|
3345
3345
|
this.entityConverter = new LibreEntityConverter(instance);
|
|
3346
3346
|
}
|
|
3347
3347
|
convert(data) {
|
|
3348
|
+
var _a;
|
|
3348
3349
|
this.entityConverter.clear();
|
|
3349
3350
|
const db = {
|
|
3350
3351
|
tables: {
|
|
@@ -3490,6 +3491,10 @@ class LibreDwgConverter {
|
|
|
3490
3491
|
viewportEntities.forEach((viewport, index) => {
|
|
3491
3492
|
viewport.viewportId = index + 1;
|
|
3492
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
|
+
}
|
|
3493
3498
|
return db;
|
|
3494
3499
|
}
|
|
3495
3500
|
getConversionStats() {
|
|
@@ -3568,17 +3573,10 @@ class LibreDwgConverter {
|
|
|
3568
3573
|
const scalability = libredwg.dwg_dynapi_entity_data(item, "block_scaling");
|
|
3569
3574
|
const layout_ptr = libredwg.dwg_dynapi_entity_data(item, "layout");
|
|
3570
3575
|
const layout = libredwg.dwg_ref_get_id(layout_ptr) ?? "";
|
|
3571
|
-
let bmpPreview
|
|
3572
|
-
const uint8ArrayToHexString2 = (bytes) => {
|
|
3573
|
-
const hexChars = new Array(bytes.length);
|
|
3574
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
3575
|
-
hexChars[i] = bytes[i].toString(16).toUpperCase();
|
|
3576
|
-
}
|
|
3577
|
-
return hexChars.join("");
|
|
3578
|
-
};
|
|
3576
|
+
let bmpPreview;
|
|
3579
3577
|
const bmpPreviewBinaryData = libredwg.dwg_entity_block_header_get_preview(item);
|
|
3580
3578
|
if (bmpPreviewBinaryData && bmpPreviewBinaryData.length > 0) {
|
|
3581
|
-
bmpPreview =
|
|
3579
|
+
bmpPreview = uint8ArrayToHexString(bmpPreviewBinaryData);
|
|
3582
3580
|
}
|
|
3583
3581
|
let entities = this.convertEntities(obj, commonAttrs.handle);
|
|
3584
3582
|
if (!entities || entities.length == 0) {
|
|
@@ -6708,8 +6706,12 @@ const _LibreDwg = class _LibreDwg {
|
|
|
6708
6706
|
* @returns Returns preview image of the block pointed by the specified block header.
|
|
6709
6707
|
*/
|
|
6710
6708
|
dwg_entity_block_header_get_preview(ptr) {
|
|
6711
|
-
const
|
|
6712
|
-
|
|
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;
|
|
6713
6715
|
}
|
|
6714
6716
|
/**
|
|
6715
6717
|
* Returns preview binary data of one entity (common entity preview field).
|
|
@@ -2703,7 +2703,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2703
2703
|
const elevation = libredwg.dwg_dynapi_entity_data(entity, "elevation");
|
|
2704
2704
|
const thickness = libredwg.dwg_dynapi_entity_data(entity, "thickness");
|
|
2705
2705
|
const extrusionDirection = libredwg.dwg_dynapi_entity_data(entity, "extrusion");
|
|
2706
|
-
const vertices = libredwg.dwg_entity_polyline_2d_get_vertices(object);
|
|
2706
|
+
const vertices = libredwg.dwg_entity_polyline_2d_get_vertices(object) ?? [];
|
|
2707
2707
|
return {
|
|
2708
2708
|
type: "POLYLINE2D",
|
|
2709
2709
|
...commonAttrs,
|
|
@@ -2739,7 +2739,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2739
2739
|
const startWidth = libredwg.dwg_dynapi_entity_data(entity, "start_width");
|
|
2740
2740
|
const endWidth = libredwg.dwg_dynapi_entity_data(entity, "end_width");
|
|
2741
2741
|
const extrusionDirection = libredwg.dwg_dynapi_entity_data(entity, "extrusion");
|
|
2742
|
-
const vertices = libredwg.dwg_entity_polyline_3d_get_vertices(object);
|
|
2742
|
+
const vertices = libredwg.dwg_entity_polyline_3d_get_vertices(object) ?? [];
|
|
2743
2743
|
return {
|
|
2744
2744
|
type: "POLYLINE3D",
|
|
2745
2745
|
...commonAttrs,
|
|
@@ -3347,6 +3347,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3347
3347
|
this.entityConverter = new LibreEntityConverter(instance);
|
|
3348
3348
|
}
|
|
3349
3349
|
convert(data) {
|
|
3350
|
+
var _a;
|
|
3350
3351
|
this.entityConverter.clear();
|
|
3351
3352
|
const db = {
|
|
3352
3353
|
tables: {
|
|
@@ -3492,6 +3493,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3492
3493
|
viewportEntities.forEach((viewport, index) => {
|
|
3493
3494
|
viewport.viewportId = index + 1;
|
|
3494
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
|
+
}
|
|
3495
3500
|
return db;
|
|
3496
3501
|
}
|
|
3497
3502
|
getConversionStats() {
|
|
@@ -3570,17 +3575,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3570
3575
|
const scalability = libredwg.dwg_dynapi_entity_data(item, "block_scaling");
|
|
3571
3576
|
const layout_ptr = libredwg.dwg_dynapi_entity_data(item, "layout");
|
|
3572
3577
|
const layout = libredwg.dwg_ref_get_id(layout_ptr) ?? "";
|
|
3573
|
-
let bmpPreview
|
|
3574
|
-
const uint8ArrayToHexString2 = (bytes) => {
|
|
3575
|
-
const hexChars = new Array(bytes.length);
|
|
3576
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
3577
|
-
hexChars[i] = bytes[i].toString(16).toUpperCase();
|
|
3578
|
-
}
|
|
3579
|
-
return hexChars.join("");
|
|
3580
|
-
};
|
|
3578
|
+
let bmpPreview;
|
|
3581
3579
|
const bmpPreviewBinaryData = libredwg.dwg_entity_block_header_get_preview(item);
|
|
3582
3580
|
if (bmpPreviewBinaryData && bmpPreviewBinaryData.length > 0) {
|
|
3583
|
-
bmpPreview =
|
|
3581
|
+
bmpPreview = uint8ArrayToHexString(bmpPreviewBinaryData);
|
|
3584
3582
|
}
|
|
3585
3583
|
let entities = this.convertEntities(obj, commonAttrs.handle);
|
|
3586
3584
|
if (!entities || entities.length == 0) {
|
|
@@ -6710,8 +6708,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6710
6708
|
* @returns Returns preview image of the block pointed by the specified block header.
|
|
6711
6709
|
*/
|
|
6712
6710
|
dwg_entity_block_header_get_preview(ptr) {
|
|
6713
|
-
const
|
|
6714
|
-
|
|
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;
|
|
6715
6717
|
}
|
|
6716
6718
|
/**
|
|
6717
6719
|
* Returns preview binary data of one entity (common entity preview field).
|
|
@@ -2,7 +2,7 @@ import { HEADER_VARIABLES } from '../database';
|
|
|
2
2
|
import { Dwg_Object_Supertype, Dwg_Object_Type } from '../types';
|
|
3
3
|
import { dwgColorToMLeaderRawColor } from './dwgColorToMLeaderRawColor';
|
|
4
4
|
import { LibreEntityConverter } from './entityConverter';
|
|
5
|
-
import { idToString, isModelSpace, isPaperSpace } from './utils';
|
|
5
|
+
import { idToString, isModelSpace, isPaperSpace, uint8ArrayToHexString } from './utils';
|
|
6
6
|
/**
|
|
7
7
|
* Class used to convert Dwg_Data instance to DwgDatabase instance.
|
|
8
8
|
*/
|
|
@@ -166,6 +166,10 @@ export class LibreDwgConverter {
|
|
|
166
166
|
viewportEntities.forEach((viewport, index) => {
|
|
167
167
|
viewport.viewportId = index + 1;
|
|
168
168
|
});
|
|
169
|
+
const thumbnail = libredwg.dwg_bmp(data);
|
|
170
|
+
if (thumbnail?.data?.length) {
|
|
171
|
+
db.thumbnailImage = thumbnail.data;
|
|
172
|
+
}
|
|
169
173
|
return db;
|
|
170
174
|
}
|
|
171
175
|
getConversionStats() {
|
|
@@ -258,14 +262,7 @@ export class LibreDwgConverter {
|
|
|
258
262
|
const scalability = libredwg.dwg_dynapi_entity_data(item, 'block_scaling');
|
|
259
263
|
const layout_ptr = libredwg.dwg_dynapi_entity_data(item, 'layout');
|
|
260
264
|
const layout = (libredwg.dwg_ref_get_id(layout_ptr) ?? '');
|
|
261
|
-
let bmpPreview
|
|
262
|
-
const uint8ArrayToHexString = (bytes) => {
|
|
263
|
-
const hexChars = new Array(bytes.length);
|
|
264
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
265
|
-
hexChars[i] = bytes[i].toString(16).toUpperCase();
|
|
266
|
-
}
|
|
267
|
-
return hexChars.join('');
|
|
268
|
-
};
|
|
265
|
+
let bmpPreview;
|
|
269
266
|
const bmpPreviewBinaryData = libredwg.dwg_entity_block_header_get_preview(item);
|
|
270
267
|
if (bmpPreviewBinaryData && bmpPreviewBinaryData.length > 0) {
|
|
271
268
|
bmpPreview = uint8ArrayToHexString(bmpPreviewBinaryData);
|
|
@@ -1320,7 +1320,7 @@ export class LibreEntityConverter {
|
|
|
1320
1320
|
const elevation = libredwg.dwg_dynapi_entity_data(entity, 'elevation');
|
|
1321
1321
|
const thickness = libredwg.dwg_dynapi_entity_data(entity, 'thickness');
|
|
1322
1322
|
const extrusionDirection = libredwg.dwg_dynapi_entity_data(entity, 'extrusion');
|
|
1323
|
-
const vertices = libredwg.dwg_entity_polyline_2d_get_vertices(object);
|
|
1323
|
+
const vertices = libredwg.dwg_entity_polyline_2d_get_vertices(object) ?? [];
|
|
1324
1324
|
return {
|
|
1325
1325
|
type: 'POLYLINE2D',
|
|
1326
1326
|
...commonAttrs,
|
|
@@ -1356,7 +1356,7 @@ export class LibreEntityConverter {
|
|
|
1356
1356
|
const startWidth = libredwg.dwg_dynapi_entity_data(entity, 'start_width');
|
|
1357
1357
|
const endWidth = libredwg.dwg_dynapi_entity_data(entity, 'end_width');
|
|
1358
1358
|
const extrusionDirection = libredwg.dwg_dynapi_entity_data(entity, 'extrusion');
|
|
1359
|
-
const vertices = libredwg.dwg_entity_polyline_3d_get_vertices(object);
|
|
1359
|
+
const vertices = libredwg.dwg_entity_polyline_3d_get_vertices(object) ?? [];
|
|
1360
1360
|
return {
|
|
1361
1361
|
type: 'POLYLINE3D',
|
|
1362
1362
|
...commonAttrs,
|
package/lib/libredwg.d.ts
CHANGED
|
@@ -717,7 +717,7 @@ export declare class LibreDwg {
|
|
|
717
717
|
* @param ptr Pointer to one Dwg_Entity_BLOCK_HEADER instance.
|
|
718
718
|
* @returns Returns preview image of the block pointed by the specified block header.
|
|
719
719
|
*/
|
|
720
|
-
dwg_entity_block_header_get_preview(ptr: Dwg_Object_BLOCK_HEADER_Ptr): Uint8Array;
|
|
720
|
+
dwg_entity_block_header_get_preview(ptr: Dwg_Object_BLOCK_HEADER_Ptr): Uint8Array | null;
|
|
721
721
|
/**
|
|
722
722
|
* Returns preview binary data of one entity (common entity preview field).
|
|
723
723
|
* For PROXY_ENTITY this contains the proxy graphics data.
|
package/lib/libredwg.js
CHANGED
|
@@ -1055,9 +1055,12 @@ export class LibreDwg {
|
|
|
1055
1055
|
* @returns Returns preview image of the block pointed by the specified block header.
|
|
1056
1056
|
*/
|
|
1057
1057
|
dwg_entity_block_header_get_preview(ptr) {
|
|
1058
|
-
const
|
|
1059
|
-
|
|
1060
|
-
|
|
1058
|
+
const wasm = this.wasmInstance;
|
|
1059
|
+
if (typeof wasm.dwg_entity_block_header_get_preview !== 'function') {
|
|
1060
|
+
return null;
|
|
1061
|
+
}
|
|
1062
|
+
const result = wasm.dwg_entity_block_header_get_preview(ptr);
|
|
1063
|
+
return result?.data ?? null;
|
|
1061
1064
|
}
|
|
1062
1065
|
/**
|
|
1063
1066
|
* Returns preview binary data of one entity (common entity preview field).
|
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.10",
|
|
7
7
|
"author": "MLight Lee <mlight.lee@outlook.com>",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"engines": {
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"lint:fix": "eslint --fix --quiet src/",
|
|
87
87
|
"test": "node --test test/node-api.test.mjs",
|
|
88
88
|
"test:node": "pnpm build && pnpm test",
|
|
89
|
-
"publish:npm": "pnpm publish --access public --no-git-checks"
|
|
89
|
+
"publish:npm": "pnpm publish --access public --no-git-checks",
|
|
90
|
+
"release": "node script/release.mjs"
|
|
90
91
|
}
|
|
91
92
|
}
|