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.
Files changed (199) hide show
  1. package/lib/chat-connector/type.d.ts +40 -0
  2. package/lib/{chat-connection → chat-connector}/type.js +1 -1
  3. package/lib/engine/index.d.ts +10 -11
  4. package/lib/engine/index.js +63 -72
  5. package/lib/engine/type.d.ts +96 -0
  6. package/lib/engine/type.js +5 -0
  7. package/lib/imports.d.ts +7 -4
  8. package/lib/imports.js +30 -4
  9. package/lib/index.d.ts +3 -2
  10. package/lib/index.js +21 -2
  11. package/lib/media-control/desktop.js +12 -12
  12. package/lib/media-control/mobile.js +4 -0
  13. package/lib/media-control/type.d.ts +32 -33
  14. package/lib/monitor-control/index.js +3 -3
  15. package/lib/peer-session/index.js +14 -14
  16. package/lib/peer-session/type.d.ts +1 -1
  17. package/lib/plugins/chat/chatroom.js +417 -0
  18. package/lib/{chat-connection → plugins/chat}/config.d.ts +1 -0
  19. package/lib/{room-control/chatroom-control → plugins/chat}/config.js +2 -1
  20. package/lib/plugins/chat/connector.d.ts +38 -0
  21. package/lib/{chat-connection/index.js → plugins/chat/connector.js} +181 -61
  22. package/lib/room-control/ability-control/index.js +5 -4
  23. package/lib/room-control/ability-control/type.d.ts +5 -1
  24. package/lib/room-control/ability-control/type.js +4 -0
  25. package/lib/room-control/chatroom-control/type.d.ts +44 -35
  26. package/lib/room-control/group-control/index.js +9 -9
  27. package/lib/room-control/index.js +37 -22
  28. package/lib/room-control/interpreter-control/index.js +7 -4
  29. package/lib/room-control/interpreter-control/room.js +3 -3
  30. package/lib/room-control/interpreter-control/types.d.ts +2 -2
  31. package/lib/room-control/join-before-host-waitingroom-control/index.js +3 -3
  32. package/lib/room-control/mainroom-control/index.js +15 -13
  33. package/lib/room-control/privilege-control/index.js +39 -24
  34. package/lib/room-control/privilege-control/type.d.ts +15 -15
  35. package/lib/room-control/room-connector-control/index.js +7 -5
  36. package/lib/room-control/room-connector-control/type.d.ts +1 -1
  37. package/lib/room-control/room-control-factory.d.ts +3 -3
  38. package/lib/room-control/room-control-factory.js +7 -7
  39. package/lib/room-control/room-session/index.js +17 -15
  40. package/lib/room-control/room-session/type.d.ts +3 -3
  41. package/lib/room-control/sharing-control/index.js +13 -7
  42. package/lib/room-control/stream-control/index.js +18 -16
  43. package/lib/room-control/stream-control/type.d.ts +5 -5
  44. package/lib/room-control/stt-control/index.js +38 -31
  45. package/lib/room-control/type.d.ts +19 -19
  46. package/lib/room-control/user-control/index.js +20 -22
  47. package/lib/room-control/user-control/type.d.ts +1 -1
  48. package/lib/room-control/waitingroom-control/index.js +11 -11
  49. package/lib/room-control/whiteboard-control-v1/board-window.d.ts +21 -20
  50. package/lib/room-control/whiteboard-control-v1/board-window.js +27 -8
  51. package/lib/room-control/whiteboard-control-v1/factory.js +1 -1
  52. package/lib/room-control/whiteboard-control-v1/index.js +26 -18
  53. package/lib/room-control/whiteboard-control-v1/type.d.ts +26 -25
  54. package/lib/room-control/whiteboard-control-v1/type.js +1 -0
  55. package/lib/room-control/whiteboard-control-v2/annotation-control/control.d.ts +15 -6
  56. package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +39 -5
  57. package/lib/room-control/whiteboard-control-v2/annotation-control/factory.d.ts +4 -5
  58. package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +6 -5
  59. package/lib/room-control/whiteboard-control-v2/annotation-control/type.d.ts +7 -1
  60. package/lib/room-control/whiteboard-control-v2/base/index.d.ts +9 -8
  61. package/lib/room-control/whiteboard-control-v2/base/index.js +84 -42
  62. package/lib/room-control/whiteboard-control-v2/base/main-window.d.ts +16 -15
  63. package/lib/room-control/whiteboard-control-v2/base/main-window.js +23 -4
  64. package/lib/room-control/whiteboard-control-v2/type.d.ts +17 -17
  65. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +12 -6
  66. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +64 -18
  67. package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.d.ts +2 -2
  68. package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +10 -10
  69. package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.d.ts +1 -1
  70. package/lib/room-router/index.js +10 -7
  71. package/lib/room-router/type.d.ts +1 -1
  72. package/lib/schema.d.ts +24 -46
  73. package/lib/schema.js +1 -2
  74. package/lib/service/api.d.ts +5 -3
  75. package/lib/service/api.js +17 -12
  76. package/lib/type.d.ts +64 -45
  77. package/lib/type.js +76 -11
  78. package/lib/utilities/abortable-retry.d.ts +38 -0
  79. package/lib/utilities/abortable-retry.js +61 -0
  80. package/lib/utilities/dual-video-stream-config.d.ts +6 -0
  81. package/lib/utilities/dual-video-stream-config.js +25 -0
  82. package/lib/utilities/error-helpers.d.ts +10 -9
  83. package/lib/utilities/error-helpers.js +12 -11
  84. package/lib/utilities/error.d.ts +4 -40
  85. package/lib/utilities/error.js +20 -77
  86. package/lib/utilities/join-helper.js +2 -2
  87. package/lib/utilities/logger.d.ts +2 -2
  88. package/lib/utilities/logger.js +6 -25
  89. package/lib/utilities/package-info.d.ts +1 -2
  90. package/lib/utilities/package-info.js +4 -8
  91. package/lib/utilities/parameters.js +88 -15
  92. package/lib/utilities/validate-params.js +1 -1
  93. package/lib/utilities/video-encoder-config.d.ts +9 -0
  94. package/lib/utilities/video-encoder-config.js +109 -0
  95. package/lib-es/base-session.js +1 -0
  96. package/lib-es/chat-connector/type.js +6 -0
  97. package/lib-es/engine/index.js +412 -0
  98. package/lib-es/engine/type.js +1 -0
  99. package/lib-es/imports.js +59 -0
  100. package/lib-es/index.js +8 -0
  101. package/lib-es/media-control/desktop.js +172 -0
  102. package/lib-es/media-control/mobile.js +198 -0
  103. package/lib-es/media-control/type.js +6 -0
  104. package/lib-es/monitor-control/index.js +46 -0
  105. package/lib-es/monitor-control/type.js +1 -0
  106. package/lib-es/peer-session/index.js +279 -0
  107. package/lib-es/peer-session/type.js +1 -0
  108. package/lib-es/plugins/chat/chatroom.js +409 -0
  109. package/{lib/chat-connection → lib-es/plugins/chat}/config.js +5 -9
  110. package/lib-es/plugins/chat/connector.js +269 -0
  111. package/lib-es/plugins/electron-rtc-plugin.js +1 -0
  112. package/lib-es/plugins/rtm-plugin.js +1 -0
  113. package/lib-es/plugins/web-rtc-plugin.js +1 -0
  114. package/lib-es/room-control/ability-control/index.js +58 -0
  115. package/lib-es/room-control/ability-control/type.js +15 -0
  116. package/lib-es/room-control/chatroom-control/type.js +12 -0
  117. package/lib-es/room-control/group-control/index.js +256 -0
  118. package/lib-es/room-control/helpers/constants.js +92 -0
  119. package/lib-es/room-control/helpers/index.js +20 -0
  120. package/lib-es/room-control/helpers/validation-helper.js +46 -0
  121. package/lib-es/room-control/index.js +623 -0
  122. package/lib-es/room-control/interpreter-control/index.js +172 -0
  123. package/lib-es/room-control/interpreter-control/room.js +28 -0
  124. package/lib-es/room-control/interpreter-control/types.js +26 -0
  125. package/lib-es/room-control/join-before-host-waitingroom-control/index.js +29 -0
  126. package/lib-es/room-control/mainroom-control/index.js +248 -0
  127. package/lib-es/room-control/privilege-control/helper.js +97 -0
  128. package/lib-es/room-control/privilege-control/index.js +339 -0
  129. package/lib-es/room-control/privilege-control/type.js +159 -0
  130. package/lib-es/room-control/room-connector-control/index.js +182 -0
  131. package/lib-es/room-control/room-connector-control/type.js +28 -0
  132. package/lib-es/room-control/room-control-factory.js +77 -0
  133. package/lib-es/room-control/room-session/index.js +292 -0
  134. package/lib-es/room-control/room-session/type.js +1 -0
  135. package/lib-es/room-control/shared-cache.js +47 -0
  136. package/lib-es/room-control/sharing-control/index.js +307 -0
  137. package/lib-es/room-control/sharing-control/type.js +16 -0
  138. package/lib-es/room-control/stream-control/index.js +536 -0
  139. package/lib-es/room-control/stream-control/type.js +1 -0
  140. package/lib-es/room-control/stt-control/de-compress-gzip.js +33 -0
  141. package/lib-es/room-control/stt-control/index.js +350 -0
  142. package/lib-es/room-control/stt-control/type.js +10 -0
  143. package/lib-es/room-control/type.js +30 -0
  144. package/lib-es/room-control/user-control/index.js +344 -0
  145. package/lib-es/room-control/user-control/type.js +21 -0
  146. package/lib-es/room-control/waitingroom-control/index.js +68 -0
  147. package/lib-es/room-control/whiteboard-control/enum.js +18 -0
  148. package/lib-es/room-control/whiteboard-control/type.js +10 -0
  149. package/lib-es/room-control/whiteboard-control/utils.js +13 -0
  150. package/lib-es/room-control/whiteboard-control-v1/board-subwindow.js +18 -0
  151. package/lib-es/room-control/whiteboard-control-v1/board-window.js +573 -0
  152. package/lib-es/room-control/whiteboard-control-v1/enum.js +157 -0
  153. package/lib-es/room-control/whiteboard-control-v1/factory.js +12 -0
  154. package/lib-es/room-control/whiteboard-control-v1/index.js +427 -0
  155. package/lib-es/room-control/whiteboard-control-v1/mount-manager.js +6 -0
  156. package/lib-es/room-control/whiteboard-control-v1/type.js +8 -0
  157. package/lib-es/room-control/whiteboard-control-v1/utils.js +273 -0
  158. package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +76 -0
  159. package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +37 -0
  160. package/lib-es/room-control/whiteboard-control-v2/annotation-control/type.js +1 -0
  161. package/lib-es/room-control/whiteboard-control-v2/base/index.js +347 -0
  162. package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +269 -0
  163. package/lib-es/room-control/whiteboard-control-v2/constant.js +9 -0
  164. package/lib-es/room-control/whiteboard-control-v2/enum.js +28 -0
  165. package/lib-es/room-control/whiteboard-control-v2/type.js +1 -0
  166. package/lib-es/room-control/whiteboard-control-v2/utils.js +92 -0
  167. package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +204 -0
  168. package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +61 -0
  169. package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/type.js +1 -0
  170. package/lib-es/room-router/index.js +263 -0
  171. package/lib-es/room-router/type.js +5 -0
  172. package/lib-es/schema.js +231 -0
  173. package/lib-es/service/api.js +1211 -0
  174. package/lib-es/service/type.js +1 -0
  175. package/lib-es/type.js +222 -0
  176. package/lib-es/utilities/abortable-retry.js +54 -0
  177. package/lib-es/utilities/cmd.js +1 -0
  178. package/lib-es/utilities/collection.js +64 -0
  179. package/lib-es/utilities/dual-video-stream-config.js +19 -0
  180. package/lib-es/utilities/error-helpers.js +224 -0
  181. package/lib-es/utilities/error.js +43 -0
  182. package/lib-es/utilities/join-helper.js +219 -0
  183. package/lib-es/utilities/logger.js +7 -0
  184. package/lib-es/utilities/package-info.js +5 -0
  185. package/lib-es/utilities/parameters.js +106 -0
  186. package/lib-es/utilities/retry-helpers.js +66 -0
  187. package/lib-es/utilities/shared-storage.js +31 -0
  188. package/lib-es/utilities/stream.js +18 -0
  189. package/lib-es/utilities/user.js +30 -0
  190. package/lib-es/utilities/validate-params.js +8 -0
  191. package/lib-es/utilities/video-encoder-config.js +103 -0
  192. package/package.json +11 -10
  193. package/lib/chat-connection/index.d.ts +0 -24
  194. package/lib/chat-connection/type.d.ts +0 -17
  195. package/lib/plugins/chatroom.js +0 -454
  196. package/lib/room-control/chatroom-control/config.d.ts +0 -51
  197. package/lib/utilities/storage.d.ts +0 -8
  198. package/lib/utilities/storage.js +0 -33
  199. /package/lib/plugins/{chatroom.d.ts → chat/chatroom.d.ts} +0 -0
