fcr-core 3.7.8 → 3.7.9-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chat-connection/index.js +26 -41
- package/lib/engine/index.js +74 -67
- package/lib/imports.js +0 -1
- package/lib/media-control/desktop.js +13 -18
- package/lib/media-control/mobile.js +13 -18
- package/lib/monitor-control/index.js +5 -10
- package/lib/peer-session/index.js +39 -48
- package/lib/plugins/chatroom.js +202 -218
- package/lib/room-control/ability-control/index.js +9 -14
- package/lib/room-control/group-control/index.js +16 -21
- package/lib/room-control/helpers/validation-helper.js +1 -1
- package/lib/room-control/index.js +36 -53
- package/lib/room-control/interpreter-control/index.js +34 -47
- package/lib/room-control/interpreter-control/room.js +4 -6
- package/lib/room-control/join-before-host-waitingroom-control/index.js +4 -6
- package/lib/room-control/mainroom-control/index.js +17 -25
- package/lib/room-control/privilege-control/helper.js +5 -8
- package/lib/room-control/privilege-control/index.js +19 -26
- package/lib/room-control/room-connector-control/index.js +19 -28
- package/lib/room-control/room-control-factory.js +1 -2
- package/lib/room-control/room-session/index.js +39 -48
- package/lib/room-control/shared-cache.js +29 -36
- package/lib/room-control/sharing-control/index.js +32 -40
- package/lib/room-control/stream-control/index.js +173 -181
- package/lib/room-control/user-control/index.js +136 -143
- package/lib/room-control/waitingroom-control/index.js +9 -14
- package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +24 -32
- package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +16 -27
- package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +53 -63
- package/lib/room-control/whiteboard-control-v2/index.js +28 -40
- package/lib/room-control/whiteboard-control-v2/main-window.js +23 -28
- package/lib/room-control/whiteboard-control-v2/utils.js +6 -7
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +27 -38
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +3 -5
- package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +42 -54
- package/lib/room-router/index.js +42 -52
- package/lib/service/api.js +207 -231
- package/lib/utilities/collection.js +2 -3
- package/lib/utilities/error-helpers.js +27 -34
- package/lib/utilities/error.js +8 -9
- package/lib/utilities/join-helper.js +25 -32
- package/lib/utilities/logger.js +3 -6
- package/lib/utilities/parameters.js +4 -8
- package/lib/utilities/retry-helpers.js +0 -1
- package/lib/utilities/shared-storage.js +0 -1
- package/lib/utilities/storage.js +0 -1
- package/lib/utilities/stream.js +11 -16
- package/lib/utilities/user.js +3 -4
- package/lib/utilities/validate-params.js +1 -2
- package/package.json +4 -4
|
@@ -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
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
79
|
+
});
|
|
80
|
+
fcrUserEvents.forEach(event => {
|
|
81
|
+
const user = event.userInfo;
|
|
131
82
|
const exists = user.userId in this._userMapByUserId;
|
|
132
|
-
if (
|
|
133
|
-
this.logger.warn(
|
|
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
|
|
110
|
+
this._userList.splice(index, 1);
|
|
139
111
|
}
|
|
140
112
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
|
203
|
-
this._roomCache.setUserPlatform(userId, userProperties
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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;
|
|
@@ -1,6 +1,5 @@
|
|
|
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
5
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
@@ -18,16 +17,10 @@ require("core-js/modules/esnext.map.reduce.js");
|
|
|
18
17
|
require("core-js/modules/esnext.map.some.js");
|
|
19
18
|
require("core-js/modules/esnext.map.update.js");
|
|
20
19
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
21
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
22
20
|
Object.defineProperty(exports, "__esModule", {
|
|
23
21
|
value: true
|
|
24
22
|
});
|
|
25
23
|
exports.FcrAnnotationControlImpl = void 0;
|
|
26
|
-
require("core-js/modules/es.error.cause.js");
|
|
27
|
-
require("core-js/modules/es.json.stringify.js");
|
|
28
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
29
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
30
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
31
24
|
var _type = require("./type");
|
|
32
25
|
var _forgeRoom = require("@netless/forge-room");
|
|
33
26
|
var _forgeWhiteboard = require("@netless/forge-whiteboard");
|
|
@@ -38,7 +31,6 @@ var _forgeRtm = require("@netless/forge-rtm");
|
|
|
38
31
|
var _error = require("../../../utilities/error");
|
|
39
32
|
var _logger = require("../../../utilities/logger");
|
|
40
33
|
var _imports2 = require("../../../imports");
|
|
41
|
-
var _FcrAnnotationControlImpl;
|
|
42
34
|
let _initProto;
|
|
43
35
|
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)]; } }; }
|
|
44
36
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
@@ -46,13 +38,16 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
46
38
|
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; }
|
|
47
39
|
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; }
|
|
48
40
|
class FcrAnnotationControlImpl {
|
|
41
|
+
static {
|
|
42
|
+
[_initProto] = _applyDecs(this, [[_imports2.trace, 2, "open"], [_imports2.trace, 2, "close"], [_imports2.trace, 2, "getConnectionState"], [_imports2.trace, 2, "getMainWindow"], [_imports2.trace, 2, "addPermission"], [_imports2.trace, 2, "removePermission"]], []).e;
|
|
43
|
+
}
|
|
44
|
+
logger = (_initProto(this), (0, _logger.createLogger)({
|
|
45
|
+
prefix: 'FcrAnnotationControlImpl'
|
|
46
|
+
}));
|
|
47
|
+
observable = new _imports2.AgoraObservable();
|
|
48
|
+
connectState = _type2.FcrConnectionState.DISCONNECTED;
|
|
49
|
+
_openAbortController = null;
|
|
49
50
|
constructor(rtmClient, annotationConfig) {
|
|
50
|
-
(0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
|
|
51
|
-
prefix: 'FcrAnnotationControlImpl'
|
|
52
|
-
})));
|
|
53
|
-
(0, _defineProperty2.default)(this, "observable", new _imports2.AgoraObservable());
|
|
54
|
-
(0, _defineProperty2.default)(this, "connectState", _type2.FcrConnectionState.DISCONNECTED);
|
|
55
|
-
(0, _defineProperty2.default)(this, "_openAbortController", null);
|
|
56
51
|
this.rtmClient = rtmClient;
|
|
57
52
|
this.annotationConfig = annotationConfig;
|
|
58
53
|
this._addLogObserver();
|
|
@@ -90,7 +85,7 @@ class FcrAnnotationControlImpl {
|
|
|
90
85
|
if (annotation) {
|
|
91
86
|
annotation.permissions.addPermission(permission);
|
|
92
87
|
} else {
|
|
93
|
-
this.logger.warn(
|
|
88
|
+
this.logger.warn(`add permission failed, annotation is not initialized, permission: ${permission}`);
|
|
94
89
|
}
|
|
95
90
|
}
|
|
96
91
|
removePermission(permission) {
|
|
@@ -98,7 +93,7 @@ class FcrAnnotationControlImpl {
|
|
|
98
93
|
if (annotation) {
|
|
99
94
|
annotation.permissions.removePermission(permission);
|
|
100
95
|
} else {
|
|
101
|
-
this.logger.warn(
|
|
96
|
+
this.logger.warn(`remove permission failed, annotation is not initialized, permission: ${permission}`);
|
|
102
97
|
}
|
|
103
98
|
}
|
|
104
99
|
addObserver(observer) {
|
|
@@ -152,14 +147,14 @@ class FcrAnnotationControlImpl {
|
|
|
152
147
|
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_WHITEBOARD, _error.FcrErrorCode.UNDEFINED_ERROR, 'boardToken is required', new Error('boardToken is required'));
|
|
153
148
|
}
|
|
154
149
|
if (!width) {
|
|
155
|
-
this.logger.warn(
|
|
150
|
+
this.logger.warn(`annotation width is a invalid vlaue: ${width}, using default value 800`);
|
|
156
151
|
width = 800;
|
|
157
152
|
}
|
|
158
153
|
if (!height) {
|
|
159
|
-
this.logger.warn(
|
|
154
|
+
this.logger.warn(`annotation height is a invalid value: ${height}, using default value 600`);
|
|
160
155
|
height = 600;
|
|
161
156
|
}
|
|
162
|
-
this.logger.info(
|
|
157
|
+
this.logger.info(`open annotation with boardId: ${boardId}, boardToken: ${boardToken}, region: ${region}`);
|
|
163
158
|
|
|
164
159
|
// @ts-ignore
|
|
165
160
|
const rtmProvider = new _forgeRtm.RTMProvider_2_2(this.rtmClient);
|
|
@@ -185,7 +180,7 @@ class FcrAnnotationControlImpl {
|
|
|
185
180
|
useMultiViews: true
|
|
186
181
|
}
|
|
187
182
|
};
|
|
188
|
-
this.logger.info(
|
|
183
|
+
this.logger.info(`join params: ${(0, _imports2.jsonstring)(joinRoomParams)}`);
|
|
189
184
|
await wbRoom.joinRoom(joinRoomParams);
|
|
190
185
|
boardRoom = wbRoom;
|
|
191
186
|
whiteboard = await wbRoom.applicationManager.launchApplication(_forgeWhiteboard.WhiteboardApplication, {
|
|
@@ -198,16 +193,15 @@ class FcrAnnotationControlImpl {
|
|
|
198
193
|
}, _type.ANNOTATION_APP_ID);
|
|
199
194
|
}, [], {
|
|
200
195
|
retriesMax
|
|
201
|
-
}).fail(async
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
} = _ref;
|
|
196
|
+
}).fail(async ({
|
|
197
|
+
error,
|
|
198
|
+
timeFn,
|
|
199
|
+
currentRetry
|
|
200
|
+
}) => {
|
|
207
201
|
if (abortController.signal.aborted) {
|
|
208
202
|
throw new Error('join board aborted');
|
|
209
203
|
}
|
|
210
|
-
this.logger.info(
|
|
204
|
+
this.logger.info(`failed to join board, error: ${error.message}, current retry: ${currentRetry}`);
|
|
211
205
|
await timeFn();
|
|
212
206
|
return true;
|
|
213
207
|
}).exec());
|
|
@@ -215,7 +209,7 @@ class FcrAnnotationControlImpl {
|
|
|
215
209
|
throw new Error('join board aborted');
|
|
216
210
|
}
|
|
217
211
|
if (error) {
|
|
218
|
-
this.logger.error(
|
|
212
|
+
this.logger.error(`join board failed, ${error.message}-${JSON.stringify(error)}`);
|
|
219
213
|
throw error;
|
|
220
214
|
}
|
|
221
215
|
whiteboard.enableCameraByMouse = false;
|
|
@@ -229,7 +223,7 @@ class FcrAnnotationControlImpl {
|
|
|
229
223
|
this.updateConnnectionState(_type2.FcrConnectionState.CONNECTED);
|
|
230
224
|
resolve(boardView);
|
|
231
225
|
} catch (e) {
|
|
232
|
-
this.logger.error(
|
|
226
|
+
this.logger.error(`join board failed`);
|
|
233
227
|
this.updateConnnectionState(_type2.FcrConnectionState.DISCONNECTED);
|
|
234
228
|
reject(e);
|
|
235
229
|
} finally {
|
|
@@ -241,6 +235,4 @@ class FcrAnnotationControlImpl {
|
|
|
241
235
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onConnectionStateUpdated', 'onActive', 'onInactive', 'onBackgroundColorUpdated']));
|
|
242
236
|
}
|
|
243
237
|
}
|
|
244
|
-
exports.FcrAnnotationControlImpl = FcrAnnotationControlImpl;
|
|
245
|
-
_FcrAnnotationControlImpl = FcrAnnotationControlImpl;
|
|
246
|
-
[_initProto] = _applyDecs(_FcrAnnotationControlImpl, [[_imports2.trace, 2, "open"], [_imports2.trace, 2, "close"], [_imports2.trace, 2, "getConnectionState"], [_imports2.trace, 2, "getMainWindow"], [_imports2.trace, 2, "addPermission"], [_imports2.trace, 2, "removePermission"]], []).e;
|
|
238
|
+
exports.FcrAnnotationControlImpl = FcrAnnotationControlImpl;
|