@mlightcad/libredwg-web 0.7.3 → 0.7.5
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 +1347 -5023
- package/dist/libredwg-web.umd.cjs +1347 -5026
- package/lib/converter/converter.d.ts +2 -0
- package/lib/converter/converter.js +272 -348
- package/lib/converter/dwgColorToMLeaderRawColor.d.ts +10 -0
- package/lib/converter/dwgColorToMLeaderRawColor.js +55 -0
- package/lib/converter/entityConverter.d.ts +3 -1
- package/lib/converter/entityConverter.js +679 -562
- package/lib/converter/index.d.ts +1 -0
- package/lib/converter/index.js +1 -0
- package/lib/database/database.d.ts +2 -1
- package/lib/database/entities/index.d.ts +2 -0
- package/lib/database/entities/index.js +2 -0
- package/lib/database/entities/multileader.d.ts +190 -0
- package/lib/database/entities/multileader.js +2 -0
- package/lib/database/entities/shape.d.ts +50 -0
- package/lib/database/entities/shape.js +2 -0
- package/lib/database/objects/index.d.ts +1 -0
- package/lib/database/objects/index.js +1 -0
- package/lib/database/objects/mleaderStyle.d.ts +101 -0
- package/lib/database/objects/mleaderStyle.js +2 -0
- package/lib/libredwg.d.ts +61 -0
- package/lib/libredwg.js +127 -21
- package/lib/types/enums.d.ts +17 -0
- package/lib/types/enums.js +18 -0
- package/package.json +11 -4
- package/wasm/libredwg-web.d.ts +24 -0
- package/wasm/libredwg-web.js +1 -1
- package/wasm/libredwg-web.wasm +0 -0
- 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-web.d.ts +0 -3
- package/lib/libredwg-web.js +0 -2313
- 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/lib/libredwg.js
CHANGED
|
@@ -2,7 +2,7 @@ import createModule from '../wasm/libredwg-web.js';
|
|
|
2
2
|
import { LibreDwgConverter } from './converter';
|
|
3
3
|
import { dwgCodePageToEncoding, dwgVersions } from './database';
|
|
4
4
|
import { SvgConverter } from './svg';
|
|
5
|
-
import { Dwg_File_Type, Dwg_Object_Type } from './types';
|
|
5
|
+
import { Dwg_Error, Dwg_File_Type, Dwg_Object_Type } from './types';
|
|
6
6
|
export { createModule };
|
|
7
7
|
export var DwgThumbnailImageType;
|
|
8
8
|
(function (DwgThumbnailImageType) {
|
|
@@ -32,8 +32,12 @@ export class LibreDwg {
|
|
|
32
32
|
try {
|
|
33
33
|
this.wasmInstance.FS.writeFile(fileName, new Uint8Array(fileContent));
|
|
34
34
|
const result = this.wasmInstance.dwg_read_file(fileName);
|
|
35
|
+
if (result.error & Dwg_Error.OUTOFMEM) {
|
|
36
|
+
this.wasmInstance.dwg_abandon(result.data);
|
|
37
|
+
throw new Error('Failed to decode DWG: out of WASM memory. Rebuild with pnpm build:wasm (INITIAL_MEMORY=1GB) or use a smaller file.');
|
|
38
|
+
}
|
|
35
39
|
if (result.error != 0) {
|
|
36
|
-
console.
|
|
40
|
+
console.warn('Open dwg file with error code:', result.error);
|
|
37
41
|
}
|
|
38
42
|
return result.data;
|
|
39
43
|
}
|
|
@@ -168,7 +172,20 @@ export class LibreDwg {
|
|
|
168
172
|
* @param data Pointer to Dwg_Data instance.
|
|
169
173
|
*/
|
|
170
174
|
dwg_free(data) {
|
|
171
|
-
|
|
175
|
+
if (!data) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
this.wasmInstance.dwg_free(data);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
try {
|
|
183
|
+
this.wasmInstance.dwg_abandon(data);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// best effort; wasm heap may already be corrupt
|
|
187
|
+
}
|
|
188
|
+
}
|
|
172
189
|
}
|
|
173
190
|
/**
|
|
174
191
|
* Frees the object (all three structs and its fields)
|
|
@@ -239,6 +256,58 @@ export class LibreDwg {
|
|
|
239
256
|
dwg_resolve_handleref(ref_ptr, obj_ptr) {
|
|
240
257
|
return this.wasmInstance.dwg_resolve_handleref(ref_ptr, obj_ptr);
|
|
241
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Returns the absolute handle reference of one Dwg_Object_Ref instance.
|
|
261
|
+
* @group Handle Conversion Methods
|
|
262
|
+
* @returns Returns null when the reference or absolute_ref is absent.
|
|
263
|
+
*/
|
|
264
|
+
dwg_ref_get_absref(ref_ptr) {
|
|
265
|
+
if (!ref_ptr)
|
|
266
|
+
return null;
|
|
267
|
+
const absref = this.wasmInstance.dwg_ref_get_absref(ref_ptr);
|
|
268
|
+
return absref === 0 ? null : absref;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Returns the handle value of one Dwg_Object_Ref instance.
|
|
272
|
+
* @group Handle Conversion Methods
|
|
273
|
+
* @returns Returns null when the reference or handle value is absent.
|
|
274
|
+
*/
|
|
275
|
+
dwg_ref_get_handle_value(ref_ptr) {
|
|
276
|
+
if (!ref_ptr)
|
|
277
|
+
return null;
|
|
278
|
+
const value = this.wasmInstance.dwg_ref_get_handle_value(ref_ptr);
|
|
279
|
+
return value === 0n ? null : value;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Returns the absolute_ref of one Dwg_Object_Ref instance as bigint.
|
|
283
|
+
* @group Handle Conversion Methods
|
|
284
|
+
* @returns Returns null when the reference or absolute_ref is absent.
|
|
285
|
+
*/
|
|
286
|
+
dwg_ref_get_handle_absolute_ref(ref_ptr) {
|
|
287
|
+
if (!ref_ptr)
|
|
288
|
+
return null;
|
|
289
|
+
const value = this.wasmInstance.dwg_ref_get_handle_absolute_ref(ref_ptr);
|
|
290
|
+
return value === 0n ? null : value;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Returns the handle value of one Dwg_Object instance.
|
|
294
|
+
* @group Handle Conversion Methods
|
|
295
|
+
* @returns Returns null when the object or handle value is absent.
|
|
296
|
+
*/
|
|
297
|
+
dwg_obj_get_handle_value(obj_ptr) {
|
|
298
|
+
if (!obj_ptr)
|
|
299
|
+
return null;
|
|
300
|
+
const value = this.wasmInstance.dwg_obj_get_handle_value(obj_ptr);
|
|
301
|
+
return value === 0n ? null : value;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Returns the absolute_ref of one Dwg_Object_Ref as uppercase hex handle id.
|
|
305
|
+
* @group Handle Conversion Methods
|
|
306
|
+
*/
|
|
307
|
+
dwg_ref_get_id(ref_ptr) {
|
|
308
|
+
const absref = this.dwg_ref_get_absref(ref_ptr);
|
|
309
|
+
return absref == null ? undefined : absref.toString(16).toUpperCase();
|
|
310
|
+
}
|
|
242
311
|
/**
|
|
243
312
|
* Returns object (such as line type, layer name, dimension style, and etc.) name by its handle.
|
|
244
313
|
* @group Handle Conversion Methods
|
|
@@ -249,8 +318,7 @@ export class LibreDwg {
|
|
|
249
318
|
const wasmInstance = this.wasmInstance;
|
|
250
319
|
const obj = wasmInstance.dwg_ref_get_object(ref_ptr);
|
|
251
320
|
const obj_tio = wasmInstance.dwg_object_to_object_tio(obj);
|
|
252
|
-
const obj_name = this.
|
|
253
|
-
.data;
|
|
321
|
+
const obj_name = this.dwg_dynapi_entity_data(obj_tio, 'name');
|
|
254
322
|
return obj_name;
|
|
255
323
|
}
|
|
256
324
|
/**
|
|
@@ -733,6 +801,13 @@ export class LibreDwg {
|
|
|
733
801
|
}
|
|
734
802
|
return value;
|
|
735
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* Returns the decoded field data of one object or entity.
|
|
806
|
+
* @group Dynamic API Methods
|
|
807
|
+
*/
|
|
808
|
+
dwg_dynapi_entity_data(obj, field) {
|
|
809
|
+
return this.dwg_dynapi_entity_value(obj, field).data;
|
|
810
|
+
}
|
|
736
811
|
/**
|
|
737
812
|
* Header field value getter. Used to get the field value of dwg/dxf header.
|
|
738
813
|
* @group Dynamic API Methods
|
|
@@ -743,6 +818,13 @@ export class LibreDwg {
|
|
|
743
818
|
dwg_dynapi_header_value(data, field) {
|
|
744
819
|
return this.wasmInstance.dwg_dynapi_header_value(data, field);
|
|
745
820
|
}
|
|
821
|
+
/**
|
|
822
|
+
* Returns the field data of dwg/dxf header.
|
|
823
|
+
* @group Dynamic API Methods
|
|
824
|
+
*/
|
|
825
|
+
dwg_dynapi_header_data(data, field) {
|
|
826
|
+
return this.dwg_dynapi_header_value(data, field).data;
|
|
827
|
+
}
|
|
746
828
|
/**
|
|
747
829
|
* The common field value getter. Used to get the value of object or entity common fields.
|
|
748
830
|
* @group Dynamic API Methods
|
|
@@ -753,6 +835,13 @@ export class LibreDwg {
|
|
|
753
835
|
dwg_dynapi_common_value(obj, field) {
|
|
754
836
|
return this.wasmInstance.dwg_dynapi_common_value(obj, field);
|
|
755
837
|
}
|
|
838
|
+
/**
|
|
839
|
+
* Returns the field data of object or entity common fields.
|
|
840
|
+
* @group Dynamic API Methods
|
|
841
|
+
*/
|
|
842
|
+
dwg_dynapi_common_data(obj, field) {
|
|
843
|
+
return this.dwg_dynapi_common_value(obj, field).data;
|
|
844
|
+
}
|
|
756
845
|
/**
|
|
757
846
|
* The field of one object or entity may not be primitive type. It means one field may consist of
|
|
758
847
|
* multiple sub-fields. This method is used to get the sub-field value of those complex field.
|
|
@@ -765,6 +854,31 @@ export class LibreDwg {
|
|
|
765
854
|
dwg_dynapi_subclass_value(obj, subclass, field) {
|
|
766
855
|
return this.wasmInstance.dwg_dynapi_subclass_value(obj, subclass, field);
|
|
767
856
|
}
|
|
857
|
+
/**
|
|
858
|
+
* Returns the sub-field data of one complex field.
|
|
859
|
+
* @group Dynamic API Methods
|
|
860
|
+
*/
|
|
861
|
+
dwg_dynapi_subclass_data(obj, subclass, field) {
|
|
862
|
+
return this.dwg_dynapi_subclass_value(obj, subclass, field).data;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Returns the struct size of a dynapi subclass.
|
|
866
|
+
*/
|
|
867
|
+
dwg_dynapi_subclass_size(subclass) {
|
|
868
|
+
return this.wasmInstance.dwg_dynapi_subclass_size(subclass);
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Returns the byte offset of a field within an entity struct.
|
|
872
|
+
*/
|
|
873
|
+
dwg_dynapi_entity_field_offset(entity, field) {
|
|
874
|
+
return this.wasmInstance.dwg_dynapi_entity_field_offset(entity, field);
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Returns the byte offset of a field within a dynapi subclass struct.
|
|
878
|
+
*/
|
|
879
|
+
dwg_dynapi_subclass_field_offset(subclass, field) {
|
|
880
|
+
return this.wasmInstance.dwg_dynapi_subclass_field_offset(subclass, field);
|
|
881
|
+
}
|
|
768
882
|
/**
|
|
769
883
|
* Returns the handle of one Dwg_Object instance.
|
|
770
884
|
* @group Dwg_Object Methods
|
|
@@ -876,8 +990,7 @@ export class LibreDwg {
|
|
|
876
990
|
*/
|
|
877
991
|
dwg_entity_get_block_name(ptr, field) {
|
|
878
992
|
const wasmInstance = this.wasmInstance;
|
|
879
|
-
const block_header_ref =
|
|
880
|
-
.data;
|
|
993
|
+
const block_header_ref = this.dwg_dynapi_entity_data(ptr, field);
|
|
881
994
|
const block_header_obj = wasmInstance.dwg_ref_get_object(block_header_ref);
|
|
882
995
|
const block_header_tio = wasmInstance.dwg_object_to_object_tio(block_header_obj);
|
|
883
996
|
const block = this.dwg_entity_block_header_get_block(block_header_tio);
|
|
@@ -893,12 +1006,10 @@ export class LibreDwg {
|
|
|
893
1006
|
*/
|
|
894
1007
|
dwg_entity_get_dimstyle_name(ptr, field = 'dimstyle') {
|
|
895
1008
|
const wasmInstance = this.wasmInstance;
|
|
896
|
-
const dimstyle_ref =
|
|
897
|
-
.data;
|
|
1009
|
+
const dimstyle_ref = this.dwg_dynapi_entity_data(ptr, field);
|
|
898
1010
|
const dimstyle_obj = wasmInstance.dwg_ref_get_object(dimstyle_ref);
|
|
899
1011
|
const dimstyle_tio = wasmInstance.dwg_object_to_object_tio(dimstyle_obj);
|
|
900
|
-
const dimstyle_name = this.
|
|
901
|
-
.data;
|
|
1012
|
+
const dimstyle_name = this.dwg_dynapi_entity_data(dimstyle_tio, 'name');
|
|
902
1013
|
return dimstyle_name;
|
|
903
1014
|
}
|
|
904
1015
|
/**
|
|
@@ -909,14 +1020,11 @@ export class LibreDwg {
|
|
|
909
1020
|
*/
|
|
910
1021
|
dwg_entity_block_header_get_block(ptr) {
|
|
911
1022
|
const wasmInstance = this.wasmInstance;
|
|
912
|
-
const block_ref =
|
|
913
|
-
.data;
|
|
1023
|
+
const block_ref = this.dwg_dynapi_entity_data(ptr, 'block_entity');
|
|
914
1024
|
const block_obj = wasmInstance.dwg_ref_get_object(block_ref);
|
|
915
1025
|
const block_tio = wasmInstance.dwg_object_to_entity_tio(block_obj);
|
|
916
|
-
const name =
|
|
917
|
-
|
|
918
|
-
const base_pt = wasmInstance.dwg_dynapi_entity_value(block_tio, 'base_pt')
|
|
919
|
-
.data;
|
|
1026
|
+
const name = this.dwg_dynapi_entity_data(block_tio, 'name');
|
|
1027
|
+
const base_pt = this.dwg_dynapi_entity_data(block_tio, 'base_pt');
|
|
920
1028
|
return {
|
|
921
1029
|
name,
|
|
922
1030
|
base_pt // preR13 only
|
|
@@ -986,12 +1094,10 @@ export class LibreDwg {
|
|
|
986
1094
|
*/
|
|
987
1095
|
dwg_entity_mtext_get_style_name(ptr) {
|
|
988
1096
|
const wasmInstance = this.wasmInstance;
|
|
989
|
-
const style_ref =
|
|
990
|
-
.data;
|
|
1097
|
+
const style_ref = this.dwg_dynapi_entity_data(ptr, 'style');
|
|
991
1098
|
const style_obj = wasmInstance.dwg_ref_get_object(style_ref);
|
|
992
1099
|
const style_tio = wasmInstance.dwg_object_to_object_tio(style_obj);
|
|
993
|
-
const name =
|
|
994
|
-
.data;
|
|
1100
|
+
const name = this.dwg_dynapi_entity_data(style_tio, 'name');
|
|
995
1101
|
return name;
|
|
996
1102
|
}
|
|
997
1103
|
/**
|
package/lib/types/enums.d.ts
CHANGED
|
@@ -2,6 +2,23 @@ export declare enum Dwg_Object_Supertype {
|
|
|
2
2
|
DWG_SUPERTYPE_ENTITY = 0,
|
|
3
3
|
DWG_SUPERTYPE_OBJECT = 1
|
|
4
4
|
}
|
|
5
|
+
/** Bit flags returned by dwg_read_file (see include/dwg.h DWG_ERROR). */
|
|
6
|
+
export declare enum Dwg_Error {
|
|
7
|
+
WRONGCRC = 1,
|
|
8
|
+
NOTYETSUPPORTED = 2,
|
|
9
|
+
UNHANDLEDCLASS = 4,
|
|
10
|
+
INVALIDTYPE = 8,
|
|
11
|
+
INVALIDHANDLE = 16,
|
|
12
|
+
INVALIDEED = 32,
|
|
13
|
+
VALUEOUTOFBOUNDS = 64,
|
|
14
|
+
CLASSESNOTFOUND = 128,
|
|
15
|
+
SECTIONNOTFOUND = 256,
|
|
16
|
+
PAGENOTFOUND = 512,
|
|
17
|
+
INTERNALERROR = 1024,
|
|
18
|
+
INVALIDDWG = 2048,
|
|
19
|
+
IOERROR = 4096,
|
|
20
|
+
OUTOFMEM = 8192
|
|
21
|
+
}
|
|
5
22
|
export declare enum Dwg_Object_Type {
|
|
6
23
|
DWG_TYPE_UNUSED = 0,
|
|
7
24
|
DWG_TYPE_TEXT = 1,
|
package/lib/types/enums.js
CHANGED
|
@@ -3,6 +3,24 @@ export var Dwg_Object_Supertype;
|
|
|
3
3
|
Dwg_Object_Supertype[Dwg_Object_Supertype["DWG_SUPERTYPE_ENTITY"] = 0] = "DWG_SUPERTYPE_ENTITY";
|
|
4
4
|
Dwg_Object_Supertype[Dwg_Object_Supertype["DWG_SUPERTYPE_OBJECT"] = 1] = "DWG_SUPERTYPE_OBJECT";
|
|
5
5
|
})(Dwg_Object_Supertype || (Dwg_Object_Supertype = {}));
|
|
6
|
+
/** Bit flags returned by dwg_read_file (see include/dwg.h DWG_ERROR). */
|
|
7
|
+
export var Dwg_Error;
|
|
8
|
+
(function (Dwg_Error) {
|
|
9
|
+
Dwg_Error[Dwg_Error["WRONGCRC"] = 1] = "WRONGCRC";
|
|
10
|
+
Dwg_Error[Dwg_Error["NOTYETSUPPORTED"] = 2] = "NOTYETSUPPORTED";
|
|
11
|
+
Dwg_Error[Dwg_Error["UNHANDLEDCLASS"] = 4] = "UNHANDLEDCLASS";
|
|
12
|
+
Dwg_Error[Dwg_Error["INVALIDTYPE"] = 8] = "INVALIDTYPE";
|
|
13
|
+
Dwg_Error[Dwg_Error["INVALIDHANDLE"] = 16] = "INVALIDHANDLE";
|
|
14
|
+
Dwg_Error[Dwg_Error["INVALIDEED"] = 32] = "INVALIDEED";
|
|
15
|
+
Dwg_Error[Dwg_Error["VALUEOUTOFBOUNDS"] = 64] = "VALUEOUTOFBOUNDS";
|
|
16
|
+
Dwg_Error[Dwg_Error["CLASSESNOTFOUND"] = 128] = "CLASSESNOTFOUND";
|
|
17
|
+
Dwg_Error[Dwg_Error["SECTIONNOTFOUND"] = 256] = "SECTIONNOTFOUND";
|
|
18
|
+
Dwg_Error[Dwg_Error["PAGENOTFOUND"] = 512] = "PAGENOTFOUND";
|
|
19
|
+
Dwg_Error[Dwg_Error["INTERNALERROR"] = 1024] = "INTERNALERROR";
|
|
20
|
+
Dwg_Error[Dwg_Error["INVALIDDWG"] = 2048] = "INVALIDDWG";
|
|
21
|
+
Dwg_Error[Dwg_Error["IOERROR"] = 4096] = "IOERROR";
|
|
22
|
+
Dwg_Error[Dwg_Error["OUTOFMEM"] = 8192] = "OUTOFMEM";
|
|
23
|
+
})(Dwg_Error || (Dwg_Error = {}));
|
|
6
24
|
export var Dwg_Object_Type;
|
|
7
25
|
(function (Dwg_Object_Type) {
|
|
8
26
|
Dwg_Object_Type[Dwg_Object_Type["DWG_TYPE_UNUSED"] = 0] = "DWG_TYPE_UNUSED";
|
package/package.json
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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.5",
|
|
7
7
|
"author": "MLight Lee <mlight.lee@outlook.com>",
|
|
8
8
|
"type": "module",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20"
|
|
11
|
+
},
|
|
9
12
|
"repository": {
|
|
10
13
|
"type": "git",
|
|
11
14
|
"url": "https://github.com/mlightcad/libredwg-web"
|
|
@@ -41,6 +44,7 @@
|
|
|
41
44
|
"require": "./dist/libredwg-web.umd.cjs"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
47
|
+
"@eslint/js": "^9.9.1",
|
|
44
48
|
"@typescript-eslint/parser": "^8.4.0",
|
|
45
49
|
"eslint": "^9.9.1",
|
|
46
50
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -70,15 +74,18 @@
|
|
|
70
74
|
"demo": "live-server examples --entry-file=index.html",
|
|
71
75
|
"doc": "typedoc",
|
|
72
76
|
"build": "tsc && vite build && cp -rf wasm examples/ && cp -rf dist examples/",
|
|
73
|
-
"build:prepare": "mkdir -p ../../build-wasm && cd ../../build-wasm && emconfigure ../configure CFLAGS=\"-O2 -sUSE_ZLIB=1\" CC=emcc --enable-release --disable-docs --disable-write --disable-python --disable-bindings --disable-shared --disable-json --enable-partial --enable-experimental",
|
|
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 --enable-partial --enable-experimental",
|
|
74
78
|
"build:obj": "cd ../../build-wasm && emmake make",
|
|
75
|
-
"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 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",
|
|
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",
|
|
76
80
|
"clean": "rm -rf ../../build-wasm ./docs ./dist ./lib",
|
|
77
81
|
"copy": "cp -f ../../build-wasm/libredwg-web.d.ts ../../build-wasm/libredwg-web.js ../../build-wasm/libredwg-web.wasm wasm/ && cp -f ../../build-wasm/libredwg-web.js src/",
|
|
78
82
|
"format": "prettier --config ./.prettierrc.js --write src/**/*.{ts,js}",
|
|
79
83
|
"install:emsdk": "cd $EMSDK && ./emsdk install latest && ./emsdk activate latest",
|
|
80
84
|
"link": "node script/create-symlink.js ./wasm/libredwg-web.js ./src/libredwg-web.js",
|
|
81
85
|
"lint": "eslint src/",
|
|
82
|
-
"lint:fix": "eslint --fix --quiet src/"
|
|
86
|
+
"lint:fix": "eslint --fix --quiet src/",
|
|
87
|
+
"test": "node --test test/node-api.test.mjs",
|
|
88
|
+
"test:node": "pnpm build && pnpm test",
|
|
89
|
+
"publish:npm": "pnpm publish --access public --no-git-checks"
|
|
83
90
|
}
|
|
84
91
|
}
|
package/wasm/libredwg-web.d.ts
CHANGED
|
@@ -224,6 +224,26 @@ declare class FSNode {
|
|
|
224
224
|
get isDevice(): any;
|
|
225
225
|
}
|
|
226
226
|
interface WasmModule {
|
|
227
|
+
__Znwm(_0: number): number;
|
|
228
|
+
__ZdlPvm(_0: number, _1: number): void;
|
|
229
|
+
_strndup(_0: number, _1: number): number;
|
|
230
|
+
__ZdaPv(_0: number): void;
|
|
231
|
+
__ZdaPvm(_0: number, _1: number): void;
|
|
232
|
+
__ZdlPv(_0: number): void;
|
|
233
|
+
_emscripten_builtin_malloc(_0: number): number;
|
|
234
|
+
__Znam(_0: number): number;
|
|
235
|
+
__ZnamSt11align_val_t(_0: number, _1: number): number;
|
|
236
|
+
__ZnwmSt11align_val_t(_0: number, _1: number): number;
|
|
237
|
+
___libc_calloc(_0: number, _1: number): number;
|
|
238
|
+
___libc_free(_0: number): void;
|
|
239
|
+
___libc_malloc(_0: number): number;
|
|
240
|
+
___libc_realloc(_0: number, _1: number): number;
|
|
241
|
+
_emscripten_builtin_calloc(_0: number, _1: number): number;
|
|
242
|
+
_emscripten_builtin_free(_0: number): void;
|
|
243
|
+
_emscripten_builtin_realloc(_0: number, _1: number): number;
|
|
244
|
+
_malloc_size(_0: number): number;
|
|
245
|
+
_malloc_usable_size(_0: number): number;
|
|
246
|
+
_reallocf(_0: number, _1: number): number;
|
|
227
247
|
}
|
|
228
248
|
|
|
229
249
|
type EmbindString = ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string;
|
|
@@ -389,6 +409,7 @@ interface EmbindModule {
|
|
|
389
409
|
dwg_get_next_object(_0: number, _1: Dwg_Object_Type, _2: number): number;
|
|
390
410
|
dwg_resolve_jump(_0: number): number;
|
|
391
411
|
dwg_free(_0: number): void;
|
|
412
|
+
dwg_abandon(_0: number): void;
|
|
392
413
|
dwg_free_object(_0: number): void;
|
|
393
414
|
dwg_new_ref(_0: number): number;
|
|
394
415
|
dwg_dup_handleref(_0: number, _1: number): number;
|
|
@@ -426,6 +447,9 @@ interface EmbindModule {
|
|
|
426
447
|
dwg_dynapi_entity_set_value(_0: number, _1: EmbindString, _2: EmbindString, _3: number, _4: boolean): boolean;
|
|
427
448
|
dwg_dynapi_common_set_value(_0: number, _1: EmbindString, _2: number, _3: boolean): boolean;
|
|
428
449
|
dwg_dynapi_handle_name(_0: number, _1: number, _2: number): string;
|
|
450
|
+
dwg_dynapi_subclass_size(_0: EmbindString): number;
|
|
451
|
+
dwg_dynapi_entity_field_offset(_0: number, _1: EmbindString): number;
|
|
452
|
+
dwg_dynapi_subclass_field_offset(_0: EmbindString, _1: EmbindString): number;
|
|
429
453
|
dwg_write_dxf(_0: EmbindString, _1: EmbindString): number;
|
|
430
454
|
dwg_find_tablehandle(_0: number, _1: EmbindString, _2: EmbindString): number;
|
|
431
455
|
dwg_find_tablehandle_index(_0: number, _1: number, _2: EmbindString): number;
|