@liveblocks/react 3.3.4 → 3.4.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/_private.cjs +5 -5
- package/dist/_private.js +1 -1
- package/dist/{chunk-FRJTGF46.cjs → chunk-JP4MG2VP.cjs} +2 -2
- package/dist/{chunk-FRJTGF46.cjs.map → chunk-JP4MG2VP.cjs.map} +1 -1
- package/dist/{chunk-TPVRRXA7.cjs → chunk-KEDRXCJD.cjs} +24 -20
- package/dist/chunk-KEDRXCJD.cjs.map +1 -0
- package/dist/{chunk-BZXNKY7M.js → chunk-TYQDESJE.js} +34 -30
- package/dist/chunk-TYQDESJE.js.map +1 -0
- package/dist/{chunk-DU4NTX4P.js → chunk-X4R5LG7N.js} +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.js +2 -2
- package/dist/suspense.cjs +4 -4
- package/dist/suspense.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-BZXNKY7M.js.map +0 -1
- package/dist/chunk-TPVRRXA7.cjs.map +0 -1
- /package/dist/{chunk-DU4NTX4P.js.map → chunk-X4R5LG7N.js.map} +0 -0
|
@@ -180,7 +180,7 @@ import {
|
|
|
180
180
|
import {
|
|
181
181
|
useCallback as useCallback2,
|
|
182
182
|
useEffect as useEffect4,
|
|
183
|
-
useMemo as
|
|
183
|
+
useMemo as useMemo3,
|
|
184
184
|
useState as useState2,
|
|
185
185
|
useSyncExternalStore as useSyncExternalStore2
|
|
186
186
|
} from "react";
|
|
@@ -240,18 +240,19 @@ function ensureNotServerSide() {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
// src/lib/use-initial.ts
|
|
243
|
-
import { useCallback,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const
|
|
243
|
+
import { useCallback, useMemo as useMemo2 } from "react";
|
|
244
|
+
function useInitial(value, roomId) {
|
|
245
|
+
return useMemo2(() => value, [roomId]);
|
|
246
|
+
}
|
|
247
|
+
function useInitialUnlessFunction(latestValue, roomId) {
|
|
248
|
+
const frozenValue = useInitial(latestValue, roomId);
|
|
249
|
+
const ref = useLatest(latestValue);
|
|
250
|
+
const wrapper = useCallback(
|
|
251
|
+
(...args) => ref.current(...args),
|
|
252
|
+
[ref]
|
|
253
|
+
);
|
|
250
254
|
if (typeof frozenValue === "function") {
|
|
251
|
-
|
|
252
|
-
return useCallback((...args) => ref.current(...args), [
|
|
253
|
-
ref
|
|
254
|
-
]);
|
|
255
|
+
return wrapper;
|
|
255
256
|
} else {
|
|
256
257
|
return frozenValue;
|
|
257
258
|
}
|
|
@@ -508,7 +509,7 @@ function usify(promise) {
|
|
|
508
509
|
);
|
|
509
510
|
return usable;
|
|
510
511
|
}
|
|
511
|
-
var
|
|
512
|
+
var noop = Promise.resolve();
|
|
512
513
|
var PaginatedResource = class {
|
|
513
514
|
#signal;
|
|
514
515
|
signal;
|
|
@@ -552,7 +553,7 @@ var PaginatedResource = class {
|
|
|
552
553
|
}
|
|
553
554
|
fetchMore() {
|
|
554
555
|
const state = this.#signal.get();
|
|
555
|
-
if (!state.data?.cursor) return
|
|
556
|
+
if (!state.data?.cursor) return noop;
|
|
556
557
|
if (!this.#pendingFetchMore) {
|
|
557
558
|
this.#pendingFetchMore = this.#fetchMore().finally(() => {
|
|
558
559
|
this.#pendingFetchMore = null;
|
|
@@ -2393,7 +2394,7 @@ function useNotificationSettings_withClient(client) {
|
|
|
2393
2394
|
};
|
|
2394
2395
|
}, [poller]);
|
|
2395
2396
|
const result = useSignal(store.outputs.notificationSettings.signal);
|
|
2396
|
-
return
|
|
2397
|
+
return useMemo3(() => {
|
|
2397
2398
|
return [result, updateNotificationSettings];
|
|
2398
2399
|
}, [result, updateNotificationSettings]);
|
|
2399
2400
|
}
|
|
@@ -2404,7 +2405,7 @@ function useNotificationSettingsSuspense_withClient(client) {
|
|
|
2404
2405
|
const [result, updateNotificationSettings] = useNotificationSettings_withClient(client);
|
|
2405
2406
|
assert(!result.error, "Did not expect error");
|
|
2406
2407
|
assert(!result.isLoading, "Did not expect loading");
|
|
2407
|
-
return
|
|
2408
|
+
return useMemo3(() => {
|
|
2408
2409
|
return [result, updateNotificationSettings];
|
|
2409
2410
|
}, [result, updateNotificationSettings]);
|
|
2410
2411
|
}
|
|
@@ -2775,7 +2776,7 @@ function LiveblocksProvider(props) {
|
|
|
2775
2776
|
o.enableDebugLogging
|
|
2776
2777
|
)
|
|
2777
2778
|
};
|
|
2778
|
-
const client =
|
|
2779
|
+
const client = useMemo3(() => createClient(options), []);
|
|
2779
2780
|
useEffect4(() => {
|
|
2780
2781
|
return () => {
|
|
2781
2782
|
client[kInternal3].ai.disconnect();
|
|
@@ -2954,7 +2955,7 @@ import {
|
|
|
2954
2955
|
import {
|
|
2955
2956
|
useCallback as useCallback3,
|
|
2956
2957
|
useEffect as useEffect6,
|
|
2957
|
-
useMemo as
|
|
2958
|
+
useMemo as useMemo4,
|
|
2958
2959
|
useRef as useRef3,
|
|
2959
2960
|
useState as useState3,
|
|
2960
2961
|
useSyncExternalStore as useSyncExternalStore3,
|
|
@@ -2992,7 +2993,7 @@ function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
|
|
|
2992
2993
|
|
|
2993
2994
|
// src/room.tsx
|
|
2994
2995
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
2995
|
-
var
|
|
2996
|
+
var noop2 = () => {
|
|
2996
2997
|
};
|
|
2997
2998
|
var identity3 = (x) => x;
|
|
2998
2999
|
var STABLE_EMPTY_LIST = Object.freeze([]);
|
|
@@ -3286,11 +3287,14 @@ function RoomProviderInner(props) {
|
|
|
3286
3287
|
`React ${requiredVersion} or higher is required (you\u2019re on ${reactVersion})`
|
|
3287
3288
|
);
|
|
3288
3289
|
}
|
|
3289
|
-
const frozenProps = useInitial(
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3290
|
+
const frozenProps = useInitial(
|
|
3291
|
+
{
|
|
3292
|
+
initialPresence: props.initialPresence,
|
|
3293
|
+
initialStorage: props.initialStorage,
|
|
3294
|
+
autoConnect: props.autoConnect ?? typeof window !== "undefined"
|
|
3295
|
+
},
|
|
3296
|
+
roomId
|
|
3297
|
+
);
|
|
3294
3298
|
const [{ room }, setRoomLeavePair] = useState3(
|
|
3295
3299
|
() => stableEnterRoom(roomId, {
|
|
3296
3300
|
...frozenProps,
|
|
@@ -3599,7 +3603,7 @@ function useStorage(selector, isEqual) {
|
|
|
3599
3603
|
[selector]
|
|
3600
3604
|
);
|
|
3601
3605
|
const subscribe = useCallback3(
|
|
3602
|
-
(onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) :
|
|
3606
|
+
(onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) : noop2,
|
|
3603
3607
|
[room, rootOrNull]
|
|
3604
3608
|
);
|
|
3605
3609
|
const getSnapshot = useCallback3(() => {
|
|
@@ -3622,7 +3626,7 @@ function useStorage(selector, isEqual) {
|
|
|
3622
3626
|
}
|
|
3623
3627
|
function useMutation(callback, deps) {
|
|
3624
3628
|
const room = useRoom();
|
|
3625
|
-
return
|
|
3629
|
+
return useMemo4(
|
|
3626
3630
|
() => {
|
|
3627
3631
|
return (...args) => (
|
|
3628
3632
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -4209,7 +4213,7 @@ function useThreadSubscription(threadId) {
|
|
|
4209
4213
|
function useRoomThreadSubscription(roomId, threadId) {
|
|
4210
4214
|
const client = useClient();
|
|
4211
4215
|
const { store } = getRoomExtrasForClient(client);
|
|
4212
|
-
const subscriptionKey =
|
|
4216
|
+
const subscriptionKey = useMemo4(
|
|
4213
4217
|
() => getSubscriptionKey2("thread", threadId),
|
|
4214
4218
|
[threadId]
|
|
4215
4219
|
);
|
|
@@ -4271,7 +4275,7 @@ function useRoomSubscriptionSettings() {
|
|
|
4271
4275
|
const settings = useSignal(
|
|
4272
4276
|
store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).signal
|
|
4273
4277
|
);
|
|
4274
|
-
return
|
|
4278
|
+
return useMemo4(() => {
|
|
4275
4279
|
return [settings, updateRoomSubscriptionSettings];
|
|
4276
4280
|
}, [settings, updateRoomSubscriptionSettings]);
|
|
4277
4281
|
}
|
|
@@ -4286,7 +4290,7 @@ function useRoomSubscriptionSettingsSuspense() {
|
|
|
4286
4290
|
const [settings, updateRoomSubscriptionSettings] = useRoomSubscriptionSettings();
|
|
4287
4291
|
assert2(!settings.error, "Did not expect error");
|
|
4288
4292
|
assert2(!settings.isLoading, "Did not expect loading");
|
|
4289
|
-
return
|
|
4293
|
+
return useMemo4(() => {
|
|
4290
4294
|
return [settings, updateRoomSubscriptionSettings];
|
|
4291
4295
|
}, [settings, updateRoomSubscriptionSettings]);
|
|
4292
4296
|
}
|
|
@@ -4672,4 +4676,4 @@ export {
|
|
|
4672
4676
|
_useStorageRoot,
|
|
4673
4677
|
_useUpdateMyPresence
|
|
4674
4678
|
};
|
|
4675
|
-
//# sourceMappingURL=chunk-
|
|
4679
|
+
//# sourceMappingURL=chunk-TYQDESJE.js.map
|