fcr-core 3.7.8 → 3.7.9-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 (50) hide show
  1. package/lib/chat-connection/index.js +26 -41
  2. package/lib/engine/index.js +74 -67
  3. package/lib/imports.js +0 -1
  4. package/lib/media-control/desktop.js +13 -18
  5. package/lib/media-control/mobile.js +13 -18
  6. package/lib/monitor-control/index.js +5 -10
  7. package/lib/peer-session/index.js +39 -48
  8. package/lib/plugins/chatroom.js +202 -218
  9. package/lib/room-control/ability-control/index.js +9 -14
  10. package/lib/room-control/group-control/index.js +16 -21
  11. package/lib/room-control/helpers/validation-helper.js +1 -1
  12. package/lib/room-control/index.js +36 -53
  13. package/lib/room-control/interpreter-control/index.js +34 -47
  14. package/lib/room-control/interpreter-control/room.js +4 -6
  15. package/lib/room-control/join-before-host-waitingroom-control/index.js +4 -6
  16. package/lib/room-control/mainroom-control/index.js +17 -25
  17. package/lib/room-control/privilege-control/helper.js +5 -8
  18. package/lib/room-control/privilege-control/index.js +19 -26
  19. package/lib/room-control/room-connector-control/index.js +19 -28
  20. package/lib/room-control/room-control-factory.js +1 -2
  21. package/lib/room-control/room-session/index.js +39 -48
  22. package/lib/room-control/shared-cache.js +29 -36
  23. package/lib/room-control/sharing-control/index.js +32 -40
  24. package/lib/room-control/stream-control/index.js +173 -181
  25. package/lib/room-control/user-control/index.js +136 -143
  26. package/lib/room-control/waitingroom-control/index.js +9 -14
  27. package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +24 -32
  28. package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +16 -27
  29. package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +53 -63
  30. package/lib/room-control/whiteboard-control-v2/index.js +28 -40
  31. package/lib/room-control/whiteboard-control-v2/main-window.js +23 -28
  32. package/lib/room-control/whiteboard-control-v2/utils.js +6 -7
  33. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +27 -38
  34. package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +3 -5
  35. package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +42 -54
  36. package/lib/room-router/index.js +42 -52
  37. package/lib/service/api.js +207 -231
  38. package/lib/utilities/collection.js +2 -3
  39. package/lib/utilities/error-helpers.js +27 -34
  40. package/lib/utilities/error.js +8 -9
  41. package/lib/utilities/join-helper.js +25 -32
  42. package/lib/utilities/logger.js +3 -6
  43. package/lib/utilities/parameters.js +4 -8
  44. package/lib/utilities/retry-helpers.js +0 -1
  45. package/lib/utilities/shared-storage.js +0 -1
  46. package/lib/utilities/storage.js +0 -1
  47. package/lib/utilities/stream.js +11 -16
  48. package/lib/utilities/user.js +3 -4
  49. package/lib/utilities/validate-params.js +1 -2
  50. package/package.json +4 -4
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.description.js");
4
3
  require("core-js/modules/es.array.push.js");
5
4
  require("core-js/modules/esnext.function.metadata.js");
6
- require("core-js/modules/esnext.iterator.constructor.js");
7
- require("core-js/modules/esnext.iterator.filter.js");
8
- require("core-js/modules/esnext.iterator.for-each.js");
9
5
  require("core-js/modules/esnext.map.delete-all.js");
10
6
  require("core-js/modules/esnext.map.emplace.js");
11
7
  require("core-js/modules/esnext.map.every.js");
@@ -26,10 +22,6 @@ Object.defineProperty(exports, "__esModule", {
26
22
  value: true
27
23
  });
28
24
  exports.FcrRoomRouterImpl = void 0;
29
- require("core-js/modules/es.error.cause.js");
30
- require("core-js/modules/es.regexp.exec.js");
31
- require("core-js/modules/web.dom-collections.iterator.js");
32
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
33
25
  var _imports = require("../imports");
