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,172 @@
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, _createRoomControlDecs, _setInterpreterUsersDecs;
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 { AgoraObservable, get, trace } from '../../imports';
27
+ import { FcrInterpreterRoomControlImpl } from './room';
28
+ import { FcrInterpreterActionType } from './types';
29
+ import { FcrReturnCode } from '../../type';
30
+ import { convertRteUserToFcrUser } from '../../utilities/user';
31
+ import { createLogger, generateLogObserver } from '../../utilities/logger';
32
+ import { handleRequestError } from '../../utilities/error';
33
+ import validateParams from '../../utilities/validate-params';
34
+ import { fcrInterpreterUsersParamsArraySchema, stringSchema } from '../../schema';
35
+ import { ErrorModuleCode } from '../../imports';
36
+
37
+ /**
38
+ * @internal
39
+ */
40
+ export class FcrInterpreterControlImpl {
41
+ static {
42
+ [_initProto] = _applyDecs(this, [[_createRoomControlDecs, 2, "createRoomControl"], [_setInterpreterUsersDecs, 2, "setInterpreterUsers"], [trace, 2, "close"], [trace, 2, "getState"], [trace, 2, "getInterpreterRoomList"], [trace, 2, "getInterpreterLanguageList"]], []).e;
43
+ }
44
+ //@internal
45
+ [(_createRoomControlDecs = [trace(['roomId']), validateParams(stringSchema)], _setInterpreterUsersDecs = [trace(['params']), validateParams(fcrInterpreterUsersParamsArraySchema)], "logger")] = (_initProto(this), createLogger({
46
+ prefix: 'FcrInterpreterControlImpl'
47
+ }));
48
+ _observable = new AgoraObservable();
49
+ _interpreterUserList = null;
50
+ constructor(_api, _scene, _config, _engine, _chatConnection, _sharedCache) {
51
+ this._api = _api;
52
+ this._scene = _scene;
53
+ this._config = _config;
54
+ this._engine = _engine;
55
+ this._chatConnection = _chatConnection;
56
+ this._sharedCache = _sharedCache;
57
+ this._roomCache = _sharedCache.getRoomCache(this._scene.sceneId);
58
+ this._roomId = this._scene.sceneId;
59
+ this._addInterpreterObservers();
60
+ this._addLogObserver();
61
+ }
62
+ createRoomControl(roomId) {
63
+ return new FcrInterpreterRoomControlImpl(this._engine, this._engine.createScene({
64
+ sceneId: roomId
65
+ }), this._api, this._config, this._sharedCache, this._chatConnection);
66
+ }
67
+ async setInterpreterUsers(params) {
68
+ await handleRequestError(() => this._api.openInterpreter({
69
+ roomId: this._roomId,
70
+ data: {
71
+ interpreters: params.map(({
72
+ userId: userUuid,
73
+ sourceLanguage,
74
+ targetLanguage
75
+ }) => {
76
+ return {
77
+ userUuid,
78
+ languagePair: [sourceLanguage, targetLanguage]
79
+ };
80
+ })
81
+ }
82
+ }), ErrorModuleCode.FCR_ROOM_INTERPRETER, 'set interpreterUsers failed');
83
+ return FcrReturnCode.SUCCESS;
84
+ }
85
+ async close() {
86
+ await handleRequestError(() => this._api.closeInterpreter({
87
+ roomId: this._roomId
88
+ }), ErrorModuleCode.FCR_ROOM_INTERPRETER, 'close interpreter failed');
89
+ return FcrReturnCode.SUCCESS;
90
+ }
91
+ getState() {
92
+ const enable = this._scene.getScenePropertiesByKeyPath('interpreter.enable');
93
+ return {
94
+ enable: enable === 1
95
+ };
96
+ }
97
+ getInterpreterRoomList() {
98
+ const rooms = this._scene.getScenePropertiesByKeyPath('interpreter.rooms') || [];
99
+ return rooms.length > 0 ? rooms.map(({
100
+ roomUuid,
101
+ language
102
+ }) => ({
103
+ roomId: roomUuid,
104
+ language
105
+ })) : null;
106
+ }
107
+ _setInterpreterUserList() {
108
+ const interpreter = this._scene.getScenePropertiesByKeyPath('interpreter');
109
+ const {
110
+ translates
111
+ } = interpreter || {
112
+ translates: []
113
+ };
114
+ const results = translates.map(({
115
+ userUuid: userId,
116
+ userName,
117
+ languagePair: [sourceLanguage, targetLanguage]
118
+ }) => ({
119
+ userId,
120
+ userName,
121
+ sourceLanguage,
122
+ targetLanguage
123
+ }));
124
+ this._interpreterUserList = results.length > 0 ? results : null;
125
+ }
126
+ getInterpreterUserList() {
127
+ return this._interpreterUserList;
128
+ }
129
+ getInterpreterLanguageList() {
130
+ const languages = this._scene.getScenePropertiesByKeyPath('interpreter.languages');
131
+ return languages;
132
+ }
133
+ addObserver(observer) {
134
+ this._observable.addObserver(observer);
135
+ }
136
+ removeObserver(observer) {
137
+ this._observable.removeObserver(observer);
138
+ }
139
+ _addInterpreterObservers() {
140
+ this._scene.addObserver({
141
+ onScenePropertiesUpdated: (_, event) => {
142
+ if (event.cause?.cmd === 800) {
143
+ const actionType = get(event.cause.data, 'actionType');
144
+ let operatorUser;
145
+ if (event.operatorUser) {
146
+ operatorUser = convertRteUserToFcrUser(event.operatorUser, this._roomCache);
147
+ }
148
+ const isStateUpdated = [FcrInterpreterActionType.OPEN, FcrInterpreterActionType.CLOSE].includes(actionType);
149
+ const isUpdated = [
150
+ // FcrInterpreterActionType.OPEN,
151
+ FcrInterpreterActionType.UPDATE].includes(actionType);
152
+ if (isStateUpdated || isUpdated) {
153
+ this._setInterpreterUserList();
154
+ }
155
+ if (isStateUpdated) {
156
+ this._observable.notifyObservers('onInterpreterStateUpdated', this._roomId, this.getState(), operatorUser);
157
+ }
158
+ if (isUpdated) {
159
+ this._observable.notifyObservers('onInterpreterUsersUpdated', this._roomId, this.getInterpreterUserList(), operatorUser);
160
+ this._observable.notifyObservers('onInterpreterRoomListUpdated', this._roomId, this.getInterpreterRoomList(), operatorUser);
161
+ }
162
+ }
163
+ },
164
+ onJoinSceneSuccess: () => {
165
+ this._setInterpreterUserList();
166
+ }
167
+ });
168
+ }
169
+ _addLogObserver() {
170
+ this.addObserver(generateLogObserver(this.logger, [['onInterpreterStateUpdated', ['roomId', 'state', 'operatorUser']], ['onInterpreterUsersUpdated', ['roomId', 'users', 'operatorUser']], ['onInterpreterRoomListUpdated', ['roomId', 'rooms', 'operatorUser']]]));
171
+ }
172
+ }
@@ -0,0 +1,28 @@
1
+ import { FcrBaseRoomControlImpl } from '..';
2
+ import { createLogger, generateLogObserver } from '../../utilities/logger';
3
+ import { FcrRoomType } from '../type';
4
+ /**
5
+ * @internal
6
+ */
7
+ export class FcrInterpreterRoomControlImpl extends FcrBaseRoomControlImpl {
8
+ //@internal
9
+ logger = createLogger({
10
+ prefix: 'FcrInterpreterRoomControlImpl'
11
+ });
12
+ constructor(_engine, _scene, _api, _config, _sharedCache, _chatConnection, chatRoomControl) {
13
+ super(_engine, _scene, _api, _config, FcrRoomType.Interpreterroom, _chatConnection, _sharedCache, chatRoomControl);
14
+ this._engine = _engine;
15
+ this._scene = _scene;
16
+ this._api = _api;
17
+ this._config = _config;
18
+ this._sharedCache = _sharedCache;
19
+ this._chatConnection = _chatConnection;
20
+ this._addLogObserver();
21
+ }
22
+ _addLogObserver() {
23
+ this.addObserver(generateLogObserver(this.logger, [['onCloudRecordingStateUpdated', ['roomId', 'state']], ['onJoinRoomFailure', ['roomId', 'error']], ['onJoinRoomSuccess', ['roomId']], ['onLiveStreamingStateUpdated', ['roomId', 'state', 'url', 'reason']],
24
+ // 'onNetworkQualityUpdated',
25
+ // 'onNetworkStatsUpdated',
26
+ ['onRoomMessageReceived', ['roomId', 'message']], ['onRoomPropertiesDeleted', ['roomId', 'event']], ['onRoomPropertiesUpdated', ['roomId', 'event']], ['onRoomStateUpdated', ['roomId', 'state']]]));
27
+ }
28
+ }
@@ -0,0 +1,26 @@
1
+ export let FcrLanguage = /*#__PURE__*/function (FcrLanguage) {
2
+ FcrLanguage["ZH"] = "zh";
3
+ FcrLanguage["EN"] = "en";
4
+ FcrLanguage["JP"] = "jp";
5
+ FcrLanguage["KO"] = "ko";
6
+ FcrLanguage["DE"] = "de";
7
+ FcrLanguage["FR"] = "fr";
8
+ FcrLanguage["RU"] = "ru";
9
+ FcrLanguage["PT"] = "pt";
10
+ FcrLanguage["ES"] = "es";
11
+ FcrLanguage["IT"] = "it";
12
+ FcrLanguage["AR"] = "ar";
13
+ FcrLanguage["ID"] = "id";
14
+ FcrLanguage["HI"] = "hi";
15
+ FcrLanguage["TH"] = "th";
16
+ FcrLanguage["VI"] = "vi";
17
+ FcrLanguage["MS"] = "ms";
18
+ FcrLanguage["TR"] = "tr";
19
+ return FcrLanguage;
20
+ }({});
21
+ export let FcrInterpreterActionType = /*#__PURE__*/function (FcrInterpreterActionType) {
22
+ FcrInterpreterActionType[FcrInterpreterActionType["OPEN"] = 1] = "OPEN";
23
+ FcrInterpreterActionType[FcrInterpreterActionType["UPDATE"] = 2] = "UPDATE";
24
+ FcrInterpreterActionType[FcrInterpreterActionType["CLOSE"] = 3] = "CLOSE";
25
+ return FcrInterpreterActionType;
26
+ }({});
@@ -0,0 +1,29 @@
1
+ import { FcrBaseRoomControlImpl } from '..';
2
+ import { createLogger, generateLogObserver } from '../../utilities/logger';
3
+ import { FcrRoomType } from '../type';
4
+
5
+ /**
6
+ * @internal
7
+ */
8
+ export class FcrJoinBeforeHostWaitingRoomControlImpl extends FcrBaseRoomControlImpl {
9
+ //@internal
10
+ logger = createLogger({
11
+ prefix: 'FcrJoinBeforeHostWaitingRoomControlImpl'
12
+ });
13
+ constructor(engine, scene, api, config, sharedCache, chatConnection, chatRoomControl) {
14
+ super(engine, scene, api, config, FcrRoomType.JoinBeforeHostWaitingRoom, chatConnection, sharedCache, chatRoomControl);
15
+ this._addLogObserver();
16
+ }
17
+ addObserver(observer) {
18
+ super.addObserver(observer);
19
+ }
20
+ removeObserver(observer) {
21
+ super.removeObserver(observer);
22
+ }
23
+ _addLogObserver() {
24
+ this.addObserver(generateLogObserver(this.logger, [['onCloudRecordingStateUpdated', ['roomId', 'state']], ['onJoinRoomFailure', ['roomId', 'error']], ['onJoinRoomSuccess', ['roomId']], ['onLiveStreamingStateUpdated', ['roomId', 'state', 'url', 'reason']],
25
+ // 'onNetworkQualityUpdated',
26
+ // 'onNetworkStatsUpdated',
27
+ ['onRoomMessageReceived', ['roomId', 'message']], ['onRoomPropertiesDeleted', ['roomId', 'event']], ['onRoomPropertiesUpdated', ['roomId', 'event']], ['onRoomStateUpdated', ['roomId', 'state']]]));
28
+ }
29
+ }
@@ -0,0 +1,248 @@
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, _enableWaitingRoomDecs, _moveToWaitingRoomByUserIdsDecs;
19
+ import "core-js/modules/es.json.stringify.js";
20
+ import "core-js/modules/esnext.iterator.constructor.js";
21
+ import "core-js/modules/esnext.iterator.find.js";
22
+ 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)]; } }; }
23
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
24
+ 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); }
25
+ 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; }
26
+ 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; }
27
+ import { FcrBaseRoomControlImpl } from '..';
28
+ import { AgoraRestfulClientError, AgoraScheduler, bound, DetailErrorCode, ErrorModuleCode, get, jsonstring, to, trace } from '../../imports';
29
+ import { booleanSchema, stringArraySchema } from '../../schema';
30
+ import { FcrPlatform, FcrReturnCode, FcrUserRole, FcrUserRoleToStringMap, FcrVideoSourceType } from '../../type';
31
+ import { generateFcrCoreClientError, generateFcrCoreServerError, handleRequestError } from '../../utilities/error';
32
+ import { createLogger, generateLogObserver } from '../../utilities/logger';
33
+ import { clearAnnotationBoardOptions, clearWhiteboardOptions, setAnnotationBoardOptions, setWhiteboardOptions } from '../../utilities/shared-storage';
34
+ import validateParams from '../../utilities/validate-params';
35
+ import { FcrGroupControl } from '../group-control';
36
+ import { FcrInterpreterControlImpl } from '../interpreter-control';
37
+ import { FcrRoomType } from '../type';
38
+ import { getAnnotationConfigFromRoomProperties } from '../whiteboard-control-v2/utils';
39
+ import { hasAnnotationWritePermission, hasBoardWritePermission } from '../whiteboard-control/utils';
40
+ const {
41
+ shared: sharedScheduler,
42
+ Duration
43
+ } = AgoraScheduler;
44
+ /**
45
+ * @internal
46
+ */
47
+ export class FcrMainRoomControlImpl extends FcrBaseRoomControlImpl {
48
+ static {
49
+ [_initProto] = _applyDecs(this, [[trace, 2, "join"], [trace, 2, "leave"], [_enableWaitingRoomDecs, 2, "enableWaitingRoom"], [_moveToWaitingRoomByUserIdsDecs, 2, "moveToWaitingRoomByUserIds"], [trace, 2, "moveToWaitingRoomByUserRoles"], [bound, 2, "_onLocalUserPermissionInfoAdded"], [bound, 2, "_onLocalUserPermissionInfoDeleted"]], [], 0, void 0, FcrBaseRoomControlImpl).e;
50
+ }
51
+ //@internal
52
+ [(_enableWaitingRoomDecs = [trace(['enable']), validateParams(booleanSchema)], _moveToWaitingRoomByUserIdsDecs = [trace(['userIds']), validateParams(stringArraySchema)], "logger")] = (_initProto(this), createLogger({
53
+ prefix: 'FcrMainRoomControlImpl'
54
+ }));
55
+ _privilegeObserver = {
56
+ onLocalUserPermissionInfoAdded: this._onLocalUserPermissionInfoAdded,
57
+ onLocalUserPermissionInfoDeleted: this._onLocalUserPermissionInfoDeleted
58
+ };
59
+ constructor(engine, scene, api, config, sharedCache, chatConnection, chatRoomControl) {
60
+ super(engine, scene, api, config, FcrRoomType.Mainroom, chatConnection, sharedCache, chatRoomControl);
61
+ this._groupControl = new FcrGroupControl(engine, scene, api, sharedCache);
62
+ this._interpreterControl = new FcrInterpreterControlImpl(api, scene, config, engine, chatConnection, sharedCache);
63
+ this._addLogObserver();
64
+ this._scene.addObserver({
65
+ onScenePropertiesUpdated: (sceneId, event) => {
66
+ const annotationBoardAppId = get(event.changedProperties, 'widgets.annotation.extra.boardAppId');
67
+ if (annotationBoardAppId) {
68
+ this.logger.info('widgets.annotation.extra.boardAppId updated, re-initializing annotation info');
69
+ this._initAnnotationInfo();
70
+ }
71
+ const whiteboardBoardAppId = get(event.changedProperties, 'widgets.netlessBoard.extra.boardAppId');
72
+ if (whiteboardBoardAppId) {
73
+ this.logger.info('widgets.netlessBoard.extra.boardAppId updated, re-initializing whiteboard info');
74
+ this._initBoardInfo();
75
+ }
76
+ },
77
+ onJoinSceneSuccess: () => {
78
+ this.logger.info('join scene success, re-initializing annotation and whiteboard info');
79
+ this._initAnnotationInfo();
80
+ this._initBoardInfo();
81
+ }
82
+ });
83
+ this.logger.info(`initialized, room id: ${this._scene.sceneId}`);
84
+ }
85
+
86
+ // @trace
87
+ getInterpreterControl() {
88
+ return this._interpreterControl;
89
+ }
90
+
91
+ // @trace
92
+ getGroupControl() {
93
+ return this._groupControl;
94
+ }
95
+ async join(options) {
96
+ try {
97
+ clearAnnotationBoardOptions();
98
+ clearWhiteboardOptions();
99
+ await super.join(options);
100
+ const privilegeControl = this.getPrivilegeControl();
101
+ privilegeControl.addObserver(this._privilegeObserver);
102
+ const task = sharedScheduler.addIntervalTask(() => {
103
+ this._engine.getMonitor().uploadLog({
104
+ userUuid: this._config.userId,
105
+ roomUuid: this._scene.sceneId
106
+ });
107
+ }, Duration.minute(5), false);
108
+ this._logUploadTask = task;
109
+ return FcrReturnCode.SUCCESS;
110
+ } finally {
111
+ this._engine.getMonitor().uploadLog({
112
+ userUuid: this._config.userId,
113
+ roomUuid: this._scene.sceneId
114
+ });
115
+ }
116
+ }
117
+ async leave() {
118
+ try {
119
+ const privilegeControl = this.getPrivilegeControl();
120
+ privilegeControl.removeObserver(this._privilegeObserver);
121
+ return await super.leave();
122
+ } finally {
123
+ this._logUploadTask?.stop();
124
+ this._engine.getMonitor().uploadLog({
125
+ userUuid: this._config.userId,
126
+ roomUuid: this._scene.sceneId
127
+ });
128
+ }
129
+ }
130
+ addObserver(observer) {
131
+ super.addObserver(observer);
132
+ }
133
+ removeObserver(observer) {
134
+ super.removeObserver(observer);
135
+ }
136
+ async enableWaitingRoom(enable) {
137
+ return handleRequestError(() => this._api.enableWaitingRoom({
138
+ enable,
139
+ roomId: this._scene.sceneId
140
+ }), ErrorModuleCode.FCR_ROOM, 'enable waiting room failed');
141
+ }
142
+ async moveToWaitingRoomByUserIds(userIds) {
143
+ const [error] = await to(this._api.moveToWaitingRoomByUserIds(userIds, this._scene.sceneId));
144
+ if (error) {
145
+ this.logger.error(`[RoomControl] move to waiting room failed, ${error.message}-${JSON.stringify(error)}`);
146
+ if (error instanceof AgoraRestfulClientError) {
147
+ throw generateFcrCoreServerError(error.serviceCode ?? -1, error.message, error);
148
+ }
149
+ throw generateFcrCoreClientError(ErrorModuleCode.FCR_ROOM, DetailErrorCode.UNDEFINED_ERROR, 'move to waiting room failed', error);
150
+ }
151
+ return FcrReturnCode.SUCCESS;
152
+ }
153
+ async moveToWaitingRoomByUserRoles() {
154
+ return this._api.moveToWaitingRoomByUserRoles([FcrUserRoleToStringMap[FcrUserRole.PARTICIPANT]], this._scene.sceneId);
155
+ }
156
+ async _initAnnotationInfo() {
157
+ const roomId = this._scene.sceneId;
158
+ const userId = this._scene.localUser.getLocalUserId();
159
+ const boardOptions = (await this._getToken(roomId, userId)).data;
160
+ if (!boardOptions) {
161
+ this.logger.error(`get annotation board options failed, roomId: ${roomId}, userId: ${userId}, boardOptions: ${jsonstring(boardOptions)}`);
162
+ } else {
163
+ this.logger.info(`get annotation board options success, roomId: ${roomId}, userId: ${userId}, boardOptions: ${jsonstring(boardOptions)}`);
164
+ setAnnotationBoardOptions(boardOptions);
165
+ }
166
+ }
167
+ async _initBoardInfo() {
168
+ const roomId = this._scene.sceneId;
169
+ const userId = this._scene.localUser.getLocalUserId();
170
+ const boardOptions = (await this._getBoardToken(roomId, userId)).data;
171
+ if (!boardOptions) {
172
+ this.logger.error(`get whiteboard options failed, roomId: ${roomId}, userId: ${userId}, boardOptions: ${jsonstring(boardOptions)}`);
173
+ } else {
174
+ this.logger.info(`get whiteboard options success, roomId: ${roomId}, userId: ${userId}, boardOptions: ${jsonstring(boardOptions)}`);
175
+ setWhiteboardOptions(boardOptions);
176
+ }
177
+ }
178
+ async _getToken(roomId, userId) {
179
+ return await handleRequestError(() => this._api.getAnnotationToken({
180
+ roomId,
181
+ userId
182
+ }), ErrorModuleCode.FCR_ROOM_WHITEBOARD, 'get whiteboard token failed');
183
+ }
184
+ async _getBoardToken(roomId, userId) {
185
+ return await handleRequestError(() => this._api.getWhiteboardToken({
186
+ roomId,
187
+ userId
188
+ }), ErrorModuleCode.FCR_ROOM_WHITEBOARD, 'get whiteboard token failed');
189
+ }
190
+ _onLocalUserPermissionInfoAdded(roomId, event) {
191
+ if (hasBoardWritePermission(event.permissionInfo)) {
192
+ this.logger.info(`add board write permission`);
193
+ this.getSharingControl().getBoardControl().setOperationPrivilege(true);
194
+ }
195
+ if (hasAnnotationWritePermission(event.permissionInfo)) {
196
+ this.logger.info(`add annotation write permission`);
197
+ this.getSharingControl().getAnnotationControl().setOperationPrivilege(true);
198
+ }
199
+ }
200
+ _onLocalUserPermissionInfoDeleted(roomId, event) {
201
+ if (hasBoardWritePermission(event.permissionInfo)) {
202
+ this.logger.info(`remove board write permission`);
203
+ this.getSharingControl().getBoardControl().setOperationPrivilege(false);
204
+ }
205
+ if (hasAnnotationWritePermission(event.permissionInfo)) {
206
+ this.logger.info(`remove annotation write permission`);
207
+ this.getSharingControl().getAnnotationControl().setOperationPrivilege(false);
208
+ }
209
+ }
210
+ _checkIfUpdateAnnotationMainWindow() {
211
+ const streamControl = this.getStreamControl();
212
+ const userControl = this.getUserControl();
213
+ const mainWindow = this.getSharingControl().getAnnotationControl().getMainWindow();
214
+ const annotationConfig = getAnnotationConfigFromRoomProperties(this._scene.getSceneProperties(), this.logger);
215
+ if (mainWindow) {
216
+ const stream = streamControl.getStreamList().find(stream => stream.videoSourceType === FcrVideoSourceType.SCREEN);
217
+ const localUserId = userControl.getLocalUser().userId;
218
+ if (stream) {
219
+ const ownerId = stream.owner.userId;
220
+ const isNotMeSharing = ownerId !== localUserId;
221
+ const platform = userControl.getUser(ownerId)?.platform;
222
+ const isPcPlatform = platform && [FcrPlatform.WEB_DESKTOP, FcrPlatform.WINDOWS, FcrPlatform.MACOS].includes(platform);
223
+ const isAndroidPlatform = platform && platform === FcrPlatform.ANDROID;
224
+ this.logger.info(`check if set auto cancel draw, isPcPlatform: ${isPcPlatform}, isAndroidPlatform: ${isAndroidPlatform}, isNotMeSharing: ${isNotMeSharing}, ownerId: ${ownerId}, localUserId: ${localUserId}, platform: ${platform}`);
225
+ if (isPcPlatform) {
226
+ mainWindow.setAutoCancelDraw(false);
227
+ }
228
+ if (isAndroidPlatform) {
229
+ mainWindow.setAutoCancelDraw(isNotMeSharing);
230
+ }
231
+ if (!isNotMeSharing) {
232
+ mainWindow.clean();
233
+ mainWindow.updateWindowSize({
234
+ width: annotationConfig.size.width,
235
+ height: annotationConfig.size.height
236
+ });
237
+ this._api.syncScreenShareOwnerAnnotationOpenDone(this._scene.sceneId);
238
+ }
239
+ }
240
+ }
241
+ }
242
+ _addLogObserver() {
243
+ this.addObserver(generateLogObserver(this.logger, [['onCloudRecordingStateUpdated', ['roomId', 'state']], ['onJoinRoomFailure', ['roomId', 'error']], ['onJoinRoomSuccess', ['roomId']], ['onLiveStreamingStateUpdated', ['roomId', 'state', 'url', 'reason']],
244
+ // 'onNetworkQualityUpdated',
245
+ // 'onNetworkStatsUpdated',
246
+ ['onRoomMessageReceived', ['roomId', 'message']], ['onRoomPropertiesDeleted', ['roomId', 'event']], ['onRoomPropertiesUpdated', ['roomId', 'event']], ['onRoomStateUpdated', ['roomId', 'state']]]));
247
+ }
248
+ }
@@ -0,0 +1,97 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.find.js";
3
+ import "core-js/modules/esnext.iterator.map.js";
4
+ // 初始化权限策略表达式:{module}:{action}-{k1=v1|v2;k2=v3}>{role1|role2}
5
+ // {module}表示模块,如房间模块room、用户模块user、发流模块stream等。
6
+ // {action}表示操作,如结束房间、静音、开启视频等。
7
+ // {k1=v1|v2;k2=v3}表示操作的个性化入参,如设置成联席主持人权限,user:setRole-role=host|co-host,入参为role=host|co-host,相同key用|隔开,多个key用;隔开。
8
+ // {role1|role2}表示操作对象所属的角色,对象可以是多个,中间用|隔开,如要表示对participant和co-host拥有静音的权限,stream:muteAudio>participant|co-host
9
+ // 如果操作对象的类型是用户,则需要指定目标角色;如果操作对象的类型是房间,则不需要指定目标角色。
10
+ // 为简化表达式,*表示所有,~表示自己(要不要给这种简便的表达式?前端是否不好识别,但如果没有,配置是否有点复杂)
11
+ // 举例:
12
+ // stream:muteAudio>~ ,表示可以对自己静音,stream:muteAudio>participant,表示对观众禁音
13
+ // user:kickout>* ,表示可以踢所有角色
14
+ // record:* ,表示有录制模块下所有操作
15
+ // *:*>*,表示拥有对房间最大权限
16
+ // {action}分为两类:操作权限和可赋予的操作权限,可赋予的操作权限又分为授权和取消授权
17
+
18
+ import { FcrOperatePermissionType } from './type';
19
+ import { checkFcrUserRole, convertRteUserToFcrUser, convertStringPrivilegeRoleToFcrPrivilegeRole } from '../../utilities/user';
20
+ export class FcrPermission {
21
+ constructor(module, action, conditions, targetRoles) {
22
+ this.module = module;
23
+ this.action = action;
24
+ this.conditions = conditions;
25
+ this.targetRoles = targetRoles;
26
+ }
27
+ static fromString(permission) {
28
+ const [moduleActionParams, roles] = permission.split('>');
29
+ const [moduleAction, params] = moduleActionParams.split('-');
30
+ const [module, action] = moduleAction.split(':');
31
+ const paramsObj = {};
32
+ if (params) {
33
+ for (const param of params.split(';')) {
34
+ const [key, values] = param.split('=');
35
+ paramsObj[key] = values.split('|');
36
+ }
37
+ }
38
+ return new FcrPermission(module, action, paramsObj, roles ? roles.split('|') : []);
39
+ }
40
+ }
41
+ export const getLocalUserPermissionInfo = (scene, action) => {
42
+ const permissionStringArray = scene.getUserPropertiesByKeyPath(`permission.list`, scene.localUser.getLocalUserId());
43
+ const permissionString = permissionStringArray.find(permission => permission.startsWith(action));
44
+ if (!permissionString) {
45
+ return {
46
+ enable: false
47
+ };
48
+ }
49
+ return convertPermissionInfo(FcrPermission.fromString(permissionString), FcrOperatePermissionType.GET);
50
+ };
51
+ const convertPermissionInfo = (permission, operateType) => {
52
+ if (!permission) {
53
+ return {
54
+ enable: false
55
+ };
56
+ }
57
+ const {
58
+ module,
59
+ action
60
+ } = permission;
61
+ const permissionInfo = {
62
+ enable: operateType === FcrOperatePermissionType.ADD || operateType === FcrOperatePermissionType.GET ? true : false,
63
+ info: {
64
+ targetRoles: permission.targetRoles.map(role => convertStringPrivilegeRoleToFcrPrivilegeRole(role)),
65
+ action: `${module}:${action}`,
66
+ params: permission.conditions
67
+ }
68
+ };
69
+ return permissionInfo;
70
+ };
71
+ export const addLocalUserPermissionObserver = (scene, observer, cache) => {
72
+ scene.addObserver({
73
+ onUserPropertiesUpdated: (sceneId, event) => {
74
+ if (event.cause?.cmd === 3200) {
75
+ if (event.modifiedUser.userId === scene.localUser.getLocalUserId()) {
76
+ const data = event.cause.data;
77
+ const addedPermissions = data.addPermissions?.map(p => convertPermissionInfo(FcrPermission.fromString(p), FcrOperatePermissionType.ADD));
78
+ const removedPermissions = data.removePermissions?.map(p => convertPermissionInfo(FcrPermission.fromString(p), FcrOperatePermissionType.DELETE));
79
+ if (removedPermissions && removedPermissions.length > 0) {
80
+ observer.onLocalUserPermissionInfoDeleted && observer.onLocalUserPermissionInfoDeleted(sceneId, {
81
+ permissionInfo: removedPermissions,
82
+ operatorUser: checkFcrUserRole(convertRteUserToFcrUser(event.operatorUser, cache)),
83
+ cause: event.cause
84
+ });
85
+ }
86
+ if (addedPermissions && addedPermissions.length > 0) {
87
+ observer.onLocalUserPermissionInfoAdded && observer.onLocalUserPermissionInfoAdded(sceneId, {
88
+ permissionInfo: addedPermissions,
89
+ operatorUser: checkFcrUserRole(convertRteUserToFcrUser(event.operatorUser, cache)),
90
+ cause: event.cause
91
+ });
92
+ }
93
+ }
94
+ }
95
+ }
96
+ });
97
+ };