fcr-core 3.7.8 → 3.7.9-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/lib/chat-connection/index.js +26 -41
  2. package/lib/engine/index.js +74 -67
  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 -48
  8. package/lib/plugins/chatroom.js +202 -218
  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 +17 -25
  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 -48
  22. package/lib/room-control/shared-cache.js +29 -36
  23. package/lib/room-control/sharing-control/index.js +32 -40
  24. package/lib/room-control/stream-control/index.js +173 -181
  25. package/lib/room-control/user-control/index.js +136 -143
  26. package/lib/room-control/waitingroom-control/index.js +9 -14
  27. package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +24 -32
  28. package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +16 -27
  29. package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +53 -63
  30. package/lib/room-control/whiteboard-control-v2/index.js +28 -40
  31. package/lib/room-control/whiteboard-control-v2/main-window.js +23 -28
  32. package/lib/room-control/whiteboard-control-v2/utils.js +6 -7
  33. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +27 -38
  34. package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +3 -5
  35. package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +42 -54
  36. package/lib/room-router/index.js +42 -52
  37. package/lib/service/api.js +207 -231
  38. package/lib/utilities/collection.js +2 -3
  39. package/lib/utilities/error-helpers.js +27 -34
  40. package/lib/utilities/error.js +8 -9
  41. package/lib/utilities/join-helper.js +25 -32
  42. package/lib/utilities/logger.js +3 -6
  43. package/lib/utilities/parameters.js +4 -8
  44. package/lib/utilities/retry-helpers.js +0 -1
  45. package/lib/utilities/shared-storage.js +0 -1
  46. package/lib/utilities/storage.js +0 -1
  47. package/lib/utilities/stream.js +11 -16
  48. package/lib/utilities/user.js +3 -4
  49. package/lib/utilities/validate-params.js +1 -2
  50. package/package.json +4 -4
@@ -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");
@@ -23,38 +22,36 @@ Object.defineProperty(exports, "__esModule", {
23
22
  value: true
24
23
  });
25
24
  exports.FcrBoardMainWindowImpl = void 0;
26
- require("core-js/modules/es.error.cause.js");
27
- require("core-js/modules/web.dom-collections.iterator.js");
28
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
25
  var _observable = require("agora-foundation/lib/utilities/observable");
30
26
  var _utils = require("./utils");
31
27
  var _logger = require("../../utilities/logger");
32
28
  var _imports = require("../../imports");
33
29
  var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
34
30
  var _schema = require("../../schema");
35
- var _FcrBoardMainWindowImpl;
36
- let _initProto, _setBackgroundColorDecs, _setToolTypeDecs, _setStrokeWidthDecs, _setStrokeColorDecs, _setTextColorDecs, _setTextSizeDecs, _insertImageDecs, _setContainerSizeRatioDecs, _updateWindowSizeDecs, _setAutoCancelDrawDecs, _ref;
31
+ let _initProto, _setBackgroundColorDecs, _setToolTypeDecs, _setStrokeWidthDecs, _setStrokeColorDecs, _setTextColorDecs, _setTextSizeDecs, _insertImageDecs, _setContainerSizeRatioDecs, _updateWindowSizeDecs, _setAutoCancelDrawDecs;
37
32
  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)]; } }; }
38
33
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
39
34
  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); }
40
35
  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; }
41
36
  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; }
