stream-chat 7.1.0 → 8.0.0-dev.0

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.js CHANGED
@@ -1271,7 +1271,9 @@ function getRandomValuesWithMathRandom(bytes) {
1271
1271
  }
1272
1272
 
1273
1273
  var getRandomValues = function () {
1274
- if (typeof crypto !== 'undefined') {
1274
+ var _crypto;
1275
+
1276
+ if (typeof crypto !== 'undefined' && typeof ((_crypto = crypto) === null || _crypto === void 0 ? void 0 : _crypto.getRandomValues) !== 'undefined') {
1275
1277
  return crypto.getRandomValues.bind(crypto);
1276
1278
  } else if (typeof msCrypto !== 'undefined') {
1277
1279
  return msCrypto.getRandomValues.bind(msCrypto);
@@ -1514,7 +1516,7 @@ var Channel = /*#__PURE__*/function () {
1514
1516
  return this._client;
1515
1517
  }
1516
1518
  /**
1517
- * getConfig - Get the configs for this channel type
1519
+ * getConfig - Get the config for this channel id (cid)
1518
1520
  *
1519
1521
  * @return {Record<string, unknown>}
1520
1522
  */
@@ -1523,7 +1525,7 @@ var Channel = /*#__PURE__*/function () {
1523
1525
  key: "getConfig",
1524
1526
  value: function getConfig() {
1525
1527
  var client = this.getClient();
1526
- return client.configs[this.type];
1528
+ return client.configs[this.cid];
1527
1529
  }
1528
1530
  /**
1529
1531
  * sendMessage - Send a message to this channel
@@ -3192,7 +3194,7 @@ var Channel = /*#__PURE__*/function () {
3192
3194
  }
3193
3195
  }
3194
3196
 
3195
- this.getClient()._addChannelConfig(state); // add any messages to our channel state
3197
+ this.getClient()._addChannelConfig(state.channel); // add any messages to our channel state
3196
3198
 
3197
3199
 
3198
3200
  _this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
@@ -3917,22 +3919,13 @@ var Channel = /*#__PURE__*/function () {
3917
3919
  }
3918
3920
 
3919
3921
  if (state.members) {
3920
- var _iterator4 = _createForOfIteratorHelper$2(state.members),
3921
- _step4;
3922
-
3923
- try {
3924
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3925
- var _member = _step4.value;
3926
-
3927
- if (_member.user) {
3928
- this.state.members[_member.user.id] = _member;
3929
- }
3922
+ this.state.members = state.members.reduce(function (acc, member) {
3923
+ if (member.user) {
3924
+ acc[member.user.id] = member;
3930
3925
  }
3931
- } catch (err) {
3932
- _iterator4.e(err);
3933
- } finally {
3934
- _iterator4.f();
3935
- }
3926
+
3927
+ return acc;
3928
+ }, {});
3936
3929
  }
3937
3930
 
3938
3931
  return {
@@ -6085,6 +6078,8 @@ var StreamChat = /*#__PURE__*/function () {
6085
6078
 
6086
6079
  _defineProperty__default['default'](this, "defaultWSTimeout", void 0);
6087
6080
 
6081
+ _defineProperty__default['default'](this, "nextRequestAbortController", null);
6082
+
6088
6083
  _defineProperty__default['default'](this, "_getConnectionID", function () {
6089
6084
  var _this$wsConnection, _this$wsFallback;
6090
6085
 
@@ -7576,7 +7571,7 @@ var StreamChat = /*#__PURE__*/function () {
7576
7571
  }
7577
7572
 
7578
7573
  if (event.channel && event.type === 'notification.message_new') {
7579
- this.configs[event.channel.type] = event.channel.config;
7574
+ this._addChannelConfig(event.channel);
7580
7575
  }
7581
7576
 
7582
7577
  if (event.type === 'notification.channel_mutes_updated' && (_event$me = event.me) !== null && _event$me !== void 0 && _event$me.channel_mutes) {
@@ -8053,7 +8048,7 @@ var StreamChat = /*#__PURE__*/function () {
8053
8048
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
8054
8049
  var channelState = _step2.value;
8055
8050
 
8056
- this._addChannelConfig(channelState);
8051
+ this._addChannelConfig(channelState.channel);
8057
8052
  }
8058
8053
  } catch (err) {
8059
8054
  _iterator2.e(err);
@@ -8374,8 +8369,10 @@ var StreamChat = /*#__PURE__*/function () {
8374
8369
  }()
8375
8370
  }, {
8376
8371
  key: "_addChannelConfig",
8377
- value: function _addChannelConfig(channelState) {
8378
- this.configs[channelState.channel.type] = channelState.channel.config;
8372
+ value: function _addChannelConfig(_ref8) {
8373
+ var cid = _ref8.cid,
8374
+ config = _ref8.config;
8375
+ this.configs[cid] = config;
8379
8376
  }
8380
8377
  /**
8381
8378
  * channel - Returns a new channel with the given type, id and custom data
@@ -9854,7 +9851,7 @@ var StreamChat = /*#__PURE__*/function () {
9854
9851
  }, {
9855
9852
  key: "getUserAgent",
9856
9853
  value: function getUserAgent() {
9857
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "7.1.0");
9854
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.0.0-dev.0");
9858
9855
  }
9859
9856
  }, {
9860
9857
  key: "setUserAgent",
@@ -9881,6 +9878,12 @@ var StreamChat = /*#__PURE__*/function () {
9881
9878
  var authorization = token ? {
9882
9879
  Authorization: token
9883
9880
  } : undefined;
9881
+ var signal = null;
9882
+
9883
+ if (this.nextRequestAbortController !== null) {
9884
+ signal = this.nextRequestAbortController.signal;
9885
+ this.nextRequestAbortController = null;
9886
+ }
9884
9887
 
9885
9888
  if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
9886
9889
  options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
@@ -9888,7 +9891,7 @@ var StreamChat = /*#__PURE__*/function () {
9888
9891
  });
9889
9892
  }
9890
9893
 
9891
- return _objectSpread({
9894
+ return _objectSpread(_objectSpread({
9892
9895
  params: _objectSpread({
9893
9896
  user_id: this.userID,
9894
9897
  connection_id: this._getConnectionID(),
@@ -9898,7 +9901,9 @@ var StreamChat = /*#__PURE__*/function () {
9898
9901
  'stream-auth-type': this.getAuthType(),
9899
9902
  'X-Stream-Client': this.getUserAgent()
9900
9903
  }, options.headers)
9901
- }, options.config);
9904
+ }, signal ? {
9905
+ signal: signal
9906
+ } : {}), options.config);
9902
9907
  }
9903
9908
  }, {
9904
9909
  key: "_getToken",
@@ -11054,13 +11059,13 @@ var StreamChat = /*#__PURE__*/function () {
11054
11059
  }, {
11055
11060
  key: "deletePushProvider",
11056
11061
  value: function () {
11057
- var _deletePushProvider = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee76(_ref8) {
11062
+ var _deletePushProvider = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee76(_ref9) {
11058
11063
  var type, name;
11059
11064
  return _regeneratorRuntime__default['default'].wrap(function _callee76$(_context76) {
11060
11065
  while (1) {
11061
11066
  switch (_context76.prev = _context76.next) {
11062
11067
  case 0:
11063
- type = _ref8.type, name = _ref8.name;
11068
+ type = _ref9.type, name = _ref9.name;
11064
11069
  _context76.next = 3;
11065
11070
  return this.delete(this.baseURL + "/push_providers/".concat(type, "/").concat(name));
11066
11071
 
@@ -11117,6 +11122,15 @@ var StreamChat = /*#__PURE__*/function () {
11117
11122
 
11118
11123
  return listPushProviders;
11119
11124
  }()
11125
+ /**
11126
+ * creates an abort controller that will be used by the next HTTP Request.
11127
+ */
11128
+
11129
+ }, {
11130
+ key: "createAbortControllerForNextRequest",
11131
+ value: function createAbortControllerForNextRequest() {
11132
+ return this.nextRequestAbortController = new AbortController();
11133
+ }
11120
11134
  }], [{
11121
11135
  key: "getInstance",
11122
11136
  value: function getInstance(key, secretOrOptions, options) {