fcr-core 3.6.2 → 3.6.4

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 (53) hide show
  1. package/lib/chat-connection/index.js +23 -41
  2. package/lib/engine/index.js +66 -65
  3. package/lib/imports.js +1 -3
  4. package/lib/media-control/desktop.js +7 -15
  5. package/lib/media-control/mobile.js +11 -18
  6. package/lib/monitor-control/index.js +3 -10
  7. package/lib/peer-session/index.js +37 -50
  8. package/lib/plugins/chatroom.js +184 -203
  9. package/lib/room-control/ability-control/index.js +7 -14
  10. package/lib/room-control/ability-control/type.d.ts +2 -1
  11. package/lib/room-control/ability-control/type.js +1 -0
  12. package/lib/room-control/group-control/index.js +14 -23
  13. package/lib/room-control/index.js +57 -84
  14. package/lib/room-control/interpreter-control/index.js +17 -25
  15. package/lib/room-control/interpreter-control/room.js +4 -6
  16. package/lib/room-control/join-before-host-waitingroom-control/index.js +4 -6
  17. package/lib/room-control/mainroom-control/index.js +10 -20
  18. package/lib/room-control/privilege-control/helper.js +5 -10
  19. package/lib/room-control/privilege-control/index.js +17 -29
  20. package/lib/room-control/privilege-control/type.js +1 -0
  21. package/lib/room-control/room-connector-control/index.js +14 -25
  22. package/lib/room-control/room-session/index.js +37 -50
  23. package/lib/room-control/shared-cache.js +19 -26
  24. package/lib/room-control/sharing-control/index.js +22 -33
  25. package/lib/room-control/stream-control/index.js +164 -176
  26. package/lib/room-control/user-control/index.js +131 -146
  27. package/lib/room-control/waitingroom-control/index.js +8 -15
  28. package/lib/room-control/whiteboard-control/board-window.js +52 -60
  29. package/lib/room-control/whiteboard-control/enums.js +84 -0
  30. package/lib/room-control/whiteboard-control/index.js +26 -40
  31. package/lib/room-control/whiteboard-control/mount-manager.js +2 -4
  32. package/lib/room-control/whiteboard-control/utils.js +14 -17
  33. package/lib/room-control/whiteboard-control-v2/annotation-control/index.d.ts +1 -1
  34. package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +20 -27
  35. package/lib/room-control/whiteboard-control-v2/index.d.ts +1 -1
  36. package/lib/room-control/whiteboard-control-v2/index.js +51 -55
  37. package/lib/room-control/whiteboard-control-v2/main-window.d.ts +2 -0
  38. package/lib/room-control/whiteboard-control-v2/main-window.js +32 -41
  39. package/lib/room-router/index.js +52 -70
  40. package/lib/schema.d.ts +15 -15
  41. package/lib/schema.js +0 -1
  42. package/lib/service/api.js +113 -117
  43. package/lib/type.js +4 -2
  44. package/lib/utilities/collection.js +2 -3
  45. package/lib/utilities/error.js +4 -6
  46. package/lib/utilities/logger.js +2 -3
  47. package/lib/utilities/parameters.js +4 -8
  48. package/lib/utilities/stream.js +12 -20
  49. package/lib/utilities/user.js +2 -3
  50. package/lib/utilities/validate-params.js +1 -2
  51. package/package.json +4 -4
  52. package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.d.ts +0 -38
  53. package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +0 -261
@@ -1,10 +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
- require("core-js/modules/esnext.async-iterator.filter.js");
6
3
  require("core-js/modules/esnext.function.metadata.js");
7
- require("core-js/modules/esnext.iterator.filter.js");
8
4
  require("core-js/modules/esnext.map.delete-all.js");
9
5
  require("core-js/modules/esnext.map.emplace.js");
10
6
  require("core-js/modules/esnext.map.every.js");
@@ -26,17 +22,11 @@ Object.defineProperty(exports, "__esModule", {
26
22
  });