42
- _ref = (_setBackgroundColorDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _setToolTypeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrBoardToolTypeSchema)], _setStrokeWidthDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.numberSchema)], _setStrokeColorDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.z.union([_schema.colorSchema, _schema.stringSchema]))], _setTextColorDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.colorSchema)], _setTextSizeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.numberSchema)], _insertImageDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.numberSchema, _schema.numberSchema, _schema.numberSchema, _schema.numberSchema)], _setContainerSizeRatioDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.numberSchema)], _updateWindowSizeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrSizeSchema)], _setAutoCancelDrawDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.booleanSchema)], "logger");
43
37
  class FcrBoardMainWindowImpl {
38
+ static {
39
+ [_initProto] = _applyDecs(this, [[[_imports.bound, _imports.trace], 2, "addPage"], [[_imports.bound, _imports.trace], 2, "removePage"], [[_imports.bound, _imports.trace], 2, "undo"], [[_imports.bound, _imports.trace], 2, "redo"], [[_imports.bound, _imports.trace], 2, "clean"], [[_imports.bound, _imports.trace], 2, "getSnapshotImage"], [_setBackgroundColorDecs, 2, "setBackgroundColor"], [[_imports.bound, _imports.trace], 2, "getPageInfo"], [[_imports.bound, _imports.trace], 2, "prevPage"], [[_imports.bound, _imports.trace], 2, "nextPage"], [_setToolTypeDecs, 2, "setToolType"], [_setStrokeWidthDecs, 2, "setStrokeWidth"], [_setStrokeColorDecs, 2, "setStrokeColor"], [_setTextColorDecs, 2, "setTextColor"], [_setTextSizeDecs, 2, "setTextSize"], [_insertImageDecs, 2, "insertImage"], [[_imports.bound, _imports.trace], 2, "getContentView"], [_setContainerSizeRatioDecs, 2, "setContainerSizeRatio"], [[_imports.bound, _imports.trace], 2, "setBoardTransparent"], [_updateWindowSizeDecs, 2, "updateWindowSize"], [_setAutoCancelDrawDecs, 2, "setAutoCancelDraw"], [[_imports.bound, _imports.trace], 2, "_handleApplicationLaunch"], [[_imports.bound, _imports.trace], 2, "_handleApplicationTerminal"], [_imports.trace, 2, "_enableAutoCancel"]], []).e;
40
+ }
41
+ [(_setBackgroundColorDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], _setToolTypeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrBoardToolTypeSchema)], _setStrokeWidthDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.numberSchema)], _setStrokeColorDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.z.union([_schema.colorSchema, _schema.stringSchema]))], _setTextColorDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.colorSchema)], _setTextSizeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.numberSchema)], _insertImageDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema, _schema.numberSchema, _schema.numberSchema, _schema.numberSchema, _schema.numberSchema)], _setContainerSizeRatioDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.numberSchema)], _updateWindowSizeDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.fcrSizeSchema)], _setAutoCancelDrawDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.booleanSchema)], "logger")] = (_initProto(this), (0, _logger.createLogger)({
42
+ prefix: 'FcrBoardMainWindowImpl'
43
+ }));
44
+ _observable = new _observable.AgoraObservable();
45
+ _currentPage = 0;
46
+ _background = 'rgba(0, 0, 0, 0)';
47
+ _isAutoCancelEnabled = false;
44
48
  constructor(whiteboard, boardRoom) {
45
- (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
46
- prefix: 'FcrBoardMainWindowImpl'
47
- })));
48
- (0, _defineProperty2.default)(this, "_observable", new _observable.AgoraObservable());
49
- (0, _defineProperty2.default)(this, "_currentPage", 0);
50
- (0, _defineProperty2.default)(this, "_background", 'rgba(0, 0, 0, 0)');
51
- (0, _defineProperty2.default)(this, "_isAutoCancelEnabled", false);
52
49
  this._addLogObserver();
53
50
  this._boardView = document.createElement('div');
54
51
  this._boardView.classList.add('fcr-whiteboard-window-view');
55
52
  this._boardView.appendChild(whiteboard.view);
56
- this._boardView.style.height = "100%";
57
- this._boardView.style.width = "100%";
53
+ this._boardView.style.height = `100%`;
54
+ this._boardView.style.width = `100%`;
58
55
  this._whiteboard = whiteboard;
59
56
  this._setBoardViewStyle(whiteboard.view);
60
57
  this._addWindowManagerEventListeners();
@@ -62,7 +59,7 @@ class FcrBoardMainWindowImpl {
62
59
  boardRoom.applicationManager.on('terminal', this._handleApplicationTerminal);
63
60
 
64
61
  // @ts-ignore
65
- this.logger.info("initialized, room: ".concat(boardRoom.roomId));
62
+ this.logger.info(`initialized, room: ${boardRoom.roomId}`);
66
63
  }
