3dviewer-sdk 1.0.24 → 1.0.25
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 +22 -28
- package/dist/index.d.ts +22 -28
- package/dist/index.js +52 -47
- package/dist/index.mjs +52 -47
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -31,10 +31,6 @@ 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",
|
|
38
34
|
LINKED_OBJECTS_GET_LIST = "viewer-linked-objects-get-list",
|
|
39
35
|
LINKED_OBJECTS_LIST = "viewer-linked-objects-list",
|
|
40
36
|
STATES_OBJECTS_GET_LIST = "viewer-states-objects-get-list",
|
|
@@ -91,8 +87,8 @@ type SheetListItem = {
|
|
|
91
87
|
viewId?: string;
|
|
92
88
|
};
|
|
93
89
|
type ObjectPropertyItem = Record<string, unknown>;
|
|
94
|
-
type
|
|
95
|
-
requestId
|
|
90
|
+
type ObjectPropertiesListPayload = {
|
|
91
|
+
requestId: string;
|
|
96
92
|
selectionKey: string;
|
|
97
93
|
nodeIds: string[];
|
|
98
94
|
persistentIds: string[];
|
|
@@ -181,12 +177,7 @@ type ViewerEventMap = {
|
|
|
181
177
|
activeSheetId?: string | number | null;
|
|
182
178
|
timestamp: number;
|
|
183
179
|
};
|
|
184
|
-
"object-properties:list":
|
|
185
|
-
requestId: string;
|
|
186
|
-
properties: ObjectPropertyItem[];
|
|
187
|
-
timestamp: number;
|
|
188
|
-
};
|
|
189
|
-
"object-properties:changed": ObjectPropertiesChangedPayload;
|
|
180
|
+
"object-properties:list": ObjectPropertiesListPayload;
|
|
190
181
|
"linked-objects:list": {
|
|
191
182
|
requestId: string;
|
|
192
183
|
linkedObjects: LinkedObjectItem[];
|
|
@@ -339,10 +330,17 @@ type ConvertV2Options = {
|
|
|
339
330
|
project?: string;
|
|
340
331
|
convertOptions?: Partial<StreamConvertOptions>;
|
|
341
332
|
};
|
|
342
|
-
type FileInfoCheckInput = string | string[];
|
|
343
333
|
type FileInfoCheckPayloadItem = {
|
|
344
334
|
baseFileId: string;
|
|
335
|
+
baseMajorRev: number;
|
|
336
|
+
baseMinorRev: number;
|
|
345
337
|
};
|
|
338
|
+
type FileInfoCheckInputItem = string | {
|
|
339
|
+
baseFileId: string;
|
|
340
|
+
baseMajorRev?: number;
|
|
341
|
+
baseMinorRev?: number;
|
|
342
|
+
};
|
|
343
|
+
type FileInfoCheckInput = FileInfoCheckInputItem | FileInfoCheckInputItem[];
|
|
346
344
|
type StreamConvertOptions = {
|
|
347
345
|
convert3DModel: number;
|
|
348
346
|
convert2DSheet: number;
|
|
@@ -435,6 +433,9 @@ type ToolbarFormat = "3d" | "pdf";
|
|
|
435
433
|
type GetSheetsOptions = {
|
|
436
434
|
timeoutMs?: number;
|
|
437
435
|
};
|
|
436
|
+
type GetObjectPropertiesOptions = GetSheetsOptions & {
|
|
437
|
+
nodeIds?: Array<string | number>;
|
|
438
|
+
};
|
|
438
439
|
declare class ToolbarModule {
|
|
439
440
|
private viewer;
|
|
440
441
|
on: {
|
|
@@ -497,7 +498,7 @@ declare class ToolbarModule {
|
|
|
497
498
|
openSheets(): void;
|
|
498
499
|
closeSheets(): void;
|
|
499
500
|
getSheets(options?: GetSheetsOptions): Promise<SheetListItem[]>;
|
|
500
|
-
getObjectProperties(options?:
|
|
501
|
+
getObjectProperties(options?: GetObjectPropertiesOptions): Promise<ObjectPropertyItem[]>;
|
|
501
502
|
getLinkedObjects(options?: GetSheetsOptions): Promise<LinkedObjectItem[]>;
|
|
502
503
|
getStatesObjects(options?: GetSheetsOptions): Promise<StateObjectItem[]>;
|
|
503
504
|
applySheet(sheetId: string | number): void;
|
|
@@ -587,24 +588,17 @@ declare class LanguageModule {
|
|
|
587
588
|
set(language: LanguageCode): void;
|
|
588
589
|
}
|
|
589
590
|
|
|
590
|
-
type
|
|
591
|
-
debounceMs?: number;
|
|
592
|
-
includeSelectionMeta?: boolean;
|
|
593
|
-
};
|
|
594
|
-
type ObjectPropertiesGetCurrentOptions = ObjectPropertiesWatchOptions & {
|
|
591
|
+
type ObjectPropertiesGetOptions = {
|
|
595
592
|
timeoutMs?: number;
|
|
593
|
+
expandToRealNodes?: boolean;
|
|
594
|
+
includeSelectionMeta?: boolean;
|
|
596
595
|
};
|
|
597
|
-
type
|
|
596
|
+
type ObjectPropertiesResult = ObjectPropertiesListPayload;
|
|
598
597
|
declare class ObjectPropertiesModule {
|
|
599
598
|
private viewer;
|
|
600
|
-
private pendingGetCurrent;
|
|
601
|
-
on: {
|
|
602
|
-
change: (cb: (payload: ObjectPropertiesChangedEvent) => void) => () => void;
|
|
603
|
-
};
|
|
604
599
|
constructor(viewer: Viewer3D);
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
getCurrent(options?: ObjectPropertiesGetCurrentOptions): Promise<ObjectPropertiesChangedEvent>;
|
|
600
|
+
get(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
601
|
+
getByNodeIds(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
608
602
|
}
|
|
609
603
|
|
|
610
604
|
type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
|
|
@@ -655,4 +649,4 @@ declare class Viewer3D {
|
|
|
655
649
|
private handleMessage;
|
|
656
650
|
}
|
|
657
651
|
|
|
658
|
-
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
|
|
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 ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, Viewer3D };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,10 +31,6 @@ 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",
|
|
38
34
|
LINKED_OBJECTS_GET_LIST = "viewer-linked-objects-get-list",
|
|
39
35
|
LINKED_OBJECTS_LIST = "viewer-linked-objects-list",
|
|
40
36
|
STATES_OBJECTS_GET_LIST = "viewer-states-objects-get-list",
|
|
@@ -91,8 +87,8 @@ type SheetListItem = {
|
|
|
91
87
|
viewId?: string;
|
|
92
88
|
};
|
|
93
89
|
type ObjectPropertyItem = Record<string, unknown>;
|
|
94
|
-
type
|
|
95
|
-
requestId
|
|
90
|
+
type ObjectPropertiesListPayload = {
|
|
91
|
+
requestId: string;
|
|
96
92
|
selectionKey: string;
|
|
97
93
|
nodeIds: string[];
|
|
98
94
|
persistentIds: string[];
|
|
@@ -181,12 +177,7 @@ type ViewerEventMap = {
|
|
|
181
177
|
activeSheetId?: string | number | null;
|
|
182
178
|
timestamp: number;
|
|
183
179
|
};
|
|
184
|
-
"object-properties:list":
|
|
185
|
-
requestId: string;
|
|
186
|
-
properties: ObjectPropertyItem[];
|
|
187
|
-
timestamp: number;
|
|
188
|
-
};
|
|
189
|
-
"object-properties:changed": ObjectPropertiesChangedPayload;
|
|
180
|
+
"object-properties:list": ObjectPropertiesListPayload;
|
|
190
181
|
"linked-objects:list": {
|
|
191
182
|
requestId: string;
|
|
192
183
|
linkedObjects: LinkedObjectItem[];
|
|
@@ -339,10 +330,17 @@ type ConvertV2Options = {
|
|
|
339
330
|
project?: string;
|
|
340
331
|
convertOptions?: Partial<StreamConvertOptions>;
|
|
341
332
|
};
|
|
342
|
-
type FileInfoCheckInput = string | string[];
|
|
343
333
|
type FileInfoCheckPayloadItem = {
|
|
344
334
|
baseFileId: string;
|
|
335
|
+
baseMajorRev: number;
|
|
336
|
+
baseMinorRev: number;
|
|
345
337
|
};
|
|
338
|
+
type FileInfoCheckInputItem = string | {
|
|
339
|
+
baseFileId: string;
|
|
340
|
+
baseMajorRev?: number;
|
|
341
|
+
baseMinorRev?: number;
|
|
342
|
+
};
|
|
343
|
+
type FileInfoCheckInput = FileInfoCheckInputItem | FileInfoCheckInputItem[];
|
|
346
344
|
type StreamConvertOptions = {
|
|
347
345
|
convert3DModel: number;
|
|
348
346
|
convert2DSheet: number;
|
|
@@ -435,6 +433,9 @@ type ToolbarFormat = "3d" | "pdf";
|
|
|
435
433
|
type GetSheetsOptions = {
|
|
436
434
|
timeoutMs?: number;
|
|
437
435
|
};
|
|
436
|
+
type GetObjectPropertiesOptions = GetSheetsOptions & {
|
|
437
|
+
nodeIds?: Array<string | number>;
|
|
438
|
+
};
|
|
438
439
|
declare class ToolbarModule {
|
|
439
440
|
private viewer;
|
|
440
441
|
on: {
|
|
@@ -497,7 +498,7 @@ declare class ToolbarModule {
|
|
|
497
498
|
openSheets(): void;
|
|
498
499
|
closeSheets(): void;
|
|
499
500
|
getSheets(options?: GetSheetsOptions): Promise<SheetListItem[]>;
|
|
500
|
-
getObjectProperties(options?:
|
|
501
|
+
getObjectProperties(options?: GetObjectPropertiesOptions): Promise<ObjectPropertyItem[]>;
|
|
501
502
|
getLinkedObjects(options?: GetSheetsOptions): Promise<LinkedObjectItem[]>;
|
|
502
503
|
getStatesObjects(options?: GetSheetsOptions): Promise<StateObjectItem[]>;
|
|
503
504
|
applySheet(sheetId: string | number): void;
|
|
@@ -587,24 +588,17 @@ declare class LanguageModule {
|
|
|
587
588
|
set(language: LanguageCode): void;
|
|
588
589
|
}
|
|
589
590
|
|
|
590
|
-
type
|
|
591
|
-
debounceMs?: number;
|
|
592
|
-
includeSelectionMeta?: boolean;
|
|
593
|
-
};
|
|
594
|
-
type ObjectPropertiesGetCurrentOptions = ObjectPropertiesWatchOptions & {
|
|
591
|
+
type ObjectPropertiesGetOptions = {
|
|
595
592
|
timeoutMs?: number;
|
|
593
|
+
expandToRealNodes?: boolean;
|
|
594
|
+
includeSelectionMeta?: boolean;
|
|
596
595
|
};
|
|
597
|
-
type
|
|
596
|
+
type ObjectPropertiesResult = ObjectPropertiesListPayload;
|
|
598
597
|
declare class ObjectPropertiesModule {
|
|
599
598
|
private viewer;
|
|
600
|
-
private pendingGetCurrent;
|
|
601
|
-
on: {
|
|
602
|
-
change: (cb: (payload: ObjectPropertiesChangedEvent) => void) => () => void;
|
|
603
|
-
};
|
|
604
599
|
constructor(viewer: Viewer3D);
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
getCurrent(options?: ObjectPropertiesGetCurrentOptions): Promise<ObjectPropertiesChangedEvent>;
|
|
600
|
+
get(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
601
|
+
getByNodeIds(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
608
602
|
}
|
|
609
603
|
|
|
610
604
|
type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
|
|
@@ -655,4 +649,4 @@ declare class Viewer3D {
|
|
|
655
649
|
private handleMessage;
|
|
656
650
|
}
|
|
657
651
|
|
|
658
|
-
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
|
|
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 ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, Viewer3D };
|
package/dist/index.js
CHANGED
|
@@ -488,11 +488,25 @@ var FilesModule = class {
|
|
|
488
488
|
};
|
|
489
489
|
}
|
|
490
490
|
buildFileInfoPayload(baseFileIds) {
|
|
491
|
-
const
|
|
492
|
-
|
|
491
|
+
const payload = (Array.isArray(baseFileIds) ? baseFileIds : [baseFileIds]).map((item) => {
|
|
492
|
+
var _a, _b, _c;
|
|
493
|
+
if (typeof item === "string") {
|
|
494
|
+
return {
|
|
495
|
+
baseFileId: item.trim(),
|
|
496
|
+
baseMajorRev: 0,
|
|
497
|
+
baseMinorRev: 0
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
return {
|
|
501
|
+
baseFileId: String((_a = item.baseFileId) != null ? _a : "").trim(),
|
|
502
|
+
baseMajorRev: (_b = item.baseMajorRev) != null ? _b : 0,
|
|
503
|
+
baseMinorRev: (_c = item.baseMinorRev) != null ? _c : 0
|
|
504
|
+
};
|
|
505
|
+
}).filter((item) => item.baseFileId);
|
|
506
|
+
if (payload.length === 0) {
|
|
493
507
|
throw new Error("No baseFileId provided");
|
|
494
508
|
}
|
|
495
|
-
return
|
|
509
|
+
return payload;
|
|
496
510
|
}
|
|
497
511
|
// Submit conversion/caching request and return service response.
|
|
498
512
|
async cacheFile(file, baseFileId, options = {}) {
|
|
@@ -792,6 +806,7 @@ var ToolbarModule = class {
|
|
|
792
806
|
const requestId = createRequestId2("object_properties");
|
|
793
807
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
794
808
|
return new Promise((resolve, reject) => {
|
|
809
|
+
var _a2;
|
|
795
810
|
const timer = setTimeout(() => {
|
|
796
811
|
off();
|
|
797
812
|
reject(new Error("Timeout while getting object properties list from viewer"));
|
|
@@ -802,7 +817,10 @@ var ToolbarModule = class {
|
|
|
802
817
|
off();
|
|
803
818
|
resolve(payload.properties);
|
|
804
819
|
});
|
|
805
|
-
this.postObjectPropertiesGetList({
|
|
820
|
+
this.postObjectPropertiesGetList({
|
|
821
|
+
requestId,
|
|
822
|
+
nodeIds: Array.from(new Set(((_a2 = options == null ? void 0 : options.nodeIds) != null ? _a2 : []).map(String).filter(Boolean)))
|
|
823
|
+
});
|
|
806
824
|
});
|
|
807
825
|
}
|
|
808
826
|
getLinkedObjects(options) {
|
|
@@ -1161,8 +1179,7 @@ var LanguageModule = class {
|
|
|
1161
1179
|
};
|
|
1162
1180
|
|
|
1163
1181
|
// src/modules/object-properties.module.ts
|
|
1164
|
-
var
|
|
1165
|
-
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "No object properties";
|
|
1182
|
+
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "Timeout while getting object properties from viewer";
|
|
1166
1183
|
function createObjectPropertiesError(message, errorStatus) {
|
|
1167
1184
|
const error = new Error(message);
|
|
1168
1185
|
error.name = "ObjectPropertiesError";
|
|
@@ -1172,57 +1189,55 @@ function createObjectPropertiesError(message, errorStatus) {
|
|
|
1172
1189
|
function createRequestId5(prefix) {
|
|
1173
1190
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1174
1191
|
}
|
|
1192
|
+
function normalizeNodeIds(nodeIds) {
|
|
1193
|
+
return Array.from(new Set(
|
|
1194
|
+
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
1195
|
+
));
|
|
1196
|
+
}
|
|
1175
1197
|
var ObjectPropertiesModule = class {
|
|
1176
1198
|
constructor(viewer) {
|
|
1177
1199
|
this.viewer = viewer;
|
|
1178
|
-
this.on = {
|
|
1179
|
-
change: (cb) => this.viewer._on("object-properties:changed", cb)
|
|
1180
|
-
};
|
|
1181
1200
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
if (typeof (options == null ? void 0 : options.debounceMs) === "number" && Number.isFinite(options.debounceMs)) {
|
|
1185
|
-
payload.debounceMs = options.debounceMs;
|
|
1186
|
-
}
|
|
1187
|
-
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1188
|
-
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1189
|
-
}
|
|
1190
|
-
this.viewer.postToViewer("viewer-object-properties-watch" /* OBJECT_PROPERTIES_WATCH */, payload);
|
|
1191
|
-
}
|
|
1192
|
-
unwatch() {
|
|
1193
|
-
this.viewer.postToViewer("viewer-object-properties-unwatch" /* OBJECT_PROPERTIES_UNWATCH */, {});
|
|
1201
|
+
get(nodeIds, options) {
|
|
1202
|
+
return this.getByNodeIds(nodeIds, options);
|
|
1194
1203
|
}
|
|
1195
|
-
|
|
1204
|
+
getByNodeIds(nodeIds, options) {
|
|
1196
1205
|
var _a;
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1206
|
+
const normalizedNodeIds = normalizeNodeIds(nodeIds);
|
|
1207
|
+
const requestId = createRequestId5("object_properties");
|
|
1208
|
+
if (normalizedNodeIds.length === 0) {
|
|
1209
|
+
return Promise.resolve({
|
|
1210
|
+
requestId,
|
|
1211
|
+
selectionKey: "",
|
|
1212
|
+
nodeIds: [],
|
|
1213
|
+
persistentIds: [],
|
|
1214
|
+
properties: [],
|
|
1215
|
+
timestamp: Date.now()
|
|
1216
|
+
});
|
|
1204
1217
|
}
|
|
1205
|
-
const
|
|
1206
|
-
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1218
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 12e4);
|
|
1207
1219
|
return new Promise((resolve, reject) => {
|
|
1208
1220
|
const timer = setTimeout(() => {
|
|
1209
|
-
this.pendingGetCurrent = void 0;
|
|
1210
1221
|
off();
|
|
1211
1222
|
reject(createObjectPropertiesError(OBJECT_PROPERTIES_TIMEOUT_ERROR, "TIMEOUT"));
|
|
1212
1223
|
}, timeoutMs);
|
|
1213
|
-
const off = this.viewer._on("object-properties:
|
|
1224
|
+
const off = this.viewer._on("object-properties:list", (payload2) => {
|
|
1214
1225
|
if (payload2.requestId !== requestId) return;
|
|
1215
1226
|
clearTimeout(timer);
|
|
1216
|
-
this.pendingGetCurrent = void 0;
|
|
1217
1227
|
off();
|
|
1218
1228
|
resolve(payload2);
|
|
1219
1229
|
});
|
|
1220
|
-
|
|
1221
|
-
|
|
1230
|
+
const payload = {
|
|
1231
|
+
requestId,
|
|
1232
|
+
nodeIds: normalizedNodeIds
|
|
1233
|
+
};
|
|
1234
|
+
if (typeof (options == null ? void 0 : options.expandToRealNodes) === "boolean") {
|
|
1235
|
+
payload.expandToRealNodes = options.expandToRealNodes;
|
|
1236
|
+
}
|
|
1222
1237
|
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1223
1238
|
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1224
1239
|
}
|
|
1225
|
-
this.viewer.postToViewer("viewer-object-properties-get-
|
|
1240
|
+
this.viewer.postToViewer("viewer-object-properties-get-list" /* OBJECT_PROPERTIES_GET_LIST */, payload);
|
|
1226
1241
|
});
|
|
1227
1242
|
}
|
|
1228
1243
|
};
|
|
@@ -1374,16 +1389,6 @@ var Viewer3D = class {
|
|
|
1374
1389
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties)) break;
|
|
1375
1390
|
this._emit("object-properties:list", {
|
|
1376
1391
|
requestId: String(payload.requestId),
|
|
1377
|
-
properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
|
|
1378
|
-
timestamp: Number(payload.timestamp) || Date.now()
|
|
1379
|
-
});
|
|
1380
|
-
break;
|
|
1381
|
-
}
|
|
1382
|
-
case "viewer-object-properties-changed" /* OBJECT_PROPERTIES_CHANGED */: {
|
|
1383
|
-
const payload = data.payload;
|
|
1384
|
-
if (!payload || !Array.isArray(payload.properties)) break;
|
|
1385
|
-
this._emit("object-properties:changed", {
|
|
1386
|
-
requestId: payload.requestId ? String(payload.requestId) : void 0,
|
|
1387
1392
|
selectionKey: String((_e = payload.selectionKey) != null ? _e : ""),
|
|
1388
1393
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1389
1394
|
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|
package/dist/index.mjs
CHANGED
|
@@ -462,11 +462,25 @@ var FilesModule = class {
|
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
buildFileInfoPayload(baseFileIds) {
|
|
465
|
-
const
|
|
466
|
-
|
|
465
|
+
const payload = (Array.isArray(baseFileIds) ? baseFileIds : [baseFileIds]).map((item) => {
|
|
466
|
+
var _a, _b, _c;
|
|
467
|
+
if (typeof item === "string") {
|
|
468
|
+
return {
|
|
469
|
+
baseFileId: item.trim(),
|
|
470
|
+
baseMajorRev: 0,
|
|
471
|
+
baseMinorRev: 0
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
baseFileId: String((_a = item.baseFileId) != null ? _a : "").trim(),
|
|
476
|
+
baseMajorRev: (_b = item.baseMajorRev) != null ? _b : 0,
|
|
477
|
+
baseMinorRev: (_c = item.baseMinorRev) != null ? _c : 0
|
|
478
|
+
};
|
|
479
|
+
}).filter((item) => item.baseFileId);
|
|
480
|
+
if (payload.length === 0) {
|
|
467
481
|
throw new Error("No baseFileId provided");
|
|
468
482
|
}
|
|
469
|
-
return
|
|
483
|
+
return payload;
|
|
470
484
|
}
|
|
471
485
|
// Submit conversion/caching request and return service response.
|
|
472
486
|
async cacheFile(file, baseFileId, options = {}) {
|
|
@@ -766,6 +780,7 @@ var ToolbarModule = class {
|
|
|
766
780
|
const requestId = createRequestId2("object_properties");
|
|
767
781
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
768
782
|
return new Promise((resolve, reject) => {
|
|
783
|
+
var _a2;
|
|
769
784
|
const timer = setTimeout(() => {
|
|
770
785
|
off();
|
|
771
786
|
reject(new Error("Timeout while getting object properties list from viewer"));
|
|
@@ -776,7 +791,10 @@ var ToolbarModule = class {
|
|
|
776
791
|
off();
|
|
777
792
|
resolve(payload.properties);
|
|
778
793
|
});
|
|
779
|
-
this.postObjectPropertiesGetList({
|
|
794
|
+
this.postObjectPropertiesGetList({
|
|
795
|
+
requestId,
|
|
796
|
+
nodeIds: Array.from(new Set(((_a2 = options == null ? void 0 : options.nodeIds) != null ? _a2 : []).map(String).filter(Boolean)))
|
|
797
|
+
});
|
|
780
798
|
});
|
|
781
799
|
}
|
|
782
800
|
getLinkedObjects(options) {
|
|
@@ -1135,8 +1153,7 @@ var LanguageModule = class {
|
|
|
1135
1153
|
};
|
|
1136
1154
|
|
|
1137
1155
|
// src/modules/object-properties.module.ts
|
|
1138
|
-
var
|
|
1139
|
-
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "No object properties";
|
|
1156
|
+
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "Timeout while getting object properties from viewer";
|
|
1140
1157
|
function createObjectPropertiesError(message, errorStatus) {
|
|
1141
1158
|
const error = new Error(message);
|
|
1142
1159
|
error.name = "ObjectPropertiesError";
|
|
@@ -1146,57 +1163,55 @@ function createObjectPropertiesError(message, errorStatus) {
|
|
|
1146
1163
|
function createRequestId5(prefix) {
|
|
1147
1164
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1148
1165
|
}
|
|
1166
|
+
function normalizeNodeIds(nodeIds) {
|
|
1167
|
+
return Array.from(new Set(
|
|
1168
|
+
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
1169
|
+
));
|
|
1170
|
+
}
|
|
1149
1171
|
var ObjectPropertiesModule = class {
|
|
1150
1172
|
constructor(viewer) {
|
|
1151
1173
|
this.viewer = viewer;
|
|
1152
|
-
this.on = {
|
|
1153
|
-
change: (cb) => this.viewer._on("object-properties:changed", cb)
|
|
1154
|
-
};
|
|
1155
1174
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
if (typeof (options == null ? void 0 : options.debounceMs) === "number" && Number.isFinite(options.debounceMs)) {
|
|
1159
|
-
payload.debounceMs = options.debounceMs;
|
|
1160
|
-
}
|
|
1161
|
-
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1162
|
-
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1163
|
-
}
|
|
1164
|
-
this.viewer.postToViewer("viewer-object-properties-watch" /* OBJECT_PROPERTIES_WATCH */, payload);
|
|
1165
|
-
}
|
|
1166
|
-
unwatch() {
|
|
1167
|
-
this.viewer.postToViewer("viewer-object-properties-unwatch" /* OBJECT_PROPERTIES_UNWATCH */, {});
|
|
1175
|
+
get(nodeIds, options) {
|
|
1176
|
+
return this.getByNodeIds(nodeIds, options);
|
|
1168
1177
|
}
|
|
1169
|
-
|
|
1178
|
+
getByNodeIds(nodeIds, options) {
|
|
1170
1179
|
var _a;
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1180
|
+
const normalizedNodeIds = normalizeNodeIds(nodeIds);
|
|
1181
|
+
const requestId = createRequestId5("object_properties");
|
|
1182
|
+
if (normalizedNodeIds.length === 0) {
|
|
1183
|
+
return Promise.resolve({
|
|
1184
|
+
requestId,
|
|
1185
|
+
selectionKey: "",
|
|
1186
|
+
nodeIds: [],
|
|
1187
|
+
persistentIds: [],
|
|
1188
|
+
properties: [],
|
|
1189
|
+
timestamp: Date.now()
|
|
1190
|
+
});
|
|
1178
1191
|
}
|
|
1179
|
-
const
|
|
1180
|
-
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1192
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 12e4);
|
|
1181
1193
|
return new Promise((resolve, reject) => {
|
|
1182
1194
|
const timer = setTimeout(() => {
|
|
1183
|
-
this.pendingGetCurrent = void 0;
|
|
1184
1195
|
off();
|
|
1185
1196
|
reject(createObjectPropertiesError(OBJECT_PROPERTIES_TIMEOUT_ERROR, "TIMEOUT"));
|
|
1186
1197
|
}, timeoutMs);
|
|
1187
|
-
const off = this.viewer._on("object-properties:
|
|
1198
|
+
const off = this.viewer._on("object-properties:list", (payload2) => {
|
|
1188
1199
|
if (payload2.requestId !== requestId) return;
|
|
1189
1200
|
clearTimeout(timer);
|
|
1190
|
-
this.pendingGetCurrent = void 0;
|
|
1191
1201
|
off();
|
|
1192
1202
|
resolve(payload2);
|
|
1193
1203
|
});
|
|
1194
|
-
|
|
1195
|
-
|
|
1204
|
+
const payload = {
|
|
1205
|
+
requestId,
|
|
1206
|
+
nodeIds: normalizedNodeIds
|
|
1207
|
+
};
|
|
1208
|
+
if (typeof (options == null ? void 0 : options.expandToRealNodes) === "boolean") {
|
|
1209
|
+
payload.expandToRealNodes = options.expandToRealNodes;
|
|
1210
|
+
}
|
|
1196
1211
|
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1197
1212
|
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1198
1213
|
}
|
|
1199
|
-
this.viewer.postToViewer("viewer-object-properties-get-
|
|
1214
|
+
this.viewer.postToViewer("viewer-object-properties-get-list" /* OBJECT_PROPERTIES_GET_LIST */, payload);
|
|
1200
1215
|
});
|
|
1201
1216
|
}
|
|
1202
1217
|
};
|
|
@@ -1348,16 +1363,6 @@ var Viewer3D = class {
|
|
|
1348
1363
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties)) break;
|
|
1349
1364
|
this._emit("object-properties:list", {
|
|
1350
1365
|
requestId: String(payload.requestId),
|
|
1351
|
-
properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
|
|
1352
|
-
timestamp: Number(payload.timestamp) || Date.now()
|
|
1353
|
-
});
|
|
1354
|
-
break;
|
|
1355
|
-
}
|
|
1356
|
-
case "viewer-object-properties-changed" /* OBJECT_PROPERTIES_CHANGED */: {
|
|
1357
|
-
const payload = data.payload;
|
|
1358
|
-
if (!payload || !Array.isArray(payload.properties)) break;
|
|
1359
|
-
this._emit("object-properties:changed", {
|
|
1360
|
-
requestId: payload.requestId ? String(payload.requestId) : void 0,
|
|
1361
1366
|
selectionKey: String((_e = payload.selectionKey) != null ? _e : ""),
|
|
1362
1367
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1363
1368
|
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|