@mlightcad/libredwg-web 0.7.7 → 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 (49) hide show
  1. package/dist/libredwg-web.js +194 -5
  2. package/dist/libredwg-web.umd.cjs +194 -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 +1 -0
  6. package/lib/converter/entityConverter.js +53 -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/index.d.ts +1 -0
  15. package/lib/database/entities/index.js +1 -0
  16. package/lib/database/entities/solid3d.d.ts +32 -0
  17. package/lib/database/entities/solid3d.js +2 -0
  18. package/lib/database/entities/unknown.d.ts +7 -0
  19. package/lib/database/entities/unknown.js +2 -0
  20. package/lib/database/objects/index.d.ts +3 -0
  21. package/lib/database/objects/index.js +3 -0
  22. package/lib/database/objects/layerFilter.d.ts +12 -0
  23. package/lib/database/objects/layerFilter.js +2 -0
  24. package/lib/database/objects/layerIndex.d.ts +18 -0
  25. package/lib/database/objects/layerIndex.js +2 -0
  26. package/lib/database/objects/unknown.d.ts +7 -0
  27. package/lib/database/objects/unknown.js +2 -0
  28. package/lib/database/objects/xrecord.d.ts +30 -0
  29. package/lib/database/objects/xrecord.js +2 -0
  30. package/lib/debug.d.ts +13 -0
  31. package/lib/debug.js +48 -0
  32. package/lib/libredwg-core.d.ts +740 -0
  33. package/lib/libredwg-core.js +1121 -0
  34. package/lib/libredwg-web.d.ts +3 -0
  35. package/lib/libredwg-web.js +2318 -0
  36. package/lib/libredwg.d.ts +30 -1
  37. package/lib/libredwg.js +44 -0
  38. package/lib/memory64/index.d.ts +4 -0
  39. package/lib/memory64/index.js +4 -0
  40. package/lib/memory64/libredwg.d.ts +13 -0
  41. package/lib/memory64/libredwg.js +23 -0
  42. package/lib/types/common.d.ts +2 -0
  43. package/lib/utils/common.d.ts +4 -0
  44. package/lib/utils/common.js +12 -0
  45. package/lib/utils/index.d.ts +2 -0
  46. package/lib/utils/index.js +2 -0
  47. package/package.json +2 -2
  48. package/wasm/libredwg-web.d.ts +548 -544
  49. package/wasm/libredwg-web.wasm +0 -0
package/lib/libredwg.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { MainModule } from '../wasm/libredwg-web';
2
2
  import createModule from '../wasm/libredwg-web.js';
3
3
  import { DwgCodePage, DwgDatabase, DwgGradientColor, DwgPoint2D, DwgPoint3D, DwgPoint4D, DwgVersion, DwgXData } from './database';
