@liveblocks/react 2.12.1-test1 → 2.12.1-test3

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.
@@ -528,6 +528,7 @@ var UmbrellaStore = class {
528
528
  this._rawThreadsDB = new ThreadDB();
529
529
  this._store = createStore({
530
530
  optimisticUpdates: [],
531
+ permissionsByRoom: {},
531
532
  notificationsById: {},
532
533
  settingsByRoomId: {},
533
534
  versionsByRoomId: {}
@@ -656,6 +657,9 @@ var UmbrellaStore = class {
656
657
  subscribe(callback) {
657
658
  return this._store.subscribe(callback);
658
659
  }
660
+ _getPermissions(roomId) {
661
+ return this._store.get().permissionsByRoom[roomId];
662
+ }
659
663
  // Direct low-level cache mutations ------------------------------------------------- {{{
660
664
  mutateThreadsDB(mutate) {
661
665
  const db = this._rawThreadsDB;
@@ -954,17 +958,32 @@ var UmbrellaStore = class {
954
958
  waitUntilNotificationsLoaded() {
955
959
  return this._notifications.waitUntilLoaded();
956
960
  }
961
+ updateRoomPermissions(permissions) {
962
+ const permissionsByRoom = { ...this._store.get().permissionsByRoom };
963
+ Object.entries(permissions).forEach(([roomId, newPermissions]) => {
964
+ const existingPermissions = permissionsByRoom[roomId] ?? /* @__PURE__ */ new Set();
965
+ newPermissions.forEach(
966
+ (permission) => existingPermissions.add(permission)
967
+ );
968
+ permissionsByRoom[roomId] = existingPermissions;
969
+ });
970
+ this._store.set((state) => ({
971
+ ...state,
972
+ permissionsByRoom
973
+ }));
974
+ }
957
975
  waitUntilRoomThreadsLoaded(roomId, query) {
958
976
  const threadsFetcher = async (cursor) => {
959
- const room = this._client.getRoom(roomId);
960
- if (room === null) {
961
- throw new HttpError(`Room '${roomId}' is not available on client`, 479);
962
- }
963
- const result = await room.getThreads({ cursor, query });
977
+ const result = await this._client[kInternal].httpClient.getThreads({
978
+ roomId,
979
+ cursor,
980
+ query
981
+ });
964
982
  this.updateThreadsAndNotifications(
965
983
  result.threads,
966
984
  result.inboxNotifications
967
985
  );
986
+ this.updateRoomPermissions(result.permissionHints);
968
987
  const lastRequestedAt = this._roomThreadsLastRequestedAtByRoom.get(roomId);
969
988
  if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
970
989
  this._roomThreadsLastRequestedAtByRoom.set(roomId, result.requestedAt);
@@ -991,11 +1010,8 @@ var UmbrellaStore = class {
991
1010
  if (lastRequestedAt === void 0) {
992
1011
  return;
993
1012
  }
994
- const room = nn(
995
- this._client.getRoom(roomId),
996
- `Room with id ${roomId} is not available on client`
997
- );
998
- const updates = await room.getThreadsSince({
1013
+ const updates = await this._client[kInternal].httpClient.getThreadsSince({
1014
+ roomId,
999
1015
  since: lastRequestedAt,
1000
1016
  signal
1001
1017
  });
@@ -1005,6 +1021,7 @@ var UmbrellaStore = class {
1005
1021
  updates.threads.deleted,
1006
1022
  updates.inboxNotifications.deleted
1007
1023
  );
1024
+ this.updateRoomPermissions(updates.permissionHints);
1008
1025
  if (lastRequestedAt < updates.requestedAt) {
1009
1026
  this._roomThreadsLastRequestedAtByRoom.set(roomId, updates.requestedAt);
1010
1027
  }
@@ -1012,7 +1029,7 @@ var UmbrellaStore = class {
1012
1029
  waitUntilUserThreadsLoaded(query) {
1013
1030
  const queryKey = makeUserThreadsQueryKey(query);
1014
1031
  const threadsFetcher = async (cursor) => {
1015
- const result = await this._client[kInternal].getUserThreads_experimental({
1032
+ const result = await this._client[kInternal].httpClient.getUserThreads_experimental({
1016
1033
  cursor,
1017
1034
  query
1018
1035
  });
@@ -1020,6 +1037,7 @@ var UmbrellaStore = class {
1020
1037
  result.threads,
1021
1038
  result.inboxNotifications
1022
1039
  );
1040
+ this.updateRoomPermissions(result.permissionHints);
1023
1041
  if (this._userThreadsLastRequestedAt === null) {
1024
1042
  this._userThreadsLastRequestedAt = result.requestedAt;
1025
1043
  }
@@ -1044,7 +1062,7 @@ var UmbrellaStore = class {
1044
1062
  if (lastRequestedAt === null) {
1045
1063
  return;
1046
1064
  }
1047
- const result = await this._client[kInternal].getUserThreadsSince_experimental({
1065
+ const result = await this._client[kInternal].httpClient.getUserThreadsSince_experimental({
1048
1066
  since: lastRequestedAt,
1049
1067
  signal
1050
1068
  });
@@ -1057,6 +1075,7 @@ var UmbrellaStore = class {
1057
1075
  result.threads.deleted,
1058
1076
  result.inboxNotifications.deleted
1059
1077
  );
1078
+ this.updateRoomPermissions(result.permissionHints);
1060
1079
  }
1061
1080
  waitUntilRoomVersionsLoaded(roomId) {
1062
1081
  const queryKey = makeVersionsQueryKey(roomId);
@@ -2367,13 +2386,12 @@ function makeMutationContext(room) {
2367
2386
  setMyPresence: room.updatePresence
2368
2387
  };
2369
2388
  }
2370
- function getCurrentUserId(room) {
2371
- const self = room.getSelf();
2372
- if (self === null || self.id === void 0) {
2389
+ function getCurrentUserId(client) {
2390
+ const userId = client[kInternal3].currentUserIdStore.get();
2391
+ if (userId === void 0) {
2373
2392
  return "anonymous";
2374
- } else {
2375
- return self.id;
2376
2393
  }
2394
+ return userId;
2377
2395
  }
2378
2396
  function handleApiError(err) {
2379
2397
  const message = `Request failed with status ${err.status}: ${err.message}`;
@@ -3020,8 +3038,10 @@ function useCommentsErrorListener(callback) {
3020
3038
  }, [savedCallback, commentsErrorEventSource]);
3021
3039
  }
3022
3040
  function useCreateThread() {
3041
+ return useCreateRoomThread(useRoom().id);
3042
+ }
3043
+ function useCreateRoomThread(roomId) {
3023
3044
  const client = useClient();
3024
- const room = useRoom();
3025
3045
  return React4.useCallback(
3026
3046
  (options) => {
3027
3047
  const body = options.body;
@@ -3033,10 +3053,10 @@ function useCreateThread() {
3033
3053
  const newComment = {
3034
3054
  id: commentId,
3035
3055
  threadId,
3036
- roomId: room.id,
3056
+ roomId,
3037
3057
  createdAt,
3038
3058
  type: "comment",
3039
- userId: getCurrentUserId(room),
3059
+ userId: getCurrentUserId(client),
3040
3060
  body,
3041
3061
  reactions: [],
3042
3062
  attachments: attachments ?? []
@@ -3046,7 +3066,7 @@ function useCreateThread() {
3046
3066
  type: "thread",
3047
3067
  createdAt,
3048
3068
  updatedAt: createdAt,
3049
- roomId: room.id,
3069
+ roomId,
3050
3070
  metadata,
3051
3071
  comments: [newComment],
3052
3072
  resolved: false
@@ -3055,10 +3075,17 @@ function useCreateThread() {
3055
3075
  const optimisticUpdateId = store.addOptimisticUpdate({
3056
3076
  type: "create-thread",
3057
3077
  thread: newThread,
3058
- roomId: room.id
3078
+ roomId
3059
3079
  });
3060
3080
  const attachmentIds = attachments?.map((attachment) => attachment.id);
3061
- room.createThread({ threadId, commentId, body, metadata, attachmentIds }).then(
3081
+ client[kInternal3].httpClient.createThread({
3082
+ roomId,
3083
+ threadId,
3084
+ commentId,
3085
+ body,
3086
+ metadata,
3087
+ attachmentIds
3088
+ }).then(
3062
3089
  (thread) => {
3063
3090
  store.createThread(optimisticUpdateId, thread);
3064
3091
  },
@@ -3066,7 +3093,7 @@ function useCreateThread() {
3066
3093
  err,
3067
3094
  optimisticUpdateId,
3068
3095
  (err2) => new CreateThreadError(err2, {
3069
- roomId: room.id,
3096
+ roomId,
3070
3097
  threadId,
3071
3098
  commentId,
3072
3099
  body,
@@ -3076,43 +3103,47 @@ function useCreateThread() {
3076
3103
  );
3077
3104
  return newThread;
3078
3105
  },
3079
- [client, room]
3106
+ [client, roomId]
3080
3107
  );
3081
3108
  }
3082
3109
  function useDeleteThread() {
3110
+ return useDeleteRoomThread(useRoom().id);
3111
+ }
3112
+ function useDeleteRoomThread(roomId) {
3083
3113
  const client = useClient();
3084
- const room = useRoom();
3085
3114
  return React4.useCallback(
3086
3115
  (threadId) => {
3087
3116
  const { store, onMutationFailure } = getRoomExtrasForClient(client);
3088
- const userId = getCurrentUserId(room);
3117
+ const userId = getCurrentUserId(client);
3089
3118
  const existing = store.getFullState().threadsDB.get(threadId);
3090
3119
  if (existing?.comments?.[0]?.userId !== userId) {
3091
3120
  throw new Error("Only the thread creator can delete the thread");
3092
3121
  }
3093
3122
  const optimisticUpdateId = store.addOptimisticUpdate({
3094
3123
  type: "delete-thread",
3095
- roomId: room.id,
3124
+ roomId,
3096
3125
  threadId,
3097
3126
  deletedAt: /* @__PURE__ */ new Date()
3098
3127
  });
3099
- room.deleteThread(threadId).then(
3128
+ client[kInternal3].httpClient.deleteThread({ roomId, threadId }).then(
3100
3129
  () => {
3101
3130
  store.deleteThread(threadId, optimisticUpdateId);
3102
3131
  },
3103
3132
  (err) => onMutationFailure(
3104
3133
  err,
3105
3134
  optimisticUpdateId,
3106
- (err2) => new DeleteThreadError(err2, { roomId: room.id, threadId })
3135
+ (err2) => new DeleteThreadError(err2, { roomId, threadId })
3107
3136
  )
3108
3137
  );
3109
3138
  },
3110
- [client, room]
3139
+ [client, roomId]
3111
3140
  );
3112
3141
  }
3113
3142
  function useEditThreadMetadata() {
3143
+ return useEditRoomThreadMetadata(useRoom().id);
3144
+ }
3145
+ function useEditRoomThreadMetadata(roomId) {
3114
3146
  const client = useClient();
3115
- const room = useRoom();
3116
3147
  return React4.useCallback(
3117
3148
  (options) => {
3118
3149
  if (!options.metadata) {
@@ -3128,7 +3159,7 @@ function useEditThreadMetadata() {
3128
3159
  threadId,
3129
3160
  updatedAt
3130
3161
  });
3131
- room.editThreadMetadata({ threadId, metadata }).then(
3162
+ client[kInternal3].httpClient.editThreadMetadata({ roomId, threadId, metadata }).then(
3132
3163
  (metadata2) => (
3133
3164
  // Replace the optimistic update by the real thing
3134
3165
  store.patchThread(
@@ -3142,19 +3173,21 @@ function useEditThreadMetadata() {
3142
3173
  err,
3143
3174
  optimisticUpdateId,
3144
3175
  (error) => new EditThreadMetadataError(error, {
3145
- roomId: room.id,
3176
+ roomId,
3146
3177
  threadId,
3147
3178
  metadata
3148
3179
  })
3149
3180
  )
3150
3181
  );
3151
3182
  },
3152
- [client, room]
3183
+ [client, roomId]
3153
3184
  );
3154
3185
  }
3155
3186
  function useCreateComment() {
3187
+ return useCreateRoomComment(useRoom().id);
3188
+ }
3189
+ function useCreateRoomComment(roomId) {
3156
3190
  const client = useClient();
3157
- const room = useRoom();
3158
3191
  return React4.useCallback(
3159
3192
  ({ threadId, body, attachments }) => {
3160
3193
  const commentId = createCommentId();
@@ -3162,10 +3195,10 @@ function useCreateComment() {
3162
3195
  const comment = {
3163
3196
  id: commentId,
3164
3197
  threadId,
3165
- roomId: room.id,
3198
+ roomId,
3166
3199
  type: "comment",
3167
3200
  createdAt,
3168
- userId: getCurrentUserId(room),
3201
+ userId: getCurrentUserId(client),
3169
3202
  body,
3170
3203
  reactions: [],
3171
3204
  attachments: attachments ?? []
@@ -3176,7 +3209,7 @@ function useCreateComment() {
3176
3209
  comment
3177
3210
  });
3178
3211
  const attachmentIds = attachments?.map((attachment) => attachment.id);
3179
- room.createComment({ threadId, commentId, body, attachmentIds }).then(
3212
+ client[kInternal3].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
3180
3213
  (newComment) => {
3181
3214
  store.createComment(newComment, optimisticUpdateId);
3182
3215
  },
@@ -3184,7 +3217,7 @@ function useCreateComment() {
3184
3217
  err,
3185
3218
  optimisticUpdateId,
3186
3219
  (err2) => new CreateCommentError(err2, {
3187
- roomId: room.id,
3220
+ roomId,
3188
3221
  threadId,
3189
3222
  commentId,
3190
3223
  body
@@ -3193,12 +3226,14 @@ function useCreateComment() {
3193
3226
  );
3194
3227
  return comment;
3195
3228
  },
3196
- [client, room]
3229
+ [client, roomId]
3197
3230
  );
3198
3231
  }
3199
3232
  function useEditComment() {
3233
+ return useEditRoomComment(useRoom().id);
3234
+ }
3235
+ function useEditRoomComment(roomId) {
3200
3236
  const client = useClient();
3201
- const room = useRoom();
3202
3237
  return React4.useCallback(
3203
3238
  ({ threadId, commentId, body, attachments }) => {
3204
3239
  const editedAt = /* @__PURE__ */ new Date();
@@ -3229,7 +3264,7 @@ function useEditComment() {
3229
3264
  }
3230
3265
  });
3231
3266
  const attachmentIds = attachments?.map((attachment) => attachment.id);
3232
- room.editComment({ threadId, commentId, body, attachmentIds }).then(
3267
+ client[kInternal3].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
3233
3268
  (editedComment) => {
3234
3269
  store.editComment(threadId, optimisticUpdateId, editedComment);
3235
3270
  },
@@ -3237,7 +3272,7 @@ function useEditComment() {
3237
3272
  err,
3238
3273
  optimisticUpdateId,
3239
3274
  (error) => new EditCommentError(error, {
3240
- roomId: room.id,
3275
+ roomId,
3241
3276
  threadId,
3242
3277
  commentId,
3243
3278
  body
@@ -3245,12 +3280,14 @@ function useEditComment() {
3245
3280
  )
3246
3281
  );
3247
3282
  },
3248
- [client, room]
3283
+ [client, roomId]
3249
3284
  );
3250
3285
  }
3251
3286
  function useDeleteComment() {
3287
+ return useDeleteRoomComment(useRoom().id);
3288
+ }
3289
+ function useDeleteRoomComment(roomId) {
3252
3290
  const client = useClient();
3253
- const room = useRoom();
3254
3291
  return React4.useCallback(
3255
3292
  ({ threadId, commentId }) => {
3256
3293
  const deletedAt = /* @__PURE__ */ new Date();
@@ -3260,9 +3297,9 @@ function useDeleteComment() {
3260
3297
  threadId,
3261
3298
  commentId,
3262
3299
  deletedAt,
3263
- roomId: room.id
3300
+ roomId
3264
3301
  });
3265
- room.deleteComment({ threadId, commentId }).then(
3302
+ client[kInternal3].httpClient.deleteComment({ roomId, threadId, commentId }).then(
3266
3303
  () => {
3267
3304
  store.deleteComment(
3268
3305
  threadId,
@@ -3275,23 +3312,25 @@ function useDeleteComment() {
3275
3312
  err,
3276
3313
  optimisticUpdateId,
3277
3314
  (error) => new DeleteCommentError(error, {
3278
- roomId: room.id,
3315
+ roomId,
3279
3316
  threadId,
3280
3317
  commentId
3281
3318
  })
3282
3319
  )
3283
3320
  );
3284
3321
  },
3285
- [client, room]
3322
+ [client, roomId]
3286
3323
  );
3287
3324
  }
3288
3325
  function useAddReaction() {
3326
+ return useAddRoomCommentReaction(useRoom().id);
3327
+ }
3328
+ function useAddRoomCommentReaction(roomId) {
3289
3329
  const client = useClient();
3290
- const room = useRoom();
3291
3330
  return React4.useCallback(
3292
3331
  ({ threadId, commentId, emoji }) => {
3293
3332
  const createdAt = /* @__PURE__ */ new Date();
3294
- const userId = getCurrentUserId(room);
3333
+ const userId = getCurrentUserId(client);
3295
3334
  const { store, onMutationFailure } = getRoomExtrasForClient(client);
3296
3335
  const optimisticUpdateId = store.addOptimisticUpdate({
3297
3336
  type: "add-reaction",
@@ -3303,7 +3342,7 @@ function useAddReaction() {
3303
3342
  createdAt
3304
3343
  }
3305
3344
  });
3306
- room.addReaction({ threadId, commentId, emoji }).then(
3345
+ client[kInternal3].httpClient.addReaction({ roomId, threadId, commentId, emoji }).then(
3307
3346
  (addedReaction) => {
3308
3347
  store.addReaction(
3309
3348
  threadId,
@@ -3317,7 +3356,7 @@ function useAddReaction() {
3317
3356
  err,
3318
3357
  optimisticUpdateId,
3319
3358
  (error) => new AddReactionError(error, {
3320
- roomId: room.id,
3359
+ roomId,
3321
3360
  threadId,
3322
3361
  commentId,
3323
3362
  emoji
@@ -3325,15 +3364,17 @@ function useAddReaction() {
3325
3364
  )
3326
3365
  );
3327
3366
  },
3328
- [client, room]
3367
+ [client, roomId]
3329
3368
  );
3330
3369
  }
3331
3370
  function useRemoveReaction() {
3371
+ return useRemoveRoomCommentReaction(useRoom().id);
3372
+ }
3373
+ function useRemoveRoomCommentReaction(roomId) {
3332
3374
  const client = useClient();
3333
- const room = useRoom();
3334
3375
  return React4.useCallback(
3335
3376
  ({ threadId, commentId, emoji }) => {
3336
- const userId = getCurrentUserId(room);
3377
+ const userId = getCurrentUserId(client);
3337
3378
  const removedAt = /* @__PURE__ */ new Date();
3338
3379
  const { store, onMutationFailure } = getRoomExtrasForClient(client);
3339
3380
  const optimisticUpdateId = store.addOptimisticUpdate({
@@ -3344,7 +3385,7 @@ function useRemoveReaction() {
3344
3385
  userId,
3345
3386
  removedAt
3346
3387
  });
3347
- room.removeReaction({ threadId, commentId, emoji }).then(
3388
+ client[kInternal3].httpClient.removeReaction({ roomId, threadId, commentId, emoji }).then(
3348
3389
  () => {
3349
3390
  store.removeReaction(
3350
3391
  threadId,
@@ -3359,7 +3400,7 @@ function useRemoveReaction() {
3359
3400
  err,
3360
3401
  optimisticUpdateId,
3361
3402
  (error) => new RemoveReactionError(error, {
3362
- roomId: room.id,
3403
+ roomId,
3363
3404
  threadId,
3364
3405
  commentId,
3365
3406
  emoji
@@ -3367,12 +3408,14 @@ function useRemoveReaction() {
3367
3408
  )
3368
3409
  );
3369
3410
  },
3370
- [client, room]
3411
+ [client, roomId]
3371
3412
  );
3372
3413
  }
3373
3414
  function useMarkThreadAsRead() {
3415
+ return useMarkRoomThreadAsRead(useRoom().id);
3416
+ }
3417
+ function useMarkRoomThreadAsRead(roomId) {
3374
3418
  const client = useClient();
3375
- const room = useRoom();
3376
3419
  return React4.useCallback(
3377
3420
  (threadId) => {
3378
3421
  const { store, onMutationFailure } = getRoomExtrasForClient(client);
@@ -3388,7 +3431,10 @@ function useMarkThreadAsRead() {
3388
3431
  inboxNotificationId: inboxNotification.id,
3389
3432
  readAt: now
3390
3433
  });
3391
- room.markInboxNotificationAsRead(inboxNotification.id).then(
3434
+ client[kInternal3].httpClient.markRoomInboxNotificationAsRead({
3435
+ roomId,
3436
+ inboxNotificationId: inboxNotification.id
3437
+ }).then(
3392
3438
  () => {
3393
3439
  store.updateInboxNotification(
3394
3440
  inboxNotification.id,
@@ -3408,12 +3454,14 @@ function useMarkThreadAsRead() {
3408
3454
  }
3409
3455
  );
3410
3456
  },
3411
- [client, room]
3457
+ [client, roomId]
3412
3458
  );
3413
3459
  }
3414
3460
  function useMarkThreadAsResolved() {
3461
+ return useMarkRoomThreadAsResolved(useRoom().id);
3462
+ }
3463
+ function useMarkRoomThreadAsResolved(roomId) {
3415
3464
  const client = useClient();
3416
- const room = useRoom();
3417
3465
  return React4.useCallback(
3418
3466
  (threadId) => {
3419
3467
  const updatedAt = /* @__PURE__ */ new Date();
@@ -3423,7 +3471,7 @@ function useMarkThreadAsResolved() {
3423
3471
  threadId,
3424
3472
  updatedAt
3425
3473
  });
3426
- room.markThreadAsResolved(threadId).then(
3474
+ client[kInternal3].httpClient.markThreadAsResolved({ roomId, threadId }).then(
3427
3475
  () => {
3428
3476
  store.patchThread(
3429
3477
  threadId,
@@ -3436,18 +3484,20 @@ function useMarkThreadAsResolved() {
3436
3484
  err,
3437
3485
  optimisticUpdateId,
3438
3486
  (error) => new MarkThreadAsResolvedError(error, {
3439
- roomId: room.id,
3487
+ roomId,
3440
3488
  threadId
3441
3489
  })
3442
3490
  )
3443
3491
  );
3444
3492
  },
3445
- [client, room]
3493
+ [client, roomId]
3446
3494
  );
3447
3495
  }
3448
3496
  function useMarkThreadAsUnresolved() {
3497
+ return useMarkRoomThreadAsUnresolved(useRoom().id);
3498
+ }
3499
+ function useMarkRoomThreadAsUnresolved(roomId) {
3449
3500
  const client = useClient();
3450
- const room = useRoom();
3451
3501
  return React4.useCallback(
3452
3502
  (threadId) => {
3453
3503
  const updatedAt = /* @__PURE__ */ new Date();
@@ -3457,7 +3507,7 @@ function useMarkThreadAsUnresolved() {
3457
3507
  threadId,
3458
3508
  updatedAt
3459
3509
  });
3460
- room.markThreadAsUnresolved(threadId).then(
3510
+ client[kInternal3].httpClient.markThreadAsUnresolved({ roomId, threadId }).then(
3461
3511
  () => {
3462
3512
  store.patchThread(
3463
3513
  threadId,
@@ -3470,13 +3520,13 @@ function useMarkThreadAsUnresolved() {
3470
3520
  err,
3471
3521
  optimisticUpdateId,
3472
3522
  (error) => new MarkThreadAsUnresolvedError(error, {
3473
- roomId: room.id,
3523
+ roomId,
3474
3524
  threadId
3475
3525
  })
3476
3526
  )
3477
3527
  );
3478
3528
  },
3479
- [client, room]
3529
+ [client, roomId]
3480
3530
  );
3481
3531
  }
3482
3532
  function useThreadSubscription(threadId) {
@@ -3745,16 +3795,20 @@ function selectorFor_useAttachmentUrl(state) {
3745
3795
  }
3746
3796
  function useAttachmentUrl(attachmentId) {
3747
3797
  const room = useRoom();
3748
- const { attachmentUrlsStore } = room[kInternal3];
3798
+ return useRoomAttachmentUrl(attachmentId, room.id);
3799
+ }
3800
+ function useRoomAttachmentUrl(attachmentId, roomId) {
3801
+ const client = useClient();
3802
+ const store = client[kInternal3].httpClient.getOrCreateAttachmentUrlsStore(roomId);
3749
3803
  const getAttachmentUrlState = React4.useCallback(
3750
- () => attachmentUrlsStore.getState(attachmentId),
3751
- [attachmentUrlsStore, attachmentId]
3804
+ () => store.getState(attachmentId),
3805
+ [store, attachmentId]
3752
3806
  );
3753
3807
  React4.useEffect(() => {
3754
- void attachmentUrlsStore.get(attachmentId);
3755
- }, [attachmentUrlsStore, attachmentId]);
3808
+ void store.get(attachmentId);
3809
+ }, [store, attachmentId]);
3756
3810
  return useSyncExternalStoreWithSelector2(
3757
- attachmentUrlsStore.subscribe,
3811
+ store.subscribe,
3758
3812
  getAttachmentUrlState,
3759
3813
  getAttachmentUrlState,
3760
3814
  selectorFor_useAttachmentUrl,
@@ -3789,6 +3843,15 @@ function useAttachmentUrlSuspense(attachmentId) {
3789
3843
  error: void 0
3790
3844
  };
3791
3845
  }
3846
+ function useRoomPermissions(roomId) {
3847
+ const client = useClient();
3848
+ const store = getRoomExtrasForClient(client).store;
3849
+ return useSyncExternalStore2(
3850
+ store.subscribe,
3851
+ React4.useCallback(() => store._getPermissions(roomId), [store, roomId]),
3852
+ React4.useCallback(() => store._getPermissions(roomId), [store, roomId])
3853
+ ) ?? /* @__PURE__ */ new Set();
3854
+ }
3792
3855
  function createRoomContext(client) {
3793
3856
  return getOrCreateRoomContextBundle(client);
3794
3857
  }
@@ -3833,6 +3896,7 @@ var _useUpdateMyPresence = useUpdateMyPresence;
3833
3896
 
3834
3897
  export {
3835
3898
  RoomContext,
3899
+ useRoomOrNull,
3836
3900
  ClientContext,
3837
3901
  getUmbrellaStoreForClient,
3838
3902
  useClient,
@@ -3867,20 +3931,33 @@ export {
3867
3931
  useCanRedo,
3868
3932
  useOthersConnectionIds,
3869
3933
  useCommentsErrorListener,
3934
+ useCreateRoomThread,
3935
+ useDeleteRoomThread,
3936
+ useEditRoomThreadMetadata,
3870
3937
  useCreateComment,
3938
+ useCreateRoomComment,
3871
3939
  useEditComment,
3940
+ useEditRoomComment,
3872
3941
  useDeleteComment,
3942
+ useDeleteRoomComment,
3943
+ useAddRoomCommentReaction,
3873
3944
  useRemoveReaction,
3945
+ useRemoveRoomCommentReaction,
3874
3946
  useMarkThreadAsRead,
3947
+ useMarkRoomThreadAsRead,
3875
3948
  useMarkThreadAsResolved,
3949
+ useMarkRoomThreadAsResolved,
3876
3950
  useMarkThreadAsUnresolved,
3951
+ useMarkRoomThreadAsUnresolved,
3877
3952
  useThreadSubscription,
3878
3953
  useHistoryVersionData,
3879
3954
  useUpdateRoomNotificationSettings,
3880
3955
  useOthersConnectionIdsSuspense,
3881
3956
  useStorageStatusSuspense,
3882
3957
  useAttachmentUrl,
3958
+ useRoomAttachmentUrl,
3883
3959
  useAttachmentUrlSuspense,
3960
+ useRoomPermissions,
3884
3961
  createRoomContext,
3885
3962
  _RoomProvider,
3886
3963
  _useBroadcastEvent,
@@ -3913,4 +3990,4 @@ export {
3913
3990
  _useStorageRoot,
3914
3991
  _useUpdateMyPresence
3915
3992
  };
3916
- //# sourceMappingURL=chunk-CX62YECU.mjs.map
3993
+ //# sourceMappingURL=chunk-SEMVNYPJ.mjs.map