34
26
  var _roomControlFactory = require("../room-control/room-control-factory");
35
27
  var _type = require("../room-control/type");
@@ -40,10 +32,7 @@ var _retryHelpers = require("../utilities/retry-helpers");
40
32
  var _logger = require("../utilities/logger");
41
33
  var _validateParams = _interopRequireDefault(require("../utilities/validate-params"));
42
34
  var _type2 = require("./type");
43
- var _FcrRoomRouterImpl;
44
- let _initProto, _initDecs, _joinRoomDecs, _ref;
45
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
46
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
35
+ let _initProto, _initDecs, _joinRoomDecs;
47
36
  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)]; } }; }
48
37
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
49
38
  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); }
@@ -52,30 +41,34 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
52
41
  /**
53
42
  * @internal
54
43
  */
55
- _ref = (_initDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _joinRoomDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrRoomJoinOptionsSchema)], "logger");
44
+
56
45
  class FcrRoomRouterImpl {
46
+ static {
47
+ [_initProto] = _applyDecs(this, [[_initDecs, 2, "_init"], [_joinRoomDecs, 2, "joinRoom"], [_imports.trace, 2, "leaveRoom"]], []).e;
48
+ }
49
+ [(_initDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _joinRoomDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrRoomJoinOptionsSchema)], "logger")] = (_initProto(this), (0, _logger.createLogger)({
50
+ prefix: 'FcrRoomRouterImpl'
51
+ }));
52
+ _abortController = null;
53
+ _observable = new _imports.AgoraObservable();
54
+ _roomControlObservable = {
55
+ onRoomRouteSwitched: async event => {
56
+ this._nextRoomRoute = event.targetRouting;
57
+ this._observable.notifyObservers('onRoomRouteSwitched', this._nextRoomRoute);
58
+ this.roomControl.removeObserver(this._roomControlObservable);
59
+ this._roomControl = null;
60
+ }
61
+ };
62
+ _roomControl = null;
63
+ _nextRoomRoute = {
64
+ roomId: '',
65
+ roomType: _type.FcrRoomType.Mainroom,
66
+ isJoined: false
67
+ };
68
+
69
+ // 接口中新增一个bypass字段,在第一次调用joinRoom的时候不传,在后续收到房间切换后的joinRoom时传true
70
+ _bypass = undefined;
57
71
  constructor(_rteEngine, _apiService, _config, _chatConnection, _sharedCache, roomId) {
58
- (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
59
- prefix: 'FcrRoomRouterImpl'
60
- })));
61
- (0, _defineProperty2.default)(this, "_abortController", null);
62
- (0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
63
- (0, _defineProperty2.default)(this, "_roomControlObservable", {
64
- onRoomRouteSwitched: async event => {
65
- this._nextRoomRoute = event.targetRouting;
66
- this._observable.notifyObservers('onRoomRouteSwitched', this._nextRoomRoute);
67
- this.roomControl.removeObserver(this._roomControlObservable);
68
- this._roomControl = null;
69
- }
70
- });
71
- (0, _defineProperty2.default)(this, "_roomControl", null);
72
- (0, _defineProperty2.default)(this, "_nextRoomRoute", {
73
- roomId: '',
74
- roomType: _type.FcrRoomType.Mainroom,
75
- isJoined: false
76
- });
77
- // 接口中新增一个bypass字段,在第一次调用joinRoom的时候不传,在后续收到房间切换后的joinRoom时传true
78
- (0, _defineProperty2.default)(this, "_bypass", undefined);
79
72
  this._rteEngine = _rteEngine;
80
73
  this._apiService = _apiService;
81
74
  this._config = _config;
@@ -108,10 +101,9 @@ class FcrRoomRouterImpl {
108
101
  }
109
102
  }
110
103
  async leaveRoom() {
111
- var _this$_abortControlle, _this$_roomControl;
112
- (_this$_abortControlle = this._abortController) === null || _this$_abortControlle === void 0 || _this$_abortControlle.abort();
104
+ this._abortController?.abort();
113
105
  this._abortController = null;
114
- (_this$_roomControl = this._roomControl) === null || _this$_roomControl === void 0 || _this$_roomControl.leave();
106
+ this._roomControl?.leave();
115
107
  this._roomControl = null;
116
108
  }
