@webex/plugin-meetings 3.10.0-next.9 → 3.10.0-webex-services-ready.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 (73) hide show
  1. package/dist/breakouts/breakout.js +1 -1
  2. package/dist/breakouts/index.js +1 -1
  3. package/dist/constants.js +11 -3
  4. package/dist/constants.js.map +1 -1
  5. package/dist/hashTree/constants.js +20 -0
  6. package/dist/hashTree/constants.js.map +1 -0
  7. package/dist/hashTree/hashTree.js +515 -0
  8. package/dist/hashTree/hashTree.js.map +1 -0
  9. package/dist/hashTree/hashTreeParser.js +1266 -0
  10. package/dist/hashTree/hashTreeParser.js.map +1 -0
  11. package/dist/hashTree/types.js +21 -0
  12. package/dist/hashTree/types.js.map +1 -0
  13. package/dist/hashTree/utils.js +48 -0
  14. package/dist/hashTree/utils.js.map +1 -0
  15. package/dist/interpretation/index.js +1 -1
  16. package/dist/interpretation/siLanguage.js +1 -1
  17. package/dist/locus-info/index.js +511 -48
  18. package/dist/locus-info/index.js.map +1 -1
  19. package/dist/locus-info/types.js +7 -0
  20. package/dist/locus-info/types.js.map +1 -0
  21. package/dist/meeting/index.js +41 -15
  22. package/dist/meeting/index.js.map +1 -1
  23. package/dist/meeting/util.js +1 -0
  24. package/dist/meeting/util.js.map +1 -1
  25. package/dist/meetings/index.js +112 -70
  26. package/dist/meetings/index.js.map +1 -1
  27. package/dist/metrics/constants.js +3 -1
  28. package/dist/metrics/constants.js.map +1 -1
  29. package/dist/reachability/clusterReachability.js +44 -358
  30. package/dist/reachability/clusterReachability.js.map +1 -1
  31. package/dist/reachability/reachability.types.js +14 -1
  32. package/dist/reachability/reachability.types.js.map +1 -1
  33. package/dist/reachability/reachabilityPeerConnection.js +445 -0
  34. package/dist/reachability/reachabilityPeerConnection.js.map +1 -0
  35. package/dist/types/constants.d.ts +26 -21
  36. package/dist/types/hashTree/constants.d.ts +8 -0
  37. package/dist/types/hashTree/hashTree.d.ts +129 -0
  38. package/dist/types/hashTree/hashTreeParser.d.ts +260 -0
  39. package/dist/types/hashTree/types.d.ts +25 -0
  40. package/dist/types/hashTree/utils.d.ts +9 -0
  41. package/dist/types/locus-info/index.d.ts +91 -42
  42. package/dist/types/locus-info/types.d.ts +46 -0
  43. package/dist/types/meeting/index.d.ts +22 -9
  44. package/dist/types/meetings/index.d.ts +9 -2
  45. package/dist/types/metrics/constants.d.ts +2 -0
  46. package/dist/types/reachability/clusterReachability.d.ts +10 -88
  47. package/dist/types/reachability/reachability.types.d.ts +12 -1
  48. package/dist/types/reachability/reachabilityPeerConnection.d.ts +111 -0
  49. package/dist/webinar/index.js +1 -1
  50. package/package.json +22 -21
  51. package/src/constants.ts +13 -1
  52. package/src/hashTree/constants.ts +9 -0
  53. package/src/hashTree/hashTree.ts +463 -0
  54. package/src/hashTree/hashTreeParser.ts +1161 -0
  55. package/src/hashTree/types.ts +30 -0
  56. package/src/hashTree/utils.ts +42 -0
  57. package/src/locus-info/index.ts +556 -85
  58. package/src/locus-info/types.ts +48 -0
  59. package/src/meeting/index.ts +58 -26
  60. package/src/meeting/util.ts +1 -0
  61. package/src/meetings/index.ts +104 -51
  62. package/src/metrics/constants.ts +2 -0
  63. package/src/reachability/clusterReachability.ts +50 -347
  64. package/src/reachability/reachability.types.ts +15 -1
  65. package/src/reachability/reachabilityPeerConnection.ts +416 -0
  66. package/test/unit/spec/hashTree/hashTree.ts +655 -0
  67. package/test/unit/spec/hashTree/hashTreeParser.ts +1532 -0
  68. package/test/unit/spec/hashTree/utils.ts +103 -0
  69. package/test/unit/spec/locus-info/index.js +667 -1
  70. package/test/unit/spec/meeting/index.js +91 -20
  71. package/test/unit/spec/meeting/utils.js +77 -0
  72. package/test/unit/spec/meetings/index.js +71 -26
  73. package/test/unit/spec/reachability/clusterReachability.ts +281 -138
@@ -1,17 +1,30 @@
1
1
  "use strict";
2
2
 
3
+ var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
3
4
  var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
5
+ var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
6
+ var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
7
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
8
+ var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
9
+ var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
10
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
11
  var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
