@liveblocks/react 3.6.1-preview1 → 3.7.0-preview1
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 +46 -8
- package/dist/_private.cjs.map +1 -1
- package/dist/_private.d.cts +8 -7
- package/dist/_private.d.ts +8 -7
- package/dist/_private.js +45 -7
- package/dist/_private.js.map +1 -1
- package/dist/{chunk-EEINMYNI.cjs → chunk-42HXAXED.cjs} +128 -62
- package/dist/chunk-42HXAXED.cjs.map +1 -0
- package/dist/{chunk-B5I7RQMM.js → chunk-AUFFB5BH.js} +2 -2
- package/dist/{chunk-I2UW4JM4.js → chunk-LYWCKEAX.js} +100 -34
- package/dist/chunk-LYWCKEAX.js.map +1 -0
- package/dist/{chunk-5WJEEON5.cjs → chunk-X5PYKCZB.cjs} +2 -2
- package/dist/{chunk-5WJEEON5.cjs.map → chunk-X5PYKCZB.cjs.map} +1 -1
- package/dist/index.cjs +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/{room-BE4TZf40.d.cts → room-RdHnZMhs.d.cts} +36 -8
- package/dist/{room-BE4TZf40.d.ts → room-RdHnZMhs.d.ts} +36 -8
- package/dist/suspense.cjs +6 -4
- package/dist/suspense.cjs.map +1 -1
- package/dist/suspense.d.cts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +4 -2
- package/dist/suspense.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-EEINMYNI.cjs.map +0 -1
- package/dist/chunk-I2UW4JM4.js.map +0 -1
- /package/dist/{chunk-B5I7RQMM.js.map → chunk-AUFFB5BH.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "3.
|
|
3
|
+
var PKG_VERSION = "3.7.0-preview1";
|
|
4
4
|
var PKG_FORMAT = "esm";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -20,4 +20,4 @@ export {
|
|
|
20
20
|
PKG_FORMAT,
|
|
21
21
|
ClientSideSuspense
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-AUFFB5BH.js.map
|
|
@@ -295,7 +295,6 @@ import {
|
|
|
295
295
|
createNotificationSettings,
|
|
296
296
|
DefaultMap,
|
|
297
297
|
DerivedSignal,
|
|
298
|
-
getMentionsFromCommentBody,
|
|
299
298
|
getSubscriptionKey,
|
|
300
299
|
kInternal as kInternal2,
|
|
301
300
|
MutableSignal as MutableSignal3,
|
|
@@ -1741,15 +1740,7 @@ function applyOptimisticUpdates_forSubscriptions(subscriptionsLUT, threads, opti
|
|
|
1741
1740
|
delete subscriptions[subscriptionKey];
|
|
1742
1741
|
break;
|
|
1743
1742
|
}
|
|
1744
|
-
// Create subscriptions for every threads in the room which the user participates in but doesn't have a subscription for yet
|
|
1745
1743
|
case "replies_and_mentions": {
|
|
1746
|
-
if (isThreadParticipant(thread, update.userId) && !subscriptions[subscriptionKey]) {
|
|
1747
|
-
subscriptions[subscriptionKey] = {
|
|
1748
|
-
kind: "thread",
|
|
1749
|
-
subjectId: thread.id,
|
|
1750
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
1751
|
-
};
|
|
1752
|
-
}
|
|
1753
1744
|
break;
|
|
1754
1745
|
}
|
|
1755
1746
|
default:
|
|
@@ -1950,27 +1941,6 @@ function upsertReaction(reactions, reaction) {
|
|
|
1950
1941
|
}
|
|
1951
1942
|
return reactions;
|
|
1952
1943
|
}
|
|
1953
|
-
function isThreadParticipant(thread, userId) {
|
|
1954
|
-
let isParticipant = false;
|
|
1955
|
-
for (const comment of thread.comments) {
|
|
1956
|
-
if (comment.deletedAt) {
|
|
1957
|
-
continue;
|
|
1958
|
-
}
|
|
1959
|
-
if (comment.userId === userId) {
|
|
1960
|
-
isParticipant = true;
|
|
1961
|
-
break;
|
|
1962
|
-
}
|
|
1963
|
-
const mentions = getMentionsFromCommentBody(
|
|
1964
|
-
comment.body,
|
|
1965
|
-
(mention) => mention.kind === "user" && mention.id === userId
|
|
1966
|
-
);
|
|
1967
|
-
if (mentions.length > 0) {
|
|
1968
|
-
isParticipant = true;
|
|
1969
|
-
break;
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
return isParticipant;
|
|
1973
|
-
}
|
|
1974
1944
|
|
|
1975
1945
|
// src/liveblocks.tsx
|
|
1976
1946
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1982,6 +1952,11 @@ function missingRoomInfoError(roomId) {
|
|
|
1982
1952
|
`resolveRoomsInfo didn't return anything for room '${roomId}'`
|
|
1983
1953
|
);
|
|
1984
1954
|
}
|
|
1955
|
+
function missingGroupInfoError(groupId) {
|
|
1956
|
+
return new Error(
|
|
1957
|
+
`resolveGroupsInfo didn't return anything for group '${groupId}'`
|
|
1958
|
+
);
|
|
1959
|
+
}
|
|
1985
1960
|
function identity2(x) {
|
|
1986
1961
|
return x;
|
|
1987
1962
|
}
|
|
@@ -2036,6 +2011,24 @@ function selectorFor_useRoomInfo(state, roomId) {
|
|
|
2036
2011
|
info: state.data
|
|
2037
2012
|
};
|
|
2038
2013
|
}
|
|
2014
|
+
function selectorFor_useGroupInfo(state, groupId) {
|
|
2015
|
+
if (state === void 0 || state?.isLoading) {
|
|
2016
|
+
return state ?? { isLoading: true };
|
|
2017
|
+
}
|
|
2018
|
+
if (state.error) {
|
|
2019
|
+
return state;
|
|
2020
|
+
}
|
|
2021
|
+
if (!state.data) {
|
|
2022
|
+
return {
|
|
2023
|
+
isLoading: false,
|
|
2024
|
+
error: missingGroupInfoError(groupId)
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
return {
|
|
2028
|
+
isLoading: false,
|
|
2029
|
+
info: state.data
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2039
2032
|
function getOrCreateContextBundle(client) {
|
|
2040
2033
|
let bundle = _bundles.get(client);
|
|
2041
2034
|
if (!bundle) {
|
|
@@ -2533,6 +2526,68 @@ function useRoomInfoSuspense_withClient(client, roomId) {
|
|
|
2533
2526
|
error: void 0
|
|
2534
2527
|
};
|
|
2535
2528
|
}
|
|
2529
|
+
function useGroupInfo_withClient(client, groupId) {
|
|
2530
|
+
const groupsInfoStore = client[kInternal3].groupsInfoStore;
|
|
2531
|
+
const getGroupInfoState = useCallback2(
|
|
2532
|
+
() => groupsInfoStore.getItemState(groupId),
|
|
2533
|
+
[groupsInfoStore, groupId]
|
|
2534
|
+
);
|
|
2535
|
+
const selector = useCallback2(
|
|
2536
|
+
(state) => selectorFor_useGroupInfo(state, groupId),
|
|
2537
|
+
[groupId]
|
|
2538
|
+
);
|
|
2539
|
+
const result = useSyncExternalStoreWithSelector(
|
|
2540
|
+
groupsInfoStore.subscribe,
|
|
2541
|
+
getGroupInfoState,
|
|
2542
|
+
getGroupInfoState,
|
|
2543
|
+
selector,
|
|
2544
|
+
shallow3
|
|
2545
|
+
);
|
|
2546
|
+
useEffect4(
|
|
2547
|
+
() => void groupsInfoStore.enqueue(groupId)
|
|
2548
|
+
// NOTE: Deliberately *not* using a dependency array here!
|
|
2549
|
+
//
|
|
2550
|
+
// It is important to call groupsInfoStore.enqueue on *every* render.
|
|
2551
|
+
// This is harmless though, on most renders, except:
|
|
2552
|
+
// 1. The very first render, in which case we'll want to trigger evaluation
|
|
2553
|
+
// of the groupId.
|
|
2554
|
+
// 2. All other subsequent renders now are a no-op (from the implementation
|
|
2555
|
+
// of .enqueue)
|
|
2556
|
+
// 3. If ever the groupId gets invalidated, the group info would be fetched again.
|
|
2557
|
+
);
|
|
2558
|
+
return result;
|
|
2559
|
+
}
|
|
2560
|
+
function useGroupInfoSuspense_withClient(client, groupId) {
|
|
2561
|
+
const groupsInfoStore = client[kInternal3].groupsInfoStore;
|
|
2562
|
+
const getGroupInfoState = useCallback2(
|
|
2563
|
+
() => groupsInfoStore.getItemState(groupId),
|
|
2564
|
+
[groupsInfoStore, groupId]
|
|
2565
|
+
);
|
|
2566
|
+
const groupInfoState = getGroupInfoState();
|
|
2567
|
+
if (!groupInfoState || groupInfoState.isLoading) {
|
|
2568
|
+
throw groupsInfoStore.enqueue(groupId);
|
|
2569
|
+
}
|
|
2570
|
+
if (groupInfoState.error) {
|
|
2571
|
+
throw groupInfoState.error;
|
|
2572
|
+
}
|
|
2573
|
+
if (!groupInfoState.data) {
|
|
2574
|
+
throw missingGroupInfoError(groupId);
|
|
2575
|
+
}
|
|
2576
|
+
const state = useSyncExternalStore2(
|
|
2577
|
+
groupsInfoStore.subscribe,
|
|
2578
|
+
getGroupInfoState,
|
|
2579
|
+
getGroupInfoState
|
|
2580
|
+
);
|
|
2581
|
+
assert(state !== void 0, "Unexpected missing state");
|
|
2582
|
+
assert(!state.isLoading, "Unexpected loading state");
|
|
2583
|
+
assert(!state.error, "Unexpected error state");
|
|
2584
|
+
assert(state.data !== void 0, "Unexpected missing group info data");
|
|
2585
|
+
return {
|
|
2586
|
+
isLoading: false,
|
|
2587
|
+
info: state.data,
|
|
2588
|
+
error: void 0
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2536
2591
|
function useAiChats(options) {
|
|
2537
2592
|
const client = useClient();
|
|
2538
2593
|
const store = getUmbrellaStoreForClient(client);
|
|
@@ -2736,6 +2791,7 @@ function createSharedContext(client) {
|
|
|
2736
2791
|
useClient: useClient2,
|
|
2737
2792
|
useUser: (userId) => useUser_withClient(client, userId),
|
|
2738
2793
|
useRoomInfo: (roomId) => useRoomInfo_withClient(client, roomId),
|
|
2794
|
+
useGroupInfo: (groupId) => useGroupInfo_withClient(client, groupId),
|
|
2739
2795
|
useIsInsideRoom,
|
|
2740
2796
|
useErrorListener,
|
|
2741
2797
|
useSyncStatus: useSyncStatus2,
|
|
@@ -2746,6 +2802,7 @@ function createSharedContext(client) {
|
|
|
2746
2802
|
useClient: useClient2,
|
|
2747
2803
|
useUser: (userId) => useUserSuspense_withClient(client, userId),
|
|
2748
2804
|
useRoomInfo: (roomId) => useRoomInfoSuspense_withClient(client, roomId),
|
|
2805
|
+
useGroupInfo: (groupId) => useGroupInfoSuspense_withClient(client, groupId),
|
|
2749
2806
|
useIsInsideRoom,
|
|
2750
2807
|
useErrorListener,
|
|
2751
2808
|
useSyncStatus: useSyncStatus2,
|
|
@@ -2783,6 +2840,7 @@ function LiveblocksProvider(props) {
|
|
|
2783
2840
|
),
|
|
2784
2841
|
resolveUsers: useInitialUnlessFunction(o.resolveUsers),
|
|
2785
2842
|
resolveRoomsInfo: useInitialUnlessFunction(o.resolveRoomsInfo),
|
|
2843
|
+
resolveGroupsInfo: useInitialUnlessFunction(o.resolveGroupsInfo),
|
|
2786
2844
|
baseUrl: useInitial(
|
|
2787
2845
|
// @ts-expect-error - Hidden config options
|
|
2788
2846
|
o.baseUrl
|
|
@@ -2893,6 +2951,12 @@ function useRoomInfo(roomId) {
|
|
|
2893
2951
|
function useRoomInfoSuspense(roomId) {
|
|
2894
2952
|
return useRoomInfoSuspense_withClient(useClient(), roomId);
|
|
2895
2953
|
}
|
|
2954
|
+
function useGroupInfo(groupId) {
|
|
2955
|
+
return useGroupInfo_withClient(useClient(), groupId);
|
|
2956
|
+
}
|
|
2957
|
+
function useGroupInfoSuspense(groupId) {
|
|
2958
|
+
return useGroupInfoSuspense_withClient(useClient(), groupId);
|
|
2959
|
+
}
|
|
2896
2960
|
var _useInboxNotificationThread = useInboxNotificationThread;
|
|
2897
2961
|
var _useUser = useUser;
|
|
2898
2962
|
var _useUserSuspense = useUserSuspense;
|
|
@@ -3424,10 +3488,10 @@ function useYjsProvider() {
|
|
|
3424
3488
|
function useCreateTextMention() {
|
|
3425
3489
|
const room = useRoom();
|
|
3426
3490
|
return useCallback3(
|
|
3427
|
-
(
|
|
3428
|
-
room[kInternal4].createTextMention(
|
|
3491
|
+
(mentionId, mention) => {
|
|
3492
|
+
room[kInternal4].createTextMention(mentionId, mention).catch((err) => {
|
|
3429
3493
|
console3.error(
|
|
3430
|
-
`Cannot create text mention for
|
|
3494
|
+
`Cannot create text mention for mention '${mentionId}'`,
|
|
3431
3495
|
err
|
|
3432
3496
|
);
|
|
3433
3497
|
});
|
|
@@ -4604,6 +4668,8 @@ export {
|
|
|
4604
4668
|
useUpdateNotificationSettings,
|
|
4605
4669
|
useRoomInfo,
|
|
4606
4670
|
useRoomInfoSuspense,
|
|
4671
|
+
useGroupInfo,
|
|
4672
|
+
useGroupInfoSuspense,
|
|
4607
4673
|
_useInboxNotificationThread,
|
|
4608
4674
|
_useUser,
|
|
4609
4675
|
_useUserSuspense,
|
|
@@ -4692,4 +4758,4 @@ export {
|
|
|
4692
4758
|
_useStorageRoot,
|
|
4693
4759
|
_useUpdateMyPresence
|
|
4694
4760
|
};
|
|
4695
|
-
//# sourceMappingURL=chunk-
|
|
4761
|
+
//# sourceMappingURL=chunk-LYWCKEAX.js.map
|