@liveblocks/react 2.24.0-sub1 → 2.24.1
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.d.cts +1 -1
- package/dist/_private.d.ts +1 -1
- package/dist/_private.js +1 -1
- package/dist/{chunk-JYG2E4EZ.cjs → chunk-2C72TPGI.cjs} +2 -2
- package/dist/{chunk-JYG2E4EZ.cjs.map → chunk-2C72TPGI.cjs.map} +1 -1
- package/dist/{chunk-VEO3XXA7.cjs → chunk-32HQP5F6.cjs} +53 -51
- package/dist/chunk-32HQP5F6.cjs.map +1 -0
- package/dist/{chunk-ZWYRZR44.js → chunk-N6OQQVYV.js} +67 -65
- package/dist/chunk-N6OQQVYV.js.map +1 -0
- package/dist/{chunk-FBBBSMFI.js → chunk-RPHUEUUE.js} +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{room-BHrloYUB.d.cts → room-CqT08uWZ.d.cts} +1 -1
- package/dist/{room-BHrloYUB.d.ts → room-CqT08uWZ.d.ts} +1 -1
- package/dist/suspense.cjs +4 -4
- package/dist/suspense.d.cts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-VEO3XXA7.cjs.map +0 -1
- package/dist/chunk-ZWYRZR44.js.map +0 -1
- /package/dist/{chunk-FBBBSMFI.js.map → chunk-RPHUEUUE.js.map} +0 -0
|
@@ -107,7 +107,7 @@ import {
|
|
|
107
107
|
kInternal as kInternal2,
|
|
108
108
|
makePoller,
|
|
109
109
|
raise,
|
|
110
|
-
shallow as
|
|
110
|
+
shallow as shallow3
|
|
111
111
|
} from "@liveblocks/core";
|
|
112
112
|
import {
|
|
113
113
|
createContext as createContext2,
|
|
@@ -247,7 +247,8 @@ import {
|
|
|
247
247
|
nanoid,
|
|
248
248
|
nn,
|
|
249
249
|
patchNotificationSettings,
|
|
250
|
-
shallow
|
|
250
|
+
shallow,
|
|
251
|
+
shallow2,
|
|
251
252
|
Signal,
|
|
252
253
|
stableStringify
|
|
253
254
|
} from "@liveblocks/core";
|
|
@@ -269,21 +270,6 @@ function autobind(self) {
|
|
|
269
270
|
} while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
|
|
270
271
|
}
|
|
271
272
|
|
|
272
|
-
// src/lib/shallow2.ts
|
|
273
|
-
import { isPlainObject, shallow } from "@liveblocks/core";
|
|
274
|
-
function shallow2(a, b) {
|
|
275
|
-
if (!isPlainObject(a) || !isPlainObject(b)) {
|
|
276
|
-
return shallow(a, b);
|
|
277
|
-
}
|
|
278
|
-
const keysA = Object.keys(a);
|
|
279
|
-
if (keysA.length !== Object.keys(b).length) {
|
|
280
|
-
return false;
|
|
281
|
-
}
|
|
282
|
-
return keysA.every(
|
|
283
|
-
(key) => Object.prototype.hasOwnProperty.call(b, key) && shallow(a[key], b[key])
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
273
|
// src/ThreadDB.ts
|
|
288
274
|
import { batch, MutableSignal, SortedList } from "@liveblocks/core";
|
|
289
275
|
|
|
@@ -932,7 +918,7 @@ var UmbrellaStore = class {
|
|
|
932
918
|
sortedNotifications: s.sortedNotifications,
|
|
933
919
|
notificationsById: s.notificationsById
|
|
934
920
|
}),
|
|
935
|
-
|
|
921
|
+
shallow
|
|
936
922
|
);
|
|
937
923
|
const threadSubscriptions = DerivedSignal.from(
|
|
938
924
|
notifications,
|
|
@@ -1067,7 +1053,7 @@ var UmbrellaStore = class {
|
|
|
1067
1053
|
nn(this.roomSubscriptionSettings.signal.get()[roomId])
|
|
1068
1054
|
);
|
|
1069
1055
|
}
|
|
1070
|
-
},
|
|
1056
|
+
}, shallow);
|
|
1071
1057
|
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
1072
1058
|
}
|
|
1073
1059
|
);
|
|
@@ -1098,7 +1084,7 @@ var UmbrellaStore = class {
|
|
|
1098
1084
|
Object.values(this.historyVersions.signal.get()[roomId] ?? {})
|
|
1099
1085
|
);
|
|
1100
1086
|
}
|
|
1101
|
-
},
|
|
1087
|
+
}, shallow);
|
|
1102
1088
|
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
1103
1089
|
}
|
|
1104
1090
|
);
|
|
@@ -1112,7 +1098,7 @@ var UmbrellaStore = class {
|
|
|
1112
1098
|
"settings",
|
|
1113
1099
|
nn(this.notificationSettings.signal.get())
|
|
1114
1100
|
);
|
|
1115
|
-
},
|
|
1101
|
+
}, shallow),
|
|
1116
1102
|
waitUntilLoaded: this.#notificationSettings.waitUntilLoaded
|
|
1117
1103
|
};
|
|
1118
1104
|
this.outputs = {
|
|
@@ -1168,7 +1154,7 @@ var UmbrellaStore = class {
|
|
|
1168
1154
|
});
|
|
1169
1155
|
}
|
|
1170
1156
|
/**
|
|
1171
|
-
* Creates
|
|
1157
|
+
* Creates an existing subscription, replacing the corresponding
|
|
1172
1158
|
* optimistic update.
|
|
1173
1159
|
*/
|
|
1174
1160
|
createSubscription(subscription, optimisticId) {
|
|
@@ -1593,47 +1579,45 @@ function applyOptimisticUpdates_forRoomSubscriptionSettings(settingsLUT, optimis
|
|
|
1593
1579
|
function applyOptimisticUpdates_forSubscriptions(subscriptionsLUT, threads, optimisticUpdates) {
|
|
1594
1580
|
const subscriptions = Object.fromEntries(subscriptionsLUT);
|
|
1595
1581
|
for (const update of optimisticUpdates) {
|
|
1596
|
-
|
|
1597
|
-
|
|
1582
|
+
switch (update.type) {
|
|
1583
|
+
case "update-room-subscription-settings": {
|
|
1584
|
+
if (!update.settings.threads) {
|
|
1585
|
+
continue;
|
|
1586
|
+
}
|
|
1598
1587
|
const roomThreads = threads.findMany(update.roomId, void 0, "desc");
|
|
1599
1588
|
for (const thread of roomThreads) {
|
|
1600
1589
|
const subscriptionKey = getSubscriptionKey("thread", thread.id);
|
|
1601
|
-
|
|
1602
|
-
subscriptions
|
|
1603
|
-
|
|
1604
|
-
subjectId: thread.id,
|
|
1605
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
1606
|
-
};
|
|
1607
|
-
} else if (update.settings.threads === "none") {
|
|
1608
|
-
delete subscriptions[subscriptionKey];
|
|
1609
|
-
} else if (update.settings.threads === "replies_and_mentions") {
|
|
1610
|
-
let isParticipant = false;
|
|
1611
|
-
for (const comment of thread.comments) {
|
|
1612
|
-
if (comment.deletedAt) {
|
|
1613
|
-
continue;
|
|
1614
|
-
}
|
|
1615
|
-
if (comment.userId === update.userId) {
|
|
1616
|
-
isParticipant = true;
|
|
1617
|
-
break;
|
|
1618
|
-
}
|
|
1619
|
-
const mentionedIds = getMentionedIdsFromCommentBody(comment.body);
|
|
1620
|
-
if (mentionedIds.includes(update.userId)) {
|
|
1621
|
-
isParticipant = true;
|
|
1622
|
-
break;
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
if (isParticipant && !subscriptions[subscriptionKey]) {
|
|
1590
|
+
switch (update.settings.threads) {
|
|
1591
|
+
// Create subscriptions for all existing threads in the room
|
|
1592
|
+
case "all": {
|
|
1626
1593
|
subscriptions[subscriptionKey] = {
|
|
1627
1594
|
kind: "thread",
|
|
1628
1595
|
subjectId: thread.id,
|
|
1629
1596
|
createdAt: /* @__PURE__ */ new Date()
|
|
1630
1597
|
};
|
|
1598
|
+
break;
|
|
1631
1599
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1600
|
+
// Delete subscriptions for all existing threads in the room
|
|
1601
|
+
case "none": {
|
|
1602
|
+
delete subscriptions[subscriptionKey];
|
|
1603
|
+
break;
|
|
1604
|
+
}
|
|
1605
|
+
// Create subscriptions for every threads in the room which the user participates in but doesn't have a subscription for yet
|
|
1606
|
+
case "replies_and_mentions": {
|
|
1607
|
+
if (isThreadParticipant(thread, update.userId) && !subscriptions[subscriptionKey]) {
|
|
1608
|
+
subscriptions[subscriptionKey] = {
|
|
1609
|
+
kind: "thread",
|
|
1610
|
+
subjectId: thread.id,
|
|
1611
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1612
|
+
};
|
|
1613
|
+
}
|
|
1614
|
+
break;
|
|
1615
|
+
}
|
|
1616
|
+
default:
|
|
1617
|
+
assertNever(
|
|
1618
|
+
update.settings.threads,
|
|
1619
|
+
"Unexpected thread subscription settings."
|
|
1620
|
+
);
|
|
1637
1621
|
}
|
|
1638
1622
|
}
|
|
1639
1623
|
}
|
|
@@ -1827,6 +1811,24 @@ function upsertReaction(reactions, reaction) {
|
|
|
1827
1811
|
}
|
|
1828
1812
|
return reactions;
|
|
1829
1813
|
}
|
|
1814
|
+
function isThreadParticipant(thread, userId) {
|
|
1815
|
+
let isParticipant = false;
|
|
1816
|
+
for (const comment of thread.comments) {
|
|
1817
|
+
if (comment.deletedAt) {
|
|
1818
|
+
continue;
|
|
1819
|
+
}
|
|
1820
|
+
if (comment.userId === userId) {
|
|
1821
|
+
isParticipant = true;
|
|
1822
|
+
break;
|
|
1823
|
+
}
|
|
1824
|
+
const mentionedIds = getMentionedIdsFromCommentBody(comment.body);
|
|
1825
|
+
if (mentionedIds.includes(userId)) {
|
|
1826
|
+
isParticipant = true;
|
|
1827
|
+
break;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
return isParticipant;
|
|
1831
|
+
}
|
|
1830
1832
|
|
|
1831
1833
|
// src/liveblocks.tsx
|
|
1832
1834
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1978,7 +1980,7 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1978
1980
|
const shared = createSharedContext(client);
|
|
1979
1981
|
const bundle = {
|
|
1980
1982
|
LiveblocksProvider: LiveblocksProvider2,
|
|
1981
|
-
useInboxNotifications: () => useInboxNotifications_withClient(client, identity2,
|
|
1983
|
+
useInboxNotifications: () => useInboxNotifications_withClient(client, identity2, shallow3),
|
|
1982
1984
|
useUnreadInboxNotificationsCount: () => useUnreadInboxNotificationsCount_withClient(client),
|
|
1983
1985
|
useMarkInboxNotificationAsRead: useMarkInboxNotificationAsRead2,
|
|
1984
1986
|
useMarkAllInboxNotificationsAsRead: useMarkAllInboxNotificationsAsRead2,
|
|
@@ -2036,7 +2038,7 @@ function useInboxNotificationsSuspense_withClient(client) {
|
|
|
2036
2038
|
ensureNotServerSide();
|
|
2037
2039
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
2038
2040
|
use(store.outputs.loadingNotifications.waitUntilLoaded());
|
|
2039
|
-
const result = useInboxNotifications_withClient(client, identity2,
|
|
2041
|
+
const result = useInboxNotifications_withClient(client, identity2, shallow3);
|
|
2040
2042
|
assert(!result.error, "Did not expect error");
|
|
2041
2043
|
assert(!result.isLoading, "Did not expect loading");
|
|
2042
2044
|
return result;
|
|
@@ -2045,7 +2047,7 @@ function useUnreadInboxNotificationsCount_withClient(client) {
|
|
|
2045
2047
|
return useInboxNotifications_withClient(
|
|
2046
2048
|
client,
|
|
2047
2049
|
selectorFor_useUnreadInboxNotificationsCount,
|
|
2048
|
-
|
|
2050
|
+
shallow3
|
|
2049
2051
|
);
|
|
2050
2052
|
}
|
|
2051
2053
|
function useUnreadInboxNotificationsCountSuspense_withClient(client) {
|
|
@@ -2265,7 +2267,7 @@ function useUser_withClient(client, userId) {
|
|
|
2265
2267
|
getUserState,
|
|
2266
2268
|
getUserState,
|
|
2267
2269
|
selector,
|
|
2268
|
-
|
|
2270
|
+
shallow3
|
|
2269
2271
|
);
|
|
2270
2272
|
useEffect3(
|
|
2271
2273
|
() => void usersStore.enqueue(userId)
|
|
@@ -2326,7 +2328,7 @@ function useRoomInfo_withClient(client, roomId) {
|
|
|
2326
2328
|
getRoomInfoState,
|
|
2327
2329
|
getRoomInfoState,
|
|
2328
2330
|
selector,
|
|
2329
|
-
|
|
2331
|
+
shallow3
|
|
2330
2332
|
);
|
|
2331
2333
|
useEffect3(
|
|
2332
2334
|
() => void roomsInfoStore.enqueue(roomId)
|
|
@@ -2486,7 +2488,7 @@ function useUserThreadsSuspense_experimental(options = {}) {
|
|
|
2486
2488
|
return result;
|
|
2487
2489
|
}
|
|
2488
2490
|
function useInboxNotifications() {
|
|
2489
|
-
return useInboxNotifications_withClient(useClient(), identity2,
|
|
2491
|
+
return useInboxNotifications_withClient(useClient(), identity2, shallow3);
|
|
2490
2492
|
}
|
|
2491
2493
|
function useInboxNotificationsSuspense() {
|
|
2492
2494
|
return useInboxNotificationsSuspense_withClient(useClient());
|
|
@@ -2593,7 +2595,7 @@ function useErrorListener(callback) {
|
|
|
2593
2595
|
}
|
|
2594
2596
|
|
|
2595
2597
|
// src/room.tsx
|
|
2596
|
-
import { shallow as
|
|
2598
|
+
import { shallow as shallow4 } from "@liveblocks/client";
|
|
2597
2599
|
import {
|
|
2598
2600
|
assert as assert2,
|
|
2599
2601
|
console as console3,
|
|
@@ -3255,7 +3257,7 @@ function useOthersMapped(itemSelector, itemIsEqual) {
|
|
|
3255
3257
|
return useOthers(wrappedSelector, wrappedIsEqual);
|
|
3256
3258
|
}
|
|
3257
3259
|
function useOthersConnectionIds() {
|
|
3258
|
-
return useOthers(selectorFor_useOthersConnectionIds,
|
|
3260
|
+
return useOthers(selectorFor_useOthersConnectionIds, shallow4);
|
|
3259
3261
|
}
|
|
3260
3262
|
var NOT_FOUND = Symbol();
|
|
3261
3263
|
function useOther(connectionId, selector, isEqual) {
|
|
@@ -3945,7 +3947,7 @@ function useRoomThreadSubscription(roomId, threadId) {
|
|
|
3945
3947
|
},
|
|
3946
3948
|
[subscriptionKey, threadId, subscribe, unsubscribe]
|
|
3947
3949
|
);
|
|
3948
|
-
return useSignal(signal, selector,
|
|
3950
|
+
return useSignal(signal, selector, shallow4);
|
|
3949
3951
|
}
|
|
3950
3952
|
function useRoomNotificationSettings() {
|
|
3951
3953
|
const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
|
|
@@ -4264,7 +4266,7 @@ function useRoomAttachmentUrl(attachmentId, roomId) {
|
|
|
4264
4266
|
getAttachmentUrlState,
|
|
4265
4267
|
getAttachmentUrlState,
|
|
4266
4268
|
selectorFor_useAttachmentUrl,
|
|
4267
|
-
|
|
4269
|
+
shallow4
|
|
4268
4270
|
);
|
|
4269
4271
|
}
|
|
4270
4272
|
function useAttachmentUrlSuspense(attachmentId) {
|
|
@@ -4459,4 +4461,4 @@ export {
|
|
|
4459
4461
|
_useStorageRoot,
|
|
4460
4462
|
_useUpdateMyPresence
|
|
4461
4463
|
};
|
|
4462
|
-
//# sourceMappingURL=chunk-
|
|
4464
|
+
//# sourceMappingURL=chunk-N6OQQVYV.js.map
|