4
- import { Dwg_Array_Ptr, Dwg_Class, Dwg_Color, Dwg_Data_Ptr, Dwg_Entity_BLOCK, Dwg_Entity_IMAGE_Ptr, Dwg_Entity_LWPOLYLINE_Ptr, Dwg_Entity_MTEXT_Ptr, Dwg_Entity_POLYLINE_2D_Ptr, Dwg_Entity_POLYLINE_3D_Ptr, Dwg_Entity_PROXY_ENTITY_Ptr, Dwg_Entity_TEXT_Ptr, Dwg_Entity_VERTEX_2D, Dwg_Entity_VERTEX_3D, Dwg_Field_Value, Dwg_Handle, Dwg_HATCH_DefLine, Dwg_HATCH_Path, Dwg_LTYPE_Dash, Dwg_MLINE_Vertex, Dwg_Object_BLOCK_HEADER_Ptr, Dwg_Object_BLOCK_Ptr, Dwg_Object_DIMSTYLE_Ptr, Dwg_Object_Entity_Ptr, Dwg_Object_Entity_TIO_Ptr, Dwg_Object_Generic_Ptr, Dwg_Object_IMAGEDEF_Ptr, Dwg_Object_LAYER_Ptr, Dwg_Object_LTYPE_Ptr, Dwg_Object_Object_Ptr, Dwg_Object_Object_TIO_Ptr, Dwg_Object_Ptr, Dwg_Object_Ref, Dwg_Object_Ref_Ptr, Dwg_Object_STYLE_Ptr, Dwg_Object_Type, Dwg_Object_VERTEX_2D_Ptr, Dwg_Object_VERTEX_3D_Ptr, Dwg_Object_VPORT_Ptr, Dwg_TABLE_Cell } from './types';
4
+ import { Dwg_Array_Ptr, Dwg_Class, Dwg_Color, Dwg_Data_Ptr, Dwg_Entity_BLOCK, Dwg_Entity_IMAGE_Ptr, Dwg_Entity_LWPOLYLINE_Ptr, Dwg_Entity_MTEXT_Ptr, Dwg_Entity_OLE2FRAME_Ptr, Dwg_Entity_OLEFRAME_Ptr, Dwg_Entity_POLYLINE_2D_Ptr, Dwg_Entity_POLYLINE_3D_Ptr, Dwg_Entity_PROXY_ENTITY_Ptr, Dwg_Entity_TEXT_Ptr, Dwg_Entity_VERTEX_2D, Dwg_Entity_VERTEX_3D, Dwg_Field_Value, Dwg_Handle, Dwg_HATCH_DefLine, Dwg_HATCH_Path, Dwg_LTYPE_Dash, Dwg_MLINE_Vertex, Dwg_Object_BLOCK_HEADER_Ptr, Dwg_Object_BLOCK_Ptr, Dwg_Object_DIMSTYLE_Ptr, Dwg_Object_Entity_Ptr, Dwg_Object_Entity_TIO_Ptr, Dwg_Object_Generic_Ptr, Dwg_Object_IMAGEDEF_Ptr, Dwg_Object_LAYER_Ptr, Dwg_Object_LTYPE_Ptr, Dwg_Object_Object_Ptr, Dwg_Object_Object_TIO_Ptr, Dwg_Object_Ptr, Dwg_Object_Ref, Dwg_Object_Ref_Ptr, Dwg_Object_STYLE_Ptr, Dwg_Object_Type, Dwg_Object_VERTEX_2D_Ptr, Dwg_Object_VERTEX_3D_Ptr, Dwg_Object_VPORT_Ptr, Dwg_TABLE_Cell } from './types';
5
5
  export { createModule };
6
6
  export type LibreDwgEx = LibreDwg & MainModule;
