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,9 +1,6 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.description.js");
4
- require("core-js/modules/es.error.cause.js");
5
3
  require("core-js/modules/esnext.function.metadata.js");
6
- require("core-js/modules/esnext.iterator.filter.js");
7
4
  require("core-js/modules/esnext.map.delete-all.js");
8
5
  require("core-js/modules/esnext.map.emplace.js");
9
6
  require("core-js/modules/esnext.map.every.js");
@@ -30,8 +27,6 @@ require("core-js/modules/esnext.iterator.find.js");
30
27
  require("core-js/modules/esnext.iterator.for-each.js");
31
28
  require("core-js/modules/esnext.iterator.map.js");
32
29
  require("core-js/modules/esnext.iterator.reduce.js");
33
- require("core-js/modules/web.dom-collections.iterator.js");
34
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
35
30
  var _imports = require("../../imports");
36
31
  var _type = require("../../type");
37
32
  var _user = require("../../utilities/user");
@@ -41,157 +36,159 @@ var _logger = require("../../utilities/logger");
41
36
  var _error = require("../../utilities/error");
42
37
  var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
43
38
  var _schema = require("../../schema");
44
- var _FcrUserControlImpl;
45
- let _initProto, _getUserDecs, _updateUserNameDecs, _updateUserPropertiesDecs, _updateIncrementUserPropertiesDecs, _deleteUserPropertiesDecs, _getUserPropertiesByUserIdDecs, _getUserPropertiesByKeyPathDecs, _updateRemoteUserRoleDecs, _claimHostDecs, _kickOutDecs, _kickOutByUserIdsDecs, _kickOutByUserRolesDecs, _mergeAudioStreamDecs, _ref;
46
- 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; }
47
- 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; }
39
+ let _initProto, _getUserDecs, _updateUserNameDecs, _updateUserPropertiesDecs, _updateIncrementUserPropertiesDecs, _deleteUserPropertiesDecs, _getUserPropertiesByUserIdDecs, _getUserPropertiesByKeyPathDecs, _updateRemoteUserRoleDecs, _claimHostDecs, _kickOutDecs, _kickOutByUserIdsDecs, _kickOutByUserRolesDecs, _mergeAudioStreamDecs;
48
40
  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)]; } }; }
49
41
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
50
42
  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); }
51
43
  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; }
52
44
  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; }
53
- _ref = (_getUserDecs = [_imports.bound, (0, _validateParams.default)(_schema.stringSchema)], _updateUserNameDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.stringSchema)], _updateUserPropertiesDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringKeyUnknownValueSchema, _schema.stringKeyUnknownValueSchema, _schema.stringSchema)], _updateIncrementUserPropertiesDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringKeyNumberValueSchema, _schema.stringKeyUnknownValueSchema, _schema.stringSchema)], _deleteUserPropertiesDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringArraySchema, _schema.stringKeyUnknownValueSchema, _schema.stringSchema)], _getUserPropertiesByUserIdDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _getUserPropertiesByKeyPathDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.stringSchema)], _updateRemoteUserRoleDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrUserRoleSchema)], _claimHostDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _kickOutDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrUserKickedOutTypeSchema)], _kickOutByUserIdsDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringArraySchema, _schema.fcrUserKickedOutTypeSchema)], _kickOutByUserRolesDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrUserRolesSchema, _schema.fcrUserKickedOutTypeSchema)], _mergeAudioStreamDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringSchema)], "logger");
54
45
  /**
55
46
  * @internal
56
47
  */
