@liveblocks/react 0.16.15 → 0.17.0-test1

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.
Files changed (4) hide show
  1. package/index.d.ts +318 -45
  2. package/index.js +565 -259
  3. package/index.mjs +511 -216
  4. package/package.json +12 -11
package/index.d.ts CHANGED
@@ -1,62 +1,335 @@
1
1
  /// <reference types="react" />
2
- import { Client } from '@liveblocks/client';
3
- export { Json, JsonObject } from '@liveblocks/client';
4
- import * as React from 'react';
5
- import * as _liveblocks_client_shared from '@liveblocks/client/shared';
2
+ import {
3
+ Client,
4
+ JsonObject,
5
+ LsonObject,
6
+ Json,
7
+ BroadcastOptions,
8
+ History,
9
+ Lson,
10
+ LiveList,
11
+ LiveMap,
12
+ LiveObject,
13
+ Others,
14
+ Room,
15
+ User,
16
+ } from "@liveblocks/client";
17
+ export { Json, JsonObject } from "@liveblocks/client";
18
+ import * as React from "react";
19
+ import { Resolve, RoomInitializers } from "@liveblocks/client/internal";
6
20
 
7
21
  declare type LiveblocksProviderProps = {
8
- children: React.ReactNode;
9
- client: Client;
22
+ children: React.ReactNode;
23
+ client: Client;
10
24
  };
11
25
  /**
12
26
  * Makes the Liveblocks client available in the component hierarchy below.
27
+ *
28
+ * @deprecated Liveblocks is no longer needed if you set up your Liveblocks
29
+ * context using `configureRoom()`. See
30
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for details.
13
31
  */
14
- declare function LiveblocksProvider(props: LiveblocksProviderProps): JSX.Element;
32
+ declare function LiveblocksProvider(
33
+ props: LiveblocksProviderProps
34
+ ): JSX.Element;
15
35
  /**
16
36
  * Returns the Client of the nearest LiveblocksProvider above in the React
17
37
  * component tree.
18
38
  */
19
39
  declare function useClient(): Client;
20
40
 
