3dviewer-sdk 1.0.22 → 1.0.24

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 CHANGED
@@ -40,6 +40,7 @@ declare enum ViewerMessageType {
40
40
  STATES_OBJECTS_GET_LIST = "viewer-states-objects-get-list",
41
41
  STATES_OBJECTS_LIST = "viewer-states-objects-list",
42
42
  TREE_SELECT_NODE = "viewer-tree-select-node",
43
+ TREE_SET_NODE_VISIBILITY = "viewer-tree-set-node-visibility",
43
44
  TREE_GET_NODE_IDS = "viewer-tree-get-node-ids",
44
45
  TREE_NODE_IDS = "viewer-tree-node-ids",
45
46
  TREE_GET_NODES = "viewer-tree-get-nodes",
@@ -539,6 +540,9 @@ declare class ModelTreeModule {
539
540
  constructor(viewer: Viewer3D);
540
541
  open(): void;
541
542
  selectNode(nodeId: string | number): void;
543
+ setNodeVisibility(nodeIds: Array<string | number>, visible: boolean): void;
544
+ hideNode(nodeIds: Array<string | number>): void;
545
+ showNode(nodeIds: Array<string | number>): void;
542
546
  getNodeIds(options?: GetNodeIdsOptions): Promise<string[]>;
543
547
  getNodes(options?: GetNodesOptions): Promise<ModelTreeNode[]>;
544
548
  getTree(options?: GetNodesOptions): Promise<ModelTreeHierarchyNode[]>;
@@ -546,6 +550,7 @@ declare class ModelTreeModule {
546
550
  private resolveTimeoutMs;
547
551
  private postPanelOpen;
548
552
  private postTreeSelectNode;
553
+ private postTreeSetNodeVisibility;
549
554
  private postTreeGetNodeIds;
550
555
  private postTreeGetNodes;
551
556
  }
@@ -592,6 +597,7 @@ type ObjectPropertiesGetCurrentOptions = ObjectPropertiesWatchOptions & {
592
597
  type ObjectPropertiesChangedEvent = ObjectPropertiesChangedPayload;
593
598
  declare class ObjectPropertiesModule {
594
599
  private viewer;
600
+ private pendingGetCurrent;
595
601
  on: {
596
602
  change: (cb: (payload: ObjectPropertiesChangedEvent) => void) => () => void;
597
603
  };
package/dist/index.d.ts CHANGED
@@ -40,6 +40,7 @@ declare enum ViewerMessageType {
40
40
  STATES_OBJECTS_GET_LIST = "viewer-states-objects-get-list",
41
41
  STATES_OBJECTS_LIST = "viewer-states-objects-list",
42
42
  TREE_SELECT_NODE = "viewer-tree-select-node",
43
+ TREE_SET_NODE_VISIBILITY = "viewer-tree-set-node-visibility",
43
44
  TREE_GET_NODE_IDS = "viewer-tree-get-node-ids",
44
45
  TREE_NODE_IDS = "viewer-tree-node-ids",
45
46
  TREE_GET_NODES = "viewer-tree-get-nodes",
@@ -539,6 +540,9 @@ declare class ModelTreeModule {
539
540
  constructor(viewer: Viewer3D);
540
541
  open(): void;
541
542
  selectNode(nodeId: string | number): void;
543
+ setNodeVisibility(nodeIds: Array<string | number>, visible: boolean): void;
544
+ hideNode(nodeIds: Array<string | number>): void;
545
+ showNode(nodeIds: Array<string | number>): void;
542
546
  getNodeIds(options?: GetNodeIdsOptions): Promise<string[]>;
543
547
  getNodes(options?: GetNodesOptions): Promise<ModelTreeNode[]>;
544
548
  getTree(options?: GetNodesOptions): Promise<ModelTreeHierarchyNode[]>;
@@ -546,6 +550,7 @@ declare class ModelTreeModule {
546
550
  private resolveTimeoutMs;
547
551
  private postPanelOpen;
548
552
  private postTreeSelectNode;
553
+ private postTreeSetNodeVisibility;
549
554
  private postTreeGetNodeIds;
550
555
  private postTreeGetNodes;
551
556
  }
@@ -592,6 +597,7 @@ type ObjectPropertiesGetCurrentOptions = ObjectPropertiesWatchOptions & {
592
597
  type ObjectPropertiesChangedEvent = ObjectPropertiesChangedPayload;
593
598
  declare class ObjectPropertiesModule {
594
599
  private viewer;
600
+ private pendingGetCurrent;
595
601
  on: {
596
602
  change: (cb: (payload: ObjectPropertiesChangedEvent) => void) => () => void;
597
603
  };
package/dist/index.js CHANGED
@@ -960,6 +960,24 @@ var ModelTreeModule = class {
960
960
  nodeId: String(nodeId)
961
961
  });
962
962
  }
963
+ setNodeVisibility(nodeIds, visible) {
964
+ const normalizedNodeIds = Array.from(
965
+ new Set(
966
+ nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
967
+ )
968
+ );
969
+ if (normalizedNodeIds.length === 0) return;
970
+ this.postTreeSetNodeVisibility({
971
+ nodeIds: normalizedNodeIds,
972
+ visible
973
+ });
974
+ }
975
+ hideNode(nodeIds) {
976
+ this.setNodeVisibility(nodeIds, false);
977
+ }
978
+ showNode(nodeIds) {
979
+ this.setNodeVisibility(nodeIds, true);
980
+ }
963
981
  getNodeIds(options) {
964
982
  const requestId = createRequestId3("tree");
965
983
  const timeoutMs = this.resolveTimeoutMs(options);
@@ -1020,6 +1038,9 @@ var ModelTreeModule = class {
1020
1038
  postTreeSelectNode(payload) {
1021
1039
  this.viewer.postToViewer("viewer-tree-select-node" /* TREE_SELECT_NODE */, payload);
1022
1040
  }
1041
+ postTreeSetNodeVisibility(payload) {
1042
+ this.viewer.postToViewer("viewer-tree-set-node-visibility" /* TREE_SET_NODE_VISIBILITY */, payload);
1043
+ }
1023
1044
  postTreeGetNodeIds(payload) {
1024
1045
  this.viewer.postToViewer("viewer-tree-get-node-ids" /* TREE_GET_NODE_IDS */, payload);
1025
1046
  }
@@ -1140,6 +1161,14 @@ var LanguageModule = class {
1140
1161
  };
1141
1162
 
1142
1163
  // src/modules/object-properties.module.ts
1164
+ var OBJECT_PROPERTIES_CANCELLED_ERROR = "Object properties request cancelled";
1165
+ var OBJECT_PROPERTIES_TIMEOUT_ERROR = "No object properties";
1166
+ function createObjectPropertiesError(message, errorStatus) {
1167
+ const error = new Error(message);
1168
+ error.name = "ObjectPropertiesError";
1169
+ error.errorStatus = errorStatus;
1170
+ return error;
1171
+ }
1143
1172
  function createRequestId5(prefix) {
1144
1173
  return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
1145
1174
  }
@@ -1165,19 +1194,30 @@ var ObjectPropertiesModule = class {
1165
1194
  }
1166
1195
  getCurrent(options) {
1167
1196
  var _a;
1197
+ if (this.pendingGetCurrent) {
1198
+ clearTimeout(this.pendingGetCurrent.timer);
1199
+ this.pendingGetCurrent.off();
1200
+ this.pendingGetCurrent.reject(
1201
+ createObjectPropertiesError(OBJECT_PROPERTIES_CANCELLED_ERROR, "CANCELLED")
1202
+ );
1203
+ this.pendingGetCurrent = void 0;
1204
+ }
1168
1205
  const requestId = createRequestId5("object_properties_current");
1169
1206
  const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
1170
1207
  return new Promise((resolve, reject) => {
1171
1208
  const timer = setTimeout(() => {
1209
+ this.pendingGetCurrent = void 0;
1172
1210
  off();
1173
- reject(new Error("Timeout while getting current object properties from viewer"));
1211
+ reject(createObjectPropertiesError(OBJECT_PROPERTIES_TIMEOUT_ERROR, "TIMEOUT"));
1174
1212
  }, timeoutMs);
1175
1213
  const off = this.viewer._on("object-properties:changed", (payload2) => {
1176
1214
  if (payload2.requestId !== requestId) return;
1177
1215
  clearTimeout(timer);
1216
+ this.pendingGetCurrent = void 0;
1178
1217
  off();
1179
1218
  resolve(payload2);
1180
1219
  });
1220
+ this.pendingGetCurrent = { requestId, off, timer, reject };
1181
1221
  const payload = { requestId };
1182
1222
  if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
1183
1223
  payload.includeSelectionMeta = options.includeSelectionMeta;
package/dist/index.mjs CHANGED
@@ -934,6 +934,24 @@ var ModelTreeModule = class {
934
934
  nodeId: String(nodeId)
935
935
  });
936
936
  }
937
+ setNodeVisibility(nodeIds, visible) {
938
+ const normalizedNodeIds = Array.from(
939
+ new Set(
940
+ nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
941
+ )
942
+ );
943
+ if (normalizedNodeIds.length === 0) return;
944
+ this.postTreeSetNodeVisibility({
945
+ nodeIds: normalizedNodeIds,
946
+ visible
947
+ });
948
+ }
949
+ hideNode(nodeIds) {
950
+ this.setNodeVisibility(nodeIds, false);
951
+ }
952
+ showNode(nodeIds) {
953
+ this.setNodeVisibility(nodeIds, true);
954
+ }
937
955
  getNodeIds(options) {
938
956
  const requestId = createRequestId3("tree");
939
957
  const timeoutMs = this.resolveTimeoutMs(options);
@@ -994,6 +1012,9 @@ var ModelTreeModule = class {
994
1012
  postTreeSelectNode(payload) {
995
1013
  this.viewer.postToViewer("viewer-tree-select-node" /* TREE_SELECT_NODE */, payload);
996
1014
  }
1015
+ postTreeSetNodeVisibility(payload) {
1016
+ this.viewer.postToViewer("viewer-tree-set-node-visibility" /* TREE_SET_NODE_VISIBILITY */, payload);
1017
+ }
997
1018
  postTreeGetNodeIds(payload) {
998
1019
  this.viewer.postToViewer("viewer-tree-get-node-ids" /* TREE_GET_NODE_IDS */, payload);
999
1020
  }
@@ -1114,6 +1135,14 @@ var LanguageModule = class {
1114
1135
  };
1115
1136
 
1116
1137
  // src/modules/object-properties.module.ts
1138
+ var OBJECT_PROPERTIES_CANCELLED_ERROR = "Object properties request cancelled";
1139
+ var OBJECT_PROPERTIES_TIMEOUT_ERROR = "No object properties";
1140
+ function createObjectPropertiesError(message, errorStatus) {
1141
+ const error = new Error(message);
1142
+ error.name = "ObjectPropertiesError";
1143
+ error.errorStatus = errorStatus;
1144
+ return error;
1145
+ }
1117
1146
  function createRequestId5(prefix) {
1118
1147
  return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
1119
1148
  }
@@ -1139,19 +1168,30 @@ var ObjectPropertiesModule = class {
1139
1168
  }
1140
1169
  getCurrent(options) {
1141
1170
  var _a;
1171
+ if (this.pendingGetCurrent) {
1172
+ clearTimeout(this.pendingGetCurrent.timer);
1173
+ this.pendingGetCurrent.off();
1174
+ this.pendingGetCurrent.reject(
1175
+ createObjectPropertiesError(OBJECT_PROPERTIES_CANCELLED_ERROR, "CANCELLED")
1176
+ );
1177
+ this.pendingGetCurrent = void 0;
1178
+ }
1142
1179
  const requestId = createRequestId5("object_properties_current");
1143
1180
  const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
1144
1181
  return new Promise((resolve, reject) => {
1145
1182
  const timer = setTimeout(() => {
1183
+ this.pendingGetCurrent = void 0;
1146
1184
  off();
1147
- reject(new Error("Timeout while getting current object properties from viewer"));
1185
+ reject(createObjectPropertiesError(OBJECT_PROPERTIES_TIMEOUT_ERROR, "TIMEOUT"));
1148
1186
  }, timeoutMs);
1149
1187
  const off = this.viewer._on("object-properties:changed", (payload2) => {
1150
1188
  if (payload2.requestId !== requestId) return;
1151
1189
  clearTimeout(timer);
1190
+ this.pendingGetCurrent = void 0;
1152
1191
  off();
1153
1192
  resolve(payload2);
1154
1193
  });
1194
+ this.pendingGetCurrent = { requestId, off, timer, reject };
1155
1195
  const payload = { requestId };
1156
1196
  if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
1157
1197
  payload.includeSelectionMeta = options.includeSelectionMeta;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "3dviewer-sdk",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [