fcr-core 3.6.0 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/engine/index.js +1 -1
  2. package/lib/room-control/ability-control/index.js +1 -1
  3. package/lib/room-control/index.js +12 -8
  4. package/lib/room-control/interpreter-control/index.js +13 -3
  5. package/lib/room-control/mainroom-control/index.js +17 -2
  6. package/lib/room-control/privilege-control/index.js +32 -4
  7. package/lib/room-control/privilege-control/type.d.ts +13 -3
  8. package/lib/room-control/privilege-control/type.js +3 -0
  9. package/lib/room-control/sharing-control/index.d.ts +44 -0
  10. package/lib/room-control/sharing-control/index.js +217 -0
  11. package/lib/room-control/sharing-control/type.d.ts +31 -0
  12. package/lib/room-control/sharing-control/type.js +17 -0
  13. package/lib/room-control/stream-control/index.js +80 -11
  14. package/lib/room-control/stream-control/type.d.ts +3 -2
  15. package/lib/room-control/type.d.ts +5 -5
  16. package/lib/room-control/whiteboard-control/board-window.d.ts +4 -3
  17. package/lib/room-control/whiteboard-control/board-window.js +4 -1
  18. package/lib/room-control/whiteboard-control/types.d.ts +39 -72
  19. package/lib/room-control/whiteboard-control-v2/annotation-control/index.d.ts +33 -0
  20. package/lib/room-control/whiteboard-control-v2/annotation-control/index.js +187 -0
  21. package/lib/room-control/whiteboard-control-v2/annotation-control/type.d.ts +32 -0
  22. package/lib/room-control/whiteboard-control-v2/annotation-control/type.js +5 -0
  23. package/lib/room-control/whiteboard-control-v2/index.d.ts +2 -1
  24. package/lib/room-control/whiteboard-control-v2/index.js +19 -1
  25. package/lib/room-control/whiteboard-control-v2/main-window.d.ts +7 -4
  26. package/lib/room-control/whiteboard-control-v2/main-window.js +20 -3
  27. package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.d.ts +38 -0
  28. package/lib/room-control/whiteboard-control-v2/whiteboard-control/index.js +261 -0
  29. package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.d.ts +42 -0
  30. package/lib/room-control/whiteboard-control-v2/whiteboard-control/type.js +5 -0
  31. package/lib/schema.d.ts +21 -0
  32. package/lib/schema.js +9 -1
  33. package/lib/service/api.d.ts +64 -3
  34. package/lib/service/api.js +88 -3
  35. package/lib/type.d.ts +7 -0
  36. package/lib/utilities/package-info.d.ts +2 -0
  37. package/lib/utilities/package-info.js +6 -2
  38. package/package.json +7 -7