21
- declare const RoomProvider: <TStorage>(props: {
41
+ declare type RoomProviderProps<
42
+ TPresence extends JsonObject,
43
+ TStorage extends LsonObject
44
+ > = Resolve<
45
+ {
46
+ /**
47
+ * The id of the room you want to connect to
48
+ */
22
49
  id: string;
23
50
  children: React.ReactNode;
24
- initialPresence?: Record<string, unknown> | ((roomId: string) => Record<string, unknown>) | undefined;
25
- initialStorage?: TStorage | ((roomId: string) => TStorage) | undefined;
26
- defaultPresence?: (() => Record<string, unknown>) | undefined;
27
- defaultStorageRoot?: TStorage | undefined;
28
- }) => JSX.Element;
29
- declare const useRoom: () => _liveblocks_client_shared.R;
30
- declare const useMyPresence: <T extends Record<string, unknown>>() => [T, (overrides: Partial<T>, options?: {
31
- addToHistory: boolean;
32
- } | undefined) => void];
33
- declare const useUpdateMyPresence: <T extends Record<string, unknown>>() => (overrides: Partial<T>, options?: {
34
- addToHistory: boolean;
35
- } | undefined) => void;
36
- declare const useOthers: <T extends Record<string, unknown>>() => _liveblocks_client_shared.O<T>;
37
- declare const useBroadcastEvent: () => (event: any, options?: _liveblocks_client_shared.B | undefined) => void;
38
- declare const useErrorListener: (callback: (err: Error) => void) => void;
39
- declare const useEventListener: <TEvent extends _liveblocks_client_shared.J>(callback: ({ connectionId, event, }: {
40
- connectionId: number;
41
- event: TEvent;
42
- }) => void) => void;
43
- declare const useSelf: <TPresence extends Record<string, unknown> = Record<string, unknown>>() => _liveblocks_client_shared.U<TPresence> | null;
44
- declare const useStorage: <TStorage extends Record<string, any>>() => [root: _liveblocks_client_shared.L<TStorage> | null];
45
- declare const useMap: {
46
- <TKey extends string, TValue extends _liveblocks_client_shared.e>(key: string): _liveblocks_client_shared.b<TKey, TValue> | null;
47
- <TKey_1 extends string, TValue_1 extends _liveblocks_client_shared.e>(key: string, entries: readonly (readonly [TKey_1, TValue_1])[] | null): _liveblocks_client_shared.b<TKey_1, TValue_1> | null;
48
- };
49
- declare const useList: {
50
- <TValue extends _liveblocks_client_shared.e>(key: string): _liveblocks_client_shared.c<TValue> | null;
51
- <TValue_1 extends _liveblocks_client_shared.e>(key: string, items: TValue_1[]): _liveblocks_client_shared.c<TValue_1> | null;
51
+ } & RoomInitializers<TPresence, TStorage>
52
+ >;
53
+ declare function configureRoom<
54
+ TPresence extends JsonObject,
55
+ TStorage extends LsonObject
56
+ >(
57
+ client?: Client
58
+ ): {
59
+ RoomProvider: (props: RoomProviderProps<TPresence, TStorage>) => JSX.Element;
60
+ useBatch: () => (callback: () => void) => void;
61
+ useBroadcastEvent: () => (event: Json, options?: BroadcastOptions) => void;
62
+ useErrorListener: (callback: (err: Error) => void) => void;
63
+ useEventListener: (
64
+ callback: (eventData: { connectionId: number; event: Json }) => void
65
+ ) => void;
66
+ useHistory: () => History;
67
+ useList: <TKey extends Extract<keyof TStorage, string>>(
68
+ key: TKey
69
+ ) => TStorage[TKey] | null;
70
+ deprecated_useList: {
71
+ <TValue extends Lson>(key: string): LiveList<TValue> | null;
72
+ <TValue_1 extends Lson>(
73
+ key: string,
74
+ items: TValue_1[]
75
+ ): LiveList<TValue_1> | null;
76
+ };
77
+ useMap: <TKey_1 extends Extract<keyof TStorage, string>>(
78
+ key: TKey_1
79
+ ) => TStorage[TKey_1] | null;
80
+ deprecated_useMap: {
81
+ <TKey_2 extends string, TValue_2 extends Lson>(key: string): LiveMap<
82
+ TKey_2,
83
+ TValue_2
84
+ > | null;
85
+ <TKey_3 extends string, TValue_3 extends Lson>(
86
+ key: string,
87
+ entries: readonly (readonly [TKey_3, TValue_3])[] | null
88
+ ): LiveMap<TKey_3, TValue_3> | null;
89
+ };
90
+ useMyPresence: () => [
91
+ TPresence,
92
+ (
93
+ overrides: Partial<TPresence>,
94
+ options?: {
95
+ addToHistory: boolean;
96
+ }
97
+ ) => void
98
+ ];
99
+ useObject: <TKey_4 extends Extract<keyof TStorage, string>>(
100
+ key: TKey_4
101
+ ) => TStorage[TKey_4] | null;
102
+ deprecated_useObject: {
103
+ <TData extends LsonObject>(key: string): LiveObject<TData> | null;
104
+ <TData_1 extends LsonObject>(
105
+ key: string,
106
+ initialData: TData_1
107
+ ): LiveObject<TData_1> | null;
108
+ };
109
+ useOthers: () => Others<TPresence>;
110
+ useRedo: () => () => void;
111
+ useRoom: () => Room<TPresence, TStorage>;
112
+ useSelf: () => User<TPresence> | null;
113
+ useStorage: () => [root: LiveObject<TStorage> | null];
114
+ useUndo: () => () => void;
115
+ useUpdateMyPresence: () => (
116
+ overrides: Partial<TPresence>,
117
+ options?: {
118
+ addToHistory: boolean;
119
+ }
120
+ ) => void;
52
121
  };
53
- declare const useObject: {
54
- <TData extends _liveblocks_client_shared.f>(key: string): _liveblocks_client_shared.L<TData> | null;
55
- <TData_1 extends _liveblocks_client_shared.f>(key: string, initialData: TData_1): _liveblocks_client_shared.L<TData_1> | null;
56
- };
57
- declare const useUndo: () => () => void;
58
- declare const useRedo: () => () => void;
59
- declare const useBatch: () => (callback: () => void) => void;
60
- declare const useHistory: () => _liveblocks_client_shared.H;
61
122
 
62
- export { LiveblocksProvider, RoomProvider, useBatch, useBroadcastEvent, useClient, useErrorListener, useEventListener, useHistory, useList, useMap, useMyPresence, useObject, useOthers, useRedo, useRoom, useSelf, useStorage, useUndo, useUpdateMyPresence };
123
+ /**
124
+ * NOTE:
125
+ * This file is AUTOGENERATED!
126
+ *
127
+ * Do not update it manually.
128
+ */
129
+
130
+ /**
131
+ * @deprecated Please use `configureRoom()` instead of importing
132
+ * `RoomProvider` from `@liveblocks/react` directly. See
133
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
134
+ * details.
135
+ */
136
+ declare function RoomProvider<
137
+ TPresence extends JsonObject,
138
+ TStorage extends LsonObject
139
+ >(props: RoomProviderProps<TPresence, TStorage>): JSX.Element;
140
+ /**
141
+ * @deprecated Please use `configureRoom()` instead of importing
142
+ * `useBatch` from `@liveblocks/react` directly. See
143
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
144
+ * details.
145
+ */
146
+ declare function useBatch(): (callback: () => void) => void;
147
+ /**
148
+ * @deprecated Please use `configureRoom()` instead of importing
149
+ * `useBroadcastEvent` from `@liveblocks/react` directly. See
150
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
151
+ * details.
152
+ */
153
+ declare function useBroadcastEvent(): (
154
+ event: Json,
155
+ options?: BroadcastOptions
156
+ ) => void;
157
+ /**
158
+ * @deprecated Please use `configureRoom()` instead of importing
159
+ * `useErrorListener` from `@liveblocks/react` directly. See
160
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
161
+ * details.
162
+ */
163
+ declare function useErrorListener(callback: (err: Error) => void): void;
164
+ /**
165
+ * @deprecated Please use `configureRoom()` instead of importing
166
+ * `useEventListener` from `@liveblocks/react` directly. See
167
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
168
+ * details.
169
+ */
170
+ declare function useEventListener(
171
+ callback: (eventData: { connectionId: number; event: Json }) => void
172
+ ): void;
173
+ /**
174
+ * @deprecated Please use `configureRoom()` instead of importing
175
+ * `useHistory` from `@liveblocks/react` directly. See
176
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
177
+ * details.
178
+ */
179
+ declare function useHistory(): History;
180
+ /**
181
+ * @deprecated Please use `configureRoom()` instead of importing
182
+ * `useList` from `@liveblocks/react` directly. See
183
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
184
+ * details.
185
+ */
186
+ declare function useList<TValue extends Lson>(
187
+ key: string
188
+ ): LiveList<TValue> | null;
189
+ /**
190
+ * @deprecated Please use `configureRoom()` instead of importing
191
+ * `useList` from `@liveblocks/react` directly. See
192
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
193
+ * details.
194
+ */
195
+ declare function useList<TValue extends Lson>(
196
+ key: string,
197
+ items: TValue[]
198
+ ): LiveList<TValue> | null;
199
+ /**
200
+ * @deprecated Please use `configureRoom()` instead of importing
201
+ * `useMap` from `@liveblocks/react` directly. See
202
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
203
+ * details.
204
+ */
205
+ declare function useMap<TKey extends string, TValue extends Lson>(
206
+ key: string
207
+ ): LiveMap<TKey, TValue> | null;
208
+ /**
209
+ * @deprecated Please use `configureRoom()` instead of importing
210
+ * `useMap` from `@liveblocks/react` directly. See
211
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
212
+ * details.
213
+ */
214
+ declare function useMap<TKey extends string, TValue extends Lson>(
215
+ key: string,
216
+ entries: readonly (readonly [TKey, TValue])[] | null
217
+ ): LiveMap<TKey, TValue> | null;
218
+ /**
219
+ * @deprecated Please use `configureRoom()` instead of importing
220
+ * `useMyPresence` from `@liveblocks/react` directly. See
221
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
222
+ * details.
223
+ */
224
+ declare function useMyPresence<TPresence extends JsonObject>(): [
225
+ TPresence,
226
+ (
227
+ overrides: Partial<TPresence>,
228
+ options?: {
229
+ addToHistory: boolean;
230
+ }
231
+ ) => void
232
+ ];
233
+ /**
234
+ * @deprecated Please use `configureRoom()` instead of importing
235
+ * `useObject` from `@liveblocks/react` directly. See
236
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
237
+ * details.
238
+ */
239
+ declare function useObject<TData extends LsonObject>(
240
+ key: string
241
+ ): LiveObject<TData> | null;
242
+ /**
243
+ * @deprecated Please use `configureRoom()` instead of importing
244
+ * `useObject` from `@liveblocks/react` directly. See
245
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
246
+ * details.
247
+ */
248
+ declare function useObject<TData extends LsonObject>(
249
+ key: string,
250
+ initialData: TData
251
+ ): LiveObject<TData> | null;
252
+ /**
253
+ * @deprecated Please use `configureRoom()` instead of importing
254
+ * `useOthers` from `@liveblocks/react` directly. See
255
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
256
+ * details.
257
+ */
258
+ declare function useOthers<TPresence extends JsonObject>(): Others<TPresence>;
259
+ /**
260
+ * @deprecated Please use `configureRoom()` instead of importing
261
+ * `useRedo` from `@liveblocks/react` directly. See
262
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
263
+ * details.
264
+ */
265
+ declare function useRedo(): () => void;
266
+ /**
267
+ * @deprecated Please use `configureRoom()` instead of importing
268
+ * `useRoom` from `@liveblocks/react` directly. See
269
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
270
+ * details.
271
+ */
272
+ declare function useRoom<
273
+ TPresence extends JsonObject,
274
+ TStorage extends LsonObject
275
+ >(): Room<TPresence, TStorage>;
276
+ /**
277
+ * @deprecated Please use `configureRoom()` instead of importing
278
+ * `useSelf` from `@liveblocks/react` directly. See
279
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
280
+ * details.
281
+ */
282
+ declare function useSelf<
283
+ TPresence extends JsonObject
284
+ >(): User<TPresence> | null;
285
+ /**
286
+ * @deprecated Please use `configureRoom()` instead of importing
287
+ * `useStorage` from `@liveblocks/react` directly. See
288
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
289
+ * details.
290
+ */
291
+ declare function useStorage<TStorage extends LsonObject>(): [
292
+ root: LiveObject<TStorage> | null
293
+ ];
294
+ /**
295
+ * @deprecated Please use `configureRoom()` instead of importing
296
+ * `useUndo` from `@liveblocks/react` directly. See
297
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
298
+ * details.
299
+ */
300
+ declare function useUndo(): () => void;
301
+ /**
302
+ * @deprecated Please use `configureRoom()` instead of importing
303
+ * `useUpdateMyPresence` from `@liveblocks/react` directly. See
304
+ * https://gist.github.com/nvie/5e718902c51ea7dad93cd6952fe1af03 for
305
+ * details.
306
+ */
307
+ declare function useUpdateMyPresence<TPresence extends JsonObject>(): (
308
+ overrides: Partial<TPresence>,
309
+ options?: {
310
+ addToHistory: boolean;
311
+ }
312
+ ) => void;
313
+
314
+ export {
315
+ LiveblocksProvider,
316
+ RoomProvider,
317
+ configureRoom,
318
+ useBatch,
319
+ useBroadcastEvent,
320
+ useClient,
321
+ useErrorListener,
322
+ useEventListener,
323
+ useHistory,
324
+ useList,
325
+ useMap,
326
+ useMyPresence,
327
+ useObject,
328
+ useOthers,
329
+ useRedo,
330
+ useRoom,
331
+ useSelf,
332
+ useStorage,
333
+ useUndo,
334
+ useUpdateMyPresence,
335
+ };