3dviewer-sdk 1.0.19 → 1.0.21

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
@@ -31,6 +31,10 @@ declare enum ViewerMessageType {
31
31
  SHEETS_APPLY = "viewer-sheets-apply",
32
32
  OBJECT_PROPERTIES_GET_LIST = "viewer-object-properties-get-list",
33
33
  OBJECT_PROPERTIES_LIST = "viewer-object-properties-list",
34
+ OBJECT_PROPERTIES_WATCH = "viewer-object-properties-watch",
35
+ OBJECT_PROPERTIES_UNWATCH = "viewer-object-properties-unwatch",
36
+ OBJECT_PROPERTIES_GET_CURRENT = "viewer-object-properties-get-current",
37
+ OBJECT_PROPERTIES_CHANGED = "viewer-object-properties-changed",
34
38
  LINKED_OBJECTS_GET_LIST = "viewer-linked-objects-get-list",
35
39
  LINKED_OBJECTS_LIST = "viewer-linked-objects-list",
36
40
  STATES_OBJECTS_GET_LIST = "viewer-states-objects-get-list",
@@ -86,6 +90,14 @@ type SheetListItem = {
86
90
  viewId?: string;
87
91
  };
88
92
  type ObjectPropertyItem = Record<string, unknown>;
93
+ type ObjectPropertiesChangedPayload = {
94
+ requestId?: string;
95
+ selectionKey: string;
96
+ nodeIds: string[];
97
+ persistentIds: string[];
98
+ properties: ObjectPropertyItem[];
99
+ timestamp: number;
100
+ };
89
101
  type LinkedObjectItem = Record<string, unknown>;
90
102
  type StateObjectRefItem = {
91
103
  name: string;
@@ -173,6 +185,7 @@ type ViewerEventMap = {
173
185
  properties: ObjectPropertyItem[];
174
186
  timestamp: number;
175
187
  };
188
+ "object-properties:changed": ObjectPropertiesChangedPayload;
176
189
  "linked-objects:list": {
177
190
  requestId: string;
178
191
  linkedObjects: LinkedObjectItem[];
@@ -569,6 +582,25 @@ declare class LanguageModule {
569
582
  set(language: LanguageCode): void;
570
583
  }
571
584
 
585
+ type ObjectPropertiesWatchOptions = {
586
+ debounceMs?: number;
587
+ includeSelectionMeta?: boolean;
588
+ };
589
+ type ObjectPropertiesGetCurrentOptions = ObjectPropertiesWatchOptions & {
590
+ timeoutMs?: number;
591
+ };
592
+ type ObjectPropertiesChangedEvent = ObjectPropertiesChangedPayload;
593
+ declare class ObjectPropertiesModule {
594
+ private viewer;
595
+ on: {
596
+ change: (cb: (payload: ObjectPropertiesChangedEvent) => void) => () => void;
597
+ };
598
+ constructor(viewer: Viewer3D);
599
+ watch(options?: ObjectPropertiesWatchOptions): void;
600
+ unwatch(): void;
601
+ getCurrent(options?: ObjectPropertiesGetCurrentOptions): Promise<ObjectPropertiesChangedEvent>;
602
+ }
603
+
572
604
  type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
573
605
  type Viewer3DOptions = {
574
606
  container: HTMLElement | string;
@@ -598,6 +630,7 @@ declare class Viewer3D {
598
630
  modelTree: ModelTreeModule;
599
631
  markup: MarkupModule;
600
632
  language: LanguageModule;
633
+ objectProperties: ObjectPropertiesModule;
601
634
  constructor(options: Viewer3DOptions);
602
635
  getOptions(): Viewer3DOptions;
603
636
  patchOptions(next: Partial<Viewer3DOptions>): void;
@@ -616,4 +649,4 @@ declare class Viewer3D {
616
649
  private handleMessage;
617
650
  }
618
651
 
619
- export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
652
+ export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesChangedEvent, type ObjectPropertiesGetCurrentOptions, type ObjectPropertiesWatchOptions, type PreparedViewerData, Viewer3D };
package/dist/index.d.ts CHANGED
@@ -31,6 +31,10 @@ declare enum ViewerMessageType {
31
31
  SHEETS_APPLY = "viewer-sheets-apply",
32
32
  OBJECT_PROPERTIES_GET_LIST = "viewer-object-properties-get-list",
33
33
  OBJECT_PROPERTIES_LIST = "viewer-object-properties-list",
34
+ OBJECT_PROPERTIES_WATCH = "viewer-object-properties-watch",
35
+ OBJECT_PROPERTIES_UNWATCH = "viewer-object-properties-unwatch",
36
+ OBJECT_PROPERTIES_GET_CURRENT = "viewer-object-properties-get-current",
37
+ OBJECT_PROPERTIES_CHANGED = "viewer-object-properties-changed",
34
38
  LINKED_OBJECTS_GET_LIST = "viewer-linked-objects-get-list",
35
39
  LINKED_OBJECTS_LIST = "viewer-linked-objects-list",
36
40
  STATES_OBJECTS_GET_LIST = "viewer-states-objects-get-list",
@@ -86,6 +90,14 @@ type SheetListItem = {
86
90
  viewId?: string;
87
91
  };
88
92
  type ObjectPropertyItem = Record<string, unknown>;
93
+ type ObjectPropertiesChangedPayload = {
94
+ requestId?: string;
95
+ selectionKey: string;
96
+ nodeIds: string[];
97
+ persistentIds: string[];
98
+ properties: ObjectPropertyItem[];
99
+ timestamp: number;
100
+ };
89
101
  type LinkedObjectItem = Record<string, unknown>;
90
102
  type StateObjectRefItem = {
91
103
  name: string;
@@ -173,6 +185,7 @@ type ViewerEventMap = {
173
185
  properties: ObjectPropertyItem[];
174
186
  timestamp: number;
175
187
  };
188
+ "object-properties:changed": ObjectPropertiesChangedPayload;
176
189
  "linked-objects:list": {
177
190
  requestId: string;
178
191
  linkedObjects: LinkedObjectItem[];
@@ -569,6 +582,25 @@ declare class LanguageModule {
569
582
  set(language: LanguageCode): void;
570
583
  }
571
584
 
585
+ type ObjectPropertiesWatchOptions = {
586
+ debounceMs?: number;
587
+ includeSelectionMeta?: boolean;
588
+ };
589
+ type ObjectPropertiesGetCurrentOptions = ObjectPropertiesWatchOptions & {
590
+ timeoutMs?: number;
591
+ };
592
+ type ObjectPropertiesChangedEvent = ObjectPropertiesChangedPayload;
593
+ declare class ObjectPropertiesModule {
594
+ private viewer;
595
+ on: {
596
+ change: (cb: (payload: ObjectPropertiesChangedEvent) => void) => () => void;
597
+ };
598
+ constructor(viewer: Viewer3D);
599
+ watch(options?: ObjectPropertiesWatchOptions): void;
600
+ unwatch(): void;
601
+ getCurrent(options?: ObjectPropertiesGetCurrentOptions): Promise<ObjectPropertiesChangedEvent>;
602
+ }
603
+
572
604
  type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
573
605
  type Viewer3DOptions = {
574
606
  container: HTMLElement | string;
@@ -598,6 +630,7 @@ declare class Viewer3D {
598
630
  modelTree: ModelTreeModule;
599
631
  markup: MarkupModule;
600
632
  language: LanguageModule;
633
+ objectProperties: ObjectPropertiesModule;
601
634
  constructor(options: Viewer3DOptions);
602
635
  getOptions(): Viewer3DOptions;
603
636
  patchOptions(next: Partial<Viewer3DOptions>): void;
@@ -616,4 +649,4 @@ declare class Viewer3D {
616
649
  private handleMessage;
617
650
  }
618
651
 
619
- export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type PreparedViewerData, Viewer3D };
652
+ export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesChangedEvent, type ObjectPropertiesGetCurrentOptions, type ObjectPropertiesWatchOptions, type PreparedViewerData, Viewer3D };
package/dist/index.js CHANGED
@@ -1141,6 +1141,54 @@ var LanguageModule = class {
1141
1141
  }
1142
1142
  };
1143
1143
 
1144
+ // src/modules/object-properties.module.ts
1145
+ function createRequestId5(prefix) {
1146
+ return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
1147
+ }
1148
+ var ObjectPropertiesModule = class {
1149
+ constructor(viewer) {
1150
+ this.viewer = viewer;
1151
+ this.on = {
1152
+ change: (cb) => this.viewer._on("object-properties:changed", cb)
1153
+ };
1154
+ }
1155
+ watch(options) {
1156
+ const payload = {};
1157
+ if (typeof (options == null ? void 0 : options.debounceMs) === "number" && Number.isFinite(options.debounceMs)) {
1158
+ payload.debounceMs = options.debounceMs;
1159
+ }
1160
+ if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
1161
+ payload.includeSelectionMeta = options.includeSelectionMeta;
1162
+ }
1163
+ this.viewer.postToViewer("viewer-object-properties-watch" /* OBJECT_PROPERTIES_WATCH */, payload);
1164
+ }
1165
+ unwatch() {
1166
+ this.viewer.postToViewer("viewer-object-properties-unwatch" /* OBJECT_PROPERTIES_UNWATCH */, {});
1167
+ }
1168
+ getCurrent(options) {
1169
+ var _a;
1170
+ const requestId = createRequestId5("object_properties_current");
1171
+ const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
1172
+ return new Promise((resolve, reject) => {
1173
+ const timer = setTimeout(() => {
1174
+ off();
1175
+ reject(new Error("Timeout while getting current object properties from viewer"));
1176
+ }, timeoutMs);
1177
+ const off = this.viewer._on("object-properties:changed", (payload2) => {
1178
+ if (payload2.requestId !== requestId) return;
1179
+ clearTimeout(timer);
1180
+ off();
1181
+ resolve(payload2);
1182
+ });
1183
+ const payload = { requestId };
1184
+ if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
1185
+ payload.includeSelectionMeta = options.includeSelectionMeta;
1186
+ }
1187
+ this.viewer.postToViewer("viewer-object-properties-get-current" /* OBJECT_PROPERTIES_GET_CURRENT */, payload);
1188
+ });
1189
+ }
1190
+ };
1191
+
1144
1192
  // src/viewer.ts
1145
1193
  var SDK_VIEWER_PATH2 = "/mainviewer-sdk";
1146
1194
  var LEGACY_VIEWER_PATH2 = "/mainviewer";
@@ -1152,7 +1200,7 @@ var Viewer3D = class {
1152
1200
  this.initialized = false;
1153
1201
  this.emitter = new Emitter();
1154
1202
  this.handleMessage = (event) => {
1155
- var _a, _b, _c, _d;
1203
+ var _a, _b, _c, _d, _e;
1156
1204
  const data = event.data;
1157
1205
  if (!data || typeof data !== "object") return;
1158
1206
  switch (data.type) {
@@ -1295,6 +1343,19 @@ var Viewer3D = class {
1295
1343
  });
1296
1344
  break;
1297
1345
  }
1346
+ case "viewer-object-properties-changed" /* OBJECT_PROPERTIES_CHANGED */: {
1347
+ const payload = data.payload;
1348
+ if (!payload || !Array.isArray(payload.properties)) break;
1349
+ this._emit("object-properties:changed", {
1350
+ requestId: payload.requestId ? String(payload.requestId) : void 0,
1351
+ selectionKey: String((_e = payload.selectionKey) != null ? _e : ""),
1352
+ nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
1353
+ persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
1354
+ properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
1355
+ timestamp: Number(payload.timestamp) || Date.now()
1356
+ });
1357
+ break;
1358
+ }
1298
1359
  case "viewer-linked-objects-list" /* LINKED_OBJECTS_LIST */: {
1299
1360
  const payload = data.payload;
1300
1361
  if (!payload || !payload.requestId || !Array.isArray(payload.linkedObjects)) break;
@@ -1311,7 +1372,7 @@ var Viewer3D = class {
1311
1372
  this._emit("states-objects:list", {
1312
1373
  requestId: String(payload.requestId),
1313
1374
  statesObjects: payload.statesObjects.map((item) => {
1314
- var _a2, _b2, _c2, _d2, _e, _f, _g;
1375
+ var _a2, _b2, _c2, _d2, _e2, _f, _g;
1315
1376
  return {
1316
1377
  id: String((_a2 = item.id) != null ? _a2 : ""),
1317
1378
  name: String((_b2 = item.name) != null ? _b2 : ""),
@@ -1324,7 +1385,7 @@ var Viewer3D = class {
1324
1385
  };
1325
1386
  }) : [],
1326
1387
  states: {
1327
- color: String((_e = (_d2 = item.states) == null ? void 0 : _d2.color) != null ? _e : ""),
1388
+ color: String((_e2 = (_d2 = item.states) == null ? void 0 : _d2.color) != null ? _e2 : ""),
1328
1389
  type: String((_g = (_f = item.states) == null ? void 0 : _f.type) != null ? _g : "")
1329
1390
  }
1330
1391
  };
@@ -1391,6 +1452,7 @@ var Viewer3D = class {
1391
1452
  this.modelTree = new ModelTreeModule(this);
1392
1453
  this.markup = new MarkupModule(this);
1393
1454
  this.language = new LanguageModule(this);
1455
+ this.objectProperties = new ObjectPropertiesModule(this);
1394
1456
  }
1395
1457
  // ===== options helpers =====
1396
1458
  getOptions() {
package/dist/index.mjs CHANGED
@@ -1115,6 +1115,54 @@ var LanguageModule = class {
1115
1115
  }
1116
1116
  };
1117
1117
 
1118
+ // src/modules/object-properties.module.ts
1119
+ function createRequestId5(prefix) {
1120
+ return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
1121
+ }
1122
+ var ObjectPropertiesModule = class {
1123
+ constructor(viewer) {
1124
+ this.viewer = viewer;
1125
+ this.on = {
1126
+ change: (cb) => this.viewer._on("object-properties:changed", cb)
1127
+ };
1128
+ }
1129
+ watch(options) {
1130
+ const payload = {};
1131
+ if (typeof (options == null ? void 0 : options.debounceMs) === "number" && Number.isFinite(options.debounceMs)) {
1132
+ payload.debounceMs = options.debounceMs;
1133
+ }
1134
+ if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
1135
+ payload.includeSelectionMeta = options.includeSelectionMeta;
1136
+ }
1137
+ this.viewer.postToViewer("viewer-object-properties-watch" /* OBJECT_PROPERTIES_WATCH */, payload);
1138
+ }
1139
+ unwatch() {
1140
+ this.viewer.postToViewer("viewer-object-properties-unwatch" /* OBJECT_PROPERTIES_UNWATCH */, {});
1141
+ }
1142
+ getCurrent(options) {
1143
+ var _a;
1144
+ const requestId = createRequestId5("object_properties_current");
1145
+ const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
1146
+ return new Promise((resolve, reject) => {
1147
+ const timer = setTimeout(() => {
1148
+ off();
1149
+ reject(new Error("Timeout while getting current object properties from viewer"));
1150
+ }, timeoutMs);
1151
+ const off = this.viewer._on("object-properties:changed", (payload2) => {
1152
+ if (payload2.requestId !== requestId) return;
1153
+ clearTimeout(timer);
1154
+ off();
1155
+ resolve(payload2);
1156
+ });
1157
+ const payload = { requestId };
1158
+ if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
1159
+ payload.includeSelectionMeta = options.includeSelectionMeta;
1160
+ }
1161
+ this.viewer.postToViewer("viewer-object-properties-get-current" /* OBJECT_PROPERTIES_GET_CURRENT */, payload);
1162
+ });
1163
+ }
1164
+ };
1165
+
1118
1166
  // src/viewer.ts
1119
1167
  var SDK_VIEWER_PATH2 = "/mainviewer-sdk";
1120
1168
  var LEGACY_VIEWER_PATH2 = "/mainviewer";
@@ -1126,7 +1174,7 @@ var Viewer3D = class {
1126
1174
  this.initialized = false;
1127
1175
  this.emitter = new Emitter();
1128
1176
  this.handleMessage = (event) => {
1129
- var _a, _b, _c, _d;
1177
+ var _a, _b, _c, _d, _e;
1130
1178
  const data = event.data;
1131
1179
  if (!data || typeof data !== "object") return;
1132
1180
  switch (data.type) {
@@ -1269,6 +1317,19 @@ var Viewer3D = class {
1269
1317
  });
1270
1318
  break;
1271
1319
  }
1320
+ case "viewer-object-properties-changed" /* OBJECT_PROPERTIES_CHANGED */: {
1321
+ const payload = data.payload;
1322
+ if (!payload || !Array.isArray(payload.properties)) break;
1323
+ this._emit("object-properties:changed", {
1324
+ requestId: payload.requestId ? String(payload.requestId) : void 0,
1325
+ selectionKey: String((_e = payload.selectionKey) != null ? _e : ""),
1326
+ nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
1327
+ persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
1328
+ properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
1329
+ timestamp: Number(payload.timestamp) || Date.now()
1330
+ });
1331
+ break;
1332
+ }
1272
1333
  case "viewer-linked-objects-list" /* LINKED_OBJECTS_LIST */: {
1273
1334
  const payload = data.payload;
1274
1335
  if (!payload || !payload.requestId || !Array.isArray(payload.linkedObjects)) break;
@@ -1285,7 +1346,7 @@ var Viewer3D = class {
1285
1346
  this._emit("states-objects:list", {
1286
1347
  requestId: String(payload.requestId),
1287
1348
  statesObjects: payload.statesObjects.map((item) => {
1288
- var _a2, _b2, _c2, _d2, _e, _f, _g;
1349
+ var _a2, _b2, _c2, _d2, _e2, _f, _g;
1289
1350
  return {
1290
1351
  id: String((_a2 = item.id) != null ? _a2 : ""),
1291
1352
  name: String((_b2 = item.name) != null ? _b2 : ""),
@@ -1298,7 +1359,7 @@ var Viewer3D = class {
1298
1359
  };
1299
1360
  }) : [],
1300
1361
  states: {
1301
- color: String((_e = (_d2 = item.states) == null ? void 0 : _d2.color) != null ? _e : ""),
1362
+ color: String((_e2 = (_d2 = item.states) == null ? void 0 : _d2.color) != null ? _e2 : ""),
1302
1363
  type: String((_g = (_f = item.states) == null ? void 0 : _f.type) != null ? _g : "")
1303
1364
  }
1304
1365
  };
@@ -1365,6 +1426,7 @@ var Viewer3D = class {
1365
1426
  this.modelTree = new ModelTreeModule(this);
1366
1427
  this.markup = new MarkupModule(this);
1367
1428
  this.language = new LanguageModule(this);
1429
+ this.objectProperties = new ObjectPropertiesModule(this);
1368
1430
  }
1369
1431
  // ===== options helpers =====
1370
1432
  getOptions() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "3dviewer-sdk",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [