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