@liveblocks/react 2.7.0 → 2.7.2

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.
@@ -1,10 +1,10 @@
1
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; }// src/version.ts
2
2
  var PKG_NAME = "@liveblocks/react";
3
- var PKG_VERSION = "2.7.0";
3
+ var PKG_VERSION = "2.7.2";
4
4
  var PKG_FORMAT = "cjs";
5
5
 
6
6
  // src/ClientSideSuspense.tsx
7
- var _react = require('react'); var React = _interopRequireWildcard(_react); var React4 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react);
7
+ var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react); var React5 = _interopRequireWildcard(_react); var React4 = _interopRequireWildcard(_react);
8
8
  function ClientSideSuspense(props) {
9
9
  const [mounted, setMounted] = React.useState(false);
10
10
  React.useEffect(() => {
@@ -13,106 +13,19 @@ function ClientSideSuspense(props) {
13
13
  return /* @__PURE__ */ React.createElement(React.Suspense, { fallback: props.fallback }, mounted ? typeof props.children === "function" ? props.children() : props.children : props.fallback);
14
14
  }
15
15
 
16
- // src/comments/errors.ts
17
- var CreateThreadError = class extends Error {
18
- constructor(cause, context) {
19
- super("Create thread failed.");
20
- this.cause = cause;
21
- this.context = context;
22
- this.name = "CreateThreadError";
23
- }
24
- };
25
- var DeleteThreadError = class extends Error {
26
- constructor(cause, context) {
27
- super("Delete thread failed.");
28
- this.cause = cause;
29
- this.context = context;
30
- this.name = "DeleteThreadError";
31
- }
32
- };
33
- var EditThreadMetadataError = class extends Error {
34
- constructor(cause, context) {
35
- super("Edit thread metadata failed.");
36
- this.cause = cause;
37
- this.context = context;
38
- this.name = "EditThreadMetadataError";
39
- }
40
- };
41
- var MarkThreadAsResolvedError = class extends Error {
42
- constructor(cause, context) {
43
- super("Mark thread as resolved failed.");
44
- this.cause = cause;
45
- this.context = context;
46
- this.name = "MarkThreadAsResolvedError";
47
- }
48
- };
49
- var MarkThreadAsUnresolvedError = class extends Error {
50
- constructor(cause, context) {
51
- super("Mark thread as unresolved failed.");
52
- this.cause = cause;
53
- this.context = context;
54
- this.name = "MarkThreadAsUnresolvedError";
55
- }
56
- };
57
- var CreateCommentError = class extends Error {
58
- constructor(cause, context) {
59
- super("Create comment failed.");
60
- this.cause = cause;
61
- this.context = context;
62
- this.name = "CreateCommentError";
63
- }
64
- };
65
- var EditCommentError = class extends Error {
66
- constructor(cause, context) {
67
- super("Edit comment failed.");
68
- this.cause = cause;
69
- this.context = context;
70
- this.name = "EditCommentError";
71
- }
72
- };
73
- var DeleteCommentError = class extends Error {
74
- constructor(cause, context) {
75
- super("Delete comment failed.");
76
- this.cause = cause;
77
- this.context = context;
78
- this.name = "DeleteCommentError";
79
- }
80
- };
81
- var AddReactionError = class extends Error {
82
- constructor(cause, context) {
83
- super("Add reaction failed.");
84
- this.cause = cause;
85
- this.context = context;
86
- this.name = "AddReactionError";
87
- }
88
- };
89
- var RemoveReactionError = class extends Error {
90
- constructor(cause, context) {
91
- super("Remove reaction failed.");
92
- this.cause = cause;
93
- this.context = context;
94
- this.name = "RemoveReactionError";
95
- }
96
- };
97
- var MarkInboxNotificationAsReadError = class extends Error {
98
- constructor(cause, context) {
99
- super("Mark inbox notification as read failed.");
100
- this.cause = cause;
101
- this.context = context;
102
- this.name = "MarkInboxNotificationAsReadError";
103
- }
104
- };
105
- var UpdateNotificationSettingsError = class extends Error {
106
- constructor(cause, context) {
107
- super("Update notification settings failed.");
108
- this.cause = cause;
109
- this.context = context;
110
- this.name = "UpdateNotificationSettingsError";
111
- }
112
- };
16
+ // src/contexts.ts
17
+
18
+ var RoomContext = React2.createContext(null);
19
+ function useRoomOrNull() {
20
+ return React2.useContext(RoomContext);
21
+ }
22
+ function useIsInsideRoom() {
23
+ const room = useRoomOrNull();
24
+ return room !== null;
25
+ }
26
+
27
+ // src/liveblocks.tsx
113
28
 
114
- // src/room.tsx
115
- var _client = require('@liveblocks/client');
116
29
 
117
30
 
118
31
 
@@ -121,14 +34,15 @@ var _client = require('@liveblocks/client');
121
34
 
122
35
 
123
36
 
37
+ var _core = require('@liveblocks/core');
124
38
 
125
39
 
126
40
 
127
41
 
128
42
 
129
43
 
130
- var _core = require('@liveblocks/core');
131
44
 
45
+ var _indexjs = require('use-sync-external-store/shim/index.js');
132
46
  var _withselectorjs = require('use-sync-external-store/shim/with-selector.js');
133
47
 
134
48
  // src/lib/compare.ts
@@ -204,6 +118,21 @@ async function autoRetry(promiseFn, maxTries, backoff) {
204
118
  }
205
119
  }
206
120
 
121
+ // src/lib/shallow2.ts
122
+
123
+ function shallow2(a, b) {
124
+ if (!_core.isPlainObject.call(void 0, a) || !_core.isPlainObject.call(void 0, b)) {
125
+ return _core.shallow.call(void 0, a, b);
126
+ }
127
+ const keysA = Object.keys(a);
128
+ if (keysA.length !== Object.keys(b).length) {
129
+ return false;
130
+ }
131
+ return keysA.every(
132
+ (key) => Object.prototype.hasOwnProperty.call(b, key) && _core.shallow.call(void 0, a[key], b[key])
133
+ );
134
+ }
135
+
207
136
  // src/lib/use-initial.ts
208
137
 
209
138
 
@@ -261,66 +190,147 @@ var use = (
261
190
  }
262
191
  );
263
192
 
264
- // src/liveblocks.tsx
265
-
266
-
267
-
268
-
269
-
270
-
271
-
272
-
273
-
274
-
275
-
276
-
193
+ // src/umbrella-store.ts
277
194
 
278
195
 
279
196
 
280
197
 
281
198
 
282
- var _indexjs = require('use-sync-external-store/shim/index.js');
283
199
 
284
200
 
285
- // src/umbrella-store.ts
286
201
 
202
+ var QUERY_STATE_LOADING = Object.freeze({ isLoading: true });
203
+ var QUERY_STATE_OK = Object.freeze({ isLoading: false, data: void 0 });
204
+ var INBOX_NOTIFICATIONS_QUERY = "INBOX_NOTIFICATIONS";
205
+ function makeNotificationSettingsQueryKey(roomId) {
206
+ return `${roomId}:NOTIFICATION_SETTINGS`;
207
+ }
208
+ function makeVersionsQueryKey(roomId) {
209
+ return `${roomId}-VERSIONS`;
210
+ }
287
211
  var UmbrellaStore = class {
288
212
  constructor() {
213
+ this._prevState = null;
214
+ this._stateCached = null;
289
215
  this._store = _core.createStore.call(void 0, {
290
- threads: {},
216
+ rawThreadsById: {},
291
217
  queries: {},
292
218
  optimisticUpdates: [],
293
- inboxNotifications: {},
294
- notificationSettings: {},
295
- versions: {}
219
+ inboxNotificationsById: {},
220
+ notificationSettingsByRoomId: {},
221
+ versionsByRoomId: {}
296
222
  });
297
- this.get = this.get.bind(this);
298
- this.subscribe = this.subscribe.bind(this);
223
+ this.getThreads = this.getThreads.bind(this);
224
+ this.getInboxNotifications = this.getInboxNotifications.bind(this);
225
+ this.getInboxNotificationsAsync = this.getInboxNotificationsAsync.bind(this);
226
+ this.subscribeThreads = this.subscribeThreads.bind(this);
227
+ this.subscribeInboxNotifications = this.subscribeInboxNotifications.bind(this);
228
+ this.subscribeNotificationSettings = this.subscribeNotificationSettings.bind(this);
229
+ this.subscribeVersions = this.subscribeVersions.bind(this);
230
+ this._hasOptimisticUpdates = this._hasOptimisticUpdates.bind(this);
231
+ this._subscribeOptimisticUpdates = this._subscribeOptimisticUpdates.bind(this);
299
232
  }
300
233
  get() {
301
- return this._store.get();
234
+ const rawState = this._store.get();
235
+ if (this._prevState !== rawState || this._stateCached === null) {
236
+ this._prevState = rawState;
237
+ this._stateCached = internalToExternalState(rawState);
238
+ }
239
+ return this._stateCached;
240
+ }
241
+ getThreads() {
242
+ return this.get();
243
+ }
244
+ getInboxNotifications() {
245
+ return this.get();
246
+ }
247
+ // NOTE: This will read the async result, but WILL NOT start loading at the moment!
248
+ getInboxNotificationsAsync() {
249
+ const internalState = this._store.get();
250
+ const query = internalState.queries[INBOX_NOTIFICATIONS_QUERY];
251
+ if (query === void 0 || query.isLoading) {
252
+ return QUERY_STATE_LOADING;
253
+ }
254
+ if (query.error !== void 0) {
255
+ return query;
256
+ }
257
+ const inboxNotifications = this.get().inboxNotifications;
258
+ return { isLoading: false, inboxNotifications };
259
+ }
260
+ // NOTE: This will read the async result, but WILL NOT start loading at the moment!
261
+ getNotificationSettingsAsync(roomId) {
262
+ const state = this.get();
263
+ const query = state.queries[makeNotificationSettingsQueryKey(roomId)];
264
+ if (query === void 0 || query.isLoading) {
265
+ return QUERY_STATE_LOADING;
266
+ }
267
+ if (query.error !== void 0) {
268
+ return query;
269
+ }
270
+ return {
271
+ isLoading: false,
272
+ settings: _core.nn.call(void 0, state.notificationSettingsByRoomId[roomId])
273
+ };
274
+ }
275
+ getVersionsAsync(roomId) {
276
+ const state = this.get();
277
+ const query = state.queries[makeVersionsQueryKey(roomId)];
278
+ if (query === void 0 || query.isLoading) {
279
+ return QUERY_STATE_LOADING;
280
+ }
281
+ if (query.error !== void 0) {
282
+ return query;
283
+ }
284
+ return {
285
+ isLoading: false,
286
+ versions: _core.nn.call(void 0, state.versionsByRoomId[roomId])
287
+ };
288
+ }
289
+ /**
290
+ * @private Only used by the E2E test suite.
291
+ */
292
+ _hasOptimisticUpdates() {
293
+ return this._store.get().optimisticUpdates.length > 0;
302
294
  }
303
295
  subscribe(callback) {
304
296
  return this._store.subscribe(callback);
305
297
  }
298
+ /**
299
+ * @private Only used by the E2E test suite.
300
+ */
301
+ _subscribeOptimisticUpdates(callback) {
302
+ return this.subscribe(callback);
303
+ }
304
+ subscribeThreads(callback) {
305
+ return this.subscribe(callback);
306
+ }
307
+ subscribeInboxNotifications(callback) {
308
+ return this.subscribe(callback);
309
+ }
310
+ subscribeNotificationSettings(callback) {
311
+ return this.subscribe(callback);
312
+ }
313
+ subscribeVersions(callback) {
314
+ return this.subscribe(callback);
315
+ }
306
316
  // Direct low-level cache mutations ------------------------------------------------- {{{
307
317
  updateThreadsCache(mapFn) {
308
318
  this._store.set((state) => {
309
- const threads = mapFn(state.threads);
310
- return threads !== state.threads ? { ...state, threads } : state;
319
+ const threads = mapFn(state.rawThreadsById);
320
+ return threads !== state.rawThreadsById ? { ...state, rawThreadsById: threads } : state;
311
321
  });
312
322
  }
313
323
  updateInboxNotificationsCache(mapFn) {
314
324
  this._store.set((state) => {
315
- const inboxNotifications = mapFn(state.inboxNotifications);
316
- return inboxNotifications !== state.inboxNotifications ? { ...state, inboxNotifications } : state;
325
+ const inboxNotifications = mapFn(state.inboxNotificationsById);
326
+ return inboxNotifications !== state.inboxNotificationsById ? { ...state, inboxNotificationsById: inboxNotifications } : state;
317
327
  });
318
328
  }
319
329
  setNotificationSettings(roomId, settings) {
320
330
  this._store.set((state) => ({
321
331
  ...state,
322
- notificationSettings: {
323
- ...state.notificationSettings,
332
+ notificationSettingsByRoomId: {
333
+ ...state.notificationSettingsByRoomId,
324
334
  [roomId]: settings
325
335
  }
326
336
  }));
@@ -328,8 +338,8 @@ var UmbrellaStore = class {
328
338
  setVersions(roomId, versions) {
329
339
  this._store.set((state) => ({
330
340
  ...state,
331
- versions: {
332
- ...state.versions,
341
+ versionsByRoomId: {
342
+ ...state.versionsByRoomId,
333
343
  [roomId]: versions
334
344
  }
335
345
  }));
@@ -449,6 +459,30 @@ var UmbrellaStore = class {
449
459
  });
450
460
  });
451
461
  }
462
+ patchThread(threadId, optimisticUpdateId, patch, updatedAt) {
463
+ return this.updateThread(
464
+ threadId,
465
+ optimisticUpdateId,
466
+ (thread) => ({ ...thread, ..._core.compactObject.call(void 0, patch) }),
467
+ updatedAt
468
+ );
469
+ }
470
+ addReaction(threadId, optimisticUpdateId, commentId, reaction, createdAt) {
471
+ this.updateThread(
472
+ threadId,
473
+ optimisticUpdateId,
474
+ (thread) => applyAddReaction(thread, commentId, reaction),
475
+ createdAt
476
+ );
477
+ }
478
+ removeReaction(threadId, optimisticUpdateId, commentId, emoji, userId, removedAt) {
479
+ this.updateThread(
480
+ threadId,
481
+ optimisticUpdateId,
482
+ (thread) => applyRemoveReaction(thread, commentId, emoji, userId, removedAt),
483
+ removedAt
484
+ );
485
+ }
452
486
  /**
453
487
  * Soft-deletes an existing thread by setting its `deletedAt` value,
454
488
  * replacing the corresponding optimistic update.
@@ -472,13 +506,13 @@ var UmbrellaStore = class {
472
506
  createComment(newComment, optimisticUpdateId) {
473
507
  this._store.batch(() => {
474
508
  this.removeOptimisticUpdate(optimisticUpdateId);
475
- const existingThread = this._store.get().threads[newComment.threadId];
509
+ const existingThread = this._store.get().rawThreadsById[newComment.threadId];
476
510
  if (!existingThread) {
477
511
  return;
478
512
  }
479
513
  this.updateThreadsCache((cache) => ({
480
514
  ...cache,
481
- [newComment.threadId]: upsertComment(existingThread, newComment)
515
+ [newComment.threadId]: applyUpsertComment(existingThread, newComment)
482
516
  }));
483
517
  this.updateInboxNotificationsCache((cache) => {
484
518
  const existingNotification = Object.values(cache).find(
@@ -498,6 +532,21 @@ var UmbrellaStore = class {
498
532
  });
499
533
  });
500
534
  }
535
+ editComment(threadId, optimisticUpdateId, editedComment) {
536
+ return this.updateThread(
537
+ threadId,
538
+ optimisticUpdateId,
539
+ (thread) => applyUpsertComment(thread, editedComment)
540
+ );
541
+ }
542
+ deleteComment(threadId, optimisticUpdateId, commentId, deletedAt) {
543
+ return this.updateThread(
544
+ threadId,
545
+ optimisticUpdateId,
546
+ (thread) => applyDeleteComment(thread, commentId, deletedAt),
547
+ deletedAt
548
+ );
549
+ }
501
550
  updateThreadAndNotification(thread, inboxNotification) {
502
551
  this._store.batch(() => {
503
552
  this.updateThreadsCache((cache) => {
@@ -570,35 +619,29 @@ var UmbrellaStore = class {
570
619
  // Query State APIs
571
620
  //
572
621
  setQueryLoading(queryKey) {
573
- this.setQueryState(queryKey, { isLoading: true });
622
+ this.setQueryState(queryKey, QUERY_STATE_LOADING);
574
623
  }
575
624
  setQueryOK(queryKey) {
576
- this.setQueryState(queryKey, { isLoading: false, data: void 0 });
625
+ this.setQueryState(queryKey, QUERY_STATE_OK);
577
626
  }
578
627
  setQueryError(queryKey, error) {
579
628
  this.setQueryState(queryKey, { isLoading: false, error });
580
629
  }
581
630
  };
582
- function applyOptimisticUpdates(state) {
583
- const result = {
584
- threads: {
585
- ...state.threads
586
- },
587
- inboxNotifications: {
588
- ...state.inboxNotifications
589
- },
590
- notificationSettings: {
591
- ...state.notificationSettings
592
- }
631
+ function internalToExternalState(state) {
632
+ const computed = {
633
+ threadsById: { ...state.rawThreadsById },
634
+ inboxNotificationsById: { ...state.inboxNotificationsById },
635
+ notificationSettingsByRoomId: { ...state.notificationSettingsByRoomId }
593
636
  };
594
637
  for (const optimisticUpdate of state.optimisticUpdates) {
595
638
  switch (optimisticUpdate.type) {
596
639
  case "create-thread": {
597
- result.threads[optimisticUpdate.thread.id] = optimisticUpdate.thread;
640
+ computed.threadsById[optimisticUpdate.thread.id] = optimisticUpdate.thread;
598
641
  break;
599
642
  }
600
643
  case "edit-thread-metadata": {
601
- const thread = result.threads[optimisticUpdate.threadId];
644
+ const thread = computed.threadsById[optimisticUpdate.threadId];
602
645
  if (thread === void 0) {
603
646
  break;
604
647
  }
@@ -608,7 +651,7 @@ function applyOptimisticUpdates(state) {
608
651
  if (thread.updatedAt !== void 0 && thread.updatedAt > optimisticUpdate.updatedAt) {
609
652
  break;
610
653
  }
611
- result.threads[thread.id] = {
654
+ computed.threadsById[thread.id] = {
612
655
  ...thread,
613
656
  updatedAt: optimisticUpdate.updatedAt,
614
657
  metadata: {
@@ -619,49 +662,51 @@ function applyOptimisticUpdates(state) {
619
662
  break;
620
663
  }
621
664
  case "mark-thread-as-resolved": {
622
- const thread = result.threads[optimisticUpdate.threadId];
665
+ const thread = computed.threadsById[optimisticUpdate.threadId];
623
666
  if (thread === void 0) {
624
667
  break;
625
668
  }
626
669
  if (thread.deletedAt !== void 0) {
627
670
  break;
628
671
  }
629
- result.threads[thread.id] = {
672
+ computed.threadsById[thread.id] = {
630
673
  ...thread,
631
674
  resolved: true
632
675
  };
633
676
  break;
634
677
  }
635
678
  case "mark-thread-as-unresolved": {
636
- const thread = result.threads[optimisticUpdate.threadId];
679
+ const thread = computed.threadsById[optimisticUpdate.threadId];
637
680
  if (thread === void 0) {
638
681
  break;
639
682
  }
640
683
  if (thread.deletedAt !== void 0) {
641
684
  break;
642
685
  }
643
- result.threads[thread.id] = {
686
+ computed.threadsById[thread.id] = {
644
687
  ...thread,
645
688
  resolved: false
646
689
  };
647
690
  break;
648
691
  }
649
692
  case "create-comment": {
650
- const thread = result.threads[optimisticUpdate.comment.threadId];
693
+ const thread = computed.threadsById[optimisticUpdate.comment.threadId];
651
694
  if (thread === void 0) {
652
695
  break;
653
696
  }
654
- result.threads[thread.id] = upsertComment(
697
+ computed.threadsById[thread.id] = applyUpsertComment(
655
698
  thread,
656
699
  optimisticUpdate.comment
657
700
  );
658
- const inboxNotification = Object.values(result.inboxNotifications).find(
701
+ const inboxNotification = Object.values(
702
+ computed.inboxNotificationsById
703
+ ).find(
659
704
  (notification) => notification.kind === "thread" && notification.threadId === thread.id
660
705
  );
661
706
  if (inboxNotification === void 0) {
662
707
  break;
663
708
  }
664
- result.inboxNotifications[inboxNotification.id] = {
709
+ computed.inboxNotificationsById[inboxNotification.id] = {
665
710
  ...inboxNotification,
666
711
  notifiedAt: optimisticUpdate.comment.createdAt,
667
712
  readAt: optimisticUpdate.comment.createdAt
@@ -669,22 +714,22 @@ function applyOptimisticUpdates(state) {
669
714
  break;
670
715
  }
671
716
  case "edit-comment": {
672
- const thread = result.threads[optimisticUpdate.comment.threadId];
717
+ const thread = computed.threadsById[optimisticUpdate.comment.threadId];
673
718
  if (thread === void 0) {
674
719
  break;
675
720
  }
676
- result.threads[thread.id] = upsertComment(
721
+ computed.threadsById[thread.id] = applyUpsertComment(
677
722
  thread,
678
723
  optimisticUpdate.comment
679
724
  );
680
725
  break;
681
726
  }
682
727
  case "delete-comment": {
683
- const thread = result.threads[optimisticUpdate.threadId];
728
+ const thread = computed.threadsById[optimisticUpdate.threadId];
684
729
  if (thread === void 0) {
685
730
  break;
686
731
  }
687
- result.threads[thread.id] = deleteComment(
732
+ computed.threadsById[thread.id] = applyDeleteComment(
688
733
  thread,
689
734
  optimisticUpdate.commentId,
690
735
  optimisticUpdate.deletedAt
@@ -692,12 +737,12 @@ function applyOptimisticUpdates(state) {
692
737
  break;
693
738
  }
694
739
  case "delete-thread": {
695
- const thread = result.threads[optimisticUpdate.threadId];
740
+ const thread = computed.threadsById[optimisticUpdate.threadId];
696
741
  if (thread === void 0) {
697
742
  break;
698
743
  }
699
- result.threads[optimisticUpdate.threadId] = {
700
- ...result.threads[optimisticUpdate.threadId],
744
+ computed.threadsById[optimisticUpdate.threadId] = {
745
+ ...thread,
701
746
  deletedAt: optimisticUpdate.deletedAt,
702
747
  updatedAt: optimisticUpdate.deletedAt,
703
748
  comments: []
@@ -705,11 +750,11 @@ function applyOptimisticUpdates(state) {
705
750
  break;
706
751
  }
707
752
  case "add-reaction": {
708
- const thread = result.threads[optimisticUpdate.threadId];
753
+ const thread = computed.threadsById[optimisticUpdate.threadId];
709
754
  if (thread === void 0) {
710
755
  break;
711
756
  }
712
- result.threads[thread.id] = addReaction(
757
+ computed.threadsById[thread.id] = applyAddReaction(
713
758
  thread,
714
759
  optimisticUpdate.commentId,
715
760
  optimisticUpdate.reaction
@@ -717,11 +762,11 @@ function applyOptimisticUpdates(state) {
717
762
  break;
718
763
  }
719
764
  case "remove-reaction": {
720
- const thread = result.threads[optimisticUpdate.threadId];
765
+ const thread = computed.threadsById[optimisticUpdate.threadId];
721
766
  if (thread === void 0) {
722
767
  break;
723
768
  }
724
- result.threads[thread.id] = removeReaction(
769
+ computed.threadsById[thread.id] = applyRemoveReaction(
725
770
  thread,
726
771
  optimisticUpdate.commentId,
727
772
  optimisticUpdate.emoji,
@@ -731,42 +776,70 @@ function applyOptimisticUpdates(state) {
731
776
  break;
732
777
  }
733
778
  case "mark-inbox-notification-as-read": {
734
- result.inboxNotifications[optimisticUpdate.inboxNotificationId] = {
735
- ...state.inboxNotifications[optimisticUpdate.inboxNotificationId],
736
- readAt: optimisticUpdate.readAt
737
- };
779
+ const ibn = computed.inboxNotificationsById[optimisticUpdate.inboxNotificationId];
780
+ if (ibn === void 0) {
781
+ break;
782
+ }
783
+ computed.inboxNotificationsById[optimisticUpdate.inboxNotificationId] = { ...ibn, readAt: optimisticUpdate.readAt };
738
784
  break;
739
785
  }
740
786
  case "mark-all-inbox-notifications-as-read": {
741
- for (const id in result.inboxNotifications) {
742
- result.inboxNotifications[id] = {
743
- ...result.inboxNotifications[id],
787
+ for (const id in computed.inboxNotificationsById) {
788
+ const ibn = computed.inboxNotificationsById[id];
789
+ if (ibn === void 0) {
790
+ break;
791
+ }
792
+ computed.inboxNotificationsById[id] = {
793
+ ...ibn,
744
794
  readAt: optimisticUpdate.readAt
745
795
  };
746
796
  }
747
797
  break;
748
798
  }
749
799
  case "delete-inbox-notification": {
750
- const {
751
- [optimisticUpdate.inboxNotificationId]: _,
752
- ...inboxNotifications
753
- } = result.inboxNotifications;
754
- result.inboxNotifications = inboxNotifications;
800
+ delete computed.inboxNotificationsById[optimisticUpdate.inboxNotificationId];
755
801
  break;
756
802
  }
757
803
  case "delete-all-inbox-notifications": {
758
- result.inboxNotifications = {};
804
+ computed.inboxNotificationsById = {};
759
805
  break;
760
806
  }
761
807
  case "update-notification-settings": {
762
- result.notificationSettings[optimisticUpdate.roomId] = {
763
- ...result.notificationSettings[optimisticUpdate.roomId],
808
+ const settings = computed.notificationSettingsByRoomId[optimisticUpdate.roomId];
809
+ if (settings === void 0) {
810
+ break;
811
+ }
812
+ computed.notificationSettingsByRoomId[optimisticUpdate.roomId] = {
813
+ ...settings,
764
814
  ...optimisticUpdate.settings
765
815
  };
766
816
  }
767
817
  }
768
818
  }
769
- return result;
819
+ const cleanedThreads = (
820
+ // Don't expose any soft-deleted threads
821
+ Object.values(computed.threadsById).filter((thread) => !thread.deletedAt).filter(
822
+ (thread) => (
823
+ // Only keep a thread if there is at least one non-deleted comment
824
+ thread.comments.some((c) => c.deletedAt === void 0)
825
+ )
826
+ )
827
+ );
828
+ const cleanedNotifications = (
829
+ // Sort so that the most recent notifications are first
830
+ Object.values(computed.inboxNotificationsById).filter(
831
+ (ibn) => ibn.kind === "thread" ? computed.threadsById[ibn.threadId] && _optionalChain([computed, 'access', _ => _.threadsById, 'access', _2 => _2[ibn.threadId], 'optionalAccess', _3 => _3.deletedAt]) === void 0 : true
832
+ ).sort((a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime())
833
+ );
834
+ return {
835
+ inboxNotifications: cleanedNotifications,
836
+ inboxNotificationsById: computed.inboxNotificationsById,
837
+ notificationSettingsByRoomId: computed.notificationSettingsByRoomId,
838
+ queries: state.queries,
839
+ threads: cleanedThreads,
840
+ threadsById: computed.threadsById,
841
+ versionsByRoomId: state.versionsByRoomId
842
+ };
770
843
  }
771
844
  function applyThreadUpdates(existingThreads, updates) {
772
845
  const updatedThreads = { ...existingThreads };
@@ -819,7 +892,7 @@ function compareInboxNotifications(inboxNotificationA, inboxNotificationB) {
819
892
  }
820
893
  return 0;
821
894
  }
822
- function upsertComment(thread, comment) {
895
+ function applyUpsertComment(thread, comment) {
823
896
  if (thread.deletedAt !== void 0) {
824
897
  return thread;
825
898
  }
@@ -834,7 +907,7 @@ function upsertComment(thread, comment) {
834
907
  );
835
908
  if (existingComment === void 0) {
836
909
  const updatedAt = new Date(
837
- Math.max(_optionalChain([thread, 'access', _2 => _2.updatedAt, 'optionalAccess', _3 => _3.getTime, 'call', _4 => _4()]) || 0, comment.createdAt.getTime())
910
+ Math.max(_optionalChain([thread, 'access', _4 => _4.updatedAt, 'optionalAccess', _5 => _5.getTime, 'call', _6 => _6()]) || 0, comment.createdAt.getTime())
838
911
  );
839
912
  const updatedThread = {
840
913
  ...thread,
@@ -854,8 +927,8 @@ function upsertComment(thread, comment) {
854
927
  ...thread,
855
928
  updatedAt: new Date(
856
929
  Math.max(
857
- _optionalChain([thread, 'access', _5 => _5.updatedAt, 'optionalAccess', _6 => _6.getTime, 'call', _7 => _7()]) || 0,
858
- _optionalChain([comment, 'access', _8 => _8.editedAt, 'optionalAccess', _9 => _9.getTime, 'call', _10 => _10()]) || comment.createdAt.getTime()
930
+ _optionalChain([thread, 'access', _7 => _7.updatedAt, 'optionalAccess', _8 => _8.getTime, 'call', _9 => _9()]) || 0,
931
+ _optionalChain([comment, 'access', _10 => _10.editedAt, 'optionalAccess', _11 => _11.getTime, 'call', _12 => _12()]) || comment.createdAt.getTime()
859
932
  )
860
933
  ),
861
934
  comments: updatedComments
@@ -864,7 +937,7 @@ function upsertComment(thread, comment) {
864
937
  }
865
938
  return thread;
866
939
  }
867
- function deleteComment(thread, commentId, deletedAt) {
940
+ function applyDeleteComment(thread, commentId, deletedAt) {
868
941
  if (thread.deletedAt !== void 0) {
869
942
  return thread;
870
943
  }
@@ -884,12 +957,11 @@ function deleteComment(thread, commentId, deletedAt) {
884
957
  body: void 0
885
958
  } : comment
886
959
  );
887
- if (!updatedComments.some((comment) => comment.deletedAt === void 0)) {
960
+ if (updatedComments.every((comment) => comment.deletedAt !== void 0)) {
888
961
  return {
889
962
  ...thread,
890
963
  deletedAt,
891
- updatedAt: deletedAt,
892
- comments: []
964
+ updatedAt: deletedAt
893
965
  };
894
966
  }
895
967
  return {
@@ -898,7 +970,7 @@ function deleteComment(thread, commentId, deletedAt) {
898
970
  comments: updatedComments
899
971
  };
900
972
  }
901
- function addReaction(thread, commentId, reaction) {
973
+ function applyAddReaction(thread, commentId, reaction) {
902
974
  if (thread.deletedAt !== void 0) {
903
975
  return thread;
904
976
  }
@@ -920,12 +992,12 @@ function addReaction(thread, commentId, reaction) {
920
992
  return {
921
993
  ...thread,
922
994
  updatedAt: new Date(
923
- Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _11 => _11.updatedAt, 'optionalAccess', _12 => _12.getTime, 'call', _13 => _13()]) || 0)
995
+ Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _13 => _13.updatedAt, 'optionalAccess', _14 => _14.getTime, 'call', _15 => _15()]) || 0)
924
996
  ),
925
997
  comments: updatedComments
926
998
  };
927
999
  }
928
- function removeReaction(thread, commentId, emoji, userId, removedAt) {
1000
+ function applyRemoveReaction(thread, commentId, emoji, userId, removedAt) {
929
1001
  if (thread.deletedAt !== void 0) {
930
1002
  return thread;
931
1003
  }
@@ -953,7 +1025,7 @@ function removeReaction(thread, commentId, emoji, userId, removedAt) {
953
1025
  return {
954
1026
  ...thread,
955
1027
  updatedAt: new Date(
956
- Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _14 => _14.updatedAt, 'optionalAccess', _15 => _15.getTime, 'call', _16 => _16()]) || 0)
1028
+ Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _16 => _16.updatedAt, 'optionalAccess', _17 => _17.getTime, 'call', _18 => _18()]) || 0)
957
1029
  ),
958
1030
  comments: updatedComments
959
1031
  };
@@ -993,70 +1065,34 @@ function missingRoomInfoError(roomId) {
993
1065
  `resolveRoomsInfo didn't return anything for room '${roomId}'`
994
1066
  );
995
1067
  }
1068
+ function identity(x) {
1069
+ return x;
1070
+ }
996
1071
  var _umbrellaStores = /* @__PURE__ */ new WeakMap();
997
1072
  var _extras = /* @__PURE__ */ new WeakMap();
998
1073
  var _bundles = /* @__PURE__ */ new WeakMap();
999
1074
  var POLLING_INTERVAL = 60 * 1e3;
1000
- var INBOX_NOTIFICATIONS_QUERY = "INBOX_NOTIFICATIONS";
1001
1075
  var USER_THREADS_QUERY = "USER_THREADS";
1002
- function selectorFor_useInboxNotifications(state) {
1003
- const query = state.queries[INBOX_NOTIFICATIONS_QUERY];
1004
- if (query === void 0 || query.isLoading) {
1005
- return {
1006
- isLoading: true
1007
- };
1008
- }
1009
- if (query.error !== void 0) {
1010
- return {
1011
- error: query.error,
1012
- isLoading: false
1013
- };
1014
- }
1015
- return {
1016
- inboxNotifications: selectInboxNotifications(state),
1017
- isLoading: false
1018
- };
1019
- }
1020
- function selectUserThreads(state, options) {
1021
- const result = applyOptimisticUpdates(state);
1022
- let threads = Object.values(result.threads).filter(
1023
- (thread) => !thread.deletedAt
1024
- );
1025
- const query = options.query;
1026
- if (query) {
1027
- threads = threads.filter(makeThreadsFilter(query));
1028
- }
1029
- return threads.sort(byMostRecentlyUpdated);
1030
- }
1031
- function selectUnreadInboxNotificationsCount(state) {
1076
+ function selectUnreadInboxNotificationsCount(inboxNotifications) {
1032
1077
  let count = 0;
1033
- for (const notification of selectInboxNotifications(state)) {
1078
+ for (const notification of inboxNotifications) {
1034
1079
  if (notification.readAt === null || notification.readAt < notification.notifiedAt) {
1035
1080
  count++;
1036
1081
  }
1037
1082
  }
1038
1083
  return count;
1039
1084
  }
1040
- function selectorFor_useUnreadInboxNotificationsCount(state) {
1041
- const query = state.queries[INBOX_NOTIFICATIONS_QUERY];
1042
- if (query === void 0 || query.isLoading) {
1043
- return {
1044
- isLoading: true
1045
- };
1046
- }
1047
- if (query.error !== void 0) {
1048
- return {
1049
- error: query.error,
1050
- isLoading: false
1051
- };
1085
+ function selectorFor_useUnreadInboxNotificationsCount(result) {
1086
+ if (!result.inboxNotifications) {
1087
+ return result;
1052
1088
  }
1053
1089
  return {
1054
1090
  isLoading: false,
1055
- count: selectUnreadInboxNotificationsCount(state)
1091
+ count: selectUnreadInboxNotificationsCount(result.inboxNotifications)
1056
1092
  };
1057
1093
  }
1058
1094
  function selectorFor_useUser(state, userId) {
1059
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _17 => _17.isLoading])) {
1095
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _19 => _19.isLoading])) {
1060
1096
  return _nullishCoalesce(state, () => ( { isLoading: true }));
1061
1097
  }
1062
1098
  if (state.error) {
@@ -1074,7 +1110,7 @@ function selectorFor_useUser(state, userId) {
1074
1110
  };
1075
1111
  }
1076
1112
  function selectorFor_useRoomInfo(state, roomId) {
1077
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _18 => _18.isLoading])) {
1113
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _20 => _20.isLoading])) {
1078
1114
  return _nullishCoalesce(state, () => ( { isLoading: true }));
1079
1115
  }