7
7
  export declare enum DwgThumbnailImageType {
@@ -661,6 +661,23 @@ export declare class LibreDwg {
661
661
  * @returns Returns xdata of one Dwg_Object_Entity instance.
662
662
  */
663
663
  dwg_object_entity_get_xdata(ptr: Dwg_Object_Entity_Ptr): DwgXData;
664
+ /**
665
+ * Returns the extension dictionary handle of a Dwg_Object_Object instance.
666
+ * @group Dwg_Object_Object Methods
667
+ * @param ptr Pointer to one Dwg_Object_Object instance.
668
+ * @returns Object ref for the extension dictionary, or null when absent.
669
+ */
670
+ dwg_object_object_get_xdicobjhandle_object(ptr: Dwg_Object_Object_Ptr): Dwg_Object_Ref | null;
671
+ /**
672
+ * Returns XRECORD payload as DXF group-code / value pairs.
673
+ * @group Dwg_Object_XRECORD Methods
674
+ * @param ptr Pointer to one Dwg_Object_XRECORD instance (object tio).
675
+ * @returns Array of `{ code, value }` groups.
676
+ */
677
+ dwg_object_xrecord_get_xdata(ptr: Dwg_Object_Object_TIO_Ptr): {
678
+ code: number;
679
+ value: unknown;
680
+ }[];
664
681
  /**
665
682
  * Returns pointer to BLOCK_HEADER owner for generic entity from ent->ownerhandle.
666
683
  * @group Dwg_Object_Entity Methods
@@ -713,6 +730,18 @@ export declare class LibreDwg {
713
730
  * @returns Entity data bytes, or null when absent.
714
731
  */
715
732
  dwg_entity_proxy_entity_get_entity_data(ptr: Dwg_Entity_PROXY_ENTITY_Ptr): Uint8Array | null;
733
+ /**
734
+ * Returns binary OLE payload of one Dwg_Entity_OLE2FRAME instance.
735
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
736
+ * @group Dwg_Entity_OLE2FRAME Methods
737
+ */
738
+ dwg_entity_ole2frame_get_data(ptr: Dwg_Entity_OLE2FRAME_Ptr): Uint8Array | null;
739
+ /**
740
+ * Returns binary OLE payload of one Dwg_Entity_OLEFRAME instance.
741
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
742
+ * @group Dwg_Entity_OLEFRAME Methods
743
+ */
744
+ dwg_entity_oleframe_get_data(ptr: Dwg_Entity_OLEFRAME_Ptr): Uint8Array | null;
716
745
  /**
717
746
  * Returns the first entity owned by the block header or null
718
747
  * @group Dwg_Entity_BLOCK_HEADER Methods
package/lib/libredwg.js CHANGED
@@ -969,6 +969,24 @@ export class LibreDwg {
969
969
  dwg_object_entity_get_xdata(ptr) {
970
970
  return this.wasmInstance.dwg_object_entity_get_xdata(ptr);
971
971
  }
972
+ /**
973
+ * Returns the extension dictionary handle of a Dwg_Object_Object instance.
974
+ * @group Dwg_Object_Object Methods
975
+ * @param ptr Pointer to one Dwg_Object_Object instance.
976
+ * @returns Object ref for the extension dictionary, or null when absent.
977
+ */
978
+ dwg_object_object_get_xdicobjhandle_object(ptr) {
979
+ return this.wasmInstance.dwg_object_object_get_xdicobjhandle_object(ptr);
980
+ }
981
+ /**
982
+ * Returns XRECORD payload as DXF group-code / value pairs.
983
+ * @group Dwg_Object_XRECORD Methods
984
+ * @param ptr Pointer to one Dwg_Object_XRECORD instance (object tio).
985
+ * @returns Array of `{ code, value }` groups.
986
+ */
987
+ dwg_object_xrecord_get_xdata(ptr) {
988
+ return this.wasmInstance.dwg_object_xrecord_get_xdata(ptr) ?? [];
989
+ }
972
990
  /**
973
991
  * Returns pointer to BLOCK_HEADER owner for generic entity from ent->ownerhandle.
974
992
  * @group Dwg_Object_Entity Methods
@@ -1067,6 +1085,32 @@ export class LibreDwg {
1067
1085
  const result = wasm.dwg_entity_proxy_entity_get_entity_data(ptr);
1068
1086
  return result?.data ?? null;
1069
1087
  }
1088
+ /**
1089
+ * Returns binary OLE payload of one Dwg_Entity_OLE2FRAME instance.
1090
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
1091
+ * @group Dwg_Entity_OLE2FRAME Methods
1092
+ */
1093
+ dwg_entity_ole2frame_get_data(ptr) {
1094
+ const wasm = this.wasmInstance;
1095
+ if (typeof wasm.dwg_entity_ole2frame_get_data !== 'function') {
1096
+ return null;
1097
+ }
1098
+ const result = wasm.dwg_entity_ole2frame_get_data(ptr);
1099
+ return result?.data ?? null;
1100
+ }
1101
+ /**
1102
+ * Returns binary OLE payload of one Dwg_Entity_OLEFRAME instance.
1103
+ * Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
1104
+ * @group Dwg_Entity_OLEFRAME Methods
1105
+ */
1106
+ dwg_entity_oleframe_get_data(ptr) {
1107
+ const wasm = this.wasmInstance;
1108
+ if (typeof wasm.dwg_entity_oleframe_get_data !== 'function') {
1109
+ return null;
1110
+ }
1111
+ const result = wasm.dwg_entity_oleframe_get_data(ptr);
1112
+ return result?.data ?? null;
1113
+ }
1070
1114
  /**
1071
1115
  * Returns the first entity owned by the block header or null
1072
1116
  * @group Dwg_Entity_BLOCK_HEADER Methods
@@ -0,0 +1,4 @@
1
+ export * from '../database';
2
+ export * from './libredwg';
3
+ export * from '../types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * from '../database';
2
+ export * from './libredwg';
3
+ export * from '../types';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,13 @@
1
+ import type { MainModule } from '../../wasm64/libredwg-web';
2
+ import createModule from '../../wasm64/libredwg-web.js';
3
+ import { DwgThumbnailImageType, LibreDwgCore } from '../libredwg-core';
4
+ export { createModule };
5
+ export { DwgThumbnailImageType };
6
+ export type { DwgThumbnail } from '../libredwg-core';
7
+ export type LibreDwgEx = LibreDwg & MainModule;
8
+ export declare class LibreDwg extends LibreDwgCore {
9
+ static instance: LibreDwgEx;
10
+ static createByWasmInstance(wasmInstance: MainModule): LibreDwgEx;
11
+ static create(filepath?: string): Promise<LibreDwgEx>;
12
+ }
13
+ //# sourceMappingURL=libredwg.d.ts.map
@@ -0,0 +1,23 @@
1
+ import createModule from '../../wasm64/libredwg-web.js';
2
+ import { DwgThumbnailImageType, LibreDwgCore } from '../libredwg-core';
3
+ export { createModule };
4
+ export { DwgThumbnailImageType };
5
+ export class LibreDwg extends LibreDwgCore {
6
+ static instance;
7
+ static createByWasmInstance(wasmInstance) {
8
+ return this.instance == null
9
+ ? new LibreDwg(wasmInstance)
10
+ : this.instance;
11
+ }
12
+ static async create(filepath) {
13
+ const wasmInstance = filepath == null
14
+ ? await createModule()
15
+ : await createModule({
16
+ locateFile: (filename) => {
17
+ return `${filepath}/${filename}`;
18
+ }
19
+ });
20
+ return this.createByWasmInstance(wasmInstance);
21
+ }
22
+ }
23
+ //# sourceMappingURL=libredwg.js.map
@@ -26,6 +26,8 @@ export type Dwg_Entity_LWPOLYLINE_Ptr = number;
26
26
  export type Dwg_Entity_MTEXT_Ptr = number;
27
27
  export type Dwg_Entity_TEXT_Ptr = number;
28
28
  export type Dwg_Entity_PROXY_ENTITY_Ptr = number;
29
+ export type Dwg_Entity_OLE2FRAME_Ptr = number;
30
+ export type Dwg_Entity_OLEFRAME_Ptr = number;
29
31
  export interface Dwg_Handle {
30
32
  code: number;
31
33
  size: number;
@@ -0,0 +1,4 @@
1
+ export declare const isModelSpace: (name: string) => boolean | "";
2
+ export declare const isPaperSpace: (name: string) => boolean | "";
3
+ export declare const idToString: (id: number | bigint) => string;
4
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1,12 @@
1
+ const MODEL_SPACE = '*MODEL_SPACE';
2
+ const MODEL_SPACE_PREFIX = '*PAPER_SPACE';
3
+ export const isModelSpace = (name) => {
4
+ return name && name.toUpperCase() == MODEL_SPACE;
5
+ };
6
+ export const isPaperSpace = (name) => {
7
+ return name && name.toUpperCase().startsWith(MODEL_SPACE_PREFIX);
8
+ };
9
+ export const idToString = (id) => {
10
+ return id.toString(16).toUpperCase();
11
+ };
12
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1,2 @@
1
+ export * from './common';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './common';
2
+ //# sourceMappingURL=index.js.map
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.7",
6
+ "version": "0.7.8",
7
7
  "author": "MLight Lee <mlight.lee@outlook.com>",
8
8
  "type": "module",
9
9
  "engines": {
@@ -73,7 +73,7 @@
73
73
  "scripts": {
74
74
  "demo": "live-server examples --entry-file=index.html",
75
75
  "doc": "typedoc",
76
- "build": "tsc && vite build && cp -rf wasm examples/ && cp -rf dist examples/",
76
+ "build": "tsc && vite build && node script/copy-build-artifacts.js",
77
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",