@webex/plugin-meetings 3.12.0-task-refactor.1 → 3.12.0-webex-services-ready.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +197 -0
  3. package/dist/aiEnableRequest/index.js.map +1 -0
  4. package/dist/aiEnableRequest/utils.js +36 -0
  5. package/dist/aiEnableRequest/utils.js.map +1 -0
  6. package/dist/annotation/index.js +14 -5
  7. package/dist/annotation/index.js.map +1 -1
  8. package/dist/breakouts/breakout.js +8 -3
  9. package/dist/breakouts/breakout.js.map +1 -1
  10. package/dist/breakouts/index.js +26 -2
  11. package/dist/breakouts/index.js.map +1 -1
  12. package/dist/common/errors/webex-errors.js +49 -5
  13. package/dist/common/errors/webex-errors.js.map +1 -1
  14. package/dist/config.js +9 -3
  15. package/dist/config.js.map +1 -1
  16. package/dist/constants.js +59 -10
  17. package/dist/constants.js.map +1 -1
  18. package/dist/controls-options-manager/constants.js +11 -1
  19. package/dist/controls-options-manager/constants.js.map +1 -1
  20. package/dist/controls-options-manager/index.js +67 -29
  21. package/dist/controls-options-manager/index.js.map +1 -1
  22. package/dist/controls-options-manager/util.js +91 -0
  23. package/dist/controls-options-manager/util.js.map +1 -1
  24. package/dist/hashTree/constants.js +34 -0
  25. package/dist/hashTree/constants.js.map +1 -0
  26. package/dist/hashTree/hashTree.js +533 -0
  27. package/dist/hashTree/hashTree.js.map +1 -0
  28. package/dist/hashTree/hashTreeParser.js +2068 -36
  29. package/dist/hashTree/hashTreeParser.js.map +1 -1
  30. package/dist/hashTree/types.js +13 -3
  31. package/dist/hashTree/types.js.map +1 -1
  32. package/dist/hashTree/utils.js +111 -0
  33. package/dist/hashTree/utils.js.map +1 -0
  34. package/dist/index.js +18 -2
  35. package/dist/index.js.map +1 -1
  36. package/dist/interceptors/constant.js +12 -0
  37. package/dist/interceptors/constant.js.map +1 -0
  38. package/dist/interceptors/dataChannelAuthToken.js +350 -0
  39. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  40. package/dist/interceptors/index.js +7 -0
  41. package/dist/interceptors/index.js.map +1 -1
  42. package/dist/interceptors/locusRetry.js +23 -8
  43. package/dist/interceptors/locusRetry.js.map +1 -1
  44. package/dist/interceptors/locusRouteToken.js +27 -5
  45. package/dist/interceptors/locusRouteToken.js.map +1 -1
  46. package/dist/interceptors/utils.js +27 -0
  47. package/dist/interceptors/utils.js.map +1 -0
  48. package/dist/interpretation/index.js +11 -2
  49. package/dist/interpretation/index.js.map +1 -1
  50. package/dist/interpretation/interpretation.types.js +7 -0
  51. package/dist/interpretation/interpretation.types.js.map +1 -0
  52. package/dist/interpretation/siLanguage.js +1 -1
  53. package/dist/locus-info/controlsUtils.js +11 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +896 -277
  56. package/dist/locus-info/index.js.map +1 -1
  57. package/dist/locus-info/infoUtils.js +36 -5
  58. package/dist/locus-info/infoUtils.js.map +1 -1
  59. package/dist/locus-info/selfUtils.js +1 -0
  60. package/dist/locus-info/selfUtils.js.map +1 -1
  61. package/dist/locus-info/types.js +19 -0
  62. package/dist/locus-info/types.js.map +1 -1
  63. package/dist/media/MediaConnectionAwaiter.js +72 -3
  64. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  65. package/dist/media/index.js +8 -2
  66. package/dist/media/index.js.map +1 -1
  67. package/dist/media/properties.js +5 -2
  68. package/dist/media/properties.js.map +1 -1
  69. package/dist/meeting/in-meeting-actions.js +11 -1
  70. package/dist/meeting/in-meeting-actions.js.map +1 -1
  71. package/dist/meeting/index.js +2075 -1096
  72. package/dist/meeting/index.js.map +1 -1
  73. package/dist/meeting/locusMediaRequest.js +229 -82
  74. package/dist/meeting/locusMediaRequest.js.map +1 -1
  75. package/dist/meeting/muteState.js +10 -1
  76. package/dist/meeting/muteState.js.map +1 -1
  77. package/dist/meeting/request.js +55 -2
  78. package/dist/meeting/request.js.map +1 -1
  79. package/dist/meeting/request.type.js.map +1 -1
  80. package/dist/meeting/util.js +168 -5
  81. package/dist/meeting/util.js.map +1 -1
  82. package/dist/meeting-info/meeting-info-v2.js +2 -2
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +369 -173
  85. package/dist/meetings/index.js.map +1 -1
  86. package/dist/meetings/meetings.types.js +6 -1
  87. package/dist/meetings/meetings.types.js.map +1 -1
  88. package/dist/meetings/request.js +39 -0
  89. package/dist/meetings/request.js.map +1 -1
  90. package/dist/meetings/util.js +127 -25
  91. package/dist/meetings/util.js.map +1 -1
  92. package/dist/member/index.js +20 -0
  93. package/dist/member/index.js.map +1 -1
  94. package/dist/member/types.js.map +1 -1
  95. package/dist/member/util.js +40 -0
  96. package/dist/member/util.js.map +1 -1
  97. package/dist/members/index.js +101 -43
  98. package/dist/members/index.js.map +1 -1
  99. package/dist/members/util.js +8 -1
  100. package/dist/members/util.js.map +1 -1
  101. package/dist/metrics/constants.js +11 -1
  102. package/dist/metrics/constants.js.map +1 -1
  103. package/dist/multistream/codec/constants.js +63 -0
  104. package/dist/multistream/codec/constants.js.map +1 -0
  105. package/dist/multistream/mediaRequestManager.js +64 -68
  106. package/dist/multistream/mediaRequestManager.js.map +1 -1
  107. package/dist/multistream/receiveSlot.js +9 -0
  108. package/dist/multistream/receiveSlot.js.map +1 -1
  109. package/dist/multistream/remoteMediaManager.js +11 -0
  110. package/dist/multistream/remoteMediaManager.js.map +1 -1
  111. package/dist/multistream/sendSlotManager.js +116 -2
  112. package/dist/multistream/sendSlotManager.js.map +1 -1
  113. package/dist/reachability/clusterReachability.js +171 -18
  114. package/dist/reachability/clusterReachability.js.map +1 -1
  115. package/dist/reachability/index.js +142 -94
  116. package/dist/reachability/index.js.map +1 -1
  117. package/dist/reachability/reachability.types.js +2 -0
  118. package/dist/reachability/reachability.types.js.map +1 -1
  119. package/dist/reachability/reachabilityPeerConnection.js +1 -1
  120. package/dist/reachability/reachabilityPeerConnection.js.map +1 -1
  121. package/dist/reachability/util.js +45 -0
  122. package/dist/reachability/util.js.map +1 -1
  123. package/dist/reactions/reactions.type.js.map +1 -1
  124. package/dist/reconnection-manager/index.js +0 -1
  125. package/dist/reconnection-manager/index.js.map +1 -1
  126. package/dist/recording-controller/index.js +1 -3
  127. package/dist/recording-controller/index.js.map +1 -1
  128. package/dist/types/aiEnableRequest/index.d.ts +5 -0
  129. package/dist/types/aiEnableRequest/utils.d.ts +2 -0
  130. package/dist/types/common/browser-detection.d.ts +1 -0
  131. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  132. package/dist/types/common/events/events-scope.d.ts +1 -0
  133. package/dist/types/common/events/events.d.ts +1 -0
  134. package/dist/types/config.d.ts +7 -2
  135. package/dist/types/constants.d.ts +35 -1
  136. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  137. package/dist/types/controls-options-manager/index.d.ts +16 -0
  138. package/dist/types/hashTree/constants.d.ts +11 -0
  139. package/dist/types/hashTree/hashTree.d.ts +136 -0
  140. package/dist/types/hashTree/hashTreeParser.d.ts +392 -14
  141. package/dist/types/hashTree/types.d.ts +20 -0
  142. package/dist/types/hashTree/utils.d.ts +40 -0
  143. package/dist/types/index.d.ts +4 -0
  144. package/dist/types/interceptors/constant.d.ts +5 -0
  145. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  146. package/dist/types/interceptors/index.d.ts +2 -1
  147. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  148. package/dist/types/interceptors/locusRouteToken.d.ts +2 -0
  149. package/dist/types/interceptors/utils.d.ts +1 -0
  150. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  151. package/dist/types/locus-info/index.d.ts +116 -51
  152. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  153. package/dist/types/locus-info/types.d.ts +48 -12
  154. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  155. package/dist/types/media/properties.d.ts +3 -1
  156. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  157. package/dist/types/meeting/index.d.ts +196 -15
  158. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  159. package/dist/types/meeting/request.d.ts +17 -1
  160. package/dist/types/meeting/request.type.d.ts +5 -0
  161. package/dist/types/meeting/util.d.ts +40 -0
  162. package/dist/types/meeting-info/util.d.ts +1 -0
  163. package/dist/types/meeting-info/utilv2.d.ts +1 -0
  164. package/dist/types/meetings/index.d.ts +34 -20
  165. package/dist/types/meetings/meetings.types.d.ts +15 -0
  166. package/dist/types/meetings/request.d.ts +14 -0
  167. package/dist/types/member/index.d.ts +2 -0
  168. package/dist/types/member/types.d.ts +5 -4
  169. package/dist/types/member/util.d.ts +14 -0
  170. package/dist/types/members/index.d.ts +15 -2
  171. package/dist/types/members/util.d.ts +1 -5
  172. package/dist/types/metrics/constants.d.ts +10 -0
  173. package/dist/types/multistream/codec/constants.d.ts +7 -0
  174. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  175. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  176. package/dist/types/reachability/clusterReachability.d.ts +33 -6
  177. package/dist/types/reachability/index.d.ts +10 -3
  178. package/dist/types/reachability/reachability.types.d.ts +7 -0
  179. package/dist/types/reachability/util.d.ts +17 -0
  180. package/dist/types/reactions/reactions.type.d.ts +4 -0
  181. package/dist/types/recording-controller/util.d.ts +5 -5
  182. package/dist/types/roap/index.d.ts +1 -1
  183. package/dist/types/webinar/utils.d.ts +6 -0
  184. package/dist/webinar/index.js +585 -164
  185. package/dist/webinar/index.js.map +1 -1
  186. package/dist/webinar/utils.js +25 -0
  187. package/dist/webinar/utils.js.map +1 -0
  188. package/package.json +26 -24
  189. package/src/aiEnableRequest/README.md +84 -0
  190. package/src/aiEnableRequest/index.ts +186 -0
  191. package/src/aiEnableRequest/utils.ts +25 -0
  192. package/src/annotation/index.ts +27 -7
  193. package/src/breakouts/breakout.ts +3 -1
  194. package/src/breakouts/index.ts +31 -0
  195. package/src/common/errors/webex-errors.ts +50 -3
  196. package/src/config.ts +7 -2
  197. package/src/constants.ts +49 -3
  198. package/src/controls-options-manager/constants.ts +14 -1
  199. package/src/controls-options-manager/index.ts +87 -28
  200. package/src/controls-options-manager/util.ts +81 -1
  201. package/src/hashTree/constants.ts +26 -0
  202. package/src/hashTree/hashTree.ts +480 -0
  203. package/src/hashTree/hashTreeParser.ts +1911 -29
  204. package/src/hashTree/types.ts +24 -1
  205. package/src/hashTree/utils.ts +98 -0
  206. package/src/index.ts +14 -1
  207. package/src/interceptors/constant.ts +6 -0
  208. package/src/interceptors/dataChannelAuthToken.ts +246 -0
  209. package/src/interceptors/index.ts +2 -1
  210. package/src/interceptors/locusRetry.ts +25 -4
  211. package/src/interceptors/locusRouteToken.ts +22 -5
  212. package/src/interceptors/utils.ts +16 -0
  213. package/src/interpretation/index.ts +29 -11
  214. package/src/interpretation/interpretation.types.ts +11 -0
  215. package/src/locus-info/controlsUtils.ts +20 -1
  216. package/src/locus-info/index.ts +958 -250
  217. package/src/locus-info/infoUtils.ts +41 -6
  218. package/src/locus-info/selfUtils.ts +1 -0
  219. package/src/locus-info/types.ts +51 -12
  220. package/src/media/MediaConnectionAwaiter.ts +62 -5
  221. package/src/media/index.ts +10 -1
  222. package/src/media/properties.ts +4 -1
  223. package/src/meeting/in-meeting-actions.ts +20 -0
  224. package/src/meeting/index.ts +1025 -146
  225. package/src/meeting/locusMediaRequest.ts +106 -6
  226. package/src/meeting/muteState.ts +10 -1
  227. package/src/meeting/request.ts +53 -0
  228. package/src/meeting/request.type.ts +6 -0
  229. package/src/meeting/util.ts +207 -7
  230. package/src/meeting-info/meeting-info-v2.ts +4 -2
  231. package/src/meetings/index.ts +307 -132
  232. package/src/meetings/meetings.types.ts +19 -0
  233. package/src/meetings/request.ts +43 -0
  234. package/src/meetings/util.ts +127 -13
  235. package/src/member/index.ts +20 -0
  236. package/src/member/types.ts +1 -0
  237. package/src/member/util.ts +41 -0
  238. package/src/members/index.ts +70 -7
  239. package/src/members/util.ts +12 -4
  240. package/src/metrics/constants.ts +11 -0
  241. package/src/multistream/codec/constants.ts +58 -0
  242. package/src/multistream/mediaRequestManager.ts +117 -76
  243. package/src/multistream/receiveSlot.ts +18 -0
  244. package/src/multistream/remoteMediaManager.ts +13 -0
  245. package/src/multistream/sendSlotManager.ts +97 -3
  246. package/src/reachability/clusterReachability.ts +156 -29
  247. package/src/reachability/index.ts +62 -17
  248. package/src/reachability/reachability.types.ts +11 -0
  249. package/src/reachability/reachabilityPeerConnection.ts +3 -1
  250. package/src/reachability/util.ts +36 -0
  251. package/src/reactions/reactions.type.ts +4 -0
  252. package/src/reconnection-manager/index.ts +0 -1
  253. package/src/recording-controller/index.ts +1 -2
  254. package/src/webinar/index.ts +448 -11
  255. package/src/webinar/utils.ts +16 -0
  256. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  257. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  258. package/test/unit/spec/annotation/index.ts +69 -7
  259. package/test/unit/spec/breakouts/breakout.ts +9 -3
  260. package/test/unit/spec/breakouts/index.ts +49 -0
  261. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  262. package/test/unit/spec/controls-options-manager/index.js +244 -29
  263. package/test/unit/spec/controls-options-manager/util.js +165 -0
  264. package/test/unit/spec/hashTree/hashTree.ts +721 -0
  265. package/test/unit/spec/hashTree/hashTreeParser.ts +5328 -0
  266. package/test/unit/spec/hashTree/utils.ts +264 -0
  267. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +406 -0
  268. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  269. package/test/unit/spec/interceptors/locusRouteToken.ts +44 -0
  270. package/test/unit/spec/interceptors/utils.ts +75 -0
  271. package/test/unit/spec/interpretation/index.ts +26 -4
  272. package/test/unit/spec/locus-info/controlsUtils.js +222 -52
  273. package/test/unit/spec/locus-info/index.js +2000 -171
  274. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  275. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  276. package/test/unit/spec/media/index.ts +92 -0
  277. package/test/unit/spec/media/properties.ts +12 -3
  278. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  279. package/test/unit/spec/meeting/index.js +2925 -209
  280. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  281. package/test/unit/spec/meeting/muteState.js +81 -0
  282. package/test/unit/spec/meeting/request.js +82 -0
  283. package/test/unit/spec/meeting/utils.js +595 -27
  284. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  285. package/test/unit/spec/meetings/index.js +1214 -75
  286. package/test/unit/spec/meetings/request.js +141 -0
  287. package/test/unit/spec/meetings/utils.js +453 -52
  288. package/test/unit/spec/member/index.js +35 -4
  289. package/test/unit/spec/member/util.js +154 -27
  290. package/test/unit/spec/members/index.js +216 -0
  291. package/test/unit/spec/members/request.js +37 -1
  292. package/test/unit/spec/members/utils.js +63 -0
  293. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  294. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  295. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  296. package/test/unit/spec/reachability/clusterReachability.ts +125 -1
  297. package/test/unit/spec/reachability/index.ts +154 -49
  298. package/test/unit/spec/reachability/util.ts +31 -0
  299. package/test/unit/spec/reconnection-manager/index.js +4 -8
  300. package/test/unit/spec/recording-controller/index.js +9 -8
  301. package/test/unit/spec/webinar/index.ts +837 -39
  302. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -1,35 +1,40 @@
