3dviewer-sdk 1.0.23 → 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 +59 -44
- package/dist/index.mjs +59 -44
- 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,58 +1179,65 @@ var LanguageModule = class {
|
|
|
1161
1179
|
};
|
|
1162
1180
|
|
|
1163
1181
|
// src/modules/object-properties.module.ts
|
|
1182
|
+
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "Timeout while getting object properties from viewer";
|
|
1183
|
+
function createObjectPropertiesError(message, errorStatus) {
|
|
1184
|
+
const error = new Error(message);
|
|
1185
|
+
error.name = "ObjectPropertiesError";
|
|
1186
|
+
error.errorStatus = errorStatus;
|
|
1187
|
+
return error;
|
|
1188
|
+
}
|
|
1164
1189
|
function createRequestId5(prefix) {
|
|
1165
1190
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1166
1191
|
}
|
|
1192
|
+
function normalizeNodeIds(nodeIds) {
|
|
1193
|
+
return Array.from(new Set(
|
|
1194
|
+
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
1195
|
+
));
|
|
1196
|
+
}
|
|
1167
1197
|
var ObjectPropertiesModule = class {
|
|
1168
1198
|
constructor(viewer) {
|
|
1169
1199
|
this.viewer = viewer;
|
|
1170
|
-
this.on = {
|
|
1171
|
-
change: (cb) => this.viewer._on("object-properties:changed", cb)
|
|
1172
|
-
};
|
|
1173
1200
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
if (typeof (options == null ? void 0 : options.debounceMs) === "number" && Number.isFinite(options.debounceMs)) {
|
|
1177
|
-
payload.debounceMs = options.debounceMs;
|
|
1178
|
-
}
|
|
1179
|
-
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1180
|
-
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1181
|
-
}
|
|
1182
|
-
this.viewer.postToViewer("viewer-object-properties-watch" /* OBJECT_PROPERTIES_WATCH */, payload);
|
|
1201
|
+
get(nodeIds, options) {
|
|
1202
|
+
return this.getByNodeIds(nodeIds, options);
|
|
1183
1203
|
}
|
|
1184
|
-
|
|
1185
|
-
this.viewer.postToViewer("viewer-object-properties-unwatch" /* OBJECT_PROPERTIES_UNWATCH */, {});
|
|
1186
|
-
}
|
|
1187
|
-
getCurrent(options) {
|
|
1204
|
+
getByNodeIds(nodeIds, options) {
|
|
1188
1205
|
var _a;
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
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
|
+
});
|
|
1194
1217
|
}
|
|
1195
|
-
const
|
|
1196
|
-
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);
|
|
1197
1219
|
return new Promise((resolve, reject) => {
|
|
1198
1220
|
const timer = setTimeout(() => {
|
|
1199
|
-
this.pendingGetCurrent = void 0;
|
|
1200
1221
|
off();
|
|
1201
|
-
reject(
|
|
1222
|
+
reject(createObjectPropertiesError(OBJECT_PROPERTIES_TIMEOUT_ERROR, "TIMEOUT"));
|
|
1202
1223
|
}, timeoutMs);
|
|
1203
|
-
const off = this.viewer._on("object-properties:
|
|
1224
|
+
const off = this.viewer._on("object-properties:list", (payload2) => {
|
|
1204
1225
|
if (payload2.requestId !== requestId) return;
|
|
1205
1226
|
clearTimeout(timer);
|
|
1206
|
-
this.pendingGetCurrent = void 0;
|
|
1207
1227
|
off();
|
|
1208
1228
|
resolve(payload2);
|
|
1209
1229
|
});
|
|
1210
|
-
|
|
1211
|
-
|
|
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
|
+
}
|
|
1212
1237
|
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1213
1238
|
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1214
1239
|
}
|
|
1215
|
-
this.viewer.postToViewer("viewer-object-properties-get-
|
|
1240
|
+
this.viewer.postToViewer("viewer-object-properties-get-list" /* OBJECT_PROPERTIES_GET_LIST */, payload);
|
|
1216
1241
|
});
|
|
1217
1242
|
}
|
|
1218
1243
|
};
|
|
@@ -1364,16 +1389,6 @@ var Viewer3D = class {
|
|
|
1364
1389
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties)) break;
|
|
1365
1390
|
this._emit("object-properties:list", {
|
|
1366
1391
|
requestId: String(payload.requestId),
|
|
1367
|
-
properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
|
|
1368
|
-
timestamp: Number(payload.timestamp) || Date.now()
|
|
1369
|
-
});
|
|
1370
|
-
break;
|
|
1371
|
-
}
|
|
1372
|
-
case "viewer-object-properties-changed" /* OBJECT_PROPERTIES_CHANGED */: {
|
|
1373
|
-
const payload = data.payload;
|
|
1374
|
-
if (!payload || !Array.isArray(payload.properties)) break;
|
|
1375
|
-
this._emit("object-properties:changed", {
|
|
1376
|
-
requestId: payload.requestId ? String(payload.requestId) : void 0,
|
|
1377
1392
|
selectionKey: String((_e = payload.selectionKey) != null ? _e : ""),
|
|
1378
1393
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1379
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,58 +1153,65 @@ var LanguageModule = class {
|
|
|
1135
1153
|
};
|
|
1136
1154
|
|
|
1137
1155
|
// src/modules/object-properties.module.ts
|
|
1156
|
+
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "Timeout while getting object properties from viewer";
|
|
1157
|
+
function createObjectPropertiesError(message, errorStatus) {
|
|
1158
|
+
const error = new Error(message);
|
|
1159
|
+
error.name = "ObjectPropertiesError";
|
|
1160
|
+
error.errorStatus = errorStatus;
|
|
1161
|
+
return error;
|
|
1162
|
+
}
|
|
1138
1163
|
function createRequestId5(prefix) {
|
|
1139
1164
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1140
1165
|
}
|
|
1166
|
+
function normalizeNodeIds(nodeIds) {
|
|
1167
|
+
return Array.from(new Set(
|
|
1168
|
+
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
1169
|
+
));
|
|
1170
|
+
}
|
|
1141
1171
|
var ObjectPropertiesModule = class {
|
|
1142
1172
|
constructor(viewer) {
|
|
1143
1173
|
this.viewer = viewer;
|
|
1144
|
-
this.on = {
|
|
1145
|
-
change: (cb) => this.viewer._on("object-properties:changed", cb)
|
|
1146
|
-
};
|
|
1147
1174
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
if (typeof (options == null ? void 0 : options.debounceMs) === "number" && Number.isFinite(options.debounceMs)) {
|
|
1151
|
-
payload.debounceMs = options.debounceMs;
|
|
1152
|
-
}
|
|
1153
|
-
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1154
|
-
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1155
|
-
}
|
|
1156
|
-
this.viewer.postToViewer("viewer-object-properties-watch" /* OBJECT_PROPERTIES_WATCH */, payload);
|
|
1175
|
+
get(nodeIds, options) {
|
|
1176
|
+
return this.getByNodeIds(nodeIds, options);
|
|
1157
1177
|
}
|
|
1158
|
-
|
|
1159
|
-
this.viewer.postToViewer("viewer-object-properties-unwatch" /* OBJECT_PROPERTIES_UNWATCH */, {});
|
|
1160
|
-
}
|
|
1161
|
-
getCurrent(options) {
|
|
1178
|
+
getByNodeIds(nodeIds, options) {
|
|
1162
1179
|
var _a;
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
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
|
+
});
|
|
1168
1191
|
}
|
|
1169
|
-
const
|
|
1170
|
-
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);
|
|
1171
1193
|
return new Promise((resolve, reject) => {
|
|
1172
1194
|
const timer = setTimeout(() => {
|
|
1173
|
-
this.pendingGetCurrent = void 0;
|
|
1174
1195
|
off();
|
|
1175
|
-
reject(
|
|
1196
|
+
reject(createObjectPropertiesError(OBJECT_PROPERTIES_TIMEOUT_ERROR, "TIMEOUT"));
|
|
1176
1197
|
}, timeoutMs);
|
|
1177
|
-
const off = this.viewer._on("object-properties:
|
|
1198
|
+
const off = this.viewer._on("object-properties:list", (payload2) => {
|
|
1178
1199
|
if (payload2.requestId !== requestId) return;
|
|
1179
1200
|
clearTimeout(timer);
|
|
1180
|
-
this.pendingGetCurrent = void 0;
|
|
1181
1201
|
off();
|
|
1182
1202
|
resolve(payload2);
|
|
1183
1203
|
});
|
|
1184
|
-
|
|
1185
|
-
|
|
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
|
+
}
|
|
1186
1211
|
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1187
1212
|
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1188
1213
|
}
|
|
1189
|
-
this.viewer.postToViewer("viewer-object-properties-get-
|
|
1214
|
+
this.viewer.postToViewer("viewer-object-properties-get-list" /* OBJECT_PROPERTIES_GET_LIST */, payload);
|
|
1190
1215
|
});
|
|
1191
1216
|
}
|
|
1192
1217
|
};
|
|
@@ -1338,16 +1363,6 @@ var Viewer3D = class {
|
|
|
1338
1363
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties)) break;
|
|
1339
1364
|
this._emit("object-properties:list", {
|
|
1340
1365
|
requestId: String(payload.requestId),
|
|
1341
|
-
properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
|
|
1342
|
-
timestamp: Number(payload.timestamp) || Date.now()
|
|
1343
|
-
});
|
|
1344
|
-
break;
|
|
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
1366
|
selectionKey: String((_e = payload.selectionKey) != null ? _e : ""),
|
|
1352
1367
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1353
1368
|
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|