@liveblocks/react 0.15.0-alpha.2 → 0.15.0-alpha.4

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/lib/index.js CHANGED
@@ -81,6 +81,14 @@ function useClient() {
81
81
  */
82
82
  function RoomProvider(_a) {
83
83
  var id = _a.id, children = _a.children, defaultPresence = _a.defaultPresence, defaultStorageRoot = _a.defaultStorageRoot;
84
+ if (process.env.NODE_ENV !== "production") {
85
+ if (id == null) {
86
+ throw new Error("RoomProvider id property is required. For more information: https://liveblocks.io/docs/errors/liveblocks-react/RoomProvider-id-property-is-required");
87
+ }
88
+ if (typeof id !== "string") {
89
+ throw new Error("RoomProvider id property should be a string.");
90
+ }
91
+ }
84
92
  var client = useClient();
85
93
  React.useEffect(function () {
86
94
  return function () {
@@ -91,6 +99,7 @@ function RoomProvider(_a) {
91
99
  client.enter(id, {
92
100
  defaultPresence: defaultPresence ? defaultPresence() : undefined,
93
101
  defaultStorageRoot: defaultStorageRoot,
102
+ DO_NOT_USE_withoutConnecting: typeof window === "undefined",
94
103
  });
95
104
  return React.createElement(RoomContext.Provider, { value: room }, children);
96
105
  }
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 BroadcastOptions,\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 */\nexport function 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>, options?: { addToHistory: boolean }) => 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 const unsubscribe = room.subscribe(\"my-presence\", onMyPresenceChange);\n\n return () => {\n unsubscribe();\n };\n }, [room]);\n\n const setPresence = React.useCallback(\n (overrides: Partial<T>, options?: { addToHistory: boolean }) =>\n room.updatePresence(overrides, options),\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 options?: { addToHistory: boolean }\n) => void {\n const room = useRoom();\n\n return React.useCallback(\n (overrides: Partial<T>, options?: { addToHistory: boolean }) => {\n room.updatePresence(overrides, options);\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 const unsubscribe = room.subscribe(\"others\", onOthersChange);\n\n return () => {\n unsubscribe();\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 (\n event: any,\n options: BroadcastOptions = { shouldQueueEventIfNotReady: false }\n ) => {\n room.broadcastEvent(event, options);\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 const unsubscribe = room.subscribe(\"error\", listener);\n\n return () => {\n unsubscribe();\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 const unsubscribe = room.subscribe(\"event\", listener);\n\n return () => {\n unsubscribe();\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 const unsubscribePresence = room.subscribe(\"my-presence\", onChange);\n const unsubscribeConnection = room.subscribe(\"connection\", onChange);\n\n return () => {\n unsubscribePresence();\n unsubscribeConnection();\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 let didCancel = false;\n\n async function fetchStorage() {\n const storage = await room.getStorage<TRoot>();\n if (!didCancel) {\n setState(storage.root);\n }\n }\n\n fetchStorage();\n\n return () => {\n didCancel = true;\n };\n }, [room]);\n\n return [root];\n}\n\n/**\n * Returns the LiveMap associated with the provided key. If the LiveMap does not exist, 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 *\n * @param key The storage key associated with the LiveMap\n * @param entries Optional entries that are used to create the LiveMap for the first time\n * @returns null while the storage is loading, otherwise, returns the LiveMap associated to the storage\n *\n * @example\n * const emptyMap = useMap(\"mapA\");\n * const mapWithItems = useMap(\"mapB\", [[\"keyA\", \"valueA\"], [\"keyB\", \"valueB\"]]);\n */\nexport function useMap<TKey extends string, TValue>(\n key: string,\n entries?: readonly (readonly [TKey, TValue])[] | null | undefined\n): LiveMap<TKey, TValue> | null {\n return useCrdt(key, new LiveMap(entries));\n}\n\n/**\n * Returns the LiveList associated with the provided key. If the LiveList does not exist, a new 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 *\n * @param key The storage key associated with the LiveList\n * @param items Optional items that are used to create the LiveList for the first time\n * @returns null while the storage is loading, otherwise, returns the LiveList associated to the storage\n *\n * @example\n * const emptyList = useList(\"listA\");\n * const listWithItems = useList(\"listB\", [\"a\", \"b\", \"c\"]);\n */\nexport function useList<TValue>(\n key: string,\n items?: TValue[] | undefined\n): LiveList<TValue> | null {\n return useCrdt<LiveList<TValue>>(key, new LiveList(items));\n}\n\n/**\n * Returns the LiveObject associated with the provided key. If the LiveObject does not exist, 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 *\n * @param key The storage key associated with the LiveObject\n * @param initialData Optional data that is used to create the LiveObject for the first time\n * @returns null while the storage is loading, otherwise, returns the LveObject associated to the storage\n *\n * @example\n * const object = useObject(\"obj\", {\n * company: \"Liveblocks\",\n * website: \"https://liveblocks.io\"\n * });\n */\nexport function useObject<TData>(\n key: string,\n initialData?: TData\n): LiveObject<TData> | null {\n return useCrdt(key, new LiveObject(initialData));\n}\n\n/**\n * Returns a function that undoes the last operation executed by the current client.\n * It does not impact operations made by other clients.\n */\nexport function useUndo() {\n return useRoom().history.undo;\n}\n\n/**\n * Returns a function that redoes the last operation executed by the current client.\n * It does not impact operations made by other clients.\n */\nexport function useRedo() {\n return useRoom().history.redo;\n}\n\n/**\n * Returns a function that batches modifications made during the given function.\n * All the modifications are sent to other clients in a single message.\n * All the modifications are merged in a single history item (undo/redo).\n * All the subscribers are called only after the batch is over.\n */\nexport function useBatch() {\n return useRoom().batch;\n}\n\n/**\n * Returns the room.history\n */\nexport function useHistory() {\n return useRoom().history;\n}\n\nfunction useCrdt<T>(key: string, initialCrdt: T): T | null {\n const room = useRoom();\n const [root] = useStorage();\n const [, setCount] = React.useState(0);\n\n React.useEffect(() => {\n if (root == null) {\n return;\n }\n\n let crdt: null | T = root.get(key);\n\n if (crdt == null) {\n crdt = initialCrdt;\n root.set(key, crdt);\n }\n\n function onChange() {\n setCount((x) => x + 1);\n }\n\n function onRootChange() {\n const newCrdt = root!.get(key);\n if (newCrdt !== crdt) {\n unsubscribeCrdt();\n crdt = newCrdt;\n unsubscribeCrdt = room.subscribe(\n crdt as any /* AbstractCrdt */,\n onChange\n );\n setCount((x) => x + 1);\n }\n }\n\n let unsubscribeCrdt = room.subscribe(\n crdt as any /* AbstractCrdt */,\n onChange\n );\n const unsubscribeRoot = room.subscribe(\n root as any /* AbstractCrdt */,\n onRootChange\n );\n\n setCount((x) => x + 1);\n\n return () => {\n unsubscribeRoot();\n unsubscribeCrdt();\n };\n }, [root, room]);\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,IAAM,aAAa,GAAGA,mBAAmB,CAAgB,IAAI,CAAC,CAAC;AAC/D,IAAM,WAAW,GAAGA,mBAAmB,CAAc,IAAI,CAAC,CAAC;AAE3D;;;SAGgB,kBAAkB,CAAC,KAA8B;IAC/D,QACEC,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,MAAM,IACxC,KAAK,CAAC,QAAQ,CACQ,EACzB;AACJ,CAAC;AAED;;;AAGA,SAAS,SAAS;IAChB,IAAM,MAAM,GAAGC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC/C,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAkBD;;;;;SAKgB,YAAY,CAAe,EAKT;QAJhC,EAAE,QAAA,EACF,QAAQ,cAAA,EACR,eAAe,qBAAA,EACf,kBAAkB,wBAAA;IAElB,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3BC,eAAe,CAAC;QACd,OAAO;YACL,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SAClB,CAAC;KACH,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IAEjB,IAAM,IAAI,GACR,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAClB,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;YACf,eAAe,EAAE,eAAe,GAAG,eAAe,EAAE,GAAG,SAAS;YAChE,kBAAkB,oBAAA;SACnB,CAAC,CAAC;IAEL,OAAOF,oBAAC,WAAW,CAAC,QAAQ,IAAC,KA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L,eAAe,EAAE,CAAC;YAClB,eAAe,EAAE,CAAC;SACnB,CAAC;KACH,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEjB,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 BroadcastOptions,\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 if (process.env.NODE_ENV !== \"production\") {\n if (id == null) {\n throw new Error(\n \"RoomProvider id property is required. For more information: https://liveblocks.io/docs/errors/liveblocks-react/RoomProvider-id-property-is-required\"\n );\n }\n if (typeof id !== \"string\") {\n throw new Error(\"RoomProvider id property should be a string.\");\n }\n }\n\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 DO_NOT_USE_withoutConnecting: typeof window === \"undefined\",\n } as any);\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 */\nexport function 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>, options?: { addToHistory: boolean }) => 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 const unsubscribe = room.subscribe(\"my-presence\", onMyPresenceChange);\n\n return () => {\n unsubscribe();\n };\n }, [room]);\n\n const setPresence = React.useCallback(\n (overrides: Partial<T>, options?: { addToHistory: boolean }) =>\n room.updatePresence(overrides, options),\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 options?: { addToHistory: boolean }\n) => void {\n const room = useRoom();\n\n return React.useCallback(\n (overrides: Partial<T>, options?: { addToHistory: boolean }) => {\n room.updatePresence(overrides, options);\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 const unsubscribe = room.subscribe(\"others\", onOthersChange);\n\n return () => {\n unsubscribe();\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 (\n event: any,\n options: BroadcastOptions = { shouldQueueEventIfNotReady: false }\n ) => {\n room.broadcastEvent(event, options);\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 const unsubscribe = room.subscribe(\"error\", listener);\n\n return () => {\n unsubscribe();\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 const unsubscribe = room.subscribe(\"event\", listener);\n\n return () => {\n unsubscribe();\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 const unsubscribePresence = room.subscribe(\"my-presence\", onChange);\n const unsubscribeConnection = room.subscribe(\"connection\", onChange);\n\n return () => {\n unsubscribePresence();\n unsubscribeConnection();\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 let didCancel = false;\n\n async function fetchStorage() {\n const storage = await room.getStorage<TRoot>();\n if (!didCancel) {\n setState(storage.root);\n }\n }\n\n fetchStorage();\n\n return () => {\n didCancel = true;\n };\n }, [room]);\n\n return [root];\n}\n\n/**\n * Returns the LiveMap associated with the provided key. If the LiveMap does not exist, 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 *\n * @param key The storage key associated with the LiveMap\n * @param entries Optional entries that are used to create the LiveMap for the first time\n * @returns null while the storage is loading, otherwise, returns the LiveMap associated to the storage\n *\n * @example\n * const emptyMap = useMap(\"mapA\");\n * const mapWithItems = useMap(\"mapB\", [[\"keyA\", \"valueA\"], [\"keyB\", \"valueB\"]]);\n */\nexport function useMap<TKey extends string, TValue>(\n key: string,\n entries?: readonly (readonly [TKey, TValue])[] | null | undefined\n): LiveMap<TKey, TValue> | null {\n return useCrdt(key, new LiveMap(entries));\n}\n\n/**\n * Returns the LiveList associated with the provided key. If the LiveList does not exist, a new 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 *\n * @param key The storage key associated with the LiveList\n * @param items Optional items that are used to create the LiveList for the first time\n * @returns null while the storage is loading, otherwise, returns the LiveList associated to the storage\n *\n * @example\n * const emptyList = useList(\"listA\");\n * const listWithItems = useList(\"listB\", [\"a\", \"b\", \"c\"]);\n */\nexport function useList<TValue>(\n key: string,\n items?: TValue[] | undefined\n): LiveList<TValue> | null {\n return useCrdt<LiveList<TValue>>(key, new LiveList(items));\n}\n\n/**\n * Returns the LiveObject associated with the provided key. If the LiveObject does not exist, 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 *\n * @param key The storage key associated with the LiveObject\n * @param initialData Optional data that is used to create the LiveObject for the first time\n * @returns null while the storage is loading, otherwise, returns the LveObject associated to the storage\n *\n * @example\n * const object = useObject(\"obj\", {\n * company: \"Liveblocks\",\n * website: \"https://liveblocks.io\"\n * });\n */\nexport function useObject<TData>(\n key: string,\n initialData?: TData\n): LiveObject<TData> | null {\n return useCrdt(key, new LiveObject(initialData));\n}\n\n/**\n * Returns a function that undoes the last operation executed by the current client.\n * It does not impact operations made by other clients.\n */\nexport function useUndo() {\n return useRoom().history.undo;\n}\n\n/**\n * Returns a function that redoes the last operation executed by the current client.\n * It does not impact operations made by other clients.\n */\nexport function useRedo() {\n return useRoom().history.redo;\n}\n\n/**\n * Returns a function that batches modifications made during the given function.\n * All the modifications are sent to other clients in a single message.\n * All the modifications are merged in a single history item (undo/redo).\n * All the subscribers are called only after the batch is over.\n */\nexport function useBatch() {\n return useRoom().batch;\n}\n\n/**\n * Returns the room.history\n */\nexport function useHistory() {\n return useRoom().history;\n}\n\nfunction useCrdt<T>(key: string, initialCrdt: T): T | null {\n const room = useRoom();\n const [root] = useStorage();\n const [, setCount] = React.useState(0);\n\n React.useEffect(() => {\n if (root == null) {\n return;\n }\n\n let crdt: null | T = root.get(key);\n\n if (crdt == null) {\n crdt = initialCrdt;\n root.set(key, crdt);\n }\n\n function onChange() {\n setCount((x) => x + 1);\n }\n\n function onRootChange() {\n const newCrdt = root!.get(key);\n if (newCrdt !== crdt) {\n unsubscribeCrdt();\n crdt = newCrdt;\n unsubscribeCrdt = room.subscribe(\n crdt as any /* AbstractCrdt */,\n onChange\n );\n setCount((x) => x + 1);\n }\n }\n\n let unsubscribeCrdt = room.subscribe(\n crdt as any /* AbstractCrdt */,\n onChange\n );\n const unsubscribeRoot = room.subscribe(\n root as any /* AbstractCrdt */,\n onRootChange\n );\n\n setCount((x) => x + 1);\n\n return () => {\n unsubscribeRoot();\n unsubscribeCrdt();\n };\n }, [root, room]);\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,IAAM,aAAa,GAAGA,mBAAmB,CAAgB,IAAI,CAAC,CAAC;AAC/D,IAAM,WAAW,GAAGA,mBAAmB,CAAc,IAAI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L,eAAe,EAAE,CAAC;YAClB,eAAe,EAAE,CAAC;SACnB,CAAC;KACH,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEjB,aAAO,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,GAAG,oCAAK,IAAI,CAAC;AAChC;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/react",
3
- "version": "0.15.0-alpha.2",
3
+ "version": "0.15.0-alpha.4",
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.15.0-alpha.2",
26
+ "@liveblocks/client": "0.15.0-alpha.4",
27
27
  "react": "^16.14.0 || ^17"
28
28
  },
29
29
  "devDependencies": {