@liveblocks/react 1.19.0-test1 → 2.0.0-alpha2

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/dist/index.js CHANGED
@@ -1,25 +1,104 @@
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; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
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
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+ var _chunkOKKDBZH4js = require('./chunk-OKKDBZH4.js');
2
59
 
3
60
  // src/index.ts
4
61
  var _core = require('@liveblocks/core');
5
-
6
- // src/version.ts
7
- var PKG_NAME = "@liveblocks/react";
8
- var PKG_VERSION = "1.19.0-test1";
9
- var PKG_FORMAT = "cjs";
10
-
11
- // src/ClientSideSuspense.tsx
12
- var _react = require('react'); var React = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react);
13
- function ClientSideSuspense(props) {
14
- const [mounted, setMounted] = React.useState(false);
15
- React.useEffect(() => {
16
- setMounted(true);
17
- }, []);
18
- return /* @__PURE__ */ React.createElement(React.Suspense, { fallback: props.fallback }, mounted ? props.children() : props.fallback);
19
- }
20
-
21
- // src/factory.tsx
22
62
  var _client = require('@liveblocks/client');
63
+ _core.detectDupes.call(void 0, _chunkOKKDBZH4js.PKG_NAME, _chunkOKKDBZH4js.PKG_VERSION, _chunkOKKDBZH4js.PKG_FORMAT);
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
23
102
 
24
103
 
25
104
 
@@ -29,1871 +108,13 @@ var _client = require('@liveblocks/client');
29
108
 
30
109
 
31
110
 
32
- var _withselectorjs = require('use-sync-external-store/shim/with-selector.js');
33
111
 
