3dviewer-sdk 1.1.7 → 1.1.9
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 +72 -1
- package/dist/index.d.ts +72 -1
- package/dist/index.js +146 -5
- package/dist/index.mjs +146 -5
- 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",
|
|
@@ -123,6 +127,38 @@ type SheetListItem = {
|
|
|
123
127
|
name: string;
|
|
124
128
|
is3D?: boolean;
|
|
125
129
|
viewId?: string;
|
|
130
|
+
cacheStatus?: number;
|
|
131
|
+
};
|
|
132
|
+
type SdkViewType = "cad" | "saved";
|
|
133
|
+
type SdkViewItem = {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
type: SdkViewType;
|
|
137
|
+
modelFileId?: string;
|
|
138
|
+
sheetId?: string | number | null;
|
|
139
|
+
createdBy?: string;
|
|
140
|
+
createdDate?: number;
|
|
141
|
+
modifiedDate?: number;
|
|
142
|
+
isPerspective?: boolean;
|
|
143
|
+
drawMode?: number;
|
|
144
|
+
};
|
|
145
|
+
type ViewsListPayload = {
|
|
146
|
+
requestId: string;
|
|
147
|
+
success: boolean;
|
|
148
|
+
cadViews: SdkViewItem[];
|
|
149
|
+
savedViews: SdkViewItem[];
|
|
150
|
+
selectedViewId?: string | null;
|
|
151
|
+
selectedViewType?: SdkViewType | null;
|
|
152
|
+
timestamp: number;
|
|
153
|
+
error?: string;
|
|
154
|
+
};
|
|
155
|
+
type ViewsApplyResultPayload = {
|
|
156
|
+
requestId: string;
|
|
157
|
+
success: boolean;
|
|
158
|
+
id: string;
|
|
159
|
+
type: SdkViewType;
|
|
160
|
+
timestamp: number;
|
|
161
|
+
error?: string;
|
|
126
162
|
};
|
|
127
163
|
type ObjectPropertyItem = Record<string, unknown>;
|
|
128
164
|
type ObjectPropertiesListPayload = {
|
|
@@ -227,10 +263,13 @@ type ViewerEventMap = {
|
|
|
227
263
|
name: string;
|
|
228
264
|
is3D?: boolean;
|
|
229
265
|
viewId?: string;
|
|
266
|
+
cacheStatus?: number;
|
|
230
267
|
}[];
|
|
231
268
|
activeSheetId?: string | number | null;
|
|
232
269
|
timestamp: number;
|
|
233
270
|
};
|
|
271
|
+
"views:list": ViewsListPayload;
|
|
272
|
+
"views:apply-result": ViewsApplyResultPayload;
|
|
234
273
|
"object-properties:list": ObjectPropertiesListPayload;
|
|
235
274
|
"linked-objects:list": {
|
|
236
275
|
requestId: string;
|
|
@@ -696,6 +735,37 @@ declare class ObjectPropertiesModule {
|
|
|
696
735
|
getByNodeIds(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
697
736
|
}
|
|
698
737
|
|
|
738
|
+
type GetViewsOptions = {
|
|
739
|
+
timeoutMs?: number;
|
|
740
|
+
};
|
|
741
|
+
type ApplyViewInput = {
|
|
742
|
+
id: string;
|
|
743
|
+
type: SdkViewType;
|
|
744
|
+
};
|
|
745
|
+
type ApplyViewOptions = {
|
|
746
|
+
timeoutMs?: number;
|
|
747
|
+
};
|
|
748
|
+
type ApplyViewResult = {
|
|
749
|
+
id: string;
|
|
750
|
+
type: SdkViewType;
|
|
751
|
+
timestamp: number;
|
|
752
|
+
};
|
|
753
|
+
type SdkViewsList = {
|
|
754
|
+
cadViews: SdkViewItem[];
|
|
755
|
+
savedViews: SdkViewItem[];
|
|
756
|
+
selectedViewId?: string | null;
|
|
757
|
+
selectedViewType?: SdkViewType | null;
|
|
758
|
+
timestamp: number;
|
|
759
|
+
};
|
|
760
|
+
declare class ViewsModule {
|
|
761
|
+
private viewer;
|
|
762
|
+
constructor(viewer: Viewer3D);
|
|
763
|
+
getViews(options?: GetViewsOptions): Promise<SdkViewsList>;
|
|
764
|
+
getCadViews(options?: GetViewsOptions): Promise<SdkViewItem[]>;
|
|
765
|
+
getSavedViews(options?: GetViewsOptions): Promise<SdkViewItem[]>;
|
|
766
|
+
applyView(input: ApplyViewInput, options?: ApplyViewOptions): Promise<ApplyViewResult>;
|
|
767
|
+
}
|
|
768
|
+
|
|
699
769
|
type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
|
|
700
770
|
type Viewer3DOptions = {
|
|
701
771
|
container: HTMLElement | string;
|
|
@@ -735,6 +805,7 @@ declare class Viewer3D {
|
|
|
735
805
|
markup: MarkupModule;
|
|
736
806
|
language: LanguageModule;
|
|
737
807
|
objectProperties: ObjectPropertiesModule;
|
|
808
|
+
views: ViewsModule;
|
|
738
809
|
constructor(options: Viewer3DOptions);
|
|
739
810
|
getOptions(): Viewer3DOptions;
|
|
740
811
|
patchOptions(next: Partial<Viewer3DOptions>): void;
|
|
@@ -764,4 +835,4 @@ declare class Viewer3D {
|
|
|
764
835
|
private handleMessage;
|
|
765
836
|
}
|
|
766
837
|
|
|
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 };
|
|
838
|
+
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",
|
|
@@ -123,6 +127,38 @@ type SheetListItem = {
|
|
|
123
127
|
name: string;
|
|
124
128
|
is3D?: boolean;
|
|
125
129
|
viewId?: string;
|
|
130
|
+
cacheStatus?: number;
|
|
131
|
+
};
|
|
132
|
+
type SdkViewType = "cad" | "saved";
|
|
133
|
+
type SdkViewItem = {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
type: SdkViewType;
|
|
137
|
+
modelFileId?: string;
|
|
138
|
+
sheetId?: string | number | null;
|
|
139
|
+
createdBy?: string;
|
|
140
|
+
createdDate?: number;
|
|
141
|
+
modifiedDate?: number;
|
|
142
|
+
isPerspective?: boolean;
|
|
143
|
+
drawMode?: number;
|
|
144
|
+
};
|
|
145
|
+
type ViewsListPayload = {
|
|
146
|
+
requestId: string;
|
|
147
|
+
success: boolean;
|
|
148
|
+
cadViews: SdkViewItem[];
|
|
149
|
+
savedViews: SdkViewItem[];
|
|
150
|
+
selectedViewId?: string | null;
|
|
151
|
+
selectedViewType?: SdkViewType | null;
|
|
152
|
+
timestamp: number;
|
|
153
|
+
error?: string;
|
|
154
|
+
};
|
|
155
|
+
type ViewsApplyResultPayload = {
|
|
156
|
+
requestId: string;
|
|
157
|
+
success: boolean;
|
|
158
|
+
id: string;
|
|
159
|
+
type: SdkViewType;
|
|
160
|
+
timestamp: number;
|
|
161
|
+
error?: string;
|
|
126
162
|
};
|
|
127
163
|
type ObjectPropertyItem = Record<string, unknown>;
|
|
128
164
|
type ObjectPropertiesListPayload = {
|
|
@@ -227,10 +263,13 @@ type ViewerEventMap = {
|
|
|
227
263
|
name: string;
|
|
228
264
|
is3D?: boolean;
|
|
229
265
|
viewId?: string;
|
|
266
|
+
cacheStatus?: number;
|
|
230
267
|
}[];
|
|
231
268
|
activeSheetId?: string | number | null;
|
|
232
269
|
timestamp: number;
|
|
233
270
|
};
|
|
271
|
+
"views:list": ViewsListPayload;
|
|
272
|
+
"views:apply-result": ViewsApplyResultPayload;
|
|
234
273
|
"object-properties:list": ObjectPropertiesListPayload;
|
|
235
274
|
"linked-objects:list": {
|
|
236
275
|
requestId: string;
|
|
@@ -696,6 +735,37 @@ declare class ObjectPropertiesModule {
|
|
|
696
735
|
getByNodeIds(nodeIds: Array<string | number>, options?: ObjectPropertiesGetOptions): Promise<ObjectPropertiesResult>;
|
|
697
736
|
}
|
|
698
737
|
|
|
738
|
+
type GetViewsOptions = {
|
|
739
|
+
timeoutMs?: number;
|
|
740
|
+
};
|
|
741
|
+
type ApplyViewInput = {
|
|
742
|
+
id: string;
|
|
743
|
+
type: SdkViewType;
|
|
744
|
+
};
|
|
745
|
+
type ApplyViewOptions = {
|
|
746
|
+
timeoutMs?: number;
|
|
747
|
+
};
|
|
748
|
+
type ApplyViewResult = {
|
|
749
|
+
id: string;
|
|
750
|
+
type: SdkViewType;
|
|
751
|
+
timestamp: number;
|
|
752
|
+
};
|
|
753
|
+
type SdkViewsList = {
|
|
754
|
+
cadViews: SdkViewItem[];
|
|
755
|
+
savedViews: SdkViewItem[];
|
|
756
|
+
selectedViewId?: string | null;
|
|
757
|
+
selectedViewType?: SdkViewType | null;
|
|
758
|
+
timestamp: number;
|
|
759
|
+
};
|
|
760
|
+
declare class ViewsModule {
|
|
761
|
+
private viewer;
|
|
762
|
+
constructor(viewer: Viewer3D);
|
|
763
|
+
getViews(options?: GetViewsOptions): Promise<SdkViewsList>;
|
|
764
|
+
getCadViews(options?: GetViewsOptions): Promise<SdkViewItem[]>;
|
|
765
|
+
getSavedViews(options?: GetViewsOptions): Promise<SdkViewItem[]>;
|
|
766
|
+
applyView(input: ApplyViewInput, options?: ApplyViewOptions): Promise<ApplyViewResult>;
|
|
767
|
+
}
|
|
768
|
+
|
|
699
769
|
type InitialToolbarUse = ToolbarUseTarget | ToolbarUseTarget[] | Partial<Record<ToolbarUseTarget, boolean>>;
|
|
700
770
|
type Viewer3DOptions = {
|
|
701
771
|
container: HTMLElement | string;
|
|
@@ -735,6 +805,7 @@ declare class Viewer3D {
|
|
|
735
805
|
markup: MarkupModule;
|
|
736
806
|
language: LanguageModule;
|
|
737
807
|
objectProperties: ObjectPropertiesModule;
|
|
808
|
+
views: ViewsModule;
|
|
738
809
|
constructor(options: Viewer3DOptions);
|
|
739
810
|
getOptions(): Viewer3DOptions;
|
|
740
811
|
patchOptions(next: Partial<Viewer3DOptions>): void;
|
|
@@ -764,4 +835,4 @@ declare class Viewer3D {
|
|
|
764
835
|
private handleMessage;
|
|
765
836
|
}
|
|
766
837
|
|
|
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 };
|
|
838
|
+
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) {
|
|
@@ -1731,7 +1814,8 @@ var Viewer3D = class {
|
|
|
1731
1814
|
id: sheet.id,
|
|
1732
1815
|
name: String((_a2 = sheet.name) != null ? _a2 : ""),
|
|
1733
1816
|
is3D: Boolean(sheet.is3D),
|
|
1734
|
-
viewId: sheet.viewId ? String(sheet.viewId) : void 0
|
|
1817
|
+
viewId: sheet.viewId ? String(sheet.viewId) : void 0,
|
|
1818
|
+
cacheStatus: typeof sheet.cacheStatus === "number" ? sheet.cacheStatus : void 0
|
|
1735
1819
|
};
|
|
1736
1820
|
}),
|
|
1737
1821
|
activeSheetId: (_b = payload.activeSheetId) != null ? _b : null,
|
|
@@ -1739,13 +1823,69 @@ var Viewer3D = class {
|
|
|
1739
1823
|
});
|
|
1740
1824
|
break;
|
|
1741
1825
|
}
|
|
1826
|
+
case "viewer-views-list" /* VIEWS_LIST */: {
|
|
1827
|
+
const payload = data.payload;
|
|
1828
|
+
if (!payload || !payload.requestId) break;
|
|
1829
|
+
this._emit("views:list", {
|
|
1830
|
+
requestId: String(payload.requestId),
|
|
1831
|
+
success: Boolean(payload.success),
|
|
1832
|
+
cadViews: Array.isArray(payload.cadViews) ? payload.cadViews.filter((item) => item && typeof item === "object").map((item) => {
|
|
1833
|
+
var _a2, _b2, _c2;
|
|
1834
|
+
return {
|
|
1835
|
+
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1836
|
+
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
1837
|
+
type: item.type === "saved" ? "saved" : "cad",
|
|
1838
|
+
modelFileId: item.modelFileId ? String(item.modelFileId) : void 0,
|
|
1839
|
+
sheetId: (_c2 = item.sheetId) != null ? _c2 : null,
|
|
1840
|
+
createdBy: item.createdBy ? String(item.createdBy) : void 0,
|
|
1841
|
+
createdDate: typeof item.createdDate === "number" ? item.createdDate : void 0,
|
|
1842
|
+
modifiedDate: typeof item.modifiedDate === "number" ? item.modifiedDate : void 0,
|
|
1843
|
+
isPerspective: typeof item.isPerspective === "boolean" ? item.isPerspective : void 0,
|
|
1844
|
+
drawMode: typeof item.drawMode === "number" ? item.drawMode : void 0
|
|
1845
|
+
};
|
|
1846
|
+
}) : [],
|
|
1847
|
+
savedViews: Array.isArray(payload.savedViews) ? payload.savedViews.filter((item) => item && typeof item === "object").map((item) => {
|
|
1848
|
+
var _a2, _b2, _c2;
|
|
1849
|
+
return {
|
|
1850
|
+
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1851
|
+
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
1852
|
+
type: item.type === "cad" ? "cad" : "saved",
|
|
1853
|
+
modelFileId: item.modelFileId ? String(item.modelFileId) : void 0,
|
|
1854
|
+
sheetId: (_c2 = item.sheetId) != null ? _c2 : null,
|
|
1855
|
+
createdBy: item.createdBy ? String(item.createdBy) : void 0,
|
|
1856
|
+
createdDate: typeof item.createdDate === "number" ? item.createdDate : void 0,
|
|
1857
|
+
modifiedDate: typeof item.modifiedDate === "number" ? item.modifiedDate : void 0,
|
|
1858
|
+
isPerspective: typeof item.isPerspective === "boolean" ? item.isPerspective : void 0,
|
|
1859
|
+
drawMode: typeof item.drawMode === "number" ? item.drawMode : void 0
|
|
1860
|
+
};
|
|
1861
|
+
}) : [],
|
|
1862
|
+
selectedViewId: payload.selectedViewId ? String(payload.selectedViewId) : null,
|
|
1863
|
+
selectedViewType: payload.selectedViewType === "saved" ? "saved" : payload.selectedViewType === "cad" ? "cad" : null,
|
|
1864
|
+
error: payload.error ? String(payload.error) : void 0,
|
|
1865
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1866
|
+
});
|
|
1867
|
+
break;
|
|
1868
|
+
}
|
|
1869
|
+
case "viewer-views-apply-result" /* VIEWS_APPLY_RESULT */: {
|
|
1870
|
+
const payload = data.payload;
|
|
1871
|
+
if (!payload || !payload.requestId) break;
|
|
1872
|
+
this._emit("views:apply-result", {
|
|
1873
|
+
requestId: String(payload.requestId),
|
|
1874
|
+
success: Boolean(payload.success),
|
|
1875
|
+
id: String((_c = payload.id) != null ? _c : ""),
|
|
1876
|
+
type: payload.type === "saved" ? "saved" : "cad",
|
|
1877
|
+
error: payload.error ? String(payload.error) : void 0,
|
|
1878
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1879
|
+
});
|
|
1880
|
+
break;
|
|
1881
|
+
}
|
|
1742
1882
|
case "viewer-object-properties-list" /* OBJECT_PROPERTIES_LIST */: {
|
|
1743
1883
|
const payload = data.payload;
|
|
1744
1884
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties))
|
|
1745
1885
|
break;
|
|
1746
1886
|
this._emit("object-properties:list", {
|
|
1747
1887
|
requestId: String(payload.requestId),
|
|
1748
|
-
selectionKey: String((
|
|
1888
|
+
selectionKey: String((_d = payload.selectionKey) != null ? _d : ""),
|
|
1749
1889
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1750
1890
|
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|
|
1751
1891
|
properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
|
|
@@ -1771,7 +1911,7 @@ var Viewer3D = class {
|
|
|
1771
1911
|
this._emit("states-objects:list", {
|
|
1772
1912
|
requestId: String(payload.requestId),
|
|
1773
1913
|
statesObjects: payload.statesObjects.map((item) => {
|
|
1774
|
-
var _a2, _b2, _c2,
|
|
1914
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g;
|
|
1775
1915
|
return {
|
|
1776
1916
|
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1777
1917
|
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
@@ -1784,7 +1924,7 @@ var Viewer3D = class {
|
|
|
1784
1924
|
};
|
|
1785
1925
|
}) : [],
|
|
1786
1926
|
states: {
|
|
1787
|
-
color: String((_e = (
|
|
1927
|
+
color: String((_e = (_d2 = item.states) == null ? void 0 : _d2.color) != null ? _e : ""),
|
|
1788
1928
|
type: String((_g = (_f = item.states) == null ? void 0 : _f.type) != null ? _g : "")
|
|
1789
1929
|
}
|
|
1790
1930
|
};
|
|
@@ -1854,6 +1994,7 @@ var Viewer3D = class {
|
|
|
1854
1994
|
this.markup = new MarkupModule(this);
|
|
1855
1995
|
this.language = new LanguageModule(this);
|
|
1856
1996
|
this.objectProperties = new ObjectPropertiesModule(this);
|
|
1997
|
+
this.views = new ViewsModule(this);
|
|
1857
1998
|
}
|
|
1858
1999
|
// ===== options helpers =====
|
|
1859
2000
|
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) {
|
|
@@ -1705,7 +1788,8 @@ var Viewer3D = class {
|
|
|
1705
1788
|
id: sheet.id,
|
|
1706
1789
|
name: String((_a2 = sheet.name) != null ? _a2 : ""),
|
|
1707
1790
|
is3D: Boolean(sheet.is3D),
|
|
1708
|
-
viewId: sheet.viewId ? String(sheet.viewId) : void 0
|
|
1791
|
+
viewId: sheet.viewId ? String(sheet.viewId) : void 0,
|
|
1792
|
+
cacheStatus: typeof sheet.cacheStatus === "number" ? sheet.cacheStatus : void 0
|
|
1709
1793
|
};
|
|
1710
1794
|
}),
|
|
1711
1795
|
activeSheetId: (_b = payload.activeSheetId) != null ? _b : null,
|
|
@@ -1713,13 +1797,69 @@ var Viewer3D = class {
|
|
|
1713
1797
|
});
|
|
1714
1798
|
break;
|
|
1715
1799
|
}
|
|
1800
|
+
case "viewer-views-list" /* VIEWS_LIST */: {
|
|
1801
|
+
const payload = data.payload;
|
|
1802
|
+
if (!payload || !payload.requestId) break;
|
|
1803
|
+
this._emit("views:list", {
|
|
1804
|
+
requestId: String(payload.requestId),
|
|
1805
|
+
success: Boolean(payload.success),
|
|
1806
|
+
cadViews: Array.isArray(payload.cadViews) ? payload.cadViews.filter((item) => item && typeof item === "object").map((item) => {
|
|
1807
|
+
var _a2, _b2, _c2;
|
|
1808
|
+
return {
|
|
1809
|
+
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1810
|
+
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
1811
|
+
type: item.type === "saved" ? "saved" : "cad",
|
|
1812
|
+
modelFileId: item.modelFileId ? String(item.modelFileId) : void 0,
|
|
1813
|
+
sheetId: (_c2 = item.sheetId) != null ? _c2 : null,
|
|
1814
|
+
createdBy: item.createdBy ? String(item.createdBy) : void 0,
|
|
1815
|
+
createdDate: typeof item.createdDate === "number" ? item.createdDate : void 0,
|
|
1816
|
+
modifiedDate: typeof item.modifiedDate === "number" ? item.modifiedDate : void 0,
|
|
1817
|
+
isPerspective: typeof item.isPerspective === "boolean" ? item.isPerspective : void 0,
|
|
1818
|
+
drawMode: typeof item.drawMode === "number" ? item.drawMode : void 0
|
|
1819
|
+
};
|
|
1820
|
+
}) : [],
|
|
1821
|
+
savedViews: Array.isArray(payload.savedViews) ? payload.savedViews.filter((item) => item && typeof item === "object").map((item) => {
|
|
1822
|
+
var _a2, _b2, _c2;
|
|
1823
|
+
return {
|
|
1824
|
+
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1825
|
+
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
1826
|
+
type: item.type === "cad" ? "cad" : "saved",
|
|
1827
|
+
modelFileId: item.modelFileId ? String(item.modelFileId) : void 0,
|
|
1828
|
+
sheetId: (_c2 = item.sheetId) != null ? _c2 : null,
|
|
1829
|
+
createdBy: item.createdBy ? String(item.createdBy) : void 0,
|
|
1830
|
+
createdDate: typeof item.createdDate === "number" ? item.createdDate : void 0,
|
|
1831
|
+
modifiedDate: typeof item.modifiedDate === "number" ? item.modifiedDate : void 0,
|
|
1832
|
+
isPerspective: typeof item.isPerspective === "boolean" ? item.isPerspective : void 0,
|
|
1833
|
+
drawMode: typeof item.drawMode === "number" ? item.drawMode : void 0
|
|
1834
|
+
};
|
|
1835
|
+
}) : [],
|
|
1836
|
+
selectedViewId: payload.selectedViewId ? String(payload.selectedViewId) : null,
|
|
1837
|
+
selectedViewType: payload.selectedViewType === "saved" ? "saved" : payload.selectedViewType === "cad" ? "cad" : null,
|
|
1838
|
+
error: payload.error ? String(payload.error) : void 0,
|
|
1839
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1840
|
+
});
|
|
1841
|
+
break;
|
|
1842
|
+
}
|
|
1843
|
+
case "viewer-views-apply-result" /* VIEWS_APPLY_RESULT */: {
|
|
1844
|
+
const payload = data.payload;
|
|
1845
|
+
if (!payload || !payload.requestId) break;
|
|
1846
|
+
this._emit("views:apply-result", {
|
|
1847
|
+
requestId: String(payload.requestId),
|
|
1848
|
+
success: Boolean(payload.success),
|
|
1849
|
+
id: String((_c = payload.id) != null ? _c : ""),
|
|
1850
|
+
type: payload.type === "saved" ? "saved" : "cad",
|
|
1851
|
+
error: payload.error ? String(payload.error) : void 0,
|
|
1852
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1853
|
+
});
|
|
1854
|
+
break;
|
|
1855
|
+
}
|
|
1716
1856
|
case "viewer-object-properties-list" /* OBJECT_PROPERTIES_LIST */: {
|
|
1717
1857
|
const payload = data.payload;
|
|
1718
1858
|
if (!payload || !payload.requestId || !Array.isArray(payload.properties))
|
|
1719
1859
|
break;
|
|
1720
1860
|
this._emit("object-properties:list", {
|
|
1721
1861
|
requestId: String(payload.requestId),
|
|
1722
|
-
selectionKey: String((
|
|
1862
|
+
selectionKey: String((_d = payload.selectionKey) != null ? _d : ""),
|
|
1723
1863
|
nodeIds: Array.isArray(payload.nodeIds) ? payload.nodeIds.map(String) : [],
|
|
1724
1864
|
persistentIds: Array.isArray(payload.persistentIds) ? payload.persistentIds.map(String) : [],
|
|
1725
1865
|
properties: payload.properties.filter((item) => item && typeof item === "object").map((item) => ({ ...item })),
|
|
@@ -1745,7 +1885,7 @@ var Viewer3D = class {
|
|
|
1745
1885
|
this._emit("states-objects:list", {
|
|
1746
1886
|
requestId: String(payload.requestId),
|
|
1747
1887
|
statesObjects: payload.statesObjects.map((item) => {
|
|
1748
|
-
var _a2, _b2, _c2,
|
|
1888
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g;
|
|
1749
1889
|
return {
|
|
1750
1890
|
id: String((_a2 = item.id) != null ? _a2 : ""),
|
|
1751
1891
|
name: String((_b2 = item.name) != null ? _b2 : ""),
|
|
@@ -1758,7 +1898,7 @@ var Viewer3D = class {
|
|
|
1758
1898
|
};
|
|
1759
1899
|
}) : [],
|
|
1760
1900
|
states: {
|
|
1761
|
-
color: String((_e = (
|
|
1901
|
+
color: String((_e = (_d2 = item.states) == null ? void 0 : _d2.color) != null ? _e : ""),
|
|
1762
1902
|
type: String((_g = (_f = item.states) == null ? void 0 : _f.type) != null ? _g : "")
|
|
1763
1903
|
}
|
|
1764
1904
|
};
|
|
@@ -1828,6 +1968,7 @@ var Viewer3D = class {
|
|
|
1828
1968
|
this.markup = new MarkupModule(this);
|
|
1829
1969
|
this.language = new LanguageModule(this);
|
|
1830
1970
|
this.objectProperties = new ObjectPropertiesModule(this);
|
|
1971
|
+
this.views = new ViewsModule(this);
|
|
1831
1972
|
}
|
|
1832
1973
|
// ===== options helpers =====
|
|
1833
1974
|
getOptions() {
|