@liveblocks/react 3.3.3 → 3.4.0-alpha1
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-TQGRXOMA.js → chunk-ACVALBTI.js} +2 -2
- package/dist/{chunk-V36VCKRB.cjs → chunk-KEDRXCJD.cjs} +29 -21
- package/dist/chunk-KEDRXCJD.cjs.map +1 -0
- package/dist/{chunk-XWK43YXO.cjs → chunk-M3QELTRL.cjs} +2 -2
- package/dist/{chunk-XWK43YXO.cjs.map → chunk-M3QELTRL.cjs.map} +1 -1
- package/dist/{chunk-UHR5FZDL.js → chunk-TYQDESJE.js} +39 -31
- package/dist/chunk-TYQDESJE.js.map +1 -0
- 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 +5 -5
- package/dist/chunk-UHR5FZDL.js.map +0 -1
- package/dist/chunk-V36VCKRB.cjs.map +0 -1
- /package/dist/{chunk-TQGRXOMA.js.map → chunk-ACVALBTI.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "3.
|
|
3
|
+
var PKG_VERSION = "3.4.0-alpha1";
|
|
4
4
|
var PKG_FORMAT = "cjs";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -20,4 +20,4 @@ function ClientSideSuspense(props) {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense;
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-M3QELTRL.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-M3QELTRL.cjs","../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":"AAAA;ACGO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,cAAA;AACvD,IAAM,WAAA,EAAgD,KAAA;ADD7D;AACA;AEJA,8BAA8C;AAkC1C,+CAAA;AAVG,SAAS,kBAAA,CAAmB,KAAA,EAAc;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAE5C,EAAA,8BAAA,CAAU,EAAA,GAAM;AAGd,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,CAAC,CAAC,CAAA;AAEL,EAAA,uBACE,6BAAA,eAAC,EAAA,EAAS,QAAA,EAAU,KAAA,CAAM,QAAA,EACvB,QAAA,EAAA,QAAA,EACG,OAAO,KAAA,CAAM,SAAA,IAAa,WAAA,EACxB,KAAA,CAAM,QAAA,CAAS,EAAA,EACf,KAAA,CAAM,SAAA,EACR,KAAA,CAAM,SAAA,CACZ,CAAA;AAEJ;AF5BA;AACA;AACE;AACA;AACA;AACA;AACF,iJAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-M3QELTRL.cjs","sourcesContent":[null,"declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n","import type { ReactNode } from \"react\";\nimport { Suspense, useEffect, useState } from \"react\";\n\ntype Props = {\n fallback: ReactNode;\n children: (() => ReactNode | undefined) | ReactNode | undefined;\n};\n\n/**\n * Almost like a normal <Suspense> component, except that for server-side\n * renders, the fallback will be used.\n *\n * The child props will have to be provided in a function, i.e. change:\n *\n * <Suspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </Suspense>\n *\n * To:\n *\n * <ClientSideSuspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </ClientSideSuspense>\n *\n */\nexport function ClientSideSuspense(props: Props) {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n // Effects are never executed on the server side. The point of this is to\n // delay the flipping of this boolean until after hydration has happened.\n setMounted(true);\n }, []);\n\n return (\n <Suspense fallback={props.fallback}>\n {mounted\n ? typeof props.children === \"function\"\n ? props.children()\n : props.children\n : props.fallback}\n </Suspense>\n );\n}\n"]}
|
|
@@ -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
|
}
|
|
@@ -2547,7 +2548,11 @@ function useAiChats(options) {
|
|
|
2547
2548
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
2548
2549
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
2549
2550
|
);
|
|
2550
|
-
return useSignal(
|
|
2551
|
+
return useSignal(
|
|
2552
|
+
store.outputs.aiChats.getOrCreate(queryKey).signal,
|
|
2553
|
+
identity2,
|
|
2554
|
+
shallow3
|
|
2555
|
+
);
|
|
2551
2556
|
}
|
|
2552
2557
|
function useAiChatsSuspense(options) {
|
|
2553
2558
|
ensureNotServerSide();
|
|
@@ -2771,7 +2776,7 @@ function LiveblocksProvider(props) {
|
|
|
2771
2776
|
o.enableDebugLogging
|
|
2772
2777
|
)
|
|
2773
2778
|
};
|
|
2774
|
-
const client =
|
|
2779
|
+
const client = useMemo3(() => createClient(options), []);
|
|
2775
2780
|
useEffect4(() => {
|
|
2776
2781
|
return () => {
|
|
2777
2782
|
client[kInternal3].ai.disconnect();
|
|
@@ -2950,7 +2955,7 @@ import {
|
|
|
2950
2955
|
import {
|
|
2951
2956
|
useCallback as useCallback3,
|
|
2952
2957
|
useEffect as useEffect6,
|
|
2953
|
-
useMemo as
|
|
2958
|
+
useMemo as useMemo4,
|
|
2954
2959
|
useRef as useRef3,
|
|
2955
2960
|
useState as useState3,
|
|
2956
2961
|
useSyncExternalStore as useSyncExternalStore3,
|
|
@@ -2988,7 +2993,7 @@ function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
|
|
|
2988
2993
|
|
|
2989
2994
|
// src/room.tsx
|
|
2990
2995
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
2991
|
-
var
|
|
2996
|
+
var noop2 = () => {
|
|
2992
2997
|
};
|
|
2993
2998
|
var identity3 = (x) => x;
|
|
2994
2999
|
var STABLE_EMPTY_LIST = Object.freeze([]);
|
|
@@ -3282,11 +3287,14 @@ function RoomProviderInner(props) {
|
|
|
3282
3287
|
`React ${requiredVersion} or higher is required (you\u2019re on ${reactVersion})`
|
|
3283
3288
|
);
|
|
3284
3289
|
}
|
|
3285
|
-
const frozenProps = useInitial(
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
+
const frozenProps = useInitial(
|
|
3291
|
+
{
|
|
3292
|
+
initialPresence: props.initialPresence,
|
|
3293
|
+
initialStorage: props.initialStorage,
|
|
3294
|
+
autoConnect: props.autoConnect ?? typeof window !== "undefined"
|
|
3295
|
+
},
|
|
3296
|
+
roomId
|
|
3297
|
+
);
|
|
3290
3298
|
const [{ room }, setRoomLeavePair] = useState3(
|
|
3291
3299
|
() => stableEnterRoom(roomId, {
|
|
3292
3300
|
...frozenProps,
|
|
@@ -3595,7 +3603,7 @@ function useStorage(selector, isEqual) {
|
|
|
3595
3603
|
[selector]
|
|
3596
3604
|
);
|
|
3597
3605
|
const subscribe = useCallback3(
|
|
3598
|
-
(onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) :
|
|
3606
|
+
(onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) : noop2,
|
|
3599
3607
|
[room, rootOrNull]
|
|
3600
3608
|
);
|
|
3601
3609
|
const getSnapshot = useCallback3(() => {
|
|
@@ -3618,7 +3626,7 @@ function useStorage(selector, isEqual) {
|
|
|
3618
3626
|
}
|
|
3619
3627
|
function useMutation(callback, deps) {
|
|
3620
3628
|
const room = useRoom();
|
|
3621
|
-
return
|
|
3629
|
+
return useMemo4(
|
|
3622
3630
|
() => {
|
|
3623
3631
|
return (...args) => (
|
|
3624
3632
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -4205,7 +4213,7 @@ function useThreadSubscription(threadId) {
|
|
|
4205
4213
|
function useRoomThreadSubscription(roomId, threadId) {
|
|
4206
4214
|
const client = useClient();
|
|
4207
4215
|
const { store } = getRoomExtrasForClient(client);
|
|
4208
|
-
const subscriptionKey =
|
|
4216
|
+
const subscriptionKey = useMemo4(
|
|
4209
4217
|
() => getSubscriptionKey2("thread", threadId),
|
|
4210
4218
|
[threadId]
|
|
4211
4219
|
);
|
|
@@ -4267,7 +4275,7 @@ function useRoomSubscriptionSettings() {
|
|
|
4267
4275
|
const settings = useSignal(
|
|
4268
4276
|
store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).signal
|
|
4269
4277
|
);
|
|
4270
|
-
return
|
|
4278
|
+
return useMemo4(() => {
|
|
4271
4279
|
return [settings, updateRoomSubscriptionSettings];
|
|
4272
4280
|
}, [settings, updateRoomSubscriptionSettings]);
|
|
4273
4281
|
}
|
|
@@ -4282,7 +4290,7 @@ function useRoomSubscriptionSettingsSuspense() {
|
|
|
4282
4290
|
const [settings, updateRoomSubscriptionSettings] = useRoomSubscriptionSettings();
|
|
4283
4291
|
assert2(!settings.error, "Did not expect error");
|
|
4284
4292
|
assert2(!settings.isLoading, "Did not expect loading");
|
|
4285
|
-
return
|
|
4293
|
+
return useMemo4(() => {
|
|
4286
4294
|
return [settings, updateRoomSubscriptionSettings];
|
|
4287
4295
|
}, [settings, updateRoomSubscriptionSettings]);
|
|
4288
4296
|
}
|
|
@@ -4668,4 +4676,4 @@ export {
|
|
|
4668
4676
|
_useStorageRoot,
|
|
4669
4677
|
_useUpdateMyPresence
|
|
4670
4678
|
};
|
|
4671
|
-
//# sourceMappingURL=chunk-
|
|
4679
|
+
//# sourceMappingURL=chunk-TYQDESJE.js.map
|