fcr-core 3.7.8 → 3.8.0-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 (108) hide show
  1. package/lib/chat-connection/index.d.ts +1 -1
  2. package/lib/engine/index.js +6 -5
  3. package/lib/imports.d.ts +7 -2
  4. package/lib/imports.js +25 -4
  5. package/lib/index.d.ts +2 -2
  6. package/lib/index.js +12 -0
  7. package/lib/media-control/desktop.js +4 -4
  8. package/lib/media-control/mobile.js +20 -20
  9. package/lib/media-control/type.d.ts +8 -0
  10. package/lib/plugins/chatroom.js +19 -3
  11. package/lib/room-control/ability-control/type.d.ts +4 -1
  12. package/lib/room-control/ability-control/type.js +3 -0
  13. package/lib/room-control/helpers/constants.d.ts +4 -0
  14. package/lib/room-control/helpers/constants.js +5 -1
  15. package/lib/room-control/index.js +16 -5
  16. package/lib/room-control/interpreter-control/index.js +2 -4
  17. package/lib/room-control/mainroom-control/index.js +66 -1
  18. package/lib/room-control/privilege-control/index.js +43 -3
  19. package/lib/room-control/privilege-control/type.d.ts +57 -10
  20. package/lib/room-control/privilege-control/type.js +17 -0
  21. package/lib/room-control/room-control-factory.js +1 -1
  22. package/lib/room-control/room-session/index.js +23 -13
  23. package/lib/room-control/room-session/type.d.ts +2 -2
  24. package/lib/room-control/sharing-control/index.d.ts +5 -5
  25. package/lib/room-control/sharing-control/index.js +43 -13
  26. package/lib/room-control/sharing-control/type.d.ts +9 -5
  27. package/lib/room-control/sharing-control/type.js +6 -1
  28. package/lib/room-control/stream-control/index.d.ts +8 -1
  29. package/lib/room-control/stream-control/index.js +139 -36
  30. package/lib/room-control/stream-control/type.d.ts +6 -0
  31. package/lib/room-control/stt-control/de-compress-gzip.d.ts +1 -0
  32. package/lib/room-control/stt-control/de-compress-gzip.js +49 -0
  33. package/lib/room-control/stt-control/index.d.ts +1 -0
  34. package/lib/room-control/stt-control/index.js +353 -0
  35. package/lib/room-control/stt-control/type.d.ts +142 -0
  36. package/lib/room-control/stt-control/type.js +16 -0
  37. package/lib/room-control/type.d.ts +15 -0
  38. package/lib/room-control/type.js +13 -1
  39. package/lib/room-control/whiteboard-control/enum.d.ts +15 -0
  40. package/lib/room-control/whiteboard-control/{types.js → enum.js} +12 -1
  41. package/lib/room-control/whiteboard-control/type.d.ts +38 -0
  42. package/lib/room-control/whiteboard-control/type.js +15 -0
  43. package/lib/room-control/whiteboard-control/utils.d.ts +3 -0
  44. package/lib/room-control/whiteboard-control/utils.js +23 -0
  45. package/lib/room-control/whiteboard-control-v1/board-subwindow.d.ts +6 -0
  46. package/lib/room-control/whiteboard-control-v1/board-subwindow.js +26 -0
  47. package/lib/room-control/whiteboard-control-v1/board-window.d.ts +58 -0
  48. package/lib/room-control/whiteboard-control-v1/board-window.js +571 -0
  49. package/lib/room-control/{whiteboard-control/enums.d.ts → whiteboard-control-v1/enum.d.ts} +3 -17
  50. package/lib/room-control/{whiteboard-control/enums.js → whiteboard-control-v1/enum.js} +3 -20
  51. package/lib/room-control/whiteboard-control-v1/factory.d.ts +9 -0
  52. package/lib/room-control/whiteboard-control-v1/factory.js +22 -0
  53. package/lib/room-control/whiteboard-control-v1/index.d.ts +1 -0
  54. package/lib/room-control/whiteboard-control-v1/index.js +440 -0
  55. package/lib/room-control/whiteboard-control-v1/mount-manager.d.ts +4 -0
  56. package/lib/room-control/whiteboard-control-v1/mount-manager.js +15 -0
  57. package/lib/room-control/whiteboard-control-v1/type.d.ts +300 -0
  58. package/lib/room-control/whiteboard-control-v1/type.js +13 -0
  59. package/lib/room-control/whiteboard-control-v1/utils.d.ts +53 -0
  60. package/lib/room-control/whiteboard-control-v1/utils.js +290 -0
  61. package/lib/room-control/whiteboard-control-v2/annotation-control/control.d.ts +17 -31
  62. package/lib/room-control/whiteboard-control-v2/annotation-control/control.js +39 -233
  63. package/lib/room-control/whiteboard-control-v2/annotation-control/factory.d.ts +10 -0
  64. package/lib/room-control/whiteboard-control-v2/annotation-control/factory.js +48 -0
  65. package/lib/room-control/whiteboard-control-v2/annotation-control/type.d.ts +11 -19
  66. package/lib/room-control/whiteboard-control-v2/annotation-control/type.js +1 -3
  67. package/lib/room-control/whiteboard-control-v2/base/index.d.ts +42 -0
  68. package/lib/room-control/whiteboard-control-v2/base/index.js +317 -0
  69. package/lib/room-control/whiteboard-control-v2/{main-window.d.ts → base/main-window.d.ts} +6 -4
  70. package/lib/room-control/whiteboard-control-v2/{main-window.js → base/main-window.js} +31 -18
  71. package/lib/room-control/whiteboard-control-v2/constant.d.ts +6 -0
  72. package/lib/room-control/whiteboard-control-v2/constant.js +15 -0
  73. package/lib/room-control/whiteboard-control-v2/enum.d.ts +26 -0
  74. package/lib/room-control/whiteboard-control-v2/enum.js +34 -0
  75. package/lib/room-control/{whiteboard-control/types.d.ts → whiteboard-control-v2/type.d.ts} +51 -165
  76. package/lib/room-control/whiteboard-control-v2/type.js +5 -0
  77. package/lib/room-control/whiteboard-control-v2/utils.d.ts +5 -4
  78. package/lib/room-control/whiteboard-control-v2/utils.js +22 -21
  79. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.d.ts +34 -33
  80. package/lib/room-control/whiteboard-control-v2/whiteboard-control/control.js +124 -191
  81. package/lib/room-control/whiteboard-control-v2/whiteboard-control/factory.d.ts +11 -0
  82. package/lib/room-control/whiteboard-control-v2/{annotation-control/index.js → whiteboard-control/factory.js} +35 -44
  83. package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.d.ts +18 -30
  84. package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.js +1 -9
  85. package/lib/room-router/index.js +4 -0
  86. package/lib/schema.d.ts +23 -9
  87. package/lib/schema.js +10 -4
  88. package/lib/service/api.d.ts +75 -19
  89. package/lib/service/api.js +193 -24
  90. package/lib/type.d.ts +15 -2
  91. package/lib/type.js +13 -0
  92. package/lib/utilities/error-helpers.d.ts +2 -1
  93. package/lib/utilities/error-helpers.js +1 -0
  94. package/lib/utilities/error.d.ts +1 -0
  95. package/lib/utilities/error.js +1 -0
  96. package/lib/utilities/logger.d.ts +2 -2
  97. package/lib/utilities/shared-storage.d.ts +3 -1
  98. package/lib/utilities/shared-storage.js +9 -1
  99. package/package.json +11 -5
  100. package/lib/room-control/whiteboard-control-v2/annotation-control/index.d.ts +0 -19
  101. package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.d.ts +0 -36
  102. package/lib/room-control/whiteboard-control-v2/annotation-control/privilege-control.js +0 -262
  103. package/lib/room-control/whiteboard-control-v2/index.d.ts +0 -38
  104. package/lib/room-control/whiteboard-control-v2/index.js +0 -286
  105. package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.d.ts +0 -17
  106. package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +0 -32
  107. package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.d.ts +0 -36
  108. package/lib/room-control/whiteboard-control-v2/whiteboard-control/privilege-control.js +0 -252
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.symbol.description.js");
4
+ require("core-js/modules/es.error.cause.js");
4
5
  require("core-js/modules/es.array.push.js");