1080
1116
  if (state.error) {
@@ -1091,11 +1127,17 @@ function selectorFor_useRoomInfo(state, roomId) {
1091
1127
  info: state.data
1092
1128
  };
1093
1129
  }
1094
- function selectInboxNotifications(state) {
1095
- const result = applyOptimisticUpdates(state);
1096
- return Object.values(result.inboxNotifications).sort(
1097
- // Sort so that the most recent notifications are first
1098
- (a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime()
1130
+ function selectThreads(state, options) {
1131
+ let threads = state.threads;
1132
+ if (options.roomId !== null) {
1133
+ threads = threads.filter((thread) => thread.roomId === options.roomId);
1134
+ }
1135
+ const query = options.query;
1136
+ if (query) {
1137
+ threads = threads.filter(makeThreadsFilter(query));
1138
+ }
1139
+ return threads.sort(
1140
+ options.orderBy === "last-update" ? byMostRecentlyUpdated : byFirstCreated
1099
1141
  );
1100
1142
  }
1101
1143
  function getOrCreateContextBundle(client) {
@@ -1178,23 +1220,21 @@ function makeExtrasForClient(client) {
1178
1220
  void waitUntilInboxNotificationsLoaded().catch(() => {
1179
1221
  });
1180
1222
  }
1181
- function useEnableInboxNotificationsPolling() {
1182
- _react.useEffect.call(void 0, () => {
1183
- pollerSubscribers++;
1184
- poller.start(POLLING_INTERVAL);
1185
- return () => {
1186
- if (pollerSubscribers <= 0) {
1187
- console.warn(
1188
- `Internal unexpected behavior. Cannot decrease subscriber count for query "${INBOX_NOTIFICATIONS_QUERY}"`
1189
- );
1190
- return;
1191
- }
1192
- pollerSubscribers--;
1193
- if (pollerSubscribers <= 0) {
1194
- poller.stop();
1195
- }
1196
- };
1197
- }, []);
1223
+ function startPolling() {
1224
+ pollerSubscribers++;
1225
+ poller.start(POLLING_INTERVAL);
1226
+ return () => {
1227
+ if (pollerSubscribers <= 0) {
1228
+ console.warn(
1229
+ `Internal unexpected behavior. Cannot decrease subscriber count for query "${INBOX_NOTIFICATIONS_QUERY}"`
1230
+ );
1231
+ return;
1232
+ }
1233
+ pollerSubscribers--;
1234
+ if (pollerSubscribers <= 0) {
1235
+ poller.stop();
1236
+ }
1237
+ };
1198
1238
  }
1199
1239
  const userThreadsPoller = _core.makePoller.call(void 0, refreshUserThreads);
1200
1240
  let isFetchingUserThreadsUpdates = false;
@@ -1279,7 +1319,7 @@ function makeExtrasForClient(client) {
1279
1319
  }
1280
1320
  return {
1281
1321
  store,
1282
- useEnableInboxNotificationsPolling,
1322
+ startPolling,
1283
1323
  waitUntilInboxNotificationsLoaded,
1284
1324
  loadInboxNotifications,
1285
1325
  incrementUserThreadsQuerySubscribers,
@@ -1324,16 +1364,14 @@ function makeLiveblocksContextBundle(client) {
1324
1364
  return bundle;
1325
1365
  }
1326
1366
  function useInboxNotifications_withClient(client) {
1327
- const { loadInboxNotifications, store, useEnableInboxNotificationsPolling } = getExtrasForClient(client);
1328
- _react.useEffect.call(void 0, () => {
1329
- loadInboxNotifications();
1330
- }, [loadInboxNotifications]);
1331
- useEnableInboxNotificationsPolling();
1367
+ const { loadInboxNotifications, store, startPolling } = getExtrasForClient(client);
1368
+ _react.useEffect.call(void 0, loadInboxNotifications, [loadInboxNotifications]);
1369
+ _react.useEffect.call(void 0, startPolling, [startPolling]);
1332
1370
  return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
1333
- store.subscribe,
1334
- store.get,
1335
- store.get,
1336
- selectorFor_useInboxNotifications,
1371
+ store.subscribeInboxNotifications,
1372
+ store.getInboxNotificationsAsync,
1373
+ store.getInboxNotificationsAsync,
1374
+ identity,
1337
1375
  _core.shallow
1338
1376
  );
1339
1377
  }
@@ -1346,15 +1384,13 @@ function useInboxNotificationsSuspense_withClient(client) {
1346
1384
  return result;
1347
1385
  }
1348
1386
  function useUnreadInboxNotificationsCount_withClient(client) {
1349
- const { store, loadInboxNotifications, useEnableInboxNotificationsPolling } = getExtrasForClient(client);
1350
- _react.useEffect.call(void 0, () => {
1351
- loadInboxNotifications();
1352
- }, [loadInboxNotifications]);
1353
- useEnableInboxNotificationsPolling();
1387
+ const { store, loadInboxNotifications, startPolling } = getExtrasForClient(client);
1388
+ _react.useEffect.call(void 0, loadInboxNotifications, [loadInboxNotifications]);
1389
+ _react.useEffect.call(void 0, startPolling, [startPolling]);
1354
1390
  return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
1355
- store.subscribe,
1356
- store.get,
1357
- store.get,
1391
+ store.subscribeInboxNotifications,
1392
+ store.getInboxNotificationsAsync,
1393
+ store.getInboxNotificationsAsync,
1358
1394
  selectorFor_useUnreadInboxNotificationsCount,
1359
1395
  _core.shallow
1360
1396
  );
@@ -1461,13 +1497,13 @@ function useInboxNotificationThread_withClient(client, inboxNotificationId) {
1461
1497
  const { store } = getExtrasForClient(client);
1462
1498
  const selector = _react.useCallback.call(void 0,
1463
1499
  (state) => {
1464
- const inboxNotification = _nullishCoalesce(state.inboxNotifications[inboxNotificationId], () => ( _core.raise.call(void 0, `Inbox notification with ID "${inboxNotificationId}" not found`)));
1500
+ const inboxNotification = _nullishCoalesce(state.inboxNotificationsById[inboxNotificationId], () => ( _core.raise.call(void 0, `Inbox notification with ID "${inboxNotificationId}" not found`)));
1465
1501
  if (inboxNotification.kind !== "thread") {
1466
1502
  _core.raise.call(void 0,
1467
1503
  `Inbox notification with ID "${inboxNotificationId}" is not of kind "thread"`
1468
1504
  );
1469
1505
  }
1470
- const thread = _nullishCoalesce(state.threads[inboxNotification.threadId], () => ( _core.raise.call(void 0,
1506
+ const thread = _nullishCoalesce(state.threadsById[inboxNotification.threadId], () => ( _core.raise.call(void 0,
1471
1507
  `Thread with ID "${inboxNotification.threadId}" not found, this inbox notification might not be of kind "thread"`
1472
1508
  )));
1473
1509
  return thread;
@@ -1475,9 +1511,9 @@ function useInboxNotificationThread_withClient(client, inboxNotificationId) {
1475
1511
  [inboxNotificationId]
1476
1512
  );
1477
1513
  return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
1478
- store.subscribe,
1479
- store.get,
1480
- store.get,
1514
+ store.subscribeInboxNotifications,
1515
+ store.getInboxNotifications,
1516
+ store.getInboxNotifications,
1481
1517
  selector
1482
1518
  );
1483
1519
  }
@@ -1591,19 +1627,19 @@ function createSharedContext(client) {
1591
1627
  useClient: useClient2,
1592
1628
  useUser: (userId) => useUser_withClient(client, userId),
1593
1629
  useRoomInfo: (roomId) => useRoomInfo_withClient(client, roomId),
1594
- useIsInsideRoom: _useIsInsideRoom
1630
+ useIsInsideRoom
1595
1631
  },
1596
1632
  suspense: {
1597
1633
  useClient: useClient2,
1598
1634
  useUser: (userId) => useUserSuspense_withClient(client, userId),
1599
1635
  useRoomInfo: (roomId) => useRoomInfoSuspense_withClient(client, roomId),
1600
- useIsInsideRoom: _useIsInsideRoom
1636
+ useIsInsideRoom
1601
1637
  }
1602
1638
  };
1603
1639
  }
1604
1640
  function useEnsureNoLiveblocksProvider(options) {
1605
1641
  const existing = useClientOrNull();
1606
- if (!_optionalChain([options, 'optionalAccess', _19 => _19.allowNesting]) && existing !== null) {
1642
+ if (!_optionalChain([options, 'optionalAccess', _21 => _21.allowNesting]) && existing !== null) {
1607
1643
  throw new Error(
1608
1644
  "You cannot nest multiple LiveblocksProvider instances in the same React tree."
1609
1645
  );
@@ -1681,18 +1717,24 @@ function useUserThreads_experimental(options = {
1681
1717
  };
1682
1718
  }
1683
1719
  return {
1684
- threads: selectUserThreads(state, options),
1720
+ threads: selectThreads(state, {
1721
+ roomId: null,
1722
+ // Do _not_ filter by roomId
1723
+ query: options.query,
1724
+ orderBy: "last-update"
1725
+ }),
1685
1726
  isLoading: false
1686
1727
  };
1687
1728
  },
1688
1729
  [queryKey, options]
1689
1730
  );
1690
1731
  return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
1691
- store.subscribe,
1692
- store.get,
1693
- store.get,
1732
+ store.subscribeThreads,
1733
+ store.getThreads,
1734
+ store.getThreads,
1694
1735
  selector,
1695
- _core.shallow
1736
+ shallow2
1737
+ // NOTE: Using 2-level-deep shallow check here, because the result of selectThreads() is not stable!
1696
1738
  );
1697
1739
  }
1698
1740
  function useUserThreadsSuspense_experimental(options = {
@@ -1710,7 +1752,7 @@ function useUserThreadsSuspense_experimental(options = {
1710
1752
  const { incrementUserThreadsQuerySubscribers } = getExtrasForClient(client);
1711
1753
  return incrementUserThreadsQuerySubscribers(queryKey);
1712
1754
  }, [client, queryKey]);
1713
- const query = store.get().queries[queryKey];
1755
+ const query = store.getThreads().queries[queryKey];
1714
1756
  if (query === void 0 || query.isLoading) {
1715
1757
  throw getUserThreads(queryKey, options);
1716
1758
  }
@@ -1720,18 +1762,24 @@ function useUserThreadsSuspense_experimental(options = {
1720
1762
  const selector = _react.useCallback.call(void 0,
1721
1763
  (state) => {
1722
1764
  return {
1723
- threads: selectUserThreads(state, options),
1765
+ threads: selectThreads(state, {
1766
+ roomId: null,
1767
+ // Do _not_ filter by roomId
1768
+ query: options.query,
1769
+ orderBy: "last-update"
1770
+ }),
1724
1771
  isLoading: false
1725
1772
  };
1726
1773
  },
1727
1774
  [options]
1728
1775
  );
1729
1776
  return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
1730
- store.subscribe,
1731
- store.get,
1732
- store.get,
1777
+ store.subscribeThreads,
1778
+ store.getThreads,
1779
+ store.getThreads,
1733
1780
  selector,
1734
- _core.shallow
1781
+ shallow2
1782
+ // NOTE: Using 2-level-deep shallow check here, because the result of selectThreads() is not stable!
1735
1783
  );
1736
1784
  }
1737
1785
  function useInboxNotifications() {
@@ -1785,6 +1833,123 @@ var _useUserThreads_experimental = useUserThreads_experimental;
1785
1833
  var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
1786
1834
  var makeUserThreadsQueryKey = (options) => `${USER_THREADS_QUERY}:${_core.stringify.call(void 0, options)}`;
1787
1835
 
1836
+ // src/types/errors.ts
1837
+ var CreateThreadError = class extends Error {
1838
+ constructor(cause, context) {
1839
+ super("Create thread failed.");
1840
+ this.cause = cause;
1841
+ this.context = context;
1842
+ this.name = "CreateThreadError";
1843
+ }
1844
+ };
1845
+ var DeleteThreadError = class extends Error {
1846
+ constructor(cause, context) {
1847
+ super("Delete thread failed.");
1848
+ this.cause = cause;
1849
+ this.context = context;
1850
+ this.name = "DeleteThreadError";
1851
+ }
1852
+ };
1853
+ var EditThreadMetadataError = class extends Error {
1854
+ constructor(cause, context) {
1855
+ super("Edit thread metadata failed.");
1856
+ this.cause = cause;
1857
+ this.context = context;
1858
+ this.name = "EditThreadMetadataError";
1859
+ }
1860
+ };
1861
+ var MarkThreadAsResolvedError = class extends Error {
1862
+ constructor(cause, context) {
1863
+ super("Mark thread as resolved failed.");
1864
+ this.cause = cause;
1865
+ this.context = context;
1866
+ this.name = "MarkThreadAsResolvedError";
1867
+ }
1868
+ };
1869
+ var MarkThreadAsUnresolvedError = class extends Error {
1870
+ constructor(cause, context) {
1871
+ super("Mark thread as unresolved failed.");
1872
+ this.cause = cause;
1873
+ this.context = context;
1874
+ this.name = "MarkThreadAsUnresolvedError";
1875
+ }
1876
+ };
1877
+ var CreateCommentError = class extends Error {
1878
+ constructor(cause, context) {
1879
+ super("Create comment failed.");
1880
+ this.cause = cause;
1881
+ this.context = context;
1882
+ this.name = "CreateCommentError";
1883
+ }
1884
+ };
1885
+ var EditCommentError = class extends Error {
1886
+ constructor(cause, context) {
1887
+ super("Edit comment failed.");
1888
+ this.cause = cause;
1889
+ this.context = context;
1890
+ this.name = "EditCommentError";
1891
+ }
1892
+ };
1893
+ var DeleteCommentError = class extends Error {
1894
+ constructor(cause, context) {
1895
+ super("Delete comment failed.");
1896
+ this.cause = cause;
1897
+ this.context = context;
1898
+ this.name = "DeleteCommentError";
1899
+ }
1900
+ };
1901
+ var AddReactionError = class extends Error {
1902
+ constructor(cause, context) {
1903
+ super("Add reaction failed.");
1904
+ this.cause = cause;
1905
+ this.context = context;
1906
+ this.name = "AddReactionError";
1907
+ }
1908
+ };
1909
+ var RemoveReactionError = class extends Error {
1910
+ constructor(cause, context) {
1911
+ super("Remove reaction failed.");
1912
+ this.cause = cause;
1913
+ this.context = context;
1914
+ this.name = "RemoveReactionError";
1915
+ }
1916
+ };
1917
+ var MarkInboxNotificationAsReadError = class extends Error {
1918
+ constructor(cause, context) {
1919
+ super("Mark inbox notification as read failed.");
1920
+ this.cause = cause;
1921
+ this.context = context;
1922
+ this.name = "MarkInboxNotificationAsReadError";
1923
+ }
1924
+ };
1925
+ var UpdateNotificationSettingsError = class extends Error {
1926
+ constructor(cause, context) {
1927
+ super("Update notification settings failed.");
1928
+ this.cause = cause;
1929
+ this.context = context;
1930
+ this.name = "UpdateNotificationSettingsError";
1931
+ }
1932
+ };
1933
+
1934
+ // src/room.tsx
1935
+ var _client = require('@liveblocks/client');
1936
+
1937
+
1938
+
1939
+
1940
+
1941
+
1942
+
1943
+
1944
+
1945
+
1946
+
1947
+
1948
+
1949
+
1950
+
1951
+
1952
+
1788
1953
  // src/use-scroll-to-comment-on-load-effect.ts
1789
1954
 
1790
1955
  function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
@@ -1805,7 +1970,7 @@ function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
1805
1970
  comment.scrollIntoView();
1806
1971
  }
1807
1972
  function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
1808
- React3.useEffect(
1973
+ React4.useEffect(
1809
1974
  () => {
1810
1975
  handleScrollToCommentOnLoad(shouldScrollOnLoad, state);
1811
1976
  },
@@ -1818,7 +1983,7 @@ function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
1818
1983
  var SMOOTH_DELAY = 1e3;
1819
1984
  var noop2 = () => {
1820
1985
  };
1821
- var identity = (x) => x;
1986
+ var identity2 = (x) => x;
1822
1987
  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:
1823
1988
 
1824
1989
  import { unstable_batchedUpdates } from "react-dom"; // or "react-native"
@@ -1832,13 +1997,10 @@ var missing_unstable_batchedUpdates = (reactVersion, roomId) => `We noticed you\
1832
1997
  Why? Please see https://liveblocks.io/docs/platform/troubleshooting#stale-props-zombie-child for more information`;
1833
1998
  var superfluous_unstable_batchedUpdates = "You don\u2019t need to pass unstable_batchedUpdates to RoomProvider anymore, since you\u2019re on React 18+ already.";
1834
1999
  function useSyncExternalStore2(s, gs, gss) {
1835
- return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0, s, gs, gss, identity);
2000
+ return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0, s, gs, gss, identity2);
1836
2001
  }
1837
2002
  var STABLE_EMPTY_LIST = Object.freeze([]);
1838
2003
  var POLLING_INTERVAL2 = 5 * 60 * 1e3;
1839
- function makeNotificationSettingsQueryKey(roomId) {
1840
- return `${roomId}:NOTIFICATION_SETTINGS`;
1841
- }
1842
2004
  function alwaysEmptyList() {
1843
2005
  return STABLE_EMPTY_LIST;
1844
2006
  }
@@ -1848,22 +2010,6 @@ function alwaysNull() {
1848
2010
  function selectorFor_useOthersConnectionIds(others) {
1849
2011
  return others.map((user) => user.connectionId);
1850
2012
  }
1851
- function selectRoomThreads(roomId, state, options) {
1852
- const result = applyOptimisticUpdates(state);
1853
- let threads = Object.values(result.threads).filter(
1854
- (thread) => !thread.deletedAt
1855
- );
1856
- threads = threads.filter((thread) => thread.roomId === roomId);
1857
- const query = options.query;
1858
- if (query) {
1859
- threads = threads.filter(makeThreadsFilter(query));
1860
- }
1861
- return threads.sort(byFirstCreated);
1862
- }
1863
- function selectNotificationSettings(roomId, state) {
1864
- const { notificationSettings } = applyOptimisticUpdates(state);
1865
- return _core.nn.call(void 0, notificationSettings[roomId]);
1866
- }
1867
2013
  function makeMutationContext(room) {
1868
2014
  const cannotUseUntil = "This mutation cannot be used until";
1869
2015
  const needsPresence = `${cannotUseUntil} connected to the Liveblocks room`;
@@ -1903,7 +2049,7 @@ function getCurrentUserId(room) {
1903
2049
  }
1904
2050
  function handleApiError(err) {
1905
2051
  const message = `Request failed with status ${err.status}: ${err.message}`;
1906
- if (_optionalChain([err, 'access', _20 => _20.details, 'optionalAccess', _21 => _21.error]) === "FORBIDDEN") {
2052
+ if (_optionalChain([err, 'access', _22 => _22.details, 'optionalAccess', _23 => _23.error]) === "FORBIDDEN") {
1907
2053
  const detailedMessage = [message, err.details.suggestion, err.details.docs].filter(Boolean).join("\n");
1908
2054
  _core.console.error(detailedMessage);
1909
2055
  }
@@ -1992,7 +2138,7 @@ function makeExtrasForClient2(client) {
1992
2138
  }
1993
2139
  }
1994
2140
  async function getRoomVersions(room, { retryCount } = { retryCount: 0 }) {
1995
- const queryKey = getVersionsQueryKey(room.id);
2141
+ const queryKey = makeVersionsQueryKey(room.id);
1996
2142
  const existingRequest = requestsByQuery.get(queryKey);
1997
2143
  if (existingRequest !== void 0) return existingRequest;
1998
2144
  const request = room[_core.kInternal].listTextVersions();
@@ -2052,7 +2198,8 @@ function makeExtrasForClient2(client) {
2052
2198
  }
2053
2199
  return;
2054
2200
  }
2055
- async function getInboxNotificationSettings(room, queryKey, { retryCount } = { retryCount: 0 }) {
2201
+ async function getInboxNotificationSettings(room, { retryCount } = { retryCount: 0 }) {
2202
+ const queryKey = makeNotificationSettingsQueryKey(room.id);
2056
2203
  const existingRequest = requestsByQuery.get(queryKey);
2057
2204
  if (existingRequest !== void 0) return existingRequest;
2058
2205
  try {
@@ -2064,7 +2211,7 @@ function makeExtrasForClient2(client) {
2064
2211
  } catch (err) {
2065
2212
  requestsByQuery.delete(queryKey);
2066
2213
  retryError(() => {
2067
- void getInboxNotificationSettings(room, queryKey, {
2214
+ void getInboxNotificationSettings(room, {
2068
2215
  retryCount: retryCount + 1
2069
2216
  });
2070
2217
  }, retryCount);
@@ -2097,10 +2244,9 @@ function makeExtrasForClient2(client) {
2097
2244
  onMutationFailure
2098
2245
  };
2099
2246
  }
2100
- var RoomContext = React4.createContext(null);
2101
2247
  function makeRoomContextBundle(client) {
2102
2248
  function RoomProvider_withImplicitLiveblocksProvider(props) {
2103
- return /* @__PURE__ */ React4.createElement(LiveblocksProviderWithClient, { client, allowNesting: true }, /* @__PURE__ */ React4.createElement(RoomProvider, { ...props }));
2249
+ return /* @__PURE__ */ React5.createElement(LiveblocksProviderWithClient, { client, allowNesting: true }, /* @__PURE__ */ React5.createElement(RoomProvider, { ...props }));
2104
2250
  }
2105
2251
  const shared = createSharedContext(client);
2106
2252
  const bundle = {
@@ -2202,10 +2348,10 @@ function makeRoomContextBundle(client) {
2202
2348
  }
2203
2349
  function RoomProvider(props) {
2204
2350
  const client = useClient();
2205
- const [cache] = React4.useState(
2351
+ const [cache] = React5.useState(
2206
2352
  () => /* @__PURE__ */ new Map()
2207
2353
  );
2208
- const stableEnterRoom = React4.useCallback(
2354
+ const stableEnterRoom = React5.useCallback(
2209
2355
  (roomId, options) => {
2210
2356
  const cached = cache.get(roomId);
2211
2357
  if (cached) return cached;
@@ -2220,7 +2366,7 @@ function RoomProvider(props) {
2220
2366
  },
2221
2367
  [client, cache]
2222
2368
  );
2223
- return /* @__PURE__ */ React4.createElement(
2369
+ return /* @__PURE__ */ React5.createElement(
2224
2370
  RoomProviderInner,
2225
2371
  {
2226
2372
  ...props,
@@ -2240,7 +2386,7 @@ function RoomProviderInner(props) {
2240
2386
  if (!isString(roomId)) {
2241
2387
  throw new Error("RoomProvider id property should be a string.");
2242
2388
  }
2243
- const majorReactVersion = parseInt(React4.version) || 1;
2389
+ const majorReactVersion = parseInt(React5.version) || 1;
2244
2390
  const oldReactVersion = majorReactVersion < 18;
2245
2391
  _core.errorIf.call(void 0,
2246
2392
  oldReactVersion && props.unstable_batchedUpdates === void 0,
@@ -2257,14 +2403,14 @@ function RoomProviderInner(props) {
2257
2403
  unstable_batchedUpdates: props.unstable_batchedUpdates,
2258
2404
  autoConnect: _nullishCoalesce(props.autoConnect, () => ( typeof window !== "undefined"))
2259
2405
  });
2260
- const [{ room }, setRoomLeavePair] = React4.useState(
2406
+ const [{ room }, setRoomLeavePair] = React5.useState(
2261
2407
  () => stableEnterRoom(roomId, {
2262
2408
  ...frozenProps,
2263
2409
  autoConnect: false
2264
2410
  // Deliberately using false here on the first render, see below
2265
2411
  })
2266
2412
  );
2267
- React4.useEffect(() => {
2413
+ React5.useEffect(() => {
2268
2414
  const { store } = getExtrasForClient2(client);
2269
2415
  async function handleCommentEvent(message) {
2270
2416
  if (message.type === _core.ServerMsgCode.THREAD_DELETED) {
@@ -2277,7 +2423,7 @@ function RoomProviderInner(props) {
2277
2423
  return;
2278
2424
  }
2279
2425
  const { thread, inboxNotification } = info;
2280
- const existingThread = store.get().threads[message.threadId];
2426
+ const existingThread = store.getThreads().threadsById[message.threadId];
2281
2427
  switch (message.type) {
2282
2428
  case _core.ServerMsgCode.COMMENT_EDITED:
2283
2429
  case _core.ServerMsgCode.THREAD_METADATA_UPDATED:
@@ -2299,11 +2445,11 @@ function RoomProviderInner(props) {
2299
2445
  (message) => void handleCommentEvent(message)
2300
2446
  );
2301
2447
  }, [client, room]);
2302
- React4.useEffect(() => {
2448
+ React5.useEffect(() => {
2303
2449
  const { getThreadsUpdates } = getExtrasForClient2(client);
2304
2450
  void getThreadsUpdates(room.id);
2305
2451
  }, [client, room.id]);
2306
- React4.useEffect(() => {
2452
+ React5.useEffect(() => {
2307
2453
  function handleIsOnline() {
2308
2454
  const { getThreadsUpdates } = getExtrasForClient2(client);
2309
2455
  void getThreadsUpdates(room.id);
@@ -2313,7 +2459,7 @@ function RoomProviderInner(props) {
2313
2459
  window.removeEventListener("online", handleIsOnline);
2314
2460
  };
2315
2461
  }, [client, room.id]);
2316
- React4.useEffect(() => {
2462
+ React5.useEffect(() => {
2317
2463
  const pair = stableEnterRoom(roomId, frozenProps);
2318
2464
  setRoomLeavePair(pair);
2319
2465
  const { room: room2, leave } = pair;
@@ -2324,7 +2470,7 @@ function RoomProviderInner(props) {
2324
2470
  leave();
2325
2471
  };
2326
2472
  }, [roomId, frozenProps, stableEnterRoom]);
2327
- return /* @__PURE__ */ React4.createElement(RoomContext.Provider, { value: room }, props.children);
2473
+ return /* @__PURE__ */ React5.createElement(RoomContext.Provider, { value: room }, props.children);
2328
2474
  }
2329
2475
  function useRoom() {
2330
2476
  const room = useRoomOrNull();
@@ -2333,10 +2479,6 @@ function useRoom() {
2333
2479
  }
2334
2480
  return room;
2335
2481
  }
2336
- function useIsInsideRoom() {
2337
- const room = useRoomOrNull();
2338
- return room !== null;
2339
- }
2340
2482
  function useStatus() {
2341
2483
  const room = useRoom();
2342
2484
  const subscribe = room.events.status.subscribe;
@@ -2345,7 +2487,7 @@ function useStatus() {
2345
2487
  return useSyncExternalStore2(subscribe, getSnapshot, getServerSnapshot);
2346
2488
  }
2347
2489
  function useStorageStatus(options) {
2348
- const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.smooth]), () => ( false)));
2490
+ const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _24 => _24.smooth]), () => ( false)));
2349
2491
  if (smooth) {
2350
2492
  return useStorageStatusSmooth();
2351
2493
  } else {
@@ -2361,9 +2503,9 @@ function useStorageStatusImmediate() {
2361
2503
  }
2362
2504
  function useStorageStatusSmooth() {
2363
2505
  const room = useRoom();
2364
- const [status, setStatus] = React4.useState(room.getStorageStatus);
2506
+ const [status, setStatus] = React5.useState(room.getStorageStatus);
2365
2507
  const oldStatus = useLatest(room.getStorageStatus());
2366
- React4.useEffect(() => {
2508
+ React5.useEffect(() => {
2367
2509
  let timeoutId;
2368
2510
  const unsub = room.events.storageStatus.subscribe((newStatus) => {
2369
2511
  if (oldStatus.current === "synchronizing" && newStatus === "synchronized") {
@@ -2385,7 +2527,7 @@ function useBatch() {
2385
2527
  }
2386
2528
  function useBroadcastEvent() {
2387
2529
  const room = useRoom();
2388
- return React4.useCallback(
2530
+ return React5.useCallback(
2389
2531
  (event, options = { shouldQueueEventIfNotReady: false }) => {
2390
2532
  room.broadcastEvent(event, options);
2391
2533
  },
@@ -2395,7 +2537,7 @@ function useBroadcastEvent() {
2395
2537
  function useOthersListener(callback) {
2396
2538
  const room = useRoom();
2397
2539
  const savedCallback = useLatest(callback);
2398
- React4.useEffect(
2540
+ React5.useEffect(
2399
2541
  () => room.events.others.subscribe((event) => savedCallback.current(event)),
2400
2542
  [room, savedCallback]
2401
2543
  );
@@ -2403,7 +2545,7 @@ function useOthersListener(callback) {
2403
2545
  function useLostConnectionListener(callback) {
2404
2546
  const room = useRoom();
2405
2547
  const savedCallback = useLatest(callback);
2406
- React4.useEffect(
2548
+ React5.useEffect(
2407
2549
  () => room.events.lostConnection.subscribe(
2408
2550
  (event) => savedCallback.current(event)
2409
2551
  ),
@@ -2413,7 +2555,7 @@ function useLostConnectionListener(callback) {
2413
2555
  function useErrorListener(callback) {
2414
2556
  const room = useRoom();
2415
2557
  const savedCallback = useLatest(callback);
2416
- React4.useEffect(
2558
+ React5.useEffect(
2417
2559
  () => room.events.error.subscribe((e) => savedCallback.current(e)),
2418
2560
  [room, savedCallback]
2419
2561
  );
@@ -2421,7 +2563,7 @@ function useErrorListener(callback) {
2421
2563
  function useEventListener(callback) {
2422
2564
  const room = useRoom();
2423
2565
  const savedCallback = useLatest(callback);
2424
- React4.useEffect(() => {
2566
+ React5.useEffect(() => {
2425
2567
  const listener = (eventData) => {
2426
2568
  savedCallback.current(eventData);
2427
2569
  };
@@ -2453,8 +2595,8 @@ function useSelf(maybeSelector, isEqual) {
2453
2595
  const room = useRoom();
2454
2596
  const subscribe = room.events.self.subscribe;
2455
2597
  const getSnapshot = room.getSelf;
2456
- const selector = _nullishCoalesce(maybeSelector, () => ( identity));
2457
- const wrappedSelector = React4.useCallback(
2598
+ const selector = _nullishCoalesce(maybeSelector, () => ( identity2));
2599
+ const wrappedSelector = React5.useCallback(
2458
2600
  (me) => me !== null ? selector(me) : null,
2459
2601
  [selector]
2460
2602
  );
@@ -2487,16 +2629,16 @@ function useOthers(selector, isEqual) {
2487
2629
  subscribe,
2488
2630
  getSnapshot,
2489
2631
  getServerSnapshot,
2490
- _nullishCoalesce(selector, () => ( identity)),
2632
+ _nullishCoalesce(selector, () => ( identity2)),
2491
2633
  isEqual
2492
2634
  );
2493
2635
  }
2494
2636
  function useOthersMapped(itemSelector, itemIsEqual) {
2495
- const wrappedSelector = React4.useCallback(
2637
+ const wrappedSelector = React5.useCallback(
2496
2638
  (others) => others.map((other) => [other.connectionId, itemSelector(other)]),
2497
2639
  [itemSelector]
2498
2640
  );
2499
- const wrappedIsEqual = React4.useCallback(
2641
+ const wrappedIsEqual = React5.useCallback(
2500
2642
  (a, b) => {
2501
2643
  const eq = _nullishCoalesce(itemIsEqual, () => ( Object.is));
2502
2644
  return a.length === b.length && a.every((atuple, index) => {
@@ -2513,14 +2655,14 @@ function useOthersConnectionIds() {
2513
2655
  }
2514
2656
  var NOT_FOUND = Symbol();
2515
2657
  function useOther(connectionId, selector, isEqual) {
2516
- const wrappedSelector = React4.useCallback(
2658
+ const wrappedSelector = React5.useCallback(
2517
2659
  (others) => {
2518
2660
  const other2 = others.find((other3) => other3.connectionId === connectionId);
2519
2661
  return other2 !== void 0 ? selector(other2) : NOT_FOUND;
2520
2662
  },
2521
2663
  [connectionId, selector]
2522
2664
  );
2523
- const wrappedIsEqual = React4.useCallback(
2665
+ const wrappedIsEqual = React5.useCallback(
2524
2666
  (prev, curr) => {
2525
2667
  if (prev === NOT_FOUND || curr === NOT_FOUND) {
2526
2668
  return prev === curr;
@@ -2551,15 +2693,15 @@ function useStorageRoot() {
2551
2693
  function useStorage(selector, isEqual) {
2552
2694
  const room = useRoom();
2553
2695
  const rootOrNull = useMutableStorageRoot();
2554
- const wrappedSelector = React4.useCallback(
2696
+ const wrappedSelector = React5.useCallback(
2555
2697
  (rootOrNull2) => rootOrNull2 !== null ? selector(rootOrNull2) : null,
2556
2698
  [selector]
2557
2699
  );
2558
- const subscribe = React4.useCallback(
2700
+ const subscribe = React5.useCallback(
2559
2701
  (onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) : noop2,
2560
2702
  [room, rootOrNull]
2561
2703
  );
2562
- const getSnapshot = React4.useCallback(() => {
2704
+ const getSnapshot = React5.useCallback(() => {
2563
2705
  if (rootOrNull === null) {
2564
2706
  return null;
2565
2707
  } else {
@@ -2579,7 +2721,7 @@ function useStorage(selector, isEqual) {
2579
2721
  }
2580
2722
  function useMutation(callback, deps) {
2581
2723
  const room = useRoom();
2582
- return React4.useMemo(
2724
+ return React5.useMemo(
2583
2725
  () => {
2584
2726
  return (...args) => (
2585
2727
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
@@ -2604,16 +2746,16 @@ function useThreads(options = {
2604
2746
  const { scrollOnLoad = true } = options;
2605
2747
  const client = useClient();
2606
2748
  const room = useRoom();
2607
- const queryKey = React4.useMemo(
2749
+ const queryKey = React5.useMemo(
2608
2750
  () => generateQueryKey(room.id, options.query),
2609
2751
  [room, options]
2610
2752
  );
2611
2753
  const { store, getThreadsAndInboxNotifications, incrementQuerySubscribers } = getExtrasForClient2(client);
2612
- React4.useEffect(() => {
2754
+ React5.useEffect(() => {
2613
2755
  void getThreadsAndInboxNotifications(room, queryKey, options);
2614
2756
  return incrementQuerySubscribers(queryKey);
2615
2757
  }, [room, queryKey]);
2616
- const selector = React4.useCallback(
2758
+ const selector = React5.useCallback(
2617
2759
  (state2) => {
2618
2760
  const query = state2.queries[queryKey];
2619
2761
  if (query === void 0 || query.isLoading) {
@@ -2622,7 +2764,11 @@ function useThreads(options = {
2622
2764
  };
2623
2765
  }
2624
2766
  return {
2625
- threads: selectRoomThreads(room.id, state2, options),
2767
+ threads: selectThreads(state2, {
2768
+ roomId: room.id,
2769
+ query: options.query,
2770
+ orderBy: "age"
2771
+ }),
2626
2772
  isLoading: false,
2627
2773
  error: query.error
2628
2774
  };
@@ -2631,9 +2777,9 @@ function useThreads(options = {
2631
2777
  // eslint-disable-line react-hooks/exhaustive-deps
2632
2778
  );
2633
2779
  const state = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
2634
- store.subscribe,
2635
- store.get,
2636
- store.get,
2780
+ store.subscribeThreads,
2781
+ store.getThreads,
2782
+ store.getThreads,
2637
2783
  selector
2638
2784
  );
2639
2785
  useScrollToCommentOnLoadEffect(scrollOnLoad, state);
@@ -2643,14 +2789,14 @@ function useCommentsErrorListener(callback) {
2643
2789
  const client = useClient();
2644
2790
  const savedCallback = useLatest(callback);
2645
2791
  const { commentsErrorEventSource } = getExtrasForClient2(client);
2646
- React4.useEffect(() => {
2792
+ React5.useEffect(() => {
2647
2793
  return commentsErrorEventSource.subscribe(savedCallback.current);
2648
2794
  }, [savedCallback, commentsErrorEventSource]);
2649
2795
  }
2650
2796
  function useCreateThread() {
2651
2797
  const client = useClient();
2652
2798
  const room = useRoom();
2653
- return React4.useCallback(
2799
+ return React5.useCallback(
2654
2800
  (options) => {
2655
2801
  const body = options.body;
2656
2802
  const metadata = _nullishCoalesce(options.metadata, () => ( {}));
@@ -2707,12 +2853,12 @@ function useCreateThread() {
2707
2853
  function useDeleteThread() {
2708
2854
  const client = useClient();
2709
2855
  const room = useRoom();
2710
- return React4.useCallback(
2856
+ return React5.useCallback(
2711
2857
  (threadId) => {
2712
2858
  const { store, onMutationFailure } = getExtrasForClient2(client);
2713
- const thread = store.get().threads[threadId];
2859
+ const thread = store.getThreads().threadsById[threadId];
2714
2860
  const userId = getCurrentUserId(room);
2715
- if (_optionalChain([thread, 'optionalAccess', _23 => _23.comments, 'optionalAccess', _24 => _24[0], 'optionalAccess', _25 => _25.userId]) !== userId) {
2861
+ if (_optionalChain([thread, 'optionalAccess', _25 => _25.comments, 'optionalAccess', _26 => _26[0], 'optionalAccess', _27 => _27.userId]) !== userId) {
2716
2862
  throw new Error("Only the thread creator can delete the thread");
2717
2863
  }
2718
2864
  const optimisticUpdateId = store.addOptimisticUpdate({
@@ -2738,7 +2884,7 @@ function useDeleteThread() {
2738
2884
  function useEditThreadMetadata() {
2739
2885
  const client = useClient();
2740
2886
  const room = useRoom();
2741
- return React4.useCallback(
2887
+ return React5.useCallback(
2742
2888
  (options) => {
2743
2889
  if (!options.metadata) {
2744
2890
  return;
@@ -2756,10 +2902,10 @@ function useEditThreadMetadata() {
2756
2902
  room.editThreadMetadata({ threadId, metadata }).then(
2757
2903
  (metadata2) => (
2758
2904
  // Replace the optimistic update by the real thing
2759
- store.updateThread(
2905
+ store.patchThread(
2760
2906
  threadId,
2761
2907
  optimisticUpdateId,
2762
- (thread) => ({ ...thread, metadata: metadata2 }),
2908
+ { metadata: metadata2 },
2763
2909
  updatedAt
2764
2910
  )
2765
2911
  ),
@@ -2780,7 +2926,7 @@ function useEditThreadMetadata() {
2780
2926
  function useCreateComment() {
2781
2927
  const client = useClient();
2782
2928
  const room = useRoom();
2783
- return React4.useCallback(
2929
+ return React5.useCallback(
2784
2930
  ({ threadId, body }) => {
2785
2931
  const commentId = _core.createCommentId.call(void 0, );
2786
2932
  const createdAt = /* @__PURE__ */ new Date();
@@ -2822,11 +2968,11 @@ function useCreateComment() {
2822
2968
  function useEditComment() {
2823
2969
  const client = useClient();
2824
2970
  const room = useRoom();
2825
- return React4.useCallback(
2971
+ return React5.useCallback(
2826
2972
  ({ threadId, commentId, body }) => {
2827
2973
  const editedAt = /* @__PURE__ */ new Date();
2828
2974
  const { store, onMutationFailure } = getExtrasForClient2(client);
2829
- const thread = store.get().threads[threadId];
2975
+ const thread = store.getThreads().threadsById[threadId];
2830
2976
  if (thread === void 0) {
2831
2977
  _core.console.warn(
2832
2978
  `Internal unexpected behavior. Cannot edit comment in thread "${threadId}" because the thread does not exist in the cache.`
@@ -2852,11 +2998,7 @@ function useEditComment() {
2852
2998
  });
2853
2999
  room.editComment({ threadId, commentId, body }).then(
2854
3000
  (editedComment) => {
2855
- store.updateThread(
2856
- threadId,
2857
- optimisticUpdateId,
2858
- (thread2) => upsertComment(thread2, editedComment)
2859
- );
3001
+ store.editComment(threadId, optimisticUpdateId, editedComment);
2860
3002
  },
2861
3003
  (err) => onMutationFailure(
2862
3004
  err,
@@ -2876,7 +3018,7 @@ function useEditComment() {
2876
3018
  function useDeleteComment() {
2877
3019
  const client = useClient();
2878
3020
  const room = useRoom();
2879
- return React4.useCallback(
3021
+ return React5.useCallback(
2880
3022
  ({ threadId, commentId }) => {
2881
3023
  const deletedAt = /* @__PURE__ */ new Date();
2882
3024
  const { store, onMutationFailure } = getExtrasForClient2(client);
@@ -2889,10 +3031,10 @@ function useDeleteComment() {
2889
3031
  });
2890
3032
  room.deleteComment({ threadId, commentId }).then(
2891
3033
  () => {
2892
- store.updateThread(
3034
+ store.deleteComment(
2893
3035
  threadId,
2894
3036
  optimisticUpdateId,
2895
- (thread) => deleteComment(thread, commentId, deletedAt),
3037
+ commentId,
2896
3038
  deletedAt
2897
3039
  );
2898
3040
  },
@@ -2913,7 +3055,7 @@ function useDeleteComment() {
2913
3055
  function useAddReaction() {
2914
3056
  const client = useClient();
2915
3057
  const room = useRoom();
2916
- return React4.useCallback(
3058
+ return React5.useCallback(
2917
3059
  ({ threadId, commentId, emoji }) => {
2918
3060
  const createdAt = /* @__PURE__ */ new Date();
2919
3061
  const userId = getCurrentUserId(room);
@@ -2930,10 +3072,11 @@ function useAddReaction() {
2930
3072
  });
2931
3073
  room.addReaction({ threadId, commentId, emoji }).then(
2932
3074
  (addedReaction) => {
2933
- store.updateThread(
3075
+ store.addReaction(
2934
3076
  threadId,
2935
3077
  optimisticUpdateId,
2936
- (thread) => addReaction(thread, commentId, addedReaction),
3078
+ commentId,
3079
+ addedReaction,
2937
3080
  createdAt
2938
3081
  );
2939
3082
  },
@@ -2955,7 +3098,7 @@ function useAddReaction() {
2955
3098
  function useRemoveReaction() {
2956
3099
  const client = useClient();
2957
3100
  const room = useRoom();
2958
- return React4.useCallback(
3101
+ return React5.useCallback(
2959
3102
  ({ threadId, commentId, emoji }) => {
2960
3103
  const userId = getCurrentUserId(room);
2961
3104
  const removedAt = /* @__PURE__ */ new Date();
@@ -2970,10 +3113,12 @@ function useRemoveReaction() {
2970
3113
  });
2971
3114
  room.removeReaction({ threadId, commentId, emoji }).then(
2972
3115
  () => {
2973
- store.updateThread(
3116
+ store.removeReaction(
2974
3117
  threadId,
2975
3118
  optimisticUpdateId,
2976
- (thread) => removeReaction(thread, commentId, emoji, userId, removedAt),
3119
+ commentId,
3120
+ emoji,
3121
+ userId,
2977
3122
  removedAt
2978
3123
  );
2979
3124
  },
@@ -2995,11 +3140,11 @@ function useRemoveReaction() {
2995
3140
  function useMarkThreadAsRead() {
2996
3141
  const client = useClient();
2997
3142
  const room = useRoom();
2998
- return React4.useCallback(
3143
+ return React5.useCallback(
2999
3144
  (threadId) => {
3000
3145
  const { store, onMutationFailure } = getExtrasForClient2(client);
3001
3146
  const inboxNotification = Object.values(
3002
- store.get().inboxNotifications
3147
+ store.getInboxNotifications().inboxNotificationsById
3003
3148
  ).find(
3004
3149
  (inboxNotification2) => inboxNotification2.kind === "thread" && inboxNotification2.threadId === threadId
3005
3150
  );
@@ -3036,7 +3181,7 @@ function useMarkThreadAsRead() {
3036
3181
  function useMarkThreadAsResolved() {
3037
3182
  const client = useClient();
3038
3183
  const room = useRoom();
3039
- return React4.useCallback(
3184
+ return React5.useCallback(
3040
3185
  (threadId) => {
3041
3186
  const updatedAt = /* @__PURE__ */ new Date();
3042
3187
  const { store, onMutationFailure } = getExtrasForClient2(client);
@@ -3047,10 +3192,10 @@ function useMarkThreadAsResolved() {
3047
3192
  });
3048
3193
  room.markThreadAsResolved(threadId).then(
3049
3194
  () => {
3050
- store.updateThread(
3195
+ store.patchThread(
3051
3196
  threadId,
3052
3197
  optimisticUpdateId,
3053
- (thread) => ({ ...thread, resolved: true }),
3198
+ { resolved: true },
3054
3199
  updatedAt
3055
3200
  );
3056
3201
  },
@@ -3070,7 +3215,7 @@ function useMarkThreadAsResolved() {
3070
3215
  function useMarkThreadAsUnresolved() {
3071
3216
  const client = useClient();
3072
3217
  const room = useRoom();
3073
- return React4.useCallback(
3218
+ return React5.useCallback(
3074
3219
  (threadId) => {
3075
3220
  const updatedAt = /* @__PURE__ */ new Date();
3076
3221
  const { store, onMutationFailure } = getExtrasForClient2(client);
@@ -3081,10 +3226,10 @@ function useMarkThreadAsUnresolved() {
3081
3226
  });
3082
3227
  room.markThreadAsUnresolved(threadId).then(
3083
3228
  () => {
3084
- store.updateThread(
3229
+ store.patchThread(
3085
3230
  threadId,
3086
3231
  optimisticUpdateId,
3087
- (thread) => ({ ...thread, resolved: false }),
3232
+ { resolved: false },
3088
3233
  updatedAt
3089
3234
  );
3090
3235
  },
@@ -3104,12 +3249,12 @@ function useMarkThreadAsUnresolved() {
3104
3249
  function useThreadSubscription(threadId) {
3105
3250
  const client = useClient();
3106
3251
  const { store } = getExtrasForClient2(client);
3107
- const selector = React4.useCallback(
3252
+ const selector = React5.useCallback(
3108
3253
  (state) => {
3109
- const inboxNotification = selectInboxNotifications(state).find(
3254
+ const inboxNotification = state.inboxNotifications.find(
3110
3255
  (inboxNotification2) => inboxNotification2.kind === "thread" && inboxNotification2.threadId === threadId
3111
3256
  );
3112
- const thread = state.threads[threadId];
3257
+ const thread = state.threadsById[threadId];
3113
3258
  if (inboxNotification === void 0 || thread === void 0) {
3114
3259
  return {
3115
3260
  status: "not-subscribed"
@@ -3123,54 +3268,68 @@ function useThreadSubscription(threadId) {
3123
3268
  [threadId]
3124
3269
  );
3125
3270
  return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
3126
- store.subscribe,
3127
- store.get,
3128
- store.get,
3271
+ store.subscribeThreads,
3272
+ store.getThreads,
3273
+ store.getThreads,
3129
3274
  selector
3130
3275
  );
3131
3276
  }
3132
3277
  function useRoomNotificationSettings() {
3278
+ const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
3133
3279
  const client = useClient();
3134
3280
  const room = useRoom();
3135
3281
  const { store } = getExtrasForClient2(client);
3136
- React4.useEffect(() => {
3282
+ const getter = React5.useCallback(
3283
+ () => store.getNotificationSettingsAsync(room.id),
3284
+ [store, room.id]
3285
+ );
3286
+ React5.useEffect(() => {
3137
3287
  const { getInboxNotificationSettings } = getExtrasForClient2(client);
3138
- const queryKey = makeNotificationSettingsQueryKey(room.id);
3139
- void getInboxNotificationSettings(room, queryKey);
3288
+ void getInboxNotificationSettings(room);
3140
3289
  }, [client, room]);
3290
+ const settings = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
3291
+ store.subscribeNotificationSettings,
3292
+ getter,
3293
+ getter,
3294
+ identity2,
3295
+ _client.shallow
3296
+ );
3297
+ return React5.useMemo(() => {
3298
+ return [settings, updateRoomNotificationSettings];
3299
+ }, [settings, updateRoomNotificationSettings]);
3300
+ }
3301
+ function useRoomNotificationSettingsSuspense() {
3141
3302
  const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
3142
- const selector = React4.useCallback(
3143
- (state) => {
3144
- const query = state.queries[makeNotificationSettingsQueryKey(room.id)];
3145
- if (query === void 0 || query.isLoading) {
3146
- return { isLoading: true };
3147
- }
3148
- if (query.error !== void 0) {
3149
- return { isLoading: false, error: query.error };
3150
- }
3151
- return {
3152
- isLoading: false,
3153
- settings: selectNotificationSettings(room.id, state)
3154
- };
3155
- },
3156
- [room]
3303
+ const client = useClient();
3304
+ const room = useRoom();
3305
+ const { store } = getExtrasForClient2(client);
3306
+ const getter = React5.useCallback(
3307
+ () => store.getNotificationSettingsAsync(room.id),
3308
+ [store, room.id]
3157
3309
  );
3158
3310
  const settings = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
3159
- store.subscribe,
3160
- store.get,
3161
- store.get,
3162
- selector
3311
+ store.subscribeNotificationSettings,
3312
+ getter,
3313
+ getter,
3314
+ identity2,
3315
+ _client.shallow
3163
3316
  );
3164
- return React4.useMemo(() => {
3317
+ if (settings.isLoading) {
3318
+ const { getInboxNotificationSettings } = getExtrasForClient2(client);
3319
+ throw getInboxNotificationSettings(room);
3320
+ } else if (settings.error) {
3321
+ throw settings.error;
3322
+ }
3323
+ return React5.useMemo(() => {
3165
3324
  return [settings, updateRoomNotificationSettings];
3166
3325
  }, [settings, updateRoomNotificationSettings]);
3167
3326
  }
3168
3327
  function useHistoryVersionData(versionId) {
3169
- const [state, setState] = React4.useState({
3328
+ const [state, setState] = React5.useState({
3170
3329
  isLoading: true
3171
3330
  });
3172
3331
  const room = useRoom();
3173
- React4.useEffect(() => {
3332
+ React5.useEffect(() => {
3174
3333
  setState({ isLoading: true });
3175
3334
  const load = async () => {
3176
3335
  try {
@@ -3197,40 +3356,50 @@ function useHistoryVersionData(versionId) {
3197
3356
  function useHistoryVersions() {
3198
3357
  const client = useClient();
3199
3358
  const room = useRoom();
3200
- const queryKey = getVersionsQueryKey(room.id);
3201
3359
  const { store, getRoomVersions } = getExtrasForClient2(client);
3202
- React4.useEffect(() => {
3360
+ const getter = React5.useCallback(
3361
+ () => store.getVersionsAsync(room.id),
3362
+ [store, room.id]
3363
+ );
3364
+ React5.useEffect(() => {
3203
3365
  void getRoomVersions(room);
3204
3366
  }, [room]);
3205
- const selector = React4.useCallback(
3206
- (state2) => {
3207
- const query = state2.queries[queryKey];
3208
- if (query === void 0 || query.isLoading) {
3209
- return {
3210
- isLoading: true
3211
- };
3212
- }
3213
- return {
3214
- versions: state2.versions[room.id],
3215
- isLoading: false,
3216
- error: query.error
3217
- };
3218
- },
3219
- [room, queryKey]
3220
- // eslint-disable-line react-hooks/exhaustive-deps
3221
- );
3222
3367
  const state = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
3223
- store.subscribe,
3224
- store.get,
3225
- store.get,
3226
- selector
3368
+ store.subscribeVersions,
3369
+ getter,
3370
+ getter,
3371
+ identity2,
3372
+ _client.shallow
3373
+ );
3374
+ return state;
3375
+ }
3376
+ function useHistoryVersionsSuspense() {
3377
+ const client = useClient();
3378
+ const room = useRoom();
3379
+ const { store } = getExtrasForClient2(client);
3380
+ const getter = React5.useCallback(
3381
+ () => store.getVersionsAsync(room.id),
3382
+ [store, room.id]
3227
3383
  );
3384
+ const state = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
3385
+ store.subscribeVersions,
3386
+ getter,
3387
+ getter,
3388
+ identity2,
3389
+ _client.shallow
3390
+ );
3391
+ if (state.isLoading) {
3392
+ const { getRoomVersions } = getExtrasForClient2(client);
3393
+ throw getRoomVersions(room);
3394
+ } else if (state.error) {
3395
+ throw state.error;
3396
+ }
3228
3397
  return state;
3229
3398
  }
3230
3399
  function useUpdateRoomNotificationSettings() {
3231
3400
  const client = useClient();
3232
3401
  const room = useRoom();
3233
- return React4.useCallback(
3402
+ return React5.useCallback(
3234
3403
  (settings) => {
3235
3404
  const { store, onMutationFailure } = getExtrasForClient2(client);
3236
3405
  const optimisticUpdateId = store.addOptimisticUpdate({
@@ -3318,115 +3487,51 @@ function useThreadsSuspense(options = {
3318
3487
  const { scrollOnLoad = true } = options;
3319
3488
  const client = useClient();
3320
3489
  const room = useRoom();
3321
- const queryKey = React4.useMemo(
3490
+ const queryKey = React5.useMemo(
3322
3491
  () => generateQueryKey(room.id, options.query),
3323
3492
  [room, options]
3324
3493
  );
3325
3494
  const { store, getThreadsAndInboxNotifications } = getExtrasForClient2(client);
3326
- const query = store.get().queries[queryKey];
3495
+ const query = store.getThreads().queries[queryKey];
3327
3496
  if (query === void 0 || query.isLoading) {
3328
3497
  throw getThreadsAndInboxNotifications(room, queryKey, options);
3329
3498
  }
3330
3499
  if (query.error) {
3331
3500
  throw query.error;
3332
3501
  }
3333
- const selector = React4.useCallback(
3502
+ const selector = React5.useCallback(
3334
3503
  (state2) => {
3335
3504
  return {
3336
- threads: selectRoomThreads(room.id, state2, options),
3505
+ threads: selectThreads(state2, {
3506
+ roomId: room.id,
3507
+ query: options.query,
3508
+ orderBy: "age"
3509
+ }),
3337
3510
  isLoading: false
3338
3511
  };
3339
3512
  },
3340
3513
  [room, queryKey]
3341
3514
  // eslint-disable-line react-hooks/exhaustive-deps
3342
3515
  );
3343
- React4.useEffect(() => {
3516
+ React5.useEffect(() => {
3344
3517
  const { incrementQuerySubscribers } = getExtrasForClient2(client);
3345
3518
  return incrementQuerySubscribers(queryKey);
3346
3519
  }, [client, queryKey]);
3347
3520
  const state = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
3348
- store.subscribe,
3349
- store.get,
3350
- store.get,
3521
+ store.subscribeThreads,
3522
+ store.getThreads,
3523
+ store.getThreads,
3351
3524
  selector
3352
3525
  );
3353
3526
  useScrollToCommentOnLoadEffect(scrollOnLoad, state);
3354
3527
  return state;
3355
3528
  }
3356
- function useHistoryVersionsSuspense() {
3357
- const client = useClient();
3358
- const room = useRoom();
3359
- const queryKey = getVersionsQueryKey(room.id);
3360
- const { store, getRoomVersions } = getExtrasForClient2(client);
3361
- const query = store.get().queries[queryKey];
3362
- if (query === void 0 || query.isLoading) {
3363
- throw getRoomVersions(room);
3364
- }
3365
- if (query.error) {
3366
- throw query.error;
3367
- }
3368
- const selector = React4.useCallback(
3369
- (state2) => {
3370
- return {
3371
- versions: state2.versions[room.id],
3372
- isLoading: false
3373
- };
3374
- },
3375
- [room, queryKey]
3376
- // eslint-disable-line react-hooks/exhaustive-deps
3377
- );
3378
- const state = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
3379
- store.subscribe,
3380
- store.get,
3381
- store.get,
3382
- selector
3383
- );
3384
- return state;
3385
- }
3386
- function useRoomNotificationSettingsSuspense() {
3387
- const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
3388
- const client = useClient();
3389
- const room = useRoom();
3390
- const queryKey = makeNotificationSettingsQueryKey(room.id);
3391
- const { store, getInboxNotificationSettings } = getExtrasForClient2(client);
3392
- const query = store.get().queries[queryKey];
3393
- if (query === void 0 || query.isLoading) {
3394
- throw getInboxNotificationSettings(room, queryKey);
3395
- }
3396
- if (query.error) {
3397
- throw query.error;
3398
- }
3399
- const selector = React4.useCallback(
3400
- (state) => {
3401
- return {
3402
- isLoading: false,
3403
- settings: selectNotificationSettings(room.id, state)
3404
- };
3405
- },
3406
- [room]
3407
- );
3408
- const settings = _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
3409
- store.subscribe,
3410
- store.get,
3411
- store.get,
3412
- selector
3413
- );
3414
- return React4.useMemo(() => {
3415
- return [settings, updateRoomNotificationSettings];
3416
- }, [settings, updateRoomNotificationSettings]);
3417
- }
3418
- function useRoomOrNull() {
3419
- return React4.useContext(RoomContext);
3420
- }
3421
3529
  function createRoomContext(client) {
3422
3530
  return getOrCreateRoomContextBundle(client);
3423
3531
  }
3424
3532
  function generateQueryKey(roomId, options) {
3425
3533
  return `${roomId}-${_core.stringify.call(void 0, _nullishCoalesce(options, () => ( {})))}`;
3426
3534
  }
3427
- function getVersionsQueryKey(roomId) {
3428
- return `${roomId}-VERSIONS`;
3429
- }
3430
3535
  var _RoomProvider = RoomProvider;
3431
3536
  var _useBroadcastEvent = useBroadcastEvent;
3432
3537
  var _useOthersListener = useOthersListener;
@@ -3546,5 +3651,5 @@ var _useUpdateMyPresence = useUpdateMyPresence;
3546
3651
 
3547
3652
 
3548
3653
 
3549
- exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense; exports.CreateThreadError = CreateThreadError; exports.selectRoomThreads = selectRoomThreads; exports.RoomContext = RoomContext; exports.useStatus = useStatus; exports.useStorageStatus = useStorageStatus; exports.useBatch = useBatch; exports.useLostConnectionListener = useLostConnectionListener; exports.useErrorListener = useErrorListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCommentsErrorListener = useCommentsErrorListener; exports.useCreateComment = useCreateComment; exports.useEditComment = useEditComment; exports.useDeleteComment = useDeleteComment; exports.useRemoveReaction = useRemoveReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useThreadSubscription = useThreadSubscription; exports.useRoomNotificationSettings = useRoomNotificationSettings; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; exports._useIsInsideRoom = _useIsInsideRoom; exports._useAddReaction = _useAddReaction; exports._useMutation = _useMutation; exports._useCreateThread = _useCreateThread; exports._useDeleteThread = _useDeleteThread; exports._useEditThreadMetadata = _useEditThreadMetadata; exports._useEventListener = _useEventListener; exports._useMyPresence = _useMyPresence; exports._useOthersMapped = _useOthersMapped; exports._useOthersMappedSuspense = _useOthersMappedSuspense; exports._useThreads = _useThreads; exports._useThreadsSuspense = _useThreadsSuspense; exports._useHistoryVersions = _useHistoryVersions; exports._useHistoryVersionsSuspense = _useHistoryVersionsSuspense; exports._useOther = _useOther; exports._useOthers = _useOthers; exports._useOtherSuspense = _useOtherSuspense; exports._useOthersSuspense = _useOthersSuspense; exports._useStorage = _useStorage; exports._useStorageSuspense = _useStorageSuspense; exports._useSelf = _useSelf; exports._useSelfSuspense = _useSelfSuspense; exports._useStorageRoot = _useStorageRoot; exports._useUpdateMyPresence = _useUpdateMyPresence; exports.ClientContext = ClientContext; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useClient = useClient; exports.LiveblocksProvider = LiveblocksProvider; exports.createLiveblocksContext = createLiveblocksContext; exports.useInboxNotifications = useInboxNotifications; exports.useInboxNotificationsSuspense = useInboxNotificationsSuspense; exports.useMarkAllInboxNotificationsAsRead = useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = useMarkInboxNotificationAsRead; exports.useDeleteAllInboxNotifications = useDeleteAllInboxNotifications; exports.useDeleteInboxNotification = useDeleteInboxNotification; exports.useUnreadInboxNotificationsCount = useUnreadInboxNotificationsCount; exports.useUnreadInboxNotificationsCountSuspense = useUnreadInboxNotificationsCountSuspense; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental;
3550
- //# sourceMappingURL=chunk-KNPU4P3Y.js.map
3654
+ exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense; exports.RoomContext = RoomContext; exports.ClientContext = ClientContext; exports.selectThreads = selectThreads; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useClient = useClient; exports.LiveblocksProvider = LiveblocksProvider; exports.createLiveblocksContext = createLiveblocksContext; exports.useInboxNotifications = useInboxNotifications; exports.useInboxNotificationsSuspense = useInboxNotificationsSuspense; exports.useMarkAllInboxNotificationsAsRead = useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = useMarkInboxNotificationAsRead; exports.useDeleteAllInboxNotifications = useDeleteAllInboxNotifications; exports.useDeleteInboxNotification = useDeleteInboxNotification; exports.useUnreadInboxNotificationsCount = useUnreadInboxNotificationsCount; exports.useUnreadInboxNotificationsCountSuspense = useUnreadInboxNotificationsCountSuspense; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental; exports.CreateThreadError = CreateThreadError; exports.useStatus = useStatus; exports.useStorageStatus = useStorageStatus; exports.useBatch = useBatch; exports.useLostConnectionListener = useLostConnectionListener; exports.useErrorListener = useErrorListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCommentsErrorListener = useCommentsErrorListener; exports.useCreateComment = useCreateComment; exports.useEditComment = useEditComment; exports.useDeleteComment = useDeleteComment; exports.useRemoveReaction = useRemoveReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useThreadSubscription = useThreadSubscription; exports.useRoomNotificationSettings = useRoomNotificationSettings; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; exports._useIsInsideRoom = _useIsInsideRoom; exports._useAddReaction = _useAddReaction; exports._useMutation = _useMutation; exports._useCreateThread = _useCreateThread; exports._useDeleteThread = _useDeleteThread; exports._useEditThreadMetadata = _useEditThreadMetadata; exports._useEventListener = _useEventListener; exports._useMyPresence = _useMyPresence; exports._useOthersMapped = _useOthersMapped; exports._useOthersMappedSuspense = _useOthersMappedSuspense; exports._useThreads = _useThreads; exports._useThreadsSuspense = _useThreadsSuspense; exports._useHistoryVersions = _useHistoryVersions; exports._useHistoryVersionsSuspense = _useHistoryVersionsSuspense; exports._useOther = _useOther; exports._useOthers = _useOthers; exports._useOtherSuspense = _useOtherSuspense; exports._useOthersSuspense = _useOthersSuspense; exports._useStorage = _useStorage; exports._useStorageSuspense = _useStorageSuspense; exports._useSelf = _useSelf; exports._useSelfSuspense = _useSelfSuspense; exports._useStorageRoot = _useStorageRoot; exports._useUpdateMyPresence = _useUpdateMyPresence;
3655
+ //# sourceMappingURL=chunk-TGC7HD5F.js.map