@liveblocks/react 2.15.1 → 2.16.0-toolbars1
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 +6 -4
- package/dist/_private.d.ts +6 -4
- package/dist/_private.js +11 -6
- package/dist/_private.js.map +1 -1
- package/dist/_private.mjs +10 -5
- package/dist/_private.mjs.map +1 -1
- package/dist/{chunk-WV5AI4AE.js → chunk-FKSXNQBA.js} +2 -2
- package/dist/chunk-FKSXNQBA.js.map +1 -0
- package/dist/{chunk-GMKB6I6V.mjs → chunk-FQKGWA7O.mjs} +487 -697
- package/dist/chunk-FQKGWA7O.mjs.map +1 -0
- package/dist/{chunk-NUDMG62P.js → chunk-VJYVOAD5.js} +493 -703
- package/dist/chunk-VJYVOAD5.js.map +1 -0
- package/dist/{chunk-UX3CG7ZS.mjs → chunk-XGO3ZXGZ.mjs} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{room-XbmI0Hoh.d.mts → room-ne1TCZyH.d.mts} +125 -160
- package/dist/{room-XbmI0Hoh.d.ts → room-ne1TCZyH.d.ts} +125 -160
- package/dist/suspense.d.mts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +4 -4
- package/dist/suspense.js.map +1 -1
- package/dist/suspense.mjs +2 -2
- package/package.json +5 -5
- package/dist/chunk-GMKB6I6V.mjs.map +0 -1
- package/dist/chunk-NUDMG62P.js.map +0 -1
- package/dist/chunk-WV5AI4AE.js.map +0 -1
- /package/dist/{chunk-UX3CG7ZS.mjs.map → chunk-XGO3ZXGZ.mjs.map} +0 -0
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as react from 'react';
|
|
3
2
|
import { Context, PropsWithChildren, ReactNode } from 'react';
|
|
4
|
-
import { JsonObject, LsonObject, BaseUserMeta,
|
|
3
|
+
import { JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata, Room, LiveObject, User, RoomNotificationSettings, Status, BroadcastOptions, OthersEvent, LostConnectionEvent, History, Client as Client$1, ClientOptions, StorageStatus as StorageStatus$1, ThreadData as ThreadData$1, CommentData as CommentData$1 } from '@liveblocks/client';
|
|
5
4
|
import * as _liveblocks_core from '@liveblocks/core';
|
|
6
|
-
import { BaseMetadata, CommentBody, Patchable, StorageStatus, QueryMetadata, AsyncResult, DRI, AsyncSuccess, Resolve, CommentAttachment, PartialUnless, InboxNotificationData, ToImmutable, AsyncLoading, AsyncError, ThreadData, HistoryVersion, Client, SyncStatus, LiveblocksError, RoomEventMessage, CommentData, MutableSignal, ThreadDataWithDeleteInfo, ThreadDeleteInfo, DerivedSignal, OpaqueClient, CommentUserReaction, InboxNotificationDeleteInfo, RoomNotificationSettings as RoomNotificationSettings$1, Permission, BaseUserMeta as BaseUserMeta$1, DistributiveOmit, DU, DM,
|
|
5
|
+
import { OpaqueRoom, BaseMetadata as BaseMetadata$1, CommentBody, Patchable, StorageStatus, QueryMetadata, AsyncResult, DRI, AsyncSuccess, Resolve, CommentAttachment, PartialUnless, InboxNotificationData, ToImmutable, AsyncLoading, AsyncError, ThreadData, HistoryVersion, Client, SyncStatus, LiveblocksError, RoomEventMessage, CommentData, MutableSignal, ThreadDataWithDeleteInfo, ThreadDeleteInfo, DerivedSignal, DefaultMap, OpaqueClient, CommentUserReaction, InboxNotificationDeleteInfo, RoomNotificationSettings as RoomNotificationSettings$1, ISignal, Permission, BaseUserMeta as BaseUserMeta$1, DistributiveOmit, DU, DM, TextEditorType, IYjsProvider, DP, DS, DE } from '@liveblocks/core';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Raw access to the React context where the RoomProvider stores the current
|
|
10
|
+
* room. Exposed for advanced use cases only.
|
|
11
|
+
*
|
|
12
|
+
* @private This is a private/advanced API. Do not rely on it.
|
|
13
|
+
*/
|
|
14
|
+
declare const RoomContext: react.Context<OpaqueRoom | null>;
|
|
15
|
+
/** @private */
|
|
16
|
+
declare function useRoomOrNull<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json, M extends BaseMetadata>(): Room<P, S, U, E, M> | null;
|
|
7
17
|
|
|
8
18
|
/**
|
|
9
19
|
* @private Internal API, do not rely on it.
|
|
10
20
|
*/
|
|
11
|
-
declare class CreateThreadError<M extends BaseMetadata> extends Error {
|
|
21
|
+
declare class CreateThreadError<M extends BaseMetadata$1> extends Error {
|
|
12
22
|
cause: Error;
|
|
13
23
|
context: {
|
|
14
24
|
roomId: string;
|
|
@@ -28,7 +38,7 @@ declare class CreateThreadError<M extends BaseMetadata> extends Error {
|
|
|
28
38
|
/**
|
|
29
39
|
* @private Internal API, do not rely on it.
|
|
30
40
|
*/
|
|
31
|
-
declare class EditThreadMetadataError<M extends BaseMetadata> extends Error {
|
|
41
|
+
declare class EditThreadMetadataError<M extends BaseMetadata$1> extends Error {
|
|
32
42
|
cause: Error;
|
|
33
43
|
context: {
|
|
34
44
|
roomId: string;
|
|
@@ -120,9 +130,9 @@ declare class UpdateNotificationSettingsError extends Error {
|
|
|
120
130
|
/**
|
|
121
131
|
* @private Internal API, do not rely on it.
|
|
122
132
|
*/
|
|
123
|
-
|
|
133
|
+
type CommentsError<M extends BaseMetadata$1> = CreateThreadError<M> | EditThreadMetadataError<M> | CreateCommentError | EditCommentError | DeleteCommentError | MarkInboxNotificationAsReadError | UpdateNotificationSettingsError;
|
|
124
134
|
|
|
125
|
-
|
|
135
|
+
type UseSyncStatusOptions = {
|
|
126
136
|
/**
|
|
127
137
|
* When setting smooth, the hook will not update immediately as status
|
|
128
138
|
* changes. This is because in typical applications, these states can change
|
|
@@ -131,9 +141,9 @@ declare type UseSyncStatusOptions = {
|
|
|
131
141
|
*/
|
|
132
142
|
smooth?: boolean;
|
|
133
143
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
144
|
+
type UseStorageStatusOptions = UseSyncStatusOptions;
|
|
145
|
+
type StorageStatusSuccess = Exclude<StorageStatus, "not-loaded" | "loading">;
|
|
146
|
+
type ThreadsQuery<M extends BaseMetadata$1> = {
|
|
137
147
|
/**
|
|
138
148
|
* Whether to only return threads marked as resolved or unresolved. If not provided,
|
|
139
149
|
* all threads will be returned.
|
|
@@ -145,14 +155,14 @@ declare type ThreadsQuery<M extends BaseMetadata> = {
|
|
|
145
155
|
*/
|
|
146
156
|
metadata?: Partial<QueryMetadata<M>>;
|
|
147
157
|
};
|
|
148
|
-
|
|
158
|
+
type UseUserThreadsOptions<M extends BaseMetadata$1> = {
|
|
149
159
|
/**
|
|
150
160
|
* The query (including metadata) to filter the threads by. If provided, only threads
|
|
151
161
|
* that match the query will be returned. If not provided, all threads will be returned.
|
|
152
162
|
*/
|
|
153
163
|
query?: ThreadsQuery<M>;
|
|
154
164
|
};
|
|
155
|
-
|
|
165
|
+
type UseThreadsOptions<M extends BaseMetadata$1> = {
|
|
156
166
|
/**
|
|
157
167
|
* The query (including metadata) to filter the threads by. If provided, only threads
|
|
158
168
|
* that match the query will be returned. If not provided, all threads will be returned.
|
|
@@ -167,68 +177,68 @@ declare type UseThreadsOptions<M extends BaseMetadata> = {
|
|
|
167
177
|
*/
|
|
168
178
|
scrollOnLoad?: boolean;
|
|
169
179
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
type UserAsyncResult<T> = AsyncResult<T, "user">;
|
|
181
|
+
type UserAsyncSuccess<T> = AsyncSuccess<T, "user">;
|
|
182
|
+
type RoomInfoAsyncResult = AsyncResult<DRI, "info">;
|
|
183
|
+
type RoomInfoAsyncSuccess = AsyncSuccess<DRI, "info">;
|
|
184
|
+
type AttachmentUrlAsyncResult = AsyncResult<string, "url">;
|
|
185
|
+
type AttachmentUrlAsyncSuccess = AsyncSuccess<string, "url">;
|
|
186
|
+
type CreateThreadOptions<M extends BaseMetadata$1> = Resolve<{
|
|
177
187
|
body: CommentBody;
|
|
178
188
|
attachments?: CommentAttachment[];
|
|
179
189
|
} & PartialUnless<M, {
|
|
180
190
|
metadata: M;
|
|
181
191
|
}>>;
|
|
182
|
-
|
|
192
|
+
type EditThreadMetadataOptions<M extends BaseMetadata$1> = {
|
|
183
193
|
threadId: string;
|
|
184
194
|
metadata: Patchable<M>;
|
|
185
195
|
};
|
|
186
|
-
|
|
196
|
+
type CreateCommentOptions = {
|
|
187
197
|
threadId: string;
|
|
188
198
|
body: CommentBody;
|
|
189
199
|
attachments?: CommentAttachment[];
|
|
190
200
|
};
|
|
191
|
-
|
|
201
|
+
type EditCommentOptions = {
|
|
192
202
|
threadId: string;
|
|
193
203
|
commentId: string;
|
|
194
204
|
body: CommentBody;
|
|
195
205
|
attachments?: CommentAttachment[];
|
|
196
206
|
};
|
|
197
|
-
|
|
207
|
+
type DeleteCommentOptions = {
|
|
198
208
|
threadId: string;
|
|
199
209
|
commentId: string;
|
|
200
210
|
};
|
|
201
|
-
|
|
211
|
+
type CommentReactionOptions = {
|
|
202
212
|
threadId: string;
|
|
203
213
|
commentId: string;
|
|
204
214
|
emoji: string;
|
|
205
215
|
};
|
|
206
|
-
|
|
216
|
+
type NoPaginationFields = {
|
|
207
217
|
hasFetchedAll?: never;
|
|
208
218
|
isFetchingMore?: never;
|
|
209
219
|
fetchMore?: never;
|
|
210
220
|
fetchMoreError?: never;
|
|
211
221
|
};
|
|
212
|
-
|
|
222
|
+
type PaginationFields = {
|
|
213
223
|
hasFetchedAll: boolean;
|
|
214
224
|
isFetchingMore: boolean;
|
|
215
225
|
fetchMore: () => void;
|
|
216
226
|
fetchMoreError?: Error;
|
|
217
227
|
};
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
type PagedAsyncSuccess<T, F extends string> = Resolve<AsyncSuccess<T, F> & PaginationFields>;
|
|
229
|
+
type PagedAsyncResult<T, F extends string> = Resolve<AsyncLoading<F> & NoPaginationFields> | Resolve<AsyncError<F> & NoPaginationFields> | PagedAsyncSuccess<T, F>;
|
|
230
|
+
type ThreadsAsyncSuccess<M extends BaseMetadata$1> = PagedAsyncSuccess<ThreadData<M>[], "threads">;
|
|
231
|
+
type ThreadsAsyncResult<M extends BaseMetadata$1> = PagedAsyncResult<ThreadData<M>[], "threads">;
|
|
232
|
+
type InboxNotificationsAsyncSuccess = PagedAsyncSuccess<InboxNotificationData[], "inboxNotifications">;
|
|
233
|
+
type InboxNotificationsAsyncResult = PagedAsyncResult<InboxNotificationData[], "inboxNotifications">;
|
|
234
|
+
type UnreadInboxNotificationsCountAsyncSuccess = AsyncSuccess<number, "count">;
|
|
235
|
+
type UnreadInboxNotificationsCountAsyncResult = AsyncResult<number, "count">;
|
|
236
|
+
type RoomNotificationSettingsAsyncSuccess = AsyncSuccess<RoomNotificationSettings, "settings">;
|
|
237
|
+
type RoomNotificationSettingsAsyncResult = AsyncResult<RoomNotificationSettings, "settings">;
|
|
238
|
+
type HistoryVersionDataAsyncResult = AsyncResult<Uint8Array>;
|
|
239
|
+
type HistoryVersionsAsyncSuccess = AsyncSuccess<HistoryVersion[], "versions">;
|
|
240
|
+
type HistoryVersionsAsyncResult = AsyncResult<HistoryVersion[], "versions">;
|
|
241
|
+
type RoomProviderProps<P extends JsonObject, S extends LsonObject> = Resolve<{
|
|
232
242
|
/**
|
|
233
243
|
* The id of the room you want to connect to
|
|
234
244
|
*/
|
|
@@ -259,8 +269,8 @@ declare type RoomProviderProps<P extends JsonObject, S extends LsonObject> = Res
|
|
|
259
269
|
* For any function type, returns a similar function type, but without the
|
|
260
270
|
* first argument.
|
|
261
271
|
*/
|
|
262
|
-
|
|
263
|
-
|
|
272
|
+
type OmitFirstArg<F> = F extends (first: any, ...rest: infer A) => infer R ? (...args: A) => R : never;
|
|
273
|
+
type MutationContext<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta> = {
|
|
264
274
|
storage: LiveObject<S>;
|
|
265
275
|
self: User<P, U>;
|
|
266
276
|
others: readonly User<P, U>[];
|
|
@@ -268,7 +278,7 @@ declare type MutationContext<P extends JsonObject, S extends LsonObject, U exten
|
|
|
268
278
|
addToHistory: boolean;
|
|
269
279
|
}) => void;
|
|
270
280
|
};
|
|
271
|
-
|
|
281
|
+
type ThreadSubscription = {
|
|
272
282
|
status: "not-subscribed";
|
|
273
283
|
unreadSince?: never;
|
|
274
284
|
} | {
|
|
@@ -278,7 +288,7 @@ declare type ThreadSubscription = {
|
|
|
278
288
|
status: "subscribed";
|
|
279
289
|
unreadSince: Date;
|
|
280
290
|
};
|
|
281
|
-
|
|
291
|
+
type SharedContextBundle<U extends BaseUserMeta> = {
|
|
282
292
|
classic: {
|
|
283
293
|
/**
|
|
284
294
|
* Obtains a reference to the current Liveblocks client.
|
|
@@ -359,7 +369,7 @@ declare type SharedContextBundle<U extends BaseUserMeta> = {
|
|
|
359
369
|
/**
|
|
360
370
|
* Properties that are the same in RoomContext and RoomContext["suspense"].
|
|
361
371
|
*/
|
|
362
|
-
|
|
372
|
+
type RoomContextBundleCommon<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json, M extends BaseMetadata$1> = {
|
|
363
373
|
/**
|
|
364
374
|
* You normally don't need to directly interact with the RoomContext, but
|
|
365
375
|
* it can be necessary if you're building an advanced app where you need to
|
|
@@ -775,10 +785,10 @@ declare type RoomContextBundleCommon<P extends JsonObject, S extends LsonObject,
|
|
|
775
785
|
* of Liveblocks, NEVER USE ANY OF THESE DIRECTLY, because bad things
|
|
776
786
|
* will probably happen if you do.
|
|
777
787
|
*/
|
|
778
|
-
|
|
779
|
-
useCommentsErrorListener<M extends BaseMetadata>(callback: (err: CommentsError<M>) => void): void;
|
|
788
|
+
type PrivateRoomContextApi = {
|
|
789
|
+
useCommentsErrorListener<M extends BaseMetadata$1>(callback: (err: CommentsError<M>) => void): void;
|
|
780
790
|
};
|
|
781
|
-
|
|
791
|
+
type RoomContextBundle<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json, M extends BaseMetadata$1> = Resolve<RoomContextBundleCommon<P, S, U, E, M> & SharedContextBundle<U>["classic"] & {
|
|
782
792
|
/**
|
|
783
793
|
* Returns the current storage status for the Room, and triggers
|
|
784
794
|
* a re-render whenever it changes. Can be used to render a "Saving..."
|
|
@@ -974,7 +984,7 @@ declare type RoomContextBundle<P extends JsonObject, S extends LsonObject, U ext
|
|
|
974
984
|
/**
|
|
975
985
|
* Properties that are the same in LiveblocksContext and LiveblocksContext["suspense"].
|
|
976
986
|
*/
|
|
977
|
-
|
|
987
|
+
type LiveblocksContextBundleCommon<M extends BaseMetadata$1> = {
|
|
978
988
|
/**
|
|
979
989
|
* Makes Liveblocks features outside of rooms (e.g. Notifications) available
|
|
980
990
|
* in the component hierarchy below.
|
|
@@ -1040,7 +1050,7 @@ declare type LiveblocksContextBundleCommon<M extends BaseMetadata> = {
|
|
|
1040
1050
|
*/
|
|
1041
1051
|
useSyncStatus(options?: UseSyncStatusOptions): SyncStatus;
|
|
1042
1052
|
};
|
|
1043
|
-
|
|
1053
|
+
type LiveblocksContextBundle<U extends BaseUserMeta, M extends BaseMetadata$1> = Resolve<LiveblocksContextBundleCommon<M> & SharedContextBundle<U>["classic"] & {
|
|
1044
1054
|
/**
|
|
1045
1055
|
* Returns the inbox notifications for the current user.
|
|
1046
1056
|
*
|
|
@@ -1087,7 +1097,7 @@ declare type LiveblocksContextBundle<U extends BaseUserMeta, M extends BaseMetad
|
|
|
1087
1097
|
}>;
|
|
1088
1098
|
}>;
|
|
1089
1099
|
|
|
1090
|
-
|
|
1100
|
+
type ReadonlyThreadDB<M extends BaseMetadata$1> = Omit<ThreadDB<M>, "upsert" | "delete" | "signal">;
|
|
1091
1101
|
/**
|
|
1092
1102
|
* This class implements a lightweight, in-memory, "database" for all Thread
|
|
1093
1103
|
* instances.
|
|
@@ -1105,7 +1115,7 @@ declare type ReadonlyThreadDB<M extends BaseMetadata> = Omit<ThreadDB<M>, "upser
|
|
|
1105
1115
|
* optimistic updates without losing the original thread contents.
|
|
1106
1116
|
*
|
|
1107
1117
|
*/
|
|
1108
|
-
declare class ThreadDB<M extends BaseMetadata> {
|
|
1118
|
+
declare class ThreadDB<M extends BaseMetadata$1> {
|
|
1109
1119
|
#private;
|
|
1110
1120
|
readonly signal: MutableSignal<this>;
|
|
1111
1121
|
constructor();
|
|
@@ -1118,10 +1128,7 @@ declare class ThreadDB<M extends BaseMetadata> {
|
|
|
1118
1128
|
upsert(thread: ThreadDataWithDeleteInfo<M>): void;
|
|
1119
1129
|
/** Like .upsert(), except it won't update if a thread by this ID already exists. */
|
|
1120
1130
|
upsertIfNewer(thread: ThreadDataWithDeleteInfo<M>): void;
|
|
1121
|
-
applyDelta(
|
|
1122
|
-
newThreads: ThreadData<M>[];
|
|
1123
|
-
deletedThreads: ThreadDeleteInfo[];
|
|
1124
|
-
}): void;
|
|
1131
|
+
applyDelta(newThreads: ThreadData<M>[], deletedThreads: ThreadDeleteInfo[]): void;
|
|
1125
1132
|
/**
|
|
1126
1133
|
* Marks a thread as deleted. It will no longer pop up in .findMany()
|
|
1127
1134
|
* queries, but it can still be accessed via `.getEvenIfDeleted()`.
|
|
@@ -1141,50 +1148,50 @@ declare class ThreadDB<M extends BaseMetadata> {
|
|
|
1141
1148
|
findMany(roomId: string | undefined, query: ThreadsQuery<M>, direction: "asc" | "desc"): ThreadData<M>[];
|
|
1142
1149
|
}
|
|
1143
1150
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1151
|
+
type OptimisticUpdate<M extends BaseMetadata$1> = CreateThreadOptimisticUpdate<M> | DeleteThreadOptimisticUpdate | EditThreadMetadataOptimisticUpdate<M> | MarkThreadAsResolvedOptimisticUpdate | MarkThreadAsUnresolvedOptimisticUpdate | CreateCommentOptimisticUpdate | EditCommentOptimisticUpdate | DeleteCommentOptimisticUpdate | AddReactionOptimisticUpdate | RemoveReactionOptimisticUpdate | MarkInboxNotificationAsReadOptimisticUpdate | MarkAllInboxNotificationsAsReadOptimisticUpdate | DeleteInboxNotificationOptimisticUpdate | DeleteAllInboxNotificationsOptimisticUpdate | UpdateNotificationSettingsOptimisticUpdate;
|
|
1152
|
+
type CreateThreadOptimisticUpdate<M extends BaseMetadata$1> = {
|
|
1146
1153
|
type: "create-thread";
|
|
1147
1154
|
id: string;
|
|
1148
1155
|
roomId: string;
|
|
1149
1156
|
thread: ThreadData<M>;
|
|
1150
1157
|
};
|
|
1151
|
-
|
|
1158
|
+
type DeleteThreadOptimisticUpdate = {
|
|
1152
1159
|
type: "delete-thread";
|
|
1153
1160
|
id: string;
|
|
1154
1161
|
roomId: string;
|
|
1155
1162
|
threadId: string;
|
|
1156
1163
|
deletedAt: Date;
|
|
1157
1164
|
};
|
|
1158
|
-
|
|
1165
|
+
type EditThreadMetadataOptimisticUpdate<M extends BaseMetadata$1> = {
|
|
1159
1166
|
type: "edit-thread-metadata";
|
|
1160
1167
|
id: string;
|
|
1161
1168
|
threadId: string;
|
|
1162
1169
|
metadata: Resolve<Patchable<M>>;
|
|
1163
1170
|
updatedAt: Date;
|
|
1164
1171
|
};
|
|
1165
|
-
|
|
1172
|
+
type MarkThreadAsResolvedOptimisticUpdate = {
|
|
1166
1173
|
type: "mark-thread-as-resolved";
|
|
1167
1174
|
id: string;
|
|
1168
1175
|
threadId: string;
|
|
1169
1176
|
updatedAt: Date;
|
|
1170
1177
|
};
|
|
1171
|
-
|
|
1178
|
+
type MarkThreadAsUnresolvedOptimisticUpdate = {
|
|
1172
1179
|
type: "mark-thread-as-unresolved";
|
|
1173
1180
|
id: string;
|
|
1174
1181
|
threadId: string;
|
|
1175
1182
|
updatedAt: Date;
|
|
1176
1183
|
};
|
|
1177
|
-
|
|
1184
|
+
type CreateCommentOptimisticUpdate = {
|
|
1178
1185
|
type: "create-comment";
|
|
1179
1186
|
id: string;
|
|
1180
1187
|
comment: CommentData;
|
|
1181
1188
|
};
|
|
1182
|
-
|
|
1189
|
+
type EditCommentOptimisticUpdate = {
|
|
1183
1190
|
type: "edit-comment";
|
|
1184
1191
|
id: string;
|
|
1185
1192
|
comment: CommentData;
|
|
1186
1193
|
};
|
|
1187
|
-
|
|
1194
|
+
type DeleteCommentOptimisticUpdate = {
|
|
1188
1195
|
type: "delete-comment";
|
|
1189
1196
|
id: string;
|
|
1190
1197
|
roomId: string;
|
|
@@ -1192,14 +1199,14 @@ declare type DeleteCommentOptimisticUpdate = {
|
|
|
1192
1199
|
deletedAt: Date;
|
|
1193
1200
|
commentId: string;
|
|
1194
1201
|
};
|
|
1195
|
-
|
|
1202
|
+
type AddReactionOptimisticUpdate = {
|
|
1196
1203
|
type: "add-reaction";
|
|
1197
1204
|
id: string;
|
|
1198
1205
|
threadId: string;
|
|
1199
1206
|
commentId: string;
|
|
1200
1207
|
reaction: CommentUserReaction;
|
|
1201
1208
|
};
|
|
1202
|
-
|
|
1209
|
+
type RemoveReactionOptimisticUpdate = {
|
|
1203
1210
|
type: "remove-reaction";
|
|
1204
1211
|
id: string;
|
|
1205
1212
|
threadId: string;
|
|
@@ -1208,29 +1215,29 @@ declare type RemoveReactionOptimisticUpdate = {
|
|
|
1208
1215
|
userId: string;
|
|
1209
1216
|
removedAt: Date;
|
|
1210
1217
|
};
|
|
1211
|
-
|
|
1218
|
+
type MarkInboxNotificationAsReadOptimisticUpdate = {
|
|
1212
1219
|
type: "mark-inbox-notification-as-read";
|
|
1213
1220
|
id: string;
|
|
1214
1221
|
inboxNotificationId: string;
|
|
1215
1222
|
readAt: Date;
|
|
1216
1223
|
};
|
|
1217
|
-
|
|
1224
|
+
type MarkAllInboxNotificationsAsReadOptimisticUpdate = {
|
|
1218
1225
|
type: "mark-all-inbox-notifications-as-read";
|
|
1219
1226
|
id: string;
|
|
1220
1227
|
readAt: Date;
|
|
1221
1228
|
};
|
|
1222
|
-
|
|
1229
|
+
type DeleteInboxNotificationOptimisticUpdate = {
|
|
1223
1230
|
type: "delete-inbox-notification";
|
|
1224
1231
|
id: string;
|
|
1225
1232
|
inboxNotificationId: string;
|
|
1226
1233
|
deletedAt: Date;
|
|
1227
1234
|
};
|
|
1228
|
-
|
|
1235
|
+
type DeleteAllInboxNotificationsOptimisticUpdate = {
|
|
1229
1236
|
type: "delete-all-inbox-notifications";
|
|
1230
1237
|
id: string;
|
|
1231
1238
|
deletedAt: Date;
|
|
1232
1239
|
};
|
|
1233
|
-
|
|
1240
|
+
type UpdateNotificationSettingsOptimisticUpdate = {
|
|
1234
1241
|
type: "update-notification-settings";
|
|
1235
1242
|
id: string;
|
|
1236
1243
|
roomId: string;
|
|
@@ -1241,7 +1248,7 @@ declare type UpdateNotificationSettingsOptimisticUpdate = {
|
|
|
1241
1248
|
* field, indicating the status of the promise.
|
|
1242
1249
|
* This is compatible with React's `use()` promises, hence the name.
|
|
1243
1250
|
*/
|
|
1244
|
-
|
|
1251
|
+
type UsablePromise<T> = Promise<T> & ({
|
|
1245
1252
|
status: "pending";
|
|
1246
1253
|
} | {
|
|
1247
1254
|
status: "rejected";
|
|
@@ -1250,24 +1257,17 @@ declare type UsablePromise<T> = Promise<T> & ({
|
|
|
1250
1257
|
status: "fulfilled";
|
|
1251
1258
|
value: T;
|
|
1252
1259
|
});
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
* e.g. { 'room-abc': {versions: "all versions"}}
|
|
1261
|
-
*/
|
|
1262
|
-
declare type VersionsByRoomId = Record<RoomId, Record<string, HistoryVersion>>;
|
|
1260
|
+
type LoadableResource<T> = {
|
|
1261
|
+
signal: ISignal<T>;
|
|
1262
|
+
waitUntilLoaded: () => UsablePromise<void>;
|
|
1263
|
+
};
|
|
1264
|
+
type RoomId = string;
|
|
1265
|
+
type UserQueryKey = string;
|
|
1266
|
+
type RoomQueryKey = string;
|
|
1263
1267
|
/**
|
|
1264
1268
|
* A lookup table (LUT) for all the inbox notifications.
|
|
1265
1269
|
*/
|
|
1266
|
-
|
|
1267
|
-
/**
|
|
1268
|
-
* A lookup table (LUT) for all the room notification settings.
|
|
1269
|
-
*/
|
|
1270
|
-
declare type SettingsLUT = Map<RoomId, RoomNotificationSettings$1>;
|
|
1270
|
+
type NotificationsLUT = Map<string, InboxNotificationData>;
|
|
1271
1271
|
/**
|
|
1272
1272
|
* Notification settings by room ID.
|
|
1273
1273
|
* e.g. { 'room-abc': { threads: "all" },
|
|
@@ -1275,10 +1275,10 @@ declare type SettingsLUT = Map<RoomId, RoomNotificationSettings$1>;
|
|
|
1275
1275
|
* 'room-xyz': { threads: "none" },
|
|
1276
1276
|
* }
|
|
1277
1277
|
*/
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1278
|
+
type SettingsByRoomId = Record<RoomId, RoomNotificationSettings$1>;
|
|
1279
|
+
type PermissionHintsLUT = DefaultMap<RoomId, Set<Permission>>;
|
|
1280
|
+
type CleanThreadifications<M extends BaseMetadata$1> = CleanThreads<M> & CleanNotifications;
|
|
1281
|
+
type CleanThreads<M extends BaseMetadata$1> = {
|
|
1282
1282
|
/**
|
|
1283
1283
|
* Keep track of loading and error status of all the queries made by the client.
|
|
1284
1284
|
* e.g. 'room-abc-{"color":"red"}' - ok
|
|
@@ -1286,7 +1286,7 @@ declare type CleanThreads<M extends BaseMetadata> = {
|
|
|
1286
1286
|
*/
|
|
1287
1287
|
threadsDB: ReadonlyThreadDB<M>;
|
|
1288
1288
|
};
|
|
1289
|
-
|
|
1289
|
+
type CleanNotifications = {
|
|
1290
1290
|
/**
|
|
1291
1291
|
* All inbox notifications in a sorted array, optimistic updates applied.
|
|
1292
1292
|
*/
|
|
@@ -1298,39 +1298,37 @@ declare type CleanNotifications = {
|
|
|
1298
1298
|
notificationsById: Record<string, InboxNotificationData>;
|
|
1299
1299
|
};
|
|
1300
1300
|
declare function createStore_forNotifications(): {
|
|
1301
|
-
signal:
|
|
1301
|
+
signal: ISignal<NotificationsLUT>;
|
|
1302
1302
|
markAllRead: (readAt: Date) => void;
|
|
1303
1303
|
markRead: (notificationId: string, readAt: Date) => void;
|
|
1304
1304
|
delete: (inboxNotificationId: string) => void;
|
|
1305
|
-
applyDelta: (
|
|
1305
|
+
applyDelta: (newNotifications: InboxNotificationData[], deletedNotifications: InboxNotificationDeleteInfo[]) => void;
|
|
1306
1306
|
clear: () => void;
|
|
1307
1307
|
updateAssociatedNotification: (newComment: CommentData) => void;
|
|
1308
|
-
|
|
1309
|
-
invalidate: () => void;
|
|
1308
|
+
upsert: (notification: InboxNotificationData) => void;
|
|
1310
1309
|
};
|
|
1311
|
-
declare function createStore_forRoomNotificationSettings(): {
|
|
1312
|
-
signal:
|
|
1310
|
+
declare function createStore_forRoomNotificationSettings(updates: ISignal<readonly OptimisticUpdate<BaseMetadata$1>[]>): {
|
|
1311
|
+
signal: DerivedSignal<SettingsByRoomId>;
|
|
1313
1312
|
update: (roomId: string, settings: RoomNotificationSettings$1) => void;
|
|
1314
|
-
invalidate: () => void;
|
|
1315
1313
|
};
|
|
1316
1314
|
declare function createStore_forHistoryVersions(): {
|
|
1317
|
-
signal:
|
|
1315
|
+
signal: DerivedSignal<{
|
|
1316
|
+
[k: string]: {
|
|
1317
|
+
[k: string]: HistoryVersion;
|
|
1318
|
+
};
|
|
1319
|
+
}>;
|
|
1318
1320
|
update: (roomId: string, versions: HistoryVersion[]) => void;
|
|
1319
|
-
force_set: (callback: (lut: VersionsLUT) => void | boolean) => void;
|
|
1320
|
-
invalidate: () => void;
|
|
1321
1321
|
};
|
|
1322
1322
|
declare function createStore_forPermissionHints(): {
|
|
1323
|
-
signal:
|
|
1323
|
+
signal: ISignal<PermissionHintsLUT>;
|
|
1324
1324
|
update: (newHints: Record<string, Permission[]>) => void;
|
|
1325
|
-
invalidate: () => void;
|
|
1326
1325
|
};
|
|
1327
|
-
declare function createStore_forOptimistic<M extends BaseMetadata>(client: Client<BaseUserMeta$1, M>): {
|
|
1328
|
-
signal:
|
|
1326
|
+
declare function createStore_forOptimistic<M extends BaseMetadata$1>(client: Client<BaseUserMeta$1, M>): {
|
|
1327
|
+
signal: ISignal<readonly OptimisticUpdate<M>[]>;
|
|
1329
1328
|
add: (optimisticUpdate: DistributiveOmit<OptimisticUpdate<M>, "id">) => string;
|
|
1330
1329
|
remove: (optimisticId: string) => void;
|
|
1331
|
-
invalidate: () => void;
|
|
1332
1330
|
};
|
|
1333
|
-
declare class UmbrellaStore<M extends BaseMetadata> {
|
|
1331
|
+
declare class UmbrellaStore<M extends BaseMetadata$1> {
|
|
1334
1332
|
#private;
|
|
1335
1333
|
readonly threads: ThreadDB<M>;
|
|
1336
1334
|
readonly notifications: ReturnType<typeof createStore_forNotifications>;
|
|
@@ -1340,32 +1338,15 @@ declare class UmbrellaStore<M extends BaseMetadata> {
|
|
|
1340
1338
|
readonly optimisticUpdates: ReturnType<typeof createStore_forOptimistic<M>>;
|
|
1341
1339
|
readonly outputs: {
|
|
1342
1340
|
readonly threadifications: DerivedSignal<CleanThreadifications<M>>;
|
|
1343
|
-
readonly threads: DerivedSignal<
|
|
1341
|
+
readonly threads: DerivedSignal<ReadonlyThreadDB<M>>;
|
|
1342
|
+
readonly loadingRoomThreads: DefaultMap<RoomQueryKey, LoadableResource<ThreadsAsyncResult<M>>>;
|
|
1343
|
+
readonly loadingUserThreads: DefaultMap<UserQueryKey, LoadableResource<ThreadsAsyncResult<M>>>;
|
|
1344
1344
|
readonly notifications: DerivedSignal<CleanNotifications>;
|
|
1345
|
-
readonly
|
|
1346
|
-
readonly
|
|
1345
|
+
readonly loadingNotifications: LoadableResource<InboxNotificationsAsyncResult>;
|
|
1346
|
+
readonly settingsByRoomId: DefaultMap<RoomId, LoadableResource<RoomNotificationSettingsAsyncResult>>;
|
|
1347
|
+
readonly versionsByRoomId: DefaultMap<RoomId, LoadableResource<HistoryVersionsAsyncResult>>;
|
|
1347
1348
|
};
|
|
1348
1349
|
constructor(client: OpaqueClient);
|
|
1349
|
-
get1_both(): CleanThreadifications<M>;
|
|
1350
|
-
subscribe1_both(callback: () => void): () => void;
|
|
1351
|
-
get1_threads(): CleanThreads<M>;
|
|
1352
|
-
subscribe1_threads(callback: () => void): () => void;
|
|
1353
|
-
get1_notifications(): CleanNotifications;
|
|
1354
|
-
subscribe1_notifications(callback: () => void): () => void;
|
|
1355
|
-
get2(): SettingsByRoomId;
|
|
1356
|
-
subscribe2(callback: () => void): () => void;
|
|
1357
|
-
get3(): VersionsByRoomId;
|
|
1358
|
-
subscribe3(callback: () => void): () => void;
|
|
1359
|
-
/**
|
|
1360
|
-
* Returns the async result of the given query and room id. If the query is success,
|
|
1361
|
-
* then it will return the threads that match that provided query and room id.
|
|
1362
|
-
*
|
|
1363
|
-
*/
|
|
1364
|
-
getRoomThreadsLoadingState(roomId: string, query: ThreadsQuery<M> | undefined): ThreadsAsyncResult<M>;
|
|
1365
|
-
getUserThreadsLoadingState(query: ThreadsQuery<M> | undefined): ThreadsAsyncResult<M>;
|
|
1366
|
-
getInboxNotificationsLoadingState(): InboxNotificationsAsyncResult;
|
|
1367
|
-
getNotificationSettingsLoadingState(roomId: string): RoomNotificationSettingsAsyncResult;
|
|
1368
|
-
getRoomVersionsLoadingState(roomId: string): AsyncResult<HistoryVersion[], "versions">;
|
|
1369
1350
|
/**
|
|
1370
1351
|
* Updates an existing inbox notification with a new value, replacing the
|
|
1371
1352
|
* corresponding optimistic update.
|
|
@@ -1417,15 +1398,9 @@ declare class UmbrellaStore<M extends BaseMetadata> {
|
|
|
1417
1398
|
*/
|
|
1418
1399
|
updateRoomNotificationSettings(roomId: string, optimisticId: string, settings: Readonly<RoomNotificationSettings$1>): void;
|
|
1419
1400
|
fetchNotificationsDeltaUpdate(signal: AbortSignal): Promise<void>;
|
|
1420
|
-
waitUntilNotificationsLoaded(): UsablePromise<void>;
|
|
1421
|
-
waitUntilRoomThreadsLoaded(roomId: string, query: ThreadsQuery<M> | undefined): UsablePromise<void>;
|
|
1422
1401
|
fetchRoomThreadsDeltaUpdate(roomId: string, signal: AbortSignal): Promise<void>;
|
|
1423
|
-
waitUntilUserThreadsLoaded(query: ThreadsQuery<M> | undefined): UsablePromise<void>;
|
|
1424
|
-
invalidateEntireStore(): void;
|
|
1425
1402
|
fetchUserThreadsDeltaUpdate(signal: AbortSignal): Promise<void>;
|
|
1426
|
-
waitUntilRoomVersionsLoaded(roomId: string): UsablePromise<void>;
|
|
1427
1403
|
fetchRoomVersionsDeltaUpdate(roomId: string, signal: AbortSignal): Promise<void>;
|
|
1428
|
-
waitUntilRoomNotificationSettingsLoaded(roomId: string): UsablePromise<void>;
|
|
1429
1404
|
refreshRoomNotificationSettings(roomId: string, signal: AbortSignal): Promise<void>;
|
|
1430
1405
|
}
|
|
1431
1406
|
|
|
@@ -1441,15 +1416,15 @@ declare const ClientContext: react.Context<OpaqueClient | null>;
|
|
|
1441
1416
|
*
|
|
1442
1417
|
* @private
|
|
1443
1418
|
*/
|
|
1444
|
-
declare function getUmbrellaStoreForClient<M extends BaseMetadata
|
|
1419
|
+
declare function getUmbrellaStoreForClient<M extends BaseMetadata>(client: OpaqueClient): UmbrellaStore<M>;
|
|
1445
1420
|
/**
|
|
1446
1421
|
* @private This is an internal API.
|
|
1447
1422
|
*/
|
|
1448
|
-
declare function useClientOrNull<U extends BaseUserMeta>(): Client$1<U
|
|
1423
|
+
declare function useClientOrNull<U extends BaseUserMeta>(): Client$1<U> | null;
|
|
1449
1424
|
/**
|
|
1450
1425
|
* Obtains a reference to the current Liveblocks client.
|
|
1451
1426
|
*/
|
|
1452
|
-
declare function useClient<U extends BaseUserMeta>(): Client$1<U
|
|
1427
|
+
declare function useClient<U extends BaseUserMeta>(): Client$1<U>;
|
|
1453
1428
|
/**
|
|
1454
1429
|
* Sets up a client for connecting to Liveblocks, and is the recommended way to do
|
|
1455
1430
|
* this for React apps. You must define either `authEndpoint` or `publicApiKey`.
|
|
@@ -1464,7 +1439,7 @@ declare function LiveblocksProvider<U extends BaseUserMeta = DU>(props: PropsWit
|
|
|
1464
1439
|
* LiveblocksProvider created in this way takes no props, because it uses
|
|
1465
1440
|
* settings from the given client instead.
|
|
1466
1441
|
*/
|
|
1467
|
-
declare function createLiveblocksContext<U extends BaseUserMeta = DU, M extends BaseMetadata
|
|
1442
|
+
declare function createLiveblocksContext<U extends BaseUserMeta = DU, M extends BaseMetadata = DM>(client: OpaqueClient): LiveblocksContextBundle<U, M>;
|
|
1468
1443
|
/**
|
|
1469
1444
|
* Returns the inbox notifications for the current user.
|
|
1470
1445
|
*
|
|
@@ -1480,7 +1455,7 @@ declare function useInboxNotifications(): InboxNotificationsAsyncResult;
|
|
|
1480
1455
|
*/
|
|
1481
1456
|
declare function useInboxNotificationsSuspense(): {
|
|
1482
1457
|
readonly isLoading: false;
|
|
1483
|
-
readonly inboxNotifications: InboxNotificationData[];
|
|
1458
|
+
readonly inboxNotifications: _liveblocks_core.InboxNotificationData[];
|
|
1484
1459
|
readonly error?: undefined;
|
|
1485
1460
|
hasFetchedAll: boolean;
|
|
1486
1461
|
isFetchingMore: boolean;
|
|
@@ -1551,7 +1526,7 @@ declare function useRoomInfo(roomId: string): RoomInfoAsyncResult;
|
|
|
1551
1526
|
* const { info } = useRoomInfo("room-id");
|
|
1552
1527
|
*/
|
|
1553
1528
|
declare function useRoomInfoSuspense(roomId: string): RoomInfoAsyncSuccess;
|
|
1554
|
-
|
|
1529
|
+
type TypedBundle$1 = LiveblocksContextBundle<DU, DM>;
|
|
1555
1530
|
/**
|
|
1556
1531
|
* Returns the thread associated with a `"thread"` inbox notification.
|
|
1557
1532
|
*
|
|
@@ -1626,16 +1601,6 @@ declare const _useUserThreadsSuspense_experimental: TypedBundle$1["suspense"]["u
|
|
|
1626
1601
|
*/
|
|
1627
1602
|
declare function useSyncStatus(options?: UseSyncStatusOptions): SyncStatus;
|
|
1628
1603
|
|
|
1629
|
-
/**
|
|
1630
|
-
* Raw access to the React context where the RoomProvider stores the current
|
|
1631
|
-
* room. Exposed for advanced use cases only.
|
|
1632
|
-
*
|
|
1633
|
-
* @private This is a private/advanced API. Do not rely on it.
|
|
1634
|
-
*/
|
|
1635
|
-
declare const RoomContext: react.Context<OpaqueRoom | null>;
|
|
1636
|
-
/** @private */
|
|
1637
|
-
declare function useRoomOrNull<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json, M extends BaseMetadata$1>(): Room<P, S, U, E, M> | null;
|
|
1638
|
-
|
|
1639
1604
|
/**
|
|
1640
1605
|
* Returns the current connection status for the Room, and triggers
|
|
1641
1606
|
* a re-render whenever it changes. Can be used to render a status badge.
|
|
@@ -1742,13 +1707,13 @@ declare function useOthersConnectionIds(): readonly number[];
|
|
|
1742
1707
|
/**
|
|
1743
1708
|
* @private Internal API, do not rely on it.
|
|
1744
1709
|
*/
|
|
1745
|
-
declare function useCommentsErrorListener<M extends BaseMetadata
|
|
1710
|
+
declare function useCommentsErrorListener<M extends BaseMetadata>(callback: (error: CommentsError<M>) => void): void;
|
|
1746
1711
|
/**
|
|
1747
1712
|
* @private
|
|
1748
1713
|
*/
|
|
1749
|
-
declare function useCreateRoomThread<M extends BaseMetadata
|
|
1714
|
+
declare function useCreateRoomThread<M extends BaseMetadata>(roomId: string): (options: CreateThreadOptions<M>) => ThreadData$1<M>;
|
|
1750
1715
|
declare function useDeleteRoomThread(roomId: string): (threadId: string) => void;
|
|
1751
|
-
declare function useEditRoomThreadMetadata<M extends BaseMetadata
|
|
1716
|
+
declare function useEditRoomThreadMetadata<M extends BaseMetadata>(roomId: string): (options: EditThreadMetadataOptions<M>) => void;
|
|
1752
1717
|
/**
|
|
1753
1718
|
* Returns a function that adds a comment to a thread.
|
|
1754
1719
|
*
|
|
@@ -1789,7 +1754,7 @@ declare function useDeleteRoomComment(roomId: string): ({ threadId, commentId }:
|
|
|
1789
1754
|
/**
|
|
1790
1755
|
* @private
|
|
1791
1756
|
*/
|
|
1792
|
-
declare function useAddRoomCommentReaction<M extends BaseMetadata
|
|
1757
|
+
declare function useAddRoomCommentReaction<M extends BaseMetadata>(roomId: string): ({ threadId, commentId, emoji }: CommentReactionOptions) => void;
|
|
1793
1758
|
/**
|
|
1794
1759
|
* Returns a function that removes a reaction on a comment.
|
|
1795
1760
|
*
|
|
@@ -1915,8 +1880,8 @@ declare function useRoomPermissions(roomId: string): Set<unknown>;
|
|
|
1915
1880
|
* that any RoomProvider created in this way does not need to be nested in
|
|
1916
1881
|
* LiveblocksProvider, as it already has access to the client.
|
|
1917
1882
|
*/
|
|
1918
|
-
declare function createRoomContext<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE, M extends BaseMetadata
|
|
1919
|
-
|
|
1883
|
+
declare function createRoomContext<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE, M extends BaseMetadata = DM>(client: OpaqueClient): RoomContextBundle<P, S, U, E, M>;
|
|
1884
|
+
type TypedBundle = RoomContextBundle<DP, DS, DU, DE, DM>;
|
|
1920
1885
|
/**
|
|
1921
1886
|
* Makes a Room available in the component hierarchy below.
|
|
1922
1887
|
* Joins the room when the component is mounted, and automatically leaves
|