@@ -0,0 +1,187 @@
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.FcrAnnotationControlImpl = 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 _forgeRoom = require("@netless/forge-room");
31
+ var _forgeWhiteboard = require("@netless/forge-whiteboard");
32
+ var _imports = require("agora-rte-sdk/lib/imports");
33
+ var _ = require("../../..");
34
+ var _mainWindow = require("../main-window");
35
+ var _logger = require("../../../utilities/logger");
36
+ var _forgeRtm = require("@netless/forge-rtm");
37
+ var _FcrAnnotationControlImpl;
38
+ let _initProto;
39
+ 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)]; } }; }
40
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
41
+ 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); }
42
+ 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; }
43
+ 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; }
44
+ class FcrAnnotationControlImpl {
45
+ constructor(_scene, _api, _engine, _privilegeControl, _sharedCache) {
46
+ (0, _defineProperty2.default)(this, "logger", (_initProto(this), (0, _imports.createLogger)({
47
+ prefix: 'FcrAnnotationControlImpl'
48
+ })));
49
+ (0, _defineProperty2.default)(this, "_FCR_ANNOTATION_APP_ID", 'Annotation');
50
+ (0, _defineProperty2.default)(this, "_observable", new _imports.AgoraObservable());
51
+ (0, _defineProperty2.default)(this, "_connectState", _.FcrConnectionState.DISCONNECTED);
52
+ (0, _defineProperty2.default)(this, "_joined", false);
53
+ this._scene = _scene;
54
+ this._api = _api;
55
+ this._engine = _engine;
56
+ this._privilegeControl = _privilegeControl;
57
+ this._sharedCache = _sharedCache;
58
+ this._addLogObserver();
59
+ }
60
+ async open() {
61
+ var _this$_scene$getUser;
62
+ const {
63
+ size,
64
+ extra
65
+ } = this._getBoardConfigInfoWithScene();
66
+ const {
67
+ width,
68
+ height
69
+ } = size;
70
+ const {
71
+ boardAppId,
72
+ boardId,
73
+ boardToken,
74
+ region
75
+ } = extra;
76
+ const userId = this._scene.localUser.getLocalUserId();
77
+ const nickName = (_this$_scene$getUser = this._scene.getUser(userId)) === null || _this$_scene$getUser === void 0 ? void 0 : _this$_scene$getUser.userName;
78
+ // @ts-ignore
79
+ const rtmClient = this._engine._rtmClient._client;
80
+ const rtmProvider = new _forgeRtm.RTMProvider_2_2(rtmClient);
81
+ const wbRoom = new _forgeRoom.Room(boardId, rtmProvider);
82
+ wbRoom.applicationManager.registerApplication(_forgeWhiteboard.WhiteboardApplication);
83
+ try {
84
+ this._updateConnnectionState(_.FcrConnectionState.CONNECTING);
85
+ const retriesMax = 10;
86
+ await (0, _imports.retryAttempt)(async () => {
87
+ await wbRoom.joinRoom({
88
+ userId,
89
+ nickName,
90
+ roomToken: boardToken,
91
+ sdkConfig: {
92
+ // @ts-ignore
93
+ region,
94
+ appIdentifier: boardAppId,
95
+ enableIFramePlugin: false,
96
+ useMultiViews: true
97
+ }
98
+ });
99
+ this._boardRoom = wbRoom;
100
+ const whiteboard = await wbRoom.applicationManager.launchApplication(_forgeWhiteboard.WhiteboardApplication, {
101
+ width,
102
+ height,
103
+ defaultToolbarStyle: {
104
+ tool: 'laser'
105
+ },
106
+ maxScaleRatio: 1
107
+ }, this._FCR_ANNOTATION_APP_ID);
108
+ whiteboard.enableCameraByMouse = false;
109
+ whiteboard.enableCameraByTouch = false;
110
+ whiteboard.setViewModeToMain();
111
+ this._boardView = new _mainWindow.FcrBoardMainWindowImpl(whiteboard, this._scene, this._sharedCache, wbRoom);
112
+ this._boardView.setBackgroundColor('rgba(0, 0, 0, 0)');
113
+ // this._boardView.setBoardTransparent(true);
114
+ this._updateConnnectionState(_.FcrConnectionState.CONNECTED);
115
+ }, [], {
116
+ retriesMax
117
+ }).fail(async _ref => {
118
+ let {
119
+ error,
120
+ timeFn,
121
+ currentRetry
122
+ } = _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;
127
+ }).abort(() => {
128
+ this._updateConnnectionState(_.FcrConnectionState.DISCONNECTED);
129
+ }).exec();
130
+ } catch (e) {
131
+ this._updateConnnectionState(_.FcrConnectionState.DISCONNECTED);
132
+ }
133
+ return this._boardView;
134
+ }
135
+ 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());
140
+ this._boardRoom = undefined;
141
+ this._boardView = undefined;
142
+ }
143
+ getConnectionState() {
144
+ return this._connectState;
145
+ }
146
+ getMainWindow() {
147
+ return this._boardView;
148
+ }
149
+ addObserver(observer) {
150
+ this._observable.addObserver(observer);
151
+ }
152
+ removeObserver(observer) {
153
+ this._observable.removeObserver(observer);
154
+ }
155
+ _getBoardConfigInfoWithScene() {
156
+ const boardAppId = this._scene.getScenePropertiesByKeyPath('widgets.annotation.extra.boardAppId');
157
+ const boardId = this._scene.getScenePropertiesByKeyPath('widgets.annotation.extra.boardId');
158
+ const boardToken = this._scene.getScenePropertiesByKeyPath('widgets.annotation.extra.boardToken');
159
+ const boardRegion = this._scene.getScenePropertiesByKeyPath('widgets.annotation.extra.boardRegion');
160
+ const boardWidthVal = Number(this._scene.getScenePropertiesByKeyPath('widgets.annotation.size.width'));
161
+ const boardHeightVal = Number(this._scene.getScenePropertiesByKeyPath('widgets.annotation.size.height'));
162
+ const boardWidth = Number.isNaN(boardWidthVal) ? 16 / 9 * 1000 : boardWidthVal;
163
+ const boardHeight = Number.isNaN(boardHeightVal) ? 1000 : boardHeightVal;
164
+ return {
165
+ size: {
166
+ width: boardWidth,
167
+ height: boardHeight
168
+ },
169
+ extra: {
170
+ boardAppId,
171
+ boardId,
172
+ boardToken,
173
+ region: boardRegion
174
+ }
175
+ };
176
+ }
177
+ _updateConnnectionState(state) {
178
+ this._connectState = state;
179
+ this._observable.notifyObservers('onConnectionStateUpdated', state);
180
+ }
181
+ _addLogObserver() {
182
+ this.addObserver((0, _logger.generateLogObserver)(this.logger, ['onActive', 'onInactive', 'onBackgroundColorUpdated', 'onConnectionStateUpdated']));
183
+ }
184
+ }
185
+ exports.FcrAnnotationControlImpl = FcrAnnotationControlImpl;
186
+ _FcrAnnotationControlImpl = FcrAnnotationControlImpl;
187
+ [_initProto] = _applyDecs(_FcrAnnotationControlImpl, [[_imports.bound, 2, "open"], [[_imports.bound, _imports.trace], 2, "close"], [[_imports.bound, _imports.trace], 2, "getConnectionState"], [[_imports.bound, _imports.trace], 2, "getMainWindow"], [_imports.bound, 2, "_updateConnnectionState"]], []).e;
@@ -0,0 +1,32 @@
1
+ import { FcrBaseWhiteboardControl } from '../../whiteboard-control/types';
2
+ export interface FcrAnnotationControl extends FcrBaseWhiteboardControl {
3
+ }
4
+ export interface FcrAnnotationBoardConfig {
5
+ state: number;
6
+ position: {
7
+ xAxis: number;
8
+ yAxis: number;
9
+ };
10
+ size: {
11
+ width: number;
12
+ height: number;
13
+ };
14
+ extra: {
15
+ boardAppId: string;
16
+ boardId: string;
17
+ boardToken: string;
18
+ region: string;
19
+ };
20
+ }
21
+ export interface FcrAnnotationBoardSceneInfo {
22
+ size: {
23
+ width: number;
24
+ height: number;
25
+ };
26
+ extra: {
27
+ boardAppId: string;
28
+ boardId: string;
29
+ boardToken: string;
30
+ region: string;
31
+ };
32
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,8 +1,9 @@
1
- import { FcrBoardActiveInfo, FcrBoardMainWindow, FcrWhiteboardControl, FcrWhiteboardObserver } from '../whiteboard-control/types';
1
+ import { FcrBoardActiveInfo, FcrBoardMainWindow } from '../whiteboard-control/types';
2
2
  import { AgoraRteEngine, AgoraRteScene } from '../../imports';
3
3
  import { FcrCoreServiceApi } from '../../service/api';
4
4
  import { FcrConnectionState } from '../..';
5
5
  import { FcrSharedCache } from '../shared-cache';
6
+ import { FcrWhiteboardControl, FcrWhiteboardObserver } from './whiteboard-control/type';
6
7
  export declare class FcrWhiteboardControlImpl implements FcrWhiteboardControl {
7
8
  private _scene;
8
9
  private _api;
@@ -41,6 +41,7 @@ var _logger = require("../../utilities/logger");
41
41
  var _error = require("../../utilities/error");
42
42
  var _validateParams = _interopRequireDefault(require("../../utilities/validate-params"));
43
43
  var _schema = require("../../schema");
44
+ var _packageInfo = require("../../utilities/package-info");
44
45
  var _FcrWhiteboardControlImpl;
45
46
  let _initProto, _setBackgroundColorDecs, _ref;
46
47
  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)]; } }; }
