@liveblocks/react 3.8.0-next2 → 3.8.0-next3

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.
@@ -186,6 +186,7 @@ function useSignal(signal, selector, isEqual) {
186
186
 
187
187
 
188
188
 
189
+
189
190
  // src/config.ts
190
191
  var SECONDS = 1e3;
191
192
  var MINUTES = 60 * SECONDS;
@@ -216,21 +217,6 @@ function ASYNC_OK(fieldOrData, data) {
216
217
  }
217
218
  }
218
219
 
219
- // src/lib/itertools.ts
220
- function find(it, predicate) {
221
- for (const item of it) {
222
- if (predicate(item)) return item;
223
- }
224
- return void 0;
225
- }
226
- function count(it, predicate) {
227
- let total = 0;
228
- for (const item of it) {
229
- if (predicate(item)) total++;
230
- }
231
- return total;
232
- }
233
-
234
220
  // src/lib/ssr.ts
235
221
  function ensureNotServerSide() {
236
222
  if (typeof window === "undefined") {
@@ -324,6 +310,14 @@ function autobind(self) {
324
310
  } while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
325
311
  }
326
312
 
313
+ // src/lib/itertools.ts
314
+ function find(it, predicate) {
315
+ for (const item of it) {
316
+ if (predicate(item)) return item;
317
+ }
318
+ return void 0;
319
+ }
320
+
327
321
  // src/lib/querying.ts
328
322
 
329
323
  function makeThreadsFilter(query) {
@@ -722,6 +716,21 @@ function createStore_forNotifications() {
722
716
  upsert
723
717
  };
724
718
  }
719
+ function createStore_forUnreadNotificationsCount() {
720
+ const baseSignal = new (0, _core.MutableSignal)(
721
+ /* @__PURE__ */ new Map()
722
+ );
723
+ function update(queryKey, count) {
724
+ baseSignal.mutate((lut) => {
725
+ lut.set(queryKey, count);
726
+ });
727
+ }
728
+ return {
729
+ signal: _core.DerivedSignal.from(baseSignal, (c) => Object.fromEntries(c)),
730
+ // Mutations
731
+ update
732
+ };
733
+ }
725
734
  function createStore_forSubscriptions(updates, threads) {
726
735
  const baseSignal = new (0, _core.MutableSignal)(/* @__PURE__ */ new Map());
727
736
  function applyDelta(newSubscriptions, deletedSubscriptions) {
@@ -914,6 +923,7 @@ var UmbrellaStore = class {
914
923
 
915
924
 
916
925
 
926
+
917
927
  //
918
928
  // Output signals.
919
929
  // (Readonly, clean, consistent. With optimistic updates applied.)
@@ -958,6 +968,7 @@ var UmbrellaStore = class {
958
968
  this.optimisticUpdates.signal
959
969
  );
960
970
  this.historyVersions = createStore_forHistoryVersions();
971
+ this.unreadNotificationsCount = createStore_forUnreadNotificationsCount();
961
972
  const threadifications = _core.DerivedSignal.from(
962
973
  this.threads.signal,
963
974
  this.notifications.signal,
@@ -1114,6 +1125,35 @@ var UmbrellaStore = class {
1114
1125
  };
1115
1126
  }
1116
1127
  );
1128
+ const unreadNotificationsCount = new (0, _core.DefaultMap)(
1129
+ (queryKey) => {
1130
+ const query = JSON.parse(queryKey);
1131
+ const resource = new SinglePageResource(async () => {
1132
+ const result = await this.#client.getUnreadInboxNotificationsCount({
1133
+ query
1134
+ });
1135
+ this.unreadNotificationsCount.update(queryKey, result);
1136
+ });
1137
+ const signal = _core.DerivedSignal.from(
1138
+ () => {
1139
+ const result = resource.get();
1140
+ if (result.isLoading || result.error) {
1141
+ return result;
1142
+ } else {
1143
+ return ASYNC_OK(
1144
+ "count",
1145
+ _core.nn.call(void 0, this.unreadNotificationsCount.signal.get()[queryKey])
1146
+ );
1147
+ }
1148
+ },
1149
+ _core.shallow
1150
+ );
1151
+ return {
1152
+ signal,
1153
+ waitUntilLoaded: resource.waitUntilLoaded
1154
+ };
1155
+ }
1156
+ );
1117
1157
  const roomSubscriptionSettingsByRoomId = new (0, _core.DefaultMap)(
1118
1158
  (roomId) => {
1119
1159
  const resource = new SinglePageResource(async () => {
@@ -1262,6 +1302,7 @@ var UmbrellaStore = class {
1262
1302
  loadingUserThreads,
1263
1303
  notifications,
1264
1304
  loadingNotifications,
1305
+ unreadNotificationsCount,
1265
1306
  roomSubscriptionSettingsByRoomId,
1266
1307
  versionsByRoomId,
1267
1308
  notificationSettings,
@@ -1469,6 +1510,14 @@ var UmbrellaStore = class {
1469
1510
  result.subscriptions.deleted
1470
1511
  );
1471
1512
  }
1513
+ async fetchUnreadNotificationsCount(queryKey, signal) {
1514
+ const query = JSON.parse(queryKey);
1515
+ const result = await this.#client.getUnreadInboxNotificationsCount({
1516
+ query,
1517
+ signal
1518
+ });
1519
+ this.unreadNotificationsCount.update(queryKey, result);
1520
+ }
1472
1521
  async fetchRoomThreadsDeltaUpdate(roomId, signal) {
1473
1522
  const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
1474
1523
  if (lastRequestedAt === void 0) {
@@ -1983,16 +2032,10 @@ var _umbrellaStores = /* @__PURE__ */ new WeakMap();
1983
2032
  var _extras = /* @__PURE__ */ new WeakMap();
1984
2033
  var _bundles = /* @__PURE__ */ new WeakMap();
1985
2034
  function selectorFor_useUnreadInboxNotificationsCount(result) {
1986
- if (!result.inboxNotifications) {
2035
+ if (!("count" in result) || result.count === void 0) {
1987
2036
  return result;
1988
2037
  }
1989
- return ASYNC_OK(
1990
- "count",
1991
- count(
1992
- result.inboxNotifications,
1993
- (n) => n.readAt === null || n.readAt < n.notifiedAt
1994
- )
1995
- );
2038
+ return ASYNC_OK("count", result.count);
1996
2039
  }
1997
2040
  function selectorFor_useUser(state, userId) {
1998
2041
  if (state === void 0 || _optionalChain([state, 'optionalAccess', _10 => _10.isLoading])) {
@@ -2091,6 +2134,22 @@ function makeLiveblocksExtrasForClient(client) {
2091
2134
  config.NOTIFICATIONS_POLL_INTERVAL,
2092
2135
  { maxStaleTimeMs: config.NOTIFICATIONS_MAX_STALE_TIME }
2093
2136
  );
2137
+ const unreadNotificationsCountPollersByQueryKey = new (0, _core.DefaultMap)(
2138
+ (queryKey) => _core.makePoller.call(void 0,
2139
+ async (signal) => {
2140
+ try {
2141
+ return await store.fetchUnreadNotificationsCount(queryKey, signal);
2142
+ } catch (err) {
2143
+ _core.console.warn(
2144
+ `Polling unread inbox notifications countfailed: ${String(err)}`
2145
+ );
2146
+ throw err;
2147
+ }
2148
+ },
2149
+ config.NOTIFICATIONS_POLL_INTERVAL,
2150
+ { maxStaleTimeMs: config.NOTIFICATIONS_MAX_STALE_TIME }
2151
+ )
2152
+ );
2094
2153
  const userThreadsPoller = _core.makePoller.call(void 0,
2095
2154
  async (signal) => {
2096
2155
  try {
@@ -2121,7 +2180,8 @@ function makeLiveblocksExtrasForClient(client) {
2121
2180
  store,
2122
2181
  notificationsPoller,
2123
2182
  userThreadsPoller,
2124
- notificationSettingsPoller
2183
+ notificationSettingsPoller,
2184
+ unreadNotificationsCountPollersByQueryKey
2125
2185
  };
2126
2186
  }
2127
2187
  function makeLiveblocksContextBundle(client) {
@@ -2225,19 +2285,39 @@ function useInboxNotificationsSuspense_withClient(client, options) {
2225
2285
  return result;
2226
2286
  }
2227
2287
  function useUnreadInboxNotificationsCount_withClient(client, options) {
2228
- return useInboxNotifications_withClient(
2229
- client,
2288
+ const { store, unreadNotificationsCountPollersByQueryKey: pollers } = getLiveblocksExtrasForClient(client);
2289
+ const queryKey = makeInboxNotificationsQueryKey(_optionalChain([options, 'optionalAccess', _15 => _15.query]));
2290
+ const poller = pollers.getOrCreate(queryKey);
2291
+ _react.useEffect.call(void 0,
2292
+ () => void store.outputs.unreadNotificationsCount.getOrCreate(queryKey).waitUntilLoaded()
2293
+ // NOTE: Deliberately *not* using a dependency array here!
2294
+ //
2295
+ // It is important to call waitUntil on *every* render.
2296
+ // This is harmless though, on most renders, except:
2297
+ // 1. The very first render, in which case we'll want to trigger the initial page fetch.
2298
+ // 2. All other subsequent renders now "just" return the same promise (a quick operation).
2299
+ // 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
2300
+ // *next* render after that, a *new* fetch/promise will get created.
2301
+ );
2302
+ _react.useEffect.call(void 0, () => {
2303
+ poller.inc();
2304
+ poller.pollNowIfStale();
2305
+ return () => {
2306
+ poller.dec();
2307
+ };
2308
+ }, [poller]);
2309
+ return useSignal(
2310
+ store.outputs.unreadNotificationsCount.getOrCreate(queryKey).signal,
2230
2311
  selectorFor_useUnreadInboxNotificationsCount,
2231
- _core.shallow,
2232
- options
2312
+ _core.shallow
2233
2313
  );
2234
2314
  }
2235
2315
  function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
2236
2316
  ensureNotServerSide();
2237
2317
  const store = getLiveblocksExtrasForClient(client).store;
2238
- const queryKey = makeInboxNotificationsQueryKey(_optionalChain([options, 'optionalAccess', _15 => _15.query]));
2318
+ const queryKey = makeInboxNotificationsQueryKey(_optionalChain([options, 'optionalAccess', _16 => _16.query]));
2239
2319
  use(
2240
- store.outputs.loadingNotifications.getOrCreate(queryKey).waitUntilLoaded()
2320
+ store.outputs.unreadNotificationsCount.getOrCreate(queryKey).waitUntilLoaded()
2241
2321
  );
2242
2322
  const result = useUnreadInboxNotificationsCount_withClient(client, options);
2243
2323
  _core.assert.call(void 0, !result.isLoading, "Did not expect loading");
@@ -2247,7 +2327,7 @@ function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
2247
2327
  function useMarkInboxNotificationAsRead_withClient(client) {
2248
2328
  return _react.useCallback.call(void 0,
2249
2329
  (inboxNotificationId) => {
2250
- const { store } = getLiveblocksExtrasForClient(client);
2330
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2251
2331
  const readAt = /* @__PURE__ */ new Date();
2252
2332
  const optimisticId = store.optimisticUpdates.add({
2253
2333
  type: "mark-inbox-notification-as-read",
@@ -2261,6 +2341,10 @@ function useMarkInboxNotificationAsRead_withClient(client) {
2261
2341
  readAt,
2262
2342
  optimisticId
2263
2343
  );
2344
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2345
+ poller.markAsStale();
2346
+ poller.pollNowIfStale();
2347
+ }
2264
2348
  },
2265
2349
  (err) => {
2266
2350
  store.optimisticUpdates.remove(optimisticId);
@@ -2279,7 +2363,7 @@ function useMarkInboxNotificationAsRead_withClient(client) {
2279
2363
  }
2280
2364
  function useMarkAllInboxNotificationsAsRead_withClient(client) {
2281
2365
  return _react.useCallback.call(void 0, () => {
2282
- const { store } = getLiveblocksExtrasForClient(client);
2366
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2283
2367
  const readAt = /* @__PURE__ */ new Date();
2284
2368
  const optimisticId = store.optimisticUpdates.add({
2285
2369
  type: "mark-all-inbox-notifications-as-read",
@@ -2288,6 +2372,10 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
2288
2372
  client.markAllInboxNotificationsAsRead().then(
2289
2373
  () => {
2290
2374
  store.markAllInboxNotificationsRead(optimisticId, readAt);
2375
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2376
+ poller.markAsStale();
2377
+ poller.pollNowIfStale();
2378
+ }
2291
2379
  },
2292
2380
  (err) => {
2293
2381
  store.optimisticUpdates.remove(optimisticId);
@@ -2303,7 +2391,7 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
2303
2391
  function useDeleteInboxNotification_withClient(client) {
2304
2392
  return _react.useCallback.call(void 0,
2305
2393
  (inboxNotificationId) => {
2306
- const { store } = getLiveblocksExtrasForClient(client);
2394
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2307
2395
  const deletedAt = /* @__PURE__ */ new Date();
2308
2396
  const optimisticId = store.optimisticUpdates.add({
2309
2397
  type: "delete-inbox-notification",
@@ -2313,6 +2401,10 @@ function useDeleteInboxNotification_withClient(client) {
2313
2401
  client.deleteInboxNotification(inboxNotificationId).then(
2314
2402
  () => {
2315
2403
  store.deleteInboxNotification(inboxNotificationId, optimisticId);
2404
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2405
+ poller.markAsStale();
2406
+ poller.pollNowIfStale();
2407
+ }
2316
2408
  },
2317
2409
  (err) => {
2318
2410
  store.optimisticUpdates.remove(optimisticId);
@@ -2328,7 +2420,7 @@ function useDeleteInboxNotification_withClient(client) {
2328
2420
  }
2329
2421
  function useDeleteAllInboxNotifications_withClient(client) {
2330
2422
  return _react.useCallback.call(void 0, () => {
2331
- const { store } = getLiveblocksExtrasForClient(client);
2423
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2332
2424
  const deletedAt = /* @__PURE__ */ new Date();
2333
2425
  const optimisticId = store.optimisticUpdates.add({
2334
2426
  type: "delete-all-inbox-notifications",
@@ -2337,6 +2429,10 @@ function useDeleteAllInboxNotifications_withClient(client) {
2337
2429
  client.deleteAllInboxNotifications().then(
2338
2430
  () => {
2339
2431
  store.deleteAllInboxNotifications(optimisticId);
2432
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2433
+ poller.markAsStale();
2434
+ poller.pollNowIfStale();
2435
+ }
2340
2436
  },
2341
2437
  (err) => {
2342
2438
  store.optimisticUpdates.remove(optimisticId);
@@ -2390,7 +2486,7 @@ function useUpdateNotificationSettings_withClient(client) {
2390
2486
  store.optimisticUpdates.remove(optimisticUpdateId);
2391
2487
  if (err instanceof _core.HttpError) {
2392
2488
  if (err.status === 422) {
2393
- const msg = [_optionalChain([err, 'access', _16 => _16.details, 'optionalAccess', _17 => _17.error]), _optionalChain([err, 'access', _18 => _18.details, 'optionalAccess', _19 => _19.reason])].filter(Boolean).join("\n");
2489
+ const msg = [_optionalChain([err, 'access', _17 => _17.details, 'optionalAccess', _18 => _18.error]), _optionalChain([err, 'access', _19 => _19.details, 'optionalAccess', _20 => _20.reason])].filter(Boolean).join("\n");
2394
2490
  _core.console.error(msg);
2395
2491
  }
2396
2492
  client[_core.kInternal].emitError(
@@ -2625,7 +2721,7 @@ function useGroupInfoSuspense_withClient(client, groupId) {
2625
2721
  function useAiChats(options) {
2626
2722
  const client = useClient();
2627
2723
  const store = getUmbrellaStoreForClient(client);
2628
- const queryKey = makeAiChatsQueryKey(_optionalChain([options, 'optionalAccess', _20 => _20.query]));
2724
+ const queryKey = makeAiChatsQueryKey(_optionalChain([options, 'optionalAccess', _21 => _21.query]));
2629
2725
  useEnsureAiConnection(client);
2630
2726
  _react.useEffect.call(void 0,
2631
2727
  () => void store.outputs.aiChats.getOrCreate(queryKey).waitUntilLoaded()
@@ -2649,7 +2745,7 @@ function useAiChatsSuspense(options) {
2649
2745
  const client = useClient();
2650
2746
  const store = getUmbrellaStoreForClient(client);
2651
2747
  useEnsureAiConnection(client);
2652
- const queryKey = makeAiChatsQueryKey(_optionalChain([options, 'optionalAccess', _21 => _21.query]));
2748
+ const queryKey = makeAiChatsQueryKey(_optionalChain([options, 'optionalAccess', _22 => _22.query]));
2653
2749
  use(store.outputs.aiChats.getOrCreate(queryKey).waitUntilLoaded());
2654
2750
  const result = useAiChats(options);
2655
2751
  _core.assert.call(void 0, !result.error, "Did not expect error");
@@ -2661,7 +2757,7 @@ function useAiChatMessages(chatId, options) {
2661
2757
  const store = getUmbrellaStoreForClient(client);
2662
2758
  useEnsureAiConnection(client);
2663
2759
  _react.useEffect.call(void 0,
2664
- () => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.branchId]), () => ( null))).waitUntilLoaded()
2760
+ () => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.branchId]), () => ( null))).waitUntilLoaded()
2665
2761
  // NOTE: Deliberately *not* using a dependency array here!
2666
2762
  //
2667
2763
  // It is important to call waitUntil on *every* render.
@@ -2672,7 +2768,7 @@ function useAiChatMessages(chatId, options) {
2672
2768
  // *next* render after that, a *new* fetch/promise will get created.
2673
2769
  );
2674
2770
  return useSignal(
2675
- store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.branchId]), () => ( null))).signal
2771
+ store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _24 => _24.branchId]), () => ( null))).signal
2676
2772
  );
2677
2773
  }
2678
2774
  function useAiChatMessagesSuspense(chatId, options) {
@@ -2681,7 +2777,7 @@ function useAiChatMessagesSuspense(chatId, options) {
2681
2777
  const store = getUmbrellaStoreForClient(client);
2682
2778
  useEnsureAiConnection(client);
2683
2779
  use(
2684
- store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _24 => _24.branchId]), () => ( null))).waitUntilLoaded()
2780
+ store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _25 => _25.branchId]), () => ( null))).waitUntilLoaded()
2685
2781
  );
2686
2782
  const result = useAiChatMessages(chatId, options);
2687
2783
  _core.assert.call(void 0, !result.error, "Did not expect error");
@@ -2766,19 +2862,19 @@ function useAiChatStatus(chatId, branchId) {
2766
2862
  if (result.error) return IDLE;
2767
2863
  const messages = result.messages;
2768
2864
  const lastMessage = messages[messages.length - 1];
2769
- if (_optionalChain([lastMessage, 'optionalAccess', _25 => _25.role]) !== "assistant") return IDLE;
2865
+ if (_optionalChain([lastMessage, 'optionalAccess', _26 => _26.role]) !== "assistant") return IDLE;
2770
2866
  if (lastMessage.status !== "generating" && lastMessage.status !== "awaiting-tool")
2771
2867
  return IDLE;
2772
2868
  const contentSoFar = lastMessage.contentSoFar;
2773
2869
  const lastPart = contentSoFar[contentSoFar.length - 1];
2774
- if (_optionalChain([lastPart, 'optionalAccess', _26 => _26.type]) === "tool-invocation") {
2870
+ if (_optionalChain([lastPart, 'optionalAccess', _27 => _27.type]) === "tool-invocation") {
2775
2871
  return {
2776
2872
  status: "generating",
2777
2873
  partType: "tool-invocation",
2778
2874
  toolName: lastPart.name
2779
2875
  };
2780
2876
  } else {
2781
- return { status: "generating", partType: _optionalChain([lastPart, 'optionalAccess', _27 => _27.type]) };
2877
+ return { status: "generating", partType: _optionalChain([lastPart, 'optionalAccess', _28 => _28.type]) };
2782
2878
  }
2783
2879
  },
2784
2880
  // Consider { status: "generating", partType: "text" } and { status: "generating", partType: "text" } equal
@@ -2801,7 +2897,7 @@ function useSendAiMessage(chatId, options) {
2801
2897
  "chatId must be provided to either `useSendAiMessage` or its returned function."
2802
2898
  )));
2803
2899
  const messages = client[_core.kInternal].ai.signals.getChatMessagesForBranch\u03A3(resolvedChatId).get();
2804
- if (process.env.NODE_ENV !== "production" && !messageOptionsCopilotId && !_optionalChain([options, 'optionalAccess', _28 => _28.copilotId])) {
2900
+ if (process.env.NODE_ENV !== "production" && !messageOptionsCopilotId && !_optionalChain([options, 'optionalAccess', _29 => _29.copilotId])) {
2805
2901
  _core.console.warn(
2806
2902
  `No copilot ID was provided to useSendAiMessage when sending the message "${messageText.slice(
2807
2903
  0,
@@ -2813,8 +2909,8 @@ To ensure the correct copilot ID is used, specify it either through the hook as
2813
2909
  )}\u2026", copilotId: "co_xxx" })'`
2814
2910
  );
2815
2911
  }
2816
- const resolvedCopilotId = _nullishCoalesce(_nullishCoalesce(messageOptionsCopilotId, () => ( _optionalChain([options, 'optionalAccess', _29 => _29.copilotId]))), () => ( client[_core.kInternal].ai.getLastUsedCopilotId(resolvedChatId)));
2817
- const lastMessageId = _nullishCoalesce(_optionalChain([messages, 'access', _30 => _30[messages.length - 1], 'optionalAccess', _31 => _31.id]), () => ( null));
2912
+ const resolvedCopilotId = _nullishCoalesce(_nullishCoalesce(messageOptionsCopilotId, () => ( _optionalChain([options, 'optionalAccess', _30 => _30.copilotId]))), () => ( client[_core.kInternal].ai.getLastUsedCopilotId(resolvedChatId)));
2913
+ const lastMessageId = _nullishCoalesce(_optionalChain([messages, 'access', _31 => _31[messages.length - 1], 'optionalAccess', _32 => _32.id]), () => ( null));
2818
2914
  const content = [{ type: "text", text: messageText }];
2819
2915
  const newMessageId = client[_core.kInternal].ai[_core.kInternal].context.messagesStore.createOptimistically(
2820
2916
  resolvedChatId,
@@ -2834,10 +2930,10 @@ To ensure the correct copilot ID is used, specify it either through the hook as
2834
2930
  { id: newMessageId, parentMessageId: lastMessageId, content },
2835
2931
  targetMessageId,
2836
2932
  {
2837
- stream: _nullishCoalesce(messageOptions.stream, () => ( _optionalChain([options, 'optionalAccess', _32 => _32.stream]))),
2933
+ stream: _nullishCoalesce(messageOptions.stream, () => ( _optionalChain([options, 'optionalAccess', _33 => _33.stream]))),
2838
2934
  copilotId: resolvedCopilotId,
2839
- timeout: _nullishCoalesce(messageOptions.timeout, () => ( _optionalChain([options, 'optionalAccess', _33 => _33.timeout]))),
2840
- knowledge: _nullishCoalesce(messageOptions.knowledge, () => ( _optionalChain([options, 'optionalAccess', _34 => _34.knowledge])))
2935
+ timeout: _nullishCoalesce(messageOptions.timeout, () => ( _optionalChain([options, 'optionalAccess', _34 => _34.timeout]))),
2936
+ knowledge: _nullishCoalesce(messageOptions.knowledge, () => ( _optionalChain([options, 'optionalAccess', _35 => _35.knowledge])))
2841
2937
  }
2842
2938
  );
2843
2939
  return newMessage;
@@ -2845,10 +2941,10 @@ To ensure the correct copilot ID is used, specify it either through the hook as
2845
2941
  [
2846
2942
  client,
2847
2943
  chatId,
2848
- _optionalChain([options, 'optionalAccess', _35 => _35.copilotId]),
2849
- _optionalChain([options, 'optionalAccess', _36 => _36.stream]),
2850
- _optionalChain([options, 'optionalAccess', _37 => _37.timeout]),
2851
- _optionalChain([options, 'optionalAccess', _38 => _38.knowledge])
2944
+ _optionalChain([options, 'optionalAccess', _36 => _36.copilotId]),
2945
+ _optionalChain([options, 'optionalAccess', _37 => _37.stream]),
2946
+ _optionalChain([options, 'optionalAccess', _38 => _38.timeout]),
2947
+ _optionalChain([options, 'optionalAccess', _39 => _39.knowledge])
2852
2948
  ]
2853
2949
  );
2854
2950
  }
@@ -2884,7 +2980,7 @@ function createSharedContext(client) {
2884
2980
  }
2885
2981
  function useEnsureNoLiveblocksProvider(options) {
2886
2982
  const existing = useClientOrNull();
2887
- if (!_optionalChain([options, 'optionalAccess', _39 => _39.allowNesting]) && existing !== null) {
2983
+ if (!_optionalChain([options, 'optionalAccess', _40 => _40.allowNesting]) && existing !== null) {
2888
2984
  throw new Error(
2889
2985
  "You cannot nest multiple LiveblocksProvider instances in the same React tree."
2890
2986
  );
@@ -3048,7 +3144,7 @@ var _useAiChatSuspense = useAiChatSuspense;
3048
3144
  var _useAiChatMessages = useAiChatMessages;
3049
3145
  var _useAiChatMessagesSuspense = useAiChatMessagesSuspense;
3050
3146
  function useSyncStatus_withClient(client, options) {
3051
- const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.smooth]), () => ( false)));
3147
+ const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.smooth]), () => ( false)));
3052
3148
  if (smooth) {
3053
3149
  return useSyncStatusSmooth_withClient(client);
3054
3150
  } else {
@@ -3227,8 +3323,8 @@ function makeRoomExtrasForClient(client) {
3227
3323
  if (innerError.status === 403) {
3228
3324
  const detailedMessage = [
3229
3325
  innerError.message,
3230
- _optionalChain([innerError, 'access', _41 => _41.details, 'optionalAccess', _42 => _42.suggestion]),
3231
- _optionalChain([innerError, 'access', _43 => _43.details, 'optionalAccess', _44 => _44.docs])
3326
+ _optionalChain([innerError, 'access', _42 => _42.details, 'optionalAccess', _43 => _43.suggestion]),
3327
+ _optionalChain([innerError, 'access', _44 => _44.details, 'optionalAccess', _45 => _45.docs])
3232
3328
  ].filter(Boolean).join("\n");
3233
3329
  _core.console.error(detailedMessage);
3234
3330
  }
@@ -3523,7 +3619,7 @@ function RoomProviderInner(props) {
3523
3619
  }
3524
3620
  function useRoom(options) {
3525
3621
  const room = useRoomOrNull();
3526
- if (room === null && !_optionalChain([options, 'optionalAccess', _45 => _45.allowOutsideRoom])) {
3622
+ if (room === null && !_optionalChain([options, 'optionalAccess', _46 => _46.allowOutsideRoom])) {
3527
3623
  throw new Error("RoomProvider is missing from the React tree.");
3528
3624
  }
3529
3625
  return room;
@@ -3873,7 +3969,7 @@ function useCreateRoomThread(roomId) {
3873
3969
  thread: newThread,
3874
3970
  roomId
3875
3971
  });
3876
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _46 => _46.map, 'call', _47 => _47((attachment) => attachment.id)]);
3972
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _47 => _47.map, 'call', _48 => _48((attachment) => attachment.id)]);
3877
3973
  client[_core.kInternal].httpClient.createThread({
3878
3974
  roomId,
3879
3975
  threadId,
@@ -3913,7 +4009,7 @@ function useDeleteRoomThread(roomId) {
3913
4009
  const { store, onMutationFailure } = getRoomExtrasForClient(client);
3914
4010
  const userId = getCurrentUserId(client);
3915
4011
  const existing = store.outputs.threads.get().get(threadId);
3916
- if (_optionalChain([existing, 'optionalAccess', _48 => _48.comments, 'optionalAccess', _49 => _49[0], 'optionalAccess', _50 => _50.userId]) !== userId) {
4012
+ if (_optionalChain([existing, 'optionalAccess', _49 => _49.comments, 'optionalAccess', _50 => _50[0], 'optionalAccess', _51 => _51.userId]) !== userId) {
3917
4013
  throw new Error("Only the thread creator can delete the thread");
3918
4014
  }
3919
4015
  const optimisticId = store.optimisticUpdates.add({
@@ -4001,7 +4097,7 @@ function useCreateRoomComment(roomId) {
4001
4097
  type: "create-comment",
4002
4098
  comment
4003
4099
  });
4004
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _51 => _51.map, 'call', _52 => _52((attachment) => attachment.id)]);
4100
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _52 => _52.map, 'call', _53 => _53((attachment) => attachment.id)]);
4005
4101
  client[_core.kInternal].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
4006
4102
  (newComment) => {
4007
4103
  store.createComment(newComment, optimisticId);
@@ -4057,7 +4153,7 @@ function useEditRoomComment(roomId) {
4057
4153
  attachments: _nullishCoalesce(attachments, () => ( []))
4058
4154
  }
4059
4155
  });
4060
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _53 => _53.map, 'call', _54 => _54((attachment) => attachment.id)]);
4156
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _54 => _54.map, 'call', _55 => _55((attachment) => attachment.id)]);
4061
4157
  client[_core.kInternal].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
4062
4158
  (editedComment) => {
4063
4159
  store.editComment(threadId, optimisticId, editedComment);
@@ -4398,7 +4494,7 @@ function useRoomThreadSubscription(roomId, threadId) {
4398
4494
  }
4399
4495
  return {
4400
4496
  status: "subscribed",
4401
- unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess', _55 => _55.readAt]), () => ( null)),
4497
+ unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess', _56 => _56.readAt]), () => ( null)),
4402
4498
  subscribe,
4403
4499
  unsubscribe
4404
4500
  };
@@ -4609,7 +4705,7 @@ function useThreadsSuspense(options = {}) {
4609
4705
  return result;
4610
4706
  }
4611
4707
  function selectorFor_useAttachmentUrl(state) {
4612
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _56 => _56.isLoading])) {
4708
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _57 => _57.isLoading])) {
4613
4709
  return _nullishCoalesce(state, () => ( { isLoading: true }));
4614
4710
  }
4615
4711
  if (state.error) {
@@ -4838,4 +4934,4 @@ var _useUpdateMyPresence = useUpdateMyPresence;
4838
4934
 
4839
4935
 
4840
4936
  exports.ClientContext = ClientContext; exports.useClientOrNull = useClientOrNull; exports.useClient = useClient; exports.RoomContext = RoomContext; exports.useLatest = useLatest; exports.RegisterAiKnowledge = RegisterAiKnowledge; exports.RegisterAiTool = RegisterAiTool; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; exports.useSignal = useSignal; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useCreateAiChat = useCreateAiChat; exports.useDeleteAiChat = useDeleteAiChat; exports.useAiChatStatus = useAiChatStatus; exports.useSendAiMessage = useSendAiMessage; 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.useNotificationSettings = useNotificationSettings; exports.useNotificationSettingsSuspense = useNotificationSettingsSuspense; exports.useUpdateNotificationSettings = useUpdateNotificationSettings; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports.useGroupInfo = useGroupInfo; exports.useGroupInfoSuspense = useGroupInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental; exports._useAiChats = _useAiChats; exports._useAiChatsSuspense = _useAiChatsSuspense; exports._useAiChat = _useAiChat; exports._useAiChatSuspense = _useAiChatSuspense; exports._useAiChatMessages = _useAiChatMessages; exports._useAiChatMessagesSuspense = _useAiChatMessagesSuspense; exports.useSyncStatus = useSyncStatus; exports.useErrorListener = useErrorListener; exports.useStatus = useStatus; exports.useReportTextEditor = useReportTextEditor; exports.useYjsProvider = useYjsProvider; exports.useCreateTextMention = useCreateTextMention; exports.useDeleteTextMention = useDeleteTextMention; exports.useResolveMentionSuggestions = useResolveMentionSuggestions; exports.useMentionSuggestionsCache = useMentionSuggestionsCache; exports.useLostConnectionListener = useLostConnectionListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCreateRoomThread = useCreateRoomThread; exports.useDeleteRoomThread = useDeleteRoomThread; exports.useEditRoomThreadMetadata = useEditRoomThreadMetadata; exports.useCreateComment = useCreateComment; exports.useCreateRoomComment = useCreateRoomComment; exports.useEditComment = useEditComment; exports.useEditRoomComment = useEditRoomComment; exports.useDeleteComment = useDeleteComment; exports.useDeleteRoomComment = useDeleteRoomComment; exports.useAddRoomCommentReaction = useAddRoomCommentReaction; exports.useRemoveReaction = useRemoveReaction; exports.useRemoveRoomCommentReaction = useRemoveRoomCommentReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkRoomThreadAsRead = useMarkRoomThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkRoomThreadAsResolved = useMarkRoomThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useMarkRoomThreadAsUnresolved = useMarkRoomThreadAsUnresolved; exports.useSubscribeToThread = useSubscribeToThread; exports.useUnsubscribeFromThread = useUnsubscribeFromThread; exports.useThreadSubscription = useThreadSubscription; exports.useRoomThreadSubscription = useRoomThreadSubscription; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomSubscriptionSettings = useUpdateRoomSubscriptionSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useAttachmentUrl = useAttachmentUrl; exports.useRoomAttachmentUrl = useRoomAttachmentUrl; exports.useAttachmentUrlSuspense = useAttachmentUrlSuspense; exports.useRoomPermissions = useRoomPermissions; 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._useRoomSubscriptionSettings = _useRoomSubscriptionSettings; exports._useRoomSubscriptionSettingsSuspense = _useRoomSubscriptionSettingsSuspense; 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;
4841
- //# sourceMappingURL=chunk-45BFK66K.cjs.map
4937
+ //# sourceMappingURL=chunk-OYVPE6CV.cjs.map