@liveblocks/react 2.8.0-beta2 → 2.8.0-beta4

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,6 +1,6 @@
1
1
  // src/version.ts
2
2
  var PKG_NAME = "@liveblocks/react";
3
- var PKG_VERSION = "2.8.0-beta2";
3
+ var PKG_VERSION = "2.8.0-beta4";
4
4
  var PKG_FORMAT = "esm";
5
5
 
6
6
  // src/ClientSideSuspense.tsx
@@ -182,30 +182,35 @@ import {
182
182
  nanoid,
183
183
  nn
184
184
  } from "@liveblocks/core";
185
- var QUERY_STATE_LOADING = Object.freeze({ isLoading: true });
186
- var QUERY_STATE_OK = Object.freeze({ isLoading: false, data: void 0 });
187
- var INBOX_NOTIFICATIONS_QUERY = "INBOX_NOTIFICATIONS";
185
+ var ASYNC_LOADING = Object.freeze({ isLoading: true });
186
+ var ASYNC_OK = Object.freeze({ isLoading: false, data: void 0 });
188
187
  function makeNotificationSettingsQueryKey(roomId) {
189
188
  return `${roomId}:NOTIFICATION_SETTINGS`;
190
189
  }
190
+ function makeVersionsQueryKey(roomId) {
191
+ return `${roomId}-VERSIONS`;
192
+ }
191
193
  var UmbrellaStore = class {
192
194
  constructor() {
193
195
  this._prevState = null;
194
196
  this._stateCached = null;
195
197
  this._store = createStore({
196
198
  rawThreadsById: {},
197
- queries: {},
199
+ // queries: {},
200
+ query1: void 0,
201
+ queries2: {},
202
+ queries3: {},
203
+ queries4: {},
198
204
  optimisticUpdates: [],
199
205
  inboxNotificationsById: {},
200
206
  notificationSettingsByRoomId: {},
201
207
  versionsByRoomId: {}
202
208
  });
203
- this.getThreads = this.getThreads.bind(this);
204
- this.getInboxNotifications = this.getInboxNotifications.bind(this);
209
+ this.getFullState = this.getFullState.bind(this);
205
210
  this.getInboxNotificationsAsync = this.getInboxNotificationsAsync.bind(this);
206
- this.getVersions = this.getVersions.bind(this);
207
211
  this.subscribeThreads = this.subscribeThreads.bind(this);
208
- this.subscribeInboxNotifications = this.subscribeInboxNotifications.bind(this);
212
+ this.subscribeUserThreads = this.subscribeUserThreads.bind(this);
213
+ this.subscribeThreadsOrInboxNotifications = this.subscribeThreadsOrInboxNotifications.bind(this);
209
214
  this.subscribeNotificationSettings = this.subscribeNotificationSettings.bind(this);
210
215
  this.subscribeVersions = this.subscribeVersions.bind(this);
211
216
  this._hasOptimisticUpdates = this._hasOptimisticUpdates.bind(this);
@@ -219,31 +224,59 @@ var UmbrellaStore = class {
219
224
  }
220
225
  return this._stateCached;
221
226
  }
222
- getThreads() {
223
- return this.get();
227
+ batch(callback) {
228
+ return this._store.batch(callback);
224
229
  }
225
- getInboxNotifications() {
230
+ getFullState() {
226
231
  return this.get();
227
232
  }
233
+ /**
234
+ * Returns the async result of the given queryKey. If the query is success,
235
+ * then it will return the entire store's state in the payload.
236
+ */
237
+ // TODO: This return type is a bit weird! Feels like we haven't found the
238
+ // right abstraction here yet.
239
+ getThreadsAsync(queryKey) {
240
+ const internalState = this._store.get();
241
+ const query = internalState.queries2[queryKey];
242
+ if (query === void 0 || query.isLoading) {
243
+ return ASYNC_LOADING;
244
+ }
245
+ if (query.error) {
246
+ return query;
247
+ }
248
+ return { isLoading: false, fullState: this.getFullState() };
249
+ }
250
+ getUserThreadsAsync(queryKey) {
251
+ const internalState = this._store.get();
252
+ const query = internalState.queries2[queryKey];
253
+ if (query === void 0 || query.isLoading) {
254
+ return ASYNC_LOADING;
255
+ }
256
+ if (query.error) {
257
+ return query;
258
+ }
259
+ return { isLoading: false, fullState: this.getFullState() };
260
+ }
228
261
  // NOTE: This will read the async result, but WILL NOT start loading at the moment!
229
262
  getInboxNotificationsAsync() {
230
263
  const internalState = this._store.get();
231
- const query = internalState.queries[INBOX_NOTIFICATIONS_QUERY];
264
+ const query = internalState.query1;
232
265
  if (query === void 0 || query.isLoading) {
233
- return QUERY_STATE_LOADING;
266
+ return ASYNC_LOADING;
234
267
  }
235
268
  if (query.error !== void 0) {
236
269
  return query;
237
270
  }
238
- const inboxNotifications = this.get().inboxNotifications;
271
+ const inboxNotifications = this.getFullState().inboxNotifications;
239
272
  return { isLoading: false, inboxNotifications };
240
273
  }
241
274
  // NOTE: This will read the async result, but WILL NOT start loading at the moment!
242
275
  getNotificationSettingsAsync(roomId) {
243
276
  const state = this.get();
244
- const query = state.queries[makeNotificationSettingsQueryKey(roomId)];
277
+ const query = state.queries3[makeNotificationSettingsQueryKey(roomId)];
245
278
  if (query === void 0 || query.isLoading) {
246
- return QUERY_STATE_LOADING;
279
+ return ASYNC_LOADING;
247
280
  }
248
281
  if (query.error !== void 0) {
249
282
  return query;
@@ -253,8 +286,19 @@ var UmbrellaStore = class {
253
286
  settings: nn(state.notificationSettingsByRoomId[roomId])
254
287
  };
255
288
  }
256
- getVersions() {
257
- return this.get();
289
+ getVersionsAsync(roomId) {
290
+ const state = this.get();
291
+ const query = state.queries4[makeVersionsQueryKey(roomId)];
292
+ if (query === void 0 || query.isLoading) {
293
+ return ASYNC_LOADING;
294
+ }
295
+ if (query.error !== void 0) {
296
+ return query;
297
+ }
298
+ return {
299
+ isLoading: false,
300
+ versions: nn(state.versionsByRoomId[roomId])
301
+ };
258
302
  }
259
303
  /**
260
304
  * @private Only used by the E2E test suite.
@@ -274,7 +318,10 @@ var UmbrellaStore = class {
274
318
  subscribeThreads(callback) {
275
319
  return this.subscribe(callback);
276
320
  }
277
- subscribeInboxNotifications(callback) {
321
+ subscribeUserThreads(callback) {
322
+ return this.subscribe(callback);
323
+ }
324
+ subscribeThreadsOrInboxNotifications(callback) {
278
325
  return this.subscribe(callback);
279
326
  }
280
327
  subscribeNotificationSettings(callback) {
@@ -314,11 +361,35 @@ var UmbrellaStore = class {
314
361
  }
315
362
  }));
316
363
  }
317
- setQueryState(queryKey, queryState) {
364
+ setQuery1State(queryState) {
365
+ this._store.set((state) => ({
366
+ ...state,
367
+ query1: queryState
368
+ }));
369
+ }
370
+ setQuery2State(queryKey, queryState) {
371
+ this._store.set((state) => ({
372
+ ...state,
373
+ queries2: {
374
+ ...state.queries2,
375
+ [queryKey]: queryState
376
+ }
377
+ }));
378
+ }
379
+ setQuery3State(queryKey, queryState) {
380
+ this._store.set((state) => ({
381
+ ...state,
382
+ queries3: {
383
+ ...state.queries3,
384
+ [queryKey]: queryState
385
+ }
386
+ }));
387
+ }
388
+ setQuery4State(queryKey, queryState) {
318
389
  this._store.set((state) => ({
319
390
  ...state,
320
- queries: {
321
- ...state.queries,
391
+ queries4: {
392
+ ...state.queries4,
322
393
  [queryKey]: queryState
323
394
  }
324
395
  }));
@@ -531,7 +602,7 @@ var UmbrellaStore = class {
531
602
  }
532
603
  });
533
604
  }
534
- updateThreadsAndNotifications(threads, inboxNotifications, deletedThreads, deletedInboxNotifications, queryKey) {
605
+ updateThreadsAndNotifications(threads, inboxNotifications, deletedThreads, deletedInboxNotifications) {
535
606
  this._store.batch(() => {
536
607
  this.updateThreadsCache(
537
608
  (cache) => applyThreadUpdates(cache, {
@@ -545,9 +616,6 @@ var UmbrellaStore = class {
545
616
  deletedNotifications: deletedInboxNotifications
546
617
  })
547
618
  );
548
- if (queryKey !== void 0) {
549
- this.setQueryOK(queryKey);
550
- }
551
619
  });
552
620
  }
553
621
  /**
@@ -562,7 +630,7 @@ var UmbrellaStore = class {
562
630
  }
563
631
  updateRoomInboxNotificationSettings(roomId, settings, queryKey) {
564
632
  this._store.batch(() => {
565
- this.setQueryOK(queryKey);
633
+ this.setQuery3OK(queryKey);
566
634
  this.setNotificationSettings(roomId, settings);
567
635
  });
568
636
  }
@@ -570,7 +638,7 @@ var UmbrellaStore = class {
570
638
  this._store.batch(() => {
571
639
  this.setVersions(roomId, versions);
572
640
  if (queryKey !== void 0) {
573
- this.setQueryOK(queryKey);
641
+ this.setQuery4OK(queryKey);
574
642
  }
575
643
  });
576
644
  }
@@ -588,30 +656,61 @@ var UmbrellaStore = class {
588
656
  //
589
657
  // Query State APIs
590
658
  //
591
- setQueryLoading(queryKey) {
592
- this.setQueryState(queryKey, QUERY_STATE_LOADING);
659
+ // Query 1
660
+ setQuery1Loading() {
661
+ this.setQuery1State(ASYNC_LOADING);
662
+ }
663
+ setQuery1OK() {
664
+ this.setQuery1State(ASYNC_OK);
665
+ }
666
+ setQuery1Error(error) {
667
+ this.setQuery1State({ isLoading: false, error });
668
+ }
669
+ // Query 2
670
+ setQuery2Loading(queryKey) {
671
+ this.setQuery2State(queryKey, ASYNC_LOADING);
672
+ }
673
+ setQuery2OK(queryKey) {
674
+ this.setQuery2State(queryKey, ASYNC_OK);
675
+ }
676
+ setQuery2Error(queryKey, error) {
677
+ this.setQuery2State(queryKey, { isLoading: false, error });
678
+ }
679
+ // Query 3
680
+ setQuery3Loading(queryKey) {
681
+ this.setQuery3State(queryKey, ASYNC_LOADING);
593
682
  }
594
- setQueryOK(queryKey) {
595
- this.setQueryState(queryKey, QUERY_STATE_OK);
683
+ setQuery3OK(queryKey) {
684
+ this.setQuery3State(queryKey, ASYNC_OK);
596
685
  }
597
- setQueryError(queryKey, error) {
598
- this.setQueryState(queryKey, { isLoading: false, error });
686
+ setQuery3Error(queryKey, error) {
687
+ this.setQuery3State(queryKey, { isLoading: false, error });
688
+ }
689
+ // Query 4
690
+ setQuery4Loading(queryKey) {
691
+ this.setQuery4State(queryKey, ASYNC_LOADING);
692
+ }
693
+ setQuery4OK(queryKey) {
694
+ this.setQuery4State(queryKey, ASYNC_OK);
695
+ }
696
+ setQuery4Error(queryKey, error) {
697
+ this.setQuery4State(queryKey, { isLoading: false, error });
599
698
  }
600
699
  };
601
700
  function internalToExternalState(state) {
602
- const output = {
603
- threads: { ...state.rawThreadsById },
604
- inboxNotifications: { ...state.inboxNotificationsById },
605
- notificationSettings: { ...state.notificationSettingsByRoomId }
701
+ const computed = {
702
+ threadsById: { ...state.rawThreadsById },
703
+ inboxNotificationsById: { ...state.inboxNotificationsById },
704
+ notificationSettingsByRoomId: { ...state.notificationSettingsByRoomId }
606
705
  };
607
706
  for (const optimisticUpdate of state.optimisticUpdates) {
608
707
  switch (optimisticUpdate.type) {
609
708
  case "create-thread": {
610
- output.threads[optimisticUpdate.thread.id] = optimisticUpdate.thread;
709
+ computed.threadsById[optimisticUpdate.thread.id] = optimisticUpdate.thread;
611
710
  break;
612
711
  }
613
712
  case "edit-thread-metadata": {
614
- const thread = output.threads[optimisticUpdate.threadId];
713
+ const thread = computed.threadsById[optimisticUpdate.threadId];
615
714
  if (thread === void 0) {
616
715
  break;
617
716
  }
@@ -621,7 +720,7 @@ function internalToExternalState(state) {
621
720
  if (thread.updatedAt !== void 0 && thread.updatedAt > optimisticUpdate.updatedAt) {
622
721
  break;
623
722
  }
624
- output.threads[thread.id] = {
723
+ computed.threadsById[thread.id] = {
625
724
  ...thread,
626
725
  updatedAt: optimisticUpdate.updatedAt,
627
726
  metadata: {
@@ -632,49 +731,51 @@ function internalToExternalState(state) {
632
731
  break;
633
732
  }
634
733
  case "mark-thread-as-resolved": {
635
- const thread = output.threads[optimisticUpdate.threadId];
734
+ const thread = computed.threadsById[optimisticUpdate.threadId];
636
735
  if (thread === void 0) {
637
736
  break;
638
737
  }
639
738
  if (thread.deletedAt !== void 0) {
640
739
  break;
641
740
  }
642
- output.threads[thread.id] = {
741
+ computed.threadsById[thread.id] = {
643
742
  ...thread,
644
743
  resolved: true
645
744
  };
646
745
  break;
647
746
  }
648
747
  case "mark-thread-as-unresolved": {
649
- const thread = output.threads[optimisticUpdate.threadId];
748
+ const thread = computed.threadsById[optimisticUpdate.threadId];
650
749
  if (thread === void 0) {
651
750
  break;
652
751
  }
653
752
  if (thread.deletedAt !== void 0) {
654
753
  break;
655
754
  }
656
- output.threads[thread.id] = {
755
+ computed.threadsById[thread.id] = {
657
756
  ...thread,
658
757
  resolved: false
659
758
  };
660
759
  break;
661
760
  }
662
761
  case "create-comment": {
663
- const thread = output.threads[optimisticUpdate.comment.threadId];
762
+ const thread = computed.threadsById[optimisticUpdate.comment.threadId];
664
763
  if (thread === void 0) {
665
764
  break;
666
765
  }
667
- output.threads[thread.id] = applyUpsertComment(
766
+ computed.threadsById[thread.id] = applyUpsertComment(
668
767
  thread,
669
768
  optimisticUpdate.comment
670
769
  );
671
- const inboxNotification = Object.values(output.inboxNotifications).find(
770
+ const inboxNotification = Object.values(
771
+ computed.inboxNotificationsById
772
+ ).find(
672
773
  (notification) => notification.kind === "thread" && notification.threadId === thread.id
673
774
  );
674
775
  if (inboxNotification === void 0) {
675
776
  break;
676
777
  }
677
- output.inboxNotifications[inboxNotification.id] = {
778
+ computed.inboxNotificationsById[inboxNotification.id] = {
678
779
  ...inboxNotification,
679
780
  notifiedAt: optimisticUpdate.comment.createdAt,
680
781
  readAt: optimisticUpdate.comment.createdAt
@@ -682,22 +783,22 @@ function internalToExternalState(state) {
682
783
  break;
683
784
  }
684
785
  case "edit-comment": {
685
- const thread = output.threads[optimisticUpdate.comment.threadId];
786
+ const thread = computed.threadsById[optimisticUpdate.comment.threadId];
686
787
  if (thread === void 0) {
687
788
  break;
688
789
  }
689
- output.threads[thread.id] = applyUpsertComment(
790
+ computed.threadsById[thread.id] = applyUpsertComment(
690
791
  thread,
691
792
  optimisticUpdate.comment
692
793
  );
693
794
  break;
694
795
  }
695
796
  case "delete-comment": {
696
- const thread = output.threads[optimisticUpdate.threadId];
797
+ const thread = computed.threadsById[optimisticUpdate.threadId];
697
798
  if (thread === void 0) {
698
799
  break;
699
800
  }
700
- output.threads[thread.id] = applyDeleteComment(
801
+ computed.threadsById[thread.id] = applyDeleteComment(
701
802
  thread,
702
803
  optimisticUpdate.commentId,
703
804
  optimisticUpdate.deletedAt
@@ -705,12 +806,12 @@ function internalToExternalState(state) {
705
806
  break;
706
807
  }
707
808
  case "delete-thread": {
708
- const thread = output.threads[optimisticUpdate.threadId];
809
+ const thread = computed.threadsById[optimisticUpdate.threadId];
709
810
  if (thread === void 0) {
710
811
  break;
711
812
  }
712
- output.threads[optimisticUpdate.threadId] = {
713
- ...output.threads[optimisticUpdate.threadId],
813
+ computed.threadsById[optimisticUpdate.threadId] = {
814
+ ...thread,
714
815
  deletedAt: optimisticUpdate.deletedAt,
715
816
  updatedAt: optimisticUpdate.deletedAt,
716
817
  comments: []
@@ -718,11 +819,11 @@ function internalToExternalState(state) {
718
819
  break;
719
820
  }
720
821
  case "add-reaction": {
721
- const thread = output.threads[optimisticUpdate.threadId];
822
+ const thread = computed.threadsById[optimisticUpdate.threadId];
722
823
  if (thread === void 0) {
723
824
  break;
724
825
  }
725
- output.threads[thread.id] = applyAddReaction(
826
+ computed.threadsById[thread.id] = applyAddReaction(
726
827
  thread,
727
828
  optimisticUpdate.commentId,
728
829
  optimisticUpdate.reaction
@@ -730,11 +831,11 @@ function internalToExternalState(state) {
730
831
  break;
731
832
  }
732
833
  case "remove-reaction": {
733
- const thread = output.threads[optimisticUpdate.threadId];
834
+ const thread = computed.threadsById[optimisticUpdate.threadId];
734
835
  if (thread === void 0) {
735
836
  break;
736
837
  }
737
- output.threads[thread.id] = applyRemoveReaction(
838
+ computed.threadsById[thread.id] = applyRemoveReaction(
738
839
  thread,
739
840
  optimisticUpdate.commentId,
740
841
  optimisticUpdate.emoji,
@@ -744,36 +845,41 @@ function internalToExternalState(state) {
744
845
  break;
745
846
  }
746
847
  case "mark-inbox-notification-as-read": {
747
- output.inboxNotifications[optimisticUpdate.inboxNotificationId] = {
748
- ...state.inboxNotificationsById[optimisticUpdate.inboxNotificationId],
749
- readAt: optimisticUpdate.readAt
750
- };
848
+ const ibn = computed.inboxNotificationsById[optimisticUpdate.inboxNotificationId];
849
+ if (ibn === void 0) {
850
+ break;
851
+ }
852
+ computed.inboxNotificationsById[optimisticUpdate.inboxNotificationId] = { ...ibn, readAt: optimisticUpdate.readAt };
751
853
  break;
752
854
  }
753
855
  case "mark-all-inbox-notifications-as-read": {
754
- for (const id in output.inboxNotifications) {
755
- output.inboxNotifications[id] = {
756
- ...output.inboxNotifications[id],
856
+ for (const id in computed.inboxNotificationsById) {
857
+ const ibn = computed.inboxNotificationsById[id];
858
+ if (ibn === void 0) {
859
+ break;
860
+ }
861
+ computed.inboxNotificationsById[id] = {
862
+ ...ibn,
757
863
  readAt: optimisticUpdate.readAt
758
864
  };
759
865
  }
760
866
  break;
761
867
  }
762
868
  case "delete-inbox-notification": {
763
- const {
764
- [optimisticUpdate.inboxNotificationId]: _,
765
- ...inboxNotifications
766
- } = output.inboxNotifications;
767
- output.inboxNotifications = inboxNotifications;
869
+ delete computed.inboxNotificationsById[optimisticUpdate.inboxNotificationId];
768
870
  break;
769
871
  }
770
872
  case "delete-all-inbox-notifications": {
771
- output.inboxNotifications = {};
873
+ computed.inboxNotificationsById = {};
772
874
  break;
773
875
  }
774
876
  case "update-notification-settings": {
775
- output.notificationSettings[optimisticUpdate.roomId] = {
776
- ...output.notificationSettings[optimisticUpdate.roomId],
877
+ const settings = computed.notificationSettingsByRoomId[optimisticUpdate.roomId];
878
+ if (settings === void 0) {
879
+ break;
880
+ }
881
+ computed.notificationSettingsByRoomId[optimisticUpdate.roomId] = {
882
+ ...settings,
777
883
  ...optimisticUpdate.settings
778
884
  };
779
885
  }
@@ -781,23 +887,28 @@ function internalToExternalState(state) {
781
887
  }
782
888
  const cleanedThreads = (
783
889
  // Don't expose any soft-deleted threads
784
- Object.values(output.threads).filter(
785
- (thread) => !thread.deletedAt
890
+ Object.values(computed.threadsById).filter((thread) => !thread.deletedAt).filter(
891
+ (thread) => (
892
+ // Only keep a thread if there is at least one non-deleted comment
893
+ thread.comments.some((c) => c.deletedAt === void 0)
894
+ )
786
895
  )
787
896
  );
788
897
  const cleanedNotifications = (
789
898
  // Sort so that the most recent notifications are first
790
- Object.values(output.inboxNotifications).sort(
791
- (a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime()
792
- )
899
+ Object.values(computed.inboxNotificationsById).filter(
900
+ (ibn) => ibn.kind === "thread" ? computed.threadsById[ibn.threadId] && computed.threadsById[ibn.threadId]?.deletedAt === void 0 : true
901
+ ).sort((a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime())
793
902
  );
794
903
  return {
795
904
  inboxNotifications: cleanedNotifications,
796
- inboxNotificationsById: output.inboxNotifications,
797
- notificationSettingsByRoomId: output.notificationSettings,
798
- queries: state.queries,
905
+ inboxNotificationsById: computed.inboxNotificationsById,
906
+ notificationSettingsByRoomId: computed.notificationSettingsByRoomId,
907
+ queries2: state.queries2,
908
+ queries3: state.queries3,
909
+ queries4: state.queries4,
799
910
  threads: cleanedThreads,
800
- threadsById: output.threads,
911
+ threadsById: computed.threadsById,
801
912
  versionsByRoomId: state.versionsByRoomId
802
913
  };
803
914
  }
@@ -919,12 +1030,11 @@ function applyDeleteComment(thread, commentId, deletedAt) {
919
1030
  attachments: []
920
1031
  } : comment
921
1032
  );
922
- if (!updatedComments.some((comment) => comment.deletedAt === void 0)) {
1033
+ if (updatedComments.every((comment) => comment.deletedAt !== void 0)) {
923
1034
  return {
924
1035
  ...thread,
925
1036
  deletedAt,
926
- updatedAt: deletedAt,
927
- comments: []
1037
+ updatedAt: deletedAt
928
1038
  };
929
1039
  }
930
1040
  return {
@@ -1133,25 +1243,29 @@ function makeExtrasForClient(client) {
1133
1243
  async function fetchInboxNotifications() {
1134
1244
  if (lastRequestedAt === void 0) {
1135
1245
  const result = await client.getInboxNotifications();
1136
- store.updateThreadsAndNotifications(
1137
- result.threads,
1138
- result.inboxNotifications,
1139
- [],
1140
- [],
1141
- INBOX_NOTIFICATIONS_QUERY
1142
- );
1246
+ store.batch(() => {
1247
+ store.updateThreadsAndNotifications(
1248
+ result.threads,
1249
+ result.inboxNotifications,
1250
+ [],
1251
+ []
1252
+ );
1253
+ store.setQuery1OK();
1254
+ });
1143
1255
  lastRequestedAt = result.requestedAt;
1144
1256
  } else {
1145
1257
  const result = await client.getInboxNotificationsSince({
1146
1258
  since: lastRequestedAt
1147
1259
  });
1148
- store.updateThreadsAndNotifications(
1149
- result.threads.updated,
1150
- result.inboxNotifications.updated,
1151
- result.threads.deleted,
1152
- result.inboxNotifications.deleted,
1153
- INBOX_NOTIFICATIONS_QUERY
1154
- );
1260
+ store.batch(() => {
1261
+ store.updateThreadsAndNotifications(
1262
+ result.threads.updated,
1263
+ result.inboxNotifications.updated,
1264
+ result.threads.deleted,
1265
+ result.inboxNotifications.deleted
1266
+ );
1267
+ store.setQuery1OK();
1268
+ });
1155
1269
  if (lastRequestedAt < result.requestedAt) {
1156
1270
  lastRequestedAt = result.requestedAt;
1157
1271
  }
@@ -1167,7 +1281,7 @@ function makeExtrasForClient(client) {
1167
1281
  }
1168
1282
  });
1169
1283
  const waitUntilInboxNotificationsLoaded = memoizeOnSuccess(async () => {
1170
- store.setQueryLoading(INBOX_NOTIFICATIONS_QUERY);
1284
+ store.setQuery1Loading();
1171
1285
  try {
1172
1286
  await autoRetry(
1173
1287
  () => fetchInboxNotifications(),
@@ -1175,7 +1289,7 @@ function makeExtrasForClient(client) {
1175
1289
  [5e3, 5e3, 1e4, 15e3]
1176
1290
  );
1177
1291
  } catch (err) {
1178
- store.setQueryError(INBOX_NOTIFICATIONS_QUERY, err);
1292
+ store.setQuery1Error(err);
1179
1293
  throw err;
1180
1294
  }
1181
1295
  });
@@ -1183,23 +1297,21 @@ function makeExtrasForClient(client) {
1183
1297
  void waitUntilInboxNotificationsLoaded().catch(() => {
1184
1298
  });
1185
1299
  }
1186
- function useEnableInboxNotificationsPolling() {
1187
- useEffect3(() => {
1188
- pollerSubscribers++;
1189
- poller.start(POLLING_INTERVAL);
1190
- return () => {
1191
- if (pollerSubscribers <= 0) {
1192
- console.warn(
1193
- `Internal unexpected behavior. Cannot decrease subscriber count for query "${INBOX_NOTIFICATIONS_QUERY}"`
1194
- );
1195
- return;
1196
- }
1197
- pollerSubscribers--;
1198
- if (pollerSubscribers <= 0) {
1199
- poller.stop();
1200
- }
1201
- };
1202
- }, []);
1300
+ function startPolling() {
1301
+ pollerSubscribers++;
1302
+ poller.start(POLLING_INTERVAL);
1303
+ return () => {
1304
+ if (pollerSubscribers <= 0) {
1305
+ console.warn(
1306
+ "Unexpected internal error: cannot decrease subscriber count for inbox notifications."
1307
+ );
1308
+ return;
1309
+ }
1310
+ pollerSubscribers--;
1311
+ if (pollerSubscribers <= 0) {
1312
+ poller.stop();
1313
+ }
1314
+ };
1203
1315
  }
1204
1316
  const userThreadsPoller = makePoller(refreshUserThreads);
1205
1317
  let isFetchingUserThreadsUpdates = false;
@@ -1214,13 +1326,15 @@ function makeExtrasForClient(client) {
1214
1326
  since
1215
1327
  });
1216
1328
  isFetchingUserThreadsUpdates = false;
1217
- store.updateThreadsAndNotifications(
1218
- updates.threads.updated,
1219
- [],
1220
- updates.threads.deleted,
1221
- [],
1222
- USER_THREADS_QUERY
1223
- );
1329
+ store.batch(() => {
1330
+ store.updateThreadsAndNotifications(
1331
+ updates.threads.updated,
1332
+ [],
1333
+ updates.threads.deleted,
1334
+ []
1335
+ );
1336
+ store.setQuery2OK(USER_THREADS_QUERY);
1337
+ });
1224
1338
  userThreadslastRequestedAt = updates.requestedAt;
1225
1339
  } catch (err) {
1226
1340
  isFetchingUserThreadsUpdates = false;
@@ -1257,16 +1371,18 @@ function makeExtrasForClient(client) {
1257
1371
  if (existingRequest !== void 0) return existingRequest;
1258
1372
  const request = client[kInternal].getThreads(options);
1259
1373
  userThreadsRequestsByQuery.set(queryKey, request);
1260
- store.setQueryLoading(queryKey);
1374
+ store.setQuery2Loading(queryKey);
1261
1375
  try {
1262
1376
  const result = await request;
1263
- store.updateThreadsAndNotifications(
1264
- result.threads,
1265
- result.inboxNotifications,
1266
- [],
1267
- [],
1268
- queryKey
1269
- );
1377
+ store.batch(() => {
1378
+ store.updateThreadsAndNotifications(
1379
+ result.threads,
1380
+ result.inboxNotifications,
1381
+ [],
1382
+ []
1383
+ );
1384
+ store.setQuery2OK(queryKey);
1385
+ });
1270
1386
  if (userThreadslastRequestedAt === void 0 || userThreadslastRequestedAt < result.requestedAt) {
1271
1387
  userThreadslastRequestedAt = result.requestedAt;
1272
1388
  }
@@ -1278,13 +1394,13 @@ function makeExtrasForClient(client) {
1278
1394
  retryCount: retryCount + 1
1279
1395
  });
1280
1396
  }, retryCount);
1281
- store.setQueryError(queryKey, err);
1397
+ store.setQuery2Error(queryKey, err);
1282
1398
  }
1283
1399
  return;
1284
1400
  }
1285
1401
  return {
1286
1402
  store,
1287
- useEnableInboxNotificationsPolling,
1403
+ startPolling,
1288
1404
  waitUntilInboxNotificationsLoaded,
1289
1405
  loadInboxNotifications,
1290
1406
  incrementUserThreadsQuerySubscribers,
@@ -1329,13 +1445,11 @@ function makeLiveblocksContextBundle(client) {
1329
1445
  return bundle;
1330
1446
  }
1331
1447
  function useInboxNotifications_withClient(client) {
1332
- const { loadInboxNotifications, store, useEnableInboxNotificationsPolling } = getExtrasForClient(client);
1333
- useEffect3(() => {
1334
- loadInboxNotifications();
1335
- }, [loadInboxNotifications]);
1336
- useEnableInboxNotificationsPolling();
1448
+ const { loadInboxNotifications, store, startPolling } = getExtrasForClient(client);
1449
+ useEffect3(loadInboxNotifications, [loadInboxNotifications]);
1450
+ useEffect3(startPolling, [startPolling]);
1337
1451
  return useSyncExternalStoreWithSelector(
1338
- store.subscribeInboxNotifications,
1452
+ store.subscribeThreadsOrInboxNotifications,
1339
1453
  store.getInboxNotificationsAsync,
1340
1454
  store.getInboxNotificationsAsync,
1341
1455
  identity,
@@ -1351,13 +1465,11 @@ function useInboxNotificationsSuspense_withClient(client) {
1351
1465
  return result;
1352
1466
  }
1353
1467
  function useUnreadInboxNotificationsCount_withClient(client) {
1354
- const { store, loadInboxNotifications, useEnableInboxNotificationsPolling } = getExtrasForClient(client);
1355
- useEffect3(() => {
1356
- loadInboxNotifications();
1357
- }, [loadInboxNotifications]);
1358
- useEnableInboxNotificationsPolling();
1468
+ const { store, loadInboxNotifications, startPolling } = getExtrasForClient(client);
1469
+ useEffect3(loadInboxNotifications, [loadInboxNotifications]);
1470
+ useEffect3(startPolling, [startPolling]);
1359
1471
  return useSyncExternalStoreWithSelector(
1360
- store.subscribeInboxNotifications,
1472
+ store.subscribeThreadsOrInboxNotifications,
1361
1473
  store.getInboxNotificationsAsync,
1362
1474
  store.getInboxNotificationsAsync,
1363
1475
  selectorFor_useUnreadInboxNotificationsCount,
@@ -1464,6 +1576,7 @@ function useDeleteAllInboxNotifications_withClient(client) {
1464
1576
  }
1465
1577
  function useInboxNotificationThread_withClient(client, inboxNotificationId) {
1466
1578
  const { store } = getExtrasForClient(client);
1579
+ const getter = store.getFullState;
1467
1580
  const selector = useCallback2(
1468
1581
  (state) => {
1469
1582
  const inboxNotification = state.inboxNotificationsById[inboxNotificationId] ?? raise(`Inbox notification with ID "${inboxNotificationId}" not found`);
@@ -1480,9 +1593,10 @@ function useInboxNotificationThread_withClient(client, inboxNotificationId) {
1480
1593
  [inboxNotificationId]
1481
1594
  );
1482
1595
  return useSyncExternalStoreWithSelector(
1483
- store.subscribeInboxNotifications,
1484
- store.getInboxNotifications,
1485
- store.getInboxNotifications,
1596
+ store.subscribeThreadsOrInboxNotifications,
1597
+ // Re-evaluate if we need to update any time the notification changes over time
1598
+ getter,
1599
+ getter,
1486
1600
  selector
1487
1601
  );
1488
1602
  }
@@ -1670,37 +1784,29 @@ function useUserThreads_experimental(options = {
1670
1784
  void getUserThreads(queryKey, options);
1671
1785
  return incrementUserThreadsQuerySubscribers(queryKey);
1672
1786
  }, [queryKey, incrementUserThreadsQuerySubscribers, getUserThreads, options]);
1787
+ const getter = useCallback2(
1788
+ () => store.getUserThreadsAsync(queryKey),
1789
+ [store, queryKey]
1790
+ );
1673
1791
  const selector = useCallback2(
1674
- (state) => {
1675
- const query = state.queries[queryKey];
1676
- if (query === void 0 || query.isLoading) {
1677
- return {
1678
- isLoading: true
1679
- };
1792
+ (result) => {
1793
+ if (!result.fullState) {
1794
+ return result;
1680
1795
  }
1681
- if (query.error !== void 0) {
1682
- return {
1683
- threads: [],
1684
- error: query.error,
1685
- isLoading: false
1686
- };
1687
- }
1688
- return {
1689
- threads: selectThreads(state, {
1690
- roomId: null,
1691
- // Do _not_ filter by roomId
1692
- query: options.query,
1693
- orderBy: "last-update"
1694
- }),
1695
- isLoading: false
1696
- };
1796
+ const threads = selectThreads(result.fullState, {
1797
+ roomId: null,
1798
+ // Do _not_ filter by roomId
1799
+ query: options.query,
1800
+ orderBy: "last-update"
1801
+ });
1802
+ return { isLoading: false, threads };
1697
1803
  },
1698
- [queryKey, options]
1804
+ [options]
1699
1805
  );
1700
1806
  return useSyncExternalStoreWithSelector(
1701
- store.subscribeThreads,
1702
- store.getThreads,
1703
- store.getThreads,
1807
+ store.subscribeUserThreads,
1808
+ getter,
1809
+ getter,
1704
1810
  selector,
1705
1811
  shallow2
1706
1812
  // NOTE: Using 2-level-deep shallow check here, because the result of selectThreads() is not stable!
@@ -1721,13 +1827,14 @@ function useUserThreadsSuspense_experimental(options = {
1721
1827
  const { incrementUserThreadsQuerySubscribers } = getExtrasForClient(client);
1722
1828
  return incrementUserThreadsQuerySubscribers(queryKey);
1723
1829
  }, [client, queryKey]);
1724
- const query = store.getThreads().queries[queryKey];
1830
+ const query = store.getFullState().queries2[queryKey];
1725
1831
  if (query === void 0 || query.isLoading) {
1726
1832
  throw getUserThreads(queryKey, options);
1727
1833
  }
1728
1834
  if (query.error) {
1729
1835
  throw query.error;
1730
1836
  }
1837
+ const getter = store.getFullState;
1731
1838
  const selector = useCallback2(
1732
1839
  (state) => {
1733
1840
  return {
@@ -1743,9 +1850,9 @@ function useUserThreadsSuspense_experimental(options = {
1743
1850
  [options]
1744
1851
  );
1745
1852
  return useSyncExternalStoreWithSelector(
1746
- store.subscribeThreads,
1747
- store.getThreads,
1748
- store.getThreads,
1853
+ store.subscribeUserThreads,
1854
+ getter,
1855
+ getter,
1749
1856
  selector,
1750
1857
  shallow2
1751
1858
  // NOTE: Using 2-level-deep shallow check here, because the result of selectThreads() is not stable!
@@ -1924,7 +2031,7 @@ import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector2 }
1924
2031
  import * as React4 from "react";
1925
2032
  function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
1926
2033
  if (shouldScrollOnLoad === false) return;
1927
- if (state.isLoading) return;
2034
+ if (!state.threads) return;
1928
2035
  const isWindowDefined = typeof window !== "undefined";
1929
2036
  if (!isWindowDefined) return;
1930
2037
  const hash = window.location.hash;
@@ -2108,12 +2215,12 @@ function makeExtrasForClient2(client) {
2108
2215
  }
2109
2216
  }
2110
2217
  async function getRoomVersions(room, { retryCount } = { retryCount: 0 }) {
2111
- const queryKey = getVersionsQueryKey(room.id);
2218
+ const queryKey = makeVersionsQueryKey(room.id);
2112
2219
  const existingRequest = requestsByQuery.get(queryKey);
2113
2220
  if (existingRequest !== void 0) return existingRequest;
2114
2221
  const request = room[kInternal2].listTextVersions();
2115
2222
  requestsByQuery.set(queryKey, request);
2116
- store.setQueryLoading(queryKey);
2223
+ store.setQuery4Loading(queryKey);
2117
2224
  try {
2118
2225
  const result = await request;
2119
2226
  const data = await result.json();
@@ -2132,7 +2239,7 @@ function makeExtrasForClient2(client) {
2132
2239
  retryCount: retryCount + 1
2133
2240
  });
2134
2241
  }, retryCount);
2135
- store.setQueryError(queryKey, err);
2242
+ store.setQuery4Error(queryKey, err);
2136
2243
  }
2137
2244
  return;
2138
2245
  }
@@ -2141,17 +2248,19 @@ function makeExtrasForClient2(client) {
2141
2248
  if (existingRequest !== void 0) return existingRequest;
2142
2249
  const request = room.getThreads(options);
2143
2250
  requestsByQuery.set(queryKey, request);
2144
- store.setQueryLoading(queryKey);
2251
+ store.setQuery2Loading(queryKey);
2145
2252
  try {
2146
2253
  const result = await request;
2147
- store.updateThreadsAndNotifications(
2148
- result.threads,
2149
- // TODO: Figure out how to remove this casting
2150
- result.inboxNotifications,
2151
- [],
2152
- [],
2153
- queryKey
2154
- );
2254
+ store.batch(() => {
2255
+ store.updateThreadsAndNotifications(
2256
+ result.threads,
2257
+ // TODO: Figure out how to remove this casting
2258
+ result.inboxNotifications,
2259
+ [],
2260
+ []
2261
+ );
2262
+ store.setQuery2OK(queryKey);
2263
+ });
2155
2264
  const lastRequestedAt = lastRequestedAtByRoom.get(room.id);
2156
2265
  if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
2157
2266
  lastRequestedAtByRoom.set(room.id, result.requestedAt);
@@ -2164,7 +2273,7 @@ function makeExtrasForClient2(client) {
2164
2273
  retryCount: retryCount + 1
2165
2274
  });
2166
2275
  }, retryCount);
2167
- store.setQueryError(queryKey, err);
2276
+ store.setQuery2Error(queryKey, err);
2168
2277
  }
2169
2278
  return;
2170
2279
  }
@@ -2175,7 +2284,7 @@ function makeExtrasForClient2(client) {
2175
2284
  try {
2176
2285
  const request = room.getNotificationSettings();
2177
2286
  requestsByQuery.set(queryKey, request);
2178
- store.setQueryLoading(queryKey);
2287
+ store.setQuery3Loading(queryKey);
2179
2288
  const settings = await request;
2180
2289
  store.updateRoomInboxNotificationSettings(room.id, settings, queryKey);
2181
2290
  } catch (err) {
@@ -2185,7 +2294,7 @@ function makeExtrasForClient2(client) {
2185
2294
  retryCount: retryCount + 1
2186
2295
  });
2187
2296
  }, retryCount);
2188
- store.setQueryError(queryKey, err);
2297
+ store.setQuery3Error(queryKey, err);
2189
2298
  }
2190
2299
  return;
2191
2300
  }
@@ -2395,7 +2504,7 @@ function RoomProviderInner(props) {
2395
2504
  return;
2396
2505
  }
2397
2506
  const { thread, inboxNotification } = info;
2398
- const existingThread = store.getThreads().threadsById[message.threadId];
2507
+ const existingThread = store.getFullState().threadsById[message.threadId];
2399
2508
  switch (message.type) {
2400
2509
  case ServerMsgCode.COMMENT_EDITED:
2401
2510
  case ServerMsgCode.THREAD_METADATA_UPDATED:
@@ -2727,32 +2836,31 @@ function useThreads(options = {
2727
2836
  void getThreadsAndInboxNotifications(room, queryKey, options);
2728
2837
  return incrementQuerySubscribers(queryKey);
2729
2838
  }, [room, queryKey]);
2839
+ const getter = React5.useCallback(
2840
+ () => store.getThreadsAsync(queryKey),
2841
+ [store, queryKey]
2842
+ );
2730
2843
  const selector = React5.useCallback(
2731
- (state2) => {
2732
- const query = state2.queries[queryKey];
2733
- if (query === void 0 || query.isLoading) {
2734
- return {
2735
- isLoading: true
2736
- };
2844
+ (result) => {
2845
+ if (!result.fullState) {
2846
+ return result;
2737
2847
  }
2738
- return {
2739
- threads: selectThreads(state2, {
2740
- roomId: room.id,
2741
- query: options.query,
2742
- orderBy: "age"
2743
- }),
2744
- isLoading: false,
2745
- error: query.error
2746
- };
2848
+ const threads = selectThreads(result.fullState, {
2849
+ roomId: room.id,
2850
+ query: options.query,
2851
+ orderBy: "age"
2852
+ });
2853
+ return { isLoading: false, threads };
2747
2854
  },
2748
- [room, queryKey]
2855
+ [room.id, queryKey]
2749
2856
  // eslint-disable-line react-hooks/exhaustive-deps
2750
2857
  );
2751
2858
  const state = useSyncExternalStoreWithSelector2(
2752
2859
  store.subscribeThreads,
2753
- store.getThreads,
2754
- store.getThreads,
2755
- selector
2860
+ getter,
2861
+ getter,
2862
+ selector,
2863
+ shallow2
2756
2864
  );
2757
2865
  useScrollToCommentOnLoadEffect(scrollOnLoad, state);
2758
2866
  return state;
@@ -2831,7 +2939,7 @@ function useDeleteThread() {
2831
2939
  return React5.useCallback(
2832
2940
  (threadId) => {
2833
2941
  const { store, onMutationFailure } = getExtrasForClient2(client);
2834
- const thread = store.getThreads().threadsById[threadId];
2942
+ const thread = store.getFullState().threadsById[threadId];
2835
2943
  const userId = getCurrentUserId(room);
2836
2944
  if (thread?.comments?.[0]?.userId !== userId) {
2837
2945
  throw new Error("Only the thread creator can delete the thread");
@@ -2949,7 +3057,7 @@ function useEditComment() {
2949
3057
  ({ threadId, commentId, body, attachments }) => {
2950
3058
  const editedAt = /* @__PURE__ */ new Date();
2951
3059
  const { store, onMutationFailure } = getExtrasForClient2(client);
2952
- const thread = store.getThreads().threadsById[threadId];
3060
+ const thread = store.getFullState().threadsById[threadId];
2953
3061
  if (thread === void 0) {
2954
3062
  console3.warn(
2955
3063
  `Internal unexpected behavior. Cannot edit comment in thread "${threadId}" because the thread does not exist in the cache.`
@@ -3123,7 +3231,7 @@ function useMarkThreadAsRead() {
3123
3231
  (threadId) => {
3124
3232
  const { store, onMutationFailure } = getExtrasForClient2(client);
3125
3233
  const inboxNotification = Object.values(
3126
- store.getInboxNotifications().inboxNotificationsById
3234
+ store.getFullState().inboxNotificationsById
3127
3235
  ).find(
3128
3236
  (inboxNotification2) => inboxNotification2.kind === "thread" && inboxNotification2.threadId === threadId
3129
3237
  );
@@ -3248,8 +3356,8 @@ function useThreadSubscription(threadId) {
3248
3356
  );
3249
3357
  return useSyncExternalStoreWithSelector2(
3250
3358
  store.subscribeThreads,
3251
- store.getThreads,
3252
- store.getThreads,
3359
+ store.getFullState,
3360
+ store.getFullState,
3253
3361
  selector
3254
3362
  );
3255
3363
  }
@@ -3335,34 +3443,44 @@ function useHistoryVersionData(versionId) {
3335
3443
  function useHistoryVersions() {
3336
3444
  const client = useClient();
3337
3445
  const room = useRoom();
3338
- const queryKey = getVersionsQueryKey(room.id);
3339
3446
  const { store, getRoomVersions } = getExtrasForClient2(client);
3447
+ const getter = React5.useCallback(
3448
+ () => store.getVersionsAsync(room.id),
3449
+ [store, room.id]
3450
+ );
3340
3451
  React5.useEffect(() => {
3341
3452
  void getRoomVersions(room);
3342
3453
  }, [room]);
3343
- const selector = React5.useCallback(
3344
- (state2) => {
3345
- const query = state2.queries[queryKey];
3346
- if (query === void 0 || query.isLoading) {
3347
- return {
3348
- isLoading: true
3349
- };
3350
- }
3351
- return {
3352
- versions: state2.versionsByRoomId[room.id],
3353
- isLoading: false,
3354
- error: query.error
3355
- };
3356
- },
3357
- [room, queryKey]
3358
- // eslint-disable-line react-hooks/exhaustive-deps
3454
+ const state = useSyncExternalStoreWithSelector2(
3455
+ store.subscribeVersions,
3456
+ getter,
3457
+ getter,
3458
+ identity2,
3459
+ shallow4
3460
+ );
3461
+ return state;
3462
+ }
3463
+ function useHistoryVersionsSuspense() {
3464
+ const client = useClient();
3465
+ const room = useRoom();
3466
+ const { store } = getExtrasForClient2(client);
3467
+ const getter = React5.useCallback(
3468
+ () => store.getVersionsAsync(room.id),
3469
+ [store, room.id]
3359
3470
  );
3360
3471
  const state = useSyncExternalStoreWithSelector2(
3361
3472
  store.subscribeVersions,
3362
- store.getVersions,
3363
- store.getVersions,
3364
- selector
3473
+ getter,
3474
+ getter,
3475
+ identity2,
3476
+ shallow4
3365
3477
  );
3478
+ if (state.isLoading) {
3479
+ const { getRoomVersions } = getExtrasForClient2(client);
3480
+ throw getRoomVersions(room);
3481
+ } else if (state.error) {
3482
+ throw state.error;
3483
+ }
3366
3484
  return state;
3367
3485
  }
3368
3486
  function useUpdateRoomNotificationSettings() {
@@ -3461,7 +3579,7 @@ function useThreadsSuspense(options = {
3461
3579
  [room, options]
3462
3580
  );
3463
3581
  const { store, getThreadsAndInboxNotifications } = getExtrasForClient2(client);
3464
- const query = store.getThreads().queries[queryKey];
3582
+ const query = store.getFullState().queries2[queryKey];
3465
3583
  if (query === void 0 || query.isLoading) {
3466
3584
  throw getThreadsAndInboxNotifications(room, queryKey, options);
3467
3585
  }
@@ -3488,8 +3606,8 @@ function useThreadsSuspense(options = {
3488
3606
  }, [client, queryKey]);
3489
3607
  const state = useSyncExternalStoreWithSelector2(
3490
3608
  store.subscribeThreads,
3491
- store.getThreads,
3492
- store.getThreads,
3609
+ store.getFullState,
3610
+ store.getFullState,
3493
3611
  selector
3494
3612
  );
3495
3613
  useScrollToCommentOnLoadEffect(scrollOnLoad, state);
@@ -3554,45 +3672,12 @@ function useAttachmentUrlSuspense(attachmentId) {
3554
3672
  error: void 0
3555
3673
  };
3556
3674
  }
3557
- function useHistoryVersionsSuspense() {
3558
- const client = useClient();
3559
- const room = useRoom();
3560
- const queryKey = getVersionsQueryKey(room.id);
3561
- const { store, getRoomVersions } = getExtrasForClient2(client);
3562
- const query = store.getVersions().queries[queryKey];
3563
- if (query === void 0 || query.isLoading) {
3564
- throw getRoomVersions(room);
3565
- }
3566
- if (query.error) {
3567
- throw query.error;
3568
- }
3569
- const selector = React5.useCallback(
3570
- (state2) => {
3571
- return {
3572
- versions: state2.versionsByRoomId[room.id],
3573
- isLoading: false
3574
- };
3575
- },
3576
- [room, queryKey]
3577
- // eslint-disable-line react-hooks/exhaustive-deps
3578
- );
3579
- const state = useSyncExternalStoreWithSelector2(
3580
- store.subscribeVersions,
3581
- store.getVersions,
3582
- store.getVersions,
3583
- selector
3584
- );
3585
- return state;
3586
- }
3587
3675
  function createRoomContext(client) {
3588
3676
  return getOrCreateRoomContextBundle(client);
3589
3677
  }
3590
3678
  function generateQueryKey(roomId, options) {
3591
3679
  return `${roomId}-${stringify2(options ?? {})}`;
3592
3680
  }
3593
- function getVersionsQueryKey(roomId) {
3594
- return `${roomId}-VERSIONS`;
3595
- }
3596
3681
  var _RoomProvider = RoomProvider;
3597
3682
  var _useBroadcastEvent = useBroadcastEvent;
3598
3683
  var _useOthersListener = useOthersListener;
@@ -3715,4 +3800,4 @@ export {
3715
3800
  _useStorageRoot,
3716
3801
  _useUpdateMyPresence
3717
3802
  };
3718
- //# sourceMappingURL=chunk-OBLKSEC3.mjs.map
3803
+ //# sourceMappingURL=chunk-G35ZEFD6.mjs.map