3dviewer-sdk 1.0.21 → 1.0.22

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.
@@ -1,96 +0,0 @@
1
- import { ViewerMessageType, } from "../contracts/messages";
2
- function createRequestId(prefix) {
3
- return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
4
- }
5
- export class MarkupModule {
6
- constructor(viewer) {
7
- this.viewer = viewer;
8
- }
9
- action(action) {
10
- this.viewer.postToViewer(ViewerMessageType.MARKUP_ACTION, { action });
11
- }
12
- drawLine() {
13
- this.action("line");
14
- }
15
- drawArrow() {
16
- this.action("arrow");
17
- }
18
- drawCircle() {
19
- this.action("circle");
20
- }
21
- drawEllipse() {
22
- this.action("ellipse");
23
- }
24
- drawRectangle() {
25
- this.action("rectangle");
26
- }
27
- drawPolygon() {
28
- this.action("polygon");
29
- }
30
- drawPolyline() {
31
- this.action("polyline");
32
- }
33
- drawTextBox() {
34
- this.action("textbox");
35
- }
36
- drawNote() {
37
- this.action("note");
38
- }
39
- drawCallout() {
40
- this.action("callout");
41
- }
42
- drawCloud() {
43
- this.action("cloud");
44
- }
45
- drawFreehand() {
46
- this.action("freehand");
47
- }
48
- save(options) {
49
- return this.runRequest("markup-save", ViewerMessageType.MARKUP_SAVE, "markup:save", options);
50
- }
51
- cancel(options) {
52
- return this.runRequest("markup-cancel", ViewerMessageType.MARKUP_CANCEL, "markup:cancel", options);
53
- }
54
- getList(options) {
55
- var _a;
56
- const requestId = createRequestId("markup-list");
57
- const timeoutMs = Math.max(1000, (_a = options === null || options === void 0 ? void 0 : options.timeoutMs) !== null && _a !== void 0 ? _a : 10000);
58
- return new Promise((resolve, reject) => {
59
- const timer = setTimeout(() => {
60
- off();
61
- reject(new Error("Timeout while getting markup list from viewer"));
62
- }, timeoutMs);
63
- const off = this.viewer._on("markup:list", (payload) => {
64
- if (payload.requestId !== requestId)
65
- return;
66
- clearTimeout(timer);
67
- off();
68
- resolve(payload.markups);
69
- });
70
- this.viewer.postToViewer(ViewerMessageType.MARKUP_GET_LIST, { requestId });
71
- });
72
- }
73
- runRequest(prefix, messageType, eventName, options) {
74
- var _a;
75
- const requestId = createRequestId(prefix);
76
- const timeoutMs = Math.max(1000, (_a = options === null || options === void 0 ? void 0 : options.timeoutMs) !== null && _a !== void 0 ? _a : 10000);
77
- return new Promise((resolve, reject) => {
78
- const timer = setTimeout(() => {
79
- off();
80
- reject(new Error(`Timeout while waiting for ${prefix} result from viewer`));
81
- }, timeoutMs);
82
- const off = this.viewer._on(eventName, (payload) => {
83
- if (payload.requestId !== requestId)
84
- return;
85
- clearTimeout(timer);
86
- off();
87
- if (payload.success) {
88
- resolve();
89
- return;
90
- }
91
- reject(new Error(payload.error || `Viewer ${prefix} failed`));
92
- });
93
- this.viewer.postToViewer(messageType, { requestId });
94
- });
95
- }
96
- }
@@ -1,12 +0,0 @@
1
- import { Viewer3D } from "../viewer";
2
- export declare type GetNodeIdsOptions = {
3
- onlyRealNodes?: boolean;
4
- timeoutMs?: number;
5
- };
6
- export declare class ModelTreeModule {
7
- private viewer;
8
- constructor(viewer: Viewer3D);
9
- open(): void;
10
- selectNode(nodeId: string | number): void;
11
- getNodeIds(options?: GetNodeIdsOptions): Promise<string[]>;
12
- }
@@ -1,42 +0,0 @@
1
- import { ViewerMessageType } from "../contracts/messages";
2
- function createRequestId() {
3
- return `tree_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
4
- }
5
- export class ModelTreeModule {
6
- constructor(viewer) {
7
- this.viewer = viewer;
8
- }
9
- open() {
10
- this.viewer.postToViewer(ViewerMessageType.PANEL_OPEN, {
11
- panel: "model-tree",
12
- format: "3d",
13
- });
14
- }
15
- selectNode(nodeId) {
16
- this.viewer.postToViewer(ViewerMessageType.TREE_SELECT_NODE, {
17
- nodeId: String(nodeId),
18
- });
19
- }
20
- getNodeIds(options) {
21
- var _a;
22
- const requestId = createRequestId();
23
- const timeoutMs = Math.max(1000, (_a = options === null || options === void 0 ? void 0 : options.timeoutMs) !== null && _a !== void 0 ? _a : 10000);
24
- return new Promise((resolve, reject) => {
25
- const timer = setTimeout(() => {
26
- off();
27
- reject(new Error("Timeout while getting node ids from viewer"));
28
- }, timeoutMs);
29
- const off = this.viewer._on("modelTree:node-ids", (payload) => {
30
- if (payload.requestId !== requestId)
31
- return;
32
- clearTimeout(timer);
33
- off();
34
- resolve(payload.nodeIds);
35
- });
36
- this.viewer.postToViewer(ViewerMessageType.TREE_GET_NODE_IDS, {
37
- requestId,
38
- onlyRealNodes: (options === null || options === void 0 ? void 0 : options.onlyRealNodes) !== false,
39
- });
40
- });
41
- }
42
- }
@@ -1,11 +0,0 @@
1
- import { Viewer3D } from "../viewer";
2
- export declare class NodeModule {
3
- private viewer;
4
- on: {
5
- select: (cb: (payload: {
6
- nodeId: string;
7
- timestamp: number;
8
- }) => void) => () => void;
9
- };
10
- constructor(viewer: Viewer3D);
11
- }
@@ -1,6 +0,0 @@
1
- export class NodeModule {
2
- constructor(viewer) {
3
- this.viewer = viewer;
4
- this.on = { select: (cb) => this.viewer._on("node:select", cb) };
5
- }
6
- }
@@ -1,93 +0,0 @@
1
- import { Viewer3D } from "../viewer";
2
- import { type SheetListItem, type ToolbarVisibilityTarget } from "../contracts/messages";
3
- export declare type ToolbarFormat = "3d" | "pdf";
4
- export declare type GetSheetsOptions = {
5
- timeoutMs?: number;
6
- };
7
- export declare class ToolbarModule {
8
- private viewer;
9
- on: {
10
- planMode: (cb: (payload: {
11
- mode: "plan" | "document";
12
- timestamp: number;
13
- }) => void) => () => void;
14
- documentMode: (cb: (payload: {
15
- mode: "plan" | "document";
16
- timestamp: number;
17
- }) => void) => () => void;
18
- firstPage: (cb: (payload: {
19
- timestamp: number;
20
- }) => void) => () => void;
21
- previousPage: (cb: (payload: {
22
- timestamp: number;
23
- }) => void) => () => void;
24
- nextPage: (cb: (payload: {
25
- timestamp: number;
26
- }) => void) => () => void;
27
- lastPage: (cb: (payload: {
28
- timestamp: number;
29
- }) => void) => () => void;
30
- currentPage: (cb: (payload: {
31
- pageIndex: number;
32
- pageNumber: number;
33
- timestamp: number;
34
- }) => void) => () => void;
35
- };
36
- constructor(viewer: Viewer3D);
37
- setDisabled3D(operators: string[]): void;
38
- setDisabledPdf(operators: string[]): void;
39
- clearDisabled3D(): void;
40
- clearDisabledPdf(): void;
41
- disableAll3D(): void;
42
- disableAllPdf(): void;
43
- enableAll3D(): void;
44
- enableAllPdf(): void;
45
- hideToolbar(): void;
46
- showToolbar(): void;
47
- setToolbarVisible(visible: boolean, target?: ToolbarVisibilityTarget): void;
48
- hideLeftToolbar(): void;
49
- showLeftToolbar(): void;
50
- hideCenterToolbar(): void;
51
- showCenterToolbar(): void;
52
- hideRightToolbar(): void;
53
- showRightToolbar(): void;
54
- openClippingPlanes(): void;
55
- closeClippingPlanes(): void;
56
- openSetting(): void;
57
- closeSetting(): void;
58
- openSetting3D(): void;
59
- closeSetting3D(): void;
60
- openSettingPdf(): void;
61
- closeSettingPdf(): void;
62
- openStatesObjects(): void;
63
- closeStatesObjects(): void;
64
- openLinkedObjects(): void;
65
- closeLinkedObjects(): void;
66
- openModelTree(): void;
67
- closeModelTree(): void;
68
- openObjectProperties(): void;
69
- closeObjectProperties(): void;
70
- openSheets(): void;
71
- closeSheets(): void;
72
- getSheets(options?: GetSheetsOptions): Promise<SheetListItem[]>;
73
- applySheet(sheetId: string | number): void;
74
- cuttingCloseSections(): void;
75
- cuttingMultipleSides(): void;
76
- cuttingToggleSelection(): void;
77
- cuttingTogglePlanes(): void;
78
- cuttingPlaneX(): void;
79
- cuttingPlaneY(): void;
80
- cuttingPlaneZ(): void;
81
- cuttingPlaneBox(): void;
82
- cuttingRotateBox(): void;
83
- cuttingReversePlaneX(): void;
84
- cuttingReversePlaneY(): void;
85
- cuttingReversePlaneZ(): void;
86
- private postConfig;
87
- private postToolbarVisibility;
88
- private postPanelOpen;
89
- private postPanelClose;
90
- private postCuttingAction;
91
- private postSheetsGetList;
92
- private postSheetsApply;
93
- }
@@ -1,249 +0,0 @@
1
- import { ViewerMessageType, } from "../contracts/messages";
2
- function createRequestId() {
3
- return `sheets_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
4
- }
5
- const ALL_3D_TOOLBAR_OPERATORS = [
6
- "home",
7
- "select",
8
- "areaSelect",
9
- "pan",
10
- "zoomIn",
11
- "zoomOut",
12
- "zoomWindow",
13
- "zoomFit",
14
- "orbit",
15
- "rotateZ",
16
- "walkThrough",
17
- "drawMode-shaded",
18
- "drawMode-wireframe",
19
- "drawMode-shaded-wire",
20
- "drawMode-hidden-line",
21
- "drawMode-xray",
22
- "drawMode-ghosting",
23
- "cutting-plane",
24
- "clipping-commands",
25
- "explode",
26
- "setting",
27
- "propertyPanel",
28
- "model-tree",
29
- "linkedObjects",
30
- "statesObjects",
31
- "synchronized",
32
- ];
33
- const ALL_PDF_TOOLBAR_OPERATORS = [
34
- "home",
35
- "select",
36
- "pan",
37
- "zoomIn",
38
- "zoomOut",
39
- "zoomWindow",
40
- "zoomFit",
41
- "rotateZ",
42
- "save",
43
- "setting",
44
- "plan-mode",
45
- "document-mode",
46
- "first-page",
47
- "previous-page",
48
- "next-page",
49
- "last-page",
50
- "current-page",
51
- ];
52
- export class ToolbarModule {
53
- constructor(viewer) {
54
- this.viewer = viewer;
55
- this.on = {
56
- planMode: (cb) => this.viewer._on("toolbar:pdf-plan-mode", cb),
57
- documentMode: (cb) => this.viewer._on("toolbar:pdf-document-mode", cb),
58
- firstPage: (cb) => this.viewer._on("toolbar:pdf-first-page", cb),
59
- previousPage: (cb) => this.viewer._on("toolbar:pdf-previous-page", cb),
60
- nextPage: (cb) => this.viewer._on("toolbar:pdf-next-page", cb),
61
- lastPage: (cb) => this.viewer._on("toolbar:pdf-last-page", cb),
62
- currentPage: (cb) => this.viewer._on("toolbar:pdf-current-page", cb),
63
- };
64
- }
65
- setDisabled3D(operators) {
66
- this.postConfig({ format: "3d", mode: "set", operators });
67
- }
68
- setDisabledPdf(operators) {
69
- this.postConfig({ format: "pdf", mode: "set", operators });
70
- }
71
- clearDisabled3D() {
72
- this.postConfig({ format: "3d", mode: "clear" });
73
- }
74
- clearDisabledPdf() {
75
- this.postConfig({ format: "pdf", mode: "clear" });
76
- }
77
- disableAll3D() {
78
- this.setDisabled3D(ALL_3D_TOOLBAR_OPERATORS);
79
- }
80
- disableAllPdf() {
81
- this.setDisabledPdf(ALL_PDF_TOOLBAR_OPERATORS);
82
- }
83
- enableAll3D() {
84
- this.clearDisabled3D();
85
- }
86
- enableAllPdf() {
87
- this.clearDisabledPdf();
88
- }
89
- hideToolbar() {
90
- this.setToolbarVisible(false);
91
- }
92
- showToolbar() {
93
- this.setToolbarVisible(true);
94
- }
95
- setToolbarVisible(visible, target = "all") {
96
- this.postToolbarVisibility({ visible, target });
97
- }
98
- hideLeftToolbar() {
99
- this.setToolbarVisible(false, "left");
100
- }
101
- showLeftToolbar() {
102
- this.setToolbarVisible(true, "left");
103
- }
104
- hideCenterToolbar() {
105
- this.setToolbarVisible(false, "center");
106
- }
107
- showCenterToolbar() {
108
- this.setToolbarVisible(true, "center");
109
- }
110
- hideRightToolbar() {
111
- this.setToolbarVisible(false, "right");
112
- }
113
- showRightToolbar() {
114
- this.setToolbarVisible(true, "right");
115
- }
116
- openClippingPlanes() {
117
- this.postPanelOpen({ panel: "clipping-commands", format: "3d" });
118
- }
119
- closeClippingPlanes() {
120
- this.postPanelClose({ panel: "clipping-commands", format: "3d" });
121
- }
122
- openSetting() {
123
- this.postPanelOpen({ panel: "setting" });
124
- }
125
- closeSetting() {
126
- this.postPanelClose({ panel: "setting" });
127
- }
128
- openSetting3D() {
129
- this.postPanelOpen({ panel: "setting", format: "3d" });
130
- }
131
- closeSetting3D() {
132
- this.postPanelClose({ panel: "setting", format: "3d" });
133
- }
134
- openSettingPdf() {
135
- this.postPanelOpen({ panel: "setting", format: "pdf" });
136
- }
137
- closeSettingPdf() {
138
- this.postPanelClose({ panel: "setting", format: "pdf" });
139
- }
140
- openStatesObjects() {
141
- this.postPanelOpen({ panel: "statesObjects", format: "3d" });
142
- }
143
- closeStatesObjects() {
144
- this.postPanelClose({ panel: "statesObjects", format: "3d" });
145
- }
146
- openLinkedObjects() {
147
- this.postPanelOpen({ panel: "linkedObjects", format: "3d" });
148
- }
149
- closeLinkedObjects() {
150
- this.postPanelClose({ panel: "linkedObjects", format: "3d" });
151
- }
152
- openModelTree() {
153
- this.postPanelOpen({ panel: "model-tree", format: "3d" });
154
- }
155
- closeModelTree() {
156
- this.postPanelClose({ panel: "model-tree", format: "3d" });
157
- }
158
- openObjectProperties() {
159
- this.postPanelOpen({ panel: "object-properties", format: "3d" });
160
- }
161
- closeObjectProperties() {
162
- this.postPanelClose({ panel: "object-properties", format: "3d" });
163
- }
164
- openSheets() {
165
- this.postPanelOpen({ panel: "sheets", format: "3d" });
166
- }
167
- closeSheets() {
168
- this.postPanelClose({ panel: "sheets", format: "3d" });
169
- }
170
- getSheets(options) {
171
- var _a;
172
- const requestId = createRequestId();
173
- const timeoutMs = Math.max(1000, (_a = options === null || options === void 0 ? void 0 : options.timeoutMs) !== null && _a !== void 0 ? _a : 10000);
174
- return new Promise((resolve, reject) => {
175
- const timer = setTimeout(() => {
176
- off();
177
- reject(new Error("Timeout while getting sheets list from viewer"));
178
- }, timeoutMs);
179
- const off = this.viewer._on("sheets:list", (payload) => {
180
- if (payload.requestId !== requestId)
181
- return;
182
- clearTimeout(timer);
183
- off();
184
- resolve(payload.sheets);
185
- });
186
- this.postSheetsGetList({ requestId });
187
- });
188
- }
189
- applySheet(sheetId) {
190
- this.postSheetsApply({ sheetId });
191
- }
192
- cuttingCloseSections() {
193
- this.postCuttingAction({ action: "close" });
194
- }
195
- cuttingMultipleSides() {
196
- this.postCuttingAction({ action: "multi" });
197
- }
198
- cuttingToggleSelection() {
199
- this.postCuttingAction({ action: "toggle-section" });
200
- }
201
- cuttingTogglePlanes() {
202
- this.postCuttingAction({ action: "toggle-plane" });
203
- }
204
- cuttingPlaneX() {
205
- this.postCuttingAction({ action: "plane-x" });
206
- }
207
- cuttingPlaneY() {
208
- this.postCuttingAction({ action: "plane-y" });
209
- }
210
- cuttingPlaneZ() {
211
- this.postCuttingAction({ action: "plane-z" });
212
- }
213
- cuttingPlaneBox() {
214
- this.postCuttingAction({ action: "plane-box" });
215
- }
216
- cuttingRotateBox() {
217
- this.postCuttingAction({ action: "rotate-box" });
218
- }
219
- cuttingReversePlaneX() {
220
- this.postCuttingAction({ action: "reverse-plane-x" });
221
- }
222
- cuttingReversePlaneY() {
223
- this.postCuttingAction({ action: "reverse-plane-y" });
224
- }
225
- cuttingReversePlaneZ() {
226
- this.postCuttingAction({ action: "reverse-plane-z" });
227
- }
228
- postConfig(payload) {
229
- this.viewer.postToViewer(ViewerMessageType.TOOLBAR_CONFIG, payload);
230
- }
231
- postToolbarVisibility(payload) {
232
- this.viewer.postToViewer(ViewerMessageType.TOOLBAR_VISIBILITY, payload);
233
- }
234
- postPanelOpen(payload) {
235
- this.viewer.postToViewer(ViewerMessageType.PANEL_OPEN, payload);
236
- }
237
- postPanelClose(payload) {
238
- this.viewer.postToViewer(ViewerMessageType.PANEL_CLOSE, payload);
239
- }
240
- postCuttingAction(payload) {
241
- this.viewer.postToViewer(ViewerMessageType.CUTTING_PLANE_ACTION, payload);
242
- }
243
- postSheetsGetList(payload) {
244
- this.viewer.postToViewer(ViewerMessageType.SHEETS_GET_LIST, payload);
245
- }
246
- postSheetsApply(payload) {
247
- this.viewer.postToViewer(ViewerMessageType.SHEETS_APPLY, payload);
248
- }
249
- }
package/dist/viewer.d.ts DELETED
@@ -1,54 +0,0 @@
1
- import type { PreparedViewerData, SdkEventKey, SdkEventPayload } from "./contracts/events";
2
- import { CameraModule } from "./modules/camera.module";
3
- import { InteractionModule } from "./modules/interaction.module";
4
- import { NodeModule } from "./modules/node.module";
5
- import { FilesModule } from "./modules/files.module";
6
- import { ToolbarModule } from "./modules/toolbar.module";
7
- import { ModelTreeModule } from "./modules/model-tree.module";
8
- import { MarkupModule } from "./modules/markup.module";
9
- import { LanguageModule } from "./modules/language.module";
10
- import { ViewerMessageType, type ToolbarVisibilityTarget } from "./contracts/messages";
11
- export declare type InitialToolbarVisibility = Partial<Record<ToolbarVisibilityTarget, boolean>>;
12
- export declare type Viewer3DOptions = {
13
- container: HTMLElement | string;
14
- url?: string;
15
- baseUrl?: string;
16
- viewerPath?: string;
17
- uploadPath?: string;
18
- file?: File;
19
- initialToolbarVisibility?: InitialToolbarVisibility;
20
- width?: string;
21
- height?: string;
22
- sandbox?: string;
23
- allowedOrigin?: string;
24
- };
25
- export declare class Viewer3D {
26
- private options;
27
- private containerEl;
28
- private iframeEl;
29
- private initialized;
30
- private emitter;
31
- camera: CameraModule;
32
- interaction: InteractionModule;
33
- node: NodeModule;
34
- files: FilesModule;
35
- toolbar: ToolbarModule;
36
- modelTree: ModelTreeModule;
37
- markup: MarkupModule;
38
- language: LanguageModule;
39
- constructor(options: Viewer3DOptions);
40
- getOptions(): Viewer3DOptions;
41
- patchOptions(next: Partial<Viewer3DOptions>): void;
42
- getUrl(): string | null;
43
- init(): void;
44
- render(file?: File): Promise<PreparedViewerData | void>;
45
- open(url: string): void;
46
- destroy(): void;
47
- private ensureInit;
48
- private withInitialOptions;
49
- _on<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): () => void;
50
- _off<K extends SdkEventKey>(event: K, cb: (payload: SdkEventPayload<K>) => void): void;
51
- _emit<K extends SdkEventKey>(event: K, payload: SdkEventPayload<K>): void;
52
- postToViewer<TPayload = unknown>(type: ViewerMessageType, payload?: TPayload): void;
53
- private handleMessage;
54
- }