5
12
  var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
6
13
  var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
7
14
  var _Array$isArray2 = require("@babel/runtime-corejs2/core-js/array/is-array");
8
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
15
+ var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
9
16
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
10
17
  _Object$defineProperty(exports, "__esModule", {
11
18
  value: true
12
19
  });
13
20
  exports.default = void 0;
21
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
22
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
23
+ var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
24
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
25
+ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
14
26
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
27
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
15
28
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
16
29
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
17
30
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
@@ -32,11 +45,25 @@ var _mediaSharesUtils = _interopRequireDefault(require("./mediaSharesUtils"));
32
45
  var _parser = _interopRequireDefault(require("./parser"));
33
46
  var _metrics = _interopRequireDefault(require("../metrics"));
34
47
  var _constants2 = _interopRequireDefault(require("../metrics/constants"));
48
+ var _hashTreeParser = _interopRequireWildcard(require("../hashTree/hashTreeParser"));
49
+ var _types = require("../hashTree/types");
50
+ function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
35
51
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && r[_Symbol$iterator] || r["@@iterator"]; if (!t) { if (_Array$isArray2(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
36
52
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
37
53
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
54
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
55
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
38
56
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
39
57
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
58
+ // list of top level keys in Locus DTO relevant for Hash Tree DTOs processing
59
+ // it does not contain fields specific to classic Locus DTOs like sequence or baseSequence
60
+ var LocusDtoTopLevelKeys = ['controls', 'fullState', 'host', 'info', 'links', 'mediaShares', 'meetings', 'participants', 'replaces', 'self', 'sequence', 'syncUrl', 'url', 'htMeta' // only exists when hash trees are used
61
+ ];
62
+ var LocusObjectStateAfterUpdates = {
63
+ unchanged: 'unchanged',
64
+ removed: 'removed',
65
+ updated: 'updated'
66
+ };
40
67
  /**
41
68
  * @description LocusInfo extends ChildEmitter to convert locusInfo info a private emitter to parent object
42
69
  * @export
@@ -86,6 +113,10 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
86
113
  (0, _defineProperty2.default)(_this, "resources", void 0);
87
114
  (0, _defineProperty2.default)(_this, "mainSessionLocusCache", void 0);
88
115
  (0, _defineProperty2.default)(_this, "self", void 0);
116
+ (0, _defineProperty2.default)(_this, "hashTreeParser", void 0);
117
+ (0, _defineProperty2.default)(_this, "hashTreeObjectId2ParticipantId", void 0);
118
+ // mapping of hash tree object ids to participant ids
119
+ (0, _defineProperty2.default)(_this, "classicVsHashTreeMismatchMetricCounter", 0);
89
120
  _this.parsedLocus = {
90
121
  states: []
91
122
  };
@@ -95,11 +126,13 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
95
126
  _this.meetingId = meetingId;
96
127
  _this.updateMeeting = updateMeeting;
97
128
  _this.locusParser = new _parser.default();
129
+ _this.hashTreeObjectId2ParticipantId = new _map.default();
98
130
  return _this;
99
131
  }
100
132
 
101
133
  /**
102
134
  * Does a Locus sync. It tries to get the latest delta DTO or if it can't, it falls back to getting the full Locus DTO.
135
+ * WARNING: This function must not be used for hash tree based Locus meetings.
103
136
  *
104
137
  * @param {Meeting} meeting
105
138
  * @param {boolean} isLocusUrlChanged
@@ -307,30 +340,380 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
307
340
  }
308
341
 
309
342
  /**
310
- * @param {Object} locus
343
+ * Creates the HashTreeParser instance.
344
+ * @param {Object} initial locus data
345
+ * @returns {void}
346
+ */
347
+ }, {
348
+ key: "createHashTreeParser",
349
+ value: function createHashTreeParser(_ref) {
350
+ var initialLocus = _ref.initialLocus;
351
+ return new _hashTreeParser.default({
352
+ initialLocus: initialLocus,
353
+ webexRequest: this.webex.request.bind(this.webex),
354
+ locusInfoUpdateCallback: this.updateFromHashTree.bind(this),
355
+ debugId: "HT-".concat(this.meetingId.substring(0, 4))
356
+ });
357
+ }
358
+
359
+ /**
360
+ * @param {Object} data - data to initialize locus info with. It may be from a join or GET /loci response or from a Mercury event that triggers a creation of meeting object
311
361
  * @returns {undefined}
312
362
  * @memberof LocusInfo
313
363
  */
314
364
  }, {
315
365
  key: "initialSetup",
316
- value: function initialSetup(locus) {
317
- this.updateLocusCache(locus);
318
- this.onFullLocus(locus);
366
+ value: (function () {
367
+ var _initialSetup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(data) {
368
+ var _data$locus, _data$locus$links, _data$locus$links$res, _data$locus$links$res2;
369
+ var _data$hashTreeMessage, _selfObject$data, selfObject, _data$locus2, _data$locus2$self, _t;
370
+ return _regenerator.default.wrap(function (_context) {
371
+ while (1) switch (_context.prev = _context.next) {
372
+ case 0:
373
+ _t = data.trigger;
374
+ _context.next = _t === 'locus-message' ? 1 : _t === 'join-response' ? 6 : _t === 'get-loci-response' ? 7 : 10;
375
+ break;
376
+ case 1:
377
+ if (!data.hashTreeMessage) {
378
+ _context.next = 4;
379
+ break;
380
+ }
381
+ // we need the SELF object to be in the received message, because it contains visibleDataSets
382
+ // and these are needed to initialize all the hash trees
383
+ selfObject = (_data$hashTreeMessage = data.hashTreeMessage.locusStateElements) === null || _data$hashTreeMessage === void 0 ? void 0 : _data$hashTreeMessage.find(function (el) {
384
+ return (0, _hashTreeParser.isSelf)(el);
385
+ });
386
+ if (selfObject !== null && selfObject !== void 0 && (_selfObject$data = selfObject.data) !== null && _selfObject$data !== void 0 && _selfObject$data.visibleDataSets) {
387
+ _context.next = 2;
388
+ break;
389
+ }
390
+ _loggerProxy.default.logger.warn("Locus-info:index#initialSetup --> cannot initialize HashTreeParser, SELF object with visibleDataSets is missing in the message");
391
+ throw new Error('SELF object with visibleDataSets is missing in the message');
392
+ case 2:
393
+ _loggerProxy.default.logger.info('Locus-info:index#initialSetup --> creating HashTreeParser from message');
394
+ // first create the HashTreeParser, but don't initialize it with any data yet
395
+ // pass just a fake locus that contains only the visibleDataSets
396
+ this.hashTreeParser = this.createHashTreeParser({
397
+ initialLocus: {
398
+ locus: {
399
+ self: {
400
+ visibleDataSets: selfObject.data.visibleDataSets
401
+ }
402
+ },
403
+ dataSets: [] // empty, because they will be populated in initializeFromMessage() call // dataSets: data.hashTreeMessage.dataSets,
404
+ }
405
+ });
319
406
 
320
- // Change it to true after it receives it first locus object
321
- this.emitChange = true;
322
- }
407
+ // now handle the message - that should populate all the visible datasets
408
+ _context.next = 3;
409
+ return this.hashTreeParser.initializeFromMessage(data.hashTreeMessage);
410
+ case 3:
411
+ _context.next = 5;
412
+ break;
413
+ case 4:
414
+ // "classic" Locus case, no hash trees involved
415
+ this.updateLocusCache(data.locus);
416
+ this.onFullLocus(data.locus, undefined);
417
+ case 5:
418
+ return _context.abrupt("continue", 10);
419
+ case 6:
420
+ this.updateLocusCache(data.locus);
421
+ this.onFullLocus(data.locus, undefined, data.dataSets);
422
+ return _context.abrupt("continue", 10);
423
+ case 7:
424
+ if (!((_data$locus = data.locus) !== null && _data$locus !== void 0 && (_data$locus$links = _data$locus.links) !== null && _data$locus$links !== void 0 && (_data$locus$links$res = _data$locus$links.resources) !== null && _data$locus$links$res !== void 0 && (_data$locus$links$res2 = _data$locus$links$res.visibleDataSets) !== null && _data$locus$links$res2 !== void 0 && _data$locus$links$res2.url)) {
425
+ _context.next = 9;
426
+ break;
427
+ }
428
+ _loggerProxy.default.logger.info('Locus-info:index#initialSetup --> creating HashTreeParser from get-loci-response');
429
+ // first create the HashTreeParser, but don't initialize it with any data yet
430
+ // pass just a fake locus that contains only the visibleDataSets
431
+ this.hashTreeParser = this.createHashTreeParser({
432
+ initialLocus: {
433
+ locus: {
434
+ self: {
435
+ visibleDataSets: (_data$locus2 = data.locus) === null || _data$locus2 === void 0 ? void 0 : (_data$locus2$self = _data$locus2.self) === null || _data$locus2$self === void 0 ? void 0 : _data$locus2$self.visibleDataSets
436
+ }
437
+ },
438
+ dataSets: [] // empty, because we don't have them yet
439
+ }
440
+ });
323
441
 
442
+ // now initialize all the data
443
+ _context.next = 8;
444
+ return this.hashTreeParser.initializeFromGetLociResponse(data.locus);
445
+ case 8:
446
+ _context.next = 10;
447
+ break;
448
+ case 9:
449
+ // "classic" Locus case, no hash trees involved
450
+ this.updateLocusCache(data.locus);
451
+ this.onFullLocus(data.locus, undefined);
452
+ case 10:
453
+ // Change it to true after it receives it first locus object
454
+ this.emitChange = true;
455
+ case 11:
456
+ case "end":
457
+ return _context.stop();
458
+ }
459
+ }, _callee, this);
460
+ }));
461
+ function initialSetup(_x) {
462
+ return _initialSetup.apply(this, arguments);
463
+ }
464
+ return initialSetup;
465
+ }()
324
466
  /**
325
467
  * Handles HTTP response from Locus API call.
326
468
  * @param {Meeting} meeting meeting object
327
469
  * @param {LocusApiResponseBody} responseBody body of the http response from Locus API call
328
470
  * @returns {void}
329
471
  */
472
+ )
330
473
  }, {
331
474
  key: "handleLocusAPIResponse",
332
475
  value: function handleLocusAPIResponse(meeting, responseBody) {
333
- this.handleLocusDelta(responseBody.locus, meeting);
476
+ if (this.hashTreeParser) {
477
+ if (!responseBody.dataSets) {
478
+ this.sendClassicVsHashTreeMismatchMetric(meeting, "expected hash tree dataSets in API response but they are missing");
479
+ // continuing as we can still manage without responseBody.dataSets, but this is very suspicious
480
+ }
481
+ _loggerProxy.default.logger.info('Locus-info:index#handleLocusAPIResponse --> passing Locus API response to HashTreeParser: ', responseBody);
482
+ // update the data in our hash trees
483
+ this.hashTreeParser.handleLocusUpdate(responseBody);
484
+ } else {
485
+ if (responseBody.dataSets) {
486
+ this.sendClassicVsHashTreeMismatchMetric(meeting, "unexpected hash tree dataSets in API response");
487
+ }
488
+ // classic Locus delta
489
+ this.handleLocusDelta(responseBody.locus, meeting);
490
+ }
491
+ }
492
+
493
+ /**
494
+ *
495
+ * @param {HashTreeObject} object data set object
496
+ * @param {any} locus
497
+ * @returns {void}
498
+ */
499
+ }, {
500
+ key: "updateLocusFromHashTreeObject",
501
+ value: function updateLocusFromHashTreeObject(object, locus) {
502
+ var type = object.htMeta.elementId.type.toLowerCase();
503
+ switch (type) {
504
+ case _types.ObjectType.locus:
505
+ {
506
+ if (!object.data) {
507
+ // not doing anything here, as we need Locus to always be there (at least some fields)
508
+ // and that's already taken care of in updateFromHashTree()
509
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object removed, version=".concat(object.htMeta.elementId.version));
510
+ return locus;
511
+ }
512
+ // replace the main locus
513
+
514
+ // The Locus object we receive from backend has empty participants array,
515
+ // and may have (although it shouldn't) other fields that are managed by other ObjectTypes
516
+ // like "fullState" or "info", so we're making sure to delete them here
517
+ var locusObjectFromData = object.data;
518
+ (0, _values.default)(_types.ObjectTypeToLocusKeyMap).forEach(function (locusDtoKey) {
519
+ delete locusObjectFromData[locusDtoKey];
520
+ });
521
+ locus = _objectSpread(_objectSpread({}, locus), locusObjectFromData);
522
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object updated to version=".concat(object.htMeta.elementId.version));
523
+ break;
524
+ }
525
+ case _types.ObjectType.mediaShare:
526
+ if (object.data) {
527
+ var _object$data$floor, _object$data$floor2, _object$data$floor2$b, _locus$mediaShares;
528
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> mediaShare id=".concat(object.htMeta.elementId.id, " name='").concat(object.data.name, "' updated ").concat(object.data.name === 'content' ? "floor=".concat((_object$data$floor = object.data.floor) === null || _object$data$floor === void 0 ? void 0 : _object$data$floor.disposition, ", ").concat((_object$data$floor2 = object.data.floor) === null || _object$data$floor2 === void 0 ? void 0 : (_object$data$floor2$b = _object$data$floor2.beneficiary) === null || _object$data$floor2$b === void 0 ? void 0 : _object$data$floor2$b.id) : '', " version=").concat(object.htMeta.elementId.version));
529
+ var existingMediaShare = (_locus$mediaShares = locus.mediaShares) === null || _locus$mediaShares === void 0 ? void 0 : _locus$mediaShares.find(function (ms) {
530
+ return ms.htMeta.elementId.id === object.htMeta.elementId.id;
531
+ });
532
+ if (existingMediaShare) {
533
+ (0, _assign.default)(existingMediaShare, object.data);
534
+ } else {
535
+ locus.mediaShares = locus.mediaShares || [];
536
+ locus.mediaShares.push(object.data);
537
+ }
538
+ } else {
539
+ var _locus$mediaShares2;
540
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> mediaShare id=".concat(object.htMeta.elementId.id, " removed, version=").concat(object.htMeta.elementId.version));
541
+ locus.mediaShares = (_locus$mediaShares2 = locus.mediaShares) === null || _locus$mediaShares2 === void 0 ? void 0 : _locus$mediaShares2.filter(function (ms) {
542
+ return ms.htMeta.elementId.id !== object.htMeta.elementId.id;
543
+ });
544
+ }
545
+ break;
546
+ case _types.ObjectType.participant:
547
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> participant id=".concat(object.htMeta.elementId.id, " ").concat(object.data ? 'updated' : 'removed', " version=").concat(object.htMeta.elementId.version));
548
+ if (object.data) {
549
+ if (!locus.participants) {
550
+ locus.participants = [];
551
+ }
552
+ var participantObject = object.data;
553
+ participantObject.htMeta = object.htMeta;
554
+ locus.participants.push(participantObject);
555
+ this.hashTreeObjectId2ParticipantId.set(object.htMeta.elementId.id, participantObject.id);
556
+ } else {
557
+ var participantId = this.hashTreeObjectId2ParticipantId.get(object.htMeta.elementId.id);
558
+ if (!locus.jsSdkMeta) {
559
+ locus.jsSdkMeta = {
560
+ removedParticipantIds: []
561
+ };
562
+ }
563
+ locus.jsSdkMeta.removedParticipantIds.push(participantId);
564
+ this.hashTreeObjectId2ParticipantId.delete(object.htMeta.elementId.id);
565
+ }
566
+ break;
567
+ case _types.ObjectType.info:
568
+ case _types.ObjectType.fullState:
569
+ case _types.ObjectType.self:
570
+ if (!object.data) {
571
+ // self without data is handled inside HashTreeParser and results in LocusInfoUpdateType.MEETING_ENDED, so we should never get here
572
+ // other types like info or fullstate - Locus should never send them without data
573
+ _loggerProxy.default.logger.warn("Locus-info:index#updateLocusFromHashTreeObject --> received ".concat(type, " object without data, this is not expected! version=").concat(object.htMeta.elementId.version));
574
+ } else {
575
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> ".concat(type, " object updated to version ").concat(object.htMeta.elementId.version));
576
+ var locusDtoKey = _types.ObjectTypeToLocusKeyMap[type];
577
+ locus[locusDtoKey] = object.data;
578
+ }
579
+ break;
580
+ default:
581
+ _loggerProxy.default.logger.warn("Locus-info:index#updateLocusFromHashTreeObject --> received unsupported object type ".concat(type));
582
+ break;
583
+ }
584
+ return locus;
585
+ }
586
+
587
+ /**
588
+ * Sends a metric when we receive something from Locus that uses hash trees while we
589
+ * expect classic deltas or the other way around.
590
+ * @param {Meeting} meeting
591
+ * @param {string} message
592
+ * @returns {void}
593
+ */
594
+ }, {
595
+ key: "sendClassicVsHashTreeMismatchMetric",
596
+ value: function sendClassicVsHashTreeMismatchMetric(meeting, message) {
597
+ _loggerProxy.default.logger.warn("Locus-info:index#sendClassicVsHashTreeMismatchMetric --> classic vs hash tree mismatch! ".concat(message));
598
+
599
+ // we don't want to flood the metrics system
600
+ if (this.classicVsHashTreeMismatchMetricCounter < 5) {
601
+ _metrics.default.sendBehavioralMetric(_constants2.default.LOCUS_CLASSIC_VS_HASH_TREE_MISMATCH, {
602
+ correlationId: meeting.correlationId,
603
+ message: message
604
+ });
605
+ this.classicVsHashTreeMismatchMetricCounter += 1;
606
+ }
607
+ }
608
+
609
+ /**
610
+ * Handles a hash tree message received from Locus.
611
+ *
612
+ * @param {Meeting} meeting - The meeting object
613
+ * @param {eventType} eventType - The event type
614
+ * @param {HashTreeMessage} message incoming hash tree message
615
+ * @returns {void}
616
+ */
617
+ }, {
618
+ key: "handleHashTreeMessage",
619
+ value: function handleHashTreeMessage(meeting, eventType, message) {
620
+ if (eventType !== _constants.LOCUSEVENT.HASH_TREE_DATA_UPDATED) {
621
+ this.sendClassicVsHashTreeMismatchMetric(meeting, "got ".concat(eventType, ", expected ").concat(_constants.LOCUSEVENT.HASH_TREE_DATA_UPDATED));
622
+ return;
623
+ }
624
+ this.hashTreeParser.handleMessage(message);
625
+ }
626
+
627
+ /**
628
+ * Callback registered with HashTreeParser to receive locus info updates.
629
+ * Updates our locus info based on the data parsed by the hash tree parser.
630
+ *
631
+ * @param {LocusInfoUpdateType} updateType - The type of update received.
632
+ * @param {Object} [data] - Additional data for the update, if applicable.
633
+ * @returns {void}
634
+ */
635
+ }, {
636
+ key: "updateFromHashTree",
637
+ value: function updateFromHashTree(updateType, data) {
638
+ var _this4 = this;
639
+ switch (updateType) {
640
+ case _hashTreeParser.LocusInfoUpdateType.OBJECTS_UPDATED:
641
+ {
642
+ // initialize our new locus
643
+ var locus = {
644
+ participants: [],
645
+ jsSdkMeta: {
646
+ removedParticipantIds: []
647
+ }
648
+ };
649
+
650
+ // first go over all the updates and check what happens with the main locus object
651
+ var locusObjectStateAfterUpdates = LocusObjectStateAfterUpdates.unchanged;
652
+ data.updatedObjects.forEach(function (object) {
653
+ if (object.htMeta.elementId.type.toLowerCase() === _types.ObjectType.locus) {
654
+ if (locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.updated) {
655
+ var _object$data;
656
+ // this code doesn't supported it right now,
657
+ // cases for "updated" followed by "removed", or multiple "updated" would need more handling
658
+ // but these should never happen
659
+ _loggerProxy.default.logger.warn("Locus-info:index#updateFromHashTree --> received multiple LOCUS objects in one update, this is unexpected!");
660
+ _metrics.default.sendBehavioralMetric(_constants2.default.LOCUS_HASH_TREE_UNSUPPORTED_OPERATION, {
661
+ locusUrl: ((_object$data = object.data) === null || _object$data === void 0 ? void 0 : _object$data.url) || _this4.url,
662
+ message: object.data ? 'multiple LOCUS object updates' : 'LOCUS object update followed by removal'
663
+ });
664
+ }
665
+ if (object.data) {
666
+ locusObjectStateAfterUpdates = LocusObjectStateAfterUpdates.updated;
667
+ } else {
668
+ locusObjectStateAfterUpdates = LocusObjectStateAfterUpdates.removed;
669
+ }
670
+ }
671
+ });
672
+
673
+ // if Locus object is unchanged or removed, we need to keep using the existing locus
674
+ // because the rest of the locusInfo code expects locus to always be present (with at least some of the fields)
675
+ // if it gets updated, we only need to have the fields that are not part of "locus" object (like "info" or "mediaShares")
676
+ // so that when Locus object gets updated, if the new one is missing some field, that field will
677
+ // be removed from our locusInfo
678
+ if (locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.unchanged || locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.removed) {
679
+ // copy over all of existing locus except participants
680
+ LocusDtoTopLevelKeys.forEach(function (key) {
681
+ if (key !== 'participants') {
682
+ locus[key] = (0, _lodash.cloneDeep)(_this4[key]);
683
+ }
684
+ });
685
+ } else {
686
+ // initialize only the fields that are not part of main "Locus" object
687
+ // (except participants, which need to stay empty - that means "no participant changes")
688
+ (0, _values.default)(_types.ObjectTypeToLocusKeyMap).forEach(function (locusDtoKey) {
689
+ if (locusDtoKey !== 'participants') {
690
+ locus[locusDtoKey] = (0, _lodash.cloneDeep)(_this4[locusDtoKey]);
691
+ }
692
+ });
693
+ }
694
+ _loggerProxy.default.logger.info("Locus-info:index#updateFromHashTree --> LOCUS object is ".concat(locusObjectStateAfterUpdates, ", all updates: ").concat((0, _stringify.default)(data.updatedObjects.map(function (o) {
695
+ return {
696
+ type: o.htMeta.elementId.type,
697
+ id: o.htMeta.elementId.id,
698
+ hasData: !!o.data
699
+ };
700
+ }))));
701
+ // now apply all the updates from the hash tree onto the locus
702
+ data.updatedObjects.forEach(function (object) {
703
+ locus = _this4.updateLocusFromHashTreeObject(object, locus);
704
+ });
705
+
706
+ // update our locus info with the new locus
707
+ this.onDeltaLocus(locus);
708
+ break;
709
+ }
710
+ case _hashTreeParser.LocusInfoUpdateType.MEETING_ENDED:
711
+ {
712
+ _loggerProxy.default.logger.info("Locus-info:index#updateFromHashTree --> received signal that meeting ended, destroying meeting ".concat(this.meetingId));
713
+ var meeting = this.webex.meetings.meetingCollection.get(this.meetingId);
714
+ this.webex.meetings.destroy(meeting, _constants.MEETING_REMOVED_REASON.SELF_REMOVED);
715
+ }
716
+ }
334
717
  }
335
718
 
336
719
  /**
@@ -342,37 +725,44 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
342
725
  }, {
343
726
  key: "parse",
344
727
  value: function parse(meeting, data) {
345
- // eslint-disable-next-line @typescript-eslint/no-shadow
346
- var eventType = data.eventType;
347
- var locus = this.getTheLocusToUpdate(data.locus);
348
- _loggerProxy.default.logger.info("Locus-info:index#parse --> received locus data: ".concat(eventType));
349
- locus.jsSdkMeta = {
350
- removedParticipantIds: []
351
- };
352
- switch (eventType) {
353
- case _constants.LOCUSEVENT.PARTICIPANT_JOIN:
354
- case _constants.LOCUSEVENT.PARTICIPANT_LEFT:
355
- case _constants.LOCUSEVENT.CONTROLS_UPDATED:
356
- case _constants.LOCUSEVENT.PARTICIPANT_AUDIO_MUTED:
357
- case _constants.LOCUSEVENT.PARTICIPANT_AUDIO_UNMUTED:
358
- case _constants.LOCUSEVENT.PARTICIPANT_VIDEO_MUTED:
359
- case _constants.LOCUSEVENT.PARTICIPANT_VIDEO_UNMUTED:
360
- case _constants.LOCUSEVENT.SELF_CHANGED:
361
- case _constants.LOCUSEVENT.PARTICIPANT_UPDATED:
362
- case _constants.LOCUSEVENT.PARTICIPANT_CONTROLS_UPDATED:
363
- case _constants.LOCUSEVENT.PARTICIPANT_ROLES_UPDATED:
364
- case _constants.LOCUSEVENT.PARTICIPANT_DECLINED:
365
- case _constants.LOCUSEVENT.FLOOR_GRANTED:
366
- case _constants.LOCUSEVENT.FLOOR_RELEASED:
367
- this.onFullLocus(locus, eventType);
368
- break;
369
- case _constants.LOCUSEVENT.DIFFERENCE:
370
- this.handleLocusDelta(locus, meeting);
371
- break;
372
- default:
373
- // Why will there be a event with no eventType ????
374
- // we may not need this, we can get full locus
375
- this.handleLocusDelta(locus, meeting);
728
+ if (this.hashTreeParser) {
729
+ this.handleHashTreeMessage(meeting, data.eventType, data.stateElementsMessage);
730
+ } else {
731
+ // eslint-disable-next-line @typescript-eslint/no-shadow
732
+ var eventType = data.eventType;
733
+ var locus = this.getTheLocusToUpdate(data.locus);
734
+ _loggerProxy.default.logger.info("Locus-info:index#parse --> received locus data: ".concat(eventType));
735
+ locus.jsSdkMeta = {
736
+ removedParticipantIds: []
737
+ };
738
+ switch (eventType) {
739
+ case _constants.LOCUSEVENT.PARTICIPANT_JOIN:
740
+ case _constants.LOCUSEVENT.PARTICIPANT_LEFT:
741
+ case _constants.LOCUSEVENT.CONTROLS_UPDATED:
742
+ case _constants.LOCUSEVENT.PARTICIPANT_AUDIO_MUTED:
743
+ case _constants.LOCUSEVENT.PARTICIPANT_AUDIO_UNMUTED:
744
+ case _constants.LOCUSEVENT.PARTICIPANT_VIDEO_MUTED:
745
+ case _constants.LOCUSEVENT.PARTICIPANT_VIDEO_UNMUTED:
746
+ case _constants.LOCUSEVENT.SELF_CHANGED:
747
+ case _constants.LOCUSEVENT.PARTICIPANT_UPDATED:
748
+ case _constants.LOCUSEVENT.PARTICIPANT_CONTROLS_UPDATED:
749
+ case _constants.LOCUSEVENT.PARTICIPANT_ROLES_UPDATED:
750
+ case _constants.LOCUSEVENT.PARTICIPANT_DECLINED:
751
+ case _constants.LOCUSEVENT.FLOOR_GRANTED:
752
+ case _constants.LOCUSEVENT.FLOOR_RELEASED:
753
+ this.onFullLocus(locus, eventType);
754
+ break;
755
+ case _constants.LOCUSEVENT.DIFFERENCE:
756
+ this.handleLocusDelta(locus, meeting);
757
+ break;
758
+ case _constants.LOCUSEVENT.HASH_TREE_DATA_UPDATED:
759
+ this.sendClassicVsHashTreeMismatchMetric(meeting, "got ".concat(eventType, ", expected classic events"));
760
+ break;
761
+ default:
762
+ // Why will there be a event with no eventType ????
763
+ // we may not need this, we can get full locus
764
+ this.handleLocusDelta(locus, meeting);
765
+ }
376
766
  }
377
767
  }
378
768
 
@@ -389,26 +779,99 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
389
779
  return this.emit(scope, eventName, args);
390
780
  }
391
781
 
782
+ /**
783
+ * Function for handling full locus when it's using hash trees (so not the "classic" one).
784
+ *
785
+ * @param {object} locus locus object
786
+ * @param {string} eventType locus event
787
+ * @param {DataSet[]} dataSets
788
+ * @returns {void}
789
+ */
790
+ }, {
791
+ key: "onFullLocusWithHashTrees",
792
+ value: function onFullLocusWithHashTrees(locus, eventType, dataSets) {
793
+ if (!this.hashTreeParser) {
794
+ _loggerProxy.default.logger.info("Locus-info:index#onFullLocus --> creating hash tree parser");
795
+ _loggerProxy.default.logger.info('Locus-info:index#onFullLocus --> dataSets:', dataSets, ' and locus:', locus);
796
+ this.hashTreeParser = this.createHashTreeParser({
797
+ initialLocus: {
798
+ locus: locus,
799
+ dataSets: dataSets
800
+ }
801
+ });
802
+ this.onFullLocusCommon(locus, eventType);
803
+ } else {
804
+ // in this case the Locus we're getting is not necessarily the full one
805
+ // so treat it like if we just got it in any api response
806
+
807
+ _loggerProxy.default.logger.info('Locus-info:index#onFullLocus --> hash tree parser already exists, handling it like a normal API response');
808
+ this.handleLocusAPIResponse(undefined, {
809
+ dataSets: dataSets,
810
+ locus: locus
811
+ });
812
+ }
813
+ }
814
+
815
+ /**
816
+ * Function for handling full locus when it's the "classic" one (not hash trees)
817
+ *
818
+ * @param {object} locus locus object
819
+ * @param {string} eventType locus event
820
+ * @returns {void}
821
+ */
822
+ }, {
823
+ key: "onFullLocusClassic",
824
+ value: function onFullLocusClassic(locus, eventType) {
825
+ if (!this.locusParser.isNewFullLocus(locus)) {
826
+ _loggerProxy.default.logger.info("Locus-info:index#onFullLocus --> ignoring old full locus DTO, eventType=".concat(eventType));
827
+ return;
828
+ }
829
+ this.onFullLocusCommon(locus, eventType);
830
+ }
831
+
392
832
  /**
393
833
  * updates the locus with full locus object
394
834
  * @param {object} locus locus object
395
- * @param {string} eventType particulat locus event
835
+ * @param {string} eventType locus event
836
+ * @param {DataSet[]} dataSets
396
837
  * @returns {object} null
397
838
  * @memberof LocusInfo
398
839
  */
399
840
  }, {
400
841
  key: "onFullLocus",
401
- value: function onFullLocus(locus, eventType) {
402
- var _locus$jsSdkMeta;
842
+ value: function onFullLocus(locus, eventType, dataSets) {
403
843
  if (!locus) {
404
844
  _loggerProxy.default.logger.error('Locus-info:index#onFullLocus --> object passed as argument was invalid, continuing.');
405
845
  }
406
- if (!this.locusParser.isNewFullLocus(locus)) {
407
- _loggerProxy.default.logger.info("Locus-info:index#onFullLocus --> ignoring old full locus DTO, eventType=".concat(eventType));
408
- return;
846
+ if (dataSets) {
847
+ // this is the new hashmap Locus DTO format (only applicable to webinars for now)
848
+ this.onFullLocusWithHashTrees(locus, eventType, dataSets);
849
+ } else {
850
+ this.onFullLocusClassic(locus, eventType);
409
851
  }
852
+ }
853
+
854
+ /**
855
+ * Common part of handling full locus, used by both classic and hash tree based locus handling
856
+ * @param {object} locus locus object
857
+ * @param {string} eventType locus event
858
+ * @returns {void}
859
+ */
860
+ }, {
861
+ key: "onFullLocusCommon",
862
+ value: function onFullLocusCommon(locus, eventType) {
863
+ var _this$participants,
864
+ _this5 = this,
865
+ _locus$jsSdkMeta;
410
866
  this.scheduledMeeting = locus.meeting || null;
411
867
  this.participants = locus.participants;
868
+ (_this$participants = this.participants) === null || _this$participants === void 0 ? void 0 : _this$participants.forEach(function (participant) {
869
+ var _participant$htMeta;
870
+ // participant.htMeta is set only for hash tree based locus
871
+ if ((_participant$htMeta = participant.htMeta) !== null && _participant$htMeta !== void 0 && _participant$htMeta.elementId.id) {
872
+ _this5.hashTreeObjectId2ParticipantId.set(participant.htMeta.elementId.id, participant.id);
873
+ }
874
+ });
412
875
  var isReplaceMembers = _controlsUtils.default.isNeedReplaceMembers(this.controls, locus.controls);
413
876
  this.updateLocusInfo(locus);
414
877
  this.updateParticipants(locus.participants, (_locus$jsSdkMeta = locus.jsSdkMeta) === null || _locus$jsSdkMeta === void 0 ? void 0 : _locus$jsSdkMeta.removedParticipantIds, isReplaceMembers);
@@ -1628,7 +2091,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1628
2091
  }, {
1629
2092
  key: "updateMainSessionLocusCache",
1630
2093
  value: function updateMainSessionLocusCache(mainLocus) {
1631
- var _this4 = this;
2094
+ var _this6 = this;
1632
2095
  if (!mainLocus) {
1633
2096
  return;
1634
2097
  }
@@ -1637,7 +2100,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1637
2100
  // shallow merge and do special merge for participants
1638
2101
  (0, _lodash.assignWith)(this.mainSessionLocusCache, locusClone, function (objValue, srcValue, key) {
1639
2102
  if (key === 'participants') {
1640
- return _this4.mergeParticipants(objValue, srcValue);
2103
+ return _this6.mergeParticipants(objValue, srcValue);
1641
2104
  }
1642
2105
  return srcValue || objValue;
1643
2106
  });