3dviewer-sdk 1.1.7 → 1.1.8
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 +70 -1
- package/dist/index.d.ts +70 -1
- package/dist/index.js +144 -4
- package/dist/index.mjs +144 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -32,6 +32,10 @@ declare enum ViewerMessageType {
|
|
|
32
32
|
SHEETS_GET_LIST = "viewer-sheets-get-list",
|
|
33
33
|
SHEETS_LIST = "viewer-sheets-list",
|
|
34
34
|
SHEETS_APPLY = "viewer-sheets-apply",
|
|
35
|
+
VIEWS_GET_LIST = "viewer-views-get-list",
|
|
36
|
+
VIEWS_LIST = "viewer-views-list",
|
|
37
|
+
VIEWS_APPLY = "viewer-views-apply",
|
|
38
|
+
VIEWS_APPLY_RESULT = "viewer-views-apply-result",
|
|
35
39
|
OBJECT_PROPERTIES_GET_LIST = "viewer-object-properties-get-list",
|
|
36
40
|
OBJECT_PROPERTIES_LIST = "viewer-object-properties-list",
|
|
37
41
|
LINKED_OBJECTS_GET_LIST = "viewer-linked-objects-get-list",
|
|
@@ -124,6 +128,37 @@ type SheetListItem = {
|
|
|
124
128
|
is3D?: boolean;
|
|
125
129
|
viewId?: string;
|
|
126
130
|
};
|
|
131
|
+
type SdkViewType = "cad" | "saved";
|
|
132
|
+
type SdkViewItem = {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
type: SdkViewType;
|
|
136
|
+
modelFileId?: string;
|
|
137
|
+
sheetId?: string | number | null;
|
|
138
|
+
createdBy?: string;
|
|
139
|
+
createdDate?: number;
|
|
140
|
+
modifiedDate?: number;
|
|
141
|
+
isPerspective?: boolean;
|
|
142
|
+
drawMode?: number;
|
|
143
|
+
};
|
|
144
|
+
type ViewsListPayload = {
|
|
145
|
+
requestId: string;
|
|
146
|
+
success: boolean;
|
|
147
|
+
cadViews: SdkViewItem[];
|
|
148
|
+
savedViews: SdkViewItem[];
|
|
149
|
+
selectedViewId?: string | null;
|
|
150
|
+
selectedViewType?: SdkViewType | null;
|
|
151
|
+
timestamp: number;
|
|
152
|
+
error?: string;
|
|
153
|
+
};
|
|
154
|
+
type ViewsApplyResultPayload = {
|
|
155
|
+
requestId: string;
|
|
156
|
+
success: boolean;
|
|
157
|
+
id: string;
|
|
158
|
+
type: SdkViewType;
|
|
159
|
+
timestamp: number;
|
|
160
|
+
error?: string;
|
|
161
|
+
};
|
|
127
162
|
type ObjectPropertyItem = Record<string, unknown>;
|
|
128
163
|
type ObjectPropertiesListPayload = {
|
|
129
164
|
requestId: string;
|
|
@@ -231,6 +266,8 @@ type ViewerEventMap = {
|
|
|
231
266
|
activeSheetId?: string | number | null;
|
|
232
267
|
timestamp: number;
|
|
233
268
|
};
|
|
269
|
+
"views:list": ViewsListPayload;
|
|
270
|
+
"views:apply-result": ViewsApplyResultPayload;
|
|
234
271
|
"object-properties:list": ObjectPropertiesListPayload;
|
|
235
272
|
"linked-objects:list": {
|
|
236
273
|
requestId: string;
|
|
@@ -696,6 +733,37 @@ declare class ObjectPropertiesModule {
|
|
|
696
733
|
getByNodeIds(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
697
734
|
}
|
|
698
735
|
|
|
736
|
+
type GetViewsOptions = {
|
|
737
|
+
timeoutMs?: number;
|
|
738
|
+
};
|
|
739
|
+
type ApplyViewInput = {
|
|
740
|
+
id: string;
|
|
741
|
+
type: SdkViewType;
|
|
742
|
+
};
|
|
743
|
+
type ApplyViewOptions = {
|
|
744
|
+
timeoutMs?: number;
|
|
745
|
+
};
|
|
746
|
+
type ApplyViewResult = {
|
|
747
|
+
id: string;
|
|
748
|
+
type: SdkViewType;
|
|
749
|
+
timestamp: number;
|
|
750
|
+
};
|
|
751
|
+
type SdkViewsList = {
|
|
752
|
+
cadViews: SdkViewItem[];
|
|
753
|
+
savedViews: SdkViewItem[];
|
|
754
|
+
selectedViewId?: string | null;
|
|
755
|
+
selectedViewType?: SdkViewType | null;
|
|
756
|
+
timestamp: number;
|
|
757
|
+
};
|
|
758
|
+
declare class ViewsModule {
|
|
759
|
+
private viewer;
|
|
760
|
+
constructor(viewer: Viewer3D);
|
|
761
|
+
getViews(options?: GetViewsOptions): Promise<SdkViewsList>;
|
|
762
|
+
getCadViews(options?: GetViewsOptions): Promise<SdkViewItem[]>;
|
|
763
|
+
getSavedViews(options?: GetViewsOptions): Promise<SdkViewItem[]>;
|
|
764
|
+
applyView(input: ApplyViewInput, options?: ApplyViewOptions): Promise<ApplyViewResult>;
|
|
765
|
+
}
|
|
766
|
+
|
|
699
767
|
type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
|
|
700
768
|
type Viewer3DOptions = {
|
|
701
769
|
container: HTMLElement | string;
|
|
@@ -735,6 +803,7 @@ declare class Viewer3D {
|
|
|
735
803
|
markup: MarkupModule;
|
|
736
804
|
language: LanguageModule;
|
|
737
805
|
objectProperties: ObjectPropertiesModule;
|
|
806
|
+
views: ViewsModule;
|
|
738
807
|
constructor(options: Viewer3DOptions);
|
|
739
808
|
getOptions(): Viewer3DOptions;
|
|
740
809
|
patchOptions(next: Partial<Viewer3DOptions>): void;
|
|
@@ -764,4 +833,4 @@ declare class Viewer3D {
|
|
|
764
833
|
private handleMessage;
|
|
765
834
|
}
|
|
766
835
|
|
|
767
|
-
export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type CreatePipelineOptions, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type GetLockedStatePayload, type InitialBackground, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type LockedState, type LockedStatePayload, type LockedStateRequestOptions, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, type SetBackgroundOptions, type SyncLockedStateInput, type SyncLockedStatePayload, Viewer3D, type Viewer3DOptions, type ViewerBackgroundColorInput, type ViewerBackgroundPayload, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload, type ViewerRgbColor, type ViewerRgbaColor };
|
|
836
|
+
export { type ApplyViewInput, type ApplyViewOptions, type ApplyViewResult, type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type CreatePipelineOptions, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type GetLockedStatePayload, type GetViewsOptions, type InitialBackground, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type LockedState, type LockedStatePayload, type LockedStateRequestOptions, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, type SdkViewItem, type SdkViewType, type SdkViewsList, type SetBackgroundOptions, type SyncLockedStateInput, type SyncLockedStatePayload, Viewer3D, type Viewer3DOptions, type ViewerBackgroundColorInput, type ViewerBackgroundPayload, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload, type ViewerRgbColor, type ViewerRgbaColor, type ViewsApplyResultPayload, type ViewsListPayload };
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ declare enum ViewerMessageType {
|
|
|
32
32
|
SHEETS_GET_LIST = "viewer-sheets-get-list",
|
|
33
33
|
SHEETS_LIST = "viewer-sheets-list",
|
|
34
34
|
SHEETS_APPLY = "viewer-sheets-apply",
|
|
35
|
+
VIEWS_GET_LIST = "viewer-views-get-list",
|
|
36
|
+
VIEWS_LIST = "viewer-views-list",
|
|
37
|
+
VIEWS_APPLY = "viewer-views-apply",
|
|
38
|
+
VIEWS_APPLY_RESULT = "viewer-views-apply-result",
|
|
35
39
|
OBJECT_PROPERTIES_GET_LIST = "viewer-object-properties-get-list",
|
|
36
40
|
OBJECT_PROPERTIES_LIST = "viewer-object-properties-list",
|
|
37
41
|
LINKED_OBJECTS_GET_LIST = "viewer-linked-objects-get-list",
|
|
@@ -124,6 +128,37 @@ type SheetListItem = {
|
|
|
124
128
|
is3D?: boolean;
|
|
125
129
|
viewId?: string;
|
|
126
130
|
};
|
|
131
|
+
type SdkViewType = "cad" | "saved";
|
|
132
|
+
type SdkViewItem = {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
type: SdkViewType;
|
|
136
|
+
modelFileId?: string;
|
|
137
|
+
sheetId?: string | number | null;
|
|
138
|
+
createdBy?: string;
|
|
139
|
+
createdDate?: number;
|
|
140
|
+
modifiedDate?: number;
|
|
141
|
+
isPerspective?: boolean;
|
|
142
|
+
drawMode?: number;
|
|
143
|
+
};
|
|
144
|
+
type ViewsListPayload = {
|
|
145
|
+
requestId: string;
|
|
146
|
+
success: boolean;
|
|
147
|
+
cadViews: SdkViewItem[];
|
|
148
|
+
savedViews: SdkViewItem[];
|
|
149
|
+
selectedViewId?: string | null;
|
|
150
|
+
selectedViewType?: SdkViewType | null;
|
|
151
|
+
timestamp: number;
|
|
152
|
+
error?: string;
|
|
153
|
+
};
|
|
154
|
+
type ViewsApplyResultPayload = {
|
|
155
|
+
requestId: string;
|
|
156
|
+
success: boolean;
|
|
157
|
+
id: string;
|
|
158
|
+
type: SdkViewType;
|
|
159
|
+
timestamp: number;
|
|
160
|
+
error?: string;
|
|
161
|
+
};
|
|
127
162
|
type ObjectPropertyItem = Record<string, unknown>;
|
|
128
163
|
type ObjectPropertiesListPayload = {
|
|
129
164
|
requestId: string;
|
|
@@ -231,6 +266,8 @@ type ViewerEventMap = {
|
|
|
231
266
|
activeSheetId?: string | number | null;
|
|
232
267
|
timestamp: number;
|
|
233
268
|
};
|
|
269
|
+
"views:list": ViewsListPayload;
|
|
270
|
+
"views:apply-result": ViewsApplyResultPayload;
|
|
234
271
|
"object-properties:list": ObjectPropertiesListPayload;
|
|
235
272
|
"linked-objects:list": {
|
|
236
273
|
requestId: string;
|
|
@@ -696,6 +733,37 @@ declare class ObjectPropertiesModule {
|
|
|
696
733
|
getByNodeIds(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
697
734
|
}
|
|
698
735
|
|
|
736
|
+
type GetViewsOptions = {
|
|
737
|
+
timeoutMs?: number;
|
|
738
|
+
};
|
|
739
|
+
type ApplyViewInput = {
|
|
740
|
+
id: string;
|
|
741
|
+
type: SdkViewType;
|
|
742
|
+
};
|
|
743
|
+
type ApplyViewOptions = {
|
|
744
|
+
timeoutMs?: number;
|
|
745
|
+
};
|
|
746
|
+
type ApplyViewResult = {
|
|
747
|
+
id: string;
|
|
748
|
+
type: SdkViewType;
|
|
749
|
+
timestamp: number;
|
|
750
|
+
};
|
|
751
|
+
type SdkViewsList = {
|
|
752
|
+
cadViews: SdkViewItem[];
|
|
753
|
+
savedViews: SdkViewItem[];
|
|
754
|
+
selectedViewId?: string | null;
|
|
755
|
+
selectedViewType?: SdkViewType | null;
|
|
756
|
+
timestamp: number;
|
|
757
|
+
};
|
|
758
|
+
declare class ViewsModule {
|
|
759
|
+
private viewer;
|
|
760
|
+
constructor(viewer: Viewer3D);
|
|
761
|
+
getViews(options?: GetViewsOptions): Promise<SdkViewsList>;
|
|
762
|
+
getCadViews(options?: GetViewsOptions): Promise<SdkViewItem[]>;
|
|
763
|
+
getSavedViews(options?: GetViewsOptions): Promise<SdkViewItem[]>;
|
|
764
|
+
applyView(input: ApplyViewInput, options?: ApplyViewOptions): Promise<ApplyViewResult>;
|
|
765
|
+
}
|
|
766
|
+
|
|
699
767
|
type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
|
|
700
768
|
type Viewer3DOptions = {
|
|
701
769
|
container: HTMLElement | string;
|
|
@@ -735,6 +803,7 @@ declare class Viewer3D {
|
|
|
735
803
|
markup: MarkupModule;
|
|
736
804
|
language: LanguageModule;
|
|
737
805
|
objectProperties: ObjectPropertiesModule;
|
|
806
|
+
views: ViewsModule;
|
|
738
807
|
constructor(options: Viewer3DOptions);
|
|
739
808
|
getOptions(): Viewer3DOptions;
|
|
740
809
|
patchOptions(next: Partial<Viewer3DOptions>): void;
|
|
@@ -764,4 +833,4 @@ declare class Viewer3D {
|
|
|
764
833
|
private handleMessage;
|
|
765
834
|
}
|
|
766
835
|
|
|
767
|
-
export { type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type CreatePipelineOptions, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type GetLockedStatePayload, type InitialBackground, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type LockedState, type LockedStatePayload, type LockedStateRequestOptions, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, type SetBackgroundOptions, type SyncLockedStateInput, type SyncLockedStatePayload, Viewer3D, type Viewer3DOptions, type ViewerBackgroundColorInput, type ViewerBackgroundPayload, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload, type ViewerRgbColor, type ViewerRgbaColor };
|
|
836
|
+
export { type ApplyViewInput, type ApplyViewOptions, type ApplyViewResult, type CameraZoomPayload, type ConvertOptions, type ConvertV2Options, type CreatePipelineOptions, type FileInfoCheckInput, type FileInfoCheckPayloadItem, type FilesConfig, type GetLockedStatePayload, type GetViewsOptions, type InitialBackground, type InitialToolbarUse, type LanguageCode, type LoadStage, type LoadStatePayload, type LockedState, type LockedStatePayload, type LockedStateRequestOptions, type MarkupAction, type MarkupListItem, type MarkupOperationResultPayload, type ObjectPropertiesGetOptions, type ObjectPropertiesResult, type PreparedViewerData, type SdkViewItem, type SdkViewType, type SdkViewsList, type SetBackgroundOptions, type SyncLockedStateInput, type SyncLockedStatePayload, Viewer3D, type Viewer3DOptions, type ViewerBackgroundColorInput, type ViewerBackgroundPayload, type ViewerLoadingChangePayload, type ViewerLoadingPhase, type ViewerReadyPayload, type ViewerRgbColor, type ViewerRgbaColor, type ViewsApplyResultPayload, type ViewsListPayload };
|
package/dist/index.js
CHANGED
|
@@ -1523,6 +1523,89 @@ var ObjectPropertiesModule = class {
|
|
|
1523
1523
|
}
|
|
1524
1524
|
};
|
|
1525
1525
|
|
|
1526
|
+
// src/modules/views.module.ts
|
|
1527
|
+
function createRequestId7(prefix) {
|
|
1528
|
+
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1529
|
+
}
|
|
1530
|
+
var ViewsModule = class {
|
|
1531
|
+
constructor(viewer) {
|
|
1532
|
+
this.viewer = viewer;
|
|
1533
|
+
}
|
|
1534
|
+
getViews(options) {
|
|
1535
|
+
var _a;
|
|
1536
|
+
const requestId = createRequestId7("views");
|
|
1537
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1538
|
+
return new Promise((resolve, reject) => {
|
|
1539
|
+
const timer = setTimeout(() => {
|
|
1540
|
+
off();
|
|
1541
|
+
reject(new Error("Timeout while getting views list from viewer"));
|
|
1542
|
+
}, timeoutMs);
|
|
1543
|
+
const off = this.viewer._on("views:list", (payload) => {
|
|
1544
|
+
var _a2, _b;
|
|
1545
|
+
if (payload.requestId !== requestId) return;
|
|
1546
|
+
clearTimeout(timer);
|
|
1547
|
+
off();
|
|
1548
|
+
if (!payload.success) {
|
|
1549
|
+
reject(new Error(payload.error || "Viewer failed to load views"));
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
resolve({
|
|
1553
|
+
cadViews: payload.cadViews,
|
|
1554
|
+
savedViews: payload.savedViews,
|
|
1555
|
+
selectedViewId: (_a2 = payload.selectedViewId) != null ? _a2 : null,
|
|
1556
|
+
selectedViewType: (_b = payload.selectedViewType) != null ? _b : null,
|
|
1557
|
+
timestamp: payload.timestamp
|
|
1558
|
+
});
|
|
1559
|
+
});
|
|
1560
|
+
this.viewer.postToViewer(
|
|
1561
|
+
"viewer-views-get-list" /* VIEWS_GET_LIST */,
|
|
1562
|
+
{ requestId }
|
|
1563
|
+
);
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
async getCadViews(options) {
|
|
1567
|
+
const views = await this.getViews(options);
|
|
1568
|
+
return views.cadViews;
|
|
1569
|
+
}
|
|
1570
|
+
async getSavedViews(options) {
|
|
1571
|
+
const views = await this.getViews(options);
|
|
1572
|
+
return views.savedViews;
|
|
1573
|
+
}
|
|
1574
|
+
applyView(input, options) {
|
|
1575
|
+
var _a;
|
|
1576
|
+
const requestId = createRequestId7("views-apply");
|
|
1577
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1578
|
+
return new Promise((resolve, reject) => {
|
|
1579
|
+
const timer = setTimeout(() => {
|
|
1580
|
+
off();
|
|
1581
|
+
reject(new Error("Timeout while waiting for view apply result from viewer"));
|
|
1582
|
+
}, timeoutMs);
|
|
1583
|
+
const off = this.viewer._on(
|
|
1584
|
+
"views:apply-result",
|
|
1585
|
+
(payload) => {
|
|
1586
|
+
if (payload.requestId !== requestId) return;
|
|
1587
|
+
clearTimeout(timer);
|
|
1588
|
+
off();
|
|
1589
|
+
if (!payload.success) {
|
|
1590
|
+
reject(new Error(payload.error || "Viewer failed to apply view"));
|
|
1591
|
+
return;
|
|
1592
|
+
}
|
|
1593
|
+
resolve({
|
|
1594
|
+
id: payload.id,
|
|
1595
|
+
type: payload.type,
|
|
1596
|
+
timestamp: payload.timestamp
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
);
|
|
1600
|
+
this.viewer.postToViewer("viewer-views-apply" /* VIEWS_APPLY */, {
|
|
1601
|
+
requestId,
|
|
1602
|
+
id: input.id,
|
|
1603
|
+
type: input.type
|
|
1604
|
+
});
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1526
1609
|
// src/viewer.ts
|
|
1527
1610
|
var Viewer3D = class {
|
|
1528
1611
|
constructor(options) {
|
|
@@ -1539,7 +1622,7 @@ var Viewer3D = class {
|
|
|
1539
1622
|
};
|
|
1540
1623
|
this.emitter = new Emitter();
|
|
1541
1624
|
this.handleMessage = (event) => {
|
|
1542
|
-
var _a, _b, _c;
|
|
1625
|
+
var _a, _b, _c, _d;
|
|
1543
1626
|
const data = event.data;
|
|
1544
1627
|
if (!data || typeof data !== "object") return;
|
|
1545
1628
|
switch (data.type) {
|
|
@@ -1739,13 +1822,69 @@ var Viewer3D = class {
|
|
|
1739
1822
|
});
|
|
1740
1823
|
break;
|
|
1741
1824
|
}
|
|
1825
|
+
case "viewer-views-list" /* VIEWS_LIST */: {
|
|
1826
|
+
const payload = data.payload;
|
|
1827
|
+
if (!payload || !payload.requestId) break;
|
|
1828
|
+
this._emit("views:list", {
|
|
1829
|
+
requestId: String(payload.requestId),
|
|
1830
|
+
success: Boolean(payload.success),
|
|
1831
|
+
cadViews: Array.isArray(payload.cadViews) ? payload.cadViews.filter((item) => item && typeof item === "object").map((item) => {
|
|
1832
|
+
var _a2, _b2, _c2;
|
|
1833
|
+
return {
|
|
1834
|
+
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1835
|
+
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
1836
|
+
type: item.type === "saved" ? "saved" : "cad",
|
|
1837
|
+
modelFileId: item.modelFileId ? String(item.modelFileId) : void 0,
|
|
1838
|
+
sheetId: (_c2 = item.sheetId) != null ? _c2 : null,
|
|
1839
|
+
createdBy: item.createdBy ? String(item.createdBy) : void 0,
|
|
1840
|
+
createdDate: typeof item.createdDate === "number" ? item.createdDate : void 0,
|
|
1841
|
+
modifiedDate: typeof item.modifiedDate === "number" ? item.modifiedDate : void 0,
|
|
1842
|
+
isPerspective: typeof item.isPerspective === "boolean" ? item.isPerspective : void 0,
|
|
1843
|
+
drawMode: typeof item.drawMode === "number" ? item.drawMode : void 0
|
|
1844
|
+
};
|
|
1845
|
+
}) : [],
|
|
1846
|
+
savedViews: Array.isArray(payload.savedViews) ? payload.savedViews.filter((item) => item && typeof item === "object").map((item) => {
|
|
1847
|
+
var _a2, _b2, _c2;
|
|
1848
|
+
return {
|
|
1849
|
+
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1850
|
+
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
1851
|
+
type: item.type === "cad" ? "cad" : "saved",
|
|
1852
|
+
modelFileId: item.modelFileId ? String(item.modelFileId) : void 0,
|
|
1853
|
+
sheetId: (_c2 = item.sheetId) != null ? _c2 : null,
|
|
1854
|
+
createdBy: item.createdBy ? String(item.createdBy) : void 0,
|
|
1855
|
+
createdDate: typeof item.createdDate === "number" ? item.createdDate : void 0,
|
|
1856
|
+
modifiedDate: typeof item.modifiedDate === "number" ? item.modifiedDate : void 0,
|
|
1857
|
+
isPerspective: typeof item.isPerspective === "boolean" ? item.isPerspective : void 0,
|
|
1858
|
+
drawMode: typeof item.drawMode === "number" ? item.drawMode : void 0
|
|
1859
|
+
};
|
|
1860
|
+
}) : [],
|
|
1861
|
+
selectedViewId: payload.selectedViewId ? String(payload.selectedViewId) : null,
|
|
1862
|
+
selectedViewType: payload.selectedViewType === "saved" ? "saved" : payload.selectedViewType === "cad" ? "cad" : null,
|
|
1863
|
+
error: payload.error ? String(payload.error) : void 0,
|
|
1864
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1865
|
+
});
|
|
1866
|
+
break;
|
|
1867
|
+
}
|
|
1868
|
+
case "viewer-views-apply-result" /* VIEWS_APPLY_RESULT */: {
|
|
1869
|
+
const payload = data.payload;
|
|
1870
|
+
if (!payload || !payload.requestId) break;
|
|
1871
|
+
this._emit("views:apply-result", {
|
|
1872
|
+
requestId: String(payload.requestId),
|
|
1873
|
+
success: Boolean(payload.success),
|
|
1874
|
+
id: String((_c = payload.id) != null ? _c : ""),
|
|
1875
|
+
type: payload.type === "saved" ? "saved" : "cad",
|
|
1876
|
+
error: payload.error ? String(payload.error) : void 0,
|
|
1877
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1878
|
+
});
|
|
1879
|
+
break;
|
|
1880
|
+
}
|
|
1742
1881
|
case "viewer-object-properties-list" /* OBJECT_PROPERTIES_LIST */: {
|
|
1743
1882
|
const payload = data.payload;
|
|
1744
1883
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties))
|
|
1745
1884
|
break;
|
|
1746
1885
|
this._emit("object-properties:list", {
|
|
1747
1886
|
requestId: String(payload.requestId),
|
|
1748
|
-
selectionKey: String((
|
|
1887
|
+
selectionKey: String((_d = payload.selectionKey) != null ? _d : ""),
|
|
1749
1888
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1750
1889
|
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|
|
1751
1890
|
properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
|
|
@@ -1771,7 +1910,7 @@ var Viewer3D = class {
|
|
|
1771
1910
|
this._emit("states-objects:list", {
|
|
1772
1911
|
requestId: String(payload.requestId),
|
|
1773
1912
|
statesObjects: payload.statesObjects.map((item) => {
|
|
1774
|
-
var _a2, _b2, _c2,
|
|
1913
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g;
|
|
1775
1914
|
return {
|
|
1776
1915
|
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1777
1916
|
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
@@ -1784,7 +1923,7 @@ var Viewer3D = class {
|
|
|
1784
1923
|
};
|
|
1785
1924
|
}) : [],
|
|
1786
1925
|
states: {
|
|
1787
|
-
color: String((_e = (
|
|
1926
|
+
color: String((_e = (_d2 = item.states) == null ? void 0 : _d2.color) != null ? _e : ""),
|
|
1788
1927
|
type: String((_g = (_f = item.states) == null ? void 0 : _f.type) != null ? _g : "")
|
|
1789
1928
|
}
|
|
1790
1929
|
};
|
|
@@ -1854,6 +1993,7 @@ var Viewer3D = class {
|
|
|
1854
1993
|
this.markup = new MarkupModule(this);
|
|
1855
1994
|
this.language = new LanguageModule(this);
|
|
1856
1995
|
this.objectProperties = new ObjectPropertiesModule(this);
|
|
1996
|
+
this.views = new ViewsModule(this);
|
|
1857
1997
|
}
|
|
1858
1998
|
// ===== options helpers =====
|
|
1859
1999
|
getOptions() {
|
package/dist/index.mjs
CHANGED
|
@@ -1497,6 +1497,89 @@ var ObjectPropertiesModule = class {
|
|
|
1497
1497
|
}
|
|
1498
1498
|
};
|
|
1499
1499
|
|
|
1500
|
+
// src/modules/views.module.ts
|
|
1501
|
+
function createRequestId7(prefix) {
|
|
1502
|
+
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1503
|
+
}
|
|
1504
|
+
var ViewsModule = class {
|
|
1505
|
+
constructor(viewer) {
|
|
1506
|
+
this.viewer = viewer;
|
|
1507
|
+
}
|
|
1508
|
+
getViews(options) {
|
|
1509
|
+
var _a;
|
|
1510
|
+
const requestId = createRequestId7("views");
|
|
1511
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1512
|
+
return new Promise((resolve, reject) => {
|
|
1513
|
+
const timer = setTimeout(() => {
|
|
1514
|
+
off();
|
|
1515
|
+
reject(new Error("Timeout while getting views list from viewer"));
|
|
1516
|
+
}, timeoutMs);
|
|
1517
|
+
const off = this.viewer._on("views:list", (payload) => {
|
|
1518
|
+
var _a2, _b;
|
|
1519
|
+
if (payload.requestId !== requestId) return;
|
|
1520
|
+
clearTimeout(timer);
|
|
1521
|
+
off();
|
|
1522
|
+
if (!payload.success) {
|
|
1523
|
+
reject(new Error(payload.error || "Viewer failed to load views"));
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
resolve({
|
|
1527
|
+
cadViews: payload.cadViews,
|
|
1528
|
+
savedViews: payload.savedViews,
|
|
1529
|
+
selectedViewId: (_a2 = payload.selectedViewId) != null ? _a2 : null,
|
|
1530
|
+
selectedViewType: (_b = payload.selectedViewType) != null ? _b : null,
|
|
1531
|
+
timestamp: payload.timestamp
|
|
1532
|
+
});
|
|
1533
|
+
});
|
|
1534
|
+
this.viewer.postToViewer(
|
|
1535
|
+
"viewer-views-get-list" /* VIEWS_GET_LIST */,
|
|
1536
|
+
{ requestId }
|
|
1537
|
+
);
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
async getCadViews(options) {
|
|
1541
|
+
const views = await this.getViews(options);
|
|
1542
|
+
return views.cadViews;
|
|
1543
|
+
}
|
|
1544
|
+
async getSavedViews(options) {
|
|
1545
|
+
const views = await this.getViews(options);
|
|
1546
|
+
return views.savedViews;
|
|
1547
|
+
}
|
|
1548
|
+
applyView(input, options) {
|
|
1549
|
+
var _a;
|
|
1550
|
+
const requestId = createRequestId7("views-apply");
|
|
1551
|
+
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1552
|
+
return new Promise((resolve, reject) => {
|
|
1553
|
+
const timer = setTimeout(() => {
|
|
1554
|
+
off();
|
|
1555
|
+
reject(new Error("Timeout while waiting for view apply result from viewer"));
|
|
1556
|
+
}, timeoutMs);
|
|
1557
|
+
const off = this.viewer._on(
|
|
1558
|
+
"views:apply-result",
|
|
1559
|
+
(payload) => {
|
|
1560
|
+
if (payload.requestId !== requestId) return;
|
|
1561
|
+
clearTimeout(timer);
|
|
1562
|
+
off();
|
|
1563
|
+
if (!payload.success) {
|
|
1564
|
+
reject(new Error(payload.error || "Viewer failed to apply view"));
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
resolve({
|
|
1568
|
+
id: payload.id,
|
|
1569
|
+
type: payload.type,
|
|
1570
|
+
timestamp: payload.timestamp
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
);
|
|
1574
|
+
this.viewer.postToViewer("viewer-views-apply" /* VIEWS_APPLY */, {
|
|
1575
|
+
requestId,
|
|
1576
|
+
id: input.id,
|
|
1577
|
+
type: input.type
|
|
1578
|
+
});
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1500
1583
|
// src/viewer.ts
|
|
1501
1584
|
var Viewer3D = class {
|
|
1502
1585
|
constructor(options) {
|
|
@@ -1513,7 +1596,7 @@ var Viewer3D = class {
|
|
|
1513
1596
|
};
|
|
1514
1597
|
this.emitter = new Emitter();
|
|
1515
1598
|
this.handleMessage = (event) => {
|
|
1516
|
-
var _a, _b, _c;
|
|
1599
|
+
var _a, _b, _c, _d;
|
|
1517
1600
|
const data = event.data;
|
|
1518
1601
|
if (!data || typeof data !== "object") return;
|
|
1519
1602
|
switch (data.type) {
|
|
@@ -1713,13 +1796,69 @@ var Viewer3D = class {
|
|
|
1713
1796
|
});
|
|
1714
1797
|
break;
|
|
1715
1798
|
}
|
|
1799
|
+
case "viewer-views-list" /* VIEWS_LIST */: {
|
|
1800
|
+
const payload = data.payload;
|
|
1801
|
+
if (!payload || !payload.requestId) break;
|
|
1802
|
+
this._emit("views:list", {
|
|
1803
|
+
requestId: String(payload.requestId),
|
|
1804
|
+
success: Boolean(payload.success),
|
|
1805
|
+
cadViews: Array.isArray(payload.cadViews) ? payload.cadViews.filter((item) => item && typeof item === "object").map((item) => {
|
|
1806
|
+
var _a2, _b2, _c2;
|
|
1807
|
+
return {
|
|
1808
|
+
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1809
|
+
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
1810
|
+
type: item.type === "saved" ? "saved" : "cad",
|
|
1811
|
+
modelFileId: item.modelFileId ? String(item.modelFileId) : void 0,
|
|
1812
|
+
sheetId: (_c2 = item.sheetId) != null ? _c2 : null,
|
|
1813
|
+
createdBy: item.createdBy ? String(item.createdBy) : void 0,
|
|
1814
|
+
createdDate: typeof item.createdDate === "number" ? item.createdDate : void 0,
|
|
1815
|
+
modifiedDate: typeof item.modifiedDate === "number" ? item.modifiedDate : void 0,
|
|
1816
|
+
isPerspective: typeof item.isPerspective === "boolean" ? item.isPerspective : void 0,
|
|
1817
|
+
drawMode: typeof item.drawMode === "number" ? item.drawMode : void 0
|
|
1818
|
+
};
|
|
1819
|
+
}) : [],
|
|
1820
|
+
savedViews: Array.isArray(payload.savedViews) ? payload.savedViews.filter((item) => item && typeof item === "object").map((item) => {
|
|
1821
|
+
var _a2, _b2, _c2;
|
|
1822
|
+
return {
|
|
1823
|
+
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1824
|
+
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
1825
|
+
type: item.type === "cad" ? "cad" : "saved",
|
|
1826
|
+
modelFileId: item.modelFileId ? String(item.modelFileId) : void 0,
|
|
1827
|
+
sheetId: (_c2 = item.sheetId) != null ? _c2 : null,
|
|
1828
|
+
createdBy: item.createdBy ? String(item.createdBy) : void 0,
|
|
1829
|
+
createdDate: typeof item.createdDate === "number" ? item.createdDate : void 0,
|
|
1830
|
+
modifiedDate: typeof item.modifiedDate === "number" ? item.modifiedDate : void 0,
|
|
1831
|
+
isPerspective: typeof item.isPerspective === "boolean" ? item.isPerspective : void 0,
|
|
1832
|
+
drawMode: typeof item.drawMode === "number" ? item.drawMode : void 0
|
|
1833
|
+
};
|
|
1834
|
+
}) : [],
|
|
1835
|
+
selectedViewId: payload.selectedViewId ? String(payload.selectedViewId) : null,
|
|
1836
|
+
selectedViewType: payload.selectedViewType === "saved" ? "saved" : payload.selectedViewType === "cad" ? "cad" : null,
|
|
1837
|
+
error: payload.error ? String(payload.error) : void 0,
|
|
1838
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1839
|
+
});
|
|
1840
|
+
break;
|
|
1841
|
+
}
|
|
1842
|
+
case "viewer-views-apply-result" /* VIEWS_APPLY_RESULT */: {
|
|
1843
|
+
const payload = data.payload;
|
|
1844
|
+
if (!payload || !payload.requestId) break;
|
|
1845
|
+
this._emit("views:apply-result", {
|
|
1846
|
+
requestId: String(payload.requestId),
|
|
1847
|
+
success: Boolean(payload.success),
|
|
1848
|
+
id: String((_c = payload.id) != null ? _c : ""),
|
|
1849
|
+
type: payload.type === "saved" ? "saved" : "cad",
|
|
1850
|
+
error: payload.error ? String(payload.error) : void 0,
|
|
1851
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1852
|
+
});
|
|
1853
|
+
break;
|
|
1854
|
+
}
|
|
1716
1855
|
case "viewer-object-properties-list" /* OBJECT_PROPERTIES_LIST */: {
|
|
1717
1856
|
const payload = data.payload;
|
|
1718
1857
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties))
|
|
1719
1858
|
break;
|
|
1720
1859
|
this._emit("object-properties:list", {
|
|
1721
1860
|
requestId: String(payload.requestId),
|
|
1722
|
-
selectionKey: String((
|
|
1861
|
+
selectionKey: String((_d = payload.selectionKey) != null ? _d : ""),
|
|
1723
1862
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1724
1863
|
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|
|
1725
1864
|
properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
|
|
@@ -1745,7 +1884,7 @@ var Viewer3D = class {
|
|
|
1745
1884
|
this._emit("states-objects:list", {
|
|
1746
1885
|
requestId: String(payload.requestId),
|
|
1747
1886
|
statesObjects: payload.statesObjects.map((item) => {
|
|
1748
|
-
var _a2, _b2, _c2,
|
|
1887
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g;
|
|
1749
1888
|
return {
|
|
1750
1889
|
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1751
1890
|
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
@@ -1758,7 +1897,7 @@ var Viewer3D = class {
|
|
|
1758
1897
|
};
|
|
1759
1898
|
}) : [],
|
|
1760
1899
|
states: {
|
|
1761
|
-
color: String((_e = (
|
|
1900
|
+
color: String((_e = (_d2 = item.states) == null ? void 0 : _d2.color) != null ? _e : ""),
|
|
1762
1901
|
type: String((_g = (_f = item.states) == null ? void 0 : _f.type) != null ? _g : "")
|
|
1763
1902
|
}
|
|
1764
1903
|
};
|
|
@@ -1828,6 +1967,7 @@ var Viewer3D = class {
|
|
|
1828
1967
|
this.markup = new MarkupModule(this);
|
|
1829
1968
|
this.language = new LanguageModule(this);
|
|
1830
1969
|
this.objectProperties = new ObjectPropertiesModule(this);
|
|
1970
|
+
this.views = new ViewsModule(this);
|
|
1831
1971
|
}
|
|
1832
1972
|
// ===== options helpers =====
|
|
1833
1973
|
getOptions() {
|