fcr-core 3.8.0-alpha → 3.8.1-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 (60) hide show
  1. package/lib/chat-connection/index.js +26 -40
  2. package/lib/engine/index.js +72 -66
  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 -47
  8. package/lib/plugins/chatroom.js +213 -229
  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 +27 -35
  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 -46
  22. package/lib/room-control/shared-cache.js +29 -36
  23. package/lib/room-control/sharing-control/index.d.ts +1 -1
  24. package/lib/room-control/sharing-control/index.js +34 -42
  25. package/lib/room-control/stream-control/index.js +191 -195
  26. package/lib/room-control/stream-control/type.d.ts +1 -1
  27. package/lib/room-control/stt-control/de-compress-gzip.js +0 -10
  28. package/lib/room-control/stt-control/index.js +95 -98
  29. package/lib/room-control/stt-control/type.d.ts +1 -1
  30. package/lib/room-control/user-control/index.js +136 -143
  31. package/lib/room-control/waitingroom-control/index.js +9 -14
  32. package/lib/room-control/whiteboard-control/utils.js +2 -4
  33. package/lib/room-control/whiteboard-control-v1/board-subwindow.js +1 -2
  34. package/lib/room-control/whiteboard-control-v1/board-window.js +88 -99
  35. package/lib/room-control/whiteboard-control-v1/factory.js +4 -7
  36. package/lib/room-control/whiteboard-control-v1/index.js +28 -40
  37. package/lib/room-control/whiteboard-control-v1/mount-manager.js +2 -4
  38. package/lib/room-control/whiteboard-control-v1/utils.js +14 -17
  39. package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +4 -6
  40. package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +5 -10
  41. package/lib/room-control/whiteboard-control-v2/base/index.js +34 -41
  42. package/lib/room-control/whiteboard-control-v2/base/main-window.js +24 -29
  43. package/lib/room-control/whiteboard-control-v2/utils.js +6 -7
  44. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +0 -1
  45. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +23 -34
  46. package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +7 -14
  47. package/lib/room-router/index.js +47 -53
  48. package/lib/room-router/type.d.ts +2 -2
  49. package/lib/service/api.js +227 -250
  50. package/lib/utilities/collection.js +2 -3
  51. package/lib/utilities/error-helpers.js +27 -34
  52. package/lib/utilities/error.js +8 -9
  53. package/lib/utilities/join-helper.js +25 -32
  54. package/lib/utilities/logger.js +3 -6
  55. package/lib/utilities/parameters.js +4 -8
  56. package/lib/utilities/retry-helpers.js +0 -1
  57. package/lib/utilities/stream.js +11 -16
  58. package/lib/utilities/user.js +3 -4
  59. package/lib/utilities/validate-params.js +1 -2
  60. package/package.json +5 -6
@@ -1,18 +1,13 @@
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.symbol.metadata.js");
10
6
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
11
7
  Object.defineProperty(exports, "__esModule", {
12
8
  value: true
13
9
  });
14
10
  exports.FcrPeerSessionControlImpl = void 0;
15
- require("core-js/modules/es.error.cause.js");
16
11
  require("core-js/modules/es.json.stringify.js");
17
12
  require("core-js/modules/esnext.map.delete-all.js");
18
13
  require("core-js/modules/esnext.map.emplace.js");
@@ -28,17 +23,12 @@ require("core-js/modules/esnext.map.merge.js");
28
23
  require("core-js/modules/esnext.map.reduce.js");
29
24
  require("core-js/modules/esnext.map.some.js");
30
25
  require("core-js/modules/esnext.map.update.js");
31
- require("core-js/modules/web.dom-collections.iterator.js");
32
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
33
26
  var _imports = require("../imports");
34
27
  var _error = require("../utilities/error");
35
28
  var _logger = require("../utilities/logger");
36
29
  var _schema = require("../schema");
37
30
  var _validateParams = _interopRequireDefault(require("../utilities/validate-params"));
38
- var _FcrPeerSessionControlImpl;
39
- let _initProto, _startPeerSessionDecs, _stopPeerSessionDecs, _acceptPeerSessionDecs, _rejectPeerSessionDecs, _ref;
40
- 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; }
41
- 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; }
31
+ let _initProto, _startPeerSessionDecs, _stopPeerSessionDecs, _acceptPeerSessionDecs, _rejectPeerSessionDecs;
42
32
  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)]; } }; }
43
33
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
44
34
  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); }
@@ -47,21 +37,25 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
47
37
  /**
48
38
  * @internal
49
39
  */