57
48
  class FcrUserControlImpl {
58
- constructor(_scene, _api, _sharedCache) {
59
- //@internal
60
- (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
61
- prefix: 'FcrUserControlImpl'
62
- })));
63
- //@internal
64
- (0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
65
- //@internal
66
- (0, _defineProperty2.default)(this, "_userMapByUserId", {});
67
- //@internal
68
- (0, _defineProperty2.default)(this, "_userList", []);
69
- //@internal
70
- (0, _defineProperty2.default)(this, "_sceneObserver", {
71
- onRemoteUsersJoined: (roomId, events) => {
72
- events.forEach(event => {
73
- const userProperties = this._scene.getUserPropertiesByUserId(event.userInfo.userId);
74
- this._roomCache.setUserPlatform(event.userInfo.userId, userProperties === null || userProperties === void 0 ? void 0 : userProperties.platform);
75
- this._roomCache.setUserAvatar(event.userInfo.userId, userProperties === null || userProperties === void 0 ? void 0 : userProperties.avatar);
76
- });
77
- const fcrUserEvents = events.map(e => {
78
- return {
79
- userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache),
80
- operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser, this._roomCache)
81
- };
82
- });
83
- fcrUserEvents.forEach(event => {
84
- const user = event.userInfo;
85
- const exists = user.userId in this._userMapByUserId;
86
- if (exists) {
87
- this.logger.warn("[FcrUserControl] user joined when the user already exists, userId: ".concat(user.userId));
88
- } else {
89
- this._userMapByUserId[user.userId] = user;
90
- this._userList.push(user);
91
- }
92
- });
93
- this._observable.notifyObservers('onRemoteUsersJoined', roomId, fcrUserEvents);
94
- },
95
- onRemoteUsersLeft: (roomId, events) => {
96
- const fcrUserEvents = events.map(e => {
97
- var _e$cause;
98
- return {
99
- userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache),
100
- userProperties: e.userProperties,
101
- operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser, this._roomCache),
102
- reason: ((_e$cause = e.cause) === null || _e$cause === void 0 ? void 0 : _e$cause.cmd) === 5 ? _type2.FcrUserLeftReason.kickOut : _type2.FcrUserLeftReason.LeaveRoom
103
- };
104
- });
105
- fcrUserEvents.forEach(event => {
106
- const user = event.userInfo;
107
- const exists = user.userId in this._userMapByUserId;
108
- if (!exists) {
109
- this.logger.warn("[FcrUserControl] user left when the user does not exist, userId: ".concat(user.userId));
110
- } else {
111
- delete this._userMapByUserId[user.userId];
112
- const index = this._userList.findIndex(u => user.userId === u.userId);
113
- if (index !== -1) {
114
- this._userList.splice(index, 1);
115
- }
116
- }
117
- });
118
- events.forEach(event => {
119
- this._roomCache.deleteUserPlatform(event.userInfo.userId);
120
- this._roomCache.deleteUserAvatar(event.userInfo.userId);
121
- });
122
- this._observable.notifyObservers('onRemoteUsersLeft', roomId, fcrUserEvents);
123
- },
124
- onUserUpdated: (sceneId, event) => {
125
- const fcrUserUpdatedEvent = {
126
- modifiedUser: event.modifiedUser && (0, _user.convertRteUserToFcrUser)(event.modifiedUser, this._roomCache),
127
- operatorUser: event.operatorUser && (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache),
128
- reason: event.reason
49
+ static {
50
+ [_initProto] = _applyDecs(this, [[_imports.bound, 2, "getLocalUser"], [_imports.bound, 2, "getUsers"], [_imports.bound, 2, "getUserList"], [_getUserDecs, 2, "getUser"], [[_imports.bound, _imports.trace], 2, "getAllUserCount"], [_imports.bound, 2, "getWaterMarkContent"], [[_imports.bound, _imports.trace], 2, "fetchUserList"], [_updateUserNameDecs, 2, "updateUserName"], [_updateUserPropertiesDecs, 2, "updateUserProperties"], [_updateIncrementUserPropertiesDecs, 2, "updateIncrementUserProperties"], [_deleteUserPropertiesDecs, 2, "deleteUserProperties"], [[_imports.bound, _imports.trace], 2, "getUserProperties"], [_getUserPropertiesByUserIdDecs, 2, "getUserPropertiesByUserId"], [_getUserPropertiesByKeyPathDecs, 2, "getUserPropertiesByKeyPath"], [_updateRemoteUserRoleDecs, 2, "updateRemoteUserRole"], [[_imports.bound, _imports.trace], 2, "revokeHost"], [_claimHostDecs, 2, "claimHost"], [_kickOutDecs, 2, "kickOut"], [_kickOutByUserIdsDecs, 2, "kickOutByUserIds"], [_kickOutByUserRolesDecs, 2, "kickOutByUserRoles"], [_mergeAudioStreamDecs, 2, "mergeAudioStream"]], []).e;
51
+ }
52
+ //@internal
53
+ [(_getUserDecs = [_imports.bound, (0, _validateParams.default)(_schema.stringSchema)], _updateUserNameDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.stringSchema)], _updateUserPropertiesDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringKeyUnknownValueSchema, _schema.stringKeyUnknownValueSchema, _schema.stringSchema)], _updateIncrementUserPropertiesDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringKeyNumberValueSchema, _schema.stringKeyUnknownValueSchema, _schema.stringSchema)], _deleteUserPropertiesDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringArraySchema, _schema.stringKeyUnknownValueSchema, _schema.stringSchema)], _getUserPropertiesByUserIdDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _getUserPropertiesByKeyPathDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.stringSchema)], _updateRemoteUserRoleDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrUserRoleSchema)], _claimHostDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _kickOutDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.fcrUserKickedOutTypeSchema)], _kickOutByUserIdsDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringArraySchema, _schema.fcrUserKickedOutTypeSchema)], _kickOutByUserRolesDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrUserRolesSchema, _schema.fcrUserKickedOutTypeSchema)], _mergeAudioStreamDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringSchema)], "logger")] = (_initProto(this), (0, _logger.createLogger)({
54
+ prefix: 'FcrUserControlImpl'
55
+ }));
56
+ //@internal
57
+ _observable = new _imports.AgoraObservable();
58
+ //@internal
59
+ _userMapByUserId = {};
60
+ //@internal
61
+ _userList = [];
62
+ //@internal
63
+
64
+ //@internal
65
+
66
+ //@internal
67
+ _sceneObserver = {
68
+ onRemoteUsersJoined: (roomId, events) => {
69
+ events.forEach(event => {
70
+ const userProperties = this._scene.getUserPropertiesByUserId(event.userInfo.userId);
71
+ this._roomCache.setUserPlatform(event.userInfo.userId, userProperties?.platform);
72
+ this._roomCache.setUserAvatar(event.userInfo.userId, userProperties?.avatar);
73
+ });
74
+ const fcrUserEvents = events.map(e => {
75
+ return {
76
+ userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache),
77
+ operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser, this._roomCache)
129
78
  };
130
- const user = fcrUserUpdatedEvent.modifiedUser;
79
+ });
80
+ fcrUserEvents.forEach(event => {
81
+ const user = event.userInfo;
131
82
  const exists = user.userId in this._userMapByUserId;
132
- if (!exists) {
133
- this.logger.warn("[FcrUserControl] user updated when the user does not exist, userId: ".concat(user.userId));
83
+ if (exists) {
84
+ this.logger.warn(`[FcrUserControl] user joined when the user already exists, userId: ${user.userId}`);
134
85
  } else {
135
86
  this._userMapByUserId[user.userId] = user;
87
+ this._userList.push(user);
88
+ }
89
+ });
90
+ this._observable.notifyObservers('onRemoteUsersJoined', roomId, fcrUserEvents);
91
+ },
92
+ onRemoteUsersLeft: (roomId, events) => {
93
+ const fcrUserEvents = events.map(e => {
94
+ return {
95
+ userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache),
96
+ userProperties: e.userProperties,
97
+ operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser, this._roomCache),
98
+ reason: e.cause?.cmd === 5 ? _type2.FcrUserLeftReason.kickOut : _type2.FcrUserLeftReason.LeaveRoom
99
+ };
100
+ });
101
+ fcrUserEvents.forEach(event => {
102
+ const user = event.userInfo;
103
+ const exists = user.userId in this._userMapByUserId;
104
+ if (!exists) {
105
+ this.logger.warn(`[FcrUserControl] user left when the user does not exist, userId: ${user.userId}`);
106
+ } else {
107
+ delete this._userMapByUserId[user.userId];
136
108
  const index = this._userList.findIndex(u => user.userId === u.userId);
137
109
  if (index !== -1) {
138
- this._userList.splice(index, 1, user);
110
+ this._userList.splice(index, 1);
139
111
  }
140
112
  }
141
- this._observable.notifyObservers('onUserInfoUpdated', sceneId, fcrUserUpdatedEvent);
142
- },
143
- onAllUserCountUpdated: (sceneId, count) => {
144
- this._observable.notifyObservers('onAllUserCountUpdated', sceneId, count);
145
- },
146
- onUserPropertiesUpdated: (roomId, event) => {
147
- var _event$cause, _event$cause2;
148
- if (((_event$cause = event.cause) === null || _event$cause === void 0 ? void 0 : _event$cause.cmd) === 5 && event.modifiedUser.userId === this._localUserId) {
149
- const {
150
- changedProperties
151
- } = event;
152
- const dirtyStateMap = {
153
- '0': _type2.FcrUserKickedOutType.Once,
154
- '1': _type2.FcrUserKickedOutType.Forever,
155
- '2': 2
156
- };
157
- const key = (0, _imports.get)(changedProperties, 'dirty.state');
158
- const type = dirtyStateMap[key];
159
- this._observable.notifyObservers('onLocalUserKickedOut', roomId, {
160
- type
161
- });
113
+ });
114
+ events.forEach(event => {
115
+ this._roomCache.deleteUserPlatform(event.userInfo.userId);
116
+ this._roomCache.deleteUserAvatar(event.userInfo.userId);
117
+ });
118
+ this._observable.notifyObservers('onRemoteUsersLeft', roomId, fcrUserEvents);
119
+ },
120
+ onUserUpdated: (sceneId, event) => {
121
+ const fcrUserUpdatedEvent = {
122
+ modifiedUser: event.modifiedUser && (0, _user.convertRteUserToFcrUser)(event.modifiedUser, this._roomCache),
123
+ operatorUser: event.operatorUser && (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache),
124
+ reason: event.reason
125
+ };
126
+ const user = fcrUserUpdatedEvent.modifiedUser;
127
+ const exists = user.userId in this._userMapByUserId;
128
+ if (!exists) {
129
+ this.logger.warn(`[FcrUserControl] user updated when the user does not exist, userId: ${user.userId}`);
130
+ } else {
131
+ this._userMapByUserId[user.userId] = user;
132
+ const index = this._userList.findIndex(u => user.userId === u.userId);
133
+ if (index !== -1) {
134
+ this._userList.splice(index, 1, user);
162
135
  }
163
- if (((_event$cause2 = event.cause) === null || _event$cause2 === void 0 ? void 0 : _event$cause2.cmd) === 8) {
164
- const changedProperties = {};
165
- for (const key in event.changedProperties) {
166
- if (key.startsWith('flexProps')) {
167
- changedProperties[key] = event.changedProperties[key];
168
- }
169
- }
170
- if (Object.keys(changedProperties).length > 0) {
171
- const structure = (0, _collection.convertToStructure)(changedProperties);
172
- this._observable.notifyObservers('onUserPropertiesUpdated', roomId, _objectSpread(_objectSpread({}, event), {}, {
173
- changedProperties: structure['flexProps']
174
- }));
136
+ }
137
+ this._observable.notifyObservers('onUserInfoUpdated', sceneId, fcrUserUpdatedEvent);
138
+ },
139
+ onAllUserCountUpdated: (sceneId, count) => {
140
+ this._observable.notifyObservers('onAllUserCountUpdated', sceneId, count);
141
+ },
142
+ onUserPropertiesUpdated: (roomId, event) => {
143
+ if (event.cause?.cmd === 5 && event.modifiedUser.userId === this._localUserId) {
144
+ const {
145
+ changedProperties
146
+ } = event;
147
+ const dirtyStateMap = {
148
+ '0': _type2.FcrUserKickedOutType.Once,
149
+ '1': _type2.FcrUserKickedOutType.Forever,
150
+ '2': 2
151
+ };
152
+ const key = (0, _imports.get)(changedProperties, 'dirty.state');
153
+ const type = dirtyStateMap[key];
154
+ this._observable.notifyObservers('onLocalUserKickedOut', roomId, {
155
+ type
156
+ });
157
+ }
158
+ if (event.cause?.cmd === 8) {
159
+ const changedProperties = {};
160
+ for (const key in event.changedProperties) {
161
+ if (key.startsWith('flexProps')) {
162
+ changedProperties[key] = event.changedProperties[key];
175
163
  }
176
164
  }
177
- },
178
- onUserPropertiesDeleted: (roomId, event) => {
179
- var _event$cause3;
180
- if (((_event$cause3 = event.cause) === null || _event$cause3 === void 0 ? void 0 : _event$cause3.cmd) === 8) {
181
- const changedKeyPaths = [];
182
- for (const keyPath of event.changedKeyPaths) {
183
- if (keyPath.startsWith('flexProps')) {
184
- changedKeyPaths.push(keyPath);
185
- }
186
- }
187
- if (changedKeyPaths.length > 0) {
188
- this._observable.notifyObservers('onUserPropertiesDeleted', roomId, _objectSpread(_objectSpread({}, event), {}, {
189
- changedKeyPaths
190
- }));
165
+ if (Object.keys(changedProperties).length > 0) {
166
+ const structure = (0, _collection.convertToStructure)(changedProperties);
167
+ this._observable.notifyObservers('onUserPropertiesUpdated', roomId, {
168
+ ...event,
169
+ changedProperties: structure['flexProps']
170
+ });
171
+ }
172
+ }
173
+ },
174
+ onUserPropertiesDeleted: (roomId, event) => {
175
+ if (event.cause?.cmd === 8) {
176
+ const changedKeyPaths = [];
177
+ for (const keyPath of event.changedKeyPaths) {
178
+ if (keyPath.startsWith('flexProps')) {
179
+ changedKeyPaths.push(keyPath);
191
180
  }
192
181
  }
182
+ if (changedKeyPaths.length > 0) {
183
+ this._observable.notifyObservers('onUserPropertiesDeleted', roomId, {
184
+ ...event,
185
+ changedKeyPaths
186
+ });
187
+ }
193
188
  }
194
- });
189
+ }
190
+ };
191
+ constructor(_scene, _api, _sharedCache) {
195
192
  this._scene = _scene;
196
193
  this._api = _api;
197
194
  this._sharedCache = _sharedCache;
@@ -199,8 +196,8 @@ class FcrUserControlImpl {
199
196
  const users = this._scene.getUsers();
200
197
  Object.keys(users).forEach(userId => {
201
198
  const userProperties = this._scene.getUserPropertiesByUserId(userId);
202
- this._roomCache.setUserAvatar(userId, userProperties === null || userProperties === void 0 ? void 0 : userProperties.avatar);
203
- this._roomCache.setUserPlatform(userId, userProperties === null || userProperties === void 0 ? void 0 : userProperties.platform);
199
+ this._roomCache.setUserAvatar(userId, userProperties?.avatar);
200
+ this._roomCache.setUserPlatform(userId, userProperties?.platform);
204
201
  });
205
202
  this._userMapByUserId = Object.keys(users).reduce((prev, userId) => {
206
203
  prev[userId] = (0, _user.convertRteUserToFcrUser)(users[userId], this._roomCache);
@@ -280,14 +277,12 @@ class FcrUserControlImpl {
280
277
  const userProperties = this._scene.getUserProperties();
281
278
  const res = {};
282
279
  for (const userId in userProperties) {
283
- var _userProperties$userI;
284
- res[userId] = (_userProperties$userI = userProperties[userId]) === null || _userProperties$userI === void 0 ? void 0 : _userProperties$userI['flexProps'];
280
+ res[userId] = userProperties[userId]?.['flexProps'];
285
281
  }
286
282
  return res;
287
283
  }
288
284
  getUserPropertiesByUserId(userId) {
289
- var _this$_scene$getUserP;
290
- return (_this$_scene$getUserP = this._scene.getUserPropertiesByUserId(userId)) === null || _this$_scene$getUserP === void 0 ? void 0 : _this$_scene$getUserP['flexProps'];
285
+ return this._scene.getUserPropertiesByUserId(userId)?.['flexProps'];
291
286
  }
292
287
  getUserPropertiesByKeyPath(keyPath, userId) {
293
288
  return this._scene.getUserPropertiesByKeyPath('flexProps.' + keyPath, userId);
@@ -308,7 +303,7 @@ class FcrUserControlImpl {
308
303
  roomId: this._scene.sceneId,
309
304
  localRole: _type.FcrUserRoleToStringMap[_type.FcrUserRole.HOST],
310
305
  remoteRole: _type.FcrUserRoleToStringMap[_type.FcrUserRole.PARTICIPANT],
311
- userId: originHostUser === null || originHostUser === void 0 ? void 0 : originHostUser.userId
306
+ userId: originHostUser?.userId
312
307
  }), _error.FcrErrorModuleCode.ROOM_USER, 'revoke host failed');
313
308
  }
314
309
  }
@@ -352,6 +347,4 @@ class FcrUserControlImpl {
352
347
  this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onRemoteUsersJoined', 'onRemoteUsersLeft', 'onUserInfoUpdated', 'onAllUserCountUpdated', 'onLocalUserKickedOut', 'onUserPropertiesUpdated', 'onUserPropertiesDeleted']));
353
348
  }
354
349
  }
355
- exports.FcrUserControlImpl = FcrUserControlImpl;
356
- _FcrUserControlImpl = FcrUserControlImpl;
357
- [_initProto] = _applyDecs(_FcrUserControlImpl, [[_imports.bound, 2, "getLocalUser"], [_imports.bound, 2, "getUsers"], [_imports.bound, 2, "getUserList"], [_getUserDecs, 2, "getUser"], [[_imports.bound, _imports.trace], 2, "getAllUserCount"], [_imports.bound, 2, "getWaterMarkContent"], [[_imports.bound, _imports.trace], 2, "fetchUserList"], [_updateUserNameDecs, 2, "updateUserName"], [_updateUserPropertiesDecs, 2, "updateUserProperties"], [_updateIncrementUserPropertiesDecs, 2, "updateIncrementUserProperties"], [_deleteUserPropertiesDecs, 2, "deleteUserProperties"], [[_imports.bound, _imports.trace], 2, "getUserProperties"], [_getUserPropertiesByUserIdDecs, 2, "getUserPropertiesByUserId"], [_getUserPropertiesByKeyPathDecs, 2, "getUserPropertiesByKeyPath"], [_updateRemoteUserRoleDecs, 2, "updateRemoteUserRole"], [[_imports.bound, _imports.trace], 2, "revokeHost"], [_claimHostDecs, 2, "claimHost"], [_kickOutDecs, 2, "kickOut"], [_kickOutByUserIdsDecs, 2, "kickOutByUserIds"], [_kickOutByUserRolesDecs, 2, "kickOutByUserRoles"], [_mergeAudioStreamDecs, 2, "mergeAudioStream"]], []).e;
350
+ exports.FcrUserControlImpl = FcrUserControlImpl;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.description.js");
4
- require("core-js/modules/es.error.cause.js");
5
3
  require("core-js/modules/es.array.push.js");
6
4
  require("core-js/modules/esnext.function.metadata.js");
7
5
  require("core-js/modules/esnext.map.delete-all.js");
@@ -26,8 +24,6 @@ Object.defineProperty(exports, "__esModule", {
26
24
  exports.FcrWaitingRoomControlImpl = void 0;
27
25
  require("core-js/modules/esnext.iterator.constructor.js");
28
26
  require("core-js/modules/esnext.iterator.map.js");
29
- require("core-js/modules/web.dom-collections.iterator.js");
30
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
31
27
  var _imports = require("../../imports");
32
28
  var _ = require("..");
33
29
  var _type = require("../type");
@@ -36,24 +32,25 @@ var _logger = require("../../utilities/logger");
36
32
  var _error = require("../../utilities/error");
37
33
  var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
38
34
  var _schema = require("../../schema");
39
- var _FcrWaitingRoomControlImpl;
40
- let _initProto, _moveToMainRoomByUserIdsDecs, _moveToMainRoomByUserRolesDecs, _ref;
35
+ let _initProto, _moveToMainRoomByUserIdsDecs, _moveToMainRoomByUserRolesDecs;
41
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)]; } }; }
42
37
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
43
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); }
44
39
  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; }
