@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.d.mts +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -936,6 +936,7 @@ declare function makeEventSource<T>(): EventSource<T>;
|
|
|
936
936
|
declare type BatchStore<O, I> = Observable<void> & {
|
|
937
937
|
get: (input: I) => Promise<void>;
|
|
938
938
|
getState: (input: I) => AsyncResult<O> | undefined;
|
|
939
|
+
invalidate: (inputs?: I[]) => void;
|
|
939
940
|
};
|
|
940
941
|
|
|
941
942
|
/**
|
|
@@ -2371,6 +2372,7 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
|
|
|
2371
2372
|
*/
|
|
2372
2373
|
declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
|
|
2373
2374
|
readonly currentUserIdStore: Store<string | null>;
|
|
2375
|
+
readonly mentionSuggestionsCache: Map<string, string[]>;
|
|
2374
2376
|
readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
|
|
2375
2377
|
readonly usersStore: BatchStore<U["info"] | undefined, string>;
|
|
2376
2378
|
readonly roomsInfoStore: BatchStore<DRI | undefined, string>;
|
|
@@ -2520,6 +2522,43 @@ declare type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> =
|
|
|
2520
2522
|
* Call this whenever you log out a user in your application.
|
|
2521
2523
|
*/
|
|
2522
2524
|
logout(): void;
|
|
2525
|
+
/**
|
|
2526
|
+
* Advanced APIs related to the resolvers.
|
|
2527
|
+
*/
|
|
2528
|
+
resolvers: {
|
|
2529
|
+
/**
|
|
2530
|
+
* Invalidate some or all users that were previously cached by `resolveUsers`.
|
|
2531
|
+
*
|
|
2532
|
+
* @example
|
|
2533
|
+
* // Invalidate all users
|
|
2534
|
+
* client.resolvers.invalidateUsers();
|
|
2535
|
+
*
|
|
2536
|
+
* @example
|
|
2537
|
+
* // Invalidate specific users
|
|
2538
|
+
* client.resolvers.invalidateUsers(["user-1", "user-2"]);
|
|
2539
|
+
*/
|
|
2540
|
+
invalidateUsers(userIds?: string[]): void;
|
|
2541
|
+
/**
|
|
2542
|
+
* Invalidate some or all rooms info that were previously cached by `resolveRoomsInfo`.
|
|
2543
|
+
*
|
|
2544
|
+
* @example
|
|
2545
|
+
* // Invalidate all rooms
|
|
2546
|
+
* client.resolvers.invalidateRoomsInfo();
|
|
2547
|
+
*
|
|
2548
|
+
* @example
|
|
2549
|
+
* // Invalidate specific rooms
|
|
2550
|
+
* client.resolvers.invalidateRoomsInfo(["room-1", "room-2"]);
|
|
2551
|
+
*/
|
|
2552
|
+
invalidateRoomsInfo(roomIds?: string[]): void;
|
|
2553
|
+
/**
|
|
2554
|
+
* Invalidate all mention suggestions cached by `resolveMentionSuggestions`.
|
|
2555
|
+
*
|
|
2556
|
+
* @example
|
|
2557
|
+
* // Invalidate all mention suggestions
|
|
2558
|
+
* client.resolvers.invalidateMentionSuggestions();
|
|
2559
|
+
*/
|
|
2560
|
+
invalidateMentionSuggestions(): void;
|
|
2561
|
+
};
|
|
2523
2562
|
/**
|
|
2524
2563
|
* @private
|
|
2525
2564
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -936,6 +936,7 @@ declare function makeEventSource<T>(): EventSource<T>;
|
|
|
936
936
|
declare type BatchStore<O, I> = Observable<void> & {
|
|
937
937
|
get: (input: I) => Promise<void>;
|
|
938
938
|
getState: (input: I) => AsyncResult<O> | undefined;
|
|
939
|
+
invalidate: (inputs?: I[]) => void;
|
|
939
940
|
};
|
|
940
941
|
|
|
941
942
|
/**
|
|
@@ -2371,6 +2372,7 @@ declare type EnterOptions<P extends JsonObject = DP, S extends LsonObject = DS>
|
|
|
2371
2372
|
*/
|
|
2372
2373
|
declare type PrivateClientApi<U extends BaseUserMeta, M extends BaseMetadata> = {
|
|
2373
2374
|
readonly currentUserIdStore: Store<string | null>;
|
|
2375
|
+
readonly mentionSuggestionsCache: Map<string, string[]>;
|
|
2374
2376
|
readonly resolveMentionSuggestions: ClientOptions<U>["resolveMentionSuggestions"];
|
|
2375
2377
|
readonly usersStore: BatchStore<U["info"] | undefined, string>;
|
|
2376
2378
|
readonly roomsInfoStore: BatchStore<DRI | undefined, string>;
|
|
@@ -2520,6 +2522,43 @@ declare type Client<U extends BaseUserMeta = DU, M extends BaseMetadata = DM> =
|
|
|
2520
2522
|
* Call this whenever you log out a user in your application.
|
|
2521
2523
|
*/
|
|
2522
2524
|
logout(): void;
|
|
2525
|
+
/**
|
|
2526
|
+
* Advanced APIs related to the resolvers.
|
|
2527
|
+
*/
|
|
2528
|
+
resolvers: {
|
|
2529
|
+
/**
|
|
2530
|
+
* Invalidate some or all users that were previously cached by `resolveUsers`.
|
|
2531
|
+
*
|
|
2532
|
+
* @example
|
|
2533
|
+
* // Invalidate all users
|
|
2534
|
+
* client.resolvers.invalidateUsers();
|
|
2535
|
+
*
|
|
2536
|
+
* @example
|
|
2537
|
+
* // Invalidate specific users
|
|
2538
|
+
* client.resolvers.invalidateUsers(["user-1", "user-2"]);
|
|
2539
|
+
*/
|
|
2540
|
+
invalidateUsers(userIds?: string[]): void;
|
|
2541
|
+
/**
|
|
2542
|
+
* Invalidate some or all rooms info that were previously cached by `resolveRoomsInfo`.
|
|
2543
|
+
*
|
|
2544
|
+
* @example
|
|
2545
|
+
* // Invalidate all rooms
|
|
2546
|
+
* client.resolvers.invalidateRoomsInfo();
|
|
2547
|
+
*
|
|
2548
|
+
* @example
|
|
2549
|
+
* // Invalidate specific rooms
|
|
2550
|
+
* client.resolvers.invalidateRoomsInfo(["room-1", "room-2"]);
|
|
2551
|
+
*/
|
|
2552
|
+
invalidateRoomsInfo(roomIds?: string[]): void;
|
|
2553
|
+
/**
|
|
2554
|
+
* Invalidate all mention suggestions cached by `resolveMentionSuggestions`.
|
|
2555
|
+
*
|
|
2556
|
+
* @example
|
|
2557
|
+
* // Invalidate all mention suggestions
|
|
2558
|
+
* client.resolvers.invalidateMentionSuggestions();
|
|
2559
|
+
*/
|
|
2560
|
+
invalidateMentionSuggestions(): void;
|
|
2561
|
+
};
|
|
2523
2562
|
/**
|
|
2524
2563
|
* @private
|
|
2525
2564
|
*
|
package/dist/index.js
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
|
+
var PKG_VERSION = "2.10.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
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,
|