@liveblocks/react 2.4.1-test4 → 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-test4";
3
+ var PKG_VERSION = "2.5.0";
4
4
  var PKG_FORMAT = "esm";
5
5
 
6
6
  // src/ClientSideSuspense.tsx
@@ -72,31 +72,142 @@ var assertMetadataValueIsString = (value) => {
72
72
  return typeof value === "string";
73
73
  };
74
74
 
75
- // 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";
76
175
  import {
77
- assert,
78
- createClient,
79
- kInternal,
80
- makePoller,
81
- memoizeOnSuccess,
82
- nanoid,
83
- raise,
84
- 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
85
193
  } from "@liveblocks/core";
86
- import React2, {
87
- createContext,
88
- useCallback as useCallback2,
89
- useContext,
90
- useEffect as useEffect3,
91
- useMemo
92
- } from "react";
93
- import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
94
- 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
+ }
95
206
 
96
207
  // src/comments/lib/selected-inbox-notifications.ts
97
- import { applyOptimisticUpdates as applyOptimisticUpdates2 } from "@liveblocks/core";
208
+ import { applyOptimisticUpdates as applyOptimisticUpdates3 } from "@liveblocks/core";
98
209
  function selectedInboxNotifications(state) {
99
- const result = applyOptimisticUpdates2(state);
210
+ const result = applyOptimisticUpdates3(state);
100
211
  return Object.values(result.inboxNotifications).sort(
101
212
  // Sort so that the most recent notifications are first
102
213
  (a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime()
@@ -190,6 +301,25 @@ var use = (
190
301
  );
191
302
 
192
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";
193
323
  var ClientContext = createContext(null);
194
324
  function missingUserError(userId) {
195
325
  return new Error(`resolveUsers didn't return anything for user '${userId}'`);
@@ -887,12 +1017,14 @@ function createSharedContext(client) {
887
1017
  classic: {
888
1018
  useClient: useClient2,
889
1019
  useUser: (userId) => useUser_withClient(client, userId),
890
- useRoomInfo: (roomId) => useRoomInfo_withClient(client, roomId)
1020
+ useRoomInfo: (roomId) => useRoomInfo_withClient(client, roomId),
1021
+ useIsInsideRoom: _useIsInsideRoom
891
1022
  },
892
1023
  suspense: {
893
1024
  useClient: useClient2,
894
1025
  useUser: (userId) => useUserSuspense_withClient(client, userId),
895
- useRoomInfo: (roomId) => useRoomInfoSuspense_withClient(client, roomId)
1026
+ useRoomInfo: (roomId) => useRoomInfoSuspense_withClient(client, roomId),
1027
+ useIsInsideRoom: _useIsInsideRoom
896
1028
  }
897
1029
  };
898
1030
  }
@@ -1001,138 +1133,6 @@ var _useUserSuspense = useUserSuspense;
1001
1133
  var _useUserThreads_experimental = useUserThreads_experimental;
1002
1134
  var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
1003
1135
 
1004
- // src/comments/errors.ts
1005
- var CreateThreadError = class extends Error {
1006
- constructor(cause, context) {
1007
- super("Create thread failed.");
1008
- this.cause = cause;
1009
- this.context = context;
1010
- this.name = "CreateThreadError";
1011
- }
1012
- };
1013
- var DeleteThreadError = class extends Error {
1014
- constructor(cause, context) {
1015
- super("Delete thread failed.");
1016
- this.cause = cause;
1017
- this.context = context;
1018
- this.name = "DeleteThreadError";
1019
- }
1020
- };
1021
- var EditThreadMetadataError = class extends Error {
1022
- constructor(cause, context) {
1023
- super("Edit thread metadata failed.");
1024
- this.cause = cause;
1025
- this.context = context;
1026
- this.name = "EditThreadMetadataError";
1027
- }
1028
- };
1029
- var MarkThreadAsResolvedError = class extends Error {
1030
- constructor(cause, context) {
1031
- super("Mark thread as resolved failed.");
1032
- this.cause = cause;
1033
- this.context = context;
1034
- this.name = "MarkThreadAsResolvedError";
1035
- }
1036
- };
1037
- var MarkThreadAsUnresolvedError = class extends Error {
1038
- constructor(cause, context) {
1039
- super("Mark thread as unresolved failed.");
1040
- this.cause = cause;
1041
- this.context = context;
1042
- this.name = "MarkThreadAsUnresolvedError";
1043
- }
1044
- };
1045
- var CreateCommentError = class extends Error {
1046
- constructor(cause, context) {
1047
- super("Create comment failed.");
1048
- this.cause = cause;
1049
- this.context = context;
1050
- this.name = "CreateCommentError";
1051
- }
1052
- };
1053
- var EditCommentError = class extends Error {
1054
- constructor(cause, context) {
1055
- super("Edit comment failed.");
1056
- this.cause = cause;
1057
- this.context = context;
1058
- this.name = "EditCommentError";
1059
- }
1060
- };
1061
- var DeleteCommentError = class extends Error {
1062
- constructor(cause, context) {
1063
- super("Delete comment failed.");
1064
- this.cause = cause;
1065
- this.context = context;
1066
- this.name = "DeleteCommentError";
1067
- }
1068
- };
1069
- var AddReactionError = class extends Error {
1070
- constructor(cause, context) {
1071
- super("Add reaction failed.");
1072
- this.cause = cause;
1073
- this.context = context;
1074
- this.name = "AddReactionError";
1075
- }
1076
- };
1077
- var RemoveReactionError = class extends Error {
1078
- constructor(cause, context) {
1079
- super("Remove reaction failed.");
1080
- this.cause = cause;
1081
- this.context = context;
1082
- this.name = "RemoveReactionError";
1083
- }
1084
- };
1085
- var MarkInboxNotificationAsReadError = class extends Error {
1086
- constructor(cause, context) {
1087
- super("Mark inbox notification as read failed.");
1088
- this.cause = cause;
1089
- this.context = context;
1090
- this.name = "MarkInboxNotificationAsReadError";
1091
- }
1092
- };
1093
- var UpdateNotificationSettingsError = class extends Error {
1094
- constructor(cause, context) {
1095
- super("Update notification settings failed.");
1096
- this.cause = cause;
1097
- this.context = context;
1098
- this.name = "UpdateNotificationSettingsError";
1099
- }
1100
- };
1101
-
1102
- // src/room.tsx
1103
- import { shallow as shallow2 } from "@liveblocks/client";
1104
- import {
1105
- addReaction,
1106
- CommentsApiError,
1107
- console as console2,
1108
- createCommentId,
1109
- createThreadId,
1110
- deleteComment,
1111
- deprecateIf,
1112
- errorIf,
1113
- kInternal as kInternal2,
1114
- makeEventSource,
1115
- makePoller as makePoller2,
1116
- nanoid as nanoid2,
1117
- NotificationsApiError,
1118
- removeReaction,
1119
- ServerMsgCode,
1120
- stringify,
1121
- upsertComment
1122
- } from "@liveblocks/core";
1123
- import * as React4 from "react";
1124
- import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector2 } from "use-sync-external-store/shim/with-selector.js";
1125
-
1126
- // src/comments/lib/select-notification-settings.ts
1127
- import {
1128
- applyOptimisticUpdates as applyOptimisticUpdates3,
1129
- nn
1130
- } from "@liveblocks/core";
1131
- function selectNotificationSettings(roomId, state) {
1132
- const { notificationSettings } = applyOptimisticUpdates3(state);
1133
- return nn(notificationSettings[roomId]);
1134
- }
1135
-
1136
1136
  // src/use-scroll-to-comment-on-load-effect.ts
1137
1137
  import * as React3 from "react";
1138
1138
  function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
@@ -1646,6 +1646,10 @@ function useRoom() {
1646
1646
  }
1647
1647
  return room;
1648
1648
  }
1649
+ function useIsInsideRoom() {
1650
+ const room = useRoomOrNull();
1651
+ return room !== null;
1652
+ }
1649
1653
  function useStatus() {
1650
1654
  const room = useRoom();
1651
1655
  const subscribe = room.events.status.subscribe;
@@ -2897,6 +2901,7 @@ var _RoomProvider = RoomProvider;
2897
2901
  var _useBroadcastEvent = useBroadcastEvent;
2898
2902
  var _useOthersListener = useOthersListener;
2899
2903
  var _useRoom = useRoom;
2904
+ var _useIsInsideRoom = useIsInsideRoom;
2900
2905
  var _useAddReaction = useAddReaction;
2901
2906
  var _useMutation = useMutation;
2902
2907
  var _useCreateThread = useCreateThread;
@@ -2933,25 +2938,6 @@ export {
2933
2938
  PKG_FORMAT,
2934
2939
  ClientSideSuspense,
2935
2940
  selectedThreads,
2936
- ClientContext,
2937
- useClient,
2938
- LiveblocksProvider,
2939
- createLiveblocksContext,
2940
- useInboxNotifications,
2941
- useInboxNotificationsSuspense,
2942
- useMarkAllInboxNotificationsAsRead,
2943
- useMarkInboxNotificationAsRead,
2944
- useDeleteAllInboxNotifications,
2945
- useDeleteInboxNotification,
2946
- useUnreadInboxNotificationsCount,
2947
- useUnreadInboxNotificationsCountSuspense,
2948
- useRoomInfo,
2949
- useRoomInfoSuspense,
2950
- _useInboxNotificationThread,
2951
- _useUser,
2952
- _useUserSuspense,
2953
- _useUserThreads_experimental,
2954
- _useUserThreadsSuspense_experimental,
2955
2941
  CreateThreadError,
2956
2942
  RoomContext,
2957
2943
  useStatus,
@@ -2983,6 +2969,7 @@ export {
2983
2969
  _useBroadcastEvent,
2984
2970
  _useOthersListener,
2985
2971
  _useRoom,
2972
+ _useIsInsideRoom,
2986
2973
  _useAddReaction,
2987
2974
  _useMutation,
2988
2975
  _useCreateThread,
@@ -3003,6 +2990,25 @@ export {
3003
2990
  _useSelf,
3004
2991
  _useSelfSuspense,
3005
2992
  _useStorageRoot,
3006
- _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
3007
3013
  };
3008
- //# sourceMappingURL=chunk-XPY53VGO.mjs.map
3014
+ //# sourceMappingURL=chunk-SIEZLPM7.mjs.map