fcr-core 3.8.1 → 3.9.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-connector/type.d.ts +40 -0
- package/lib/{chat-connection → chat-connector}/type.js +1 -1
- package/lib/engine/index.d.ts +10 -11
- package/lib/engine/index.js +63 -72
- package/lib/engine/type.d.ts +96 -0
- package/lib/engine/type.js +5 -0
- package/lib/imports.d.ts +7 -4
- package/lib/imports.js +30 -4
- package/lib/index.d.ts +3 -2
- package/lib/index.js +21 -2
- package/lib/media-control/desktop.js +12 -12
- package/lib/media-control/mobile.js +4 -0
- package/lib/media-control/type.d.ts +32 -33
- package/lib/monitor-control/index.js +3 -3
- package/lib/peer-session/index.js +14 -14
- package/lib/peer-session/type.d.ts +1 -1
- package/lib/plugins/chat/chatroom.js +417 -0
- package/lib/{chat-connection → plugins/chat}/config.d.ts +1 -0
- package/lib/{room-control/chatroom-control → plugins/chat}/config.js +2 -1
- package/lib/plugins/chat/connector.d.ts +38 -0
- package/lib/{chat-connection/index.js → plugins/chat/connector.js} +181 -61
- package/lib/room-control/ability-control/index.js +5 -4
- package/lib/room-control/ability-control/type.d.ts +5 -1
- package/lib/room-control/ability-control/type.js +4 -0
- package/lib/room-control/chatroom-control/type.d.ts +44 -35
- package/lib/room-control/group-control/index.js +9 -9
- package/lib/room-control/index.js +37 -22
- package/lib/room-control/interpreter-control/index.js +7 -4
- package/lib/room-control/interpreter-control/room.js +3 -3
- package/lib/room-control/interpreter-control/types.d.ts +2 -2
- package/lib/room-control/join-before-host-waitingroom-control/index.js +3 -3
- package/lib/room-control/mainroom-control/index.js +15 -13
- package/lib/room-control/privilege-control/index.js +39 -24
- package/lib/room-control/privilege-control/type.d.ts +15 -15
- package/lib/room-control/room-connector-control/index.js +7 -5
- package/lib/room-control/room-connector-control/type.d.ts +1 -1
- package/lib/room-control/room-control-factory.d.ts +3 -3
- package/lib/room-control/room-control-factory.js +7 -7
- package/lib/room-control/room-session/index.js +17 -15
- package/lib/room-control/room-session/type.d.ts +3 -3
- package/lib/room-control/sharing-control/index.js +13 -7
- package/lib/room-control/stream-control/index.js +18 -16
- package/lib/room-control/stream-control/type.d.ts +5 -5
- package/lib/room-control/stt-control/index.js +38 -31
- package/lib/room-control/type.d.ts +19 -19
- package/lib/room-control/user-control/index.js +20 -22
- package/lib/room-control/user-control/type.d.ts +1 -1
- package/lib/room-control/waitingroom-control/index.js +11 -11
- package/lib/room-control/whiteboard-control-v1/board-window.d.ts +21 -20
- package/lib/room-control/whiteboard-control-v1/board-window.js +27 -8
- package/lib/room-control/whiteboard-control-v1/factory.js +1 -1
- package/lib/room-control/whiteboard-control-v1/index.js +26 -18
- package/lib/room-control/whiteboard-control-v1/type.d.ts +26 -25
- package/lib/room-control/whiteboard-control-v1/type.js +1 -0
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.d.ts +15 -6
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +39 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.d.ts +4 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +6 -5
- package/lib/room-control/whiteboard-control-v2/annotation-control/type.d.ts +7 -1
- package/lib/room-control/whiteboard-control-v2/base/index.d.ts +9 -8
- package/lib/room-control/whiteboard-control-v2/base/index.js +84 -42
- package/lib/room-control/whiteboard-control-v2/base/main-window.d.ts +16 -15
- package/lib/room-control/whiteboard-control-v2/base/main-window.js +23 -4
- package/lib/room-control/whiteboard-control-v2/type.d.ts +17 -17
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +12 -6
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +64 -18
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.d.ts +2 -2
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +10 -10
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.d.ts +1 -1
- package/lib/room-router/index.js +10 -7
- package/lib/room-router/type.d.ts +1 -1
- package/lib/schema.d.ts +24 -46
- package/lib/schema.js +1 -2
- package/lib/service/api.d.ts +5 -3
- package/lib/service/api.js +17 -12
- package/lib/type.d.ts +64 -45
- package/lib/type.js +76 -11
- package/lib/utilities/abortable-retry.d.ts +38 -0
- package/lib/utilities/abortable-retry.js +61 -0
- package/lib/utilities/dual-video-stream-config.d.ts +6 -0
- package/lib/utilities/dual-video-stream-config.js +25 -0
- package/lib/utilities/error-helpers.d.ts +10 -9
- package/lib/utilities/error-helpers.js +12 -11
- package/lib/utilities/error.d.ts +4 -40
- package/lib/utilities/error.js +20 -77
- package/lib/utilities/join-helper.js +2 -2
- package/lib/utilities/logger.d.ts +2 -2
- package/lib/utilities/logger.js +6 -25
- package/lib/utilities/package-info.d.ts +1 -2
- package/lib/utilities/package-info.js +4 -8
- package/lib/utilities/parameters.js +88 -15
- package/lib/utilities/validate-params.js +1 -1
- package/lib/utilities/video-encoder-config.d.ts +9 -0
- package/lib/utilities/video-encoder-config.js +109 -0
- package/lib-es/base-session.js +1 -0
- package/lib-es/chat-connector/type.js +6 -0
- package/lib-es/engine/index.js +412 -0
- package/lib-es/engine/type.js +1 -0
- package/lib-es/imports.js +59 -0
- package/lib-es/index.js +8 -0
- package/lib-es/media-control/desktop.js +172 -0
- package/lib-es/media-control/mobile.js +198 -0
- package/lib-es/media-control/type.js +6 -0
- package/lib-es/monitor-control/index.js +46 -0
- package/lib-es/monitor-control/type.js +1 -0
- package/lib-es/peer-session/index.js +279 -0
- package/lib-es/peer-session/type.js +1 -0
- package/lib-es/plugins/chat/chatroom.js +409 -0
- package/{lib/chat-connection → lib-es/plugins/chat}/config.js +5 -9
- package/lib-es/plugins/chat/connector.js +269 -0
- package/lib-es/plugins/electron-rtc-plugin.js +1 -0
- package/lib-es/plugins/rtm-plugin.js +1 -0
- package/lib-es/plugins/web-rtc-plugin.js +1 -0
- package/lib-es/room-control/ability-control/index.js +58 -0
- package/lib-es/room-control/ability-control/type.js +15 -0
- package/lib-es/room-control/chatroom-control/type.js +12 -0
- package/lib-es/room-control/group-control/index.js +256 -0
- package/lib-es/room-control/helpers/constants.js +92 -0
- package/lib-es/room-control/helpers/index.js +20 -0
- package/lib-es/room-control/helpers/validation-helper.js +46 -0
- package/lib-es/room-control/index.js +623 -0
- package/lib-es/room-control/interpreter-control/index.js +172 -0
- package/lib-es/room-control/interpreter-control/room.js +28 -0
- package/lib-es/room-control/interpreter-control/types.js +26 -0
- package/lib-es/room-control/join-before-host-waitingroom-control/index.js +29 -0
- package/lib-es/room-control/mainroom-control/index.js +248 -0
- package/lib-es/room-control/privilege-control/helper.js +97 -0
- package/lib-es/room-control/privilege-control/index.js +339 -0
- package/lib-es/room-control/privilege-control/type.js +159 -0
- package/lib-es/room-control/room-connector-control/index.js +182 -0
- package/lib-es/room-control/room-connector-control/type.js +28 -0
- package/lib-es/room-control/room-control-factory.js +77 -0
- package/lib-es/room-control/room-session/index.js +292 -0
- package/lib-es/room-control/room-session/type.js +1 -0
- package/lib-es/room-control/shared-cache.js +47 -0
- package/lib-es/room-control/sharing-control/index.js +307 -0
- package/lib-es/room-control/sharing-control/type.js +16 -0
- package/lib-es/room-control/stream-control/index.js +536 -0
- package/lib-es/room-control/stream-control/type.js +1 -0
- package/lib-es/room-control/stt-control/de-compress-gzip.js +33 -0
- package/lib-es/room-control/stt-control/index.js +350 -0
- package/lib-es/room-control/stt-control/type.js +10 -0
- package/lib-es/room-control/type.js +30 -0
- package/lib-es/room-control/user-control/index.js +344 -0
- package/lib-es/room-control/user-control/type.js +21 -0
- package/lib-es/room-control/waitingroom-control/index.js +68 -0
- package/lib-es/room-control/whiteboard-control/enum.js +18 -0
- package/lib-es/room-control/whiteboard-control/type.js +10 -0
- package/lib-es/room-control/whiteboard-control/utils.js +13 -0
- package/lib-es/room-control/whiteboard-control-v1/board-subwindow.js +18 -0
- package/lib-es/room-control/whiteboard-control-v1/board-window.js +573 -0
- package/lib-es/room-control/whiteboard-control-v1/enum.js +157 -0
- package/lib-es/room-control/whiteboard-control-v1/factory.js +12 -0
- package/lib-es/room-control/whiteboard-control-v1/index.js +427 -0
- package/lib-es/room-control/whiteboard-control-v1/mount-manager.js +6 -0
- package/lib-es/room-control/whiteboard-control-v1/type.js +8 -0
- package/lib-es/room-control/whiteboard-control-v1/utils.js +273 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +76 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +37 -0
- package/lib-es/room-control/whiteboard-control-v2/annotation-control/type.js +1 -0
- package/lib-es/room-control/whiteboard-control-v2/base/index.js +347 -0
- package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +269 -0
- package/lib-es/room-control/whiteboard-control-v2/constant.js +9 -0
- package/lib-es/room-control/whiteboard-control-v2/enum.js +28 -0
- package/lib-es/room-control/whiteboard-control-v2/type.js +1 -0
- package/lib-es/room-control/whiteboard-control-v2/utils.js +92 -0
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +204 -0
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +61 -0
- package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/type.js +1 -0
- package/lib-es/room-router/index.js +263 -0
- package/lib-es/room-router/type.js +5 -0
- package/lib-es/schema.js +231 -0
- package/lib-es/service/api.js +1211 -0
- package/lib-es/service/type.js +1 -0
- package/lib-es/type.js +222 -0
- package/lib-es/utilities/abortable-retry.js +54 -0
- package/lib-es/utilities/cmd.js +1 -0
- package/lib-es/utilities/collection.js +64 -0
- package/lib-es/utilities/dual-video-stream-config.js +19 -0
- package/lib-es/utilities/error-helpers.js +224 -0
- package/lib-es/utilities/error.js +43 -0
- package/lib-es/utilities/join-helper.js +219 -0
- package/lib-es/utilities/logger.js +7 -0
- package/lib-es/utilities/package-info.js +5 -0
- package/lib-es/utilities/parameters.js +106 -0
- package/lib-es/utilities/retry-helpers.js +66 -0
- package/lib-es/utilities/shared-storage.js +31 -0
- package/lib-es/utilities/stream.js +18 -0
- package/lib-es/utilities/user.js +30 -0
- package/lib-es/utilities/validate-params.js +8 -0
- package/lib-es/utilities/video-encoder-config.js +103 -0
- package/package.json +11 -10
- package/lib/chat-connection/index.d.ts +0 -24
- package/lib/chat-connection/type.d.ts +0 -17
- package/lib/plugins/chatroom.js +0 -454
- package/lib/room-control/chatroom-control/config.d.ts +0 -51
- package/lib/utilities/storage.d.ts +0 -8
- package/lib/utilities/storage.js +0 -33
- /package/lib/plugins/{chatroom.d.ts → chat/chatroom.d.ts} +0 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import "core-js/modules/es.array.push.js";
|
|
2
|
+
import { md5 } from 'js-md5';
|
|
3
|
+
import { ApplianceNames, FcrBoardShape, FcrBoardToolType, ShapeType } from './enum';
|
|
4
|
+
import { EStrokeType } from '@netless/appliance-plugin';
|
|
5
|
+
export const heightPerTool = 36;
|
|
6
|
+
export const heightPerColor = 18;
|
|
7
|
+
export const defaultToolsRetain = heightPerTool * 6;
|
|
8
|
+
export const verticalPadding = 10;
|
|
9
|
+
export const sceneNavHeight = heightPerTool + verticalPadding;
|
|
10
|
+
export const widgetContainerClassName = 'netless-whiteboard-wrapper';
|
|
11
|
+
export const layoutContentClassName = 'fcr-layout-content-main-view';
|
|
12
|
+
export const videoRowClassName = 'fcr-layout-content-video-list-row';
|
|
13
|
+
export const toolbarClassName = 'fcr-board-toolbar';
|
|
14
|
+
export const windowClassName = 'netless-whiteboard-wrapper';
|
|
15
|
+
export const WINDOW_TITLE_HEIGHT = 28;
|
|
16
|
+
// width / height
|
|
17
|
+
export const WINDOW_ASPECT_RATIO = 1836 / 847;
|
|
18
|
+
export const WINDOW_MIN_SIZE = {
|
|
19
|
+
width: 653,
|
|
20
|
+
height: 336
|
|
21
|
+
};
|
|
22
|
+
export const WINDOW_REMAIN_SIZE = {
|
|
23
|
+
width: 783,
|
|
24
|
+
height: 388
|
|
25
|
+
};
|
|
26
|
+
export const WINDOW_REMAIN_POSITION = {
|
|
27
|
+
x: 0,
|
|
28
|
+
y: 171
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 根据
|
|
33
|
+
* @param imageInnerSize
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
export const getImageSize = (imageInnerSize, containerSize) => {
|
|
37
|
+
const windowSize = containerSize;
|
|
38
|
+
const widthHeightProportion = imageInnerSize.width / imageInnerSize.height;
|
|
39
|
+
const maxSize = 960;
|
|
40
|
+
if (imageInnerSize.width > maxSize && windowSize.width > maxSize || imageInnerSize.height > maxSize && windowSize.height > maxSize) {
|
|
41
|
+
if (widthHeightProportion > 1) {
|
|
42
|
+
return {
|
|
43
|
+
width: maxSize,
|
|
44
|
+
height: maxSize / widthHeightProportion
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
return {
|
|
48
|
+
width: maxSize * widthHeightProportion,
|
|
49
|
+
height: maxSize
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
if (imageInnerSize.width > windowSize.width || imageInnerSize.height > windowSize.height) {
|
|
54
|
+
if (widthHeightProportion > 1) {
|
|
55
|
+
return {
|
|
56
|
+
width: windowSize.width,
|
|
57
|
+
height: windowSize.width / widthHeightProportion
|
|
58
|
+
};
|
|
59
|
+
} else {
|
|
60
|
+
return {
|
|
61
|
+
width: windowSize.height * widthHeightProportion,
|
|
62
|
+
height: windowSize.height
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
return {
|
|
67
|
+
width: imageInnerSize.width,
|
|
68
|
+
height: imageInnerSize.height
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* @param url
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
export const fetchImageInfoByUrl = async (url, containerSize) => {
|
|
80
|
+
try {
|
|
81
|
+
const res = await fetch(url);
|
|
82
|
+
const blob = await res.blob();
|
|
83
|
+
const contentType = blob.type;
|
|
84
|
+
const image = new Image();
|
|
85
|
+
const reader = new FileReader();
|
|
86
|
+
const file = new File([blob], url, {
|
|
87
|
+
type: contentType
|
|
88
|
+
});
|
|
89
|
+
const result = await new Promise(resolve => {
|
|
90
|
+
reader.readAsDataURL(blob);
|
|
91
|
+
reader.onload = () => {
|
|
92
|
+
image.addEventListener('load', () => {
|
|
93
|
+
const uuid = md5(reader.result);
|
|
94
|
+
const res = getImageSize(image, containerSize);
|
|
95
|
+
const result = {
|
|
96
|
+
width: res.width,
|
|
97
|
+
height: res.height,
|
|
98
|
+
file: file,
|
|
99
|
+
url,
|
|
100
|
+
uuid
|
|
101
|
+
};
|
|
102
|
+
resolve(result);
|
|
103
|
+
}, false);
|
|
104
|
+
image.src = reader.result;
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
return result;
|
|
108
|
+
} catch (err) {
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
export const mergeCanvasImage = async scenes => {
|
|
113
|
+
let width = 0,
|
|
114
|
+
height = 0;
|
|
115
|
+
const bigCanvas = document.createElement('canvas');
|
|
116
|
+
const ctx = bigCanvas.getContext('2d');
|
|
117
|
+
const canvasArray = [];
|
|
118
|
+
for (const canvasPromise of scenes) {
|
|
119
|
+
const canvas = await canvasPromise();
|
|
120
|
+
if (canvas) {
|
|
121
|
+
width = Math.max(canvas.width, width);
|
|
122
|
+
height = Math.max(canvas.height, height);
|
|
123
|
+
canvasArray.push(canvas);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
bigCanvas.setAttribute('width', `${width}`);
|
|
127
|
+
bigCanvas.setAttribute('height', `${height * canvasArray.length}`);
|
|
128
|
+
canvasArray.forEach((canvas, index) => {
|
|
129
|
+
ctx && ctx.drawImage(canvas, 0, index * height, width, height);
|
|
130
|
+
});
|
|
131
|
+
return bigCanvas;
|
|
132
|
+
};
|
|
133
|
+
export const textColors = ['#ffffff', '#9b9b9b', '#4a4a4a', '#000000', '#d0021b', '#f5a623', '#f8e71c', '#7ed321', '#9013fe', '#50e3c2', '#0073ff', '#ffc8e2'];
|
|
134
|
+
export const defaultStrokeColor = {
|
|
135
|
+
r: 0,
|
|
136
|
+
g: 115,
|
|
137
|
+
b: 255
|
|
138
|
+
};
|
|
139
|
+
export const defaultTextSize = 24;
|
|
140
|
+
export const mediaMimeTypes = {
|
|
141
|
+
opus: 'video/ogg',
|
|
142
|
+
ogv: 'video/ogg',
|
|
143
|
+
mp4: 'video/mp4',
|
|
144
|
+
mov: 'video/mp4',
|
|
145
|
+
m4v: 'video/mp4',
|
|
146
|
+
mkv: 'video/x-matroska',
|
|
147
|
+
m4a: 'audio/mp4',
|
|
148
|
+
mp3: 'audio/mpeg',
|
|
149
|
+
aac: 'audio/aac',
|
|
150
|
+
caf: 'audio/x-caf',
|
|
151
|
+
flac: 'audio/flac',
|
|
152
|
+
oga: 'audio/ogg',
|
|
153
|
+
wav: 'audio/wav',
|
|
154
|
+
m3u8: 'application/x-mpegURL',
|
|
155
|
+
jpg: 'image/jpeg',
|
|
156
|
+
jpeg: 'image/jpeg',
|
|
157
|
+
gif: 'image/gif',
|
|
158
|
+
png: 'image/png',
|
|
159
|
+
svg: 'image/svg+xml',
|
|
160
|
+
webp: 'image/webp'
|
|
161
|
+
};
|
|
162
|
+
export const convertToNetlessBoardTool = tool => {
|
|
163
|
+
switch (tool) {
|
|
164
|
+
case FcrBoardToolType.SELECTOR:
|
|
165
|
+
return [ApplianceNames.selector];
|
|
166
|
+
case FcrBoardToolType.ERASER:
|
|
167
|
+
return [ApplianceNames.pencilEraser];
|
|
168
|
+
case FcrBoardToolType.LASER_POINTER:
|
|
169
|
+
return [ApplianceNames.laserPointer];
|
|
170
|
+
case FcrBoardToolType.HAND:
|
|
171
|
+
return [ApplianceNames.hand];
|
|
172
|
+
case FcrBoardToolType.TEXT:
|
|
173
|
+
return [ApplianceNames.text];
|
|
174
|
+
case FcrBoardToolType.ARROW:
|
|
175
|
+
return [ApplianceNames.arrow];
|
|
176
|
+
case FcrBoardToolType.RECTANGLE:
|
|
177
|
+
return [ApplianceNames.rectangle];
|
|
178
|
+
case FcrBoardToolType.ELLIPSE:
|
|
179
|
+
return [ApplianceNames.ellipse];
|
|
180
|
+
case FcrBoardToolType.STRAIGHT:
|
|
181
|
+
return [ApplianceNames.straight];
|
|
182
|
+
case FcrBoardToolType.CURVE:
|
|
183
|
+
return [ApplianceNames.pencil];
|
|
184
|
+
case FcrBoardToolType.TRIANGLE:
|
|
185
|
+
return [ApplianceNames.shape, ShapeType.Triangle];
|
|
186
|
+
case FcrBoardToolType.PENTAGRAM:
|
|
187
|
+
return [ApplianceNames.shape, ShapeType.Pentagram];
|
|
188
|
+
case FcrBoardToolType.RHOMBUS:
|
|
189
|
+
return [ApplianceNames.shape, ShapeType.Rhombus];
|
|
190
|
+
case FcrBoardToolType.DOTTED_LINE:
|
|
191
|
+
case FcrBoardToolType.LONG_DOTTED_LINE:
|
|
192
|
+
return [ApplianceNames.straight];
|
|
193
|
+
case FcrBoardToolType.NONE:
|
|
194
|
+
return [ApplianceNames.clicker];
|
|
195
|
+
default:
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
export const convertToNetlessStorkeType = type => {
|
|
200
|
+
switch (type) {
|
|
201
|
+
case FcrBoardToolType.DOTTED_LINE:
|
|
202
|
+
return EStrokeType.Dotted;
|
|
203
|
+
case FcrBoardToolType.LONG_DOTTED_LINE:
|
|
204
|
+
return EStrokeType.LongDotted;
|
|
205
|
+
default:
|
|
206
|
+
return EStrokeType.Normal;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
export const convertToFcrBoardToolShape = (tool, shape) => {
|
|
210
|
+
switch (tool) {
|
|
211
|
+
case ApplianceNames.selector:
|
|
212
|
+
return [FcrBoardToolType.SELECTOR];
|
|
213
|
+
case ApplianceNames.eraser:
|
|
214
|
+
return [FcrBoardToolType.ERASER];
|
|
215
|
+
case ApplianceNames.laserPointer:
|
|
216
|
+
return [FcrBoardToolType.LASER_POINTER];
|
|
217
|
+
case ApplianceNames.text:
|
|
218
|
+
return [FcrBoardToolType.TEXT];
|
|
219
|
+
case ApplianceNames.hand:
|
|
220
|
+
return [FcrBoardToolType.HAND];
|
|
221
|
+
}
|
|
222
|
+
switch (`${tool || ''}${shape || ''}`) {
|
|
223
|
+
case `${ApplianceNames.rectangle}`:
|
|
224
|
+
return [, FcrBoardShape.Rectangle];
|
|
225
|
+
case `${ApplianceNames.ellipse}`:
|
|
226
|
+
return [, FcrBoardShape.Ellipse];
|
|
227
|
+
case `${ApplianceNames.straight}`:
|
|
228
|
+
return [, FcrBoardShape.Straight];
|
|
229
|
+
case `${ApplianceNames.arrow}`:
|
|
230
|
+
return [, FcrBoardShape.Arrow];
|
|
231
|
+
case `${ApplianceNames.pencil}`:
|
|
232
|
+
return [, FcrBoardShape.Curve];
|
|
233
|
+
case `${ApplianceNames.shape}${ShapeType.Triangle}`:
|
|
234
|
+
return [, FcrBoardShape.Triangle];
|
|
235
|
+
case `${ApplianceNames.shape, ShapeType.Pentagram}`:
|
|
236
|
+
return [, FcrBoardShape.Pentagram];
|
|
237
|
+
case `${ApplianceNames.shape}${ShapeType.Rhombus}`:
|
|
238
|
+
return [, FcrBoardShape.Rhombus];
|
|
239
|
+
}
|
|
240
|
+
return [];
|
|
241
|
+
};
|
|
242
|
+
export const hexColorToWhiteboardColor = val => {
|
|
243
|
+
const pattern = /^(#?)[a-fA-F0-9]{6}$/; // 16进制颜色校验规则
|
|
244
|
+
if (!pattern.test(val)) {
|
|
245
|
+
return [255, 255, 255];
|
|
246
|
+
}
|
|
247
|
+
const v = val.replace(/#/, '');
|
|
248
|
+
const rgbArr = [];
|
|
249
|
+
for (let i = 0; i < 3; i++) {
|
|
250
|
+
const item = v.substring(i * 2, i * 2 + 2);
|
|
251
|
+
const num = parseInt(item, 16);
|
|
252
|
+
rgbArr.push(num);
|
|
253
|
+
}
|
|
254
|
+
return rgbArr;
|
|
255
|
+
};
|
|
256
|
+
export const src2DataURL = src => {
|
|
257
|
+
return new Promise((resolve, reject) => {
|
|
258
|
+
const canvas = document.createElement('canvas');
|
|
259
|
+
const ctx = canvas.getContext('2d');
|
|
260
|
+
const image = new Image();
|
|
261
|
+
image.onload = () => {
|
|
262
|
+
canvas.setAttribute('width', `${image.width}`);
|
|
263
|
+
canvas.setAttribute('height', `${image.height}`);
|
|
264
|
+
ctx?.drawImage(image, 0, 0);
|
|
265
|
+
resolve(canvas.toDataURL('image/jpeg', 0.8));
|
|
266
|
+
};
|
|
267
|
+
image.onerror = () => {
|
|
268
|
+
reject('error');
|
|
269
|
+
};
|
|
270
|
+
image.crossOrigin = 'anonymous';
|
|
271
|
+
image.src = src;
|
|
272
|
+
});
|
|
273
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { FcrErrorCode, FcrErrorModuleCode, generateFcrCoreClientError } from '../../../utilities/error';
|
|
2
|
+
import { createLogger } from '../../../utilities/logger';
|
|
3
|
+
import { FcrBaseWhiteboardControlImpl } from '../base';
|
|
4
|
+
import { ANNOTATION_APP_ID } from '../constant';
|
|
5
|
+
import { FcrBoardPropertiesState } from '../../whiteboard-control/type';
|
|
6
|
+
export class FcrAnnotationControlImpl extends FcrBaseWhiteboardControlImpl {
|
|
7
|
+
logger = createLogger({
|
|
8
|
+
prefix: 'FcrAnnotationControlImpl'
|
|
9
|
+
});
|
|
10
|
+
constructor(rtmClient, config, hasOperationPrivilege, forgeInitConfigFetcher, _sceneConfig, _api) {
|
|
11
|
+
super(rtmClient, config, hasOperationPrivilege, forgeInitConfigFetcher);
|
|
12
|
+
this.rtmClient = rtmClient;
|
|
13
|
+
this.config = config;
|
|
14
|
+
this._sceneConfig = _sceneConfig;
|
|
15
|
+
this._api = _api;
|
|
16
|
+
this.logger.info(`initialized, hasOperationPrivilege: ${hasOperationPrivilege}`);
|
|
17
|
+
}
|
|
18
|
+
async syncScreenShareOwnerAnnotationOpenDone() {
|
|
19
|
+
try {
|
|
20
|
+
await this._api.syncScreenShareOwnerAnnotationOpenDone(this._sceneConfig.sceneId);
|
|
21
|
+
return 0;
|
|
22
|
+
} catch (e) {
|
|
23
|
+
const error = e;
|
|
24
|
+
const errorMessage = error.message;
|
|
25
|
+
throw generateFcrCoreClientError(FcrErrorModuleCode.FCR_ROOM_WHITEBOARD, FcrErrorCode.LOCAL_HTTP_REQUEST_FAILED, `sync screen share owner annotation open done failed: ${errorMessage}`, error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async open() {
|
|
29
|
+
const state = this._sceneConfig.getAnnotationState();
|
|
30
|
+
if (state === FcrBoardPropertiesState.INACTIVE) {
|
|
31
|
+
return await super.internalOpen(true);
|
|
32
|
+
} else {
|
|
33
|
+
return await super.internalOpen(false);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
getApplicationId() {
|
|
37
|
+
return ANNOTATION_APP_ID;
|
|
38
|
+
}
|
|
39
|
+
getWhiteboardOption() {
|
|
40
|
+
return {
|
|
41
|
+
width: this.config.size.width,
|
|
42
|
+
height: this.config.size.height,
|
|
43
|
+
defaultToolbarStyle: {
|
|
44
|
+
tool: 'laser'
|
|
45
|
+
},
|
|
46
|
+
maxScaleRatio: 1
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class FcrStandaloneAnnotationControlImpl extends FcrBaseWhiteboardControlImpl {
|
|
51
|
+
logger = createLogger({
|
|
52
|
+
prefix: 'FcrStandaloneAnnotationControlImpl'
|
|
53
|
+
});
|
|
54
|
+
constructor(rtmClient, config, hasOperationPrivilege, forgeInitConfigFetcher) {
|
|
55
|
+
super(rtmClient, config, hasOperationPrivilege, forgeInitConfigFetcher);
|
|
56
|
+
this.rtmClient = rtmClient;
|
|
57
|
+
this.config = config;
|
|
58
|
+
this.logger.info(`initialized, hasOperationPrivilege: ${hasOperationPrivilege}`);
|
|
59
|
+
}
|
|
60
|
+
async open() {
|
|
61
|
+
return await super.internalOpen(true);
|
|
62
|
+
}
|
|
63
|
+
getApplicationId() {
|
|
64
|
+
return ANNOTATION_APP_ID;
|
|
65
|
+
}
|
|
66
|
+
getWhiteboardOption() {
|
|
67
|
+
return {
|
|
68
|
+
width: this.config.size.width,
|
|
69
|
+
height: this.config.size.height,
|
|
70
|
+
defaultToolbarStyle: {
|
|
71
|
+
tool: 'laser'
|
|
72
|
+
},
|
|
73
|
+
maxScaleRatio: 1
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "core-js/modules/es.json.stringify.js";
|
|
2
|
+
import { FcrAnnotationControlImpl, FcrStandaloneAnnotationControlImpl } from './control';
|
|
3
|
+
import { createLogger } from '../../../utilities/logger';
|
|
4
|
+
import { generateFcrCoreClientError, handleRequestError } from '../../../utilities/error';
|
|
5
|
+
import { getAnnotationBoardOptions } from '../../../utilities/shared-storage';
|
|
6
|
+
import { DetailErrorCode, ErrorModuleCode } from '../../../imports';
|
|
7
|
+
export class FcrAnnotationControlFactoryImpl {
|
|
8
|
+
logger = createLogger({
|
|
9
|
+
prefix: 'FcrAnnotationControlFactory'
|
|
10
|
+
});
|
|
11
|
+
createForSubProcess(rtmClient, hasOperationPrivilege, config) {
|
|
12
|
+
this.logger.info(`create for sub process with config: ${JSON.stringify(config)}`);
|
|
13
|
+
return new FcrStandaloneAnnotationControlImpl(rtmClient, config, hasOperationPrivilege, () => {
|
|
14
|
+
const forgeInitConfig = getAnnotationBoardOptions();
|
|
15
|
+
if (!forgeInitConfig) {
|
|
16
|
+
throw generateFcrCoreClientError(ErrorModuleCode.FCR_ROOM_WHITEBOARD, DetailErrorCode.UNDEFINED_ERROR, `whiteboard init config is not exist`, new Error(`whiteboard init config is not exist`));
|
|
17
|
+
}
|
|
18
|
+
return Promise.resolve(forgeInitConfig);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
createForMainProcess(rtmClient, hasOperationPrivilege, config, annotationSceneConfig, api) {
|
|
22
|
+
const control = new FcrAnnotationControlImpl(rtmClient, config, hasOperationPrivilege, this._createForgeInitConfigFetcher(api, config.roomId, config.userId), annotationSceneConfig, api);
|
|
23
|
+
return control;
|
|
24
|
+
}
|
|
25
|
+
_createForgeInitConfigFetcher(api, roomId, userId) {
|
|
26
|
+
const getObjectInitConfig = async (roomId, userId) => {
|
|
27
|
+
return await handleRequestError(() => api.getAnnotationToken({
|
|
28
|
+
roomId,
|
|
29
|
+
userId
|
|
30
|
+
}), ErrorModuleCode.FCR_ROOM_WHITEBOARD, 'get annotation token failed');
|
|
31
|
+
};
|
|
32
|
+
return async () => {
|
|
33
|
+
const response = await getObjectInitConfig(roomId, userId);
|
|
34
|
+
return response.data;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|