27
23
  exports.FcrUserControlImpl = void 0;
28
24
  require("core-js/modules/es.array.push.js");
29
- require("core-js/modules/esnext.async-iterator.find.js");
30
- require("core-js/modules/esnext.async-iterator.for-each.js");
31
- require("core-js/modules/esnext.async-iterator.map.js");
32
- require("core-js/modules/esnext.async-iterator.reduce.js");
33
25
  require("core-js/modules/esnext.iterator.constructor.js");
34
26
  require("core-js/modules/esnext.iterator.find.js");
35
27
  require("core-js/modules/esnext.iterator.for-each.js");
36
28
  require("core-js/modules/esnext.iterator.map.js");
37
29
  require("core-js/modules/esnext.iterator.reduce.js");
38
- require("core-js/modules/web.dom-collections.iterator.js");
39
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
40
30
  var _imports = require("../../imports");
41
31
  var _type = require("../../type");
42
32
  var _user = require("../../utilities/user");
@@ -46,163 +36,162 @@ var _logger = require("../../utilities/logger");
46
36
  var _error = require("../../utilities/error");
47
37
  var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
48
38
  var _schema = require("../../schema");
49
- var _FcrUserControlImpl;
50
- let _initProto, _getUserDecs, _updateUserNameDecs, _updateUserPropertiesDecs, _updateIncrementUserPropertiesDecs, _deleteUserPropertiesDecs, _getUserPropertiesByUserIdDecs, _getUserPropertiesByKeyPathDecs, _updateRemoteUserRoleDecs, _claimHostDecs, _kickOutDecs, _kickOutByUserIdsDecs, _kickOutByUserRolesDecs, _mergeAudioStreamDecs, _ref;
51
- 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; }
52
- 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;
53
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)]; } }; }
54
41
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
55
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); }
56
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; }
57
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; }
58
- _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");
59
45
  /**
60
46
  * @internal
61
47
  */
