@liveblocks/react 0.12.0-beta.6 → 0.12.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 +2 -12
- package/lib/index.d.ts +23 -1
- package/lib/index.js +30 -2
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,16 +12,6 @@ Liveblocks helps you create performant and reliable collaborative experiences.
|
|
|
12
12
|
|
|
13
13
|
## Examples
|
|
14
14
|
|
|
15
|
-
Try it live on [liveblocks.io](https://liveblocks.io/examples)
|
|
15
|
+
Try it live on [liveblocks.io](https://liveblocks.io/examples).
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Clone this [github repository](https://github.com/liveblocks/next-js-examples) or try it directly on [CodeSandbox](https://codesandbox.io/s/github/liveblocks/next-js-examples?file=/pages/presence.tsx)
|
|
20
|
-
|
|
21
|
-
### Nuxt.js
|
|
22
|
-
|
|
23
|
-
Clone this [github repository](https://github.com/liveblocks/nuxt-js-examples) or try it directly on [CodeSandbox](https://codesandbox.io/s/github/liveblocks/nuxt-js-examples?file=/pages/presence.vue)
|
|
24
|
-
|
|
25
|
-
### Vanilla JavaScript + Express.js
|
|
26
|
-
|
|
27
|
-
Clone this [github repository](https://github.com/liveblocks/javascript-examples)
|
|
17
|
+
Clone one of our [examples](https://github.com/liveblocks/liveblocks/tree/main/examples).
|
package/lib/index.d.ts
CHANGED
|
@@ -128,7 +128,29 @@ export declare function useSelf<TPresence extends Presence = Presence>(): User<T
|
|
|
128
128
|
export declare function useStorage<TRoot extends Record<string, any>>(): [
|
|
129
129
|
root: LiveObject<TRoot> | null
|
|
130
130
|
];
|
|
131
|
+
/**
|
|
132
|
+
* Returns the LiveMap associated to the provided key. If the LiveList does not exists, a new empty LiveMap will be created.
|
|
133
|
+
* The hook triggers a re-render if the LiveMap is updated, however it does not triggers a re-render if a nested CRDT is updated.
|
|
134
|
+
*/
|
|
131
135
|
export declare function useMap<TKey extends string, TValue>(key: string): LiveMap<TKey, TValue> | null;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the LiveList associated to the provided key. If the LiveList does not exists, a new empty LiveList will be created.
|
|
138
|
+
* 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.
|
|
139
|
+
*/
|
|
132
140
|
export declare function useList<TValue>(key: string): LiveList<TValue> | null;
|
|
133
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Returns the LiveObject associated to the provided key. If the LiveObject does not exists, it will be created with the initialData parameter.
|
|
143
|
+
* 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.
|
|
144
|
+
*/
|
|
145
|
+
export declare function useObject<TData>(key: string, initialData?: TData): LiveObject<TData> | null;
|
|
146
|
+
/**
|
|
147
|
+
* Returns a function that undo the last operation executed by the current client.
|
|
148
|
+
* Undo does not impact operations made by other clients.
|
|
149
|
+
*/
|
|
150
|
+
export declare function useUndo(): () => void;
|
|
151
|
+
/**
|
|
152
|
+
* Returns a function that redo the last operation executed by the current client.
|
|
153
|
+
* Redo does not impact operations made by other clients.
|
|
154
|
+
*/
|
|
155
|
+
export declare function useRedo(): () => void;
|
|
134
156
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -300,6 +300,10 @@ function useStorage() {
|
|
|
300
300
|
}, [room]);
|
|
301
301
|
return [root];
|
|
302
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Returns the LiveMap associated to the provided key. If the LiveList does not exists, a new empty LiveMap will be created.
|
|
305
|
+
* The hook triggers a re-render if the LiveMap is updated, however it does not triggers a re-render if a nested CRDT is updated.
|
|
306
|
+
*/
|
|
303
307
|
function useMap(key) {
|
|
304
308
|
var _a;
|
|
305
309
|
var root = useStorage()[0];
|
|
@@ -324,6 +328,10 @@ function useMap(key) {
|
|
|
324
328
|
}, [root]);
|
|
325
329
|
return (_a = root === null || root === void 0 ? void 0 : root.get(key)) !== null && _a !== void 0 ? _a : null;
|
|
326
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Returns the LiveList associated to the provided key. If the LiveList does not exists, a new empty LiveList will be created.
|
|
333
|
+
* 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.
|
|
334
|
+
*/
|
|
327
335
|
function useList(key) {
|
|
328
336
|
var _a;
|
|
329
337
|
var root = useStorage()[0];
|
|
@@ -348,7 +356,11 @@ function useList(key) {
|
|
|
348
356
|
}, [root]);
|
|
349
357
|
return (_a = root === null || root === void 0 ? void 0 : root.get(key)) !== null && _a !== void 0 ? _a : null;
|
|
350
358
|
}
|
|
351
|
-
|
|
359
|
+
/**
|
|
360
|
+
* Returns the LiveObject associated to the provided key. If the LiveObject does not exists, it will be created with the initialData parameter.
|
|
361
|
+
* 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.
|
|
362
|
+
*/
|
|
363
|
+
function useObject(key, initialData) {
|
|
352
364
|
var _a;
|
|
353
365
|
var root = useStorage()[0];
|
|
354
366
|
var _b = React.useState(0), setCount = _b[1];
|
|
@@ -358,7 +370,7 @@ function useObject(key) {
|
|
|
358
370
|
}
|
|
359
371
|
var obj = root.get(key);
|
|
360
372
|
if (obj == null) {
|
|
361
|
-
obj = new client.LiveObject();
|
|
373
|
+
obj = new client.LiveObject(initialData);
|
|
362
374
|
root.set(key, obj);
|
|
363
375
|
}
|
|
364
376
|
function onChange() {
|
|
@@ -371,6 +383,20 @@ function useObject(key) {
|
|
|
371
383
|
};
|
|
372
384
|
}, [root]);
|
|
373
385
|
return (_a = root === null || root === void 0 ? void 0 : root.get(key)) !== null && _a !== void 0 ? _a : null;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Returns a function that undo the last operation executed by the current client.
|
|
389
|
+
* Undo does not impact operations made by other clients.
|
|
390
|
+
*/
|
|
391
|
+
function useUndo() {
|
|
392
|
+
return useRoom().undo;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Returns a function that redo the last operation executed by the current client.
|
|
396
|
+
* Redo does not impact operations made by other clients.
|
|
397
|
+
*/
|
|
398
|
+
function useRedo() {
|
|
399
|
+
return useRoom().redo;
|
|
374
400
|
}
|
|
375
401
|
|
|
376
402
|
exports.LiveblocksProvider = LiveblocksProvider;
|
|
@@ -383,7 +409,9 @@ exports.useMap = useMap;
|
|
|
383
409
|
exports.useMyPresence = useMyPresence;
|
|
384
410
|
exports.useObject = useObject;
|
|
385
411
|
exports.useOthers = useOthers;
|
|
412
|
+
exports.useRedo = useRedo;
|
|
386
413
|
exports.useSelf = useSelf;
|
|
387
414
|
exports.useStorage = useStorage;
|
|
415
|
+
exports.useUndo = useUndo;
|
|
388
416
|
exports.useUpdateMyPresence = useUpdateMyPresence;
|
|
389
417
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import {\n Client,\n Others,\n Presence,\n LiveObject,\n LiveMap,\n Room,\n User,\n LiveList,\n} from \"@liveblocks/client\";\nimport * as React from \"react\";\n\ntype LiveblocksProviderProps = {\n children: React.ReactNode;\n client: Client;\n};\n\nconst ClientContext = React.createContext<Client | null>(null);\nconst RoomContext = React.createContext<Room | null>(null);\n\n/**\n * Makes the Liveblocks client available in the component hierarchy below.\n */\nexport function LiveblocksProvider(props: LiveblocksProviderProps) {\n return (\n <ClientContext.Provider value={props.client}>\n {props.children}\n </ClientContext.Provider>\n );\n}\n\n/**\n * Returns the client of the nearest LiveblocksProvider above in the react component tree\n */\nfunction useClient(): Client {\n const client = React.useContext(ClientContext);\n if (client == null) {\n throw new Error(\"LiveblocksProvider is missing from the react tree\");\n }\n\n return client;\n}\n\ntype RoomProviderProps<TStorageRoot> = {\n /**\n * The id of the room you want to connect to\n */\n id: string;\n /**\n * A callback that let you initialize the default presence when entering the room.\n * If ommited, the default presence will be an empty object\n */\n defaultPresence?: () => Presence;\n\n defaultStorageRoot?: TStorageRoot;\n\n children: React.ReactNode;\n};\n\n/**\n * Makes a Room available in the component hierarchy below.\n * When this component is unmounted, the current user leave the room.\n * That means that you can't have 2 RoomProvider with the same room id in your react tree.\n */\nexport function RoomProvider<TStorageRoot>({\n id,\n children,\n defaultPresence,\n defaultStorageRoot,\n}: RoomProviderProps<TStorageRoot>) {\n const client = useClient();\n\n React.useEffect(() => {\n return () => {\n client.leave(id);\n };\n }, [client, id]);\n\n const room =\n client.getRoom(id) ||\n client.enter(id, {\n defaultPresence: defaultPresence ? defaultPresence() : undefined,\n defaultStorageRoot,\n });\n\n return <RoomContext.Provider value={room}>{children}</RoomContext.Provider>;\n}\n\n/**\n * Returns the room of the nearest RoomProvider above in the react component tree\n */\nfunction useRoom() {\n const room = React.useContext(RoomContext);\n\n if (room == null) {\n throw new Error(\"RoomProvider is missing from the react tree\");\n }\n\n return room;\n}\n\n/**\n * Returns the presence of the current user of the current room, and a function to update it.\n * It is different from the setState function returned by the useState hook from React.\n * You don't need to pass the full presence object to update it.\n *\n * @example\n * import { useMyPresence } from \"@liveblocks/react\";\n *\n * const [myPresence, updateMyPresence] = useMyPresence();\n * updateMyPresence({ x: 0 });\n * updateMyPresence({ y: 0 });\n *\n * // At the next render, \"myPresence\" will be equal to \"{ x: 0, y: 0 }\"\n */\nexport function useMyPresence<T extends Presence>(): [\n T,\n (overrides: Partial<T>) => void\n] {\n const room = useRoom();\n const presence = room.getPresence<T>();\n const [, update] = React.useState(0);\n\n React.useEffect(() => {\n function onMyPresenceChange() {\n update((x) => x + 1);\n }\n\n room.subscribe(\"my-presence\", onMyPresenceChange);\n\n return () => {\n room.unsubscribe(\"my-presence\", onMyPresenceChange);\n };\n }, [room]);\n\n const setPresence = React.useCallback(\n (overrides: Partial<T>) => room.updatePresence(overrides),\n [room]\n );\n\n return [presence, setPresence];\n}\n\n/**\n * useUpdateMyPresence is similar to useMyPresence but it only returns the function to update the current user presence.\n * 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.\n *\n * @example\n * import { useUpdateMyPresence } from \"@liveblocks/react\";\n *\n * const updateMyPresence = useUpdateMyPresence();\n * updateMyPresence({ x: 0 });\n * updateMyPresence({ y: 0 });\n *\n * // At the next render, the presence of the current user will be equal to \"{ x: 0, y: 0 }\"\n */\nexport function useUpdateMyPresence<T extends Presence>(): (\n overrides: Partial<T>\n) => void {\n const room = useRoom();\n\n return React.useCallback(\n (overrides: Partial<T>) => {\n room.updatePresence(overrides);\n },\n [room]\n );\n}\n\n/**\n * Returns an object that lets you get information about all the the users currently connected in the room.\n *\n * @example\n * import { useOthers } from \"@liveblocks/react\";\n *\n * const others = useOthers();\n *\n * // Example to map all cursors in jsx\n * {\n * others.map(({ connectionId, presence }) => {\n * if(presence == null || presence.cursor == null) {\n * return null;\n * }\n * return <Cursor key={connectionId} cursor={presence.cursor} />\n * })\n * }\n */\nexport function useOthers<T extends Presence>(): Others<T> {\n const room = useRoom();\n\n const [, update] = React.useState(0);\n\n React.useEffect(() => {\n function onOthersChange() {\n update((x) => x + 1);\n }\n\n room.subscribe(\"others\", onOthersChange);\n\n return () => {\n room.subscribe(\"others\", onOthersChange);\n };\n }, [room]);\n\n return room.getOthers();\n}\n\n/**\n * Returns a callback that lets you broadcast custom events to other users in the room\n *\n * @example\n * import { useBroadcastEvent } from \"@liveblocks/react\";\n *\n * const broadcast = useBroadcastEvent();\n *\n * broadcast({ type: \"CUSTOM_EVENT\", data: { x: 0, y: 0 } });\n */\nexport function useBroadcastEvent() {\n const room = useRoom();\n\n return React.useCallback(\n (event: any) => {\n room.broadcastEvent(event);\n },\n [room]\n );\n}\n\n/**\n * useErrorListener is a react hook that lets you react to potential room connection errors.\n *\n * @example\n * import { useErrorListener } from \"@liveblocks/react\";\n *\n * useErrorListener(er => {\n * console.error(er);\n * })\n */\nexport function useErrorListener(callback: (er: Error) => void) {\n const room = useRoom();\n const savedCallback = React.useRef(callback);\n\n React.useEffect(() => {\n savedCallback.current = callback;\n });\n\n React.useEffect(() => {\n const listener = (e: Error) => savedCallback.current(e);\n\n room.subscribe(\"error\", listener);\n\n return () => {\n room.unsubscribe(\"error\", listener);\n };\n }, [room]);\n}\n\n/**\n * useEventListener is a react hook that lets you react to event broadcasted by other users in the room.\n *\n * @example\n * import { useEventListener } from \"@liveblocks/react\";\n *\n * useEventListener(({ connectionId, event }) => {\n * if (event.type === \"CUSTOM_EVENT\") {\n * // Do something\n * }\n * });\n */\nexport function useEventListener<TEvent>(\n callback: ({\n connectionId,\n event,\n }: {\n connectionId: number;\n event: TEvent;\n }) => void\n) {\n const room = useRoom();\n const savedCallback = React.useRef(callback);\n\n React.useEffect(() => {\n savedCallback.current = callback;\n });\n\n React.useEffect(() => {\n const listener = (e: { connectionId: number; event: TEvent }) =>\n savedCallback.current(e);\n\n room.subscribe(\"event\", listener);\n\n return () => {\n room.unsubscribe(\"event\", listener);\n };\n }, [room]);\n}\n\n/**\n * Gets the current user once it is connected to the room.\n *\n * @example\n * import { useSelf } from \"@liveblocks/react\";\n *\n * const user = useSelf();\n */\nexport function useSelf<\n TPresence extends Presence = Presence\n>(): User<TPresence> | null {\n const room = useRoom();\n const [, update] = React.useState(0);\n\n React.useEffect(() => {\n function onChange() {\n update((x) => x + 1);\n }\n\n room.subscribe(\"my-presence\", onChange);\n room.subscribe(\"connection\", onChange);\n\n return () => {\n room.unsubscribe(\"my-presence\", onChange);\n room.unsubscribe(\"connection\", onChange);\n };\n }, [room]);\n\n return room.getSelf<TPresence>();\n}\n\nexport function useStorage<TRoot extends Record<string, any>>(): [\n root: LiveObject<TRoot> | null\n] {\n const room = useRoom();\n const [root, setState] = React.useState<LiveObject<TRoot> | null>(null);\n\n React.useEffect(() => {\n async function fetchStorage() {\n const storage = await room.getStorage<TRoot>();\n setState(storage.root);\n }\n\n fetchStorage();\n\n return () => {};\n }, [room]);\n\n return [root];\n}\n\nexport function useMap<TKey extends string, TValue>(\n key: string\n): LiveMap<TKey, TValue> | null {\n const [root] = useStorage();\n const [, setCount] = React.useState(0);\n\n React.useEffect(() => {\n if (root == null) {\n return;\n }\n\n let map: LiveMap<TKey, TValue> = root.get(key);\n\n if (map == null) {\n map = new LiveMap();\n root.set(key, map);\n }\n\n function onChange() {\n setCount((x) => x + 1);\n }\n\n map.subscribe(onChange);\n\n setCount((x) => x + 1);\n\n return () => {\n return map.unsubscribe(onChange);\n };\n }, [root]);\n\n return root?.get(key) ?? null;\n}\n\nexport function useList<TValue>(\n key: string,\n): LiveList<TValue> | null {\n const [root] = useStorage();\n const [, setCount] = React.useState(0);\n\n React.useEffect(() => {\n if (root == null) {\n return;\n }\n\n let list: LiveList<TValue> = root.get(key);\n\n if (list == null) {\n list = new LiveList();\n root.set(key, list);\n }\n\n function onChange() {\n setCount((x) => x + 1);\n }\n\n list.subscribe(onChange);\n\n setCount((x) => x + 1);\n\n return () => {\n return list.unsubscribe(onChange);\n };\n }, [root]);\n\n return root?.get(key) ?? null;\n}\n\nexport function useObject<TData>(\n key: string\n): LiveObject<TData> | null {\n const [root] = useStorage();\n const [, setCount] = React.useState(0);\n\n React.useEffect(() => {\n if (root == null) {\n return;\n }\n\n let obj: LiveObject<TData> = root.get(key);\n\n if (obj == null) {\n obj = new LiveObject();\n root.set(key, obj);\n }\n\n function onChange() {\n setCount((x) => x + 1);\n }\n\n obj.subscribe(onChange);\n\n setCount((x) => x + 1);\n\n return () => {\n return obj.unsubscribe(onChange);\n };\n }, [root]);\n\n return root?.get(key) ?? null;\n}\n"],"names":["React.createContext","React.createElement","React.useContext","React.useEffect","React.useState","React.useCallback","React.useRef","LiveMap","LiveList","LiveObject"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAM,aAAa,GAAGA,mBAAmB,CAAgB,IAAI,CAAC,CAAC;AAC/D,IAAM,WAAW,GAAGA,mBAAmB,CAAc,IAAI,CAAC,CAAC;AAE3D;;;SAGgB,kB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CAAC,GAAG,CAAC,GAAA,CAAC,CAAC;QAEvB,OAAO;YACL,OAAO,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;SAClC,CAAC;KACH,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,aAAO,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,GAAG,oCAAK,IAAI,CAAC;AAChC;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import {\n Client,\n Others,\n Presence,\n LiveObject,\n LiveMap,\n Room,\n User,\n LiveList,\n} from \"@liveblocks/client\";\nimport * as React from \"react\";\n\ntype LiveblocksProviderProps = {\n children: React.ReactNode;\n client: Client;\n};\n\nconst ClientContext = React.createContext<Client | null>(null);\nconst RoomContext = React.createContext<Room | null>(null);\n\n/**\n * Makes the Liveblocks client available in the component hierarchy below.\n */\nexport function LiveblocksProvider(props: LiveblocksProviderProps) {\n return (\n <ClientContext.Provider value={props.client}>\n {props.children}\n </ClientContext.Provider>\n );\n}\n\n/**\n * Returns the client of the nearest LiveblocksProvider above in the react component tree\n */\nfunction useClient(): Client {\n const client = React.useContext(ClientContext);\n if (client == null) {\n throw new Error(\"LiveblocksProvider is missing from the react tree\");\n }\n\n return client;\n}\n\ntype RoomProviderProps<TStorageRoot> = {\n /**\n * The id of the room you want to connect to\n */\n id: string;\n /**\n * A callback that let you initialize the default presence when entering the room.\n * If ommited, the default presence will be an empty object\n */\n defaultPresence?: () => Presence;\n\n defaultStorageRoot?: TStorageRoot;\n\n children: React.ReactNode;\n};\n\n/**\n * Makes a Room available in the component hierarchy below.\n * When this component is unmounted, the current user leave the room.\n * That means that you can't have 2 RoomProvider with the same room id in your react tree.\n */\nexport function RoomProvider<TStorageRoot>({\n id,\n children,\n defaultPresence,\n defaultStorageRoot,\n}: RoomProviderProps<TStorageRoot>) {\n const client = useClient();\n\n React.useEffect(() => {\n return () => {\n client.leave(id);\n };\n }, [client, id]);\n\n const room =\n client.getRoom(id) ||\n client.enter(id, {\n defaultPresence: defaultPresence ? defaultPresence() : undefined,\n defaultStorageRoot,\n });\n\n return <RoomContext.Provider value={room}>{children}</RoomContext.Provider>;\n}\n\n/**\n * Returns the room of the nearest RoomProvider above in the react component tree\n */\nfunction useRoom() {\n const room = React.useContext(RoomContext);\n\n if (room == null) {\n throw new Error(\"RoomProvider is missing from the react tree\");\n }\n\n return room;\n}\n\n/**\n * Returns the presence of the current user of the current room, and a function to update it.\n * It is different from the setState function returned by the useState hook from React.\n * You don't need to pass the full presence object to update it.\n *\n * @example\n * import { useMyPresence } from \"@liveblocks/react\";\n *\n * const [myPresence, updateMyPresence] = useMyPresence();\n * updateMyPresence({ x: 0 });\n * updateMyPresence({ y: 0 });\n *\n * // At the next render, \"myPresence\" will be equal to \"{ x: 0, y: 0 }\"\n */\nexport function useMyPresence<T extends Presence>(): [\n T,\n (overrides: Partial<T>) => void\n] {\n const room = useRoom();\n const presence = room.getPresence<T>();\n const [, update] = React.useState(0);\n\n React.useEffect(() => {\n function onMyPresenceChange() {\n update((x) => x + 1);\n }\n\n room.subscribe(\"my-presence\", onMyPresenceChange);\n\n return () => {\n room.unsubscribe(\"my-presence\", onMyPresenceChange);\n };\n }, [room]);\n\n const setPresence = React.useCallback(\n (overrides: Partial<T>) => room.updatePresence(overrides),\n [room]\n );\n\n return [presence, setPresence];\n}\n\n/**\n * useUpdateMyPresence is similar to useMyPresence but it only returns the function to update the current user presence.\n * 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.\n *\n * @example\n * import { useUpdateMyPresence } from \"@liveblocks/react\";\n *\n * const updateMyPresence = useUpdateMyPresence();\n * updateMyPresence({ x: 0 });\n * updateMyPresence({ y: 0 });\n *\n * // At the next render, the presence of the current user will be equal to \"{ x: 0, y: 0 }\"\n */\nexport function useUpdateMyPresence<T extends Presence>(): (\n overrides: Partial<T>\n) => void {\n const room = useRoom();\n\n return React.useCallback(\n (overrides: Partial<T>) => {\n room.updatePresence(overrides);\n },\n [room]\n );\n}\n\n/**\n * Returns an object that lets you get information about all the the users currently connected in the room.\n *\n * @example\n * import { useOthers } from \"@liveblocks/react\";\n *\n * const others = useOthers();\n *\n * // Example to map all cursors in jsx\n * {\n * others.map(({ connectionId, presence }) => {\n * if(presence == null || presence.cursor == null) {\n * return null;\n * }\n * return <Cursor key={connectionId} cursor={presence.cursor} />\n * })\n * }\n */\nexport function useOthers<T extends Presence>(): Others<T> {\n const room = useRoom();\n\n const [, update] = React.useState(0);\n\n React.useEffect(() => {\n function onOthersChange() {\n update((x) => x + 1);\n }\n\n room.subscribe(\"others\", onOthersChange);\n\n return () => {\n room.subscribe(\"others\", onOthersChange);\n };\n }, [room]);\n\n return room.getOthers();\n}\n\n/**\n * Returns a callback that lets you broadcast custom events to other users in the room\n *\n * @example\n * import { useBroadcastEvent } from \"@liveblocks/react\";\n *\n * const broadcast = useBroadcastEvent();\n *\n * broadcast({ type: \"CUSTOM_EVENT\", data: { x: 0, y: 0 } });\n */\nexport function useBroadcastEvent() {\n const room = useRoom();\n\n return React.useCallback(\n (event: any) => {\n room.broadcastEvent(event);\n },\n [room]\n );\n}\n\n/**\n * useErrorListener is a react hook that lets you react to potential room connection errors.\n *\n * @example\n * import { useErrorListener } from \"@liveblocks/react\";\n *\n * useErrorListener(er => {\n * console.error(er);\n * })\n */\nexport function useErrorListener(callback: (er: Error) => void) {\n const room = useRoom();\n const savedCallback = React.useRef(callback);\n\n React.useEffect(() => {\n savedCallback.current = callback;\n });\n\n React.useEffect(() => {\n const listener = (e: Error) => savedCallback.current(e);\n\n room.subscribe(\"error\", listener);\n\n return () => {\n room.unsubscribe(\"error\", listener);\n };\n }, [room]);\n}\n\n/**\n * useEventListener is a react hook that lets you react to event broadcasted by other users in the room.\n *\n * @example\n * import { useEventListener } from \"@liveblocks/react\";\n *\n * useEventListener(({ connectionId, event }) => {\n * if (event.type === \"CUSTOM_EVENT\") {\n * // Do something\n * }\n * });\n */\nexport function useEventListener<TEvent>(\n callback: ({\n connectionId,\n event,\n }: {\n connectionId: number;\n event: TEvent;\n }) => void\n) {\n const room = useRoom();\n const savedCallback = React.useRef(callback);\n\n React.useEffect(() => {\n savedCallback.current = callback;\n });\n\n React.useEffect(() => {\n const listener = (e: { connectionId: number; event: TEvent }) =>\n savedCallback.current(e);\n\n room.subscribe(\"event\", listener);\n\n return () => {\n room.unsubscribe(\"event\", listener);\n };\n }, [room]);\n}\n\n/**\n * Gets the current user once it is connected to the room.\n *\n * @example\n * import { useSelf } from \"@liveblocks/react\";\n *\n * const user = useSelf();\n */\nexport function useSelf<\n TPresence extends Presence = Presence\n>(): User<TPresence> | null {\n const room = useRoom();\n const [, update] = React.useState(0);\n\n React.useEffect(() => {\n function onChange() {\n update((x) => x + 1);\n }\n\n room.subscribe(\"my-presence\", onChange);\n room.subscribe(\"connection\", onChange);\n\n return () => {\n room.unsubscribe(\"my-presence\", onChange);\n room.unsubscribe(\"connection\", onChange);\n };\n }, [room]);\n\n return room.getSelf<TPresence>();\n}\n\nexport function useStorage<TRoot extends Record<string, any>>(): [\n root: LiveObject<TRoot> | null\n] {\n const room = useRoom();\n const [root, setState] = React.useState<LiveObject<TRoot> | null>(null);\n\n React.useEffect(() => {\n async function fetchStorage() {\n const storage = await room.getStorage<TRoot>();\n setState(storage.root);\n }\n\n fetchStorage();\n\n return () => {};\n }, [room]);\n\n return [root];\n}\n\n/**\n * Returns the LiveMap associated to the provided key. If the LiveList does not exists, a new empty LiveMap will be created.\n * The hook triggers a re-render if the LiveMap is updated, however it does not triggers a re-render if a nested CRDT is updated.\n */\nexport function useMap<TKey extends string, TValue>(\n key: string\n): LiveMap<TKey, TValue> | null {\n const [root] = useStorage();\n const [, setCount] = React.useState(0);\n\n React.useEffect(() => {\n if (root == null) {\n return;\n }\n\n let map: LiveMap<TKey, TValue> = root.get(key);\n\n if (map == null) {\n map = new LiveMap();\n root.set(key, map);\n }\n\n function onChange() {\n setCount((x) => x + 1);\n }\n\n map.subscribe(onChange);\n\n setCount((x) => x + 1);\n\n return () => {\n return map.unsubscribe(onChange);\n };\n }, [root]);\n\n return root?.get(key) ?? null;\n}\n\n/**\n * Returns the LiveList associated to the provided key. If the LiveList does not exists, a new empty LiveList will be created.\n * 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.\n */\nexport function useList<TValue>(key: string): LiveList<TValue> | null {\n const [root] = useStorage();\n const [, setCount] = React.useState(0);\n\n React.useEffect(() => {\n if (root == null) {\n return;\n }\n\n let list: LiveList<TValue> = root.get(key);\n\n if (list == null) {\n list = new LiveList();\n root.set(key, list);\n }\n\n function onChange() {\n setCount((x) => x + 1);\n }\n\n list.subscribe(onChange);\n\n setCount((x) => x + 1);\n\n return () => {\n return list.unsubscribe(onChange);\n };\n }, [root]);\n\n return root?.get(key) ?? null;\n}\n\n/**\n * Returns the LiveObject associated to the provided key. If the LiveObject does not exists, it will be created with the initialData parameter.\n * 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.\n */\nexport function useObject<TData>(\n key: string,\n initialData?: TData\n): LiveObject<TData> | null {\n const [root] = useStorage();\n const [, setCount] = React.useState(0);\n\n React.useEffect(() => {\n if (root == null) {\n return;\n }\n\n let obj: LiveObject<TData> = root.get(key);\n\n if (obj == null) {\n obj = new LiveObject(initialData);\n root.set(key, obj);\n }\n\n function onChange() {\n setCount((x) => x + 1);\n }\n\n obj.subscribe(onChange);\n\n setCount((x) => x + 1);\n\n return () => {\n return obj.unsubscribe(onChange);\n };\n }, [root]);\n\n return root?.get(key) ?? null;\n}\n\n/**\n * Returns a function that undo the last operation executed by the current client.\n * Undo does not impact operations made by other clients.\n */\nexport function useUndo() {\n return useRoom().undo;\n}\n\n/**\n * Returns a function that redo the last operation executed by the current client.\n * Redo does not impact operations made by other clients.\n */\nexport function useRedo() {\n return useRoom().redo;\n}\n"],"names":["React.createContext","React.createElement","React.useContext","React.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YACf,GAAG,GAAG,IAAIM,iBAAU,CAAC,WAAW,CAAC,CAAC;YAClC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SACpB;QAED,SAAS,QAAQ;YACf,QAAQ,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,GAAA,CAAC,CAAC;SACxB;QAED,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAExB,QAAQ,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,GAAA,CAAC,CAAC;QAEvB,OAAO;YACL,OAAO,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;SAClC,CAAC;KACH,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,aAAO,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,GAAG,oCAAK,IAAI,CAAC;AAChC,CAAC;AAED;;;;SAIgB,OAAO;IACrB,OAAO,OAAO,EAAE,CAAC,IAAI,CAAC;AACxB,CAAC;AAED;;;;SAIgB,OAAO;IACrB,OAAO,OAAO,EAAE,CAAC,IAAI,CAAC;AACxB;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/react",
|
|
3
|
-
"version": "0.12.0
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@liveblocks/client": "0.12.0
|
|
26
|
+
"@liveblocks/client": "0.12.0",
|
|
27
27
|
"react": "^16.14.0 || ^17"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|