@liveblocks/react 1.11.3 → 1.12.0-lexical2
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/index.d.mts +229 -106
- package/dist/index.d.ts +229 -106
- package/dist/index.js +1979 -1844
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1986 -1851
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ReactElement, ReactNode, PropsWithChildren } from 'react';
|
|
1
|
+
import { ReactElement, ReactNode, Provider, PropsWithChildren } from 'react';
|
|
2
|
+
import { BaseMetadata, CommentBody, PartialNullable, QueryMetadata, Resolve, ToImmutable, kInternal, ThreadData, InboxNotificationData, LiveblocksError, RoomEventMessage, CommentData, RoomInfo, RoomInitializers, ResolveUsersArgs, OptionalPromise, ResolveMentionSuggestionsArgs } from '@liveblocks/core';
|
|
2
3
|
import { JsonObject, LsonObject, BaseUserMeta, LiveObject, User, Json, RoomNotificationSettings, Room, Status, BroadcastOptions, OthersEvent, LostConnectionEvent, History, BaseMetadata as BaseMetadata$1, Client } from '@liveblocks/client';
|
|
3
4
|
export { Json, JsonObject, shallow } from '@liveblocks/client';
|
|
4
|
-
import * as _liveblocks_core from '@liveblocks/core';
|
|
5
|
-
import { BaseMetadata, Resolve, ToImmutable, kInternal, ThreadData, InboxNotificationData, LiveblocksError, RoomEventMessage, CommentData, RoomInfo, CommentBody, PartialNullable, RoomInitializers, ResolveUsersArgs, OptionalPromise, ResolveMentionSuggestionsArgs, BaseUserMeta as BaseUserMeta$1 } from '@liveblocks/core';
|
|
6
5
|
|
|
7
6
|
declare type Props = {
|
|
8
7
|
fallback: NonNullable<ReactNode> | null;
|
|
@@ -27,7 +26,100 @@ declare type Props = {
|
|
|
27
26
|
*/
|
|
28
27
|
declare function ClientSideSuspense(props: Props): ReactElement;
|
|
29
28
|
|
|
30
|
-
declare
|
|
29
|
+
declare class CreateThreadError<M extends BaseMetadata> extends Error {
|
|
30
|
+
cause: Error;
|
|
31
|
+
context: {
|
|
32
|
+
roomId: string;
|
|
33
|
+
threadId: string;
|
|
34
|
+
commentId: string;
|
|
35
|
+
body: CommentBody;
|
|
36
|
+
metadata: M;
|
|
37
|
+
};
|
|
38
|
+
constructor(cause: Error, context: {
|
|
39
|
+
roomId: string;
|
|
40
|
+
threadId: string;
|
|
41
|
+
commentId: string;
|
|
42
|
+
body: CommentBody;
|
|
43
|
+
metadata: M;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
declare class EditThreadMetadataError<M extends BaseMetadata> extends Error {
|
|
47
|
+
cause: Error;
|
|
48
|
+
context: {
|
|
49
|
+
roomId: string;
|
|
50
|
+
threadId: string;
|
|
51
|
+
metadata: PartialNullable<M>;
|
|
52
|
+
};
|
|
53
|
+
constructor(cause: Error, context: {
|
|
54
|
+
roomId: string;
|
|
55
|
+
threadId: string;
|
|
56
|
+
metadata: PartialNullable<M>;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
declare class CreateCommentError extends Error {
|
|
60
|
+
cause: Error;
|
|
61
|
+
context: {
|
|
62
|
+
roomId: string;
|
|
63
|
+
threadId: string;
|
|
64
|
+
commentId: string;
|
|
65
|
+
body: CommentBody;
|
|
66
|
+
};
|
|
67
|
+
constructor(cause: Error, context: {
|
|
68
|
+
roomId: string;
|
|
69
|
+
threadId: string;
|
|
70
|
+
commentId: string;
|
|
71
|
+
body: CommentBody;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
declare class EditCommentError extends Error {
|
|
75
|
+
cause: Error;
|
|
76
|
+
context: {
|
|
77
|
+
roomId: string;
|
|
78
|
+
threadId: string;
|
|
79
|
+
commentId: string;
|
|
80
|
+
body: CommentBody;
|
|
81
|
+
};
|
|
82
|
+
constructor(cause: Error, context: {
|
|
83
|
+
roomId: string;
|
|
84
|
+
threadId: string;
|
|
85
|
+
commentId: string;
|
|
86
|
+
body: CommentBody;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
declare class DeleteCommentError extends Error {
|
|
90
|
+
cause: Error;
|
|
91
|
+
context: {
|
|
92
|
+
roomId: string;
|
|
93
|
+
threadId: string;
|
|
94
|
+
commentId: string;
|
|
95
|
+
};
|
|
96
|
+
constructor(cause: Error, context: {
|
|
97
|
+
roomId: string;
|
|
98
|
+
threadId: string;
|
|
99
|
+
commentId: string;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
declare class MarkInboxNotificationAsReadError extends Error {
|
|
103
|
+
cause: Error;
|
|
104
|
+
context: {
|
|
105
|
+
inboxNotificationId: string;
|
|
106
|
+
};
|
|
107
|
+
constructor(cause: Error, context: {
|
|
108
|
+
inboxNotificationId: string;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
declare class UpdateNotificationSettingsError extends Error {
|
|
112
|
+
cause: Error;
|
|
113
|
+
context: {
|
|
114
|
+
roomId: string;
|
|
115
|
+
};
|
|
116
|
+
constructor(cause: Error, context: {
|
|
117
|
+
roomId: string;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
declare type CommentsError<M extends BaseMetadata> = CreateThreadError<M> | EditThreadMetadataError<M> | CreateCommentError | EditCommentError | DeleteCommentError | MarkInboxNotificationAsReadError | UpdateNotificationSettingsError;
|
|
121
|
+
|
|
122
|
+
declare type UseThreadsOptions<M extends BaseMetadata> = {
|
|
31
123
|
/**
|
|
32
124
|
* The query (including metadata) to filter the threads by. If provided, only threads
|
|
33
125
|
* that match the query will be returned. If not provided, all threads will be returned.
|
|
@@ -37,7 +129,7 @@ declare type UseThreadsOptions<TThreadMetadata extends BaseMetadata> = {
|
|
|
37
129
|
* The metadata to filter the threads by. If provided, only threads with metadata that matches
|
|
38
130
|
* the provided metadata will be returned. If not provided, all threads will be returned.
|
|
39
131
|
*/
|
|
40
|
-
metadata?: Partial<
|
|
132
|
+
metadata?: Partial<QueryMetadata<M>>;
|
|
41
133
|
};
|
|
42
134
|
/**
|
|
43
135
|
* Whether to scroll to a comment on load based on the URL hash. Defaults to `true`.
|
|
@@ -81,21 +173,19 @@ declare type RoomInfoStateSuccess = {
|
|
|
81
173
|
error?: never;
|
|
82
174
|
};
|
|
83
175
|
declare type RoomInfoState = RoomInfoStateLoading | RoomInfoStateError | RoomInfoStateSuccess;
|
|
84
|
-
declare type CreateThreadOptions<
|
|
85
|
-
TMetadata
|
|
86
|
-
] extends [never] ? {
|
|
176
|
+
declare type CreateThreadOptions<M extends BaseMetadata> = [M] extends [never] ? {
|
|
87
177
|
body: CommentBody;
|
|
88
178
|
} : {
|
|
89
179
|
body: CommentBody;
|
|
90
|
-
metadata:
|
|
180
|
+
metadata: M;
|
|
91
181
|
};
|
|
92
|
-
declare type EditThreadMetadataOptions<
|
|
93
|
-
|
|
94
|
-
]
|
|
182
|
+
declare type EditThreadMetadataOptions<M extends BaseMetadata> = [M] extends [
|
|
183
|
+
never
|
|
184
|
+
] ? {
|
|
95
185
|
threadId: string;
|
|
96
186
|
} : {
|
|
97
187
|
threadId: string;
|
|
98
|
-
metadata: Resolve<PartialNullable<
|
|
188
|
+
metadata: Resolve<PartialNullable<M>>;
|
|
99
189
|
};
|
|
100
190
|
declare type CreateCommentOptions = {
|
|
101
191
|
threadId: string;
|
|
@@ -120,17 +210,17 @@ declare type ThreadsStateLoading = {
|
|
|
120
210
|
threads?: never;
|
|
121
211
|
error?: never;
|
|
122
212
|
};
|
|
123
|
-
declare type ThreadsStateResolved<
|
|
213
|
+
declare type ThreadsStateResolved<M extends BaseMetadata> = {
|
|
124
214
|
isLoading: false;
|
|
125
|
-
threads: ThreadData<
|
|
215
|
+
threads: ThreadData<M>[];
|
|
126
216
|
error?: Error;
|
|
127
217
|
};
|
|
128
|
-
declare type ThreadsStateSuccess<
|
|
218
|
+
declare type ThreadsStateSuccess<M extends BaseMetadata> = {
|
|
129
219
|
isLoading: false;
|
|
130
|
-
threads: ThreadData<
|
|
220
|
+
threads: ThreadData<M>[];
|
|
131
221
|
error?: never;
|
|
132
222
|
};
|
|
133
|
-
declare type ThreadsState<
|
|
223
|
+
declare type ThreadsState<M extends BaseMetadata> = ThreadsStateLoading | ThreadsStateResolved<M>;
|
|
134
224
|
declare type InboxNotificationsStateLoading = {
|
|
135
225
|
isLoading: true;
|
|
136
226
|
inboxNotifications?: never;
|
|
@@ -184,7 +274,7 @@ declare type RoomNotificationSettingsStateSuccess = {
|
|
|
184
274
|
error?: never;
|
|
185
275
|
};
|
|
186
276
|
declare type RoomNotificationSettingsState = RoomNotificationSettingsStateLoading | RoomNotificationSettingsStateError | RoomNotificationSettingsStateSuccess;
|
|
187
|
-
declare type RoomProviderProps<
|
|
277
|
+
declare type RoomProviderProps<P extends JsonObject, S extends LsonObject> = Resolve<{
|
|
188
278
|
/**
|
|
189
279
|
* The id of the room you want to connect to
|
|
190
280
|
*/
|
|
@@ -216,17 +306,17 @@ declare type RoomProviderProps<TPresence extends JsonObject, TStorage extends Ls
|
|
|
216
306
|
* Not necessary when you're on React v18 or later.
|
|
217
307
|
*/
|
|
218
308
|
unstable_batchedUpdates?: (cb: () => void) => void;
|
|
219
|
-
} & RoomInitializers<
|
|
309
|
+
} & RoomInitializers<P, S>>;
|
|
220
310
|
/**
|
|
221
311
|
* For any function type, returns a similar function type, but without the
|
|
222
312
|
* first argument.
|
|
223
313
|
*/
|
|
224
314
|
declare type OmitFirstArg<F> = F extends (first: any, ...rest: infer A) => infer R ? (...args: A) => R : never;
|
|
225
|
-
declare type MutationContext<
|
|
226
|
-
storage: LiveObject<
|
|
227
|
-
self: User<
|
|
228
|
-
others: readonly User<
|
|
229
|
-
setMyPresence: (patch: Partial<
|
|
315
|
+
declare type MutationContext<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta> = {
|
|
316
|
+
storage: LiveObject<S>;
|
|
317
|
+
self: User<P, U>;
|
|
318
|
+
others: readonly User<P, U>[];
|
|
319
|
+
setMyPresence: (patch: Partial<P>, options?: {
|
|
230
320
|
addToHistory: boolean;
|
|
231
321
|
}) => void;
|
|
232
322
|
};
|
|
@@ -240,25 +330,27 @@ declare type ThreadSubscription = {
|
|
|
240
330
|
status: "subscribed";
|
|
241
331
|
unreadSince: Date;
|
|
242
332
|
};
|
|
243
|
-
declare type SharedContextBundle<
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
333
|
+
declare type SharedContextBundle<U extends BaseUserMeta> = {
|
|
334
|
+
classic: {
|
|
335
|
+
/**
|
|
336
|
+
* @beta
|
|
337
|
+
*
|
|
338
|
+
* Returns user info from a given user ID.
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* const { user, error, isLoading } = useUser("user-id");
|
|
342
|
+
*/
|
|
343
|
+
useUser(userId: string): UserState<U["info"]>;
|
|
344
|
+
/**
|
|
345
|
+
* @private
|
|
346
|
+
*
|
|
347
|
+
* Returns room info from a given room ID.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* const { info, error, isLoading } = useRoomInfo("room-id");
|
|
351
|
+
*/
|
|
352
|
+
useRoomInfo(roomId: string): RoomInfoState;
|
|
353
|
+
};
|
|
262
354
|
suspense: {
|
|
263
355
|
/**
|
|
264
356
|
* @beta
|
|
@@ -268,7 +360,7 @@ declare type SharedContextBundle<TUserMeta extends BaseUserMeta> = {
|
|
|
268
360
|
* @example
|
|
269
361
|
* const { user } = useUser("user-id");
|
|
270
362
|
*/
|
|
271
|
-
useUser(userId: string): UserStateSuccess<
|
|
363
|
+
useUser(userId: string): UserStateSuccess<U["info"]>;
|
|
272
364
|
/**
|
|
273
365
|
* @private
|
|
274
366
|
*
|
|
@@ -283,24 +375,24 @@ declare type SharedContextBundle<TUserMeta extends BaseUserMeta> = {
|
|
|
283
375
|
/**
|
|
284
376
|
* Properties that are the same in RoomContext and RoomContext["suspense"].
|
|
285
377
|
*/
|
|
286
|
-
declare type RoomContextBundleCommon<
|
|
378
|
+
declare type RoomContextBundleCommon<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json, M extends BaseMetadata> = {
|
|
287
379
|
/**
|
|
288
380
|
* You normally don't need to directly interact with the RoomContext, but
|
|
289
381
|
* it can be necessary if you're building an advanced app where you need to
|
|
290
382
|
* set up a context bridge between two React renderers.
|
|
291
383
|
*/
|
|
292
|
-
RoomContext: React.Context<Room<
|
|
384
|
+
RoomContext: React.Context<Room<P, S, U, E> | null>;
|
|
293
385
|
/**
|
|
294
386
|
* Makes a Room available in the component hierarchy below.
|
|
295
387
|
* Joins the room when the component is mounted, and automatically leaves
|
|
296
388
|
* the room when the component is unmounted.
|
|
297
389
|
*/
|
|
298
|
-
RoomProvider(props: RoomProviderProps<
|
|
390
|
+
RoomProvider(props: RoomProviderProps<P, S>): JSX.Element;
|
|
299
391
|
/**
|
|
300
392
|
* Returns the Room of the nearest RoomProvider above in the React component
|
|
301
393
|
* tree.
|
|
302
394
|
*/
|
|
303
|
-
useRoom(): Room<
|
|
395
|
+
useRoom(): Room<P, S, U, E>;
|
|
304
396
|
/**
|
|
305
397
|
* Returns the current connection status for the Room, and triggers
|
|
306
398
|
* a re-render whenever it changes. Can be used to render a status badge.
|
|
@@ -321,7 +413,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
321
413
|
*
|
|
322
414
|
* broadcast({ type: "CUSTOM_EVENT", data: { x: 0, y: 0 } });
|
|
323
415
|
*/
|
|
324
|
-
useBroadcastEvent(): (event:
|
|
416
|
+
useBroadcastEvent(): (event: E, options?: BroadcastOptions) => void;
|
|
325
417
|
/**
|
|
326
418
|
* Get informed when users enter or leave the room, as an event.
|
|
327
419
|
*
|
|
@@ -334,7 +426,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
334
426
|
* }
|
|
335
427
|
* })
|
|
336
428
|
*/
|
|
337
|
-
useOthersListener(callback: (event: OthersEvent<
|
|
429
|
+
useOthersListener(callback: (event: OthersEvent<P, U>) => void): void;
|
|
338
430
|
/**
|
|
339
431
|
* Get informed when reconnecting to the Liveblocks servers is taking
|
|
340
432
|
* longer than usual. This typically is a sign of a client that has lost
|
|
@@ -377,7 +469,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
377
469
|
* }
|
|
378
470
|
* });
|
|
379
471
|
*/
|
|
380
|
-
useEventListener(callback: (data: RoomEventMessage<
|
|
472
|
+
useEventListener(callback: (data: RoomEventMessage<P, U, E>) => void): void;
|
|
381
473
|
/**
|
|
382
474
|
* Returns the room.history
|
|
383
475
|
*/
|
|
@@ -407,7 +499,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
407
499
|
* @example
|
|
408
500
|
* const [root] = useStorageRoot();
|
|
409
501
|
*/
|
|
410
|
-
useStorageRoot(): [root: LiveObject<
|
|
502
|
+
useStorageRoot(): [root: LiveObject<S> | null];
|
|
411
503
|
/**
|
|
412
504
|
* Returns the presence of the current user of the current room, and a function to update it.
|
|
413
505
|
* It is different from the setState function returned by the useState hook from React.
|
|
@@ -421,8 +513,8 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
421
513
|
* // At the next render, "myPresence" will be equal to "{ x: 0, y: 0 }"
|
|
422
514
|
*/
|
|
423
515
|
useMyPresence(): [
|
|
424
|
-
|
|
425
|
-
(patch: Partial<
|
|
516
|
+
P,
|
|
517
|
+
(patch: Partial<P>, options?: {
|
|
426
518
|
addToHistory: boolean;
|
|
427
519
|
}) => void
|
|
428
520
|
];
|
|
@@ -437,7 +529,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
437
529
|
*
|
|
438
530
|
* // At the next render, the presence of the current user will be equal to "{ x: 0, y: 0 }"
|
|
439
531
|
*/
|
|
440
|
-
useUpdateMyPresence(): (patch: Partial<
|
|
532
|
+
useUpdateMyPresence(): (patch: Partial<P>, options?: {
|
|
441
533
|
addToHistory: boolean;
|
|
442
534
|
}) => void;
|
|
443
535
|
/**
|
|
@@ -484,7 +576,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
484
576
|
*
|
|
485
577
|
* deleteLayers();
|
|
486
578
|
*/
|
|
487
|
-
useMutation<F extends (context: MutationContext<
|
|
579
|
+
useMutation<F extends (context: MutationContext<P, S, U>, ...args: any[]) => any>(callback: F, deps: readonly unknown[]): OmitFirstArg<F>;
|
|
488
580
|
/**
|
|
489
581
|
* Returns an object that lets you get information about all the users
|
|
490
582
|
* currently connected in the room.
|
|
@@ -504,7 +596,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
504
596
|
* </>
|
|
505
597
|
* )
|
|
506
598
|
*/
|
|
507
|
-
useOthers(): readonly User<
|
|
599
|
+
useOthers(): readonly User<P, U>[];
|
|
508
600
|
/**
|
|
509
601
|
* Extract arbitrary data based on all the users currently connected in the
|
|
510
602
|
* room (except yourself).
|
|
@@ -526,7 +618,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
526
618
|
* const someoneIsTyping = useOthers(users => users.some(u => u.presence.isTyping));
|
|
527
619
|
*
|
|
528
620
|
*/
|
|
529
|
-
useOthers<T>(selector: (others: readonly User<
|
|
621
|
+
useOthers<T>(selector: (others: readonly User<P, U>[]) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
530
622
|
/**
|
|
531
623
|
* Returns an array of connection IDs. This matches the values you'll get by
|
|
532
624
|
* using the `useOthers()` hook.
|
|
@@ -566,7 +658,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
566
658
|
* shallow, // 👈
|
|
567
659
|
* );
|
|
568
660
|
*/
|
|
569
|
-
useOthersMapped<T>(itemSelector: (other: User<
|
|
661
|
+
useOthersMapped<T>(itemSelector: (other: User<P, U>) => T, itemIsEqual?: (prev: T, curr: T) => boolean): ReadonlyArray<readonly [connectionId: number, data: T]>;
|
|
570
662
|
/**
|
|
571
663
|
* Given a connection ID (as obtained by using `useOthersConnectionIds`), you
|
|
572
664
|
* can call this selector deep down in your component stack to only have the
|
|
@@ -576,7 +668,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
576
668
|
* // Returns only the selected values re-renders whenever that selection changes)
|
|
577
669
|
* const { x, y } = useOther(2, user => user.presence.cursor);
|
|
578
670
|
*/
|
|
579
|
-
useOther<T>(connectionId: number, selector: (other: User<
|
|
671
|
+
useOther<T>(connectionId: number, selector: (other: User<P, U>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
580
672
|
/**
|
|
581
673
|
* @beta
|
|
582
674
|
*
|
|
@@ -586,7 +678,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
586
678
|
* const createThread = useCreateThread();
|
|
587
679
|
* createThread({ body: {}, metadata: {} });
|
|
588
680
|
*/
|
|
589
|
-
useCreateThread(): (options: CreateThreadOptions<
|
|
681
|
+
useCreateThread(): (options: CreateThreadOptions<M>) => ThreadData<M>;
|
|
590
682
|
/**
|
|
591
683
|
* @beta
|
|
592
684
|
*
|
|
@@ -597,7 +689,7 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
597
689
|
* const editThreadMetadata = useEditThreadMetadata();
|
|
598
690
|
* editThreadMetadata({ threadId: "th_xxx", metadata: {} })
|
|
599
691
|
*/
|
|
600
|
-
useEditThreadMetadata(): (options: EditThreadMetadataOptions<
|
|
692
|
+
useEditThreadMetadata(): (options: EditThreadMetadataOptions<M>) => void;
|
|
601
693
|
/**
|
|
602
694
|
* @beta
|
|
603
695
|
*
|
|
@@ -680,6 +772,10 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
680
772
|
*/
|
|
681
773
|
useThreadSubscription(threadId: string): ThreadSubscription;
|
|
682
774
|
};
|
|
775
|
+
declare type ThreadCreateCallback = (threadId: string) => void;
|
|
776
|
+
declare type ThreadDeleteCallback = (threadId: string) => void;
|
|
777
|
+
declare type ComposerFocusCallback = (commentId: string | undefined, threadId: string | undefined) => void;
|
|
778
|
+
declare type IsThreadActiveCallback = (threadId: string) => boolean;
|
|
683
779
|
/**
|
|
684
780
|
* @private
|
|
685
781
|
*
|
|
@@ -688,11 +784,19 @@ declare type RoomContextBundleCommon<TPresence extends JsonObject, TStorage exte
|
|
|
688
784
|
* will probably happen if you do.
|
|
689
785
|
*/
|
|
690
786
|
declare type PrivateRoomContextApi = {
|
|
691
|
-
hasResolveMentionSuggestions: boolean;
|
|
692
787
|
useMentionSuggestions(search?: string): string[] | undefined;
|
|
693
788
|
useCurrentUserId(): string | null;
|
|
789
|
+
useCommentsErrorListener<M extends BaseMetadata>(callback: (err: CommentsError<M>) => void): void;
|
|
790
|
+
ThreadCreateCallbackProvider: Provider<ThreadCreateCallback | null>;
|
|
791
|
+
useThreadCreateCallback(): ThreadCreateCallback | null;
|
|
792
|
+
ThreadDeleteCallbackProvider: Provider<ThreadDeleteCallback | null>;
|
|
793
|
+
useThreadDeleteCallback(): ThreadDeleteCallback | null;
|
|
794
|
+
ComposerFocusCallbackProvider: Provider<ComposerFocusCallback | null>;
|
|
795
|
+
useComposerFocusCallback(): ComposerFocusCallback | null;
|
|
796
|
+
IsThreadActiveCallbackProvider: Provider<IsThreadActiveCallback | null>;
|
|
797
|
+
useIsThreadActiveCallback(): IsThreadActiveCallback | null;
|
|
694
798
|
};
|
|
695
|
-
declare type RoomContextBundle<
|
|
799
|
+
declare type RoomContextBundle<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json, M extends BaseMetadata> = Resolve<RoomContextBundleCommon<P, S, U, E, M> & SharedContextBundle<U>["classic"] & {
|
|
696
800
|
/**
|
|
697
801
|
* Extract arbitrary data from the Liveblocks Storage state, using an
|
|
698
802
|
* arbitrary selector function.
|
|
@@ -712,7 +816,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
712
816
|
* return the result of a .map() or .filter() call from the selector. In
|
|
713
817
|
* those cases, you'll probably want to use a `shallow` comparison check.
|
|
714
818
|
*/
|
|
715
|
-
useStorage<T>(selector: (root: ToImmutable<
|
|
819
|
+
useStorage<T>(selector: (root: ToImmutable<S>) => T, isEqual?: (prev: T | null, curr: T | null) => boolean): T | null;
|
|
716
820
|
/**
|
|
717
821
|
* Gets the current user once it is connected to the room.
|
|
718
822
|
*
|
|
@@ -720,7 +824,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
720
824
|
* const me = useSelf();
|
|
721
825
|
* const { x, y } = me.presence.cursor;
|
|
722
826
|
*/
|
|
723
|
-
useSelf(): User<
|
|
827
|
+
useSelf(): User<P, U> | null;
|
|
724
828
|
/**
|
|
725
829
|
* Extract arbitrary data based on the current user.
|
|
726
830
|
*
|
|
@@ -744,7 +848,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
744
848
|
* }
|
|
745
849
|
*
|
|
746
850
|
*/
|
|
747
|
-
useSelf<T>(selector: (me: User<
|
|
851
|
+
useSelf<T>(selector: (me: User<P, U>) => T, isEqual?: (prev: T, curr: T) => boolean): T | null;
|
|
748
852
|
/**
|
|
749
853
|
* @beta
|
|
750
854
|
*
|
|
@@ -753,7 +857,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
753
857
|
* @example
|
|
754
858
|
* const { threads, error, isLoading } = useThreads();
|
|
755
859
|
*/
|
|
756
|
-
useThreads(options?: UseThreadsOptions<
|
|
860
|
+
useThreads(options?: UseThreadsOptions<M>): ThreadsState<M>;
|
|
757
861
|
/**
|
|
758
862
|
* @beta
|
|
759
863
|
*
|
|
@@ -782,7 +886,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
782
886
|
* @deprecated We no longer recommend using `useList`. Prefer `useStorage`
|
|
783
887
|
* for reading and `useMutation` for writing.
|
|
784
888
|
*/
|
|
785
|
-
useList<TKey extends Extract<keyof
|
|
889
|
+
useList<TKey extends Extract<keyof S, string>>(key: TKey): S[TKey] | null;
|
|
786
890
|
/**
|
|
787
891
|
* Returns the LiveMap associated with the provided key. If the LiveMap
|
|
788
892
|
* does not exist, a new empty LiveMap will be created. The hook triggers
|
|
@@ -799,7 +903,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
799
903
|
* @deprecated We no longer recommend using `useMap`. Prefer `useStorage`
|
|
800
904
|
* for reading and `useMutation` for writing.
|
|
801
905
|
*/
|
|
802
|
-
useMap<TKey extends Extract<keyof
|
|
906
|
+
useMap<TKey extends Extract<keyof S, string>>(key: TKey): S[TKey] | null;
|
|
803
907
|
/**
|
|
804
908
|
* Returns the LiveObject associated with the provided key.
|
|
805
909
|
* The hook triggers a re-render if the LiveObject is updated, however it does not triggers a re-render if a nested CRDT is updated.
|
|
@@ -814,8 +918,8 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
814
918
|
* @deprecated We no longer recommend using `useObject`. Prefer `useStorage`
|
|
815
919
|
* for reading and `useMutation` for writing.
|
|
816
920
|
*/
|
|
817
|
-
useObject<TKey extends Extract<keyof
|
|
818
|
-
suspense: Resolve<RoomContextBundleCommon<
|
|
921
|
+
useObject<TKey extends Extract<keyof S, string>>(key: TKey): S[TKey] | null;
|
|
922
|
+
suspense: Resolve<RoomContextBundleCommon<P, S, U, E, M> & SharedContextBundle<U>["suspense"] & {
|
|
819
923
|
/**
|
|
820
924
|
* Extract arbitrary data from the Liveblocks Storage state, using an
|
|
821
925
|
* arbitrary selector function.
|
|
@@ -835,7 +939,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
835
939
|
* return the result of a .map() or .filter() call from the selector. In
|
|
836
940
|
* those cases, you'll probably want to use a `shallow` comparison check.
|
|
837
941
|
*/
|
|
838
|
-
useStorage<T>(selector: (root: ToImmutable<
|
|
942
|
+
useStorage<T>(selector: (root: ToImmutable<S>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
839
943
|
/**
|
|
840
944
|
* Gets the current user once it is connected to the room.
|
|
841
945
|
*
|
|
@@ -843,7 +947,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
843
947
|
* const me = useSelf();
|
|
844
948
|
* const { x, y } = me.presence.cursor;
|
|
845
949
|
*/
|
|
846
|
-
useSelf(): User<
|
|
950
|
+
useSelf(): User<P, U>;
|
|
847
951
|
/**
|
|
848
952
|
* Extract arbitrary data based on the current user.
|
|
849
953
|
*
|
|
@@ -867,7 +971,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
867
971
|
* }
|
|
868
972
|
*
|
|
869
973
|
*/
|
|
870
|
-
useSelf<T>(selector: (me: User<
|
|
974
|
+
useSelf<T>(selector: (me: User<P, U>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
871
975
|
/**
|
|
872
976
|
* @beta
|
|
873
977
|
*
|
|
@@ -876,7 +980,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
876
980
|
* @example
|
|
877
981
|
* const { threads } = useThreads();
|
|
878
982
|
*/
|
|
879
|
-
useThreads(options?: UseThreadsOptions<
|
|
983
|
+
useThreads(options?: UseThreadsOptions<M>): ThreadsStateSuccess<M>;
|
|
880
984
|
/**
|
|
881
985
|
* @beta
|
|
882
986
|
*
|
|
@@ -905,7 +1009,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
905
1009
|
* @deprecated We no longer recommend using `useList`. Prefer `useStorage`
|
|
906
1010
|
* for reading and `useMutation` for writing.
|
|
907
1011
|
*/
|
|
908
|
-
useList<TKey extends Extract<keyof
|
|
1012
|
+
useList<TKey extends Extract<keyof S, string>>(key: TKey): S[TKey];
|
|
909
1013
|
/**
|
|
910
1014
|
* Returns the LiveMap associated with the provided key. If the LiveMap
|
|
911
1015
|
* does not exist, a new empty LiveMap will be created. The hook triggers
|
|
@@ -922,7 +1026,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
922
1026
|
* @deprecated We no longer recommend using `useMap`. Prefer `useStorage`
|
|
923
1027
|
* for reading and `useMutation` for writing.
|
|
924
1028
|
*/
|
|
925
|
-
useMap<TKey extends Extract<keyof
|
|
1029
|
+
useMap<TKey extends Extract<keyof S, string>>(key: TKey): S[TKey];
|
|
926
1030
|
/**
|
|
927
1031
|
* Returns the LiveObject associated with the provided key.
|
|
928
1032
|
* The hook triggers a re-render if the LiveObject is updated, however it does not triggers a re-render if a nested CRDT is updated.
|
|
@@ -937,7 +1041,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
937
1041
|
* @deprecated We no longer recommend using `useObject`. Prefer `useStorage`
|
|
938
1042
|
* for reading and `useMutation` for writing.
|
|
939
1043
|
*/
|
|
940
|
-
useObject<TKey extends Extract<keyof
|
|
1044
|
+
useObject<TKey extends Extract<keyof S, string>>(key: TKey): S[TKey];
|
|
941
1045
|
}>;
|
|
942
1046
|
}> & {
|
|
943
1047
|
/**
|
|
@@ -952,7 +1056,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
952
1056
|
/**
|
|
953
1057
|
* Properties that are the same in LiveblocksContext and LiveblocksContext["suspense"].
|
|
954
1058
|
*/
|
|
955
|
-
declare type LiveblocksContextBundleCommon = {
|
|
1059
|
+
declare type LiveblocksContextBundleCommon<M extends BaseMetadata> = {
|
|
956
1060
|
/**
|
|
957
1061
|
* @beta
|
|
958
1062
|
*
|
|
@@ -980,6 +1084,15 @@ declare type LiveblocksContextBundleCommon = {
|
|
|
980
1084
|
* markAllInboxNotificationsAsRead();
|
|
981
1085
|
*/
|
|
982
1086
|
useMarkAllInboxNotificationsAsRead(): () => void;
|
|
1087
|
+
/**
|
|
1088
|
+
* @beta
|
|
1089
|
+
*
|
|
1090
|
+
* Returns the thread associated with a `"thread"` inbox notification.
|
|
1091
|
+
*
|
|
1092
|
+
* @example
|
|
1093
|
+
* const thread = useInboxNotificationThread("in_xxx");
|
|
1094
|
+
*/
|
|
1095
|
+
useInboxNotificationThread(inboxNotificationId: string): ThreadData<M>;
|
|
983
1096
|
};
|
|
984
1097
|
/**
|
|
985
1098
|
* @private
|
|
@@ -989,15 +1102,6 @@ declare type LiveblocksContextBundleCommon = {
|
|
|
989
1102
|
* will probably happen if you do.
|
|
990
1103
|
*/
|
|
991
1104
|
declare type PrivateLiveblocksContextApi = {
|
|
992
|
-
/**
|
|
993
|
-
* @private
|
|
994
|
-
*
|
|
995
|
-
* Returns a thread from the cache.
|
|
996
|
-
*
|
|
997
|
-
* @example
|
|
998
|
-
* const thread = useThreadFromCache("th_xxx");
|
|
999
|
-
*/
|
|
1000
|
-
useThreadFromCache(threadId: string): ThreadData<BaseMetadata>;
|
|
1001
1105
|
/**
|
|
1002
1106
|
* @private
|
|
1003
1107
|
*
|
|
@@ -1005,7 +1109,7 @@ declare type PrivateLiveblocksContextApi = {
|
|
|
1005
1109
|
*/
|
|
1006
1110
|
useCurrentUserId(): string | null;
|
|
1007
1111
|
};
|
|
1008
|
-
declare type LiveblocksContextBundle<
|
|
1112
|
+
declare type LiveblocksContextBundle<U extends BaseUserMeta, M extends BaseMetadata> = Resolve<LiveblocksContextBundleCommon<M> & SharedContextBundle<U>["classic"] & {
|
|
1009
1113
|
/**
|
|
1010
1114
|
* @beta
|
|
1011
1115
|
*
|
|
@@ -1024,7 +1128,7 @@ declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta> = Resolve<L
|
|
|
1024
1128
|
* const { count, error, isLoading } = useUnreadInboxNotificationsCount();
|
|
1025
1129
|
*/
|
|
1026
1130
|
useUnreadInboxNotificationsCount(): UnreadInboxNotificationsCountState;
|
|
1027
|
-
suspense: Resolve<LiveblocksContextBundleCommon & SharedContextBundle<
|
|
1131
|
+
suspense: Resolve<LiveblocksContextBundleCommon<M> & SharedContextBundle<U>["suspense"] & {
|
|
1028
1132
|
/**
|
|
1029
1133
|
* @beta
|
|
1030
1134
|
*
|
|
@@ -1055,28 +1159,53 @@ declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta> = Resolve<L
|
|
|
1055
1159
|
readonly [kInternal]: PrivateLiveblocksContextApi;
|
|
1056
1160
|
};
|
|
1057
1161
|
|
|
1162
|
+
/** DP = Default Presence type */
|
|
1163
|
+
declare type DP = JsonObject;
|
|
1164
|
+
/** DS = Default Storage type */
|
|
1165
|
+
declare type DS = LsonObject;
|
|
1166
|
+
/** DU = Default UserMeta type */
|
|
1167
|
+
declare type DU = BaseUserMeta;
|
|
1168
|
+
/**
|
|
1169
|
+
* @private
|
|
1170
|
+
*
|
|
1171
|
+
* This is an internal API, use `createLiveblocksContext` or `createRoomContext` instead.
|
|
1172
|
+
*/
|
|
1173
|
+
declare function useSharedContextBundle(): RoomContextBundle<JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata$1> | LiveblocksContextBundle<BaseUserMeta, BaseMetadata$1>;
|
|
1174
|
+
|
|
1175
|
+
declare type OpaqueClient$1 = Client<BaseUserMeta>;
|
|
1176
|
+
/**
|
|
1177
|
+
* @beta This is an internal API for now, but it will become public eventually.
|
|
1178
|
+
*/
|
|
1179
|
+
declare function useClient(): OpaqueClient$1;
|
|
1180
|
+
/**
|
|
1181
|
+
* @private
|
|
1182
|
+
*
|
|
1183
|
+
* This is an internal API, use "createLiveblocksContext" instead.
|
|
1184
|
+
*/
|
|
1185
|
+
declare function useLiveblocksContextBundleOrNull(): LiveblocksContextBundle<BaseUserMeta, BaseMetadata$1> | null;
|
|
1058
1186
|
/**
|
|
1059
1187
|
* @private
|
|
1060
1188
|
*
|
|
1061
1189
|
* This is an internal API, use "createLiveblocksContext" instead.
|
|
1062
1190
|
*/
|
|
1063
|
-
declare function useLiveblocksContextBundle(): LiveblocksContextBundle<BaseUserMeta>;
|
|
1064
|
-
declare function createLiveblocksContext<
|
|
1191
|
+
declare function useLiveblocksContextBundle(): LiveblocksContextBundle<BaseUserMeta, BaseMetadata$1>;
|
|
1192
|
+
declare function createLiveblocksContext<U extends BaseUserMeta = DU, M extends BaseMetadata$1 = never>(client: OpaqueClient$1): LiveblocksContextBundle<U, M>;
|
|
1065
1193
|
|
|
1194
|
+
declare type OpaqueClient = Client<BaseUserMeta>;
|
|
1066
1195
|
/**
|
|
1067
1196
|
* @private
|
|
1068
1197
|
*
|
|
1069
1198
|
* This is an internal API, use `createRoomContext` instead.
|
|
1070
1199
|
*/
|
|
1071
|
-
declare function useRoomContextBundle(): RoomContextBundle<JsonObject, LsonObject, BaseUserMeta,
|
|
1072
|
-
declare type Options<
|
|
1200
|
+
declare function useRoomContextBundle(): RoomContextBundle<JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata$1>;
|
|
1201
|
+
declare type Options<U extends BaseUserMeta> = {
|
|
1073
1202
|
/**
|
|
1074
1203
|
* @deprecated Define 'resolveUsers' in 'createClient' from '@liveblocks/client' instead.
|
|
1075
1204
|
* Please refer to our Upgrade Guide to learn more, see https://liveblocks.io/docs/platform/upgrading/1.10.
|
|
1076
1205
|
*
|
|
1077
1206
|
* A function that returns user info from user IDs.
|
|
1078
1207
|
*/
|
|
1079
|
-
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(
|
|
1208
|
+
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
|
|
1080
1209
|
/**
|
|
1081
1210
|
* @deprecated Define 'resolveMentionSuggestions' in 'createClient' from '@liveblocks/client' instead.
|
|
1082
1211
|
* Please refer to our Upgrade Guide to learn more, see https://liveblocks.io/docs/platform/upgrading/1.10.
|
|
@@ -1085,13 +1214,7 @@ declare type Options<TUserMeta extends BaseUserMeta> = {
|
|
|
1085
1214
|
*/
|
|
1086
1215
|
resolveMentionSuggestions?: (args: ResolveMentionSuggestionsArgs) => OptionalPromise<string[]>;
|
|
1087
1216
|
};
|
|
1088
|
-
declare function createRoomContext<
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
* @private
|
|
1092
|
-
*
|
|
1093
|
-
* This is an internal API, use `createLiveblocksContext` or `createRoomContext` instead.
|
|
1094
|
-
*/
|
|
1095
|
-
declare function useSharedContextBundle(): RoomContextBundle<_liveblocks_core.JsonObject, _liveblocks_core.LsonObject, BaseUserMeta$1, never, _liveblocks_core.BaseMetadata> | LiveblocksContextBundle<BaseUserMeta$1>;
|
|
1217
|
+
declare function createRoomContext<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = never, // TODO Change this to DE for 2.0
|
|
1218
|
+
M extends BaseMetadata$1 = never>(client: OpaqueClient, options?: Options<U>): RoomContextBundle<P, S, U, E, M>;
|
|
1096
1219
|
|
|
1097
|
-
export { ClientSideSuspense, type MutationContext, type UseThreadsOptions, createLiveblocksContext, createRoomContext, useLiveblocksContextBundle, useRoomContextBundle, useSharedContextBundle };
|
|
1220
|
+
export { ClientSideSuspense, CreateThreadError, DeleteCommentError, type MutationContext, type UseThreadsOptions, createLiveblocksContext, createRoomContext, useClient, useLiveblocksContextBundle, useLiveblocksContextBundleOrNull, useRoomContextBundle, useSharedContextBundle };
|