@liveblocks/react 2.12.1-test1 → 2.12.1-test2
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 +2 -2
- package/dist/_private.d.ts +2 -2
- package/dist/_private.js +34 -8
- package/dist/_private.js.map +1 -1
- package/dist/_private.mjs +33 -7
- package/dist/_private.mjs.map +1 -1
- package/dist/{chunk-IACZPXTY.js → chunk-HVOJBD7X.js} +156 -79
- package/dist/chunk-HVOJBD7X.js.map +1 -0
- package/dist/{chunk-JORFBIBS.mjs → chunk-IGSZZWUJ.mjs} +2 -2
- package/dist/{chunk-QIL7LU4H.js → chunk-MFSDNSIH.js} +2 -2
- package/dist/{chunk-CX62YECU.mjs → chunk-SEMVNYPJ.mjs} +155 -78
- package/dist/chunk-SEMVNYPJ.mjs.map +1 -0
- package/dist/index.d.mts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.js +4 -4
- package/dist/index.mjs +2 -2
- package/dist/{liveblocks-1ujmr05d.d.mts → room-t_BUxm1-.d.mts} +761 -9
- package/dist/{liveblocks-1ujmr05d.d.ts → room-t_BUxm1-.d.ts} +761 -9
- package/dist/suspense.d.mts +2 -2
- package/dist/suspense.d.ts +2 -2
- package/dist/suspense.js +4 -4
- package/dist/suspense.mjs +2 -2
- package/package.json +3 -3
- package/dist/chunk-CX62YECU.mjs.map +0 -1
- package/dist/chunk-IACZPXTY.js.map +0 -1
- package/dist/suspense-560_K0iP.d.ts +0 -730
- package/dist/suspense-TeBnnKGw.d.mts +0 -730
- /package/dist/{chunk-JORFBIBS.mjs.map → chunk-IGSZZWUJ.mjs.map} +0 -0
- /package/dist/{chunk-QIL7LU4H.js.map → chunk-MFSDNSIH.js.map} +0 -0
|
@@ -1,730 +0,0 @@
|
|
|
1
|
-
import { U as UseStorageStatusOptions, a as CommentsError, b as CreateCommentOptions, E as EditCommentOptions, D as DeleteCommentOptions, c as CommentReactionOptions, T as ThreadSubscription, H as HistoryVersionDataAsyncResult, S as StorageStatusSuccess, A as AttachmentUrlAsyncResult, R as RoomContextBundle } from './liveblocks-1ujmr05d.mjs';
|
|
2
|
-
import { Status, StorageStatus, LostConnectionEvent, History, BaseMetadata, CommentData, RoomNotificationSettings, JsonObject, LsonObject, BaseUserMeta, Json, User } from '@liveblocks/client';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
import { OpaqueRoom, LiveblocksError, DP, DS, DU, DE, DM, OpaqueClient } from '@liveblocks/core';
|
|
6
|
-
|
|
7
|
-
declare type Props = {
|
|
8
|
-
fallback: ReactNode;
|
|
9
|
-
children: (() => ReactNode | undefined) | ReactNode | undefined;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Almost like a normal <Suspense> component, except that for server-side
|
|
13
|
-
* renders, the fallback will be used.
|
|
14
|
-
*
|
|
15
|
-
* The child props will have to be provided in a function, i.e. change:
|
|
16
|
-
*
|
|
17
|
-
* <Suspense fallback={<Loading />}>
|
|
18
|
-
* <MyRealComponent a={1} />
|
|
19
|
-
* </Suspense>
|
|
20
|
-
*
|
|
21
|
-
* To:
|
|
22
|
-
*
|
|
23
|
-
* <ClientSideSuspense fallback={<Loading />}>
|
|
24
|
-
* <MyRealComponent a={1} />
|
|
25
|
-
* </ClientSideSuspense>
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
declare function ClientSideSuspense(props: Props): React.JSX.Element;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Raw access to the React context where the RoomProvider stores the current
|
|
32
|
-
* room. Exposed for advanced use cases only.
|
|
33
|
-
*
|
|
34
|
-
* @private This is a private/advanced API. Do not rely on it.
|
|
35
|
-
*/
|
|
36
|
-
declare const RoomContext: React.Context<OpaqueRoom | null>;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Returns the current connection status for the Room, and triggers
|
|
40
|
-
* a re-render whenever it changes. Can be used to render a status badge.
|
|
41
|
-
*/
|
|
42
|
-
declare function useStatus(): Status;
|
|
43
|
-
/**
|
|
44
|
-
* Returns the current storage status for the Room, and triggers
|
|
45
|
-
* a re-render whenever it changes. Can be used to render a "Saving..."
|
|
46
|
-
* indicator.
|
|
47
|
-
*
|
|
48
|
-
* @deprecated Prefer useSyncStatus()
|
|
49
|
-
*/
|
|
50
|
-
declare function useStorageStatus(options?: UseStorageStatusOptions): StorageStatus;
|
|
51
|
-
/**
|
|
52
|
-
* @deprecated It's recommended to use `useMutation` for writing to Storage,
|
|
53
|
-
* which will automatically batch all mutations.
|
|
54
|
-
*
|
|
55
|
-
* Returns a function that batches modifications made during the given function.
|
|
56
|
-
* All the modifications are sent to other clients in a single message.
|
|
57
|
-
* All the modifications are merged in a single history item (undo/redo).
|
|
58
|
-
* All the subscribers are called only after the batch is over.
|
|
59
|
-
*/
|
|
60
|
-
declare function useBatch<T>(): (callback: () => T) => T;
|
|
61
|
-
/**
|
|
62
|
-
* Get informed when reconnecting to the Liveblocks servers is taking
|
|
63
|
-
* longer than usual. This typically is a sign of a client that has lost
|
|
64
|
-
* internet connectivity.
|
|
65
|
-
*
|
|
66
|
-
* This isn't problematic (because the Liveblocks client is still trying to
|
|
67
|
-
* reconnect), but it's typically a good idea to inform users about it if
|
|
68
|
-
* the connection takes too long to recover.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* useLostConnectionListener(event => {
|
|
72
|
-
* if (event === 'lost') {
|
|
73
|
-
* toast.warn('Reconnecting to the Liveblocks servers is taking longer than usual...')
|
|
74
|
-
* } else if (event === 'failed') {
|
|
75
|
-
* toast.warn('Reconnecting to the Liveblocks servers failed.')
|
|
76
|
-
* } else if (event === 'restored') {
|
|
77
|
-
* toast.clear();
|
|
78
|
-
* }
|
|
79
|
-
* })
|
|
80
|
-
*/
|
|
81
|
-
declare function useLostConnectionListener(callback: (event: LostConnectionEvent) => void): void;
|
|
82
|
-
/**
|
|
83
|
-
* useErrorListener is a React hook that allows you to respond to potential room
|
|
84
|
-
* connection errors.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* useErrorListener(er => {
|
|
88
|
-
* console.error(er);
|
|
89
|
-
* })
|
|
90
|
-
*/
|
|
91
|
-
declare function useErrorListener(callback: (err: LiveblocksError) => void): void;
|
|
92
|
-
/**
|
|
93
|
-
* Returns the room.history
|
|
94
|
-
*/
|
|
95
|
-
declare function useHistory(): History;
|
|
96
|
-
/**
|
|
97
|
-
* Returns a function that undoes the last operation executed by the current
|
|
98
|
-
* client. It does not impact operations made by other clients.
|
|
99
|
-
*/
|
|
100
|
-
declare function useUndo(): () => void;
|
|
101
|
-
/**
|
|
102
|
-
* Returns a function that redoes the last operation executed by the current
|
|
103
|
-
* client. It does not impact operations made by other clients.
|
|
104
|
-
*/
|
|
105
|
-
declare function useRedo(): () => void;
|
|
106
|
-
/**
|
|
107
|
-
* Returns whether there are any operations to undo.
|
|
108
|
-
*/
|
|
109
|
-
declare function useCanUndo(): boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Returns whether there are any operations to redo.
|
|
112
|
-
*/
|
|
113
|
-
declare function useCanRedo(): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Returns an array of connection IDs. This matches the values you'll get by
|
|
116
|
-
* using the `useOthers()` hook.
|
|
117
|
-
*
|
|
118
|
-
* Roughly equivalent to:
|
|
119
|
-
* useOthers((others) => others.map(other => other.connectionId), shallow)
|
|
120
|
-
*
|
|
121
|
-
* This is useful in particular to implement efficiently rendering components
|
|
122
|
-
* for each user in the room, e.g. cursors.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* const ids = useOthersConnectionIds();
|
|
126
|
-
* // [2, 4, 7]
|
|
127
|
-
*/
|
|
128
|
-
declare function useOthersConnectionIds(): readonly number[];
|
|
129
|
-
/**
|
|
130
|
-
* @private Internal API, do not rely on it.
|
|
131
|
-
*/
|
|
132
|
-
declare function useCommentsErrorListener<M extends BaseMetadata>(callback: (error: CommentsError<M>) => void): void;
|
|
133
|
-
/**
|
|
134
|
-
* Returns a function that adds a comment to a thread.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* const createComment = useCreateComment();
|
|
138
|
-
* createComment({ threadId: "th_xxx", body: {} });
|
|
139
|
-
*/
|
|
140
|
-
declare function useCreateComment(): (options: CreateCommentOptions) => CommentData;
|
|
141
|
-
/**
|
|
142
|
-
* Returns a function that edits a comment's body.
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* const editComment = useEditComment()
|
|
146
|
-
* editComment({ threadId: "th_xxx", commentId: "cm_xxx", body: {} })
|
|
147
|
-
*/
|
|
148
|
-
declare function useEditComment(): (options: EditCommentOptions) => void;
|
|
149
|
-
/**
|
|
150
|
-
* Returns a function that deletes a comment.
|
|
151
|
-
* If it is the last non-deleted comment, the thread also gets deleted.
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* const deleteComment = useDeleteComment();
|
|
155
|
-
* deleteComment({ threadId: "th_xxx", commentId: "cm_xxx" })
|
|
156
|
-
*/
|
|
157
|
-
declare function useDeleteComment(): ({ threadId, commentId }: DeleteCommentOptions) => void;
|
|
158
|
-
/**
|
|
159
|
-
* Returns a function that removes a reaction on a comment.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* const removeReaction = useRemoveReaction();
|
|
163
|
-
* removeReaction({ threadId: "th_xxx", commentId: "cm_xxx", emoji: "👍" })
|
|
164
|
-
*/
|
|
165
|
-
declare function useRemoveReaction(): ({ threadId, commentId, emoji }: CommentReactionOptions) => void;
|
|
166
|
-
/**
|
|
167
|
-
* Returns a function that marks a thread as read.
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* const markThreadAsRead = useMarkThreadAsRead();
|
|
171
|
-
* markThreadAsRead("th_xxx");
|
|
172
|
-
*/
|
|
173
|
-
declare function useMarkThreadAsRead(): (threadId: string) => void;
|
|
174
|
-
/**
|
|
175
|
-
* Returns a function that marks a thread as resolved.
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* const markThreadAsResolved = useMarkThreadAsResolved();
|
|
179
|
-
* markThreadAsResolved("th_xxx");
|
|
180
|
-
*/
|
|
181
|
-
declare function useMarkThreadAsResolved(): (threadId: string) => void;
|
|
182
|
-
/**
|
|
183
|
-
* Returns a function that marks a thread as unresolved.
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* const markThreadAsUnresolved = useMarkThreadAsUnresolved();
|
|
187
|
-
* markThreadAsUnresolved("th_xxx");
|
|
188
|
-
*/
|
|
189
|
-
declare function useMarkThreadAsUnresolved(): (threadId: string) => void;
|
|
190
|
-
/**
|
|
191
|
-
* Returns the subscription status of a thread.
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* const { status, unreadSince } = useThreadSubscription("th_xxx");
|
|
195
|
-
*/
|
|
196
|
-
declare function useThreadSubscription(threadId: string): ThreadSubscription;
|
|
197
|
-
/**
|
|
198
|
-
* Returns the version data bianry for a given version
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* const {data} = useHistoryVersionData(versionId);
|
|
202
|
-
*/
|
|
203
|
-
declare function useHistoryVersionData(versionId: string): HistoryVersionDataAsyncResult;
|
|
204
|
-
/**
|
|
205
|
-
* Returns a function that updates the user's notification settings
|
|
206
|
-
* for the current room.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
|
|
210
|
-
* updateRoomNotificationSettings({ threads: "all" });
|
|
211
|
-
*/
|
|
212
|
-
declare function useUpdateRoomNotificationSettings(): (settings: Partial<RoomNotificationSettings>) => void;
|
|
213
|
-
/**
|
|
214
|
-
* Returns an array of connection IDs. This matches the values you'll get by
|
|
215
|
-
* using the `useOthers()` hook.
|
|
216
|
-
*
|
|
217
|
-
* Roughly equivalent to:
|
|
218
|
-
* useOthers((others) => others.map(other => other.connectionId), shallow)
|
|
219
|
-
*
|
|
220
|
-
* This is useful in particular to implement efficiently rendering components
|
|
221
|
-
* for each user in the room, e.g. cursors.
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* const ids = useOthersConnectionIds();
|
|
225
|
-
* // [2, 4, 7]
|
|
226
|
-
*/
|
|
227
|
-
declare function useOthersConnectionIdsSuspense(): readonly number[];
|
|
228
|
-
/**
|
|
229
|
-
* Returns the current storage status for the Room, and triggers
|
|
230
|
-
* a re-render whenever it changes. Can be used to render a "Saving..."
|
|
231
|
-
* indicator.
|
|
232
|
-
*
|
|
233
|
-
* @deprecated Prefer useSyncStatus()
|
|
234
|
-
*/
|
|
235
|
-
declare function useStorageStatusSuspense(options?: UseStorageStatusOptions): StorageStatusSuccess;
|
|
236
|
-
/**
|
|
237
|
-
* Returns a presigned URL for an attachment by its ID.
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* const { url, error, isLoading } = useAttachmentUrl("at_xxx");
|
|
241
|
-
*/
|
|
242
|
-
declare function useAttachmentUrl(attachmentId: string): AttachmentUrlAsyncResult;
|
|
243
|
-
/**
|
|
244
|
-
* Returns a presigned URL for an attachment by its ID.
|
|
245
|
-
*
|
|
246
|
-
* @example
|
|
247
|
-
* const { url } = useAttachmentUrl("at_xxx");
|
|
248
|
-
*/
|
|
249
|
-
declare function useAttachmentUrlSuspense(attachmentId: string): {
|
|
250
|
-
readonly isLoading: false;
|
|
251
|
-
readonly url: string;
|
|
252
|
-
readonly error: undefined;
|
|
253
|
-
};
|
|
254
|
-
/**
|
|
255
|
-
* Creates a RoomProvider and a set of typed hooks to use in your app. Note
|
|
256
|
-
* that any RoomProvider created in this way does not need to be nested in
|
|
257
|
-
* LiveblocksProvider, as it already has access to the client.
|
|
258
|
-
*/
|
|
259
|
-
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>;
|
|
260
|
-
declare type TypedBundle = RoomContextBundle<DP, DS, DU, DE, DM>;
|
|
261
|
-
/**
|
|
262
|
-
* Makes a Room available in the component hierarchy below.
|
|
263
|
-
* Joins the room when the component is mounted, and automatically leaves
|
|
264
|
-
* the room when the component is unmounted.
|
|
265
|
-
*/
|
|
266
|
-
declare const _RoomProvider: TypedBundle["RoomProvider"];
|
|
267
|
-
/**
|
|
268
|
-
* Returns a callback that lets you broadcast custom events to other users in the room
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* const broadcast = useBroadcastEvent();
|
|
272
|
-
*
|
|
273
|
-
* broadcast({ type: "CUSTOM_EVENT", data: { x: 0, y: 0 } });
|
|
274
|
-
*/
|
|
275
|
-
declare const _useBroadcastEvent: TypedBundle["useBroadcastEvent"];
|
|
276
|
-
/**
|
|
277
|
-
* Get informed when users enter or leave the room, as an event.
|
|
278
|
-
*
|
|
279
|
-
* @example
|
|
280
|
-
* useOthersListener({ type, user, others }) => {
|
|
281
|
-
* if (type === 'enter') {
|
|
282
|
-
* // `user` has joined the room
|
|
283
|
-
* } else if (type === 'leave') {
|
|
284
|
-
* // `user` has left the room
|
|
285
|
-
* }
|
|
286
|
-
* })
|
|
287
|
-
*/
|
|
288
|
-
declare const _useOthersListener: TypedBundle["useOthersListener"];
|
|
289
|
-
/**
|
|
290
|
-
* Returns the Room of the nearest RoomProvider above in the React component
|
|
291
|
-
* tree.
|
|
292
|
-
*/
|
|
293
|
-
declare const _useRoom: TypedBundle["useRoom"];
|
|
294
|
-
/**
|
|
295
|
-
* Returns whether the hook is called within a RoomProvider context.
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* const isInsideRoom = useIsInsideRoom();
|
|
299
|
-
*/
|
|
300
|
-
declare const _useIsInsideRoom: TypedBundle["useIsInsideRoom"];
|
|
301
|
-
/**
|
|
302
|
-
* Returns a function that adds a reaction from a comment.
|
|
303
|
-
*
|
|
304
|
-
* @example
|
|
305
|
-
* const addReaction = useAddReaction();
|
|
306
|
-
* addReaction({ threadId: "th_xxx", commentId: "cm_xxx", emoji: "👍" })
|
|
307
|
-
*/
|
|
308
|
-
declare const _useAddReaction: TypedBundle["useAddReaction"];
|
|
309
|
-
/**
|
|
310
|
-
* Create a callback function that lets you mutate Liveblocks state.
|
|
311
|
-
*
|
|
312
|
-
* The first argument that gets passed into your callback will be
|
|
313
|
-
* a "mutation context", which exposes the following:
|
|
314
|
-
*
|
|
315
|
-
* - `storage` - The mutable Storage root.
|
|
316
|
-
* You can mutate any Live structures with this, for example:
|
|
317
|
-
* `storage.get('layers').get('layer1').set('fill', 'red')`
|
|
318
|
-
*
|
|
319
|
-
* - `setMyPresence` - Call this with a new (partial) Presence value.
|
|
320
|
-
*
|
|
321
|
-
* - `self` - A read-only version of the latest self, if you need it to
|
|
322
|
-
* compute the next state.
|
|
323
|
-
*
|
|
324
|
-
* - `others` - A read-only version of the latest others list, if you
|
|
325
|
-
* need it to compute the next state.
|
|
326
|
-
*
|
|
327
|
-
* useMutation is like React's useCallback, except that the first argument
|
|
328
|
-
* that gets passed into your callback will be a "mutation context".
|
|
329
|
-
*
|
|
330
|
-
* If you want get access to the immutable root somewhere in your mutation,
|
|
331
|
-
* you can use `storage.ToImmutable()`.
|
|
332
|
-
*
|
|
333
|
-
* @example
|
|
334
|
-
* const fillLayers = useMutation(
|
|
335
|
-
* ({ storage }, color: Color) => {
|
|
336
|
-
* ...
|
|
337
|
-
* },
|
|
338
|
-
* [],
|
|
339
|
-
* );
|
|
340
|
-
*
|
|
341
|
-
* fillLayers('red');
|
|
342
|
-
*
|
|
343
|
-
* const deleteLayers = useMutation(
|
|
344
|
-
* ({ storage }) => {
|
|
345
|
-
* ...
|
|
346
|
-
* },
|
|
347
|
-
* [],
|
|
348
|
-
* );
|
|
349
|
-
*
|
|
350
|
-
* deleteLayers();
|
|
351
|
-
*/
|
|
352
|
-
declare const _useMutation: TypedBundle["useMutation"];
|
|
353
|
-
/**
|
|
354
|
-
* Returns a function that creates a thread with an initial comment, and optionally some metadata.
|
|
355
|
-
*
|
|
356
|
-
* @example
|
|
357
|
-
* const createThread = useCreateThread();
|
|
358
|
-
* createThread({ body: {}, metadata: {} });
|
|
359
|
-
*/
|
|
360
|
-
declare const _useCreateThread: TypedBundle["useCreateThread"];
|
|
361
|
-
/**
|
|
362
|
-
* Returns a function that deletes a thread and its associated comments.
|
|
363
|
-
* Only the thread creator can delete a thread, it will throw otherwise.
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* const deleteThread = useDeleteThread();
|
|
367
|
-
* deleteThread("th_xxx");
|
|
368
|
-
*/
|
|
369
|
-
declare const _useDeleteThread: TypedBundle["useDeleteThread"];
|
|
370
|
-
/**
|
|
371
|
-
* Returns a function that edits a thread's metadata.
|
|
372
|
-
* To delete an existing metadata property, set its value to `null`.
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
* const editThreadMetadata = useEditThreadMetadata();
|
|
376
|
-
* editThreadMetadata({ threadId: "th_xxx", metadata: {} })
|
|
377
|
-
*/
|
|
378
|
-
declare const _useEditThreadMetadata: TypedBundle["useEditThreadMetadata"];
|
|
379
|
-
/**
|
|
380
|
-
* useEventListener is a React hook that allows you to respond to events broadcast
|
|
381
|
-
* by other users in the room.
|
|
382
|
-
*
|
|
383
|
-
* The `user` argument will indicate which `User` instance sent the message.
|
|
384
|
-
* This will be equal to one of the others in the room, but it can be `null`
|
|
385
|
-
* in case this event was broadcasted from the server.
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* useEventListener(({ event, user, connectionId }) => {
|
|
389
|
-
* // ^^^^ Will be Client A
|
|
390
|
-
* if (event.type === "CUSTOM_EVENT") {
|
|
391
|
-
* // Do something
|
|
392
|
-
* }
|
|
393
|
-
* });
|
|
394
|
-
*/
|
|
395
|
-
declare const _useEventListener: TypedBundle["useEventListener"];
|
|
396
|
-
/**
|
|
397
|
-
* Returns the presence of the current user of the current room, and a function to update it.
|
|
398
|
-
* It is different from the setState function returned by the useState hook from React.
|
|
399
|
-
* You don't need to pass the full presence object to update it.
|
|
400
|
-
*
|
|
401
|
-
* @example
|
|
402
|
-
* const [myPresence, updateMyPresence] = useMyPresence();
|
|
403
|
-
* updateMyPresence({ x: 0 });
|
|
404
|
-
* updateMyPresence({ y: 0 });
|
|
405
|
-
*
|
|
406
|
-
* // At the next render, "myPresence" will be equal to "{ x: 0, y: 0 }"
|
|
407
|
-
*/
|
|
408
|
-
declare const _useMyPresence: TypedBundle["useMyPresence"];
|
|
409
|
-
/**
|
|
410
|
-
* Related to useOthers(), but optimized for selecting only "subsets" of
|
|
411
|
-
* others. This is useful for performance reasons in particular, because
|
|
412
|
-
* selecting only a subset of users also means limiting the number of
|
|
413
|
-
* re-renders that will be triggered.
|
|
414
|
-
*
|
|
415
|
-
* @example
|
|
416
|
-
* const avatars = useOthersMapped(user => user.info.avatar);
|
|
417
|
-
* // ^^^^^^^
|
|
418
|
-
* // { connectionId: number; data: string }[]
|
|
419
|
-
*
|
|
420
|
-
* The selector function you pass to useOthersMapped() is called an "item
|
|
421
|
-
* selector", and operates on a single user at a time. If you provide an
|
|
422
|
-
* (optional) "item comparison" function, it will be used to compare each
|
|
423
|
-
* item pairwise.
|
|
424
|
-
*
|
|
425
|
-
* For example, to select multiple properties:
|
|
426
|
-
*
|
|
427
|
-
* @example
|
|
428
|
-
* const avatarsAndCursors = useOthersMapped(
|
|
429
|
-
* user => [u.info.avatar, u.presence.cursor],
|
|
430
|
-
* shallow, // 👈
|
|
431
|
-
* );
|
|
432
|
-
*/
|
|
433
|
-
declare const _useOthersMapped: TypedBundle["useOthersMapped"];
|
|
434
|
-
/**
|
|
435
|
-
* Related to useOthers(), but optimized for selecting only "subsets" of
|
|
436
|
-
* others. This is useful for performance reasons in particular, because
|
|
437
|
-
* selecting only a subset of users also means limiting the number of
|
|
438
|
-
* re-renders that will be triggered.
|
|
439
|
-
*
|
|
440
|
-
* @example
|
|
441
|
-
* const avatars = useOthersMapped(user => user.info.avatar);
|
|
442
|
-
* // ^^^^^^^
|
|
443
|
-
* // { connectionId: number; data: string }[]
|
|
444
|
-
*
|
|
445
|
-
* The selector function you pass to useOthersMapped() is called an "item
|
|
446
|
-
* selector", and operates on a single user at a time. If you provide an
|
|
447
|
-
* (optional) "item comparison" function, it will be used to compare each
|
|
448
|
-
* item pairwise.
|
|
449
|
-
*
|
|
450
|
-
* For example, to select multiple properties:
|
|
451
|
-
*
|
|
452
|
-
* @example
|
|
453
|
-
* const avatarsAndCursors = useOthersMapped(
|
|
454
|
-
* user => [u.info.avatar, u.presence.cursor],
|
|
455
|
-
* shallow, // 👈
|
|
456
|
-
* );
|
|
457
|
-
*/
|
|
458
|
-
declare const _useOthersMappedSuspense: TypedBundle["suspense"]["useOthersMapped"];
|
|
459
|
-
/**
|
|
460
|
-
* Returns the threads within the current room.
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* const { threads, error, isLoading } = useThreads();
|
|
464
|
-
*/
|
|
465
|
-
declare const _useThreads: TypedBundle["useThreads"];
|
|
466
|
-
/**
|
|
467
|
-
* Returns the threads within the current room.
|
|
468
|
-
*
|
|
469
|
-
* @example
|
|
470
|
-
* const { threads } = useThreads();
|
|
471
|
-
*/
|
|
472
|
-
declare const _useThreadsSuspense: TypedBundle["suspense"]["useThreads"];
|
|
473
|
-
/**
|
|
474
|
-
* Returns the user's notification settings for the current room
|
|
475
|
-
* and a function to update them.
|
|
476
|
-
*
|
|
477
|
-
* @example
|
|
478
|
-
* const [{ settings }, updateSettings] = useRoomNotificationSettings();
|
|
479
|
-
*/
|
|
480
|
-
declare const _useRoomNotificationSettings: TypedBundle["useRoomNotificationSettings"];
|
|
481
|
-
/**
|
|
482
|
-
* Returns the user's notification settings for the current room
|
|
483
|
-
* and a function to update them.
|
|
484
|
-
*
|
|
485
|
-
* @example
|
|
486
|
-
* const [{ settings }, updateSettings] = useRoomNotificationSettings();
|
|
487
|
-
*/
|
|
488
|
-
declare const _useRoomNotificationSettingsSuspense: TypedBundle["suspense"]["useRoomNotificationSettings"];
|
|
489
|
-
/**
|
|
490
|
-
* (Private beta) Returns a history of versions of the current room.
|
|
491
|
-
*
|
|
492
|
-
* @example
|
|
493
|
-
* const { versions, error, isLoading } = useHistoryVersions();
|
|
494
|
-
*/
|
|
495
|
-
declare const _useHistoryVersions: TypedBundle["useHistoryVersions"];
|
|
496
|
-
/**
|
|
497
|
-
* (Private beta) Returns a history of versions of the current room.
|
|
498
|
-
*
|
|
499
|
-
* @example
|
|
500
|
-
* const { versions } = useHistoryVersions();
|
|
501
|
-
*/
|
|
502
|
-
declare const _useHistoryVersionsSuspense: TypedBundle["suspense"]["useHistoryVersions"];
|
|
503
|
-
/**
|
|
504
|
-
* Given a connection ID (as obtained by using `useOthersConnectionIds`), you
|
|
505
|
-
* can call this selector deep down in your component stack to only have the
|
|
506
|
-
* component re-render if properties for this particular user change.
|
|
507
|
-
*
|
|
508
|
-
* @example
|
|
509
|
-
* // Returns only the selected values re-renders whenever that selection changes)
|
|
510
|
-
* const { x, y } = useOther(2, user => user.presence.cursor);
|
|
511
|
-
*/
|
|
512
|
-
declare const _useOther: TypedBundle["useOther"];
|
|
513
|
-
/**
|
|
514
|
-
* Returns an array with information about all the users currently connected in
|
|
515
|
-
* the room (except yourself).
|
|
516
|
-
*
|
|
517
|
-
* @example
|
|
518
|
-
* const others = useOthers();
|
|
519
|
-
*
|
|
520
|
-
* // Example to map all cursors in JSX
|
|
521
|
-
* return (
|
|
522
|
-
* <>
|
|
523
|
-
* {others.map((user) => {
|
|
524
|
-
* if (user.presence.cursor == null) {
|
|
525
|
-
* return null;
|
|
526
|
-
* }
|
|
527
|
-
* return <Cursor key={user.connectionId} cursor={user.presence.cursor} />
|
|
528
|
-
* })}
|
|
529
|
-
* </>
|
|
530
|
-
* )
|
|
531
|
-
*/
|
|
532
|
-
declare function _useOthers(): readonly User<DP, DU>[];
|
|
533
|
-
/**
|
|
534
|
-
* Extract arbitrary data based on all the users currently connected in the
|
|
535
|
-
* room (except yourself).
|
|
536
|
-
*
|
|
537
|
-
* The selector function will get re-evaluated any time a user enters or
|
|
538
|
-
* leaves the room, as well as whenever their presence data changes.
|
|
539
|
-
*
|
|
540
|
-
* The component that uses this hook will automatically re-render if your
|
|
541
|
-
* selector function returns a different value from its previous run.
|
|
542
|
-
*
|
|
543
|
-
* By default `useOthers()` uses strict `===` to check for equality. Take
|
|
544
|
-
* extra care when returning a computed object or list, for example when you
|
|
545
|
-
* return the result of a .map() or .filter() call from the selector. In
|
|
546
|
-
* those cases, you'll probably want to use a `shallow` comparison check.
|
|
547
|
-
*
|
|
548
|
-
* @example
|
|
549
|
-
* const avatars = useOthers(users => users.map(u => u.info.avatar), shallow);
|
|
550
|
-
* const cursors = useOthers(users => users.map(u => u.presence.cursor), shallow);
|
|
551
|
-
* const someoneIsTyping = useOthers(users => users.some(u => u.presence.isTyping));
|
|
552
|
-
*
|
|
553
|
-
*/
|
|
554
|
-
declare function _useOthers<T>(selector: (others: readonly User<DP, DU>[]) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
555
|
-
/**
|
|
556
|
-
* Given a connection ID (as obtained by using `useOthersConnectionIds`), you
|
|
557
|
-
* can call this selector deep down in your component stack to only have the
|
|
558
|
-
* component re-render if properties for this particular user change.
|
|
559
|
-
*
|
|
560
|
-
* @example
|
|
561
|
-
* // Returns only the selected values re-renders whenever that selection changes)
|
|
562
|
-
* const { x, y } = useOther(2, user => user.presence.cursor);
|
|
563
|
-
*/
|
|
564
|
-
declare const _useOtherSuspense: TypedBundle["suspense"]["useOther"];
|
|
565
|
-
/**
|
|
566
|
-
* Returns an array with information about all the users currently connected in
|
|
567
|
-
* the room (except yourself).
|
|
568
|
-
*
|
|
569
|
-
* @example
|
|
570
|
-
* const others = useOthers();
|
|
571
|
-
*
|
|
572
|
-
* // Example to map all cursors in JSX
|
|
573
|
-
* return (
|
|
574
|
-
* <>
|
|
575
|
-
* {others.map((user) => {
|
|
576
|
-
* if (user.presence.cursor == null) {
|
|
577
|
-
* return null;
|
|
578
|
-
* }
|
|
579
|
-
* return <Cursor key={user.connectionId} cursor={user.presence.cursor} />
|
|
580
|
-
* })}
|
|
581
|
-
* </>
|
|
582
|
-
* )
|
|
583
|
-
*/
|
|
584
|
-
declare function _useOthersSuspense(): readonly User<DP, DU>[];
|
|
585
|
-
/**
|
|
586
|
-
* Extract arbitrary data based on all the users currently connected in the
|
|
587
|
-
* room (except yourself).
|
|
588
|
-
*
|
|
589
|
-
* The selector function will get re-evaluated any time a user enters or
|
|
590
|
-
* leaves the room, as well as whenever their presence data changes.
|
|
591
|
-
*
|
|
592
|
-
* The component that uses this hook will automatically re-render if your
|
|
593
|
-
* selector function returns a different value from its previous run.
|
|
594
|
-
*
|
|
595
|
-
* By default `useOthers()` uses strict `===` to check for equality. Take
|
|
596
|
-
* extra care when returning a computed object or list, for example when you
|
|
597
|
-
* return the result of a .map() or .filter() call from the selector. In
|
|
598
|
-
* those cases, you'll probably want to use a `shallow` comparison check.
|
|
599
|
-
*
|
|
600
|
-
* @example
|
|
601
|
-
* const avatars = useOthers(users => users.map(u => u.info.avatar), shallow);
|
|
602
|
-
* const cursors = useOthers(users => users.map(u => u.presence.cursor), shallow);
|
|
603
|
-
* const someoneIsTyping = useOthers(users => users.some(u => u.presence.isTyping));
|
|
604
|
-
*
|
|
605
|
-
*/
|
|
606
|
-
declare function _useOthersSuspense<T>(selector: (others: readonly User<DP, DU>[]) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
607
|
-
/**
|
|
608
|
-
* Extract arbitrary data from the Liveblocks Storage state, using an
|
|
609
|
-
* arbitrary selector function.
|
|
610
|
-
*
|
|
611
|
-
* The selector function will get re-evaluated any time something changes in
|
|
612
|
-
* Storage. The value returned by your selector function will also be the
|
|
613
|
-
* value returned by the hook.
|
|
614
|
-
*
|
|
615
|
-
* The `root` value that gets passed to your selector function is
|
|
616
|
-
* a immutable/readonly version of your Liveblocks storage root.
|
|
617
|
-
*
|
|
618
|
-
* The component that uses this hook will automatically re-render if the
|
|
619
|
-
* returned value changes.
|
|
620
|
-
*
|
|
621
|
-
* By default `useStorage()` uses strict `===` to check for equality. Take
|
|
622
|
-
* extra care when returning a computed object or list, for example when you
|
|
623
|
-
* return the result of a .map() or .filter() call from the selector. In
|
|
624
|
-
* those cases, you'll probably want to use a `shallow` comparison check.
|
|
625
|
-
*/
|
|
626
|
-
declare const _useStorage: TypedBundle["useStorage"];
|
|
627
|
-
/**
|
|
628
|
-
* Extract arbitrary data from the Liveblocks Storage state, using an
|
|
629
|
-
* arbitrary selector function.
|
|
630
|
-
*
|
|
631
|
-
* The selector function will get re-evaluated any time something changes in
|
|
632
|
-
* Storage. The value returned by your selector function will also be the
|
|
633
|
-
* value returned by the hook.
|
|
634
|
-
*
|
|
635
|
-
* The `root` value that gets passed to your selector function is
|
|
636
|
-
* a immutable/readonly version of your Liveblocks storage root.
|
|
637
|
-
*
|
|
638
|
-
* The component that uses this hook will automatically re-render if the
|
|
639
|
-
* returned value changes.
|
|
640
|
-
*
|
|
641
|
-
* By default `useStorage()` uses strict `===` to check for equality. Take
|
|
642
|
-
* extra care when returning a computed object or list, for example when you
|
|
643
|
-
* return the result of a .map() or .filter() call from the selector. In
|
|
644
|
-
* those cases, you'll probably want to use a `shallow` comparison check.
|
|
645
|
-
*/
|
|
646
|
-
declare const _useStorageSuspense: TypedBundle["suspense"]["useStorage"];
|
|
647
|
-
/**
|
|
648
|
-
* Gets the current user once it is connected to the room.
|
|
649
|
-
*
|
|
650
|
-
* @example
|
|
651
|
-
* const me = useSelf();
|
|
652
|
-
* if (me !== null) {
|
|
653
|
-
* const { x, y } = me.presence.cursor;
|
|
654
|
-
* }
|
|
655
|
-
*/
|
|
656
|
-
declare function _useSelf(): User<DP, DU> | null;
|
|
657
|
-
/**
|
|
658
|
-
* Extract arbitrary data based on the current user.
|
|
659
|
-
*
|
|
660
|
-
* The selector function will get re-evaluated any time your presence data
|
|
661
|
-
* changes.
|
|
662
|
-
*
|
|
663
|
-
* The component that uses this hook will automatically re-render if your
|
|
664
|
-
* selector function returns a different value from its previous run.
|
|
665
|
-
*
|
|
666
|
-
* By default `useSelf()` uses strict `===` to check for equality. Take extra
|
|
667
|
-
* care when returning a computed object or list, for example when you return
|
|
668
|
-
* the result of a .map() or .filter() call from the selector. In those
|
|
669
|
-
* cases, you'll probably want to use a `shallow` comparison check.
|
|
670
|
-
*
|
|
671
|
-
* Will return `null` while Liveblocks isn't connected to a room yet.
|
|
672
|
-
*
|
|
673
|
-
* @example
|
|
674
|
-
* const cursor = useSelf(me => me.presence.cursor);
|
|
675
|
-
* if (cursor !== null) {
|
|
676
|
-
* const { x, y } = cursor;
|
|
677
|
-
* }
|
|
678
|
-
*
|
|
679
|
-
*/
|
|
680
|
-
declare function _useSelf<T>(selector: (me: User<DP, DU>) => T, isEqual?: (prev: T, curr: T) => boolean): T | null;
|
|
681
|
-
/**
|
|
682
|
-
* Gets the current user once it is connected to the room.
|
|
683
|
-
*
|
|
684
|
-
* @example
|
|
685
|
-
* const me = useSelf();
|
|
686
|
-
* const { x, y } = me.presence.cursor;
|
|
687
|
-
*/
|
|
688
|
-
declare function _useSelfSuspense(): User<DP, DU>;
|
|
689
|
-
/**
|
|
690
|
-
* Extract arbitrary data based on the current user.
|
|
691
|
-
*
|
|
692
|
-
* The selector function will get re-evaluated any time your presence data
|
|
693
|
-
* changes.
|
|
694
|
-
*
|
|
695
|
-
* The component that uses this hook will automatically re-render if your
|
|
696
|
-
* selector function returns a different value from its previous run.
|
|
697
|
-
*
|
|
698
|
-
* By default `useSelf()` uses strict `===` to check for equality. Take extra
|
|
699
|
-
* care when returning a computed object or list, for example when you return
|
|
700
|
-
* the result of a .map() or .filter() call from the selector. In those
|
|
701
|
-
* cases, you'll probably want to use a `shallow` comparison check.
|
|
702
|
-
*
|
|
703
|
-
* @example
|
|
704
|
-
* const cursor = useSelf(me => me.presence.cursor);
|
|
705
|
-
* const { x, y } = cursor;
|
|
706
|
-
*
|
|
707
|
-
*/
|
|
708
|
-
declare function _useSelfSuspense<T>(selector: (me: User<DP, DU>) => T, isEqual?: (prev: T, curr: T) => boolean): T;
|
|
709
|
-
/**
|
|
710
|
-
* Returns the mutable (!) Storage root. This hook exists for
|
|
711
|
-
* backward-compatible reasons.
|
|
712
|
-
*
|
|
713
|
-
* @example
|
|
714
|
-
* const [root] = useStorageRoot();
|
|
715
|
-
*/
|
|
716
|
-
declare const _useStorageRoot: TypedBundle["useStorageRoot"];
|
|
717
|
-
/**
|
|
718
|
-
* useUpdateMyPresence is similar to useMyPresence but it only returns the function to update the current user presence.
|
|
719
|
-
* If you don't use the current user presence in your component, but you need to update it (e.g. live cursor), it's better to use useUpdateMyPresence to avoid unnecessary renders.
|
|
720
|
-
*
|
|
721
|
-
* @example
|
|
722
|
-
* const updateMyPresence = useUpdateMyPresence();
|
|
723
|
-
* updateMyPresence({ x: 0 });
|
|
724
|
-
* updateMyPresence({ y: 0 });
|
|
725
|
-
*
|
|
726
|
-
* // At the next render, the presence of the current user will be equal to "{ x: 0, y: 0 }"
|
|
727
|
-
*/
|
|
728
|
-
declare const _useUpdateMyPresence: TypedBundle["useUpdateMyPresence"];
|
|
729
|
-
|
|
730
|
-
export { _useStorageSuspense as $, useStatus as A, _useStorageRoot as B, ClientSideSuspense as C, useThreadSubscription as D, useUndo as E, _useUpdateMyPresence as F, useUpdateRoomNotificationSettings as G, useHistoryVersionData as H, useCommentsErrorListener as I, _useOther as J, _useOthers as K, useOthersConnectionIds as L, _useOthersMapped as M, _useSelf as N, _useStorage as O, useStorageStatus as P, _useThreads as Q, RoomContext as R, useAttachmentUrl as S, _useHistoryVersions as T, _useRoomNotificationSettings as U, _useOtherSuspense as V, _useOthersSuspense as W, useOthersConnectionIdsSuspense as X, _useOthersMappedSuspense as Y, _useSelfSuspense as Z, _RoomProvider as _, _useAddReaction as a, useStorageStatusSuspense as a0, _useThreadsSuspense as a1, useAttachmentUrlSuspense as a2, _useHistoryVersionsSuspense as a3, _useRoomNotificationSettingsSuspense as a4, _useBroadcastEvent as b, createRoomContext as c, useCanRedo as d, useCanUndo as e, useCreateComment as f, _useCreateThread as g, useDeleteComment as h, _useDeleteThread as i, useEditComment as j, _useEditThreadMetadata as k, useMarkThreadAsResolved as l, useMarkThreadAsUnresolved as m, useErrorListener as n, _useEventListener as o, useHistory as p, _useIsInsideRoom as q, useLostConnectionListener as r, useMarkThreadAsRead as s, _useMutation as t, useBatch as u, _useMyPresence as v, _useOthersListener as w, useRedo as x, useRemoveReaction as y, _useRoom as z };
|