@liveblocks/core 2.9.3-experimental1 → 2.10.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.mjs CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "2.9.3-experimental1";
9
+ var PKG_VERSION = "2.10.0";
10
10
  var PKG_FORMAT = "esm";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -1881,6 +1881,16 @@ function createBatchStore(batch) {
1881
1881
  cache.set(cacheKey, state);
1882
1882
  eventSource2.notify();
1883
1883
  }
1884
+ function invalidate(inputs) {
1885
+ if (Array.isArray(inputs)) {
1886
+ for (const input of inputs) {
1887
+ cache.delete(getCacheKey(input));
1888
+ }
1889
+ } else {
1890
+ cache.clear();
1891
+ }
1892
+ eventSource2.notify();
1893
+ }
1884
1894
  async function get(input) {
1885
1895
  const cacheKey = getCacheKey(input);
1886
1896
  if (cache.has(cacheKey)) {
@@ -1901,10 +1911,15 @@ function createBatchStore(batch) {
1901
1911
  const cacheKey = getCacheKey(input);
1902
1912
  return cache.get(cacheKey);
1903
1913
  }
1914
+ function _cacheKeys() {
1915
+ return [...cache.keys()];
1916
+ }
1904
1917
  return {
1905
1918
  ...eventSource2.observable,
1906
1919
  get,
1907
- getState
1920
+ getState,
1921
+ invalidate,
1922
+ _cacheKeys
1908
1923
  };
1909
1924
  }
1910
1925
 
@@ -7330,6 +7345,9 @@ function createClient(options) {
7330
7345
  { delay: RESOLVE_USERS_BATCH_DELAY }
7331
7346
  );
7332
7347
  const usersStore = createBatchStore(batchedResolveUsers);
7348
+ function invalidateResolvedUsers(userIds) {
7349
+ usersStore.invalidate(userIds);
7350
+ }
7333
7351
  const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
7334
7352
  const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
7335
7353
  () => !resolveRoomsInfo,
@@ -7345,15 +7363,29 @@ function createClient(options) {
7345
7363
  { delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
7346
7364
  );
7347
7365
  const roomsInfoStore = createBatchStore(batchedResolveRoomsInfo);
7366
+ function invalidateResolvedRoomsInfo(roomIds) {
7367
+ roomsInfoStore.invalidate(roomIds);
7368
+ }
7369
+ const mentionSuggestionsCache = /* @__PURE__ */ new Map();
7370
+ function invalidateResolvedMentionSuggestions() {
7371
+ mentionSuggestionsCache.clear();
7372
+ }
7348
7373
  return Object.defineProperty(
7349
7374
  {
7350
7375
  enterRoom,
7351
7376
  getRoom,
7352
7377
  logout,
7353
7378
  ...httpClientLike,
7379
+ // Advanced resolvers APIs
7380
+ resolvers: {
7381
+ invalidateUsers: invalidateResolvedUsers,
7382
+ invalidateRoomsInfo: invalidateResolvedRoomsInfo,
7383
+ invalidateMentionSuggestions: invalidateResolvedMentionSuggestions
7384
+ },
7354
7385
  // Internal
7355
7386
  [kInternal]: {
7356
7387
  currentUserIdStore,
7388
+ mentionSuggestionsCache,
7357
7389
  resolveMentionSuggestions: clientOptions.resolveMentionSuggestions,
7358
7390
  usersStore,
7359
7391
  roomsInfoStore,