@liveblocks/react 2.25.0-aiprivatebeta9 → 3.1.0-alpha1

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,52 @@ 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
+ enabled
56
+ }) {
57
+ const client = useClient();
58
+ const ai = client[_core.kInternal].ai;
59
+ _react.useEffect.call(void 0, () => {
60
+ const toolWithEnabled = enabled !== void 0 ? { ...tool, enabled } : tool;
61
+ return ai.registerTool(name, toolWithEnabled, chatId);
62
+ }, [ai, chatId, name, tool, enabled]);
63
+ return null;
64
+ });
65
+
12
66
  // src/use-sync-external-store-with-selector.ts
13
67
 
14
68
 
@@ -86,7 +140,7 @@ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnaps
86
140
  }
87
141
 
88
142
  // src/use-signal.ts
89
- var _core = require('@liveblocks/core');
143
+
90
144
  var identity = (value) => value;
91
145
  function useSignal(signal, selector, isEqual) {
92
146
  if (signal instanceof _core.MutableSignal) {
@@ -120,10 +174,6 @@ function useSignal(signal, selector, isEqual) {
120
174
 
121
175
 
122
176
 
123
-
124
-
125
-
126
-
127
177
 
128
178
  // src/config.ts
129
179
  var SECONDS = 1e3;
@@ -1905,8 +1955,11 @@ function isThreadParticipant(thread, userId) {
1905
1955
  isParticipant = true;
1906
1956
  break;
1907
1957
  }
1908
- const mentionedIds = _core.getMentionedIdsFromCommentBody.call(void 0, comment.body);
1909
- if (mentionedIds.includes(userId)) {
1958
+ const mentions = _core.getMentionsFromCommentBody.call(void 0,
1959
+ comment.body,
1960
+ (mention) => mention.kind === "user" && mention.id === userId
1961
+ );
1962
+ if (mentions.length > 0) {
1910
1963
  isParticipant = true;
1911
1964
  break;
1912
1965
  }
@@ -1916,7 +1969,6 @@ function isThreadParticipant(thread, userId) {
1916
1969
 
1917
1970
  // src/liveblocks.tsx
1918
1971
  var _jsxruntime = require('react/jsx-runtime');
1919
- var ClientContext = _react.createContext.call(void 0, null);
1920
1972
  function missingUserError(userId) {
1921
1973
  return new Error(`resolveUsers didn't return anything for user '${userId}'`);
1922
1974
  }
@@ -2003,6 +2055,11 @@ function getLiveblocksExtrasForClient(client) {
2003
2055
  }
2004
2056
  return extras;
2005
2057
  }
2058
+ function useEnsureAiConnection(client) {
2059
+ _react.useEffect.call(void 0, () => {
2060
+ client[_core.kInternal].ai.connectInitially();
2061
+ }, [client]);
2062
+ }
2006
2063
  function makeLiveblocksExtrasForClient(client) {
2007
2064
  const store = getUmbrellaStoreForClient(client);
2008
2065
  const notificationsPoller = _core.makePoller.call(void 0,
@@ -2079,6 +2136,7 @@ function makeLiveblocksContextBundle(client) {
2079
2136
  useAiChatMessages,
2080
2137
  useCreateAiChat,
2081
2138
  useDeleteAiChat,
2139
+ useSendAiMessage,
2082
2140
  ...shared.classic,
2083
2141
  suspense: {
2084
2142
  LiveblocksProvider: LiveblocksProvider2,
@@ -2097,6 +2155,7 @@ function makeLiveblocksContextBundle(client) {
2097
2155
  useAiChatMessages: useAiChatMessagesSuspense,
2098
2156
  useCreateAiChat,
2099
2157
  useDeleteAiChat,
2158
+ useSendAiMessage,
2100
2159
  ...shared.suspense
2101
2160
  }
2102
2161
  };
@@ -2304,7 +2363,7 @@ function useUpdateNotificationSettings_withClient(client) {
2304
2363
  }
2305
2364
  client[_core.kInternal].emitError(
2306
2365
  {
2307
- type: "UPDATE_USER_NOTIFICATION_SETTINGS_ERROR"
2366
+ type: "UPDATE_NOTIFICATION_SETTINGS_ERROR"
2308
2367
  },
2309
2368
  err
2310
2369
  );
@@ -2472,6 +2531,7 @@ function useRoomInfoSuspense_withClient(client, roomId) {
2472
2531
  function useAiChats() {
2473
2532
  const client = useClient();
2474
2533
  const store = getUmbrellaStoreForClient(client);
2534
+ useEnsureAiConnection(client);
2475
2535
  _react.useEffect.call(void 0,
2476
2536
  () => void store.outputs.aiChats.waitUntilLoaded()
2477
2537
  // NOTE: Deliberately *not* using a dependency array here!
@@ -2489,17 +2549,19 @@ function useAiChatsSuspense() {
2489
2549
  ensureNotServerSide();
2490
2550
  const client = useClient();
2491
2551
  const store = getUmbrellaStoreForClient(client);
2552
+ useEnsureAiConnection(client);
2492
2553
  use(store.outputs.aiChats.waitUntilLoaded());
2493
2554
  const result = useAiChats();
2494
2555
  _core.assert.call(void 0, !result.error, "Did not expect error");
2495
2556
  _core.assert.call(void 0, !result.isLoading, "Did not expect loading");
2496
2557
  return result;
2497
2558
  }
2498
- function useAiChatMessages(chatId, branch) {
2559
+ function useAiChatMessages(chatId, options) {
2499
2560
  const client = useClient();
2500
2561
  const store = getUmbrellaStoreForClient(client);
2562
+ useEnsureAiConnection(client);
2501
2563
  _react.useEffect.call(void 0,
2502
- () => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(branch, () => ( null))).waitUntilLoaded()
2564
+ () => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _16 => _16.branchId]), () => ( null))).waitUntilLoaded()
2503
2565
  // NOTE: Deliberately *not* using a dependency array here!
2504
2566
  //
2505
2567
  // It is important to call waitUntil on *every* render.
@@ -2510,17 +2572,18 @@ function useAiChatMessages(chatId, branch) {
2510
2572
  // *next* render after that, a *new* fetch/promise will get created.
2511
2573
  );
2512
2574
  return useSignal(
2513
- store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(branch, () => ( null))).signal
2575
+ store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.branchId]), () => ( null))).signal
2514
2576
  );
2515
2577
  }
2516
- function useAiChatMessagesSuspense(chatId, branch) {
2578
+ function useAiChatMessagesSuspense(chatId, options) {
2517
2579
  ensureNotServerSide();
2518
2580
  const client = useClient();
2519
2581
  const store = getUmbrellaStoreForClient(client);
2582
+ useEnsureAiConnection(client);
2520
2583
  use(
2521
- store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(branch, () => ( null))).waitUntilLoaded()
2584
+ store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _18 => _18.branchId]), () => ( null))).waitUntilLoaded()
2522
2585
  );
