@liveblocks/react 0.18.0-beta1 → 0.18.0-beta2
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/.built-by-link-script +1 -1
- package/index.d.ts +11 -11
- package/index.js +7 -11
- package/package.json +2 -2
package/.built-by-link-script
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
b78a4b6045d3aab4fd9a5e4686ccac3b534923fe
|
package/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
59
59
|
* All the modifications are merged in a single history item (undo/redo).
|
|
60
60
|
* All the subscribers are called only after the batch is over.
|
|
61
61
|
*/
|
|
62
|
-
useBatch(): (callback: () =>
|
|
62
|
+
useBatch<T>(): (callback: () => T) => T;
|
|
63
63
|
/**
|
|
64
64
|
* Returns a callback that lets you broadcast custom events to other users in the room
|
|
65
65
|
*
|
|
@@ -173,7 +173,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
173
173
|
* return the result of a .map() or .filter() call from the selector. In
|
|
174
174
|
* those cases, you'll probably want to use a `shallow` comparison check.
|
|
175
175
|
*/
|
|
176
|
-
useStorage<T>(selector: (root: ToImmutable<TStorage>) => T, isEqual?: (
|
|
176
|
+
useStorage<T>(selector: (root: ToImmutable<TStorage>) => T, isEqual?: (prev: T, curr: T) => boolean): T | null;
|
|
177
177
|
/**
|
|
178
178
|
* Returns the presence of the current user of the current room, and a function to update it.
|
|
179
179
|
* It is different from the setState function returned by the useState hook from React.
|
|
@@ -233,7 +233,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
233
233
|
* const someoneIsTyping = useOthers(users => users.some(u => u.presence.isTyping));
|
|
234
234
|
*
|
|
235
235
|
*/
|
|
236
|
-
useOthers<T>(selector: (others: Others<TPresence, TUserMeta>) => T, isEqual?: (
|
|
236
|
+
useOthers<T>(selector: (others: Others<TPresence, TUserMeta>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
237
237
|
/**
|
|
238
238
|
* Related to useOthers(), but optimized for selecting only "subsets" of
|
|
239
239
|
* others. This is useful for performance reasons in particular, because
|
|
@@ -274,7 +274,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
274
274
|
* shallow, // ❗️
|
|
275
275
|
* );
|
|
276
276
|
*/
|
|
277
|
-
useOtherIds<T>(itemSelector: (other: User<TPresence, TUserMeta>) => T, isEqual?: (
|
|
277
|
+
useOtherIds<T>(itemSelector: (other: User<TPresence, TUserMeta>) => T, isEqual?: (prev: T, curr: T) => boolean): readonly {
|
|
278
278
|
readonly connectionId: number;
|
|
279
279
|
readonly data: T;
|
|
280
280
|
}[];
|
|
@@ -297,7 +297,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
297
297
|
* // Returns only the selected values re-renders whenever that selection changes)
|
|
298
298
|
* const { x, y } = useOther(2, user => user.presence.cursor);
|
|
299
299
|
*/
|
|
300
|
-
useOther<T>(connectionId: number, selector: (other: User<TPresence, TUserMeta>) => T, isEqual?: (
|
|
300
|
+
useOther<T>(connectionId: number, selector: (other: User<TPresence, TUserMeta>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
301
301
|
/**
|
|
302
302
|
* Returns the Room of the nearest RoomProvider above in the React component
|
|
303
303
|
* tree.
|
|
@@ -334,7 +334,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
334
334
|
* }
|
|
335
335
|
*
|
|
336
336
|
*/
|
|
337
|
-
useSelf<T>(selector: (me: User<TPresence, TUserMeta>) => T, isEqual?: (
|
|
337
|
+
useSelf<T>(selector: (me: User<TPresence, TUserMeta>) => T, isEqual?: (prev: T, curr: T) => boolean): T | null;
|
|
338
338
|
/**
|
|
339
339
|
* Returns the mutable (!) Storage root. This hook exists for
|
|
340
340
|
* backward-compatible reasons.
|
|
@@ -360,18 +360,18 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
360
360
|
useMutation<F extends (context: MutationContext<TPresence, TStorage>, ...args: any[]) => any>(callback: F, deps?: unknown[]): OmitFirstArg<F>;
|
|
361
361
|
suspense: {
|
|
362
362
|
useStorage(): ToImmutable<TStorage>;
|
|
363
|
-
useStorage<T>(selector: (root: ToImmutable<TStorage>) => T, isEqual?: (
|
|
363
|
+
useStorage<T>(selector: (root: ToImmutable<TStorage>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
364
364
|
useSelf(): User<TPresence, TUserMeta>;
|
|
365
|
-
useSelf<T>(selector: (me: User<TPresence, TUserMeta>) => T, isEqual?: (
|
|
365
|
+
useSelf<T>(selector: (me: User<TPresence, TUserMeta>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
366
366
|
useOthers(): Others<TPresence, TUserMeta>;
|
|
367
|
-
useOthers<T>(selector: (others: Others<TPresence, TUserMeta>) => T, isEqual?: (
|
|
367
|
+
useOthers<T>(selector: (others: Others<TPresence, TUserMeta>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
368
368
|
useOtherIds(): readonly number[];
|
|
369
|
-
useOtherIds<T>(itemSelector: (other: User<TPresence, TUserMeta>) => T, isEqual?: (
|
|
369
|
+
useOtherIds<T>(itemSelector: (other: User<TPresence, TUserMeta>) => T, isEqual?: (prev: T, curr: T) => boolean): readonly {
|
|
370
370
|
readonly connectionId: number;
|
|
371
371
|
readonly data: T;
|
|
372
372
|
}[];
|
|
373
373
|
useOther(connectionId: number): User<TPresence, TUserMeta>;
|
|
374
|
-
useOther<T>(connectionId: number, selector: (other: User<TPresence, TUserMeta>) => T, isEqual?: (
|
|
374
|
+
useOther<T>(connectionId: number, selector: (other: User<TPresence, TUserMeta>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
375
375
|
useList<TKey extends Extract<keyof TStorage, string>>(key: TKey): TStorage[TKey];
|
|
376
376
|
useMap<TKey extends Extract<keyof TStorage, string>>(key: TKey): TStorage[TKey];
|
|
377
377
|
useObject<TKey extends Extract<keyof TStorage, string>>(key: TKey): TStorage[TKey];
|
package/index.js
CHANGED
|
@@ -165,12 +165,12 @@ function createRoomContext(client) {
|
|
|
165
165
|
[connectionId, selector]
|
|
166
166
|
);
|
|
167
167
|
const wrappedIsEqual = _useCallback(
|
|
168
|
-
(
|
|
169
|
-
if (
|
|
170
|
-
return
|
|
168
|
+
(prev, curr) => {
|
|
169
|
+
if (prev === sentinel || curr === sentinel) {
|
|
170
|
+
return prev === curr;
|
|
171
171
|
}
|
|
172
172
|
const eq = isEqual != null ? isEqual : Object.is;
|
|
173
|
-
return eq(
|
|
173
|
+
return eq(prev, curr);
|
|
174
174
|
},
|
|
175
175
|
[isEqual]
|
|
176
176
|
);
|
|
@@ -399,13 +399,9 @@ function createRoomContext(client) {
|
|
|
399
399
|
root,
|
|
400
400
|
setMyPresence
|
|
401
401
|
};
|
|
402
|
-
return (...args) =>
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
rv = callback(mutationCtx, ...args);
|
|
406
|
-
});
|
|
407
|
-
return rv;
|
|
408
|
-
};
|
|
402
|
+
return (...args) => room.batch(
|
|
403
|
+
() => callback(mutationCtx, ...args)
|
|
404
|
+
);
|
|
409
405
|
} else {
|
|
410
406
|
return () => {
|
|
411
407
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/react",
|
|
3
|
-
"version": "0.18.0-
|
|
3
|
+
"version": "0.18.0-beta2",
|
|
4
4
|
"description": "A set of React hooks and providers to use Liveblocks declaratively.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.mjs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"use-sync-external-store": "^1.2.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@liveblocks/client": "0.18.0-
|
|
30
|
+
"@liveblocks/client": "0.18.0-beta2",
|
|
31
31
|
"react": "^16.14.0 || ^17 || ^18"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|