@liveblocks/react 2.17.0-usrnotsettings1 → 2.17.0-usrnotsettings3
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.d.mts +1 -1
- package/dist/_private.d.ts +1 -1
- package/dist/_private.js +5 -5
- package/dist/_private.mjs +1 -1
- package/dist/{chunk-4F7C4HN7.js → chunk-HV3HU2RB.js} +61 -35
- package/dist/chunk-HV3HU2RB.js.map +1 -0
- package/dist/{chunk-KAFU5ZQA.mjs → chunk-L7XOVOE2.mjs} +2 -2
- package/dist/{chunk-LOPNJCSB.mjs → chunk-M2B54KRP.mjs} +52 -26
- package/dist/chunk-M2B54KRP.mjs.map +1 -0
- package/dist/{chunk-DT3BO7N5.js → chunk-N7SHYNWS.js} +2 -2
- package/dist/{chunk-DT3BO7N5.js.map → chunk-N7SHYNWS.js.map} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +2 -2
- package/dist/{room-DlI0Yrzf.d.mts → room-BDt2BfPN.d.mts} +5 -1
- package/dist/{room-DlI0Yrzf.d.ts → room-BDt2BfPN.d.ts} +5 -1
- package/dist/suspense.d.mts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +4 -4
- package/dist/suspense.mjs +2 -2
- package/package.json +3 -3
- package/dist/chunk-4F7C4HN7.js.map +0 -1
- package/dist/chunk-LOPNJCSB.mjs.map +0 -1
- /package/dist/{chunk-KAFU5ZQA.mjs.map → chunk-L7XOVOE2.mjs.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "2.17.0-
|
|
3
|
+
var PKG_VERSION = "2.17.0-usrnotsettings3";
|
|
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-L7XOVOE2.mjs.map
|
|
@@ -98,6 +98,9 @@ function useSignal(signal, selector, isEqual) {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
// src/liveblocks.tsx
|
|
101
|
+
import {
|
|
102
|
+
HttpError
|
|
103
|
+
} from "@liveblocks/core";
|
|
101
104
|
import {
|
|
102
105
|
assert,
|
|
103
106
|
createClient,
|
|
@@ -161,6 +164,15 @@ function count(it, predicate) {
|
|
|
161
164
|
return total;
|
|
162
165
|
}
|
|
163
166
|
|
|
167
|
+
// src/lib/ssr.ts
|
|
168
|
+
function ensureNotServerSide() {
|
|
169
|
+
if (typeof window === "undefined") {
|
|
170
|
+
throw new Error(
|
|
171
|
+
"You cannot use the Suspense version of Liveblocks hooks server side. Make sure to only call them client side by using a ClientSideSuspense wrapper.\nFor tips, see https://liveblocks.io/docs/api-reference/liveblocks-react#ClientSideSuspense"
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
164
176
|
// src/lib/use-initial.ts
|
|
165
177
|
import { useCallback, useReducer } from "react";
|
|
166
178
|
|
|
@@ -771,16 +783,16 @@ var UmbrellaStore = class {
|
|
|
771
783
|
//
|
|
772
784
|
// Mutate inputs... ...observe clean/consistent output!
|
|
773
785
|
//
|
|
774
|
-
// .-> Base ThreadDB ---------+ +----> Clean threads by ID
|
|
786
|
+
// .-> Base ThreadDB ---------+ +----> Clean threads by ID (Part 1)
|
|
775
787
|
// / | |
|
|
776
|
-
// mutate ----> Base Notifications --+ | | +--> Clean notifications
|
|
788
|
+
// mutate ----> Base Notifications --+ | | +--> Clean notifications (Part 1)
|
|
777
789
|
// \ | | | | & notifications by ID
|
|
778
790
|
// | \ | | Apply | |
|
|
779
|
-
// | `-> OptimisticUpdates --+--+--> Optimistic --+-+--> Notification Settings
|
|
791
|
+
// | `-> OptimisticUpdates --+--+--> Optimistic --+-+--> Room Notification Settings (Part 2)
|
|
780
792
|
// \ | Updates | |
|
|
781
|
-
// `------- etc etc ---------+ | +--> History Versions
|
|
793
|
+
// `------- etc etc ---------+ | +--> History Versions (Part 3)
|
|
782
794
|
// ^ |
|
|
783
|
-
// | +----->
|
|
795
|
+
// | +-----> User Notification Settings (Part 4)
|
|
784
796
|
// |
|
|
785
797
|
// |
|
|
786
798
|
// | ^ ^
|
|
@@ -840,7 +852,7 @@ var UmbrellaStore = class {
|
|
|
840
852
|
return nextCursor;
|
|
841
853
|
}
|
|
842
854
|
);
|
|
843
|
-
const
|
|
855
|
+
const userNotificationSettingsFetcher = async () => {
|
|
844
856
|
const result = await this.#client.getNotificationSettings();
|
|
845
857
|
this.userNotificationSettings.update(result);
|
|
846
858
|
};
|
|
@@ -848,7 +860,7 @@ var UmbrellaStore = class {
|
|
|
848
860
|
this.optimisticUpdates.signal
|
|
849
861
|
);
|
|
850
862
|
this.#userNotificationSettings = new SinglePageResource(
|
|
851
|
-
|
|
863
|
+
userNotificationSettingsFetcher
|
|
852
864
|
);
|
|
853
865
|
this.threads = new ThreadDB();
|
|
854
866
|
this.notifications = createStore_forNotifications();
|
|
@@ -1897,6 +1909,7 @@ function useInboxNotifications_withClient(client, selector, isEqual) {
|
|
|
1897
1909
|
);
|
|
1898
1910
|
}
|
|
1899
1911
|
function useInboxNotificationsSuspense_withClient(client) {
|
|
1912
|
+
ensureNotServerSide();
|
|
1900
1913
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
1901
1914
|
use(store.outputs.loadingNotifications.waitUntilLoaded());
|
|
1902
1915
|
const result = useInboxNotifications_withClient(client, identity2, shallow4);
|
|
@@ -1912,6 +1925,7 @@ function useUnreadInboxNotificationsCount_withClient(client) {
|
|
|
1912
1925
|
);
|
|
1913
1926
|
}
|
|
1914
1927
|
function useUnreadInboxNotificationsCountSuspense_withClient(client) {
|
|
1928
|
+
ensureNotServerSide();
|
|
1915
1929
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
1916
1930
|
use(store.outputs.loadingNotifications.waitUntilLoaded());
|
|
1917
1931
|
const result = useUnreadInboxNotificationsCount_withClient(client);
|
|
@@ -2061,8 +2075,22 @@ function useUpdateNotificationSettings_withClient(client) {
|
|
|
2061
2075
|
optimisticUpdateId
|
|
2062
2076
|
);
|
|
2063
2077
|
},
|
|
2064
|
-
() => {
|
|
2078
|
+
(err) => {
|
|
2065
2079
|
store.optimisticUpdates.remove(optimisticUpdateId);
|
|
2080
|
+
if (err instanceof HttpError) {
|
|
2081
|
+
if (err.status === 422) {
|
|
2082
|
+
const msg = [err.details?.error, err.details?.reason].filter(Boolean).join("\n");
|
|
2083
|
+
console.error(msg);
|
|
2084
|
+
}
|
|
2085
|
+
client[kInternal2].emitError(
|
|
2086
|
+
{
|
|
2087
|
+
type: "UPDATE_USER_NOTIFICATION_SETTINGS_ERROR"
|
|
2088
|
+
},
|
|
2089
|
+
err
|
|
2090
|
+
);
|
|
2091
|
+
} else {
|
|
2092
|
+
throw err;
|
|
2093
|
+
}
|
|
2066
2094
|
}
|
|
2067
2095
|
);
|
|
2068
2096
|
},
|
|
@@ -2082,20 +2110,21 @@ function useNotificationSettings_withClient(client) {
|
|
|
2082
2110
|
poller.dec();
|
|
2083
2111
|
};
|
|
2084
2112
|
}, [poller]);
|
|
2085
|
-
const
|
|
2113
|
+
const result = useSignal(store.outputs.userNotificationSettings.signal);
|
|
2086
2114
|
return useMemo2(() => {
|
|
2087
|
-
return [
|
|
2088
|
-
}, [
|
|
2115
|
+
return [result, updateNotificationSettings];
|
|
2116
|
+
}, [result, updateNotificationSettings]);
|
|
2089
2117
|
}
|
|
2090
2118
|
function useNotificationSettingsSuspense_withClient(client) {
|
|
2119
|
+
ensureNotServerSide();
|
|
2091
2120
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
2092
2121
|
use(store.outputs.userNotificationSettings.waitUntilLoaded());
|
|
2093
|
-
const [
|
|
2094
|
-
assert(!
|
|
2095
|
-
assert(!
|
|
2122
|
+
const [result, updateNotificationSettings] = useNotificationSettings_withClient(client);
|
|
2123
|
+
assert(!result.error, "Did not expect error");
|
|
2124
|
+
assert(!result.isLoading, "Did not expect loading");
|
|
2096
2125
|
return useMemo2(() => {
|
|
2097
|
-
return [
|
|
2098
|
-
}, [
|
|
2126
|
+
return [result, updateNotificationSettings];
|
|
2127
|
+
}, [result, updateNotificationSettings]);
|
|
2099
2128
|
}
|
|
2100
2129
|
function useUser_withClient(client, userId) {
|
|
2101
2130
|
const usersStore = client[kInternal2].usersStore;
|
|
@@ -2321,6 +2350,7 @@ function useUserThreads_experimental(options = {}) {
|
|
|
2321
2350
|
);
|
|
2322
2351
|
}
|
|
2323
2352
|
function useUserThreadsSuspense_experimental(options = {}) {
|
|
2353
|
+
ensureNotServerSide();
|
|
2324
2354
|
const client = useClient();
|
|
2325
2355
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
2326
2356
|
const queryKey = makeUserThreadsQueryKey(options.query);
|
|
@@ -2446,7 +2476,7 @@ import {
|
|
|
2446
2476
|
createThreadId,
|
|
2447
2477
|
DefaultMap as DefaultMap2,
|
|
2448
2478
|
errorIf,
|
|
2449
|
-
HttpError,
|
|
2479
|
+
HttpError as HttpError2,
|
|
2450
2480
|
kInternal as kInternal3,
|
|
2451
2481
|
makePoller as makePoller2,
|
|
2452
2482
|
ServerMsgCode
|
|
@@ -2563,7 +2593,7 @@ function makeRoomExtrasForClient(client) {
|
|
|
2563
2593
|
const store = getUmbrellaStoreForClient(client);
|
|
2564
2594
|
function onMutationFailure(optimisticId, context, innerError) {
|
|
2565
2595
|
store.optimisticUpdates.remove(optimisticId);
|
|
2566
|
-
if (innerError instanceof
|
|
2596
|
+
if (innerError instanceof HttpError2) {
|
|
2567
2597
|
if (innerError.status === 403) {
|
|
2568
2598
|
const detailedMessage = [
|
|
2569
2599
|
innerError.message,
|
|
@@ -3724,6 +3754,7 @@ function useRoomNotificationSettings() {
|
|
|
3724
3754
|
}, [settings, updateRoomNotificationSettings]);
|
|
3725
3755
|
}
|
|
3726
3756
|
function useRoomNotificationSettingsSuspense() {
|
|
3757
|
+
ensureNotServerSide();
|
|
3727
3758
|
const client = useClient();
|
|
3728
3759
|
const store = getRoomExtrasForClient(client).store;
|
|
3729
3760
|
const room = useRoom();
|
|
@@ -3788,6 +3819,7 @@ function useHistoryVersions() {
|
|
|
3788
3819
|
return useSignal(store.outputs.versionsByRoomId.getOrCreate(room.id).signal);
|
|
3789
3820
|
}
|
|
3790
3821
|
function useHistoryVersionsSuspense() {
|
|
3822
|
+
ensureNotServerSide();
|
|
3791
3823
|
const client = useClient();
|
|
3792
3824
|
const room = useRoom();
|
|
3793
3825
|
const store = getRoomExtrasForClient(client).store;
|
|
@@ -3822,13 +3854,6 @@ function useUpdateRoomNotificationSettings() {
|
|
|
3822
3854
|
[client, room]
|
|
3823
3855
|
);
|
|
3824
3856
|
}
|
|
3825
|
-
function ensureNotServerSide() {
|
|
3826
|
-
if (typeof window === "undefined") {
|
|
3827
|
-
throw new Error(
|
|
3828
|
-
"You cannot use the Suspense version of this hook on the server side. Make sure to only call them on the client side.\nFor tips, see https://liveblocks.io/docs/api-reference/liveblocks-react#suspense-avoid-ssr"
|
|
3829
|
-
);
|
|
3830
|
-
}
|
|
3831
|
-
}
|
|
3832
3857
|
function useSuspendUntilPresenceReady() {
|
|
3833
3858
|
ensureNotServerSide();
|
|
3834
3859
|
const room = useRoom();
|
|
@@ -3877,6 +3902,7 @@ function useStorageStatusSuspense(options) {
|
|
|
3877
3902
|
return useStorageStatus(options);
|
|
3878
3903
|
}
|
|
3879
3904
|
function useThreadsSuspense(options = {}) {
|
|
3905
|
+
ensureNotServerSide();
|
|
3880
3906
|
const client = useClient();
|
|
3881
3907
|
const room = useRoom();
|
|
3882
3908
|
const { store } = getRoomExtrasForClient(client);
|
|
@@ -4107,4 +4133,4 @@ export {
|
|
|
4107
4133
|
_useStorageRoot,
|
|
4108
4134
|
_useUpdateMyPresence
|
|
4109
4135
|
};
|
|
4110
|
-
//# sourceMappingURL=chunk-
|
|
4136
|
+
//# sourceMappingURL=chunk-M2B54KRP.mjs.map
|