1
1
  "use strict";
2
2
 
3
3
  var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
4
- var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
5
- var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
4
+ var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
5
+ var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
6
+ var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
7
+ var _Array$isArray2 = require("@babel/runtime-corejs2/core-js/array/is-array");
8
+ var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
6
9
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
7
10
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
8
11
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
9
12
  var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
10
13
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
11
- var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
12
- var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
13
- var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
14
- var _Array$isArray2 = require("@babel/runtime-corejs2/core-js/array/is-array");
14
+ var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
15
15
  var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
16
16
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
17
17
  _Object$defineProperty(exports, "__esModule", {
18
18
  value: true
19
19
  });
20
+ exports.createLocusFromHashTreeMessage = createLocusFromHashTreeMessage;
20
21
  exports.default = void 0;
22
+ exports.findMeetingForHashTreeMessage = findMeetingForHashTreeMessage;
21
23
  var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
22
- var _map = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
23
- var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
24
- var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
25
- var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
26
24
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
25
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
27
26
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
28
27
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
29
28
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
30
29
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
31
30
  var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
32
31
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
32
+ var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
33
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
34
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
35
+ var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
36
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
37
+ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
33
38
  var _lodash = require("lodash");
34
39
  var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
35
40
  var _eventsScope = _interopRequireDefault(require("../common/events/events-scope"));
@@ -44,23 +49,192 @@ var _mediaSharesUtils = _interopRequireDefault(require("./mediaSharesUtils"));
44
49
  var _parser = _interopRequireDefault(require("./parser"));
45
50
  var _metrics = _interopRequireDefault(require("../metrics"));
46
51
  var _constants2 = _interopRequireDefault(require("../metrics/constants"));
47
- var _hashTreeParser = _interopRequireWildcard(require("../hashTree/hashTreeParser"));
52
+ var _hashTreeParser2 = _interopRequireWildcard(require("../hashTree/hashTreeParser"));
48
53
  var _types = require("../hashTree/types");
49
- 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); }
54
+ var _utils = require("../hashTree/utils");
55
+ var _util = _interopRequireDefault(require("../meetings/util"));
56
+ 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 _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); }
57
+ 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)); }
58
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
59
+ function ownKeys(e, r) { var t = _Object$keys2(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; }
60
+ 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; }
50
61
  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; } } }; }
51
62
  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; } }
52
63
  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; }
53
- 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; }
54
- 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; }
55
- 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)); }
56
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
57
- var LocusDtoTopLevelKeys = ['controls', 'fullState', 'host', 'info', 'links', 'mediaShares', 'meetings', 'participants', 'replaces', 'self', 'sequence', 'syncUrl', 'url', 'htMeta' // only exists when hash trees are used
64
+ // list of top level keys in Locus DTO relevant for Hash Tree DTOs processing
65
+ // it does not contain fields specific to classic Locus DTOs like sequence or baseSequence
66
+ var LocusDtoTopLevelKeys = ['controls', 'fullState', 'embeddedApps', 'host', 'info', 'links', 'mediaShares', 'meetings', 'participants', 'replaces', 'self', 'sequence', 'syncUrl', 'url', 'htMeta' // only exists when hash trees are used
58
67
  ];
68
+ // when we invoke APIs on the whole Locus like "mute all" backend returns the whole Locus in the response like this
69
+
59
70
  var LocusObjectStateAfterUpdates = {
60
71
  unchanged: 'unchanged',
61
72
  removed: 'removed',
62
73
  updated: 'updated'
63
74
  };
75
+ /**
76
+ * Gets the replacement information
77
+ *
78
+ * @param {any} self - "self" object from Locus DTO
79
+ * @param {string} deviceUrl - The URL of the specified device
80
+ * @returns {any} The replace information if available, otherwise undefined
81
+ */
82
+ function getReplaceInfoFromSelf(self, deviceUrl) {
83
+ if (self) {
84
+ var _device$replaces;
85
+ var device = _util.default.getThisDevice({
86
+ self: self
87
+ }, deviceUrl);
88
+ if ((device === null || device === void 0 ? void 0 : (_device$replaces = device.replaces) === null || _device$replaces === void 0 ? void 0 : _device$replaces.length) > 0) {
89
+ return device.replaces[0];
90
+ }
91
+ }
92
+ return undefined;
93
+ }
94
+
95
+ /**
96
+ * Finds a meeting by its locus URL in meeting collection. It checks all HashTreeParsers of all meetings in the collection.
97
+ *
98
+ * @param {MeetingCollection} meetingCollection - The collection of meetings to search
99
+ * @param {string} locusUrl - The locus URL to search for
100
+ * @returns {any} The meeting if found, otherwise undefined
101
+ */
102
+ function findLocusUrlInAnyHashTreeParser(meetingCollection, locusUrl) {
103
+ for (var _i = 0, _arr = (0, _values.default)(meetingCollection.getAll()); _i < _arr.length; _i++) {
104
+ var _meeting$locusInfo, _meeting$locusInfo$ha;
105
+ var meeting = _arr[_i];
106
+ if (meeting !== null && meeting !== void 0 && (_meeting$locusInfo = meeting.locusInfo) !== null && _meeting$locusInfo !== void 0 && (_meeting$locusInfo$ha = _meeting$locusInfo.hashTreeParsers) !== null && _meeting$locusInfo$ha !== void 0 && _meeting$locusInfo$ha.has(locusUrl)) {
107
+ return meeting;
108
+ }
109
+ }
110
+ return undefined;
111
+ }
112
+
113
+ /**
114
+ * Finds a meeting for a given hash tree message.
115
+ *
116
+ * @param {HashTreeMessage} message - The hash tree message to find the meeting for
117
+ * @param {MeetingCollection} meetingCollection - The collection of meetings to search
118
+ * @returns {any} The meeting if found, otherwise undefined
119
+ */
120
+ function findMeetingForHashTreeMessage(message, meetingCollection) {
121
+ var _message$locusStateEl, _message$locusStateEl2;
122
+ if (!message) {
123
+ return undefined;
124
+ }
125
+ var foundMeeting = findLocusUrlInAnyHashTreeParser(meetingCollection, message.locusUrl);
126
+ if (foundMeeting) {
127
+ return foundMeeting;
128
+ }
129
+
130
+ // if we haven't found anything, it may mean that message has a new locusUrl
131
+ // check if it indicates that it replaces some existing current locusUrl (this is indicated in "self")
132
+ var self = (_message$locusStateEl = message.locusStateElements) === null || _message$locusStateEl === void 0 ? void 0 : (_message$locusStateEl2 = _message$locusStateEl.find(function (el) {
133
+ return (0, _utils.isSelf)(el);
134
+ })) === null || _message$locusStateEl2 === void 0 ? void 0 : _message$locusStateEl2.data;
135
+ var replaces = getReplaceInfoFromSelf(self, self === null || self === void 0 ? void 0 : self.deviceUrl);
136
+ if (replaces !== null && replaces !== void 0 && replaces.locusUrl) {
137
+ foundMeeting = findLocusUrlInAnyHashTreeParser(meetingCollection, replaces.locusUrl);
138
+ return foundMeeting;
139
+ }
140
+ return undefined;
141
+ }
142
+
143
+ /**
144
+ * Creates a locus object from the objects received in a hash tree message. It usually will be
145
+ * incomplete, because hash tree messages only contain the parts of locus that have changed,
146
+ * and some updates come separately over Mercury or LLM in separate messages.
147
+ *
148
+ * @param {HashTreeMessage} message hash tree message to created the locus from
149
+ * @returns {Object} the created locus object and metadata if present
150
+ */
151
+ function createLocusFromHashTreeMessage(message) {
152
+ var locus = {
153
+ participants: [],
154
+ url: message.locusUrl
155
+ };
156
+ var metadata;
157
+ if (!message.locusStateElements) {
158
+ return {
159
+ locus: locus,
160
+ metadata: metadata
161
+ };
162
+ }
163
+ var _iterator = _createForOfIteratorHelper(message.locusStateElements),
164
+ _step;
165
+ try {
166
+ var _loop = function _loop() {
167
+ var element = _step.value;
168
+ if (!element.data) {
169
+ // eslint-disable-next-line no-continue
170
+ return 1; // continue
171
+ }
172
+ var type = element.htMeta.elementId.type.toLowerCase();
173
+ switch (type) {
174
+ case _types.ObjectType.locus:
175
+ {
176
+ // spread locus object data onto the top level, but remove keys managed by other ObjectTypes
177
+ var locusObjectData = _objectSpread({}, element.data);
178
+ (0, _values.default)(_types.ObjectTypeToLocusKeyMap).forEach(function (locusDtoKey) {
179
+ delete locusObjectData[locusDtoKey];
180
+ });
181
+ (0, _assign.default)(locus, locusObjectData);
182
+ break;
183
+ }
184
+ case _types.ObjectType.participant:
185
+ locus.participants.push(element.data);
186
+ break;
187
+ case _types.ObjectType.mediaShare:
188
+ if (!locus.mediaShares) {
189
+ locus.mediaShares = [];
190
+ }
191
+ locus.mediaShares.push(element.data);
192
+ break;
193
+ case _types.ObjectType.embeddedApp:
194
+ if (!locus.embeddedApps) {
195
+ locus.embeddedApps = [];
196
+ }
197
+ locus.embeddedApps.push(element.data);
198
+ break;
199
+ case _types.ObjectType.control:
200
+ if (!locus.controls) {
201
+ locus.controls = {};
202
+ }
203
+ (0, _assign.default)(locus.controls, element.data);
204
+ break;
205
+ case _types.ObjectType.links:
206
+ case _types.ObjectType.info:
207
+ case _types.ObjectType.fullState:
208
+ case _types.ObjectType.self:
209
+ {
210
+ var locusDtoKey = _types.ObjectTypeToLocusKeyMap[type];
211
+ locus[locusDtoKey] = element.data;
212
+ break;
213
+ }
214
+ case _types.ObjectType.metadata:
215
+ // metadata is not part of Locus DTO
216
+ metadata = _objectSpread(_objectSpread({}, element.data), {}, {
217
+ htMeta: element.htMeta
218
+ });
219
+ break;
220
+ default:
221
+ break;
222
+ }
223
+ };
224
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
225
+ if (_loop()) continue;
226
+ }
227
+ } catch (err) {
228
+ _iterator.e(err);
229
+ } finally {
230
+ _iterator.f();
231
+ }
232
+ return {
233
+ locus: locus,
234
+ metadata: metadata
235
+ };
236
+ }
237
+
64
238
  /**
65
239
  * @description LocusInfo extends ChildEmitter to convert locusInfo info a private emitter to parent object
66
240
  * @export
@@ -89,10 +263,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
89
263
  (0, _defineProperty2.default)(_this, "aclUrl", void 0);
90
264
  (0, _defineProperty2.default)(_this, "baseSequence", void 0);
91
265
  (0, _defineProperty2.default)(_this, "created", void 0);
92
- (0, _defineProperty2.default)(_this, "identities", void 0);
93
- (0, _defineProperty2.default)(_this, "membership", void 0);
94
266
  (0, _defineProperty2.default)(_this, "participants", void 0);
95
- (0, _defineProperty2.default)(_this, "participantsUrl", void 0);
96
267
  (0, _defineProperty2.default)(_this, "replaces", void 0);
97
268
  (0, _defineProperty2.default)(_this, "scheduledMeeting", void 0);
98
269
  (0, _defineProperty2.default)(_this, "sequence", void 0);
@@ -104,13 +275,11 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
104
275
  (0, _defineProperty2.default)(_this, "info", void 0);
105
276
  (0, _defineProperty2.default)(_this, "roles", void 0);
106
277
  (0, _defineProperty2.default)(_this, "mediaShares", void 0);
107
- (0, _defineProperty2.default)(_this, "replace", void 0);
108
278
  (0, _defineProperty2.default)(_this, "url", void 0);
109
- (0, _defineProperty2.default)(_this, "services", void 0);
110
- (0, _defineProperty2.default)(_this, "resources", void 0);
279
+ (0, _defineProperty2.default)(_this, "links", void 0);
111
280
  (0, _defineProperty2.default)(_this, "mainSessionLocusCache", void 0);
112
281
  (0, _defineProperty2.default)(_this, "self", void 0);
113
- (0, _defineProperty2.default)(_this, "hashTreeParser", void 0);
282
+ (0, _defineProperty2.default)(_this, "hashTreeParsers", void 0);
114
283
  (0, _defineProperty2.default)(_this, "hashTreeObjectId2ParticipantId", void 0);
115
284
  // mapping of hash tree object ids to participant ids
116
285
  (0, _defineProperty2.default)(_this, "classicVsHashTreeMismatchMetricCounter", 0);
@@ -123,6 +292,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
123
292
  _this.meetingId = meetingId;
124
293
  _this.updateMeeting = updateMeeting;
125
294
  _this.locusParser = new _parser.default();
295
+ _this.hashTreeParsers = new _map.default();
126
296
  _this.hashTreeObjectId2ParticipantId = new _map.default();
127
297
  return _this;
128
298
  }
@@ -210,7 +380,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
210
380
  // in some cases Locus might return us full DTO even when we asked for a delta
211
381
  _loggerProxy.default.logger.info('Locus-info:index#doLocusSync --> got full DTO when we asked for delta');
212
382
  }
213
- meeting.locusInfo.onFullLocus(res.body);
383
+ meeting.locusInfo.onFullLocus('classic Locus sync', res.body);
214
384
  }).catch(function (e) {
215
385
  _loggerProxy.default.logger.info("Locus-info:index#doLocusSync --> getLocusDTO succeeded but failed to handle result, locus parser will resume but not all data may be synced (".concat(e.toString(), ")"));
216
386
  _metrics.default.sendBehavioralMetric(_constants2.default.LOCUS_SYNC_HANDLING_FAILED, {
@@ -296,17 +466,13 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
296
466
  }, {
297
467
  key: "init",
298
468
  value: function init() {
299
- var _locus$links, _locus$links2;
300
469
  var locus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
301
470
  this.created = locus.created || null;
302
471
  this.scheduledMeeting = locus.meeting || null;
303
- this.participantsUrl = locus.participantsUrl || null;
304
472
  this.replaces = locus.replaces || null;
305
473
  this.aclUrl = locus.aclUrl || null;
306
474
  this.baseSequence = locus.baseSequence || null;
307
475
  this.sequence = locus.sequence || null;
308
- this.membership = locus.membership || null;
309
- this.identities = locus.identities || null;
310
476
  this.participants = locus.participants || null;
311
477
 
312
478
  /**
@@ -326,47 +492,88 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
326
492
  this.updateControls(locus.controls, locus.self);
327
493
  this.updateLocusUrl(locus.url, _controlsUtils.default.isMainSessionDTO(locus));
328
494
  this.updateFullState(locus.fullState);
329
- this.updateMeetingInfo(locus.info);
495
+ this.updateMeetingInfo(locus.info, locus.self);
330
496
  this.updateEmbeddedApps(locus.embeddedApps);
331
497
  // self and participants generate sipUrl for 1:1 meeting
332
498
  this.updateSelf(locus.self);
333
499
  this.updateHostInfo(locus.host);
334
500
  this.updateMediaShares(locus.mediaShares);
335
- this.updateServices((_locus$links = locus.links) === null || _locus$links === void 0 ? void 0 : _locus$links.services);
336
- this.updateResources((_locus$links2 = locus.links) === null || _locus$links2 === void 0 ? void 0 : _locus$links2.resources);
501
+ this.updateLinks(locus.links);
337
502
  }
338
503
 
339
504
  /**
340
- * Creates the HashTreeParser instance.
341
- * @param {Object} initial locus data
342
- * @returns {void}
505
+ * Creates a HashTreeParser instance for a given locusUrl and stores it in the map.
506
+ * @param {Object} params
507
+ * @param {string} params.locusUrl - the locus URL used as the map key
508
+ * @param {Object} params.initialLocus - initial locus data
509
+ * @param {Object} params.metadata - hash tree metadata
510
+ * @param {string} params.replacedAt - timestamp from Locus indicating when the replacement happened
511
+ * @returns {HashTreeParser} the newly created parser
343
512
  */