45
40
  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; }
46
- _ref = (_moveToMainRoomByUserIdsDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringArraySchema)], _moveToMainRoomByUserRolesDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrUserRolesSchema)], "logger");
47
41
  /**
48
42
  * @internal
49
43
  */
50
44
  class FcrWaitingRoomControlImpl extends _.FcrBaseRoomControlImpl {
45
+ static {
46
+ [_initProto] = _applyDecs(this, [[_moveToMainRoomByUserIdsDecs, 2, "moveToMainRoomByUserIds"], [_moveToMainRoomByUserRolesDecs, 2, "moveToMainRoomByUserRoles"]], [], 0, void 0, _.FcrBaseRoomControlImpl).e;
47
+ }
48
+ //@internal
49
+ [(_moveToMainRoomByUserIdsDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringArraySchema)], _moveToMainRoomByUserRolesDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrUserRolesSchema)], "logger")] = (_initProto(this), (0, _logger.createLogger)({
50
+ prefix: 'FcrWaitingRoomControlImpl'
51
+ }));
51
52
  constructor(engine, scene, api, config, sharedCache, chatConnection, chatRoomControl) {
52
53
  super(engine, scene, api, config, _type.FcrRoomType.Waitingroom, chatConnection, sharedCache, chatRoomControl);
53
- //@internal
54
- (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
55
- prefix: 'FcrWaitingRoomControlImpl'
56
- })));
57
54
  this._addLogObserver();
