3dviewer-sdk 1.0.15 → 1.0.16
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 +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/index.js +110 -13
- package/dist/index.mjs +110 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -36,6 +36,8 @@ declare enum ViewerMessageType {
|
|
|
36
36
|
TREE_SELECT_NODE = "viewer-tree-select-node",
|
|
37
37
|
TREE_GET_NODE_IDS = "viewer-tree-get-node-ids",
|
|
38
38
|
TREE_NODE_IDS = "viewer-tree-node-ids",
|
|
39
|
+
TREE_GET_NODES = "viewer-tree-get-nodes",
|
|
40
|
+
TREE_NODES = "viewer-tree-nodes",
|
|
39
41
|
PDF_PLAN_MODE = "viewer-pdf-plan-mode",
|
|
40
42
|
PDF_DOCUMENT_MODE = "viewer-pdf-document-mode",
|
|
41
43
|
PDF_FIRST_PAGE = "viewer-pdf-first-page",
|
|
@@ -91,6 +93,19 @@ type StateObjectItem = {
|
|
|
91
93
|
type: string;
|
|
92
94
|
};
|
|
93
95
|
};
|
|
96
|
+
type TreeNodeItem = {
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
type: number;
|
|
100
|
+
parent?: string;
|
|
101
|
+
childs?: string[];
|
|
102
|
+
modelFileId?: string;
|
|
103
|
+
persistentId?: string;
|
|
104
|
+
categoryName?: string;
|
|
105
|
+
familyName?: string;
|
|
106
|
+
typeName?: string;
|
|
107
|
+
isRealNode: boolean;
|
|
108
|
+
};
|
|
94
109
|
type PdfModeEventPayload = {
|
|
95
110
|
mode: "plan" | "document";
|
|
96
111
|
timestamp: number;
|
|
@@ -127,6 +142,12 @@ type ViewerEventMap = {
|
|
|
127
142
|
nodeIds: string[];
|
|
128
143
|
timestamp: number;
|
|
129
144
|
};
|
|
145
|
+
"modelTree:nodes": {
|
|
146
|
+
requestId: string;
|
|
147
|
+
nodes: TreeNodeItem[];
|
|
148
|
+
rootNodeIds?: string[];
|
|
149
|
+
timestamp: number;
|
|
150
|
+
};
|
|
130
151
|
"sheets:list": {
|
|
131
152
|
requestId: string;
|
|
132
153
|
sheets: {
|
|
@@ -237,8 +258,7 @@ declare class InteractionModule {
|
|
|
237
258
|
}) => void) => () => void;
|
|
238
259
|
};
|
|
239
260
|
constructor(viewer: Viewer3D);
|
|
240
|
-
|
|
241
|
-
disablePan(): void;
|
|
261
|
+
pan(): void;
|
|
242
262
|
select(): void;
|
|
243
263
|
areaSelect(): void;
|
|
244
264
|
orbit(): void;
|
|
@@ -476,16 +496,30 @@ declare class ToolbarModule {
|
|
|
476
496
|
private postStatesObjectsGetList;
|
|
477
497
|
}
|
|
478
498
|
|
|
479
|
-
type
|
|
499
|
+
type ModelTreeRequestOptions = {
|
|
480
500
|
onlyRealNodes?: boolean;
|
|
481
501
|
timeoutMs?: number;
|
|
482
502
|
};
|
|
503
|
+
type GetNodeIdsOptions = ModelTreeRequestOptions;
|
|
504
|
+
type GetNodesOptions = ModelTreeRequestOptions;
|
|
505
|
+
type ModelTreeNode = TreeNodeItem;
|
|
506
|
+
type ModelTreeHierarchyNode = ModelTreeNode & {
|
|
507
|
+
children: ModelTreeHierarchyNode[];
|
|
508
|
+
};
|
|
483
509
|
declare class ModelTreeModule {
|
|
484
510
|
private viewer;
|
|
485
511
|
constructor(viewer: Viewer3D);
|
|
486
512
|
open(): void;
|
|
487
513
|
selectNode(nodeId: string | number): void;
|
|
488
514
|
getNodeIds(options?: GetNodeIdsOptions): Promise<string[]>;
|
|
515
|
+
getNodes(options?: GetNodesOptions): Promise<ModelTreeNode[]>;
|
|
516
|
+
getTree(options?: GetNodesOptions): Promise<ModelTreeHierarchyNode[]>;
|
|
517
|
+
private requestNodes;
|
|
518
|
+
private resolveTimeoutMs;
|
|
519
|
+
private postPanelOpen;
|
|
520
|
+
private postTreeSelectNode;
|
|
521
|
+
private postTreeGetNodeIds;
|
|
522
|
+
private postTreeGetNodes;
|
|
489
523
|
}
|
|
490
524
|
|
|
491
525
|
type MarkupRequestOptions = {
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ declare enum ViewerMessageType {
|
|
|
36
36
|
TREE_SELECT_NODE = "viewer-tree-select-node",
|
|
37
37
|
TREE_GET_NODE_IDS = "viewer-tree-get-node-ids",
|
|
38
38
|
TREE_NODE_IDS = "viewer-tree-node-ids",
|
|
39
|
+
TREE_GET_NODES = "viewer-tree-get-nodes",
|
|
40
|
+
TREE_NODES = "viewer-tree-nodes",
|
|
39
41
|
PDF_PLAN_MODE = "viewer-pdf-plan-mode",
|
|
40
42
|
PDF_DOCUMENT_MODE = "viewer-pdf-document-mode",
|
|
41
43
|
PDF_FIRST_PAGE = "viewer-pdf-first-page",
|
|
@@ -91,6 +93,19 @@ type StateObjectItem = {
|
|
|
91
93
|
type: string;
|
|
92
94
|
};
|
|
93
95
|
};
|
|
96
|
+
type TreeNodeItem = {
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
type: number;
|
|
100
|
+
parent?: string;
|
|
101
|
+
childs?: string[];
|
|
102
|
+
modelFileId?: string;
|
|
103
|
+
persistentId?: string;
|
|
104
|
+
categoryName?: string;
|
|
105
|
+
familyName?: string;
|
|
106
|
+
typeName?: string;
|
|
107
|
+
isRealNode: boolean;
|
|
108
|
+
};
|
|
94
109
|
type PdfModeEventPayload = {
|
|
95
110
|
mode: "plan" | "document";
|
|
96
111
|
timestamp: number;
|
|
@@ -127,6 +142,12 @@ type ViewerEventMap = {
|
|
|
127
142
|
nodeIds: string[];
|
|
128
143
|
timestamp: number;
|
|
129
144
|
};
|
|
145
|
+
"modelTree:nodes": {
|
|
146
|
+
requestId: string;
|
|
147
|
+
nodes: TreeNodeItem[];
|
|
148
|
+
rootNodeIds?: string[];
|
|
149
|
+
timestamp: number;
|
|
150
|
+
};
|
|
130
151
|
"sheets:list": {
|
|
131
152
|
requestId: string;
|
|
132
153
|
sheets: {
|
|
@@ -237,8 +258,7 @@ declare class InteractionModule {
|
|
|
237
258
|
}) => void) => () => void;
|
|
238
259
|
};
|
|
239
260
|
constructor(viewer: Viewer3D);
|
|
240
|
-
|
|
241
|
-
disablePan(): void;
|
|
261
|
+
pan(): void;
|
|
242
262
|
select(): void;
|
|
243
263
|
areaSelect(): void;
|
|
244
264
|
orbit(): void;
|
|
@@ -476,16 +496,30 @@ declare class ToolbarModule {
|
|
|
476
496
|
private postStatesObjectsGetList;
|
|
477
497
|
}
|
|
478
498
|
|
|
479
|
-
type
|
|
499
|
+
type ModelTreeRequestOptions = {
|
|
480
500
|
onlyRealNodes?: boolean;
|
|
481
501
|
timeoutMs?: number;
|
|
482
502
|
};
|
|
503
|
+
type GetNodeIdsOptions = ModelTreeRequestOptions;
|
|
504
|
+
type GetNodesOptions = ModelTreeRequestOptions;
|
|
505
|
+
type ModelTreeNode = TreeNodeItem;
|
|
506
|
+
type ModelTreeHierarchyNode = ModelTreeNode & {
|
|
507
|
+
children: ModelTreeHierarchyNode[];
|
|
508
|
+
};
|
|
483
509
|
declare class ModelTreeModule {
|
|
484
510
|
private viewer;
|
|
485
511
|
constructor(viewer: Viewer3D);
|
|
486
512
|
open(): void;
|
|
487
513
|
selectNode(nodeId: string | number): void;
|
|
488
514
|
getNodeIds(options?: GetNodeIdsOptions): Promise<string[]>;
|
|
515
|
+
getNodes(options?: GetNodesOptions): Promise<ModelTreeNode[]>;
|
|
516
|
+
getTree(options?: GetNodesOptions): Promise<ModelTreeHierarchyNode[]>;
|
|
517
|
+
private requestNodes;
|
|
518
|
+
private resolveTimeoutMs;
|
|
519
|
+
private postPanelOpen;
|
|
520
|
+
private postTreeSelectNode;
|
|
521
|
+
private postTreeGetNodeIds;
|
|
522
|
+
private postTreeGetNodes;
|
|
489
523
|
}
|
|
490
524
|
|
|
491
525
|
type MarkupRequestOptions = {
|
package/dist/index.js
CHANGED
|
@@ -80,11 +80,8 @@ var InteractionModule = class {
|
|
|
80
80
|
panChange: (cb) => this.viewer._on("interaction:pan-change", cb)
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
this.viewer.postToViewer("viewer-pan-toggle" /* PAN_TOGGLE
|
|
85
|
-
}
|
|
86
|
-
disablePan() {
|
|
87
|
-
this.viewer.postToViewer("viewer-pan-toggle" /* PAN_TOGGLE */, { enabled: false });
|
|
83
|
+
pan() {
|
|
84
|
+
this.viewer.postToViewer("viewer-pan-toggle" /* PAN_TOGGLE */);
|
|
88
85
|
}
|
|
89
86
|
select() {
|
|
90
87
|
this.viewer.postToViewer("viewer-select" /* SELECT */);
|
|
@@ -891,28 +888,56 @@ var ToolbarModule = class {
|
|
|
891
888
|
};
|
|
892
889
|
|
|
893
890
|
// src/modules/model-tree.module.ts
|
|
894
|
-
function createRequestId2() {
|
|
895
|
-
return
|
|
891
|
+
function createRequestId2(prefix) {
|
|
892
|
+
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
893
|
+
}
|
|
894
|
+
function buildTree(nodes, rootNodeIds) {
|
|
895
|
+
const uniqueNodes = Array.from(
|
|
896
|
+
nodes.reduce((map, node) => {
|
|
897
|
+
map.set(node.id, node);
|
|
898
|
+
return map;
|
|
899
|
+
}, /* @__PURE__ */ new Map()),
|
|
900
|
+
([, node]) => node
|
|
901
|
+
);
|
|
902
|
+
const hierarchyMap = new Map(
|
|
903
|
+
uniqueNodes.map((node) => [node.id, { ...node, children: [] }])
|
|
904
|
+
);
|
|
905
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
906
|
+
uniqueNodes.forEach((node) => {
|
|
907
|
+
var _a;
|
|
908
|
+
if (!node.parent) return;
|
|
909
|
+
const current = (_a = childrenByParent.get(node.parent)) != null ? _a : [];
|
|
910
|
+
current.push(node.id);
|
|
911
|
+
childrenByParent.set(node.parent, current);
|
|
912
|
+
});
|
|
913
|
+
hierarchyMap.forEach((node) => {
|
|
914
|
+
var _a, _b;
|
|
915
|
+
const childIdsFromNode = ((_a = node.childs) != null ? _a : []).filter((childId) => hierarchyMap.has(childId));
|
|
916
|
+
const fallbackChildIds = (_b = childrenByParent.get(node.id)) != null ? _b : [];
|
|
917
|
+
const childIds = childIdsFromNode.length > 0 ? childIdsFromNode : fallbackChildIds;
|
|
918
|
+
node.children = Array.from(new Set(childIds)).map((childId) => hierarchyMap.get(childId)).filter((child) => Boolean(child));
|
|
919
|
+
});
|
|
920
|
+
const rootIds = Array.isArray(rootNodeIds) && rootNodeIds.length > 0 ? rootNodeIds.filter((id) => hierarchyMap.has(id)) : uniqueNodes.filter((node) => !node.parent || !hierarchyMap.has(node.parent)).map((node) => node.id);
|
|
921
|
+
return Array.from(new Set(rootIds)).map((id) => hierarchyMap.get(id)).filter((node) => Boolean(node));
|
|
896
922
|
}
|
|
897
923
|
var ModelTreeModule = class {
|
|
898
924
|
constructor(viewer) {
|
|
899
925
|
this.viewer = viewer;
|
|
900
926
|
}
|
|
901
927
|
open() {
|
|
902
|
-
this.
|
|
928
|
+
this.postPanelOpen({
|
|
903
929
|
panel: "model-tree",
|
|
904
930
|
format: "3d"
|
|
905
931
|
});
|
|
906
932
|
}
|
|
907
933
|
selectNode(nodeId) {
|
|
908
|
-
this.
|
|
934
|
+
this.postTreeSelectNode({
|
|
909
935
|
nodeId: String(nodeId)
|
|
910
936
|
});
|
|
911
937
|
}
|
|
912
938
|
getNodeIds(options) {
|
|
913
|
-
|
|
914
|
-
const
|
|
915
|
-
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
939
|
+
const requestId = createRequestId2("tree");
|
|
940
|
+
const timeoutMs = this.resolveTimeoutMs(options);
|
|
916
941
|
return new Promise((resolve, reject) => {
|
|
917
942
|
const timer = setTimeout(() => {
|
|
918
943
|
off();
|
|
@@ -924,12 +949,58 @@ var ModelTreeModule = class {
|
|
|
924
949
|
off();
|
|
925
950
|
resolve(payload.nodeIds);
|
|
926
951
|
});
|
|
927
|
-
this.
|
|
952
|
+
this.postTreeGetNodeIds({
|
|
928
953
|
requestId,
|
|
929
954
|
onlyRealNodes: (options == null ? void 0 : options.onlyRealNodes) !== false
|
|
930
955
|
});
|
|
931
956
|
});
|
|
932
957
|
}
|
|
958
|
+
getNodes(options) {
|
|
959
|
+
return this.requestNodes(options).then((response) => response.nodes);
|
|
960
|
+
}
|
|
961
|
+
getTree(options) {
|
|
962
|
+
return this.requestNodes(options).then((response) => buildTree(response.nodes, response.rootNodeIds));
|
|
963
|
+
}
|
|
964
|
+
requestNodes(options) {
|
|
965
|
+
const requestId = createRequestId2("tree_nodes");
|
|
966
|
+
const timeoutMs = this.resolveTimeoutMs(options);
|
|
967
|
+
return new Promise((resolve, reject) => {
|
|
968
|
+
const timer = setTimeout(() => {
|
|
969
|
+
off();
|
|
970
|
+
reject(new Error("Timeout while getting model tree nodes from viewer"));
|
|
971
|
+
}, timeoutMs);
|
|
972
|
+
const off = this.viewer._on("modelTree:nodes", (payload) => {
|
|
973
|
+
if (payload.requestId !== requestId) return;
|
|
974
|
+
clearTimeout(timer);
|
|
975
|
+
off();
|
|
976
|
+
resolve({
|
|
977
|
+
nodes: payload.nodes,
|
|
978
|
+
rootNodeIds: payload.rootNodeIds
|
|
979
|
+
});
|
|
980
|
+
});
|
|
981
|
+
this.postTreeGetNodes({
|
|
982
|
+
requestId,
|
|
983
|
+
// For backward compatibility, default includes helper/system nodes unless caller opts in.
|
|
984
|
+
onlyRealNodes: (options == null ? void 0 : options.onlyRealNodes) === true
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
resolveTimeoutMs(options) {
|
|
989
|
+
var _a;
|
|
990
|
+
return Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
991
|
+
}
|
|
992
|
+
postPanelOpen(payload) {
|
|
993
|
+
this.viewer.postToViewer("viewer-panel-open" /* PANEL_OPEN */, payload);
|
|
994
|
+
}
|
|
995
|
+
postTreeSelectNode(payload) {
|
|
996
|
+
this.viewer.postToViewer("viewer-tree-select-node" /* TREE_SELECT_NODE */, payload);
|
|
997
|
+
}
|
|
998
|
+
postTreeGetNodeIds(payload) {
|
|
999
|
+
this.viewer.postToViewer("viewer-tree-get-node-ids" /* TREE_GET_NODE_IDS */, payload);
|
|
1000
|
+
}
|
|
1001
|
+
postTreeGetNodes(payload) {
|
|
1002
|
+
this.viewer.postToViewer("viewer-tree-get-nodes" /* TREE_GET_NODES */, payload);
|
|
1003
|
+
}
|
|
933
1004
|
};
|
|
934
1005
|
|
|
935
1006
|
// src/modules/markup.module.ts
|
|
@@ -1131,6 +1202,32 @@ var Viewer3D = class {
|
|
|
1131
1202
|
});
|
|
1132
1203
|
break;
|
|
1133
1204
|
}
|
|
1205
|
+
case "viewer-tree-nodes" /* TREE_NODES */: {
|
|
1206
|
+
const payload = data.payload;
|
|
1207
|
+
if (!payload || !payload.requestId || !Array.isArray(payload.nodes)) break;
|
|
1208
|
+
this._emit("modelTree:nodes", {
|
|
1209
|
+
requestId: String(payload.requestId),
|
|
1210
|
+
nodes: payload.nodes.filter((node) => node && typeof node === "object").map((node) => {
|
|
1211
|
+
var _a2, _b2;
|
|
1212
|
+
return {
|
|
1213
|
+
id: String((_a2 = node.id) != null ? _a2 : ""),
|
|
1214
|
+
name: String((_b2 = node.name) != null ? _b2 : ""),
|
|
1215
|
+
type: Number(node.type) || 0,
|
|
1216
|
+
parent: node.parent ? String(node.parent) : void 0,
|
|
1217
|
+
childs: Array.isArray(node.childs) ? node.childs.map(String) : [],
|
|
1218
|
+
modelFileId: node.modelFileId ? String(node.modelFileId) : void 0,
|
|
1219
|
+
persistentId: node.persistentId ? String(node.persistentId) : void 0,
|
|
1220
|
+
categoryName: node.categoryName ? String(node.categoryName) : void 0,
|
|
1221
|
+
familyName: node.familyName ? String(node.familyName) : void 0,
|
|
1222
|
+
typeName: node.typeName ? String(node.typeName) : void 0,
|
|
1223
|
+
isRealNode: Boolean(node.isRealNode)
|
|
1224
|
+
};
|
|
1225
|
+
}),
|
|
1226
|
+
rootNodeIds: Array.isArray(payload.rootNodeIds) ? payload.rootNodeIds.map(String) : void 0,
|
|
1227
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1228
|
+
});
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1134
1231
|
case "viewer-sheets-list" /* SHEETS_LIST */: {
|
|
1135
1232
|
const payload = data.payload;
|
|
1136
1233
|
if (!payload || !payload.requestId || !Array.isArray(payload.sheets)) break;
|
package/dist/index.mjs
CHANGED
|
@@ -54,11 +54,8 @@ var InteractionModule = class {
|
|
|
54
54
|
panChange: (cb) => this.viewer._on("interaction:pan-change", cb)
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
this.viewer.postToViewer("viewer-pan-toggle" /* PAN_TOGGLE
|
|
59
|
-
}
|
|
60
|
-
disablePan() {
|
|
61
|
-
this.viewer.postToViewer("viewer-pan-toggle" /* PAN_TOGGLE */, { enabled: false });
|
|
57
|
+
pan() {
|
|
58
|
+
this.viewer.postToViewer("viewer-pan-toggle" /* PAN_TOGGLE */);
|
|
62
59
|
}
|
|
63
60
|
select() {
|
|
64
61
|
this.viewer.postToViewer("viewer-select" /* SELECT */);
|
|
@@ -865,28 +862,56 @@ var ToolbarModule = class {
|
|
|
865
862
|
};
|
|
866
863
|
|
|
867
864
|
// src/modules/model-tree.module.ts
|
|
868
|
-
function createRequestId2() {
|
|
869
|
-
return
|
|
865
|
+
function createRequestId2(prefix) {
|
|
866
|
+
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
867
|
+
}
|
|
868
|
+
function buildTree(nodes, rootNodeIds) {
|
|
869
|
+
const uniqueNodes = Array.from(
|
|
870
|
+
nodes.reduce((map, node) => {
|
|
871
|
+
map.set(node.id, node);
|
|
872
|
+
return map;
|
|
873
|
+
}, /* @__PURE__ */ new Map()),
|
|
874
|
+
([, node]) => node
|
|
875
|
+
);
|
|
876
|
+
const hierarchyMap = new Map(
|
|
877
|
+
uniqueNodes.map((node) => [node.id, { ...node, children: [] }])
|
|
878
|
+
);
|
|
879
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
880
|
+
uniqueNodes.forEach((node) => {
|
|
881
|
+
var _a;
|
|
882
|
+
if (!node.parent) return;
|
|
883
|
+
const current = (_a = childrenByParent.get(node.parent)) != null ? _a : [];
|
|
884
|
+
current.push(node.id);
|
|
885
|
+
childrenByParent.set(node.parent, current);
|
|
886
|
+
});
|
|
887
|
+
hierarchyMap.forEach((node) => {
|
|
888
|
+
var _a, _b;
|
|
889
|
+
const childIdsFromNode = ((_a = node.childs) != null ? _a : []).filter((childId) => hierarchyMap.has(childId));
|
|
890
|
+
const fallbackChildIds = (_b = childrenByParent.get(node.id)) != null ? _b : [];
|
|
891
|
+
const childIds = childIdsFromNode.length > 0 ? childIdsFromNode : fallbackChildIds;
|
|
892
|
+
node.children = Array.from(new Set(childIds)).map((childId) => hierarchyMap.get(childId)).filter((child) => Boolean(child));
|
|
893
|
+
});
|
|
894
|
+
const rootIds = Array.isArray(rootNodeIds) && rootNodeIds.length > 0 ? rootNodeIds.filter((id) => hierarchyMap.has(id)) : uniqueNodes.filter((node) => !node.parent || !hierarchyMap.has(node.parent)).map((node) => node.id);
|
|
895
|
+
return Array.from(new Set(rootIds)).map((id) => hierarchyMap.get(id)).filter((node) => Boolean(node));
|
|
870
896
|
}
|
|
871
897
|
var ModelTreeModule = class {
|
|
872
898
|
constructor(viewer) {
|
|
873
899
|
this.viewer = viewer;
|
|
874
900
|
}
|
|
875
901
|
open() {
|
|
876
|
-
this.
|
|
902
|
+
this.postPanelOpen({
|
|
877
903
|
panel: "model-tree",
|
|
878
904
|
format: "3d"
|
|
879
905
|
});
|
|
880
906
|
}
|
|
881
907
|
selectNode(nodeId) {
|
|
882
|
-
this.
|
|
908
|
+
this.postTreeSelectNode({
|
|
883
909
|
nodeId: String(nodeId)
|
|
884
910
|
});
|
|
885
911
|
}
|
|
886
912
|
getNodeIds(options) {
|
|
887
|
-
|
|
888
|
-
const
|
|
889
|
-
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
913
|
+
const requestId = createRequestId2("tree");
|
|
914
|
+
const timeoutMs = this.resolveTimeoutMs(options);
|
|
890
915
|
return new Promise((resolve, reject) => {
|
|
891
916
|
const timer = setTimeout(() => {
|
|
892
917
|
off();
|
|
@@ -898,12 +923,58 @@ var ModelTreeModule = class {
|
|
|
898
923
|
off();
|
|
899
924
|
resolve(payload.nodeIds);
|
|
900
925
|
});
|
|
901
|
-
this.
|
|
926
|
+
this.postTreeGetNodeIds({
|
|
902
927
|
requestId,
|
|
903
928
|
onlyRealNodes: (options == null ? void 0 : options.onlyRealNodes) !== false
|
|
904
929
|
});
|
|
905
930
|
});
|
|
906
931
|
}
|
|
932
|
+
getNodes(options) {
|
|
933
|
+
return this.requestNodes(options).then((response) => response.nodes);
|
|
934
|
+
}
|
|
935
|
+
getTree(options) {
|
|
936
|
+
return this.requestNodes(options).then((response) => buildTree(response.nodes, response.rootNodeIds));
|
|
937
|
+
}
|
|
938
|
+
requestNodes(options) {
|
|
939
|
+
const requestId = createRequestId2("tree_nodes");
|
|
940
|
+
const timeoutMs = this.resolveTimeoutMs(options);
|
|
941
|
+
return new Promise((resolve, reject) => {
|
|
942
|
+
const timer = setTimeout(() => {
|
|
943
|
+
off();
|
|
944
|
+
reject(new Error("Timeout while getting model tree nodes from viewer"));
|
|
945
|
+
}, timeoutMs);
|
|
946
|
+
const off = this.viewer._on("modelTree:nodes", (payload) => {
|
|
947
|
+
if (payload.requestId !== requestId) return;
|
|
948
|
+
clearTimeout(timer);
|
|
949
|
+
off();
|
|
950
|
+
resolve({
|
|
951
|
+
nodes: payload.nodes,
|
|
952
|
+
rootNodeIds: payload.rootNodeIds
|
|
953
|
+
});
|
|
954
|
+
});
|
|
955
|
+
this.postTreeGetNodes({
|
|
956
|
+
requestId,
|
|
957
|
+
// For backward compatibility, default includes helper/system nodes unless caller opts in.
|
|
958
|
+
onlyRealNodes: (options == null ? void 0 : options.onlyRealNodes) === true
|
|
959
|
+
});
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
resolveTimeoutMs(options) {
|
|
963
|
+
var _a;
|
|
964
|
+
return Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
965
|
+
}
|
|
966
|
+
postPanelOpen(payload) {
|
|
967
|
+
this.viewer.postToViewer("viewer-panel-open" /* PANEL_OPEN */, payload);
|
|
968
|
+
}
|
|
969
|
+
postTreeSelectNode(payload) {
|
|
970
|
+
this.viewer.postToViewer("viewer-tree-select-node" /* TREE_SELECT_NODE */, payload);
|
|
971
|
+
}
|
|
972
|
+
postTreeGetNodeIds(payload) {
|
|
973
|
+
this.viewer.postToViewer("viewer-tree-get-node-ids" /* TREE_GET_NODE_IDS */, payload);
|
|
974
|
+
}
|
|
975
|
+
postTreeGetNodes(payload) {
|
|
976
|
+
this.viewer.postToViewer("viewer-tree-get-nodes" /* TREE_GET_NODES */, payload);
|
|
977
|
+
}
|
|
907
978
|
};
|
|
908
979
|
|
|
909
980
|
// src/modules/markup.module.ts
|
|
@@ -1105,6 +1176,32 @@ var Viewer3D = class {
|
|
|
1105
1176
|
});
|
|
1106
1177
|
break;
|
|
1107
1178
|
}
|
|
1179
|
+
case "viewer-tree-nodes" /* TREE_NODES */: {
|
|
1180
|
+
const payload = data.payload;
|
|
1181
|
+
if (!payload || !payload.requestId || !Array.isArray(payload.nodes)) break;
|
|
1182
|
+
this._emit("modelTree:nodes", {
|
|
1183
|
+
requestId: String(payload.requestId),
|
|
1184
|
+
nodes: payload.nodes.filter((node) => node && typeof node === "object").map((node) => {
|
|
1185
|
+
var _a2, _b2;
|
|
1186
|
+
return {
|
|
1187
|
+
id: String((_a2 = node.id) != null ? _a2 : ""),
|
|
1188
|
+
name: String((_b2 = node.name) != null ? _b2 : ""),
|
|
1189
|
+
type: Number(node.type) || 0,
|
|
1190
|
+
parent: node.parent ? String(node.parent) : void 0,
|
|
1191
|
+
childs: Array.isArray(node.childs) ? node.childs.map(String) : [],
|
|
1192
|
+
modelFileId: node.modelFileId ? String(node.modelFileId) : void 0,
|
|
1193
|
+
persistentId: node.persistentId ? String(node.persistentId) : void 0,
|
|
1194
|
+
categoryName: node.categoryName ? String(node.categoryName) : void 0,
|
|
1195
|
+
familyName: node.familyName ? String(node.familyName) : void 0,
|
|
1196
|
+
typeName: node.typeName ? String(node.typeName) : void 0,
|
|
1197
|
+
isRealNode: Boolean(node.isRealNode)
|
|
1198
|
+
};
|
|
1199
|
+
}),
|
|
1200
|
+
rootNodeIds: Array.isArray(payload.rootNodeIds) ? payload.rootNodeIds.map(String) : void 0,
|
|
1201
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1202
|
+
});
|
|
1203
|
+
break;
|
|
1204
|
+
}
|
|
1108
1205
|
case "viewer-sheets-list" /* SHEETS_LIST */: {
|
|
1109
1206
|
const payload = data.payload;
|
|
1110
1207
|
if (!payload || !payload.requestId || !Array.isArray(payload.sheets)) break;
|