344
513
  }, {
345
514
  key: "createHashTreeParser",
346
515
  value: function createHashTreeParser(_ref) {
347
- var initialLocus = _ref.initialLocus;
348
- return new _hashTreeParser.default({
516
+ var _locusUrl$split, _locusUrl$split$pop, _this$webex$config$me;
517
+ var locusUrl = _ref.locusUrl,
518
+ initialLocus = _ref.initialLocus,
519
+ metadata = _ref.metadata,
520
+ replacedAt = _ref.replacedAt;
521
+ var parser = new _hashTreeParser2.default({
349
522
  initialLocus: initialLocus,
523
+ metadata: metadata,
350
524
  webexRequest: this.webex.request.bind(this.webex),
351
- locusInfoUpdateCallback: this.updateFromHashTree.bind(this),
352
- debugId: "HT-".concat(this.meetingId.substring(0, 4))
525
+ locusInfoUpdateCallback: this.updateFromHashTree.bind(this, locusUrl),
526
+ debugId: "HT-".concat((_locusUrl$split = locusUrl.split('/')) === null || _locusUrl$split === void 0 ? void 0 : (_locusUrl$split$pop = _locusUrl$split.pop()) === null || _locusUrl$split$pop === void 0 ? void 0 : _locusUrl$split$pop.substring(0, 4)),
527
+ excludedDataSets: (_this$webex$config$me = this.webex.config.meetings.locus) === null || _this$webex$config$me === void 0 ? void 0 : _this$webex$config$me.excludedDataSets
528
+ });
529
+
530
+ // When a new HashTreeParser is created, previous one should be stopped.
531
+ // Locus will only be sending us updates for the current one.
532
+ var _iterator2 = _createForOfIteratorHelper(this.hashTreeParsers),
533
+ _step2;
534
+ try {
535
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
536
+ var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
537
+ existingLocusUrl = _step2$value[0],
538
+ existingEntry = _step2$value[1];
539
+ if (existingEntry.parser.state !== 'stopped') {
540
+ existingEntry.parser.stop();
541
+ if (replacedAt) {
542
+ existingEntry.replacedAt = replacedAt;
543
+ } else {
544
+ _loggerProxy.default.logger.warn("Locus-info:index#createHashTreeParser --> no replacedAt timestamp provided for new HashTreeParser with locusUrl ".concat(locusUrl, ", replacing ").concat(existingLocusUrl));
545
+ }
546
+ }
547
+ }
548
+ } catch (err) {
549
+ _iterator2.e(err);
550
+ } finally {
551
+ _iterator2.f();
552
+ }
553
+ this.hashTreeParsers.set(locusUrl, {
554
+ parser: parser,
555
+ initializedFromHashTree: false
353
556
  });
557
+ this.hashTreeObjectId2ParticipantId.clear();
558
+ return parser;
354
559
  }
355
560
 
356
561
  /**
357
562
  * @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
563
+ * @param {Function} [onLocusSynced] - optional callback that will be called at the end of initial setup, when locus info is fully synced. It will be called with the full locus snapshot as an argument (which may be null if we haven't received any full locus DTOs during the initial setup, for example in case we receive only hash tree messages without full locus DTOs)
358
564
  * @returns {undefined}
359
565
  * @memberof LocusInfo
360
566
  */
361
567
  }, {
362
568
  key: "initialSetup",
363
569
  value: (function () {
364
- var _initialSetup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(data) {
570
+ var _initialSetup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(data, onLocusSynced) {
365
571
  var _data$locus, _data$locus$links, _data$locus$links$res, _data$locus$links$res2;
366
- var _data$hashTreeMessage, _selfObject$data, selfObject, _data$locus2, _data$locus2$self, _t;
572
+ var initialFullLocus, _data$hashTreeMessage, _metadataObject$data, metadataObject, hashTreeParser, _hashTreeParser, _t;
367
573
  return _regenerator.default.wrap(function (_context) {
368
574
  while (1) switch (_context.prev = _context.next) {
369
575
  case 0:
576
+ initialFullLocus = null;
370
577
  _t = data.trigger;
371
578
  _context.next = _t === 'locus-message' ? 1 : _t === 'join-response' ? 6 : _t === 'get-loci-response' ? 7 : 10;
372
579
  break;
@@ -375,47 +582,50 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
375
582
  _context.next = 4;
376
583
  break;
377
584
  }
378
- // we need the SELF object to be in the received message, because it contains visibleDataSets
585
+ // we need the Metadata object to be in the received message, because it contains visibleDataSets
379
586
  // and these are needed to initialize all the hash trees
380
- selfObject = (_data$hashTreeMessage = data.hashTreeMessage.locusStateElements) === null || _data$hashTreeMessage === void 0 ? void 0 : _data$hashTreeMessage.find(function (el) {
381
- return (0, _hashTreeParser.isSelf)(el);
587
+ metadataObject = (_data$hashTreeMessage = data.hashTreeMessage.locusStateElements) === null || _data$hashTreeMessage === void 0 ? void 0 : _data$hashTreeMessage.find(function (el) {
588
+ return (0, _utils.isMetadata)(el);
382
589
  });
383
- if (selfObject !== null && selfObject !== void 0 && (_selfObject$data = selfObject.data) !== null && _selfObject$data !== void 0 && _selfObject$data.visibleDataSets) {
590
+ if (metadataObject !== null && metadataObject !== void 0 && (_metadataObject$data = metadataObject.data) !== null && _metadataObject$data !== void 0 && _metadataObject$data.visibleDataSets) {
384
591
  _context.next = 2;
385
592
  break;
386
593
  }
387
- _loggerProxy.default.logger.warn("Locus-info:index#initialSetup --> cannot initialize HashTreeParser, SELF object with visibleDataSets is missing in the message");
388
- throw new Error('SELF object with visibleDataSets is missing in the message');
594
+ // this is a common case (not an error)
595
+ // it happens for example after we leave the meeting and still get some heartbeats or delayed messages
596
+ _loggerProxy.default.logger.info("Locus-info:index#initialSetup --> cannot initialize HashTreeParser, Metadata object with visibleDataSets is missing in the message");
597
+
598
+ // throw so that handleLocusEvent() catches it and destroys the partially created meeting object
599
+ throw new Error('Metadata object with visibleDataSets is missing in the message');
389
600
  case 2:
390
601
  _loggerProxy.default.logger.info('Locus-info:index#initialSetup --> creating HashTreeParser from message');
391
602
  // first create the HashTreeParser, but don't initialize it with any data yet
392
- // pass just a fake locus that contains only the visibleDataSets
393
- this.hashTreeParser = this.createHashTreeParser({
603
+ hashTreeParser = this.createHashTreeParser({
604
+ locusUrl: data.hashTreeMessage.locusUrl,
394
605
  initialLocus: {
395
- locus: {
396
- self: {
397
- visibleDataSets: selfObject.data.visibleDataSets
398
- }
399
- },
400
- dataSets: [] // empty, because they will be populated in initializeFromMessage() call // dataSets: data.hashTreeMessage.dataSets,
606
+ locus: null,
607
+ dataSets: data.hashTreeMessage.dataSets
608
+ },
609
+ metadata: {
610
+ htMeta: metadataObject.htMeta,
611
+ visibleDataSets: metadataObject.data.visibleDataSets
401
612
  }
402
- });
403
-
404
- // now handle the message - that should populate all the visible datasets
613
+ }); // now handle the message - that should populate all the visible datasets
405
614
  _context.next = 3;
406
- return this.hashTreeParser.initializeFromMessage(data.hashTreeMessage);
615
+ return hashTreeParser.initializeFromMessage(data.hashTreeMessage);
407
616
  case 3:
408
617
  _context.next = 5;
409
618
  break;
410
619
  case 4:
411
620
  // "classic" Locus case, no hash trees involved
412
621
  this.updateLocusCache(data.locus);
413
- this.onFullLocus(data.locus, undefined);
622
+ this.onFullLocus('classic locus message', data.locus, undefined);
414
623
  case 5:
415
624
  return _context.abrupt("continue", 10);
416
625
  case 6:
417
626
  this.updateLocusCache(data.locus);
418
- this.onFullLocus(data.locus, undefined, data.dataSets);
627
+ this.onFullLocus('join response', data.locus, undefined, data.dataSets, data.metadata);
628
+ initialFullLocus = data.locus;
419
629
  return _context.abrupt("continue", 10);
420
630
  case 7:
421
631
  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)) {
@@ -424,29 +634,33 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
424
634
  }
425
635
  _loggerProxy.default.logger.info('Locus-info:index#initialSetup --> creating HashTreeParser from get-loci-response');
426
636
  // first create the HashTreeParser, but don't initialize it with any data yet
427
- // pass just a fake locus that contains only the visibleDataSets
428
- this.hashTreeParser = this.createHashTreeParser({
637
+ _hashTreeParser = this.createHashTreeParser({
638
+ locusUrl: data.locus.url,
429
639
  initialLocus: {
430
- locus: {
431
- self: {
432
- 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
433
- }
434
- },
640
+ locus: null,
435
641
  dataSets: [] // empty, because we don't have them yet
436
- }
437
- });
438
-
439
- // now initialize all the data
642
+ },
643
+ metadata: null // get-loci-response doesn't contain Metadata object
644
+ }); // now initialize all the data
440
645
  _context.next = 8;
441
- return this.hashTreeParser.initializeFromGetLociResponse(data.locus);
646
+ return _hashTreeParser.initializeFromGetLociResponse(data.locus);
442
647
  case 8:
443
648
  _context.next = 10;
444
649
  break;
445
650
  case 9:
446
651
  // "classic" Locus case, no hash trees involved
447
652
  this.updateLocusCache(data.locus);
448
- this.onFullLocus(data.locus, undefined);
653
+ this.onFullLocus('classic get-loci-response', data.locus, undefined);
654
+ initialFullLocus = data.locus || null;
449
655
  case 10:
656
+ if (onLocusSynced) {
657
+ try {
658
+ onLocusSynced(initialFullLocus || this.getCurrentLocusSnapshot());
659
+ } catch (error) {
660
+ _loggerProxy.default.logger.warn("Locus-info:index#initialSetup --> onLocusSynced callback failed: ".concat(error));
661
+ }
662
+ }
663
+
450
664
  // Change it to true after it receives it first locus object
451
665
  this.emitChange = true;
452
666
  case 11:
@@ -455,37 +669,82 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
455
669
  }
456
670
  }, _callee, this);
457
671
  }));
458
- function initialSetup(_x) {
672
+ function initialSetup(_x, _x2) {
459
673
  return _initialSetup.apply(this, arguments);
460
674
  }
461
675
  return initialSetup;
462
676
  }()
677
+ /**
678
+ * Builds a full locus DTO snapshot from current internal locus state.
679
+ *
680
+ * @returns {LocusDTO}
681
+ */
682
+ )
683
+ }, {
684
+ key: "getCurrentLocusSnapshot",
685
+ value: function getCurrentLocusSnapshot() {
686
+ var _this4 = this;
687
+ var locus = {};
688
+ LocusDtoTopLevelKeys.forEach(function (key) {
689
+ var value = _this4[key];
690
+ if (value !== undefined && value !== null) {
691
+ locus[key] = (0, _lodash.cloneDeep)(value);
692
+ }
693
+ });
694
+ if (!(0, _isArray.default)(locus.participants)) {
695
+ locus.participants = [];
696
+ }
697
+ return locus;
698
+ }
699
+
463
700
  /**
464
701
  * Handles HTTP response from Locus API call.
465
702
  * @param {Meeting} meeting meeting object
466
703
  * @param {LocusApiResponseBody} responseBody body of the http response from Locus API call
467
704
  * @returns {void}
468
705
  */
469
- )
470
706
  }, {
471
707
  key: "handleLocusAPIResponse",
472
708
  value: function handleLocusAPIResponse(meeting, responseBody) {
473
- if (this.hashTreeParser) {
474
- // API responses with hash tree are a bit problematic and not fully confirmed how they will look like
475
- // we don't really need them, because all updates are guaranteed to come via Mercury or LLM messages anyway
476
- // so it's OK to skip them for now
477
- _loggerProxy.default.logger.info('Locus-info:index#handleLocusAPIResponse: skipping handling of API http response with hashTreeParser');
478
- } else {
479
- if (responseBody.dataSets) {
480
- this.sendClassicVsHashTreeMismatchMetric(meeting, "unexpected hash tree dataSets in API response");
709
+ var _responseBody$locus;
710
+ var isWrapped = 'locus' in responseBody;
711
+ var locusUrl = isWrapped ? (_responseBody$locus = responseBody.locus) === null || _responseBody$locus === void 0 ? void 0 : _responseBody$locus.url : responseBody.url;
712
+ var hashTreeParserEntry = locusUrl && this.hashTreeParsers.get(locusUrl);
713
+ var locus = isWrapped ? responseBody.locus : responseBody;
714
+ if (this.hashTreeParsers.size > 0) {
715
+ // We are in hash tree mode. Check if we need to create/reactivate a parser for this locusUrl.
716
+ if (!hashTreeParserEntry || hashTreeParserEntry.parser.state === 'stopped') {
717
+ if (!locusUrl) {
718
+ _loggerProxy.default.logger.warn('Locus-info:index#handleLocusAPIResponse --> API response has no locusUrl, cannot handle hash tree parser switch');
719
+ return;
720
+ }
721
+ this.handleHashTreeParserSwitchForAPIResponse(locusUrl, locus);
722
+ return;
723
+ }
724
+
725
+ // Active parser found - pass the API response to it
726
+ if (isWrapped) {
727
+ // update the data in our hash trees
728
+ hashTreeParserEntry.parser.handleLocusUpdate(responseBody);
729
+ } else {
730
+ // LocusDTO without wrapper - pass it through as if it had no dataSets nor metadata
731
+ hashTreeParserEntry.parser.handleLocusUpdate({
732
+ locus: responseBody
733
+ });
481
734
  }
482
- // classic Locus delta
483
- this.handleLocusDelta(responseBody.locus, meeting);
735
+ return;
484
736
  }
737
+
738
+ // No hash tree parsers - classic Locus mode
739
+ if (isWrapped && responseBody.dataSets) {
740
+ this.sendClassicVsHashTreeMismatchMetric(meeting, "unexpected hash tree dataSets in API response");
741
+ }
742
+
743
+ // classic Locus delta
744
+ this.handleLocusDelta(locus, meeting);
485
745
  }
486
746
 
487
747
  /**
488
- *
489
748
  * @param {HashTreeObject} object data set object
490
749
  * @param {any} locus
491
750
  * @returns {void}
@@ -493,32 +752,42 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
493
752
  }, {
494
753
  key: "updateLocusFromHashTreeObject",
495
754
  value: function updateLocusFromHashTreeObject(object, locus) {
755
+ var _this5 = this,
756
+ _locus$self;
496
757
  var type = object.htMeta.elementId.type.toLowerCase();
758
+ var addParticipantObject = function addParticipantObject(obj) {
759
+ if (!locus.participants) {
760
+ locus.participants = [];
761
+ }
762
+ locus.participants.push(obj.data);
763
+ _this5.hashTreeObjectId2ParticipantId.set(obj.htMeta.elementId.id, obj.data.id);
764
+ };
497
765
  switch (type) {
498
766
  case _types.ObjectType.locus:
499
767
  {
500
768
  if (!object.data) {
501
769
  // not doing anything here, as we need Locus to always be there (at least some fields)
502
770
  // and that's already taken care of in updateFromHashTree()
503
- _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object removed");
771
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object removed, version=".concat(object.htMeta.elementId.version));
504
772
  return locus;
505
773
  }
506
774
  // replace the main locus
507
775
 
508
- // The Locus object we receive from backend has empty participants, so removing them to avoid it overriding the ones in our current locus object
509
- // Also, other fields like mediaShares are managed by other ObjectType updates, so removing them too
510
- // BTW, it also doesn't have "self". That's OK as it won't override existing locus.self and also existing SDK code can handle that missing self in Locus updates
776
+ // The Locus object we receive from backend has empty participants array,
777
+ // and may have (although it shouldn't) other fields that are managed by other ObjectTypes
778
+ // like "fullState" or "info", so we're making sure to delete them here
511
779
  var locusObjectFromData = object.data;
512
- delete locusObjectFromData.participants;
513
- delete locusObjectFromData.mediaShares;
780
+ (0, _values.default)(_types.ObjectTypeToLocusKeyMap).forEach(function (locusDtoKey) {
781
+ delete locusObjectFromData[locusDtoKey];
782
+ });
514
783
  locus = _objectSpread(_objectSpread({}, locus), locusObjectFromData);
515
- _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object updated");
784
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object updated to version=".concat(object.htMeta.elementId.version));
516
785
  break;
517
786
  }
518
787
  case _types.ObjectType.mediaShare:
519
788
  if (object.data) {
520
789
  var _object$data$floor, _object$data$floor2, _object$data$floor2$b, _locus$mediaShares;
521
- _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) : ''));
790
+ _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));
522
791
  var existingMediaShare = (_locus$mediaShares = locus.mediaShares) === null || _locus$mediaShares === void 0 ? void 0 : _locus$mediaShares.find(function (ms) {
523
792
  return ms.htMeta.elementId.id === object.htMeta.elementId.id;
524
793
  });
@@ -530,22 +799,37 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
530
799
  }
531
800
  } else {
532
801
  var _locus$mediaShares2;
533
- _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> mediaShare id=".concat(object.htMeta.elementId.id, " removed"));
802
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> mediaShare id=".concat(object.htMeta.elementId.id, " removed, version=").concat(object.htMeta.elementId.version));
534
803
  locus.mediaShares = (_locus$mediaShares2 = locus.mediaShares) === null || _locus$mediaShares2 === void 0 ? void 0 : _locus$mediaShares2.filter(function (ms) {
535
804
  return ms.htMeta.elementId.id !== object.htMeta.elementId.id;
536
805
  });
537
806
  }
538
807
  break;
539
- case _types.ObjectType.participant:
540
- _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> participant id=".concat(object.htMeta.elementId.id, " ").concat(object.data ? 'updated' : 'removed'));
808
+ case _types.ObjectType.embeddedApp:
541
809
  if (object.data) {
542
- if (!locus.participants) {
543
- locus.participants = [];
810
+ var _locus$embeddedApps;
811
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> embeddedApp id=".concat(object.htMeta.elementId.id, " url='").concat(object.data.url, "' updated version=").concat(object.htMeta.elementId.version, ":"), object.data);
812
+ var existingEmbeddedApp = (_locus$embeddedApps = locus.embeddedApps) === null || _locus$embeddedApps === void 0 ? void 0 : _locus$embeddedApps.find(function (ms) {
813
+ return ms.htMeta.elementId.id === object.htMeta.elementId.id;
814
+ });
815
+ if (existingEmbeddedApp) {
816
+ (0, _assign.default)(existingEmbeddedApp, object.data);
817
+ } else {
818
+ locus.embeddedApps = locus.embeddedApps || [];
819
+ locus.embeddedApps.push(object.data);
544
820
  }
545
- var participantObject = object.data;
546
- participantObject.htMeta = object.htMeta;
547
- locus.participants.push(participantObject);
548
- this.hashTreeObjectId2ParticipantId.set(object.htMeta.elementId.id, participantObject.id);
821
+ } else {
822
+ var _locus$embeddedApps2;
823
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> embeddedApp id=".concat(object.htMeta.elementId.id, " removed, version=").concat(object.htMeta.elementId.version));
824
+ locus.embeddedApps = (_locus$embeddedApps2 = locus.embeddedApps) === null || _locus$embeddedApps2 === void 0 ? void 0 : _locus$embeddedApps2.filter(function (ms) {
825
+ return ms.htMeta.elementId.id !== object.htMeta.elementId.id;
826
+ });
827
+ }
828
+ break;
829
+ case _types.ObjectType.participant:
830
+ _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));
831
+ if (object.data) {
832
+ addParticipantObject(object);
549
833
  } else {
550
834
  var participantId = this.hashTreeObjectId2ParticipantId.get(object.htMeta.elementId.id);
551
835
  if (!locus.jsSdkMeta) {
@@ -556,15 +840,64 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
556
840
  locus.jsSdkMeta.removedParticipantIds.push(participantId);
557
841
  this.hashTreeObjectId2ParticipantId.delete(object.htMeta.elementId.id);
558
842
  }
843
+ // Create self from the participant if it matches self identity and is being moved.
844
+ // We need this, because participant update comes in LLM message often before the self update from Mercury.
845
+ // Other parts of the code detect move only by looking at self, while some other parts of the SDK/webapp code
846
+ // look at participant for roles etc, so if participant is updated but not self, then it looks like we our lost roles temporarily
847
+ // (until self is updated)
848
+ // This will be fixed properly in SPARK-790239
849
+ if (object.data && object.data.identity === ((_locus$self = locus.self) === null || _locus$self === void 0 ? void 0 : _locus$self.identity) && object.data.state === 'LEFT' && object.data.reason === 'MOVED') {
850
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> FOUND a match for MOVED self in participant object ".concat(object.htMeta.elementId.id));
851
+ (0, _assign.default)(locus[_types.ObjectTypeToLocusKeyMap[_types.ObjectType.self]], object.data);
852
+ }
559
853
  break;
854
+ case _types.ObjectType.control:
855
+ if (object.data) {
856
+ (0, _keys.default)(object.data).forEach(function (controlKey) {
857
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> control ".concat(controlKey, " updated:"), object.data[controlKey]);
858
+ if (!locus.controls) {
859
+ locus.controls = {};
860
+ }
861
+ locus.controls[controlKey] = object.data[controlKey];
862
+ });
863
+ } else {
864
+ _loggerProxy.default.logger.warn("Locus-info:index#updateLocusFromHashTreeObject --> control object update without data - this is not expected!");
865
+ }
866
+ break;
867
+ case _types.ObjectType.links:
868
+ case _types.ObjectType.info:
869
+ case _types.ObjectType.fullState:
560
870
  case _types.ObjectType.self:
561
871
  if (!object.data) {
562
872
  // self without data is handled inside HashTreeParser and results in LocusInfoUpdateType.MEETING_ENDED, so we should never get here
563
- _loggerProxy.default.logger.warn("Locus-info:index#updateLocusFromHashTreeObject --> received SELF object without data, this is not expected!");
564
- return locus;
873
+ // all other types info, fullstate, etc - Locus should never send them without data
874
+ // but we end up with this method being called without the data for them when the main dataset is removed from visible datasets list
875
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> received ".concat(type, " object without data, version=").concat(object.htMeta.elementId.version));
876
+ } else {
877
+ var _locus$info, _object$data$controls, _object$data$controls2, _object$data$controls3;
878
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> ".concat(type, " object updated to version ").concat(object.htMeta.elementId.version));
879
+ if (type === _types.ObjectType.self) {
880
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> self data: removed=".concat(object.data.removed, " state=").concat(object.data.state, " reason=").concat(object.data.reason));
881
+ }
882
+ var locusDtoKey = _types.ObjectTypeToLocusKeyMap[type];
883
+ locus[locusDtoKey] = object.data;
884
+
885
+ /* Hash tree based webinar attendees don't receive a Participant object for themselves from Locus,
886
+ but a lot of existing code in SDK and web app expects a member object for self to exist,
887
+ so whenever SELF changes for a webinar attendee, we copy it into a participant object.
888
+ We can do it, because SELF has always all the same properties as a participant object.
889
+ */
890
+ if (type === _types.ObjectType.self && (_locus$info = locus.info) !== null && _locus$info !== void 0 && _locus$info.isWebinar && (_object$data$controls = object.data.controls) !== null && _object$data$controls !== void 0 && (_object$data$controls2 = _object$data$controls.role) !== null && _object$data$controls2 !== void 0 && (_object$data$controls3 = _object$data$controls2.roles) !== null && _object$data$controls3 !== void 0 && _object$data$controls3.find(function (r) {
891
+ return r.type === _constants.SELF_ROLES.ATTENDEE && r.hasRole;
892
+ })) {
893
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> webinar attendee: creating participant object from self");
894
+ addParticipantObject(object);
895
+ }
565
896
  }
566
- _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> SELF object updated");
567
- locus.self = object.data;
897
+ break;
898
+ case _types.ObjectType.metadata:
899
+ _loggerProxy.default.logger.info("Locus-info:index#updateLocusFromHashTreeObject --> metadata object updated to version ".concat(object.htMeta.elementId.version));
900
+ // we don't use hash tree metadata right now for anything, it's mainly used internally by HashTreeParser
568
901
  break;
569
902
  default:
570
903
  _loggerProxy.default.logger.warn("Locus-info:index#updateLocusFromHashTreeObject --> received unsupported object type ".concat(type));
@@ -595,6 +928,136 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
595
928
  }
596
929
  }
