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