@@ -65,6 +66,7 @@ class FcrWhiteboardControlImpl {
65
66
  this._roomCache = _sharedCache.getRoomCache(this._scene.sceneId);
66
67
  this._addLogObserver();
67
68
  _scene.addObserver(this._notifyObservers());
69
+ this.logger.info("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')));
68
70
  }
69
71
  async open() {
70
72
  var _this$_scene$getUser;
@@ -88,6 +90,22 @@ class FcrWhiteboardControlImpl {
88
90
  const rtmClient = this._engine._rtmClient._client;
89
91
  const rtmProvider = new _forgeRtm.RTMProvider_2_2(rtmClient);
90
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
+ });
91
109
  wbRoom.applicationManager.registerApplication(_forgeWhiteboard.WhiteboardApplication);
92
110
  try {
93
111
  this._updateConnnectionState(_2.FcrConnectionState.CONNECTING);
@@ -123,7 +141,7 @@ class FcrWhiteboardControlImpl {
123
141
  // wbRoom.applicationManager.on('terminal', () => {
124
142
  // this._updateConnnectionState(FcrConnectionState.DISCONNECTED);
125
143
  // });
126
- this._boardView = new _mainWindow.FcrBoardMainWindowImpl(whiteboard, this._scene, this._sharedCache);
144
+ this._boardView = new _mainWindow.FcrBoardMainWindowImpl(whiteboard, this._scene, this._sharedCache, wbRoom);
127
145
  this._updateConnnectionState(_2.FcrConnectionState.CONNECTED);
128
146
  }, [], {
129
147
  retriesMax
@@ -1,17 +1,19 @@
1
1
  import { FcrBoardToolType } from '../whiteboard-control/enums';
2
- import { Color, FcrBoardMainWindow, FcrBoardPageInfo, FcrBoardWindowObserver } from '../whiteboard-control/types';
2
+ import { Color, FcrBoardMainWindow, FcrBoardMainWindowObserver, FcrBoardPageInfo } from '../whiteboard-control/types';
3
3
  import { Whiteboard } from '@netless/forge-whiteboard';
4
4
  import { type AgoraRteScene } from '../../imports';
5
5
  import { FcrSharedCache } from '../shared-cache';
6
+ import { Room } from '@netless/forge-room';
6
7
  export declare class FcrBoardMainWindowImpl implements FcrBoardMainWindow {
7
8
  protected logger: import("agora-foundation/lib/logger").Logger;
8
9
  private _whiteboard;
9
10
  private _observable;
10
11
  private _boardView;
11
12
  private _currentPage;
13
+ private _background;
12
14
  private _roomCache;
13
15
  private _scene;
14
- constructor(whiteboard: Whiteboard, scene: AgoraRteScene, sharedCache: FcrSharedCache);
16
+ constructor(whiteboard: Whiteboard, scene: AgoraRteScene, sharedCache: FcrSharedCache, boardRoom: Room);
15
17
  addPage(): Promise<void>;
16
18
  removePage(): Promise<void>;
17
19
  undo(): Promise<void>;
@@ -30,8 +32,9 @@ export declare class FcrBoardMainWindowImpl implements FcrBoardMainWindow {
30
32
  insertImage(resourceUrl: string, x: number, y: number, width: number, height: number): Promise<void>;
31
33
  getContentView(): HTMLElement;
32
34
  setContainerSizeRatio(ratio: number): Promise<void>;
33
- addObserver(observer: FcrBoardWindowObserver): void;
34
- removeObserver(observer: FcrBoardWindowObserver): void;
35
+ setBoardTransparent(isTransparent: boolean): Promise<void>;
36
+ addObserver(observer: FcrBoardMainWindowObserver): void;
37
+ removeObserver(observer: FcrBoardMainWindowObserver): void;
35
38
  private _addWindowManagerEventListeners;
36
39
  private _isBoardWritePermission;
37
40
  private _addLogObserver;
@@ -47,12 +47,13 @@ function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.descrip
47
47
  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
48
  _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.colorSchema)], _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)], "logger");
