fcr-core 3.6.2 → 3.6.3

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.
@@ -19,7 +19,7 @@ export declare class FcrAnnotationControlImpl implements FcrAnnotationControl {
19
19
  private _boardRoom;
20
20
  private _observable;
21
21
  private _connectState;
22
- private _joined;
22
+ private _needRetry;
23
23
  constructor(_scene: AgoraRteScene, _api: FcrCoreServiceApi, _engine: AgoraRteEngine, _privilegeControl: FcrPrivilegeControl, _sharedCache: FcrSharedCache);
24
24
  open(): Promise<FcrBoardMainWindow>;
25
25
  close(): Promise<void>;
@@ -49,7 +49,7 @@ class FcrAnnotationControlImpl {
49
49
  (0, _defineProperty2.default)(this, "_FCR_ANNOTATION_APP_ID", 'Annotation');
50
50
  (0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
51
51
  (0, _defineProperty2.default)(this, "_connectState", _.FcrConnectionState.DISCONNECTED);
52
- (0, _defineProperty2.default)(this, "_joined", false);
52
+ (0, _defineProperty2.default)(this, "_needRetry", true);
53
53
  this._scene = _scene;
54
54
  this._api = _api;
55
55
  this._engine = _engine;
@@ -109,6 +109,7 @@ class FcrAnnotationControlImpl {
109
109
  whiteboard.enableCameraByTouch = false;
110
110
  whiteboard.setViewModeToMain();
111
111
  this._boardView = new _mainWindow.FcrBoardMainWindowImpl(whiteboard, this._scene, this._sharedCache, wbRoom);
112
+ this._needRetry = false;
112
113
  this._boardView.setBackgroundColor('rgba(0, 0, 0, 0)');
113
114
  // this._boardView.setBoardTransparent(true);
114
115
  this._updateConnnectionState(_.FcrConnectionState.CONNECTED);
@@ -120,10 +121,10 @@ class FcrAnnotationControlImpl {
120
121
  timeFn,
121
122
  currentRetry
122
123
  } = _ref;
123
- this.logger.info("failed to join board room, error: ".concat(error.message, ", current retry: ").concat(currentRetry));
124
- this._joined && (await timeFn());
125
- this.logger.info("continue attemptting? ".concat(this._joined));
126
- return this._joined;
124
+ this.logger.info("[annotation]: failed to join board room, error: ".concat(error.message, ", current retry: ").concat(currentRetry));
125
+ this._needRetry && (await timeFn());
126
+ this.logger.info("[annotation]: continue attemptting? need retry: ".concat(this._needRetry));
127
+ return this._needRetry;
127
128
  }).abort(() => {
128
129
  this._updateConnnectionState(_.FcrConnectionState.DISCONNECTED);
129
130
  }).exec();
@@ -133,12 +134,14 @@ class FcrAnnotationControlImpl {
133
134
  return this._boardView;
134
135
  }
135
136
  async close() {
136
- var _this$_boardRoom, _this$_boardRoom2;
137
- this._joined = false;
138
- (_this$_boardRoom = this._boardRoom) === null || _this$_boardRoom === void 0 || _this$_boardRoom.applicationManager.terminateApplication(this._FCR_ANNOTATION_APP_ID);
139
- await ((_this$_boardRoom2 = this._boardRoom) === null || _this$_boardRoom2 === void 0 ? void 0 : _this$_boardRoom2.leaveRoom());
137
+ var _this$_boardRoom, _this$_boardRoom2, _this$_boardRoom3;
138
+ this._needRetry = false;
139
+ (_this$_boardRoom = this._boardRoom) === null || _this$_boardRoom === void 0 || _this$_boardRoom.applicationManager.removeAllListeners();
140
+ (_this$_boardRoom2 = this._boardRoom) === null || _this$_boardRoom2 === void 0 || _this$_boardRoom2.applicationManager.terminateApplication(this._FCR_ANNOTATION_APP_ID);
141
+ await ((_this$_boardRoom3 = this._boardRoom) === null || _this$_boardRoom3 === void 0 ? void 0 : _this$_boardRoom3.leaveRoom());
140
142
  this._boardRoom = undefined;
141
143
  this._boardView = undefined;
144
+ this.logger.info('[annotation]: closed annotation control');
142
145
  }
143
146
  getConnectionState() {
144
147
  return this._connectState;
@@ -14,7 +14,7 @@ export declare class FcrWhiteboardControlImpl implements FcrWhiteboardControl {
14
14
  private _boardRoom;
15
15
  private _observable;
16
16
  private _connectState;
17
- private _joined;
17
+ private _needRetry;
18
18
  private _FORGE_WHITEBOARD_APP_ID;
19
19
  private _roomCache;
20
20
  constructor(_scene: AgoraRteScene, _api: FcrCoreServiceApi, _engine: AgoraRteEngine, _sharedCache: FcrSharedCache);
@@ -57,7 +57,7 @@ class FcrWhiteboardControlImpl {
57
57
  })));
58
58
  (0, _defineProperty2.default)(this, "_observable", new _observable.AgoraObservable());
59
59
  (0, _defineProperty2.default)(this, "_connectState", _2.FcrConnectionState.DISCONNECTED);
60
- (0, _defineProperty2.default)(this, "_joined", false);
60
+ (0, _defineProperty2.default)(this, "_needRetry", true);
61
61
  (0, _defineProperty2.default)(this, "_FORGE_WHITEBOARD_APP_ID", 'MainWhiteboard');
62
62
  this._scene = _scene;
63
63
  this._api = _api;
@@ -90,25 +90,30 @@ class FcrWhiteboardControlImpl {
90
90
  const rtmClient = this._engine._rtmClient._client;
91
91
  const rtmProvider = new _forgeRtm.RTMProvider_2_2(rtmClient);
92
92
  const wbRoom = new _forgeRoom.Room(boardId, rtmProvider);
93
- rtmProvider.addListener('connectionStatusChange', state => {
94
- switch (state) {
95
- case 'CONNECTED':
96
- this._updateConnnectionState(_2.FcrConnectionState.CONNECTED);
97
- break;
98
- case 'RECONNECTING':
99
- this._updateConnnectionState(_2.FcrConnectionState.RECONNECTING);
100
- break;
101
- case 'CONNECTING':
102
- this._updateConnnectionState(_2.FcrConnectionState.CONNECTING);
103
- break;
104
- case 'DISCONNECTED':
105
- this._updateConnnectionState(_2.FcrConnectionState.DISCONNECTED);
106
- break;
107
- }
108
- });
93
+
94
+ // rtmProvider.addListener('connectionStatusChange', (state: ConnectionStatus) => {
95
+ // switch (state) {
96
+ // case 'CONNECTED':
97
+ // this._updateConnnectionState(FcrConnectionState.CONNECTED);
98
+ // break;
99
+ // case 'RECONNECTING':
100
+ // this._updateConnnectionState(FcrConnectionState.RECONNECTING);
101
+ // break;
102
+ // case 'CONNECTING':
103
+ // this._updateConnnectionState(FcrConnectionState.CONNECTING);
104
+ // break;
105
+ // case 'DISCONNECTED':
106
+ // this._updateConnnectionState(FcrConnectionState.DISCONNECTED);
107
+ // break;
108
+ // }
109
+ // });
110
+ // 由于白板用的也是 rtm 的链接状态,主应用也通过监听 rtm 状态的变化来显示加载动画,所以白板不再需要监听 rtm 状态的变化,三端、产品和测试已同步
111
+ // 白板的 rtm 状态和加入房间更新的状态用的是同一个枚举,在弱网环境下有冲突会导致问题,去掉之后即不再有此问题
112
+
109
113
  wbRoom.applicationManager.registerApplication(_forgeWhiteboard.WhiteboardApplication);
110
114
  try {
111
115
  this._updateConnnectionState(_2.FcrConnectionState.CONNECTING);
116
+ this.logger.info('[whiteboard]: join board room, state: CONNECTING');
112
117
  const retriesMax = 10;
113
118
  await (0, _asyncRetry.retryAttempt)(async () => {
114
119
  await wbRoom.joinRoom({
@@ -142,6 +147,8 @@ class FcrWhiteboardControlImpl {
142
147
  // this._updateConnnectionState(FcrConnectionState.DISCONNECTED);
143
148
  // });
144
149
  this._boardView = new _mainWindow.FcrBoardMainWindowImpl(whiteboard, this._scene, this._sharedCache, wbRoom);
150
+ this._needRetry = false;
151
+ this.logger.info('[whiteboard]: join board room success, state: CONNECTED');
145
152
  this._updateConnnectionState(_2.FcrConnectionState.CONNECTED);
146
153
  }, [], {
147
154
  retriesMax
@@ -151,21 +158,23 @@ class FcrWhiteboardControlImpl {
151
158
  timeFn,
152
159
  currentRetry
153
160
  } = _ref2;
154
- this.logger.info("failed to join board room, error: ".concat(error.message, ", current retry: ").concat(currentRetry));
155
- this._joined && (await timeFn());
156
- this.logger.info("continue attemptting? ".concat(this._joined));
157
- return this._joined;
161
+ this.logger.info("[whiteboard]: failed to join board room, error: ".concat(error.message, ", current retry: ").concat(currentRetry));
162
+ this._needRetry && (await timeFn());
163
+ this.logger.info("[whiteboard]: continue attemptting? need retry: ".concat(this._needRetry));
164
+ return this._needRetry;
158
165
  }).abort(() => {
166
+ this.logger.info('[whiteboard]: join board room aborted, state: DISCONNECTED');
159
167
  this._updateConnnectionState(_2.FcrConnectionState.DISCONNECTED);
160
168
  }).exec();
161
169
  } catch (e) {
170
+ this.logger.info('[whiteboard]: join board room failed, state: DISCONNECTED');
162
171
  this._updateConnnectionState(_2.FcrConnectionState.DISCONNECTED);
163
172
  }
164
173
  return this._boardView;
165
174
  }
166
175
  async close() {
167
176
  var _this$_boardRoom, _this$_boardRoom2;
168
- this._joined = false;
177
+ this._needRetry = false;
169
178
  (_this$_boardRoom = this._boardRoom) === null || _this$_boardRoom === void 0 || _this$_boardRoom.applicationManager.terminateApplication(this._FORGE_WHITEBOARD_APP_ID);
170
179
  await ((_this$_boardRoom2 = this._boardRoom) === null || _this$_boardRoom2 === void 0 ? void 0 : _this$_boardRoom2.leaveRoom());
171
180
  this._boardRoom = undefined;
@@ -37,5 +37,7 @@ export declare class FcrBoardMainWindowImpl implements FcrBoardMainWindow {
37
37
  removeObserver(observer: FcrBoardMainWindowObserver): void;
38
38
  private _addWindowManagerEventListeners;
39
39
  private _isBoardWritePermission;
40
+ private _handleApplicationLaunch;
41
+ private _handleApplicationTerminal;
40
42
  private _addLogObserver;
41
43
  }
@@ -66,20 +66,8 @@ class FcrBoardMainWindowImpl {
66
66
  this._whiteboard = whiteboard;
67
67
  this._scene = scene;
68
68
  this._addWindowManagerEventListeners();
69
- boardRoom.applicationManager.on('launch', (appId, app) => {
70
- this.logger.info('launch event is triggered');
71
- const newNode = app.view;
72
- newNode.style.height = "100%";
73
- newNode.style.width = "100%";
74
- if (this._background) {
75
- newNode.style.backgroundColor = 'rgba(0,0,0,0)';
76
- }
77
- this._boardView.appendChild(newNode);
78
- });
79
- boardRoom.applicationManager.on('terminal', (appId, app) => {
80
- this.logger.info('terminal event is triggered');
81
- this._boardView.removeChild(app.view);
82
- });
69
+ boardRoom.applicationManager.on('launch', this._handleApplicationLaunch);
70
+ boardRoom.applicationManager.on('terminal', this._handleApplicationTerminal);
83
71
  const hasOperationPrivilege = (0, _helper.getLocalUserPermissionInfo)(scene, _type.FcrPermissionAction.BoardWrite).enable || (0, _helper.getLocalUserPermissionInfo)(scene, _type.FcrPermissionAction.AnnotationWrite).enable;
84
72
  whiteboard.permissions[hasOperationPrivilege ? 'addPermission' : 'removePermission'](_forgeWhiteboard.WhiteboardPermissionFlag.all);
85
73
  (0, _helper.addLocalUserPermissionObserver)(scene, {
@@ -236,10 +224,24 @@ class FcrBoardMainWindowImpl {
236
224
  return ((_perm$info = perm.info) === null || _perm$info === void 0 ? void 0 : _perm$info.action) === _type.FcrPermissionAction.BoardWrite;
237
225
  });
238
226
  }
227
+ _handleApplicationLaunch(appId, app) {
228
+ this.logger.info('launch event is triggered');
229
+ const newNode = app.view;
230
+ newNode.style.height = "100%";
231
+ newNode.style.width = "100%";
232
+ if (this._background) {
233
+ newNode.style.backgroundColor = 'rgba(0,0,0,0)';
234
+ }
235
+ this._boardView.appendChild(newNode);
236
+ }
237
+ _handleApplicationTerminal(appId, app) {
238
+ this.logger.info('terminal event is triggered');
239
+ this._boardView.removeChild(app.view);
240
+ }
239
241
  _addLogObserver() {
240
242
  this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onPageInfoUpdated', 'onUndoStateUpdated', 'onRedoStateUpdated']));
241
243
  }
242
244
  }
243
245
  exports.FcrBoardMainWindowImpl = FcrBoardMainWindowImpl;
244
246
  _FcrBoardMainWindowImpl = FcrBoardMainWindowImpl;
245
- [_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"]], []).e;
247
+ [_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"], [_imports.bound, 2, "_handleApplicationLaunch"], [_imports.bound, 2, "_handleApplicationTerminal"]], []).e;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fcr-core",
3
3
  "description": "Core APIs for building online scenes",
4
- "version": "3.6.2",
4
+ "version": "3.6.3",
5
5
  "module": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "files": [
@@ -40,7 +40,7 @@
40
40
  "@types/lodash": "^4.14.168",
41
41
  "@types/sinon": "^17.0.2",
42
42
  "@types/uuid": "^8.3.0",
43
- "agora-toolchain": "^3.6.2",
43
+ "agora-toolchain": "^3.6.3",
44
44
  "core-js": "^3.33.3",
45
45
  "decomment": "^0.9.5",
46
46
  "husky": "^9.0.11",
@@ -60,8 +60,8 @@
60
60
  "@netless/video-js-plugin": "^0.3.8",
61
61
  "@netless/white-snapshot": "^0.4.2",
62
62
  "@netless/window-manager": "^0.4.72",
63
- "agora-foundation": "^3.6.2",
64
- "agora-rte-sdk": "^3.6.2",
63
+ "agora-foundation": "^3.6.3",
64
+ "agora-rte-sdk": "^3.6.3",
65
65
  "await-to-js": "^3.0.0",
66
66
  "dayjs": "^1.10.4",
67
67
  "easemob-websdk": "4.8.1",
@@ -1,38 +0,0 @@
1
- import { FcrBoardActiveInfo, FcrBoardMainWindow } from '../../whiteboard-control/types';
2
- import { AgoraRteEngine, AgoraRteScene } from '../../../imports';
3
- import { FcrCoreServiceApi } from '../../../service/api';
4
- import { FcrConnectionState } from '../../../';
5
- import { FcrWhiteboardControl, FcrWhiteboardObserver } from '../whiteboard-control/type';
6
- import { FcrSharedCache } from '../../shared-cache';
7
- export declare class FcrWhiteboardControlImpl implements FcrWhiteboardControl {
8
- private _scene;
9
- private _api;
10
- private _engine;
11
- private _sharedCache;
12
- protected logger: import("agora-foundation/lib/logger").Logger;
13
- private _boardView;
14
- private _boardRoom;
15
- private _observable;
16
- private _connectState;
17
- private _joined;
18
- private _FORGE_WHITEBOARD_APP_ID;
19
- private _roomCache;
20
- constructor(_scene: AgoraRteScene, _api: FcrCoreServiceApi, _engine: AgoraRteEngine, _sharedCache: FcrSharedCache);
21
- open(): Promise<FcrBoardMainWindow>;
22
- close(): Promise<void>;
23
- active(): Promise<void>;
24
- inactive(): Promise<void>;
25
- getConnectionState(): FcrConnectionState;
26
- getMainWindow(): FcrBoardMainWindow | undefined;
27
- getBoardActiveInfo(): FcrBoardActiveInfo;
28
- setBackgroundColor(backgroundColor: string): Promise<void>;
29
- getBackgroundColor(): string | undefined;
30
- getActivity(): boolean;
31
- getOwnerId(): string;
32
- addObserver(observer: FcrWhiteboardObserver): void;
33
- removeObserver(observer: FcrWhiteboardObserver): void;
34
- private _notifyObservers;
35
- private _updateConnnectionState;
36
- private _getToken;
37
- private _addLogObserver;
38
- }
@@ -1,261 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.symbol.description.js");
4
- require("core-js/modules/es.error.cause.js");
5
- require("core-js/modules/es.array.push.js");
6
- require("core-js/modules/esnext.function.metadata.js");
7
- require("core-js/modules/esnext.map.delete-all.js");
8
- require("core-js/modules/esnext.map.emplace.js");
9
- require("core-js/modules/esnext.map.every.js");
10
- require("core-js/modules/esnext.map.filter.js");
11
- require("core-js/modules/esnext.map.find.js");
12
- require("core-js/modules/esnext.map.find-key.js");
13
- require("core-js/modules/esnext.map.includes.js");
14
- require("core-js/modules/esnext.map.key-of.js");
15
- require("core-js/modules/esnext.map.map-keys.js");
16
- require("core-js/modules/esnext.map.map-values.js");
17
- require("core-js/modules/esnext.map.merge.js");
18
- require("core-js/modules/esnext.map.reduce.js");
19
- require("core-js/modules/esnext.map.some.js");
20
- require("core-js/modules/esnext.map.update.js");
21
- require("core-js/modules/esnext.symbol.metadata.js");
22
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
23
- Object.defineProperty(exports, "__esModule", {
24
- value: true
25
- });
26
- exports.FcrWhiteboardControlImpl = void 0;
27
- require("core-js/modules/es.regexp.exec.js");
28
- require("core-js/modules/web.dom-collections.iterator.js");
29
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
30
- var _enums = require("../../whiteboard-control/enums");
31
- var _forgeRoom = require("@netless/forge-room");
32
- var _forgeWhiteboard = require("@netless/forge-whiteboard");
33
- var _forgeRtm = require("@netless/forge-rtm");
34
- var _asyncRetry = require("agora-foundation/lib/utilities/async-retry");
35
- var _mainWindow = require("../main-window");
36
- var _user = require("../../../utilities/user");
37
- var _observable = require("agora-foundation/lib/utilities/observable");
38
- var _decorator = require("agora-foundation/lib/decorator");
39
- var _ = require("../../../");
40
- var _logger = require("../../../utilities/logger");
41
- var _error = require("../../../utilities/error");
42
- var _validateParams = _interopRequireDefault(require("../../../utilities/validate-params"));
43
- var _schema = require("../../../schema");
44
- var _FcrWhiteboardControlImpl;
45
- let _initProto, _setBackgroundColorDecs, _ref;
46
- 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)]; } }; }
47
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
48
- 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); }
49
- 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; }
50
- 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; }
51
- _ref = (_setBackgroundColorDecs = [_decorator.bound, _logger.trace, (0, _validateParams.default)(_schema.stringSchema)], "logger");
52
- class FcrWhiteboardControlImpl {
53
- constructor(_scene, _api, _engine, _sharedCache) {
54
- (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
55
- prefix: 'FcrWhiteboardControlImpl'
56
- })));
57
- (0, _defineProperty2.default)(this, "_observable", new _observable.AgoraObservable());
58
- (0, _defineProperty2.default)(this, "_connectState", _.FcrConnectionState.DISCONNECTED);
59
- (0, _defineProperty2.default)(this, "_joined", false);
60
- (0, _defineProperty2.default)(this, "_FORGE_WHITEBOARD_APP_ID", 'MainWhiteboard');
61
- this._scene = _scene;
62
- this._api = _api;
63
- this._engine = _engine;
64
- this._sharedCache = _sharedCache;
65
- this._roomCache = _sharedCache.getRoomCache(this._scene.sceneId);
66
- this._addLogObserver();
67
- _scene.addObserver(this._notifyObservers());
68
- }
69
- async open() {
70
- var _this$_scene$getUser;
71
- // 此宽高为设计稿中的白板尺寸,如无特殊需求,不建议修改
72
- const width = 1920;
73
- const height = 1220;
74
- const roomId = this._scene.sceneId;
75
- const userId = this._scene.localUser.getLocalUserId();
76
- const nickName = (_this$_scene$getUser = this._scene.getUser(userId)) === null || _this$_scene$getUser === void 0 ? void 0 : _this$_scene$getUser.userName;
77
- const {
78
- data
79
- } = await this._getToken(roomId, userId);
80
- const {
81
- boardAppId: appIdentifier,
82
- boardId,
83
- boardRegion: region,
84
- boardToken: roomToken
85
- } = data || {};
86
-
87
- // @ts-ignore
88
- const rtmClient = this._engine._rtmClient._client;
89
- const rtmProvider = new _forgeRtm.RTMProvider_2_2(rtmClient);
90
- const wbRoom = new _forgeRoom.Room(boardId, rtmProvider);
91
- wbRoom.applicationManager.registerApplication(_forgeWhiteboard.WhiteboardApplication);
92
- try {
93
- this._updateConnnectionState(_.FcrConnectionState.CONNECTING);
94
- const retriesMax = 10;
95
- await (0, _asyncRetry.retryAttempt)(async () => {
96
- await wbRoom.joinRoom({
97
- userId,
98
- nickName,
99
- roomToken,
100
- sdkConfig: {
101
- // @ts-ignore
102
- region,
103
- appIdentifier
104
- }
105
- });
106
- this._boardRoom = wbRoom;
107
- this.logger.info({
108
- appIdentifier,
109
- boardId,
110
- region,
111
- roomToken
112
- });
113
- const whiteboard = await wbRoom.applicationManager.launchApplication(_forgeWhiteboard.WhiteboardApplication, {
114
- width,
115
- height,
116
- defaultToolbarStyle: {
117
- tool: 'laser'
118
- }
119
- }, this._FORGE_WHITEBOARD_APP_ID);
120
- whiteboard.enableCameraByMouse = false;
121
- whiteboard.enableCameraByTouch = false;
122
- whiteboard.setViewModeToMain();
123
- // wbRoom.applicationManager.on('terminal', () => {
124
- // this._updateConnnectionState(FcrConnectionState.DISCONNECTED);
125
- // });
126
- this._boardView = new _mainWindow.FcrBoardMainWindowImpl(whiteboard, this._scene, this._sharedCache, wbRoom);
127
- this._updateConnnectionState(_.FcrConnectionState.CONNECTED);
128
- }, [], {
129
- retriesMax
130
- }).fail(async _ref2 => {
131
- let {
132
- error,
133
- timeFn,
134
- currentRetry
135
- } = _ref2;
136
- this.logger.info("failed to join board room, error: ".concat(error.message, ", current retry: ").concat(currentRetry));
137
- this._joined && (await timeFn());
138
- this.logger.info("continue attemptting? ".concat(this._joined));
139
- return this._joined;
140
- }).abort(() => {
141
- this._updateConnnectionState(_.FcrConnectionState.DISCONNECTED);
142
- }).exec();
143
- } catch (e) {
144
- this._updateConnnectionState(_.FcrConnectionState.DISCONNECTED);
145
- }
146
- return this._boardView;
147
- }
148
- async close() {
149
- var _this$_boardRoom, _this$_boardRoom2;
150
- this._joined = false;
151
- (_this$_boardRoom = this._boardRoom) === null || _this$_boardRoom === void 0 || _this$_boardRoom.applicationManager.terminateApplication(this._FORGE_WHITEBOARD_APP_ID);
152
- await ((_this$_boardRoom2 = this._boardRoom) === null || _this$_boardRoom2 === void 0 ? void 0 : _this$_boardRoom2.leaveRoom());
153
- this._boardRoom = undefined;
154
- this._boardView = undefined;
155
- }
156
- async active() {
157
- return (0, _error.handleRequestError)(() => this._api.toggleWhiteboardActivityState(this._scene.sceneId, _enums.FcrSharePermissionState.ON), _error.FcrErrorModuleCode.ROOM_WHITEBOARD, 'active failed');
158
- }
159
- async inactive() {
160
- return (0, _error.handleRequestError)(() => this._api.toggleWhiteboardActivityState(this._scene.sceneId, _enums.FcrSharePermissionState.OFF), _error.FcrErrorModuleCode.ROOM_WHITEBOARD, 'inactive failed');
161
- }
162
- getConnectionState() {
163
- return this._connectState;
164
- }
165
- getMainWindow() {
166
- return this._boardView;
167
- }
168
- getBoardActiveInfo() {
169
- const {
170
- state,
171
- ownerUserUuid: ownerUserId
172
- } = this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard') || {
173
- isActive: false,
174
- ownerUserUuid: null
175
- };
176
- const isActive = state === _enums.FcrSharePermissionState.ON;
177
- if (isActive) {
178
- return {
179
- isActive: true,
180
- ownerUserId
181
- };
182
- } else {
183
- return {
184
- isActive: false,
185
- ownerUserId: null
186
- };
187
- }
188
- }
189
- async setBackgroundColor(backgroundColor) {
190
- var _this$_boardView;
191
- await this._api.setBackgroundColor({
192
- roomId: this._scene.sceneId,
193
- backgroundColor
194
- });
195
- (_this$_boardView = this._boardView) === null || _this$_boardView === void 0 || _this$_boardView.setBackgroundColor(backgroundColor);
196
- }
197
- getBackgroundColor() {
198
- return this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard.extra.backgroundColor');
199
- }
200
- getActivity() {
201
- return this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard').state === 1;
202
- }
203
- getOwnerId() {
204
- return this._scene.getScenePropertiesByKeyPath('widgets.netlessBoard.ownerUserUuid');
205
- }
206
- addObserver(observer) {
207
- this._observable.addObserver(observer);
208
- }
209
- removeObserver(observer) {
210
- this._observable.removeObserver(observer);
211
- }
212
- _notifyObservers() {
213
- return {
214
- onScenePropertiesUpdated: (sceneId, event) => {
215
- var _event$cause;
216
- const operatorUser = (0, _user.convertRteUserToFcrUser)(event.operatorUser, this._roomCache);
217
- const getByKeyPath = value => this._scene.getScenePropertiesByKeyPath(value);
218
- if (((_event$cause = event.cause) === null || _event$cause === void 0 ? void 0 : _event$cause.cmd) === 10) {
219
- var _ref3, _ref4, _event$cause$data$wid2;
220
- const {
221
- state,
222
- ownerUserUuid
223
- } = (_ref3 = getByKeyPath('widgets.netlessBoard')) !== null && _ref3 !== void 0 ? _ref3 : {
224
- state: 0
225
- };
226
- const {
227
- backgroundColor: bgColor
228
- } = (_ref4 = getByKeyPath('widgets.netlessBoard.extra')) !== null && _ref4 !== void 0 ? _ref4 : {
229
- backgroundColor: '#ffffff'
230
- };
231
- if (state === 1) {
232
- this._observable.notifyObservers('onActive', ownerUserUuid, operatorUser);
233
- }
234
- if (state === 0) {
235
- var _event$cause$data$wid;
236
- this._observable.notifyObservers('onInactive', (_event$cause$data$wid = event.cause.data.widgetCause) === null || _event$cause$data$wid === void 0 || (_event$cause$data$wid = _event$cause$data$wid.data) === null || _event$cause$data$wid === void 0 ? void 0 : _event$cause$data$wid.reason, operatorUser);
237
- }
238
- if (((_event$cause$data$wid2 = event.cause.data.widgetCause) === null || _event$cause$data$wid2 === void 0 ? void 0 : _event$cause$data$wid2.cmd) === 100101) {
239
- this._observable.notifyObservers('onBackgroundColorUpdated', bgColor, operatorUser);
240
- }
241
- }
242
- }
243
- };
244
- }
245
- _updateConnnectionState(state) {
246
- this._connectState = state;
247
- this._observable.notifyObservers('onConnectionStateUpdated', state);
248
- }
249
- async _getToken(roomId, userId) {
250
- return await (0, _error.handleRequestError)(() => this._api.getWhiteboardToken({
251
- roomId,
252
- userId
253
- }), _error.FcrErrorModuleCode.ROOM_WHITEBOARD, 'get whiteboard token failed');
254
- }
255
- _addLogObserver() {
256
- this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onActive', 'onInactive', 'onBackgroundColorUpdated', 'onConnectionStateUpdated']));
257
- }
258
- }
259
- exports.FcrWhiteboardControlImpl = FcrWhiteboardControlImpl;
260
- _FcrWhiteboardControlImpl = FcrWhiteboardControlImpl;
261
- [_initProto] = _applyDecs(_FcrWhiteboardControlImpl, [[_logger.trace, 2, "open"], [_logger.trace, 2, "close"], [_logger.trace, 2, "active"], [_logger.trace, 2, "inactive"], [[_decorator.bound, _logger.trace], 2, "getConnectionState"], [[_decorator.bound, _logger.trace], 2, "getMainWindow"], [_decorator.bound, 2, "getBoardActiveInfo"], [_setBackgroundColorDecs, 2, "setBackgroundColor"], [[_decorator.bound, _logger.trace], 2, "getBackgroundColor"], [[_decorator.bound, _logger.trace], 2, "getActivity"], [[_decorator.bound, _logger.trace], 2, "getOwnerId"], [_decorator.bound, 2, "_notifyObservers"], [_decorator.bound, 2, "_updateConnnectionState"], [_decorator.bound, 2, "_getToken"]], []).e;