fcr-core 3.7.8 → 3.8.0-alpha
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/lib/chat-connection/index.d.ts +1 -1
- package/lib/engine/index.js +6 -5
- package/lib/imports.d.ts +7 -2
- package/lib/imports.js +25 -4
- package/lib/index.d.ts +2 -2
- package/lib/index.js +12 -0
- package/lib/media-control/desktop.js +4 -4
- package/lib/media-control/mobile.js +20 -20
- package/lib/media-control/type.d.ts +8 -0
- package/lib/plugins/chatroom.js +19 -3
- package/lib/room-control/ability-control/type.d.ts +4 -1
- package/lib/room-control/ability-control/type.js +3 -0
- package/lib/room-control/helpers/constants.d.ts +4 -0
- package/lib/room-control/helpers/constants.js +5 -1
- package/lib/room-control/index.js +16 -5
- package/lib/room-control/interpreter-control/index.js +2 -4
- package/lib/room-control/mainroom-control/index.js +66 -1
- package/lib/room-control/privilege-control/index.js +43 -3
- package/lib/room-control/privilege-control/type.d.ts +57 -10
- package/lib/room-control/privilege-control/type.js +17 -0
- package/lib/room-control/room-control-factory.js +1 -1
- package/lib/room-control/room-session/index.js +23 -13
- package/lib/room-control/room-session/type.d.ts +2 -2
- package/lib/room-control/sharing-control/index.d.ts +5 -5
- package/lib/room-control/sharing-control/index.js +43 -13
- package/lib/room-control/sharing-control/type.d.ts +9 -5
- package/lib/room-control/sharing-control/type.js +6 -1
- package/lib/room-control/stream-control/index.d.ts +8 -1
- package/lib/room-control/stream-control/index.js +139 -36
- package/lib/room-control/stream-control/type.d.ts +6 -0
- package/lib/room-control/stt-control/de-compress-gzip.d.ts +1 -0
- package/lib/room-control/stt-control/de-compress-gzip.js +49 -0
- package/lib/room-control/stt-control/index.d.ts +1 -0
- package/lib/room-control/stt-control/index.js +353 -0
- package/lib/room-control/stt-control/type.d.ts +142 -0
- package/lib/room-control/stt-control/type.js +16 -0
- package/lib/room-control/type.d.ts +15 -0
- package/lib/room-control/type.js +13 -1
- package/lib/room-control/whiteboard-control/enum.d.ts +15 -0
- package/lib/room-control/whiteboard-control/{types.js → enum.js} +12 -1
- package/lib/room-control/whiteboard-control/type.d.ts +38 -0
- package/lib/room-control/whiteboard-control/type.js +15 -0
- package/lib/room-control/whiteboard-control/utils.d.ts +3 -0
- package/lib/room-control/whiteboard-control/utils.js +23 -0
- package/lib/room-control/whiteboard-control-v1/board-subwindow.d.ts +6 -0
- package/lib/room-control/whiteboard-control-v1/board-subwindow.js +26 -0
- package/lib/room-control/whiteboard-control-v1/board-window.d.ts +58 -0
- package/lib/room-control/whiteboard-control-v1/board-window.js +571 -0
- package/lib/room-control/{whiteboard-control/enums.d.ts → whiteboard-control-v1/enum.d.ts} +3 -17
- package/lib/room-control/{whiteboard-control/enums.js → whiteboard-control-v1/enum.js} +3 -20
- package/lib/room-control/whiteboard-control-v1/factory.d.ts +9 -0
- package/lib/room-control/whiteboard-control-v1/factory.js +22 -0
- package/lib/room-control/whiteboard-control-v1/index.d.ts +1 -0
- package/lib/room-control/whiteboard-control-v1/index.js +440 -0
- package/lib/room-control/whiteboard-control-v1/mount-manager.d.ts +4 -0
- package/lib/room-control/whiteboard-control-v1/mount-manager.js +15 -0
- package/lib/room-control/whiteboard-control-v1/type.d.ts +300 -0
- package/lib/room-control/whiteboard-control-v1/type.js +13 -0
- package/lib/room-control/whiteboard-control-v1/utils.d.ts +53 -0
- package/lib/room-control/whiteboard-control-v1/utils.js +290 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.d.ts +17 -31
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +39 -233
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.d.ts +10 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +48 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/type.d.ts +11 -19
- package/lib/room-control/whiteboard-control-v2/annotation-control/type.js +1 -3
- package/lib/room-control/whiteboard-control-v2/base/index.d.ts +42 -0
- package/lib/room-control/whiteboard-control-v2/base/index.js +317 -0
- package/lib/room-control/whiteboard-control-v2/{main-window.d.ts → base/main-window.d.ts} +6 -4
- package/lib/room-control/whiteboard-control-v2/{main-window.js → base/main-window.js} +31 -18
- package/lib/room-control/whiteboard-control-v2/constant.d.ts +6 -0
- package/lib/room-control/whiteboard-control-v2/constant.js +15 -0
- package/lib/room-control/whiteboard-control-v2/enum.d.ts +26 -0
- package/lib/room-control/whiteboard-control-v2/enum.js +34 -0
- package/lib/room-control/{whiteboard-control/types.d.ts → whiteboard-control-v2/type.d.ts} +51 -165
- package/lib/room-control/whiteboard-control-v2/type.js +5 -0
- package/lib/room-control/whiteboard-control-v2/utils.d.ts +5 -4
- package/lib/room-control/whiteboard-control-v2/utils.js +22 -21
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +34 -33
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +124 -191
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.d.ts +11 -0
- package/lib/room-control/whiteboard-control-v2/{annotation-control/index.js → whiteboard-control/factory.js} +35 -44
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.d.ts +18 -30
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.js +1 -9
- package/lib/room-router/index.js +4 -0
- package/lib/schema.d.ts +23 -9
- package/lib/schema.js +10 -4
- package/lib/service/api.d.ts +75 -19
- package/lib/service/api.js +193 -24
- package/lib/type.d.ts +15 -2
- package/lib/type.js +13 -0
- package/lib/utilities/error-helpers.d.ts +2 -1
- package/lib/utilities/error-helpers.js +1 -0
- package/lib/utilities/error.d.ts +1 -0
- package/lib/utilities/error.js +1 -0
- package/lib/utilities/logger.d.ts +2 -2
- package/lib/utilities/shared-storage.d.ts +3 -1
- package/lib/utilities/shared-storage.js +9 -1
- package/package.json +11 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/index.d.ts +0 -19
- package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.d.ts +0 -36
- package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +0 -262
- package/lib/room-control/whiteboard-control-v2/index.d.ts +0 -38
- package/lib/room-control/whiteboard-control-v2/index.js +0 -286
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.d.ts +0 -17
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +0 -32
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.d.ts +0 -36
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +0 -252
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { FcrBoardExtra, FcrColor } from '../whiteboard-control/type';
|
|
2
|
+
import { FcrConnectionState, FcrUserInfo, FcrWhiteboardParameters } from '../../type';
|
|
3
|
+
import { FcrBoardActiveInfo, FcrBoardPageInfo } from '../whiteboard-control/type';
|
|
4
|
+
import { FcrBoardToolType, FcrBoardShape } from './enum';
|
|
5
|
+
import { FcrCoreServiceApi } from '../../service/api';
|
|
6
|
+
import { FcrSharedCache } from '../shared-cache';
|
|
7
|
+
import { AgoraRteRenderView, AgoraRteScene } from 'agora-rte-sdk';
|
|
8
|
+
import { FcrImageData, FcrWhiteboardView } from '../../imports';
|
|
9
|
+
import { FcrBoardInactiveReason } from '../whiteboard-control/enum';
|
|
10
|
+
export declare const WHITEBOARD_APP_ID = "MainWhiteboard";
|
|
11
|
+
export type FcrBoardConfig = {
|
|
12
|
+
userId: string;
|
|
13
|
+
nickName: string;
|
|
14
|
+
boardConfig?: FcrBoardExtra;
|
|
15
|
+
};
|
|
16
|
+
export type FetchImageResult = {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
file: unknown;
|
|
20
|
+
uuid: string;
|
|
21
|
+
url: string;
|
|
22
|
+
};
|
|
23
|
+
export interface FcrWhiteboardControlFactory {
|
|
24
|
+
createForMainProcess(hasOperationPrivilege: boolean, scene: AgoraRteScene, api: FcrCoreServiceApi, sharedCache: FcrSharedCache): FcrWhiteboardControl;
|
|
25
|
+
}
|
|
26
|
+
export type BaseImageSize = {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
export type FcrBoardPage = {
|
|
31
|
+
name: string;
|
|
32
|
+
contentUrl: string;
|
|
33
|
+
previewUrl: string;
|
|
34
|
+
contentWidth: number;
|
|
35
|
+
contentHeight: number;
|
|
36
|
+
};
|
|
37
|
+
export type MountOptions = {
|
|
38
|
+
collectorContainer?: AgoraRteRenderView;
|
|
39
|
+
containerSizeRatio?: number;
|
|
40
|
+
};
|
|
41
|
+
export type BoardState = {
|
|
42
|
+
strokeColor: FcrColor;
|
|
43
|
+
strokeWidth: number;
|
|
44
|
+
textSize: number;
|
|
45
|
+
tool: FcrBoardToolType;
|
|
46
|
+
shape: FcrBoardShape;
|
|
47
|
+
};
|
|
48
|
+
export interface FcrWhiteboardControl {
|
|
49
|
+
/**
|
|
50
|
+
* Indicates whether the user has the permission to draw on the whiteboard.
|
|
51
|
+
*/
|
|
52
|
+
hasOperationPrivilege(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Sets whether the user has the permission to draw on the whiteboard.
|
|
55
|
+
* @param hasPrivilege
|
|
56
|
+
*/
|
|
57
|
+
setOperationPrivilege(hasPrivilege: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* Opens the whiteboard and creates a main window.
|
|
60
|
+
*/
|
|
61
|
+
open(params?: FcrWhiteboardParameters): Promise<FcrBoardMainWindow_V1>;
|
|
62
|
+
/**
|
|
63
|
+
* Closes the whiteboard and releases the main window.
|
|
64
|
+
*/
|
|
65
|
+
close(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Activates the whiteboard.
|
|
68
|
+
*/
|
|
69
|
+
active(): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Inactivates the whiteboard.
|
|
72
|
+
*/
|
|
73
|
+
inactive(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the connection state of the whiteboard.
|
|
76
|
+
*/
|
|
77
|
+
getConnectionState(): FcrConnectionState;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the main window of the whiteboard.
|
|
80
|
+
*/
|
|
81
|
+
getMainWindow(): FcrBoardMainWindow_V1 | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Gets the active info of the whiteboard.
|
|
84
|
+
*/
|
|
85
|
+
getBoardActiveInfo(): FcrBoardActiveInfo;
|
|
86
|
+
/**
|
|
87
|
+
* Sets the background color of the whiteboard.
|
|
88
|
+
* @param color
|
|
89
|
+
*/
|
|
90
|
+
setBackgroundColor(color: string): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the background color of the whiteboard.
|
|
93
|
+
*/
|
|
94
|
+
getBackgroundColor(): string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Gets the whiteboard activity info.
|
|
97
|
+
*/
|
|
98
|
+
getActivity(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Gets the whiteboard owner ID.
|
|
101
|
+
*/
|
|
102
|
+
getOwnerId(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Adds an observer to the whiteboard.
|
|
105
|
+
* @param observer
|
|
106
|
+
*/
|
|
107
|
+
addObserver(observer: FcrWhiteboardObserver): void;
|
|
108
|
+
/**
|
|
109
|
+
* Removes the observer from the whiteboard.
|
|
110
|
+
* @param observer
|
|
111
|
+
*/
|
|
112
|
+
removeObserver(observer: FcrWhiteboardObserver): void;
|
|
113
|
+
}
|
|
114
|
+
export interface FcrBoardSubWindow {
|
|
115
|
+
exportPdf(): Promise<ArrayBuffer>;
|
|
116
|
+
}
|
|
117
|
+
export declare enum FcrBoardEraserSize {
|
|
118
|
+
SMALL = 1,
|
|
119
|
+
MEDIUM = 2,
|
|
120
|
+
LARGE = 3
|
|
121
|
+
}
|
|
122
|
+
export interface FcrBoardMainWindow_V1 {
|
|
123
|
+
/**
|
|
124
|
+
* Adds a page.
|
|
125
|
+
*/
|
|
126
|
+
addPage(): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Removes a page.
|
|
129
|
+
*/
|
|
130
|
+
removePage(): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Undoes the operation.
|
|
133
|
+
*/
|
|
134
|
+
undo(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Redoes the operation.
|
|
137
|
+
*/
|
|
138
|
+
redo(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Cleans the whiteboard.
|
|
141
|
+
*/
|
|
142
|
+
clean(): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Gets the snapshot image of the whiteboard.
|
|
145
|
+
*/
|
|
146
|
+
getSnapshotImage(): Promise<FcrImageData>;
|
|
147
|
+
/**
|
|
148
|
+
* Sets the background color of the whiteboard.
|
|
149
|
+
* @param color
|
|
150
|
+
*/
|
|
151
|
+
setBackgroundColor(color: string): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Gets page info.
|
|
154
|
+
*/
|
|
155
|
+
getPageInfo(): FcrBoardPageInfo;
|
|
156
|
+
/**
|
|
157
|
+
* Navigates to the previous page.
|
|
158
|
+
*/
|
|
159
|
+
prevPage(): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Navigate to the next page.
|
|
162
|
+
*/
|
|
163
|
+
nextPage(): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Sets the tool type.
|
|
166
|
+
* @param type
|
|
167
|
+
*/
|
|
168
|
+
setToolType(type: FcrBoardToolType): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Sets the stroke width.
|
|
171
|
+
* @param strokeWidth
|
|
172
|
+
*/
|
|
173
|
+
setStrokeWidth(strokeWidth: number): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Sets the stroke color.
|
|
176
|
+
* @param color
|
|
177
|
+
*/
|
|
178
|
+
setStrokeColor(color: FcrColor): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Sets the text color.
|
|
181
|
+
* @param color
|
|
182
|
+
*/
|
|
183
|
+
setTextColor(color: FcrColor): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Sets the text size.
|
|
186
|
+
* @param textSize
|
|
187
|
+
*/
|
|
188
|
+
setTextSize(textSize: number): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* Sets the fill color.
|
|
191
|
+
* @param color
|
|
192
|
+
*/
|
|
193
|
+
setFillColor(color: FcrColor): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Set eraser size.
|
|
196
|
+
* @param size small: 1, medium: 2, large: 3
|
|
197
|
+
*/
|
|
198
|
+
setEraserSize(size: FcrBoardEraserSize): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Inserts an image.
|
|
201
|
+
* @param resourceUrl
|
|
202
|
+
* @param x
|
|
203
|
+
* @param y
|
|
204
|
+
* @param width
|
|
205
|
+
* @param height
|
|
206
|
+
*/
|
|
207
|
+
insertImage(resourceUrl: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Inserts a media.
|
|
210
|
+
* @param resourceUrl
|
|
211
|
+
* @param title
|
|
212
|
+
*/
|
|
213
|
+
insertMedia(resourceUrl: string, title?: string): Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* Gets the content view.
|
|
216
|
+
*/
|
|
217
|
+
getContentView(): FcrWhiteboardView;
|
|
218
|
+
/**
|
|
219
|
+
* Sets the container size ratio.
|
|
220
|
+
* @param ratio
|
|
221
|
+
*/
|
|
222
|
+
setContainerSizeRatio(ratio: number): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* open the sub window with task id.
|
|
225
|
+
* @param title
|
|
226
|
+
* @param taskId
|
|
227
|
+
* @param urlPrefix
|
|
228
|
+
*/
|
|
229
|
+
openSubWindowWithTaskId(title: string, taskId: string, urlPrefix?: string): Promise<FcrBoardSubWindow | undefined>;
|
|
230
|
+
/**
|
|
231
|
+
* open the sub window with page list.
|
|
232
|
+
* @param title
|
|
233
|
+
* @param pageList
|
|
234
|
+
*/
|
|
235
|
+
openSubWindowWithPageList(title: string, pageList: FcrBoardPage[]): Promise<FcrBoardSubWindow | undefined>;
|
|
236
|
+
/**
|
|
237
|
+
* set scale.
|
|
238
|
+
* @param scale
|
|
239
|
+
*/
|
|
240
|
+
setScale(scale: number): void;
|
|
241
|
+
/**
|
|
242
|
+
* get whether the user has the permission to draw on the whiteboard.
|
|
243
|
+
*/
|
|
244
|
+
getWritable(): boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Adds an observer to the main window.
|
|
247
|
+
* @param observer
|
|
248
|
+
*/
|
|
249
|
+
addObserver(observer: FcrBoardWindowObserver): void;
|
|
250
|
+
/**
|
|
251
|
+
* Removes the observer from the main window.
|
|
252
|
+
* @param observer
|
|
253
|
+
*/
|
|
254
|
+
removeObserver(observer: FcrBoardWindowObserver): void;
|
|
255
|
+
}
|
|
256
|
+
export type FcrBoardWindowObserver = {
|
|
257
|
+
/**
|
|
258
|
+
* Callback to receive the page info change.
|
|
259
|
+
* @param info
|
|
260
|
+
*/
|
|
261
|
+
onPageInfoUpdated?(info: FcrBoardPageInfo): void;
|
|
262
|
+
/**
|
|
263
|
+
* Callback to receive the undo state change.
|
|
264
|
+
* @param enable
|
|
265
|
+
*/
|
|
266
|
+
onUndoStateUpdated?(enable: boolean): void;
|
|
267
|
+
/**
|
|
268
|
+
* Callback to receive the redo state change.
|
|
269
|
+
* @param enable
|
|
270
|
+
*/
|
|
271
|
+
onRedoStateUpdated?(enable: boolean): void;
|
|
272
|
+
/**
|
|
273
|
+
* Callback to receive the writable state change.
|
|
274
|
+
* @param isWritable
|
|
275
|
+
*/
|
|
276
|
+
onWritable?(isWritable: boolean): void;
|
|
277
|
+
};
|
|
278
|
+
export type FcrWhiteboardObserver = {
|
|
279
|
+
/**
|
|
280
|
+
* Callback to receive the connection state change.
|
|
281
|
+
* @param state
|
|
282
|
+
*/
|
|
283
|
+
onConnectionStateUpdated?(state: FcrConnectionState): void;
|
|
284
|
+
/**
|
|
285
|
+
* Callback to receive the background color of the whiteboard change.
|
|
286
|
+
* @param info
|
|
287
|
+
*/
|
|
288
|
+
onBackgroundColorUpdated?(color: string, operatorUser?: FcrUserInfo): void;
|
|
289
|
+
/**
|
|
290
|
+
* Callback to receive the whiteboard active event.
|
|
291
|
+
* @param info
|
|
292
|
+
*/
|
|
293
|
+
onActive?(ownerId: string, operatorUser: FcrUserInfo): void;
|
|
294
|
+
/**
|
|
295
|
+
* Callback to receive the whiteboard inactive event.
|
|
296
|
+
* @param reason
|
|
297
|
+
* @param operatorUser
|
|
298
|
+
*/
|
|
299
|
+
onInactive?(reason: FcrBoardInactiveReason, operatorUser?: FcrUserInfo): void;
|
|
300
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WHITEBOARD_APP_ID = exports.FcrBoardEraserSize = void 0;
|
|
7
|
+
const WHITEBOARD_APP_ID = exports.WHITEBOARD_APP_ID = 'MainWhiteboard';
|
|
8
|
+
let FcrBoardEraserSize = exports.FcrBoardEraserSize = /*#__PURE__*/function (FcrBoardEraserSize) {
|
|
9
|
+
FcrBoardEraserSize[FcrBoardEraserSize["SMALL"] = 1] = "SMALL";
|
|
10
|
+
FcrBoardEraserSize[FcrBoardEraserSize["MEDIUM"] = 2] = "MEDIUM";
|
|
11
|
+
FcrBoardEraserSize[FcrBoardEraserSize["LARGE"] = 3] = "LARGE";
|
|
12
|
+
return FcrBoardEraserSize;
|
|
13
|
+
}({});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ApplianceNames, FcrBoardShape, FcrBoardToolType, ShapeType } from './enum';
|
|
2
|
+
import { EStrokeType } from '@netless/appliance-plugin';
|
|
3
|
+
import { BaseImageSize, FetchImageResult } from './type';
|
|
4
|
+
export declare const heightPerTool = 36;
|
|
5
|
+
export declare const heightPerColor = 18;
|
|
6
|
+
export declare const defaultToolsRetain: number;
|
|
7
|
+
export declare const verticalPadding = 10;
|
|
8
|
+
export declare const sceneNavHeight: number;
|
|
9
|
+
export declare const widgetContainerClassName = "netless-whiteboard-wrapper";
|
|
10
|
+
export declare const layoutContentClassName = "fcr-layout-content-main-view";
|
|
11
|
+
export declare const videoRowClassName = "fcr-layout-content-video-list-row";
|
|
12
|
+
export declare const toolbarClassName = "fcr-board-toolbar";
|
|
13
|
+
export declare const windowClassName = "netless-whiteboard-wrapper";
|
|
14
|
+
export declare const WINDOW_TITLE_HEIGHT = 28;
|
|
15
|
+
export declare const WINDOW_ASPECT_RATIO: number;
|
|
16
|
+
export declare const WINDOW_MIN_SIZE: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const WINDOW_REMAIN_SIZE: {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const WINDOW_REMAIN_POSITION: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* 根据
|
|
30
|
+
* @param imageInnerSize
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare const getImageSize: (imageInnerSize: BaseImageSize, containerSize: BaseImageSize) => BaseImageSize;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param url
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
export declare const fetchImageInfoByUrl: (url: string, containerSize: BaseImageSize) => Promise<FetchImageResult>;
|
|
40
|
+
export declare const mergeCanvasImage: (scenes: (() => Promise<HTMLCanvasElement | null>)[]) => Promise<HTMLCanvasElement>;
|
|
41
|
+
export declare const textColors: string[];
|
|
42
|
+
export declare const defaultStrokeColor: {
|
|
43
|
+
r: number;
|
|
44
|
+
g: number;
|
|
45
|
+
b: number;
|
|
46
|
+
};
|
|
47
|
+
export declare const defaultTextSize = 24;
|
|
48
|
+
export declare const mediaMimeTypes: Record<string, string>;
|
|
49
|
+
export declare const convertToNetlessBoardTool: (tool: FcrBoardToolType) => never[] | readonly [ApplianceNames.selector] | readonly [ApplianceNames.pencilEraser] | readonly [ApplianceNames.laserPointer] | readonly [ApplianceNames.hand] | readonly [ApplianceNames.text] | readonly [ApplianceNames.arrow] | readonly [ApplianceNames.rectangle] | readonly [ApplianceNames.ellipse] | readonly [ApplianceNames.straight] | readonly [ApplianceNames.pencil] | readonly [ApplianceNames.shape, ShapeType.Triangle] | readonly [ApplianceNames.shape, ShapeType.Pentagram] | readonly [ApplianceNames.shape, ShapeType.Rhombus] | readonly [ApplianceNames.clicker];
|
|
50
|
+
export declare const convertToNetlessStorkeType: (type: FcrBoardToolType) => EStrokeType.Normal | EStrokeType.Dotted | EStrokeType.LongDotted;
|
|
51
|
+
export declare const convertToFcrBoardToolShape: (tool?: ApplianceNames, shape?: ShapeType) => FcrBoardToolType[] | (FcrBoardShape | undefined)[];
|
|
52
|
+
export declare const hexColorToWhiteboardColor: (val: string) => number[];
|
|
53
|
+
export declare const src2DataURL: (src: string) => Promise<string>;
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.windowClassName = exports.widgetContainerClassName = exports.videoRowClassName = exports.verticalPadding = exports.toolbarClassName = exports.textColors = exports.src2DataURL = exports.sceneNavHeight = exports.mergeCanvasImage = exports.mediaMimeTypes = exports.layoutContentClassName = exports.hexColorToWhiteboardColor = exports.heightPerTool = exports.heightPerColor = exports.getImageSize = exports.fetchImageInfoByUrl = exports.defaultToolsRetain = exports.defaultTextSize = exports.defaultStrokeColor = exports.convertToNetlessStorkeType = exports.convertToNetlessBoardTool = exports.convertToFcrBoardToolShape = exports.WINDOW_TITLE_HEIGHT = exports.WINDOW_REMAIN_SIZE = exports.WINDOW_REMAIN_POSITION = exports.WINDOW_MIN_SIZE = exports.WINDOW_ASPECT_RATIO = void 0;
|
|
7
|
+
require("core-js/modules/es.array.push.js");
|
|
8
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
9
|
+
require("core-js/modules/es.string.replace.js");
|
|
10
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
|
+
var _jsMd = require("js-md5");
|
|
12
|
+
var _enum = require("./enum");
|
|
13
|
+
var _appliancePlugin = require("@netless/appliance-plugin");
|
|
14
|
+
const heightPerTool = exports.heightPerTool = 36;
|
|
15
|
+
const heightPerColor = exports.heightPerColor = 18;
|
|
16
|
+
const defaultToolsRetain = exports.defaultToolsRetain = heightPerTool * 6;
|
|
17
|
+
const verticalPadding = exports.verticalPadding = 10;
|
|
18
|
+
const sceneNavHeight = exports.sceneNavHeight = heightPerTool + verticalPadding;
|
|
19
|
+
const widgetContainerClassName = exports.widgetContainerClassName = 'netless-whiteboard-wrapper';
|
|
20
|
+
const layoutContentClassName = exports.layoutContentClassName = 'fcr-layout-content-main-view';
|
|
21
|
+
const videoRowClassName = exports.videoRowClassName = 'fcr-layout-content-video-list-row';
|
|
22
|
+
const toolbarClassName = exports.toolbarClassName = 'fcr-board-toolbar';
|
|
23
|
+
const windowClassName = exports.windowClassName = 'netless-whiteboard-wrapper';
|
|
24
|
+
const WINDOW_TITLE_HEIGHT = exports.WINDOW_TITLE_HEIGHT = 28;
|
|
25
|
+
// width / height
|
|
26
|
+
const WINDOW_ASPECT_RATIO = exports.WINDOW_ASPECT_RATIO = 1836 / 847;
|
|
27
|
+
const WINDOW_MIN_SIZE = exports.WINDOW_MIN_SIZE = {
|
|
28
|
+
width: 653,
|
|
29
|
+
height: 336
|
|
30
|
+
};
|
|
31
|
+
const WINDOW_REMAIN_SIZE = exports.WINDOW_REMAIN_SIZE = {
|
|
32
|
+
width: 783,
|
|
33
|
+
height: 388
|
|
34
|
+
};
|
|
35
|
+
const WINDOW_REMAIN_POSITION = exports.WINDOW_REMAIN_POSITION = {
|
|
36
|
+
x: 0,
|
|
37
|
+
y: 171
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 根据
|
|
42
|
+
* @param imageInnerSize
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
const getImageSize = (imageInnerSize, containerSize) => {
|
|
46
|
+
const windowSize = containerSize;
|
|
47
|
+
const widthHeightProportion = imageInnerSize.width / imageInnerSize.height;
|
|
48
|
+
const maxSize = 960;
|
|
49
|
+
if (imageInnerSize.width > maxSize && windowSize.width > maxSize || imageInnerSize.height > maxSize && windowSize.height > maxSize) {
|
|
50
|
+
if (widthHeightProportion > 1) {
|
|
51
|
+
return {
|
|
52
|
+
width: maxSize,
|
|
53
|
+
height: maxSize / widthHeightProportion
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
return {
|
|
57
|
+
width: maxSize * widthHeightProportion,
|
|
58
|
+
height: maxSize
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
if (imageInnerSize.width > windowSize.width || imageInnerSize.height > windowSize.height) {
|
|
63
|
+
if (widthHeightProportion > 1) {
|
|
64
|
+
return {
|
|
65
|
+
width: windowSize.width,
|
|
66
|
+
height: windowSize.width / widthHeightProportion
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
return {
|
|
70
|
+
width: windowSize.height * widthHeightProportion,
|
|
71
|
+
height: windowSize.height
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
return {
|
|
76
|
+
width: imageInnerSize.width,
|
|
77
|
+
height: imageInnerSize.height
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @param url
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
exports.getImageSize = getImageSize;
|
|
89
|
+
const fetchImageInfoByUrl = async (url, containerSize) => {
|
|
90
|
+
try {
|
|
91
|
+
const res = await fetch(url);
|
|
92
|
+
const blob = await res.blob();
|
|
93
|
+
const contentType = blob.type;
|
|
94
|
+
const image = new Image();
|
|
95
|
+
const reader = new FileReader();
|
|
96
|
+
const file = new File([blob], url, {
|
|
97
|
+
type: contentType
|
|
98
|
+
});
|
|
99
|
+
const result = await new Promise(resolve => {
|
|
100
|
+
reader.readAsDataURL(blob);
|
|
101
|
+
reader.onload = () => {
|
|
102
|
+
image.addEventListener('load', () => {
|
|
103
|
+
const uuid = (0, _jsMd.md5)(reader.result);
|
|
104
|
+
const res = getImageSize(image, containerSize);
|
|
105
|
+
const result = {
|
|
106
|
+
width: res.width,
|
|
107
|
+
height: res.height,
|
|
108
|
+
file: file,
|
|
109
|
+
url,
|
|
110
|
+
uuid
|
|
111
|
+
};
|
|
112
|
+
resolve(result);
|
|
113
|
+
}, false);
|
|
114
|
+
image.src = reader.result;
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
return result;
|
|
118
|
+
} catch (err) {
|
|
119
|
+
throw err;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
exports.fetchImageInfoByUrl = fetchImageInfoByUrl;
|
|
123
|
+
const mergeCanvasImage = async scenes => {
|
|
124
|
+
let width = 0,
|
|
125
|
+
height = 0;
|
|
126
|
+
const bigCanvas = document.createElement('canvas');
|
|
127
|
+
const ctx = bigCanvas.getContext('2d');
|
|
128
|
+
const canvasArray = [];
|
|
129
|
+
for (const canvasPromise of scenes) {
|
|
130
|
+
const canvas = await canvasPromise();
|
|
131
|
+
if (canvas) {
|
|
132
|
+
width = Math.max(canvas.width, width);
|
|
133
|
+
height = Math.max(canvas.height, height);
|
|
134
|
+
canvasArray.push(canvas);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
bigCanvas.setAttribute('width', "".concat(width));
|
|
138
|
+
bigCanvas.setAttribute('height', "".concat(height * canvasArray.length));
|
|
139
|
+
canvasArray.forEach((canvas, index) => {
|
|
140
|
+
ctx && ctx.drawImage(canvas, 0, index * height, width, height);
|
|
141
|
+
});
|
|
142
|
+
return bigCanvas;
|
|
143
|
+
};
|
|
144
|
+
exports.mergeCanvasImage = mergeCanvasImage;
|
|
145
|
+
const textColors = exports.textColors = ['#ffffff', '#9b9b9b', '#4a4a4a', '#000000', '#d0021b', '#f5a623', '#f8e71c', '#7ed321', '#9013fe', '#50e3c2', '#0073ff', '#ffc8e2'];
|
|
146
|
+
const defaultStrokeColor = exports.defaultStrokeColor = {
|
|
147
|
+
r: 0,
|
|
148
|
+
g: 115,
|
|
149
|
+
b: 255
|
|
150
|
+
};
|
|
151
|
+
const defaultTextSize = exports.defaultTextSize = 24;
|
|
152
|
+
const mediaMimeTypes = exports.mediaMimeTypes = {
|
|
153
|
+
opus: 'video/ogg',
|
|
154
|
+
ogv: 'video/ogg',
|
|
155
|
+
mp4: 'video/mp4',
|
|
156
|
+
mov: 'video/mp4',
|
|
157
|
+
m4v: 'video/mp4',
|
|
158
|
+
mkv: 'video/x-matroska',
|
|
159
|
+
m4a: 'audio/mp4',
|
|
160
|
+
mp3: 'audio/mpeg',
|
|
161
|
+
aac: 'audio/aac',
|
|
162
|
+
caf: 'audio/x-caf',
|
|
163
|
+
flac: 'audio/flac',
|
|
164
|
+
oga: 'audio/ogg',
|
|
165
|
+
wav: 'audio/wav',
|
|
166
|
+
m3u8: 'application/x-mpegURL',
|
|
167
|
+
jpg: 'image/jpeg',
|
|
168
|
+
jpeg: 'image/jpeg',
|
|
169
|
+
gif: 'image/gif',
|
|
170
|
+
png: 'image/png',
|
|
171
|
+
svg: 'image/svg+xml',
|
|
172
|
+
webp: 'image/webp'
|
|
173
|
+
};
|
|
174
|
+
const convertToNetlessBoardTool = tool => {
|
|
175
|
+
switch (tool) {
|
|
176
|
+
case _enum.FcrBoardToolType.SELECTOR:
|
|
177
|
+
return [_enum.ApplianceNames.selector];
|
|
178
|
+
case _enum.FcrBoardToolType.ERASER:
|
|
179
|
+
return [_enum.ApplianceNames.pencilEraser];
|
|
180
|
+
case _enum.FcrBoardToolType.LASER_POINTER:
|
|
181
|
+
return [_enum.ApplianceNames.laserPointer];
|
|
182
|
+
case _enum.FcrBoardToolType.HAND:
|
|
183
|
+
return [_enum.ApplianceNames.hand];
|
|
184
|
+
case _enum.FcrBoardToolType.TEXT:
|
|
185
|
+
return [_enum.ApplianceNames.text];
|
|
186
|
+
case _enum.FcrBoardToolType.ARROW:
|
|
187
|
+
return [_enum.ApplianceNames.arrow];
|
|
188
|
+
case _enum.FcrBoardToolType.RECTANGLE:
|
|
189
|
+
return [_enum.ApplianceNames.rectangle];
|
|
190
|
+
case _enum.FcrBoardToolType.ELLIPSE:
|
|
191
|
+
return [_enum.ApplianceNames.ellipse];
|
|
192
|
+
case _enum.FcrBoardToolType.STRAIGHT:
|
|
193
|
+
return [_enum.ApplianceNames.straight];
|
|
194
|
+
case _enum.FcrBoardToolType.CURVE:
|
|
195
|
+
return [_enum.ApplianceNames.pencil];
|
|
196
|
+
case _enum.FcrBoardToolType.TRIANGLE:
|
|
197
|
+
return [_enum.ApplianceNames.shape, _enum.ShapeType.Triangle];
|
|
198
|
+
case _enum.FcrBoardToolType.PENTAGRAM:
|
|
199
|
+
return [_enum.ApplianceNames.shape, _enum.ShapeType.Pentagram];
|
|
200
|
+
case _enum.FcrBoardToolType.RHOMBUS:
|
|
201
|
+
return [_enum.ApplianceNames.shape, _enum.ShapeType.Rhombus];
|
|
202
|
+
case _enum.FcrBoardToolType.DOTTED_LINE:
|
|
203
|
+
case _enum.FcrBoardToolType.LONG_DOTTED_LINE:
|
|
204
|
+
return [_enum.ApplianceNames.straight];
|
|
205
|
+
case _enum.FcrBoardToolType.NONE:
|
|
206
|
+
return [_enum.ApplianceNames.clicker];
|
|
207
|
+
default:
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
exports.convertToNetlessBoardTool = convertToNetlessBoardTool;
|
|
212
|
+
const convertToNetlessStorkeType = type => {
|
|
213
|
+
switch (type) {
|
|
214
|
+
case _enum.FcrBoardToolType.DOTTED_LINE:
|
|
215
|
+
return _appliancePlugin.EStrokeType.Dotted;
|
|
216
|
+
case _enum.FcrBoardToolType.LONG_DOTTED_LINE:
|
|
217
|
+
return _appliancePlugin.EStrokeType.LongDotted;
|
|
218
|
+
default:
|
|
219
|
+
return _appliancePlugin.EStrokeType.Normal;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
exports.convertToNetlessStorkeType = convertToNetlessStorkeType;
|
|
223
|
+
const convertToFcrBoardToolShape = (tool, shape) => {
|
|
224
|
+
switch (tool) {
|
|
225
|
+
case _enum.ApplianceNames.selector:
|
|
226
|
+
return [_enum.FcrBoardToolType.SELECTOR];
|
|
227
|
+
case _enum.ApplianceNames.eraser:
|
|
228
|
+
return [_enum.FcrBoardToolType.ERASER];
|
|
229
|
+
case _enum.ApplianceNames.laserPointer:
|
|
230
|
+
return [_enum.FcrBoardToolType.LASER_POINTER];
|
|
231
|
+
case _enum.ApplianceNames.text:
|
|
232
|
+
return [_enum.FcrBoardToolType.TEXT];
|
|
233
|
+
case _enum.ApplianceNames.hand:
|
|
234
|
+
return [_enum.FcrBoardToolType.HAND];
|
|
235
|
+
}
|
|
236
|
+
switch ("".concat(tool || '').concat(shape || '')) {
|
|
237
|
+
case "".concat(_enum.ApplianceNames.rectangle):
|
|
238
|
+
return [, _enum.FcrBoardShape.Rectangle];
|
|
239
|
+
case "".concat(_enum.ApplianceNames.ellipse):
|
|
240
|
+
return [, _enum.FcrBoardShape.Ellipse];
|
|
241
|
+
case "".concat(_enum.ApplianceNames.straight):
|
|
242
|
+
return [, _enum.FcrBoardShape.Straight];
|
|
243
|
+
case "".concat(_enum.ApplianceNames.arrow):
|
|
244
|
+
return [, _enum.FcrBoardShape.Arrow];
|
|
245
|
+
case "".concat(_enum.ApplianceNames.pencil):
|
|
246
|
+
return [, _enum.FcrBoardShape.Curve];
|
|
247
|
+
case "".concat(_enum.ApplianceNames.shape).concat(_enum.ShapeType.Triangle):
|
|
248
|
+
return [, _enum.FcrBoardShape.Triangle];
|
|
249
|
+
case "".concat((_enum.ApplianceNames.shape, _enum.ShapeType.Pentagram)):
|
|
250
|
+
return [, _enum.FcrBoardShape.Pentagram];
|
|
251
|
+
case "".concat(_enum.ApplianceNames.shape).concat(_enum.ShapeType.Rhombus):
|
|
252
|
+
return [, _enum.FcrBoardShape.Rhombus];
|
|
253
|
+
}
|
|
254
|
+
return [];
|
|
255
|
+
};
|
|
256
|
+
exports.convertToFcrBoardToolShape = convertToFcrBoardToolShape;
|
|
257
|
+
const hexColorToWhiteboardColor = val => {
|
|
258
|
+
const pattern = /^(#?)[a-fA-F0-9]{6}$/; // 16进制颜色校验规则
|
|
259
|
+
if (!pattern.test(val)) {
|
|
260
|
+
return [255, 255, 255];
|
|
261
|
+
}
|
|
262
|
+
const v = val.replace(/#/, '');
|
|
263
|
+
const rgbArr = [];
|
|
264
|
+
for (let i = 0; i < 3; i++) {
|
|
265
|
+
const item = v.substring(i * 2, i * 2 + 2);
|
|
266
|
+
const num = parseInt(item, 16);
|
|
267
|
+
rgbArr.push(num);
|
|
268
|
+
}
|
|
269
|
+
return rgbArr;
|
|
270
|
+
};
|
|
271
|
+
exports.hexColorToWhiteboardColor = hexColorToWhiteboardColor;
|
|
272
|
+
const src2DataURL = src => {
|
|
273
|
+
return new Promise((resolve, reject) => {
|
|
274
|
+
const canvas = document.createElement('canvas');
|
|
275
|
+
const ctx = canvas.getContext('2d');
|
|
276
|
+
const image = new Image();
|
|
277
|
+
image.onload = () => {
|
|
278
|
+
canvas.setAttribute('width', "".concat(image.width));
|
|
279
|
+
canvas.setAttribute('height', "".concat(image.height));
|
|
280
|
+
ctx === null || ctx === void 0 || ctx.drawImage(image, 0, 0);
|
|
281
|
+
resolve(canvas.toDataURL('image/jpeg', 0.8));
|
|
282
|
+
};
|
|
283
|
+
image.onerror = () => {
|
|
284
|
+
reject('error');
|
|
285
|
+
};
|
|
286
|
+
image.crossOrigin = 'anonymous';
|
|
287
|
+
image.src = src;
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
exports.src2DataURL = src2DataURL;
|