fcr-core 3.7.5 → 3.7.7-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/lib/chat-connection/index.js +34 -20
  2. package/lib/engine/index.js +62 -69
  3. package/lib/imports.js +1 -0
  4. package/lib/media-control/desktop.js +13 -8
  5. package/lib/media-control/mobile.js +17 -12
  6. package/lib/monitor-control/index.js +9 -4
  7. package/lib/peer-session/index.js +47 -38
  8. package/lib/plugins/chatroom.js +217 -202
  9. package/lib/room-control/ability-control/index.js +13 -8
  10. package/lib/room-control/group-control/index.js +20 -15
  11. package/lib/room-control/helpers/validation-helper.js +1 -1
  12. package/lib/room-control/index.js +53 -36
  13. package/lib/room-control/interpreter-control/index.js +23 -17
  14. package/lib/room-control/interpreter-control/room.js +6 -4
  15. package/lib/room-control/join-before-host-waitingroom-control/index.js +6 -4
  16. package/lib/room-control/mainroom-control/index.js +24 -16
  17. package/lib/room-control/privilege-control/helper.js +8 -5
  18. package/lib/room-control/privilege-control/index.js +25 -18
  19. package/lib/room-control/room-connector-control/index.js +22 -15
  20. package/lib/room-control/room-control-factory.js +2 -1
  21. package/lib/room-control/room-session/index.js +47 -38
  22. package/lib/room-control/shared-cache.js +36 -29
  23. package/lib/room-control/sharing-control/index.js +40 -29
  24. package/lib/room-control/stream-control/index.js +177 -172
  25. package/lib/room-control/user-control/index.js +142 -135
  26. package/lib/room-control/waitingroom-control/index.js +13 -8
  27. package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +25 -18
  28. package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +26 -15
  29. package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +62 -52
  30. package/lib/room-control/whiteboard-control-v2/index.js +35 -24
  31. package/lib/room-control/whiteboard-control-v2/main-window.js +27 -22
  32. package/lib/room-control/whiteboard-control-v2/utils.js +5 -5
  33. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +32 -23
  34. package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +5 -3
  35. package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +53 -41
  36. package/lib/room-router/index.js +67 -34
  37. package/lib/room-router/type.d.ts +4 -0
  38. package/lib/service/api.d.ts +12 -1
  39. package/lib/service/api.js +98 -88
  40. package/lib/utilities/collection.js +3 -2
  41. package/lib/utilities/error-helpers.js +32 -26
  42. package/lib/utilities/error.js +9 -8
  43. package/lib/utilities/join-helper.js +22 -18
  44. package/lib/utilities/logger.js +2 -2
  45. package/lib/utilities/parameters.js +8 -4
  46. package/lib/utilities/retry-helpers.js +1 -0
  47. package/lib/utilities/shared-storage.js +1 -0
  48. package/lib/utilities/storage.js +1 -0
  49. package/lib/utilities/stream.js +16 -11
  50. package/lib/utilities/user.js +4 -3
  51. package/lib/utilities/validate-params.js +2 -1
  52. package/package.json +4 -4
@@ -1,7 +1,10 @@
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");
4
5
  require("core-js/modules/esnext.function.metadata.js");
6
+ require("core-js/modules/esnext.iterator.filter.js");
7
+ require("core-js/modules/esnext.iterator.for-each.js");
5
8
  require("core-js/modules/esnext.map.delete-all.js");
6
9
  require("core-js/modules/esnext.map.emplace.js");
7
10
  require("core-js/modules/esnext.map.every.js");
@@ -22,8 +25,12 @@ Object.defineProperty(exports, "__esModule", {
22
25
  value: true
23
26
  });
24
27
  exports.FcrChatRoomControlImpl = void 0;
28
+ require("core-js/modules/es.error.cause.js");
29
+ require("core-js/modules/es.regexp.exec.js");
25
30
  require("core-js/modules/esnext.iterator.constructor.js");
26
31
  require("core-js/modules/esnext.iterator.map.js");
32
+ require("core-js/modules/web.dom-collections.iterator.js");
33
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
34
  var _imports = require("../imports");
28
35
  var _observable = require("agora-foundation/lib/utilities/observable");
