stream-chat 9.45.5 → 9.45.6

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.
@@ -14112,6 +14112,69 @@ var getPendingTaskChannelData = (cid) => {
14112
14112
  };
14113
14113
  };
14114
14114
 
14115
+ // src/utils/FixedSizeQueueCache.ts
14116
+ var FixedSizeQueueCache = class {
14117
+ constructor(size, options) {
14118
+ if (!size) throw new Error("Size must be greater than 0");
14119
+ this.keys = [];
14120
+ this.size = size;
14121
+ this.map = /* @__PURE__ */ new Map();
14122
+ this.dispose = options?.dispose ?? null;
14123
+ }
14124
+ /**
14125
+ * Adds a new or moves the existing reference to the front of the queue
14126
+ * @param key
14127
+ * @param value
14128
+ */
14129
+ add(key, value) {
14130
+ const index = this.keys.indexOf(key);
14131
+ if (index > -1) {
14132
+ this.keys.splice(this.keys.indexOf(key), 1);
14133
+ } else if (this.keys.length >= this.size) {
14134
+ const itemKey = this.keys.shift();
14135
+ if (itemKey) {
14136
+ const item = this.peek(itemKey);
14137
+ if (item) {
14138
+ this.dispose?.(itemKey, item);
14139
+ }
14140
+ this.map.delete(itemKey);
14141
+ }
14142
+ }
14143
+ this.keys.push(key);
14144
+ this.map.set(key, value);
14145
+ }
14146
+ /**
14147
+ * Retrieves the value by key.
14148
+ * @param key
14149
+ */
14150
+ peek(key) {
14151
+ const value = this.map.get(key);
14152
+ return value;
14153
+ }
14154
+ /**
14155
+ * Retrieves the value and moves it to the front of the queue.
14156
+ * @param key
14157
+ */
14158
+ get(key) {
14159
+ const foundItem = this.peek(key);
14160
+ if (foundItem && this.keys.indexOf(key) !== this.size - 1) {
14161
+ this.keys.splice(this.keys.indexOf(key), 1);
14162
+ this.keys.push(key);
14163
+ }
14164
+ return foundItem;
14165
+ }
14166
+ /**
14167
+ * Clears queue entirely and disposes of each item individually.
14168
+ */
14169
+ clear() {
14170
+ if (this.dispose) {
14171
+ this.map.forEach((entry, key) => this.dispose?.(key, entry));
14172
+ }
14173
+ this.map.clear();
14174
+ this.keys = [];
14175
+ }
14176
+ };
14177
+
14115
14178
  // src/client.ts
14116
14179
  function isString2(x) {
14117
14180
  return typeof x === "string" || x instanceof String;
@@ -14318,6 +14381,7 @@ var StreamChat = class _StreamChat {
14318
14381
  this.state = new ClientState({ client: this });
14319
14382
  this.threads.resetState();
14320
14383
  this.uploadManager.reset();
14384
+ this.messageComposerCache.clear();
14321
14385
  closePromise.finally(() => {
14322
14386
  this.tokenManager.reset();
14323
14387
  }).catch((err) => console.error(err));
@@ -14769,6 +14833,7 @@ var StreamChat = class _StreamChat {
14769
14833
  this.polls = new PollManager({ client: this });
14770
14834
  this.reminders = new ReminderManager({ client: this });
14771
14835
  this.messageDeliveryReporter = new MessageDeliveryReporter({ client: this });
14836
+ this.messageComposerCache = new FixedSizeQueueCache(64);
14772
14837
  }
14773
14838
  static getInstance(key, secretOrOptions, options) {
14774
14839
  if (!_StreamChat._instance) {
@@ -16641,7 +16706,7 @@ var StreamChat = class _StreamChat {
16641
16706
  if (this.userAgent) {
16642
16707
  return this.userAgent;
16643
16708
  }
16644
- const version = "9.45.5";
16709
+ const version = "9.45.6";
16645
16710
  const clientBundle = "browser-cjs";
16646
16711
  let userAgentString = "";
16647
16712
  if (this.sdkIdentifier) {
@@ -19239,57 +19304,4 @@ var _LiveLocationManager = class _LiveLocationManager extends WithSubscriptions
19239
19304
  };
19240
19305
  _LiveLocationManager.symbol = Symbol(_LiveLocationManager.name);
19241
19306
  var LiveLocationManager = _LiveLocationManager;
19242
-
19243
- // src/utils/FixedSizeQueueCache.ts
19244
- var FixedSizeQueueCache = class {
19245
- constructor(size, options) {
19246
- if (!size) throw new Error("Size must be greater than 0");
19247
- this.keys = [];
19248
- this.size = size;
19249
- this.map = /* @__PURE__ */ new Map();
19250
- this.dispose = options?.dispose ?? null;
19251
- }
19252
- /**
19253
- * Adds a new or moves the existing reference to the front of the queue
19254
- * @param key
19255
- * @param value
19256
- */
19257
- add(key, value) {
19258
- const index = this.keys.indexOf(key);
19259
- if (index > -1) {
19260
- this.keys.splice(this.keys.indexOf(key), 1);
19261
- } else if (this.keys.length >= this.size) {
19262
- const itemKey = this.keys.shift();
19263
- if (itemKey) {
19264
- const item = this.peek(itemKey);
19265
- if (item) {
19266
- this.dispose?.(itemKey, item);
19267
- }
19268
- this.map.delete(itemKey);
19269
- }
19270
- }
19271
- this.keys.push(key);
19272
- this.map.set(key, value);
19273
- }
19274
- /**
19275
- * Retrieves the value by key.
19276
- * @param key
19277
- */
19278
- peek(key) {
19279
- const value = this.map.get(key);
19280
- return value;
19281
- }
19282
- /**
19283
- * Retrieves the value and moves it to the front of the queue.
19284
- * @param key
19285
- */
19286
- get(key) {
19287
- const foundItem = this.peek(key);
19288
- if (foundItem && this.keys.indexOf(key) !== this.size - 1) {
19289
- this.keys.splice(this.keys.indexOf(key), 1);
19290
- this.keys.push(key);
19291
- }
19292
- return foundItem;
19293
- }
19294
- };
19295
19307
  //# sourceMappingURL=index.browser.js.map