@liveblocks/react 0.17.8 → 0.17.9
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/.built-by-link-script +1 -0
- package/index.d.ts +251 -373
- package/index.js +602 -599
- package/index.mjs +23 -573
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,636 +1,639 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
(
|
|
29
|
-
Object.freeze(n)
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/client.tsx
|
|
23
|
+
var _internal = require('@liveblocks/client/internal');
|
|
24
|
+
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
|
|
25
|
+
var ClientContext = React.createContext(null);
|
|
26
|
+
function LiveblocksProvider(props) {
|
|
27
|
+
_internal.deprecate.call(void 0,
|
|
28
|
+
"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."
|
|
30
29
|
);
|
|
30
|
+
return /* @__PURE__ */ React.createElement(ClientContext.Provider, {
|
|
31
|
+
value: props.client
|
|
32
|
+
}, props.children);
|
|
31
33
|
}
|
|
32
|
-
var React__namespace = _interopNamespace(React),
|
|
33
|
-
ClientContext = React__namespace.createContext(null);
|
|
34
34
|
function useClient() {
|
|
35
|
-
|
|
36
|
-
if (
|
|
35
|
+
const client = React.useContext(ClientContext);
|
|
36
|
+
if (client == null) {
|
|
37
37
|
throw new Error("LiveblocksProvider is missing from the react tree");
|
|
38
|
-
return client;
|
|
39
|
-
}
|
|
40
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
41
|
-
try {
|
|
42
|
-
var info = gen[key](arg),
|
|
43
|
-
value = info.value;
|
|
44
|
-
} catch (error) {
|
|
45
|
-
return void reject(error);
|
|
46
38
|
}
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
function _asyncToGenerator(fn) {
|
|
50
|
-
return function () {
|
|
51
|
-
var self = this,
|
|
52
|
-
args = arguments;
|
|
53
|
-
return new Promise(function (resolve, reject) {
|
|
54
|
-
var gen = fn.apply(self, args);
|
|
55
|
-
function _next(value) {
|
|
56
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
57
|
-
}
|
|
58
|
-
function _throw(err) {
|
|
59
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
60
|
-
}
|
|
61
|
-
_next(void 0);
|
|
62
|
-
});
|
|
63
|
-
};
|
|
39
|
+
return client;
|
|
64
40
|
}
|
|
41
|
+
|
|
42
|
+
// src/factory.tsx
|
|
43
|
+
var _client2 = require('@liveblocks/client');
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// src/hooks.ts
|
|
48
|
+
|
|
65
49
|
function useRerender() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
const [, update] = _react.useReducer.call(void 0,
|
|
51
|
+
(x) => x + 1,
|
|
52
|
+
0
|
|
53
|
+
);
|
|
54
|
+
return update;
|
|
69
55
|
}
|
|
56
|
+
|
|
57
|
+
// src/factory.tsx
|
|
70
58
|
function useInitial(value) {
|
|
71
|
-
return
|
|
59
|
+
return React2.useRef(value).current;
|
|
72
60
|
}
|
|
73
|
-
function createRoomContext(client
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
61
|
+
function createRoomContext(client) {
|
|
62
|
+
let useClient2;
|
|
63
|
+
if (client !== "__legacy") {
|
|
64
|
+
useClient2 = () => client;
|
|
65
|
+
} else {
|
|
66
|
+
useClient2 = useClient;
|
|
67
|
+
}
|
|
68
|
+
const RoomContext = React2.createContext(null);
|
|
69
|
+
function RoomProvider2(props) {
|
|
70
|
+
const {
|
|
71
|
+
id: roomId,
|
|
72
|
+
initialPresence,
|
|
73
|
+
initialStorage,
|
|
74
|
+
defaultPresence,
|
|
75
|
+
defaultStorageRoot
|
|
76
|
+
} = props;
|
|
77
|
+
if (process.env.NODE_ENV !== "production") {
|
|
78
|
+
if (roomId == null) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
"RoomProvider id property is required. For more information: https://liveblocks.io/docs/errors/liveblocks-react/RoomProvider-id-property-is-required"
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
if (typeof roomId !== "string") {
|
|
84
|
+
throw new Error("RoomProvider id property should be a string.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
_internal.errorIf.call(void 0,
|
|
88
|
+
defaultPresence,
|
|
89
|
+
"RoomProvider's `defaultPresence` prop will be removed in @liveblocks/react 0.18. Please use `initialPresence` instead. For more info, see https://bit.ly/3Niy5aP"
|
|
90
|
+
);
|
|
91
|
+
_internal.errorIf.call(void 0,
|
|
92
|
+
defaultStorageRoot,
|
|
93
|
+
"RoomProvider's `defaultStorageRoot` prop will be removed in @liveblocks/react 0.18. Please use `initialStorage` instead. For more info, see https://bit.ly/3Niy5aP"
|
|
94
|
+
);
|
|
95
|
+
const _client = useClient2();
|
|
96
|
+
const frozen = useInitial({
|
|
97
|
+
initialPresence,
|
|
98
|
+
initialStorage,
|
|
99
|
+
defaultPresence,
|
|
100
|
+
defaultStorageRoot
|
|
101
|
+
});
|
|
102
|
+
const [room, setRoom] = React2.useState(
|
|
103
|
+
() => _client.enter(roomId, {
|
|
104
|
+
initialPresence,
|
|
105
|
+
initialStorage,
|
|
106
|
+
defaultPresence,
|
|
107
|
+
defaultStorageRoot,
|
|
108
|
+
DO_NOT_USE_withoutConnecting: typeof window === "undefined"
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
React2.useEffect(() => {
|
|
112
|
+
setRoom(
|
|
113
|
+
_client.enter(roomId, {
|
|
114
|
+
initialPresence: frozen.initialPresence,
|
|
115
|
+
initialStorage: frozen.initialStorage,
|
|
116
|
+
defaultPresence: frozen.defaultPresence,
|
|
117
|
+
defaultStorageRoot: frozen.defaultStorageRoot,
|
|
118
|
+
DO_NOT_USE_withoutConnecting: typeof window === "undefined"
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
return () => {
|
|
122
|
+
_client.leave(roomId);
|
|
123
|
+
};
|
|
124
|
+
}, [_client, roomId, frozen]);
|
|
125
|
+
return /* @__PURE__ */ React2.createElement(RoomContext.Provider, {
|
|
126
|
+
value: room
|
|
127
|
+
}, props.children);
|
|
128
|
+
}
|
|
129
|
+
function useRoom2() {
|
|
130
|
+
const room = React2.useContext(RoomContext);
|
|
131
|
+
if (room == null) {
|
|
85
132
|
throw new Error("RoomProvider is missing from the react tree");
|
|
133
|
+
}
|
|
86
134
|
return room;
|
|
87
135
|
}
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return _context.stop();
|
|
112
|
-
}
|
|
113
|
-
}, _callee);
|
|
114
|
-
})
|
|
115
|
-
)).apply(this, arguments);
|
|
116
|
-
}
|
|
117
|
-
return (
|
|
118
|
-
(function () {
|
|
119
|
-
_fetchStorage.apply(this, arguments);
|
|
120
|
-
})(),
|
|
121
|
-
function () {
|
|
122
|
-
didCancel = !0;
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
},
|
|
126
|
-
[room]
|
|
127
|
-
),
|
|
128
|
-
[root]
|
|
136
|
+
function useMyPresence2() {
|
|
137
|
+
const room = useRoom2();
|
|
138
|
+
const presence = room.getPresence();
|
|
139
|
+
const rerender = useRerender();
|
|
140
|
+
React2.useEffect(() => {
|
|
141
|
+
const unsubscribe = room.subscribe("my-presence", rerender);
|
|
142
|
+
return () => {
|
|
143
|
+
unsubscribe();
|
|
144
|
+
};
|
|
145
|
+
}, [room, rerender]);
|
|
146
|
+
const setPresence = React2.useCallback(
|
|
147
|
+
(overrides, options) => room.updatePresence(overrides, options),
|
|
148
|
+
[room]
|
|
149
|
+
);
|
|
150
|
+
return [presence, setPresence];
|
|
151
|
+
}
|
|
152
|
+
function useUpdateMyPresence2() {
|
|
153
|
+
const room = useRoom2();
|
|
154
|
+
return React2.useCallback(
|
|
155
|
+
(overrides, options) => {
|
|
156
|
+
room.updatePresence(overrides, options);
|
|
157
|
+
},
|
|
158
|
+
[room]
|
|
129
159
|
);
|
|
130
160
|
}
|
|
161
|
+
function useOthers2() {
|
|
162
|
+
const room = useRoom2();
|
|
163
|
+
const rerender = useRerender();
|
|
164
|
+
React2.useEffect(() => {
|
|
165
|
+
const unsubscribe = room.subscribe("others", rerender);
|
|
166
|
+
return () => {
|
|
167
|
+
unsubscribe();
|
|
168
|
+
};
|
|
169
|
+
}, [room, rerender]);
|
|
170
|
+
return room.getOthers();
|
|
171
|
+
}
|
|
172
|
+
function useBroadcastEvent2() {
|
|
173
|
+
const room = useRoom2();
|
|
174
|
+
return React2.useCallback(
|
|
175
|
+
(event, options = { shouldQueueEventIfNotReady: false }) => {
|
|
176
|
+
room.broadcastEvent(event, options);
|
|
177
|
+
},
|
|
178
|
+
[room]
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
function useErrorListener2(callback) {
|
|
182
|
+
const room = useRoom2();
|
|
183
|
+
const savedCallback = React2.useRef(callback);
|
|
184
|
+
React2.useEffect(() => {
|
|
185
|
+
savedCallback.current = callback;
|
|
186
|
+
});
|
|
187
|
+
React2.useEffect(() => {
|
|
188
|
+
const listener = (e) => savedCallback.current(e);
|
|
189
|
+
const unsubscribe = room.subscribe("error", listener);
|
|
190
|
+
return () => {
|
|
191
|
+
unsubscribe();
|
|
192
|
+
};
|
|
193
|
+
}, [room]);
|
|
194
|
+
}
|
|
195
|
+
function useEventListener2(callback) {
|
|
196
|
+
const room = useRoom2();
|
|
197
|
+
const savedCallback = React2.useRef(callback);
|
|
198
|
+
React2.useEffect(() => {
|
|
199
|
+
savedCallback.current = callback;
|
|
200
|
+
});
|
|
201
|
+
React2.useEffect(() => {
|
|
202
|
+
const listener = (eventData) => {
|
|
203
|
+
savedCallback.current(eventData);
|
|
204
|
+
};
|
|
205
|
+
const unsubscribe = room.subscribe("event", listener);
|
|
206
|
+
return () => {
|
|
207
|
+
unsubscribe();
|
|
208
|
+
};
|
|
209
|
+
}, [room]);
|
|
210
|
+
}
|
|
211
|
+
function useSelf2() {
|
|
212
|
+
const room = useRoom2();
|
|
213
|
+
const rerender = useRerender();
|
|
214
|
+
React2.useEffect(() => {
|
|
215
|
+
const unsubscribePresence = room.subscribe("my-presence", rerender);
|
|
216
|
+
const unsubscribeConnection = room.subscribe("connection", rerender);
|
|
217
|
+
return () => {
|
|
218
|
+
unsubscribePresence();
|
|
219
|
+
unsubscribeConnection();
|
|
220
|
+
};
|
|
221
|
+
}, [room, rerender]);
|
|
222
|
+
return room.getSelf();
|
|
223
|
+
}
|
|
224
|
+
function useStorage2() {
|
|
225
|
+
const room = useRoom2();
|
|
226
|
+
const [root, setState] = React2.useState(null);
|
|
227
|
+
React2.useEffect(() => {
|
|
228
|
+
let didCancel = false;
|
|
229
|
+
function fetchStorage() {
|
|
230
|
+
return __async(this, null, function* () {
|
|
231
|
+
const storage = yield room.getStorage();
|
|
232
|
+
if (!didCancel) {
|
|
233
|
+
setState(storage.root);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
fetchStorage();
|
|
238
|
+
return () => {
|
|
239
|
+
didCancel = true;
|
|
240
|
+
};
|
|
241
|
+
}, [room]);
|
|
242
|
+
return [root];
|
|
243
|
+
}
|
|
131
244
|
function useMap_deprecated(key, entries) {
|
|
132
|
-
|
|
245
|
+
_internal.errorIf.call(void 0,
|
|
133
246
|
entries,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
key,
|
|
140
|
-
|
|
247
|
+
`Support for initializing entries in useMap() directly will be removed in @liveblocks/react 0.18.
|
|
248
|
+
|
|
249
|
+
Instead, please initialize this data where you set up your RoomProvider:
|
|
250
|
+
|
|
251
|
+
const initialStorage = () => ({
|
|
252
|
+
${JSON.stringify(key)}: new LiveMap(...),
|
|
253
|
+
...
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
<RoomProvider initialStorage={initialStorage}>
|
|
257
|
+
...
|
|
258
|
+
</RoomProvider>
|
|
259
|
+
|
|
260
|
+
Please see https://bit.ly/3Niy5aP for details.`
|
|
141
261
|
);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
262
|
+
const value = useStorageValue(key, new (0, _client2.LiveMap)(entries != null ? entries : void 0));
|
|
263
|
+
if (value.status === "ok") {
|
|
264
|
+
return value.value;
|
|
265
|
+
} else {
|
|
266
|
+
_internal.errorIf.call(void 0,
|
|
267
|
+
value.status === "notfound",
|
|
268
|
+
`Key ${JSON.stringify(
|
|
269
|
+
key
|
|
270
|
+
)} was not found in Storage. Starting with 0.18, useMap() will no longer automatically create this key.
|
|
271
|
+
|
|
272
|
+
Instead, please initialize your storage where you set up your RoomProvider:
|
|
273
|
+
|
|
274
|
+
import { LiveMap } from "@liveblocks/client";
|
|
275
|
+
|
|
276
|
+
const initialStorage = () => ({
|
|
277
|
+
${JSON.stringify(key)}: new LiveMap(...),
|
|
278
|
+
...
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
<RoomProvider initialStorage={initialStorage}>
|
|
282
|
+
...
|
|
283
|
+
</RoomProvider>
|
|
284
|
+
|
|
285
|
+
Please see https://bit.ly/3Niy5aP for details.`
|
|
286
|
+
);
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
153
289
|
}
|
|
154
290
|
function useList_deprecated(key, items) {
|
|
155
|
-
|
|
291
|
+
_internal.errorIf.call(void 0,
|
|
156
292
|
items,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
293
|
+
`Support for initializing items in useList() directly will be removed in @liveblocks/react 0.18.
|
|
294
|
+
|
|
295
|
+
Instead, please initialize this data where you set up your RoomProvider:
|
|
296
|
+
|
|
297
|
+
import { LiveList } from "@liveblocks/client";
|
|
298
|
+
|
|
299
|
+
const initialStorage = () => ({
|
|
300
|
+
${JSON.stringify(key)}: new LiveList(...),
|
|
301
|
+
...
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
<RoomProvider initialStorage={initialStorage}>
|
|
305
|
+
...
|
|
306
|
+
</RoomProvider>
|
|
307
|
+
|
|
308
|
+
Please see https://bit.ly/3Niy5aP for details.`
|
|
160
309
|
);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
310
|
+
const value = useStorageValue(key, new (0, _client2.LiveList)(items));
|
|
311
|
+
if (value.status === "ok") {
|
|
312
|
+
return value.value;
|
|
313
|
+
} else {
|
|
314
|
+
_internal.errorIf.call(void 0,
|
|
315
|
+
value.status === "notfound",
|
|
316
|
+
`Key ${JSON.stringify(
|
|
317
|
+
key
|
|
318
|
+
)} was not found in Storage. Starting with 0.18, useList() will no longer automatically create this key.
|
|
319
|
+
|
|
320
|
+
Instead, please initialize your storage where you set up your RoomProvider:
|
|
321
|
+
|
|
322
|
+
import { LiveList } from "@liveblocks/client";
|
|
323
|
+
|
|
324
|
+
const initialStorage = () => ({
|
|
325
|
+
${JSON.stringify(key)}: new LiveList(...),
|
|
326
|
+
...
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
<RoomProvider initialStorage={initialStorage}>
|
|
330
|
+
...
|
|
331
|
+
</RoomProvider>
|
|
332
|
+
|
|
333
|
+
Please see https://bit.ly/3Niy5aP for details.`
|
|
334
|
+
);
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
173
337
|
}
|
|
174
338
|
function useObject_deprecated(key, initialData) {
|
|
175
|
-
|
|
339
|
+
_internal.errorIf.call(void 0,
|
|
176
340
|
initialData,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
341
|
+
`Support for initializing data in useObject() directly will be removed in @liveblocks/react 0.18.
|
|
342
|
+
|
|
343
|
+
Instead, please initialize this data where you set up your RoomProvider:
|
|
344
|
+
|
|
345
|
+
import { LiveObject } from "@liveblocks/client";
|
|
346
|
+
|
|
347
|
+
const initialStorage = () => ({
|
|
348
|
+
${JSON.stringify(key)}: new LiveObject(...),
|
|
349
|
+
...
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
<RoomProvider initialStorage={initialStorage}>
|
|
353
|
+
...
|
|
354
|
+
</RoomProvider>
|
|
355
|
+
|
|
356
|
+
Please see https://bit.ly/3Niy5aP for details.`
|
|
180
357
|
);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
358
|
+
const value = useStorageValue(key, new (0, _client2.LiveObject)(initialData));
|
|
359
|
+
if (value.status === "ok") {
|
|
360
|
+
return value.value;
|
|
361
|
+
} else {
|
|
362
|
+
_internal.errorIf.call(void 0,
|
|
363
|
+
value.status === "notfound",
|
|
364
|
+
`Key ${JSON.stringify(
|
|
365
|
+
key
|
|
366
|
+
)} was not found in Storage. Starting with 0.18, useObject() will no longer automatically create this key.
|
|
367
|
+
|
|
368
|
+
Instead, please initialize your storage where you set up your RoomProvider:
|
|
369
|
+
|
|
370
|
+
import { LiveObject } from "@liveblocks/client";
|
|
371
|
+
|
|
372
|
+
const initialStorage = () => ({
|
|
373
|
+
${JSON.stringify(key)}: new LiveObject(...),
|
|
374
|
+
...
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
<RoomProvider initialStorage={initialStorage}>
|
|
378
|
+
...
|
|
379
|
+
</RoomProvider>
|
|
380
|
+
|
|
381
|
+
Please see https://bit.ly/3Niy5aP for details.`
|
|
382
|
+
);
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
193
385
|
}
|
|
194
|
-
function
|
|
195
|
-
return
|
|
386
|
+
function useList2(key) {
|
|
387
|
+
return useList_deprecated(key);
|
|
196
388
|
}
|
|
197
|
-
function
|
|
198
|
-
|
|
199
|
-
root = useStorage()[0],
|
|
200
|
-
rerender = useRerender(),
|
|
201
|
-
frozenInitialValue = useInitial(initialValue);
|
|
202
|
-
if (
|
|
203
|
-
(React__namespace.useEffect(
|
|
204
|
-
function () {
|
|
205
|
-
if (null != root) {
|
|
206
|
-
var liveValue = root.get(key);
|
|
207
|
-
null == liveValue &&
|
|
208
|
-
((liveValue = frozenInitialValue), root.set(key, liveValue));
|
|
209
|
-
var unsubscribeCrdt = room.subscribe(liveValue, rerender),
|
|
210
|
-
unsubscribeRoot = room.subscribe(root, function () {
|
|
211
|
-
var newCrdt = root.get(key);
|
|
212
|
-
newCrdt !== liveValue &&
|
|
213
|
-
(unsubscribeCrdt(),
|
|
214
|
-
(liveValue = newCrdt),
|
|
215
|
-
(unsubscribeCrdt = room.subscribe(liveValue, rerender)),
|
|
216
|
-
rerender());
|
|
217
|
-
});
|
|
218
|
-
return (
|
|
219
|
-
rerender(),
|
|
220
|
-
function () {
|
|
221
|
-
unsubscribeRoot(), unsubscribeCrdt();
|
|
222
|
-
}
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
[root, room, key, frozenInitialValue, rerender]
|
|
227
|
-
),
|
|
228
|
-
null == root)
|
|
229
|
-
)
|
|
230
|
-
return { status: "loading" };
|
|
231
|
-
var value = root.get(key);
|
|
232
|
-
return null == value
|
|
233
|
-
? { status: "notfound" }
|
|
234
|
-
: { status: "ok", value: value };
|
|
389
|
+
function useMap2(key) {
|
|
390
|
+
return useMap_deprecated(key);
|
|
235
391
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
"
|
|
254
|
-
|
|
255
|
-
internal.errorIf(
|
|
256
|
-
defaultStorageRoot,
|
|
257
|
-
"RoomProvider's `defaultStorageRoot` prop will be removed in @liveblocks/react 0.18. Please use `initialStorage` instead. For more info, see https://bit.ly/3Niy5aP"
|
|
258
|
-
);
|
|
259
|
-
var _client = useClient$1(),
|
|
260
|
-
frozen = useInitial({
|
|
261
|
-
initialPresence: initialPresence,
|
|
262
|
-
initialStorage: initialStorage,
|
|
263
|
-
defaultPresence: defaultPresence,
|
|
264
|
-
defaultStorageRoot: defaultStorageRoot,
|
|
265
|
-
}),
|
|
266
|
-
_React$useState = React__namespace.useState(function () {
|
|
267
|
-
return _client.enter(roomId, {
|
|
268
|
-
initialPresence: initialPresence,
|
|
269
|
-
initialStorage: initialStorage,
|
|
270
|
-
defaultPresence: defaultPresence,
|
|
271
|
-
defaultStorageRoot: defaultStorageRoot,
|
|
272
|
-
DO_NOT_USE_withoutConnecting: "undefined" == typeof window,
|
|
273
|
-
});
|
|
274
|
-
}),
|
|
275
|
-
room = _React$useState[0],
|
|
276
|
-
setRoom = _React$useState[1];
|
|
277
|
-
return (
|
|
278
|
-
React__namespace.useEffect(
|
|
279
|
-
function () {
|
|
280
|
-
return (
|
|
281
|
-
setRoom(
|
|
282
|
-
_client.enter(roomId, {
|
|
283
|
-
initialPresence: frozen.initialPresence,
|
|
284
|
-
initialStorage: frozen.initialStorage,
|
|
285
|
-
defaultPresence: frozen.defaultPresence,
|
|
286
|
-
defaultStorageRoot: frozen.defaultStorageRoot,
|
|
287
|
-
DO_NOT_USE_withoutConnecting: "undefined" == typeof window,
|
|
288
|
-
})
|
|
289
|
-
),
|
|
290
|
-
function () {
|
|
291
|
-
_client.leave(roomId);
|
|
292
|
-
}
|
|
293
|
-
);
|
|
294
|
-
},
|
|
295
|
-
[_client, roomId, frozen]
|
|
296
|
-
),
|
|
297
|
-
React__namespace.createElement(
|
|
298
|
-
RoomContext.Provider,
|
|
299
|
-
{ value: room },
|
|
300
|
-
props.children
|
|
301
|
-
)
|
|
302
|
-
);
|
|
303
|
-
},
|
|
304
|
-
useBatch: function () {
|
|
305
|
-
return useRoom().batch;
|
|
306
|
-
},
|
|
307
|
-
useBroadcastEvent: function () {
|
|
308
|
-
var room = useRoom();
|
|
309
|
-
return React__namespace.useCallback(
|
|
310
|
-
function (event, options) {
|
|
311
|
-
void 0 === options && (options = { shouldQueueEventIfNotReady: !1 }),
|
|
312
|
-
room.broadcastEvent(event, options);
|
|
313
|
-
},
|
|
314
|
-
[room]
|
|
315
|
-
);
|
|
316
|
-
},
|
|
317
|
-
useCanRedo: function () {
|
|
318
|
-
var room = useRoom(),
|
|
319
|
-
_React$useState4 = React__namespace.useState(room.history.canRedo),
|
|
320
|
-
canRedo = _React$useState4[0],
|
|
321
|
-
setCanRedo = _React$useState4[1];
|
|
322
|
-
return (
|
|
323
|
-
React__namespace.useEffect(
|
|
324
|
-
function () {
|
|
325
|
-
var unsubscribe = room.subscribe("history", function (_ref2) {
|
|
326
|
-
var canRedo = _ref2.canRedo;
|
|
327
|
-
return setCanRedo(canRedo);
|
|
328
|
-
});
|
|
329
|
-
return function () {
|
|
330
|
-
unsubscribe();
|
|
331
|
-
};
|
|
332
|
-
},
|
|
333
|
-
[room]
|
|
334
|
-
),
|
|
335
|
-
canRedo
|
|
336
|
-
);
|
|
337
|
-
},
|
|
338
|
-
useCanUndo: function () {
|
|
339
|
-
var room = useRoom(),
|
|
340
|
-
_React$useState3 = React__namespace.useState(room.history.canUndo),
|
|
341
|
-
canUndo = _React$useState3[0],
|
|
342
|
-
setCanUndo = _React$useState3[1];
|
|
343
|
-
return (
|
|
344
|
-
React__namespace.useEffect(
|
|
345
|
-
function () {
|
|
346
|
-
var unsubscribe = room.subscribe("history", function (_ref) {
|
|
347
|
-
var canUndo = _ref.canUndo;
|
|
348
|
-
return setCanUndo(canUndo);
|
|
349
|
-
});
|
|
350
|
-
return function () {
|
|
351
|
-
unsubscribe();
|
|
352
|
-
};
|
|
353
|
-
},
|
|
354
|
-
[room]
|
|
355
|
-
),
|
|
356
|
-
canUndo
|
|
357
|
-
);
|
|
358
|
-
},
|
|
359
|
-
useErrorListener: function (callback) {
|
|
360
|
-
var room = useRoom(),
|
|
361
|
-
savedCallback = React__namespace.useRef(callback);
|
|
362
|
-
React__namespace.useEffect(function () {
|
|
363
|
-
savedCallback.current = callback;
|
|
364
|
-
}),
|
|
365
|
-
React__namespace.useEffect(
|
|
366
|
-
function () {
|
|
367
|
-
var unsubscribe = room.subscribe("error", function (e) {
|
|
368
|
-
return savedCallback.current(e);
|
|
369
|
-
});
|
|
370
|
-
return function () {
|
|
371
|
-
unsubscribe();
|
|
372
|
-
};
|
|
373
|
-
},
|
|
374
|
-
[room]
|
|
375
|
-
);
|
|
376
|
-
},
|
|
377
|
-
useEventListener: function (callback) {
|
|
378
|
-
var room = useRoom(),
|
|
379
|
-
savedCallback = React__namespace.useRef(callback);
|
|
380
|
-
React__namespace.useEffect(function () {
|
|
381
|
-
savedCallback.current = callback;
|
|
382
|
-
}),
|
|
383
|
-
React__namespace.useEffect(
|
|
384
|
-
function () {
|
|
385
|
-
var unsubscribe = room.subscribe("event", function (eventData) {
|
|
386
|
-
savedCallback.current(eventData);
|
|
387
|
-
});
|
|
388
|
-
return function () {
|
|
389
|
-
unsubscribe();
|
|
390
|
-
};
|
|
391
|
-
},
|
|
392
|
-
[room]
|
|
393
|
-
);
|
|
394
|
-
},
|
|
395
|
-
useHistory: useHistory,
|
|
396
|
-
useList: function (key) {
|
|
397
|
-
return useList_deprecated(key);
|
|
398
|
-
},
|
|
399
|
-
useMap: function (key) {
|
|
400
|
-
return useMap_deprecated(key);
|
|
401
|
-
},
|
|
402
|
-
useMyPresence: function () {
|
|
403
|
-
var room = useRoom(),
|
|
404
|
-
presence = room.getPresence(),
|
|
405
|
-
rerender = useRerender();
|
|
406
|
-
return (
|
|
407
|
-
React__namespace.useEffect(
|
|
408
|
-
function () {
|
|
409
|
-
var unsubscribe = room.subscribe("my-presence", rerender);
|
|
410
|
-
return function () {
|
|
411
|
-
unsubscribe();
|
|
412
|
-
};
|
|
413
|
-
},
|
|
414
|
-
[room, rerender]
|
|
415
|
-
),
|
|
416
|
-
[
|
|
417
|
-
presence,
|
|
418
|
-
React__namespace.useCallback(
|
|
419
|
-
function (overrides, options) {
|
|
420
|
-
return room.updatePresence(overrides, options);
|
|
421
|
-
},
|
|
422
|
-
[room]
|
|
423
|
-
),
|
|
424
|
-
]
|
|
392
|
+
function useObject2(key) {
|
|
393
|
+
return useObject_deprecated(key);
|
|
394
|
+
}
|
|
395
|
+
function useHistory2() {
|
|
396
|
+
return useRoom2().history;
|
|
397
|
+
}
|
|
398
|
+
function useUndo2() {
|
|
399
|
+
return useHistory2().undo;
|
|
400
|
+
}
|
|
401
|
+
function useRedo2() {
|
|
402
|
+
return useHistory2().redo;
|
|
403
|
+
}
|
|
404
|
+
function useCanUndo() {
|
|
405
|
+
const room = useRoom2();
|
|
406
|
+
const [canUndo, setCanUndo] = React2.useState(room.history.canUndo);
|
|
407
|
+
React2.useEffect(() => {
|
|
408
|
+
const unsubscribe = room.subscribe(
|
|
409
|
+
"history",
|
|
410
|
+
({ canUndo: canUndo2 }) => setCanUndo(canUndo2)
|
|
425
411
|
);
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
},
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
};
|
|
440
|
-
},
|
|
441
|
-
[room, rerender]
|
|
442
|
-
),
|
|
443
|
-
room.getOthers()
|
|
412
|
+
return () => {
|
|
413
|
+
unsubscribe();
|
|
414
|
+
};
|
|
415
|
+
}, [room]);
|
|
416
|
+
return canUndo;
|
|
417
|
+
}
|
|
418
|
+
function useCanRedo() {
|
|
419
|
+
const room = useRoom2();
|
|
420
|
+
const [canRedo, setCanRedo] = React2.useState(room.history.canRedo);
|
|
421
|
+
React2.useEffect(() => {
|
|
422
|
+
const unsubscribe = room.subscribe(
|
|
423
|
+
"history",
|
|
424
|
+
({ canRedo: canRedo2 }) => setCanRedo(canRedo2)
|
|
444
425
|
);
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
426
|
+
return () => {
|
|
427
|
+
unsubscribe();
|
|
428
|
+
};
|
|
429
|
+
}, [room]);
|
|
430
|
+
return canRedo;
|
|
431
|
+
}
|
|
432
|
+
function useBatch2() {
|
|
433
|
+
return useRoom2().batch;
|
|
434
|
+
}
|
|
435
|
+
function useStorageValue(key, initialValue) {
|
|
436
|
+
const room = useRoom2();
|
|
437
|
+
const [root] = useStorage2();
|
|
438
|
+
const rerender = useRerender();
|
|
439
|
+
const frozenInitialValue = useInitial(initialValue);
|
|
440
|
+
React2.useEffect(() => {
|
|
441
|
+
if (root == null) {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
let liveValue = root.get(key);
|
|
445
|
+
if (liveValue == null) {
|
|
446
|
+
liveValue = frozenInitialValue;
|
|
447
|
+
root.set(key, liveValue);
|
|
448
|
+
}
|
|
449
|
+
function onRootChange() {
|
|
450
|
+
const newCrdt = root.get(key);
|
|
451
|
+
if (newCrdt !== liveValue) {
|
|
452
|
+
unsubscribeCrdt();
|
|
453
|
+
liveValue = newCrdt;
|
|
454
|
+
unsubscribeCrdt = room.subscribe(
|
|
455
|
+
liveValue,
|
|
456
|
+
rerender
|
|
457
|
+
);
|
|
458
|
+
rerender();
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
let unsubscribeCrdt = room.subscribe(
|
|
462
|
+
liveValue,
|
|
463
|
+
rerender
|
|
465
464
|
);
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
return useHistory().undo;
|
|
470
|
-
},
|
|
471
|
-
useUpdateMyPresence: function () {
|
|
472
|
-
var room = useRoom();
|
|
473
|
-
return React__namespace.useCallback(
|
|
474
|
-
function (overrides, options) {
|
|
475
|
-
room.updatePresence(overrides, options);
|
|
476
|
-
},
|
|
477
|
-
[room]
|
|
465
|
+
const unsubscribeRoot = room.subscribe(
|
|
466
|
+
root,
|
|
467
|
+
onRootChange
|
|
478
468
|
);
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
469
|
+
rerender();
|
|
470
|
+
return () => {
|
|
471
|
+
unsubscribeRoot();
|
|
472
|
+
unsubscribeCrdt();
|
|
473
|
+
};
|
|
474
|
+
}, [root, room, key, frozenInitialValue, rerender]);
|
|
475
|
+
if (root == null) {
|
|
476
|
+
return { status: "loading" };
|
|
477
|
+
} else {
|
|
478
|
+
const value = root.get(key);
|
|
479
|
+
if (value == null) {
|
|
480
|
+
return { status: "notfound" };
|
|
481
|
+
} else {
|
|
482
|
+
return { status: "ok", value };
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return {
|
|
487
|
+
RoomProvider: RoomProvider2,
|
|
488
|
+
useBatch: useBatch2,
|
|
489
|
+
useBroadcastEvent: useBroadcastEvent2,
|
|
490
|
+
useCanRedo,
|
|
491
|
+
useCanUndo,
|
|
492
|
+
useErrorListener: useErrorListener2,
|
|
493
|
+
useEventListener: useEventListener2,
|
|
494
|
+
useHistory: useHistory2,
|
|
495
|
+
useList: useList2,
|
|
496
|
+
useMap: useMap2,
|
|
497
|
+
useMyPresence: useMyPresence2,
|
|
498
|
+
useObject: useObject2,
|
|
499
|
+
useOthers: useOthers2,
|
|
500
|
+
useRedo: useRedo2,
|
|
501
|
+
useRoom: useRoom2,
|
|
502
|
+
useSelf: useSelf2,
|
|
503
|
+
useStorage: useStorage2,
|
|
504
|
+
useUndo: useUndo2,
|
|
505
|
+
useUpdateMyPresence: useUpdateMyPresence2,
|
|
506
|
+
RoomContext,
|
|
507
|
+
useList_deprecated,
|
|
508
|
+
useMap_deprecated,
|
|
509
|
+
useObject_deprecated
|
|
484
510
|
};
|
|
485
511
|
}
|
|
512
|
+
|
|
513
|
+
// src/compat.tsx
|
|
514
|
+
|
|
486
515
|
var _hooks = createRoomContext("__legacy");
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
"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."
|
|
491
|
-
),
|
|
492
|
-
React__namespace.createElement(
|
|
493
|
-
ClientContext.Provider,
|
|
494
|
-
{ value: props.client },
|
|
495
|
-
props.children
|
|
496
|
-
)
|
|
516
|
+
function RoomProvider(props) {
|
|
517
|
+
_internal.deprecate.call(void 0,
|
|
518
|
+
"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."
|
|
497
519
|
);
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
(
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
)
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
(
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
(
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
_hooks.useStorage()
|
|
619
|
-
);
|
|
620
|
-
}),
|
|
621
|
-
(exports.useUndo = function () {
|
|
622
|
-
return (
|
|
623
|
-
internal.deprecate(
|
|
624
|
-
"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."
|
|
625
|
-
),
|
|
626
|
-
_hooks.useUndo()
|
|
627
|
-
);
|
|
628
|
-
}),
|
|
629
|
-
(exports.useUpdateMyPresence = function () {
|
|
630
|
-
return (
|
|
631
|
-
internal.deprecate(
|
|
632
|
-
"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."
|
|
633
|
-
),
|
|
634
|
-
_hooks.useUpdateMyPresence()
|
|
635
|
-
);
|
|
636
|
-
});
|
|
520
|
+
return _hooks.RoomProvider(props);
|
|
521
|
+
}
|
|
522
|
+
function useBatch() {
|
|
523
|
+
_internal.deprecate.call(void 0,
|
|
524
|
+
"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."
|
|
525
|
+
);
|
|
526
|
+
return _hooks.useBatch();
|
|
527
|
+
}
|
|
528
|
+
function useBroadcastEvent() {
|
|
529
|
+
_internal.deprecate.call(void 0,
|
|
530
|
+
"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."
|
|
531
|
+
);
|
|
532
|
+
return _hooks.useBroadcastEvent();
|
|
533
|
+
}
|
|
534
|
+
function useErrorListener(callback) {
|
|
535
|
+
_internal.deprecate.call(void 0,
|
|
536
|
+
"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."
|
|
537
|
+
);
|
|
538
|
+
return _hooks.useErrorListener(callback);
|
|
539
|
+
}
|
|
540
|
+
function useEventListener(callback) {
|
|
541
|
+
_internal.deprecate.call(void 0,
|
|
542
|
+
"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."
|
|
543
|
+
);
|
|
544
|
+
return _hooks.useEventListener(callback);
|
|
545
|
+
}
|
|
546
|
+
function useHistory() {
|
|
547
|
+
_internal.deprecate.call(void 0,
|
|
548
|
+
"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."
|
|
549
|
+
);
|
|
550
|
+
return _hooks.useHistory();
|
|
551
|
+
}
|
|
552
|
+
function useMyPresence() {
|
|
553
|
+
_internal.deprecate.call(void 0,
|
|
554
|
+
"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."
|
|
555
|
+
);
|
|
556
|
+
return _hooks.useMyPresence();
|
|
557
|
+
}
|
|
558
|
+
function useOthers() {
|
|
559
|
+
_internal.deprecate.call(void 0,
|
|
560
|
+
"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."
|
|
561
|
+
);
|
|
562
|
+
return _hooks.useOthers();
|
|
563
|
+
}
|
|
564
|
+
function useRedo() {
|
|
565
|
+
_internal.deprecate.call(void 0,
|
|
566
|
+
"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."
|
|
567
|
+
);
|
|
568
|
+
return _hooks.useRedo();
|
|
569
|
+
}
|
|
570
|
+
function useRoom() {
|
|
571
|
+
_internal.deprecate.call(void 0,
|
|
572
|
+
"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."
|
|
573
|
+
);
|
|
574
|
+
return _hooks.useRoom();
|
|
575
|
+
}
|
|
576
|
+
function useSelf() {
|
|
577
|
+
_internal.deprecate.call(void 0,
|
|
578
|
+
"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."
|
|
579
|
+
);
|
|
580
|
+
return _hooks.useSelf();
|
|
581
|
+
}
|
|
582
|
+
function useStorage() {
|
|
583
|
+
_internal.deprecate.call(void 0,
|
|
584
|
+
"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."
|
|
585
|
+
);
|
|
586
|
+
return _hooks.useStorage();
|
|
587
|
+
}
|
|
588
|
+
function useUndo() {
|
|
589
|
+
_internal.deprecate.call(void 0,
|
|
590
|
+
"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."
|
|
591
|
+
);
|
|
592
|
+
return _hooks.useUndo();
|
|
593
|
+
}
|
|
594
|
+
function useUpdateMyPresence() {
|
|
595
|
+
_internal.deprecate.call(void 0,
|
|
596
|
+
"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."
|
|
597
|
+
);
|
|
598
|
+
return _hooks.useUpdateMyPresence();
|
|
599
|
+
}
|
|
600
|
+
function useList(key, items) {
|
|
601
|
+
_internal.deprecate.call(void 0,
|
|
602
|
+
"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."
|
|
603
|
+
);
|
|
604
|
+
return _hooks.useList_deprecated(key, items);
|
|
605
|
+
}
|
|
606
|
+
function useMap(key, entries) {
|
|
607
|
+
_internal.deprecate.call(void 0,
|
|
608
|
+
"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."
|
|
609
|
+
);
|
|
610
|
+
return _hooks.useMap_deprecated(key, entries);
|
|
611
|
+
}
|
|
612
|
+
function useObject(key, initialData) {
|
|
613
|
+
_internal.deprecate.call(void 0,
|
|
614
|
+
"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."
|
|
615
|
+
);
|
|
616
|
+
return _hooks.useObject_deprecated(key, initialData);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
exports.LiveblocksProvider = LiveblocksProvider; exports.RoomProvider = RoomProvider; exports.createRoomContext = createRoomContext; 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;
|