3dviewer-sdk 1.1.6 → 1.1.7
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/index.d.mts +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +98 -14
- package/dist/index.mjs +98 -14
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -40,6 +40,8 @@ declare enum ViewerMessageType {
|
|
|
40
40
|
STATES_OBJECTS_LIST = "viewer-states-objects-list",
|
|
41
41
|
TREE_SELECT_NODE = "viewer-tree-select-node",
|
|
42
42
|
TREE_SET_NODE_VISIBILITY = "viewer-tree-set-node-visibility",
|
|
43
|
+
NODE_SYNC_LOCKED_STATE = "viewer-node-sync-locked-state",
|
|
44
|
+
NODE_GET_LOCKED_STATE = "viewer-node-get-locked-state",
|
|
43
45
|
TREE_GET_NODE_IDS = "viewer-tree-get-node-ids",
|
|
44
46
|
TREE_NODE_IDS = "viewer-tree-node-ids",
|
|
45
47
|
TREE_GET_NODES = "viewer-tree-get-nodes",
|
|
@@ -53,6 +55,8 @@ declare enum ViewerMessageType {
|
|
|
53
55
|
PDF_CURRENT_PAGE = "viewer-pdf-current-page",
|
|
54
56
|
HOME_CLICK = "viewer-home-click",
|
|
55
57
|
NODE_SELECTION_CHANGE = "viewer-node-selection-change",
|
|
58
|
+
NODE_LOCKED_STATE = "viewer-node-locked-state",
|
|
59
|
+
NODE_LOCKED_STATE_CHANGE = "viewer-node-locked-state-change",
|
|
56
60
|
PAN_CHANGE = "viewer-pan-change"
|
|
57
61
|
}
|
|
58
62
|
type LanguageCode = "en" | "vn";
|
|
@@ -144,6 +148,21 @@ type StateObjectItem = {
|
|
|
144
148
|
type: string;
|
|
145
149
|
};
|
|
146
150
|
};
|
|
151
|
+
type SyncLockedStatePayload = {
|
|
152
|
+
persistentIds?: string[];
|
|
153
|
+
treeNodeIds?: string[];
|
|
154
|
+
requestId?: string;
|
|
155
|
+
};
|
|
156
|
+
type GetLockedStatePayload = {
|
|
157
|
+
requestId?: string;
|
|
158
|
+
};
|
|
159
|
+
type LockedStatePayload = {
|
|
160
|
+
requestId?: string;
|
|
161
|
+
persistentIds: string[];
|
|
162
|
+
treeNodeIds: string[];
|
|
163
|
+
renderedNodeIds: string[];
|
|
164
|
+
timestamp: number;
|
|
165
|
+
};
|
|
147
166
|
type TreeNodeItem = {
|
|
148
167
|
id: string;
|
|
149
168
|
name: string;
|
|
@@ -178,6 +197,8 @@ type ViewerEventMap = {
|
|
|
178
197
|
};
|
|
179
198
|
"camera:zoom": CameraZoomPayload;
|
|
180
199
|
"node:selection-change": NodeSelectionChangePayload;
|
|
200
|
+
"node:locked-state": LockedStatePayload;
|
|
201
|
+
"node:locked-state-change": LockedStatePayload;
|
|
181
202
|
"interaction:pan-change": {
|
|
182
203
|
enabled: boolean;
|
|
183
204
|
};
|
|
@@ -346,6 +367,11 @@ declare class InteractionModule {
|
|
|
346
367
|
private setDrawMode;
|
|
347
368
|
}
|
|
348
369
|
|
|
370
|
+
type LockedState = LockedStatePayload;
|
|
371
|
+
type SyncLockedStateInput = Omit<SyncLockedStatePayload, "requestId">;
|
|
372
|
+
type LockedStateRequestOptions = {
|
|
373
|
+
timeoutMs?: number;
|
|
374
|
+
};
|
|
349
375
|
declare class NodeModule {
|
|
350
376
|
private viewer;
|
|
351
377
|
on: {
|
|
@@ -353,8 +379,11 @@ declare class NodeModule {
|
|
|
353
379
|
nodeIds: string[];
|
|
354
380
|
timestamp: number;
|
|
355
381
|
}) => void) => () => void;
|
|
382
|
+
lockedStateChange: (cb: (payload: LockedState) => void) => () => void;
|
|
356
383
|
};
|
|
357
384
|
constructor(viewer: Viewer3D);
|
|
385
|
+
syncLockedState(input: SyncLockedStateInput, options?: LockedStateRequestOptions): Promise<LockedState>;
|
|
386
|
+
getLockedState(options?: LockedStateRequestOptions): Promise<LockedState>;
|
|
358
387
|
}
|
|
359
388
|
|
|
360
389
|
type FilesConfig = {
|
|
@@ -735,4 +764,4 @@ declare class Viewer3D {
|
|
|
735
764
|
private handleMessage;
|
|
736
765
|
}
|
|
737
766
|
|
|
738
|
-
export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type CreatePipelineOptions, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialBackground, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, type SetBackgroundOptions, Viewer3D, type Viewer3DOptions, type ViewerBackgroundColorInput, type ViewerBackgroundPayload, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload, type ViewerRgbColor, type ViewerRgbaColor };
|
|
767
|
+
export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type CreatePipelineOptions, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type GetLockedStatePayload, type InitialBackground, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type LockedState, type LockedStatePayload, type LockedStateRequestOptions, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, type SetBackgroundOptions, type SyncLockedStateInput, type SyncLockedStatePayload, Viewer3D, type Viewer3DOptions, type ViewerBackgroundColorInput, type ViewerBackgroundPayload, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload, type ViewerRgbColor, type ViewerRgbaColor };
|
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ declare enum ViewerMessageType {
|
|
|
40
40
|
STATES_OBJECTS_LIST = "viewer-states-objects-list",
|
|
41
41
|
TREE_SELECT_NODE = "viewer-tree-select-node",
|
|
42
42
|
TREE_SET_NODE_VISIBILITY = "viewer-tree-set-node-visibility",
|
|
43
|
+
NODE_SYNC_LOCKED_STATE = "viewer-node-sync-locked-state",
|
|
44
|
+
NODE_GET_LOCKED_STATE = "viewer-node-get-locked-state",
|
|
43
45
|
TREE_GET_NODE_IDS = "viewer-tree-get-node-ids",
|
|
44
46
|
TREE_NODE_IDS = "viewer-tree-node-ids",
|
|
45
47
|
TREE_GET_NODES = "viewer-tree-get-nodes",
|
|
@@ -53,6 +55,8 @@ declare enum ViewerMessageType {
|
|
|
53
55
|
PDF_CURRENT_PAGE = "viewer-pdf-current-page",
|
|
54
56
|
HOME_CLICK = "viewer-home-click",
|
|
55
57
|
NODE_SELECTION_CHANGE = "viewer-node-selection-change",
|
|
58
|
+
NODE_LOCKED_STATE = "viewer-node-locked-state",
|
|
59
|
+
NODE_LOCKED_STATE_CHANGE = "viewer-node-locked-state-change",
|
|
56
60
|
PAN_CHANGE = "viewer-pan-change"
|
|
57
61
|
}
|
|
58
62
|
type LanguageCode = "en" | "vn";
|
|
@@ -144,6 +148,21 @@ type StateObjectItem = {
|
|
|
144
148
|
type: string;
|
|
145
149
|
};
|
|
146
150
|
};
|
|
151
|
+
type SyncLockedStatePayload = {
|
|
152
|
+
persistentIds?: string[];
|
|
153
|
+
treeNodeIds?: string[];
|
|
154
|
+
requestId?: string;
|
|
155
|
+
};
|
|
156
|
+
type GetLockedStatePayload = {
|
|
157
|
+
requestId?: string;
|
|
158
|
+
};
|
|
159
|
+
type LockedStatePayload = {
|
|
160
|
+
requestId?: string;
|
|
161
|
+
persistentIds: string[];
|
|
162
|
+
treeNodeIds: string[];
|
|
163
|
+
renderedNodeIds: string[];
|
|
164
|
+
timestamp: number;
|
|
165
|
+
};
|
|
147
166
|
type TreeNodeItem = {
|
|
148
167
|
id: string;
|
|
149
168
|
name: string;
|
|
@@ -178,6 +197,8 @@ type ViewerEventMap = {
|
|
|
178
197
|
};
|
|
179
198
|
"camera:zoom": CameraZoomPayload;
|
|
180
199
|
"node:selection-change": NodeSelectionChangePayload;
|
|
200
|
+
"node:locked-state": LockedStatePayload;
|
|
201
|
+
"node:locked-state-change": LockedStatePayload;
|
|
181
202
|
"interaction:pan-change": {
|
|
182
203
|
enabled: boolean;
|
|
183
204
|
};
|
|
@@ -346,6 +367,11 @@ declare class InteractionModule {
|
|
|
346
367
|
private setDrawMode;
|
|
347
368
|
}
|
|
348
369
|
|
|
370
|
+
type LockedState = LockedStatePayload;
|
|
371
|
+
type SyncLockedStateInput = Omit<SyncLockedStatePayload, "requestId">;
|
|
372
|
+
type LockedStateRequestOptions = {
|
|
373
|
+
timeoutMs?: number;
|
|
374
|
+
};
|
|
349
375
|
declare class NodeModule {
|
|
350
376
|
private viewer;
|
|
351
377
|
on: {
|
|
@@ -353,8 +379,11 @@ declare class NodeModule {
|
|
|
353
379
|
nodeIds: string[];
|
|
354
380
|
timestamp: number;
|
|
355
381
|
}) => void) => () => void;
|
|
382
|
+
lockedStateChange: (cb: (payload: LockedState) => void) => () => void;
|
|
356
383
|
};
|
|
357
384
|
constructor(viewer: Viewer3D);
|
|
385
|
+
syncLockedState(input: SyncLockedStateInput, options?: LockedStateRequestOptions): Promise<LockedState>;
|
|
386
|
+
getLockedState(options?: LockedStateRequestOptions): Promise<LockedState>;
|
|
358
387
|
}
|
|
359
388
|
|
|
360
389
|
type FilesConfig = {
|
|
@@ -735,4 +764,4 @@ declare class Viewer3D {
|
|
|
735
764
|
private handleMessage;
|
|
736
765
|
}
|
|
737
766
|
|
|
738
|
-
export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type CreatePipelineOptions, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialBackground, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, type SetBackgroundOptions, Viewer3D, type Viewer3DOptions, type ViewerBackgroundColorInput, type ViewerBackgroundPayload, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload, type ViewerRgbColor, type ViewerRgbaColor };
|
|
767
|
+
export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type CreatePipelineOptions, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type GetLockedStatePayload, type InitialBackground, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type LockedState, type LockedStatePayload, type LockedStateRequestOptions, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, type SetBackgroundOptions, type SyncLockedStateInput, type SyncLockedStatePayload, Viewer3D, type Viewer3DOptions, type ViewerBackgroundColorInput, type ViewerBackgroundPayload, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload, type ViewerRgbColor, type ViewerRgbaColor };
|
package/dist/index.js
CHANGED
|
@@ -260,14 +260,74 @@ var InteractionModule = class {
|
|
|
260
260
|
};
|
|
261
261
|
|
|
262
262
|
// src/modules/node.module.ts
|
|
263
|
+
function createRequestId2(prefix) {
|
|
264
|
+
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
265
|
+
}
|
|
266
|
+
function normalizeIds(values) {
|
|
267
|
+
if (!values) return void 0;
|
|
268
|
+
const normalized = Array.from(
|
|
269
|
+
new Set(
|
|
270
|
+
values.map((value) => String(value).trim()).filter((value) => value !== "")
|
|
271
|
+
)
|
|
272
|
+
);
|
|
273
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
274
|
+
}
|
|
263
275
|
var NodeModule = class {
|
|
264
276
|
constructor(viewer) {
|
|
265
277
|
this.viewer = viewer;
|
|
266
278
|
this.on = {
|
|
267
279
|
// SDK no longer supports first-node-only select events; listen to selectionChange for the full node list.
|
|
268
|
-
selectionChange: (cb) => this.viewer._on("node:selection-change", cb)
|
|
280
|
+
selectionChange: (cb) => this.viewer._on("node:selection-change", cb),
|
|
281
|
+
lockedStateChange: (cb) => this.viewer._on("node:locked-state-change", cb)
|
|
269
282
|
};
|
|
270
283
|
}
|
|
284
|
+
syncLockedState(input, options) {
|
|
285
|
+
var _a;
|
|
286
|
+
const requestId = createRequestId2("locked_state_sync");
|
|
287
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
288
|
+
return new Promise((resolve, reject) => {
|
|
289
|
+
const timer = setTimeout(() => {
|
|
290
|
+
off();
|
|
291
|
+
reject(new Error("Timeout while syncing locked state with viewer"));
|
|
292
|
+
}, timeoutMs);
|
|
293
|
+
const off = this.viewer._on("node:locked-state", (payload2) => {
|
|
294
|
+
if (payload2.requestId !== requestId) return;
|
|
295
|
+
clearTimeout(timer);
|
|
296
|
+
off();
|
|
297
|
+
resolve(payload2);
|
|
298
|
+
});
|
|
299
|
+
const payload = {
|
|
300
|
+
requestId,
|
|
301
|
+
persistentIds: normalizeIds(input.persistentIds),
|
|
302
|
+
treeNodeIds: normalizeIds(input.treeNodeIds)
|
|
303
|
+
};
|
|
304
|
+
this.viewer.postToViewer(
|
|
305
|
+
"viewer-node-sync-locked-state" /* NODE_SYNC_LOCKED_STATE */,
|
|
306
|
+
payload
|
|
307
|
+
);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
getLockedState(options) {
|
|
311
|
+
var _a;
|
|
312
|
+
const requestId = createRequestId2("locked_state_get");
|
|
313
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
314
|
+
return new Promise((resolve, reject) => {
|
|
315
|
+
const timer = setTimeout(() => {
|
|
316
|
+
off();
|
|
317
|
+
reject(new Error("Timeout while getting locked state from viewer"));
|
|
318
|
+
}, timeoutMs);
|
|
319
|
+
const off = this.viewer._on("node:locked-state", (payload) => {
|
|
320
|
+
if (payload.requestId !== requestId) return;
|
|
321
|
+
clearTimeout(timer);
|
|
322
|
+
off();
|
|
323
|
+
resolve(payload);
|
|
324
|
+
});
|
|
325
|
+
this.viewer.postToViewer(
|
|
326
|
+
"viewer-node-get-locked-state" /* NODE_GET_LOCKED_STATE */,
|
|
327
|
+
{ requestId }
|
|
328
|
+
);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
271
331
|
};
|
|
272
332
|
|
|
273
333
|
// src/modules/files.module.ts
|
|
@@ -833,7 +893,7 @@ var FilesModule = class {
|
|
|
833
893
|
};
|
|
834
894
|
|
|
835
895
|
// src/modules/toolbar.module.ts
|
|
836
|
-
function
|
|
896
|
+
function createRequestId3(prefix) {
|
|
837
897
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
838
898
|
}
|
|
839
899
|
var ALL_3D_TOOLBAR_OPERATORS = [
|
|
@@ -991,7 +1051,7 @@ var ToolbarModule = class {
|
|
|
991
1051
|
}
|
|
992
1052
|
getSheets(options) {
|
|
993
1053
|
var _a;
|
|
994
|
-
const requestId =
|
|
1054
|
+
const requestId = createRequestId3("sheets");
|
|
995
1055
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
996
1056
|
return new Promise((resolve, reject) => {
|
|
997
1057
|
const timer = setTimeout(() => {
|
|
@@ -1009,7 +1069,7 @@ var ToolbarModule = class {
|
|
|
1009
1069
|
}
|
|
1010
1070
|
getObjectProperties(options) {
|
|
1011
1071
|
var _a;
|
|
1012
|
-
const requestId =
|
|
1072
|
+
const requestId = createRequestId3("object_properties");
|
|
1013
1073
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1014
1074
|
return new Promise((resolve, reject) => {
|
|
1015
1075
|
var _a2;
|
|
@@ -1031,7 +1091,7 @@ var ToolbarModule = class {
|
|
|
1031
1091
|
}
|
|
1032
1092
|
getLinkedObjects(options) {
|
|
1033
1093
|
var _a;
|
|
1034
|
-
const requestId =
|
|
1094
|
+
const requestId = createRequestId3("linked_objects");
|
|
1035
1095
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1036
1096
|
return new Promise((resolve, reject) => {
|
|
1037
1097
|
const timer = setTimeout(() => {
|
|
@@ -1049,7 +1109,7 @@ var ToolbarModule = class {
|
|
|
1049
1109
|
}
|
|
1050
1110
|
getStatesObjects(options) {
|
|
1051
1111
|
var _a;
|
|
1052
|
-
const requestId =
|
|
1112
|
+
const requestId = createRequestId3("states_objects");
|
|
1053
1113
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1054
1114
|
return new Promise((resolve, reject) => {
|
|
1055
1115
|
const timer = setTimeout(() => {
|
|
@@ -1137,7 +1197,7 @@ var ToolbarModule = class {
|
|
|
1137
1197
|
};
|
|
1138
1198
|
|
|
1139
1199
|
// src/modules/model-tree.module.ts
|
|
1140
|
-
function
|
|
1200
|
+
function createRequestId4(prefix) {
|
|
1141
1201
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1142
1202
|
}
|
|
1143
1203
|
function buildTree(nodes, rootNodeIds) {
|
|
@@ -1211,7 +1271,7 @@ var ModelTreeModule = class {
|
|
|
1211
1271
|
this.setNodeVisibility(nodeIds, true);
|
|
1212
1272
|
}
|
|
1213
1273
|
getNodeIds(options) {
|
|
1214
|
-
const requestId =
|
|
1274
|
+
const requestId = createRequestId4("tree");
|
|
1215
1275
|
const timeoutMs = this.resolveTimeoutMs(options);
|
|
1216
1276
|
return new Promise((resolve, reject) => {
|
|
1217
1277
|
const timer = setTimeout(() => {
|
|
@@ -1237,7 +1297,7 @@ var ModelTreeModule = class {
|
|
|
1237
1297
|
return this.requestNodes(options).then((response) => buildTree(response.nodes, response.rootNodeIds));
|
|
1238
1298
|
}
|
|
1239
1299
|
requestNodes(options) {
|
|
1240
|
-
const requestId =
|
|
1300
|
+
const requestId = createRequestId4("tree_nodes");
|
|
1241
1301
|
const timeoutMs = this.resolveTimeoutMs(options);
|
|
1242
1302
|
return new Promise((resolve, reject) => {
|
|
1243
1303
|
const timer = setTimeout(() => {
|
|
@@ -1289,7 +1349,7 @@ var ModelTreeModule = class {
|
|
|
1289
1349
|
};
|
|
1290
1350
|
|
|
1291
1351
|
// src/modules/markup.module.ts
|
|
1292
|
-
function
|
|
1352
|
+
function createRequestId5(prefix) {
|
|
1293
1353
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1294
1354
|
}
|
|
1295
1355
|
var MarkupModule = class {
|
|
@@ -1343,7 +1403,7 @@ var MarkupModule = class {
|
|
|
1343
1403
|
}
|
|
1344
1404
|
getList(options) {
|
|
1345
1405
|
var _a;
|
|
1346
|
-
const requestId =
|
|
1406
|
+
const requestId = createRequestId5("markup-list");
|
|
1347
1407
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1348
1408
|
return new Promise((resolve, reject) => {
|
|
1349
1409
|
const timer = setTimeout(() => {
|
|
@@ -1361,7 +1421,7 @@ var MarkupModule = class {
|
|
|
1361
1421
|
}
|
|
1362
1422
|
runRequest(prefix, messageType, eventName, options) {
|
|
1363
1423
|
var _a;
|
|
1364
|
-
const requestId =
|
|
1424
|
+
const requestId = createRequestId5(prefix);
|
|
1365
1425
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1366
1426
|
return new Promise((resolve, reject) => {
|
|
1367
1427
|
const timer = setTimeout(() => {
|
|
@@ -1407,7 +1467,7 @@ function createObjectPropertiesError(message, errorStatus) {
|
|
|
1407
1467
|
error.errorStatus = errorStatus;
|
|
1408
1468
|
return error;
|
|
1409
1469
|
}
|
|
1410
|
-
function
|
|
1470
|
+
function createRequestId6(prefix) {
|
|
1411
1471
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1412
1472
|
}
|
|
1413
1473
|
function normalizeNodeIds(nodeIds) {
|
|
@@ -1425,7 +1485,7 @@ var ObjectPropertiesModule = class {
|
|
|
1425
1485
|
getByNodeIds(nodeIds, options) {
|
|
1426
1486
|
var _a;
|
|
1427
1487
|
const normalizedNodeIds = normalizeNodeIds(nodeIds);
|
|
1428
|
-
const requestId =
|
|
1488
|
+
const requestId = createRequestId6("object_properties");
|
|
1429
1489
|
if (normalizedNodeIds.length === 0) {
|
|
1430
1490
|
return Promise.resolve({
|
|
1431
1491
|
requestId,
|
|
@@ -1538,6 +1598,30 @@ var Viewer3D = class {
|
|
|
1538
1598
|
});
|
|
1539
1599
|
break;
|
|
1540
1600
|
}
|
|
1601
|
+
case "viewer-node-locked-state" /* NODE_LOCKED_STATE */: {
|
|
1602
|
+
const payload = data.payload;
|
|
1603
|
+
if (!payload) break;
|
|
1604
|
+
this._emit("node:locked-state", {
|
|
1605
|
+
requestId: payload.requestId ? String(payload.requestId) : void 0,
|
|
1606
|
+
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|
|
1607
|
+
treeNodeIds: Array.isArray(payload.treeNodeIds) ? payload.treeNodeIds.map(String) : [],
|
|
1608
|
+
renderedNodeIds: Array.isArray(payload.renderedNodeIds) ? payload.renderedNodeIds.map(String) : [],
|
|
1609
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1610
|
+
});
|
|
1611
|
+
break;
|
|
1612
|
+
}
|
|
1613
|
+
case "viewer-node-locked-state-change" /* NODE_LOCKED_STATE_CHANGE */: {
|
|
1614
|
+
const payload = data.payload;
|
|
1615
|
+
if (!payload) break;
|
|
1616
|
+
this._emit("node:locked-state-change", {
|
|
1617
|
+
requestId: payload.requestId ? String(payload.requestId) : void 0,
|
|
1618
|
+
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|
|
1619
|
+
treeNodeIds: Array.isArray(payload.treeNodeIds) ? payload.treeNodeIds.map(String) : [],
|
|
1620
|
+
renderedNodeIds: Array.isArray(payload.renderedNodeIds) ? payload.renderedNodeIds.map(String) : [],
|
|
1621
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1622
|
+
});
|
|
1623
|
+
break;
|
|
1624
|
+
}
|
|
1541
1625
|
case "viewer-pan-change" /* PAN_CHANGE */:
|
|
1542
1626
|
this._emit("interaction:pan-change", {
|
|
1543
1627
|
enabled: Boolean((_a = data.payload) == null ? void 0 : _a.enabled)
|
package/dist/index.mjs
CHANGED
|
@@ -234,14 +234,74 @@ var InteractionModule = class {
|
|
|
234
234
|
};
|
|
235
235
|
|
|
236
236
|
// src/modules/node.module.ts
|
|
237
|
+
function createRequestId2(prefix) {
|
|
238
|
+
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
239
|
+
}
|
|
240
|
+
function normalizeIds(values) {
|
|
241
|
+
if (!values) return void 0;
|
|
242
|
+
const normalized = Array.from(
|
|
243
|
+
new Set(
|
|
244
|
+
values.map((value) => String(value).trim()).filter((value) => value !== "")
|
|
245
|
+
)
|
|
246
|
+
);
|
|
247
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
248
|
+
}
|
|
237
249
|
var NodeModule = class {
|
|
238
250
|
constructor(viewer) {
|
|
239
251
|
this.viewer = viewer;
|
|
240
252
|
this.on = {
|
|
241
253
|
// SDK no longer supports first-node-only select events; listen to selectionChange for the full node list.
|
|
242
|
-
selectionChange: (cb) => this.viewer._on("node:selection-change", cb)
|
|
254
|
+
selectionChange: (cb) => this.viewer._on("node:selection-change", cb),
|
|
255
|
+
lockedStateChange: (cb) => this.viewer._on("node:locked-state-change", cb)
|
|
243
256
|
};
|
|
244
257
|
}
|
|
258
|
+
syncLockedState(input, options) {
|
|
259
|
+
var _a;
|
|
260
|
+
const requestId = createRequestId2("locked_state_sync");
|
|
261
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
262
|
+
return new Promise((resolve, reject) => {
|
|
263
|
+
const timer = setTimeout(() => {
|
|
264
|
+
off();
|
|
265
|
+
reject(new Error("Timeout while syncing locked state with viewer"));
|
|
266
|
+
}, timeoutMs);
|
|
267
|
+
const off = this.viewer._on("node:locked-state", (payload2) => {
|
|
268
|
+
if (payload2.requestId !== requestId) return;
|
|
269
|
+
clearTimeout(timer);
|
|
270
|
+
off();
|
|
271
|
+
resolve(payload2);
|
|
272
|
+
});
|
|
273
|
+
const payload = {
|
|
274
|
+
requestId,
|
|
275
|
+
persistentIds: normalizeIds(input.persistentIds),
|
|
276
|
+
treeNodeIds: normalizeIds(input.treeNodeIds)
|
|
277
|
+
};
|
|
278
|
+
this.viewer.postToViewer(
|
|
279
|
+
"viewer-node-sync-locked-state" /* NODE_SYNC_LOCKED_STATE */,
|
|
280
|
+
payload
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
getLockedState(options) {
|
|
285
|
+
var _a;
|
|
286
|
+
const requestId = createRequestId2("locked_state_get");
|
|
287
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
288
|
+
return new Promise((resolve, reject) => {
|
|
289
|
+
const timer = setTimeout(() => {
|
|
290
|
+
off();
|
|
291
|
+
reject(new Error("Timeout while getting locked state from viewer"));
|
|
292
|
+
}, timeoutMs);
|
|
293
|
+
const off = this.viewer._on("node:locked-state", (payload) => {
|
|
294
|
+
if (payload.requestId !== requestId) return;
|
|
295
|
+
clearTimeout(timer);
|
|
296
|
+
off();
|
|
297
|
+
resolve(payload);
|
|
298
|
+
});
|
|
299
|
+
this.viewer.postToViewer(
|
|
300
|
+
"viewer-node-get-locked-state" /* NODE_GET_LOCKED_STATE */,
|
|
301
|
+
{ requestId }
|
|
302
|
+
);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
245
305
|
};
|
|
246
306
|
|
|
247
307
|
// src/modules/files.module.ts
|
|
@@ -807,7 +867,7 @@ var FilesModule = class {
|
|
|
807
867
|
};
|
|
808
868
|
|
|
809
869
|
// src/modules/toolbar.module.ts
|
|
810
|
-
function
|
|
870
|
+
function createRequestId3(prefix) {
|
|
811
871
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
812
872
|
}
|
|
813
873
|
var ALL_3D_TOOLBAR_OPERATORS = [
|
|
@@ -965,7 +1025,7 @@ var ToolbarModule = class {
|
|
|
965
1025
|
}
|
|
966
1026
|
getSheets(options) {
|
|
967
1027
|
var _a;
|
|
968
|
-
const requestId =
|
|
1028
|
+
const requestId = createRequestId3("sheets");
|
|
969
1029
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
970
1030
|
return new Promise((resolve, reject) => {
|
|
971
1031
|
const timer = setTimeout(() => {
|
|
@@ -983,7 +1043,7 @@ var ToolbarModule = class {
|
|
|
983
1043
|
}
|
|
984
1044
|
getObjectProperties(options) {
|
|
985
1045
|
var _a;
|
|
986
|
-
const requestId =
|
|
1046
|
+
const requestId = createRequestId3("object_properties");
|
|
987
1047
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
988
1048
|
return new Promise((resolve, reject) => {
|
|
989
1049
|
var _a2;
|
|
@@ -1005,7 +1065,7 @@ var ToolbarModule = class {
|
|
|
1005
1065
|
}
|
|
1006
1066
|
getLinkedObjects(options) {
|
|
1007
1067
|
var _a;
|
|
1008
|
-
const requestId =
|
|
1068
|
+
const requestId = createRequestId3("linked_objects");
|
|
1009
1069
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1010
1070
|
return new Promise((resolve, reject) => {
|
|
1011
1071
|
const timer = setTimeout(() => {
|
|
@@ -1023,7 +1083,7 @@ var ToolbarModule = class {
|
|
|
1023
1083
|
}
|
|
1024
1084
|
getStatesObjects(options) {
|
|
1025
1085
|
var _a;
|
|
1026
|
-
const requestId =
|
|
1086
|
+
const requestId = createRequestId3("states_objects");
|
|
1027
1087
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1028
1088
|
return new Promise((resolve, reject) => {
|
|
1029
1089
|
const timer = setTimeout(() => {
|
|
@@ -1111,7 +1171,7 @@ var ToolbarModule = class {
|
|
|
1111
1171
|
};
|
|
1112
1172
|
|
|
1113
1173
|
// src/modules/model-tree.module.ts
|
|
1114
|
-
function
|
|
1174
|
+
function createRequestId4(prefix) {
|
|
1115
1175
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1116
1176
|
}
|
|
1117
1177
|
function buildTree(nodes, rootNodeIds) {
|
|
@@ -1185,7 +1245,7 @@ var ModelTreeModule = class {
|
|
|
1185
1245
|
this.setNodeVisibility(nodeIds, true);
|
|
1186
1246
|
}
|
|
1187
1247
|
getNodeIds(options) {
|
|
1188
|
-
const requestId =
|
|
1248
|
+
const requestId = createRequestId4("tree");
|
|
1189
1249
|
const timeoutMs = this.resolveTimeoutMs(options);
|
|
1190
1250
|
return new Promise((resolve, reject) => {
|
|
1191
1251
|
const timer = setTimeout(() => {
|
|
@@ -1211,7 +1271,7 @@ var ModelTreeModule = class {
|
|
|
1211
1271
|
return this.requestNodes(options).then((response) => buildTree(response.nodes, response.rootNodeIds));
|
|
1212
1272
|
}
|
|
1213
1273
|
requestNodes(options) {
|
|
1214
|
-
const requestId =
|
|
1274
|
+
const requestId = createRequestId4("tree_nodes");
|
|
1215
1275
|
const timeoutMs = this.resolveTimeoutMs(options);
|
|
1216
1276
|
return new Promise((resolve, reject) => {
|
|
1217
1277
|
const timer = setTimeout(() => {
|
|
@@ -1263,7 +1323,7 @@ var ModelTreeModule = class {
|
|
|
1263
1323
|
};
|
|
1264
1324
|
|
|
1265
1325
|
// src/modules/markup.module.ts
|
|
1266
|
-
function
|
|
1326
|
+
function createRequestId5(prefix) {
|
|
1267
1327
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1268
1328
|
}
|
|
1269
1329
|
var MarkupModule = class {
|
|
@@ -1317,7 +1377,7 @@ var MarkupModule = class {
|
|
|
1317
1377
|
}
|
|
1318
1378
|
getList(options) {
|
|
1319
1379
|
var _a;
|
|
1320
|
-
const requestId =
|
|
1380
|
+
const requestId = createRequestId5("markup-list");
|
|
1321
1381
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1322
1382
|
return new Promise((resolve, reject) => {
|
|
1323
1383
|
const timer = setTimeout(() => {
|
|
@@ -1335,7 +1395,7 @@ var MarkupModule = class {
|
|
|
1335
1395
|
}
|
|
1336
1396
|
runRequest(prefix, messageType, eventName, options) {
|
|
1337
1397
|
var _a;
|
|
1338
|
-
const requestId =
|
|
1398
|
+
const requestId = createRequestId5(prefix);
|
|
1339
1399
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1340
1400
|
return new Promise((resolve, reject) => {
|
|
1341
1401
|
const timer = setTimeout(() => {
|
|
@@ -1381,7 +1441,7 @@ function createObjectPropertiesError(message, errorStatus) {
|
|
|
1381
1441
|
error.errorStatus = errorStatus;
|
|
1382
1442
|
return error;
|
|
1383
1443
|
}
|
|
1384
|
-
function
|
|
1444
|
+
function createRequestId6(prefix) {
|
|
1385
1445
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1386
1446
|
}
|
|
1387
1447
|
function normalizeNodeIds(nodeIds) {
|
|
@@ -1399,7 +1459,7 @@ var ObjectPropertiesModule = class {
|
|
|
1399
1459
|
getByNodeIds(nodeIds, options) {
|
|
1400
1460
|
var _a;
|
|
1401
1461
|
const normalizedNodeIds = normalizeNodeIds(nodeIds);
|
|
1402
|
-
const requestId =
|
|
1462
|
+
const requestId = createRequestId6("object_properties");
|
|
1403
1463
|
if (normalizedNodeIds.length === 0) {
|
|
1404
1464
|
return Promise.resolve({
|
|
1405
1465
|
requestId,
|
|
@@ -1512,6 +1572,30 @@ var Viewer3D = class {
|
|
|
1512
1572
|
});
|
|
1513
1573
|
break;
|
|
1514
1574
|
}
|
|
1575
|
+
case "viewer-node-locked-state" /* NODE_LOCKED_STATE */: {
|
|
1576
|
+
const payload = data.payload;
|
|
1577
|
+
if (!payload) break;
|
|
1578
|
+
this._emit("node:locked-state", {
|
|
1579
|
+
requestId: payload.requestId ? String(payload.requestId) : void 0,
|
|
1580
|
+
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|
|
1581
|
+
treeNodeIds: Array.isArray(payload.treeNodeIds) ? payload.treeNodeIds.map(String) : [],
|
|
1582
|
+
renderedNodeIds: Array.isArray(payload.renderedNodeIds) ? payload.renderedNodeIds.map(String) : [],
|
|
1583
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1584
|
+
});
|
|
1585
|
+
break;
|
|
1586
|
+
}
|
|
1587
|
+
case "viewer-node-locked-state-change" /* NODE_LOCKED_STATE_CHANGE */: {
|
|
1588
|
+
const payload = data.payload;
|
|
1589
|
+
if (!payload) break;
|
|
1590
|
+
this._emit("node:locked-state-change", {
|
|
1591
|
+
requestId: payload.requestId ? String(payload.requestId) : void 0,
|
|
1592
|
+
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|
|
1593
|
+
treeNodeIds: Array.isArray(payload.treeNodeIds) ? payload.treeNodeIds.map(String) : [],
|
|
1594
|
+
renderedNodeIds: Array.isArray(payload.renderedNodeIds) ? payload.renderedNodeIds.map(String) : [],
|
|
1595
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1596
|
+
});
|
|
1597
|
+
break;
|
|
1598
|
+
}
|
|
1515
1599
|
case "viewer-pan-change" /* PAN_CHANGE */:
|
|
1516
1600
|
this._emit("interaction:pan-change", {
|
|
1517
1601
|
enabled: Boolean((_a = data.payload) == null ? void 0 : _a.enabled)
|