@liveblocks/react 2.25.0-aiprivatebeta8 → 3.0.0

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,5 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/contexts.ts
2
+ var _core = require('@liveblocks/core');
2
3
  var _react = require('react');
4
+ var ClientContext = _react.createContext.call(void 0, null);
5
+ function useClientOrNull() {
6
+ return _react.useContext.call(void 0, ClientContext);
7
+ }
8
+ function useClient() {
9
+ return _nullishCoalesce(useClientOrNull(), () => ( _core.raise.call(void 0, "LiveblocksProvider is missing from the React tree.")));
10
+ }
3
11
  var RoomContext = _react.createContext.call(void 0, null);
4
12
  function useRoomOrNull() {
5
13
  return _react.useContext.call(void 0, RoomContext);
@@ -9,6 +17,50 @@ function useIsInsideRoom() {
9
17
  return room !== null;
10
18
  }
11
19
 
20
+ // src/ai.tsx
21
+
22
+
23
+ function useAi() {
24
+ return useClient()[_core.kInternal].ai;
25
+ }
26
+ function useRandom() {
27
+ return _react.useState.call(void 0, _core.nanoid)[0];
28
+ }
29
+ var RegisterAiKnowledge = _react.memo.call(void 0, function RegisterAiKnowledge2(props) {
30
+ const layerId = _react.useId.call(void 0, );
31
+ const ai = useAi();
32
+ const { description, value } = props;
33
+ const [layerKey, setLayerKey] = _react.useState.call(void 0, );
34
+ _react.useEffect.call(void 0, () => {
35
+ const layerKey2 = ai.registerKnowledgeLayer(layerId);
36
+ setLayerKey(layerKey2);
37
+ return () => {
38
+ ai.deregisterKnowledgeLayer(layerKey2);
39
+ setLayerKey(void 0);
40
+ };
41
+ }, [ai, layerId]);
42
+ const randomKey = useRandom();
43
+ const knowledgeKey = _nullishCoalesce(props.id, () => ( randomKey));
44
+ _react.useEffect.call(void 0, () => {
45
+ if (layerKey !== void 0) {
46
+ ai.updateKnowledge(layerKey, { description, value }, knowledgeKey);
47
+ }
48
+ }, [ai, layerKey, knowledgeKey, description, value]);
49
+ return null;
50
+ });
51
+ var RegisterAiTool = _react.memo.call(void 0, function RegisterAiTool2({
52
+ chatId,
53
+ name,
54
+ tool
55
+ }) {
56
+ const client = useClient();
57
+ const ai = client[_core.kInternal].ai;
58
+ _react.useEffect.call(void 0, () => {
59
+ return ai.registerTool(name, tool, chatId);
60
+ }, [ai, chatId, name, tool]);
61
+ return null;
62
+ });
63
+
12
64
  // src/use-sync-external-store-with-selector.ts
13
65
 
14
66
 
@@ -86,7 +138,7 @@ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnaps
86
138
  }
87
139
 
88
140
  // src/use-signal.ts
89
- var _core = require('@liveblocks/core');
141
+
90
142
  var identity = (value) => value;