34
- // src/comments/CommentsRoom.tsx
35
-
36
- var _nanoid = require('nanoid');
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
- var _indexjs = require('use-sync-external-store/shim/index.js');
46
-
47
- // src/comments/errors.ts
48
- var CreateThreadError = class extends Error {
49
- constructor(cause, context) {
50
- super("Create thread failed.");
51
- this.cause = cause;
52
- this.context = context;
53
- this.name = "CreateThreadError";
54
- }
55
- };
56
- var EditThreadMetadataError = class extends Error {
57
- constructor(cause, context) {
58
- super("Edit thread metadata failed.");
59
- this.cause = cause;
60
- this.context = context;
61
- this.name = "EditThreadMetadataError";
62
- }
63
- };
64
- var CreateCommentError = class extends Error {
65
- constructor(cause, context) {
66
- super("Create comment failed.");
67
- this.cause = cause;
68
- this.context = context;
69
- this.name = "CreateCommentError";
70
- }
71
- };
72
- var EditCommentError = class extends Error {
73
- constructor(cause, context) {
74
- super("Edit comment failed.");
75
- this.cause = cause;
76
- this.context = context;
77
- this.name = "EditCommentError";
78
- }
79
- };
80
- var DeleteCommentError = class extends Error {
81
- constructor(cause, context) {
82
- super("Delete comment failed.");
83
- this.cause = cause;
84
- this.context = context;
85
- this.name = "DeleteCommentError";
86
- }
87
- };
88
- var AddReactionError = class extends Error {
89
- constructor(cause, context) {
90
- super("Add reaction failed.");
91
- this.cause = cause;
92
- this.context = context;
93
- this.name = "AddReactionError";
94
- }
95
- };
96
- var RemoveReactionError = class extends Error {
97
- constructor(cause, context) {
98
- super("Remove reaction failed.");
99
- this.cause = cause;
100
- this.context = context;
101
- this.name = "RemoveReactionError";
102
- }
103
- };
104
-
105
- // src/comments/lib/revalidation.ts
106
-
107
-
108
- // src/comments/lib/use-is-document-visible.ts
109
-
110
- function useIsDocumentVisible() {
111
- const isVisible = _indexjs.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getSnapshot);
112
- return isVisible;
113
- }
114
- function subscribe(onStoreChange) {
115
- document.addEventListener("visibilitychange", onStoreChange);
116
- return () => {
117
- document.removeEventListener("visibilitychange", onStoreChange);
118
- };
119
- }
120
- function getSnapshot() {
121
- const isDocumentDefined = typeof document !== "undefined";
122
- return isDocumentDefined ? document.visibilityState === "visible" : true;
123
- }
124
-
125
- // src/comments/lib/use-is-online.ts
126
-
127
-
128
- function useIsOnline() {
129
- const isOnlineRef = _react.useRef.call(void 0, true);
130
- const subscribe2 = _react.useCallback.call(void 0, (onStoreChange) => {
131
- function handleIsOnline() {
132
- isOnlineRef.current = true;
133
- onStoreChange();
134
- }
135
- function handleIsOffline() {
136
- isOnlineRef.current = false;
137
- onStoreChange();
138
- }
139
- window.addEventListener("online", handleIsOnline);
140
- window.addEventListener("offline", handleIsOffline);
141
- return () => {
142
- window.removeEventListener("online", handleIsOnline);
143
- window.removeEventListener("offline", handleIsOffline);
144
- };
145
- }, []);
146
- const getSnapshot2 = _react.useCallback.call(void 0, () => {
147
- return isOnlineRef.current;
148
- }, []);
149
- const isOnline = _indexjs.useSyncExternalStore.call(void 0, subscribe2, getSnapshot2, getSnapshot2);
150
- return isOnline;
151
- }
152
-
153
- // src/comments/lib/revalidation.ts
154
- var DEFAULT_ERROR_RETRY_INTERVAL = 5e3;
155
- var DEFAULT_MAX_ERROR_RETRY_COUNT = 5;
156
- var DEFAULT_DEDUPING_INTERVAL = 2e3;
157
- var timestamp = 0;
158
- function useRevalidateCache(manager, fetcher, options = {}) {
159
- const isOnlineRef = _react.useRef.call(void 0, true);
160
- const {
161
- dedupingInterval = DEFAULT_DEDUPING_INTERVAL,
162
- errorRetryInterval = DEFAULT_ERROR_RETRY_INTERVAL,
163
- errorRetryCount = DEFAULT_MAX_ERROR_RETRY_COUNT
164
- } = options;
165
- const _revalidateCache = _react.useCallback.call(void 0,
166
- async ({
167
- shouldDedupe,
168
- retryCount = 0
169
- }) => {
170
- let startAt;
171
- const shouldStartRequest = !manager.getRequest() || !shouldDedupe;
172
- function deleteActiveRequest() {
173
- const activeRequest = manager.getRequest();
174
- if (!activeRequest)
175
- return;
176
- if (activeRequest.timestamp !== startAt)
177
- return;
178
- manager.setRequest(void 0);
179
- }
180
- function handleError() {
181
- const timeout = ~~((Math.random() + 0.5) * (1 << (retryCount < 8 ? retryCount : 8))) * errorRetryInterval;
182
- if (retryCount > errorRetryCount)
183
- return;
184
- setTimeout(() => {
185
- void _revalidateCache({
186
- shouldDedupe: false,
187
- retryCount: retryCount + 1
188
- });
189
- }, timeout);
190
- }
191
- if (shouldStartRequest) {
192
- manager.setRequest({
193
- fetcher: fetcher(),
194
- timestamp: ++timestamp
195
- });
196
- }
197
- try {
198
- let activeRequest = manager.getRequest();
199
- if (!activeRequest)
200
- return;
201
- startAt = activeRequest.timestamp;
202
- const newData = await activeRequest.fetcher;
203
- if (shouldStartRequest) {
204
- setTimeout(deleteActiveRequest, dedupingInterval);
205
- }
206
- activeRequest = manager.getRequest();
207
- if (!activeRequest || activeRequest.timestamp !== startAt)
208
- return;
209
- const activeMutation = manager.getMutation();
210
- if (activeMutation && (activeMutation.startTime > startAt || activeMutation.endTime > startAt || activeMutation.endTime === 0)) {
211
- return;
212
- }
213
- manager.setCache(newData);
214
- } catch (err) {
215
- deleteActiveRequest();
216
- const isVisible = document.visibilityState === "visible";
217
- const isOnline = isOnlineRef.current;
218
- if (shouldStartRequest && isVisible && isOnline)
219
- handleError();
220
- manager.setError(err);
221
- }
222
- return;
223
- },
224
- [manager, fetcher, dedupingInterval, errorRetryInterval, errorRetryCount]
225
- );
226
- _react.useEffect.call(void 0, () => {
227
- function handleIsOnline() {
228
- isOnlineRef.current = true;
229
- }
230
- function handleIsOffline() {
231
- isOnlineRef.current = false;
232
- }
233
- window.addEventListener("online", handleIsOnline);
234
- window.addEventListener("offline", handleIsOffline);
235
- return () => {
236
- window.removeEventListener("online", handleIsOnline);
237
- window.removeEventListener("offline", handleIsOffline);
238
- };
239
- }, []);
240
- const revalidateCache = _react.useCallback.call(void 0,
241
- ({ shouldDedupe }) => {
242
- return _revalidateCache({ shouldDedupe, retryCount: 0 });
243
- },
244
- [_revalidateCache]
245
- );
246
- return revalidateCache;
247
- }
248
- function useMutate(manager, revalidateCache) {
249
- const mutate = _react.useCallback.call(void 0,
250
- async (data, options) => {
251
- const beforeMutationTimestamp = ++timestamp;
252
- manager.setMutation({
253
- startTime: beforeMutationTimestamp,
254
- endTime: 0
255
- });
256
- const currentCache = manager.getCache();
257
- manager.setCache(options.optimisticData);
258
- let error;
259
- try {
260
- await data;
261
- } catch (err) {
262
- error = err;
263
- }
264
- const activeMutation = manager.getMutation();
265
- if (activeMutation && beforeMutationTimestamp !== activeMutation.startTime) {
266
- if (error)
267
- throw error;
268
- return;
269
- }
270
- if (error) {
271
- manager.setCache(currentCache);
272
- }
273
- manager.setMutation({
274
- startTime: beforeMutationTimestamp,
275
- endTime: ++timestamp
276
- });
277
- manager.setRequest(void 0);
278
- void revalidateCache({ shouldDedupe: false });
279
- if (error)
280
- throw error;
281
- },
282
- [manager, revalidateCache]
283
- );
284
- return mutate;
285
- }
286
- function useAutomaticRevalidation(manager, revalidateCache, options = {}) {
287
- const isOnline = useIsOnline();
288
- const isDocumentVisible = useIsDocumentVisible();
289
- const {
290
- revalidateOnFocus = true,
291
- revalidateOnReconnect = true,
292
- refreshInterval = 0
293
- } = options;
294
- _react.useEffect.call(void 0, () => {
295
- let revalidationTimerId;
296
- function scheduleRevalidation() {
297
- if (refreshInterval === 0)
298
- return;
299
- revalidationTimerId = window.setTimeout(() => {
300
- if (isOnline && isDocumentVisible && !manager.getError()) {
301
- void revalidateCache({ shouldDedupe: true }).then(
302
- scheduleRevalidation
303
- );
304
- return;
305
- }
306
- scheduleRevalidation();
307
- }, refreshInterval);
308
- }
309
- scheduleRevalidation();
310
- return () => {
311
- window.clearTimeout(revalidationTimerId);
312
- };
313
- }, [revalidateCache, refreshInterval, isOnline, isDocumentVisible, manager]);
314
- _react.useEffect.call(void 0, () => {
315
- function handleIsOnline() {
316
- if (revalidateOnReconnect && isDocumentVisible) {
317
- void revalidateCache({ shouldDedupe: true });
318
- }
319
- }
320
- window.addEventListener("online", handleIsOnline);
321
- return () => {
322
- window.removeEventListener("online", handleIsOnline);
323
- };
324
- }, [revalidateCache, revalidateOnReconnect, isDocumentVisible]);
325
- _react.useEffect.call(void 0, () => {
326
- function handleVisibilityChange() {
327
- const isVisible = document.visibilityState === "visible";
328
- if (revalidateOnFocus && isVisible && isOnline) {
329
- void revalidateCache({ shouldDedupe: true });
330
- }
331
- }
332
- document.addEventListener("visibilitychange", handleVisibilityChange);
333
- return () => {
334
- document.removeEventListener("visibilitychange", handleVisibilityChange);
335
- };
336
- }, [revalidateCache, revalidateOnFocus, isOnline]);
337
- }
338
-
339
- // src/comments/CommentsRoom.tsx
340
- var POLLING_INTERVAL_REALTIME = 3e4;
341
- var POLLING_INTERVAL = 5e3;
342
- var THREAD_ID_PREFIX = "th";
343
- var COMMENT_ID_PREFIX = "cm";
344
- function createCommentsRoom(errorEventSource) {
345
- const manager = createThreadsCacheManager();
346
- const filterOptions = /* @__PURE__ */ new Map();
347
- const cacheStates = /* @__PURE__ */ new Map();
348
- const revalidationManagers = /* @__PURE__ */ new Map();
349
- function createThreadsRevalidationManager(key) {
350
- let request;
351
- let error;
352
- return {
353
- getCache() {
354
- return void 0;
355
- },
356
- setCache(value) {
357
- const cache = new Map(
358
- (_nullishCoalesce(manager.getCache(), () => ( []))).map((thread) => [thread.id, thread])
359
- );
360
- for (const thread of value) {
361
- cache.set(thread.id, thread);
362
- }
363
- setCache(key, {
364
- isLoading: false,
365
- data: value
366
- });
367
- manager.setCache(Array.from(cache.values()));
368
- },
369
- // Request
370
- getRequest() {
371
- return request;
372
- },
373
- setRequest(value) {
374
- request = value;
375
- },
376
- // Error
377
- getError() {
378
- return error;
379
- },
380
- setError(err) {
381
- error = err;
382
- manager.setError(err);
383
- },
384
- // Mutation
385
- getMutation() {
386
- return void 0;
387
- },
388
- setMutation() {
389
- }
390
- };
391
- }
392
- const eventSource = _core.makeEventSource.call(void 0, );
393
- const subscribe2 = eventSource.subscribe;
394
- const getCache = (key) => cacheStates.get(key);
395
- const setCache = (key, value) => {
396
- cacheStates.set(key, value);
397
- };
398
- const FetcherContext = _react.createContext.call(void 0, null);
399
- const CommentsEventSubscriptionContext = _react.createContext.call(void 0, () => {
400
- });
401
- function getThreads() {
402
- const threads = manager.getCache();
403
- if (!threads) {
404
- throw new Error(
405
- "Cannot update threads or comments before they are loaded."
406
- );
407
- }
408
- return threads;
409
- }
410
- function CommentsRoomProvider({
411
- room,
412
- children
413
- }) {
414
- const commentsEventSubscribersCountRef = _react.useRef.call(void 0, 0);
415
- const commentsEventDisposerRef = _react.useRef.call(void 0, );
416
- const fetcher = _react.useCallback.call(void 0, async () => {
417
- const responses = await Promise.all(
418
- Array.from(filterOptions.values()).map((info) => {
419
- return room.getThreads(info.options);
420
- })
421
- );
422
- const threads = Array.from(
423
- new Map(responses.flat().map((thread) => [thread.id, thread])).values()
424
- );
425
- return threads;
426
- }, [room]);
427
- const revalidateCache = useRevalidateCache(manager, fetcher);
428
- const subscribeToCommentEvents = _react.useCallback.call(void 0, () => {
429
- const commentsEventSubscribersCount = commentsEventSubscribersCountRef.current;
430
- if (commentsEventSubscribersCount === 0) {
431
- const unsubscribe = room.events.comments.subscribe(() => {
432
- void revalidateCache({ shouldDedupe: true });
433
- });
434
- commentsEventDisposerRef.current = unsubscribe;
435
- }
436
- commentsEventSubscribersCountRef.current = commentsEventSubscribersCount + 1;
437
- return () => {
438
- commentsEventSubscribersCountRef.current = commentsEventSubscribersCountRef.current - 1;
439
- if (commentsEventSubscribersCountRef.current > 0)
440
- return;
441
- _optionalChain([commentsEventDisposerRef, 'access', _ => _.current, 'optionalCall', _2 => _2()]);
442
- commentsEventDisposerRef.current = void 0;
443
- };
444
- }, [revalidateCache, room]);
445
- _react.useEffect.call(void 0, () => {
446
- const unsubscribe = manager.subscribe("cache", (threads) => {
447
- for (const [key, info] of filterOptions.entries()) {
448
- const filtered = threads.filter((thread) => {
449
- const query = info.options.query;
450
- if (!query)
451
- return true;
452
- for (const key2 in query.metadata) {
453
- if (thread.metadata[key2] !== query.metadata[key2]) {
454
- return false;
455
- }
456
- }
457
- return true;
458
- });
459
- setCache(key, {
460
- isLoading: false,
461
- data: filtered
462
- });
463
- }
464
- for (const [key] of cacheStates.entries()) {
465
- if (filterOptions.has(key))
466
- continue;
467
- cacheStates.delete(key);
468
- }
469
- eventSource.notify(threads);
470
- });
471
- return () => {
472
- unsubscribe();
473
- };
474
- }, []);
475
- _react.useEffect.call(void 0, () => {
476
- const unsubscribe = manager.subscribe("error", (error) => {
477
- for (const state of cacheStates.values()) {
478
- state.error = error;
479
- }
480
- });
481
- return () => {
482
- unsubscribe();
483
- };
484
- }, []);
485
- return /* @__PURE__ */ React.default.createElement(FetcherContext.Provider, { value: fetcher }, /* @__PURE__ */ React.default.createElement(
486
- CommentsEventSubscriptionContext.Provider,
487
- {
488
- value: subscribeToCommentEvents
489
- },
490
- children
491
- ));
492
- }
493
- function useThreadsFetcher() {
494
- const fetcher = _react.useContext.call(void 0, FetcherContext);
495
- if (fetcher === null) {
496
- throw new Error("CommentsRoomProvider is missing from the React tree.");
497
- }
498
- return fetcher;
499
- }
500
- function _useThreads(room, key) {
501
- const fetcher = useThreadsFetcher();
502
- const revalidateCache = useRevalidateCache(manager, fetcher);
503
- const status = _indexjs.useSyncExternalStore.call(void 0,
504
- room.events.status.subscribe,
505
- room.getStatus,
506
- room.getStatus
507
- );
508
- const isOnline = useIsOnline();
509
- const isDocumentVisible = useIsDocumentVisible();
510
- const subscribeToCommentEvents = _react.useContext.call(void 0,
511
- CommentsEventSubscriptionContext
512
- );
513
- const interval = getPollingInterval(
514
- isOnline,
515
- isDocumentVisible,
516
- status === "connected"
517
- );
518
- useAutomaticRevalidation(manager, revalidateCache, {
519
- revalidateOnFocus: true,
520
- revalidateOnReconnect: true,
521
- refreshInterval: interval
522
- });
523
- _react.useEffect.call(void 0, subscribeToCommentEvents, [subscribeToCommentEvents]);
524
- const cache = _indexjs.useSyncExternalStore.call(void 0,
525
- subscribe2,
526
- () => getCache(key),
527
- () => getCache(key)
528
- );
529
- if (!cache || cache.isLoading) {
530
- return { isLoading: true };
531
- }
532
- return {
533
- isLoading: cache.isLoading,
534
- threads: cache.data || [],
535
- error: cache.error
536
- };
537
- }
538
- function useThreads(room, options = { query: { metadata: {} } }) {
539
- const key = _react.useMemo.call(void 0, () => _core.stringify.call(void 0, options), [options]);
540
- let revalidationManager = revalidationManagers.get(key);
541
- if (!revalidationManager) {
542
- revalidationManager = createThreadsRevalidationManager(key);
543
- revalidationManagers.set(key, revalidationManager);
544
- }
545
- const fetcher = _react.useCallback.call(void 0,
546
- () => {
547
- return room.getThreads(options);
548
- },
549
- // eslint-disable-next-line react-hooks/exhaustive-deps
550
- [key]
551
- );
552
- const revalidateCache = useRevalidateCache(revalidationManager, fetcher);
553
- _react.useEffect.call(void 0,
554
- () => {
555
- const info = filterOptions.get(key);
556
- if (info) {
557
- info.count += 1;
558
- } else {
559
- filterOptions.set(key, {
560
- options,
561
- count: 1
562
- });
563
- cacheStates.set(key, { isLoading: true });
564
- }
565
- return () => {
566
- const info2 = filterOptions.get(key);
567
- if (!info2)
568
- return;
569
- info2.count -= 1;
570
- if (info2.count > 0)
571
- return;
572
- filterOptions.delete(key);
573
- };
574
- },
575
- // eslint-disable-next-line react-hooks/exhaustive-deps
576
- [key]
577
- );
578
- _react.useEffect.call(void 0, () => {
579
- void revalidateCache({ shouldDedupe: true });
580
- }, [revalidateCache]);
581
- return _useThreads(room, key);
582
- }
583
- function useThreadsSuspense(room, options = {}) {
584
- const key = _react.useMemo.call(void 0, () => _core.stringify.call(void 0, options), [options]);
585
- let revalidationManager = revalidationManagers.get(key);
586
- if (!revalidationManager) {
587
- revalidationManager = createThreadsRevalidationManager(key);
588
- revalidationManagers.set(key, revalidationManager);
589
- }
590
- const fetcher = _react.useCallback.call(void 0,
591
- () => {
592
- return room.getThreads(options);
593
- },
594
- // eslint-disable-next-line react-hooks/exhaustive-deps
595
- [key]
596
- );
597
- const info = filterOptions.get(key);
598
- if (!info) {
599
- filterOptions.set(key, {
600
- options,
601
- count: 0
602
- });
603
- cacheStates.set(key, { isLoading: true });
604
- }
605
- const revalidateCache = useRevalidateCache(revalidationManager, fetcher);
606
- _react.useEffect.call(void 0,
607
- () => {
608
- const info2 = filterOptions.get(key);
609
- if (info2) {
610
- info2.count += 1;
611
- } else {
612
- filterOptions.set(key, {
613
- options,
614
- count: 1
615
- });
616
- }
617
- return () => {
618
- const info3 = filterOptions.get(key);
619
- if (!info3)
620
- return;
621
- info3.count -= 1;
622
- if (info3.count > 0)
623
- return;
624
- filterOptions.delete(key);
625
- };
626
- },
627
- // eslint-disable-next-line react-hooks/exhaustive-deps
628
- [key]
629
- );
630
- const cache = _useThreads(room, key);
631
- if (cache.error) {
632
- throw cache.error;
633
- }
634
- if (cache.isLoading || !cache.threads) {
635
- throw revalidateCache({ shouldDedupe: true });
636
- }
637
- return {
638
- threads: cache.threads,
639
- isLoading: false
640
- };
641
- }
642
- function useEditThreadMetadata(room) {
643
- const revalidate = useRevalidateCache(manager, room.getThreads);
644
- const mutate = useMutate(manager, revalidate);
645
- const editThreadMetadata = _react.useCallback.call(void 0,
646
- (options) => {
647
- const threadId = options.threadId;
648
- const metadata = "metadata" in options ? options.metadata : {};
649
- const threads = getThreads();
650
- const optimisticData = threads.map(
651
- (thread) => thread.id === threadId ? {
652
- ...thread,
653
- metadata: {
654
- ...thread.metadata,
655
- ...metadata
656
- }
657
- } : thread
658
- );
659
- mutate(room.editThreadMetadata({ metadata, threadId }), {
660
- optimisticData
661
- }).catch((err) => {
662
- if (!(err instanceof _core.CommentsApiError)) {
663
- throw err;
664
- }
665
- const error = handleCommentsApiError(err);
666
- errorEventSource.notify(
667
- new EditThreadMetadataError(error, {
668
- roomId: room.id,
669
- threadId,
670
- metadata
671
- })
672
- );
673
- });
674
- },
675
- [room, mutate]
676
- );
677
- return editThreadMetadata;
678
- }
679
- function useCreateThread(room) {
680
- const fetcher = useThreadsFetcher();
681
- const revalidate = useRevalidateCache(manager, fetcher);
682
- const mutate = useMutate(manager, revalidate);
683
- const createThread = _react.useCallback.call(void 0,
684
- (options) => {
685
- const body = options.body;
686
- const metadata = "metadata" in options ? options.metadata : {};
687
- const threads = getThreads();
688
- const threadId = createOptimisticId(THREAD_ID_PREFIX);
689
- const commentId = createOptimisticId(COMMENT_ID_PREFIX);
690
- const now = /* @__PURE__ */ new Date();
691
- const newComment = {
692
- id: commentId,
693
- threadId,
694
- roomId: room.id,
695
- createdAt: now,
696
- type: "comment",
697
- userId: getCurrentUserId(room),
698
- body,
699
- reactions: []
700
- };
701
- const newThread = {
702
- id: threadId,
703
- type: "thread",
704
- createdAt: now,
705
- roomId: room.id,
706
- metadata,
707
- comments: [newComment]
708
- };
709
- mutate(room.createThread({ threadId, commentId, body, metadata }), {
710
- optimisticData: [...threads, newThread]
711
- }).catch((err) => {
712
- if (!(err instanceof _core.CommentsApiError)) {
713
- throw err;
714
- }
715
- const error = handleCommentsApiError(err);
716
- errorEventSource.notify(
717
- new CreateThreadError(error, {
718
- roomId: room.id,
719
- threadId,
720
- commentId,
721
- body,
722
- metadata
723
- })
724
- );
725
- });
726
- return newThread;
727
- },
728
- [room, mutate]
729
- );
730
- return createThread;
731
- }
732
- function useCreateComment(room) {
733
- const fetcher = useThreadsFetcher();
734
- const revalidate = useRevalidateCache(manager, fetcher);
735
- const mutate = useMutate(manager, revalidate);
736
- const createComment = _react.useCallback.call(void 0,
737
- ({ threadId, body }) => {
738
- const threads = getThreads();
739
- const commentId = createOptimisticId(COMMENT_ID_PREFIX);
740
- const now = /* @__PURE__ */ new Date();
741
- const comment = {
742
- id: commentId,
743
- threadId,
744
- roomId: room.id,
745
- type: "comment",
746
- createdAt: now,
747
- userId: getCurrentUserId(room),
748
- body,
749
- reactions: []
750
- };
751
- const optimisticData = threads.map(
752
- (thread) => thread.id === threadId ? {
753
- ...thread,
754
- comments: [...thread.comments, comment]
755
- } : thread
756
- );
757
- mutate(room.createComment({ threadId, commentId, body }), {
758
- optimisticData
759
- }).catch((err) => {
760
- if (!(err instanceof _core.CommentsApiError)) {
761
- throw err;
762
- }
763
- const error = handleCommentsApiError(err);
764
- errorEventSource.notify(
765
- new CreateCommentError(error, {
766
- roomId: room.id,
767
- threadId,
768
- commentId,
769
- body
770
- })
771
- );
772
- });
773
- return comment;
774
- },
775
- [room, mutate]
776
- );
777
- return createComment;
778
- }
779
- function useEditComment(room) {
780
- const revalidate = useRevalidateCache(manager, room.getThreads);
781
- const mutate = useMutate(manager, revalidate);
782
- const editComment = _react.useCallback.call(void 0,
783
- ({ threadId, commentId, body }) => {
784
- const threads = getThreads();
785
- const now = /* @__PURE__ */ new Date();
786
- const optimisticData = threads.map(
787
- (thread) => thread.id === threadId ? {
788
- ...thread,
789
- comments: thread.comments.map(
790
- (comment) => comment.id === commentId ? {
791
- ...comment,
792
- editedAt: now,
793
- body
794
- } : comment
795
- )
796
- } : thread
797
- );
798
- mutate(room.editComment({ threadId, commentId, body }), {
799
- optimisticData
800
- }).catch((err) => {
801
- if (!(err instanceof _core.CommentsApiError)) {
802
- throw err;
803
- }
804
- const error = handleCommentsApiError(err);
805
- errorEventSource.notify(
806
- new EditCommentError(error, {
807
- roomId: room.id,
808
- threadId,
809
- commentId,
810
- body
811
- })
812
- );
813
- });
814
- },
815
- [room, mutate]
816
- );
817
- return editComment;
818
- }
819
- function useDeleteComment(room) {
820
- const revalidate = useRevalidateCache(manager, room.getThreads);
821
- const mutate = useMutate(manager, revalidate);
822
- const deleteComment = _react.useCallback.call(void 0,
823
- ({ threadId, commentId }) => {
824
- const threads = getThreads();
825
- const now = /* @__PURE__ */ new Date();
826
- const newThreads = [];
827
- for (const thread of threads) {
828
- if (thread.id === threadId) {
829
- const newThread = {
830
- ...thread,
831
- comments: thread.comments.map(
832
- (comment) => comment.id === commentId ? {
833
- ...comment,
834
- deletedAt: now,
835
- body: void 0
836
- } : comment
837
- )
838
- };
839
- if (newThread.comments.some(
840
- (comment) => comment.deletedAt === void 0
841
- )) {
842
- newThreads.push(newThread);
843
- }
844
- } else {
845
- newThreads.push(thread);
846
- }
847
- }
848
- mutate(room.deleteComment({ threadId, commentId }), {
849
- optimisticData: newThreads
850
- }).catch((err) => {
851
- if (!(err instanceof _core.CommentsApiError)) {
852
- throw err;
853
- }
854
- const error = handleCommentsApiError(err);
855
- errorEventSource.notify(
856
- new DeleteCommentError(error, {
857
- roomId: room.id,
858
- threadId,
859
- commentId
860
- })
861
- );
862
- });
863
- },
864
- [room, mutate]
865
- );
866
- return deleteComment;
867
- }
868
- function useAddReaction(room) {
869
- const revalidate = useRevalidateCache(manager, room.getThreads);
870
- const mutate = useMutate(manager, revalidate);
871
- const createComment = _react.useCallback.call(void 0,
872
- ({ threadId, commentId, emoji }) => {
873
- const threads = getThreads();
874
- const now = /* @__PURE__ */ new Date();
875
- const userId = getCurrentUserId(room);
876
- const optimisticData = threads.map(
877
- (thread) => thread.id === threadId ? {
878
- ...thread,
879
- comments: thread.comments.map((comment) => {
880
- if (comment.id !== commentId) {
881
- return comment;
882
- }
883
- let reactions;
884
- if (comment.reactions.some(
885
- (reaction) => reaction.emoji === emoji
886
- )) {
887
- reactions = comment.reactions.map(
888
- (reaction) => reaction.emoji === emoji ? {
889
- ...reaction,
890
- users: [...reaction.users, { id: userId }]
891
- } : reaction
892
- );
893
- } else {
894
- reactions = [
895
- ...comment.reactions,
896
- {
897
- emoji,
898
- createdAt: now,
899
- users: [{ id: userId }]
900
- }
901
- ];
902
- }
903
- return {
904
- ...comment,
905
- reactions
906
- };
907
- })
908
- } : thread
909
- );
910
- mutate(room.addReaction({ threadId, commentId, emoji }), {
911
- optimisticData
912
- }).catch((err) => {
913
- if (!(err instanceof _core.CommentsApiError)) {
914
- throw err;
915
- }
916
- const error = handleCommentsApiError(err);
917
- errorEventSource.notify(
918
- new AddReactionError(error, {
919
- roomId: room.id,
920
- threadId,
921
- commentId,
922
- emoji
923
- })
924
- );
925
- });
926
- },
927
- [room, mutate]
928
- );
929
- return createComment;
930
- }
931
- function useRemoveReaction(room) {
932
- const revalidate = useRevalidateCache(manager, room.getThreads);
933
- const mutate = useMutate(manager, revalidate);
934
- const createComment = _react.useCallback.call(void 0,
935
- ({ threadId, commentId, emoji }) => {
936
- const threads = getThreads();
937
- const userId = getCurrentUserId(room);
938
- const optimisticData = threads.map(
939
- (thread) => thread.id === threadId ? {
940
- ...thread,
941
- comments: thread.comments.map((comment) => {
942
- if (comment.id !== commentId) {
943
- return comment;
944
- }
945
- const reactionIndex = comment.reactions.findIndex(
946
- (reaction) => reaction.emoji === emoji
947
- );
948
- let reactions = comment.reactions;
949
- if (reactionIndex >= 0 && comment.reactions[reactionIndex].users.some(
950
- (user) => user.id === userId
951
- )) {
952
- if (comment.reactions[reactionIndex].users.length <= 1) {
953
- reactions = [...comment.reactions];
954
- reactions.splice(reactionIndex, 1);
955
- } else {
956
- reactions[reactionIndex] = {
957
- ...reactions[reactionIndex],
958
- users: reactions[reactionIndex].users.filter(
959
- (user) => user.id !== userId
960
- )
961
- };
962
- }
963
- }
964
- return {
965
- ...comment,
966
- reactions
967
- };
968
- })
969
- } : thread
970
- );
971
- mutate(room.removeReaction({ threadId, commentId, emoji }), {
972
- optimisticData
973
- }).catch((err) => {
974
- if (!(err instanceof _core.CommentsApiError)) {
975
- throw err;
976
- }
977
- const error = handleCommentsApiError(err);
978
- errorEventSource.notify(
979
- new RemoveReactionError(error, {
980
- roomId: room.id,
981
- threadId,
982
- commentId,
983
- emoji
984
- })
985
- );
986
- });
987
- },
988
- [room, mutate]
989
- );
990
- return createComment;
991
- }
992
- return {
993
- CommentsRoomProvider,
994
- useThreads,
995
- useThreadsSuspense,
996
- useEditThreadMetadata,
997
- useCreateThread,
998
- useCreateComment,
999
- useEditComment,
1000
- useDeleteComment,
1001
- useAddReaction,
1002
- useRemoveReaction
1003
- };
1004
- }
1005
- function createOptimisticId(prefix) {
1006
- return `${prefix}_${_nanoid.nanoid.call(void 0, )}`;
1007
- }
1008
- function getCurrentUserId(room) {
1009
- const self = room.getSelf();
1010
- if (self === null || self.id === void 0) {
1011
- return "anonymous";
1012
- } else {
1013
- return self.id;
1014
- }
1015
- }
1016
- function handleCommentsApiError(err) {
1017
- const message = `Request failed with status ${err.status}: ${err.message}`;
1018
- if (_optionalChain([err, 'access', _3 => _3.details, 'optionalAccess', _4 => _4.error]) === "FORBIDDEN") {
1019
- const detailedMessage = [message, err.details.suggestion, err.details.docs].filter(Boolean).join("\n");
1020
- console.error(detailedMessage);
1021
- }
1022
- return new Error(message);
1023
- }
1024
- function getPollingInterval(isBrowserOnline, isDocumentVisible, isRoomConnected) {
1025
- if (!isBrowserOnline || !isDocumentVisible)
1026
- return;
1027
- if (isRoomConnected)
1028
- return POLLING_INTERVAL_REALTIME;
1029
- return POLLING_INTERVAL;
1030
- }
1031
- function createThreadsCacheManager() {
1032
- let cache;
1033
- let request;
1034
- let error;
1035
- let mutation;
1036
- const cacheEventSource = _core.makeEventSource.call(void 0, );
1037
- const errorEventSource = _core.makeEventSource.call(void 0, );
1038
- return {
1039
- // Cache
1040
- getCache() {
1041
- return cache;
1042
- },
1043
- setCache(value) {
1044
- const sorted = value.sort(
1045
- (a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()
1046
- );
1047
- cache = sorted;
1048
- cacheEventSource.notify(cache);
1049
- },
1050
- // Request
1051
- getRequest() {
1052
- return request;
1053
- },
1054
- setRequest(value) {
1055
- request = value;
1056
- },
1057
- // Error
1058
- getError() {
1059
- return error;
1060
- },
1061
- setError(err) {
1062
- error = err;
1063
- errorEventSource.notify(err);
1064
- },
1065
- // Mutation
1066
- getMutation() {
1067
- return mutation;
1068
- },
1069
- setMutation(info) {
1070
- mutation = info;
1071
- },
1072
- // Subscription
1073
- subscribe(type, callback) {
1074
- switch (type) {
1075
- case "cache":
1076
- return cacheEventSource.subscribe(
1077
- callback
1078
- );
1079
- case "error":
1080
- return errorEventSource.subscribe(callback);
1081
- }
1082
- }
1083
- };
1084
- }
1085
-
1086
- // src/comments/lib/use-debounce.ts
1087
-
1088
- var DEFAULT_DELAY = 500;
1089
- function useDebounce(value, delay = DEFAULT_DELAY) {
1090
- const timeout = _react.useRef.call(void 0, );
1091
- const [debouncedValue, setDebouncedValue] = _react.useState.call(void 0, value);
1092
- _react.useEffect.call(void 0, () => {
1093
- if (delay === false) {
1094
- return;
1095
- }
1096
- if (timeout.current === void 0) {
1097
- setDebouncedValue(value);
1098
- }
1099
- timeout.current = window.setTimeout(() => {
1100
- setDebouncedValue(value);
1101
- timeout.current = void 0;
1102
- }, delay);
1103
- return () => {
1104
- window.clearTimeout(timeout.current);
1105
- };
1106
- }, [value, delay]);
1107
- return debouncedValue;
1108
- }
1109
-
1110
- // src/lib/use-async-cache.ts
1111
-
1112
-
1113
-
1114
- // src/lib/use-initial.ts
1115
-
1116
- function useInitial(value) {
1117
- return _react.useState.call(void 0, value)[0];
1118
- }
1119
-
1120
- // src/lib/use-async-cache.ts
1121
- var INITIAL_ASYNC_STATE = {
1122
- isLoading: false,
1123
- data: void 0,
1124
- error: void 0
1125
- };
1126
- var noop = () => {
1127
- };
1128
- function useAsyncCache(cache, key, options) {
1129
- const frozenOptions = useInitial(options);
1130
- const cacheItem = _react.useMemo.call(void 0, () => {
1131
- if (key === null || !cache) {
1132
- return null;
1133
- }
1134
- const cacheItem2 = cache.create(key);
1135
- void cacheItem2.get();
1136
- return cacheItem2;
1137
- }, [cache, key]);
1138
- const subscribe2 = _react.useCallback.call(void 0,
1139
- (callback) => _nullishCoalesce(_optionalChain([cacheItem, 'optionalAccess', _5 => _5.subscribe, 'call', _6 => _6(callback)]), () => ( noop)),
1140
- [cacheItem]
1141
- );
1142
- const getState = _react.useCallback.call(void 0,
1143
- () => _nullishCoalesce(_optionalChain([cacheItem, 'optionalAccess', _7 => _7.getState, 'call', _8 => _8()]), () => ( INITIAL_ASYNC_STATE)),
1144
- [cacheItem]
1145
- );
1146
- const revalidate = _react.useCallback.call(void 0, () => _optionalChain([cacheItem, 'optionalAccess', _9 => _9.revalidate, 'call', _10 => _10()]), [cacheItem]);
1147
- const state = _indexjs.useSyncExternalStore.call(void 0, subscribe2, getState, getState);
1148
- const previousData = _react.useRef.call(void 0, );
1149
- let data = state.data;
1150
- _react.useEffect.call(void 0, () => {
1151
- previousData.current = { key, data: state.data };
1152
- }, [key, state.data]);
1153
- if (!cacheItem) {
1154
- return {
1155
- isLoading: false,
1156
- data: void 0,
1157
- error: void 0,
1158
- getState,
1159
- revalidate
1160
- };
1161
- }
1162
- if (_optionalChain([frozenOptions, 'optionalAccess', _11 => _11.suspense])) {
1163
- const error = getState().error;
1164
- if (error) {
1165
- throw error;
1166
- } else if (getState().isLoading) {
1167
- throw new Promise((resolve) => {
1168
- cacheItem.subscribeOnce((state2) => {
1169
- if (!state2.isLoading) {
1170
- resolve();
1171
- }
1172
- });
1173
- });
1174
- }
1175
- }
1176
- if (state.isLoading && _optionalChain([frozenOptions, 'optionalAccess', _12 => _12.keepPreviousDataWhileLoading]) && typeof state.data === "undefined" && _optionalChain([previousData, 'access', _13 => _13.current, 'optionalAccess', _14 => _14.key]) !== key && typeof _optionalChain([previousData, 'access', _15 => _15.current, 'optionalAccess', _16 => _16.data]) !== "undefined") {
1177
- data = previousData.current.data;
1178
- }
1179
- return {
1180
- isLoading: state.isLoading,
1181
- data,
1182
- error: state.error,
1183
- getState,
1184
- revalidate
1185
- };
1186
- }
1187
-
1188
- // src/lib/use-latest.ts
1189
-
1190
- function useLatest(value) {
1191
- const ref = _react.useRef.call(void 0, value);
1192
- _react.useEffect.call(void 0, () => {
1193
- ref.current = value;
1194
- }, [value]);
1195
- return ref;
1196
- }
1197
-
1198
- // src/lib/use-rerender.ts
1199
-
1200
- function useRerender() {
1201
- const [, update] = _react.useReducer.call(void 0,
1202
- // This implementation works by incrementing a hidden counter value that is
1203
- // never consumed. Simply incrementing the counter changes the component's
1204
- // state and, thus, trigger a re-render.
1205
- (x) => x + 1,
1206
- 0
1207
- );
1208
- return update;
1209
- }
1210
-
1211
- // src/factory.tsx
1212
- var noop2 = () => {
1213
- };
1214
- var identity = (x) => x;
1215
- var missing_unstable_batchedUpdates = (reactVersion, roomId) => `We noticed you\u2019re using React ${reactVersion}. Please pass unstable_batchedUpdates at the RoomProvider level until you\u2019re ready to upgrade to React 18:
1216
-
1217
- import { unstable_batchedUpdates } from "react-dom"; // or "react-native"
1218
-
1219
- <RoomProvider id=${JSON.stringify(
1220
- roomId
1221
- )} ... unstable_batchedUpdates={unstable_batchedUpdates}>
1222
- ...
1223
- </RoomProvider>
1224
-
1225
- Why? Please see https://liveblocks.io/docs/platform/troubleshooting#stale-props-zombie-child for more information`;
1226
- var superfluous_unstable_batchedUpdates = "You don\u2019t need to pass unstable_batchedUpdates to RoomProvider anymore, since you\u2019re on React 18+ already.";
1227
- function useSyncExternalStore5(s, gs, gss) {
1228
- return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0, s, gs, gss, identity);
1229
- }
1230
- var STABLE_EMPTY_LIST = Object.freeze([]);
1231
- function alwaysEmptyList() {
1232
- return STABLE_EMPTY_LIST;
1233
- }
1234
- function alwaysNull() {
1235
- return null;
1236
- }
1237
- function makeMutationContext(room) {
1238
- const errmsg = "This mutation cannot be used until connected to the Liveblocks room";
1239
- return {
1240
- get storage() {
1241
- const mutableRoot = room.getStorageSnapshot();
1242
- if (mutableRoot === null) {
1243
- throw new Error(errmsg);
1244
- }
1245
- return mutableRoot;
1246
- },
1247
- get self() {
1248
- const self = room.getSelf();
1249
- if (self === null) {
1250
- throw new Error(errmsg);
1251
- }
1252
- return self;
1253
- },
1254
- get others() {
1255
- const others = room.getOthers();
1256
- if (room.getSelf() === null) {
1257
- throw new Error(errmsg);
1258
- }
1259
- return others;
1260
- },
1261
- setMyPresence: room.updatePresence
1262
- };
1263
- }
1264
- var hasWarnedIfNoResolveUsers = false;
1265
- function warnIfNoResolveUsers(usersCache) {
1266
- if (!hasWarnedIfNoResolveUsers && !usersCache && process.env.NODE_ENV !== "production") {
1267
- console.warn(
1268
- "Set the resolveUsers option in createRoomContext to specify user info."
1269
- );
1270
- hasWarnedIfNoResolveUsers = true;
1271
- }
1272
- }
1273
- var ContextBundle = React3.createContext(null);
1274
- function useRoomContextBundle() {
1275
- const bundle = React3.useContext(ContextBundle);
1276
- if (bundle === null) {
1277
- throw new Error("RoomProvider is missing from the React tree.");
1278
- }
1279
- return bundle;
1280
- }
1281
- function createRoomContext(client, options) {
1282
- const RoomContext = React3.createContext(null);
1283
- const commentsErrorEventSource = _core.makeEventSource.call(void 0, );
1284
- const { CommentsRoomProvider, ...commentsRoom } = createCommentsRoom(commentsErrorEventSource);
1285
- function RoomProviderOuter(props) {
1286
- const [cache] = React3.useState(
1287
- () => /* @__PURE__ */ new Map()
1288
- );
1289
- const stableEnterRoom = React3.useCallback(
1290
- (roomId, options2) => {
1291
- const cached = cache.get(roomId);
1292
- if (cached)
1293
- return cached;
1294
- const rv = client.enterRoom(
1295
- roomId,
1296
- options2
1297
- );
1298
- const origLeave = rv.leave;
1299
- rv.leave = () => {
1300
- origLeave();
1301
- cache.delete(roomId);
1302
- };
1303
- cache.set(roomId, rv);
1304
- return rv;
1305
- },
1306
- [cache]
1307
- );
1308
- return /* @__PURE__ */ React3.createElement(RoomProviderInner, { ...props, stableEnterRoom });
1309
- }
1310
- function RoomProviderInner(props) {
1311
- const { id: roomId, stableEnterRoom } = props;
1312
- if (process.env.NODE_ENV !== "production") {
1313
- if (!roomId) {
1314
- throw new Error(
1315
- "RoomProvider id property is required. For more information: https://liveblocks.io/docs/errors/liveblocks-react/RoomProvider-id-property-is-required"
1316
- );
1317
- }
1318
- if (typeof roomId !== "string") {
1319
- throw new Error("RoomProvider id property should be a string.");
1320
- }
1321
- const majorReactVersion = parseInt(React3.version) || 1;
1322
- const oldReactVersion = majorReactVersion < 18;
1323
- _core.errorIf.call(void 0,
1324
- oldReactVersion && props.unstable_batchedUpdates === void 0,
1325
- missing_unstable_batchedUpdates(majorReactVersion, roomId)
1326
- );
1327
- _core.deprecateIf.call(void 0,
1328
- !oldReactVersion && props.unstable_batchedUpdates !== void 0,
1329
- superfluous_unstable_batchedUpdates
1330
- );
1331
- }
1332
- const frozenProps = useInitial({
1333
- initialPresence: props.initialPresence,
1334
- initialStorage: props.initialStorage,
1335
- unstable_batchedUpdates: props.unstable_batchedUpdates,
1336
- autoConnect: _nullishCoalesce(_nullishCoalesce(props.autoConnect, () => ( props.shouldInitiallyConnect)), () => ( typeof window !== "undefined"))
1337
- });
1338
- const [{ room }, setRoomLeavePair] = React3.useState(
1339
- () => stableEnterRoom(roomId, {
1340
- ...frozenProps,
1341
- autoConnect: false
1342
- // Deliberately using false here on the first render, see below
1343
- })
1344
- );
1345
- React3.useEffect(() => {
1346
- const pair = stableEnterRoom(roomId, frozenProps);
1347
- setRoomLeavePair(pair);
1348
- const { room: room2, leave } = pair;
1349
- if (frozenProps.autoConnect) {
1350
- room2.connect();
1351
- }
1352
- return () => {
1353
- leave();
1354
- };
1355
- }, [roomId, frozenProps, stableEnterRoom]);
1356
- return /* @__PURE__ */ React3.createElement(RoomContext.Provider, { value: room }, /* @__PURE__ */ React3.createElement(CommentsRoomProvider, { room }, /* @__PURE__ */ React3.createElement(
1357
- ContextBundle.Provider,
1358
- {
1359
- value: internalBundle
1360
- },
1361
- props.children
1362
- )));
1363
- }
1364
- function connectionIdSelector(others) {
1365
- return others.map((user) => user.connectionId);
1366
- }
1367
- function useRoom() {
1368
- const room = React3.useContext(RoomContext);
1369
- if (room === null) {
1370
- throw new Error("RoomProvider is missing from the React tree.");
1371
- }
1372
- return room;
1373
- }
1374
- function useStatus() {
1375
- const room = useRoom();
1376
- const subscribe2 = room.events.status.subscribe;
1377
- const getSnapshot2 = room.getStatus;
1378
- const getServerSnapshot = room.getStatus;
1379
- return useSyncExternalStore5(subscribe2, getSnapshot2, getServerSnapshot);
1380
- }
1381
- function useMyPresence() {
1382
- const room = useRoom();
1383
- const subscribe2 = room.events.myPresence.subscribe;
1384
- const getSnapshot2 = room.getPresence;
1385
- const presence = useSyncExternalStore5(subscribe2, getSnapshot2, getSnapshot2);
1386
- const setPresence = room.updatePresence;
1387
- return [presence, setPresence];
1388
- }
1389
- function useUpdateMyPresence() {
1390
- return useRoom().updatePresence;
1391
- }
1392
- function useOthers(selector, isEqual) {
1393
- const room = useRoom();
1394
- const subscribe2 = room.events.others.subscribe;
1395
- const getSnapshot2 = room.getOthers;
1396
- const getServerSnapshot = alwaysEmptyList;
1397
- return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
1398
- subscribe2,
1399
- getSnapshot2,
1400
- getServerSnapshot,
1401
- _nullishCoalesce(selector, () => ( identity)),
1402
- isEqual
1403
- );
1404
- }
1405
- function useOthersConnectionIds() {
1406
- return useOthers(connectionIdSelector, _client.shallow);
1407
- }
1408
- function useOthersMapped(itemSelector, itemIsEqual) {
1409
- const wrappedSelector = React3.useCallback(
1410
- (others) => others.map(
1411
- (other) => [other.connectionId, itemSelector(other)]
1412
- ),
1413
- [itemSelector]
1414
- );
1415
- const wrappedIsEqual = React3.useCallback(
1416
- (a, b) => {
1417
- const eq = _nullishCoalesce(itemIsEqual, () => ( Object.is));
1418
- return a.length === b.length && a.every((atuple, index) => {
1419
- const btuple = b[index];
1420
- return atuple[0] === btuple[0] && eq(atuple[1], btuple[1]);
1421
- });
1422
- },
1423
- [itemIsEqual]
1424
- );
1425
- return useOthers(wrappedSelector, wrappedIsEqual);
1426
- }
1427
- const NOT_FOUND = Symbol();
1428
- function useOther(connectionId, selector, isEqual) {
1429
- const wrappedSelector = React3.useCallback(
1430
- (others) => {
1431
- const other2 = others.find(
1432
- (other3) => other3.connectionId === connectionId
1433
- );
1434
- return other2 !== void 0 ? selector(other2) : NOT_FOUND;
1435
- },
1436
- [connectionId, selector]
1437
- );
1438
- const wrappedIsEqual = React3.useCallback(
1439
- (prev, curr) => {
1440
- if (prev === NOT_FOUND || curr === NOT_FOUND) {
1441
- return prev === curr;
1442
- }
1443
- const eq = _nullishCoalesce(isEqual, () => ( Object.is));
1444
- return eq(prev, curr);
1445
- },
1446
- [isEqual]
1447
- );
1448
- const other = useOthers(wrappedSelector, wrappedIsEqual);
1449
- if (other === NOT_FOUND) {
1450
- throw new Error(
1451
- `No such other user with connection id ${connectionId} exists`
1452
- );
1453
- }
1454
- return other;
1455
- }
1456
- function useBroadcastEvent() {
1457
- const room = useRoom();
1458
- return React3.useCallback(
1459
- (event, options2 = { shouldQueueEventIfNotReady: false }) => {
1460
- room.broadcastEvent(event, options2);
1461
- },
1462
- [room]
1463
- );
1464
- }
1465
- function useOthersListener(callback) {
1466
- const room = useRoom();
1467
- const savedCallback = useLatest(callback);
1468
- React3.useEffect(
1469
- () => room.events.others.subscribe((event) => savedCallback.current(event)),
1470
- [room, savedCallback]
1471
- );
1472
- }
1473
- function useLostConnectionListener(callback) {
1474
- const room = useRoom();
1475
- const savedCallback = useLatest(callback);
1476
- React3.useEffect(
1477
- () => room.events.lostConnection.subscribe(
1478
- (event) => savedCallback.current(event)
1479
- ),
1480
- [room, savedCallback]
1481
- );
1482
- }
1483
- function useErrorListener(callback) {
1484
- const room = useRoom();
1485
- const savedCallback = useLatest(callback);
1486
- React3.useEffect(
1487
- () => room.events.error.subscribe((e) => savedCallback.current(e)),
1488
- [room, savedCallback]
1489
- );
1490
- }
1491
- function useEventListener(callback) {
1492
- const room = useRoom();
1493
- const savedCallback = useLatest(callback);
1494
- React3.useEffect(() => {
1495
- const listener = (eventData) => {
1496
- savedCallback.current(eventData);
1497
- };
1498
- return room.events.customEvent.subscribe(listener);
1499
- }, [room, savedCallback]);
1500
- }
1501
- function useSelf(maybeSelector, isEqual) {
1502
- const room = useRoom();
1503
- const subscribe2 = room.events.self.subscribe;
1504
- const getSnapshot2 = room.getSelf;
1505
- const selector = _nullishCoalesce(maybeSelector, () => ( identity));
1506
- const wrappedSelector = React3.useCallback(
1507
- (me) => me !== null ? selector(me) : null,
1508
- [selector]
1509
- );
1510
- const getServerSnapshot = alwaysNull;
1511
- return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
1512
- subscribe2,
1513
- getSnapshot2,
1514
- getServerSnapshot,
1515
- wrappedSelector,
1516
- isEqual
1517
- );
1518
- }
1519
- function useMutableStorageRoot() {
1520
- const room = useRoom();
1521
- const subscribe2 = room.events.storageDidLoad.subscribeOnce;
1522
- const getSnapshot2 = room.getStorageSnapshot;
1523
- const getServerSnapshot = alwaysNull;
1524
- return useSyncExternalStore5(subscribe2, getSnapshot2, getServerSnapshot);
1525
- }
1526
- function useStorageRoot() {
1527
- return [useMutableStorageRoot()];
1528
- }
1529
- function useHistory() {
1530
- return useRoom().history;
1531
- }
1532
- function useUndo() {
1533
- return useHistory().undo;
1534
- }
1535
- function useRedo() {
1536
- return useHistory().redo;
1537
- }
1538
- function useCanUndo() {
1539
- const room = useRoom();
1540
- const subscribe2 = room.events.history.subscribe;
1541
- const canUndo = room.history.canUndo;
1542
- return useSyncExternalStore5(subscribe2, canUndo, canUndo);
1543
- }
1544
- function useCanRedo() {
1545
- const room = useRoom();
1546
- const subscribe2 = room.events.history.subscribe;
1547
- const canRedo = room.history.canRedo;
1548
- return useSyncExternalStore5(subscribe2, canRedo, canRedo);
1549
- }
1550
- function useBatch() {
1551
- return useRoom().batch;
1552
- }
1553
- function useLegacyKey(key) {
1554
- const room = useRoom();
1555
- const rootOrNull = useMutableStorageRoot();
1556
- const rerender = useRerender();
1557
- React3.useEffect(() => {
1558
- if (rootOrNull === null) {
1559
- return;
1560
- }
1561
- const root = rootOrNull;
1562
- let unsubCurr;
1563
- let curr = root.get(key);
1564
- function subscribeToCurr() {
1565
- unsubCurr = _core.isLiveNode.call(void 0, curr) ? room.subscribe(curr, rerender) : void 0;
1566
- }
1567
- function onRootChange() {
1568
- const newValue = root.get(key);
1569
- if (newValue !== curr) {
1570
- _optionalChain([unsubCurr, 'optionalCall', _17 => _17()]);
1571
- curr = newValue;
1572
- subscribeToCurr();
1573
- rerender();
1574
- }
1575
- }
1576
- subscribeToCurr();
1577
- rerender();
1578
- const unsubscribeRoot = room.subscribe(root, onRootChange);
1579
- return () => {
1580
- unsubscribeRoot();
1581
- _optionalChain([unsubCurr, 'optionalCall', _18 => _18()]);
1582
- };
1583
- }, [rootOrNull, room, key, rerender]);
1584
- if (rootOrNull === null) {
1585
- return null;
1586
- } else {
1587
- return rootOrNull.get(key);
1588
- }
1589
- }
1590
- function useStorage(selector, isEqual) {
1591
- const room = useRoom();
1592
- const rootOrNull = useMutableStorageRoot();
1593
- const wrappedSelector = React3.useCallback(
1594
- (rootOrNull2) => rootOrNull2 !== null ? selector(rootOrNull2) : null,
1595
- [selector]
1596
- );
1597
- const subscribe2 = React3.useCallback(
1598
- (onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) : noop2,
1599
- [room, rootOrNull]
1600
- );
1601
- const getSnapshot2 = React3.useCallback(() => {
1602
- if (rootOrNull === null) {
1603
- return null;
1604
- } else {
1605
- const root = rootOrNull;
1606
- const imm = root.toImmutable();
1607
- return imm;
1608
- }
1609
- }, [rootOrNull]);
1610
- const getServerSnapshot = alwaysNull;
1611
- return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
1612
- subscribe2,
1613
- getSnapshot2,
1614
- getServerSnapshot,
1615
- wrappedSelector,
1616
- isEqual
1617
- );
1618
- }
1619
- function ensureNotServerSide() {
1620
- if (typeof window === "undefined") {
1621
- throw new Error(
1622
- "You cannot use the Suspense version of this hook on the server side. Make sure to only call them on the client side.\nFor tips, see https://liveblocks.io/docs/api-reference/liveblocks-react#suspense-avoid-ssr"
1623
- );
1624
- }
1625
- }
1626
- function useSuspendUntilStorageLoaded() {
1627
- const room = useRoom();
1628
- if (room.getStorageSnapshot() !== null) {
1629
- return;
1630
- }
1631
- ensureNotServerSide();
1632
- throw new Promise((res) => {
1633
- room.events.storageDidLoad.subscribeOnce(() => res());
1634
- });
1635
- }
1636
- function useSuspendUntilPresenceLoaded() {
1637
- const room = useRoom();
1638
- if (room.getSelf() !== null) {
1639
- return;
1640
- }
1641
- ensureNotServerSide();
1642
- throw new Promise((res) => {
1643
- room.events.self.subscribeOnce(() => res());
1644
- room.events.status.subscribeOnce(() => res());
1645
- });
1646
- }
1647
- function useMutation(callback, deps) {
1648
- const room = useRoom();
1649
- return React3.useMemo(
1650
- () => {
1651
- return (...args) => (
1652
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
1653
- room.batch(
1654
- () => (
1655
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
1656
- callback(
1657
- makeMutationContext(room),
1658
- ...args
1659
- )
1660
- )
1661
- )
1662
- );
1663
- },
1664
- // eslint-disable-next-line react-hooks/exhaustive-deps
1665
- [room, ...deps]
1666
- );
1667
- }
1668
- function useStorageSuspense(selector, isEqual) {
1669
- useSuspendUntilStorageLoaded();
1670
- return useStorage(
1671
- selector,
1672
- isEqual
1673
- );
1674
- }
1675
- function useSelfSuspense(selector, isEqual) {
1676
- useSuspendUntilPresenceLoaded();
1677
- return useSelf(
1678
- selector,
1679
- isEqual
1680
- );
1681
- }
1682
- function useOthersSuspense(selector, isEqual) {
1683
- useSuspendUntilPresenceLoaded();
1684
- return useOthers(
1685
- selector,
1686
- isEqual
1687
- );
1688
- }
1689
- function useOthersConnectionIdsSuspense() {
1690
- useSuspendUntilPresenceLoaded();
1691
- return useOthersConnectionIds();
1692
- }
1693
- function useOthersMappedSuspense(itemSelector, itemIsEqual) {
1694
- useSuspendUntilPresenceLoaded();
1695
- return useOthersMapped(itemSelector, itemIsEqual);
1696
- }
1697
- function useOtherSuspense(connectionId, selector, isEqual) {
1698
- useSuspendUntilPresenceLoaded();
1699
- return useOther(connectionId, selector, isEqual);
1700
- }
1701
- function useLegacyKeySuspense(key) {
1702
- useSuspendUntilStorageLoaded();
1703
- return useLegacyKey(key);
1704
- }
1705
- function useThreads(options2) {
1706
- const room = useRoom();
1707
- return commentsRoom.useThreads(room, options2);
1708
- }
1709
- function useThreadsSuspense(options2) {
1710
- const room = useRoom();
1711
- return commentsRoom.useThreadsSuspense(room, options2);
1712
- }
1713
- function useCreateThread() {
1714
- const room = useRoom();
1715
- return commentsRoom.useCreateThread(room);
1716
- }
1717
- function useEditThreadMetadata() {
1718
- const room = useRoom();
1719
- return commentsRoom.useEditThreadMetadata(room);
1720
- }
1721
- function useAddReaction() {
1722
- const room = useRoom();
1723
- return commentsRoom.useAddReaction(room);
1724
- }
1725
- function useRemoveReaction() {
1726
- const room = useRoom();
1727
- return commentsRoom.useRemoveReaction(room);
1728
- }
1729
- function useCreateComment() {
1730
- const room = useRoom();
1731
- return commentsRoom.useCreateComment(room);
1732
- }
1733
- function useEditComment() {
1734
- const room = useRoom();
1735
- return commentsRoom.useEditComment(room);
1736
- }
1737
- function useDeleteComment() {
1738
- const room = useRoom();
1739
- return commentsRoom.useDeleteComment(room);
1740
- }
1741
- const { resolveUsers, resolveMentionSuggestions } = _nullishCoalesce(options, () => ( {}));
1742
- const usersCache = resolveUsers ? _core.createAsyncCache.call(void 0, async (stringifiedOptions) => {
1743
- const users = await resolveUsers(
1744
- JSON.parse(stringifiedOptions)
1745
- );
1746
- return _optionalChain([users, 'optionalAccess', _19 => _19[0]]);
1747
- }) : void 0;
1748
- function useUser(userId) {
1749
- const room = useRoom();
1750
- const resolverKey = React3.useMemo(
1751
- () => _core.stringify.call(void 0, { userIds: [userId], roomId: room.id }),
1752
- [userId, room.id]
1753
- );
1754
- const state = useAsyncCache(usersCache, resolverKey);
1755
- React3.useEffect(() => warnIfNoResolveUsers(usersCache), []);
1756
- if (state.isLoading) {
1757
- return {
1758
- isLoading: true
1759
- };
1760
- } else {
1761
- return {
1762
- user: state.data,
1763
- error: state.error,
1764
- isLoading: false
1765
- };
1766
- }
1767
- }
1768
- function useUserSuspense(userId) {
1769
- const room = useRoom();
1770
- const resolverKey = React3.useMemo(
1771
- () => _core.stringify.call(void 0, { userIds: [userId], roomId: room.id }),
1772
- [userId, room.id]
1773
- );
1774
- const state = useAsyncCache(usersCache, resolverKey, {
1775
- suspense: true
1776
- });
1777
- React3.useEffect(() => warnIfNoResolveUsers(usersCache), []);
1778
- return {
1779
- user: state.data,
1780
- isLoading: false
1781
- };
1782
- }
1783
- const mentionSuggestionsCache = _core.createAsyncCache.call(void 0,
1784
- resolveMentionSuggestions ? (stringifiedOptions) => {
1785
- return resolveMentionSuggestions(
1786
- JSON.parse(stringifiedOptions)
1787
- );
1788
- } : () => Promise.resolve([])
1789
- );
1790
- function useMentionSuggestions(search) {
1791
- const room = useRoom();
1792
- const debouncedSearch = useDebounce(search, 500);
1793
- const resolverKey = React3.useMemo(
1794
- () => debouncedSearch !== void 0 ? _core.stringify.call(void 0, { text: debouncedSearch, roomId: room.id }) : null,
1795
- [debouncedSearch, room.id]
1796
- );
1797
- const { data } = useAsyncCache(mentionSuggestionsCache, resolverKey, {
1798
- keepPreviousDataWhileLoading: true
1799
- });
1800
- return data;
1801
- }
1802
- const bundle = {
1803
- RoomContext,
1804
- RoomProvider: RoomProviderOuter,
1805
- useRoom,
1806
- useStatus,
1807
- useBatch,
1808
- useBroadcastEvent,
1809
- useOthersListener,
1810
- useLostConnectionListener,
1811
- useErrorListener,
1812
- useEventListener,
1813
- useHistory,
1814
- useUndo,
1815
- useRedo,
1816
- useCanRedo,
1817
- useCanUndo,
1818
- // These are just aliases. The passed-in key will define their return values.
1819
- useList: useLegacyKey,
1820
- useMap: useLegacyKey,
1821
- useObject: useLegacyKey,
1822
- useStorageRoot,
1823
- useStorage,
1824
- useSelf,
1825
- useMyPresence,
1826
- useUpdateMyPresence,
1827
- useOthers,
1828
- useOthersMapped,
1829
- useOthersConnectionIds,
1830
- useOther,
1831
- useMutation,
1832
- useThreads,
1833
- useUser,
1834
- useCreateThread,
1835
- useEditThreadMetadata,
1836
- useCreateComment,
1837
- useEditComment,
1838
- useDeleteComment,
1839
- useAddReaction,
1840
- useRemoveReaction,
1841
- suspense: {
1842
- RoomContext,
1843
- RoomProvider: RoomProviderOuter,
1844
- useRoom,
1845
- useStatus,
1846
- useBatch,
1847
- useBroadcastEvent,
1848
- useOthersListener,
1849
- useLostConnectionListener,
1850
- useErrorListener,
1851
- useEventListener,
1852
- useHistory,
1853
- useUndo,
1854
- useRedo,
1855
- useCanRedo,
1856
- useCanUndo,
1857
- // Legacy hooks
1858
- useList: useLegacyKeySuspense,
1859
- useMap: useLegacyKeySuspense,
1860
- useObject: useLegacyKeySuspense,
1861
- useStorageRoot,
1862
- useStorage: useStorageSuspense,
1863
- useSelf: useSelfSuspense,
1864
- useMyPresence,
1865
- useUpdateMyPresence,
1866
- useOthers: useOthersSuspense,
1867
- useOthersMapped: useOthersMappedSuspense,
1868
- useOthersConnectionIds: useOthersConnectionIdsSuspense,
1869
- useOther: useOtherSuspense,
1870
- useMutation,
1871
- useThreads: useThreadsSuspense,
1872
- useUser: useUserSuspense,
1873
- useCreateThread,
1874
- useEditThreadMetadata,
1875
- useCreateComment,
1876
- useEditComment,
1877
- useDeleteComment,
1878
- useAddReaction,
1879
- useRemoveReaction
1880
- }
1881
- };
1882
- const internalBundle = {
1883
- ...bundle,
1884
- hasResolveMentionSuggestions: resolveMentionSuggestions !== void 0,
1885
- useMentionSuggestions
1886
- };
1887
- return bundle;
1888
- }
1889
112
 