49
49
  class FcrBoardMainWindowImpl {
50
- constructor(whiteboard, scene, sharedCache) {
50
+ constructor(whiteboard, scene, sharedCache, boardRoom) {
51
51
  (0, _defineProperty2.default)(this, _ref, (_initProto(this), (0, _logger.createLogger)({
52
52
  prefix: 'FcrBoardMainWindowImpl'
53
53
  })));
54
54
  (0, _defineProperty2.default)(this, "_observable", new _observable.AgoraObservable());
55
55
  (0, _defineProperty2.default)(this, "_currentPage", 0);
56
+ (0, _defineProperty2.default)(this, "_background", 'rgba(0, 0, 0, 0)');
56
57
  this._roomCache = sharedCache.getRoomCache(scene.sceneId);
57
58
  this._addLogObserver();
58
59
  this._boardView = document.createElement('div');
@@ -65,7 +66,21 @@ class FcrBoardMainWindowImpl {
65
66
  this._whiteboard = whiteboard;
66
67
  this._scene = scene;
67
68
  this._addWindowManagerEventListeners();
68
- const hasOperationPrivilege = (0, _helper.getLocalUserPermissionInfo)(scene, _type.FcrPermissionAction.BoardWrite).enable;
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
+ });
83
+ const hasOperationPrivilege = (0, _helper.getLocalUserPermissionInfo)(scene, _type.FcrPermissionAction.BoardWrite).enable || (0, _helper.getLocalUserPermissionInfo)(scene, _type.FcrPermissionAction.AnnotationWrite).enable;
69
84
  whiteboard.permissions[hasOperationPrivilege ? 'addPermission' : 'removePermission'](_forgeWhiteboard.WhiteboardPermissionFlag.all);
70
85
  (0, _helper.addLocalUserPermissionObserver)(scene, {
71
86
  onLocalUserPermissionInfoAdded: (roomId, event) => {
@@ -124,6 +139,7 @@ class FcrBoardMainWindowImpl {
124
139
  }
125
140
  }
126
141
  async setBackgroundColor(color) {
142
+ this._background = color;
127
143
  this._whiteboard.setCanvasBackgroundColor(color);
128
144
  }
129
145
  getPageInfo() {
@@ -183,6 +199,7 @@ class FcrBoardMainWindowImpl {
183
199
  return this._boardView;
184
200
  }
185
201
  async setContainerSizeRatio(ratio) {}
202
+ async setBoardTransparent(isTransparent) {}
186
203
  addObserver(observer) {
187
204
  this._observable.addObserver(observer);
188
205
  }
@@ -225,4 +242,4 @@ class FcrBoardMainWindowImpl {
225
242
  }
226
243
  exports.FcrBoardMainWindowImpl = FcrBoardMainWindowImpl;
227
244
  _FcrBoardMainWindowImpl = FcrBoardMainWindowImpl;
228
- [_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"]], []).e;
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;
@@ -0,0 +1,38 @@
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
+ }