5
6
  require("core-js/modules/esnext.function.metadata.js");
7
+ require("core-js/modules/esnext.iterator.constructor.js");
8
+ require("core-js/modules/esnext.iterator.filter.js");
9
+ require("core-js/modules/esnext.iterator.for-each.js");
6
10
  require("core-js/modules/esnext.map.delete-all.js");
7
11
  require("core-js/modules/esnext.map.emplace.js");
8
12
  require("core-js/modules/esnext.map.every.js");
@@ -22,223 +26,152 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
22
26
  Object.defineProperty(exports, "__esModule", {
23
27
  value: true
24
28
  });
25
- 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
+ exports.FcrWhiteboardControlImpl = exports.FcrStandaloneWhiteboardControlImpl = void 0;
29
30
  require("core-js/modules/web.dom-collections.iterator.js");
30
31
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
31
- var _decorator = require("agora-foundation/lib/decorator");
32
- var _imports = require("agora-rte-sdk/lib/imports");
33
- var _type = require("./type");
34
- var _ = require("../../..");
35
- var _forgeRtm = require("@netless/forge-rtm");
36
- var _forgeRoom = require("@netless/forge-room");
37
- var _forgeWhiteboard = require("@netless/forge-whiteboard");
38
- var _mainWindow = require("../main-window");
32
+ var _imports = require("../../../imports");
33
+ var _user = require("../../../utilities/user");
39
34
  var _error = require("../../../utilities/error");