62
48
  class FcrUserControlImpl {
63
- constructor(_scene, _api, _sharedCache) {
64
- //@internal
65
- (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
66
- prefix: 'FcrUserControlImpl'
67
- })));
68
- //@internal
69
- (0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
70
- //@internal
71
- (0, _defineProperty2.default)(this, "_userMapByUserId", {});
72
- //@internal
73
- (0, _defineProperty2.default)(this, "_userList", []);
74
- //@internal
75
- (0, _defineProperty2.default)(this, "_sceneObserver", {
76
- onRemoteUsersJoined: (roomId, events) => {
77
- events.forEach(event => {
78
- const userProperties = this._scene.getUserPropertiesByUserId(event.userInfo.userId);
79
- this._roomCache.setUserPlatform(event.userInfo.userId, userProperties === null || userProperties === void 0 ? void 0 : userProperties.platform);
80
- });
81
- const fcrUserEvents = events.map(e => {
82
- return {
83
- userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache),
84
- operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser, this._roomCache)
85
- };
86
- });
87
- fcrUserEvents.forEach(event => {
88
- const user = event.userInfo;
89
- const exists = user.userId in this._userMapByUserId;
90
- if (exists) {
91
- this.logger.warn("[FcrUserControl] user joined when the user already exists, userId: ".concat(user.userId));
92
- } else {
93
- this._userMapByUserId[user.userId] = user;
94
- this._userList.push(user);
95
- }
96
- });
97
- this._observable.notifyObservers('onRemoteUsersJoined', roomId, fcrUserEvents);
98
- },
99
- onRemoteUsersLeft: (roomId, events) => {
100
- const fcrUserEvents = events.map(e => {
101
- var _e$cause;
102
- return {
103
- userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache),
104
- userProperties: e.userProperties,
105
- operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser, this._roomCache),
106
- reason: ((_e$cause = e.cause) === null || _e$cause === void 0 ? void 0 : _e$cause.cmd) === 5 ? _type2.FcrUserLeftReason.kickOut : _type2.FcrUserLeftReason.LeaveRoom
107
- };
108
- });
109
- fcrUserEvents.forEach(event => {
110
- const user = event.userInfo;
111
- const exists = user.userId in this._userMapByUserId;
112
- if (!exists) {
113
- this.logger.warn("[FcrUserControl] user left when the user does not exist, userId: ".concat(user.userId));
114
- } else {
115
- delete this._userMapByUserId[user.userId];
116
- const index = this._userList.findIndex(u => user.userId === u.userId);
117
- if (index !== -1) {
118
- this._userList.splice(index, 1);
119
- }
120
- }
121
- });
122
- events.forEach(event => {
123
- this._roomCache.deleteUserPlatform(event.userInfo.userId);
124
- });
125
- this._observable.notifyObservers('onRemoteUsersLeft', roomId, fcrUserEvents);
126
- },
127
- onUserUpdated: (sceneId, event) => {
128
- const fcrUserUpdatedEvent = {
129
- modifiedUser: event.modifiedUser && (0, _user.convertRteUserToFcrUser)(event.modifiedUser, this._roomCache),
130
- operatorUser: event.operatorUser && (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache),
131
- reason: event.reason
49
+ static #_ = (() => [_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)();
50
+ //@internal
51
+ [(_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)({
52
+ prefix: 'FcrUserControlImpl'
53
+ })))();
54
+ //@internal
55
+ _observable = (() => new _imports.AgoraObservable())();
56
+ //@internal
57
+ _userMapByUserId = {};
58
+ //@internal
59
+ _userList = [];
60
+ //@internal
61
+
62
+ //@internal
63
+
64
+ //@internal
65
+ _sceneObserver = {
66
+ onRemoteUsersJoined: (roomId, events) => {
67
+ events.forEach(event => {
68
+ const userProperties = this._scene.getUserPropertiesByUserId(event.userInfo.userId);
69
+ this._roomCache.setUserPlatform(event.userInfo.userId, userProperties?.platform);
70
+ });
71
+ const fcrUserEvents = events.map(e => {
72
+ return {
73
+ userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache),
74
+ operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser, this._roomCache)
132
75
  };
133
- const user = fcrUserUpdatedEvent.modifiedUser;
76
+ });
77
+ fcrUserEvents.forEach(event => {
78
+ const user = event.userInfo;
134
79
  const exists = user.userId in this._userMapByUserId;
135
- if (!exists) {
136
- this.logger.warn("[FcrUserControl] user updated when the user does not exist, userId: ".concat(user.userId));
80
+ if (exists) {
81
+ this.logger.warn(`[FcrUserControl] user joined when the user already exists, userId: ${user.userId}`);
137
82
  } else {
138
83
  this._userMapByUserId[user.userId] = user;
84
+ this._userList.push(user);
85
+ }
86
+ });
87
+ this._observable.notifyObservers('onRemoteUsersJoined', roomId, fcrUserEvents);
88
+ },
89
+ onRemoteUsersLeft: (roomId, events) => {
90
+ const fcrUserEvents = events.map(e => {
91
+ return {
92
+ userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache),
93
+ userProperties: e.userProperties,
94
+ operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser, this._roomCache),
95
+ reason: e.cause?.cmd === 5 ? _type2.FcrUserLeftReason.kickOut : _type2.FcrUserLeftReason.LeaveRoom
96
+ };
97
+ });
98
+ fcrUserEvents.forEach(event => {
99
+ const user = event.userInfo;
100
+ const exists = user.userId in this._userMapByUserId;
101
+ if (!exists) {
102
+ this.logger.warn(`[FcrUserControl] user left when the user does not exist, userId: ${user.userId}`);
103
+ } else {
104
+ delete this._userMapByUserId[user.userId];
139
105
  const index = this._userList.findIndex(u => user.userId === u.userId);
140
106
  if (index !== -1) {
141
- this._userList.splice(index, 1, user);
107
+ this._userList.splice(index, 1);
142
108
  }
143
109
  }
144
- this._observable.notifyObservers('onUserInfoUpdated', sceneId, fcrUserUpdatedEvent);
145
- },
146
- onAllUserCountUpdated: (sceneId, count) => {
147
- this._observable.notifyObservers('onAllUserCountUpdated', sceneId, count);
148
- },
149
- onUserPropertiesUpdated: (roomId, event) => {
150
- var _event$cause, _event$cause2;
151
- if (((_event$cause = event.cause) === null || _event$cause === void 0 ? void 0 : _event$cause.cmd) === 5 && event.modifiedUser.userId === this._localUserId) {
152
- const {
153
- changedProperties
154
- } = event;
155
- const dirtyStateMap = {
156
- '0': _type2.FcrUserKickedOutType.Once,
157
- '1': _type2.FcrUserKickedOutType.Forever,
158
- '2': 2
159
- };
160
- const key = (0, _imports.get)(changedProperties, 'dirty.state');
161
- const type = dirtyStateMap[key];
162
- this._observable.notifyObservers('onLocalUserKickedOut', roomId, {
163
- type
164
- });
110
+ });
111
+ events.forEach(event => {
112
+ this._roomCache.deleteUserPlatform(event.userInfo.userId);
113
+ });
114
+ this._observable.notifyObservers('onRemoteUsersLeft', roomId, fcrUserEvents);
115
+ },
116
+ onUserUpdated: (sceneId, event) => {
117
+ const fcrUserUpdatedEvent = {
118
+ modifiedUser: event.modifiedUser && (0, _user.convertRteUserToFcrUser)(event.modifiedUser, this._roomCache),
119
+ operatorUser: event.operatorUser && (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache),
120
+ reason: event.reason
121
+ };
122
+ const user = fcrUserUpdatedEvent.modifiedUser;
123
+ const exists = user.userId in this._userMapByUserId;
124
+ if (!exists) {
125
+ this.logger.warn(`[FcrUserControl] user updated when the user does not exist, userId: ${user.userId}`);
126
+ } else {
127
+ this._userMapByUserId[user.userId] = user;
128
+ const index = this._userList.findIndex(u => user.userId === u.userId);
129
+ if (index !== -1) {
130
+ this._userList.splice(index, 1, user);
165
131
  }
166
- if (((_event$cause2 = event.cause) === null || _event$cause2 === void 0 ? void 0 : _event$cause2.cmd) === 8) {
167
- const changedProperties = {};
168
- for (const key in event.changedProperties) {
169
- if (key.startsWith('flexProps')) {
170
- changedProperties[key] = event.changedProperties[key];
171
- }
172
- }
173
- if (Object.keys(changedProperties).length > 0) {
174
- const structure = (0, _collection.convertToStructure)(changedProperties);
175
- this._observable.notifyObservers('onUserPropertiesUpdated', roomId, _objectSpread(_objectSpread({}, event), {}, {
176
- changedProperties: structure['flexProps']
177
- }));
132
+ }
133
+ this._observable.notifyObservers('onUserInfoUpdated', sceneId, fcrUserUpdatedEvent);
134
+ },
135
+ onAllUserCountUpdated: (sceneId, count) => {
136
+ this._observable.notifyObservers('onAllUserCountUpdated', sceneId, count);
137
+ },
138
+ onUserPropertiesUpdated: (roomId, event) => {
139
+ if (event.cause?.cmd === 5 && event.modifiedUser.userId === this._localUserId) {
140
+ const {
141
+ changedProperties
142
+ } = event;
143
+ const dirtyStateMap = {
144
+ '0': _type2.FcrUserKickedOutType.Once,
145
+ '1': _type2.FcrUserKickedOutType.Forever,
146
+ '2': 2
147
+ };
148
+ const key = (0, _imports.get)(changedProperties, 'dirty.state');
149
+ const type = dirtyStateMap[key];
150
+ this._observable.notifyObservers('onLocalUserKickedOut', roomId, {
151
+ type
152
+ });
153
+ }
154
+ if (event.cause?.cmd === 8) {
155
+ const changedProperties = {};
156
+ for (const key in event.changedProperties) {
157
+ if (key.startsWith('flexProps')) {
158
+ changedProperties[key] = event.changedProperties[key];
178
159
  }
179
160
  }
180
- },
181
- onUserPropertiesDeleted: (roomId, event) => {
182
- var _event$cause3;
183
- if (((_event$cause3 = event.cause) === null || _event$cause3 === void 0 ? void 0 : _event$cause3.cmd) === 8) {
184
- const changedKeyPaths = [];
185
- for (const keyPath of event.changedKeyPaths) {
186
- if (keyPath.startsWith('flexProps')) {
187
- changedKeyPaths.push(keyPath);
188
- }
189
- }
190
- if (changedKeyPaths.length > 0) {
191
- this._observable.notifyObservers('onUserPropertiesDeleted', roomId, _objectSpread(_objectSpread({}, event), {}, {
192
- changedKeyPaths
193
- }));
161
+ if (Object.keys(changedProperties).length > 0) {
162
+ const structure = (0, _collection.convertToStructure)(changedProperties);
163
+ this._observable.notifyObservers('onUserPropertiesUpdated', roomId, {
164
+ ...event,
165
+ changedProperties: structure['flexProps']
166
+ });
167
+ }
168
+ }
169
+ },
170
+ onUserPropertiesDeleted: (roomId, event) => {
171
+ if (event.cause?.cmd === 8) {
172
+ const changedKeyPaths = [];
173
+ for (const keyPath of event.changedKeyPaths) {
174
+ if (keyPath.startsWith('flexProps')) {
175
+ changedKeyPaths.push(keyPath);
194
176
  }
195
177
  }
178
+ if (changedKeyPaths.length > 0) {
179
+ this._observable.notifyObservers('onUserPropertiesDeleted', roomId, {
180
+ ...event,
181
+ changedKeyPaths
182
+ });
183
+ }
196
184
  }
197
- });
185
+ }
186
+ };
187
+ constructor(_scene, _api, _sharedCache) {
198
188
  this._scene = _scene;
199
189
  this._api = _api;
200
190
  this._sharedCache = _sharedCache;
201
191
  this._roomCache = _sharedCache.getRoomCache(this._scene.sceneId);
202
192
  const users = this._scene.getUsers();
203
193
  Object.keys(users).forEach(userId => {
204
- var _this$_scene$getUserP;
205
- this._roomCache.setUserPlatform(userId, (_this$_scene$getUserP = this._scene.getUserPropertiesByUserId(userId)) === null || _this$_scene$getUserP === void 0 ? void 0 : _this$_scene$getUserP.platform);
194
+ this._roomCache.setUserPlatform(userId, this._scene.getUserPropertiesByUserId(userId)?.platform);
206
195
  });
207
196
  this._userMapByUserId = Object.keys(users).reduce((prev, userId) => {
208
197
  prev[userId] = (0, _user.convertRteUserToFcrUser)(users[userId], this._roomCache);
@@ -282,14 +271,12 @@ class FcrUserControlImpl {
282
271
  const userProperties = this._scene.getUserProperties();
283
272
  const res = {};
284
273
  for (const userId in userProperties) {
285
- var _userProperties$userI;
286
- res[userId] = (_userProperties$userI = userProperties[userId]) === null || _userProperties$userI === void 0 ? void 0 : _userProperties$userI['flexProps'];
274
+ res[userId] = userProperties[userId]?.['flexProps'];
287
275
  }
288
276
  return res;
289
277
  }
290
278
  getUserPropertiesByUserId(userId) {
291
- var _this$_scene$getUserP2;
292
- return (_this$_scene$getUserP2 = this._scene.getUserPropertiesByUserId(userId)) === null || _this$_scene$getUserP2 === void 0 ? void 0 : _this$_scene$getUserP2['flexProps'];
279
+ return this._scene.getUserPropertiesByUserId(userId)?.['flexProps'];
293
280
  }
294
281
  getUserPropertiesByKeyPath(keyPath, userId) {
295
282
  return this._scene.getUserPropertiesByKeyPath('flexProps.' + keyPath, userId);
@@ -310,7 +297,7 @@ class FcrUserControlImpl {
310
297
  roomId: this._scene.sceneId,
311
298
  localRole: _type.FcrUserRoleToStringMap[_type.FcrUserRole.HOST],
312
299
  remoteRole: _type.FcrUserRoleToStringMap[_type.FcrUserRole.PARTICIPANT],
313
- userId: originHostUser === null || originHostUser === void 0 ? void 0 : originHostUser.userId
300
+ userId: originHostUser?.userId
314
301
  }), _error.FcrErrorModuleCode.ROOM_USER, 'revoke host failed');
315
302
  }
316
303
  }
@@ -354,6 +341,4 @@ class FcrUserControlImpl {
354
341
  this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onRemoteUsersJoined', 'onRemoteUsersLeft', 'onUserInfoUpdated', 'onAllUserCountUpdated', 'onLocalUserKickedOut', 'onUserPropertiesUpdated', 'onUserPropertiesDeleted']));
355
342
  }
356
343
  }