91
143
  function useSignal(signal, selector, isEqual) {
92
144
  if (signal instanceof _core.MutableSignal) {
@@ -120,10 +172,6 @@ function useSignal(signal, selector, isEqual) {
120
172
 
121
173
 
122
174
 
123
-
124
-
125
-
126
-
127
175
 
128
176
  // src/config.ts
129
177
  var SECONDS = 1e3;
@@ -1162,7 +1210,7 @@ var UmbrellaStore = class {
1162
1210
  await this.#client[_core.kInternal].ai.getOrCreateChat(chatId);
1163
1211
  });
1164
1212
  const signal = _core.DerivedSignal.from(() => {
1165
- const chat = this.#client[_core.kInternal].ai.signals.getChatById(chatId);
1213
+ const chat = this.#client[_core.kInternal].ai.getChatById(chatId);
1166
1214
  if (chat === void 0) {
1167
1215
  const result = resource.get();
1168
1216
  if (result.isLoading || result.error) {
@@ -1170,13 +1218,13 @@ var UmbrellaStore = class {
1170
1218
  } else {
1171
1219
  return ASYNC_OK(
1172
1220
  "chat",
1173
- _core.nn.call(void 0, this.#client[_core.kInternal].ai.signals.getChatById(chatId))
1221
+ _core.nn.call(void 0, this.#client[_core.kInternal].ai.getChatById(chatId))
1174
1222
  );
1175
1223
  }
1176
1224
  } else {
1177
1225
  return ASYNC_OK(
1178
1226
  "chat",
1179
- _core.nn.call(void 0, this.#client[_core.kInternal].ai.signals.getChatById(chatId))
1227
+ _core.nn.call(void 0, this.#client[_core.kInternal].ai.getChatById(chatId))
1180
1228
  );
1181
1229
  }
1182
1230
  }, _core.shallow);
@@ -1905,8 +1953,11 @@ function isThreadParticipant(thread, userId) {
1905
1953
  isParticipant = true;
1906
1954
  break;
1907
1955
  }
1908
- const mentionedIds = _core.getMentionedIdsFromCommentBody.call(void 0, comment.body);
1909
- if (mentionedIds.includes(userId)) {
1956
+ const mentions = _core.getMentionsFromCommentBody.call(void 0,
1957
+ comment.body,
1958
+ (mention) => mention.kind === "user" && mention.id === userId
1959
+ );
1960
+ if (mentions.length > 0) {
1910
1961
  isParticipant = true;
1911
1962
  break;
1912
1963
  }
@@ -1916,7 +1967,6 @@ function isThreadParticipant(thread, userId) {
1916
1967
 
1917
1968
  // src/liveblocks.tsx
1918
1969
  var _jsxruntime = require('react/jsx-runtime');
1919
- var ClientContext = _react.createContext.call(void 0, null);
1920
1970
  function missingUserError(userId) {
1921
1971
  return new Error(`resolveUsers didn't return anything for user '${userId}'`);
1922
1972
  }
@@ -2003,6 +2053,11 @@ function getLiveblocksExtrasForClient(client) {
2003
2053
  }
2004
2054
  return extras;
2005
2055
  }
2056
+ function useEnsureAiConnection(client) {
2057
+ _react.useEffect.call(void 0, () => {
2058
+ client[_core.kInternal].ai.connectInitially();
2059
+ }, [client]);
2060
+ }
2006
2061
  function makeLiveblocksExtrasForClient(client) {
2007
2062
  const store = getUmbrellaStoreForClient(client);
2008
2063
  const notificationsPoller = _core.makePoller.call(void 0,
@@ -2079,6 +2134,7 @@ function makeLiveblocksContextBundle(client) {
2079
2134
  useAiChatMessages,
2080
2135
  useCreateAiChat,
2081
2136
  useDeleteAiChat,
2137
+ useSendAiMessage,
2082
2138
  ...shared.classic,
2083
2139
  suspense: {
2084
2140
  LiveblocksProvider: LiveblocksProvider2,
@@ -2097,6 +2153,7 @@ function makeLiveblocksContextBundle(client) {
2097
2153
  useAiChatMessages: useAiChatMessagesSuspense,
2098
2154
  useCreateAiChat,
2099
2155
  useDeleteAiChat,
2156
+ useSendAiMessage,
2100
2157
  ...shared.suspense
2101
2158
  }
2102
2159
  };
@@ -2304,7 +2361,7 @@ function useUpdateNotificationSettings_withClient(client) {
2304
2361
  }
2305
2362
  client[_core.kInternal].emitError(
2306
2363
  {
2307
- type: "UPDATE_USER_NOTIFICATION_SETTINGS_ERROR"
2364
+ type: "UPDATE_NOTIFICATION_SETTINGS_ERROR"
2308
2365
  },
2309
2366
  err
2310
2367
  );
@@ -2472,6 +2529,7 @@ function useRoomInfoSuspense_withClient(client, roomId) {
2472
2529
  function useAiChats() {
2473
2530
  const client = useClient();
2474
2531
  const store = getUmbrellaStoreForClient(client);
2532
+ useEnsureAiConnection(client);
2475
2533
  _react.useEffect.call(void 0,
2476
2534
  () => void store.outputs.aiChats.waitUntilLoaded()
2477
2535
  // NOTE: Deliberately *not* using a dependency array here!
@@ -2489,17 +2547,19 @@ function useAiChatsSuspense() {
2489
2547
  ensureNotServerSide();
2490
2548
  const client = useClient();
2491
2549
  const store = getUmbrellaStoreForClient(client);
2550
+ useEnsureAiConnection(client);
2492
2551
  use(store.outputs.aiChats.waitUntilLoaded());
2493
2552
  const result = useAiChats();
2494
2553
  _core.assert.call(void 0, !result.error, "Did not expect error");
2495
2554
  _core.assert.call(void 0, !result.isLoading, "Did not expect loading");
2496
2555
  return result;
2497
2556
  }
2498
- function useAiChatMessages(chatId, branch) {
2557
+ function useAiChatMessages(chatId, options) {
2499
2558
  const client = useClient();
2500
2559
  const store = getUmbrellaStoreForClient(client);
2560
+ useEnsureAiConnection(client);
2501
2561
  _react.useEffect.call(void 0,
2502
- () => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(branch, () => ( null))).waitUntilLoaded()
2562
+ () => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _16 => _16.branchId]), () => ( null))).waitUntilLoaded()
2503
2563
  // NOTE: Deliberately *not* using a dependency array here!
2504
2564
  //
2505
2565
  // It is important to call waitUntil on *every* render.
@@ -2510,17 +2570,18 @@ function useAiChatMessages(chatId, branch) {
2510
2570
  // *next* render after that, a *new* fetch/promise will get created.
2511
2571
  );
2512
2572
  return useSignal(
2513
- store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(branch, () => ( null))).signal
2573
+ store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.branchId]), () => ( null))).signal
2514
2574
  );
2515
2575
  }
2516
- function useAiChatMessagesSuspense(chatId, branch) {
2576
+ function useAiChatMessagesSuspense(chatId, options) {
2517
2577
  ensureNotServerSide();
2518
2578
  const client = useClient();
2519
2579
  const store = getUmbrellaStoreForClient(client);
2580
+ useEnsureAiConnection(client);
2520
2581
  use(
2521
- store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(branch, () => ( null))).waitUntilLoaded()
2582
+ store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _18 => _18.branchId]), () => ( null))).waitUntilLoaded()
2522
2583
  );
2523
- const result = useAiChatMessages(chatId, branch);
2584
+ const result = useAiChatMessages(chatId, options);
2524
2585
  _core.assert.call(void 0, !result.error, "Did not expect error");
2525
2586
  _core.assert.call(void 0, !result.isLoading, "Did not expect loading");
2526
2587
  return result;
@@ -2528,6 +2589,7 @@ function useAiChatMessagesSuspense(chatId, branch) {
2528
2589
  function useAiChat(chatId) {
2529
2590
  const client = useClient();
2530
2591
  const store = getUmbrellaStoreForClient(client);
2592
+ useEnsureAiConnection(client);
2531
2593
  _react.useEffect.call(void 0,
2532
2594
  () => void store.outputs.aiChatById.getOrCreate(chatId).waitUntilLoaded()
2533
2595
  // NOTE: Deliberately *not* using a dependency array here!
@@ -2545,6 +2607,7 @@ function useAiChatSuspense(chatId) {
2545
2607
  ensureNotServerSide();
2546
2608
  const client = useClient();
2547
2609
  const store = getUmbrellaStoreForClient(client);
2610
+ useEnsureAiConnection(client);
2548
2611
  use(store.outputs.aiChatById.getOrCreate(chatId).waitUntilLoaded());
2549
2612
  const result = useAiChat(chatId);
2550
2613
  _core.assert.call(void 0, !result.error, "Did not expect error");
@@ -2555,7 +2618,10 @@ function useCreateAiChat() {
2555
2618
  const client = useClient();
2556
2619
  return _react.useCallback.call(void 0,
2557
2620
  (options) => {
2558
- client[_core.kInternal].ai.getOrCreateChat(options.id, options).catch((err) => {
2621
+ client[_core.kInternal].ai.getOrCreateChat(options.id, {
2622
+ title: options.title,
2623
+ metadata: options.metadata
2624
+ }).catch((err) => {
2559
2625
  console.error(
2560
2626
  `Failed to create chat with ID "${options.id}": ${String(err)}`
2561
2627
  );
@@ -2577,6 +2643,39 @@ function useDeleteAiChat() {
2577
2643
  [client]
2578
2644
  );
2579
2645
  }
2646
+ function useSendAiMessage(chatId, options) {
2647
+ const client = useClient();
2648
+ const copilotId = _optionalChain([options, 'optionalAccess', _19 => _19.copilotId]);
2649
+ return _react.useCallback.call(void 0,
2650
+ (message) => {
2651
+ const messages = client[_core.kInternal].ai.signals.getChatMessagesForBranch\u03A3(chatId).get();
2652
+ const lastMessageId = _nullishCoalesce(_optionalChain([messages, 'access', _20 => _20[messages.length - 1], 'optionalAccess', _21 => _21.id]), () => ( null));
2653
+ const content = [{ type: "text", text: message }];
2654
+ const newMessageId = client[_core.kInternal].ai[_core.kInternal].context.messagesStore.createOptimistically(
2655
+ chatId,
2656
+ "user",
2657
+ lastMessageId,
2658
+ content
2659
+ );
2660
+ const targetMessageId = client[_core.kInternal].ai[_core.kInternal].context.messagesStore.createOptimistically(
2661
+ chatId,
2662
+ "assistant",
2663
+ newMessageId
2664
+ );
2665
+ void client[_core.kInternal].ai.askUserMessageInChat(
2666
+ chatId,
2667
+ { id: newMessageId, parentMessageId: lastMessageId, content },
2668
+ targetMessageId,
2669
+ {
2670
+ stream: _optionalChain([options, 'optionalAccess', _22 => _22.stream]),
2671
+ copilotId,
2672
+ timeout: _optionalChain([options, 'optionalAccess', _23 => _23.timeout])
2673
+ }
2674
+ );
2675
+ },
2676
+ [client, chatId, copilotId, _optionalChain([options, 'optionalAccess', _24 => _24.stream]), _optionalChain([options, 'optionalAccess', _25 => _25.timeout])]
2677
+ );
2678
+ }
2580
2679
  function createSharedContext(client) {
2581
2680
  const useClient2 = () => client;
2582
2681
  function useSyncStatus2(options) {
@@ -2589,7 +2688,9 @@ function createSharedContext(client) {
2589
2688
  useRoomInfo: (roomId) => useRoomInfo_withClient(client, roomId),
2590
2689
  useIsInsideRoom,
2591
2690
  useErrorListener,
2592
- useSyncStatus: useSyncStatus2
2691
+ useSyncStatus: useSyncStatus2,
2692
+ RegisterAiKnowledge,
2693
+ RegisterAiTool
2593
2694
  },
2594
2695
  suspense: {
2595
2696
  useClient: useClient2,
@@ -2597,24 +2698,20 @@ function createSharedContext(client) {
2597
2698
  useRoomInfo: (roomId) => useRoomInfoSuspense_withClient(client, roomId),
2598
2699
  useIsInsideRoom,
2599
2700
  useErrorListener,
2600
- useSyncStatus: useSyncStatus2
2701
+ useSyncStatus: useSyncStatus2,
2702
+ RegisterAiKnowledge,
2703
+ RegisterAiTool
2601
2704
  }
2602
2705
  };
2603
2706
  }
2604
2707
  function useEnsureNoLiveblocksProvider(options) {
2605
2708
  const existing = useClientOrNull();
2606
- if (!_optionalChain([options, 'optionalAccess', _16 => _16.allowNesting]) && existing !== null) {
2709
+ if (!_optionalChain([options, 'optionalAccess', _26 => _26.allowNesting]) && existing !== null) {
2607
2710
  throw new Error(
2608
2711
  "You cannot nest multiple LiveblocksProvider instances in the same React tree."
2609
2712
  );
2610
2713
  }
2611
2714
  }
2612
- function useClientOrNull() {
2613
- return _react.useContext.call(void 0, ClientContext);
2614
- }
2615
- function useClient() {
2616
- return _nullishCoalesce(useClientOrNull(), () => ( _core.raise.call(void 0, "LiveblocksProvider is missing from the React tree.")));
2617
- }
2618
2715
  function LiveblocksProviderWithClient(props) {
2619
2716
  useEnsureNoLiveblocksProvider(props);
2620
2717
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ClientContext.Provider, { value: props.client, children: props.children });
@@ -2628,7 +2725,6 @@ function LiveblocksProvider(props) {
2628
2725
  backgroundKeepAliveTimeout: useInitial(o.backgroundKeepAliveTimeout),
2629
2726
  polyfills: useInitial(o.polyfills),
2630
2727
  largeMessageStrategy: useInitial(o.largeMessageStrategy),
2631
- unstable_fallbackToHTTP: useInitial(o.unstable_fallbackToHTTP),
2632
2728
  unstable_streamData: useInitial(o.unstable_streamData),
2633
2729
  preventUnsavedChanges: useInitial(o.preventUnsavedChanges),
2634
2730
  authEndpoint: useInitialUnlessFunction(o.authEndpoint),
@@ -2648,7 +2744,6 @@ function LiveblocksProvider(props) {
2648
2744
  };
2649
2745
  const client = _react.useMemo.call(void 0, () => _core.createClient.call(void 0, options), []);
2650
2746
  _react.useEffect.call(void 0, () => {
2651
- client[_core.kInternal].ai.connect();
2652
2747
  return () => {
2653
2748
  client[_core.kInternal].ai.disconnect();
2654
2749
  };
@@ -2755,11 +2850,12 @@ var _useUserThreads_experimental = useUserThreads_experimental;
2755
2850
  var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
2756
2851
  var _useAiChats = useAiChats;
2757
2852
  var _useAiChatsSuspense = useAiChatsSuspense;
2853
+ var _useAiChat = useAiChat;
2758
2854
  var _useAiChatSuspense = useAiChatSuspense;
2759
2855
  var _useAiChatMessages = useAiChatMessages;
2760
2856
  var _useAiChatMessagesSuspense = useAiChatMessagesSuspense;
2761
2857
  function useSyncStatus_withClient(client, options) {
2762
- const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.smooth]), () => ( false)));
2858
+ const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.smooth]), () => ( false)));
2763
2859
  if (smooth) {
2764
2860
  return useSyncStatusSmooth_withClient(client);
2765
2861
  } else {
@@ -2938,8 +3034,8 @@ function makeRoomExtrasForClient(client) {
2938
3034
  if (innerError.status === 403) {
2939
3035
  const detailedMessage = [
2940
3036
  innerError.message,
2941
- _optionalChain([innerError, 'access', _18 => _18.details, 'optionalAccess', _19 => _19.suggestion]),
2942
- _optionalChain([innerError, 'access', _20 => _20.details, 'optionalAccess', _21 => _21.docs])
3037
+ _optionalChain([innerError, 'access', _28 => _28.details, 'optionalAccess', _29 => _29.suggestion]),
3038
+ _optionalChain([innerError, 'access', _30 => _30.details, 'optionalAccess', _31 => _31.docs])
2943
3039
  ].filter(Boolean).join("\n");
2944
3040
  _core.console.error(detailedMessage);
2945
3041
  }
@@ -3019,8 +3115,6 @@ function makeRoomContextBundle(client) {
3019
3115
  RoomProvider: RoomProvider_withImplicitLiveblocksProvider,
3020
3116
  useRoom,
3021
3117
  useStatus,
3022
- useStorageStatus,
3023
- useBatch,
3024
3118
  useBroadcastEvent,
3025
3119
  useOthersListener,
3026
3120
  useLostConnectionListener,
@@ -3058,9 +3152,7 @@ function makeRoomContextBundle(client) {
3058
3152
  useAttachmentUrl,
3059
3153
  useHistoryVersions,
3060
3154
  useHistoryVersionData,
3061
- useRoomNotificationSettings,
3062
3155
  useRoomSubscriptionSettings,
3063
- useUpdateRoomNotificationSettings,
3064
3156
  useUpdateRoomSubscriptionSettings,
3065
3157
  ...shared.classic,
3066
3158
  suspense: {
@@ -3068,8 +3160,6 @@ function makeRoomContextBundle(client) {
3068
3160
  RoomProvider: RoomProvider_withImplicitLiveblocksProvider,
3069
3161
  useRoom,
3070
3162
  useStatus,
3071
- useStorageStatus: useStorageStatusSuspense,
3072
- useBatch,
3073
3163
  useBroadcastEvent,
3074
3164
  useOthersListener,
3075
3165
  useLostConnectionListener,
@@ -3107,9 +3197,7 @@ function makeRoomContextBundle(client) {
3107
3197
  useAttachmentUrl: useAttachmentUrlSuspense,
3108
3198
  // TODO: useHistoryVersionData: useHistoryVersionDataSuspense,
3109
3199
  useHistoryVersions: useHistoryVersionsSuspense,
3110
- useRoomNotificationSettings: useRoomNotificationSettingsSuspense,
3111
3200
  useRoomSubscriptionSettings: useRoomSubscriptionSettingsSuspense,
3112
- useUpdateRoomNotificationSettings,
3113
3201
  useUpdateRoomSubscriptionSettings,
3114
3202
  ...shared.suspense
3115
3203
  }
@@ -3239,7 +3327,7 @@ function RoomProviderInner(props) {
3239
3327
  }
3240
3328
  function useRoom(options) {
3241
3329
  const room = useRoomOrNull();
3242
- if (room === null && !_optionalChain([options, 'optionalAccess', _22 => _22.allowOutsideRoom])) {
3330
+ if (room === null && !_optionalChain([options, 'optionalAccess', _32 => _32.allowOutsideRoom])) {
3243
3331
  throw new Error("RoomProvider is missing from the React tree.");
3244
3332
  }
3245
3333
  return room;
@@ -3313,45 +3401,6 @@ function useMentionSuggestionsCache() {
3313
3401
  const client = useClient();
3314
3402
  return client[_core.kInternal].mentionSuggestionsCache;
3315
3403
  }
3316
- function useStorageStatus(options) {
3317
- const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.smooth]), () => ( false)));
3318
- if (smooth) {
3319
- return useStorageStatusSmooth();
3320
- } else {
3321
- return useStorageStatusImmediate();
3322
- }
3323
- }
3324
- function useStorageStatusImmediate() {
3325
- const room = useRoom();
3326
- const subscribe = room.events.storageStatus.subscribe;
3327
- const getSnapshot = room.getStorageStatus;
3328
- const getServerSnapshot = room.getStorageStatus;
3329
- return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getServerSnapshot);
3330
- }
3331
- function useStorageStatusSmooth() {
3332
- const room = useRoom();
3333
- const [status, setStatus] = _react.useState.call(void 0, room.getStorageStatus);
3334
- const oldStatus = useLatest(room.getStorageStatus());
3335
- _react.useEffect.call(void 0, () => {
3336
- let timeoutId;
3337
- const unsub = room.events.storageStatus.subscribe((newStatus) => {
3338
- if (oldStatus.current === "synchronizing" && newStatus === "synchronized") {
3339
- timeoutId = setTimeout(() => setStatus(newStatus), config.SMOOTH_DELAY);
3340
- } else {
3341
- clearTimeout(timeoutId);
3342
- setStatus(newStatus);
3343
- }
3344
- });
3345
- return () => {
3346
- clearTimeout(timeoutId);
3347
- unsub();
3348
- };
3349
- }, [room, oldStatus]);
3350
- return status;
3351
- }
3352
- function useBatch() {
3353
- return useRoom().batch;
3354
- }
3355
3404
  function useBroadcastEvent() {
3356
3405
  const room = useRoom();
3357
3406
  return _react.useCallback.call(void 0,
@@ -3628,7 +3677,7 @@ function useCreateRoomThread(roomId) {
3628
3677
  thread: newThread,
3629
3678
  roomId
3630
3679
  });
3631
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _24 => _24.map, 'call', _25 => _25((attachment) => attachment.id)]);
3680
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _33 => _33.map, 'call', _34 => _34((attachment) => attachment.id)]);
3632
3681
  client[_core.kInternal].httpClient.createThread({
3633
3682
  roomId,
3634
3683
  threadId,
@@ -3668,7 +3717,7 @@ function useDeleteRoomThread(roomId) {
3668
3717
  const { store, onMutationFailure } = getRoomExtrasForClient(client);
3669
3718
  const userId = getCurrentUserId(client);
3670
3719
  const existing = store.outputs.threads.get().get(threadId);
3671
- if (_optionalChain([existing, 'optionalAccess', _26 => _26.comments, 'optionalAccess', _27 => _27[0], 'optionalAccess', _28 => _28.userId]) !== userId) {
3720
+ if (_optionalChain([existing, 'optionalAccess', _35 => _35.comments, 'optionalAccess', _36 => _36[0], 'optionalAccess', _37 => _37.userId]) !== userId) {
3672
3721
  throw new Error("Only the thread creator can delete the thread");
3673
3722
  }
3674
3723
  const optimisticId = store.optimisticUpdates.add({
@@ -3756,7 +3805,7 @@ function useCreateRoomComment(roomId) {
3756
3805
  type: "create-comment",
3757
3806
  comment
3758
3807
  });
3759
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _29 => _29.map, 'call', _30 => _30((attachment) => attachment.id)]);
3808
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _38 => _38.map, 'call', _39 => _39((attachment) => attachment.id)]);
3760
3809
  client[_core.kInternal].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
3761
3810
  (newComment) => {
3762
3811
  store.createComment(newComment, optimisticId);
@@ -3812,7 +3861,7 @@ function useEditRoomComment(roomId) {
3812
3861
  attachments: _nullishCoalesce(attachments, () => ( []))
3813
3862
  }
3814
3863
  });
3815
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _31 => _31.map, 'call', _32 => _32((attachment) => attachment.id)]);
3864
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _40 => _40.map, 'call', _41 => _41((attachment) => attachment.id)]);
3816
3865
  client[_core.kInternal].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
3817
3866
  (editedComment) => {
3818
3867
  store.editComment(threadId, optimisticId, editedComment);
@@ -4153,7 +4202,7 @@ function useRoomThreadSubscription(roomId, threadId) {
4153
4202
  }
4154
4203
  return {
4155
4204
  status: "subscribed",
4156
- unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess', _33 => _33.readAt]), () => ( null)),
4205
+ unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess', _42 => _42.readAt]), () => ( null)),
4157
4206
  subscribe,
4158
4207
  unsubscribe
4159
4208
  };
@@ -4162,37 +4211,6 @@ function useRoomThreadSubscription(roomId, threadId) {
4162
4211
  );
4163
4212
  return useSignal(signal, selector, _client.shallow);
4164
4213
  }
4165
- function useRoomNotificationSettings() {
4166
- const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
4167
- const client = useClient();
4168
- const room = useRoom();
4169
- const { store, getOrCreateSubscriptionSettingsPollerForRoomId } = getRoomExtrasForClient(client);
4170
- const poller = getOrCreateSubscriptionSettingsPollerForRoomId(room.id);
4171
- _react.useEffect.call(void 0,
4172
- () => void store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).waitUntilLoaded()
4173
- // NOTE: Deliberately *not* using a dependency array here!
4174
- //
4175
- // It is important to call waitUntil on *every* render.
4176
- // This is harmless though, on most renders, except:
4177
- // 1. The very first render, in which case we'll want to trigger the initial page fetch.
4178
- // 2. All other subsequent renders now "just" return the same promise (a quick operation).
4179
- // 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
4180
- // *next* render after that, a *new* fetch/promise will get created.
4181
- );
4182
- _react.useEffect.call(void 0, () => {
4183
- poller.inc();
4184
- poller.pollNowIfStale();
4185
- return () => {
4186
- poller.dec();
4187
- };
4188
- }, [poller]);
4189
- const settings = useSignal(
4190
- store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).signal
4191
- );
4192
- return _react.useMemo.call(void 0, () => {
4193
- return [settings, updateRoomNotificationSettings];
4194
- }, [settings, updateRoomNotificationSettings]);
4195
- }
4196
4214
  function useRoomSubscriptionSettings() {
4197
4215
  const updateRoomSubscriptionSettings = useUpdateRoomSubscriptionSettings();
4198
4216
  const client = useClient();
@@ -4224,21 +4242,6 @@ function useRoomSubscriptionSettings() {
4224
4242
  return [settings, updateRoomSubscriptionSettings];
4225
4243
  }, [settings, updateRoomSubscriptionSettings]);
4226
4244
  }
4227
- function useRoomNotificationSettingsSuspense() {
4228
- ensureNotServerSide();
4229
- const client = useClient();
4230
- const store = getRoomExtrasForClient(client).store;
4231
- const room = useRoom();
4232
- use(
4233
- store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).waitUntilLoaded()
4234
- );
4235
- const [settings, updateRoomNotificationSettings] = useRoomNotificationSettings();
4236
- _core.assert.call(void 0, !settings.error, "Did not expect error");
4237
- _core.assert.call(void 0, !settings.isLoading, "Did not expect loading");
4238
- return _react.useMemo.call(void 0, () => {
4239
- return [settings, updateRoomNotificationSettings];
4240
- }, [settings, updateRoomNotificationSettings]);
4241
- }
4242
4245
  function useRoomSubscriptionSettingsSuspense() {
4243
4246
  ensureNotServerSide();
4244
4247
  const client = useClient();
@@ -4317,40 +4320,6 @@ function useHistoryVersionsSuspense() {
4317
4320
  _core.assert.call(void 0, !result.isLoading, "Did not expect loading");
4318
4321
  return result;
4319
4322
  }
4320
- function useUpdateRoomNotificationSettings() {
4321
- const client = useClient();
4322
- const room = useRoom();
4323
- return _react.useCallback.call(void 0,
4324
- (settings) => {
4325
- const { store, onMutationFailure, pollThreadsForRoomId } = getRoomExtrasForClient(client);
4326
- const userId = getCurrentUserId(client);
4327
- const optimisticId = store.optimisticUpdates.add({
4328
- type: "update-room-subscription-settings",
4329
- roomId: room.id,
4330
- userId,
4331
- settings
4332
- });
4333
- room.updateSubscriptionSettings(settings).then(
4334
- (updatedSettings) => {
4335
- store.updateRoomSubscriptionSettings(
4336
- room.id,
4337
- optimisticId,
4338
- updatedSettings
4339
- );
4340
- if (settings.threads) {
4341
- pollThreadsForRoomId(room.id);
4342
- }
4343
- },
4344
- (err) => onMutationFailure(
4345
- optimisticId,
4346
- { type: "UPDATE_NOTIFICATION_SETTINGS_ERROR", roomId: room.id },
4347
- err
4348
- )
4349
- );
4350
- },
4351
- [client, room]
4352
- );
4353
- }
4354
4323
  function useUpdateRoomSubscriptionSettings() {
4355
4324
  const client = useClient();
4356
4325
  const room = useRoom();
@@ -4431,10 +4400,6 @@ function useStorageSuspense(selector, isEqual) {
4431
4400
  isEqual
4432
4401
  );
4433
4402
  }
4434
- function useStorageStatusSuspense(options) {
4435
- useSuspendUntilStorageReady();
4436
- return useStorageStatus(options);
4437
- }
4438
4403
  function useThreadsSuspense(options = {}) {
4439
4404
  ensureNotServerSide();
4440
4405
  const client = useClient();
@@ -4448,7 +4413,7 @@ function useThreadsSuspense(options = {}) {
4448
4413
  return result;
4449
4414
  }
4450
4415
  function selectorFor_useAttachmentUrl(state) {
4451
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _34 => _34.isLoading])) {
4416
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _43 => _43.isLoading])) {
4452
4417
  return _nullishCoalesce(state, () => ( { isLoading: true }));
4453
4418
  }
4454
4419
  if (state.error) {
@@ -4534,9 +4499,7 @@ var _useOthersMapped = useOthersMapped;
4534
4499
  var _useOthersMappedSuspense = useOthersMappedSuspense;
4535
4500
  var _useThreads = useThreads;
4536
4501
  var _useThreadsSuspense = useThreadsSuspense;
4537
- var _useRoomNotificationSettings = useRoomNotificationSettings;
4538
4502
  var _useRoomSubscriptionSettings = useRoomSubscriptionSettings;
4539
- var _useRoomNotificationSettingsSuspense = useRoomNotificationSettingsSuspense;
4540
4503
  var _useRoomSubscriptionSettingsSuspense = useRoomSubscriptionSettingsSuspense;
4541
4504
  var _useHistoryVersions = useHistoryVersions;
4542
4505
  var _useHistoryVersionsSuspense = useHistoryVersionsSuspense;
@@ -4674,7 +4637,5 @@ var _useUpdateMyPresence = useUpdateMyPresence;
4674
4637
 
4675
4638
 
4676
4639
 
4677
-
4678
-
4679
- exports.RoomContext = RoomContext; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; exports.useSignal = useSignal; exports.ClientContext = ClientContext; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useCreateAiChat = useCreateAiChat; exports.useDeleteAiChat = useDeleteAiChat; exports.useClientOrNull = useClientOrNull; exports.useClient = useClient; exports.LiveblocksProvider = LiveblocksProvider; exports.createLiveblocksContext = createLiveblocksContext; exports.useInboxNotifications = useInboxNotifications; exports.useInboxNotificationsSuspense = useInboxNotificationsSuspense; exports.useMarkAllInboxNotificationsAsRead = useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = useMarkInboxNotificationAsRead; exports.useDeleteAllInboxNotifications = useDeleteAllInboxNotifications; exports.useDeleteInboxNotification = useDeleteInboxNotification; exports.useUnreadInboxNotificationsCount = useUnreadInboxNotificationsCount; exports.useUnreadInboxNotificationsCountSuspense = useUnreadInboxNotificationsCountSuspense; exports.useNotificationSettings = useNotificationSettings; exports.useNotificationSettingsSuspense = useNotificationSettingsSuspense; exports.useUpdateNotificationSettings = useUpdateNotificationSettings; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental; exports._useAiChats = _useAiChats; exports._useAiChatsSuspense = _useAiChatsSuspense; 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.useStorageStatus = useStorageStatus; exports.useBatch = useBatch; 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.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useUpdateRoomSubscriptionSettings = useUpdateRoomSubscriptionSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; 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._useRoomNotificationSettings = _useRoomNotificationSettings; exports._useRoomSubscriptionSettings = _useRoomSubscriptionSettings; exports._useRoomNotificationSettingsSuspense = _useRoomNotificationSettingsSuspense; 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;
4680
- //# sourceMappingURL=chunk-G2EOFP6S.cjs.map
4640
+ exports.ClientContext = ClientContext; exports.useClientOrNull = useClientOrNull; exports.useClient = useClient; exports.RoomContext = RoomContext; exports.RegisterAiKnowledge = RegisterAiKnowledge; exports.RegisterAiTool = RegisterAiTool; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; exports.useSignal = useSignal; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useCreateAiChat = useCreateAiChat; exports.useDeleteAiChat = useDeleteAiChat; 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._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;
4641
+ //# sourceMappingURL=chunk-UR7FENGR.cjs.map