@@ -0,0 +1,157 @@
1
+ export let FcrBoardShape = /*#__PURE__*/function (FcrBoardShape) {
2
+ FcrBoardShape[FcrBoardShape["Curve"] = 1] = "Curve";
3
+ FcrBoardShape[FcrBoardShape["Straight"] = 2] = "Straight";
4
+ FcrBoardShape[FcrBoardShape["Arrow"] = 3] = "Arrow";
5
+ FcrBoardShape[FcrBoardShape["Rectangle"] = 4] = "Rectangle";
6
+ FcrBoardShape[FcrBoardShape["Triangle"] = 5] = "Triangle";
7
+ FcrBoardShape[FcrBoardShape["Rhombus"] = 6] = "Rhombus";
8
+ FcrBoardShape[FcrBoardShape["Pentagram"] = 7] = "Pentagram";
9
+ FcrBoardShape[FcrBoardShape["Ellipse"] = 8] = "Ellipse";
10
+ return FcrBoardShape;
11
+ }({});
12
+ export let RoomPhase = /*#__PURE__*/function (RoomPhase) {
13
+ /**
14
+ * 连接中
15
+ */
16
+ RoomPhase["Connecting"] = "connecting";
17
+ /**
18
+ * 已连接
19
+ */
20
+ RoomPhase["Connected"] = "connected";
21
+ /**
22
+ * 正在重连
23
+ */
24
+ RoomPhase["Reconnecting"] = "reconnecting";
25
+ /**
26
+ * 断开连接中
27
+ */
28
+ RoomPhase["Disconnecting"] = "disconnecting";
29
+ /**
30
+ * 已断开连接
31
+ */
32
+ RoomPhase["Disconnected"] = "disconnected";
33
+ return RoomPhase;
34
+ }({});
35
+ export let ViewMode = /*#__PURE__*/function (ViewMode) {
36
+ /**
37
+ * 自由模式。不跟随任何人,也不被任何人跟随,自己可以自由操作视角。
38
+ */
39
+ ViewMode["Freedom"] = "freedom";
40
+ /**
41
+ * 跟随模式。跟随当前房间的主播视角。
42
+ */
43
+ ViewMode["Follower"] = "follower";
44
+ /**
45
+ * 主播模式。可以自由操作视角,但房间中处于跟随模式的人会跟随。
46
+ */
47
+ ViewMode["Broadcaster"] = "broadcaster";
48
+ return ViewMode;
49
+ }({});
50
+ export let DeviceType = /*#__PURE__*/function (DeviceType) {
51
+ /**
52
+ * 桌面设备,使用键盘鼠标
53
+ */
54
+ DeviceType["Desktop"] = "desktop";
55
+ /**
56
+ * 触碰板设备,比如只能手机、平板电脑
57
+ */
58
+ DeviceType["Touch"] = "touch";
59
+ /**
60
+ * 同时支持键盘、鼠标、触碰板的设备
61
+ */
62
+ DeviceType["Surface"] = "surface";
63
+ return DeviceType;
64
+ }({});
65
+ export let ApplianceNames = /*#__PURE__*/function (ApplianceNames) {
66
+ /**
67
+ * 选择工具
68
+ */
69
+ ApplianceNames["selector"] = "selector";
70
+ /**
71
+ * 互动工具(无默认行为,可供 plugin 自定义)
72
+ */
73
+ ApplianceNames["clicker"] = "clicker";
74
+ /**
75
+ * 激光笔
76
+ */
77
+ ApplianceNames["laserPointer"] = "laserPointer";
78
+ /**
79
+ * 铅笔工具
80
+ */
81
+ ApplianceNames["pencil"] = "pencil";
82
+ /**
83
+ * 矩形工具
84
+ */
85
+ ApplianceNames["rectangle"] = "rectangle";
86
+ /**
87
+ * 圆形工具
88
+ */
89
+ ApplianceNames["ellipse"] = "ellipse";
90
+ /**
91
+ * 图形工具
92
+ */
93
+ ApplianceNames["shape"] = "shape";
94
+ /**
95
+ * 橡皮工具
96
+ */
97
+ ApplianceNames["eraser"] = "eraser";
98
+ /**
99
+ * 橡皮工具(用来擦除铅笔笔迹的局部)
100
+ */
101
+ ApplianceNames["pencilEraser"] = "pencilEraser";
102
+ /**
103
+ * 文字工具
104
+ */
105
+ ApplianceNames["text"] = "text";
106
+ /**
107
+ * 直线工具
108
+ */
109
+ ApplianceNames["straight"] = "straight";
110
+ /**
111
+ * 箭头工具
112
+ */
113
+ ApplianceNames["arrow"] = "arrow";
114
+ /**
115
+ * 抓手工具
116
+ */
117
+ ApplianceNames["hand"] = "hand";
118
+ return ApplianceNames;
119
+ }({});
120
+ export let ShapeType = /*#__PURE__*/function (ShapeType) {
121
+ /**
122
+ * 三角形
123
+ */
124
+ ShapeType["Triangle"] = "triangle";
125
+ /**
126
+ * 菱形
127
+ */
128
+ ShapeType["Rhombus"] = "rhombus";
129
+ /**
130
+ * 五角星
131
+ */
132
+ ShapeType["Pentagram"] = "pentagram";
133
+ /**
134
+ * 说话泡泡
135
+ */
136
+ ShapeType["SpeechBalloon"] = "speechBalloon";
137
+ return ShapeType;
138
+ }({});
139
+ export let FcrBoardToolType = /*#__PURE__*/function (FcrBoardToolType) {
140
+ FcrBoardToolType[FcrBoardToolType["NONE"] = 0] = "NONE";
141
+ FcrBoardToolType[FcrBoardToolType["SELECTOR"] = 1] = "SELECTOR";
142
+ FcrBoardToolType[FcrBoardToolType["LASER_POINTER"] = 2] = "LASER_POINTER";
143
+ FcrBoardToolType[FcrBoardToolType["ERASER"] = 3] = "ERASER";
144
+ FcrBoardToolType[FcrBoardToolType["TEXT"] = 4] = "TEXT";
145
+ FcrBoardToolType[FcrBoardToolType["HAND"] = 5] = "HAND";
146
+ FcrBoardToolType[FcrBoardToolType["CURVE"] = 6] = "CURVE";
147
+ FcrBoardToolType[FcrBoardToolType["STRAIGHT"] = 7] = "STRAIGHT";
148
+ FcrBoardToolType[FcrBoardToolType["ARROW"] = 8] = "ARROW";
149
+ FcrBoardToolType[FcrBoardToolType["RECTANGLE"] = 9] = "RECTANGLE";
150
+ FcrBoardToolType[FcrBoardToolType["TRIANGLE"] = 10] = "TRIANGLE";
151
+ FcrBoardToolType[FcrBoardToolType["RHOMBUS"] = 11] = "RHOMBUS";
152
+ FcrBoardToolType[FcrBoardToolType["PENTAGRAM"] = 12] = "PENTAGRAM";
153
+ FcrBoardToolType[FcrBoardToolType["ELLIPSE"] = 13] = "ELLIPSE";
154
+ FcrBoardToolType[FcrBoardToolType["DOTTED_LINE"] = 14] = "DOTTED_LINE";
155
+ FcrBoardToolType[FcrBoardToolType["LONG_DOTTED_LINE"] = 15] = "LONG_DOTTED_LINE";
156
+ return FcrBoardToolType;
157
+ }({});
@@ -0,0 +1,12 @@
1
+ import { FcrWhiteboardControlImpl } from '.';
2
+ import { createLogger } from '../../utilities/logger';
3
+ export class FcrWhiteboardControlFactoryImpl {
4
+ logger = createLogger({
5
+ prefix: 'FcrWhiteboardControlFactory'
6
+ });
7
+ constructor() {}
8
+ createForMainProcess(hasOperationPrivilege, scene, api, sharedCache) {
9
+ this.logger.info('create for main process, use old whiteboard control');
10
+ return new FcrWhiteboardControlImpl(scene, api, sharedCache, hasOperationPrivilege);
11
+ }
12
+ }
@@ -0,0 +1,427 @@
1
+ import "core-js/modules/es.array.push.js";
2
+ import "core-js/modules/esnext.function.metadata.js";
3
+ import "core-js/modules/esnext.map.delete-all.js";
4
+ import "core-js/modules/esnext.map.emplace.js";
5
+ import "core-js/modules/esnext.map.every.js";
6
+ import "core-js/modules/esnext.map.filter.js";
7
+ import "core-js/modules/esnext.map.find.js";
8
+ import "core-js/modules/esnext.map.find-key.js";
9
+ import "core-js/modules/esnext.map.includes.js";
10
+ import "core-js/modules/esnext.map.key-of.js";
11
+ import "core-js/modules/esnext.map.map-keys.js";
12
+ import "core-js/modules/esnext.map.map-values.js";
13
+ import "core-js/modules/esnext.map.merge.js";
14
+ import "core-js/modules/esnext.map.reduce.js";
15
+ import "core-js/modules/esnext.map.some.js";
16
+ import "core-js/modules/esnext.map.update.js";
17
+ import "core-js/modules/esnext.symbol.metadata.js";
18
+ let _initProto, _openDecs, _setBackgroundColorDecs, _setOperationPrivilegeDecs, _setBoardWritableDecs;
19
+ import "core-js/modules/esnext.iterator.constructor.js";
20
+ import "core-js/modules/esnext.iterator.map.js";
21
+ function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
+ function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
25
+ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
26
+ import SlideApp from '@netless/app-slide';
27
+ import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
28
+ import * as netlessVideoPlugin from '@netless/video-js-plugin';
29
+ import { WindowManager } from '@netless/window-manager';
30
+ import { bound } from 'agora-foundation/lib/decorator';
31
+ import { ErrorModuleCode } from '../../imports';
32
+ import { AgoraObservable } from 'agora-foundation/lib/utilities/observable';
33
+ import { sleep } from 'agora-rte-sdk/lib/imports';
34
+ import { DeviceType, LoggerReportMode, RoomPhase, ViewMode, WhiteWebSdk, createPlugins } from 'white-web-sdk';
35
+ import { FcrConnectionState } from '../..';
36
+ import { trace } from '../../imports';
37
+ import { FcrReturnCode } from '../../type';
38
+ import { handleRequestError } from '../../utilities/error';
39
+ import { createLogger, generateLogObserver } from '../../utilities/logger';
40
+ import { convertRteUserToFcrUser } from '../../utilities/user';
41
+ import { FcrSharePermissionState } from '../sharing-control/type';
42
+ import { FcrBoardPropertiesState } from '../whiteboard-control/type';
43
+ import { FcrBoardMainWindowImpl } from './board-window';
44
+ import { convertToFcrBoardToolShape, hexColorToWhiteboardColor, textColors } from './utils';
45
+
46
+ /**
47
+ * @internal
48
+ */
49
+ export class FcrWhiteboardControlImpl {
50
+ static {
51
+ [_initProto] = _applyDecs(this, [[[bound, trace], 2, "active"], [[bound, trace], 2, "inactive"], [_openDecs, 2, "open"], [[bound, trace], 2, "close"], [_setBackgroundColorDecs, 2, "setBackgroundColor"], [[bound, trace], 2, "getActivity"], [[bound, trace], 2, "getOwnerId"], [[bound, trace], 2, "getBackgroundColor"], [[bound, trace], 2, "getConnectionState"], [[bound, trace], 2, "getMainWindow"], [[bound, trace], 2, "addObserver"], [[bound, trace], 2, "removeObserver"], [[bound, trace], 2, "getBoardActiveInfo"], [[bound, trace], 2, "hasOperationPrivilege"], [_setOperationPrivilegeDecs, 2, "setOperationPrivilege"], [_setBoardWritableDecs, 2, "_setBoardWritable"], [bound, 2, "_getToken"], [bound, 2, "_handleRoomStateUpdated"], [bound, 2, "_updateConnnectionState"], [bound, 2, "_handleConnectionStateUpdated"], [trace, 2, "_connect"], [trace, 2, "_clean"]], []).e;
52
+ }
53
+ [(_openDecs = [bound, trace(['params'])], _setBackgroundColorDecs = [bound, trace(['backgroundColor'])], _setOperationPrivilegeDecs = [bound, trace(['hasPrivilege'])], _setBoardWritableDecs = trace(['granted']), "logger")] = (_initProto(this), createLogger({
54
+ prefix: 'FcrWhiteboardControlImpl'
55
+ }));
56
+ _client = {};
57
+ _joined = false;
58
+ _connectState = FcrConnectionState.DISCONNECTED;
59
+ _observable = new AgoraObservable();
60
+ _options = {
61
+ debug: false
62
+ };
63
+ _hasOperationPrivilege = false;
64
+ constructor(_scene, _api, _sharedCache, hasOperationPrivilege) {
65
+ this._scene = _scene;
66
+ this._api = _api;
67
+ this._sharedCache = _sharedCache;
68
+ this._hasOperationPrivilege = hasOperationPrivilege;
69
+ this._roomCache = this._sharedCache.getRoomCache(this._scene.sceneId);
70
+ this._addLogObserver();
71
+ _scene.addObserver({
72
+ onScenePropertiesUpdated: (_, event) => {
73
+ const operatorUser = convertRteUserToFcrUser(event.operatorUser, this._roomCache);
74
+ if (event.cause?.cmd === 10) {
75
+ const {
76
+ state,
77
+ extra: {
78
+ backgroundColor: bgColor
79
+ }
80
+ } = _scene.getScenePropertiesByKeyPath('widgets.netlessBoard') ?? {
81
+ state: 0,
82
+ extra: {
83
+ backgroundColor: '#fff'
84
+ }
85
+ };
86
+ if (state === 1) {
87
+ this._observable.notifyObservers('onActive', _scene.getScenePropertiesByKeyPath('widgets.netlessBoard').ownerUserUuid, operatorUser);
88
+ }
89
+ if (state === 0) {
90
+ this._observable.notifyObservers('onInactive', event.cause.data.widgetCause?.data?.reason, operatorUser);
91
+ }
92
+ if (event.cause.data.widgetCause?.cmd === 100101) {
93
+ this._observable.notifyObservers('onBackgroundColorUpdated', bgColor, operatorUser);
94
+ }
95
+ }
96
+ }
97
+ });
98
+ WindowManager.register({
99
+ kind: 'Slide',
100
+ src: SlideApp
101
+ });
102
+ }
103
+ async active() {
104
+ return handleRequestError(() => this._api.toggleWhiteboardActivityState(this._scene.sceneId, FcrSharePermissionState.ON), ErrorModuleCode.FCR_ROOM_WHITEBOARD, 'active failed');
105
+ }
106
+ async inactive() {
107
+ return handleRequestError(() => this._api.toggleWhiteboardActivityState(this._scene.sceneId, FcrSharePermissionState.OFF), ErrorModuleCode.FCR_ROOM_WHITEBOARD, 'inactive failed');
108
+ }
109
+ async open(params = {}) {
110
+ this._whiteboardPrivateParameters = params;
111
+ // 白板权限禁用状态下,主持人和联席主持人仍然可以发起共享,所以,不能根据是否禁用状态直接拒绝
112
+
113
+ this._joined = true;
114
+ if (this._connectState !== FcrConnectionState.DISCONNECTED) {
115
+ return this._boardView;
116
+ }
117
+ const boardView = await this._connect();
118
+ return boardView;
119
+ }
120
+ async close() {
121
+ this._joined = false;
122
+ await this._clean();
123
+ return FcrReturnCode.SUCCESS;
124
+ }
125
+ async setBackgroundColor(backgroundColor) {
126
+ await this._api.setBackgroundColor({
127
+ roomId: this._scene.sceneId,
128
+ backgroundColor
129
+ });
130
+ return FcrReturnCode.SUCCESS;
131
+ }
132
+ getActivity() {
133
+ return this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard').state === 1;
134
+ }
135
+ getOwnerId() {
136
+ return this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard.ownerUserUuid');
137
+ }
138
+ getBackgroundColor() {
139
+ return this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard.extra.backgroundColor');
140
+ }
141
+ getConnectionState() {
142
+ return this._connectState;
143
+ }
144
+ getMainWindow() {
145
+ return this._boardView;
146
+ }
147
+ addObserver(observer) {
148
+ this._observable.addObserver(observer);
149
+ return FcrReturnCode.SUCCESS;
150
+ }
151
+ removeObserver(observer) {
152
+ this._observable.removeObserver(observer);
153
+ return FcrReturnCode.SUCCESS;
154
+ }
155
+ getBoardActiveInfo() {
156
+ const {
157
+ state,
158
+ ownerUserUuid: ownerUserId
159
+ } = this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard') || {
160
+ isActive: false,
161
+ ownerUserUuid: null
162
+ };
163
+ if (state === FcrBoardPropertiesState.ACTIVE) {
164
+ return {
165
+ isActive: true,
166
+ ownerUserId
167
+ };
168
+ } else {
169
+ return {
170
+ isActive: false,
171
+ ownerUserId: null
172
+ };
173
+ }
174
+ }
175
+ hasOperationPrivilege() {
176
+ return this._hasOperationPrivilege;
177
+ }
178
+ setOperationPrivilege(hasPrivilege) {
179
+ if (hasPrivilege !== this._hasOperationPrivilege) {
180
+ this._hasOperationPrivilege = hasPrivilege;
181
+ this._setBoardWritable(hasPrivilege);
182
+ }
183
+ return FcrReturnCode.SUCCESS;
184
+ }
185
+ async _setBoardWritable(granted) {
186
+ if (this._room) {
187
+ const room = this._room;
188
+ if (granted) {
189
+ this.logger.info('set whiteboard writable => true, start');
190
+ await room.setWritable(true);
191
+ this.logger.info('set whiteboard writable => true, success');
192
+ room.disableDeviceInputs = false;
193
+ room.disableSerialization = false;
194
+ const mainWindow = this._boardView;
195
+ if (mainWindow) {
196
+ // @ts-ignore
197
+ mainWindow._observable.notifyObservers('onWritable', true);
198
+ }
199
+ } else {
200
+ room.disableDeviceInputs = true;
201
+ room.disableSerialization = true;
202
+ this.logger.info('set whiteboard writable => false, start');
203
+ await room.setWritable(false);
204
+ this.logger.info('set whiteboard writable => false, success');
205
+ const mainWindow = this._boardView;
206
+ if (mainWindow) {
207
+ // @ts-ignore
208
+ mainWindow._observable.notifyObservers('onWritable', false);
209
+ }
210
+ }
211
+ }
212
+ return FcrReturnCode.SUCCESS;
213
+ }
214
+ _createPlugins() {
215
+ const plugins = createPlugins({
216
+ [netlessVideoPlugin.PluginId]: netlessVideoPlugin.videoJsPlugin()
217
+ });
218
+ plugins.setPluginContext(netlessVideoPlugin.PluginId, {
219
+ enable: true,
220
+ verbose: true
221
+ });
222
+ return plugins;
223
+ }
224
+ async _getToken(roomId, userId) {
225
+ return await handleRequestError(() => this._api.getWhiteboardToken({
226
+ roomId,
227
+ userId
228
+ }), ErrorModuleCode.FCR_ROOM_WHITEBOARD, 'get whiteboard token failed');
229
+ }
230
+ _handleRoomStateUpdated(state) {
231
+ const {
232
+ memberState
233
+ } = state;
234
+ if (memberState) {
235
+ const {
236
+ strokeColor,
237
+ strokeWidth,
238
+ currentApplianceName,
239
+ textSize,
240
+ shapeType
241
+ } = memberState;
242
+ const localState = {};
243
+ const [tool, shape] = convertToFcrBoardToolShape(currentApplianceName, shapeType);
244
+ localState.tool = tool;
245
+ localState.shape = shape;
246
+ if (typeof strokeColor !== 'undefined') {
247
+ const [r, g, b] = strokeColor;
248
+ localState.strokeColor = {
249
+ r,
250
+ g,
251
+ b
252
+ };
253
+ }
254
+ if (typeof strokeWidth !== 'undefined') {
255
+ localState.strokeWidth = strokeWidth;
256
+ }
257
+ if (typeof textSize !== 'undefined') {
258
+ localState.textSize = textSize;
259
+ }
260
+ }
261
+ }
262
+ _updateConnnectionState(state) {
263
+ if (this._connectState !== state) {
264
+ if (state === FcrConnectionState.CONNECTED) {
265
+ // 首次加入白板,白板回调connected时,boardView还为创建
266
+ if (this._boardView) {
267
+ this._connectState = state;
268
+ this._observable.notifyObservers('onConnectionStateUpdated', state);
269
+ }
270
+ } else if (state === FcrConnectionState.DISCONNECTED) {
271
+ if (this._joined) {
272
+ this.logger.info('whiteboard is disconnected, about to reconnect..');
273
+ sleep(5000).then(() => {
274
+ if (this._joined) {
275
+ this._connect();
276
+ }
277
+ });
278
+ } else {
279
+ this._connectState = state;
280
+ this._observable.notifyObservers('onConnectionStateUpdated', state);
281
+ }
282
+ } else {
283
+ this._connectState = state;
284
+ this._observable.notifyObservers('onConnectionStateUpdated', state);
285
+ }
286
+ }
287
+ }
288
+ _handleConnectionStateUpdated(phase) {
289
+ if (phase === RoomPhase.Connecting) {
290
+ this._updateConnnectionState(FcrConnectionState.CONNECTING);
291
+ } else if (phase === RoomPhase.Connected) {
292
+ this._updateConnnectionState(FcrConnectionState.CONNECTED);
293
+ } else if (phase === RoomPhase.Reconnecting) {
294
+ this._updateConnnectionState(FcrConnectionState.RECONNECTING);
295
+ } else if (phase === RoomPhase.Disconnected) {
296
+ this._updateConnnectionState(FcrConnectionState.DISCONNECTED);
297
+ } else if (phase === RoomPhase.Disconnecting) {
298
+ // this._updateConnnectionState(FcrConnectionState.DISCONNECTING);
299
+ }
300
+ }
301
+ async _connect() {
302
+ try {
303
+ this._updateConnnectionState(FcrConnectionState.CONNECTING);
304
+ const roomId = this._scene.sceneId;
305
+ const userId = this._scene.localUser.getLocalUserId();
306
+ const cursorName = this._scene.getUser(userId)?.userName;
307
+ const syncMode = this._whiteboardPrivateParameters?.syncMode ?? false;
308
+ const {
309
+ data
310
+ } = await this._getToken(roomId, userId);
311
+ const {
312
+ boardAppId,
313
+ boardId,
314
+ boardRegion,
315
+ boardToken
316
+ } = data || {};
317
+ const plugins = this._createPlugins();
318
+ this._client = new WhiteWebSdk({
319
+ appIdentifier: boardAppId,
320
+ useMobXState: true,
321
+ pptParams: {
322
+ useServerWrap: true
323
+ },
324
+ deviceType: DeviceType.Surface,
325
+ plugins,
326
+ preloadDynamicPPT: true,
327
+ loggerOptions: {
328
+ reportQualityMode: LoggerReportMode.AlwaysReport,
329
+ reportDebugLogMode: LoggerReportMode.AlwaysReport,
330
+ reportLevelMask: this._options.debug ? 'debug' : 'info',
331
+ printLevelMask: this._options.debug ? 'debug' : 'info'
332
+ },
333
+ ...this._whiteboardPrivateParameters
334
+ });
335
+ const hasPermission = this._hasOperationPrivilege;
336
+ const joinParams = {
337
+ region: boardRegion,
338
+ uuid: boardId,
339
+ uid: userId,
340
+ roomToken: boardToken,
341
+ isWritable: hasPermission,
342
+ disableDeviceInputs: false,
343
+ disableCameraTransform: true,
344
+ disableNewPencil: false,
345
+ disableEraseImage: false,
346
+ wrappedComponents: [],
347
+ invisiblePlugins: [WindowManager, ApplianceMultiPlugin],
348
+ useMultiViews: true,
349
+ disableMagixEventDispatchLimit: true,
350
+ userPayload: {
351
+ userId,
352
+ avatar: '',
353
+ cursorName,
354
+ disappearCursor: true
355
+ },
356
+ floatBar: this._whiteboardPrivateParameters?.floatBar ?? {
357
+ colors: textColors.map(color => hexColorToWhiteboardColor(color))
358
+ }
359
+ };
360
+ const room = await this._client.joinRoom(joinParams, {
361
+ onPhaseChanged: this._handleConnectionStateUpdated,
362
+ onRoomStateChanged: this._handleRoomStateUpdated
363
+ });
364
+ this._room = room;
365
+ if (hasPermission) {
366
+ room.setViewMode(ViewMode.Broadcaster);
367
+ }
368
+ this.logger.info(`set whiteboard sync mode: ${syncMode}`);
369
+ room.syncMode = syncMode;
370
+ const mountOptions = {};
371
+ const privateParams = this._whiteboardPrivateParameters;
372
+ if (!this._boardView) {
373
+ const mainWindow = this._createBoardMainWindow(room);
374
+ this._boardView = mainWindow;
375
+
376
+ // @ts-ignore
377
+ await this._boardView._mount(mountOptions, privateParams);
378
+ } else {
379
+ this.logger.info('reusing main window for whiteboard');
380
+ //@ts-ignore
381
+ this._boardView._setRoom(room, mountOptions, privateParams);
382
+ }
383
+ if (this._joined) {
384
+ this._updateConnnectionState(FcrConnectionState.CONNECTED);
385
+ } else {
386
+ // 如果没有加入白板,则需要清理掉之前的状态
387
+ this.logger.info('whiteboard is not joined, cleaning up the state');
388
+ this._clean();
389
+ }
390
+ } catch (e) {
391
+ this.logger.error('error when connecting to whiteboard', e);
392
+ this._updateConnnectionState(FcrConnectionState.DISCONNECTED);
393
+ }
394
+ return this._boardView;
395
+ }
396
+ _createBoardMainWindow(room) {
397
+ this.logger.info('creating main window for whiteboard');
398
+ const mainWindow = new FcrBoardMainWindowImpl(room);
399
+ return mainWindow;
400
+ }
401
+ async _clean() {
402
+ if (this._boardView) {
403
+ // @ts-ignore
404
+ this._boardView.destroy();
405
+ this._boardView = undefined;
406
+ }
407
+ if (this._room) {
408
+ try {
409
+ // Workaround for whiteboard sdk issue: frameGenerator being null when disconnecting will cause error and trigger 'did-finish-loading' event in electron.
410
+ // Set writable to false to prevent this error from throwing.
411
+ // this.logger.info('change writable to false before disconnecting');
412
+ // await this._room.setWritable(false);
413
+ await this._room.disconnect();
414
+ } catch (e) {
415
+ this.logger.error('error when disconnecting whiteboard room', e);
416
+ } finally {
417
+ this._room.callbacks.off('onPhaseChanged', this._handleConnectionStateUpdated);
418
+ this._room.callbacks.off('onRoomStateChanged', this._handleRoomStateUpdated);
419
+ }
420
+ this._room = undefined;
421
+ }
422
+ return FcrReturnCode.SUCCESS;
423
+ }
424
+ _addLogObserver() {
425
+ this.addObserver(generateLogObserver(this.logger, [['onActive', ['ownerId', 'operatorUser']], ['onInactive', ['reason', 'operatorUser']], ['onBackgroundColorUpdated', ['color', 'operatorUser']], ['onConnectionStateUpdated', ['state']]]));
426
+ }
427
+ }
@@ -0,0 +1,6 @@
1
+ export class BoardMountManager {
2
+ static isMounting = false;
3
+ static setIsMounting(isMounting) {
4
+ BoardMountManager.isMounting = isMounting;
5
+ }
6
+ }
@@ -0,0 +1,8 @@
1
+ export const WHITEBOARD_APP_ID = 'MainWhiteboard';
2
+ export let FcrBoardEraserSize = /*#__PURE__*/function (FcrBoardEraserSize) {
3
+ FcrBoardEraserSize[FcrBoardEraserSize["SMALL"] = 1] = "SMALL";
4
+ FcrBoardEraserSize[FcrBoardEraserSize["MEDIUM"] = 2] = "MEDIUM";
5
+ FcrBoardEraserSize[FcrBoardEraserSize["LARGE"] = 3] = "LARGE";
6
+ FcrBoardEraserSize[FcrBoardEraserSize["GIANT"] = 4] = "GIANT";
7
+ return FcrBoardEraserSize;
8
+ }({});