29
36
  var _easemobWebsdk = _interopRequireDefault(require("easemob-websdk"));
@@ -34,38 +41,20 @@ var _type2 = require("../chat-connection/type");
34
41
  var _logger = require("../utilities/logger");
35
42
  var _validateParams = _interopRequireDefault(require("../utilities/validate-params"));
36
43
  var _schema = require("../schema");
37
- var _staticBlock;
38
- let _initProto, _sendMessageDecs;
44
+ var _FcrChatRoomControlImpl;
45
+ let _initProto, _sendMessageDecs, _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
48
  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)]; } }; }
40
49
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
41
50
  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); }
42
51
  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; }
43
52
  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 = (_sendMessageDecs = [_imports.trace, (0, _validateParams.default)(_schema.messageSchema, _schema.progressSchema.optional())], "logger");
44
54
  /**
45
55
  * @internal
46
56
  */
47
57
  class FcrChatRoomControlImpl {
48
- [(_sendMessageDecs = [_imports.trace, (0, _validateParams.default)(_schema.messageSchema, _schema.progressSchema.optional())], "logger")] = (() => (_initProto(this), (0, _logger.createLogger)({
49
- prefix: 'FcrChatRoomControlImpl'
50
- })))();
51
- _observable = (() => new _observable.AgoraObservable())();
52
- _connectionState = (() => _type.FcrChatRoomConnectionState.Disconnected)();
53
- _chatConnectionObserver = {
54
- onConnectionStateUpdated: async state => {
55
- // im reconnect
56
- this.logger.info(`onConnectionStateUpdated, chatConnectionState: ${state}, chatControlState: ${this.getConnectionState()}`);
57
- if (state === _type2.FcrChatConnectionState.DISCONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Connected) {
58
- this._setConnectionState(_type.FcrChatRoomConnectionState.Disconnected);
59
- } else if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() !== _type.FcrChatRoomConnectionState.Connected) {
60
- this._removeEventListener();
61
- this._addEventListener();
62
- await this._joinChatRoom(state);
63
- }
64
- },
65
- onConnectionLoginSuccess: () => {
66
- this._addEventListener();
67
- }
68
- };
69
58
  get conn() {
70
59
  if (!this._chatConnection.getConnectionInstance()) {
71
60
  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'));
@@ -76,6 +65,195 @@ class FcrChatRoomControlImpl {
76
65
  return this._scene.getScenePropertiesByKeyPath('widgets.easemobIM.extra.chatRoomId');
77
66
  }
78
67
  constructor(_scene, _chatConnection, _sharedCache) {
68
+ (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
69
+ prefix: 'FcrChatRoomControlImpl'
70
+ })));
71
+ (0, _defineProperty2.default)(this, "_observable", new _observable.AgoraObservable());
72
+ (0, _defineProperty2.default)(this, "_connectionState", _type.FcrChatRoomConnectionState.Disconnected);
73
+ (0, _defineProperty2.default)(this, "_chatConnectionObserver", {
74
+ onConnectionStateUpdated: async state => {
75
+ // im reconnect
76
+ this.logger.info("onConnectionStateUpdated, chatConnectionState: ".concat(state, ", chatControlState: ").concat(this.getConnectionState()));
77
+ if (state === _type2.FcrChatConnectionState.DISCONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Connected) {
78
+ this._setConnectionState(_type.FcrChatRoomConnectionState.Disconnected);
79
+ } else if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() !== _type.FcrChatRoomConnectionState.Connected) {
80
+ this._removeEventListener();
81
+ this._addEventListener();
82
+ await this._joinChatRoom(state);
83
+ }
84
+ },
85
+ onConnectionLoginSuccess: () => {
86
+ this._addEventListener();
87
+ }
88
+ });
89
+ (0, _defineProperty2.default)(this, "_joinChatRoom", async state => {
90
+ this.logger.info("joinChatRoom, chatConnectionState: ".concat(state, ", chatControlState: ").concat(this.getConnectionState()));
91
+ if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Disconnected && this.chatRoomId) {
92
+ this._setConnectionState(_type.FcrChatRoomConnectionState.Connecting);
93
+ this.logger.info("start join chat room, room id: ".concat(this.chatRoomId, ", scene id: ").concat(this._scene.sceneId));
94
+ let error = null;
95
+ [error] = await (0, _imports.to)((0, _imports.retryAttempt)(async () => {
96
+ await this.conn.joinChatRoom({
97
+ roomId: this.chatRoomId
98
+ });
99
+ }, [], {
100
+ retriesMax: 4
101
+ }).fail(async _ref2 => {
102
+ let {
103
+ error,
104
+ timeFn,
105
+ currentRetry
106
+ } = _ref2;
107
+ this.logger.error("retry to join chat room, ".concat(error.message, ", retry ").concat(currentRetry, " times"));
108
+ await timeFn();
109
+ return true;
110
+ }).exec());
111
+ if (error) {
112
+ this._setConnectionState(_type.FcrChatRoomConnectionState.Disconnected);
113
+ throw error;
114
+ }
115
+ this._setConnectionState(_type.FcrChatRoomConnectionState.Connected);
116
+ }
117
+ });
118
+ (0, _defineProperty2.default)(this, "_convertAgoraChatMessageToFcrChatRoomReceiveMessage", msg => {
119
+ // TODO: 没看到有 contentsType 字段
120
+ //@ts-ignore
121
+ switch (msg.type) {
122
+ case 'txt':
123
+ {
124
+ var _msg$ext, _msg$ext2;
125
+ const message = {
126
+ id: msg.id,
127
+ //@ts-ignore
128
+ from: msg.ext.sender,
129
+ type: _type.FcrChatRoomMessageType.Text,
130
+ //@ts-ignore
131
+ timestamp: parseInt(msg.time),
132
+ //@ts-ignore
133
+ content: msg.msg,
134
+ isPrivate: (_msg$ext = msg.ext) === null || _msg$ext === void 0 ? void 0 : _msg$ext.isPrivate,
135
+ properties: (_msg$ext2 = msg.ext) === null || _msg$ext2 === void 0 ? void 0 : _msg$ext2.properties
136
+ };
137
+ return message;
138
+ }
139
+ case 'img':
140
+ {
141
+ var _msg$ext3, _msg$ext4, _msg$ext5;
142
+ const message = {
143
+ id: msg.id,
144
+ from: (_msg$ext3 = msg.ext) === null || _msg$ext3 === void 0 ? void 0 : _msg$ext3.sender,
145
+ type: _type.FcrChatRoomMessageType.Image,
146
+ //@ts-ignore
147
+ timestamp: parseInt(msg.time),
148
+ url: msg.url || '',
149
+ isPrivate: (_msg$ext4 = msg.ext) === null || _msg$ext4 === void 0 ? void 0 : _msg$ext4.isPrivate,
150
+ properties: (_msg$ext5 = msg.ext) === null || _msg$ext5 === void 0 ? void 0 : _msg$ext5.properties
151
+ };
152
+ return message;
153
+ }
154
+ }
155
+ throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
156
+ });
157
+ (0, _defineProperty2.default)(this, "_convertAgoraChatHistoryMessageToFcrChatRoomReceiveMessage", msg => {
158
+ // TODO: 没看到有 contentsType 字段
159
+ //@ts-ignore
160
+ switch (msg.contentsType) {
161
+ case 'TEXT':
162
+ {
163
+ var _msg$ext6;
164
+ const message = {
165
+ id: msg.id,
166
+ //@ts-ignore
167
+ from: msg.ext.sender,
168
+ type: _type.FcrChatRoomMessageType.Text,
169
+ //@ts-ignore
170
+ timestamp: parseInt(msg.time),
171
+ //@ts-ignore
172
+ content: msg.data,
173
+ //@ts-ignore
174
+ isPrivate: msg.ext.isPrivate,
175
+ //@ts-ignore
176
+ properties: (_msg$ext6 = msg.ext) === null || _msg$ext6 === void 0 ? void 0 : _msg$ext6.properties
177
+ };
178
+ return message;
179
+ }
180
+ case 'IMAGE':
181
+ {
182
+ var _msg$ext7, _msg$ext8, _msg$ext9;
183
+ const message = {
184
+ id: msg.id,
185
+ //@ts-ignore
186
+ from: (_msg$ext7 = msg.ext) === null || _msg$ext7 === void 0 ? void 0 : _msg$ext7.sender,
187
+ type: _type.FcrChatRoomMessageType.Image,
188
+ //@ts-ignore
189
+ timestamp: parseInt(msg.time),
190
+ //@ts-ignore
191
+ url: msg.url || '',
192
+ //@ts-ignore
193
+ isPrivate: (_msg$ext8 = msg.ext) === null || _msg$ext8 === void 0 ? void 0 : _msg$ext8.isPrivate,
194
+ //@ts-ignore
195
+ properties: (_msg$ext9 = msg.ext) === null || _msg$ext9 === void 0 ? void 0 : _msg$ext9.properties
196
+ };
197
+ return message;
198
+ }
199
+ }
200
+ throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
201
+ });
202
+ (0, _defineProperty2.default)(this, "_convertFcrChatRoomSendBaseMessageToAgoraChatMessage", (msg, progress) => {
203
+ switch (msg.type) {
204
+ case _type.FcrChatRoomMessageType.Text:
205
+ {
206
+ var _message$to;
207
+ const message = msg;
208
+ const isPrivate = !!((_message$to = message.to) !== null && _message$to !== void 0 && _message$to.length);
209
+ const localUserId = this._scene.getLocalUser().getLocalUserId();
210
+ const localUserInfo = this._scene.getUser(localUserId);
211
+ return _easemobWebsdk.default.message.create({
212
+ to: this.chatRoomId,
213
+ msg: message.content,
214
+ type: 'txt',
215
+ chatType: 'chatRoom',
216
+ ext: {
217
+ sender: (0, _user.convertRteUserToFcrUser)(localUserInfo, this._roomCache),
218
+ roomUuid: this._scene.sceneId,
219
+ isPrivate,
220
+ properties: msg.properties
221
+ },
222
+ receiverList: message.to
223
+ });
224
+ }
225
+ case _type.FcrChatRoomMessageType.Image:
226
+ {
227
+ var _imageMessage$to;
228
+ const imageMessage = msg;
229
+ const isPrivateImage = !!((_imageMessage$to = imageMessage.to) !== null && _imageMessage$to !== void 0 && _imageMessage$to.length);
230
+ const localUser = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
231
+ return _easemobWebsdk.default.message.create({
232
+ to: this.chatRoomId,
233
+ type: 'img',
234
+ chatType: 'chatRoom',
235
+ url: imageMessage.file.filePath,
236
+ file: {
237
+ filename: imageMessage.file.fileName,
238
+ filetype: imageMessage.file.fileType,
239
+ data: imageMessage.file.data,
240
+ url: ''
241
+ },
242
+ ext: {
243
+ sender: (0, _user.convertRteUserToFcrUser)(localUser, this._roomCache),
244
+ roomUuid: this._scene.sceneId,
245
+ isPrivate: isPrivateImage,
246
+ properties: msg.properties
247
+ },
248
+ receiverList: imageMessage.to,
249
+ onFileUploadProgress: e => {
250
+ progress === null || progress === void 0 || progress(Math.round(e.loaded / e.total * 100));
251
+ }
252
+ });
253
+ }
254
+ }
255
+ throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown local message type', new Error('unknown local message type'));
256
+ });
79
257
  this._scene = _scene;