597
930
 
931
+ /**
932
+ * Helper that handles the common logic for reactivating a stopped HashTreeParser when
933
+ * a newer "replaces" is detected. Used by both the message and API response parser switch methods.
934
+ *
935
+ * @param {string} callerName - name of the calling method, used in log messages
936
+ * @param {string} locusUrl - the locus URL of the stopped parser
937
+ * @param {HashTreeParserEntry} stoppedEntry - the stopped parser entry
938
+ * @param {ReplacesInfo} replaces - replacement info extracted from self
939
+ * @param {Function} resumeCallback - callback to invoke after reactivation to resume the parser
940
+ * @returns {void}
941
+ */
942
+ }, {
943
+ key: "resumeStoppedParser",
944
+ value: function resumeStoppedParser(callerName, locusUrl, stoppedEntry, replaces, resumeCallback) {
945
+ // this check is just for typescript, it should never happen, replaces should always be defined
946
+ if (!replaces) {
947
+ _loggerProxy.default.logger.info("Locus-info:index#".concat(callerName, " --> received data for stopped HashTreeParser with locusUrl ").concat(locusUrl, ", but no replaces info provided, so not re-activating the parser"));
948
+ return;
949
+ }
950
+ if (replaces.replacedAt <= (stoppedEntry.replacedAt || '')) {
951
+ _loggerProxy.default.logger.info("Locus-info:index#".concat(callerName, " --> received data for stopped HashTreeParser with locusUrl ").concat(locusUrl, ", but replaces info provided is not newer, so not re-activating the parser"));
952
+ return;
953
+ }
954
+ _loggerProxy.default.logger.info("Locus-info:index#".concat(callerName, " --> reactivating HashTreeParser for locusUrl=").concat(locusUrl, ", which replaces ").concat(replaces.locusUrl));
955
+ var replacedEntry = this.hashTreeParsers.get(replaces.locusUrl);
956
+ if (replacedEntry) {
957
+ replacedEntry.replacedAt = replaces.replacedAt;
958
+ replacedEntry.parser.stop();
959
+ } else {
960
+ _loggerProxy.default.logger.warn("Locus-info:index#".concat(callerName, " --> the parser that is supposed to be replaced with the currently reactivated parser is not found, locusUrl=").concat(replaces.locusUrl));
961
+ }
962
+ stoppedEntry.initializedFromHashTree = false;
963
+ this.hashTreeObjectId2ParticipantId.clear();
964
+ resumeCallback();
965
+ }
966
+
967
+ /**
968
+ * Handles an API response whose locusUrl doesn't match any active HashTreeParser
969
+ * (either no entry exists, or the existing entry is stopped).
970
+ * Creates a new parser or reactivates a stopped one using initializeFromGetLociResponse.
971
+ *
972
+ * @param {string} locusUrl - the locus URL from the API response
973
+ * @param {LocusDTO} locus - the locus DTO from the API response
974
+ * @returns {void}
975
+ */
976
+ }, {
977
+ key: "handleHashTreeParserSwitchForAPIResponse",
978
+ value: function handleHashTreeParserSwitchForAPIResponse(locusUrl, locus) {
979
+ var entry = this.hashTreeParsers.get(locusUrl);
980
+ var replaces = getReplaceInfoFromSelf(locus.self,
981
+ // @ts-ignore
982
+ this.webex.internal.device.url);
983
+ if (!entry) {
984
+ _loggerProxy.default.logger.info("Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> no parser for locusUrl ".concat(locusUrl, ", creating a new one"));
985
+ var parser = this.createHashTreeParser({
986
+ locusUrl: locusUrl,
987
+ initialLocus: {
988
+ locus: null,
989
+ dataSets: []
990
+ },
991
+ metadata: null,
992
+ replacedAt: replaces === null || replaces === void 0 ? void 0 : replaces.replacedAt
993
+ });
994
+ parser.initializeFromGetLociResponse(locus);
995
+ return;
996
+ }
997
+ if (entry.parser.state !== 'stopped') {
998
+ _loggerProxy.default.logger.warn("Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> unexpected parser state \"".concat(entry.parser.state, "\" for locusUrl ").concat(locusUrl));
999
+ return;
1000
+ }
1001
+ this.resumeStoppedParser('handleHashTreeParserSwitchForAPIResponse', locusUrl, entry, replaces, function () {
1002
+ return entry.parser.resumeFromApiResponse(locus);
1003
+ });
1004
+ }
1005
+
1006
+ /**
1007
+ * Checks if the hash tree message should trigger a switch to a different HashTreeParser
1008
+ *
1009
+ * @param {HashTreeMessage} message incoming hash tree message
1010
+ * @returns {boolean} true if the message was handled as a parser switch, false otherwise
1011
+ */
1012
+ }, {
1013
+ key: "handleHashTreeParserSwitch",
1014
+ value: function handleHashTreeParserSwitch(message) {
1015
+ var _message$locusStateEl3, _message$locusStateEl4;
1016
+ var entry = this.hashTreeParsers.get(message.locusUrl);
1017
+ var self = (_message$locusStateEl3 = message.locusStateElements) === null || _message$locusStateEl3 === void 0 ? void 0 : (_message$locusStateEl4 = _message$locusStateEl3.find(function (el) {
1018
+ return (0, _utils.isSelf)(el);
1019
+ })) === null || _message$locusStateEl4 === void 0 ? void 0 : _message$locusStateEl4.data;
1020
+ var replaces = getReplaceInfoFromSelf(self,
1021
+ // @ts-ignore
1022
+ this.webex.internal.device.url);
1023
+ if (!entry) {
1024
+ var _message$locusStateEl5, _metadata$data, _metadata$data$visibl;
1025
+ // Metadata object that contains information about visible datasets is needed to initialize the HashTreeParser,
1026
+ // but it's buried inside the message, we need to find it and pass it to HashTreeParser constructor
1027
+ var metadata = (_message$locusStateEl5 = message.locusStateElements) === null || _message$locusStateEl5 === void 0 ? void 0 : _message$locusStateEl5.find(function (el) {
1028
+ return (0, _utils.isMetadata)(el);
1029
+ });
1030
+ if (metadata && ((_metadata$data = metadata.data) === null || _metadata$data === void 0 ? void 0 : (_metadata$data$visibl = _metadata$data.visibleDataSets) === null || _metadata$data$visibl === void 0 ? void 0 : _metadata$data$visibl.length) > 0) {
1031
+ _loggerProxy.default.logger.info("Locus-info:index#handleHashTreeParserSwitch --> no hash tree parser found for locusUrl ".concat(message.locusUrl, ", creating a new one"));
1032
+ var parser = this.createHashTreeParser({
1033
+ locusUrl: message.locusUrl,
1034
+ initialLocus: {
1035
+ locus: null,
1036
+ dataSets: message.dataSets
1037
+ },
1038
+ metadata: {
1039
+ htMeta: metadata.htMeta,
1040
+ visibleDataSets: metadata.data.visibleDataSets
1041
+ },
1042
+ replacedAt: replaces === null || replaces === void 0 ? void 0 : replaces.replacedAt
1043
+ });
1044
+
1045
+ // handle the message with the new parser
1046
+ parser.handleMessage(message);
1047
+ }
1048
+ return true;
1049
+ }
1050
+ if (entry.parser.state === 'stopped') {
1051
+ // the message matches a stopped parser, we need to check if maybe this is a new "replacement" and we need to re-activate the parser
1052
+ // this happens when you move from breakout A -> breakout B -> back to breakout A
1053
+ this.resumeStoppedParser('handleHashTreeParserSwitch', message.locusUrl, entry, replaces, function () {
1054
+ return entry.parser.resumeFromMessage(message);
1055
+ });
1056
+ return true;
1057
+ }
1058
+ return false;
1059
+ }
1060
+
598
1061
  /**
599
1062
  * Handles a hash tree message received from Locus.
600
1063
  *
@@ -610,35 +1073,109 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
610
1073
  this.sendClassicVsHashTreeMismatchMetric(meeting, "got ".concat(eventType, ", expected ").concat(_constants.LOCUSEVENT.HASH_TREE_DATA_UPDATED));
611
1074
  return;
612
1075
  }
613
- this.hashTreeParser.handleMessage(message);
1076
+ var parserSwitched = this.handleHashTreeParserSwitch(message);
1077
+ if (parserSwitched) {
1078
+ return;
1079
+ }
1080
+ var entry = this.hashTreeParsers.get(message.locusUrl);
1081
+
1082
+ // the check is just for typescript, the case of no entry in hashTreeParsers is handled in handleHashTreeParserSwitch() above
1083
+ if (entry) {
1084
+ entry.parser.handleMessage(message);
1085
+ }
614
1086
  }
615
1087
 
1088
+ /**
1089
+ * Triggers a sync of all hash tree datasets for all hash tree parsers associated with this meeting.
1090
+ * The syncs are executed sequentially within each parser.
1091
+ *
1092
+ * @param {Object} [options={}] - Options for syncing
1093
+ * @param {boolean} [options.onlyLLM=false] - Whether to sync only LLM based data sets
1094
+ * @returns {Promise<void>}
1095
+ */
1096
+ }, {
1097
+ key: "syncAllHashTreeDatasets",
1098
+ value: (function () {
1099
+ var _syncAllHashTreeDatasets = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
1100
+ var options,
1101
+ _iterator3,
1102
+ _step3,
1103
+ _step3$value,
1104
+ entry,
1105
+ _args2 = arguments,
1106
+ _t2;
1107
+ return _regenerator.default.wrap(function (_context2) {
1108
+ while (1) switch (_context2.prev = _context2.next) {
1109
+ case 0:
1110
+ options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
1111
+ _iterator3 = _createForOfIteratorHelper(this.hashTreeParsers);
1112
+ _context2.prev = 1;
1113
+ _iterator3.s();
1114
+ case 2:
1115
+ if ((_step3 = _iterator3.n()).done) {
1116
+ _context2.next = 4;
1117
+ break;
1118
+ }
1119
+ _step3$value = (0, _slicedToArray2.default)(_step3.value, 2), entry = _step3$value[1];
1120
+ if (!entry.parser) {
1121
+ _context2.next = 3;
1122
+ break;
1123
+ }
1124
+ _context2.next = 3;
1125
+ return entry.parser.syncAllDatasets(options);
1126
+ case 3:
1127
+ _context2.next = 2;
1128
+ break;
1129
+ case 4:
1130
+ _context2.next = 6;
1131
+ break;
1132
+ case 5:
1133
+ _context2.prev = 5;
1134
+ _t2 = _context2["catch"](1);
1135
+ _iterator3.e(_t2);
1136
+ case 6:
1137
+ _context2.prev = 6;
1138
+ _iterator3.f();
1139
+ return _context2.finish(6);
1140
+ case 7:
1141
+ case "end":
1142
+ return _context2.stop();
1143
+ }
1144
+ }, _callee2, this, [[1, 5, 6, 7]]);
1145
+ }));
1146
+ function syncAllHashTreeDatasets() {
1147
+ return _syncAllHashTreeDatasets.apply(this, arguments);
1148
+ }
1149
+ return syncAllHashTreeDatasets;
1150
+ }()
616
1151
  /**
617
1152
  * Callback registered with HashTreeParser to receive locus info updates.
618
1153
  * Updates our locus info based on the data parsed by the hash tree parser.
619
1154
  *
620
- * @param {LocusInfoUpdateType} updateType - The type of update received.
621
- * @param {Object} [data] - Additional data for the update, if applicable.
1155
+ * @param {string} locusUrl - the locus URL for which the update is received
1156
+ * @param {LocusInfoUpdate} update - Details about the update.
622
1157
  * @returns {void}
623
1158
  */