1890
- // src/index.ts
1891
113
 
1892
- _core.detectDupes.call(void 0, PKG_NAME, PKG_VERSION, PKG_FORMAT);
1893
114
 
1894
115
 
1895
116
 
1896
117
 
1897
118
 
1898
- exports.ClientSideSuspense = ClientSideSuspense; exports.createRoomContext = createRoomContext; exports.shallow = _client.shallow; exports.useRoomContextBundle = useRoomContextBundle;
119
+ exports.ClientContext = _chunkOKKDBZH4js.ClientContext; exports.ClientSideSuspense = _chunkOKKDBZH4js.ClientSideSuspense; exports.CreateThreadError = _chunkOKKDBZH4js.CreateThreadError; exports.LiveblocksProvider = _chunkOKKDBZH4js.LiveblocksProvider; exports.RoomContext = _chunkOKKDBZH4js.RoomContext; exports.RoomProvider = _chunkOKKDBZH4js._RoomProvider; exports.createLiveblocksContext = _chunkOKKDBZH4js.createLiveblocksContext; exports.createRoomContext = _chunkOKKDBZH4js.createRoomContext; exports.selectedThreads = _chunkOKKDBZH4js.selectedThreads; exports.shallow = _client.shallow; exports.useAddReaction = _chunkOKKDBZH4js._useAddReaction; exports.useBatch = _chunkOKKDBZH4js.useBatch; exports.useBroadcastEvent = _chunkOKKDBZH4js._useBroadcastEvent; exports.useCanRedo = _chunkOKKDBZH4js.useCanRedo; exports.useCanUndo = _chunkOKKDBZH4js.useCanUndo; exports.useClient = _chunkOKKDBZH4js.useClient; exports.useCommentsErrorListener = _chunkOKKDBZH4js.useCommentsErrorListener; exports.useCreateComment = _chunkOKKDBZH4js.useCreateComment; exports.useCreateThread = _chunkOKKDBZH4js._useCreateThread; exports.useDeleteComment = _chunkOKKDBZH4js.useDeleteComment; exports.useEditComment = _chunkOKKDBZH4js.useEditComment; exports.useEditThreadMetadata = _chunkOKKDBZH4js._useEditThreadMetadata; exports.useErrorListener = _chunkOKKDBZH4js.useErrorListener; exports.useEventListener = _chunkOKKDBZH4js._useEventListener; exports.useHistory = _chunkOKKDBZH4js.useHistory; exports.useInboxNotificationThread = _chunkOKKDBZH4js.__1; exports.useInboxNotifications = _chunkOKKDBZH4js.useInboxNotifications; exports.useLostConnectionListener = _chunkOKKDBZH4js.useLostConnectionListener; exports.useMarkAllInboxNotificationsAsRead = _chunkOKKDBZH4js.useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = _chunkOKKDBZH4js.useMarkInboxNotificationAsRead; exports.useMarkThreadAsRead = _chunkOKKDBZH4js.useMarkThreadAsRead; exports.useMutation = _chunkOKKDBZH4js._useMutation; exports.useMyPresence = _chunkOKKDBZH4js._useMyPresence; exports.useOther = _chunkOKKDBZH4js._useOther; exports.useOthers = _chunkOKKDBZH4js._useOthers; exports.useOthersConnectionIds = _chunkOKKDBZH4js.useOthersConnectionIds; exports.useOthersListener = _chunkOKKDBZH4js._useOthersListener; exports.useOthersMapped = _chunkOKKDBZH4js._useOthersMapped; exports.useRedo = _chunkOKKDBZH4js.useRedo; exports.useRemoveReaction = _chunkOKKDBZH4js.useRemoveReaction; exports.useRoom = _chunkOKKDBZH4js._useRoom; exports.useRoomInfo = _chunkOKKDBZH4js.useRoomInfo; exports.useRoomNotificationSettings = _chunkOKKDBZH4js.useRoomNotificationSettings; exports.useSelf = _chunkOKKDBZH4js._useSelf; exports.useStatus = _chunkOKKDBZH4js.useStatus; exports.useStorage = _chunkOKKDBZH4js._useStorage; exports.useStorageRoot = _chunkOKKDBZH4js._useStorageRoot; exports.useThreadSubscription = _chunkOKKDBZH4js.useThreadSubscription; exports.useThreads = _chunkOKKDBZH4js._useThreads; exports.useUndo = _chunkOKKDBZH4js.useUndo; exports.useUnreadInboxNotificationsCount = _chunkOKKDBZH4js.useUnreadInboxNotificationsCount; exports.useUpdateMyPresence = _chunkOKKDBZH4js._useUpdateMyPresence; exports.useUpdateRoomNotificationSettings = _chunkOKKDBZH4js.useUpdateRoomNotificationSettings; exports.useUser = _chunkOKKDBZH4js.__2;
1899
120
  //# sourceMappingURL=index.js.map