357
- exports.FcrUserControlImpl = FcrUserControlImpl;
358
- _FcrUserControlImpl = FcrUserControlImpl;
359
- [_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;
344
+ 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");
@@ -24,10 +22,8 @@ Object.defineProperty(exports, "__esModule", {
24
22
  value: true
25
23
  });
26
24
  exports.FcrWaitingRoomControlImpl = void 0;
27
- require("core-js/modules/esnext.async-iterator.map.js");
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,23 @@ 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 #_ = (() => [_initProto] = _applyDecs(this, [[_moveToMainRoomByUserIdsDecs, 2, "moveToMainRoomByUserIds"], [_moveToMainRoomByUserRolesDecs, 2, "moveToMainRoomByUserRoles"]], [], 0, void 0, _.FcrBaseRoomControlImpl).e)();
46
+ //@internal
47
+ [(_moveToMainRoomByUserIdsDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringArraySchema)], _moveToMainRoomByUserRolesDecs = [_imports.trace, (0, _validateParams.default)(_schema.fcrUserRolesSchema)], "logger")] = (() => (_initProto(this), (0, _logger.createLogger)({
48
+ prefix: 'FcrWaitingRoomControlImpl'
49
+ })))();
51
50
  constructor(engine, scene, api, config, sharedCache, chatConnection, chatRoomControl, whitBoardControl) {
52
51
  super(engine, scene, api, config, _type.FcrRoomType.Waitingroom, chatConnection, sharedCache, chatRoomControl, whitBoardControl);
53
- //@internal
54
- (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
55
- prefix: 'FcrWaitingRoomControlImpl'
56
- })));
57
52
  this._addLogObserver();
58
53
  }
59
54
  addObserver(observer) {
@@ -75,6 +70,4 @@ class FcrWaitingRoomControlImpl extends _.FcrBaseRoomControlImpl {
75
70
  'onRoomMessageReceived', 'onRoomPropertiesDeleted', 'onRoomPropertiesUpdated', 'onRoomStateUpdated']));
76
71
  }
77
72
  }
78
- exports.FcrWaitingRoomControlImpl = FcrWaitingRoomControlImpl;
79
- _FcrWaitingRoomControlImpl = FcrWaitingRoomControlImpl;
80
- [_initProto] = _applyDecs(_FcrWaitingRoomControlImpl, [[_moveToMainRoomByUserIdsDecs, 2, "moveToMainRoomByUserIds"], [_moveToMainRoomByUserRolesDecs, 2, "moveToMainRoomByUserRoles"]], [], 0, void 0, _.FcrBaseRoomControlImpl).e;
73
+ exports.FcrWaitingRoomControlImpl = FcrWaitingRoomControlImpl;