fcr-core 3.10.0 → 3.10.1

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 (40) hide show
  1. package/lib/engine/index.js +5 -3
  2. package/lib/imports.d.ts +1 -1
  3. package/lib/imports.js +6 -0
  4. package/lib/index.d.ts +4 -0
  5. package/lib/index.js +15 -1
  6. package/lib/peer-session/index.js +23 -4
  7. package/lib/remote-control/index.js +7 -0
  8. package/lib/room-control/index.js +6 -1
  9. package/lib/room-control/room-control-factory.js +5 -1
  10. package/lib/room-control/type.d.ts +11 -6
  11. package/lib/room-control/type.js +6 -6
  12. package/lib/room-control/user-control/index.js +2 -2
  13. package/lib/room-control/widget-control/index.d.ts +1 -0
  14. package/lib/room-control/widget-control/index.js +115 -0
  15. package/lib/room-control/widget-control/type.d.ts +33 -0
  16. package/lib/room-control/widget-control/type.js +5 -0
  17. package/lib/room-router/index.js +7 -1
  18. package/lib/service/api.d.ts +5 -0
  19. package/lib/service/api.js +16 -2
  20. package/lib/type.d.ts +1 -1
  21. package/lib/utilities/convertRoomType.d.ts +2 -0
  22. package/lib/utilities/convertRoomType.js +26 -0
  23. package/lib/utilities/error-helpers.d.ts +2 -1
  24. package/lib/utilities/error-helpers.js +1 -0
  25. package/lib-es/engine/index.js +5 -3
  26. package/lib-es/imports.js +1 -1
  27. package/lib-es/index.js +3 -1
  28. package/lib-es/peer-session/index.js +23 -4
  29. package/lib-es/remote-control/index.js +7 -0
  30. package/lib-es/room-control/index.js +6 -1
  31. package/lib-es/room-control/room-control-factory.js +5 -1
  32. package/lib-es/room-control/type.js +6 -6
  33. package/lib-es/room-control/user-control/index.js +2 -2
  34. package/lib-es/room-control/widget-control/index.js +109 -0
  35. package/lib-es/room-control/widget-control/type.js +1 -0
  36. package/lib-es/room-router/index.js +7 -1
  37. package/lib-es/service/api.js +16 -2
  38. package/lib-es/utilities/convertRoomType.js +19 -0
  39. package/lib-es/utilities/error-helpers.js +1 -0
  40. package/package.json +4 -4
@@ -60,6 +60,7 @@ var _parameters = require("../utilities/parameters");
60
60
  var _validateParams = _interopRequireDefault(require("../utilities/validate-params"));
61
61
  var _infinityRoomControl = require("../room-control/infinity-room-control");
62
62
  var _remoteControl = require("../remote-control");
63
+ var _convertRoomType = require("../utilities/convertRoomType");
63
64
  let _initProto, _renewUserTokenDecs, _createMainRoomControlDecs, _createInfinityRoomControlDecs, _createWaitingRoomControlDecs, _createRoomRouterDecs, _createRoomControlAndJoinDecs, _sendPeerMessageDecs, _setParametersDecs;
64
65
  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
66
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
@@ -295,7 +296,8 @@ class FcrCoreEngineImpl {
295
296
  data,
296
297
  ts
297
298
  } = res;
