@mlightcad/libredwg-web 0.7.7 → 0.7.9
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 +207 -16
- package/dist/libredwg-web.umd.cjs +207 -16
- package/lib/converter/converter.d.ts +3 -0
- package/lib/converter/converter.js +82 -10
- package/lib/converter/entityConverter.d.ts +1 -0
- package/lib/converter/entityConverter.js +53 -5
- package/lib/converter/utils.d.ts +21 -0
- package/lib/converter/utils.js +27 -0
- package/lib/database/database.d.ts +5 -1
- package/lib/database/entities/index.d.ts +1 -0
- package/lib/database/entities/index.js +1 -0
- package/lib/database/entities/solid3d.d.ts +32 -0
- package/lib/database/entities/solid3d.js +2 -0
- package/lib/database/objects/index.d.ts +3 -0
- package/lib/database/objects/index.js +3 -0
- package/lib/database/objects/layerFilter.d.ts +12 -0
- package/lib/database/objects/layerFilter.js +2 -0
- package/lib/database/objects/layerIndex.d.ts +18 -0
- package/lib/database/objects/layerIndex.js +2 -0
- package/lib/database/objects/xrecord.d.ts +30 -0
- package/lib/database/objects/xrecord.js +2 -0
- package/lib/libredwg.d.ts +31 -2
- package/lib/libredwg.js +50 -3
- package/lib/types/common.d.ts +2 -0
- package/package.json +4 -3
- package/wasm/libredwg-web.d.ts +4 -0
- package/wasm/libredwg-web.wasm +0 -0
|
@@ -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
|
*/
|
|
@@ -42,9 +42,12 @@ export class LibreDwgConverter {
|
|
|
42
42
|
objects: {
|
|
43
43
|
DICTIONARY: [],
|
|
44
44
|
IMAGEDEF: [],
|
|
45
|
+
LAYER_FILTER: [],
|
|
46
|
+
LAYER_INDEX: [],
|
|
45
47
|
LAYOUT: [],
|
|
46
48
|
MLEADERSTYLE: [],
|
|
47
|
-
SPATIAL_FILTER: []
|
|
49
|
+
SPATIAL_FILTER: [],
|
|
50
|
+
XRECORD: []
|
|
48
51
|
},
|
|
49
52
|
header: {},
|
|
50
53
|
entities: [],
|
|
@@ -127,6 +130,12 @@ export class LibreDwgConverter {
|
|
|
127
130
|
case Dwg_Object_Type.DWG_TYPE_IMAGEDEF:
|
|
128
131
|
db.objects.IMAGEDEF.push(this.convertImageDef(tio, obj));
|
|
129
132
|
break;
|
|
133
|
+
case Dwg_Object_Type.DWG_TYPE_LAYERFILTER:
|
|
134
|
+
db.objects.LAYER_FILTER.push(this.convertLayerFilter(tio, obj));
|
|
135
|
+
break;
|
|
136
|
+
case Dwg_Object_Type.DWG_TYPE_LAYER_INDEX:
|
|
137
|
+
db.objects.LAYER_INDEX.push(this.convertLayerIndex(tio, obj));
|
|
138
|
+
break;
|
|
130
139
|
case Dwg_Object_Type.DWG_TYPE_LAYOUT:
|
|
131
140
|
db.objects.LAYOUT.push(this.convertLayout(tio, obj));
|
|
132
141
|
break;
|
|
@@ -136,6 +145,9 @@ export class LibreDwgConverter {
|
|
|
136
145
|
case Dwg_Object_Type.DWG_TYPE_SPATIAL_FILTER:
|
|
137
146
|
db.objects.SPATIAL_FILTER.push(this.convertSpatialFilter(tio, obj));
|
|
138
147
|
break;
|
|
148
|
+
case Dwg_Object_Type.DWG_TYPE_XRECORD:
|
|
149
|
+
db.objects.XRECORD.push(this.convertXRecord(tio, obj));
|
|
150
|
+
break;
|
|
139
151
|
default:
|
|
140
152
|
break;
|
|
141
153
|
}
|
|
@@ -154,6 +166,10 @@ export class LibreDwgConverter {
|
|
|
154
166
|
viewportEntities.forEach((viewport, index) => {
|
|
155
167
|
viewport.viewportId = index + 1;
|
|
156
168
|
});
|
|
169
|
+
const thumbnail = libredwg.dwg_bmp(data);
|
|
170
|
+
if (thumbnail?.data?.length) {
|
|
171
|
+
db.thumbnailImage = thumbnail.data;
|
|
172
|
+
}
|
|
157
173
|
return db;
|
|
158
174
|
}
|
|
159
175
|
getConversionStats() {
|
|
@@ -246,14 +262,7 @@ export class LibreDwgConverter {
|
|
|
246
262
|
const scalability = libredwg.dwg_dynapi_entity_data(item, 'block_scaling');
|
|
247
263
|
const layout_ptr = libredwg.dwg_dynapi_entity_data(item, 'layout');
|
|
248
264
|
const layout = (libredwg.dwg_ref_get_id(layout_ptr) ?? '');
|
|
249
|
-
let bmpPreview
|
|
250
|
-
const uint8ArrayToHexString = (bytes) => {
|
|
251
|
-
const hexChars = new Array(bytes.length);
|
|
252
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
253
|
-
hexChars[i] = bytes[i].toString(16).toUpperCase();
|
|
254
|
-
}
|
|
255
|
-
return hexChars.join('');
|
|
256
|
-
};
|
|
265
|
+
let bmpPreview;
|
|
257
266
|
const bmpPreviewBinaryData = libredwg.dwg_entity_block_header_get_preview(item);
|
|
258
267
|
if (bmpPreviewBinaryData && bmpPreviewBinaryData.length > 0) {
|
|
259
268
|
bmpPreview = uint8ArrayToHexString(bmpPreviewBinaryData);
|
|
@@ -741,6 +750,50 @@ export class LibreDwgConverter {
|
|
|
741
750
|
resolutionUnits: resolutionUnits
|
|
742
751
|
};
|
|
743
752
|
}
|
|
753
|
+
convertLayerFilter(item, obj) {
|
|
754
|
+
const libredwg = this.libredwg;
|
|
755
|
+
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
756
|
+
const numNames = libredwg.dwg_dynapi_entity_data(item, 'num_names') ?? 0;
|
|
757
|
+
const namesPtr = libredwg.dwg_dynapi_entity_data(item, 'names');
|
|
758
|
+
const layerNames = namesPtr && numNames > 0
|
|
759
|
+
? libredwg
|
|
760
|
+
.dwg_ptr_to_wchar_string_array(namesPtr, numNames)
|
|
761
|
+
.filter((name) => name != null && name !== '')
|
|
762
|
+
: [];
|
|
763
|
+
return {
|
|
764
|
+
...commonAttrs,
|
|
765
|
+
...(layerNames.length ? { layerNames } : {})
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
convertLayerIndex(item, obj) {
|
|
769
|
+
const libredwg = this.libredwg;
|
|
770
|
+
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
771
|
+
const timeStamp = libredwg.dwg_dynapi_entity_data(item, 'last_updated');
|
|
772
|
+
const numEntries = libredwg.dwg_dynapi_entity_data(item, 'num_entries') ?? 0;
|
|
773
|
+
const entriesPtr = libredwg.dwg_dynapi_entity_data(item, 'entries');
|
|
774
|
+
const entrySize = libredwg.dwg_dynapi_subclass_size('LAYER_entry');
|
|
775
|
+
const layerNames = [];
|
|
776
|
+
const idBufferIds = [];
|
|
777
|
+
const idBufferEntryCounts = [];
|
|
778
|
+
if (entriesPtr && entrySize > 0) {
|
|
779
|
+
for (let i = 0; i < numEntries; i++) {
|
|
780
|
+
const entryPtr = entriesPtr + i * entrySize;
|
|
781
|
+
const name = libredwg.dwg_dynapi_subclass_data(entryPtr, 'LAYER_entry', 'name');
|
|
782
|
+
// Keep parallel arrays aligned with entries even when name is absent.
|
|
783
|
+
layerNames.push(name ?? '');
|
|
784
|
+
const handleRef = libredwg.dwg_dynapi_subclass_data(entryPtr, 'LAYER_entry', 'handle');
|
|
785
|
+
idBufferIds.push(handleRef ? (libredwg.dwg_ref_get_id(handleRef) ?? '') : '');
|
|
786
|
+
idBufferEntryCounts.push(libredwg.dwg_dynapi_subclass_data(entryPtr, 'LAYER_entry', 'numlayers') ?? 0);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return {
|
|
790
|
+
...commonAttrs,
|
|
791
|
+
...(timeStamp != null ? { timeStamp } : {}),
|
|
792
|
+
...(layerNames.length ? { layerNames } : {}),
|
|
793
|
+
...(idBufferIds.length ? { idBufferIds } : {}),
|
|
794
|
+
...(idBufferEntryCounts.length ? { idBufferEntryCounts } : {})
|
|
795
|
+
};
|
|
796
|
+
}
|
|
744
797
|
convertLayout(item, obj) {
|
|
745
798
|
const libredwg = this.libredwg;
|
|
746
799
|
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
@@ -879,6 +932,25 @@ export class LibreDwgConverter {
|
|
|
879
932
|
invertBlockMatrix: invertBlockMatrix
|
|
880
933
|
};
|
|
881
934
|
}
|
|
935
|
+
convertXRecord(item, obj) {
|
|
936
|
+
const libredwg = this.libredwg;
|
|
937
|
+
const commonAttrs = this.getCommonObjectAttrs(obj);
|
|
938
|
+
const cloning = libredwg.dwg_dynapi_entity_data(item, 'cloning');
|
|
939
|
+
const data = libredwg.dwg_object_xrecord_get_xdata(item) ?? [];
|
|
940
|
+
const objectObj = libredwg.dwg_object_get_tio(obj);
|
|
941
|
+
const xdic = objectObj
|
|
942
|
+
? libredwg.dwg_object_object_get_xdicobjhandle_object(objectObj)
|
|
943
|
+
: null;
|
|
944
|
+
const extensionDictionary = xdic && xdic.absolute_ref
|
|
945
|
+
? idToString(xdic.absolute_ref)
|
|
946
|
+
: undefined;
|
|
947
|
+
return {
|
|
948
|
+
...commonAttrs,
|
|
949
|
+
...(cloning != null ? { cloning } : {}),
|
|
950
|
+
...(extensionDictionary ? { extensionDictionary } : {}),
|
|
951
|
+
data
|
|
952
|
+
};
|
|
953
|
+
}
|
|
882
954
|
getCommonObjectAttrs(obj) {
|
|
883
955
|
const libredwg = this.libredwg;
|
|
884
956
|
const object_tio = libredwg.dwg_object_get_tio(obj);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DwgBoundaryPathEdgeType, DwgHatchAssociativity, DwgHatchGradientColorFlag, DwgHatchGradientFlag, DwgHatchSolidFill } from '../database';
|
|
2
2
|
import { Dwg_Hatch_Edge_Type, Dwg_Object_Type } from '../types';
|
|
3
3
|
import { dwgColorToMLeaderRawColor } from './dwgColorToMLeaderRawColor';
|
|
4
|
-
import { idToString, uint8ArrayToHexString } from './utils';
|
|
4
|
+
import { decodeOle2FrameCornersFromData, idToString, uint8ArrayToHexString } from './utils';
|
|
5
5
|
export class LibreEntityConverter {
|
|
6
6
|
libredwg;
|
|
7
7
|
layers = new Map();
|
|
@@ -49,6 +49,9 @@ export class LibreEntityConverter {
|
|
|
49
49
|
if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DFACE) {
|
|
50
50
|
return this.convert3dFace(entity_tio, commonAttrs);
|
|
51
51
|
}
|
|
52
|
+
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_3DSOLID) {
|
|
53
|
+
return this.convert3dSolid(entity_tio, commonAttrs);
|
|
54
|
+
}
|
|
52
55
|
else if (fixedtype == Dwg_Object_Type.DWG_TYPE_ARC) {
|
|
53
56
|
return this.convertArc(entity_tio, commonAttrs);
|
|
54
57
|
}
|
|
@@ -185,6 +188,40 @@ export class LibreEntityConverter {
|
|
|
185
188
|
flag: flag
|
|
186
189
|
};
|
|
187
190
|
}
|
|
191
|
+
convert3dSolid(entity, commonAttrs) {
|
|
192
|
+
const libredwg = this.libredwg;
|
|
193
|
+
const version = libredwg.dwg_dynapi_entity_data(entity, 'version');
|
|
194
|
+
const satCache = libredwg.dwg_dynapi_entity_data(entity, 'acis_empty');
|
|
195
|
+
const data = libredwg.dwg_dynapi_entity_data(entity, 'acis_data');
|
|
196
|
+
const hasRevisionGuid = libredwg.dwg_dynapi_entity_data(entity, 'has_revision_guid');
|
|
197
|
+
const historyRef = libredwg.dwg_dynapi_entity_data(entity, 'history_id');
|
|
198
|
+
const historyObjectSoftId = libredwg.dwg_ref_get_id(historyRef);
|
|
199
|
+
const result = {
|
|
200
|
+
type: '3DSOLID',
|
|
201
|
+
subclassMarker: 'AcDb3dSolid',
|
|
202
|
+
...commonAttrs
|
|
203
|
+
};
|
|
204
|
+
if (version) {
|
|
205
|
+
result.version = version;
|
|
206
|
+
}
|
|
207
|
+
result.satCache = satCache;
|
|
208
|
+
if (data) {
|
|
209
|
+
result.data = data;
|
|
210
|
+
}
|
|
211
|
+
if (hasRevisionGuid) {
|
|
212
|
+
const guidOffset = libredwg.dwg_dynapi_entity_field_offset(entity, 'revision_guid');
|
|
213
|
+
if (guidOffset >= 0) {
|
|
214
|
+
const guid = libredwg.UTF8ToString(entity + guidOffset, 38);
|
|
215
|
+
if (guid) {
|
|
216
|
+
result.guid = guid;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (historyObjectSoftId) {
|
|
221
|
+
result.historyObjectSoftId = historyObjectSoftId;
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
188
225
|
convertArc(entity, commonAttrs) {
|
|
189
226
|
const libredwg = this.libredwg;
|
|
190
227
|
const center = libredwg.dwg_dynapi_entity_data(entity, 'center');
|
|
@@ -1150,12 +1187,22 @@ export class LibreEntityConverter {
|
|
|
1150
1187
|
const oleVersion = libredwg.dwg_dynapi_entity_data(entity, 'oleversion');
|
|
1151
1188
|
const oleClient = libredwg.dwg_dynapi_entity_data(entity, 'oleclient');
|
|
1152
1189
|
const dataSize = libredwg.dwg_dynapi_entity_data(entity, 'data_size');
|
|
1153
|
-
|
|
1154
|
-
|
|
1190
|
+
let leftUpPoint = libredwg.dwg_dynapi_entity_data(entity, 'pt1');
|
|
1191
|
+
let rightDownPoint = libredwg.dwg_dynapi_entity_data(entity, 'pt2');
|
|
1155
1192
|
const lockAspect = libredwg.dwg_dynapi_entity_data(entity, 'lock_aspect');
|
|
1156
1193
|
const oleObjectType = libredwg.dwg_dynapi_entity_data(entity, 'type');
|
|
1157
1194
|
const tileModeDescriptor = libredwg.dwg_dynapi_entity_data(entity, 'mode');
|
|
1158
|
-
|
|
1195
|
+
// Prefer sized TF copy: dynapi TF truncates at the first embedded NUL.
|
|
1196
|
+
const dataBytes = libredwg.dwg_entity_ole2frame_get_data(entity);
|
|
1197
|
+
const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : '';
|
|
1198
|
+
// Prefer corners decoded from the OLE header (also fixed in dwg_decode_ole2).
|
|
1199
|
+
if (dataBytes) {
|
|
1200
|
+
const corners = decodeOle2FrameCornersFromData(dataBytes);
|
|
1201
|
+
if (corners) {
|
|
1202
|
+
leftUpPoint = corners.upperLeft;
|
|
1203
|
+
rightDownPoint = corners.lowerRight;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1159
1206
|
return {
|
|
1160
1207
|
type: 'OLE2FRAME',
|
|
1161
1208
|
...commonAttrs,
|
|
@@ -1175,7 +1222,8 @@ export class LibreEntityConverter {
|
|
|
1175
1222
|
const flag = libredwg.dwg_dynapi_entity_data(entity, 'flag');
|
|
1176
1223
|
const mode = libredwg.dwg_dynapi_entity_data(entity, 'mode');
|
|
1177
1224
|
const dataSize = libredwg.dwg_dynapi_entity_data(entity, 'data_size');
|
|
1178
|
-
const
|
|
1225
|
+
const dataBytes = libredwg.dwg_entity_oleframe_get_data(entity);
|
|
1226
|
+
const binaryData = dataBytes ? uint8ArrayToHexString(dataBytes) : '';
|
|
1179
1227
|
return {
|
|
1180
1228
|
type: 'OLEFRAME',
|
|
1181
1229
|
...commonAttrs,
|
package/lib/converter/utils.d.ts
CHANGED
|
@@ -2,4 +2,25 @@ export declare const isModelSpace: (name: string) => boolean | "";
|
|
|
2
2
|
export declare const isPaperSpace: (name: string) => boolean | "";
|
|
3
3
|
export declare const idToString: (id: number | bigint) => string;
|
|
4
4
|
export declare const uint8ArrayToHexString: (bytes: Uint8Array) => string;
|
|
5
|
+
/**
|
|
6
|
+
* OLE2FRAME binary payloads begin with a 0x80-byte Autodesk header, then an
|
|
7
|
+
* MS-CFB compound document. Corner points for DXF groups 10/11 are stored in
|
|
8
|
+
* that header (also decoded by `dwg_decode_ole2`).
|
|
9
|
+
*
|
|
10
|
+
* Layout after a 2-byte unknown prefix (`0x80 0x55` in common files):
|
|
11
|
+
* four WCS corners as little-endian 3D doubles (upper-left, upper-right,
|
|
12
|
+
* lower-right, lower-left). DXF group codes 10/11 store the first and third.
|
|
13
|
+
*/
|
|
14
|
+
export declare const decodeOle2FrameCornersFromData: (data: Uint8Array) => {
|
|
15
|
+
upperLeft: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
z: number;
|
|
19
|
+
};
|
|
20
|
+
lowerRight: {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
z: number;
|
|
24
|
+
};
|
|
25
|
+
} | null;
|
|
5
26
|
//# sourceMappingURL=utils.d.ts.map
|
package/lib/converter/utils.js
CHANGED
|
@@ -16,4 +16,31 @@ export const uint8ArrayToHexString = (bytes) => {
|
|
|
16
16
|
}
|
|
17
17
|
return hexChars.join('');
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* OLE2FRAME binary payloads begin with a 0x80-byte Autodesk header, then an
|
|
21
|
+
* MS-CFB compound document. Corner points for DXF groups 10/11 are stored in
|
|
22
|
+
* that header (also decoded by `dwg_decode_ole2`).
|
|
23
|
+
*
|
|
24
|
+
* Layout after a 2-byte unknown prefix (`0x80 0x55` in common files):
|
|
25
|
+
* four WCS corners as little-endian 3D doubles (upper-left, upper-right,
|
|
26
|
+
* lower-right, lower-left). DXF group codes 10/11 store the first and third.
|
|
27
|
+
*/
|
|
28
|
+
export const decodeOle2FrameCornersFromData = (data) => {
|
|
29
|
+
// 2-byte prefix + 4 corners * 3 doubles * 8 bytes = 98 bytes
|
|
30
|
+
if (!data || data.length < 98) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
34
|
+
const readPoint = (offset) => ({
|
|
35
|
+
x: view.getFloat64(offset, true),
|
|
36
|
+
y: view.getFloat64(offset + 8, true),
|
|
37
|
+
z: view.getFloat64(offset + 16, true)
|
|
38
|
+
});
|
|
39
|
+
const upperLeft = readPoint(2);
|
|
40
|
+
const lowerRight = readPoint(2 + 48);
|
|
41
|
+
if (![upperLeft.x, upperLeft.y, upperLeft.z, lowerRight.x, lowerRight.y, lowerRight.z].every(Number.isFinite)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return { upperLeft, lowerRight };
|
|
45
|
+
};
|
|
19
46
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DwgClass } from './classes';
|
|
2
2
|
import { DwgEntity } from './entities';
|
|
3
3
|
import { DwgHeader } from './header';
|
|
4
|
-
import { DwgDictionaryObject, DwgImageDefObject, DwgLayoutObject, DwgMLeaderStyleObject, DwgSpatialFilterObject } from './objects';
|
|
4
|
+
import { DwgDictionaryObject, DwgImageDefObject, DwgLayerFilterObject, DwgLayerIndexObject, DwgLayoutObject, DwgMLeaderStyleObject, DwgSpatialFilterObject, DwgXRecordObject } from './objects';
|
|
5
5
|
import { DwgAppIdEntry, DwgBlockRecordTableEntry, DwgDimStyleTableEntry, DwgLayerTableEntry, DwgLTypeTableEntry, DwgStyleTableEntry, DwgTable, DwgVPortTableEntry } from './tables';
|
|
6
6
|
export interface DwgDatabase {
|
|
7
7
|
tables: {
|
|
@@ -16,10 +16,14 @@ export interface DwgDatabase {
|
|
|
16
16
|
objects: {
|
|
17
17
|
DICTIONARY: DwgDictionaryObject[];
|
|
18
18
|
IMAGEDEF: DwgImageDefObject[];
|
|
19
|
+
LAYER_FILTER: DwgLayerFilterObject[];
|
|
20
|
+
LAYER_INDEX: DwgLayerIndexObject[];
|
|
19
21
|
LAYOUT: DwgLayoutObject[];
|
|
20
22
|
MLEADERSTYLE: DwgMLeaderStyleObject[];
|
|
21
23
|
SPATIAL_FILTER: DwgSpatialFilterObject[];
|
|
24
|
+
XRECORD: DwgXRecordObject[];
|
|
22
25
|
};
|
|
26
|
+
thumbnailImage?: Uint8Array;
|
|
23
27
|
header: DwgHeader;
|
|
24
28
|
/**
|
|
25
29
|
* All of entities in the model space.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DwgEntity } from './entity';
|
|
2
|
+
export interface DwgSolid3dEntity extends DwgEntity {
|
|
3
|
+
/**
|
|
4
|
+
* Entity type
|
|
5
|
+
*/
|
|
6
|
+
type: '3DSOLID';
|
|
7
|
+
/**
|
|
8
|
+
* DXF subclass marker
|
|
9
|
+
*/
|
|
10
|
+
subclassMarker: 'AcDb3dSolid';
|
|
11
|
+
/**
|
|
12
|
+
* Modeler format version number (currently = 1)
|
|
13
|
+
*/
|
|
14
|
+
version?: number;
|
|
15
|
+
/**
|
|
16
|
+
* SAT cache flag (group 290, R2013+)
|
|
17
|
+
*/
|
|
18
|
+
satCache?: number;
|
|
19
|
+
/**
|
|
20
|
+
* GUID string (group 2, R2013+)
|
|
21
|
+
*/
|
|
22
|
+
guid?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Proprietary ACIS/SAT data
|
|
25
|
+
*/
|
|
26
|
+
data?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Soft-owner ID/handle to history object
|
|
29
|
+
*/
|
|
30
|
+
historyObjectSoftId?: string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=solid3d.d.ts.map
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from './common';
|
|
2
2
|
export * from './dictionary';
|
|
3
3
|
export * from './imageDef';
|
|
4
|
+
export * from './layerFilter';
|
|
5
|
+
export * from './layerIndex';
|
|
4
6
|
export * from './layout';
|
|
5
7
|
export * from './mleaderStyle';
|
|
6
8
|
export * from './plotSetting';
|
|
7
9
|
export * from './spatialFilter';
|
|
10
|
+
export * from './xrecord';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from './common';
|
|
2
2
|
export * from './dictionary';
|
|
3
3
|
export * from './imageDef';
|
|
4
|
+
export * from './layerFilter';
|
|
5
|
+
export * from './layerIndex';
|
|
4
6
|
export * from './layout';
|
|
5
7
|
export * from './mleaderStyle';
|
|
6
8
|
export * from './plotSetting';
|
|
7
9
|
export * from './spatialFilter';
|
|
10
|
+
export * from './xrecord';
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DwgCommonObject } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* DWG LAYER_FILTER / LAYERFILTER object fields.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This shape mirrors the DXF LAYER_FILTER mapping used by ObjectARX / dxf-json.
|
|
7
|
+
*/
|
|
8
|
+
export interface DwgLayerFilterObject extends DwgCommonObject {
|
|
9
|
+
/** Layer names included in this filter. */
|
|
10
|
+
layerNames?: string[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=layerFilter.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DwgCommonObject } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* DWG LAYER_INDEX object fields.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This shape mirrors the DXF LAYER_INDEX mapping used by ObjectARX / dxf-json.
|
|
7
|
+
*/
|
|
8
|
+
export interface DwgLayerIndexObject extends DwgCommonObject {
|
|
9
|
+
/** Julian / last-updated timestamp. */
|
|
10
|
+
timeStamp?: number;
|
|
11
|
+
/** Layer names included in this layer index. */
|
|
12
|
+
layerNames?: string[];
|
|
13
|
+
/** Hard-owner handles to IDBUFFER objects. */
|
|
14
|
+
idBufferIds?: string[];
|
|
15
|
+
/** Number of entries in each referenced IDBUFFER. */
|
|
16
|
+
idBufferEntryCounts?: number[];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=layerIndex.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DwgCommonObject } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* One DXF group-code / value pair stored in an XRECORD.
|
|
4
|
+
*/
|
|
5
|
+
export interface DwgXRecordGroup {
|
|
6
|
+
/** DXF group code. */
|
|
7
|
+
code: number;
|
|
8
|
+
/**
|
|
9
|
+
* Group value. Strings, numbers, booleans, handle hex strings, binary
|
|
10
|
+
* byte arrays, or `{ x, y, z }` for 3D points.
|
|
11
|
+
*/
|
|
12
|
+
value: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* DWG XRECORD object fields.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Layer Manager filters (`ACAD_LAYERFILTERS` / `ACLYDICTIONARY`) store each
|
|
19
|
+
* filter node as an XRECORD under those dictionaries. The payload mirrors the
|
|
20
|
+
* DXF XRECORD `data` group list used by ObjectARX / dxf-json.
|
|
21
|
+
*/
|
|
22
|
+
export interface DwgXRecordObject extends DwgCommonObject {
|
|
23
|
+
/** Duplicate record cloning flag (DXF group 280). */
|
|
24
|
+
cloning?: number;
|
|
25
|
+
/** Extension dictionary handle, when the object has one. */
|
|
26
|
+
extensionDictionary?: string;
|
|
27
|
+
/** XRecord payload as DXF group pairs. */
|
|
28
|
+
data: DwgXRecordGroup[];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=xrecord.d.ts.map
|
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
|
|
@@ -700,7 +717,7 @@ export declare class LibreDwg {
|
|
|
700
717
|
* @param ptr Pointer to one Dwg_Entity_BLOCK_HEADER instance.
|
|
701
718
|
* @returns Returns preview image of the block pointed by the specified block header.
|
|
702
719
|
*/
|
|
703
|
-
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;
|
|
704
721
|
/**
|
|
705
722
|
* Returns preview binary data of one entity (common entity preview field).
|
|
706
723
|
* For PROXY_ENTITY this contains the proxy graphics data.
|
|
@@ -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
|
|
@@ -1037,9 +1055,12 @@ export class LibreDwg {
|
|
|
1037
1055
|
* @returns Returns preview image of the block pointed by the specified block header.
|
|
1038
1056
|
*/
|
|
1039
1057
|
dwg_entity_block_header_get_preview(ptr) {
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1042
|
-
|
|
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;
|
|
1043
1064
|
}
|
|
1044
1065
|
/**
|
|
1045
1066
|
* Returns preview binary data of one entity (common entity preview field).
|
|
@@ -1067,6 +1088,32 @@ export class LibreDwg {
|
|
|
1067
1088
|
const result = wasm.dwg_entity_proxy_entity_get_entity_data(ptr);
|
|
1068
1089
|
return result?.data ?? null;
|
|
1069
1090
|
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Returns binary OLE payload of one Dwg_Entity_OLE2FRAME instance.
|
|
1093
|
+
* Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
|
|
1094
|
+
* @group Dwg_Entity_OLE2FRAME Methods
|
|
1095
|
+
*/
|
|
1096
|
+
dwg_entity_ole2frame_get_data(ptr) {
|
|
1097
|
+
const wasm = this.wasmInstance;
|
|
1098
|
+
if (typeof wasm.dwg_entity_ole2frame_get_data !== 'function') {
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
const result = wasm.dwg_entity_ole2frame_get_data(ptr);
|
|
1102
|
+
return result?.data ?? null;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Returns binary OLE payload of one Dwg_Entity_OLEFRAME instance.
|
|
1106
|
+
* Uses data_size so embedded NUL bytes are preserved (unlike dynapi TF).
|
|
1107
|
+
* @group Dwg_Entity_OLEFRAME Methods
|
|
1108
|
+
*/
|
|
1109
|
+
dwg_entity_oleframe_get_data(ptr) {
|
|
1110
|
+
const wasm = this.wasmInstance;
|
|
1111
|
+
if (typeof wasm.dwg_entity_oleframe_get_data !== 'function') {
|
|
1112
|
+
return null;
|
|
1113
|
+
}
|
|
1114
|
+
const result = wasm.dwg_entity_oleframe_get_data(ptr);
|
|
1115
|
+
return result?.data ?? null;
|
|
1116
|
+
}
|
|
1070
1117
|
/**
|
|
1071
1118
|
* Returns the first entity owned by the block header or null
|
|
1072
1119
|
* @group Dwg_Entity_BLOCK_HEADER Methods
|
package/lib/types/common.d.ts
CHANGED
|
@@ -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;
|