35
+ var _schema = require("../../../schema");
36
+ var _packageInfo = require("../../../utilities/package-info");
37
+ var _validateParams = _interopRequireDefault(require("../../../utilities/validate-params"));
38
+ var _base = require("../base");
39
+ var _constant = require("../constant");
40
+ var _type = require("../../whiteboard-control/type");
41
+ var _type2 = require("../../sharing-control/type");
40
42
  var _logger = require("../../../utilities/logger");
41
- var _FcrWhiteboardControlImpl;
42
- let _initProto;
43
+ var _utils = require("../utils");
44
+ var _ref, _FcrWhiteboardControlImpl;
45
+ let _initProto, _setBackgroundColorDecs, _ref2;
46
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
47
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
43
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)]; } }; }
44
49
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
45
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); }
46
51
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
47
52
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
48
- class FcrWhiteboardControlImpl {
49
- constructor(_rtmClient, _config) {
50
- (0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
53
+ _ref2 = (_setBackgroundColorDecs = [_imports.trace, (0, _validateParams.default)(_schema.stringSchema)], "logger");
54
+ class FcrWhiteboardControlImpl extends (_ref = _base.FcrBaseWhiteboardControlImpl) {
55
+ constructor(rtmClient, config, hasOperationPrivilege, sharedCache, forgeInitConfigFetcher, _scene, _api) {
56
+ super(rtmClient, config, hasOperationPrivilege, forgeInitConfigFetcher);
57
+ (0, _defineProperty2.default)(this, _ref2, (_initProto(this), (0, _logger.createLogger)({
51
58
  prefix: 'FcrWhiteboardControlImpl'
52
59
  })));
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
- this._rtmClient = _rtmClient;
57
- this._config = _config;
58
- this._addLogObserver();
59
- // 用于 sub process 的 board config, 在 main process 中,board config 由 privilege control 提供
60
- 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)));
62
- }
63
- async openWithConfig(config) {
64
- this.logger.info("[whiteboard][whiteboard-control]: openWithConfig config: ".concat(JSON.stringify(config)));
65
- this._boardConfig = config;
66
- return await this._connect();
67
- }
68
- async open() {
69
- return await this._connect();
70
- }
71
- async close() {
72
- try {
73
- if (this._openAbortController) {
74
- this._openAbortController.abort();
75
- this._openAbortController = null;
76
- }
77
- const boardRoom = this.boardRoom;
78
- this.boardRoom = undefined;
79
- this._boardView = undefined;
80
- if (boardRoom) {
81
- boardRoom.applicationManager.removeAllListeners();
82
- boardRoom.applicationManager.terminateApplication(_type.WHITEBOARD_APP_ID);
83
- await boardRoom.leaveRoom();
84
- this.logger.info('the whitebaord room is closed');
85
- this.updateConnnectionState(_.FcrConnectionState.DISCONNECTED);
86
- }
87
- } catch (error) {
88
- this.logger.error('close board failed', error);
60
+ (0, _defineProperty2.default)(this, "_backgroundColor", '#ffffff');
61
+ (0, _defineProperty2.default)(this, "_isActive", false);
62
+ (0, _defineProperty2.default)(this, "_ownerId", null);
63
+ (0, _defineProperty2.default)(this, "_notifyObservers", {
64
+ onScenePropertiesUpdated: this._onScenePropertiesUpdated
65
+ });
66
+ this._scene = _scene;
67
+ this._api = _api;
68
+ this._roomCache = sharedCache.getRoomCache(config.roomId);
69
+ this._scene.addObserver(this._notifyObservers);
70
+ this.logger.info("Whitebaord Version: forge-whiteboard@".concat((0, _packageInfo.getDependenciesInfo)('@netless/forge-whiteboard'), ", forge-room@").concat((0, _packageInfo.getDependenciesInfo)('@netless/forge-room'), ", forge-room@").concat((0, _packageInfo.getDependenciesInfo)('@netless/forge-rtm')));
71
+ this._isActive = this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard').state === 1;
72
+ const backgroundColor = this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard.extra.backgroundColor');
73
+ if (backgroundColor) {
74
+ this._backgroundColor = backgroundColor;
89
75
  }
76
+ const ownerId = this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard.ownerUserUuid');
77
+ if (ownerId) {
78
+ this._ownerId = ownerId;
79
+ }
80
+ this.logger.info("initialized, hasOperationPrivilege: ".concat(hasOperationPrivilege));
90
81
  }
91
- getConnectionState() {
92
- return this._connectState;
93
- }
94
- getMainWindow() {
95
- return this._boardView;
82
+ async active() {
83
+ return (0, _error.handleRequestError)(() => this._api.toggleWhiteboardActivityState(this.config.roomId, _type2.FcrSharePermissionState.ON), _error.FcrErrorModuleCode.ROOM_WHITEBOARD, 'active failed');
96
84
  }
97
- addObserver(observer) {
98
- this.observable.addObserver(observer);
85
+ async inactive() {
86
+ return (0, _error.handleRequestError)(() => this._api.toggleWhiteboardActivityState(this.config.roomId, _type2.FcrSharePermissionState.OFF), _error.FcrErrorModuleCode.ROOM_WHITEBOARD, 'inactive failed');
99
87
  }
100
- removeObserver(observer) {
101
- this.observable.removeObserver(observer);
88
+ getBoardActiveInfo() {
89
+ const {
90
+ state,
91
+ ownerUserUuid: ownerUserId
92
+ } = this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard');
93
+ if (state === _type.FcrBoardPropertiesState.ACTIVE) {
94
+ return {
95
+ isActive: true,
96
+ ownerUserId
97
+ };
98
+ } else {
99
+ return {
100
+ isActive: false,
101
+ ownerUserId: null
102
+ };
103
+ }
102
104
  }
103
- 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();
107
- this.boardRoom = undefined;
108
- this._boardView = undefined;
109
- this.whiteboard = undefined;
105
+ async setBackgroundColor(backgroundColor) {
106
+ await this._api.setBackgroundColor({
107
+ roomId: this.config.roomId,
108
+ backgroundColor
109
+ });
110
+ this._backgroundColor = backgroundColor;
111
+ if (this.boardView) {
112
+ this.boardView.setBackgroundColor(backgroundColor);
113
+ }
110
114
  }
111
- addPermission(permission) {
112
- var _this$whiteboard;
113
- (_this$whiteboard = this.whiteboard) === null || _this$whiteboard === void 0 || _this$whiteboard.permissions.addPermission(permission);
115
+ getBackgroundColor() {
116
+ return this._backgroundColor;
114
117
  }
115
- removePermission(permission) {
116
- var _this$whiteboard2;
117
- (_this$whiteboard2 = this.whiteboard) === null || _this$whiteboard2 === void 0 || _this$whiteboard2.permissions.removePermission(permission);
118
+ getActivity() {
119
+ return this._isActive;
118
120
  }
119
- updateConnnectionState(state) {
120
- this._connectState = state;
121
- this.logger.info("[whiteboard][whiteboard-control]: updateConnnectionState ".concat(_.FcrConnectionState[state]));
122
- this.observable.notifyObservers('onConnectionStateUpdated', state);
121
+ getOwnerId() {
122
+ return this._ownerId;
123
123
  }
124
- _addLogObserver() {
125
- this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onConnectionStateUpdated', 'onActive', 'onInactive', 'onBackgroundColorUpdated']));
124
+ getApplicationId() {
125
+ return _constant.WHITEBOARD_APP_ID;
126
126
  }
127
- async _connect() {
128
- if (this._boardView) {
129
- this.logger.info('annotation already connected, returning existing board view');
130
- return this._boardView;
131
- }
132
- const abortController = new AbortController();
133
- this._openAbortController = abortController;
134
- return new Promise(async (resolve, reject) => {
135
- // 监听中止信号
136
- abortController.signal.addEventListener('abort', () => {
137
- reject(new Error('join board aborted'));
138
- });
139
- const {
140
- userId,
141
- nickName
142
- } = this._config;
143
- const width = 1920;
144
- const height = 1080;
145
- const {
146
- boardAppId: appIdentifier,
147
- boardId,
148
- boardRegion: region,
149
- boardToken: roomToken
150
- } = this._boardConfig || {};
151
- if (!appIdentifier) {
152
- throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_WHITEBOARD, _error.FcrErrorCode.UNDEFINED_ERROR, 'board boardAppId is required', new Error('board boardAppId is required'));
127
+ _onScenePropertiesUpdated(sceneId, event) {
128
+ const operatorUser = (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache);
129
+ const getByKeyPath = value => this._scene.getScenePropertiesByKeyPath(value);
130
+ if (event.cause && event.cause.cmd === 10) {
131
+ var _getByKeyPath;
132
+ const state = (_getByKeyPath = getByKeyPath('widgets.netlessBoard.state')) !== null && _getByKeyPath !== void 0 ? _getByKeyPath : _type.FcrBoardPropertiesState.INACTIVE;
133
+ const backgroundColor = getByKeyPath('widgets.netlessBoard.extra.backgroundColor');
134
+ const widgetCauseReason = (0, _imports.get)(event.cause.data, 'widgetCause.data.reason');
135
+ const widgetCauseCmd = (0, _imports.get)(event.cause.data, 'widgetCause.cmd');
136
+ if (state === _type.FcrBoardPropertiesState.ACTIVE) {
137
+ const ownerUserId = getByKeyPath('widgets.netlessBoard.ownerUserUuid');
138
+ this._ownerId = ownerUserId;
139
+ this._isActive = true;
140
+ this.observable.notifyObservers('onActive', ownerUserId, operatorUser);
153
141
  }
154
- if (!region) {
155
- throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_WHITEBOARD, _error.FcrErrorCode.UNDEFINED_ERROR, 'board region is required', new Error('board region is required'));
142
+ if (state === _type.FcrBoardPropertiesState.INACTIVE) {
143
+ this._ownerId = null;
144
+ this._isActive = false;
145
+ this.observable.notifyObservers('onInactive', widgetCauseReason, operatorUser);
156
146
  }
157
- if (!boardId) {
158
- throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_WHITEBOARD, _error.FcrErrorCode.UNDEFINED_ERROR, 'boardId is required', new Error('boardId is required'));
159
- }
160
- if (!roomToken) {
161
- throw (0, _error.generateFcrCoreClientError)(_error.FcrErrorModuleCode.ROOM_WHITEBOARD, _error.FcrErrorCode.UNDEFINED_ERROR, 'boardToken is required', new Error('boardToken is required'));
162
- }
163
- this.logger.info("open annotation with boardId: ".concat(boardId, ", boardToken: ").concat(roomToken, ", region: ").concat(region));
164
-
165
- // @ts-ignore
166
- const rtmProvider = new _forgeRtm.RTMProvider_2_2(this._rtmClient);
167
- const wbRoom = new _forgeRoom.Room(boardId, rtmProvider);
168
- wbRoom.applicationManager.registerApplication(_forgeWhiteboard.WhiteboardApplication);
169
- try {
170
- this.updateConnnectionState(_.FcrConnectionState.CONNECTING);
171
- const retriesMax = 10;
172
- let error = null;
173
- let boardView = null;
174
- let whiteboard = null;
175
- let boardRoom = wbRoom;
176
- [error] = await (0, _imports.to)((0, _imports.retryAttempt)(async () => {
177
- const joinRoomParams = {
178
- userId,
179
- nickName,
180
- roomToken,
181
- sdkConfig: {
182
- // @ts-ignore
183
- region,
184
- appIdentifier
185
- // enableIFramePlugin: false,
186
- // useMultiViews: true,
187
- }
188
- };
189
- this.logger.info("join params: ".concat((0, _imports.jsonstring)(joinRoomParams)));
190
- await wbRoom.joinRoom(joinRoomParams);
191
- boardRoom = wbRoom;
192
- whiteboard = await wbRoom.applicationManager.launchApplication(_forgeWhiteboard.WhiteboardApplication, {
193
- width,
194
- height,
195
- defaultToolbarStyle: {
196
- tool: 'laser'
197
- },
198
- maxScaleRatio: 1
199
- }, _type.WHITEBOARD_APP_ID);
200
- }, [], {
201
- retriesMax
202
- }).fail(async _ref => {
203
- let {
204
- error,
205
- timeFn,
206
- currentRetry
207
- } = _ref;
208
- if (abortController.signal.aborted) {
209
- throw new Error('join board aborted');
210
- }
211
- this.logger.info("failed to join board, error: ".concat(error.message, ", current retry: ").concat(currentRetry));
212
- await timeFn();
213
- return true;
214
- }).exec());
215
- if (abortController.signal.aborted) {
216
- throw new Error('join board aborted');
217
- }
218
- if (error) {
219
- this.logger.error("join board failed, ".concat(error.message, "-").concat(JSON.stringify(error)));
220
- throw error;
221
- }
222
- whiteboard.enableCameraByMouse = false;
223
- whiteboard.enableCameraByTouch = false;
224
- whiteboard.setViewModeToMain();
225
- boardView = new _mainWindow.FcrBoardMainWindowImpl(whiteboard, wbRoom);
226
- boardView.setBackgroundColor('rgba(255, 255, 255, 1)');
227
- this.whiteboard = whiteboard;
228
- this._boardView = boardView;
229
- this.boardRoom = boardRoom;
230
- this.updateConnnectionState(_.FcrConnectionState.CONNECTED);
231
- resolve(boardView);
232
- } catch (e) {
233
- this.logger.error("join board failed");
234
- this.updateConnnectionState(_.FcrConnectionState.DISCONNECTED);
235
- reject(e);
236
- } finally {
237
- this._openAbortController = null;
147
+ if (widgetCauseCmd === _type.FcrBoardPropertiesState.BACKGROUND_COLOR_UPDATED) {
148
+ this._backgroundColor = backgroundColor;
149
+ this.observable.notifyObservers('onBackgroundColorUpdated', backgroundColor, operatorUser);
238
150
  }
151
+ }
152
+ }
153
+ getWhiteboardOption() {
154
+ return _objectSpread(_objectSpread({}, super.getWhiteboardOption()), {}, {
155
+ width: _utils.WHITEBOARD_WIDTH,
156
+ height: _utils.WHITEBOARD_HEIGHT
239
157
  });
240
158
  }
159
+ addLogObserver() {
160
+ this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onConnectionStateUpdated', 'onActive', 'onInactive', 'onBackgroundColorUpdated']));
161
+ }
241
162
  }
242
163
  exports.FcrWhiteboardControlImpl = FcrWhiteboardControlImpl;
243
164
  _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;
165
+ [_initProto] = _applyDecs(_FcrWhiteboardControlImpl, [[_imports.trace, 2, "active"], [_imports.trace, 2, "inactive"], [_setBackgroundColorDecs, 2, "setBackgroundColor"], [_imports.trace, 2, "getBackgroundColor"], [_imports.trace, 2, "getActivity"], [_imports.trace, 2, "getOwnerId"], [_imports.bound, 2, "_onScenePropertiesUpdated"]], [], 0, void 0, _ref).e;
166
+ class FcrStandaloneWhiteboardControlImpl extends _base.FcrBaseWhiteboardControlImpl {
167
+ getApplicationId() {
168
+ return _constant.WHITEBOARD_APP_ID;
169
+ }
170
+ getWhiteboardOption() {
171
+ return _objectSpread(_objectSpread({}, super.getWhiteboardOption()), {}, {
172
+ width: _utils.WHITEBOARD_WIDTH,
173
+ height: _utils.WHITEBOARD_HEIGHT
174
+ });
175
+ }
176
+ }
177
+ exports.FcrStandaloneWhiteboardControlImpl = FcrStandaloneWhiteboardControlImpl;
@@ -0,0 +1,11 @@
1
+ import { FcrCoreServiceApi } from '../../../service/api';
2
+ import { FcrSharedCache } from '../../shared-cache';
3
+ import { FcrBoardConfig, FcrStandaloneWhiteboardControl, FcrWhiteboardControl, FcrWhiteboardControlFactory } from './type';
4
+ import type { RTMClient } from 'agora-rtm';
5
+ import { AgoraRteScene } from 'agora-rte-sdk';
6
+ export declare class FcrWhiteboardControlFactoryImpl implements FcrWhiteboardControlFactory {
7
+ protected logger: import("agora-foundation/lib/logger").Logger;
8
+ createForSubProcess(rtmClient: RTMClient, hasOperationPrivilege: boolean, boardConfig: FcrBoardConfig): FcrStandaloneWhiteboardControl;
9
+ createForMainProcess(rtmClient: RTMClient, hasOperationPrivilege: boolean, boardConfig: FcrBoardConfig, scene: AgoraRteScene, api: FcrCoreServiceApi, sharedCache: FcrSharedCache): FcrWhiteboardControl;
10
+ private _createForgeInitConfigFetcher;
11
+ }
@@ -1,12 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.symbol.description.js");
4
- require("core-js/modules/es.error.cause.js");
5
4
  require("core-js/modules/es.array.push.js");
6
5
  require("core-js/modules/esnext.function.metadata.js");
7
- require("core-js/modules/esnext.iterator.constructor.js");
8
- require("core-js/modules/esnext.iterator.filter.js");
9
- require("core-js/modules/esnext.iterator.for-each.js");
10
6
  require("core-js/modules/esnext.map.delete-all.js");
11
7
  require("core-js/modules/esnext.map.emplace.js");
12
8
  require("core-js/modules/esnext.map.every.js");
@@ -26,59 +22,54 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
26
22
  Object.defineProperty(exports, "__esModule", {
27
23
  value: true
28
24
  });
29
- exports.FcrAnnotationControlFactoryImpl = void 0;
30
- require("core-js/modules/es.json.stringify.js");
25
+ exports.FcrWhiteboardControlFactoryImpl = void 0;
26
+ require("core-js/modules/es.error.cause.js");
31
27
  require("core-js/modules/web.dom-collections.iterator.js");
32
28
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
33
- var _control = require("./control");
34
- var _decorator = require("agora-foundation/lib/decorator");
35
29
  var _logger = require("../../../utilities/logger");
36
- var _privilegeControl2 = require("./privilege-control");
37
- var _utils = require("../utils");
38
- var _FcrAnnotationControlFactoryImpl;
30
+ var _error = require("../../../utilities/error");
31
+ var _log = require("agora-foundation/lib/decorator/log");
32
+ var _base = require("../base");
33
+ var _control = require("./control");
34
+ var _sharedStorage = require("../../../utilities/shared-storage");
35
+ var _FcrWhiteboardControlFactoryImpl;
39
36
  let _initProto;
40
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
41
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
42
37
  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
38
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
44
39
  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); }
45
40
  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
41
  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
- class FcrAnnotationControlFactoryImpl {
48
- constructor(_rtmClient, _scene, _streamControl, _userControl, _privilegeControl, _api) {
42
+ class FcrWhiteboardControlFactoryImpl {
43
+ constructor() {
49
44
  (0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _logger.createLogger)({
50
- prefix: 'FcrAnnotationControlFactory'
45
+ prefix: 'FcrWhiteboardControlFactory'
51
46
  })));
52
- this._rtmClient = _rtmClient;
53
- this._scene = _scene;
54
- this._streamControl = _streamControl;
55
- this._userControl = _userControl;
56
- this._privilegeControl = _privilegeControl;
57
- this._api = _api;
58
- this.logger.info("[annotation]: constructor initialized");
59
47
  }
60
- createForSubProcess(config) {
61
- this.logger.info("[annotation]: create for sub process with config: ".concat(JSON.stringify(config)));
62
- return new _control.FcrAnnotationControlImpl(this._rtmClient, config);
48
+ createForSubProcess(rtmClient, hasOperationPrivilege, boardConfig) {
49
+ return new _base.FcrBaseWhiteboardControlImpl(rtmClient, boardConfig, hasOperationPrivilege, () => {
50
+ const forgeInitConfig = (0, _sharedStorage.getWhiteboardOptions)();
51
+ if (!forgeInitConfig) {
52
+ 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"));
53
+ }
54
+ return Promise.resolve(forgeInitConfig);
55
+ });
63
56
  }
64
- createForMainProcess() {
65
- this.logger.info("[annotation]: start create for main process");
66
- const config = this._getBoardConfigInfoWithScene();
67
- this.logger.info("[annotation]: create for main process with config: ".concat(JSON.stringify(config)));
68
- const control = new _privilegeControl2.FcrPrivilegedAnnotationControlImpl(this._rtmClient, config, this._scene, this._streamControl, this._userControl, this._privilegeControl, this._api);
69
- return control;
57
+ createForMainProcess(rtmClient, hasOperationPrivilege, boardConfig, scene, api, sharedCache) {
58
+ return new _control.FcrWhiteboardControlImpl(rtmClient, boardConfig, hasOperationPrivilege, sharedCache, this._createForgeInitConfigFetcher(api, boardConfig.roomId, boardConfig.userId), scene, api);
70
59
  }
71
- _getBoardConfigInfoWithScene() {
72
- var _this$_userControl;
73
- const roomProperties = this._scene.getSceneProperties();
74
- const localUser = (_this$_userControl = this._userControl) === null || _this$_userControl === void 0 ? void 0 : _this$_userControl.getLocalUser();
75
- const annotationConfig = (0, _utils.getAnnotationConfigFromRoomProperties)(roomProperties, this.logger);
76
- return _objectSpread({
77
- userId: localUser.userId,
78
- nickName: localUser.userName
79
- }, annotationConfig);
60
+ _createForgeInitConfigFetcher(api, roomId, userId) {
61
+ const getObjectInitConfig = async (roomId, userId) => {
62
+ return await (0, _error.handleRequestError)(() => api.getWhiteboardToken({
63
+ roomId,
64
+ userId
65
+ }), _error.FcrErrorModuleCode.ROOM_WHITEBOARD, 'get whiteboard token failed');
66
+ };
67
+ return async () => {
68
+ const response = await getObjectInitConfig(roomId, userId);
69
+ return response.data;
70
+ };
80
71
  }
81
72
  }
82
- exports.FcrAnnotationControlFactoryImpl = FcrAnnotationControlFactoryImpl;
83
- _FcrAnnotationControlFactoryImpl = FcrAnnotationControlFactoryImpl;
84
- [_initProto] = _applyDecs(_FcrAnnotationControlFactoryImpl, [[_decorator.bound, 2, "_getBoardConfigInfoWithScene"]], []).e;
73
+ exports.FcrWhiteboardControlFactoryImpl = FcrWhiteboardControlFactoryImpl;
74
+ _FcrWhiteboardControlFactoryImpl = FcrWhiteboardControlFactoryImpl;
75
+ [_initProto] = _applyDecs(_FcrWhiteboardControlFactoryImpl, [[_log.trace, 2, "createForSubProcess"], [_log.trace, 2, "createForMainProcess"]], []).e;
@@ -1,30 +1,21 @@
1
- import { FcrConnectionState } from '../../../type';
2
1
  import { FcrUserInfo } from '../../../type';
3
- import { FcrBaseWhiteboardControl, FcrBoardExtra, FcrBoardInactiveReason } from '../../whiteboard-control/types';
4
- import { FcrWhiteboardPermissionFlag } from '../../../imports';
5
- export declare const WHITEBOARD_APP_ID = "MainWhiteboard";
6
- export interface FcrWhiteboardControl extends FcrBaseWhiteboardControl {
7
- addPermission(permission: FcrWhiteboardPermissionFlag): void;
8
- removePermission(permission: FcrWhiteboardPermissionFlag): void;
9
- addObserver(observer: FcrWhiteboardObserver): void;
10
- removeObserver(observer: FcrWhiteboardObserver): void;
2
+ import { FcrBaseWhiteboardControl, FcrBaseWhiteboardObserver } from '../type';
3
+ import { AgoraRteScene } from '../../../imports';
4
+ import { FcrCoreServiceApi } from '../../../service/api';
5
+ import { FcrSharedCache } from '../../shared-cache';
6
+ import type { RTMClient } from 'agora-rtm';
7
+ import { FcrBoardInactiveReason } from '../../whiteboard-control/enum';
8
+ export interface FcrStandaloneWhiteboardControl extends FcrBaseWhiteboardControl<FcrBaseWhiteboardObserver> {
11
9
  }
12
- export interface FcrPrivilegedWhiteboardControl extends FcrBaseWhiteboardControl {
10
+ export interface FcrWhiteboardControl extends FcrBaseWhiteboardControl<FcrWhiteboardObserver> {
13
11
  active(): Promise<void>;
14
12
  inactive(): Promise<void>;
15
13
  getActivity(): boolean;
16
- getOwnerId(): string;
17
- getBackgroundColor(): string | undefined;
14
+ getOwnerId(): string | null;
15
+ getBackgroundColor(): string;
18
16
  setBackgroundColor(color: string): Promise<void>;
19
- addObserver(observer: FcrWhiteboardObserver): void;
20
- removeObserver(observer: FcrWhiteboardObserver): void;
21
17
  }
22
- export type FcrWhiteboardObserver = {
23
- /**
24
- * Callback to receive the connection state change.
25
- * @param state
26
- */
27
- onConnectionStateUpdated?(state: FcrConnectionState): void;
18
+ export interface FcrWhiteboardObserver extends FcrBaseWhiteboardObserver {
28
19
  /**
29
20
  * Callback to receive the background color of the whiteboard change.
30
21
  * @param info
@@ -41,18 +32,15 @@ export type FcrWhiteboardObserver = {
41
32
  * @param operatorUser
42
33
  */
43
34
  onInactive?(reason: FcrBoardInactiveReason, operatorUser?: FcrUserInfo): void;
44
- };
35
+ }
45
36
  export type FcrBoardConfig = {
46
37
  userId: string;
47
- nickName: string;
48
- boardConfig?: FcrBoardExtra;
38
+ userName: string;
39
+ boardRatio: number;
40
+ roomId: string;
49
41
  };
50
- export declare enum FcrBoardPropertiesState {
51
- ACTIVE = 1,
52
- INACTIVE = 0,
53
- BACKGROUND_COLOR_UPDATED = 100101
54
- }
42
+ export type FcrBoardConfigForPrivilege = Pick<FcrBoardConfig, 'userId' | 'userName'>;
55
43
  export interface FcrWhiteboardControlFactory {
56
- createForSubProcess(config: FcrBoardConfig): FcrBaseWhiteboardControl;
57
- createForMainProcess(): FcrPrivilegedWhiteboardControl;
44
+ createForSubProcess(rtmClient: RTMClient, hasOperationPrivilege: boolean, boardConfig: FcrBoardConfig): FcrStandaloneWhiteboardControl;
45
+ createForMainProcess(rtmClient: RTMClient, hasOperationPrivilege: boolean, boardConfig: FcrBoardConfig, scene: AgoraRteScene, api: FcrCoreServiceApi, sharedCache: FcrSharedCache): FcrWhiteboardControl;
58
46
  }
@@ -2,12 +2,4 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
6
- exports.WHITEBOARD_APP_ID = exports.FcrBoardPropertiesState = void 0;
7
- const WHITEBOARD_APP_ID = exports.WHITEBOARD_APP_ID = 'MainWhiteboard';
8
- let FcrBoardPropertiesState = exports.FcrBoardPropertiesState = /*#__PURE__*/function (FcrBoardPropertiesState) {
9
- FcrBoardPropertiesState[FcrBoardPropertiesState["ACTIVE"] = 1] = "ACTIVE";
10
- FcrBoardPropertiesState[FcrBoardPropertiesState["INACTIVE"] = 0] = "INACTIVE";
11
- FcrBoardPropertiesState[FcrBoardPropertiesState["BACKGROUND_COLOR_UPDATED"] = 100101] = "BACKGROUND_COLOR_UPDATED";
12
- return FcrBoardPropertiesState;
13
- }({});
5
+ });
@@ -82,6 +82,7 @@ class FcrRoomRouterImpl {
82
82
  this._chatConnection = _chatConnection;
83
83
  this._sharedCache = _sharedCache;
84
84
  this._init(roomId);
85
+ this._addLogObserver();
85
86
  }
86
87
  get roomControl() {
87
88
  if (!this._roomControl) {
@@ -256,6 +257,9 @@ class FcrRoomRouterImpl {
256
257
  throw new Error('Join room attempt aborted');
257
258
  }
258
259
  }
260
+ _addLogObserver() {
261
+ this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onErrorOccurred', 'onRoomJoined', 'onRoomRouteSwitched']));
262
+ }
259
263
  addObserver(observer) {
260
264
  this._observable.addObserver(observer);
261
265
  }