3dviewer-sdk 1.0.15 → 1.0.17
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/contracts/events.d.ts +97 -0
- package/dist/contracts/events.js +1 -0
- package/dist/contracts/messages.d.ts +159 -0
- package/dist/contracts/messages.js +50 -0
- package/dist/core/emitter.d.ts +7 -0
- package/dist/core/emitter.js +31 -0
- package/dist/index.d.mts +39 -5
- package/dist/index.d.ts +39 -5
- package/dist/index.js +110 -13
- package/dist/index.mjs +110 -13
- package/dist/modules/camera.module.d.ts +13 -0
- package/dist/modules/camera.module.js +18 -0
- package/dist/modules/files.module.d.ts +112 -0
- package/dist/modules/files.module.js +461 -0
- package/dist/modules/interaction.module.d.ts +28 -0
- package/dist/modules/interaction.module.js +63 -0
- package/dist/modules/language.module.d.ts +8 -0
- package/dist/modules/language.module.js +15 -0
- package/dist/modules/markup.module.d.ts +26 -0
- package/dist/modules/markup.module.js +96 -0
- package/dist/modules/model-tree.module.d.ts +12 -0
- package/dist/modules/model-tree.module.js +42 -0
- package/dist/modules/node.module.d.ts +11 -0
- package/dist/modules/node.module.js +6 -0
- package/dist/modules/toolbar.module.d.ts +93 -0
- package/dist/modules/toolbar.module.js +249 -0
- package/dist/viewer.d.ts +54 -0
- package/dist/viewer.js +290 -0
- package/package.json +1 -1
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Viewer3D } from "../viewer";
|
|
2
|
+
export declare class CameraModule {
|
|
3
|
+
private viewer;
|
|
4
|
+
on: {
|
|
5
|
+
home: (cb: (payload: {
|
|
6
|
+
timestamp: number;
|
|
7
|
+
}) => void) => () => void;
|
|
8
|
+
};
|
|
9
|
+
constructor(viewer: Viewer3D);
|
|
10
|
+
zoomIn(percent: number): void;
|
|
11
|
+
zoomOut(percent: number): void;
|
|
12
|
+
home(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ViewerMessageType } from "../contracts/messages";
|
|
2
|
+
export class CameraModule {
|
|
3
|
+
constructor(viewer) {
|
|
4
|
+
this.viewer = viewer;
|
|
5
|
+
this.on = {
|
|
6
|
+
home: (cb) => this.viewer._on("camera:home", cb),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
zoomIn(percent) {
|
|
10
|
+
this.viewer.postToViewer(ViewerMessageType.ZOOM, { action: "in", percent });
|
|
11
|
+
}
|
|
12
|
+
zoomOut(percent) {
|
|
13
|
+
this.viewer.postToViewer(ViewerMessageType.ZOOM, { action: "out", percent });
|
|
14
|
+
}
|
|
15
|
+
home() {
|
|
16
|
+
this.viewer.postToViewer(ViewerMessageType.HOME, {});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { LoadStatePayload, PreparedViewerData } from "../contracts/events";
|
|
2
|
+
import { Viewer3D } from "../viewer";
|
|
3
|
+
export declare type FilesConfig = {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
viewerPath?: string;
|
|
6
|
+
uploadPath?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type ConvertOptions = {
|
|
9
|
+
downloadUrl?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type ConvertV2Options = {
|
|
12
|
+
filename: string;
|
|
13
|
+
originalFilePath: string;
|
|
14
|
+
downloadUrl: string;
|
|
15
|
+
baseFileId: string;
|
|
16
|
+
baseMajorRev?: number;
|
|
17
|
+
baseMinorRev?: number;
|
|
18
|
+
overwrite?: boolean;
|
|
19
|
+
project?: string;
|
|
20
|
+
convertOptions?: Partial<StreamConvertOptions>;
|
|
21
|
+
};
|
|
22
|
+
export declare type FileInfoCheckInput = string | string[];
|
|
23
|
+
export declare type FileInfoCheckPayloadItem = {
|
|
24
|
+
baseFileId: string;
|
|
25
|
+
};
|
|
26
|
+
declare type StreamConvertOptions = {
|
|
27
|
+
convert3DModel: number;
|
|
28
|
+
convert2DSheet: number;
|
|
29
|
+
extractProperties: number;
|
|
30
|
+
childModels: number;
|
|
31
|
+
};
|
|
32
|
+
export declare class FilesModule {
|
|
33
|
+
private viewer;
|
|
34
|
+
on: {
|
|
35
|
+
state: (cb: (payload: LoadStatePayload) => void) => () => void;
|
|
36
|
+
uploadStart: (cb: (payload: {
|
|
37
|
+
fileName: string;
|
|
38
|
+
}) => void) => () => void;
|
|
39
|
+
uploadSuccess: (cb: (payload: {
|
|
40
|
+
fileName: string;
|
|
41
|
+
baseFileId: string;
|
|
42
|
+
}) => void) => () => void;
|
|
43
|
+
uploadError: (cb: (payload: {
|
|
44
|
+
fileName: string;
|
|
45
|
+
error: string;
|
|
46
|
+
}) => void) => () => void;
|
|
47
|
+
conversionStart: (cb: (payload: {
|
|
48
|
+
fileName: string;
|
|
49
|
+
}) => void) => () => void;
|
|
50
|
+
conversionSuccess: (cb: (payload: PreparedViewerData) => void) => () => void;
|
|
51
|
+
conversionError: (cb: (payload: {
|
|
52
|
+
fileName: string;
|
|
53
|
+
error: string;
|
|
54
|
+
}) => void) => () => void;
|
|
55
|
+
renderStart: (cb: (payload: {
|
|
56
|
+
url: string;
|
|
57
|
+
}) => void) => () => void;
|
|
58
|
+
renderSuccess: (cb: (payload: {
|
|
59
|
+
url: string;
|
|
60
|
+
}) => void) => () => void;
|
|
61
|
+
renderError: (cb: (payload: {
|
|
62
|
+
url?: string;
|
|
63
|
+
error: string;
|
|
64
|
+
}) => void) => () => void;
|
|
65
|
+
loadSuccess: (cb: (payload: PreparedViewerData) => void) => () => void;
|
|
66
|
+
loadError: (cb: (payload: {
|
|
67
|
+
error: string;
|
|
68
|
+
}) => void) => () => void;
|
|
69
|
+
};
|
|
70
|
+
private config;
|
|
71
|
+
private operationStartTime;
|
|
72
|
+
private state;
|
|
73
|
+
private lastUploadSession;
|
|
74
|
+
constructor(viewer: Viewer3D);
|
|
75
|
+
setConfig(next: FilesConfig): void;
|
|
76
|
+
getState(): LoadStatePayload;
|
|
77
|
+
upload(file?: File): Promise<{
|
|
78
|
+
fileName: string;
|
|
79
|
+
baseFileId: string;
|
|
80
|
+
}>;
|
|
81
|
+
convert(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
82
|
+
prepare(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
83
|
+
convertV2(options: ConvertV2Options): Promise<PreparedViewerData>;
|
|
84
|
+
checkFileInfo(baseFileIds: FileInfoCheckInput): Promise<unknown>;
|
|
85
|
+
open(input: PreparedViewerData | {
|
|
86
|
+
url: string;
|
|
87
|
+
}): void;
|
|
88
|
+
render(file?: File, options?: ConvertOptions): Promise<PreparedViewerData>;
|
|
89
|
+
private resolveFile;
|
|
90
|
+
private normalizeBaseUrl;
|
|
91
|
+
private resolveBaseUrl;
|
|
92
|
+
private resolveViewerPath;
|
|
93
|
+
private resolveViewerOrigin;
|
|
94
|
+
private resolveHostConversion;
|
|
95
|
+
private getUploadPath;
|
|
96
|
+
private fileSignature;
|
|
97
|
+
private createBaseFileId;
|
|
98
|
+
private createUploadSession;
|
|
99
|
+
private getUploadSessionForFile;
|
|
100
|
+
private uploadInternal;
|
|
101
|
+
private buildCachePayload;
|
|
102
|
+
private buildConvertV2Payload;
|
|
103
|
+
private buildFileInfoPayload;
|
|
104
|
+
private cacheFile;
|
|
105
|
+
private cacheFileV2;
|
|
106
|
+
private convertInternal;
|
|
107
|
+
private convertV2Internal;
|
|
108
|
+
private updateState;
|
|
109
|
+
private withOperation;
|
|
110
|
+
private toErrorMessage;
|
|
111
|
+
}
|
|
112
|
+
export {};
|