stream-chat 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -5157,27 +5157,35 @@ var WSConnectionFallback = /*#__PURE__*/function () {
5157
5157
  reconnect = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
5158
5158
 
5159
5159
  if (!(_this.state === ConnectionState.Connecting)) {
5160
- _context3.next = 3;
5160
+ _context3.next = 4;
5161
5161
  break;
5162
5162
  }
5163
5163
 
5164
- throw new Error('connecting already in progress');
5164
+ _this._log('connect() - connecting already in progress', {
5165
+ reconnect: reconnect
5166
+ }, 'warn');
5165
5167
 
5166
- case 3:
5168
+ return _context3.abrupt("return");
5169
+
5170
+ case 4:
5167
5171
  if (!(_this.state === ConnectionState.Connected)) {
5168
- _context3.next = 5;
5172
+ _context3.next = 7;
5169
5173
  break;
5170
5174
  }
5171
5175
 
5172
- throw new Error('already connected and polling');
5176
+ _this._log('connect() - already connected and polling', {
5177
+ reconnect: reconnect
5178
+ }, 'warn');
5173
5179
 
5174
- case 5:
5180
+ return _context3.abrupt("return");
5181
+
5182
+ case 7:
5175
5183
  _this._setState(ConnectionState.Connecting);
5176
5184
 
5177
5185
  _this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
5178
5186
 
5179
- _context3.prev = 7;
5180
- _context3.next = 10;
5187
+ _context3.prev = 9;
5188
+ _context3.next = 12;
5181
5189
  return _this._req({
5182
5190
  json: _this.client._buildWSPayload()
5183
5191
  }, {
@@ -5185,7 +5193,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
5185
5193
  }, // 8s
5186
5194
  reconnect);
5187
5195
 
5188
- case 10:
5196
+ case 12:
5189
5197
  _yield$_this$_req = _context3.sent;
5190
5198
  event = _yield$_this$_req.event;
5191
5199
 
@@ -5201,20 +5209,20 @@ var WSConnectionFallback = /*#__PURE__*/function () {
5201
5209
 
5202
5210
  return _context3.abrupt("return", event);
5203
5211
 
5204
- case 19:
5205
- _context3.prev = 19;
5206
- _context3.t0 = _context3["catch"](7);
5212
+ case 21:
5213
+ _context3.prev = 21;
5214
+ _context3.t0 = _context3["catch"](9);
5207
5215
 
5208
5216
  _this._setState(ConnectionState.Closed);
5209
5217
 
5210
5218
  throw _context3.t0;
5211
5219
 
5212
- case 23:
5220
+ case 25:
5213
5221
  case "end":
5214
5222
  return _context3.stop();
5215
5223
  }
5216
5224
  }
5217
- }, _callee3, null, [[7, 19]]);
5225
+ }, _callee3, null, [[9, 21]]);
5218
5226
  })));
5219
5227
 
5220
5228
  _defineProperty(this, "isHealthy", function () {
@@ -5225,6 +5233,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
5225
5233
  var _this$cancelToken3;
5226
5234
 
5227
5235
  var timeout,
5236
+ connection_id,
5228
5237
  _args4 = arguments;
5229
5238
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
5230
5239
  while (1) {
@@ -5237,36 +5246,37 @@ var WSConnectionFallback = /*#__PURE__*/function () {
5237
5246
 
5238
5247
  (_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
5239
5248
  _this.cancelToken = undefined;
5240
- _context4.prev = 5;
5241
- _context4.next = 8;
5249
+ connection_id = _this.connectionID;
5250
+ _this.connectionID = undefined;
5251
+ _context4.prev = 7;
5252
+ _context4.next = 10;
5242
5253
  return _this._req({
5243
- close: true
5254
+ close: true,
5255
+ connection_id: connection_id
5244
5256
  }, {
5245
5257
  timeout: timeout
5246
5258
  }, false);
5247
5259
 
5248
- case 8:
5249
- _this.connectionID = undefined;
5250
-
5260
+ case 10:
5251
5261
  _this._log("disconnect() - Closed connectionID");
5252
5262
 
5253
- _context4.next = 15;
5263
+ _context4.next = 16;
5254
5264
  break;
5255
5265
 
5256
- case 12:
5257
- _context4.prev = 12;
5258
- _context4.t0 = _context4["catch"](5);
5266
+ case 13:
5267
+ _context4.prev = 13;
5268
+ _context4.t0 = _context4["catch"](7);
5259
5269
 
5260
5270
  _this._log("disconnect() - Failed", {
5261
5271
  err: _context4.t0
5262
5272
  }, 'error');
5263
5273
 
5264
- case 15:
5274
+ case 16:
5265
5275
  case "end":
5266
5276
  return _context4.stop();
5267
5277
  }
5268
5278
  }
5269
- }, _callee4, null, [[5, 12]]);
5279
+ }, _callee4, null, [[7, 13]]);
5270
5280
  })));