1159
+ )
624
1160
  }, {
625
1161
  key: "updateFromHashTree",
626
- value: function updateFromHashTree(updateType, data) {
627
- var _this4 = this;
628
- switch (updateType) {
629
- case _hashTreeParser.LocusInfoUpdateType.OBJECTS_UPDATED:
1162
+ value: function updateFromHashTree(locusUrl, update) {
1163
+ var _this6 = this;
1164
+ switch (update.updateType) {
1165
+ case _hashTreeParser2.LocusInfoUpdateType.OBJECTS_UPDATED:
630
1166
  {
631
1167
  // initialize our new locus
632
1168
  var locus = {
633
1169
  participants: [],
634
1170
  jsSdkMeta: {
635
- removedParticipantIds: []
1171
+ removedParticipantIds: [],
1172
+ forceReplaceMembers: false
636
1173
  }
637
1174
  };
638
1175
 
639
1176
  // first go over all the updates and check what happens with the main locus object
640
1177
  var locusObjectStateAfterUpdates = LocusObjectStateAfterUpdates.unchanged;
641
- data.updatedObjects.forEach(function (object) {
1178
+ update.updatedObjects.forEach(function (object) {
642
1179
  if (object.htMeta.elementId.type.toLowerCase() === _types.ObjectType.locus) {
643
1180
  if (locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.updated) {
644
1181
  var _object$data;
@@ -647,7 +1184,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
647
1184
  // but these should never happen
648
1185
  _loggerProxy.default.logger.warn("Locus-info:index#updateFromHashTree --> received multiple LOCUS objects in one update, this is unexpected!");
649
1186
  _metrics.default.sendBehavioralMetric(_constants2.default.LOCUS_HASH_TREE_UNSUPPORTED_OPERATION, {
650
- locusUrl: ((_object$data = object.data) === null || _object$data === void 0 ? void 0 : _object$data.url) || _this4.url,
1187
+ locusUrl: ((_object$data = object.data) === null || _object$data === void 0 ? void 0 : _object$data.url) || _this6.url,
651
1188
  message: object.data ? 'multiple LOCUS object updates' : 'LOCUS object update followed by removal'
652
1189
  });
653
1190
  }
@@ -658,41 +1195,76 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
658
1195
  }
659
1196
  }
660
1197
  });
661
-
1198
+ var hashTreeParserEntry = this.hashTreeParsers.get(locusUrl);
1199
+ if (!hashTreeParserEntry) {
1200
+ _loggerProxy.default.logger.warn("Locus-info:index#updateFromHashTree --> no HashTreeParser found for locusUrl ".concat(locusUrl, " when trying to apply updates from hash tree"));
1201
+ return;
1202
+ }
1203
+ if (!hashTreeParserEntry.initializedFromHashTree) {
1204
+ // this is the first time we're getting an update for this locusUrl,
1205
+ // so it's probably a move to/from breakout. We need to start from a clean state,
1206
+ // so empty locus and we rely on Locus giving us sufficient data in the updates to populate it.
1207
+ _loggerProxy.default.logger.info("Locus-info:index#updateFromHashTree --> first INITIAL update for locusUrl ".concat(locusUrl, ", starting from empty state"));
1208
+ hashTreeParserEntry.initializedFromHashTree = true;
1209
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1210
+ locus.jsSdkMeta.forceReplaceMembers = true;
1211
+ } else if (
662
1212
  // if Locus object is unchanged or removed, we need to keep using the existing locus
663
1213
  // because the rest of the locusInfo code expects locus to always be present (with at least some of the fields)
664
- // if it gets updated, we don't need to do anything and we start with an empty one
665
- // so that when it gets updated, if the new one is missing some field, that field will
1214
+ // if it gets updated, we only need to have the fields that are not part of "locus" object (like "info" or "mediaShares")
1215
+ // so that when Locus object gets updated, if the new one is missing some field, that field will
666
1216
  // be removed from our locusInfo
667
- if (locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.unchanged || locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.removed) {
668
- // copy over existing locus
1217
+ locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.unchanged || locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.removed) {
1218
+ // copy over all of existing locus except participants
669
1219
  LocusDtoTopLevelKeys.forEach(function (key) {
670
1220
  if (key !== 'participants') {
671
- locus[key] = (0, _lodash.cloneDeep)(_this4[key]);
1221
+ locus[key] = (0, _lodash.cloneDeep)(_this6[key]);
1222
+ }
1223
+ });
1224
+ } else {
1225
+ // initialize only the fields that are not part of main "Locus" object
1226
+ // (except participants, which need to stay empty - that means "no participant changes")
1227
+ (0, _values.default)(_types.ObjectTypeToLocusKeyMap).forEach(function (locusDtoKey) {
1228
+ if (locusDtoKey !== 'participants') {
1229
+ locus[locusDtoKey] = (0, _lodash.cloneDeep)(_this6[locusDtoKey]);
672
1230
  }
673
1231
  });
674
1232
  }
675
- _loggerProxy.default.logger.info("Locus-info:index#updateFromHashTree --> LOCUS object is ".concat(locusObjectStateAfterUpdates, ", all updates: ").concat((0, _stringify.default)(data.updatedObjects.map(function (o) {
1233
+ _loggerProxy.default.logger.info("Locus-info:index#updateFromHashTree --> LOCUS object is ".concat(locusObjectStateAfterUpdates, ", all updates: ").concat((0, _stringify.default)(update.updatedObjects.map(function (o) {
676
1234
  return {
677
1235
  type: o.htMeta.elementId.type,
678
1236
  id: o.htMeta.elementId.id,
679
- hasData: o.data !== undefined
1237
+ hasData: !!o.data
680
1238
  };
681
1239
  }))));
682
1240
  // now apply all the updates from the hash tree onto the locus
683
- data.updatedObjects.forEach(function (object) {
684
- locus = _this4.updateLocusFromHashTreeObject(object, locus);
1241
+ update.updatedObjects.forEach(function (object) {
1242
+ locus = _this6.updateLocusFromHashTreeObject(object, locus);
685
1243
  });
686
1244
 
687
1245
  // update our locus info with the new locus
688
1246
  this.onDeltaLocus(locus);
689
1247
  break;
690
1248
  }
691
- case _hashTreeParser.LocusInfoUpdateType.MEETING_ENDED:
1249
+ case _hashTreeParser2.LocusInfoUpdateType.MEETING_ENDED:
692
1250
  {
693
- _loggerProxy.default.logger.info("Locus-info:index#updateFromHashTree --> received signal that meeting ended, destroying meeting ".concat(this.meetingId));
694
1251
  var meeting = this.webex.meetings.meetingCollection.get(this.meetingId);
695
- this.webex.meetings.destroy(meeting, _constants.MEETING_REMOVED_REASON.SELF_REMOVED);
1252
+ if (meeting) {
1253
+ _loggerProxy.default.logger.info("Locus-info:index#updateFromHashTree --> received signal that meeting ended, destroying meeting ".concat(this.meetingId));
1254
+ this.webex.meetings.destroy(meeting, _constants.MEETING_REMOVED_REASON.SELF_REMOVED);
1255
+ }
1256
+ break;
1257
+ }
1258
+ case _hashTreeParser2.LocusInfoUpdateType.LOCUS_NOT_FOUND:
1259
+ {
1260
+ _loggerProxy.default.logger.info("Locus-info:index#updateFromHashTree --> received LOCUS_NOT_FOUND for ".concat(locusUrl, ", triggering syncMeetings"));
1261
+ this.webex.meetings.syncMeetings({
1262
+ keepOnlyLocusMeetings: false,
1263
+ skipHashTreeSync: true
1264
+ }).catch(function (syncError) {
1265
+ _loggerProxy.default.logger.error("Locus-info:index#updateFromHashTree --> syncMeetings failed after LOCUS_NOT_FOUND: ".concat(syncError));
1266
+ });
1267
+ break;
696
1268
  }
697
1269
  }
698
1270
  }
@@ -706,11 +1278,22 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
706
1278
  }, {
707
1279
  key: "parse",
708
1280
  value: function parse(meeting, data) {
709
- if (this.hashTreeParser) {
710
- this.handleHashTreeMessage(meeting, data.eventType, data.stateElementsMessage);
1281
+ if (this.hashTreeParsers.size > 0) {
1282
+ if (data.eventType === _constants.LOCUSEVENT.SDK_LOCUS_FROM_SYNC_MEETINGS) {
1283
+ // sync meetings response follows the format of "not wrapped" locus API responses,
1284
+ // so has no dataSets nor Metadata
1285
+ this.handleLocusAPIResponse(meeting, _objectSpread({}, data.locus));
1286
+ } else {
1287
+ this.handleHashTreeMessage(meeting, data.eventType, data.stateElementsMessage);
1288
+ }
711
1289
  } else {
712
- // eslint-disable-next-line @typescript-eslint/no-shadow
713
1290
  var eventType = data.eventType;
1291
+ if (eventType === _constants.LOCUSEVENT.HASH_TREE_DATA_UPDATED) {
1292
+ // this can happen when we get an event before join http response
1293
+ // it's OK to just ignore it
1294
+ _loggerProxy.default.logger.info("Locus-info:index#parse --> received locus hash tree event before hashTreeParser is created");
1295
+ return;
1296
+ }
714
1297
  var locus = this.getTheLocusToUpdate(data.locus);
715
1298
  _loggerProxy.default.logger.info("Locus-info:index#parse --> received locus data: ".concat(eventType));
716
1299
  locus.jsSdkMeta = {
@@ -731,14 +1314,11 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
731
1314
  case _constants.LOCUSEVENT.PARTICIPANT_DECLINED:
732
1315
  case _constants.LOCUSEVENT.FLOOR_GRANTED:
733
1316
  case _constants.LOCUSEVENT.FLOOR_RELEASED:
734
- this.onFullLocus(locus, eventType);
1317
+ this.onFullLocus("classic locus event ".concat(eventType), locus, eventType);
735
1318
  break;
736
1319
  case _constants.LOCUSEVENT.DIFFERENCE:
737
1320
  this.handleLocusDelta(locus, meeting);
738
1321
  break;
739
- case _constants.LOCUSEVENT.HASH_TREE_DATA_UPDATED:
740
- this.sendClassicVsHashTreeMismatchMetric(meeting, "got ".concat(eventType, ", expected classic events"));
741
- break;
742
1322
  default:
743
1323
  // Why will there be a event with no eventType ????
744
1324
  // we may not need this, we can get full locus
@@ -763,32 +1343,40 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
763
1343
  /**
764
1344
  * Function for handling full locus when it's using hash trees (so not the "classic" one).
765
1345
  *
1346
+ * @param {string} debugText string explaining the trigger for this call, added to logs for debugging purposes
766
1347
  * @param {object} locus locus object
767
- * @param {string} eventType locus event
1348
+ * @param {object} metadata locus hash trees metadata
768
1349
  * @param {DataSet[]} dataSets
1350
+ * @param {string} eventType locus event
769
1351
  * @returns {void}
770
1352
  */
771
1353
  }, {
772
1354
  key: "onFullLocusWithHashTrees",
773
- value: function onFullLocusWithHashTrees(locus, eventType, dataSets) {
774
- if (!this.hashTreeParser) {
775
- _loggerProxy.default.logger.info("Locus-info:index#onFullLocus --> creating hash tree parser");
776
- _loggerProxy.default.logger.info('Locus-info:index#onFullLocus --> dataSets:', dataSets, ' and locus:', locus);
777
- this.hashTreeParser = this.createHashTreeParser({
1355
+ value: function onFullLocusWithHashTrees(debugText, locus, metadata, dataSets, eventType) {
1356
+ if (!this.hashTreeParsers.has(locus.url)) {
1357
+ _loggerProxy.default.logger.info("Locus-info:index#onFullLocus (".concat(debugText, ") --> creating hash tree parser for locusUrl=").concat(locus.url));
1358
+ _loggerProxy.default.logger.info("Locus-info:index#onFullLocus (".concat(debugText, ") --> dataSets:"), dataSets, ' and locus:', locus, ' and metadata:', metadata);
1359
+ this.createHashTreeParser({
1360
+ locusUrl: locus.url,
778
1361
  initialLocus: {
779
1362
  locus: locus,
780
1363
  dataSets: dataSets
781
- }
1364
+ },
1365
+ metadata: metadata
782
1366
  });
1367
+ // we have a full locus to start with, so we consider Locus info to be "initialized"
1368
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1369
+ this.hashTreeParsers.get(locus.url).initializedFromHashTree = true;
783
1370
  this.onFullLocusCommon(locus, eventType);
784
1371
  } else {
785
1372
  // in this case the Locus we're getting is not necessarily the full one
786
1373
  // so treat it like if we just got it in any api response
787
1374
 
788
- _loggerProxy.default.logger.info('Locus-info:index#onFullLocus --> hash tree parser already exists, handling it like a normal API response');
1375
+ _loggerProxy.default.logger.info("Locus-info:index#onFullLocus (".concat(debugText, ") --> hash tree parser already exists, handling it like a normal API response"));
789
1376
  this.handleLocusAPIResponse(undefined, {
790
1377
  dataSets: dataSets,
791
- locus: locus
1378
+ locus: locus,
1379
+ metadata: metadata
792
1380
  });
793
1381
  }
794
1382
  }
@@ -796,15 +1384,16 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
796
1384
  /**
797
1385
  * Function for handling full locus when it's the "classic" one (not hash trees)
798
1386
  *
1387
+ * @param {string} debugText string explaining the trigger for this call, added to logs for debugging purposes
799
1388
  * @param {object} locus locus object
800
1389
  * @param {string} eventType locus event
801
1390
  * @returns {void}
802
1391
  */
803
1392
  }, {
804
1393
  key: "onFullLocusClassic",
805
- value: function onFullLocusClassic(locus, eventType) {
1394
+ value: function onFullLocusClassic(debugText, locus, eventType) {
806
1395
  if (!this.locusParser.isNewFullLocus(locus)) {
807
- _loggerProxy.default.logger.info("Locus-info:index#onFullLocus --> ignoring old full locus DTO, eventType=".concat(eventType));
1396
+ _loggerProxy.default.logger.info("Locus-info:index#onFullLocus (".concat(debugText, ") --> ignoring old full locus DTO, eventType=").concat(eventType));
808
1397
  return;
809
1398
  }
810
1399
  this.onFullLocusCommon(locus, eventType);
@@ -812,23 +1401,28 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
812
1401
 
813
1402
  /**
814
1403
  * updates the locus with full locus object
1404
+ * @param {string} debugText string explaining the trigger for this call, added to logs for debugging purposes
815
1405
  * @param {object} locus locus object
816
1406
  * @param {string} eventType locus event
817
1407
  * @param {DataSet[]} dataSets
1408
+ * @param {object} metadata locus hash trees metadata
818
1409
  * @returns {object} null
819
1410
  * @memberof LocusInfo
820
1411
  */
821
1412
  }, {
822
1413
  key: "onFullLocus",
823
- value: function onFullLocus(locus, eventType, dataSets) {
1414
+ value: function onFullLocus(debugText, locus, eventType, dataSets, metadata) {
824
1415
  if (!locus) {
825
- _loggerProxy.default.logger.error('Locus-info:index#onFullLocus --> object passed as argument was invalid, continuing.');
1416
+ _loggerProxy.default.logger.error("Locus-info:index#onFullLocus (".concat(debugText, ") --> object passed as argument was invalid, continuing."));
826
1417
  }
827
1418
  if (dataSets) {
1419
+ if (!metadata) {
1420
+ throw new Error("Locus-info:index#onFullLocus (".concat(debugText, ") --> hash tree metadata is missing with full Locus"));
1421
+ }
828
1422
  // this is the new hashmap Locus DTO format (only applicable to webinars for now)
829
- this.onFullLocusWithHashTrees(locus, eventType, dataSets);
1423
+ this.onFullLocusWithHashTrees(debugText, locus, metadata, dataSets, eventType);
830
1424
  } else {
831
- this.onFullLocusClassic(locus, eventType);
1425
+ this.onFullLocusClassic(debugText, locus, eventType);
832
1426
  }
833
1427
  }
834
1428
 
@@ -842,15 +1436,15 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
842
1436
  key: "onFullLocusCommon",
843
1437
  value: function onFullLocusCommon(locus, eventType) {
844
1438
  var _this$participants,
845
- _this5 = this,
1439
+ _this7 = this,
846
1440
  _locus$jsSdkMeta;
847
1441
  this.scheduledMeeting = locus.meeting || null;
848
1442
  this.participants = locus.participants;
849
1443
  (_this$participants = this.participants) === null || _this$participants === void 0 ? void 0 : _this$participants.forEach(function (participant) {
850
1444
  var _participant$htMeta;
851
1445
  // participant.htMeta is set only for hash tree based locus
852
- if ((_participant$htMeta = participant.htMeta) !== null && _participant$htMeta !== void 0 && _participant$htMeta.elementId.id) {
853
- _this5.hashTreeObjectId2ParticipantId.set(participant.htMeta.elementId.id, participant.id);
1446
+ if (typeof ((_participant$htMeta = participant.htMeta) === null || _participant$htMeta === void 0 ? void 0 : _participant$htMeta.elementId.id) === 'number') {
1447
+ _this7.hashTreeObjectId2ParticipantId.set(participant.htMeta.elementId.id, participant.id);
854
1448
  }
855
1449
  });
856
1450
  var isReplaceMembers = _controlsUtils.default.isNeedReplaceMembers(this.controls, locus.controls);
@@ -873,7 +1467,8 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
873
1467
  }, {
874
1468
  key: "handleOneOnOneEvent",
875
1469
  value: function handleOneOnOneEvent(eventType) {
876
- if (this.parsedLocus.fullState.type === _constants._CALL_ || this.parsedLocus.fullState.type === _constants._SIP_BRIDGE_) {
1470
+ var _this$parsedLocus$ful, _this$parsedLocus$ful2;
1471
+ if (((_this$parsedLocus$ful = this.parsedLocus.fullState) === null || _this$parsedLocus$ful === void 0 ? void 0 : _this$parsedLocus$ful.type) === _constants._CALL_ || ((_this$parsedLocus$ful2 = this.parsedLocus.fullState) === null || _this$parsedLocus$ful2 === void 0 ? void 0 : _this$parsedLocus$ful2.type) === _constants._SIP_BRIDGE_) {
877
1472
  // for 1:1 bob calls alice and alice declines, notify the meeting state
878
1473
  if (eventType === _constants.LOCUSEVENT.PARTICIPANT_DECLINED) {
879
1474
  // trigger the event for stop ringing
@@ -899,6 +1494,30 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
899
1494
  }
900
1495
  }
901
1496
 
1497
+ /**
1498
+ * Makes sure that passed in locus object has a participant object for self.
1499
+ *
1500
+ * @param {LocusDTO} locus The locus object to check and modify if needed
1501
+ * @returns {void}
1502
+ */
1503
+ }, {
1504
+ key: "ensureSelfParticipantExists",
1505
+ value: function ensureSelfParticipantExists(locus) {
1506
+ var self = locus.self;
1507
+
1508
+ // sanity check, this should never fail
1509
+ if (!(self !== null && self !== void 0 && self.identity) || !(0, _isArray.default)(locus.participants)) {
1510
+ _loggerProxy.default.logger.warn("Locus-info:index#ensureSelfParticipantExists --> locus object is missing required fields, cannot ensure self participant exists. self?.identity=\"".concat(self === null || self === void 0 ? void 0 : self.identity, "\""));
1511
+ return;
1512
+ }
1513
+ var selfExists = locus.participants.some(function (participant) {
1514
+ return participant.identity === self.identity;
1515
+ });
1516
+ if (!selfExists) {
1517
+ locus.participants.push(_objectSpread({}, self));
1518
+ }
1519
+ }
1520
+
902
1521
  /**
903
1522
  * @param {Object} locus
904
1523
  * @returns {undefined}
@@ -908,10 +1527,20 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
908
1527
  key: "onDeltaLocus",
909
1528
  value: function onDeltaLocus(locus) {
910
1529
  var _locus$jsSdkMeta2;
911
- var isReplaceMembers = _controlsUtils.default.isNeedReplaceMembers(this.controls, locus.controls);
1530
+ var isReplaceMembers = ((_locus$jsSdkMeta2 = locus.jsSdkMeta) === null || _locus$jsSdkMeta2 === void 0 ? void 0 : _locus$jsSdkMeta2.forceReplaceMembers) !== undefined ? locus.jsSdkMeta.forceReplaceMembers : _controlsUtils.default.isNeedReplaceMembers(this.controls, locus.controls);
1531
+ if (isReplaceMembers) {
1532
+ // when we're moving between breakouts, Locus sometimes doesn't send us
1533
+ // any participants at all for a few seconds
1534
+ // Web app relies on having at least the self participant always there
1535
+ // so we copy self into participants if it's not there.
1536
+ this.ensureSelfParticipantExists(locus);
1537
+ }
912
1538
  this.mergeParticipants(this.participants, locus.participants);
913
- this.updateLocusInfo(locus);
914
- this.updateParticipants(locus.participants, (_locus$jsSdkMeta2 = locus.jsSdkMeta) === null || _locus$jsSdkMeta2 === void 0 ? void 0 : _locus$jsSdkMeta2.removedParticipantIds, isReplaceMembers);
1539
+ var updatesApplied = this.updateLocusInfo(locus);
1540
+ if (updatesApplied) {
1541
+ var _locus$jsSdkMeta3;
1542
+ this.updateParticipants(locus.participants, (_locus$jsSdkMeta3 = locus.jsSdkMeta) === null || _locus$jsSdkMeta3 === void 0 ? void 0 : _locus$jsSdkMeta3.removedParticipantIds, isReplaceMembers);
1543
+ }
915
1544
  this.isMeetingActive();
916
1545
  }
917
1546
 
@@ -923,12 +1552,11 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
923
1552
  }, {
924
1553
  key: "updateLocusInfo",
925
1554
  value: function updateLocusInfo(locus) {
926
- var _locus$self, _locus$self2, _locus$links3, _locus$links4;
927
- if (((_locus$self = locus.self) === null || _locus$self === void 0 ? void 0 : _locus$self.reason) === 'MOVED' && ((_locus$self2 = locus.self) === null || _locus$self2 === void 0 ? void 0 : _locus$self2.state) === 'LEFT') {
1555
+ if (_util.default.isSelfMovedOrBreakoutEnded(locus)) {
928
1556
  // When moved to a breakout session locus sends a message for the previous locus
929
1557
  // indicating that we have been moved. It isn't helpful to continue parsing this
930
1558
  // as it gets interpreted as if we have left the call
931
- return;
1559
+ return false;
932
1560
  }
933
1561
  this.updateControls(locus.controls, locus.self);
934
1562
  this.updateConversationUrl(locus.conversationUrl, locus.info);
@@ -938,19 +1566,17 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
938
1566
  this.updateLocusUrl(locus.url, _controlsUtils.default.isMainSessionDTO(locus));
939
1567
  this.updateMeetingInfo(locus.info, locus.self);
940
1568
  this.updateMediaShares(locus.mediaShares);
941
- this.updateParticipantsUrl(locus.participantsUrl);
942
- this.updateReplace(locus.replace);
1569
+ this.updateReplaces(locus.replaces);
943
1570
  this.updateSelf(locus.self);
944
1571
  this.updateAclUrl(locus.aclUrl);
945
1572
  this.updateBasequence(locus.baseSequence);
946
1573
  this.updateSequence(locus.sequence);
947
- this.updateMemberShip(locus.membership);
948
- this.updateIdentifiers(locus.identities);
949
1574
  this.updateEmbeddedApps(locus.embeddedApps);
950
- this.updateServices((_locus$links3 = locus.links) === null || _locus$links3 === void 0 ? void 0 : _locus$links3.services);
951
- this.updateResources((_locus$links4 = locus.links) === null || _locus$links4 === void 0 ? void 0 : _locus$links4.resources);
1575
+ this.updateLinks(locus.links);
952
1576
  this.compareAndUpdate();
953
1577
  // update which required to compare different objects from locus
1578
+
1579
+ return true;
954
1580
  }
955
1581
 
956
1582
  /**
@@ -980,7 +1606,8 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
980
1606
  }, {
981
1607
  key: "isMeetingActive",
982
1608
  value: function isMeetingActive() {
983
- if (this.parsedLocus.fullState.type === _constants._CALL_ || this.parsedLocus.fullState.type === _constants._SIP_BRIDGE_ || this.parsedLocus.fullState.type === _constants._SPACE_SHARE_) {
1609
+ var _this$parsedLocus$ful3, _this$parsedLocus$ful4, _this$parsedLocus$ful5, _this$parsedLocus$ful6;
1610
+ if (((_this$parsedLocus$ful3 = this.parsedLocus.fullState) === null || _this$parsedLocus$ful3 === void 0 ? void 0 : _this$parsedLocus$ful3.type) === _constants._CALL_ || ((_this$parsedLocus$ful4 = this.parsedLocus.fullState) === null || _this$parsedLocus$ful4 === void 0 ? void 0 : _this$parsedLocus$ful4.type) === _constants._SIP_BRIDGE_ || ((_this$parsedLocus$ful5 = this.parsedLocus.fullState) === null || _this$parsedLocus$ful5 === void 0 ? void 0 : _this$parsedLocus$ful5.type) === _constants._SPACE_SHARE_) {
984
1611
  // @ts-ignore
985
1612
  var partner = this.getLocusPartner(this.participants, this.self);
986
1613
  this.updateMeeting({
@@ -1044,11 +1671,9 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1044
1671
  shouldLeave: false
1045
1672
  });
1046
1673
  }
1047
- } else if (this.parsedLocus.fullState.type === _constants._MEETING_) {
1048
- if (this.fullState && (this.fullState.state === _constants.LOCUS.STATE.INACTIVE ||
1049
- // @ts-ignore
1050
- this.fullState.state === _constants.LOCUS.STATE.TERMINATING)) {
1051
- _loggerProxy.default.logger.warn('Locus-info:index#isMeetingActive --> Meeting is ending due to inactive or terminating');
1674
+ } else if (((_this$parsedLocus$ful6 = this.parsedLocus.fullState) === null || _this$parsedLocus$ful6 === void 0 ? void 0 : _this$parsedLocus$ful6.type) === _constants._MEETING_) {
1675
+ if (this.fullState && _util.default.isWholeMeetingEnded(this.fullState)) {
1676
+ _loggerProxy.default.logger.warn('Locus-info:index#isMeetingActive --> Meeting is ending due to inactive');
1052
1677
 
1053
1678
  // @ts-ignore
1054
1679
  this.webex.internal.newMetrics.submitClientEvent({
@@ -1064,23 +1689,6 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1064
1689
  reason: _constants.MEETING_REMOVED_REASON.MEETING_INACTIVE_TERMINATING,
1065
1690
  shouldLeave: false
1066
1691
  });
1067
- } else if (this.fullState && this.fullState.removed) {
1068
- // user has been dropped from a meeting
1069
-
1070
- // @ts-ignore
1071
- this.webex.internal.newMetrics.submitClientEvent({
1072
- name: 'client.call.remote-ended',
1073
- options: {
1074
- meetingId: this.meetingId
1075
- }
1076
- });
1077
- this.emitScoped({
1078
- file: 'locus-info',
1079
- function: 'isMeetingActive'
1080
- }, _constants.EVENTS.DESTROY_MEETING, {
1081
- reason: _constants.MEETING_REMOVED_REASON.FULLSTATE_REMOVED,
1082
- shouldLeave: false
1083
- });
1084
1692
  }
1085
1693
  // If you are guest and you are removed from the meeting
1086
1694
  // You wont get any further events
@@ -1125,7 +1733,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1125
1733
  value: function compareSelfAndHost() {
1126
1734
  var _this$parsedLocus$hos;
1127
1735
  // In some cases the host info is not present but the moderator values changes from null to false so it triggers an update
1128
- if (this.parsedLocus.self.selfIdentity === ((_this$parsedLocus$hos = this.parsedLocus.host) === null || _this$parsedLocus$hos === void 0 ? void 0 : _this$parsedLocus$hos.hostId) && this.parsedLocus.self.moderator) {
1736
+ if (this.parsedLocus.self && this.parsedLocus.self.selfIdentity === ((_this$parsedLocus$hos = this.parsedLocus.host) === null || _this$parsedLocus$hos === void 0 ? void 0 : _this$parsedLocus$hos.hostId) && this.parsedLocus.self.moderator) {
1129
1737
  this.emitScoped({
1130
1738
  file: 'locus-info',
1131
1739
  function: 'compareSelfAndHost'
@@ -1167,11 +1775,11 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1167
1775
  isReplace: isReplace
1168
1776
  });
1169
1777
  if (participants && (0, _isArray.default)(participants) && participants.length > 0) {
1170
- var _iterator = _createForOfIteratorHelper(participants),
1171
- _step;
1778
+ var _iterator4 = _createForOfIteratorHelper(participants),
1779
+ _step4;
1172
1780
  try {
1173
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1174
- var participant = _step.value;
1781
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1782
+ var participant = _step4.value;
1175
1783
  if (participant && (participant === null || participant === void 0 ? void 0 : participant.reason) === 'FAILURE') {
1176
1784
  var _participant$person;
1177
1785
  this.emitScoped({
@@ -1183,9 +1791,9 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1183
1791
  }
1184
1792
  }
1185
1793
  } catch (err) {
1186
- _iterator.e(err);
1794
+ _iterator4.e(err);
1187
1795
  } finally {
1188
- _iterator.f();
1796
+ _iterator4.f();
1189
1797
  }
1190
1798
  }
1191
1799
  }
@@ -1207,6 +1815,8 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1207
1815
  hasRecordingPausedChanged = _ControlsUtils$getCon2.hasRecordingPausedChanged,
1208
1816
  hasMeetingContainerChanged = _ControlsUtils$getCon2.hasMeetingContainerChanged,
1209
1817
  hasTranscribeChanged = _ControlsUtils$getCon2.hasTranscribeChanged,
1818
+ hasHesiodLLMIdChanged = _ControlsUtils$getCon2.hasHesiodLLMIdChanged,
1819
+ hasAiSummaryNotificationChanged = _ControlsUtils$getCon2.hasAiSummaryNotificationChanged,
1210
1820
  hasTranscribeSpokenLanguageChanged = _ControlsUtils$getCon2.hasTranscribeSpokenLanguageChanged,
1211
1821
  hasManualCaptionChanged = _ControlsUtils$getCon2.hasManualCaptionChanged,
1212
1822
  hasEntryExitToneChanged = _ControlsUtils$getCon2.hasEntryExitToneChanged,
@@ -1304,7 +1914,9 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1304
1914
  }, _constants.LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED, {
1305
1915
  state: state,
1306
1916
  modifiedBy: current.record.modifiedBy,
1307
- lastModified: current.record.lastModified
1917
+ lastModified: current.record.lastModified,
1918
+ modifiedByServiceAppName: current.record.modifiedByServiceAppName,
1919
+ modifiedByServiceAppId: current.record.modifiedByServiceAppId
1308
1920
  });
1309
1921
  }
1310
1922
  if (hasMeetingContainerChanged) {
@@ -1328,6 +1940,23 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1328
1940
  caption: caption
1329
1941
  });
1330
1942
  }
1943
+ if (hasHesiodLLMIdChanged) {
1944
+ var hesiodLlmId = current.transcribe.hesiodLlmId;
1945
+ this.emitScoped({
1946
+ file: 'locus-info',
1947
+ function: 'updateControls'
1948
+ }, _constants.LOCUSINFO.EVENTS.CONTROLS_MEETING_HESIOD_LLM_ID_UPDATED, {
1949
+ hesiodLlmId: hesiodLlmId
1950
+ });
1951
+ }
1952
+ if (hasAiSummaryNotificationChanged) {
1953
+ this.emitScoped({
1954
+ file: 'locus-info',
1955
+ function: 'updateControls'
1956
+ }, _constants.LOCUSINFO.EVENTS.CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED, {
1957
+ aiSummaryNotification: current.transcribe.aiSummaryNotification
1958
+ });
1959
+ }
1331
1960
  if (hasTranscribeSpokenLanguageChanged) {
1332
1961
  var spokenLanguage = current.transcribe.spokenLanguage;
1333
1962
  this.emitScoped({
@@ -1497,41 +2126,35 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1497
2126
  }
1498
2127
 
1499
2128
  /**
1500
- * @param {Object} services
2129
+ * Updates links and emits appropriate events if services or resources have changed
2130
+ * @param {Object} links
1501
2131
  * @returns {undefined}
1502
2132
  * @memberof LocusInfo
1503
2133
  */
1504
2134
  }, {
1505
- key: "updateServices",
1506
- value: function updateServices(services) {
1507
- if (services && !(0, _lodash.isEqual)(this.services, services)) {
1508
- this.services = services;
2135
+ key: "updateLinks",
2136
+ value: function updateLinks(links) {
2137
+ var _this$links, _this$links2;
2138
+ var _ref2 = links || {},
2139
+ services = _ref2.services,
2140
+ resources = _ref2.resources;
2141
+ if (services && !(0, _lodash.isEqual)((_this$links = this.links) === null || _this$links === void 0 ? void 0 : _this$links.services, services)) {
1509
2142
  this.emitScoped({
1510
2143
  file: 'locus-info',
1511
- function: 'updateServices'
2144
+ function: 'updateLinks'
1512
2145
  }, _constants.LOCUSINFO.EVENTS.LINKS_SERVICES, {
1513
2146
  services: services
1514
2147
  });
1515
2148
  }
1516
- }
1517
-
1518
- /**
1519
- * @param {Object} resources
1520
- * @returns {undefined}
1521
- * @memberof LocusInfo
1522
- */
1523
- }, {
1524
- key: "updateResources",
1525
- value: function updateResources(resources) {
1526
- if (resources && !(0, _lodash.isEqual)(this.resources, resources)) {
1527
- this.resources = resources;
2149
+ if (resources && !(0, _lodash.isEqual)((_this$links2 = this.links) === null || _this$links2 === void 0 ? void 0 : _this$links2.resources, resources)) {
1528
2150
  this.emitScoped({
1529
2151
  file: 'locus-info',
1530
- function: 'updateResources'
2152
+ function: 'updateLinks'
1531
2153
  }, _constants.LOCUSINFO.EVENTS.LINKS_RESOURCES, {
1532
2154
  resources: resources
1533
2155
  });
1534
2156
  }
2157
+ this.links = links;
1535
2158
  }
1536
2159
 
1537
2160
  /**
@@ -1608,9 +2231,18 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1608
2231
  value: function updateMeetingInfo(info, self) {
1609
2232
  var _this$parsedLocus$sel;
1610
2233
  var roles = self ? _selfUtils.default.getRoles(self) : ((_this$parsedLocus$sel = this.parsedLocus.self) === null || _this$parsedLocus$sel === void 0 ? void 0 : _this$parsedLocus$sel.roles) || [];
1611
- if (info && !(0, _lodash.isEqual)(this.info, info) || !(0, _lodash.isEqual)(this.roles, roles) && info) {
1612
- var isJoined = _selfUtils.default.isJoined(self || this.parsedLocus.self);
1613
- var parsedInfo = _infoUtils.default.getInfos(this.parsedLocus.info, info, roles, isJoined);
2234
+ var isJoined = _selfUtils.default.isJoined(self || this.parsedLocus.self);
2235
+
2236
+ // The parsed userDisplayHints depend on info, roles and isJoined, so we must recompute
2237
+ // whenever any of them changes. A common case is self transitioning to JOINED via a delta
2238
+ // that doesn't carry an info section - in that case we fall back to the previously stored
2239
+ // info so the hints get reparsed with the new joined state (e.g. VIEW_THE_PARTICIPANT_LIST).
2240
+ var infoToParse = info || this.info;
2241
+ var infoChanged = info && !(0, _lodash.isEqual)(this.info, info);
2242
+ var rolesChanged = !(0, _lodash.isEqual)(this.roles, roles);
2243
+ var isJoinedChanged = _selfUtils.default.isJoined(this.parsedLocus.self) !== isJoined;
2244
+ if (infoToParse && (infoChanged || rolesChanged || isJoinedChanged)) {
2245
+ var parsedInfo = _infoUtils.default.getInfos(this.parsedLocus.info, infoToParse, roles, isJoined);
1614
2246
  if (parsedInfo.updates.isLocked) {
1615
2247
  this.emitScoped({
1616
2248
  file: 'locus-info',
@@ -1623,7 +2255,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1623
2255
  function: 'updateMeetingInfo'
1624
2256
  }, _constants.LOCUSINFO.EVENTS.MEETING_UNLOCKED, info);
1625
2257
  }
1626
- this.info = info;
2258
+ this.info = infoToParse;
1627
2259
  this.parsedLocus.info = parsedInfo.current;
1628
2260
  // Parses the info and adds necessary values
1629
2261
  this.updateMeeting(parsedInfo.current);
@@ -1689,28 +2321,15 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1689
2321
  }
1690
2322
 
1691
2323
  /**
1692
- * @param {String} participantsUrl
2324
+ * @param {Object} replaces
1693
2325
  * @returns {undefined}
1694
2326
  * @memberof LocusInfo
1695
2327
  */
1696
2328
  }, {
1697
- key: "updateParticipantsUrl",
1698
- value: function updateParticipantsUrl(participantsUrl) {
1699
- if (participantsUrl && !(0, _lodash.isEqual)(this.participantsUrl, participantsUrl)) {
1700
- this.participantsUrl = participantsUrl;
1701
- }
1702
- }
1703
-
1704
- /**
1705
- * @param {Object} replace
1706
- * @returns {undefined}
1707
- * @memberof LocusInfo
1708
- */
1709
- }, {
1710
- key: "updateReplace",
1711
- value: function updateReplace(replace) {
1712
- if (replace && !(0, _lodash.isEqual)(this.replace, replace)) {
1713
- this.replace = replace;
2329
+ key: "updateReplaces",
2330
+ value: function updateReplaces(replaces) {
2331
+ if (replaces && !(0, _lodash.isEqual)(this.replaces, replaces)) {
2332
+ this.replaces = replaces;
1714
2333
  }
1715
2334
  }
1716
2335
 
@@ -1725,6 +2344,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1725
2344
  key: "updateSelf",
1726
2345
  value: function updateSelf(self) {
1727
2346
  if (self) {
2347
+ var _this$parsedLocus$ful7, _this$parsedLocus$inf;
1728
2348
  // @ts-ignore
1729
2349
  var parsedSelves = _selfUtils.default.getSelves(this.parsedLocus.self, self, this.webex.internal.device.url, this.participants // using this.participants instead of locus.participants here, because with delta DTOs locus.participants will only contain a small subset of participants
1730
2350
  );
@@ -1736,9 +2356,9 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1736
2356
  }
1737
2357
 
1738
2358
  // TODO: check if we need to save the sipUri here as well
1739
- // this.emit(LOCUSINFO.EVENTS.MEETING_UPDATE, SelfUtils.getSipUrl(this.getLocusPartner(participants, self), this.parsedLocus.fullState.type, this.parsedLocus.info.sipUri));
1740
- var result = _selfUtils.default.getSipUrl(this.getLocusPartner(this.participants, self), this.parsedLocus.fullState.type, this.parsedLocus.info.sipUri);
1741
- if (result.sipUri) {
2359
+ // this.emit(LOCUSINFO.EVENTS.MEETING_UPDATE, SelfUtils.getSipUrl(this.getLocusPartner(participants, self), this.parsedLocus.fullState?.type, this.parsedLocus.info?.sipUri));
2360
+ var result = _selfUtils.default.getSipUrl(this.getLocusPartner(this.participants, self), (_this$parsedLocus$ful7 = this.parsedLocus.fullState) === null || _this$parsedLocus$ful7 === void 0 ? void 0 : _this$parsedLocus$ful7.type, (_this$parsedLocus$inf = this.parsedLocus.info) === null || _this$parsedLocus$inf === void 0 ? void 0 : _this$parsedLocus$inf.sipUri);
2361
+ if (result !== null && result !== void 0 && result.sipUri) {
1742
2362
  this.updateMeeting(result);
1743
2363
  }
1744
2364
  if (parsedSelves.updates.moderatorChanged) {
@@ -1770,6 +2390,14 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1770
2390
  brb: parsedSelves.current.brb
1771
2391
  });
1772
2392
  }
2393
+ if (parsedSelves.updates.selfIdChanged) {
2394
+ this.emitScoped({
2395
+ file: 'locus-info',
2396
+ function: 'updateSelf'
2397
+ }, _constants.LOCUSINFO.EVENTS.SELF_ID_CHANGED, {
2398
+ selfId: parsedSelves.current.selfId
2399
+ });
2400
+ }
1773
2401
  if (parsedSelves.updates.interpretationChanged) {
1774
2402
  this.emitScoped({
1775
2403
  file: 'locus-info',
@@ -1822,12 +2450,14 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1822
2450
  });
1823
2451
  }
1824
2452
  if (parsedSelves.updates.isMutedByOthersChanged) {
2453
+ var _parsedSelves$current2;
1825
2454
  this.emitScoped({
1826
2455
  file: 'locus-info',
1827
2456
  function: 'updateSelf'
1828
2457
  }, _constants.LOCUSINFO.EVENTS.SELF_REMOTE_MUTE_STATUS_UPDATED, {
1829
2458
  muted: parsedSelves.current.remoteMuted,
1830
- unmuteAllowed: parsedSelves.current.unmuteAllowed
2459
+ unmuteAllowed: parsedSelves.current.unmuteAllowed,
2460
+ modifiedBy: (_parsedSelves$current2 = parsedSelves.current.modifiedBy) !== null && _parsedSelves$current2 !== void 0 ? _parsedSelves$current2 : null
1831
2461
  });
1832
2462
  }
1833
2463
  if (parsedSelves.updates.localAudioUnmuteRequestedByServer) {
@@ -1857,14 +2487,14 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1857
2487
  _constants.LOCUSINFO.EVENTS.MEDIA_INACTIVITY, _selfUtils.default.getMediaStatus(self.mediaSessions));
1858
2488
  }
1859
2489
  if (parsedSelves.updates.audioStateChange || parsedSelves.updates.videoStateChange || parsedSelves.updates.shareStateChange) {
1860
- var _parsedSelves$current2, _parsedSelves$current3, _parsedSelves$current4;
2490
+ var _parsedSelves$current3, _parsedSelves$current4, _parsedSelves$current5;
1861
2491
  this.emitScoped({
1862
2492
  file: 'locus-info',
1863
2493
  function: 'updateSelf'
1864
2494
  }, _constants.LOCUSINFO.EVENTS.MEDIA_STATUS_CHANGE, {
1865
- audioStatus: (_parsedSelves$current2 = parsedSelves.current.currentMediaStatus) === null || _parsedSelves$current2 === void 0 ? void 0 : _parsedSelves$current2.audio,
1866
- videoStatus: (_parsedSelves$current3 = parsedSelves.current.currentMediaStatus) === null || _parsedSelves$current3 === void 0 ? void 0 : _parsedSelves$current3.video,
1867
- shareStatus: (_parsedSelves$current4 = parsedSelves.current.currentMediaStatus) === null || _parsedSelves$current4 === void 0 ? void 0 : _parsedSelves$current4.share
2495
+ audioStatus: (_parsedSelves$current3 = parsedSelves.current.currentMediaStatus) === null || _parsedSelves$current3 === void 0 ? void 0 : _parsedSelves$current3.audio,
2496
+ videoStatus: (_parsedSelves$current4 = parsedSelves.current.currentMediaStatus) === null || _parsedSelves$current4 === void 0 ? void 0 : _parsedSelves$current4.video,
2497
+ shareStatus: (_parsedSelves$current5 = parsedSelves.current.currentMediaStatus) === null || _parsedSelves$current5 === void 0 ? void 0 : _parsedSelves$current5.share
1868
2498
  });
1869
2499
  }
1870
2500
  if (parsedSelves.updates.isUserObserving) {
@@ -1969,32 +2599,6 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
1969
2599
  }
1970
2600
  }
1971
2601
 
1972
- /**
1973
- * @param {Object} membership
1974
- * @returns {undefined}
1975
- * @memberof LocusInfo
1976
- */
1977
- }, {
1978
- key: "updateMemberShip",
1979
- value: function updateMemberShip(membership) {
1980
- if (membership && !(0, _lodash.isEqual)(this.membership, membership)) {
1981
- this.membership = membership;
1982
- }
1983
- }
1984
-
1985
- /**
1986
- * @param {Array} identities
1987
- * @returns {undefined}
1988
- * @memberof LocusInfo
1989
- */
1990
- }, {
1991
- key: "updateIdentifiers",
1992
- value: function updateIdentifiers(identities) {
1993
- if (identities && !(0, _lodash.isEqual)(this.identities, identities)) {
1994
- this.identities = identities;
1995
- }
1996
- }
1997
-
1998
2602
  /**
1999
2603
  * check the locus is main session's one or not, if is main session's, update main session cache
2000
2604
  * @param {Object} locus
@@ -2072,7 +2676,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
2072
2676
  }, {
2073
2677
  key: "updateMainSessionLocusCache",
2074
2678
  value: function updateMainSessionLocusCache(mainLocus) {
2075
- var _this6 = this;
2679
+ var _this8 = this;
2076
2680
  if (!mainLocus) {
2077
2681
  return;
2078
2682
  }
@@ -2081,7 +2685,7 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
2081
2685
  // shallow merge and do special merge for participants
2082
2686
  (0, _lodash.assignWith)(this.mainSessionLocusCache, locusClone, function (objValue, srcValue, key) {
2083
2687
  if (key === 'participants') {
2084
- return _this6.mergeParticipants(objValue, srcValue);
2688
+ return _this8.mergeParticipants(objValue, srcValue);
2085
2689
  }
2086
2690
  return srcValue || objValue;
2087
2691
  });
@@ -2100,6 +2704,21 @@ var LocusInfo = exports.default = /*#__PURE__*/function (_EventsScope) {
2100
2704
  value: function clearMainSessionLocusCache() {
2101
2705
  this.mainSessionLocusCache = null;
2102
2706
  }
2707
+
2708
+ /**
2709
+ * Cleans up all hash tree parsers and clears internal maps.
2710
+ * @returns {void}
2711
+ * @memberof LocusInfo
2712
+ */
2713
+ }, {
2714
+ key: "cleanUp",
2715
+ value: function cleanUp() {
2716
+ this.hashTreeParsers.forEach(function (entry) {
2717
+ entry.parser.cleanUp();
2718
+ });
2719
+ this.hashTreeParsers.clear();
2720
+ this.hashTreeObjectId2ParticipantId.clear();
2721
+ }
2103
2722
  }]);
2104
2723
  }(_eventsScope.default);
2105
2724
  //# sourceMappingURL=index.js.map