3dviewer-sdk 1.0.16 → 1.0.18
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/contracts/events.d.ts +97 -0
- package/dist/contracts/events.js +1 -0
- package/dist/contracts/messages.d.ts +159 -0
- package/dist/contracts/messages.js +50 -0
- package/dist/core/emitter.d.ts +7 -0
- package/dist/core/emitter.js +31 -0
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +50 -12
- package/dist/index.mjs +50 -12
- package/dist/modules/camera.module.d.ts +13 -0
- package/dist/modules/camera.module.js +18 -0
- package/dist/modules/files.module.d.ts +112 -0
- package/dist/modules/files.module.js +461 -0
- package/dist/modules/interaction.module.d.ts +28 -0
- package/dist/modules/interaction.module.js +63 -0
- package/dist/modules/language.module.d.ts +8 -0
- package/dist/modules/language.module.js +15 -0
- package/dist/modules/markup.module.d.ts +26 -0
- package/dist/modules/markup.module.js +96 -0
- package/dist/modules/model-tree.module.d.ts +12 -0
- package/dist/modules/model-tree.module.js +42 -0
- package/dist/modules/node.module.d.ts +11 -0
- package/dist/modules/node.module.js +6 -0
- package/dist/modules/toolbar.module.d.ts +93 -0
- package/dist/modules/toolbar.module.js +249 -0
- package/dist/viewer.d.ts +54 -0
- package/dist/viewer.js +290 -0
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { MarkupListItem, MarkupOperationResultPayload, PdfCurrentPagePayload, PdfModeEventPayload, PdfToolbarActionEventPayload } from "./messages";
|
|
2
|
+
export declare type ViewerEventMap = {
|
|
3
|
+
"camera:home": {
|
|
4
|
+
timestamp: number;
|
|
5
|
+
};
|
|
6
|
+
"node:select": {
|
|
7
|
+
nodeId: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
};
|
|
10
|
+
"interaction:pan-change": {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
};
|
|
13
|
+
"toolbar:pdf-plan-mode": PdfModeEventPayload;
|
|
14
|
+
"toolbar:pdf-document-mode": PdfModeEventPayload;
|
|
15
|
+
"toolbar:pdf-first-page": PdfToolbarActionEventPayload;
|
|
16
|
+
"toolbar:pdf-previous-page": PdfToolbarActionEventPayload;
|
|
17
|
+
"toolbar:pdf-next-page": PdfToolbarActionEventPayload;
|
|
18
|
+
"toolbar:pdf-last-page": PdfToolbarActionEventPayload;
|
|
19
|
+
"toolbar:pdf-current-page": PdfCurrentPagePayload;
|
|
20
|
+
"modelTree:node-ids": {
|
|
21
|
+
requestId: string;
|
|
22
|
+
nodeIds: string[];
|
|
23
|
+
timestamp: number;
|
|
24
|
+
};
|
|
25
|
+
"sheets:list": {
|
|
26
|
+
requestId: string;
|
|
27
|
+
sheets: {
|
|
28
|
+
id: string | number;
|
|
29
|
+
name: string;
|
|
30
|
+
is3D?: boolean;
|
|
31
|
+
viewId?: string;
|
|
32
|
+
}[];
|
|
33
|
+
activeSheetId?: string | number | null;
|
|
34
|
+
timestamp: number;
|
|
35
|
+
};
|
|
36
|
+
"markup:list": {
|
|
37
|
+
requestId: string;
|
|
38
|
+
markups: MarkupListItem[];
|
|
39
|
+
timestamp: number;
|
|
40
|
+
};
|
|
41
|
+
"markup:save": MarkupOperationResultPayload;
|
|
42
|
+
"markup:cancel": MarkupOperationResultPayload;
|
|
43
|
+
};
|
|
44
|
+
export declare type LoadStage = "idle" | "uploading" | "converting" | "rendering" | "completed" | "error";
|
|
45
|
+
export declare type LoadStatePayload = {
|
|
46
|
+
isLoading: boolean;
|
|
47
|
+
stage: LoadStage;
|
|
48
|
+
message?: string;
|
|
49
|
+
elapsedMs?: number;
|
|
50
|
+
};
|
|
51
|
+
export declare type PreparedViewerData = {
|
|
52
|
+
baseFileId: string;
|
|
53
|
+
baseMajorRev: number;
|
|
54
|
+
baseMinorRev: number;
|
|
55
|
+
fileName: string;
|
|
56
|
+
query: string;
|
|
57
|
+
url: string;
|
|
58
|
+
};
|
|
59
|
+
export declare type FilesEventMap = {
|
|
60
|
+
"files:state": LoadStatePayload;
|
|
61
|
+
"files:upload:start": {
|
|
62
|
+
fileName: string;
|
|
63
|
+
};
|
|
64
|
+
"files:upload:success": {
|
|
65
|
+
fileName: string;
|
|
66
|
+
baseFileId: string;
|
|
67
|
+
};
|
|
68
|
+
"files:upload:error": {
|
|
69
|
+
fileName: string;
|
|
70
|
+
error: string;
|
|
71
|
+
};
|
|
72
|
+
"files:conversion:start": {
|
|
73
|
+
fileName: string;
|
|
74
|
+
};
|
|
75
|
+
"files:conversion:success": PreparedViewerData;
|
|
76
|
+
"files:conversion:error": {
|
|
77
|
+
fileName: string;
|
|
78
|
+
error: string;
|
|
79
|
+
};
|
|
80
|
+
"files:render:start": {
|
|
81
|
+
url: string;
|
|
82
|
+
};
|
|
83
|
+
"files:render:success": {
|
|
84
|
+
url: string;
|
|
85
|
+
};
|
|
86
|
+
"files:render:error": {
|
|
87
|
+
url?: string;
|
|
88
|
+
error: string;
|
|
89
|
+
};
|
|
90
|
+
"files:load:success": PreparedViewerData;
|
|
91
|
+
"files:load:error": {
|
|
92
|
+
error: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export declare type SdkEventMap = ViewerEventMap & FilesEventMap;
|
|
96
|
+
export declare type SdkEventKey = keyof SdkEventMap;
|
|
97
|
+
export declare type SdkEventPayload<K extends SdkEventKey> = SdkEventMap[K];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
export declare enum ViewerMessageType {
|
|
2
|
+
LANGUAGE_CHANGE = "viewer-language-change",
|
|
3
|
+
ZOOM = "viewer-zoom",
|
|
4
|
+
DRAW_MODE = "viewer-draw-mode",
|
|
5
|
+
EXPLODE = "viewer-explode",
|
|
6
|
+
MARKUP_ACTION = "viewer-markup-action",
|
|
7
|
+
MARKUP_SAVE = "viewer-markup-save",
|
|
8
|
+
MARKUP_CANCEL = "viewer-markup-cancel",
|
|
9
|
+
MARKUP_GET_LIST = "viewer-markup-get-list",
|
|
10
|
+
MARKUP_SAVE_RESULT = "viewer-markup-save-result",
|
|
11
|
+
MARKUP_CANCEL_RESULT = "viewer-markup-cancel-result",
|
|
12
|
+
MARKUP_LIST = "viewer-markup-list",
|
|
13
|
+
HOME = "viewer-home",
|
|
14
|
+
PAN_TOGGLE = "viewer-pan-toggle",
|
|
15
|
+
SELECT = "viewer-select",
|
|
16
|
+
AREA_SELECT = "viewer-area-select",
|
|
17
|
+
ORBIT = "viewer-orbit",
|
|
18
|
+
ROTATE_Z = "viewer-rotate-z",
|
|
19
|
+
WALK_THROUGH = "viewer-walk-through",
|
|
20
|
+
ZOOM_WINDOW = "viewer-zoom-window",
|
|
21
|
+
ZOOM_FIT = "viewer-zoom-fit",
|
|
22
|
+
TOOLBAR_CONFIG = "viewer-toolbar-config",
|
|
23
|
+
TOOLBAR_VISIBILITY = "viewer-toolbar-visibility",
|
|
24
|
+
PANEL_OPEN = "viewer-panel-open",
|
|
25
|
+
PANEL_CLOSE = "viewer-panel-close",
|
|
26
|
+
CUTTING_PLANE_ACTION = "viewer-cutting-plane-action",
|
|
27
|
+
SHEETS_GET_LIST = "viewer-sheets-get-list",
|
|
28
|
+
SHEETS_LIST = "viewer-sheets-list",
|
|
29
|
+
SHEETS_APPLY = "viewer-sheets-apply",
|
|
30
|
+
TREE_SELECT_NODE = "viewer-tree-select-node",
|
|
31
|
+
TREE_GET_NODE_IDS = "viewer-tree-get-node-ids",
|
|
32
|
+
TREE_NODE_IDS = "viewer-tree-node-ids",
|
|
33
|
+
PDF_PLAN_MODE = "viewer-pdf-plan-mode",
|
|
34
|
+
PDF_DOCUMENT_MODE = "viewer-pdf-document-mode",
|
|
35
|
+
PDF_FIRST_PAGE = "viewer-pdf-first-page",
|
|
36
|
+
PDF_PREVIOUS_PAGE = "viewer-pdf-previous-page",
|
|
37
|
+
PDF_NEXT_PAGE = "viewer-pdf-next-page",
|
|
38
|
+
PDF_LAST_PAGE = "viewer-pdf-last-page",
|
|
39
|
+
PDF_CURRENT_PAGE = "viewer-pdf-current-page",
|
|
40
|
+
HOME_CLICK = "viewer-home-click",
|
|
41
|
+
NODE_SELECT = "viewer-node-select",
|
|
42
|
+
PAN_CHANGE = "viewer-pan-change"
|
|
43
|
+
}
|
|
44
|
+
export declare enum ViewerMessageSource {
|
|
45
|
+
SDK = "HC_SDK",
|
|
46
|
+
VIEWER = "HC_VIEWER"
|
|
47
|
+
}
|
|
48
|
+
export declare type OutgoingMessage<T = unknown> = {
|
|
49
|
+
source: ViewerMessageSource.SDK;
|
|
50
|
+
type: ViewerMessageType;
|
|
51
|
+
payload?: T;
|
|
52
|
+
};
|
|
53
|
+
export declare type IncomingMessage<T = any> = {
|
|
54
|
+
source?: ViewerMessageSource | string;
|
|
55
|
+
type: ViewerMessageType;
|
|
56
|
+
payload?: T;
|
|
57
|
+
};
|
|
58
|
+
export declare type LanguageCode = "en" | "vn";
|
|
59
|
+
export declare type LanguageChangePayload = {
|
|
60
|
+
language: LanguageCode;
|
|
61
|
+
timestamp?: number;
|
|
62
|
+
};
|
|
63
|
+
export declare type DrawModeValue = "shaded" | "wireframe" | "hidden-line" | "shaded-wire" | "xray" | "ghosting";
|
|
64
|
+
export declare type DrawModePayload = {
|
|
65
|
+
mode: DrawModeValue;
|
|
66
|
+
};
|
|
67
|
+
export declare type ToolbarVisibilityTarget = "all" | "left" | "center" | "right";
|
|
68
|
+
export declare type ToolbarVisibilityPayload = {
|
|
69
|
+
visible: boolean;
|
|
70
|
+
target?: ToolbarVisibilityTarget;
|
|
71
|
+
};
|
|
72
|
+
export declare type ExplodePayload = {
|
|
73
|
+
magnitude: number;
|
|
74
|
+
};
|
|
75
|
+
export declare type MarkupAction = "line" | "arrow" | "circle" | "ellipse" | "rectangle" | "polygon" | "polyline" | "textbox" | "note" | "callout" | "cloud" | "freehand";
|
|
76
|
+
export declare type MarkupActionPayload = {
|
|
77
|
+
action: MarkupAction;
|
|
78
|
+
};
|
|
79
|
+
export declare type MarkupRequestPayload = {
|
|
80
|
+
requestId: string;
|
|
81
|
+
};
|
|
82
|
+
export declare type MarkupOperationResultPayload = {
|
|
83
|
+
requestId: string;
|
|
84
|
+
success: boolean;
|
|
85
|
+
timestamp: number;
|
|
86
|
+
error?: string;
|
|
87
|
+
};
|
|
88
|
+
export declare type MarkupListItem = {
|
|
89
|
+
id: string;
|
|
90
|
+
viewId: string;
|
|
91
|
+
viewName?: string;
|
|
92
|
+
title: string;
|
|
93
|
+
type: string;
|
|
94
|
+
shapeName?: string;
|
|
95
|
+
createdDate?: string;
|
|
96
|
+
modifiedDate?: string;
|
|
97
|
+
createdBy?: string;
|
|
98
|
+
lastModifiedBy?: string;
|
|
99
|
+
};
|
|
100
|
+
export declare type MarkupListPayload = {
|
|
101
|
+
requestId: string;
|
|
102
|
+
markups: MarkupListItem[];
|
|
103
|
+
timestamp: number;
|
|
104
|
+
};
|
|
105
|
+
export declare type PanelTarget = "clipping-commands" | "setting" | "statesObjects" | "linkedObjects" | "model-tree" | "sheets" | "object-properties";
|
|
106
|
+
export declare type PanelOpenPayload = {
|
|
107
|
+
panel: PanelTarget;
|
|
108
|
+
format?: "3d" | "pdf";
|
|
109
|
+
};
|
|
110
|
+
export declare type PanelClosePayload = {
|
|
111
|
+
panel: PanelTarget;
|
|
112
|
+
format?: "3d" | "pdf";
|
|
113
|
+
};
|
|
114
|
+
export declare type CuttingPlaneAction = "close" | "multi" | "toggle-section" | "toggle-plane" | "plane-x" | "plane-y" | "plane-z" | "plane-box" | "rotate-box" | "reverse-plane-x" | "reverse-plane-y" | "reverse-plane-z";
|
|
115
|
+
export declare type CuttingPlaneActionPayload = {
|
|
116
|
+
action: CuttingPlaneAction;
|
|
117
|
+
};
|
|
118
|
+
export declare type SheetsGetListPayload = {
|
|
119
|
+
requestId: string;
|
|
120
|
+
};
|
|
121
|
+
export declare type SheetListItem = {
|
|
122
|
+
id: string | number;
|
|
123
|
+
name: string;
|
|
124
|
+
is3D?: boolean;
|
|
125
|
+
viewId?: string;
|
|
126
|
+
};
|
|
127
|
+
export declare type SheetsListPayload = {
|
|
128
|
+
requestId: string;
|
|
129
|
+
sheets: SheetListItem[];
|
|
130
|
+
activeSheetId?: string | number | null;
|
|
131
|
+
timestamp: number;
|
|
132
|
+
};
|
|
133
|
+
export declare type SheetsApplyPayload = {
|
|
134
|
+
sheetId: string | number;
|
|
135
|
+
};
|
|
136
|
+
export declare type TreeSelectNodePayload = {
|
|
137
|
+
nodeId: string;
|
|
138
|
+
};
|
|
139
|
+
export declare type TreeGetNodeIdsPayload = {
|
|
140
|
+
requestId: string;
|
|
141
|
+
onlyRealNodes?: boolean;
|
|
142
|
+
};
|
|
143
|
+
export declare type TreeNodeIdsPayload = {
|
|
144
|
+
requestId: string;
|
|
145
|
+
nodeIds: string[];
|
|
146
|
+
timestamp: number;
|
|
147
|
+
};
|
|
148
|
+
export declare type PdfModeEventPayload = {
|
|
149
|
+
mode: "plan" | "document";
|
|
150
|
+
timestamp: number;
|
|
151
|
+
};
|
|
152
|
+
export declare type PdfToolbarActionEventPayload = {
|
|
153
|
+
timestamp: number;
|
|
154
|
+
};
|
|
155
|
+
export declare type PdfCurrentPagePayload = {
|
|
156
|
+
pageIndex: number;
|
|
157
|
+
pageNumber: number;
|
|
158
|
+
timestamp: number;
|
|
159
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// sdk/src/contracts/messages.ts
|
|
2
|
+
export var ViewerMessageType;
|
|
3
|
+
(function (ViewerMessageType) {
|
|
4
|
+
ViewerMessageType["LANGUAGE_CHANGE"] = "viewer-language-change";
|
|
5
|
+
ViewerMessageType["ZOOM"] = "viewer-zoom";
|
|
6
|
+
ViewerMessageType["DRAW_MODE"] = "viewer-draw-mode";
|
|
7
|
+
ViewerMessageType["EXPLODE"] = "viewer-explode";
|
|
8
|
+
ViewerMessageType["MARKUP_ACTION"] = "viewer-markup-action";
|
|
9
|
+
ViewerMessageType["MARKUP_SAVE"] = "viewer-markup-save";
|
|
10
|
+
ViewerMessageType["MARKUP_CANCEL"] = "viewer-markup-cancel";
|
|
11
|
+
ViewerMessageType["MARKUP_GET_LIST"] = "viewer-markup-get-list";
|
|
12
|
+
ViewerMessageType["MARKUP_SAVE_RESULT"] = "viewer-markup-save-result";
|
|
13
|
+
ViewerMessageType["MARKUP_CANCEL_RESULT"] = "viewer-markup-cancel-result";
|
|
14
|
+
ViewerMessageType["MARKUP_LIST"] = "viewer-markup-list";
|
|
15
|
+
ViewerMessageType["HOME"] = "viewer-home";
|
|
16
|
+
ViewerMessageType["PAN_TOGGLE"] = "viewer-pan-toggle";
|
|
17
|
+
ViewerMessageType["SELECT"] = "viewer-select";
|
|
18
|
+
ViewerMessageType["AREA_SELECT"] = "viewer-area-select";
|
|
19
|
+
ViewerMessageType["ORBIT"] = "viewer-orbit";
|
|
20
|
+
ViewerMessageType["ROTATE_Z"] = "viewer-rotate-z";
|
|
21
|
+
ViewerMessageType["WALK_THROUGH"] = "viewer-walk-through";
|
|
22
|
+
ViewerMessageType["ZOOM_WINDOW"] = "viewer-zoom-window";
|
|
23
|
+
ViewerMessageType["ZOOM_FIT"] = "viewer-zoom-fit";
|
|
24
|
+
ViewerMessageType["TOOLBAR_CONFIG"] = "viewer-toolbar-config";
|
|
25
|
+
ViewerMessageType["TOOLBAR_VISIBILITY"] = "viewer-toolbar-visibility";
|
|
26
|
+
ViewerMessageType["PANEL_OPEN"] = "viewer-panel-open";
|
|
27
|
+
ViewerMessageType["PANEL_CLOSE"] = "viewer-panel-close";
|
|
28
|
+
ViewerMessageType["CUTTING_PLANE_ACTION"] = "viewer-cutting-plane-action";
|
|
29
|
+
ViewerMessageType["SHEETS_GET_LIST"] = "viewer-sheets-get-list";
|
|
30
|
+
ViewerMessageType["SHEETS_LIST"] = "viewer-sheets-list";
|
|
31
|
+
ViewerMessageType["SHEETS_APPLY"] = "viewer-sheets-apply";
|
|
32
|
+
ViewerMessageType["TREE_SELECT_NODE"] = "viewer-tree-select-node";
|
|
33
|
+
ViewerMessageType["TREE_GET_NODE_IDS"] = "viewer-tree-get-node-ids";
|
|
34
|
+
ViewerMessageType["TREE_NODE_IDS"] = "viewer-tree-node-ids";
|
|
35
|
+
ViewerMessageType["PDF_PLAN_MODE"] = "viewer-pdf-plan-mode";
|
|
36
|
+
ViewerMessageType["PDF_DOCUMENT_MODE"] = "viewer-pdf-document-mode";
|
|
37
|
+
ViewerMessageType["PDF_FIRST_PAGE"] = "viewer-pdf-first-page";
|
|
38
|
+
ViewerMessageType["PDF_PREVIOUS_PAGE"] = "viewer-pdf-previous-page";
|
|
39
|
+
ViewerMessageType["PDF_NEXT_PAGE"] = "viewer-pdf-next-page";
|
|
40
|
+
ViewerMessageType["PDF_LAST_PAGE"] = "viewer-pdf-last-page";
|
|
41
|
+
ViewerMessageType["PDF_CURRENT_PAGE"] = "viewer-pdf-current-page";
|
|
42
|
+
ViewerMessageType["HOME_CLICK"] = "viewer-home-click";
|
|
43
|
+
ViewerMessageType["NODE_SELECT"] = "viewer-node-select";
|
|
44
|
+
ViewerMessageType["PAN_CHANGE"] = "viewer-pan-change";
|
|
45
|
+
})(ViewerMessageType || (ViewerMessageType = {}));
|
|
46
|
+
export var ViewerMessageSource;
|
|
47
|
+
(function (ViewerMessageSource) {
|
|
48
|
+
ViewerMessageSource["SDK"] = "HC_SDK";
|
|
49
|
+
ViewerMessageSource["VIEWER"] = "HC_VIEWER";
|
|
50
|
+
})(ViewerMessageSource || (ViewerMessageSource = {}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class Emitter<EventMap extends Record<string, any>> {
|
|
2
|
+
private listeners;
|
|
3
|
+
on<K extends keyof EventMap>(event: K, cb: (payload: EventMap[K]) => void): () => void;
|
|
4
|
+
off<K extends keyof EventMap>(event: K, cb: (payload: EventMap[K]) => void): void;
|
|
5
|
+
emit<K extends keyof EventMap>(event: K, payload: EventMap[K]): void;
|
|
6
|
+
clear(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// sdk/src/core/emitter.ts
|
|
2
|
+
export class Emitter {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.listeners = {};
|
|
5
|
+
}
|
|
6
|
+
on(event, cb) {
|
|
7
|
+
if (!this.listeners[event]) {
|
|
8
|
+
this.listeners[event] = [];
|
|
9
|
+
}
|
|
10
|
+
const arr = this.listeners[event];
|
|
11
|
+
arr.push(cb);
|
|
12
|
+
return () => this.off(event, cb);
|
|
13
|
+
}
|
|
14
|
+
off(event, cb) {
|
|
15
|
+
const arr = this.listeners[event];
|
|
16
|
+
if (!arr)
|
|
17
|
+
return;
|
|
18
|
+
const idx = arr.indexOf(cb);
|
|
19
|
+
if (idx >= 0)
|
|
20
|
+
arr.splice(idx, 1);
|
|
21
|
+
if (arr.length === 0)
|
|
22
|
+
delete this.listeners[event];
|
|
23
|
+
}
|
|
24
|
+
emit(event, payload) {
|
|
25
|
+
var _a;
|
|
26
|
+
(_a = this.listeners[event]) === null || _a === void 0 ? void 0 : _a.forEach((cb) => cb(payload));
|
|
27
|
+
}
|
|
28
|
+
clear() {
|
|
29
|
+
this.listeners = {};
|
|
30
|
+
}
|
|
31
|
+
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
declare enum ViewerMessageType {
|
|
2
2
|
LANGUAGE_CHANGE = "viewer-language-change",
|
|
3
3
|
ZOOM = "viewer-zoom",
|
|
4
|
+
CAMERA_GET_ZOOM = "viewer-camera-get-zoom",
|
|
5
|
+
CAMERA_ZOOM = "viewer-camera-zoom",
|
|
4
6
|
DRAW_MODE = "viewer-draw-mode",
|
|
5
7
|
EXPLODE = "viewer-explode",
|
|
6
8
|
MARKUP_ACTION = "viewer-markup-action",
|
|
@@ -50,6 +52,12 @@ declare enum ViewerMessageType {
|
|
|
50
52
|
PAN_CHANGE = "viewer-pan-change"
|
|
51
53
|
}
|
|
52
54
|
type LanguageCode = "en" | "vn";
|
|
55
|
+
type CameraZoomPayload = {
|
|
56
|
+
requestId?: string;
|
|
57
|
+
percent: number;
|
|
58
|
+
zoomFactor: number;
|
|
59
|
+
timestamp: number;
|
|
60
|
+
};
|
|
53
61
|
type ToolbarUseTarget = "all" | "left" | "center" | "right";
|
|
54
62
|
type MarkupAction = "line" | "arrow" | "circle" | "ellipse" | "rectangle" | "polygon" | "polyline" | "textbox" | "note" | "callout" | "cloud" | "freehand";
|
|
55
63
|
type MarkupOperationResultPayload = {
|
|
@@ -123,6 +131,7 @@ type ViewerEventMap = {
|
|
|
123
131
|
"camera:home": {
|
|
124
132
|
timestamp: number;
|
|
125
133
|
};
|
|
134
|
+
"camera:zoom": CameraZoomPayload;
|
|
126
135
|
"node:select": {
|
|
127
136
|
nodeId: string;
|
|
128
137
|
timestamp: number;
|
|
@@ -237,17 +246,23 @@ type SdkEventMap = ViewerEventMap & FilesEventMap;
|
|
|
237
246
|
type SdkEventKey = keyof SdkEventMap;
|
|
238
247
|
type SdkEventPayload<K extends SdkEventKey> = SdkEventMap[K];
|
|
239
248
|
|
|
249
|
+
type GetZoomOptions = {
|
|
250
|
+
timeoutMs?: number;
|
|
251
|
+
};
|
|
240
252
|
declare class CameraModule {
|
|
241
253
|
private viewer;
|
|
242
254
|
on: {
|
|
243
255
|
home: (cb: (payload: {
|
|
244
256
|
timestamp: number;
|
|
245
257
|
}) => void) => () => void;
|
|
258
|
+
zoom: (cb: (payload: CameraZoomPayload) => void) => () => void;
|
|
246
259
|
};
|
|
247
260
|
constructor(viewer: Viewer3D);
|
|
248
261
|
zoomIn(percent: number): void;
|
|
249
262
|
zoomOut(percent: number): void;
|
|
250
263
|
home(): void;
|
|
264
|
+
getZoom(options?: GetZoomOptions): Promise<CameraZoomPayload>;
|
|
265
|
+
private postCameraGetZoom;
|
|
251
266
|
}
|
|
252
267
|
|
|
253
268
|
declare class InteractionModule {
|
|
@@ -301,8 +316,8 @@ type ConvertV2Options = {
|
|
|
301
316
|
filename: string;
|
|
302
317
|
originalFilePath: string;
|
|
303
318
|
downloadUrl: string;
|
|
304
|
-
workflowId
|
|
305
|
-
taskId
|
|
319
|
+
workflowId?: string;
|
|
320
|
+
taskId?: string;
|
|
306
321
|
baseFileId: string;
|
|
307
322
|
baseMajorRev?: number;
|
|
308
323
|
baseMinorRev?: number;
|
|
@@ -601,4 +616,4 @@ declare class Viewer3D {
|
|
|
601
616
|
private handleMessage;
|
|
602
617
|
}
|
|
603
618
|
|
|
604
|
-
export { 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 PreparedViewerData, Viewer3D };
|
|
619
|
+
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 PreparedViewerData, Viewer3D };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
declare enum ViewerMessageType {
|
|
2
2
|
LANGUAGE_CHANGE = "viewer-language-change",
|
|
3
3
|
ZOOM = "viewer-zoom",
|
|
4
|
+
CAMERA_GET_ZOOM = "viewer-camera-get-zoom",
|
|
5
|
+
CAMERA_ZOOM = "viewer-camera-zoom",
|
|
4
6
|
DRAW_MODE = "viewer-draw-mode",
|
|
5
7
|
EXPLODE = "viewer-explode",
|
|
6
8
|
MARKUP_ACTION = "viewer-markup-action",
|
|
@@ -50,6 +52,12 @@ declare enum ViewerMessageType {
|
|
|
50
52
|
PAN_CHANGE = "viewer-pan-change"
|
|
51
53
|
}
|
|
52
54
|
type LanguageCode = "en" | "vn";
|
|
55
|
+
type CameraZoomPayload = {
|
|
56
|
+
requestId?: string;
|
|
57
|
+
percent: number;
|
|
58
|
+
zoomFactor: number;
|
|
59
|
+
timestamp: number;
|
|
60
|
+
};
|
|
53
61
|
type ToolbarUseTarget = "all" | "left" | "center" | "right";
|
|
54
62
|
type MarkupAction = "line" | "arrow" | "circle" | "ellipse" | "rectangle" | "polygon" | "polyline" | "textbox" | "note" | "callout" | "cloud" | "freehand";
|
|
55
63
|
type MarkupOperationResultPayload = {
|
|
@@ -123,6 +131,7 @@ type ViewerEventMap = {
|
|
|
123
131
|
"camera:home": {
|
|
124
132
|
timestamp: number;
|
|
125
133
|
};
|
|
134
|
+
"camera:zoom": CameraZoomPayload;
|
|
126
135
|
"node:select": {
|
|
127
136
|
nodeId: string;
|
|
128
137
|
timestamp: number;
|
|
@@ -237,17 +246,23 @@ type SdkEventMap = ViewerEventMap & FilesEventMap;
|
|
|
237
246
|
type SdkEventKey = keyof SdkEventMap;
|
|
238
247
|
type SdkEventPayload<K extends SdkEventKey> = SdkEventMap[K];
|
|
239
248
|
|
|
249
|
+
type GetZoomOptions = {
|
|
250
|
+
timeoutMs?: number;
|
|
251
|
+
};
|
|
240
252
|
declare class CameraModule {
|
|
241
253
|
private viewer;
|
|
242
254
|
on: {
|
|
243
255
|
home: (cb: (payload: {
|
|
244
256
|
timestamp: number;
|
|
245
257
|
}) => void) => () => void;
|
|
258
|
+
zoom: (cb: (payload: CameraZoomPayload) => void) => () => void;
|
|
246
259
|
};
|
|
247
260
|
constructor(viewer: Viewer3D);
|
|
248
261
|
zoomIn(percent: number): void;
|
|
249
262
|
zoomOut(percent: number): void;
|
|
250
263
|
home(): void;
|
|
264
|
+
getZoom(options?: GetZoomOptions): Promise<CameraZoomPayload>;
|
|
265
|
+
private postCameraGetZoom;
|
|
251
266
|
}
|
|
252
267
|
|
|
253
268
|
declare class InteractionModule {
|
|
@@ -301,8 +316,8 @@ type ConvertV2Options = {
|
|
|
301
316
|
filename: string;
|
|
302
317
|
originalFilePath: string;
|
|
303
318
|
downloadUrl: string;
|
|
304
|
-
workflowId
|
|
305
|
-
taskId
|
|
319
|
+
workflowId?: string;
|
|
320
|
+
taskId?: string;
|
|
306
321
|
baseFileId: string;
|
|
307
322
|
baseMajorRev?: number;
|
|
308
323
|
baseMinorRev?: number;
|
|
@@ -601,4 +616,4 @@ declare class Viewer3D {
|
|
|
601
616
|
private handleMessage;
|
|
602
617
|
}
|
|
603
618
|
|
|
604
|
-
export { 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 PreparedViewerData, Viewer3D };
|
|
619
|
+
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 PreparedViewerData, Viewer3D };
|
package/dist/index.js
CHANGED
|
@@ -54,11 +54,18 @@ var Emitter = class {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
// src/modules/camera.module.ts
|
|
57
|
+
function createRequestId(prefix) {
|
|
58
|
+
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
59
|
+
}
|
|
60
|
+
function resolveTimeoutMs(timeoutMs) {
|
|
61
|
+
return Math.max(1e3, timeoutMs != null ? timeoutMs : 1e4);
|
|
62
|
+
}
|
|
57
63
|
var CameraModule = class {
|
|
58
64
|
constructor(viewer) {
|
|
59
65
|
this.viewer = viewer;
|
|
60
66
|
this.on = {
|
|
61
|
-
home: (cb) => this.viewer._on("camera:home", cb)
|
|
67
|
+
home: (cb) => this.viewer._on("camera:home", cb),
|
|
68
|
+
zoom: (cb) => this.viewer._on("camera:zoom", cb)
|
|
62
69
|
};
|
|
63
70
|
}
|
|
64
71
|
zoomIn(percent) {
|
|
@@ -70,6 +77,26 @@ var CameraModule = class {
|
|
|
70
77
|
home() {
|
|
71
78
|
this.viewer.postToViewer("viewer-home" /* HOME */, {});
|
|
72
79
|
}
|
|
80
|
+
getZoom(options) {
|
|
81
|
+
const requestId = createRequestId("camera_zoom");
|
|
82
|
+
const timeoutMs = resolveTimeoutMs(options == null ? void 0 : options.timeoutMs);
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
const timer = setTimeout(() => {
|
|
85
|
+
off();
|
|
86
|
+
reject(new Error("Timeout while getting camera zoom state from viewer"));
|
|
87
|
+
}, timeoutMs);
|
|
88
|
+
const off = this.viewer._on("camera:zoom", (payload) => {
|
|
89
|
+
if (payload.requestId !== requestId) return;
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
off();
|
|
92
|
+
resolve(payload);
|
|
93
|
+
});
|
|
94
|
+
this.postCameraGetZoom({ requestId });
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
postCameraGetZoom(payload) {
|
|
98
|
+
this.viewer.postToViewer("viewer-camera-get-zoom" /* CAMERA_GET_ZOOM */, payload);
|
|
99
|
+
}
|
|
73
100
|
};
|
|
74
101
|
|
|
75
102
|
// src/modules/interaction.module.ts
|
|
@@ -588,7 +615,7 @@ var FilesModule = class {
|
|
|
588
615
|
};
|
|
589
616
|
|
|
590
617
|
// src/modules/toolbar.module.ts
|
|
591
|
-
function
|
|
618
|
+
function createRequestId2(prefix) {
|
|
592
619
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
593
620
|
}
|
|
594
621
|
var ALL_3D_TOOLBAR_OPERATORS = [
|
|
@@ -746,7 +773,7 @@ var ToolbarModule = class {
|
|
|
746
773
|
}
|
|
747
774
|
getSheets(options) {
|
|
748
775
|
var _a;
|
|
749
|
-
const requestId =
|
|
776
|
+
const requestId = createRequestId2("sheets");
|
|
750
777
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
751
778
|
return new Promise((resolve, reject) => {
|
|
752
779
|
const timer = setTimeout(() => {
|
|
@@ -764,7 +791,7 @@ var ToolbarModule = class {
|
|
|
764
791
|
}
|
|
765
792
|
getObjectProperties(options) {
|
|
766
793
|
var _a;
|
|
767
|
-
const requestId =
|
|
794
|
+
const requestId = createRequestId2("object_properties");
|
|
768
795
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
769
796
|
return new Promise((resolve, reject) => {
|
|
770
797
|
const timer = setTimeout(() => {
|
|
@@ -782,7 +809,7 @@ var ToolbarModule = class {
|
|
|
782
809
|
}
|
|
783
810
|
getLinkedObjects(options) {
|
|
784
811
|
var _a;
|
|
785
|
-
const requestId =
|
|
812
|
+
const requestId = createRequestId2("linked_objects");
|
|
786
813
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
787
814
|
return new Promise((resolve, reject) => {
|
|
788
815
|
const timer = setTimeout(() => {
|
|
@@ -800,7 +827,7 @@ var ToolbarModule = class {
|
|
|
800
827
|
}
|
|
801
828
|
getStatesObjects(options) {
|
|
802
829
|
var _a;
|
|
803
|
-
const requestId =
|
|
830
|
+
const requestId = createRequestId2("states_objects");
|
|
804
831
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
805
832
|
return new Promise((resolve, reject) => {
|
|
806
833
|
const timer = setTimeout(() => {
|
|
@@ -888,7 +915,7 @@ var ToolbarModule = class {
|
|
|
888
915
|
};
|
|
889
916
|
|
|
890
917
|
// src/modules/model-tree.module.ts
|
|
891
|
-
function
|
|
918
|
+
function createRequestId3(prefix) {
|
|
892
919
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
893
920
|
}
|
|
894
921
|
function buildTree(nodes, rootNodeIds) {
|
|
@@ -936,7 +963,7 @@ var ModelTreeModule = class {
|
|
|
936
963
|
});
|
|
937
964
|
}
|
|
938
965
|
getNodeIds(options) {
|
|
939
|
-
const requestId =
|
|
966
|
+
const requestId = createRequestId3("tree");
|
|
940
967
|
const timeoutMs = this.resolveTimeoutMs(options);
|
|
941
968
|
return new Promise((resolve, reject) => {
|
|
942
969
|
const timer = setTimeout(() => {
|
|
@@ -962,7 +989,7 @@ var ModelTreeModule = class {
|
|
|
962
989
|
return this.requestNodes(options).then((response) => buildTree(response.nodes, response.rootNodeIds));
|
|
963
990
|
}
|
|
964
991
|
requestNodes(options) {
|
|
965
|
-
const requestId =
|
|
992
|
+
const requestId = createRequestId3("tree_nodes");
|
|
966
993
|
const timeoutMs = this.resolveTimeoutMs(options);
|
|
967
994
|
return new Promise((resolve, reject) => {
|
|
968
995
|
const timer = setTimeout(() => {
|
|
@@ -1004,7 +1031,7 @@ var ModelTreeModule = class {
|
|
|
1004
1031
|
};
|
|
1005
1032
|
|
|
1006
1033
|
// src/modules/markup.module.ts
|
|
1007
|
-
function
|
|
1034
|
+
function createRequestId4(prefix) {
|
|
1008
1035
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1009
1036
|
}
|
|
1010
1037
|
var MarkupModule = class {
|
|
@@ -1058,7 +1085,7 @@ var MarkupModule = class {
|
|
|
1058
1085
|
}
|
|
1059
1086
|
getList(options) {
|
|
1060
1087
|
var _a;
|
|
1061
|
-
const requestId =
|
|
1088
|
+
const requestId = createRequestId4("markup-list");
|
|
1062
1089
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1063
1090
|
return new Promise((resolve, reject) => {
|
|
1064
1091
|
const timer = setTimeout(() => {
|
|
@@ -1076,7 +1103,7 @@ var MarkupModule = class {
|
|
|
1076
1103
|
}
|
|
1077
1104
|
runRequest(prefix, messageType, eventName, options) {
|
|
1078
1105
|
var _a;
|
|
1079
|
-
const requestId =
|
|
1106
|
+
const requestId = createRequestId4(prefix);
|
|
1080
1107
|
const timeoutMs = Math.max(1e3, (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : 1e4);
|
|
1081
1108
|
return new Promise((resolve, reject) => {
|
|
1082
1109
|
const timer = setTimeout(() => {
|
|
@@ -1132,6 +1159,17 @@ var Viewer3D = class {
|
|
|
1132
1159
|
case "viewer-home-click" /* HOME_CLICK */:
|
|
1133
1160
|
this._emit("camera:home", { timestamp: Date.now() });
|
|
1134
1161
|
break;
|
|
1162
|
+
case "viewer-camera-zoom" /* CAMERA_ZOOM */: {
|
|
1163
|
+
const payload = data.payload;
|
|
1164
|
+
if (!payload) break;
|
|
1165
|
+
this._emit("camera:zoom", {
|
|
1166
|
+
requestId: payload.requestId ? String(payload.requestId) : void 0,
|
|
1167
|
+
percent: Number(payload.percent) || 0,
|
|
1168
|
+
zoomFactor: Number(payload.zoomFactor) || 1,
|
|
1169
|
+
timestamp: Number(payload.timestamp) || Date.now()
|
|
1170
|
+
});
|
|
1171
|
+
break;
|
|
1172
|
+
}
|
|
1135
1173
|
case "viewer-node-select" /* NODE_SELECT */:
|
|
1136
1174
|
this._emit("node:select", { nodeId: String((_b = (_a = data.payload) == null ? void 0 : _a.nodeId) != null ? _b : ""), timestamp: Date.now() });
|
|
1137
1175
|
break;
|