fcr-core 3.8.0-alpha → 3.8.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/lib/chat-connection/index.js +26 -40
  2. package/lib/engine/index.js +72 -66
  3. package/lib/imports.js +0 -1
  4. package/lib/media-control/desktop.js +13 -18
  5. package/lib/media-control/mobile.js +13 -18
  6. package/lib/monitor-control/index.js +5 -10
  7. package/lib/peer-session/index.js +39 -47
  8. package/lib/plugins/chatroom.js +213 -229
  9. package/lib/room-control/ability-control/index.js +9 -14
  10. package/lib/room-control/group-control/index.js +16 -21
  11. package/lib/room-control/helpers/validation-helper.js +1 -1
  12. package/lib/room-control/index.js +36 -53
  13. package/lib/room-control/interpreter-control/index.js +34 -47
  14. package/lib/room-control/interpreter-control/room.js +4 -6
  15. package/lib/room-control/join-before-host-waitingroom-control/index.js +4 -6
  16. package/lib/room-control/mainroom-control/index.js +27 -35
  17. package/lib/room-control/privilege-control/helper.js +5 -8
  18. package/lib/room-control/privilege-control/index.js +19 -26
  19. package/lib/room-control/room-connector-control/index.js +19 -28
  20. package/lib/room-control/room-control-factory.js +1 -2
  21. package/lib/room-control/room-session/index.js +39 -46
  22. package/lib/room-control/shared-cache.js +29 -36
  23. package/lib/room-control/sharing-control/index.d.ts +1 -1
  24. package/lib/room-control/sharing-control/index.js +34 -42
  25. package/lib/room-control/stream-control/index.js +191 -195
  26. package/lib/room-control/stream-control/type.d.ts +1 -1
  27. package/lib/room-control/stt-control/de-compress-gzip.js +0 -10
  28. package/lib/room-control/stt-control/index.js +95 -98
  29. package/lib/room-control/stt-control/type.d.ts +1 -1
  30. package/lib/room-control/user-control/index.js +136 -143
  31. package/lib/room-control/waitingroom-control/index.js +9 -14
  32. package/lib/room-control/whiteboard-control/utils.js +2 -4
  33. package/lib/room-control/whiteboard-control-v1/board-subwindow.js +1 -2
  34. package/lib/room-control/whiteboard-control-v1/board-window.js +88 -99
  35. package/lib/room-control/whiteboard-control-v1/factory.js +4 -7
  36. package/lib/room-control/whiteboard-control-v1/index.js +28 -40
  37. package/lib/room-control/whiteboard-control-v1/mount-manager.js +2 -4
  38. package/lib/room-control/whiteboard-control-v1/utils.js +14 -17
  39. package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +4 -6
  40. package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +5 -10
  41. package/lib/room-control/whiteboard-control-v2/base/index.js +34 -41
  42. package/lib/room-control/whiteboard-control-v2/base/main-window.js +24 -29
  43. package/lib/room-control/whiteboard-control-v2/utils.js +6 -7
  44. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +0 -1
  45. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +23 -34
  46. package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.js +7 -14
  47. package/lib/room-router/index.js +47 -53
  48. package/lib/room-router/type.d.ts +2 -2
  49. package/lib/service/api.js +227 -250
  50. package/lib/utilities/collection.js +2 -3
  51. package/lib/utilities/error-helpers.js +27 -34
  52. package/lib/utilities/error.js +8 -9
  53. package/lib/utilities/join-helper.js +25 -32
  54. package/lib/utilities/logger.js +3 -6
  55. package/lib/utilities/parameters.js +4 -8
  56. package/lib/utilities/retry-helpers.js +0 -1
  57. package/lib/utilities/stream.js +11 -16
  58. package/lib/utilities/user.js +3 -4
  59. package/lib/utilities/validate-params.js +1 -2
  60. package/package.json +5 -6
@@ -1,11 +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");
5
3
  require("core-js/modules/es.array.push.js");
6
4
  require("core-js/modules/esnext.function.metadata.js");
7
- require("core-js/modules/esnext.iterator.filter.js");
8
- require("core-js/modules/esnext.iterator.for-each.js");
9
5
  require("core-js/modules/esnext.map.delete-all.js");
10
6
  require("core-js/modules/esnext.map.emplace.js");
11
7
  require("core-js/modules/esnext.map.every.js");