80
258
  this._chatConnection = _chatConnection;
81
259
  this._sharedCache = _sharedCache;
@@ -114,41 +292,12 @@ class FcrChatRoomControlImpl {
114
292
  }
115
293
  });
116
294
  }
117
- _joinChatRoom = async state => {
118
- this.logger.info(`joinChatRoom, chatConnectionState: ${state}, chatControlState: ${this.getConnectionState()}`);
119
- if (state === _type2.FcrChatConnectionState.CONNECTED && this.getConnectionState() === _type.FcrChatRoomConnectionState.Disconnected && this.chatRoomId) {
120
- this._setConnectionState(_type.FcrChatRoomConnectionState.Connecting);
121
- this.logger.info(`start join chat room, room id: ${this.chatRoomId}, scene id: ${this._scene.sceneId}`);
122
- let error = null;
123
- [error] = await (0, _imports.to)((0, _imports.retryAttempt)(async () => {
124
- await this.conn.joinChatRoom({
125
- roomId: this.chatRoomId
126
- });
127
- }, [], {
128
- retriesMax: 4
129
- }).fail(async _ref => {
130
- let {
131
- error,
132
- timeFn,
133
- currentRetry
134
- } = _ref;
135
- this.logger.error(`retry to join chat room, ${error.message}, retry ${currentRetry} times`);
136
- await timeFn();
137
- return true;
138
- }).exec());
139
- if (error) {
140
- this._setConnectionState(_type.FcrChatRoomConnectionState.Disconnected);
141
- throw error;
142
- }
143
- this._setConnectionState(_type.FcrChatRoomConnectionState.Connected);
144
- }
145
- };
146
295
  _removeEventListener() {
147
- this.conn.removeEventHandler(`chatroom${this._scene.sceneId}`);
296
+ this.conn.removeEventHandler("chatroom".concat(this._scene.sceneId));
148
297
  }
