@liveblocks/react
Advanced tools
Comparing version 0.16.17 to 0.17.0-beta1
353
index.d.ts
/// <reference types="react" /> | ||
import { Client } from '@liveblocks/client'; | ||
export { Json, JsonObject } from '@liveblocks/client'; | ||
import * as React from 'react'; | ||
import * as _liveblocks_client_shared from '@liveblocks/client/shared'; | ||
import { | ||
Client, | ||
JsonObject, | ||
LsonObject, | ||
BaseUserMeta, | ||
Json, | ||
BroadcastOptions, | ||
History, | ||
Others, | ||
Room, | ||
User, | ||
LiveObject, | ||
Lson, | ||
LiveList, | ||
LiveMap, | ||
} from "@liveblocks/client"; | ||
export { Json, JsonObject } from "@liveblocks/client"; | ||
import * as React from "react"; | ||
import { Resolve, RoomInitializers } from "@liveblocks/client/internal"; | ||
declare type LiveblocksProviderProps = { | ||
children: React.ReactNode; | ||
client: Client; | ||
children: React.ReactNode; | ||
client: Client; | ||
}; | ||
/** | ||
* Makes the Liveblocks client available in the component hierarchy below. | ||
* | ||
* @deprecated LiveblocksProvider is no longer needed in your component tree if | ||
* you set up your Liveblocks context using `createRoomContext()`. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for | ||
* details. | ||
*/ | ||
declare function LiveblocksProvider(props: LiveblocksProviderProps): JSX.Element; | ||
declare function LiveblocksProvider( | ||
props: LiveblocksProviderProps | ||
): JSX.Element; | ||
/** | ||
@@ -21,43 +43,284 @@ * Returns the Client of the nearest LiveblocksProvider above in the React | ||
declare const RoomProvider: <TStorage>(props: { | ||
declare type RoomProviderProps< | ||
TPresence extends JsonObject, | ||
TStorage extends LsonObject | ||
> = Resolve< | ||
{ | ||
/** | ||
* The id of the room you want to connect to | ||
*/ | ||
id: string; | ||
children: React.ReactNode; | ||
initialPresence?: Record<string, unknown> | ((roomId: string) => Record<string, unknown>) | undefined; | ||
initialStorage?: TStorage | ((roomId: string) => TStorage) | undefined; | ||
defaultPresence?: (() => Record<string, unknown>) | undefined; | ||
defaultStorageRoot?: TStorage | undefined; | ||
}) => JSX.Element; | ||
declare const useRoom: () => _liveblocks_client_shared.R; | ||
declare const useMyPresence: <T extends Record<string, unknown>>() => [T, (overrides: Partial<T>, options?: { | ||
} & RoomInitializers<TPresence, TStorage> | ||
>; | ||
declare function createRoomContext< | ||
TPresence extends JsonObject, | ||
TStorage extends LsonObject = LsonObject, | ||
TUserMeta extends BaseUserMeta = BaseUserMeta, | ||
TEvent extends Json = never | ||
>( | ||
client: Client | ||
): { | ||
RoomProvider: (props: RoomProviderProps<TPresence, TStorage>) => JSX.Element; | ||
useBatch: () => (callback: () => void) => void; | ||
useBroadcastEvent: () => (event: TEvent, options?: BroadcastOptions) => void; | ||
useErrorListener: (callback: (err: Error) => void) => void; | ||
useEventListener: ( | ||
callback: (eventData: { connectionId: number; event: TEvent }) => void | ||
) => void; | ||
useHistory: () => History; | ||
useList: <TKey extends Extract<keyof TStorage, string>>( | ||
key: TKey | ||
) => TStorage[TKey] | null; | ||
useMap: <TKey_1 extends Extract<keyof TStorage, string>>( | ||
key: TKey_1 | ||
) => TStorage[TKey_1] | null; | ||
useMyPresence: () => [ | ||
TPresence, | ||
( | ||
overrides: Partial<TPresence>, | ||
options?: { | ||
addToHistory: boolean; | ||
} | ||
) => void | ||
]; | ||
useObject: <TKey_2 extends Extract<keyof TStorage, string>>( | ||
key: TKey_2 | ||
) => TStorage[TKey_2] | null; | ||
useOthers: () => Others<TPresence, TUserMeta>; | ||
useRedo: () => () => void; | ||
useRoom: () => Room<TPresence, TStorage, TUserMeta, TEvent>; | ||
useSelf: () => User<TPresence, TUserMeta> | null; | ||
useStorage: () => [root: LiveObject<TStorage> | null]; | ||
useUndo: () => () => void; | ||
useUpdateMyPresence: () => ( | ||
overrides: Partial<TPresence>, | ||
options?: { | ||
addToHistory: boolean; | ||
} | ||
) => void; | ||
deprecated_useList: { | ||
<TValue extends Lson>(key: string): LiveList<TValue> | null; | ||
<TValue_1 extends Lson>( | ||
key: string, | ||
items: TValue_1[] | ||
): LiveList<TValue_1> | null; | ||
}; | ||
deprecated_useMap: { | ||
<TKey_3 extends string, TValue_2 extends Lson>(key: string): LiveMap< | ||
TKey_3, | ||
TValue_2 | ||
> | null; | ||
<TKey_4 extends string, TValue_3 extends Lson>( | ||
key: string, | ||
entries: readonly (readonly [TKey_4, TValue_3])[] | null | ||
): LiveMap<TKey_4, TValue_3> | null; | ||
}; | ||
deprecated_useObject: { | ||
<TData extends LsonObject>(key: string): LiveObject<TData> | null; | ||
<TData_1 extends LsonObject>( | ||
key: string, | ||
initialData: TData_1 | ||
): LiveObject<TData_1> | null; | ||
}; | ||
}; | ||
/** | ||
* NOTE: | ||
* This file is AUTOGENERATED! | ||
* | ||
* Do not update it manually. | ||
*/ | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `RoomProvider` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function RoomProvider< | ||
TPresence extends JsonObject, | ||
TStorage extends LsonObject | ||
>(props: RoomProviderProps<TPresence, TStorage>): JSX.Element; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useBatch` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useBatch(): (callback: () => void) => void; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useBroadcastEvent` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useBroadcastEvent<TEvent extends Json>(): ( | ||
event: TEvent, | ||
options?: BroadcastOptions | ||
) => void; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useErrorListener` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useErrorListener(callback: (err: Error) => void): void; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useEventListener` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useEventListener<TEvent extends Json>( | ||
callback: (eventData: { connectionId: number; event: TEvent }) => void | ||
): void; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useHistory` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useHistory(): History; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useMyPresence` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useMyPresence<TPresence extends JsonObject>(): [ | ||
TPresence, | ||
( | ||
overrides: Partial<TPresence>, | ||
options?: { | ||
addToHistory: boolean; | ||
} | ||
) => void | ||
]; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useOthers` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useOthers< | ||
TPresence extends JsonObject, | ||
TUserMeta extends BaseUserMeta | ||
>(): Others<TPresence, TUserMeta>; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useRedo` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useRedo(): () => void; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useRoom` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useRoom< | ||
TPresence extends JsonObject, | ||
TStorage extends LsonObject, | ||
TUserMeta extends BaseUserMeta, | ||
TEvent extends Json | ||
>(): Room<TPresence, TStorage, TUserMeta, TEvent>; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useSelf` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useSelf< | ||
TPresence extends JsonObject, | ||
TUserMeta extends BaseUserMeta | ||
>(): User<TPresence, TUserMeta> | null; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useStorage` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useStorage<TStorage extends LsonObject>(): [ | ||
root: LiveObject<TStorage> | null | ||
]; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useUndo` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useUndo(): () => void; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useUpdateMyPresence` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useUpdateMyPresence<TPresence extends JsonObject>(): ( | ||
overrides: Partial<TPresence>, | ||
options?: { | ||
addToHistory: boolean; | ||
} | undefined) => void]; | ||
declare const useUpdateMyPresence: <T extends Record<string, unknown>>() => (overrides: Partial<T>, options?: { | ||
addToHistory: boolean; | ||
} | undefined) => void; | ||
declare const useOthers: <T extends Record<string, unknown>>() => _liveblocks_client_shared.O<T>; | ||
declare const useBroadcastEvent: () => (event: any, options?: _liveblocks_client_shared.B | undefined) => void; | ||
declare const useErrorListener: (callback: (err: Error) => void) => void; | ||
declare const useEventListener: <TEvent extends _liveblocks_client_shared.J>(callback: ({ connectionId, event, }: { | ||
connectionId: number; | ||
event: TEvent; | ||
}) => void) => void; | ||
declare const useSelf: <TPresence extends Record<string, unknown> = Record<string, unknown>>() => _liveblocks_client_shared.U<TPresence> | null; | ||
declare const useStorage: <TStorage extends Record<string, any>>() => [root: _liveblocks_client_shared.L<TStorage> | null]; | ||
declare const useMap: { | ||
<TKey extends string, TValue extends _liveblocks_client_shared.e>(key: string): _liveblocks_client_shared.b<TKey, TValue> | null; | ||
<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; | ||
} | ||
) => void; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useList` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useList<TValue extends Lson>( | ||
key: string | ||
): LiveList<TValue> | null; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useList` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useList<TValue extends Lson>( | ||
key: string, | ||
items: TValue[] | ||
): LiveList<TValue> | null; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useMap` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useMap<TKey extends string, TValue extends Lson>( | ||
key: string | ||
): LiveMap<TKey, TValue> | null; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useMap` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useMap<TKey extends string, TValue extends Lson>( | ||
key: string, | ||
entries: readonly (readonly [TKey, TValue])[] | null | ||
): LiveMap<TKey, TValue> | null; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useObject` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useObject<TData extends LsonObject>( | ||
key: string | ||
): LiveObject<TData> | null; | ||
/** | ||
* @deprecated Please use `createRoomContext()` instead of importing | ||
* `useObject` from `@liveblocks/react` directly. See | ||
* https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details. | ||
*/ | ||
declare function useObject<TData extends LsonObject>( | ||
key: string, | ||
initialData: TData | ||
): LiveObject<TData> | null; | ||
export { | ||
LiveblocksProvider, | ||
RoomProvider, | ||
createRoomContext, | ||
useBatch, | ||
useBroadcastEvent, | ||
useClient, | ||
useErrorListener, | ||
useEventListener, | ||
useHistory, | ||
useList, | ||
useMap, | ||
useMyPresence, | ||
useObject, | ||
useOthers, | ||
useRedo, | ||
useRoom, | ||
useSelf, | ||
useStorage, | ||
useUndo, | ||
useUpdateMyPresence, | ||
}; | ||
declare const useList: { | ||
<TValue extends _liveblocks_client_shared.e>(key: string): _liveblocks_client_shared.c<TValue> | null; | ||
<TValue_1 extends _liveblocks_client_shared.e>(key: string, items: TValue_1[]): _liveblocks_client_shared.c<TValue_1> | null; | ||
}; | ||
declare const useObject: { | ||
<TData extends _liveblocks_client_shared.f>(key: string): _liveblocks_client_shared.L<TData> | null; | ||
<TData_1 extends _liveblocks_client_shared.f>(key: string, initialData: TData_1): _liveblocks_client_shared.L<TData_1> | null; | ||
}; | ||
declare const useUndo: () => () => void; | ||
declare const useRedo: () => () => void; | ||
declare const useBatch: () => (callback: () => void) => void; | ||
declare const useHistory: () => _liveblocks_client_shared.H; | ||
export { LiveblocksProvider, RoomProvider, useBatch, useBroadcastEvent, useClient, useErrorListener, useEventListener, useHistory, useList, useMap, useMyPresence, useObject, useOthers, useRedo, useRoom, useSelf, useStorage, useUndo, useUpdateMyPresence }; |
829
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
}); | ||
var React = require("react"), client = require("@liveblocks/client"), internal = require("@liveblocks/client/internal"); | ||
Object.defineProperty(exports, "__esModule", { value: !0 }); | ||
var internal = require("@liveblocks/client/internal"), | ||
React = require("react"), | ||
client = require("@liveblocks/client"); | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
return e && Object.keys(e).forEach((function(k) { | ||
if ("default" !== k) { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: !0, | ||
get: function() { | ||
return e[k]; | ||
} | ||
}); | ||
} | ||
})), n.default = e, Object.freeze(n); | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
return ( | ||
e && | ||
Object.keys(e).forEach(function (k) { | ||
if ("default" !== k) { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty( | ||
n, | ||
k, | ||
d.get | ||
? d | ||
: { | ||
enumerable: !0, | ||
get: function () { | ||
return e[k]; | ||
}, | ||
} | ||
); | ||
} | ||
}), | ||
(n.default = e), | ||
Object.freeze(n) | ||
); | ||
} | ||
var React__namespace = _interopNamespace(React), ClientContext = React__namespace.createContext(null); | ||
var React__namespace = _interopNamespace(React), | ||
ClientContext = React__namespace.createContext(null); | ||
function useClient() { | ||
var client = React__namespace.useContext(ClientContext); | ||
if (null == client) throw new Error("LiveblocksProvider is missing from the react tree"); | ||
return client; | ||
var client = React__namespace.useContext(ClientContext); | ||
if (null == client) | ||
throw new Error("LiveblocksProvider is missing from the react tree"); | ||
return client; | ||
} | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg), value = info.value; | ||
} catch (error) { | ||
return void reject(error); | ||
} | ||
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw); | ||
try { | ||
var info = gen[key](arg), | ||
value = info.value; | ||
} catch (error) { | ||
return void reject(error); | ||
} | ||
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw); | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise((function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(void 0); | ||
})); | ||
}; | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(void 0); | ||
}); | ||
}; | ||
} | ||
function useRerender() { | ||
return React.useReducer((function(x) { | ||
return x + 1; | ||
}), 0)[1]; | ||
return React.useReducer(function (x) { | ||
return x + 1; | ||
}, 0)[1]; | ||
} | ||
var _create = function() { | ||
var RoomContext = React__namespace.createContext(null); | ||
function useRoom() { | ||
var room = React__namespace.useContext(RoomContext); | ||
if (null == room) throw new Error("RoomProvider is missing from the react tree"); | ||
return room; | ||
} | ||
function useStorage() { | ||
var room = useRoom(), _React$useState2 = React__namespace.useState(null), root = _React$useState2[0], setState = _React$useState2[1]; | ||
return React__namespace.useEffect((function() { | ||
var didCancel = !1; | ||
function _fetchStorage() { | ||
return (_fetchStorage = _asyncToGenerator(regeneratorRuntime.mark((function _callee() { | ||
var storage; | ||
return regeneratorRuntime.wrap((function(_context) { | ||
for (;;) switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.next = 2, room.getStorage(); | ||
case 2: | ||
storage = _context.sent, didCancel || setState(storage.root); | ||
case 4: | ||
case "end": | ||
return _context.stop(); | ||
function createRoomContext(client$1) { | ||
var useClient$1; | ||
useClient$1 = | ||
"__legacy" !== client$1 | ||
? function () { | ||
return client$1; | ||
} | ||
: useClient; | ||
var RoomContext = React__namespace.createContext(null); | ||
function useRoom() { | ||
var room = React__namespace.useContext(RoomContext); | ||
if (null == room) | ||
throw new Error("RoomProvider is missing from the react tree"); | ||
return room; | ||
} | ||
function useStorage() { | ||
var room = useRoom(), | ||
_React$useState2 = React__namespace.useState(null), | ||
root = _React$useState2[0], | ||
setState = _React$useState2[1]; | ||
return ( | ||
React__namespace.useEffect( | ||
function () { | ||
var didCancel = !1; | ||
function _fetchStorage() { | ||
return (_fetchStorage = _asyncToGenerator( | ||
regeneratorRuntime.mark(function _callee() { | ||
var storage; | ||
return regeneratorRuntime.wrap(function (_context) { | ||
for (;;) | ||
switch ((_context.prev = _context.next)) { | ||
case 0: | ||
return (_context.next = 2), room.getStorage(); | ||
case 2: | ||
(storage = _context.sent), | ||
didCancel || setState(storage.root); | ||
case 4: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee); | ||
}) | ||
)).apply(this, arguments); | ||
} | ||
return ( | ||
(function () { | ||
_fetchStorage.apply(this, arguments); | ||
})(), | ||
function () { | ||
didCancel = !0; | ||
} | ||
); | ||
}, | ||
[room] | ||
), | ||
[root] | ||
); | ||
} | ||
function deprecated_useMap(key, entries) { | ||
internal.errorIf( | ||
entries, | ||
"Support for initializing entries in useMap() directly will be removed in @liveblocks/react 0.18.\n\nInstead, please initialize this data where you set up your RoomProvider:\n\n const initialStorage = () => ({\n " + | ||
JSON.stringify(key) + | ||
": new LiveMap(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details." | ||
); | ||
var value = useStorageValue( | ||
key, | ||
new client.LiveMap(null != entries ? entries : void 0) | ||
); | ||
return "ok" === value.status | ||
? value.value | ||
: (internal.errorIf( | ||
"notfound" === value.status, | ||
"Key " + | ||
JSON.stringify(key) + | ||
' was not found in Storage. Starting with 0.18, useMap() will no longer automatically create this key.\n\nInstead, please initialize your storage where you set up your RoomProvider:\n\n import { LiveMap } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + | ||
JSON.stringify(key) + | ||
": new LiveMap(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details." | ||
), | ||
null); | ||
} | ||
function deprecated_useList(key, items) { | ||
internal.errorIf( | ||
items, | ||
'Support for initializing items in useList() directly will be removed in @liveblocks/react 0.18.\n\nInstead, please initialize this data where you set up your RoomProvider:\n\n import { LiveList } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + | ||
JSON.stringify(key) + | ||
": new LiveList(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details." | ||
); | ||
var value = useStorageValue(key, new client.LiveList(items)); | ||
return "ok" === value.status | ||
? value.value | ||
: (internal.errorIf( | ||
"notfound" === value.status, | ||
"Key " + | ||
JSON.stringify(key) + | ||
' was not found in Storage. Starting with 0.18, useList() will no longer automatically create this key.\n\nInstead, please initialize your storage where you set up your RoomProvider:\n\n import { LiveList } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + | ||
JSON.stringify(key) + | ||
": new LiveList(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details." | ||
), | ||
null); | ||
} | ||
function deprecated_useObject(key, initialData) { | ||
internal.errorIf( | ||
initialData, | ||
'Support for initializing data in useObject() directly will be removed in @liveblocks/react 0.18.\n\nInstead, please initialize this data where you set up your RoomProvider:\n\n import { LiveObject } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + | ||
JSON.stringify(key) + | ||
": new LiveObject(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details." | ||
); | ||
var value = useStorageValue(key, new client.LiveObject(initialData)); | ||
return "ok" === value.status | ||
? value.value | ||
: (internal.errorIf( | ||
"notfound" === value.status, | ||
"Key " + | ||
JSON.stringify(key) + | ||
' was not found in Storage. Starting with 0.18, useObject() will no longer automatically create this key.\n\nInstead, please initialize your storage where you set up your RoomProvider:\n\n import { LiveObject } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + | ||
JSON.stringify(key) + | ||
": new LiveObject(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details." | ||
), | ||
null); | ||
} | ||
function useHistory() { | ||
return useRoom().history; | ||
} | ||
function useStorageValue(key, initialValue) { | ||
var room = useRoom(), | ||
root = useStorage()[0], | ||
rerender = useRerender(); | ||
if ( | ||
(React__namespace.useEffect( | ||
function () { | ||
if (null != root) { | ||
var liveValue = root.get(key); | ||
null == liveValue && | ||
((liveValue = initialValue), root.set(key, liveValue)); | ||
var unsubscribeCrdt = room.subscribe(liveValue, rerender), | ||
unsubscribeRoot = room.subscribe(root, function () { | ||
var newCrdt = root.get(key); | ||
newCrdt !== liveValue && | ||
(unsubscribeCrdt(), | ||
(liveValue = newCrdt), | ||
(unsubscribeCrdt = room.subscribe(liveValue, rerender)), | ||
rerender()); | ||
}); | ||
return ( | ||
rerender(), | ||
function () { | ||
unsubscribeRoot(), unsubscribeCrdt(); | ||
} | ||
); | ||
} | ||
}, | ||
[root, room] | ||
), | ||
null == root) | ||
) | ||
return { status: "loading" }; | ||
var value = root.get(key); | ||
return null == value | ||
? { status: "notfound" } | ||
: { status: "ok", value: value }; | ||
} | ||
return { | ||
RoomProvider: function (props) { | ||
var roomId = props.id, | ||
initialPresence = props.initialPresence, | ||
initialStorage = props.initialStorage, | ||
defaultPresence = props.defaultPresence, | ||
defaultStorageRoot = props.defaultStorageRoot; | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (null == roomId) | ||
throw new Error( | ||
"RoomProvider id property is required. For more information: https://liveblocks.io/docs/errors/liveblocks-react/RoomProvider-id-property-is-required" | ||
); | ||
if ("string" != typeof roomId) | ||
throw new Error("RoomProvider id property should be a string."); | ||
} | ||
}), _callee); | ||
})))).apply(this, arguments); | ||
} | ||
return function() { | ||
_fetchStorage.apply(this, arguments); | ||
}(), function() { | ||
didCancel = !0; | ||
}; | ||
}), [ room ]), [ root ]; | ||
} | ||
function useHistory() { | ||
return useRoom().history; | ||
} | ||
function useStorageValue(key, initialValue) { | ||
var room = useRoom(), root = useStorage()[0], rerender = useRerender(); | ||
if (React__namespace.useEffect((function() { | ||
if (null != root) { | ||
var liveValue = root.get(key); | ||
null == liveValue && (liveValue = initialValue, root.set(key, liveValue)); | ||
var unsubscribeCrdt = room.subscribe(liveValue, rerender), unsubscribeRoot = room.subscribe(root, (function() { | ||
var newCrdt = root.get(key); | ||
newCrdt !== liveValue && (unsubscribeCrdt(), liveValue = newCrdt, unsubscribeCrdt = room.subscribe(liveValue, rerender), | ||
rerender()); | ||
})); | ||
return rerender(), function() { | ||
unsubscribeRoot(), unsubscribeCrdt(); | ||
}; | ||
} | ||
}), [ root, room ]), null == root) return { | ||
status: "loading" | ||
internal.errorIf( | ||
defaultPresence, | ||
"RoomProvider's `defaultPresence` prop will be removed in @liveblocks/react 0.18. Please use `initialPresence` instead. For more info, see https://bit.ly/3Niy5aP" | ||
), | ||
internal.errorIf( | ||
defaultStorageRoot, | ||
"RoomProvider's `defaultStorageRoot` prop will be removed in @liveblocks/react 0.18. Please use `initialStorage` instead. For more info, see https://bit.ly/3Niy5aP" | ||
); | ||
var _client = useClient$1(), | ||
_React$useState = React__namespace.useState(function () { | ||
return _client.enter(roomId, { | ||
initialPresence: initialPresence, | ||
initialStorage: initialStorage, | ||
defaultPresence: defaultPresence, | ||
defaultStorageRoot: defaultStorageRoot, | ||
DO_NOT_USE_withoutConnecting: "undefined" == typeof window, | ||
}); | ||
}), | ||
room = _React$useState[0], | ||
setRoom = _React$useState[1]; | ||
return ( | ||
React__namespace.useEffect( | ||
function () { | ||
return ( | ||
setRoom( | ||
_client.enter(roomId, { | ||
initialPresence: initialPresence, | ||
initialStorage: initialStorage, | ||
defaultPresence: defaultPresence, | ||
defaultStorageRoot: defaultStorageRoot, | ||
DO_NOT_USE_withoutConnecting: "undefined" == typeof window, | ||
}) | ||
), | ||
function () { | ||
_client.leave(roomId); | ||
} | ||
); | ||
}, | ||
[_client, roomId] | ||
), | ||
React__namespace.createElement( | ||
RoomContext.Provider, | ||
{ value: room }, | ||
props.children | ||
) | ||
); | ||
}, | ||
useBatch: function () { | ||
return useRoom().batch; | ||
}, | ||
useBroadcastEvent: function () { | ||
var room = useRoom(); | ||
return React__namespace.useCallback( | ||
function (event, options) { | ||
void 0 === options && (options = { shouldQueueEventIfNotReady: !1 }), | ||
room.broadcastEvent(event, options); | ||
}, | ||
[room] | ||
); | ||
}, | ||
useErrorListener: function (callback) { | ||
var room = useRoom(), | ||
savedCallback = React__namespace.useRef(callback); | ||
React__namespace.useEffect(function () { | ||
savedCallback.current = callback; | ||
}), | ||
React__namespace.useEffect( | ||
function () { | ||
var unsubscribe = room.subscribe("error", function (e) { | ||
return savedCallback.current(e); | ||
}); | ||
return function () { | ||
unsubscribe(); | ||
}; | ||
}, | ||
[room] | ||
); | ||
}, | ||
useEventListener: function (callback) { | ||
var room = useRoom(), | ||
savedCallback = React__namespace.useRef(callback); | ||
React__namespace.useEffect(function () { | ||
savedCallback.current = callback; | ||
}), | ||
React__namespace.useEffect( | ||
function () { | ||
var unsubscribe = room.subscribe("event", function (eventData) { | ||
savedCallback.current(eventData); | ||
}); | ||
return function () { | ||
unsubscribe(); | ||
}; | ||
}, | ||
[room] | ||
); | ||
}, | ||
useHistory: useHistory, | ||
useList: function (key) { | ||
return deprecated_useList(key); | ||
}, | ||
useMap: function (key) { | ||
return deprecated_useMap(key); | ||
}, | ||
useMyPresence: function () { | ||
var room = useRoom(), | ||
presence = room.getPresence(), | ||
rerender = useRerender(); | ||
return ( | ||
React__namespace.useEffect( | ||
function () { | ||
var unsubscribe = room.subscribe("my-presence", rerender); | ||
return function () { | ||
unsubscribe(); | ||
}; | ||
}, | ||
[room] | ||
), | ||
[ | ||
presence, | ||
React__namespace.useCallback( | ||
function (overrides, options) { | ||
return room.updatePresence(overrides, options); | ||
}, | ||
[room] | ||
), | ||
] | ||
); | ||
}, | ||
useObject: function (key) { | ||
return deprecated_useObject(key); | ||
}, | ||
useOthers: function () { | ||
var room = useRoom(), | ||
rerender = useRerender(); | ||
return ( | ||
React__namespace.useEffect( | ||
function () { | ||
var unsubscribe = room.subscribe("others", rerender); | ||
return function () { | ||
unsubscribe(); | ||
}; | ||
}, | ||
[room] | ||
), | ||
room.getOthers() | ||
); | ||
}, | ||
useRedo: function () { | ||
return useHistory().redo; | ||
}, | ||
useRoom: useRoom, | ||
useSelf: function () { | ||
var room = useRoom(), | ||
rerender = useRerender(); | ||
return ( | ||
React__namespace.useEffect( | ||
function () { | ||
var unsubscribePresence = room.subscribe("my-presence", rerender), | ||
unsubscribeConnection = room.subscribe("connection", rerender); | ||
return function () { | ||
unsubscribePresence(), unsubscribeConnection(); | ||
}; | ||
}, | ||
[room] | ||
), | ||
room.getSelf() | ||
); | ||
}, | ||
useStorage: useStorage, | ||
useUndo: function () { | ||
return useHistory().undo; | ||
}, | ||
useUpdateMyPresence: function () { | ||
var room = useRoom(); | ||
return React__namespace.useCallback( | ||
function (overrides, options) { | ||
room.updatePresence(overrides, options); | ||
}, | ||
[room] | ||
); | ||
}, | ||
deprecated_useList: deprecated_useList, | ||
deprecated_useMap: deprecated_useMap, | ||
deprecated_useObject: deprecated_useObject, | ||
}; | ||
var value = root.get(key); | ||
return null == value ? { | ||
status: "notfound" | ||
} : { | ||
status: "ok", | ||
value: value | ||
}; | ||
} | ||
return { | ||
RoomProvider: function(props) { | ||
var roomId = props.id, initialPresence = props.initialPresence, initialStorage = props.initialStorage, defaultPresence = props.defaultPresence, defaultStorageRoot = props.defaultStorageRoot; | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (null == roomId) throw new Error("RoomProvider id property is required. For more information: https://liveblocks.io/docs/errors/liveblocks-react/RoomProvider-id-property-is-required"); | ||
if ("string" != typeof roomId) throw new Error("RoomProvider id property should be a string."); | ||
} | ||
internal.deprecateIf(defaultPresence, "RoomProvider's `defaultPresence` prop will be removed in @liveblocks/react 0.18. Please use `initialPresence` instead. For more info, see https://bit.ly/3Niy5aP", "defaultPresence"), | ||
internal.deprecateIf(defaultStorageRoot, "RoomProvider's `defaultStorageRoot` prop will be removed in @liveblocks/react 0.18. Please use `initialStorage` instead. For more info, see https://bit.ly/3Niy5aP", "defaultStorageRoot"); | ||
var client = useClient(), _React$useState = React__namespace.useState((function() { | ||
return client.enter(roomId, { | ||
initialPresence: initialPresence, | ||
initialStorage: initialStorage, | ||
defaultPresence: defaultPresence, | ||
defaultStorageRoot: defaultStorageRoot, | ||
DO_NOT_USE_withoutConnecting: "undefined" == typeof window | ||
}); | ||
})), room = _React$useState[0], setRoom = _React$useState[1]; | ||
return React__namespace.useEffect((function() { | ||
return setRoom(client.enter(roomId, { | ||
initialPresence: initialPresence, | ||
initialStorage: initialStorage, | ||
defaultPresence: defaultPresence, | ||
defaultStorageRoot: defaultStorageRoot, | ||
DO_NOT_USE_withoutConnecting: "undefined" == typeof window | ||
})), function() { | ||
client.leave(roomId); | ||
}; | ||
}), [ client, roomId ]), React__namespace.createElement(RoomContext.Provider, { | ||
value: room | ||
}, props.children); | ||
}, | ||
useBatch: function() { | ||
return useRoom().batch; | ||
}, | ||
useBroadcastEvent: function() { | ||
var room = useRoom(); | ||
return React__namespace.useCallback((function(event, options) { | ||
void 0 === options && (options = { | ||
shouldQueueEventIfNotReady: !1 | ||
}), room.broadcastEvent(event, options); | ||
}), [ room ]); | ||
}, | ||
useErrorListener: function(callback) { | ||
var room = useRoom(), savedCallback = React__namespace.useRef(callback); | ||
React__namespace.useEffect((function() { | ||
savedCallback.current = callback; | ||
})), React__namespace.useEffect((function() { | ||
var unsubscribe = room.subscribe("error", (function(e) { | ||
return savedCallback.current(e); | ||
})); | ||
return function() { | ||
unsubscribe(); | ||
}; | ||
}), [ room ]); | ||
}, | ||
useEventListener: function(callback) { | ||
var room = useRoom(), savedCallback = React__namespace.useRef(callback); | ||
React__namespace.useEffect((function() { | ||
savedCallback.current = callback; | ||
})), React__namespace.useEffect((function() { | ||
var unsubscribe = room.subscribe("event", (function(e) { | ||
return savedCallback.current(e); | ||
})); | ||
return function() { | ||
unsubscribe(); | ||
}; | ||
}), [ room ]); | ||
}, | ||
useHistory: useHistory, | ||
useList: function(key, items) { | ||
internal.deprecateIf(items, 'Support for initializing items in useList() directly will be removed in @liveblocks/react 0.18.\n\nInstead, please initialize this data where you set up your RoomProvider:\n\n import { LiveList } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + JSON.stringify(key) + ": new LiveList(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details."); | ||
var value = useStorageValue(key, new client.LiveList(items)); | ||
return "ok" === value.status ? value.value : (internal.deprecateIf("notfound" === value.status, "Key " + JSON.stringify(key) + ' was not found in Storage. Starting with 0.18, useList() will no longer automatically create this key.\n\nInstead, please initialize your storage where you set up your RoomProvider:\n\n import { LiveList } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + JSON.stringify(key) + ": new LiveList(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details."), | ||
null); | ||
}, | ||
useMap: function(key, entries) { | ||
internal.deprecateIf(entries, "Support for initializing entries in useMap() directly will be removed in @liveblocks/react 0.18.\n\nInstead, please initialize this data where you set up your RoomProvider:\n\n const initialStorage = () => ({\n " + JSON.stringify(key) + ": new LiveMap(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details."); | ||
var value = useStorageValue(key, new client.LiveMap(null != entries ? entries : void 0)); | ||
return "ok" === value.status ? value.value : (internal.deprecateIf("notfound" === value.status, "Key " + JSON.stringify(key) + ' was not found in Storage. Starting with 0.18, useMap() will no longer automatically create this key.\n\nInstead, please initialize your storage where you set up your RoomProvider:\n\n import { LiveMap } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + JSON.stringify(key) + ": new LiveMap(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details."), | ||
null); | ||
}, | ||
useMyPresence: function() { | ||
var room = useRoom(), presence = room.getPresence(), rerender = useRerender(); | ||
return React__namespace.useEffect((function() { | ||
var unsubscribe = room.subscribe("my-presence", rerender); | ||
return function() { | ||
unsubscribe(); | ||
}; | ||
}), [ room ]), [ presence, React__namespace.useCallback((function(overrides, options) { | ||
return room.updatePresence(overrides, options); | ||
}), [ room ]) ]; | ||
}, | ||
useObject: function(key, initialData) { | ||
internal.deprecateIf(initialData, 'Support for initializing data in useObject() directly will be removed in @liveblocks/react 0.18.\n\nInstead, please initialize this data where you set up your RoomProvider:\n\n import { LiveObject } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + JSON.stringify(key) + ": new LiveObject(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details."); | ||
var value = useStorageValue(key, new client.LiveObject(initialData)); | ||
return "ok" === value.status ? value.value : (internal.deprecateIf("notfound" === value.status, "Key " + JSON.stringify(key) + ' was not found in Storage. Starting with 0.18, useObject() will no longer automatically create this key.\n\nInstead, please initialize your storage where you set up your RoomProvider:\n\n import { LiveObject } from "@liveblocks/client";\n\n const initialStorage = () => ({\n ' + JSON.stringify(key) + ": new LiveObject(...),\n ...\n });\n\n <RoomProvider initialStorage={initialStorage}>\n ...\n </RoomProvider>\n\nPlease see https://bit.ly/3Niy5aP for details."), | ||
null); | ||
}, | ||
useOthers: function() { | ||
var room = useRoom(), rerender = useRerender(); | ||
return React__namespace.useEffect((function() { | ||
var unsubscribe = room.subscribe("others", rerender); | ||
return function() { | ||
unsubscribe(); | ||
}; | ||
}), [ room ]), room.getOthers(); | ||
}, | ||
useRedo: function() { | ||
return useHistory().redo; | ||
}, | ||
useRoom: useRoom, | ||
useSelf: function() { | ||
var room = useRoom(), rerender = useRerender(); | ||
return React__namespace.useEffect((function() { | ||
var unsubscribePresence = room.subscribe("my-presence", rerender), unsubscribeConnection = room.subscribe("connection", rerender); | ||
return function() { | ||
unsubscribePresence(), unsubscribeConnection(); | ||
}; | ||
}), [ room ]), room.getSelf(); | ||
}, | ||
useStorage: useStorage, | ||
useUndo: function() { | ||
return useHistory().undo; | ||
}, | ||
useUpdateMyPresence: function() { | ||
var room = useRoom(); | ||
return React__namespace.useCallback((function(overrides, options) { | ||
room.updatePresence(overrides, options); | ||
}), [ room ]); | ||
} | ||
}; | ||
}(), RoomProvider = _create.RoomProvider, useRoom = _create.useRoom, useMyPresence = _create.useMyPresence, useUpdateMyPresence = _create.useUpdateMyPresence, useOthers = _create.useOthers, useBroadcastEvent = _create.useBroadcastEvent, useErrorListener = _create.useErrorListener, useEventListener = _create.useEventListener, useSelf = _create.useSelf, useStorage = _create.useStorage, useMap = _create.useMap, useList = _create.useList, useObject = _create.useObject, useUndo = _create.useUndo, useRedo = _create.useRedo, useBatch = _create.useBatch, useHistory = _create.useHistory; | ||
exports.LiveblocksProvider = function(props) { | ||
return React__namespace.createElement(ClientContext.Provider, { | ||
value: props.client | ||
}, props.children); | ||
}, exports.RoomProvider = RoomProvider, exports.useBatch = useBatch, exports.useBroadcastEvent = useBroadcastEvent, | ||
exports.useClient = useClient, exports.useErrorListener = useErrorListener, exports.useEventListener = useEventListener, | ||
exports.useHistory = useHistory, exports.useList = useList, exports.useMap = useMap, | ||
exports.useMyPresence = useMyPresence, exports.useObject = useObject, exports.useOthers = useOthers, | ||
exports.useRedo = useRedo, exports.useRoom = useRoom, exports.useSelf = useSelf, | ||
exports.useStorage = useStorage, exports.useUndo = useUndo, exports.useUpdateMyPresence = useUpdateMyPresence; | ||
} | ||
var _hooks = createRoomContext("__legacy"); | ||
(exports.LiveblocksProvider = function (props) { | ||
return ( | ||
internal.deprecate( | ||
"LiveblocksProvider is no longer needed in your component tree if you set up your Liveblocks context using `createRoomContext()`. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
React__namespace.createElement( | ||
ClientContext.Provider, | ||
{ value: props.client }, | ||
props.children | ||
) | ||
); | ||
}), | ||
(exports.RoomProvider = function (props) { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `RoomProvider` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.RoomProvider(props) | ||
); | ||
}), | ||
(exports.createRoomContext = createRoomContext), | ||
(exports.useBatch = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useBatch` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useBatch() | ||
); | ||
}), | ||
(exports.useBroadcastEvent = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useBroadcastEvent` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useBroadcastEvent() | ||
); | ||
}), | ||
(exports.useClient = useClient), | ||
(exports.useErrorListener = function (callback) { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useErrorListener` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useErrorListener(callback) | ||
); | ||
}), | ||
(exports.useEventListener = function (callback) { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useEventListener` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useEventListener(callback) | ||
); | ||
}), | ||
(exports.useHistory = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useHistory` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useHistory() | ||
); | ||
}), | ||
(exports.useList = function (key, items) { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useList` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.deprecated_useList(key, items) | ||
); | ||
}), | ||
(exports.useMap = function (key, entries) { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useMap` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.deprecated_useMap(key, entries) | ||
); | ||
}), | ||
(exports.useMyPresence = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useMyPresence` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useMyPresence() | ||
); | ||
}), | ||
(exports.useObject = function (key, initialData) { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useObject` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.deprecated_useObject(key, initialData) | ||
); | ||
}), | ||
(exports.useOthers = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useOthers` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useOthers() | ||
); | ||
}), | ||
(exports.useRedo = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useRedo` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useRedo() | ||
); | ||
}), | ||
(exports.useRoom = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useRoom` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useRoom() | ||
); | ||
}), | ||
(exports.useSelf = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useSelf` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useSelf() | ||
); | ||
}), | ||
(exports.useStorage = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useStorage` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useStorage() | ||
); | ||
}), | ||
(exports.useUndo = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useUndo` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useUndo() | ||
); | ||
}), | ||
(exports.useUpdateMyPresence = function () { | ||
return ( | ||
internal.deprecate( | ||
"Please use `createRoomContext()` instead of importing `useUpdateMyPresence` from `@liveblocks/react` directly. See https://liveblocks.io/docs/guides/upgrading#upgrading-from-0-16-to-0-17 for details." | ||
), | ||
_hooks.useUpdateMyPresence() | ||
); | ||
}); |
{ | ||
"name": "@liveblocks/react", | ||
"version": "0.16.17", | ||
"version": "0.17.0-beta1", | ||
"description": "A set of React hooks and providers to use Liveblocks declaratively.", | ||
@@ -26,8 +26,9 @@ "main": "./index.js", | ||
"lint": "eslint src/", | ||
"test": "jest --watch", | ||
"test-ci": "jest" | ||
"test": "jest --watch --silent --verbose", | ||
"test-ci": "jest --silent --verbose", | ||
"codegen": "tsc scripts/generate-compat.ts && node scripts/generate-compat.js && eslint --fix src/compat.tsx && prettier --write src/compat.tsx" | ||
}, | ||
"license": "Apache-2.0", | ||
"peerDependencies": { | ||
"@liveblocks/client": "0.16.17", | ||
"@liveblocks/client": "0.17.0-beta1", | ||
"react": "^16.14.0 || ^17 || ^18" | ||
@@ -46,7 +47,5 @@ }, | ||
"@testing-library/react": "^13.1.1", | ||
"@types/jest": "^26.0.20", | ||
"@types/react": "^16.14.0", | ||
"@types/react-dom": "^17.0.14", | ||
"@typescript-eslint/eslint-plugin": "^5.18.0", | ||
"@typescript-eslint/parser": "^5.18.0", | ||
"@types/jest": "^26.0.24", | ||
"@typescript-eslint/eslint-plugin": "^5.26.0", | ||
"@typescript-eslint/parser": "^5.26.0", | ||
"eslint": "^8.12.0", | ||
@@ -60,5 +59,7 @@ "eslint-plugin-import": "^2.26.0", | ||
"rollup-plugin-command": "^1.1.3", | ||
"rollup-plugin-dts": "^4.2.0", | ||
"rollup-plugin-dts": "^4.2.2", | ||
"rollup-plugin-prettier": "^2.2.2", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.1.5", | ||
"ts-node": "^10.8.1", | ||
"typescript": "^4.7.3", | ||
"whatwg-fetch": "^3.6.2" | ||
@@ -65,0 +66,0 @@ }, |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
55343
1433
1