@@ -30,8 +26,6 @@ Object.defineProperty(exports, "__esModule", {
30
26
  exports.FcrWhiteboardControlImpl = void 0;
31
27
  require("core-js/modules/esnext.iterator.constructor.js");
32
28
  require("core-js/modules/esnext.iterator.map.js");
33
- require("core-js/modules/web.dom-collections.iterator.js");
34
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
35
29
  var _appSlide = _interopRequireDefault(require("@netless/app-slide"));
36
30
  var _whiteWebSdk = require("white-web-sdk");
37
31
  var netlessVideoPlugin = _interopRequireWildcard(require("@netless/video-js-plugin"));
@@ -49,11 +43,8 @@ var _imports = require("../../imports");
49
43
  var _error = require("../../utilities/error");
50
44
  var _imports2 = require("agora-rte-sdk/lib/imports");
51
45
  var _type2 = require("../sharing-control/type");
52
- var _FcrWhiteboardControlImpl;
53
46
  let _initProto;
54
47
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
55
- 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; }
56
- 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; }
57
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)]; } }; }
58
49
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
59
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); }
@@ -63,18 +54,21 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
63
54
  * @internal
64
55
  */
65
56
  class FcrWhiteboardControlImpl {
57
+ static {
58
+ [_initProto] = _applyDecs(this, [[[_decorator.bound, _imports.trace], 2, "active"], [[_decorator.bound, _imports.trace], 2, "inactive"], [[_decorator.bound, _imports.trace], 2, "open"], [[_decorator.bound, _imports.trace], 2, "close"], [[_decorator.bound, _imports.trace], 2, "setBackgroundColor"], [[_decorator.bound, _imports.trace], 2, "getActivity"], [[_decorator.bound, _imports.trace], 2, "getOwnerId"], [[_decorator.bound, _imports.trace], 2, "getBackgroundColor"], [[_decorator.bound, _imports.trace], 2, "getConnectionState"], [[_decorator.bound, _imports.trace], 2, "getMainWindow"], [[_decorator.bound, _imports.trace], 2, "addObserver"], [[_decorator.bound, _imports.trace], 2, "removeObserver"], [[_decorator.bound, _imports.trace], 2, "getBoardActiveInfo"], [[_decorator.bound, _imports.trace], 2, "hasOperationPrivilege"], [[_decorator.bound, _imports.trace], 2, "setOperationPrivilege"], [_imports.trace, 2, "_setBoardWritable"], [_decorator.bound, 2, "_getToken"], [_decorator.bound, 2, "_handleRoomStateUpdated"], [_decorator.bound, 2, "_updateConnnectionState"], [_decorator.bound, 2, "_handleConnectionStateUpdated"], [_imports.trace, 2, "_connect"], [_imports.trace, 2, "_clean"]], []).e;
59
+ }
60
+ logger = (_initProto(this), (0, _logger.createLogger)({
61
+ prefix: 'FcrWhiteboardControlImpl'
62
+ }));
63
+ _client = {};
64
+ _joined = false;
65
+ _connectState = _2.FcrConnectionState.DISCONNECTED;
66
+ _observable = new _observable.AgoraObservable();
67
+ _options = {
68
+ debug: false
69
+ };
70
+ _hasOperationPrivilege = false;
66
71
  constructor(_scene, _api, _sharedCache, hasOperationPrivilege) {
67
- (0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
68
- prefix: 'FcrWhiteboardControlImpl'
69
- })));
70
- (0, _defineProperty2.default)(this, "_client", {});
71
- (0, _defineProperty2.default)(this, "_joined", false);
72
- (0, _defineProperty2.default)(this, "_connectState", _2.FcrConnectionState.DISCONNECTED);
73
- (0, _defineProperty2.default)(this, "_observable", new _observable.AgoraObservable());
74
- (0, _defineProperty2.default)(this, "_options", {
75
- debug: false
76
- });
77
- (0, _defineProperty2.default)(this, "_hasOperationPrivilege", false);
78
72
  this._scene = _scene;
79
73
  this._api = _api;
80
74
  this._sharedCache = _sharedCache;