117
109
 
@@ -133,12 +125,11 @@ class FcrRoomRouterImpl {
133
125
  const abortController = this._abortController;
134
126
  return (0, _imports.retryAttempt)(() => this._performSingleJoinAttempt(options), [], {
135
127
  retriesMax: _type2.ROOM_ROUTER_CONSTANTS.MAX_JOIN_ATTEMPTS
136
- }).fail(async _ref2 => {
137
- let {
138
- error,
139
- timeFn: waitBeforeRetry,
140
- currentRetry: attemptCount
141
- } = _ref2;
128
+ }).fail(async ({
129
+ error,
130
+ timeFn: waitBeforeRetry,
131
+ currentRetry: attemptCount
132
+ }) => {
142
133
  return (0, _joinHelper.handleJoinRetryFailure)(error, waitBeforeRetry, attemptCount, _retryHelpers.canRetryJoinError, () => {
143
134
  this._throwIfAborted(abortController);
144
135
  }, 'join room via router');
@@ -191,14 +182,15 @@ class FcrRoomRouterImpl {
191
182
  } = roomResponse;
192
183
  const abortController = this._abortController;
193
184
  const roomControl = this._createRoomControl(data);
194
- abortController === null || abortController === void 0 || abortController.signal.addEventListener('abort', () => {
185
+ abortController?.signal.addEventListener('abort', () => {
195
186
  roomControl.leave();
196
187
  });
197
- await roomControl.join(_objectSpread(_objectSpread({}, options), {}, {
188
+ await roomControl.join({
189
+ ...options,
198
190
  snapshot: data,
199
191
  timestamp: ts,
200
192
  createStreamConfigs: options.createStreamConfigs
201
- }));
193
+ });
202
194
  return roomControl;
203
195
  }
204
196
 
@@ -226,8 +218,8 @@ class FcrRoomRouterImpl {
226
218
  * @private
227
219
  */
228
220
  _handleJoinRoomError(error) {
229
- this.logger.error("Failed to join the room: ".concat(error.message));
230
- const fcrError = (0, _error.generateFcrCoreClientErrorNew)(_error.FcrErrorModuleCode.ROOM, _error.FcrErrorCode.LOCAL_HTTP_REQUEST_FAILED, "join room failed: ".concat(error.message));
221
+ this.logger.error(`Failed to join the room: ${error.message}`);
222
+ const fcrError = (0, _error.generateFcrCoreClientErrorNew)(_error.FcrErrorModuleCode.ROOM, _error.FcrErrorCode.LOCAL_HTTP_REQUEST_FAILED, `join room failed: ${error.message}`);
231
223
  this._observable.notifyObservers('onErrorOccurred', fcrError);
232
224
  }
233
225
 
@@ -252,7 +244,7 @@ class FcrRoomRouterImpl {
252
244
  });
253
245
  }
254
246
  _throwIfAborted(abortController) {
255
- if (abortController !== null && abortController !== void 0 && abortController.signal.aborted) {
247
+ if (abortController?.signal.aborted) {
256
248
  throw new Error('Join room attempt aborted');
257
249
  }
258
250
  }
@@ -263,6 +255,4 @@ class FcrRoomRouterImpl {
263
255
  this._observable.removeObserver(observer);
264
256
  }
265
257
  }
266
- exports.FcrRoomRouterImpl = FcrRoomRouterImpl;
267
- _FcrRoomRouterImpl = FcrRoomRouterImpl;
268
- [_initProto] = _applyDecs(_FcrRoomRouterImpl, [[_initDecs, 2, "_init"], [_joinRoomDecs, 2, "joinRoom"], [_imports.trace, 2, "leaveRoom"]], []).e;
258
+ exports.FcrRoomRouterImpl = FcrRoomRouterImpl;