fcr-core 3.8.1-beta → 3.8.2

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 (96) hide show
  1. package/lib-es/base-session.js +1 -0
  2. package/lib-es/chat-connection/config.js +100 -0
  3. package/lib-es/chat-connection/index.js +149 -0
  4. package/lib-es/chat-connection/type.js +6 -0
  5. package/lib-es/engine/index.js +422 -0
  6. package/lib-es/imports.js +57 -0
  7. package/lib-es/index.js +7 -0
  8. package/lib-es/media-control/desktop.js +172 -0
  9. package/lib-es/media-control/mobile.js +194 -0
  10. package/lib-es/media-control/type.js +6 -0
  11. package/lib-es/monitor-control/index.js +46 -0
  12. package/lib-es/monitor-control/type.js +1 -0
  13. package/lib-es/peer-session/index.js +278 -0
  14. package/lib-es/peer-session/type.js +1 -0
  15. package/lib-es/plugins/chatroom.js +446 -0
  16. package/lib-es/plugins/electron-rtc-plugin.js +1 -0
  17. package/lib-es/plugins/rtm-plugin.js +1 -0
  18. package/lib-es/plugins/web-rtc-plugin.js +1 -0
  19. package/lib-es/room-control/ability-control/index.js +57 -0
  20. package/lib-es/room-control/ability-control/type.js +11 -0
  21. package/lib-es/room-control/chatroom-control/config.js +100 -0
  22. package/lib-es/room-control/chatroom-control/type.js +12 -0
  23. package/lib-es/room-control/group-control/index.js +255 -0
  24. package/lib-es/room-control/helpers/constants.js +92 -0
  25. package/lib-es/room-control/helpers/index.js +20 -0
  26. package/lib-es/room-control/helpers/validation-helper.js +46 -0
  27. package/lib-es/room-control/index.js +609 -0
  28. package/lib-es/room-control/interpreter-control/index.js +167 -0
  29. package/lib-es/room-control/interpreter-control/room.js +28 -0
  30. package/lib-es/room-control/interpreter-control/types.js +26 -0
  31. package/lib-es/room-control/join-before-host-waitingroom-control/index.js +28 -0
  32. package/lib-es/room-control/mainroom-control/index.js +249 -0
  33. package/lib-es/room-control/privilege-control/helper.js +97 -0
  34. package/lib-es/room-control/privilege-control/index.js +325 -0
  35. package/lib-es/room-control/privilege-control/type.js +159 -0
  36. package/lib-es/room-control/room-connector-control/index.js +179 -0
  37. package/lib-es/room-control/room-connector-control/type.js +28 -0
  38. package/lib-es/room-control/room-control-factory.js +77 -0
  39. package/lib-es/room-control/room-session/index.js +293 -0
  40. package/lib-es/room-control/room-session/type.js +1 -0
  41. package/lib-es/room-control/shared-cache.js +47 -0
  42. package/lib-es/room-control/sharing-control/index.js +301 -0
  43. package/lib-es/room-control/sharing-control/type.js +16 -0
  44. package/lib-es/room-control/stream-control/index.js +533 -0
  45. package/lib-es/room-control/stream-control/type.js +1 -0
  46. package/lib-es/room-control/stt-control/de-compress-gzip.js +33 -0
  47. package/lib-es/room-control/stt-control/index.js +342 -0
  48. package/lib-es/room-control/stt-control/type.js +10 -0
  49. package/lib-es/room-control/type.js +30 -0
  50. package/lib-es/room-control/user-control/index.js +344 -0
  51. package/lib-es/room-control/user-control/type.js +21 -0
  52. package/lib-es/room-control/waitingroom-control/index.js +67 -0
  53. package/lib-es/room-control/whiteboard-control/enum.js +18 -0
  54. package/lib-es/room-control/whiteboard-control/type.js +10 -0
  55. package/lib-es/room-control/whiteboard-control/utils.js +13 -0
  56. package/lib-es/room-control/whiteboard-control-v1/board-subwindow.js +18 -0
  57. package/lib-es/room-control/whiteboard-control-v1/board-window.js +554 -0
  58. package/lib-es/room-control/whiteboard-control-v1/enum.js +157 -0
  59. package/lib-es/room-control/whiteboard-control-v1/factory.js +12 -0
  60. package/lib-es/room-control/whiteboard-control-v1/index.js +418 -0
  61. package/lib-es/room-control/whiteboard-control-v1/mount-manager.js +6 -0
  62. package/lib-es/room-control/whiteboard-control-v1/type.js +7 -0
  63. package/lib-es/room-control/whiteboard-control-v1/utils.js +273 -0
  64. package/lib-es/room-control/whiteboard-control-v2/annotation-control/control.js +42 -0
  65. package/lib-es/room-control/whiteboard-control-v2/annotation-control/factory.js +36 -0
  66. package/lib-es/room-control/whiteboard-control-v2/annotation-control/type.js +1 -0
  67. package/lib-es/room-control/whiteboard-control-v2/base/index.js +303 -0
  68. package/lib-es/room-control/whiteboard-control-v2/base/main-window.js +250 -0
  69. package/lib-es/room-control/whiteboard-control-v2/constant.js +9 -0
  70. package/lib-es/room-control/whiteboard-control-v2/enum.js +28 -0
  71. package/lib-es/room-control/whiteboard-control-v2/type.js +1 -0
  72. package/lib-es/room-control/whiteboard-control-v2/utils.js +92 -0
  73. package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/control.js +157 -0
  74. package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/factory.js +61 -0
  75. package/lib-es/room-control/whiteboard-control-v2/whiteboard-control/type.js +1 -0
  76. package/lib-es/room-router/index.js +259 -0
  77. package/lib-es/room-router/type.js +5 -0
  78. package/lib-es/schema.js +232 -0
  79. package/lib-es/service/api.js +1206 -0
  80. package/lib-es/service/type.js +1 -0
  81. package/lib-es/type.js +170 -0
  82. package/lib-es/utilities/cmd.js +1 -0
  83. package/lib-es/utilities/collection.js +64 -0
  84. package/lib-es/utilities/error-helpers.js +223 -0
  85. package/lib-es/utilities/error.js +109 -0
  86. package/lib-es/utilities/join-helper.js +218 -0
  87. package/lib-es/utilities/logger.js +23 -0
  88. package/lib-es/utilities/package-info.js +7 -0
  89. package/lib-es/utilities/parameters.js +33 -0
  90. package/lib-es/utilities/retry-helpers.js +66 -0
  91. package/lib-es/utilities/shared-storage.js +31 -0
  92. package/lib-es/utilities/storage.js +27 -0
  93. package/lib-es/utilities/stream.js +18 -0
  94. package/lib-es/utilities/user.js +30 -0
  95. package/lib-es/utilities/validate-params.js +7 -0
  96. package/package.json +7 -6
