3dviewer-sdk 1.0.24 → 1.0.26
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 +24 -28
- package/dist/index.d.ts +24 -28
- package/dist/index.js +67 -52
- package/dist/index.mjs +67 -52
- 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;
|
|
@@ -540,6 +541,7 @@ declare class ModelTreeModule {
|
|
|
540
541
|
constructor(viewer: Viewer3D);
|
|
541
542
|
open(): void;
|
|
542
543
|
selectNode(nodeId: string | number): void;
|
|
544
|
+
selectNodes(nodeIds: Array<string | number>): void;
|
|
543
545
|
setNodeVisibility(nodeIds: Array<string | number>, visible: boolean): void;
|
|
544
546
|
hideNode(nodeIds: Array<string | number>): void;
|
|
545
547
|
showNode(nodeIds: Array<string | number>): void;
|
|
@@ -548,6 +550,7 @@ declare class ModelTreeModule {
|
|
|
548
550
|
getTree(options?: GetNodesOptions): Promise<ModelTreeHierarchyNode[]>;
|
|
549
551
|
private requestNodes;
|
|
550
552
|
private resolveTimeoutMs;
|
|
553
|
+
private normalizeNodeIds;
|
|
551
554
|
private postPanelOpen;
|
|
552
555
|
private postTreeSelectNode;
|
|
553
556
|
private postTreeSetNodeVisibility;
|
|
@@ -587,24 +590,17 @@ declare class LanguageModule {
|
|
|
587
590
|
set(language: LanguageCode): void;
|
|
588
591
|
}
|
|
589
592
|
|
|
590
|
-
type
|
|
591
|
-
debounceMs?: number;
|
|
592
|
-
includeSelectionMeta?: boolean;
|
|
593
|
-
};
|
|
594
|
-
type ObjectPropertiesGetCurrentOptions = ObjectPropertiesWatchOptions & {
|
|
593
|
+
type ObjectPropertiesGetOptions = {
|
|
595
594
|
timeoutMs?: number;
|
|
595
|
+
expandToRealNodes?: boolean;
|
|
596
|
+
includeSelectionMeta?: boolean;
|
|
596
597
|
};
|
|
597
|
-
type
|
|
598
|
+
type ObjectPropertiesResult = ObjectPropertiesListPayload;
|
|
598
599
|
declare class ObjectPropertiesModule {
|
|
599
600
|
private viewer;
|
|
600
|
-
private pendingGetCurrent;
|
|
601
|
-
on: {
|
|
602
|
-
change: (cb: (payload: ObjectPropertiesChangedEvent) => void) => () => void;
|
|
603
|
-
};
|
|
604
601
|
constructor(viewer: Viewer3D);
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
getCurrent(options?: ObjectPropertiesGetCurrentOptions): Promise<ObjectPropertiesChangedEvent>;
|
|
602
|
+
get(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
603
|
+
getByNodeIds(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
608
604
|
}
|
|
609
605
|
|
|
610
606
|
type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
|
|
@@ -655,4 +651,4 @@ declare class Viewer3D {
|
|
|
655
651
|
private handleMessage;
|
|
656
652
|
}
|
|
657
653
|
|
|
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
|
|
654
|
+
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;
|
|
@@ -540,6 +541,7 @@ declare class ModelTreeModule {
|
|
|
540
541
|
constructor(viewer: Viewer3D);
|
|
541
542
|
open(): void;
|
|
542
543
|
selectNode(nodeId: string | number): void;
|
|
544
|
+
selectNodes(nodeIds: Array<string | number>): void;
|
|
543
545
|
setNodeVisibility(nodeIds: Array<string | number>, visible: boolean): void;
|
|
544
546
|
hideNode(nodeIds: Array<string | number>): void;
|
|
545
547
|
showNode(nodeIds: Array<string | number>): void;
|
|
@@ -548,6 +550,7 @@ declare class ModelTreeModule {
|
|
|
548
550
|
getTree(options?: GetNodesOptions): Promise<ModelTreeHierarchyNode[]>;
|
|
549
551
|
private requestNodes;
|
|
550
552
|
private resolveTimeoutMs;
|
|
553
|
+
private normalizeNodeIds;
|
|
551
554
|
private postPanelOpen;
|
|
552
555
|
private postTreeSelectNode;
|
|
553
556
|
private postTreeSetNodeVisibility;
|
|
@@ -587,24 +590,17 @@ declare class LanguageModule {
|
|
|
587
590
|
set(language: LanguageCode): void;
|
|
588
591
|
}
|
|
589
592
|
|
|
590
|
-
type
|
|
591
|
-
debounceMs?: number;
|
|
592
|
-
includeSelectionMeta?: boolean;
|
|
593
|
-
};
|
|
594
|
-
type ObjectPropertiesGetCurrentOptions = ObjectPropertiesWatchOptions & {
|
|
593
|
+
type ObjectPropertiesGetOptions = {
|
|
595
594
|
timeoutMs?: number;
|
|
595
|
+
expandToRealNodes?: boolean;
|
|
596
|
+
includeSelectionMeta?: boolean;
|
|
596
597
|
};
|
|
597
|
-
type
|
|
598
|
+
type ObjectPropertiesResult = ObjectPropertiesListPayload;
|
|
598
599
|
declare class ObjectPropertiesModule {
|
|
599
600
|
private viewer;
|
|
600
|
-
private pendingGetCurrent;
|
|
601
|
-
on: {
|
|
602
|
-
change: (cb: (payload: ObjectPropertiesChangedEvent) => void) => () => void;
|
|
603
|
-
};
|
|
604
601
|
constructor(viewer: Viewer3D);
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
getCurrent(options?: ObjectPropertiesGetCurrentOptions): Promise<ObjectPropertiesChangedEvent>;
|
|
602
|
+
get(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
603
|
+
getByNodeIds(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
608
604
|
}
|
|
609
605
|
|
|
610
606
|
type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
|
|
@@ -655,4 +651,4 @@ declare class Viewer3D {
|
|
|
655
651
|
private handleMessage;
|
|
656
652
|
}
|
|
657
653
|
|
|
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
|
|
654
|
+
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) {
|
|
@@ -960,12 +978,15 @@ var ModelTreeModule = class {
|
|
|
960
978
|
nodeId: String(nodeId)
|
|
961
979
|
});
|
|
962
980
|
}
|
|
981
|
+
selectNodes(nodeIds) {
|
|
982
|
+
const normalizedNodeIds = this.normalizeNodeIds(nodeIds);
|
|
983
|
+
if (normalizedNodeIds.length === 0) return;
|
|
984
|
+
this.postTreeSelectNode({
|
|
985
|
+
nodeIds: normalizedNodeIds
|
|
986
|
+
});
|
|
987
|
+
}
|
|
963
988
|
setNodeVisibility(nodeIds, visible) {
|
|
964
|
-
const normalizedNodeIds =
|
|
965
|
-
new Set(
|
|
966
|
-
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
967
|
-
)
|
|
968
|
-
);
|
|
989
|
+
const normalizedNodeIds = this.normalizeNodeIds(nodeIds);
|
|
969
990
|
if (normalizedNodeIds.length === 0) return;
|
|
970
991
|
this.postTreeSetNodeVisibility({
|
|
971
992
|
nodeIds: normalizedNodeIds,
|
|
@@ -1032,6 +1053,13 @@ var ModelTreeModule = class {
|
|
|
1032
1053
|
var _a;
|
|
1033
1054
|
return Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1034
1055
|
}
|
|
1056
|
+
normalizeNodeIds(nodeIds) {
|
|
1057
|
+
return Array.from(
|
|
1058
|
+
new Set(
|
|
1059
|
+
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
1060
|
+
)
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1035
1063
|
postPanelOpen(payload) {
|
|
1036
1064
|
this.viewer.postToViewer("viewer-panel-open" /* PANEL_OPEN */, payload);
|
|
1037
1065
|
}
|
|
@@ -1161,8 +1189,7 @@ var LanguageModule = class {
|
|
|
1161
1189
|
};
|
|
1162
1190
|
|
|
1163
1191
|
// src/modules/object-properties.module.ts
|
|
1164
|
-
var
|
|
1165
|
-
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "No object properties";
|
|
1192
|
+
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "Timeout while getting object properties from viewer";
|
|
1166
1193
|
function createObjectPropertiesError(message, errorStatus) {
|
|
1167
1194
|
const error = new Error(message);
|
|
1168
1195
|
error.name = "ObjectPropertiesError";
|
|
@@ -1172,57 +1199,55 @@ function createObjectPropertiesError(message, errorStatus) {
|
|
|
1172
1199
|
function createRequestId5(prefix) {
|
|
1173
1200
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1174
1201
|
}
|
|
1202
|
+
function normalizeNodeIds(nodeIds) {
|
|
1203
|
+
return Array.from(new Set(
|
|
1204
|
+
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
1205
|
+
));
|
|
1206
|
+
}
|
|
1175
1207
|
var ObjectPropertiesModule = class {
|
|
1176
1208
|
constructor(viewer) {
|
|
1177
1209
|
this.viewer = viewer;
|
|
1178
|
-
this.on = {
|
|
1179
|
-
change: (cb) => this.viewer._on("object-properties:changed", cb)
|
|
1180
|
-
};
|
|
1181
1210
|
}
|
|
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);
|
|
1211
|
+
get(nodeIds, options) {
|
|
1212
|
+
return this.getByNodeIds(nodeIds, options);
|
|
1191
1213
|
}
|
|
1192
|
-
|
|
1193
|
-
this.viewer.postToViewer("viewer-object-properties-unwatch" /* OBJECT_PROPERTIES_UNWATCH */, {});
|
|
1194
|
-
}
|
|
1195
|
-
getCurrent(options) {
|
|
1214
|
+
getByNodeIds(nodeIds, options) {
|
|
1196
1215
|
var _a;
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1216
|
+
const normalizedNodeIds = normalizeNodeIds(nodeIds);
|
|
1217
|
+
const requestId = createRequestId5("object_properties");
|
|
1218
|
+
if (normalizedNodeIds.length === 0) {
|
|
1219
|
+
return Promise.resolve({
|
|
1220
|
+
requestId,
|
|
1221
|
+
selectionKey: "",
|
|
1222
|
+
nodeIds: [],
|
|
1223
|
+
persistentIds: [],
|
|
1224
|
+
properties: [],
|
|
1225
|
+
timestamp: Date.now()
|
|
1226
|
+
});
|
|
1204
1227
|
}
|
|
1205
|
-
const
|
|
1206
|
-
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1228
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 12e4);
|
|
1207
1229
|
return new Promise((resolve, reject) => {
|
|
1208
1230
|
const timer = setTimeout(() => {
|
|
1209
|
-
this.pendingGetCurrent = void 0;
|
|
1210
1231
|
off();
|
|
1211
1232
|
reject(createObjectPropertiesError(OBJECT_PROPERTIES_TIMEOUT_ERROR, "TIMEOUT"));
|
|
1212
1233
|
}, timeoutMs);
|
|
1213
|
-
const off = this.viewer._on("object-properties:
|
|
1234
|
+
const off = this.viewer._on("object-properties:list", (payload2) => {
|
|
1214
1235
|
if (payload2.requestId !== requestId) return;
|
|
1215
1236
|
clearTimeout(timer);
|
|
1216
|
-
this.pendingGetCurrent = void 0;
|
|
1217
1237
|
off();
|
|
1218
1238
|
resolve(payload2);
|
|
1219
1239
|
});
|
|
1220
|
-
|
|
1221
|
-
|
|
1240
|
+
const payload = {
|
|
1241
|
+
requestId,
|
|
1242
|
+
nodeIds: normalizedNodeIds
|
|
1243
|
+
};
|
|
1244
|
+
if (typeof (options == null ? void 0 : options.expandToRealNodes) === "boolean") {
|
|
1245
|
+
payload.expandToRealNodes = options.expandToRealNodes;
|
|
1246
|
+
}
|
|
1222
1247
|
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1223
1248
|
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1224
1249
|
}
|
|
1225
|
-
this.viewer.postToViewer("viewer-object-properties-get-
|
|
1250
|
+
this.viewer.postToViewer("viewer-object-properties-get-list" /* OBJECT_PROPERTIES_GET_LIST */, payload);
|
|
1226
1251
|
});
|
|
1227
1252
|
}
|
|
1228
1253
|
};
|
|
@@ -1374,16 +1399,6 @@ var Viewer3D = class {
|
|
|
1374
1399
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties)) break;
|
|
1375
1400
|
this._emit("object-properties:list", {
|
|
1376
1401
|
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
1402
|
selectionKey: String((_e = payload.selectionKey) != null ? _e : ""),
|
|
1388
1403
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1389
1404
|
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) {
|
|
@@ -934,12 +952,15 @@ var ModelTreeModule = class {
|
|
|
934
952
|
nodeId: String(nodeId)
|
|
935
953
|
});
|
|
936
954
|
}
|
|
955
|
+
selectNodes(nodeIds) {
|
|
956
|
+
const normalizedNodeIds = this.normalizeNodeIds(nodeIds);
|
|
957
|
+
if (normalizedNodeIds.length === 0) return;
|
|
958
|
+
this.postTreeSelectNode({
|
|
959
|
+
nodeIds: normalizedNodeIds
|
|
960
|
+
});
|
|
961
|
+
}
|
|
937
962
|
setNodeVisibility(nodeIds, visible) {
|
|
938
|
-
const normalizedNodeIds =
|
|
939
|
-
new Set(
|
|
940
|
-
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
941
|
-
)
|
|
942
|
-
);
|
|
963
|
+
const normalizedNodeIds = this.normalizeNodeIds(nodeIds);
|
|
943
964
|
if (normalizedNodeIds.length === 0) return;
|
|
944
965
|
this.postTreeSetNodeVisibility({
|
|
945
966
|
nodeIds: normalizedNodeIds,
|
|
@@ -1006,6 +1027,13 @@ var ModelTreeModule = class {
|
|
|
1006
1027
|
var _a;
|
|
1007
1028
|
return Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1008
1029
|
}
|
|
1030
|
+
normalizeNodeIds(nodeIds) {
|
|
1031
|
+
return Array.from(
|
|
1032
|
+
new Set(
|
|
1033
|
+
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
1034
|
+
)
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1009
1037
|
postPanelOpen(payload) {
|
|
1010
1038
|
this.viewer.postToViewer("viewer-panel-open" /* PANEL_OPEN */, payload);
|
|
1011
1039
|
}
|
|
@@ -1135,8 +1163,7 @@ var LanguageModule = class {
|
|
|
1135
1163
|
};
|
|
1136
1164
|
|
|
1137
1165
|
// src/modules/object-properties.module.ts
|
|
1138
|
-
var
|
|
1139
|
-
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "No object properties";
|
|
1166
|
+
var OBJECT_PROPERTIES_TIMEOUT_ERROR = "Timeout while getting object properties from viewer";
|
|
1140
1167
|
function createObjectPropertiesError(message, errorStatus) {
|
|
1141
1168
|
const error = new Error(message);
|
|
1142
1169
|
error.name = "ObjectPropertiesError";
|
|
@@ -1146,57 +1173,55 @@ function createObjectPropertiesError(message, errorStatus) {
|
|
|
1146
1173
|
function createRequestId5(prefix) {
|
|
1147
1174
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1148
1175
|
}
|
|
1176
|
+
function normalizeNodeIds(nodeIds) {
|
|
1177
|
+
return Array.from(new Set(
|
|
1178
|
+
nodeIds.map((nodeId) => String(nodeId).trim()).filter((nodeId) => nodeId !== "")
|
|
1179
|
+
));
|
|
1180
|
+
}
|
|
1149
1181
|
var ObjectPropertiesModule = class {
|
|
1150
1182
|
constructor(viewer) {
|
|
1151
1183
|
this.viewer = viewer;
|
|
1152
|
-
this.on = {
|
|
1153
|
-
change: (cb) => this.viewer._on("object-properties:changed", cb)
|
|
1154
|
-
};
|
|
1155
1184
|
}
|
|
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);
|
|
1185
|
+
get(nodeIds, options) {
|
|
1186
|
+
return this.getByNodeIds(nodeIds, options);
|
|
1165
1187
|
}
|
|
1166
|
-
|
|
1167
|
-
this.viewer.postToViewer("viewer-object-properties-unwatch" /* OBJECT_PROPERTIES_UNWATCH */, {});
|
|
1168
|
-
}
|
|
1169
|
-
getCurrent(options) {
|
|
1188
|
+
getByNodeIds(nodeIds, options) {
|
|
1170
1189
|
var _a;
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1190
|
+
const normalizedNodeIds = normalizeNodeIds(nodeIds);
|
|
1191
|
+
const requestId = createRequestId5("object_properties");
|
|
1192
|
+
if (normalizedNodeIds.length === 0) {
|
|
1193
|
+
return Promise.resolve({
|
|
1194
|
+
requestId,
|
|
1195
|
+
selectionKey: "",
|
|
1196
|
+
nodeIds: [],
|
|
1197
|
+
persistentIds: [],
|
|
1198
|
+
properties: [],
|
|
1199
|
+
timestamp: Date.now()
|
|
1200
|
+
});
|
|
1178
1201
|
}
|
|
1179
|
-
const
|
|
1180
|
-
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1202
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 12e4);
|
|
1181
1203
|
return new Promise((resolve, reject) => {
|
|
1182
1204
|
const timer = setTimeout(() => {
|
|
1183
|
-
this.pendingGetCurrent = void 0;
|
|
1184
1205
|
off();
|
|
1185
1206
|
reject(createObjectPropertiesError(OBJECT_PROPERTIES_TIMEOUT_ERROR, "TIMEOUT"));
|
|
1186
1207
|
}, timeoutMs);
|
|
1187
|
-
const off = this.viewer._on("object-properties:
|
|
1208
|
+
const off = this.viewer._on("object-properties:list", (payload2) => {
|
|
1188
1209
|
if (payload2.requestId !== requestId) return;
|
|
1189
1210
|
clearTimeout(timer);
|
|
1190
|
-
this.pendingGetCurrent = void 0;
|
|
1191
1211
|
off();
|
|
1192
1212
|
resolve(payload2);
|
|
1193
1213
|
});
|
|
1194
|
-
|
|
1195
|
-
|
|
1214
|
+
const payload = {
|
|
1215
|
+
requestId,
|
|
1216
|
+
nodeIds: normalizedNodeIds
|
|
1217
|
+
};
|
|
1218
|
+
if (typeof (options == null ? void 0 : options.expandToRealNodes) === "boolean") {
|
|
1219
|
+
payload.expandToRealNodes = options.expandToRealNodes;
|
|
1220
|
+
}
|
|
1196
1221
|
if (typeof (options == null ? void 0 : options.includeSelectionMeta) === "boolean") {
|
|
1197
1222
|
payload.includeSelectionMeta = options.includeSelectionMeta;
|
|
1198
1223
|
}
|
|
1199
|
-
this.viewer.postToViewer("viewer-object-properties-get-
|
|
1224
|
+
this.viewer.postToViewer("viewer-object-properties-get-list" /* OBJECT_PROPERTIES_GET_LIST */, payload);
|
|
1200
1225
|
});
|
|
1201
1226
|
}
|
|
1202
1227
|
};
|
|
@@ -1348,16 +1373,6 @@ var Viewer3D = class {
|
|
|
1348
1373
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties)) break;
|
|
1349
1374
|
this._emit("object-properties:list", {
|
|
1350
1375
|
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
1376
|
selectionKey: String((_e = payload.selectionKey) != null ? _e : ""),
|
|
1362
1377
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1363
1378
|
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|