298
- switch (data.room.roomProperties.roomType) {
299
+ const fcrRoomType = (0, _convertRoomType.convertServerRoomTypeToFcrRoomType)(data.room.roomProperties.roomType);
300
+ switch (fcrRoomType) {
299
301
  case _type3.FcrRoomType.Waitingroom:
300
302
  roomControl = this.createWaitingRoomControl(data.room.roomInfo.roomUuid);
301
303
  break;
@@ -306,13 +308,13 @@ class FcrCoreEngineImpl {
306
308
  roomControl = this.createMainRoomControl(roomId);
307
309
  break;
308
310
  default:
309
- throw new Error(`Unknown room type: ${data.room.roomProperties.roomType}`);
311
+ throw new Error(`Unknown room type: ${fcrRoomType}`);
310
312
  }
311
313
  await roomControl.join({
312
314
  ...options,
313
315
  snapshot: data,
314
316
  timestamp: ts,
315
- createStreamConfigs: data.room.roomProperties.roomType === _type3.FcrRoomType.Waitingroom ? [] : options.createStreamConfigs
317
+ createStreamConfigs: fcrRoomType === _type3.FcrRoomType.Waitingroom ? [] : options.createStreamConfigs
316
318
  });
317
319
  }, [], {
318
320
  retriesMax: 10
package/lib/imports.d.ts CHANGED
@@ -41,7 +41,7 @@ export type { AgoraRteAudioRawDataConfig, AgoraRteBeautyOptions, AgoraRteCameraP
41
41
  export type { AgoraRteMonitor } from 'agora-rte-sdk/lib/core/monitor';
42
42
  export type { AgoraRteMediaControl } from 'agora-rte-sdk/lib/core/media/type';
43
43
  export type { AgoraRteUpdateStreamPrivilege, AgoraRteMediaStreamInfo, } from 'agora-rte-sdk/lib/core/scene/type';
44
- export { AgoraRteConnectionState, AgoraRteEngine, convertStreamTypeToPublishState, AgoraRteLatencyLevel, } from 'agora-rte-sdk';
44
+ export { AgoraRteConnectionState, AgoraRteEngine, convertStreamTypeToPublishState, AgoraRteLatencyLevel, AgoraRteVideoOutputOrientationMode, } from 'agora-rte-sdk';
45
45
  export { AgoraRteRoomConnectorType, AgoraRteStreamPrivilegeOperation, AgoraRteStreamPrivilegeVideoSourceType, AgoraRteStreamPrivilegeAudioSourceType, AgoraRteMediaStreamType, } from 'agora-rte-sdk/lib/core/scene/type';
46
46
  export { AgoraRtcRegion, AgoraRtcVideoSourceType, AgoraRtcAudioSourceType, AgoraRtcMediaSourceState, AgoraRtcRenderMode, AgoraRtcVideoStreamType, AgoraRtcCapability, AgoraRtcAiDenoiseLevel, AgoraRtcAudioOutputRouting, AgoraRtcLatencyLevelType, AgoraRtcEncryptionMode, AgoraRtcDegradationPreference, } from 'agora-rte-sdk/lib/core/rtc/type';
47
47
  export { AgoraRteStreamLayer } from 'agora-rte-sdk/lib/type';
package/lib/imports.js CHANGED
@@ -204,6 +204,12 @@ Object.defineProperty(exports, "AgoraRteVideoOrientation", {
204
204
  return _type5.AgoraRteVideoOrientation;
205
205
  }
206
206
  });
207
+ Object.defineProperty(exports, "AgoraRteVideoOutputOrientationMode", {
208
+ enumerable: true,
209
+ get: function () {
210
+ return _agoraRteSdk.AgoraRteVideoOutputOrientationMode;
211
+ }
212
+ });
207
213
  Object.defineProperty(exports, "AgoraRteVideoSourceType", {
208
214
  enumerable: true,
209
215
  get: function () {
package/lib/index.d.ts CHANGED
@@ -3,3 +3,7 @@ export { FcrStreamLatencyLevel, FcrPermissionAction, FcrPrivilegeUserRole, FcrUs
3
3
  export { FcrCoreEngineImpl as FcrCoreEngine } from './engine';
4
4
  export { FcrCoreEngineConfig } from './struct';
5
5
  export { FcrError } from './type';
6
+ export type { AgoraRtcDimensions } from './schema';
7
+ export type { AgoraRteCameraPosition as FcrCameraPosition } from './imports';
8
+ export { FcrDegradationPreference } from './schema';
9
+ export { AgoraRteVideoOutputOrientationMode as FcrVideoOutputOrientationMode } from './imports';
package/lib/index.js CHANGED
@@ -51,6 +51,12 @@ Object.defineProperty(exports, "FcrCoreEngineConfig", {
51
51
  return _struct.FcrCoreEngineConfig;
52
52
  }
53
53
  });
54
+ Object.defineProperty(exports, "FcrDegradationPreference", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _schema.FcrDegradationPreference;
58
+ }
59
+ });
54
60
  Object.defineProperty(exports, "FcrDualVideoStreamConfig", {
55
61
  enumerable: true,
56
62
  get: function () {
@@ -147,6 +153,12 @@ Object.defineProperty(exports, "FcrVideoEncoderConfig", {
147
153
  return _type.FcrVideoEncoderConfig;
148
154
  }
149
155
  });
156
+ Object.defineProperty(exports, "FcrVideoOutputOrientationMode", {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _imports.AgoraRteVideoOutputOrientationMode;
160
+ }
161
+ });
150
162
  Object.defineProperty(exports, "FcrVideoRenderMode", {
151
163
  enumerable: true,
152
164
  get: function () {
@@ -173,4 +185,6 @@ Object.defineProperty(exports, "registerPlugin", {
173
185
  });
174
186
  var _type = require("./type");
175
187
  var _engine = require("./engine");
176
- var _struct = require("./struct");
188
+ var _struct = require("./struct");
189
+ var _schema = require("./schema");
190
+ var _imports = require("./imports");
@@ -326,6 +326,8 @@ class FcrPeerSessionControlImpl {
326
326
  data,
327
327
  cmd
328
328
  } = payload;
329
+ const logContext = `cmd=${cmd}, sessionKey=${data.sessionKey}, sessionId=${data.sessionUuid}, ` + `action=${String(data.action)}, senderId=${senderId}, keepAlive=${!!data.keepAlive}`;
330
+ this.logger.info(`[PeerSession] received peer message: ${logContext}, payload=${JSON.stringify(data.payload ?? {})}`);
329
331
  if (cmd === '1001') {
330
332
  const session = {
331
333
  sessionId: data.sessionUuid,
@@ -358,7 +360,10 @@ class FcrPeerSessionControlImpl {
358
360
  ...params,
359
361
  action: 1
360
362
  });
363
+ this.logger.info(`[PeerSession] forward peer session accepted to observers: ${logContext}`);
361
364
  this._observable.notifyObservers('onPeerSessionAccepted', sessionResponse);
365
+ } else {
366
+ this.logger.info(`[PeerSession] ignore peer session accepted without local schedule: ${logContext}`);
362
367
  }
363
368
  if (this._receivedMap.has(session.sessionId)) {
364
369
  this._receivedMap.set(session.sessionId, {
@@ -371,8 +376,10 @@ class FcrPeerSessionControlImpl {
371
376
  return;
372
377
  } else {
373
378
  if (!this._receivedMap.has(session.sessionId)) {
374
- this.logger.info(`[PeerSession] received peer session request ${JSON.stringify(session)}`);
379
+ this.logger.info(`[PeerSession] forward peer session request to observers: ${logContext}`);
375
380
  this._observable.notifyObservers('onPeerSessionReceived', session);
381
+ } else {
382
+ this.logger.info(`[PeerSession] peer session request already cached, update cache only: ${logContext}`);
376
383
  }
377
384
  this._receivedMap.set(session.sessionId, {
378
385
  ...session,
@@ -381,6 +388,8 @@ class FcrPeerSessionControlImpl {
381
388
  action: 0
382
389
  });
383
390
  }
391
+ } else {
392
+ this.logger.info(`[PeerSession] ignore expired peer session message: ${logContext}, ` + `timestamp=${session.timestamp}, duration=${session.duration}`);
384
393
  }
385
394
  } else if (cmd === '1002') {
386
395
  if (data.action === 1) {
@@ -396,9 +405,11 @@ class FcrPeerSessionControlImpl {
396
405
  cause: data.payload?.cause ?? {},
397
406
  keepAlive: !!data.keepAlive
398
407
  };
399
- this.logger.info(`[PeerSession] received peer session accepted ${JSON.stringify(sessionResponse)}`);
400
408
  this._scheduleMap.delete(data.sessionUuid);
409
+ this.logger.info(`[PeerSession] forward peer session accepted to observers: ${logContext}`);
401
410
  this._observable.notifyObservers('onPeerSessionAccepted', sessionResponse);
411
+ } else {
412
+ this.logger.info(`[PeerSession] ignore peer session accepted without local schedule: ${logContext}`);
402
413
  }
403
414
  } else if (data.action === 2) {
404
415
  if (this._scheduleMap.has(data.sessionUuid)) {
@@ -413,11 +424,13 @@ class FcrPeerSessionControlImpl {
413
424
  cause: data.payload?.cause ?? {},
414
425
  keepAlive: !!data.keepAlive
415
426
  };
416
- this.logger.info(`[PeerSession] received peer session rejected ${JSON.stringify(sessionResponse)}`);
417
427
  if (this._scheduleMap.has(data.sessionUuid)) {
418
428
  this._scheduleMap.delete(data.sessionUuid);
429
+ this.logger.info(`[PeerSession] forward peer session rejected to observers: ${logContext}`);
419
430
  this._observable.notifyObservers('onPeerSessionRejected', sessionResponse);
420
431
  }
432
+ } else {
433
+ this.logger.info(`[PeerSession] ignore peer session rejected without local schedule: ${logContext}`);
421
434
  }
422
435
  } else if (data.action === 3) {
423
436
  const scheduleSession = this._scheduleMap.get(data.sessionUuid);
@@ -429,7 +442,6 @@ class FcrPeerSessionControlImpl {
429
442
  fromUserId: senderId,
430
443
  cause: data.payload?.cause ?? {}
431
444
  };
432
- this.logger.info(`[PeerSession] received peer session ended ${JSON.stringify(params)}`);
433
445
  if (scheduleSession) {
434
446
  this._scheduleMap.delete(data.sessionUuid);
435
447
  }
@@ -437,8 +449,15 @@ class FcrPeerSessionControlImpl {
437
449
  this._receivedMap.delete(data.sessionUuid);
438
450
  }
439
451
  this._observable.notifyObservers('onPeerSessionEnded', params.sessionId, params.fromUserId, params.cause);
452
+ this.logger.info(`[PeerSession] forward peer session ended to observers: ${logContext}`);
453
+ } else {
454
+ this.logger.info(`[PeerSession] ignore peer session ended without cached session: ${logContext}`);
440
455
  }
456
+ } else {
457
+ this.logger.info(`[PeerSession] ignore peer session response with unknown action: ${logContext}`);
441
458
  }
459
+ } else {
460
+ this.logger.info(`[PeerSession] ignore unsupported peer session cmd: ${logContext}`);
442
461
  }
443
462
  }
444
463
 
@@ -78,13 +78,17 @@ class FcrRemoteControlImpl {
78
78
  data,
79
79
  cmd
80
80
  } = payload;
81
+ const logContext = `cmd=${cmd}, sessionKey=${data.sessionKey}, sessionId=${data.sessionUuid}, ` + `action=${String(data.action)}, senderId=${senderId}, keepAlive=${!!data.keepAlive}`;
81
82
  if (data.sessionKey !== this._remoteControlSessionKey) {
83
+ this.logger.info(`[RemoteControl] ignore peer message because sessionKey does not match remote-control: ${logContext}`);
82
84
  return;
83
85
  }
84
86
  if (cmd === '1001') {
85
87
  if (!data.keepAlive) {
88
+ this.logger.info(`[RemoteControl] ignore remote-control update without keepAlive: ${logContext}`);
86
89
  return;
87
90
  }
91
+ this.logger.info(`[RemoteControl] forward update session for handling: ${logContext}`);
88
92
  return await this._handleUpdateRemoteControlSession({
89
93
  senderId: senderId,
90
94
  sessionKey: data.sessionKey,
@@ -97,6 +101,7 @@ class FcrRemoteControlImpl {
97
101
  timestamp: message.timestamp
98
102
  });
99
103
  } else if (cmd === '1002') {
104
+ this.logger.info(`[RemoteControl] forward delete session for handling: ${logContext}`);
100
105
  return await this._handleDeleteRemoteControlSession({
101
106
  senderId: senderId,
102
107
  sessionKey: data.sessionKey,
@@ -107,6 +112,8 @@ class FcrRemoteControlImpl {
107
112
  action: data.action,
108
113
  timestamp: message.timestamp
109
114
  });
115
+ } else {
116
+ this.logger.info(`[RemoteControl] ignore unsupported cmd: ${logContext}`);
110
117
  }
111
118
  }
112
119
  async _handleUpdateRemoteControlSession(data) {
@@ -43,6 +43,7 @@ var _2 = require("..");
43
43
  var _errorHelpers = require("../utilities/error-helpers");
44
44
  var _helpers = require("./helpers");
45
45
  var _sttControl = require("./stt-control");
46
+ var _widgetControl = require("./widget-control");
46
47
  var _applicationControl = require("./application-control");
47
48
  let _initProto, _joinDecs, _updateRoomPropertiesDecs, _updateIncrementRoomPropertiesDecs, _deleteRoomPropertiesDecs, _startCloudRecordingDecs, _startLiveStreamingDecs, _updateLiveStreamingLayoutDecs, _sendRoomMessageDecs; // Core SDK imports
48
49
  // Service and API imports
@@ -117,6 +118,7 @@ class FcrBaseRoomControlImpl {
117
118
  this.sharingControl = new _sharingControl.FcrSharingControlImpl(this._scene, this._api, this._engine, this._config, this._privilegeControl, this._streamControl, this._sharedCache, this._userControl);
118
119
  }
119
120
  this._sttControl = new _sttControl.FcrSttControlImpl(this._scene, this._api, this._sharedCache);
121
+ this._widgetControl = new _widgetControl.FcrWidgetControlImpl(this._scene, this._api, this._sharedCache);
120
122
  this._observable.notifyObservers('onJoinRoomSuccess', sceneId);
121
123
  },
122
124
  // onJoinSceneFailure: (sceneId, error) => {
@@ -238,6 +240,10 @@ class FcrBaseRoomControlImpl {
238
240
  (0, _helpers.validateControllerInitialized)(this._sttControl, _errorHelpers.ControllerType.STT);
239
241
  return this._sttControl;
240
242
  }
243
+ getWidgetControl() {
244
+ (0, _helpers.validateControllerInitialized)(this._widgetControl, _errorHelpers.ControllerType.WIDGET);
245
+ return this._widgetControl;
246
+ }
241
247
  getApplicationControl() {
242
248
  (0, _helpers.validateControllerInitialized)(this._applicationControl, _errorHelpers.ControllerType.APPLICATION);
243
249
  return this._applicationControl;
@@ -362,7 +368,6 @@ class FcrBaseRoomControlImpl {
362
368
  (0, _helpers.validateRoomJoined)(this._joinRoomSuccess, 'get schedule info');
363
369
  const schedule = this._scene.getScenePropertiesByKeyPath('schedule');
364
370
  return {
365
- ...schedule,
366
371
  duration: schedule.duration ?? 0,
367
372
  startTime: Math.floor((schedule.startTime ?? 0) / 1000)
368
373
  };
@@ -7,6 +7,7 @@ exports.RoomControlFactory = void 0;
7
7
  require("core-js/modules/esnext.iterator.constructor.js");
8
8
  require("core-js/modules/esnext.iterator.map.js");
9
9
  var _imports = require("../imports");
10
+ var _convertRoomType = require("../utilities/convertRoomType");
10
11
  var _error = require("../utilities/error");
11
12
  var _infinityRoomControl = require("./infinity-room-control");
12
13
  var _room = require("./interpreter-control/room");
@@ -53,7 +54,10 @@ class RoomControlFactory {
53
54
  roomResponse,
54
55
  monitorControl
55
56
  } = params;
56
- const roomType = roomResponse.room.roomProperties.roomType;
57
+ const roomType = (0, _convertRoomType.convertServerRoomTypeToFcrRoomType)(roomResponse.room.roomProperties.roomType);
58
+ if (roomType === null) {
59
+ throw (0, _error.generateFcrCoreClientError)(_imports.ErrorModuleCode.FCR_ROOM, _imports.DetailErrorCode.UNDEFINED_ERROR, `Unsupported room types: ${roomResponse.room.roomProperties.roomType}`);
60
+ }
57
61
  const RoomControlImpl = ROOM_CONTROL_IMPLEMENTATIONS[roomType];
58
62
  if (!RoomControlImpl) {
59
63
  throw (0, _error.generateFcrCoreClientError)(_imports.ErrorModuleCode.FCR_ROOM, _imports.DetailErrorCode.UNDEFINED_ERROR, `Unsupported room types: ${roomType}`);
@@ -13,6 +13,7 @@ import { FcrSharingControl } from './sharing-control/type';
13
13
  import { FcrSttControl } from './stt-control/type';
14
14
  import { FcrRoomAnnouncement } from './infinity-room-control/type';
15
15
  import { FcrApplicationControl } from './application-control/type';
16
+ import { FcrWidgetControl } from './widget-control/type';
16
17
  export interface FcrBaseRoomControl {
17
18
  /**
18
19
  * Gets the caption control.
@@ -26,6 +27,10 @@ export interface FcrBaseRoomControl {
26
27
  * Gets the stream control.
27
28
  */
28
29
  getStreamControl(): FcrStreamControl;
30
+ /**
31
+ * Gets the widget control.
32
+ */
33
+ getWidgetControl(): FcrWidgetControl;
29
34
  /**
30
35
  * Gets the room session control.
31
36
  */
@@ -304,12 +309,12 @@ export type FcrJoinBeforeHostWaitingRoomObserver = FcrRoomObserver & {};
304
309
  export type FcrMainRoomObserver = FcrRoomObserver & {};
305
310
  export type FcrLocalUserWaitingRoomMovedEvent = FcrRoomPropertiesUpdatedEvent;
306
311
  export declare enum FcrRoomType {
307
- Mainroom = 11,
308
- Waitingroom = 102,
309
- Subroom = 101,
310
- Interpreterroom = 103,
311
- JoinBeforeHostWaitingRoom = 104,
312
- Infinityroom = 12
312
+ Mainroom = 0,
313
+ Subroom = 1,
314
+ Waitingroom = 2,
315
+ Interpreterroom = 3,
316
+ JoinBeforeHostWaitingRoom = 4,
317
+ Infinityroom = 5
313
318
  }
314
319
  export declare enum FcrLiveStreamingStateUpdatedReason {
315
320
  USERSTOPPED = 1,
@@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.FcrWidgetUuid = exports.FcrWidgetCauseCmd = exports.FcrRoomType = exports.FcrLiveStreamingStateUpdatedReason = exports.FcrLineType = void 0;
7
7
  let FcrRoomType = exports.FcrRoomType = /*#__PURE__*/function (FcrRoomType) {
8
- FcrRoomType[FcrRoomType["Mainroom"] = 11] = "Mainroom";
9
- FcrRoomType[FcrRoomType["Waitingroom"] = 102] = "Waitingroom";
10
- FcrRoomType[FcrRoomType["Subroom"] = 101] = "Subroom";
11
- FcrRoomType[FcrRoomType["Interpreterroom"] = 103] = "Interpreterroom";
12
- FcrRoomType[FcrRoomType["JoinBeforeHostWaitingRoom"] = 104] = "JoinBeforeHostWaitingRoom";
13
- FcrRoomType[FcrRoomType["Infinityroom"] = 12] = "Infinityroom";
8
+ FcrRoomType[FcrRoomType["Mainroom"] = 0] = "Mainroom";
9
+ FcrRoomType[FcrRoomType["Subroom"] = 1] = "Subroom";
10
+ FcrRoomType[FcrRoomType["Waitingroom"] = 2] = "Waitingroom";
11
+ FcrRoomType[FcrRoomType["Interpreterroom"] = 3] = "Interpreterroom";
12
+ FcrRoomType[FcrRoomType["JoinBeforeHostWaitingRoom"] = 4] = "JoinBeforeHostWaitingRoom";
13
+ FcrRoomType[FcrRoomType["Infinityroom"] = 5] = "Infinityroom";
14
14
  return FcrRoomType;
15
15
  }({});
16
16
  let FcrLiveStreamingStateUpdatedReason = exports.FcrLiveStreamingStateUpdatedReason = /*#__PURE__*/function (FcrLiveStreamingStateUpdatedReason) {
@@ -71,8 +71,8 @@ class FcrUserControlImpl {
71
71
  });
72
72
  const fcrUserEvents = events.map(e => {
73
73
  return {
74
- userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache),
75
- operatorUser: e.operatorUser && (0, _user.convertRteUserToFcrUser)(e.operatorUser, this._roomCache)
74
+ userInfo: e.userInfo && (0, _user.convertRteUserToFcrUser)(e.userInfo, this._roomCache)
75
+ // operatorUser: e.operatorUser && convertRteUserToFcrUser(e.operatorUser, this._roomCache),
76
76
  };
77
77
  });
78
78
  fcrUserEvents.forEach(event => {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.array.push.js");
4
+ require("core-js/modules/esnext.function.metadata.js");
5
+ require("core-js/modules/esnext.map.delete-all.js");
6
+ require("core-js/modules/esnext.map.emplace.js");
7
+ require("core-js/modules/esnext.map.every.js");
8
+ require("core-js/modules/esnext.map.filter.js");
9
+ require("core-js/modules/esnext.map.find.js");
10
+ require("core-js/modules/esnext.map.find-key.js");
11
+ require("core-js/modules/esnext.map.includes.js");
12
+ require("core-js/modules/esnext.map.key-of.js");
13
+ require("core-js/modules/esnext.map.map-keys.js");
14
+ require("core-js/modules/esnext.map.map-values.js");
15
+ require("core-js/modules/esnext.map.merge.js");
16
+ require("core-js/modules/esnext.map.reduce.js");
17
+ require("core-js/modules/esnext.map.some.js");
18
+ require("core-js/modules/esnext.map.update.js");
19
+ require("core-js/modules/esnext.symbol.metadata.js");
20
+ Object.defineProperty(exports, "__esModule", {
21
+ value: true
22
+ });
23
+ exports.FcrWidgetControlImpl = void 0;
24
+ var _imports = require("../../imports");
25
+ var _type = require("../../type");
26
+ var _error = require("../../utilities/error");
27
+ var _logger = require("../../utilities/logger");
28
+ let _initProto, _getActivityDecs, _activeDecs, _inactiveDecs;
29
+ 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)]; } }; }
30
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
31
+ 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); }
32
+ 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; }
33
+ 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; }
34
+ /** scene 属性更新中表示 widget 状态变更的 cause.cmd(与服务端约定一致) */
35
+ const WIDGET_SCENE_PROPERTIES_CMD = 13;
36
+ var WidgetState = /*#__PURE__*/function (WidgetState) {
37
+ WidgetState[WidgetState["INACTIVE"] = 0] = "INACTIVE";
38
+ WidgetState[WidgetState["ACTIVE"] = 1] = "ACTIVE";
39
+ return WidgetState;
40
+ }(WidgetState || {});
41
+ /**
42
+ * @internal
43
+ */
44
+ class FcrWidgetControlImpl {
45
+ static {
46
+ [_initProto] = _applyDecs(this, [[_getActivityDecs, 2, "getActivity"], [_activeDecs, 2, "active"], [_inactiveDecs, 2, "inactive"], [_imports.trace, 2, "release"]], []).e;
47
+ }
48
+ //@internal
49
+ [(_getActivityDecs = (0, _imports.trace)(['widgetId']), _activeDecs = (0, _imports.trace)(['widgetId']), _inactiveDecs = (0, _imports.trace)(['widgetId']), "logger")] = (_initProto(this), (0, _logger.createLogger)({
50
+ prefix: 'FcrWidgetControlImpl'
51
+ }));
52
+
53
+ //@internal
54
+ _observable = new _imports.AgoraObservable();
55
+
56
+ //@internal
57
+ _sceneObserver = {
58
+ onScenePropertiesUpdated: (sceneId, event) => {
59
+ if (event.cause?.cmd !== WIDGET_SCENE_PROPERTIES_CMD) {
60
+ return;
61
+ }
62
+ const changedWidgets = event.changedProperties?.flexWidgets;
63
+ if (!changedWidgets || typeof changedWidgets !== 'object') {
64
+ return;
65
+ }
66
+ for (const widgetId of Object.keys(changedWidgets)) {
67
+ const state = changedWidgets[widgetId]?.state;
68
+ if (state === WidgetState.ACTIVE) {
69
+ this._observable.notifyObservers('onWidgetActive', sceneId, widgetId);
70
+ } else if (state === WidgetState.INACTIVE) {
71
+ this._observable.notifyObservers('onWidgetInactive', sceneId, widgetId);
72
+ }
73
+ }
74
+ }
75
+ };
76
+ constructor(_scene, _api, _sharedCache) {
77
+ this._scene = _scene;
78
+ this._api = _api;
79
+ this._scene.addObserver(this._sceneObserver);
80
+ this._addLogObserver();
81
+ }
82
+ getActivity(widgetId) {
83
+ const state = this._scene.getScenePropertiesByKeyPath(`flexWidgets.${widgetId}.state`);
84
+ return state === WidgetState.ACTIVE;
85
+ }
86
+ active(widgetId) {
87
+ return (0, _error.handleRequestError)(() => this._api.updateWidgetState({
88
+ roomUuid: this._scene.sceneId,
89
+ widgetId,
90
+ state: 1
91
+ }), _imports.ErrorModuleCode.FCR_ROOM, 'activate widget failed');
92
+ }
93
+ inactive(widgetId) {
94
+ return (0, _error.handleRequestError)(() => this._api.updateWidgetState({
95
+ roomUuid: this._scene.sceneId,
96
+ widgetId,
97
+ state: 0
98
+ }), _imports.ErrorModuleCode.FCR_ROOM, 'deactivate widget failed');
99
+ }
100
+ addObserver(observer) {
101
+ this._observable.addObserver(observer);
102
+ }
103
+ removeObserver(observer) {
104
+ this._observable.removeObserver(observer);
105
+ }
106
+ release() {
107
+ this._scene.removeObserver(this._sceneObserver);
108
+ this._observable.removeAllObservers();
109
+ return _type.FcrReturnCode.SUCCESS;
110
+ }
111
+ _addLogObserver() {
112
+ this.addObserver((0, _logger.generateLogObserver)(this.logger, [['onWidgetActive', ['roomId', 'widgetId']], ['onWidgetInactive', ['roomId', 'widgetId']]]));
113
+ }
114
+ }
115
+ exports.FcrWidgetControlImpl = FcrWidgetControlImpl;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 房间内 widget 激活状态控制与事件订阅。
3
+ */
4
+ export interface FcrWidgetControl {
5
+ /**
6
+ * 获取指定 widget 是否处于激活状态(scene 中 `widgets.{widgetId}.state === 1`)。
7
+ */
8
+ getActivity(widgetId: string): boolean;
9
+ /**
10
+ * 激活指定 widget。
11
+ */
12
+ active(widgetId: string): Promise<void>;
13
+ /**
14
+ * 停用指定 widget。
15
+ */
16
+ inactive(widgetId: string): Promise<void>;
17
+ addObserver(observer: FcrWidgetObserver): void;
18
+ removeObserver(observer: FcrWidgetObserver): void;
19
+ /**
20
+ * 移除场景监听与观察者。
21
+ */
22
+ release(): number;
23
+ }
24
+ export interface FcrWidgetObserver {
25
+ /**
26
+ * widget 进入激活状态(scene 属性更新且 cmd === 13,state === 1)。
27
+ */
28
+ onWidgetActive?: (roomId: string, widgetId: string) => void;
29
+ /**
30
+ * widget 进入非激活状态(scene 属性更新且 cmd === 13,state === 0)。
31
+ */
32
+ onWidgetInactive?: (roomId: string, widgetId: string) => void;
33
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -33,6 +33,7 @@ var _retryHelpers = require("../utilities/retry-helpers");
33
33
  var _logger = require("../utilities/logger");
34
34
  var _validateParams = _interopRequireDefault(require("../utilities/validate-params"));
35
35
  var _type3 = require("./type");
36
+ var _convertRoomType = require("../utilities/convertRoomType");
36
37
  let _initProto, _initDecs, _joinRoomDecs;
37
38
  function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; }
38
39
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
@@ -212,8 +213,13 @@ class FcrRoomRouterImpl {
212
213
  const {
213
214
  data
214
215
  } = roomResponse;
216
+ const fcrRoomType = (0, _convertRoomType.convertServerRoomTypeToFcrRoomType)(data.room.roomProperties.roomType);
217
+ if (fcrRoomType === null) {
218
+ const fcrError = (0, _error.generateFcrCoreClientError)(_imports.ErrorModuleCode.FCR_ROOM, _imports.DetailErrorCode.UNDEFINED_ERROR, `update room state failed: Unknown room type: ${data.room.roomProperties.roomType}`);
219
+ throw fcrError;
220
+ }
215
221
  this._nextRoomRoute = {
216
- roomType: data.room.roomProperties.roomType,
222
+ roomType: fcrRoomType,
217
223
  roomId: data.room.roomInfo.roomUuid,
218
224
  isJoined: true
219
225
  };
@@ -476,6 +476,11 @@ export declare class FcrCoreServiceApi {
476
476
  roomUuid: string;
477
477
  userUuid: string;
478
478
  }): Promise<any>;
479
+ updateWidgetState(params: {
480
+ roomUuid: string;
481
+ widgetId: string;
482
+ state: 0 | 1;
483
+ }): Promise<any>;
479
484
  startTranscribing(params: {
480
485
  roomUuid: string;
481
486
  userUuid: string;
@@ -340,7 +340,7 @@ class FcrCoreServiceApi {
340
340
  ts
341
341
  } = await this._client.fetch({
342
342
  path: `/v1/rooms/${params.roomId}/users/${params.userId}/entry`,
343
- method: 'PUT',
343
+ method: 'POST',
344
344
  data: {
345
345
  password: params.password,
346
346
  stream: params.stream,
@@ -367,7 +367,7 @@ class FcrCoreServiceApi {
367
367
  ts
368
368
  } = await this._client.fetch({
369
369
  path: `/v1/rooms/${params.roomId}/users/${params.userId}/internal/entry`,
370
- method: 'PUT',
370
+ method: 'POST',
371
371
  data: {
372
372
  password: params.password,
373
373
  stream: params.stream,
@@ -1128,6 +1128,20 @@ class FcrCoreServiceApi {
1128
1128
  method: 'PUT'
1129
1129
  });
1130
1130
  }
1131
+ async updateWidgetState(params) {
1132
+ const {
1133
+ roomUuid,
1134
+ widgetId,
1135
+ state
1136
+ } = params;
1137
+ return await this._client.fetch({
1138
+ path: `/v1/rooms/${roomUuid}/widgets/${widgetId}`,
1139
+ method: 'PUT',
1140
+ data: {
1141
+ state
1142
+ }
1143
+ });
1144
+ }
1131
1145
  async startTranscribing(params) {
1132
1146
  const {
1133
1147
  roomUuid,
package/lib/type.d.ts CHANGED
@@ -90,7 +90,7 @@ export type FcrUserInfo = {
90
90
  readonly userRole: FcrUserRole;
91
91
  readonly connectorType: FcrRoomConnectorType;
92
92
  readonly platform: FcrPlatform;
93
- readonly avatar: string;
93
+ readonly avatar?: string;
94
94
  };
95
95
  /** 流信息类型 */
96
96
  export type FcrStreamInfo = {
@@ -0,0 +1,2 @@
1
+ import { FcrRoomType } from '../room-control/type';
2
+ export declare const convertServerRoomTypeToFcrRoomType: (roomType: number) => FcrRoomType | null;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertServerRoomTypeToFcrRoomType = void 0;
7
+ var _type = require("../room-control/type");
8
+ const convertServerRoomTypeToFcrRoomType = roomType => {
9
+ switch (roomType) {
10
+ case 11:
11
+ return _type.FcrRoomType.Mainroom;
12
+ case 102:
13
+ return _type.FcrRoomType.Waitingroom;
14
+ case 101:
15
+ return _type.FcrRoomType.Subroom;
16
+ case 103:
17
+ return _type.FcrRoomType.Interpreterroom;
18
+ case 104:
19
+ return _type.FcrRoomType.JoinBeforeHostWaitingRoom;
20
+ case 12:
21
+ return _type.FcrRoomType.Infinityroom;
22
+ default:
23
+ return null;
24
+ }
25
+ };
26
+ exports.convertServerRoomTypeToFcrRoomType = convertServerRoomTypeToFcrRoomType;
@@ -22,7 +22,8 @@ export declare enum ControllerType {
22
22
  MEDIA = "media",
23
23
  STT = "stt",
24
24
  REMOTE_CONTROL = "remote control",
25
- APPLICATION = "application"
25
+ APPLICATION = "application",
26
+ WIDGET = "widget"
26
27
  }
27
28
  /**
28
29
  * 错误处理配置接口
@@ -29,6 +29,7 @@ let ControllerType = exports.ControllerType = /*#__PURE__*/function (ControllerT
29
29
  ControllerType["STT"] = "stt";
30
30
  ControllerType["REMOTE_CONTROL"] = "remote control";
31
31
  ControllerType["APPLICATION"] = "application";
32
+ ControllerType["WIDGET"] = "widget";
32
33
  return ControllerType;
33
34
  }({});
34
35
  /**
@@ -59,6 +59,7 @@ import { getCoreIpList, getCoreLogFileSize, getEasemobChatIpList, getEasemobRest
59
59
  import validateParams from '../utilities/validate-params';
60
60
  import { FcrInfinityRoomControlImpl } from '../room-control/infinity-room-control';
61
61
  import { FcrRemoteControlImpl } from '../remote-control';
62
+ import { convertServerRoomTypeToFcrRoomType } from '../utilities/convertRoomType';
62
63
  export class FcrCoreEngineImpl {
63
64
  static {
64
65
  [_initProto] = _applyDecs(this, [[trace, 2, "release"], [trace, 2, "login"], [trace, 2, "logout"], [_renewUserTokenDecs, 2, "renewUserToken"], [trace, 2, "getVersion"], [_createMainRoomControlDecs, 2, "createMainRoomControl"], [_createInfinityRoomControlDecs, 2, "createInfinityRoomControl"], [_createWaitingRoomControlDecs, 2, "createWaitingRoomControl"], [_createRoomRouterDecs, 2, "createRoomRouter"], [_createRoomControlAndJoinDecs, 2, "createRoomControlAndJoin"], [trace, 2, "getDesktopMediaControl"], [trace, 2, "getMobileMediaControl"], [trace, 2, "getMonitorControl"], [trace, 2, "getPeerSessionControl"], [trace, 2, "getRemoteControl"], [_sendPeerMessageDecs, 2, "sendPeerMessage"], [_setParametersDecs, 2, "setParameters"]], []).e;
@@ -288,7 +289,8 @@ export class FcrCoreEngineImpl {
288
289
  data,
289
290
  ts
290
291
  } = res;
291
- switch (data.room.roomProperties.roomType) {
292
+ const fcrRoomType = convertServerRoomTypeToFcrRoomType(data.room.roomProperties.roomType);
293
+ switch (fcrRoomType) {
292
294
  case FcrRoomType.Waitingroom:
293
295
  roomControl = this.createWaitingRoomControl(data.room.roomInfo.roomUuid);
294
296
  break;
@@ -299,13 +301,13 @@ export class FcrCoreEngineImpl {
299
301
  roomControl = this.createMainRoomControl(roomId);
300
302
  break;
301
303
  default:
302
- throw new Error(`Unknown room type: ${data.room.roomProperties.roomType}`);
304
+ throw new Error(`Unknown room type: ${fcrRoomType}`);
303
305
  }
304
306
  await roomControl.join({
305
307
  ...options,
306
308
  snapshot: data,
307
309
  timestamp: ts,
308
- createStreamConfigs: data.room.roomProperties.roomType === FcrRoomType.Waitingroom ? [] : options.createStreamConfigs
310
+ createStreamConfigs: fcrRoomType === FcrRoomType.Waitingroom ? [] : options.createStreamConfigs
309
311
  });
310
312
  }, [], {
311
313
  retriesMax: 10
package/lib-es/imports.js CHANGED
@@ -37,7 +37,7 @@ export { Mutex } from 'agora-foundation/lib/worker/mutex';
37
37
 
38
38
  export { AgoraRteError } from 'agora-rte-sdk/lib/core/utilities/error';
39
39
  export { AgoraError as FcrError } from 'agora-foundation/lib/utilities/error/agora-error';
40
- export { AgoraRteConnectionState, AgoraRteEngine, convertStreamTypeToPublishState, AgoraRteLatencyLevel } from 'agora-rte-sdk';
40
+ export { AgoraRteConnectionState, AgoraRteEngine, convertStreamTypeToPublishState, AgoraRteLatencyLevel, AgoraRteVideoOutputOrientationMode } from 'agora-rte-sdk';
41
41
  export { AgoraRteRoomConnectorType, AgoraRteStreamPrivilegeOperation, AgoraRteStreamPrivilegeVideoSourceType, AgoraRteStreamPrivilegeAudioSourceType, AgoraRteMediaStreamType } from 'agora-rte-sdk/lib/core/scene/type';
42
42
  export { AgoraRtcRegion, AgoraRtcVideoSourceType, AgoraRtcAudioSourceType, AgoraRtcMediaSourceState, AgoraRtcRenderMode, AgoraRtcVideoStreamType, AgoraRtcCapability, AgoraRtcAiDenoiseLevel, AgoraRtcAudioOutputRouting, AgoraRtcLatencyLevelType, AgoraRtcEncryptionMode, AgoraRtcDegradationPreference } from 'agora-rte-sdk/lib/core/rtc/type';
43
43
  export { AgoraRteStreamLayer } from 'agora-rte-sdk/lib/type';
package/lib-es/index.js CHANGED
@@ -6,4 +6,6 @@ export { FcrCoreEngineImpl as FcrCoreEngine } from './engine';
6
6
  export { FcrCoreEngineConfig } from './struct';
7
7
 
8
8
  // classes
9
- export { FcrError } from './type';
9
+ export { FcrError } from './type';
10
+ export { FcrDegradationPreference } from './schema';
11
+ export { AgoraRteVideoOutputOrientationMode as FcrVideoOutputOrientationMode } from './imports';
@@ -320,6 +320,8 @@ export class FcrPeerSessionControlImpl {
320
320
  data,
321
321
  cmd
322
322
  } = payload;
323
+ const logContext = `cmd=${cmd}, sessionKey=${data.sessionKey}, sessionId=${data.sessionUuid}, ` + `action=${String(data.action)}, senderId=${senderId}, keepAlive=${!!data.keepAlive}`;
324
+ this.logger.info(`[PeerSession] received peer message: ${logContext}, payload=${JSON.stringify(data.payload ?? {})}`);
323
325
  if (cmd === '1001') {
324
326
  const session = {
325
327
  sessionId: data.sessionUuid,
@@ -352,7 +354,10 @@ export class FcrPeerSessionControlImpl {
352
354
  ...params,
353
355
  action: 1
354
356
  });
357
+ this.logger.info(`[PeerSession] forward peer session accepted to observers: ${logContext}`);
355
358
  this._observable.notifyObservers('onPeerSessionAccepted', sessionResponse);
359
+ } else {
360
+ this.logger.info(`[PeerSession] ignore peer session accepted without local schedule: ${logContext}`);
356
361
  }
357
362
  if (this._receivedMap.has(session.sessionId)) {
358
363
  this._receivedMap.set(session.sessionId, {
@@ -365,8 +370,10 @@ export class FcrPeerSessionControlImpl {
365
370
  return;
366
371
  } else {
367
372
  if (!this._receivedMap.has(session.sessionId)) {
368
- this.logger.info(`[PeerSession] received peer session request ${JSON.stringify(session)}`);
373
+ this.logger.info(`[PeerSession] forward peer session request to observers: ${logContext}`);
369
374
  this._observable.notifyObservers('onPeerSessionReceived', session);
375
+ } else {
376
+ this.logger.info(`[PeerSession] peer session request already cached, update cache only: ${logContext}`);
370
377
  }
371
378
  this._receivedMap.set(session.sessionId, {
372
379
  ...session,
@@ -375,6 +382,8 @@ export class FcrPeerSessionControlImpl {
375
382
  action: 0
376
383
  });
377
384
  }
385
+ } else {
386
+ this.logger.info(`[PeerSession] ignore expired peer session message: ${logContext}, ` + `timestamp=${session.timestamp}, duration=${session.duration}`);
378
387
  }
379
388
  } else if (cmd === '1002') {
380
389
  if (data.action === 1) {
@@ -390,9 +399,11 @@ export class FcrPeerSessionControlImpl {
390
399
  cause: data.payload?.cause ?? {},
391
400
  keepAlive: !!data.keepAlive
392
401
  };
393
- this.logger.info(`[PeerSession] received peer session accepted ${JSON.stringify(sessionResponse)}`);
394
402
  this._scheduleMap.delete(data.sessionUuid);
403
+ this.logger.info(`[PeerSession] forward peer session accepted to observers: ${logContext}`);
395
404
  this._observable.notifyObservers('onPeerSessionAccepted', sessionResponse);
405
+ } else {
406
+ this.logger.info(`[PeerSession] ignore peer session accepted without local schedule: ${logContext}`);
396
407
  }
397
408
  } else if (data.action === 2) {
398
409
  if (this._scheduleMap.has(data.sessionUuid)) {
@@ -407,11 +418,13 @@ export class FcrPeerSessionControlImpl {
407
418
  cause: data.payload?.cause ?? {},
408
419
  keepAlive: !!data.keepAlive
409
420
  };
410
- this.logger.info(`[PeerSession] received peer session rejected ${JSON.stringify(sessionResponse)}`);
411
421
  if (this._scheduleMap.has(data.sessionUuid)) {
412
422
  this._scheduleMap.delete(data.sessionUuid);
423
+ this.logger.info(`[PeerSession] forward peer session rejected to observers: ${logContext}`);
413
424
  this._observable.notifyObservers('onPeerSessionRejected', sessionResponse);
414
425
  }
426
+ } else {
427
+ this.logger.info(`[PeerSession] ignore peer session rejected without local schedule: ${logContext}`);
415
428
  }
416
429
  } else if (data.action === 3) {
417
430
  const scheduleSession = this._scheduleMap.get(data.sessionUuid);
@@ -423,7 +436,6 @@ export class FcrPeerSessionControlImpl {
423
436
  fromUserId: senderId,
424
437
  cause: data.payload?.cause ?? {}
425
438
  };
426
- this.logger.info(`[PeerSession] received peer session ended ${JSON.stringify(params)}`);
427
439
  if (scheduleSession) {
428
440
  this._scheduleMap.delete(data.sessionUuid);
429
441
  }
@@ -431,8 +443,15 @@ export class FcrPeerSessionControlImpl {
431
443
  this._receivedMap.delete(data.sessionUuid);
432
444
  }
433
445
  this._observable.notifyObservers('onPeerSessionEnded', params.sessionId, params.fromUserId, params.cause);
446
+ this.logger.info(`[PeerSession] forward peer session ended to observers: ${logContext}`);
447
+ } else {
448
+ this.logger.info(`[PeerSession] ignore peer session ended without cached session: ${logContext}`);
434
449
  }
450
+ } else {
451
+ this.logger.info(`[PeerSession] ignore peer session response with unknown action: ${logContext}`);
435
452
  }
453
+ } else {
454
+ this.logger.info(`[PeerSession] ignore unsupported peer session cmd: ${logContext}`);
436
455
  }
437
456
  }
438
457
 
@@ -72,13 +72,17 @@ export class FcrRemoteControlImpl {
72
72
  data,
73
73
  cmd
74
74
  } = payload;
75
+ const logContext = `cmd=${cmd}, sessionKey=${data.sessionKey}, sessionId=${data.sessionUuid}, ` + `action=${String(data.action)}, senderId=${senderId}, keepAlive=${!!data.keepAlive}`;
75
76
  if (data.sessionKey !== this._remoteControlSessionKey) {
77
+ this.logger.info(`[RemoteControl] ignore peer message because sessionKey does not match remote-control: ${logContext}`);
76
78
  return;
77
79
  }
78
80
  if (cmd === '1001') {
79
81
  if (!data.keepAlive) {
82
+ this.logger.info(`[RemoteControl] ignore remote-control update without keepAlive: ${logContext}`);
80
83
  return;
81
84
  }
85
+ this.logger.info(`[RemoteControl] forward update session for handling: ${logContext}`);
82
86
  return await this._handleUpdateRemoteControlSession({
83
87
  senderId: senderId,
84
88
  sessionKey: data.sessionKey,
@@ -91,6 +95,7 @@ export class FcrRemoteControlImpl {
91
95
  timestamp: message.timestamp
92
96
  });
93
97
  } else if (cmd === '1002') {
98
+ this.logger.info(`[RemoteControl] forward delete session for handling: ${logContext}`);
94
99
  return await this._handleDeleteRemoteControlSession({
95
100
  senderId: senderId,
96
101
  sessionKey: data.sessionKey,
@@ -101,6 +106,8 @@ export class FcrRemoteControlImpl {
101
106
  action: data.action,
102
107
  timestamp: message.timestamp
103
108
  });
109
+ } else {
110
+ this.logger.info(`[RemoteControl] ignore unsupported cmd: ${logContext}`);
104
111
  }
105
112
  }
106
113
  async _handleUpdateRemoteControlSession(data) {
@@ -58,6 +58,7 @@ import { FcrConnectionState } from '..';
58
58
  import { ControllerType } from '../utilities/error-helpers';
59
59
  import { FcrJoinHelper, LIVE_STREAMING_STATE_VALUES, liveStreamingErrorHelper, RECORDING_STATE_VALUES, RESPONSE_CODES, ROOM_CONTROL_CONSTANTS, ROOM_MESSAGE_COMMANDS, ROOM_STATE_VALUES, roomControlErrorHelper, validateControllerInitialized, validateJoinRoomPreconditions, validateRoomJoined } from './helpers';
60
60
  import { FcrSttControlImpl } from './stt-control';
61
+ import { FcrWidgetControlImpl } from './widget-control';
61
62
  import { FcrApplicationControlImpl } from './application-control';
62
63
 
63
64
  /**
@@ -120,6 +121,7 @@ export class FcrBaseRoomControlImpl {
120
121
  this.sharingControl = new FcrSharingControlImpl(this._scene, this._api, this._engine, this._config, this._privilegeControl, this._streamControl, this._sharedCache, this._userControl);
121
122
  }
122
123
  this._sttControl = new FcrSttControlImpl(this._scene, this._api, this._sharedCache);
124
+ this._widgetControl = new FcrWidgetControlImpl(this._scene, this._api, this._sharedCache);
123
125
  this._observable.notifyObservers('onJoinRoomSuccess', sceneId);
124
126
  },
125
127
  // onJoinSceneFailure: (sceneId, error) => {
@@ -241,6 +243,10 @@ export class FcrBaseRoomControlImpl {
241
243
  validateControllerInitialized(this._sttControl, ControllerType.STT);
242
244
  return this._sttControl;
243
245
  }
246
+ getWidgetControl() {
247
+ validateControllerInitialized(this._widgetControl, ControllerType.WIDGET);
248
+ return this._widgetControl;
249
+ }
244
250
  getApplicationControl() {
245
251
  validateControllerInitialized(this._applicationControl, ControllerType.APPLICATION);
246
252
  return this._applicationControl;
@@ -365,7 +371,6 @@ export class FcrBaseRoomControlImpl {
365
371
  validateRoomJoined(this._joinRoomSuccess, 'get schedule info');
366
372
  const schedule = this._scene.getScenePropertiesByKeyPath('schedule');
367
373
  return {
368
- ...schedule,
369
374
  duration: schedule.duration ?? 0,
370
375
  startTime: Math.floor((schedule.startTime ?? 0) / 1000)
371
376
  };
@@ -1,6 +1,7 @@
1
1
  import "core-js/modules/esnext.iterator.constructor.js";
2
2
  import "core-js/modules/esnext.iterator.map.js";
3
3
  import { DetailErrorCode, ErrorModuleCode, FcrChatRoomControlImpl } from '../imports';
4
+ import { convertServerRoomTypeToFcrRoomType } from '../utilities/convertRoomType';
4
5
  import { generateFcrCoreClientError } from '../utilities/error';
5
6
  import { FcrInfinityRoomControlImpl } from './infinity-room-control';
6
7
  import { FcrInterpreterRoomControlImpl } from './interpreter-control/room';
@@ -48,7 +49,10 @@ export class RoomControlFactory {
48
49
  roomResponse,
49
50
  monitorControl
50
51
  } = params;
51
- const roomType = roomResponse.room.roomProperties.roomType;
52
+ const roomType = convertServerRoomTypeToFcrRoomType(roomResponse.room.roomProperties.roomType);
53
+ if (roomType === null) {
54
+ throw generateFcrCoreClientError(ErrorModuleCode.FCR_ROOM, DetailErrorCode.UNDEFINED_ERROR, `Unsupported room types: ${roomResponse.room.roomProperties.roomType}`);
55
+ }
52
56
  const RoomControlImpl = ROOM_CONTROL_IMPLEMENTATIONS[roomType];
53
57
  if (!RoomControlImpl) {
54
58
  throw generateFcrCoreClientError(ErrorModuleCode.FCR_ROOM, DetailErrorCode.UNDEFINED_ERROR, `Unsupported room types: ${roomType}`);
@@ -1,10 +1,10 @@
1
1
  export let FcrRoomType = /*#__PURE__*/function (FcrRoomType) {
2
- FcrRoomType[FcrRoomType["Mainroom"] = 11] = "Mainroom";
3
- FcrRoomType[FcrRoomType["Waitingroom"] = 102] = "Waitingroom";
4
- FcrRoomType[FcrRoomType["Subroom"] = 101] = "Subroom";
5
- FcrRoomType[FcrRoomType["Interpreterroom"] = 103] = "Interpreterroom";
6
- FcrRoomType[FcrRoomType["JoinBeforeHostWaitingRoom"] = 104] = "JoinBeforeHostWaitingRoom";
7
- FcrRoomType[FcrRoomType["Infinityroom"] = 12] = "Infinityroom";
2
+ FcrRoomType[FcrRoomType["Mainroom"] = 0] = "Mainroom";
3
+ FcrRoomType[FcrRoomType["Subroom"] = 1] = "Subroom";
4
+ FcrRoomType[FcrRoomType["Waitingroom"] = 2] = "Waitingroom";
5
+ FcrRoomType[FcrRoomType["Interpreterroom"] = 3] = "Interpreterroom";
6
+ FcrRoomType[FcrRoomType["JoinBeforeHostWaitingRoom"] = 4] = "JoinBeforeHostWaitingRoom";
7
+ FcrRoomType[FcrRoomType["Infinityroom"] = 5] = "Infinityroom";
8
8
  return FcrRoomType;
9
9
  }({});
10
10
  export let FcrLiveStreamingStateUpdatedReason = /*#__PURE__*/function (FcrLiveStreamingStateUpdatedReason) {
@@ -68,8 +68,8 @@ export class FcrUserControlImpl {
68
68
  });
69
69
  const fcrUserEvents = events.map(e => {
70
70
  return {
71
- userInfo: e.userInfo && convertRteUserToFcrUser(e.userInfo, this._roomCache),
72
- operatorUser: e.operatorUser && convertRteUserToFcrUser(e.operatorUser, this._roomCache)
71
+ userInfo: e.userInfo && convertRteUserToFcrUser(e.userInfo, this._roomCache)
72
+ // operatorUser: e.operatorUser && convertRteUserToFcrUser(e.operatorUser, this._roomCache),
73
73
  };
74
74
  });
75
75
  fcrUserEvents.forEach(event => {
@@ -0,0 +1,109 @@
1
+ import "core-js/modules/es.array.push.js";
2
+ import "core-js/modules/esnext.function.metadata.js";
3
+ import "core-js/modules/esnext.map.delete-all.js";
4
+ import "core-js/modules/esnext.map.emplace.js";
5
+ import "core-js/modules/esnext.map.every.js";
6
+ import "core-js/modules/esnext.map.filter.js";
7
+ import "core-js/modules/esnext.map.find.js";
8
+ import "core-js/modules/esnext.map.find-key.js";
9
+ import "core-js/modules/esnext.map.includes.js";
10
+ import "core-js/modules/esnext.map.key-of.js";
11
+ import "core-js/modules/esnext.map.map-keys.js";
12
+ import "core-js/modules/esnext.map.map-values.js";
13
+ import "core-js/modules/esnext.map.merge.js";
14
+ import "core-js/modules/esnext.map.reduce.js";
15
+ import "core-js/modules/esnext.map.some.js";
16
+ import "core-js/modules/esnext.map.update.js";
17
+ import "core-js/modules/esnext.symbol.metadata.js";
18
+ let _initProto, _getActivityDecs, _activeDecs, _inactiveDecs;
19
+ 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)]; } }; }
20
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
21
+ 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); }
22
+ 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; }
23
+ 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; }
24
+ import { ErrorModuleCode } from '../../imports';
25
+ import { AgoraObservable, trace } from '../../imports';
26
+ import { FcrReturnCode } from '../../type';
27
+ import { handleRequestError } from '../../utilities/error';
28
+ import { createLogger, generateLogObserver } from '../../utilities/logger';
29
+ /** scene 属性更新中表示 widget 状态变更的 cause.cmd(与服务端约定一致) */
30
+ const WIDGET_SCENE_PROPERTIES_CMD = 13;
31
+ var WidgetState = /*#__PURE__*/function (WidgetState) {
32
+ WidgetState[WidgetState["INACTIVE"] = 0] = "INACTIVE";
33
+ WidgetState[WidgetState["ACTIVE"] = 1] = "ACTIVE";
34
+ return WidgetState;
35
+ }(WidgetState || {});
36
+ /**
37
+ * @internal
38
+ */
39
+ export class FcrWidgetControlImpl {
40
+ static {
41
+ [_initProto] = _applyDecs(this, [[_getActivityDecs, 2, "getActivity"], [_activeDecs, 2, "active"], [_inactiveDecs, 2, "inactive"], [trace, 2, "release"]], []).e;
42
+ }
43
+ //@internal
44
+ [(_getActivityDecs = trace(['widgetId']), _activeDecs = trace(['widgetId']), _inactiveDecs = trace(['widgetId']), "logger")] = (_initProto(this), createLogger({
45
+ prefix: 'FcrWidgetControlImpl'
46
+ }));
47
+
48
+ //@internal
49
+ _observable = new AgoraObservable();
50
+
51
+ //@internal
52
+ _sceneObserver = {
53
+ onScenePropertiesUpdated: (sceneId, event) => {
54
+ if (event.cause?.cmd !== WIDGET_SCENE_PROPERTIES_CMD) {
55
+ return;
56
+ }
57
+ const changedWidgets = event.changedProperties?.flexWidgets;
58
+ if (!changedWidgets || typeof changedWidgets !== 'object') {
59
+ return;
60
+ }
61
+ for (const widgetId of Object.keys(changedWidgets)) {
62
+ const state = changedWidgets[widgetId]?.state;
63
+ if (state === WidgetState.ACTIVE) {
64
+ this._observable.notifyObservers('onWidgetActive', sceneId, widgetId);
65
+ } else if (state === WidgetState.INACTIVE) {
66
+ this._observable.notifyObservers('onWidgetInactive', sceneId, widgetId);
67
+ }
68
+ }
69
+ }
70
+ };
71
+ constructor(_scene, _api, _sharedCache) {
72
+ this._scene = _scene;
73
+ this._api = _api;
74
+ this._scene.addObserver(this._sceneObserver);
75
+ this._addLogObserver();
76
+ }
77
+ getActivity(widgetId) {
78
+ const state = this._scene.getScenePropertiesByKeyPath(`flexWidgets.${widgetId}.state`);
79
+ return state === WidgetState.ACTIVE;
80
+ }
81
+ active(widgetId) {
82
+ return handleRequestError(() => this._api.updateWidgetState({
83
+ roomUuid: this._scene.sceneId,
84
+ widgetId,
85
+ state: 1
86
+ }), ErrorModuleCode.FCR_ROOM, 'activate widget failed');
87
+ }
88
+ inactive(widgetId) {
89
+ return handleRequestError(() => this._api.updateWidgetState({
90
+ roomUuid: this._scene.sceneId,
91
+ widgetId,
92
+ state: 0
93
+ }), ErrorModuleCode.FCR_ROOM, 'deactivate widget failed');
94
+ }
95
+ addObserver(observer) {
96
+ this._observable.addObserver(observer);
97
+ }
98
+ removeObserver(observer) {
99
+ this._observable.removeObserver(observer);
100
+ }
101
+ release() {
102
+ this._scene.removeObserver(this._sceneObserver);
103
+ this._observable.removeAllObservers();
104
+ return FcrReturnCode.SUCCESS;
105
+ }
106
+ _addLogObserver() {
107
+ this.addObserver(generateLogObserver(this.logger, [['onWidgetActive', ['roomId', 'widgetId']], ['onWidgetInactive', ['roomId', 'widgetId']]]));
108
+ }
109
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -33,6 +33,7 @@ import { createLogger, generateLogObserver } from '../utilities/logger';
33
33
  import validateParams from '../utilities/validate-params';
34
34
  import { ROOM_ROUTER_CONSTANTS } from './type';
35
35
  import { DetailErrorCode, ErrorModuleCode } from '../imports';
36
+ import { convertServerRoomTypeToFcrRoomType } from '../utilities/convertRoomType';
36
37
 
37
38
  /**
38
39
  * @internal
@@ -207,8 +208,13 @@ export class FcrRoomRouterImpl {
207
208
  const {
208
209
  data
209
210
  } = roomResponse;
211
+ const fcrRoomType = convertServerRoomTypeToFcrRoomType(data.room.roomProperties.roomType);
212
+ if (fcrRoomType === null) {
213
+ const fcrError = generateFcrCoreClientError(ErrorModuleCode.FCR_ROOM, DetailErrorCode.UNDEFINED_ERROR, `update room state failed: Unknown room type: ${data.room.roomProperties.roomType}`);
214
+ throw fcrError;
215
+ }
210
216
  this._nextRoomRoute = {
211
- roomType: data.room.roomProperties.roomType,
217
+ roomType: fcrRoomType,
212
218
  roomId: data.room.roomInfo.roomUuid,
213
219
  isJoined: true
214
220
  };
@@ -334,7 +334,7 @@ export class FcrCoreServiceApi {
334
334
  ts
335
335
  } = await this._client.fetch({
336
336
  path: `/v1/rooms/${params.roomId}/users/${params.userId}/entry`,
337
- method: 'PUT',
337
+ method: 'POST',
338
338
  data: {
339
339
  password: params.password,
340
340
  stream: params.stream,
@@ -361,7 +361,7 @@ export class FcrCoreServiceApi {
361
361
  ts
362
362
  } = await this._client.fetch({
363
363
  path: `/v1/rooms/${params.roomId}/users/${params.userId}/internal/entry`,
364
- method: 'PUT',
364
+ method: 'POST',
365
365
  data: {
366
366
  password: params.password,
367
367
  stream: params.stream,
@@ -1122,6 +1122,20 @@ export class FcrCoreServiceApi {
1122
1122
  method: 'PUT'
1123
1123
  });
1124
1124
  }
1125
+ async updateWidgetState(params) {
1126
+ const {
1127
+ roomUuid,
1128
+ widgetId,
1129
+ state
1130
+ } = params;
1131
+ return await this._client.fetch({
1132
+ path: `/v1/rooms/${roomUuid}/widgets/${widgetId}`,
1133
+ method: 'PUT',
1134
+ data: {
1135
+ state
1136
+ }
1137
+ });
1138
+ }
1125
1139
  async startTranscribing(params) {
1126
1140
  const {
1127
1141
  roomUuid,
@@ -0,0 +1,19 @@
1
+ import { FcrRoomType } from '../room-control/type';
2
+ export const convertServerRoomTypeToFcrRoomType = roomType => {
3
+ switch (roomType) {
4
+ case 11:
5
+ return FcrRoomType.Mainroom;
6
+ case 102:
7
+ return FcrRoomType.Waitingroom;
8
+ case 101:
9
+ return FcrRoomType.Subroom;
10
+ case 103:
11
+ return FcrRoomType.Interpreterroom;
12
+ case 104:
13
+ return FcrRoomType.JoinBeforeHostWaitingRoom;
14
+ case 12:
15
+ return FcrRoomType.Infinityroom;
16
+ default:
17
+ return null;
18
+ }
19
+ };
@@ -25,6 +25,7 @@ export let ControllerType = /*#__PURE__*/function (ControllerType) {
25
25
  ControllerType["STT"] = "stt";
26
26
  ControllerType["REMOTE_CONTROL"] = "remote control";
27
27
  ControllerType["APPLICATION"] = "application";
28
+ ControllerType["WIDGET"] = "widget";
28
29
  return ControllerType;
29
30
  }({});
30
31
 
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.10.0",
4
+ "version": "3.10.1",
5
5
  "module": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "files": [
@@ -41,7 +41,7 @@
41
41
  "@types/lodash": "^4.14.168",
42
42
  "@types/sinon": "^17.0.2",
43
43
  "@types/uuid": "^8.3.0",
44
- "agora-toolchain": "3.10.0",
44
+ "agora-toolchain": "3.10.1",
45
45
  "core-js": "^3.33.3",
46
46
  "decomment": "^0.9.5",
47
47
  "husky": "^9.0.11",
@@ -61,8 +61,8 @@
61
61
  "@netless/video-js-plugin": "^0.3.8",
62
62
  "@netless/white-snapshot": "^0.4.2",
63
63
  "@netless/window-manager": "^1.0.7-beta.6",
64
- "agora-foundation": "3.10.0",
65
- "agora-rte-sdk": "3.10.0",
64
+ "agora-foundation": "3.10.1",
65
+ "agora-rte-sdk": "3.10.1",
66
66
  "await-to-js": "^3.0.0",
67
67
  "dayjs": "^1.10.4",
68
68
  "easemob-websdk": "4.13.0",