@reactoo/watchtogether-sdk-js 2.7.35 → 2.7.37

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @reactoo/watchtogether-sdk-js
3
- * @version 2.7.34
3
+ * @version 2.7.35
4
4
  */
5
5
  (function webpackUniversalModuleDefinition(root, factory) {
6
6
  if(typeof exports === 'object' && typeof module === 'object')
@@ -16502,6 +16502,7 @@ let asset = function () {
16502
16502
  uploadAsset: function (file, roomIds) {
16503
16503
  let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
16504
16504
  let initiationData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
16505
+ let assetData = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
16505
16506
  return _this.__privates.auth.__client.then(client => Promise.all([client, initiationData ? Promise.resolve(initiationData) : client.apis.asset.initiateAssetUpload({
16506
16507
  id: id || (0,_modules_wt_utils__WEBPACK_IMPORTED_MODULE_0__.generateUUID)()
16507
16508
  })])).then(_ref2 => {
@@ -16523,7 +16524,8 @@ let asset = function () {
16523
16524
  title: file.name,
16524
16525
  ...(roomIds ? {
16525
16526
  roomIds
16526
- } : {})
16527
+ } : {}),
16528
+ ...(assetData ? assetData : {})
16527
16529
  }
16528
16530
  }), idn]);
16529
16531
  });
@@ -16706,13 +16708,19 @@ let iot = function () {
16706
16708
  var _this = this;
16707
16709
  let __currentTopics = new Set();
16708
16710
  let visibilityChangeHandler = null;
16711
+ let keepAliveIntervalId = null;
16712
+ let shouldBeConnected = false;
16713
+ let isReconnecting = false;
16709
16714
  return {
16710
16715
  __promise: null,
16711
16716
  __updateCredentials: () => {
16717
+ isReconnecting = true;
16712
16718
  return this.iot.getCredentials().then(response => this.__privates.iot.updateWebSocketCredentials(response.data.credentials.accessKeyId, response.data.credentials.secretAccessKey, response.data.credentials.sessionToken, response.data.credentials.expiration)).catch(error => {
16713
16719
  this.__privates.iot.log('Failed to update credentials:', error);
16714
16720
  // Let the error propagate to be handled by the Iot class
16715
16721
  throw error;
16722
+ }).finally(() => {
16723
+ isReconnecting = false;
16716
16724
  });
16717
16725
  },
16718
16726
  getCredentials: () => {
@@ -16728,6 +16736,9 @@ let iot = function () {
16728
16736
  },
16729
16737
  onClosed: () => {
16730
16738
  this.__privates.iot.log('MQTT client closed');
16739
+ if (shouldBeConnected && !isReconnecting) {
16740
+ this.iot.__updateCredentials();
16741
+ }
16731
16742
  },
16732
16743
  onError: () => {
16733
16744
  this.__privates.iot.log('MQTT client error');
@@ -16756,7 +16767,9 @@ let iot = function () {
16756
16767
  });
16757
16768
  let __currentTopicsCopy = new Set(__currentTopics); // Keep this line
16758
16769
  __currentTopics.clear();
16770
+ shouldBeConnected = true;
16759
16771
  _this.iot.setupVisibilityChangeListener();
16772
+ //this.iot.setupKeepAliveInterval();
16760
16773
  _this.iot.$on('connect', _this.iot.onConnect, _this);
16761
16774
  _this.iot.$on('closed', _this.iot.onClosed, _this);
16762
16775
  _this.iot.$on('error', _this.iot.onError, _this);
@@ -16787,7 +16800,9 @@ let iot = function () {
16787
16800
  __currentTopics.clear();
16788
16801
  }
16789
16802
  return _this.__privates.iot.disconnect().then(() => {
16803
+ shouldBeConnected = false;
16790
16804
  _this.iot.disableVisibilityChangeListener();
16805
+ //this.iot.disableKeepAliveInterval();
16791
16806
  _this.iot.$off('connect', _this.iot.onConnect, _this);
16792
16807
  _this.iot.$off('closed', _this.iot.onClosed, _this);
16793
16808
  _this.iot.$off('error', _this.iot.onError, _this);
@@ -16838,6 +16853,14 @@ let iot = function () {
16838
16853
  return this.iot.__updateCredentials();
16839
16854
  });
16840
16855
  },
16856
+ setupKeepAliveInterval: () => {
16857
+ clearInterval(keepAliveIntervalId);
16858
+ keepAliveIntervalId = setInterval(this.iot.checkConnection, 30000);
16859
+ },
16860
+ disableKeepAliveInterval: () => {
16861
+ clearInterval(keepAliveIntervalId);
16862
+ keepAliveIntervalId = null;
16863
+ },
16841
16864
  setupVisibilityChangeListener: () => {
16842
16865
  if (visibilityChangeHandler) {
16843
16866
  // Listener is already set up
@@ -25361,7 +25384,7 @@ class Iot {
25361
25384
  // room
25362
25385
  if (event === 'message' || event === 'template_updated' || event === 'record_start' || event === 'record_stop' || event === 'record_configured' || event === 'record_livestream_available' || event === 'record_livestream_kick' || event === 'user_update_displayname' || event === 'user_update_avatar' || event === 'user_update_bio' || event === 'user_update_customattributes' || event === 'user_update_privateattributes' || event === 'channel_changed' || event === "instance_homepage_changed" || event === "instance_settings_changed" || event === "externalmix_changed" || event === "video_uploaded" || event === "change_user_devices" || event === "queue" || event === "title_changed" || event === "videowall_changed" || event === 'left' ||
25363
25386
  //user removed room a.k.a. left the room
25364
- event === 'kicked' || event === 'banned' || event === 'unbanned' || event === 'approved' || event === 'muted' || event === 'unmuted' || event === 'messageRemoved' || event === 'messageReported' || event === 'chatClear' || event === 'handRaised' || event === 'handLowered' || event === 'handsCleared' || event === 'volume_set') {
25387
+ event === 'kicked' || event === 'banned' || event === 'unbanned' || event === 'approved' || event === 'muted' || event === 'unmuted' || event === 'messageRemoved' || event === 'messageReported' || event === 'chatClear' || event === 'handRaised' || event === 'handLowered' || event === 'handsCleared' || event === 'volume_set' || event === 'asset_created') {
25365
25388
  this.emit('message', {
25366
25389
  event,
25367
25390
  ...message,
@@ -25442,7 +25465,10 @@ class Iot {
25442
25465
  expiration
25443
25466
  };
25444
25467
  const currentTopics = new Set(this.subscribedTopics);
25445
- return this.disconnect().then(() => this.connect(this.lastConnectParams.apiMqttUrl, this.lastConnectParams.apiMqttClientId, this.lastConnectParams.region, accessKeyId, secretAccessKey, sessionToken, expiration)).then(() => {
25468
+
25469
+ // disconnect is part of connect process
25470
+
25471
+ return this.connect(this.lastConnectParams.apiMqttUrl, this.lastConnectParams.apiMqttClientId, this.lastConnectParams.region, accessKeyId, secretAccessKey, sessionToken, expiration).then(() => {
25446
25472
  // Resubscribe to topics
25447
25473
  currentTopics.forEach(topic => this.subscribe(topic));
25448
25474
  this.startCredentialsExpirationCheck(expiration);