67
64
  async addPage() {
68
65
  this._whiteboard.addPage('next');
@@ -109,7 +106,7 @@ class FcrBoardMainWindowImpl {
109
106
  }
110
107
  async setBackgroundColor(color) {
111
108
  this._background = color;
112
- this.logger.info("set canvas background color: ".concat(this._background));
109
+ this.logger.info(`set canvas background color: ${this._background}`);
113
110
  this._whiteboard.setCanvasBackgroundColor(color);
114
111
  }
115
112
  getPageInfo() {
@@ -140,7 +137,7 @@ class FcrBoardMainWindowImpl {
140
137
  }
141
138
  }
142
139
  async setStrokeColor(color) {
143
- const c = typeof color === 'string' ? color : "rgb(".concat(color.r, ",").concat(color.g, ",").concat(color.b, ")");
140
+ const c = typeof color === 'string' ? color : `rgb(${color.r},${color.g},${color.b})`;
144
141
  if (this._whiteboard) {
145
142
  this._whiteboard.strokeColor = c;
146
143
  } else {
@@ -148,7 +145,7 @@ class FcrBoardMainWindowImpl {
148
145
  }
149
146
  }
150
147
  async setTextColor(color) {
151
- const c = typeof color === 'string' ? color : "rgb(".concat(color.r, ",").concat(color.g, ",").concat(color.b, ")");
148
+ const c = typeof color === 'string' ? color : `rgb(${color.r},${color.g},${color.b})`;
152
149
  if (this._whiteboard) {
153
150
  this._whiteboard.fillColor = c;
154
151
  } else {
@@ -211,7 +208,7 @@ class FcrBoardMainWindowImpl {
211
208
  this._whiteboard = app;
212
209
  this._setBoardViewStyle(app.view);
213
210
  if (this._background) {
214
- this.logger.info("set canvas background color: ".concat(this._background));
211
+ this.logger.info(`set canvas background color: ${this._background}`);
215
212
  this._whiteboard.setCanvasBackgroundColor(this._background);
216
213
  }
217
214
  this._enableAutoCancel(this._isAutoCancelEnabled);
@@ -224,15 +221,15 @@ class FcrBoardMainWindowImpl {
224
221
  }
225
222
  _handleApplicationTerminal(appId, app) {
226
223
  if (this._boardView.contains(app.view)) {
227
- this.logger.info("remove application view: ".concat(appId));
224
+ this.logger.info(`remove application view: ${appId}`);
228
225
  this._boardView.removeChild(app.view);
229
226
  } else {
230
- this.logger.warn("application view not found in board view: ".concat(appId));
227
+ this.logger.warn(`application view not found in board view: ${appId}`);
231
228
  }
232
229
  }
233
230
  _setBoardViewStyle(view) {
234
- view.style.height = "100%";
235
- view.style.width = "100%";
231
+ view.style.height = `100%`;
232
+ view.style.width = `100%`;
236
233
  view.style.backgroundColor = 'rgba(0, 0, 0, 0)';
237
234
  }
238
235
  _enableAutoCancel(enable) {
@@ -245,6 +242,4 @@ class FcrBoardMainWindowImpl {
245
242
  this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onPageInfoUpdated', 'onUndoStateUpdated', 'onRedoStateUpdated']));
246
243
  }
247
244
  }
248
- exports.FcrBoardMainWindowImpl = FcrBoardMainWindowImpl;
249
- _FcrBoardMainWindowImpl = FcrBoardMainWindowImpl;
250
- [_initProto] = _applyDecs(_FcrBoardMainWindowImpl, [[[_imports.bound, _imports.trace], 2, "addPage"], [[_imports.bound, _imports.trace], 2, "removePage"], [[_imports.bound, _imports.trace], 2, "undo"], [[_imports.bound, _imports.trace], 2, "redo"], [[_imports.bound, _imports.trace], 2, "clean"], [[_imports.bound, _imports.trace], 2, "getSnapshotImage"], [_setBackgroundColorDecs, 2, "setBackgroundColor"], [[_imports.bound, _imports.trace], 2, "getPageInfo"], [[_imports.bound, _imports.trace], 2, "prevPage"], [[_imports.bound, _imports.trace], 2, "nextPage"], [_setToolTypeDecs, 2, "setToolType"], [_setStrokeWidthDecs, 2, "setStrokeWidth"], [_setStrokeColorDecs, 2, "setStrokeColor"], [_setTextColorDecs, 2, "setTextColor"], [_setTextSizeDecs, 2, "setTextSize"], [_insertImageDecs, 2, "insertImage"], [[_imports.bound, _imports.trace], 2, "getContentView"], [_setContainerSizeRatioDecs, 2, "setContainerSizeRatio"], [[_imports.bound, _imports.trace], 2, "setBoardTransparent"], [_updateWindowSizeDecs, 2, "updateWindowSize"], [_setAutoCancelDrawDecs, 2, "setAutoCancelDraw"], [[_imports.bound, _imports.trace], 2, "_handleApplicationLaunch"], [[_imports.bound, _imports.trace], 2, "_handleApplicationTerminal"], [_imports.trace, 2, "_enableAutoCancel"]], []).e;
245
+ exports.FcrBoardMainWindowImpl = FcrBoardMainWindowImpl;
@@ -49,11 +49,11 @@ const getAnnotationConfigFromRoomProperties = (properties, logger) => {
49
49
  let width = (0, _get.default)(properties, 'widgets.annotation.size.width');
50
50
  let height = (0, _get.default)(properties, 'widgets.annotation.size.height');
51
51
  if (typeof width !== 'number') {
52
- logger.warn("got invalid width for annotation board, width: ".concat(width));
52
+ logger.warn(`got invalid width for annotation board, width: ${width}`);
53
53
  width = 0;
54
54
  }
55
55
  if (typeof height !== 'number') {
56
- logger.warn("got invalid height for annotation board, height: ".concat(height));
56
+ logger.warn(`got invalid height for annotation board, height: ${height}`);
57
57
  height = 0;
58
58
  }
59
59
  const boardWidthVal = width;
@@ -66,16 +66,16 @@ const getAnnotationConfigFromRoomProperties = (properties, logger) => {
66
66
  height: boardHeight
67
67
  } = resizeToMax(boardWidthVal, boardHeightVal, FCR_ANNOTATION_SCALE_BASE));
68
68
  } else {
69
- logger.warn("got invalid width or height for annotation board, skip resizing, width: ".concat(boardWidthVal, ", height: ").concat(boardHeightVal));
69
+ logger.warn(`got invalid width or height for annotation board, skip resizing, width: ${boardWidthVal}, height: ${boardHeightVal}`);
70
70
  }
71
- logger.info("got board config info, ".concat((0, _imports.jsonstring)({
71
+ logger.info(`got board config info, ${(0, _imports.jsonstring)({
72
72
  boardAppId,
73
73
  boardId,
74
74
  boardToken,
75
75
  boardRegion,
76
76
  boardWidth,
77
77
  boardHeight
78
- })));
78
+ })}`);
79
79
  return {
80
80
  size: {
81
81
  width: boardWidth,
@@ -90,8 +90,7 @@ const getAnnotationConfigFromRoomProperties = (properties, logger) => {
90
90
  };
91
91
  };
92
92
  exports.getAnnotationConfigFromRoomProperties = getAnnotationConfigFromRoomProperties;
93
- const resizeToMax = function (w, h) {
94
- let scaleBase = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : FCR_ANNOTATION_SCALE_BASE;
93
+ const resizeToMax = (w, h, scaleBase = FCR_ANNOTATION_SCALE_BASE) => {
95
94
  const scale = scaleBase / Math.max(w, h);
96
95
  return {
97
96
  width: Math.round(w * scale),
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.description.js");
4
3
  require("core-js/modules/es.array.push.js");
5
4
  require("core-js/modules/esnext.function.metadata.js");
6
5
  require("core-js/modules/esnext.map.delete-all.js");
@@ -18,16 +17,10 @@ require("core-js/modules/esnext.map.reduce.js");
18
17
  require("core-js/modules/esnext.map.some.js");
19
18
  require("core-js/modules/esnext.map.update.js");
20
19
  require("core-js/modules/esnext.symbol.metadata.js");
21
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
22
20
  Object.defineProperty(exports, "__esModule", {
23
21
  value: true
24
22
  });
25
23
  exports.FcrWhiteboardControlImpl = void 0;
26
- require("core-js/modules/es.error.cause.js");
27
- require("core-js/modules/es.json.stringify.js");
28
- require("core-js/modules/es.regexp.exec.js");
29
- require("core-js/modules/web.dom-collections.iterator.js");
30
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
31
24
  var _decorator = require("agora-foundation/lib/decorator");
32
25
  var _imports = require("agora-rte-sdk/lib/imports");
33
26
  var _type = require("./type");
@@ -38,7 +31,6 @@ var _forgeWhiteboard = require("@netless/forge-whiteboard");
38
31
  var _mainWindow = require("../main-window");
39
32
  var _error = require("../../../utilities/error");
40
33
  var _logger = require("../../../utilities/logger");
41
- var _FcrWhiteboardControlImpl;
42
34
  let _initProto;
43
35
  function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
44
36
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
@@ -46,22 +38,25 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
46
38
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
47
39
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
48
40
  class FcrWhiteboardControlImpl {
41
+ static {
42
+ [_initProto] = _applyDecs(this, [[[_decorator.bound, _decorator.trace], 2, "openWithConfig"], [[_decorator.bound, _decorator.trace], 2, "close"], [[_decorator.bound, _decorator.trace], 2, "getConnectionState"], [[_decorator.bound, _decorator.trace], 2, "getMainWindow"], [[_decorator.bound, _decorator.trace], 2, "release"], [[_decorator.bound, _decorator.trace], 2, "addPermission"], [[_decorator.bound, _decorator.trace], 2, "removePermission"], [_decorator.bound, 2, "updateConnnectionState"]], []).e;
43
+ }
44
+ logger = (_initProto(this), (0, _logger.createLogger)({
45
+ prefix: 'FcrWhiteboardControlImpl'
46
+ }));
47
+ observable = new _imports.AgoraObservable();
48
+ _connectState = _.FcrConnectionState.DISCONNECTED;
49
+ _openAbortController = null;
49
50
  constructor(_rtmClient, _config) {
50
- (0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
51
- prefix: 'FcrWhiteboardControlImpl'
52
- })));
53
- (0, _defineProperty2.default)(this, "observable", new _imports.AgoraObservable());
54
- (0, _defineProperty2.default)(this, "_connectState", _.FcrConnectionState.DISCONNECTED);
55
- (0, _defineProperty2.default)(this, "_openAbortController", null);
56
51
  this._rtmClient = _rtmClient;
57
52
  this._config = _config;
58
53
  this._addLogObserver();
59
54
  // 用于 sub process 的 board config, 在 main process 中,board config 由 privilege control 提供
60
55
  this._boardConfig = _config.boardConfig;
61
- this.logger.info("[whiteboard][whiteboard-control]: constructor userId: ".concat(_config.userId, ", nickName: ").concat(_config.nickName, ", boardConfig: ").concat(JSON.stringify(_config.boardConfig)));
56
+ this.logger.info(`[whiteboard][whiteboard-control]: constructor userId: ${_config.userId}, nickName: ${_config.nickName}, boardConfig: ${JSON.stringify(_config.boardConfig)}`);
62
57
  }
63
58
  async openWithConfig(config) {
64
- this.logger.info("[whiteboard][whiteboard-control]: openWithConfig config: ".concat(JSON.stringify(config)));
59
+ this.logger.info(`[whiteboard][whiteboard-control]: openWithConfig config: ${JSON.stringify(config)}`);
65
60
  this._boardConfig = config;
66
61
  return await this._connect();
67
62
  }
@@ -101,24 +96,21 @@ class FcrWhiteboardControlImpl {
101
96
  this.observable.removeObserver(observer);
102
97
  }
103
98
  release() {
104
- var _this$boardRoom, _this$boardRoom2;
105
- (_this$boardRoom = this.boardRoom) === null || _this$boardRoom === void 0 || _this$boardRoom.applicationManager.terminateApplication(_type.WHITEBOARD_APP_ID);
106
- (_this$boardRoom2 = this.boardRoom) === null || _this$boardRoom2 === void 0 || _this$boardRoom2.leaveRoom();
99
+ this.boardRoom?.applicationManager.terminateApplication(_type.WHITEBOARD_APP_ID);
100
+ this.boardRoom?.leaveRoom();
107
101
  this.boardRoom = undefined;
108
102
  this._boardView = undefined;
109
103
  this.whiteboard = undefined;
110
104
  }
111
105
  addPermission(permission) {
112
- var _this$whiteboard;
113
- (_this$whiteboard = this.whiteboard) === null || _this$whiteboard === void 0 || _this$whiteboard.permissions.addPermission(permission);
106
+ this.whiteboard?.permissions.addPermission(permission);
114
107
  }
115
108
  removePermission(permission) {
116
- var _this$whiteboard2;
117
- (_this$whiteboard2 = this.whiteboard) === null || _this$whiteboard2 === void 0 || _this$whiteboard2.permissions.removePermission(permission);
109
+ this.whiteboard?.permissions.removePermission(permission);
118
110
  }
119
111
  updateConnnectionState(state) {
120
112
  this._connectState = state;
121
- this.logger.info("[whiteboard][whiteboard-control]: updateConnnectionState ".concat(_.FcrConnectionState[state]));
113
+ this.logger.info(`[whiteboard][whiteboard-control]: updateConnnectionState ${_.FcrConnectionState[state]}`);
122
114
  this.observable.notifyObservers('onConnectionStateUpdated', state);
123
115
  }
124
116
  _addLogObserver() {
@@ -160,7 +152,7 @@ class FcrWhiteboardControlImpl {
160
152
  if (!roomToken) {
161
153
  throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_WHITEBOARD, _error.FcrErrorCode.UNDEFINED_ERROR, 'boardToken is required', new Error('boardToken is required'));
162
154
  }
163
- this.logger.info("open annotation with boardId: ".concat(boardId, ", boardToken: ").concat(roomToken, ", region: ").concat(region));
155
+ this.logger.info(`open annotation with boardId: ${boardId}, boardToken: ${roomToken}, region: ${region}`);
164
156
 
165
157
  // @ts-ignore
166
158
  const rtmProvider = new _forgeRtm.RTMProvider_2_2(this._rtmClient);
@@ -186,7 +178,7 @@ class FcrWhiteboardControlImpl {
186
178
  // useMultiViews: true,
187
179
  }
188
180
  };
189
- this.logger.info("join params: ".concat((0, _imports.jsonstring)(joinRoomParams)));
181
+ this.logger.info(`join params: ${(0, _imports.jsonstring)(joinRoomParams)}`);
190
182
  await wbRoom.joinRoom(joinRoomParams);
191
183
  boardRoom = wbRoom;
192
184
  whiteboard = await wbRoom.applicationManager.launchApplication(_forgeWhiteboard.WhiteboardApplication, {
@@ -199,16 +191,15 @@ class FcrWhiteboardControlImpl {
199
191
  }, _type.WHITEBOARD_APP_ID);
200
192
  }, [], {
201
193
  retriesMax
202
- }).fail(async _ref => {
203
- let {
204
- error,
205
- timeFn,
206
- currentRetry
207
- } = _ref;
194
+ }).fail(async ({
195
+ error,
196
+ timeFn,
197
+ currentRetry
198
+ }) => {
208
199
  if (abortController.signal.aborted) {
209
200
  throw new Error('join board aborted');
210
201
  }
211
- this.logger.info("failed to join board, error: ".concat(error.message, ", current retry: ").concat(currentRetry));
202
+ this.logger.info(`failed to join board, error: ${error.message}, current retry: ${currentRetry}`);
212
203
  await timeFn();
213
204
  return true;
214
205
  }).exec());
@@ -216,7 +207,7 @@ class FcrWhiteboardControlImpl {
216
207
  throw new Error('join board aborted');
217
208
  }
218
209
  if (error) {
219
- this.logger.error("join board failed, ".concat(error.message, "-").concat(JSON.stringify(error)));
210
+ this.logger.error(`join board failed, ${error.message}-${JSON.stringify(error)}`);
220
211
  throw error;
221
212
  }
222
213
  whiteboard.enableCameraByMouse = false;
@@ -230,7 +221,7 @@ class FcrWhiteboardControlImpl {
230
221
  this.updateConnnectionState(_.FcrConnectionState.CONNECTED);
231
222
  resolve(boardView);
232
223
  } catch (e) {
233
- this.logger.error("join board failed");
224
+ this.logger.error(`join board failed`);
234
225
  this.updateConnnectionState(_.FcrConnectionState.DISCONNECTED);
235
226
  reject(e);
236
227
  } finally {
@@ -239,6 +230,4 @@ class FcrWhiteboardControlImpl {
239
230
  });
240
231
  }
241
232
  }
242
- exports.FcrWhiteboardControlImpl = FcrWhiteboardControlImpl;
243
- _FcrWhiteboardControlImpl = FcrWhiteboardControlImpl;
244
- [_initProto] = _applyDecs(_FcrWhiteboardControlImpl, [[[_decorator.bound, _decorator.trace], 2, "openWithConfig"], [[_decorator.bound, _decorator.trace], 2, "close"], [[_decorator.bound, _decorator.trace], 2, "getConnectionState"], [[_decorator.bound, _decorator.trace], 2, "getMainWindow"], [[_decorator.bound, _decorator.trace], 2, "release"], [[_decorator.bound, _decorator.trace], 2, "addPermission"], [[_decorator.bound, _decorator.trace], 2, "removePermission"], [_decorator.bound, 2, "updateConnnectionState"]], []).e;
233
+ exports.FcrWhiteboardControlImpl = FcrWhiteboardControlImpl;
@@ -1,19 +1,17 @@
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.FcrWhiteboardControlFactoryImpl = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _control = require("./control");
10
8
  var _logger = require("../../../utilities/logger");
11
9
  var _privilegeControl2 = require("./privilege-control");
12
10
  class FcrWhiteboardControlFactoryImpl {
11
+ logger = (0, _logger.createLogger)({
12
+ prefix: 'FcrWhiteboardControlFactory'
13
+ });
13
14
  constructor(_rtmClient, _scene, _api, _sharedCache, _privilegeControl) {
14
- (0, _defineProperty2.default)(this, "logger", (0, _logger.createLogger)({
15
- prefix: 'FcrWhiteboardControlFactory'
16
- }));
17
15
  this._rtmClient = _rtmClient;
18
16
  this._scene = _scene;
19
17
  this._api = _api;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.description.js");
4
- require("core-js/modules/es.error.cause.js");
5
3
  require("core-js/modules/es.array.push.js");
6
4
  require("core-js/modules/esnext.function.metadata.js");
7
5
  require("core-js/modules/esnext.map.delete-all.js");
@@ -26,8 +24,6 @@ Object.defineProperty(exports, "__esModule", {
26
24
  exports.FcrPrivilegedWhiteboardControlImpl = void 0;
27
25
  require("core-js/modules/esnext.iterator.constructor.js");
28
26
  require("core-js/modules/esnext.iterator.some.js");
29
- require("core-js/modules/web.dom-collections.iterator.js");
30
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
31
27
  var _enums = require("../../whiteboard-control/enums");
32
28
  var _imports = require("../../../imports");
33
29
  var _user = require("../../../utilities/user");
@@ -40,15 +36,44 @@ var _ = require("../../..");
40
36
  var _helper = require("../../privilege-control/helper");
41
37
  var _forgeWhiteboard = require("@netless/forge-whiteboard");
42
38
  var _validateParams = _interopRequireDefault(require("../../../utilities/validate-params"));
43
- var _FcrPrivilegedWhiteboardControlImpl;
44
- let _initProto, _setBackgroundColorDecs, _ref;
39
+ let _initProto, _setBackgroundColorDecs;
45
40
  function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
46
41
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
47
42
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
48
43
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
49
44
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
50
- _ref = (_setBackgroundColorDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], "_roomCache");
51
45
  class FcrPrivilegedWhiteboardControlImpl extends _control.FcrWhiteboardControlImpl {
46
+ static {
47
+ [_initProto] = _applyDecs(this, [[_imports.bound, 2, "open"], [_imports.trace, 2, "active"], [_imports.trace, 2, "inactive"], [_imports.bound, 2, "getBoardActiveInfo"], [_setBackgroundColorDecs, 2, "setBackgroundColor"], [[_imports.bound, _imports.trace], 2, "getBackgroundColor"], [[_imports.bound, _imports.trace], 2, "getActivity"], [[_imports.bound, _imports.trace], 2, "getOwnerId"], [[_imports.bound, _imports.trace], 2, "_handleApplicationLaunch"], [[_imports.bound, _imports.trace], 2, "_handleApplicationTerminal"], [_imports.bound, 2, "_getToken"], [_imports.bound, 2, "_onScenePropertiesUpdated"], [_imports.bound, 2, "updateConnnectionState"]], [], 0, void 0, _control.FcrWhiteboardControlImpl).e;
48
+ }
49
+ [(_setBackgroundColorDecs = [_imports.bound, _imports.trace, (0, _validateParams.default)(_schema.stringSchema)], "_roomCache")] = void _initProto(this);
50
+ _notifyObservers = {
51
+ onScenePropertiesUpdated: this._onScenePropertiesUpdated
52
+ };
53
+ _privilegeObserver = {
54
+ onLocalUserPermissionInfoAdded: (roomId, event) => {
55
+ if (this._isBoardWritePermission(event)) {
56
+ this.logger.info(`add board write permission`);
57
+ const whiteboard = this.whiteboard;
58
+ if (whiteboard) {
59
+ whiteboard.permissions.addPermission(_forgeWhiteboard.WhiteboardPermissionFlag.all);
60
+ } else {
61
+ this.logger.warn('whiteboard is not initialized yet, should add permission when application launched');
62
+ }
63
+ }
64
+ },
65
+ onLocalUserPermissionInfoDeleted: (roomId, event) => {
66
+ if (this._isBoardWritePermission(event)) {
67
+ this.logger.info(`remove board write permission`);
68
+ const whiteboard = this.whiteboard;
69
+ if (whiteboard) {
70
+ whiteboard.permissions.removePermission(_forgeWhiteboard.WhiteboardPermissionFlag.all);
71
+ } else {
72
+ this.logger.warn('whiteboard is not initialized yet, should remove permission when application launched');
73
+ }
74
+ }
75
+ }
76
+ };
52
77
  get roomId() {
53
78
  return this._scene.sceneId;
54
79
  }
@@ -56,41 +81,12 @@ class FcrPrivilegedWhiteboardControlImpl extends _control.FcrWhiteboardControlIm
56
81
  return this._scene.localUser.getLocalUserId();
57
82
  }
58
83
  constructor(_scene, _api, rtmClient, sharedCache, _privilegeControl) {
59
- var _scene$getUser;
60
84
  const userId = _scene.localUser.getLocalUserId();
61
- const nickName = (_scene$getUser = _scene.getUser(userId)) === null || _scene$getUser === void 0 ? void 0 : _scene$getUser.userName;
85
+ const nickName = _scene.getUser(userId)?.userName;
62
86
  super(rtmClient, {
63
87
  userId,
64
88
  nickName
65
89
  });
66
- (0, _defineProperty2.default)(this, _ref, void _initProto(this));
67
- (0, _defineProperty2.default)(this, "_notifyObservers", {
68
- onScenePropertiesUpdated: this._onScenePropertiesUpdated
69
- });
70
- (0, _defineProperty2.default)(this, "_privilegeObserver", {
71
- onLocalUserPermissionInfoAdded: (roomId, event) => {
72
- if (this._isBoardWritePermission(event)) {
73
- this.logger.info("add board write permission");
74
- const whiteboard = this.whiteboard;
75
- if (whiteboard) {
76
- whiteboard.permissions.addPermission(_forgeWhiteboard.WhiteboardPermissionFlag.all);
77
- } else {
78
- this.logger.warn('whiteboard is not initialized yet, should add permission when application launched');
79
- }
80
- }
81
- },
82
- onLocalUserPermissionInfoDeleted: (roomId, event) => {
83
- if (this._isBoardWritePermission(event)) {
84
- this.logger.info("remove board write permission");
85
- const whiteboard = this.whiteboard;
86
- if (whiteboard) {
87
- whiteboard.permissions.removePermission(_forgeWhiteboard.WhiteboardPermissionFlag.all);
88
- } else {
89
- this.logger.warn('whiteboard is not initialized yet, should remove permission when application launched');
90
- }
91
- }
92
- }
93
- });
94
90
  this._scene = _scene;
95
91
  this._api = _api;
96
92
  this._privilegeControl = _privilegeControl;
@@ -98,7 +94,7 @@ class FcrPrivilegedWhiteboardControlImpl extends _control.FcrWhiteboardControlIm
98
94
  this._scene.addObserver(this._notifyObservers);
99
95
  this._privilegeControl.addObserver(this._privilegeObserver);
100
96
  this.logger.info('[whiteboard][privilege-whiteboard]: constructor');
101
- this.logger.info("[whiteboard][privilege-whiteboard]: Whitebaord Version: forge-whiteboard@".concat((0, _packageInfo.getDependenciesInfo)('@netless/forge-whiteboard'), ", forge-room@").concat((0, _packageInfo.getDependenciesInfo)('@netless/forge-room'), ", forge-rtm@").concat((0, _packageInfo.getDependenciesInfo)('@netless/forge-rtm')));
97
+ this.logger.info(`[whiteboard][privilege-whiteboard]: Whitebaord Version: forge-whiteboard@${(0, _packageInfo.getDependenciesInfo)('@netless/forge-whiteboard')}, forge-room@${(0, _packageInfo.getDependenciesInfo)('@netless/forge-room')}, forge-rtm@${(0, _packageInfo.getDependenciesInfo)('@netless/forge-rtm')}`);
102
98
  }
103
99
  async open() {
104
100
  this.logger.info('[whiteboard][privilege-whiteboard]: start open');
@@ -144,19 +140,18 @@ class FcrPrivilegedWhiteboardControlImpl extends _control.FcrWhiteboardControlIm
144
140
  }
145
141
  }
146
142
  async setBackgroundColor(backgroundColor) {
147
- var _this$getMainWindow;
148
143
  await this._api.setBackgroundColor({
149
144
  roomId: this.roomId,
150
145
  backgroundColor
151
146
  });
152
- (_this$getMainWindow = this.getMainWindow()) === null || _this$getMainWindow === void 0 || _this$getMainWindow.setBackgroundColor(backgroundColor);
147
+ this.getMainWindow()?.setBackgroundColor(backgroundColor);
153
148
  }
154
149
  getBackgroundColor() {
155
150
  return this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard.extra.backgroundColor');
156
151
  }
157
152
  getActivity() {
158
153
  const isActive = this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard').state === 1;
159
- this.logger.info("[whiteboard][privilege-whiteboard]: getActivity isActive: ".concat(isActive));
154
+ this.logger.info(`[whiteboard][privilege-whiteboard]: getActivity isActive: ${isActive}`);
160
155
  return isActive;
161
156
  }
162
157
  getOwnerId() {
@@ -186,31 +181,26 @@ class FcrPrivilegedWhiteboardControlImpl extends _control.FcrWhiteboardControlIm
186
181
  }), _error.FcrErrorModuleCode.ROOM_WHITEBOARD, '[whiteboard][privilege-whiteboard]: get whiteboard token failed');
187
182
  }
188
183
  _isBoardWritePermission(event) {
189
- return event.permissionInfo.some(perm => {
190
- var _perm$info;
191
- return ((_perm$info = perm.info) === null || _perm$info === void 0 ? void 0 : _perm$info.action) === _.FcrPermissionAction.BoardWrite;
192
- });
184
+ return event.permissionInfo.some(perm => perm.info?.action === _.FcrPermissionAction.BoardWrite);
193
185
  }
194
186
  _onScenePropertiesUpdated(sceneId, event) {
195
- var _event$cause;
196
187
  const operatorUser = (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache);
197
188
  const getByKeyPath = value => this._scene.getScenePropertiesByKeyPath(value);
198
- if (((_event$cause = event.cause) === null || _event$cause === void 0 ? void 0 : _event$cause.cmd) === 10) {
199
- var _ref2, _ref3;
189
+ if (event.cause?.cmd === 10) {
200
190
  const {
201
191
  state,
202
192
  ownerUserUuid
203
- } = (_ref2 = getByKeyPath('widgets.netlessBoard')) !== null && _ref2 !== void 0 ? _ref2 : {
193
+ } = getByKeyPath('widgets.netlessBoard') ?? {
204
194
  state: 0
205
195
  };
206
196
  const {
207
197
  backgroundColor: bgColor
208
- } = (_ref3 = getByKeyPath('widgets.netlessBoard.extra')) !== null && _ref3 !== void 0 ? _ref3 : {
198
+ } = getByKeyPath('widgets.netlessBoard.extra') ?? {
209
199
  backgroundColor: '#ffffff'
210
200
  };
211
201
  const widgetCauseReason = (0, _imports.get)(event.cause.data, 'widgetCause.data.reason');
212
202
  const widgetCauseCmd = (0, _imports.get)(event.cause.data, 'widgetCause.cmd');
213
- this.logger.info("[whiteboard][privilege-whiteboard]: onScenePropertiesUpdated ".concat(_type.FcrBoardPropertiesState[state]));
203
+ this.logger.info(`[whiteboard][privilege-whiteboard]: onScenePropertiesUpdated ${_type.FcrBoardPropertiesState[state]}`);
214
204
  if (state === _type.FcrBoardPropertiesState.ACTIVE) {
215
205
  this.observable.notifyObservers('onActive', ownerUserUuid, operatorUser);
216
206
  }
@@ -247,6 +237,4 @@ class FcrPrivilegedWhiteboardControlImpl extends _control.FcrWhiteboardControlIm
247
237
  }
248
238
  }
249
239
  }
250
- exports.FcrPrivilegedWhiteboardControlImpl = FcrPrivilegedWhiteboardControlImpl;
251
- _FcrPrivilegedWhiteboardControlImpl = FcrPrivilegedWhiteboardControlImpl;
252
- [_initProto] = _applyDecs(_FcrPrivilegedWhiteboardControlImpl, [[_imports.bound, 2, "open"], [_imports.trace, 2, "active"], [_imports.trace, 2, "inactive"], [_imports.bound, 2, "getBoardActiveInfo"], [_setBackgroundColorDecs, 2, "setBackgroundColor"], [[_imports.bound, _imports.trace], 2, "getBackgroundColor"], [[_imports.bound, _imports.trace], 2, "getActivity"], [[_imports.bound, _imports.trace], 2, "getOwnerId"], [[_imports.bound, _imports.trace], 2, "_handleApplicationLaunch"], [[_imports.bound, _imports.trace], 2, "_handleApplicationTerminal"], [_imports.bound, 2, "_getToken"], [_imports.bound, 2, "_onScenePropertiesUpdated"], [_imports.bound, 2, "updateConnnectionState"]], [], 0, void 0, _control.FcrWhiteboardControlImpl).e;
240
+ exports.FcrPrivilegedWhiteboardControlImpl = FcrPrivilegedWhiteboardControlImpl;