fcr-core 3.4.3 → 3.4.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.
- package/lib/chat-connection/index.js +38 -20
- package/lib/engine/index.js +41 -39
- package/lib/imports.js +1 -0
- package/lib/media-control/desktop.js +11 -3
- package/lib/media-control/mobile.js +13 -6
- package/lib/peer-session/index.js +47 -34
- package/lib/plugins/chatroom.js +113 -99
- package/lib/room-control/ability-control/index.d.ts +1 -0
- package/lib/room-control/ability-control/index.js +69 -0
- package/lib/room-control/ability-control/type.d.ts +9 -0
- package/lib/room-control/ability-control/type.js +11 -0
- package/lib/room-control/chatroom-control/index.d.ts +1 -0
- package/lib/room-control/chatroom-control/index.js +385 -0
- package/lib/room-control/group-control/index.js +22 -11
- package/lib/room-control/index.js +82 -56
- package/lib/room-control/interpreter-control/index.js +17 -9
- package/lib/room-control/interpreter-control/room.js +6 -4
- package/lib/room-control/mainroom-control/index.js +41 -21
- package/lib/room-control/privilege-control/helper.js +10 -5
- package/lib/room-control/privilege-control/index.js +21 -12
- package/lib/room-control/privilege-control/type.js +0 -1
- package/lib/room-control/room-connector-control/index.js +24 -13
- package/lib/room-control/room-session/index.js +49 -36
- package/lib/room-control/stream-control/index.js +151 -140
- package/lib/room-control/user-control/index.js +135 -119
- package/lib/room-control/waitingroom-control/index.js +16 -8
- package/lib/room-control/whiteboard-control/board-subwindow.js +2 -1
- package/lib/room-control/whiteboard-control/board-window.js +57 -49
- package/lib/room-control/whiteboard-control/enums.js +0 -84
- package/lib/room-control/whiteboard-control/index.js +35 -22
- package/lib/room-control/whiteboard-control/mount-manager.js +4 -2
- package/lib/room-control/whiteboard-control/utils.js +17 -14
- package/lib/room-control/whiteboard-control-v2/index.js +33 -19
- package/lib/room-control/whiteboard-control-v2/main-window.js +23 -12
- package/lib/schema.d.ts +964 -0
- package/lib/schema.js +259 -0
- package/lib/service/api.js +82 -76
- package/lib/type.js +2 -4
- package/lib/utilities/collection.js +3 -2
- package/lib/utilities/error.js +5 -3
- package/lib/utilities/logger.js +2 -1
- package/lib/utilities/parameters.js +8 -4
- package/lib/utilities/stream.js +20 -12
- package/lib/utilities/user.js +1 -1
- package/lib/utilities/validate-params.d.ts +2 -0
- package/lib/utilities/validate-params.js +14 -0
- package/package.json +4 -4
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
3
4
|
require("core-js/modules/es.array.push.js");
|
|
5
|
+
require("core-js/modules/esnext.async-iterator.filter.js");
|
|
6
|
+
require("core-js/modules/esnext.async-iterator.for-each.js");
|
|
4
7
|
require("core-js/modules/esnext.function.metadata.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
10
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
5
11
|
require("core-js/modules/esnext.symbol.metadata.js");
|
|
12
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
13
|
Object.defineProperty(exports, "__esModule", {
|
|
7
14
|
value: true
|
|
8
15
|
});
|
|
9
16
|
exports.FcrPeerSessionControlImpl = void 0;
|
|
17
|
+
require("core-js/modules/es.error.cause.js");
|
|
18
|
+
require("core-js/modules/es.json.stringify.js");
|
|
10
19
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
11
20
|
require("core-js/modules/esnext.map.emplace.js");
|
|
12
21
|
require("core-js/modules/esnext.map.every.js");
|
|
@@ -21,10 +30,15 @@ require("core-js/modules/esnext.map.merge.js");
|
|
|
21
30
|
require("core-js/modules/esnext.map.reduce.js");
|
|
22
31
|
require("core-js/modules/esnext.map.some.js");
|
|
23
32
|
require("core-js/modules/esnext.map.update.js");
|
|
33
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
34
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
24
35
|
var _imports = require("../imports");
|
|
25
36
|
var _error = require("../utilities/error");
|
|
26
37
|
var _logger = require("../utilities/logger");
|
|
38
|
+
var _FcrPeerSessionControlImpl;
|
|
27
39
|
let _initProto;
|
|
40
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
41
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
28
42
|
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)]; } }; }
|
|
29
43
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
30
44
|
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); }
|
|
@@ -34,20 +48,17 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
34
48
|
* @internal
|
|
35
49
|
*/
|
|
36
50
|
class FcrPeerSessionControlImpl {
|
|
37
|
-
static #_ = (() => [_initProto] = _applyDecs(this, [[_logger.trace, 2, "startPeerSession"], [_logger.trace, 2, "stopPeerSession"], [_logger.trace, 2, "acceptPeerSession"], [_logger.trace, 2, "rejectPeerSession"]], []).e)();
|
|
38
|
-
//@internal
|
|
39
|
-
logger = (() => (_initProto(this), (0, _logger.getLogger)()))();
|
|
40
|
-
//@internal
|
|
41
|
-
_observable = (() => new _imports.AgoraObservable())();
|
|
42
|
-
//@internal
|
|
43
|
-
_taskInterval = (() => _imports.Duration.second(1))();
|
|
44
|
-
//@internal
|
|
45
|
-
|
|
46
|
-
//@internal
|
|
47
|
-
_scheduleMap = (() => new Map())();
|
|
48
|
-
//@internal
|
|
49
|
-
_receivedMap = (() => new Map())();
|
|
50
51
|
constructor(_rteEngine, _api, _userId) {
|
|
52
|
+
//@internal
|
|
53
|
+
(0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.getLogger)()));
|
|
54
|
+
//@internal
|
|
55
|
+
(0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
|
|
56
|
+
//@internal
|
|
57
|
+
(0, _defineProperty2.default)(this, "_taskInterval", _imports.Duration.second(1));
|
|
58
|
+
//@internal
|
|
59
|
+
(0, _defineProperty2.default)(this, "_scheduleMap", new Map());
|
|
60
|
+
//@internal
|
|
61
|
+
(0, _defineProperty2.default)(this, "_receivedMap", new Map());
|
|
51
62
|
this._rteEngine = _rteEngine;
|
|
52
63
|
this._api = _api;
|
|
53
64
|
this._userId = _userId;
|
|
@@ -61,7 +72,7 @@ class FcrPeerSessionControlImpl {
|
|
|
61
72
|
async startPeerSession(params) {
|
|
62
73
|
try {
|
|
63
74
|
const session = {
|
|
64
|
-
sessionId: (0, _imports.md5)(
|
|
75
|
+
sessionId: (0, _imports.md5)("".concat(Date.now())),
|
|
65
76
|
sessionKey: params.sessionKey,
|
|
66
77
|
payload: params.payload,
|
|
67
78
|
duration: params.duration,
|
|
@@ -80,12 +91,11 @@ class FcrPeerSessionControlImpl {
|
|
|
80
91
|
targetId: params.receiverId
|
|
81
92
|
});
|
|
82
93
|
const nextTs = Date.now() + interval;
|
|
83
|
-
this._scheduleMap.set(session.sessionId, {
|
|
84
|
-
...params,
|
|
94
|
+
this._scheduleMap.set(session.sessionId, _objectSpread(_objectSpread({}, params), {}, {
|
|
85
95
|
nextTs,
|
|
86
96
|
startTs: Date.now()
|
|
87
|
-
});
|
|
88
|
-
this.logger.info(
|
|
97
|
+
}));
|
|
98
|
+
this.logger.info("[PeerSession] put into session schedule: ".concat(session.sessionId, ", next ts: ").concat(nextTs, ", remain: ").concat(nextTs - Date.now(), "ms"));
|
|
89
99
|
return session.sessionId;
|
|
90
100
|
} catch (e) {
|
|
91
101
|
throw (0, _error.generateFcrCoreServerError)(_error.FcrErrorCode.LOCAL_HTTP_REQUEST_FAILED, 'start peer session failed', e);
|
|
@@ -154,13 +164,13 @@ class FcrPeerSessionControlImpl {
|
|
|
154
164
|
interval: 0
|
|
155
165
|
};
|
|
156
166
|
if (this._isSessionExpired(session)) {
|
|
157
|
-
this.logger.info(
|
|
167
|
+
this.logger.info("[PeerSession] peer session expired, removed: ".concat(session.sessionId));
|
|
158
168
|
this._scheduleMap.delete(session.sessionId);
|
|
159
169
|
continue;
|
|
160
170
|
}
|
|
161
171
|
// check timeout
|
|
162
172
|
if (params.nextTs < Date.now()) {
|
|
163
|
-
this.logger.info(
|
|
173
|
+
this.logger.info("[PeerSession] ping session: ".concat(session.sessionId));
|
|
164
174
|
try {
|
|
165
175
|
const {
|
|
166
176
|
data: {
|
|
@@ -176,14 +186,13 @@ class FcrPeerSessionControlImpl {
|
|
|
176
186
|
});
|
|
177
187
|
const nextTs = Date.now() + interval;
|
|
178
188
|
if (this._scheduleMap.has(session.sessionId)) {
|
|
179
|
-
this._scheduleMap.set(session.sessionId, {
|
|
180
|
-
...params,
|
|
189
|
+
this._scheduleMap.set(session.sessionId, _objectSpread(_objectSpread({}, params), {}, {
|
|
181
190
|
nextTs
|
|
182
|
-
});
|
|
183
|
-
this.logger.info(
|
|
191
|
+
}));
|
|
192
|
+
this.logger.info("[PeerSession] refresh session schedule: ".concat(session.sessionId, ", next ts: ").concat(nextTs));
|
|
184
193
|
}
|
|
185
194
|
} catch (e) {
|
|
186
|
-
this.logger.error(
|
|
195
|
+
this.logger.error("[PeerSession] ping session failed: ".concat(e));
|
|
187
196
|
}
|
|
188
197
|
}
|
|
189
198
|
}
|
|
@@ -192,7 +201,7 @@ class FcrPeerSessionControlImpl {
|
|
|
192
201
|
const session = this._receivedMap.get(key);
|
|
193
202
|
if (this._isSessionExpired(session)) {
|
|
194
203
|
this._receivedMap.delete(key);
|
|
195
|
-
this.logger.info(
|
|
204
|
+
this.logger.info("[PeerSession] delete session callback: ".concat(key));
|
|
196
205
|
}
|
|
197
206
|
}
|
|
198
207
|
}
|
|
@@ -223,7 +232,7 @@ class FcrPeerSessionControlImpl {
|
|
|
223
232
|
}
|
|
224
233
|
if (!this._isSessionExpired(session)) {
|
|
225
234
|
if (!this._receivedMap.has(session.sessionId)) {
|
|
226
|
-
this.logger.info(
|
|
235
|
+
this.logger.info("[PeerSession] received peer session request ".concat(JSON.stringify(session)));
|
|
227
236
|
this._observable.notifyObservers('onPeerSessionReceived', session);
|
|
228
237
|
}
|
|
229
238
|
this._receivedMap.set(session.sessionId, session);
|
|
@@ -231,6 +240,7 @@ class FcrPeerSessionControlImpl {
|
|
|
231
240
|
} else if (cmd === '1002') {
|
|
232
241
|
if (data.action === 1) {
|
|
233
242
|
if (this._scheduleMap.has(data.sessionUuid)) {
|
|
243
|
+
var _session$payload, _ref, _data$payload;
|
|
234
244
|
const session = this._scheduleMap.get(data.sessionUuid);
|
|
235
245
|
const sessionResponse = {
|
|
236
246
|
sessionId: data.sessionUuid,
|
|
@@ -238,15 +248,16 @@ class FcrPeerSessionControlImpl {
|
|
|
238
248
|
responderId: senderId,
|
|
239
249
|
// FIXME: session may be lost when the client refreshes
|
|
240
250
|
// get payload from original session
|
|
241
|
-
payload: session.payload
|
|
242
|
-
cause: data.payload
|
|
251
|
+
payload: (_session$payload = session.payload) !== null && _session$payload !== void 0 ? _session$payload : {},
|
|
252
|
+
cause: (_ref = (_data$payload = data.payload) === null || _data$payload === void 0 ? void 0 : _data$payload.cause) !== null && _ref !== void 0 ? _ref : {}
|
|
243
253
|
};
|
|
244
|
-
this.logger.info(
|
|
254
|
+
this.logger.info("[PeerSession] received peer session accepted ".concat(JSON.stringify(sessionResponse)));
|
|
245
255
|
this._scheduleMap.delete(data.sessionUuid);
|
|
246
256
|
this._observable.notifyObservers('onPeerSessionAccepted', sessionResponse);
|
|
247
257
|
}
|
|
248
258
|
} else if (data.action === 2) {
|
|
249
259
|
if (this._scheduleMap.has(data.sessionUuid)) {
|
|
260
|
+
var _session$payload2, _ref2, _data$payload2;
|
|
250
261
|
const session = this._scheduleMap.get(data.sessionUuid);
|
|
251
262
|
const sessionResponse = {
|
|
252
263
|
sessionId: data.sessionUuid,
|
|
@@ -254,10 +265,10 @@ class FcrPeerSessionControlImpl {
|
|
|
254
265
|
responderId: senderId,
|
|
255
266
|
// FIXME: session may be lost when the client refreshes
|
|
256
267
|
// get payload from original session
|
|
257
|
-
payload: session.payload
|
|
258
|
-
cause: data.payload
|
|
268
|
+
payload: (_session$payload2 = session.payload) !== null && _session$payload2 !== void 0 ? _session$payload2 : {},
|
|
269
|
+
cause: (_ref2 = (_data$payload2 = data.payload) === null || _data$payload2 === void 0 ? void 0 : _data$payload2.cause) !== null && _ref2 !== void 0 ? _ref2 : {}
|
|
259
270
|
};
|
|
260
|
-
this.logger.info(
|
|
271
|
+
this.logger.info("[PeerSession] received peer session rejected ".concat(JSON.stringify(sessionResponse)));
|
|
261
272
|
if (this._scheduleMap.has(data.sessionUuid)) {
|
|
262
273
|
this._scheduleMap.delete(data.sessionUuid);
|
|
263
274
|
this._observable.notifyObservers('onPeerSessionRejected', sessionResponse);
|
|
@@ -275,4 +286,6 @@ class FcrPeerSessionControlImpl {
|
|
|
275
286
|
this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onPeerSessionAccepted', 'onPeerSessionReceived', 'onPeerSessionRejected']));
|
|
276
287
|
}
|
|
277
288
|
}
|
|
278
|
-
exports.FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
|
|
289
|
+
exports.FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
|
|
290
|
+
_FcrPeerSessionControlImpl = FcrPeerSessionControlImpl;
|
|
291
|
+
[_initProto] = _applyDecs(_FcrPeerSessionControlImpl, [[_logger.trace, 2, "startPeerSession"], [_logger.trace, 2, "stopPeerSession"], [_logger.trace, 2, "acceptPeerSession"], [_logger.trace, 2, "rejectPeerSession"]], []).e;
|
package/lib/plugins/chatroom.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
3
4
|
require("core-js/modules/es.array.push.js");
|
|
5
|
+
require("core-js/modules/esnext.async-iterator.filter.js");
|
|
6
|
+
require("core-js/modules/esnext.async-iterator.for-each.js");
|
|
4
7
|
require("core-js/modules/esnext.function.metadata.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
10
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
5
11
|
require("core-js/modules/esnext.map.delete-all.js");
|
|
6
12
|
require("core-js/modules/esnext.map.emplace.js");
|
|
7
13
|
require("core-js/modules/esnext.map.every.js");
|
|
@@ -22,6 +28,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
22
28
|
value: true
|
|
23
29
|
});
|
|
24
30
|
exports.FcrChatRoomControlImpl = void 0;
|
|
31
|
+
require("core-js/modules/es.error.cause.js");
|
|
32
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
33
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
34
|
var _observable = require("agora-foundation/lib/utilities/observable");
|
|
26
35
|
var _easemobWebsdk = _interopRequireDefault(require("easemob-websdk"));
|
|
27
36
|
var _user = require("../utilities/user");
|
|
@@ -29,7 +38,10 @@ var _error = require("../utilities/error");
|
|
|
29
38
|
var _type = require("../room-control/chatroom-control/type");
|
|
30
39
|
var _type2 = require("../chat-connection/type");
|
|
31
40
|
var _logger = require("../utilities/logger");
|
|
41
|
+
var _FcrChatRoomControlImpl;
|
|
32
42
|
let _initProto;
|
|
43
|
+
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; }
|
|
44
|
+
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; }
|
|
33
45
|
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)]; } }; }
|
|
34
46
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
35
47
|
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); }
|
|
@@ -39,25 +51,6 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
39
51
|
* @internal
|
|
40
52
|
*/
|
|
41
53
|
class FcrChatRoomControlImpl {
|
|
42
|
-
static #_ = (() => [_initProto] = _applyDecs(this, [[_logger.trace, 2, "join"], [_logger.trace, 2, "getConnectionState"], [_logger.trace, 2, "sendMessage"], [_logger.trace, 2, "leave"]], []).e)();
|
|
43
|
-
logger = (() => (_initProto(this), (0, _logger.getLogger)()))();
|
|
44
|
-
_observable = (() => new _observable.AgoraObservable())();
|
|
45
|
-
_connectionState = (() => _type.FcrChatRoomConnectionState.Disconnected)();
|
|
46
|
-
_chatConnectionObserver = {
|
|
47
|
-
onConnectionStateUpdated: async state => {
|
|
48
|
-
// im reconnect
|
|
49
|
-
if (state === _type2.FcrChatConnectionState.DISCONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Connected) {
|
|
50
|
-
this._setConnectionState(_type.FcrChatRoomConnectionState.Disconnected);
|
|
51
|
-
} else if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() !== _type.FcrChatRoomConnectionState.Connected) {
|
|
52
|
-
this._removeEventListener();
|
|
53
|
-
this._addEventListener();
|
|
54
|
-
await this._joinChatRoom(state);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
onConnectionLoginSuccess: () => {
|
|
58
|
-
this._addEventListener();
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
54
|
get conn() {
|
|
62
55
|
if (!this._chatConnection.getConnectionInstance()) {
|
|
63
56
|
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'chat room connection not initialized, please get chat room token first', new Error('chat room connection not initialized, please get chat room token first'));
|
|
@@ -68,6 +61,94 @@ class FcrChatRoomControlImpl {
|
|
|
68
61
|
return this._scene.getScenePropertiesByKeyPath('widgets.easemobIM.extra.chatRoomId');
|
|
69
62
|
}
|
|
70
63
|
constructor(_scene, _chatConnection) {
|
|
64
|
+
(0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.getLogger)()));
|
|
65
|
+
(0, _defineProperty2.default)(this, "_observable", new _observable.AgoraObservable());
|
|
66
|
+
(0, _defineProperty2.default)(this, "_connectionState", _type.FcrChatRoomConnectionState.Disconnected);
|
|
67
|
+
(0, _defineProperty2.default)(this, "_chatConnectionObserver", {
|
|
68
|
+
onConnectionStateUpdated: async state => {
|
|
69
|
+
// im reconnect
|
|
70
|
+
if (state === _type2.FcrChatConnectionState.DISCONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Connected) {
|
|
71
|
+
this._setConnectionState(_type.FcrChatRoomConnectionState.Disconnected);
|
|
72
|
+
} else if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() !== _type.FcrChatRoomConnectionState.Connected) {
|
|
73
|
+
this._removeEventListener();
|
|
74
|
+
this._addEventListener();
|
|
75
|
+
await this._joinChatRoom(state);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
onConnectionLoginSuccess: () => {
|
|
79
|
+
this._addEventListener();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
(0, _defineProperty2.default)(this, "_joinChatRoom", async state => {
|
|
83
|
+
if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Disconnected && this.chatRoomId) {
|
|
84
|
+
this._setConnectionState(_type.FcrChatRoomConnectionState.Connecting);
|
|
85
|
+
await this.conn.joinChatRoom({
|
|
86
|
+
roomId: this.chatRoomId
|
|
87
|
+
});
|
|
88
|
+
this._setConnectionState(_type.FcrChatRoomConnectionState.Connected);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
(0, _defineProperty2.default)(this, "_convertAgoraChatMessageToFcrChatRoomReceiveMessage", msg => {
|
|
92
|
+
// TODO: 没看到有 contentsType 字段
|
|
93
|
+
//@ts-ignore
|
|
94
|
+
switch (msg.type) {
|
|
95
|
+
case 'txt':
|
|
96
|
+
{
|
|
97
|
+
const message = {
|
|
98
|
+
id: msg.id,
|
|
99
|
+
//@ts-ignore
|
|
100
|
+
from: msg.ext.sender,
|
|
101
|
+
type: _type.FcrChatRoomMessageType.Text,
|
|
102
|
+
//@ts-ignore
|
|
103
|
+
timestamp: parseInt(msg.time),
|
|
104
|
+
//@ts-ignore
|
|
105
|
+
content: msg.msg,
|
|
106
|
+
//@ts-ignore
|
|
107
|
+
isPrivate: msg.ext.isPrivate
|
|
108
|
+
};
|
|
109
|
+
return message;
|
|
110
|
+
}
|
|
111
|
+
// TODO: 3.x
|
|
112
|
+
// case 'IMAGE': {
|
|
113
|
+
// const message: FcrChatRoomReceiveImageMessage = {
|
|
114
|
+
// id: msg.id,
|
|
115
|
+
// //@ts-ignore
|
|
116
|
+
// from: msg.ext.sender,
|
|
117
|
+
// type: FcrChatRoomMessageType.Image,
|
|
118
|
+
// //@ts-ignore
|
|
119
|
+
// timestamp: parseInt(msg.time),
|
|
120
|
+
// //@ts-ignore
|
|
121
|
+
// file: msg.url,
|
|
122
|
+
// //@ts-ignore
|
|
123
|
+
// isPrivate: msg.ext.isPrivate,
|
|
124
|
+
// };
|
|
125
|
+
// return message;
|
|
126
|
+
// }
|
|
127
|
+
}
|
|
128
|
+
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
|
|
129
|
+
});
|
|
130
|
+
(0, _defineProperty2.default)(this, "_convertFcrChatRoomSendBaseMessageToAgoraChatMessage", msg => {
|
|
131
|
+
var _message$to;
|
|
132
|
+
switch (msg.type) {
|
|
133
|
+
case _type.FcrChatRoomMessageType.Text:
|
|
134
|
+
const message = msg;
|
|
135
|
+
const isPrivate = !!((_message$to = message.to) !== null && _message$to !== void 0 && _message$to.length);
|
|
136
|
+
const localUserInfo = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
|
|
137
|
+
return _easemobWebsdk.default.message.create({
|
|
138
|
+
to: this.chatRoomId,
|
|
139
|
+
msg: message.content,
|
|
140
|
+
type: 'txt',
|
|
141
|
+
chatType: 'chatRoom',
|
|
142
|
+
ext: {
|
|
143
|
+
sender: (0, _user.convertRteUserToFcrUser)(localUserInfo),
|
|
144
|
+
roomUuid: this._scene.sceneId,
|
|
145
|
+
isPrivate
|
|
146
|
+
},
|
|
147
|
+
receiverList: message.to
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown local message type', new Error('unknown local message type'));
|
|
151
|
+
});
|
|
71
152
|
this._scene = _scene;
|
|
72
153
|
this._chatConnection = _chatConnection;
|
|
73
154
|
this._addLogObserver();
|
|
@@ -83,22 +164,22 @@ class FcrChatRoomControlImpl {
|
|
|
83
164
|
return this._connectionState;
|
|
84
165
|
}
|
|
85
166
|
async sendMessage(message) {
|
|
167
|
+
var _message$to2;
|
|
86
168
|
const msg = this._convertFcrChatRoomSendBaseMessageToAgoraChatMessage(message);
|
|
87
169
|
await this.conn.send(msg);
|
|
88
170
|
const localUserInfo = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
|
|
89
|
-
const res = {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}),
|
|
171
|
+
const res = _objectSpread(_objectSpread({}, message.type === _type.FcrChatRoomMessageType.Text ? {
|
|
172
|
+
content: message.content
|
|
173
|
+
} : {
|
|
174
|
+
file: message.file
|
|
175
|
+
}), {}, {
|
|
95
176
|
from: (0, _user.convertRteUserToFcrUser)(localUserInfo),
|
|
96
177
|
id: msg.id,
|
|
97
178
|
type: _type.FcrChatRoomMessageType.Text,
|
|
98
179
|
properties: message.properties,
|
|
99
180
|
timestamp: Date.now(),
|
|
100
|
-
isPrivate: !!message.to
|
|
101
|
-
};
|
|
181
|
+
isPrivate: !!((_message$to2 = message.to) !== null && _message$to2 !== void 0 && _message$to2.length)
|
|
182
|
+
});
|
|
102
183
|
return res;
|
|
103
184
|
}
|
|
104
185
|
addObserver(observer) {
|
|
@@ -128,21 +209,12 @@ class FcrChatRoomControlImpl {
|
|
|
128
209
|
}
|
|
129
210
|
});
|
|
130
211
|
}
|
|
131
|
-
_joinChatRoom = async state => {
|
|
132
|
-
if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Disconnected && this.chatRoomId) {
|
|
133
|
-
this._setConnectionState(_type.FcrChatRoomConnectionState.Connecting);
|
|
134
|
-
await this.conn.joinChatRoom({
|
|
135
|
-
roomId: this.chatRoomId
|
|
136
|
-
});
|
|
137
|
-
this._setConnectionState(_type.FcrChatRoomConnectionState.Connected);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
212
|
_removeEventListener() {
|
|
141
|
-
this.conn.removeEventHandler(
|
|
213
|
+
this.conn.removeEventHandler("chatroom".concat(this._scene.sceneId));
|
|
142
214
|
}
|
|
143
215
|
_addEventListener() {
|
|
144
216
|
this._removeEventListener();
|
|
145
|
-
this.conn.addEventHandler(
|
|
217
|
+
this.conn.addEventHandler("chatroom".concat(this._scene.sceneId), {
|
|
146
218
|
onTextMessage: msg => {
|
|
147
219
|
if (msg.to !== this.chatRoomId) {
|
|
148
220
|
return;
|
|
@@ -187,66 +259,6 @@ class FcrChatRoomControlImpl {
|
|
|
187
259
|
// }
|
|
188
260
|
// };
|
|
189
261
|
}
|
|
190
|
-
_convertAgoraChatMessageToFcrChatRoomReceiveMessage = msg => {
|
|
191
|
-
// TODO: 没看到有 contentsType 字段
|
|
192
|
-
//@ts-ignore
|
|
193
|
-
switch (msg.type) {
|
|
194
|
-
case 'txt':
|
|
195
|
-
{
|
|
196
|
-
const message = {
|
|
197
|
-
id: msg.id,
|
|
198
|
-
//@ts-ignore
|
|
199
|
-
from: msg.ext.sender,
|
|
200
|
-
type: _type.FcrChatRoomMessageType.Text,
|
|
201
|
-
//@ts-ignore
|
|
202
|
-
timestamp: parseInt(msg.time),
|
|
203
|
-
//@ts-ignore
|
|
204
|
-
content: msg.msg,
|
|
205
|
-
//@ts-ignore
|
|
206
|
-
isPrivate: msg.ext.isPrivate
|
|
207
|
-
};
|
|
208
|
-
return message;
|
|
209
|
-
}
|
|
210
|
-
// TODO: 3.x
|
|
211
|
-
// case 'IMAGE': {
|
|
212
|
-
// const message: FcrChatRoomReceiveImageMessage = {
|
|
213
|
-
// id: msg.id,
|
|
214
|
-
// //@ts-ignore
|
|
215
|
-
// from: msg.ext.sender,
|
|
216
|
-
// type: FcrChatRoomMessageType.Image,
|
|
217
|
-
// //@ts-ignore
|
|
218
|
-
// timestamp: parseInt(msg.time),
|
|
219
|
-
// //@ts-ignore
|
|
220
|
-
// file: msg.url,
|
|
221
|
-
// //@ts-ignore
|
|
222
|
-
// isPrivate: msg.ext.isPrivate,
|
|
223
|
-
// };
|
|
224
|
-
// return message;
|
|
225
|
-
// }
|
|
226
|
-
}
|
|
227
|
-
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
|
|
228
|
-
};
|
|
229
|
-
_convertFcrChatRoomSendBaseMessageToAgoraChatMessage = msg => {
|
|
230
|
-
switch (msg.type) {
|
|
231
|
-
case _type.FcrChatRoomMessageType.Text:
|
|
232
|
-
const message = msg;
|
|
233
|
-
const isPrivate = !!message.to?.length;
|
|
234
|
-
const localUserInfo = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
|
|
235
|
-
return _easemobWebsdk.default.message.create({
|
|
236
|
-
to: this.chatRoomId,
|
|
237
|
-
msg: message.content,
|
|
238
|
-
type: 'txt',
|
|
239
|
-
chatType: 'chatRoom',
|
|
240
|
-
ext: {
|
|
241
|
-
sender: (0, _user.convertRteUserToFcrUser)(localUserInfo),
|
|
242
|
-
roomUuid: this._scene.sceneId,
|
|
243
|
-
isPrivate
|
|
244
|
-
},
|
|
245
|
-
receiverList: message.to
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown local message type', new Error('unknown local message type'));
|
|
249
|
-
};
|
|
250
262
|
_setConnectionState(state) {
|
|
251
263
|
this._connectionState = state;
|
|
252
264
|
this._observable.notifyObservers('onConnectionStateUpdated', this._scene.sceneId, state);
|
|
@@ -350,4 +362,6 @@ class FcrChatRoomControlImpl {
|
|
|
350
362
|
// });
|
|
351
363
|
// }
|
|
352
364
|
}
|
|
353
|
-
exports.FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
365
|
+
exports.FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
366
|
+
_FcrChatRoomControlImpl = FcrChatRoomControlImpl;
|
|
367
|
+
[_initProto] = _applyDecs(_FcrChatRoomControlImpl, [[_logger.trace, 2, "join"], [_logger.trace, 2, "getConnectionState"], [_logger.trace, 2, "sendMessage"], [_logger.trace, 2, "leave"]], []).e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
|
5
|
+
require("core-js/modules/es.array.push.js");
|
|
6
|
+
require("core-js/modules/esnext.function.metadata.js");
|
|
7
|
+
require("core-js/modules/esnext.map.delete-all.js");
|
|
8
|
+
require("core-js/modules/esnext.map.emplace.js");
|
|
9
|
+
require("core-js/modules/esnext.map.every.js");
|
|
10
|
+
require("core-js/modules/esnext.map.filter.js");
|
|
11
|
+
require("core-js/modules/esnext.map.find.js");
|
|
12
|
+
require("core-js/modules/esnext.map.find-key.js");
|
|
13
|
+
require("core-js/modules/esnext.map.includes.js");
|
|
14
|
+
require("core-js/modules/esnext.map.key-of.js");
|
|
15
|
+
require("core-js/modules/esnext.map.map-keys.js");
|
|
16
|
+
require("core-js/modules/esnext.map.map-values.js");
|
|
17
|
+
require("core-js/modules/esnext.map.merge.js");
|
|
18
|
+
require("core-js/modules/esnext.map.reduce.js");
|
|
19
|
+
require("core-js/modules/esnext.map.some.js");
|
|
20
|
+
require("core-js/modules/esnext.map.update.js");
|
|
21
|
+
require("core-js/modules/esnext.symbol.metadata.js");
|
|
22
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
23
|
+
Object.defineProperty(exports, "__esModule", {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
exports.FcrAbilityControlImpl = void 0;
|
|
27
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
28
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
29
|
+
var _imports = require("../../imports");
|
|
30
|
+
var _logger = require("../../utilities/logger");
|
|
31
|
+
var _FcrAbilityControlImpl;
|
|
32
|
+
let _initProto;
|
|
33
|
+
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)]; } }; }
|
|
34
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
35
|
+
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); }
|
|
36
|
+
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; }
|
|
37
|
+
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; }
|
|
38
|
+
/**
|
|
39
|
+
* 平台能力控制的实现类
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
class FcrAbilityControlImpl {
|
|
43
|
+
constructor(_scene) {
|
|
44
|
+
//@internal
|
|
45
|
+
(0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
|
|
46
|
+
prefix: 'FcrAbilityControlImpl'
|
|
47
|
+
})));
|
|
48
|
+
this._scene = _scene;
|
|
49
|
+
}
|
|
50
|
+
getPlatformAbility(ability) {
|
|
51
|
+
const platforms = this._scene.getScenePropertiesByKeyPath("setting.ability.".concat(ability));
|
|
52
|
+
if (!Array.isArray(platforms)) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
return platforms;
|
|
56
|
+
}
|
|
57
|
+
isAbilitySupported(ability) {
|
|
58
|
+
const platforms = this.getPlatformAbility(ability);
|
|
59
|
+
const currentPlatform = (0, _imports.getPlatform)();
|
|
60
|
+
return platforms.includes(currentPlatform);
|
|
61
|
+
}
|
|
62
|
+
isPlatformAbilitySupported(platform, ability) {
|
|
63
|
+
const platforms = this.getPlatformAbility(ability);
|
|
64
|
+
return platforms.includes(platform);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.FcrAbilityControlImpl = FcrAbilityControlImpl;
|
|
68
|
+
_FcrAbilityControlImpl = FcrAbilityControlImpl;
|
|
69
|
+
[_initProto] = _applyDecs(_FcrAbilityControlImpl, [[_logger.trace, 2, "getPlatformAbility"], [_logger.trace, 2, "isAbilitySupported"], [_logger.trace, 2, "isPlatformAbilitySupported"]], []).e;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FcrPlatform } from '../../type';
|
|
2
|
+
export declare enum FcrAbility {
|
|
3
|
+
RoleHost = "role:host",
|
|
4
|
+
RoomDetail = "room:detail"
|
|
5
|
+
}
|
|
6
|
+
export interface FcrAbilityControl {
|
|
7
|
+
isAbilitySupported(ability: FcrAbility): boolean;
|
|
8
|
+
isPlatformAbilitySupported(platform: FcrPlatform, ability: FcrAbility): boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FcrAbility = void 0;
|
|
7
|
+
let FcrAbility = exports.FcrAbility = /*#__PURE__*/function (FcrAbility) {
|
|
8
|
+
FcrAbility["RoleHost"] = "role:host";
|
|
9
|
+
FcrAbility["RoomDetail"] = "room:detail";
|
|
10
|
+
return FcrAbility;
|
|
11
|
+
}({});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|