5271
5281
 
5272
5282
  this.client = client;
@@ -6989,23 +6999,41 @@ var StreamChat = /*#__PURE__*/function () {
6989
6999
  client: this
6990
7000
  });
6991
7001
  _context15.prev = 8;
6992
- _context15.next = 11;
7002
+
7003
+ if (!this.wsFallback) {
7004
+ _context15.next = 13;
7005
+ break;
7006
+ }
7007
+
7008
+ _context15.next = 12;
7009
+ return this.wsFallback.connect();
7010
+
7011
+ case 12:
7012
+ return _context15.abrupt("return", _context15.sent);
7013
+
7014
+ case 13:
7015
+ _context15.next = 15;
6993
7016
  return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
6994
7017
 
6995
- case 11:
7018
+ case 15:
6996
7019
  return _context15.abrupt("return", _context15.sent);
6997
7020
 
6998
- case 14:
6999
- _context15.prev = 14;
7021
+ case 18:
7022
+ _context15.prev = 18;
7000
7023
  _context15.t0 = _context15["catch"](8);
7001
7024
 
7002
7025
  if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
7003
- _context15.next = 24;
7026
+ _context15.next = 29;
7004
7027
  break;
7005
7028
  }
7006
7029
 
7007
7030
  this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
7008
7031
  tags: ['connection', 'client']
7032
+ }); // @ts-expect-error
7033
+
7034
+ this.dispatchEvent({
7035
+ type: 'transport.changed',
7036
+ mode: 'longpoll'
7009
7037
  });
7010
7038
 
7011
7039
  this.wsConnection._destroyCurrentWSConnection();
@@ -7015,21 +7043,21 @@ var StreamChat = /*#__PURE__*/function () {
7015
7043
  this.wsFallback = new WSConnectionFallback({
7016
7044
  client: this
7017
7045
  });
7018
- _context15.next = 23;
7046
+ _context15.next = 28;
7019
7047
  return this.wsFallback.connect();
7020
7048
 
7021
- case 23:
7049
+ case 28:
7022
7050
  return _context15.abrupt("return", _context15.sent);
7023
7051
 
7024
- case 24:
7052
+ case 29:
7025
7053
  throw _context15.t0;
7026
7054
 
7027
- case 25:
7055
+ case 30:
7028
7056
  case "end":
7029
7057
  return _context15.stop();
7030
7058
  }
7031
7059
  }
7032
- }, _callee15, this, [[8, 14]]);
7060
+ }, _callee15, this, [[8, 18]]);
7033
7061
  }));
7034
7062
 
7035
7063
  function connect() {
@@ -8864,7 +8892,7 @@ var StreamChat = /*#__PURE__*/function () {
8864
8892
  }, {
8865
8893
  key: "getUserAgent",
8866
8894
  value: function getUserAgent() {
8867
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "5.0.0");
8895
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "5.0.1");
8868
8896
  }
8869
8897
  }, {
8870
8898
  key: "setUserAgent",
@@ -8899,12 +8927,11 @@ var StreamChat = /*#__PURE__*/function () {
8899
8927
  }
8900
8928
 
8901
8929
  return _objectSpread({
8902
- params: _objectSpread(_objectSpread({
8903
- user_id: this.userID
8904
- }, options.params), {}, {
8905
- api_key: this.key,
8906
- connection_id: this._getConnectionID()
8907
- }),
8930
+ params: _objectSpread({
8931
+ user_id: this.userID,
8932
+ connection_id: this._getConnectionID(),
8933
+ api_key: this.key
8934
+ }, options.params),
8908
8935
  headers: _objectSpread(_objectSpread({}, authorization), {}, {
8909
8936
  'stream-auth-type': this.getAuthType(),
8910
8937
  'X-Stream-Client': this.getUserAgent()