@liveblocks/react 2.4.1-test3 → 2.5.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.
@@ -1,6 +1,6 @@
1
1
  // src/version.ts
2
2
  var PKG_NAME = "@liveblocks/react";
3
- var PKG_VERSION = "2.4.1-test3";
3
+ var PKG_VERSION = "2.5.0";
4
4
  var PKG_FORMAT = "esm";
5
5
 
6
6
  // src/ClientSideSuspense.tsx
@@ -27,7 +27,9 @@ function selectedUserThreads(state) {
27
27
  return true;
28
28
  }
29
29
  );
30
- return threads.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
30
+ return threads.sort(
31
+ (a, b) => (b.updatedAt ?? b.createdAt).getTime() - (a.updatedAt ?? a.createdAt).getTime()
32
+ );
31
33
  }
32
34
  function selectedThreads(roomId, state, options) {
33
35
  const result = applyOptimisticUpdates(state);
@@ -70,31 +72,142 @@ var assertMetadataValueIsString = (value) => {
70
72
  return typeof value === "string";
71
73
  };
72
74
 
73
- // src/liveblocks.tsx
75
+ // src/comments/errors.ts
76
+ var CreateThreadError = class extends Error {
77
+ constructor(cause, context) {
78
+ super("Create thread failed.");
79
+ this.cause = cause;
80
+ this.context = context;
81
+ this.name = "CreateThreadError";
82
+ }
83
+ };
84
+ var DeleteThreadError = class extends Error {
85
+ constructor(cause, context) {
86
+ super("Delete thread failed.");
87
+ this.cause = cause;
88
+ this.context = context;
89
+ this.name = "DeleteThreadError";
90
+ }
91
+ };
92
+ var EditThreadMetadataError = class extends Error {
93
+ constructor(cause, context) {
94
+ super("Edit thread metadata failed.");
95
+ this.cause = cause;
96
+ this.context = context;
97
+ this.name = "EditThreadMetadataError";
98
+ }
99
+ };
100
+ var MarkThreadAsResolvedError = class extends Error {
101
+ constructor(cause, context) {
102
+ super("Mark thread as resolved failed.");
103
+ this.cause = cause;
104
+ this.context = context;
105
+ this.name = "MarkThreadAsResolvedError";
106
+ }
107
+ };
108
+ var MarkThreadAsUnresolvedError = class extends Error {
109
+ constructor(cause, context) {
110
+ super("Mark thread as unresolved failed.");
111
+ this.cause = cause;
112
+ this.context = context;
113
+ this.name = "MarkThreadAsUnresolvedError";
114
+ }
115
+ };
116
+ var CreateCommentError = class extends Error {
117
+ constructor(cause, context) {
118
+ super("Create comment failed.");
119
+ this.cause = cause;
120
+ this.context = context;
121
+ this.name = "CreateCommentError";
122
+ }
123
+ };
124
+ var EditCommentError = class extends Error {
125
+ constructor(cause, context) {
126
+ super("Edit comment failed.");
127
+ this.cause = cause;
128
+ this.context = context;
129
+ this.name = "EditCommentError";
130
+ }
131
+ };
132
+ var DeleteCommentError = class extends Error {
133
+ constructor(cause, context) {
134
+ super("Delete comment failed.");
135
+ this.cause = cause;
136
+ this.context = context;
137
+ this.name = "DeleteCommentError";
138
+ }
139
+ };
140
+ var AddReactionError = class extends Error {
141
+ constructor(cause, context) {
142
+ super("Add reaction failed.");
143
+ this.cause = cause;
144
+ this.context = context;
145
+ this.name = "AddReactionError";
146
+ }
147
+ };
148
+ var RemoveReactionError = class extends Error {
149
+ constructor(cause, context) {
150
+ super("Remove reaction failed.");
151
+ this.cause = cause;
152
+ this.context = context;
153
+ this.name = "RemoveReactionError";
154
+ }
155
+ };
156
+ var MarkInboxNotificationAsReadError = class extends Error {
157
+ constructor(cause, context) {
158
+ super("Mark inbox notification as read failed.");
159
+ this.cause = cause;
160
+ this.context = context;
161
+ this.name = "MarkInboxNotificationAsReadError";
162
+ }
163
+ };
164
+ var UpdateNotificationSettingsError = class extends Error {
165
+ constructor(cause, context) {
166
+ super("Update notification settings failed.");
167
+ this.cause = cause;
168
+ this.context = context;
169
+ this.name = "UpdateNotificationSettingsError";
170
+ }
171
+ };
172
+
173
+ // src/room.tsx
174
+ import { shallow as shallow2 } from "@liveblocks/client";
74
175
  import {
75
- assert,
76
- createClient,
77
- kInternal,
78
- makePoller,
79
- memoizeOnSuccess,
80
- nanoid,
81
- raise,
82
- shallow
176
+ addReaction,
177
+ CommentsApiError,
178
+ console as console2,
179
+ createCommentId,
180
+ createThreadId,
181
+ deleteComment,
182
+ deprecateIf,
183
+ errorIf,
184
+ kInternal as kInternal2,
185
+ makeEventSource,
186
+ makePoller as makePoller2,
187
+ nanoid as nanoid2,
188
+ NotificationsApiError,
189
+ removeReaction,
190
+ ServerMsgCode,
191
+ stringify,
192
+ upsertComment
83
193
  } from "@liveblocks/core";
84
- import React2, {
85
- createContext,
86
- useCallback as useCallback2,
87
- useContext,
88
- useEffect as useEffect3,
89
- useMemo
90
- } from "react";
91
- import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
92
- import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
194
+ import * as React4 from "react";
195
+ import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector2 } from "use-sync-external-store/shim/with-selector.js";
196
+
197
+ // src/comments/lib/select-notification-settings.ts
198
+ import {
199
+ applyOptimisticUpdates as applyOptimisticUpdates2,
200
+ nn
201
+ } from "@liveblocks/core";
202
+ function selectNotificationSettings(roomId, state) {
203
+ const { notificationSettings } = applyOptimisticUpdates2(state);
204
+ return nn(notificationSettings[roomId]);
205
+ }
93
206
 