149
298
  _addEventListener() {
150
299
  this._removeEventListener();
151
- this.conn.addEventHandler(`chatroom${this._scene.sceneId}`, {
300
+ this.conn.addEventHandler("chatroom".concat(this._scene.sceneId), {
152
301
  onTextMessage: msg => {
153
302
  if (msg.to !== this.chatRoomId) {
154
303
  return;
@@ -163,10 +312,9 @@ class FcrChatRoomControlImpl {
163
312
  }
164
313
  // 这里的数据结构和 onTextMessage 不一样,实际上contentsType是img ,type是chatroom,
165
314
  // 但是因为在onPictureMessage的回调中,所以这里直接用type: 'img',后续可以考虑优化
166
- const message = this._convertAgoraChatMessageToFcrChatRoomReceiveMessage({
167
- ...msg,
315
+ const message = this._convertAgoraChatMessageToFcrChatRoomReceiveMessage(_objectSpread(_objectSpread({}, msg), {}, {
168
316
  type: 'img'
169
- });
317
+ }));
170
318
  this._observable.notifyObservers('onImageMessageReceived', this._scene.sceneId, message);
171
319
  };
172
320
 
@@ -194,158 +342,25 @@ class FcrChatRoomControlImpl {
194
342
  // }
195
343
  // };
196
344
  }
197
- _convertAgoraChatMessageToFcrChatRoomReceiveMessage = msg => {
198
- // TODO: 没看到有 contentsType 字段
199
- //@ts-ignore
200
- switch (msg.type) {
201
- case 'txt':
202
- {
203
- const message = {
204
- id: msg.id,
205
- //@ts-ignore
206
- from: msg.ext.sender,
207
- type: _type.FcrChatRoomMessageType.Text,
208
- //@ts-ignore
209
- timestamp: parseInt(msg.time),
210
- //@ts-ignore
211
- content: msg.msg,
212
- isPrivate: msg.ext?.isPrivate,
213
- properties: msg.ext?.properties
214
- };
215
- return message;
216
- }
217
- case 'img':
218
- {
219
- const message = {
220
- id: msg.id,
221
- from: msg.ext?.sender,
222
- type: _type.FcrChatRoomMessageType.Image,
223
- //@ts-ignore
224
- timestamp: parseInt(msg.time),
225
- url: msg.url || '',
226
- isPrivate: msg.ext?.isPrivate,
227
- properties: msg.ext?.properties
228
- };
229
- return message;
230
- }
231
- }
232
- throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
233
- };
234
- _convertAgoraChatHistoryMessageToFcrChatRoomReceiveMessage = msg => {
235
- // TODO: 没看到有 contentsType 字段
236
- //@ts-ignore
237
- switch (msg.contentsType) {
238
- case 'TEXT':
239
- {
240
- const message = {
241
- id: msg.id,
242
- //@ts-ignore
243
- from: msg.ext.sender,
244
- type: _type.FcrChatRoomMessageType.Text,
245
- //@ts-ignore
246
- timestamp: parseInt(msg.time),
247
- //@ts-ignore
248
- content: msg.data,
249
- //@ts-ignore
250
- isPrivate: msg.ext.isPrivate,
251
- //@ts-ignore
252
- properties: msg.ext?.properties
253
- };
254
- return message;
255
- }
256
- case 'IMAGE':
257
- {
258
- const message = {
259
- id: msg.id,
260
- //@ts-ignore
261
- from: msg.ext?.sender,
262
- type: _type.FcrChatRoomMessageType.Image,
263
- //@ts-ignore
264
- timestamp: parseInt(msg.time),
265
- //@ts-ignore
266
- url: msg.url || '',
267
- //@ts-ignore
268
- isPrivate: msg.ext?.isPrivate,
269
- //@ts-ignore
270
- properties: msg.ext?.properties
271
- };
272
- return message;
273
- }
274
- }
275
- throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown remote message type', new Error('unknown remote message type'));
276
- };
277
- _convertFcrChatRoomSendBaseMessageToAgoraChatMessage = (msg, progress) => {
278
- switch (msg.type) {
279
- case _type.FcrChatRoomMessageType.Text:
280
- {
281
- const message = msg;
282
- const isPrivate = !!message.to?.length;
283
- const localUserId = this._scene.getLocalUser().getLocalUserId();
284
- const localUserInfo = this._scene.getUser(localUserId);
285
- return _easemobWebsdk.default.message.create({
286
- to: this.chatRoomId,
287
- msg: message.content,
288
- type: 'txt',
289
- chatType: 'chatRoom',
290
- ext: {
291
- sender: (0, _user.convertRteUserToFcrUser)(localUserInfo, this._roomCache),
292
- roomUuid: this._scene.sceneId,
293
- isPrivate,
294
- properties: msg.properties
295
- },
296
- receiverList: message.to
297
- });
298
- }
299
- case _type.FcrChatRoomMessageType.Image:
300
- {
301
- const imageMessage = msg;
302
- const isPrivateImage = !!imageMessage.to?.length;
303
- const localUser = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
304
- return _easemobWebsdk.default.message.create({
305
- to: this.chatRoomId,
306
- type: 'img',
307
- chatType: 'chatRoom',
308
- url: imageMessage.file.filePath,
309
- file: {
310
- filename: imageMessage.file.fileName,
311
- filetype: imageMessage.file.fileType,
312
- data: imageMessage.file.data,
313
- url: ''
314
- },
315
- ext: {
316
- sender: (0, _user.convertRteUserToFcrUser)(localUser, this._roomCache),
317
- roomUuid: this._scene.sceneId,
318
- isPrivate: isPrivateImage,
319
- properties: msg.properties
320
- },
321
- receiverList: imageMessage.to,
322
- onFileUploadProgress: e => {
323
- progress?.(Math.round(e.loaded / e.total * 100));
324
- }
325
- });
326
- }
327
- }
328
- throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_CHATROOM, _error.FcrErrorCode.UNDEFINED_ERROR, 'unknown local message type', new Error('unknown local message type'));
329
- };
330
345
  async sendMessage(message, progress) {
346
+ var _message$to2;
331
347
  const msg = this._convertFcrChatRoomSendBaseMessageToAgoraChatMessage(message, progress);
332
348
  const sendMsgRes = await this.conn.send(msg);
333
349
  const localUserInfo = this._scene.getUser(this._scene.getLocalUser().getLocalUserId());
334
- const res = {
335
- ...(message.type === _type.FcrChatRoomMessageType.Text ? {
336
- content: message.content
337
- } :
338
- // @ts-ignore
339
- {
340
- url: sendMsgRes.message.url
341
- }),
350
+ const res = _objectSpread(_objectSpread({}, message.type === _type.FcrChatRoomMessageType.Text ? {
351
+ content: message.content
352
+ } :
353
+ // @ts-ignore
354
+ {
355
+ url: sendMsgRes.message.url
356
+ }), {}, {
342
357
  from: (0, _user.convertRteUserToFcrUser)(localUserInfo, this._roomCache),
343
358
  id: sendMsgRes.serverMsgId,
344
359
  type: message.type,
345
360
  properties: message.properties,
346
361
  timestamp: Date.now(),
347
- isPrivate: !!message.to?.length
348
- };
362
+ isPrivate: !!((_message$to2 = message.to) !== null && _message$to2 !== void 0 && _message$to2.length)
363
+ });
349
364
  return res;
350
365
  }
351
366
  addObserver(observer) {
@@ -433,7 +448,7 @@ class FcrChatRoomControlImpl {
433
448
  // },
434
449
  // });
435
450
  // }
436
- static #_ = (() => _staticBlock = () => [_initProto] = _applyDecs(this, [[_imports.trace, 2, "join"], [_imports.trace, 2, "getConnectionState"], [_imports.trace, 2, "leave"], [_sendMessageDecs, 2, "sendMessage"], [_imports.trace, 2, "addObserver"], [_imports.trace, 2, "removeObserver"]], []).e)();
437
451
  }
438
452
  exports.FcrChatRoomControlImpl = FcrChatRoomControlImpl;
439
- _staticBlock();
453
+ _FcrChatRoomControlImpl = FcrChatRoomControlImpl;
454
+ [_initProto] = _applyDecs(_FcrChatRoomControlImpl, [[_imports.trace, 2, "join"], [_imports.trace, 2, "getConnectionState"], [_imports.trace, 2, "leave"], [_sendMessageDecs, 2, "sendMessage"], [_imports.trace, 2, "addObserver"], [_imports.trace, 2, "removeObserver"]], []).e;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.symbol.description.js");
4
+ require("core-js/modules/es.error.cause.js");
3
5
  require("core-js/modules/es.array.push.js");
4
6
  require("core-js/modules/esnext.function.metadata.js");
5
7
  require("core-js/modules/esnext.map.delete-all.js");
@@ -17,13 +19,16 @@ require("core-js/modules/esnext.map.reduce.js");
17
19
  require("core-js/modules/esnext.map.some.js");
18
20
  require("core-js/modules/esnext.map.update.js");
19
21
  require("core-js/modules/esnext.symbol.metadata.js");
22
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
20
23
  Object.defineProperty(exports, "__esModule", {
21
24
  value: true
22
25
  });
23
26
  exports.FcrAbilityControlImpl = void 0;
27
+ require("core-js/modules/web.dom-collections.iterator.js");
28
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
24
29
  var _imports = require("../../imports");
25
30
  var _logger = require("../../utilities/logger");
26
- var _staticBlock;
31
+ var _FcrAbilityControlImpl;
27
32
  let _initProto;
28
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)]; } }; }
29
34
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
@@ -35,15 +40,15 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
35
40
  * @internal
36
41
  */
37
42
  class FcrAbilityControlImpl {
38
- //@internal
39
- logger = (() => (_initProto(this), (0, _logger.createLogger)({
40
- prefix: 'FcrAbilityControlImpl'
41
- })))();
42
43
  constructor(_scene) {
44
+ //@internal
45
+ (0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
46
+ prefix: 'FcrAbilityControlImpl'
47
+ })));
43
48
  this._scene = _scene;
44
49
  }
45
50
  getPlatformAbility(ability) {
46
- const platforms = this._scene.getScenePropertiesByKeyPath(`setting.ability.${ability}`);
51
+ const platforms = this._scene.getScenePropertiesByKeyPath("setting.ability.".concat(ability));
47
52
  if (!Array.isArray(platforms)) {
48
53
  return [];
49
54
  }
@@ -58,7 +63,7 @@ class FcrAbilityControlImpl {
58
63
  const platforms = this.getPlatformAbility(ability);
59
64
  return platforms.includes(platform);
60
65
  }
61
- static #_ = (() => _staticBlock = () => [_initProto] = _applyDecs(this, [[_imports.trace, 2, "isPlatformAbilitySupported"]], []).e)();
62
66
  }
63
67
  exports.FcrAbilityControlImpl = FcrAbilityControlImpl;
64
- _staticBlock();
68
+ _FcrAbilityControlImpl = FcrAbilityControlImpl;
69
+ [_initProto] = _applyDecs(_FcrAbilityControlImpl, [[_imports.trace, 2, "isPlatformAbilitySupported"]], []).e;