@@ -0,0 +1 @@
1
+ export class BaseSession {}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * git do not control webim.config.js
3
+ * everyone should copy webim.config.js.demo to webim.config.js
4
+ * and have their own configs.
5
+ * In this way , others won't be influenced by this config while git pull.
6
+ */
7
+
8
+ // for react native
9
+ // var location = {
10
+ // protocol: "https"
11
+ // }
12
+
13
+ const agoraChatConfig = {
14
+ /*
15
+ * websocket server
16
+ * im-api-v2.easemob.com/ws 线上环境
17
+ * im-api-v2-hsb.easemob.com/ws 沙箱环境
18
+ */
19
+ // socketServer: getUrl().socketUrl, //(window.location.protocol === "https:" ? "https:" : "http:") + "//im-api-v2.easemob.com/ws",
20
+ /*
21
+ * Backend REST API URL
22
+ * a1.easemob.com 线上环境
23
+ * a1-hsb.easemob.com 沙箱环境
24
+ */
25
+ // restServer: getUrl().apiUrl, //(window.location.protocol === "https:" ? "https:" : "http:") + "//a1.easemob.com",
26
+ /*
27
+ * Application AppKey
28
+ */
29
+ // appkey: 'easemob-demo#cloudclass',
30
+ /*
31
+ * Application Host
32
+ */
33
+ Host: 'easemob.com',
34
+ /*
35
+ * Whether to use HTTPS
36
+ * @parameter {Boolean} true or false
37
+ */
38
+ https: true,
39
+ /*
40
+ * 公有云配置默认为 true,
41
+ * 私有云配置请设置 isHttpDNS = false , 详细文档:http://docs-im.easemob.com/im/web/other/privatedeploy
42
+ */
43
+ isHttpDNS: true,
44
+ /*
45
+ * isMultiLoginSessions
46
+ * true: A visitor can sign in to multiple webpages and receive messages at all the webpages.
47
+ * false: A visitor can sign in to only one webpage and receive messages at the webpage.
48
+ */
49
+ isMultiLoginSessions: true,
50
+ /**
51
+ * @parameter {Boolean} true or false
52
+ */
53
+ isSandBox: false,
54
+ //内部测试环境,集成时设为false
55
+ /**
56
+ * Whether to console.log
57
+ * @parameter {Boolean} true or false
58
+ */
59
+ isDebug: true,
60
+ /**
61
+ * will auto connect the websocket server autoReconnectNumMax times in background when client is offline.
62
+ * won't auto connect if autoReconnectNumMax=0.
63
+ */
64
+ autoReconnectNumMax: 10,
65
+ /**
66
+ * webrtc supports WebKit and https only
67
+ */
68
+ // isWebRTC: window.RTCPeerConnection && /^https\:$/.test(window.location.protocol),
69
+ /*
70
+ * Upload pictures or file to your own server and send message with url
71
+ * @parameter {Boolean} true or false
72
+ * true: Using the API provided by SDK to upload file to huanxin server
73
+ * false: Using your method to upload file to your own server
74
+ */
75
+ useOwnUploadFun: false,
76
+ /*
77
+ * Set to auto sign-in
78
+ */
79
+ isAutoLogin: false,
80
+ /**
81
+ * Size of message cache for person to person
82
+ */
83
+ p2pMessageCacheSize: 500,
84
+ /**
85
+ * When a message arrived, the receiver send an ack message to the
86
+ * sender, in order to tell the sender the message has delivered.
87
+ * See call back function onReceivedMessage
88
+ */
89
+ delivery: false,
90
+ /**
91
+ * Size of message cache for group chating like group, chatroom etc. For use in this demo
92
+ */
93
+ groupMessageCacheSize: 200,
94
+ /**
95
+ * enable localstorage for history messages. For use in this demo
96
+ */
97
+ enableLocalStorage: true,
98
+ deviceId: 'webim'
99
+ };
100
+ export { agoraChatConfig };
@@ -0,0 +1,149 @@
1
+ import "core-js/modules/es.array.push.js";
2
+ import "core-js/modules/esnext.function.metadata.js";
3
+ import "core-js/modules/esnext.map.delete-all.js";
4
+ import "core-js/modules/esnext.map.emplace.js";
5
+ import "core-js/modules/esnext.map.every.js";
6
+ import "core-js/modules/esnext.map.filter.js";
7
+ import "core-js/modules/esnext.map.find.js";
8
+ import "core-js/modules/esnext.map.find-key.js";
9
+ import "core-js/modules/esnext.map.includes.js";
10
+ import "core-js/modules/esnext.map.key-of.js";
11
+ import "core-js/modules/esnext.map.map-keys.js";
12
+ import "core-js/modules/esnext.map.map-values.js";
13
+ import "core-js/modules/esnext.map.merge.js";
14
+ import "core-js/modules/esnext.map.reduce.js";
15
+ import "core-js/modules/esnext.map.some.js";
16
+ import "core-js/modules/esnext.map.update.js";
17
+ import "core-js/modules/esnext.symbol.metadata.js";
18
+ let _initProto;
19
+ import "core-js/modules/es.json.stringify.js";
20
+ 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)]; } }; }
21
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
22
+ 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); }
23
+ 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; }
24
+ 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; }
25
+ import { AgoraObservable, EasemobChatSDK, retryAttempt, to, AgoraRestfulClientError, trace } from '../imports';
26
+ import { FcrChatConnectionState } from './type';
27
+ import { agoraChatConfig } from './config';
28
+ import { createLogger } from '../utilities/logger';
29
+ import { getDependenciesInfo } from '../utilities/package-info';
30
+ export class FcrChatConnectionImpl {
31
+ static {
32
+ [_initProto] = _applyDecs(this, [[trace, 2, "login"], [trace, 2, "logout"]], []).e;
33
+ }
34
+ logger = (_initProto(this), createLogger({
35
+ prefix: 'FcrChatConnectionImpl'
36
+ }));
37
+ _observable = new AgoraObservable();
38
+ _connectionState = FcrChatConnectionState.DISCONNECTED;
39
+ constructor(_userId, _api, _chatIpList, _restIpList) {
40
+ this._userId = _userId;
41
+ this._api = _api;
42
+ this._chatIpList = _chatIpList;
43
+ this._restIpList = _restIpList;
44
+ this.logger.info(`Chat Version: easemob-websdk@${getDependenciesInfo('easemob-websdk')}`);
45
+ }
46
+ async login() {
47
+ const privateConfig = this._getPrivateConfig();
48
+ if (privateConfig) {
49
+ this.logger.info('use private config:', JSON.stringify(privateConfig));
50
+ }
51
+ await to(retryAttempt(async () => {
52
+ const tokenResult = await this._api.getUserToken(this._userId);
53
+ this._initConfig = tokenResult;
54
+ const connParams = {
55
+ ...agoraChatConfig,
56
+ ...privateConfig,
57
+ appKey: tokenResult.appKey,
58
+ autoReconnectNumMax: 99999,
59
+ isFixedDeviceId: false
60
+ };
61
+ EasemobChatSDK.logger.setConsoleLogVisibility(false);
62
+ this._conn = new EasemobChatSDK.connection(connParams);
63
+ this._addEventListeners();
64
+ await this._conn.open({
65
+ accessToken: this._initConfig.token,
66
+ user: this._userId
67
+ });
68
+ this.logger.info(`onConnectionLoginSuccess, token: ${this._initConfig.token}, userId: ${this._userId}`);
69
+ this._observable.notifyObservers('onConnectionLoginSuccess');
70
+ }, [], {
71
+ retriesMax: 3
72
+ }).fail(async ({
73
+ error,
74
+ timeFn,
75
+ currentRetry
76
+ }) => {
77
+ if (error instanceof AgoraRestfulClientError) {
78
+ throw error;
79
+ }
80
+ this.logger.error(`retry to login ChatConnection, ${error.message},retry ${currentRetry} times`);
81
+ await timeFn();
82
+ return true;
83
+ }).exec());
84
+ }
85
+ _addEventListeners() {
86
+ this._conn?.addEventHandler('connectionListener', {
87
+ onError: e => {
88
+ this.logger.error('onError', e.message);
89
+ },
90
+ onConnected: () => {
91
+ this.logger.info('onConnected');
92
+ if (this._connectionState !== FcrChatConnectionState.CONNECTED) {
93
+ this._setConnectionState(FcrChatConnectionState.CONNECTED);
94
+ }
95
+ },
96
+ onDisconnected: () => {
97
+ if (this._connectionState !== FcrChatConnectionState.DISCONNECTED) {
98
+ this.logger.info('onDisconnected');
99
+ this._setConnectionState(FcrChatConnectionState.DISCONNECTED);
100
+ }
101
+ },
102
+ onOnline: () => {
103
+ this.logger.info('onOnline');
104
+ if (this._connectionState !== FcrChatConnectionState.CONNECTED) {
105
+ this._setConnectionState(FcrChatConnectionState.CONNECTED);
106
+ }
107
+ },
108
+ onOffline: () => {
109
+ if (this._connectionState !== FcrChatConnectionState.DISCONNECTED) {
110
+ this.logger.info('onOffline');
111
+ this._setConnectionState(FcrChatConnectionState.DISCONNECTED);
112
+ }
113
+ }
114
+ });
115
+ }
116
+ logout() {
117
+ this._conn?.close();
118
+ }
119
+ _setConnectionState(state) {
120
+ this._connectionState = state;
121
+ this._observable.notifyObservers('onConnectionStateUpdated', state);
122
+ }
123
+ getConnectionState() {
124
+ return this._connectionState;
125
+ }
126
+ getConnectionInstance() {
127
+ return this._conn;
128
+ }
129
+ addObserver(observer) {
130
+ this._observable.addObserver(observer);
131
+ }
132
+ removeObserver(observer) {
133
+ this._observable.removeObserver(observer);
134
+ }
135
+ _getPrivateConfig() {
136
+ if (this._chatIpList?.length || this._restIpList?.length) {
137
+ const privateConfig = {
138
+ isHttpDNS: false
139
+ };
140
+ if (this._chatIpList?.length) {
141
+ privateConfig.url = this._chatIpList[0];
142
+ }
143
+ if (this._restIpList?.length) {
144
+ privateConfig.apiUrl = this._restIpList[0];
145
+ }
146
+ return privateConfig;
147
+ }
148
+ }
149
+ }
@@ -0,0 +1,6 @@
1
+ export let FcrChatConnectionState = /*#__PURE__*/function (FcrChatConnectionState) {
2
+ FcrChatConnectionState[FcrChatConnectionState["DISCONNECTED"] = 0] = "DISCONNECTED";
3
+ FcrChatConnectionState[FcrChatConnectionState["CONNECTION"] = 1] = "CONNECTION";
4
+ FcrChatConnectionState[FcrChatConnectionState["CONNECTED"] = 2] = "CONNECTED";
5
+ return FcrChatConnectionState;
6
+ }({});