94
207
  // src/comments/lib/selected-inbox-notifications.ts
95
- import { applyOptimisticUpdates as applyOptimisticUpdates2 } from "@liveblocks/core";
208
+ import { applyOptimisticUpdates as applyOptimisticUpdates3 } from "@liveblocks/core";
96
209
  function selectedInboxNotifications(state) {
97
- const result = applyOptimisticUpdates2(state);
210
+ const result = applyOptimisticUpdates3(state);
98
211
  return Object.values(result.inboxNotifications).sort(
99
212
  // Sort so that the most recent notifications are first
100
213
  (a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime()
@@ -188,6 +301,25 @@ var use = (
188
301
  );
189
302
 
190
303
  // src/liveblocks.tsx
304
+ import {
305
+ assert,
306
+ createClient,
307
+ kInternal,
308
+ makePoller,
309
+ memoizeOnSuccess,
310
+ nanoid,
311
+ raise,
312
+ shallow
313
+ } from "@liveblocks/core";
314
+ import React2, {
315
+ createContext,
316
+ useCallback as useCallback2,
317
+ useContext,
318
+ useEffect as useEffect3,
319
+ useMemo
320
+ } from "react";
321
+ import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
322
+ import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
191
323
  var ClientContext = createContext(null);
192
324
  function missingUserError(userId) {
193
325
  return new Error(`resolveUsers didn't return anything for user '${userId}'`);
@@ -501,6 +633,7 @@ function makeLiveblocksContextBundle(client) {
501
633
  useDeleteInboxNotification: useDeleteInboxNotification2,
502
634
  useDeleteAllInboxNotifications: useDeleteAllInboxNotifications2,
503
635
  useInboxNotificationThread: useInboxNotificationThread2,
636
+ useUserThreads_experimental: () => useUserThreads_withClient(client),
504
637
  ...shared.classic,
505
638
  suspense: {
506
639
  LiveblocksProvider: LiveblocksProvider2,
@@ -511,6 +644,7 @@ function makeLiveblocksContextBundle(client) {
511
644
  useDeleteInboxNotification: useDeleteInboxNotification2,
512
645
  useDeleteAllInboxNotifications: useDeleteAllInboxNotifications2,
513
646
  useInboxNotificationThread: useInboxNotificationThread2,
647
+ useUserThreads_experimental: () => useUserThreadsSuspense_withClient(client),
514
648
  ...shared.suspense
515
649
  }
516
650
  };
@@ -883,12 +1017,14 @@ function createSharedContext(client) {
883
1017
  classic: {
884
1018
  useClient: useClient2,
885
1019
  useUser: (userId) => useUser_withClient(client, userId),
886
- useRoomInfo: (roomId) => useRoomInfo_withClient(client, roomId)
1020
+ useRoomInfo: (roomId) => useRoomInfo_withClient(client, roomId),
1021
+ useIsInsideRoom: _useIsInsideRoom
887
1022
  },
888
1023
  suspense: {
889
1024
  useClient: useClient2,
890
1025
  useUser: (userId) => useUserSuspense_withClient(client, userId),
891
- useRoomInfo: (roomId) => useRoomInfoSuspense_withClient(client, roomId)
1026
+ useRoomInfo: (roomId) => useRoomInfoSuspense_withClient(client, roomId),
1027
+ useIsInsideRoom: _useIsInsideRoom
892
1028
  }
893
1029
  };
894
1030
  }
@@ -941,10 +1077,10 @@ function LiveblocksProvider(props) {
941
1077
  function createLiveblocksContext(client) {
942
1078
  return getOrCreateContextBundle(client);
943
1079
  }
944
- function useUserThreads() {
1080
+ function useUserThreads_experimental() {
945
1081
  return useUserThreads_withClient(useClient());
946
1082
  }
947
- function useUserThreadsSuspense() {
1083
+ function useUserThreadsSuspense_experimental() {
948
1084
  return useUserThreadsSuspense_withClient(useClient());
949
1085
  }
950
1086
  function useInboxNotifications() {
@@ -994,138 +1130,8 @@ function useRoomInfoSuspense(roomId) {
994
1130
  var _useInboxNotificationThread = useInboxNotificationThread;
995
1131
  var _useUser = useUser;
996
1132
  var _useUserSuspense = useUserSuspense;
997
-
998
- // src/comments/errors.ts
999
- var CreateThreadError = class extends Error {
1000
- constructor(cause, context) {
1001
- super("Create thread failed.");
1002
- this.cause = cause;
1003
- this.context = context;
1004
- this.name = "CreateThreadError";
1005
- }
1006
- };
1007
- var DeleteThreadError = class extends Error {
1008
- constructor(cause, context) {
1009
- super("Delete thread failed.");
1010
- this.cause = cause;
1011
- this.context = context;
1012
- this.name = "DeleteThreadError";
1013
- }
1014
- };
1015
- var EditThreadMetadataError = class extends Error {
1016
- constructor(cause, context) {
1017
- super("Edit thread metadata failed.");
1018
- this.cause = cause;
1019
- this.context = context;
1020
- this.name = "EditThreadMetadataError";
1021
- }
1022
- };
1023
- var MarkThreadAsResolvedError = class extends Error {
1024
- constructor(cause, context) {
1025
- super("Mark thread as resolved failed.");
1026
- this.cause = cause;
1027
- this.context = context;
1028
- this.name = "MarkThreadAsResolvedError";
1029
- }
1030
- };
1031
- var MarkThreadAsUnresolvedError = class extends Error {
1032
- constructor(cause, context) {
1033
- super("Mark thread as unresolved failed.");
1034
- this.cause = cause;
1035
- this.context = context;
1036
- this.name = "MarkThreadAsUnresolvedError";
1037
- }
1038
- };
1039
- var CreateCommentError = class extends Error {
1040
- constructor(cause, context) {
1041
- super("Create comment failed.");
1042
- this.cause = cause;
1043
- this.context = context;
1044
- this.name = "CreateCommentError";
1045
- }
1046
- };
1047
- var EditCommentError = class extends Error {
1048
- constructor(cause, context) {
1049
- super("Edit comment failed.");
1050
- this.cause = cause;
1051
- this.context = context;
1052
- this.name = "EditCommentError";
1053
- }
1054
- };
1055
- var DeleteCommentError = class extends Error {
1056
- constructor(cause, context) {
1057
- super("Delete comment failed.");
1058
- this.cause = cause;
1059
- this.context = context;
1060
- this.name = "DeleteCommentError";
1061
- }
1062
- };
1063
- var AddReactionError = class extends Error {
1064
- constructor(cause, context) {
1065
- super("Add reaction failed.");
1066
- this.cause = cause;
1067
- this.context = context;
1068
- this.name = "AddReactionError";
1069
- }
1070
- };
1071
- var RemoveReactionError = class extends Error {
1072
- constructor(cause, context) {
1073
- super("Remove reaction failed.");
1074
- this.cause = cause;
1075
- this.context = context;
1076
- this.name = "RemoveReactionError";
1077
- }
1078
- };
1079
- var MarkInboxNotificationAsReadError = class extends Error {
1080
- constructor(cause, context) {
1081
- super("Mark inbox notification as read failed.");
1082
- this.cause = cause;
1083
- this.context = context;
1084
- this.name = "MarkInboxNotificationAsReadError";
1085
- }
1086
- };
1087
- var UpdateNotificationSettingsError = class extends Error {
1088
- constructor(cause, context) {
1089
- super("Update notification settings failed.");
1090
- this.cause = cause;
1091
- this.context = context;
1092
- this.name = "UpdateNotificationSettingsError";
1093
- }
1094
- };
1095
-
1096
- // src/room.tsx
1097
- import { shallow as shallow2 } from "@liveblocks/client";
1098
- import {
1099
- addReaction,
1100
- CommentsApiError,
1101
- console as console2,
1102
- createCommentId,
1103
- createThreadId,
1104
- deleteComment,
1105
- deprecateIf,
1106
- errorIf,
1107
- kInternal as kInternal2,
1108
- makeEventSource,
1109
- makePoller as makePoller2,
1110
- nanoid as nanoid2,
1111
- NotificationsApiError,
1112
- removeReaction,
1113
- ServerMsgCode,
1114
- stringify,
1115
- upsertComment
1116
- } from "@liveblocks/core";
1117
- import * as React4 from "react";
1118
- import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector2 } from "use-sync-external-store/shim/with-selector.js";
1119
-
1120
- // src/comments/lib/select-notification-settings.ts
1121
- import {
1122
- applyOptimisticUpdates as applyOptimisticUpdates3,
1123
- nn
1124
- } from "@liveblocks/core";
1125
- function selectNotificationSettings(roomId, state) {
1126
- const { notificationSettings } = applyOptimisticUpdates3(state);
1127
- return nn(notificationSettings[roomId]);
1128
- }
1133
+ var _useUserThreads_experimental = useUserThreads_experimental;
1134
+ var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
1129
1135
 
1130
1136
  // src/use-scroll-to-comment-on-load-effect.ts
1131
1137
  import * as React3 from "react";
@@ -1640,6 +1646,10 @@ function useRoom() {
1640
1646
  }
1641
1647
  return room;
1642
1648
  }
1649
+ function useIsInsideRoom() {
1650
+ const room = useRoomOrNull();
1651
+ return room !== null;
1652
+ }
1643
1653
  function useStatus() {
1644
1654
  const room = useRoom();
1645
1655
  const subscribe = room.events.status.subscribe;
@@ -2891,6 +2901,7 @@ var _RoomProvider = RoomProvider;
2891
2901
  var _useBroadcastEvent = useBroadcastEvent;
2892
2902
  var _useOthersListener = useOthersListener;
2893
2903
  var _useRoom = useRoom;
2904
+ var _useIsInsideRoom = useIsInsideRoom;
2894
2905
  var _useAddReaction = useAddReaction;
2895
2906
  var _useMutation = useMutation;
2896
2907
  var _useCreateThread = useCreateThread;
@@ -2927,25 +2938,6 @@ export {
2927
2938
  PKG_FORMAT,
2928
2939
  ClientSideSuspense,
2929
2940
  selectedThreads,
2930
- ClientContext,
2931
- useClient,
2932
- LiveblocksProvider,
2933
- createLiveblocksContext,
2934
- useUserThreads,
2935
- useUserThreadsSuspense,
2936
- useInboxNotifications,
2937
- useInboxNotificationsSuspense,
2938
- useMarkAllInboxNotificationsAsRead,
2939
- useMarkInboxNotificationAsRead,
2940
- useDeleteAllInboxNotifications,
2941
- useDeleteInboxNotification,
2942
- useUnreadInboxNotificationsCount,
2943
- useUnreadInboxNotificationsCountSuspense,
2944
- useRoomInfo,
2945
- useRoomInfoSuspense,
2946
- _useInboxNotificationThread,
2947
- _useUser,
2948
- _useUserSuspense,
2949
2941
  CreateThreadError,
2950
2942
  RoomContext,
2951
2943
  useStatus,
@@ -2977,6 +2969,7 @@ export {
2977
2969
  _useBroadcastEvent,
2978
2970
  _useOthersListener,
2979
2971
  _useRoom,
2972
+ _useIsInsideRoom,
2980
2973
  _useAddReaction,
2981
2974
  _useMutation,
2982
2975
  _useCreateThread,
@@ -2997,6 +2990,25 @@ export {
2997
2990
  _useSelf,
2998
2991
  _useSelfSuspense,
2999
2992
  _useStorageRoot,
3000
- _useUpdateMyPresence
2993
+ _useUpdateMyPresence,
2994
+ ClientContext,
2995
+ useClient,
2996
+ LiveblocksProvider,
2997
+ createLiveblocksContext,
2998
+ useInboxNotifications,
2999
+ useInboxNotificationsSuspense,
3000
+ useMarkAllInboxNotificationsAsRead,
3001
+ useMarkInboxNotificationAsRead,
3002
+ useDeleteAllInboxNotifications,
3003
+ useDeleteInboxNotification,
3004
+ useUnreadInboxNotificationsCount,
3005
+ useUnreadInboxNotificationsCountSuspense,
3006
+ useRoomInfo,
3007
+ useRoomInfoSuspense,
3008
+ _useInboxNotificationThread,
3009
+ _useUser,
3010
+ _useUserSuspense,
3011
+ _useUserThreads_experimental,
3012
+ _useUserThreadsSuspense_experimental
3001
3013
  };
3002
- //# sourceMappingURL=chunk-T6YOAS5Z.mjs.map
3014
+ //# sourceMappingURL=chunk-SIEZLPM7.mjs.map