2523
- const result = useAiChatMessages(chatId, branch);
2586
+ const result = useAiChatMessages(chatId, options);
2524
2587
  _core.assert.call(void 0, !result.error, "Did not expect error");
2525
2588
  _core.assert.call(void 0, !result.isLoading, "Did not expect loading");
2526
2589
  return result;
@@ -2528,6 +2591,7 @@ function useAiChatMessagesSuspense(chatId, branch) {
2528
2591
  function useAiChat(chatId) {
2529
2592
  const client = useClient();
2530
2593
  const store = getUmbrellaStoreForClient(client);
2594
+ useEnsureAiConnection(client);
2531
2595
  _react.useEffect.call(void 0,
2532
2596
  () => void store.outputs.aiChatById.getOrCreate(chatId).waitUntilLoaded()
2533
2597
  // NOTE: Deliberately *not* using a dependency array here!
@@ -2545,6 +2609,7 @@ function useAiChatSuspense(chatId) {
2545
2609
  ensureNotServerSide();
2546
2610
  const client = useClient();
2547
2611
  const store = getUmbrellaStoreForClient(client);
2612
+ useEnsureAiConnection(client);
2548
2613
  use(store.outputs.aiChatById.getOrCreate(chatId).waitUntilLoaded());
2549
2614
  const result = useAiChat(chatId);
2550
2615
  _core.assert.call(void 0, !result.error, "Did not expect error");
@@ -2555,7 +2620,10 @@ function useCreateAiChat() {
2555
2620
  const client = useClient();
2556
2621
  return _react.useCallback.call(void 0,
2557
2622
  (options) => {
2558
- client[_core.kInternal].ai.getOrCreateChat(options.id, options).catch((err) => {
2623
+ client[_core.kInternal].ai.getOrCreateChat(options.id, {
2624
+ title: options.title,
2625
+ metadata: options.metadata
2626
+ }).catch((err) => {
2559
2627
  console.error(
2560
2628
  `Failed to create chat with ID "${options.id}": ${String(err)}`
2561
2629
  );
@@ -2577,6 +2645,39 @@ function useDeleteAiChat() {
2577
2645
  [client]
2578
2646
  );
2579
2647
  }
2648
+ function useSendAiMessage(chatId, options) {
2649
+ const client = useClient();
2650
+ const copilotId = _optionalChain([options, 'optionalAccess', _19 => _19.copilotId]);
2651
+ return _react.useCallback.call(void 0,
2652
+ (message) => {
2653
+ const messages = client[_core.kInternal].ai.signals.getChatMessagesForBranch\u03A3(chatId).get();
2654
+ const lastMessageId = _nullishCoalesce(_optionalChain([messages, 'access', _20 => _20[messages.length - 1], 'optionalAccess', _21 => _21.id]), () => ( null));
2655
+ const content = [{ type: "text", text: message }];
2656
+ const newMessageId = client[_core.kInternal].ai[_core.kInternal].context.messagesStore.createOptimistically(
2657
+ chatId,
2658
+ "user",
2659
+ lastMessageId,
2660
+ content
2661
+ );
2662
+ const targetMessageId = client[_core.kInternal].ai[_core.kInternal].context.messagesStore.createOptimistically(
2663
+ chatId,
2664
+ "assistant",
2665
+ newMessageId
2666
+ );
2667
+ void client[_core.kInternal].ai.askUserMessageInChat(
2668
+ chatId,
2669
+ { id: newMessageId, parentMessageId: lastMessageId, content },
2670
+ targetMessageId,
2671
+ {
2672
+ stream: _optionalChain([options, 'optionalAccess', _22 => _22.stream]),
2673
+ copilotId,
2674
+ timeout: _optionalChain([options, 'optionalAccess', _23 => _23.timeout])
2675
+ }
2676
+ );
2677
+ },
2678
+ [client, chatId, copilotId, _optionalChain([options, 'optionalAccess', _24 => _24.stream]), _optionalChain([options, 'optionalAccess', _25 => _25.timeout])]
2679
+ );
2680
+ }
2580
2681
  function createSharedContext(client) {
2581
2682
  const useClient2 = () => client;
2582
2683
  function useSyncStatus2(options) {
@@ -2589,7 +2690,9 @@ function createSharedContext(client) {
2589
2690
  useRoomInfo: (roomId) => useRoomInfo_withClient(client, roomId),
2590
2691
  useIsInsideRoom,
2591
2692
  useErrorListener,
2592
- useSyncStatus: useSyncStatus2
2693
+ useSyncStatus: useSyncStatus2,
2694
+ RegisterAiKnowledge,
2695
+ RegisterAiTool
2593
2696
  },
2594
2697
  suspense: {
2595
2698
  useClient: useClient2,
@@ -2597,24 +2700,20 @@ function createSharedContext(client) {
2597
2700
  useRoomInfo: (roomId) => useRoomInfoSuspense_withClient(client, roomId),
2598
2701
  useIsInsideRoom,
2599
2702
  useErrorListener,
2600
- useSyncStatus: useSyncStatus2
2703
+ useSyncStatus: useSyncStatus2,
2704
+ RegisterAiKnowledge,
2705
+ RegisterAiTool
2601
2706
  }
2602
2707
  };
2603
2708
  }
2604
2709
  function useEnsureNoLiveblocksProvider(options) {
2605
2710
  const existing = useClientOrNull();
2606
- if (!_optionalChain([options, 'optionalAccess', _16 => _16.allowNesting]) && existing !== null) {
2711
+ if (!_optionalChain([options, 'optionalAccess', _26 => _26.allowNesting]) && existing !== null) {
2607
2712
  throw new Error(
2608
2713
  "You cannot nest multiple LiveblocksProvider instances in the same React tree."
2609
2714
  );
2610
2715
  }
2611
2716
  }
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
2717
  function LiveblocksProviderWithClient(props) {
2619
2718
  useEnsureNoLiveblocksProvider(props);
2620
2719
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ClientContext.Provider, { value: props.client, children: props.children });
@@ -2628,7 +2727,6 @@ function LiveblocksProvider(props) {
2628
2727
  backgroundKeepAliveTimeout: useInitial(o.backgroundKeepAliveTimeout),
2629
2728
  polyfills: useInitial(o.polyfills),
2630
2729
  largeMessageStrategy: useInitial(o.largeMessageStrategy),
2631
- unstable_fallbackToHTTP: useInitial(o.unstable_fallbackToHTTP),
2632
2730
  unstable_streamData: useInitial(o.unstable_streamData),
2633
2731
  preventUnsavedChanges: useInitial(o.preventUnsavedChanges),
2634
2732
  authEndpoint: useInitialUnlessFunction(o.authEndpoint),
@@ -2648,7 +2746,6 @@ function LiveblocksProvider(props) {
2648
2746
  };
2649
2747
  const client = _react.useMemo.call(void 0, () => _core.createClient.call(void 0, options), []);
2650
2748
  _react.useEffect.call(void 0, () => {
2651
- client[_core.kInternal].ai.connect();
2652
2749
  return () => {
2653
2750
  client[_core.kInternal].ai.disconnect();
2654
2751
  };
@@ -2755,11 +2852,12 @@ var _useUserThreads_experimental = useUserThreads_experimental;
2755
2852
  var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
2756
2853
  var _useAiChats = useAiChats;
2757
2854
  var _useAiChatsSuspense = useAiChatsSuspense;
2855
+ var _useAiChat = useAiChat;
2758
2856
  var _useAiChatSuspense = useAiChatSuspense;
2759
2857
  var _useAiChatMessages = useAiChatMessages;
2760
2858
  var _useAiChatMessagesSuspense = useAiChatMessagesSuspense;
2761
2859
  function useSyncStatus_withClient(client, options) {
2762
- const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.smooth]), () => ( false)));
2860
+ const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.smooth]), () => ( false)));
2763
2861
  if (smooth) {
2764
2862
  return useSyncStatusSmooth_withClient(client);
2765
2863
  } else {
@@ -2938,8 +3036,8 @@ function makeRoomExtrasForClient(client) {
2938
3036
  if (innerError.status === 403) {
2939
3037
  const detailedMessage = [
2940
3038
  innerError.message,
2941
- _optionalChain([innerError, 'access', _18 => _18.details, 'optionalAccess', _19 => _19.suggestion]),
2942
- _optionalChain([innerError, 'access', _20 => _20.details, 'optionalAccess', _21 => _21.docs])
3039
+ _optionalChain([innerError, 'access', _28 => _28.details, 'optionalAccess', _29 => _29.suggestion]),
3040
+ _optionalChain([innerError, 'access', _30 => _30.details, 'optionalAccess', _31 => _31.docs])
2943
3041
  ].filter(Boolean).join("\n");
2944
3042
  _core.console.error(detailedMessage);
2945
3043
  }
@@ -3019,8 +3117,6 @@ function makeRoomContextBundle(client) {
3019
3117
  RoomProvider: RoomProvider_withImplicitLiveblocksProvider,
3020
3118
  useRoom,
3021
3119
  useStatus,
3022
- useStorageStatus,
3023
- useBatch,
3024
3120
  useBroadcastEvent,
3025
3121
  useOthersListener,
3026
3122
  useLostConnectionListener,
@@ -3058,9 +3154,7 @@ function makeRoomContextBundle(client) {
3058
3154
  useAttachmentUrl,
3059
3155
  useHistoryVersions,
3060
3156
  useHistoryVersionData,
3061
- useRoomNotificationSettings,
3062
3157
  useRoomSubscriptionSettings,
3063
- useUpdateRoomNotificationSettings,
3064
3158
  useUpdateRoomSubscriptionSettings,
3065
3159
  ...shared.classic,
3066
3160
  suspense: {
@@ -3068,8 +3162,6 @@ function makeRoomContextBundle(client) {
3068
3162
  RoomProvider: RoomProvider_withImplicitLiveblocksProvider,
3069
3163
  useRoom,
3070
3164
  useStatus,
3071
- useStorageStatus: useStorageStatusSuspense,
3072
- useBatch,
3073
3165
  useBroadcastEvent,
3074
3166
  useOthersListener,
3075
3167
  useLostConnectionListener,
@@ -3107,9 +3199,7 @@ function makeRoomContextBundle(client) {
3107
3199
  useAttachmentUrl: useAttachmentUrlSuspense,
3108
3200
  // TODO: useHistoryVersionData: useHistoryVersionDataSuspense,
3109
3201
  useHistoryVersions: useHistoryVersionsSuspense,
3110
- useRoomNotificationSettings: useRoomNotificationSettingsSuspense,
3111
3202
  useRoomSubscriptionSettings: useRoomSubscriptionSettingsSuspense,
3112
- useUpdateRoomNotificationSettings,
3113
3203
  useUpdateRoomSubscriptionSettings,
3114
3204
  ...shared.suspense
3115
3205
  }
@@ -3239,7 +3329,7 @@ function RoomProviderInner(props) {
3239
3329
  }
3240
3330
  function useRoom(options) {
3241
3331
  const room = useRoomOrNull();
3242
- if (room === null && !_optionalChain([options, 'optionalAccess', _22 => _22.allowOutsideRoom])) {
3332
+ if (room === null && !_optionalChain([options, 'optionalAccess', _32 => _32.allowOutsideRoom])) {
3243
3333
  throw new Error("RoomProvider is missing from the React tree.");
3244
3334
  }
3245
3335
  return room;
@@ -3313,45 +3403,6 @@ function useMentionSuggestionsCache() {
3313
3403
  const client = useClient();
3314
3404
  return client[_core.kInternal].mentionSuggestionsCache;
3315
3405
  }
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
3406
  function useBroadcastEvent() {
3356
3407
  const room = useRoom();
3357
3408
  return _react.useCallback.call(void 0,
@@ -3628,7 +3679,7 @@ function useCreateRoomThread(roomId) {
3628
3679
  thread: newThread,
3629
3680
  roomId
3630
3681
  });
3631
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _24 => _24.map, 'call', _25 => _25((attachment) => attachment.id)]);
3682
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _33 => _33.map, 'call', _34 => _34((attachment) => attachment.id)]);
3632
3683
  client[_core.kInternal].httpClient.createThread({
3633
3684
  roomId,
3634
3685
  threadId,
@@ -3668,7 +3719,7 @@ function useDeleteRoomThread(roomId) {
3668
3719
  const { store, onMutationFailure } = getRoomExtrasForClient(client);
3669
3720
  const userId = getCurrentUserId(client);
3670
3721
  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) {
3722
+ if (_optionalChain([existing, 'optionalAccess', _35 => _35.comments, 'optionalAccess', _36 => _36[0], 'optionalAccess', _37 => _37.userId]) !== userId) {
3672
3723
  throw new Error("Only the thread creator can delete the thread");
3673
3724
  }
3674
3725
  const optimisticId = store.optimisticUpdates.add({
@@ -3756,7 +3807,7 @@ function useCreateRoomComment(roomId) {
3756
3807
  type: "create-comment",
3757
3808
  comment
3758
3809
  });
3759
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _29 => _29.map, 'call', _30 => _30((attachment) => attachment.id)]);
3810
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _38 => _38.map, 'call', _39 => _39((attachment) => attachment.id)]);
3760
3811
  client[_core.kInternal].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
3761
3812
  (newComment) => {
3762
3813
  store.createComment(newComment, optimisticId);
@@ -3812,7 +3863,7 @@ function useEditRoomComment(roomId) {
3812
3863
  attachments: _nullishCoalesce(attachments, () => ( []))
3813
3864
  }
3814
3865
  });
3815
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _31 => _31.map, 'call', _32 => _32((attachment) => attachment.id)]);
3866
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _40 => _40.map, 'call', _41 => _41((attachment) => attachment.id)]);
3816
3867
  client[_core.kInternal].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
3817
3868
  (editedComment) => {
3818
3869
  store.editComment(threadId, optimisticId, editedComment);
@@ -4153,7 +4204,7 @@ function useRoomThreadSubscription(roomId, threadId) {
4153
4204
  }
4154
4205
  return {
4155
4206
  status: "subscribed",
4156
- unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess', _33 => _33.readAt]), () => ( null)),
4207
+ unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess', _42 => _42.readAt]), () => ( null)),
4157
4208
  subscribe,
4158
4209
  unsubscribe
4159
4210
  };
@@ -4162,37 +4213,6 @@ function useRoomThreadSubscription(roomId, threadId) {
4162
4213
  );
4163
4214
  return useSignal(signal, selector, _client.shallow);
4164
4215
  }
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
4216
  function useRoomSubscriptionSettings() {
4197
4217
  const updateRoomSubscriptionSettings = useUpdateRoomSubscriptionSettings();
4198
4218
  const client = useClient();
@@ -4224,21 +4244,6 @@ function useRoomSubscriptionSettings() {
4224
4244
  return [settings, updateRoomSubscriptionSettings];
4225
4245
  }, [settings, updateRoomSubscriptionSettings]);
4226
4246
  }
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
4247
  function useRoomSubscriptionSettingsSuspense() {
4243
4248
  ensureNotServerSide();
4244
4249
  const client = useClient();
@@ -4317,40 +4322,6 @@ function useHistoryVersionsSuspense() {
4317
4322
  _core.assert.call(void 0, !result.isLoading, "Did not expect loading");
4318
4323
  return result;
4319
4324
  }
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
4325
  function useUpdateRoomSubscriptionSettings() {
4355
4326
  const client = useClient();
4356
4327
  const room = useRoom();
@@ -4431,10 +4402,6 @@ function useStorageSuspense(selector, isEqual) {
4431
4402
  isEqual
4432
4403
  );
4433
4404
  }
4434
- function useStorageStatusSuspense(options) {
4435
- useSuspendUntilStorageReady();
4436
- return useStorageStatus(options);
4437
- }
4438
4405
  function useThreadsSuspense(options = {}) {
4439
4406
  ensureNotServerSide();
4440
4407
  const client = useClient();
@@ -4448,7 +4415,7 @@ function useThreadsSuspense(options = {}) {
4448
4415
  return result;
4449
4416
  }
4450
4417
  function selectorFor_useAttachmentUrl(state) {
4451
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _34 => _34.isLoading])) {
4418
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _43 => _43.isLoading])) {
4452
4419
  return _nullishCoalesce(state, () => ( { isLoading: true }));
4453
4420
  }
4454
4421
  if (state.error) {
@@ -4534,9 +4501,7 @@ var _useOthersMapped = useOthersMapped;
4534
4501
  var _useOthersMappedSuspense = useOthersMappedSuspense;
4535
4502
  var _useThreads = useThreads;
4536
4503
  var _useThreadsSuspense = useThreadsSuspense;
4537
- var _useRoomNotificationSettings = useRoomNotificationSettings;
4538
4504
  var _useRoomSubscriptionSettings = useRoomSubscriptionSettings;
4539
- var _useRoomNotificationSettingsSuspense = useRoomNotificationSettingsSuspense;
4540
4505
  var _useRoomSubscriptionSettingsSuspense = useRoomSubscriptionSettingsSuspense;
4541
4506
  var _useHistoryVersions = useHistoryVersions;
4542
4507
  var _useHistoryVersionsSuspense = useHistoryVersionsSuspense;
@@ -4674,7 +4639,5 @@ var _useUpdateMyPresence = useUpdateMyPresence;
4674
4639
 
4675
4640
 
4676
4641
 
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-RB4LUCGL.cjs.map
4642
+ 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;
4643
+ //# sourceMappingURL=chunk-KDGCCWHH.cjs.map