50
- _ref = (_startPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrPeerSessionParamsSchema)], _stopPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _acceptPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrSessionBaseSchema, _schema.stringKeyUnknownValueSchema.optional())], _rejectPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrSessionBaseSchema, _schema.stringKeyUnknownValueSchema.optional())], "logger");
51
40
  class FcrPeerSessionControlImpl {
41
+ static {
42
+ [_initProto] = _applyDecs(this, [[_startPeerSessionDecs, 2, "startPeerSession"], [_stopPeerSessionDecs, 2, "stopPeerSession"], [_acceptPeerSessionDecs, 2, "acceptPeerSession"], [_rejectPeerSessionDecs, 2, "rejectPeerSession"]], []).e;
43
+ }
44
+ //@internal
45
+ [(_startPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrPeerSessionParamsSchema)], _stopPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _acceptPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrSessionBaseSchema, _schema.stringKeyUnknownValueSchema.optional())], _rejectPeerSessionDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrSessionBaseSchema, _schema.stringKeyUnknownValueSchema.optional())], "logger")] = (_initProto(this), (0, _logger.createLogger)({
46
+ prefix: 'FcrPeerSessionControlImpl'
47
+ }));
48
+ //@internal
49
+ _observable = new _imports.AgoraObservable();
50
+ //@internal
51
+ _taskInterval = _imports.Duration.second(1);
52
+ //@internal
53
+
54
+ //@internal
55
+ _scheduleMap = new Map();
56
+ //@internal
57
+ _receivedMap = new Map();
52
58
  constructor(_rteEngine, _api, _userId) {
53
- //@internal
54
- (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
55
- prefix: 'FcrPeerSessionControlImpl'
56
- })));
57
- //@internal
58
- (0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
59
- //@internal
60
- (0, _defineProperty2.default)(this, "_taskInterval", _imports.Duration.second(1));
61
- //@internal
62
- (0, _defineProperty2.default)(this, "_scheduleMap", new Map());
63
- //@internal
64
- (0, _defineProperty2.default)(this, "_receivedMap", new Map());
65
59
  this._rteEngine = _rteEngine;
66
60
  this._api = _api;
67
61
  this._userId = _userId;
@@ -75,7 +69,7 @@ class FcrPeerSessionControlImpl {
75
69
  async startPeerSession(params) {
76
70
  try {
77
71
  const session = {
78
- sessionId: (0, _imports.md5)("".concat(Date.now())),
72
+ sessionId: (0, _imports.md5)(`${Date.now()}`),
79
73
  sessionKey: params.sessionKey,
80
74
  payload: params.payload,
81
75
  duration: params.duration,
@@ -94,11 +88,12 @@ class FcrPeerSessionControlImpl {
94
88
  targetId: params.receiverId
95
89
  });
96
90
  const nextTs = Date.now() + interval;
97
- this._scheduleMap.set(session.sessionId, _objectSpread(_objectSpread({}, params), {}, {
91
+ this._scheduleMap.set(session.sessionId, {
92
+ ...params,
98
93
  nextTs,
99
94
  startTs: Date.now()
100
- }));
101
- this.logger.info("[PeerSession] put into session schedule: ".concat(session.sessionId, ", next ts: ").concat(nextTs, ", remain: ").concat(nextTs - Date.now(), "ms"));
95
+ });
96
+ this.logger.info(`[PeerSession] put into session schedule: ${session.sessionId}, next ts: ${nextTs}, remain: ${nextTs - Date.now()}ms`);
102
97
  return session.sessionId;
103
98
  } catch (e) {
104
99
  throw (0, _error.generateFcrCoreServerError)(_error.FcrErrorCode.LOCAL_HTTP_REQUEST_FAILED, 'start peer session failed', e);
@@ -167,13 +162,13 @@ class FcrPeerSessionControlImpl {
167
162
  interval: 0
168
163
  };
169
164
  if (this._isSessionExpired(session)) {
170
- this.logger.info("[PeerSession] peer session expired, removed: ".concat(session.sessionId));
165
+ this.logger.info(`[PeerSession] peer session expired, removed: ${session.sessionId}`);
171
166
  this._scheduleMap.delete(session.sessionId);
172
167
  continue;
173
168
  }
174
169
  // check timeout
175
170
  if (params.nextTs < Date.now()) {
176
- this.logger.info("[PeerSession] ping session: ".concat(session.sessionId));
171
+ this.logger.info(`[PeerSession] ping session: ${session.sessionId}`);
177
172
  try {
178
173
  const {
179
174
  data: {
@@ -189,13 +184,14 @@ class FcrPeerSessionControlImpl {
189
184
  });
190
185
  const nextTs = Date.now() + interval;
191
186
  if (this._scheduleMap.has(session.sessionId)) {
192
- this._scheduleMap.set(session.sessionId, _objectSpread(_objectSpread({}, params), {}, {
187
+ this._scheduleMap.set(session.sessionId, {
188
+ ...params,
193
189
  nextTs
194
- }));
195
- this.logger.info("[PeerSession] refresh session schedule: ".concat(session.sessionId, ", next ts: ").concat(nextTs));
190
+ });
191
+ this.logger.info(`[PeerSession] refresh session schedule: ${session.sessionId}, next ts: ${nextTs}`);
196
192
  }
197
193
  } catch (e) {
198
- this.logger.error("[PeerSession] ping session failed: ".concat(e));
194
+ this.logger.error(`[PeerSession] ping session failed: ${e}`);
199
195
  }
200
196
  }
201
197
  }
@@ -204,7 +200,7 @@ class FcrPeerSessionControlImpl {
204
200
  const session = this._receivedMap.get(key);
205
201
  if (this._isSessionExpired(session)) {
206
202
  this._receivedMap.delete(key);
207
- this.logger.info("[PeerSession] delete session callback: ".concat(key));
203
+ this.logger.info(`[PeerSession] delete session callback: ${key}`);
208
204
  }
209
205
  }
210
206
  }
@@ -235,7 +231,7 @@ class FcrPeerSessionControlImpl {
235
231
  }
236
232
  if (!this._isSessionExpired(session)) {
237
233
  if (!this._receivedMap.has(session.sessionId)) {
238
- this.logger.info("[PeerSession] received peer session request ".concat(JSON.stringify(session)));
234
+ this.logger.info(`[PeerSession] received peer session request ${JSON.stringify(session)}`);
239
235
  this._observable.notifyObservers('onPeerSessionReceived', session);
240
236
  }
241
237
  this._receivedMap.set(session.sessionId, session);
@@ -243,7 +239,6 @@ class FcrPeerSessionControlImpl {
243
239
  } else if (cmd === '1002') {
244
240
  if (data.action === 1) {
245
241
  if (this._scheduleMap.has(data.sessionUuid)) {
246
- var _session$payload, _ref2, _data$payload;
247
242
  const session = this._scheduleMap.get(data.sessionUuid);
248
243
  const sessionResponse = {
249
244
  sessionId: data.sessionUuid,
@@ -251,16 +246,15 @@ class FcrPeerSessionControlImpl {
251
246
  responderId: senderId,
252
247
  // FIXME: session may be lost when the client refreshes
253
248
  // get payload from original session
254
- payload: (_session$payload = session.payload) !== null && _session$payload !== void 0 ? _session$payload : {},
255
- cause: (_ref2 = (_data$payload = data.payload) === null || _data$payload === void 0 ? void 0 : _data$payload.cause) !== null && _ref2 !== void 0 ? _ref2 : {}
249
+ payload: session.payload ?? {},
250
+ cause: data.payload?.cause ?? {}
256
251
  };
257
- this.logger.info("[PeerSession] received peer session accepted ".concat(JSON.stringify(sessionResponse)));
252
+ this.logger.info(`[PeerSession] received peer session accepted ${JSON.stringify(sessionResponse)}`);
258
253
  this._scheduleMap.delete(data.sessionUuid);
259
254
  this._observable.notifyObservers('onPeerSessionAccepted', sessionResponse);
260
255
  }
261
256
  } else if (data.action === 2) {
262
257
  if (this._scheduleMap.has(data.sessionUuid)) {
263
- var _session$payload2, _ref3, _data$payload2;
264
258
  const session = this._scheduleMap.get(data.sessionUuid);
265
259
  const sessionResponse = {
266
260
  sessionId: data.sessionUuid,
@@ -268,10 +262,10 @@ class FcrPeerSessionControlImpl {
268
262
  responderId: senderId,
269
263
  // FIXME: session may be lost when the client refreshes
270
264
  // get payload from original session
271
- payload: (_session$payload2 = session.payload) !== null && _session$payload2 !== void 0 ? _session$payload2 : {},
272
- cause: (_ref3 = (_data$payload2 = data.payload) === null || _data$payload2 === void 0 ? void 0 : _data$payload2.cause) !== null && _ref3 !== void 0 ? _ref3 : {}
265
+ payload: session.payload ?? {},
266
+ cause: data.payload?.cause ?? {}
273
267
  };
274
- this.logger.info("[PeerSession] received peer session rejected ".concat(JSON.stringify(sessionResponse)));
268
+ this.logger.info(`[PeerSession] received peer session rejected ${JSON.stringify(sessionResponse)}`);
275
269
  if (this._scheduleMap.has(data.sessionUuid)) {
276
270
  this._scheduleMap.delete(data.sessionUuid);
277
271
  this._observable.notifyObservers('onPeerSessionRejected', sessionResponse);
@@ -289,6 +283,4 @@ class FcrPeerSessionControlImpl {
289
283
  this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onPeerSessionAccepted', 'onPeerSessionReceived', 'onPeerSessionRejected']));
290
284
  }
291
285
  }
292
- exports.FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
293
- _FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
294
- [_initProto] = _applyDecs(_FcrPeerSessionControlImpl, [[_startPeerSessionDecs, 2, "startPeerSession"], [_stopPeerSessionDecs, 2, "stopPeerSession"], [_acceptPeerSessionDecs, 2, "acceptPeerSession"], [_rejectPeerSessionDecs, 2, "rejectPeerSession"]], []).e;
286
+ exports.FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;