58
55
  }
59
56
  addObserver(observer) {
@@ -75,6 +72,4 @@ class FcrWaitingRoomControlImpl extends _.FcrBaseRoomControlImpl {
75
72
  'onRoomMessageReceived', 'onRoomPropertiesDeleted', 'onRoomPropertiesUpdated', 'onRoomStateUpdated']));
76
73
  }
77
74
  }
78
- exports.FcrWaitingRoomControlImpl = FcrWaitingRoomControlImpl;
79
- _FcrWaitingRoomControlImpl = FcrWaitingRoomControlImpl;
80
- [_initProto] = _applyDecs(_FcrWaitingRoomControlImpl, [[_moveToMainRoomByUserIdsDecs, 2, "moveToMainRoomByUserIds"], [_moveToMainRoomByUserRolesDecs, 2, "moveToMainRoomByUserRoles"]], [], 0, void 0, _.FcrBaseRoomControlImpl).e;
75
+ exports.FcrWaitingRoomControlImpl = FcrWaitingRoomControlImpl;
@@ -9,15 +9,13 @@ require("core-js/modules/esnext.iterator.some.js");
9
9
  var _type = require("../privilege-control/type");
10
10
  const hasBoardWritePermission = permissions => {
11
11
  return permissions.some(permission => {
12
- var _permission$info;
13
- return ((_permission$info = permission.info) === null || _permission$info === void 0 ? void 0 : _permission$info.action) === _type.FcrPermissionAction.BoardWrite;
12
+ return permission.info?.action === _type.FcrPermissionAction.BoardWrite;
14
13
  });
15
14
  };
16
15
  exports.hasBoardWritePermission = hasBoardWritePermission;
17
16
  const hasAnnotationWritePermission = permissions => {
18
17
  return permissions.some(permission => {
19
- var _permission$info2;
20
- return ((_permission$info2 = permission.info) === null || _permission$info2 === void 0 ? void 0 : _permission$info2.action) === _type.FcrPermissionAction.AnnotationWrite;
18
+ return permission.info?.action === _type.FcrPermissionAction.AnnotationWrite;
21
19
  });
22
20
  };
23
21
  exports.hasAnnotationWritePermission = hasAnnotationWritePermission;
@@ -16,8 +16,7 @@ class FcrBoardSubWindowImpl {
16
16
  return new Promise((resolve, reject) => {
17
17
  window.addEventListener('message', event => {
18
18
  if (event.data.type === '@netless/_result_save_pdf_') {
19
- var _event$data$result;
20
- event.data.progress === 100 && resolve((_event$data$result = event.data.result) === null || _event$data$result === void 0 ? void 0 : _event$data$result.pdf);
19
+ event.data.progress === 100 && resolve(event.data.result?.pdf);
21
20
  }
22
21
  });
23
22
  });