@liveblocks/react 0.15.11 → 0.16.0

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/README.md CHANGED
@@ -18,6 +18,8 @@
18
18
  </a>
19
19
  </p>
20
20
 
21
+ A set of [React](https://reactjs.org/) hooks and providers to use [Liveblocks](https://liveblocks.io) declaratively.
22
+
21
23
  ## Installation
22
24
 
23
25
  ```
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { Room, Presence, Others, BroadcastOptions, User, LiveObject, LiveMap, LiveList, Client } from '@liveblocks/client';
1
+ import { Room, Presence, Others, BroadcastOptions, Json, User, LiveObject, Lson, LiveMap, LiveList, LsonObject, History, Client } from '@liveblocks/client';
2
+ export { Json, JsonObject } from '@liveblocks/client';
2
3
  import * as React from 'react';
3
4
 
4
5
  declare type LiveblocksProviderProps = {
@@ -108,7 +109,7 @@ declare function useBroadcastEvent(): (event: any, options?: BroadcastOptions) =
108
109
  * console.error(er);
109
110
  * })
110
111
  */
111
- declare function useErrorListener(callback: (er: Error) => void): void;
112
+ declare function useErrorListener(callback: (err: Error) => void): void;
112
113
  /**
113
114
  * useEventListener is a react hook that lets you react to event broadcasted by other users in the room.
114
115
  *
@@ -121,7 +122,7 @@ declare function useErrorListener(callback: (er: Error) => void): void;
121
122
  * }
122
123
  * });
123
124
  */
124
- declare function useEventListener<TEvent>(callback: ({ connectionId, event, }: {
125
+ declare function useEventListener<TEvent extends Json>(callback: ({ connectionId, event, }: {
125
126
  connectionId: number;
126
127
  event: TEvent;
127
128
  }) => void): void;
@@ -149,7 +150,7 @@ declare function useStorage<TRoot extends Record<string, any>>(): [
149
150
  * const emptyMap = useMap("mapA");
150
151
  * const mapWithItems = useMap("mapB", [["keyA", "valueA"], ["keyB", "valueB"]]);
151
152
  */
152
- declare function useMap<TKey extends string, TValue>(key: string, entries?: readonly (readonly [TKey, TValue])[] | null | undefined): LiveMap<TKey, TValue> | null;
153
+ declare function useMap<TKey extends string, TValue extends Lson>(key: string, entries?: readonly (readonly [TKey, TValue])[] | null | undefined): LiveMap<TKey, TValue> | null;
153
154
  /**
154
155
  * Returns the LiveList associated with the provided key. If the LiveList does not exist, a new LiveList will be created.
155
156
  * The hook triggers a re-render if the LiveList is updated, however it does not triggers a re-render if a nested CRDT is updated.
@@ -162,7 +163,7 @@ declare function useMap<TKey extends string, TValue>(key: string, entries?: read
162
163
  * const emptyList = useList("listA");
163
164
  * const listWithItems = useList("listB", ["a", "b", "c"]);
164
165
  */
165
- declare function useList<TValue>(key: string, items?: TValue[] | undefined): LiveList<TValue> | null;
166
+ declare function useList<TValue extends Lson>(key: string, items?: TValue[] | undefined): LiveList<TValue> | null;
166
167
  /**
167
168
  * Returns the LiveObject associated with the provided key. If the LiveObject does not exist, it will be created with the initialData parameter.
168
169
  * 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.
@@ -177,7 +178,7 @@ declare function useList<TValue>(key: string, items?: TValue[] | undefined): Liv
177
178
  * website: "https://liveblocks.io"
178
179
  * });
179
180
  */
180
- declare function useObject<TData>(key: string, initialData?: TData): LiveObject<TData> | null;
181
+ declare function useObject<TData extends LsonObject>(key: string, initialData?: TData): LiveObject<TData> | null;
181
182
  /**
182
183
  * Returns a function that undoes the last operation executed by the current client.
183
184
  * It does not impact operations made by other clients.
@@ -194,15 +195,10 @@ declare function useRedo(): () => void;
194
195
  * All the modifications are merged in a single history item (undo/redo).
195
196
  * All the subscribers are called only after the batch is over.
196
197
  */
197
- declare function useBatch(): (fn: () => void) => void;
198
+ declare function useBatch(): (callback: () => void) => void;
198
199
  /**
199
200
  * Returns the room.history
200
201
  */
201
- declare function useHistory(): {
202
- undo: () => void;
203
- redo: () => void;
204
- pause: () => void;
205
- resume: () => void;
206
- };
202
+ declare function useHistory(): History;
207
203
 
208
204
  export { LiveblocksProvider, RoomProvider, useBatch, useBroadcastEvent, useErrorListener, useEventListener, useHistory, useList, useMap, useMyPresence, useObject, useOthers, useRedo, useRoom, useSelf, useStorage, useUndo, useUpdateMyPresence };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@liveblocks/react",
3
- "version": "0.15.11",
4
- "description": "",
3
+ "version": "0.16.0",
4
+ "description": "A set of React hooks and providers to use Liveblocks declaratively.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "files": [
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "license": "Apache-2.0",
35
35
  "peerDependencies": {
36
- "@liveblocks/client": "0.15.11",
36
+ "@liveblocks/client": "0.16.0",
37
37
  "react": "^16.14.0 || ^17 || ^18"
38
38
  },
39
39
  "devDependencies": {