@@ -83,16 +77,14 @@ class FcrWhiteboardControlImpl {
83
77
  this._addLogObserver();
84
78
  _scene.addObserver({
85
79
  onScenePropertiesUpdated: (_, event) => {
86
- var _event$cause;
87
80
  const operatorUser = (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache);
88
- if (((_event$cause = event.cause) === null || _event$cause === void 0 ? void 0 : _event$cause.cmd) === 10) {
89
- var _ref, _event$cause$data$wid2;
81
+ if (event.cause?.cmd === 10) {
90
82
  const {
91
83
  state,
92
84
  extra: {
93
85
  backgroundColor: bgColor
94
86
  }
95
- } = (_ref = _scene.getScenePropertiesByKeyPath('widgets.netlessBoard')) !== null && _ref !== void 0 ? _ref : {
87
+ } = _scene.getScenePropertiesByKeyPath('widgets.netlessBoard') ?? {
96
88
  state: 0,
97
89
  extra: {
98
90
  backgroundColor: '#fff'
@@ -102,10 +94,9 @@ class FcrWhiteboardControlImpl {
102
94
  this._observable.notifyObservers('onActive', _scene.getScenePropertiesByKeyPath('widgets.netlessBoard').ownerUserUuid, operatorUser);
103
95
  }
104
96
  if (state === 0) {
105
- var _event$cause$data$wid;
106
- this._observable.notifyObservers('onInactive', (_event$cause$data$wid = event.cause.data.widgetCause) === null || _event$cause$data$wid === void 0 || (_event$cause$data$wid = _event$cause$data$wid.data) === null || _event$cause$data$wid === void 0 ? void 0 : _event$cause$data$wid.reason, operatorUser);
97
+ this._observable.notifyObservers('onInactive', event.cause.data.widgetCause?.data?.reason, operatorUser);
107
98
  }
108
- if (((_event$cause$data$wid2 = event.cause.data.widgetCause) === null || _event$cause$data$wid2 === void 0 ? void 0 : _event$cause$data$wid2.cmd) === 100101) {
99
+ if (event.cause.data.widgetCause?.cmd === 100101) {
109
100
  this._observable.notifyObservers('onBackgroundColorUpdated', bgColor, operatorUser);
110
101
  }
111
102
  }
@@ -122,8 +113,7 @@ class FcrWhiteboardControlImpl {
122
113
  async inactive() {
123
114
  return (0, _error.handleRequestError)(() => this._api.toggleWhiteboardActivityState(this._scene.sceneId, _type2.FcrSharePermissionState.OFF), _error.FcrErrorModuleCode.ROOM_WHITEBOARD, 'inactive failed');
124
115
  }
125
- async open() {
126
- let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
116
+ async open(params = {}) {
127
117
  this._whiteboardPrivateParameters = params;
128
118
  // 白板权限禁用状态下,主持人和联席主持人仍然可以发起共享,所以,不能根据是否禁用状态直接拒绝
129
119
 
@@ -311,12 +301,11 @@ class FcrWhiteboardControlImpl {
311
301
  }
312
302
  async _connect() {
313
303
  try {
314
- var _this$_scene$getUser, _this$_whiteboardPriv, _this$_whiteboardPriv2, _this$_whiteboardPriv3, _this$_whiteboardPriv4;
315
304
  this._updateConnnectionState(_2.FcrConnectionState.CONNECTING);
316
305
  const roomId = this._scene.sceneId;
317
306
  const userId = this._scene.localUser.getLocalUserId();
318
- const cursorName = (_this$_scene$getUser = this._scene.getUser(userId)) === null || _this$_scene$getUser === void 0 ? void 0 : _this$_scene$getUser.userName;
319
- const syncMode = (_this$_whiteboardPriv = (_this$_whiteboardPriv2 = this._whiteboardPrivateParameters) === null || _this$_whiteboardPriv2 === void 0 ? void 0 : _this$_whiteboardPriv2.syncMode) !== null && _this$_whiteboardPriv !== void 0 ? _this$_whiteboardPriv : false;
307
+ const cursorName = this._scene.getUser(userId)?.userName;
308
+ const syncMode = this._whiteboardPrivateParameters?.syncMode ?? false;
320
309
  const {
321
310
  data
322
311
  } = await this._getToken(roomId, userId);
@@ -327,7 +316,7 @@ class FcrWhiteboardControlImpl {
327
316
  boardToken
328
317
  } = data || {};
329
318
  const plugins = this._createPlugins();
330
- this._client = new _whiteWebSdk.WhiteWebSdk(_objectSpread({
319
+ this._client = new _whiteWebSdk.WhiteWebSdk({
331
320
  appIdentifier: boardAppId,
332
321
  useMobXState: true,
333
322
  pptParams: {
@@ -341,8 +330,9 @@ class FcrWhiteboardControlImpl {
341
330
  reportDebugLogMode: _whiteWebSdk.LoggerReportMode.AlwaysReport,
342
331
  reportLevelMask: this._options.debug ? 'debug' : 'info',
343
332
  printLevelMask: this._options.debug ? 'debug' : 'info'
344
- }
345
- }, this._whiteboardPrivateParameters));
333
+ },
334
+ ...this._whiteboardPrivateParameters
335
+ });
346
336
  const hasPermission = this._hasOperationPrivilege;
347
337
  const joinParams = {
348
338
  region: boardRegion,
@@ -364,7 +354,7 @@ class FcrWhiteboardControlImpl {
364
354
  cursorName,
365
355
  disappearCursor: true
366
356
  },
367
- floatBar: (_this$_whiteboardPriv3 = (_this$_whiteboardPriv4 = this._whiteboardPrivateParameters) === null || _this$_whiteboardPriv4 === void 0 ? void 0 : _this$_whiteboardPriv4.floatBar) !== null && _this$_whiteboardPriv3 !== void 0 ? _this$_whiteboardPriv3 : {
357
+ floatBar: this._whiteboardPrivateParameters?.floatBar ?? {
368
358
  colors: _utils.textColors.map(color => (0, _utils.hexColorToWhiteboardColor)(color))
369
359
  }
370
360
  };
@@ -376,7 +366,7 @@ class FcrWhiteboardControlImpl {
376
366
  if (hasPermission) {
377
367
  room.setViewMode(_whiteWebSdk.ViewMode.Broadcaster);
378
368
  }
379
- this.logger.info("set whiteboard sync mode: ".concat(syncMode));
369
+ this.logger.info(`set whiteboard sync mode: ${syncMode}`);
380
370
  room.syncMode = syncMode;
381
371
  const mountOptions = {};
382
372
  const privateParams = this._whiteboardPrivateParameters;
@@ -435,6 +425,4 @@ class FcrWhiteboardControlImpl {
435
425
  this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onActive', 'onInactive', 'onBackgroundColorUpdated', 'onConnectionStateUpdated']));
436
426
  }
437
427
  }
438
- exports.FcrWhiteboardControlImpl = FcrWhiteboardControlImpl;
439
- _FcrWhiteboardControlImpl = FcrWhiteboardControlImpl;
440
- [_initProto] = _applyDecs(_FcrWhiteboardControlImpl, [[[_decorator.bound, _imports.trace], 2, "active"], [[_decorator.bound, _imports.trace], 2, "inactive"], [[_decorator.bound, _imports.trace], 2, "open"], [[_decorator.bound, _imports.trace], 2, "close"], [[_decorator.bound, _imports.trace], 2, "setBackgroundColor"], [[_decorator.bound, _imports.trace], 2, "getActivity"], [[_decorator.bound, _imports.trace], 2, "getOwnerId"], [[_decorator.bound, _imports.trace], 2, "getBackgroundColor"], [[_decorator.bound, _imports.trace], 2, "getConnectionState"], [[_decorator.bound, _imports.trace], 2, "getMainWindow"], [[_decorator.bound, _imports.trace], 2, "addObserver"], [[_decorator.bound, _imports.trace], 2, "removeObserver"], [[_decorator.bound, _imports.trace], 2, "getBoardActiveInfo"], [[_decorator.bound, _imports.trace], 2, "hasOperationPrivilege"], [[_decorator.bound, _imports.trace], 2, "setOperationPrivilege"], [_imports.trace, 2, "_setBoardWritable"], [_decorator.bound, 2, "_getToken"], [_decorator.bound, 2, "_handleRoomStateUpdated"], [_decorator.bound, 2, "_updateConnnectionState"], [_decorator.bound, 2, "_handleConnectionStateUpdated"], [_imports.trace, 2, "_connect"], [_imports.trace, 2, "_clean"]], []).e;
428
+ exports.FcrWhiteboardControlImpl = FcrWhiteboardControlImpl;
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.BoardMountManager = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  class BoardMountManager {
8
+ static isMounting = false;
10
9
  static setIsMounting(isMounting) {
11
10
  BoardMountManager.isMounting = isMounting;
12
11
  }
13
12
  }
14
- exports.BoardMountManager = BoardMountManager;
15
- (0, _defineProperty2.default)(BoardMountManager, "isMounting", false);
13
+ exports.BoardMountManager = BoardMountManager;
@@ -5,9 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.windowClassName = exports.widgetContainerClassName = exports.videoRowClassName = exports.verticalPadding = exports.toolbarClassName = exports.textColors = exports.src2DataURL = exports.sceneNavHeight = exports.mergeCanvasImage = exports.mediaMimeTypes = exports.layoutContentClassName = exports.hexColorToWhiteboardColor = exports.heightPerTool = exports.heightPerColor = exports.getImageSize = exports.fetchImageInfoByUrl = exports.defaultToolsRetain = exports.defaultTextSize = exports.defaultStrokeColor = exports.convertToNetlessStorkeType = exports.convertToNetlessBoardTool = exports.convertToFcrBoardToolShape = exports.WINDOW_TITLE_HEIGHT = exports.WINDOW_REMAIN_SIZE = exports.WINDOW_REMAIN_POSITION = exports.WINDOW_MIN_SIZE = exports.WINDOW_ASPECT_RATIO = void 0;
7
7
  require("core-js/modules/es.array.push.js");
8
- require("core-js/modules/es.regexp.exec.js");
9
- require("core-js/modules/es.string.replace.js");
10
- require("core-js/modules/web.dom-collections.iterator.js");
11
8
  var _jsMd = require("js-md5");
12
9
  var _enum = require("./enum");
13
10
  var _appliancePlugin = require("@netless/appliance-plugin");
@@ -134,8 +131,8 @@ const mergeCanvasImage = async scenes => {
134
131
  canvasArray.push(canvas);
135
132
  }
136
133
  }
137
- bigCanvas.setAttribute('width', "".concat(width));
138
- bigCanvas.setAttribute('height', "".concat(height * canvasArray.length));
134
+ bigCanvas.setAttribute('width', `${width}`);
135
+ bigCanvas.setAttribute('height', `${height * canvasArray.length}`);
139
136
  canvasArray.forEach((canvas, index) => {
140
137
  ctx && ctx.drawImage(canvas, 0, index * height, width, height);
141
138
  });
@@ -233,22 +230,22 @@ const convertToFcrBoardToolShape = (tool, shape) => {
233
230
  case _enum.ApplianceNames.hand:
234
231
  return [_enum.FcrBoardToolType.HAND];
235
232
  }
236
- switch ("".concat(tool || '').concat(shape || '')) {
237
- case "".concat(_enum.ApplianceNames.rectangle):
233
+ switch (`${tool || ''}${shape || ''}`) {
234
+ case `${_enum.ApplianceNames.rectangle}`:
238
235
  return [, _enum.FcrBoardShape.Rectangle];
239
- case "".concat(_enum.ApplianceNames.ellipse):
236
+ case `${_enum.ApplianceNames.ellipse}`:
240
237
  return [, _enum.FcrBoardShape.Ellipse];
241
- case "".concat(_enum.ApplianceNames.straight):
238
+ case `${_enum.ApplianceNames.straight}`:
242
239
  return [, _enum.FcrBoardShape.Straight];
243
- case "".concat(_enum.ApplianceNames.arrow):
240
+ case `${_enum.ApplianceNames.arrow}`:
244
241
  return [, _enum.FcrBoardShape.Arrow];
245
- case "".concat(_enum.ApplianceNames.pencil):
242
+ case `${_enum.ApplianceNames.pencil}`:
246
243
  return [, _enum.FcrBoardShape.Curve];
247
- case "".concat(_enum.ApplianceNames.shape).concat(_enum.ShapeType.Triangle):
244
+ case `${_enum.ApplianceNames.shape}${_enum.ShapeType.Triangle}`:
248
245
  return [, _enum.FcrBoardShape.Triangle];
249
- case "".concat((_enum.ApplianceNames.shape, _enum.ShapeType.Pentagram)):
246
+ case `${_enum.ApplianceNames.shape, _enum.ShapeType.Pentagram}`:
250
247
  return [, _enum.FcrBoardShape.Pentagram];
251
- case "".concat(_enum.ApplianceNames.shape).concat(_enum.ShapeType.Rhombus):
248
+ case `${_enum.ApplianceNames.shape}${_enum.ShapeType.Rhombus}`:
252
249
  return [, _enum.FcrBoardShape.Rhombus];
253
250
  }
254
251
  return [];
@@ -275,9 +272,9 @@ const src2DataURL = src => {
275
272
  const ctx = canvas.getContext('2d');
276
273
  const image = new Image();
277
274
  image.onload = () => {
278
- canvas.setAttribute('width', "".concat(image.width));
279
- canvas.setAttribute('height', "".concat(image.height));
280
- ctx === null || ctx === void 0 || ctx.drawImage(image, 0, 0);
275
+ canvas.setAttribute('width', `${image.width}`);
276
+ canvas.setAttribute('height', `${image.height}`);
277
+ ctx?.drawImage(image, 0, 0);
281
278
  resolve(canvas.toDataURL('image/jpeg', 0.8));
282
279
  };
283
280
  image.onerror = () => {
@@ -1,23 +1,21 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.FcrStandaloneAnnotationControlImpl = exports.FcrAnnotationControlImpl = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _logger = require("../../../utilities/logger");
10
8
  var _base = require("../base");
11
9
  var _constant = require("../constant");
12
10
  class FcrAnnotationControlImpl extends _base.FcrBaseWhiteboardControlImpl {
11
+ logger = (0, _logger.createLogger)({
12
+ prefix: 'FcrAnnotationControlImpl'
13
+ });
13
14
  constructor(rtmClient, config, hasOperationPrivilege, forgeInitConfigFetcher) {
14
15
  super(rtmClient, config, hasOperationPrivilege, forgeInitConfigFetcher);
15
- (0, _defineProperty2.default)(this, "logger", (0, _logger.createLogger)({
16
- prefix: 'FcrAnnotationControlImpl'
17
- }));
18
16
  this.rtmClient = rtmClient;
19
17
  this.config = config;
20
- this.logger.info("initialized, hasOperationPrivilege: ".concat(hasOperationPrivilege));
18
+ this.logger.info(`initialized, hasOperationPrivilege: ${hasOperationPrivilege}`);
21
19
  }
22
20
  getApplicationId() {
23
21
  return _constant.ANNOTATION_APP_ID;
@@ -1,29 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.FcrAnnotationControlFactoryImpl = void 0;
8
- require("core-js/modules/es.error.cause.js");
9
7
  require("core-js/modules/es.json.stringify.js");
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
8
  var _control = require("./control");
12
9
  var _logger = require("../../../utilities/logger");
13
10
  var _error = require("../../../utilities/error");
14
11
  var _sharedStorage = require("../../../utilities/shared-storage");
15
12
  class FcrAnnotationControlFactoryImpl {
16
- constructor() {
17
- (0, _defineProperty2.default)(this, "logger", (0, _logger.createLogger)({
18
- prefix: 'FcrAnnotationControlFactory'
19
- }));
20
- }
13
+ logger = (0, _logger.createLogger)({
14
+ prefix: 'FcrAnnotationControlFactory'
15
+ });
21
16
  createForSubProcess(rtmClient, hasOperationPrivilege, config) {
22
- this.logger.info("[annotation]: create for sub process with config: ".concat(JSON.stringify(config)));
17
+ this.logger.info(`[annotation]: create for sub process with config: ${JSON.stringify(config)}`);
23
18
  return new _control.FcrStandaloneAnnotationControlImpl(rtmClient, config, hasOperationPrivilege, () => {
24
19
  const forgeInitConfig = (0, _sharedStorage.getAnnotationBoardOptions)();
25
20
  if (!forgeInitConfig) {
26
- throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_WHITEBOARD, _error.FcrErrorCode.UNDEFINED_ERROR, "whiteboard init config is not exist", new Error("whiteboard init config is not exist"));
21
+ throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_WHITEBOARD, _error.FcrErrorCode.UNDEFINED_ERROR, `whiteboard init config is not exist`, new Error(`whiteboard init config is not exist`));
27
22
  }
28
23
  return Promise.resolve(forgeInitConfig);
29
24
  });
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.description.js");
4
3
  require("core-js/modules/es.array.push.js");
5
4
  require("core-js/modules/esnext.function.metadata.js");
6
5
  require("core-js/modules/esnext.map.delete-all.js");
@@ -18,16 +17,11 @@ require("core-js/modules/esnext.map.reduce.js");
18
17
  require("core-js/modules/esnext.map.some.js");
19
18
  require("core-js/modules/esnext.map.update.js");
20
19
  require("core-js/modules/esnext.symbol.metadata.js");
21
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
22
20
  Object.defineProperty(exports, "__esModule", {
23
21
  value: true
24
22
  });
25
23
  exports.FcrBaseWhiteboardControlImpl = void 0;
26
- require("core-js/modules/es.error.cause.js");
27
24
  require("core-js/modules/es.json.stringify.js");
28
- require("core-js/modules/es.regexp.exec.js");
29
- require("core-js/modules/web.dom-collections.iterator.js");
30
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
31
25
  var _forgeRtm = require("@netless/forge-rtm");
32
26
  var _imports = require("../../../imports");
33
27
  var _constant = require("../constant");
@@ -37,7 +31,6 @@ var _forgeWhiteboard = require("@netless/forge-whiteboard");
37
31
  var _error = require("../../../utilities/error");
38
32
  var _mainWindow = require("./main-window");
39
33
  var _type = require("../../../type");
40
- var _FcrBaseWhiteboardControlImpl;
41
34
  let _initProto;
42
35
  function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
43
36
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
@@ -45,29 +38,32 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
45
38
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
46
39
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
47
40
  class FcrBaseWhiteboardControlImpl {
41
+ static {
42
+ [_initProto] = _applyDecs(this, [[_imports.trace, 2, "setOperationPrivilege"], [_imports.trace, 2, "open"], [_imports.trace, 2, "close"], [_imports.trace, 2, "getConnectionState"], [_imports.trace, 2, "getMainWindow"]], []).e;
43
+ }
44
+ logger = (_initProto(this), (0, _logger.createLogger)({
45
+ prefix: 'FcrBaseWhiteboardControl'
46
+ }));
47
+ observable = new _imports.AgoraObservable();
48
+ boardView = null;
49
+ boardRoom = null;
50
+ whiteboard = null;
51
+ connectState = _type.FcrConnectionState.DISCONNECTED;
52
+ forgeInitConfig = null;
53
+ hasOperationPrivilege = false;
54
+ _waitPromise = null;
55
+ _waitPromiseResolve = null;
56
+ _waitPromiseReject = null;
57
+ _openAbortController = null;
58
+ _isOpen = false;
48
59
  constructor(rtmClient, config, hasOperationPrivilege, forgeInitConfigFetcher) {
49
- (0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
50
- prefix: 'FcrBaseWhiteboardControl'
51
- })));
52
- (0, _defineProperty2.default)(this, "observable", new _imports.AgoraObservable());
53
- (0, _defineProperty2.default)(this, "boardView", null);
54
- (0, _defineProperty2.default)(this, "boardRoom", null);
55
- (0, _defineProperty2.default)(this, "whiteboard", null);
56
- (0, _defineProperty2.default)(this, "connectState", _type.FcrConnectionState.DISCONNECTED);
57
- (0, _defineProperty2.default)(this, "forgeInitConfig", null);
58
- (0, _defineProperty2.default)(this, "hasOperationPrivilege", false);
59
- (0, _defineProperty2.default)(this, "_waitPromise", null);
60
- (0, _defineProperty2.default)(this, "_waitPromiseResolve", null);
61
- (0, _defineProperty2.default)(this, "_waitPromiseReject", null);
62
- (0, _defineProperty2.default)(this, "_openAbortController", null);
63
- (0, _defineProperty2.default)(this, "_isOpen", false);
64
60
  this.rtmClient = rtmClient;
65
61
  this.config = config;
66
62
  this.hasOperationPrivilege = hasOperationPrivilege;
67
63
  this.forgeInitConfigTask = _imports.AgoraScheduler.shared.addPollingTask(async () => {
68
64
  const forgeInitConfig = await forgeInitConfigFetcher();
69
65
  this.forgeInitConfig = forgeInitConfig;
70
- this.logger.info("fetch forge init config success, config: ".concat((0, _imports.jsonstring)(forgeInitConfig)));
66
+ this.logger.info(`fetch forge init config success, config: ${(0, _imports.jsonstring)(forgeInitConfig)}`);
71
67
  this.forgeInitConfigTask.stop();
72
68
  if (this._isOpen) {
73
69
  this.connect();
@@ -159,7 +155,7 @@ class FcrBaseWhiteboardControlImpl {
159
155
  }
160
156
  const oldState = this.connectState;
161
157
  this.connectState = state;
162
- this.logger.info("Connection state updated: ".concat(_type.FcrConnectionState[oldState], " -> ").concat(_type.FcrConnectionState[state]));
158
+ this.logger.info(`Connection state updated: ${_type.FcrConnectionState[oldState]} -> ${_type.FcrConnectionState[state]}`);
163
159
  this.observable.notifyObservers('onConnectionStateUpdated', state);
164
160
  }
165
161
  async connect() {
@@ -197,14 +193,14 @@ class FcrBaseWhiteboardControlImpl {
197
193
  let width = whiteboardOption.width;
198
194
  let height = whiteboardOption.height;
199
195
  if (!width) {
200
- this.logger.warn("board width is a invalid vlaue: ".concat(width, ", using default value 800"));
196
+ this.logger.warn(`board width is a invalid vlaue: ${width}, using default value 800`);
201
197
  whiteboardOption.width = 800;
202
198
  }
203
199
  if (!height) {
204
- this.logger.warn("board height is a invalid value: ".concat(height, ", using default value 600"));
200
+ this.logger.warn(`board height is a invalid value: ${height}, using default value 600`);
205
201
  whiteboardOption.height = 600;
206
202
  }
207
- this.logger.info("open board with boardId: ".concat(boardId, ", boardToken: ").concat(boardToken, ", region: ").concat(boardRegion, ", whiteboardOption: ").concat((0, _imports.jsonstring)(whiteboardOption)));
203
+ this.logger.info(`open board with boardId: ${boardId}, boardToken: ${boardToken}, region: ${boardRegion}, whiteboardOption: ${(0, _imports.jsonstring)(whiteboardOption)}`);
208
204
  const rtmProvider = new _forgeRtm.RTMProvider_2_2(this.rtmClient);
209
205
  const wbRoom = new _forgeRoom.Room(boardId, rtmProvider);
210
206
  wbRoom.applicationManager.registerApplication(_forgeWhiteboard.WhiteboardApplication);
@@ -226,22 +222,21 @@ class FcrBaseWhiteboardControlImpl {
226
222
  }
227
223
  // verboseLog: true,
228
224
  };
229
- this.logger.info("join params: ".concat((0, _imports.jsonstring)(joinRoomParams)));
225
+ this.logger.info(`join params: ${(0, _imports.jsonstring)(joinRoomParams)}`);
230
226
  await wbRoom.joinRoom(joinRoomParams);
231
227
  boardRoom = wbRoom;
232
228
  whiteboard = await wbRoom.applicationManager.launchApplication(_forgeWhiteboard.WhiteboardApplication, whiteboardOption, appId);
233
229
  }, [], {
234
230
  retriesMax: _constant.BOARD_RETRY_MAX
235
- }).fail(async _ref => {
236
- let {
237
- error,
238
- timeFn,
239
- currentRetry
240
- } = _ref;
231
+ }).fail(async ({
232
+ error,
233
+ timeFn,
234
+ currentRetry
235
+ }) => {
241
236
  if (abortController.signal.aborted) {
242
237
  throw new Error('join board aborted');
243
238
  }
244
- this.logger.error("failed to join board, error: ".concat(error.message, ", current retry: ").concat(currentRetry), error);
239
+ this.logger.error(`failed to join board, error: ${error.message}, current retry: ${currentRetry}`, error);
245
240
  await timeFn();
246
241
  return true;
247
242
  }).exec());
@@ -249,7 +244,7 @@ class FcrBaseWhiteboardControlImpl {
249
244
  throw new Error('join board aborted');
250
245
  }
251
246
  if (error) {
252
- this.logger.error("join board failed, ".concat(error.message, "-").concat(JSON.stringify(error)));
247
+ this.logger.error(`join board failed, ${error.message}-${JSON.stringify(error)}`);
253
248
  throw error;
254
249
  }
255
250
  whiteboard.enableCameraByMouse = false;
@@ -272,7 +267,7 @@ class FcrBaseWhiteboardControlImpl {
272
267
  this._clearWaitPromise();
273
268
  }
274
269
  } catch (e) {
275
- this.logger.error("join board failed");
270
+ this.logger.error(`join board failed`);
276
271
  this.updateConnectionState(_type.FcrConnectionState.DISCONNECTED);
277
272
  reject(e);
278
273
  if (this._waitPromiseReject) {
@@ -285,7 +280,7 @@ class FcrBaseWhiteboardControlImpl {
285
280
  });
286
281
  }
287
282
  getApplicationId() {
288
- return '';
283
+ return _constant.WHITEBOARD_APP_ID;
289
284
  }
290
285
  getWhiteboardOption() {
291
286
  return {
@@ -312,6 +307,4 @@ class FcrBaseWhiteboardControlImpl {
312
307
  this._waitPromise = null;
313
308
  }
314
309
  }
315
- exports.FcrBaseWhiteboardControlImpl = FcrBaseWhiteboardControlImpl;
316
- _FcrBaseWhiteboardControlImpl = FcrBaseWhiteboardControlImpl;
317
- [_initProto] = _applyDecs(_FcrBaseWhiteboardControlImpl, [[_imports.trace, 2, "setOperationPrivilege"], [_imports.trace, 2, "open"], [_imports.trace, 2, "close"], [_imports.trace, 2, "getConnectionState"], [_imports.trace, 2, "getMainWindow"]], []).e;
310
+ exports.FcrBaseWhiteboardControlImpl = FcrBaseWhiteboardControlImpl;