@mlightcad/libredwg-web 0.7.4 → 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/lib/libredwg.js CHANGED
@@ -256,6 +256,58 @@ export class LibreDwg {
256
256
  dwg_resolve_handleref(ref_ptr, obj_ptr) {
257
257
  return this.wasmInstance.dwg_resolve_handleref(ref_ptr, obj_ptr);
258
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
+ }
259
311
  /**
260
312
  * Returns object (such as line type, layer name, dimension style, and etc.) name by its handle.
261
313
  * @group Handle Conversion Methods
@@ -266,8 +318,7 @@ export class LibreDwg {
266
318
  const wasmInstance = this.wasmInstance;
267
319
  const obj = wasmInstance.dwg_ref_get_object(ref_ptr);
268
320
  const obj_tio = wasmInstance.dwg_object_to_object_tio(obj);
269
- const obj_name = this.dwg_dynapi_entity_value(obj_tio, 'name')
270
- .data;
321
+ const obj_name = this.dwg_dynapi_entity_data(obj_tio, 'name');
271
322
  return obj_name;
272
323
  }
273
324
  /**
@@ -750,6 +801,13 @@ export class LibreDwg {
750
801
  }
751
802
  return value;
752
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
+ }
753
811
  /**
754
812
  * Header field value getter. Used to get the field value of dwg/dxf header.
755
813
  * @group Dynamic API Methods
@@ -760,6 +818,13 @@ export class LibreDwg {
760
818
  dwg_dynapi_header_value(data, field) {
761
819
  return this.wasmInstance.dwg_dynapi_header_value(data, field);
762
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
+ }
763
828
  /**
764
829
  * The common field value getter. Used to get the value of object or entity common fields.
765
830
  * @group Dynamic API Methods
@@ -770,6 +835,13 @@ export class LibreDwg {
770
835
  dwg_dynapi_common_value(obj, field) {
771
836
  return this.wasmInstance.dwg_dynapi_common_value(obj, field);
772
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
+ }
773
845
  /**
774
846
  * The field of one object or entity may not be primitive type. It means one field may consist of
775
847
  * multiple sub-fields. This method is used to get the sub-field value of those complex field.
@@ -782,6 +854,31 @@ export class LibreDwg {
782
854
  dwg_dynapi_subclass_value(obj, subclass, field) {
783
855
  return this.wasmInstance.dwg_dynapi_subclass_value(obj, subclass, field);
784
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
+ }
785
882
  /**
786
883
  * Returns the handle of one Dwg_Object instance.
787
884
  * @group Dwg_Object Methods
@@ -893,8 +990,7 @@ export class LibreDwg {
893
990
  */
894
991
  dwg_entity_get_block_name(ptr, field) {
895
992
  const wasmInstance = this.wasmInstance;
896
- const block_header_ref = wasmInstance.dwg_dynapi_entity_value(ptr, field)
897
- .data;
993
+ const block_header_ref = this.dwg_dynapi_entity_data(ptr, field);
898
994
  const block_header_obj = wasmInstance.dwg_ref_get_object(block_header_ref);
899
995
  const block_header_tio = wasmInstance.dwg_object_to_object_tio(block_header_obj);
900
996
  const block = this.dwg_entity_block_header_get_block(block_header_tio);
@@ -910,12 +1006,10 @@ export class LibreDwg {
910
1006
  */
911
1007
  dwg_entity_get_dimstyle_name(ptr, field = 'dimstyle') {
912
1008
  const wasmInstance = this.wasmInstance;
913
- const dimstyle_ref = wasmInstance.dwg_dynapi_entity_value(ptr, field)
914
- .data;
1009
+ const dimstyle_ref = this.dwg_dynapi_entity_data(ptr, field);
915
1010
  const dimstyle_obj = wasmInstance.dwg_ref_get_object(dimstyle_ref);
916
1011
  const dimstyle_tio = wasmInstance.dwg_object_to_object_tio(dimstyle_obj);
917
- const dimstyle_name = this.dwg_dynapi_entity_value(dimstyle_tio, 'name')
918
- .data;
1012
+ const dimstyle_name = this.dwg_dynapi_entity_data(dimstyle_tio, 'name');
919
1013
  return dimstyle_name;
920
1014
  }
921
1015
  /**
@@ -926,14 +1020,11 @@ export class LibreDwg {
926
1020
  */
927
1021
  dwg_entity_block_header_get_block(ptr) {
928
1022
  const wasmInstance = this.wasmInstance;
929
- const block_ref = wasmInstance.dwg_dynapi_entity_value(ptr, 'block_entity')
930
- .data;
1023
+ const block_ref = this.dwg_dynapi_entity_data(ptr, 'block_entity');
931
1024
  const block_obj = wasmInstance.dwg_ref_get_object(block_ref);
932
1025
  const block_tio = wasmInstance.dwg_object_to_entity_tio(block_obj);
933
- const name = wasmInstance.dwg_dynapi_entity_value(block_tio, 'name')
934
- .data;
935
- const base_pt = wasmInstance.dwg_dynapi_entity_value(block_tio, 'base_pt')
936
- .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');
937
1028
  return {
938
1029
  name,
939
1030
  base_pt // preR13 only
@@ -1003,12 +1094,10 @@ export class LibreDwg {
1003
1094
  */
1004
1095
  dwg_entity_mtext_get_style_name(ptr) {
1005
1096
  const wasmInstance = this.wasmInstance;
1006
- const style_ref = wasmInstance.dwg_dynapi_entity_value(ptr, 'style')
1007
- .data;
1097
+ const style_ref = this.dwg_dynapi_entity_data(ptr, 'style');
1008
1098
  const style_obj = wasmInstance.dwg_ref_get_object(style_ref);
1009
1099
  const style_tio = wasmInstance.dwg_object_to_object_tio(style_obj);
1010
- const name = wasmInstance.dwg_dynapi_entity_value(style_tio, 'name')
1011
- .data;
1100
+ const name = this.dwg_dynapi_entity_data(style_tio, 'name');
1012
1101
  return name;
1013
1102
  }
1014
1103
  /**
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.4",
6
+ "version": "0.7.5",
7
7
  "author": "MLight Lee <mlight.lee@outlook.com>",
8
8
  "type": "module",
9
9
  "engines": {
@@ -447,6 +447,9 @@ interface EmbindModule {
447
447
  dwg_dynapi_entity_set_value(_0: number, _1: EmbindString, _2: EmbindString, _3: number, _4: boolean): boolean;
448
448
  dwg_dynapi_common_set_value(_0: number, _1: EmbindString, _2: number, _3: boolean): boolean;
449
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;
450
453
  dwg_write_dxf(_0: EmbindString, _1: EmbindString): number;
451
454
  dwg_find_tablehandle(_0: number, _1: EmbindString, _2: EmbindString): number;
452
455
  dwg_find_tablehandle_index(_0: number, _1: number, _2: EmbindString): number;
Binary file