@liveblocks/react 2.24.0 → 2.25.0-aiprivatebeta0
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.
- package/dist/_private.cjs +5 -5
- package/dist/_private.d.cts +1 -1
- package/dist/_private.d.ts +1 -1
- package/dist/_private.js +1 -1
- package/dist/{chunk-2GC6FA36.js → chunk-3FZLUESM.js} +2 -2
- package/dist/{chunk-N6OQQVYV.js → chunk-E6PCFJWE.js} +169 -10
- package/dist/chunk-E6PCFJWE.js.map +1 -0
- package/dist/{chunk-F2Y7N4WI.cjs → chunk-STFFVL4D.cjs} +2 -2
- package/dist/chunk-STFFVL4D.cjs.map +1 -0
- package/dist/{chunk-32HQP5F6.cjs → chunk-ZGVKI7OM.cjs} +163 -4
- package/dist/chunk-ZGVKI7OM.cjs.map +1 -0
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/{room-CqT08uWZ.d.cts → room-DmsjrDvP.d.cts} +86 -2
- package/dist/{room-CqT08uWZ.d.ts → room-DmsjrDvP.d.ts} +86 -2
- package/dist/suspense.cjs +12 -4
- package/dist/suspense.cjs.map +1 -1
- package/dist/suspense.d.cts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +10 -2
- package/dist/suspense.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-32HQP5F6.cjs.map +0 -1
- package/dist/chunk-F2Y7N4WI.cjs.map +0 -1
- package/dist/chunk-N6OQQVYV.js.map +0 -1
- /package/dist/{chunk-2GC6FA36.js.map → chunk-3FZLUESM.js.map} +0 -0
package/dist/_private.cjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkZGVKI7OMcjs = require('./chunk-ZGVKI7OM.cjs');
|
|
28
28
|
|
|
29
29
|
// src/lib/use-layout-effect.ts
|
|
30
30
|
var _react = require('react');
|
|
@@ -37,8 +37,8 @@ var MENTION_SUGGESTIONS_DEBOUNCE = 500;
|
|
|
37
37
|
function useMentionSuggestions(roomId, search) {
|
|
38
38
|
const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
|
|
39
39
|
const lastInvokedAt = _react.useRef.call(void 0, );
|
|
40
|
-
const resolveMentionSuggestions =
|
|
41
|
-
const mentionSuggestionsCache =
|
|
40
|
+
const resolveMentionSuggestions = _chunkZGVKI7OMcjs.useResolveMentionSuggestions.call(void 0, );
|
|
41
|
+
const mentionSuggestionsCache = _chunkZGVKI7OMcjs.useMentionSuggestionsCache.call(void 0, );
|
|
42
42
|
_react.useEffect.call(void 0, () => {
|
|
43
43
|
if (search === void 0 || !resolveMentionSuggestions) {
|
|
44
44
|
return;
|
|
@@ -89,7 +89,7 @@ function useMentionSuggestions(roomId, search) {
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
function useSyncSource() {
|
|
92
|
-
const client =
|
|
92
|
+
const client = _chunkZGVKI7OMcjs.useClient.call(void 0, );
|
|
93
93
|
const createSyncSource = client[_core.kInternal].createSyncSource;
|
|
94
94
|
const [syncSource, setSyncSource] = _react.useState.call(void 0, );
|
|
95
95
|
_react.useEffect.call(void 0, () => {
|
|
@@ -127,5 +127,5 @@ function useSyncSource() {
|
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
exports.getUmbrellaStoreForClient =
|
|
130
|
+
exports.getUmbrellaStoreForClient = _chunkZGVKI7OMcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkZGVKI7OMcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkZGVKI7OMcjs.useClientOrNull; exports.useCreateRoomComment = _chunkZGVKI7OMcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkZGVKI7OMcjs.useCreateRoomThread; exports.useCreateTextMention = _chunkZGVKI7OMcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkZGVKI7OMcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkZGVKI7OMcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkZGVKI7OMcjs.useDeleteTextMention; exports.useEditRoomComment = _chunkZGVKI7OMcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkZGVKI7OMcjs.useEditRoomThreadMetadata; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkZGVKI7OMcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkZGVKI7OMcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkZGVKI7OMcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkZGVKI7OMcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkZGVKI7OMcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkZGVKI7OMcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkZGVKI7OMcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkZGVKI7OMcjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunkZGVKI7OMcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkZGVKI7OMcjs.useRoomThreadSubscription; exports.useSignal = _chunkZGVKI7OMcjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkZGVKI7OMcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkZGVKI7OMcjs.useYjsProvider;
|
|
131
131
|
//# sourceMappingURL=_private.cjs.map
|
package/dist/_private.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLayoutEffect as useLayoutEffect$1 } from 'react';
|
|
2
|
-
export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-
|
|
2
|
+
export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-DmsjrDvP.cjs';
|
|
3
3
|
import { ISignal, SyncSource } from '@liveblocks/core';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import '@liveblocks/client';
|
package/dist/_private.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLayoutEffect as useLayoutEffect$1 } from 'react';
|
|
2
|
-
export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-
|
|
2
|
+
export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-DmsjrDvP.js';
|
|
3
3
|
import { ISignal, SyncSource } from '@liveblocks/core';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import '@liveblocks/client';
|
package/dist/_private.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
useSignal,
|
|
25
25
|
useSyncExternalStoreWithSelector,
|
|
26
26
|
useYjsProvider
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-E6PCFJWE.js";
|
|
28
28
|
|
|
29
29
|
// src/lib/use-layout-effect.ts
|
|
30
30
|
import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "2.
|
|
3
|
+
var PKG_VERSION = "2.25.0-aiprivatebeta0";
|
|
4
4
|
var PKG_FORMAT = "esm";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -20,4 +20,4 @@ export {
|
|
|
20
20
|
PKG_FORMAT,
|
|
21
21
|
ClientSideSuspense
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-3FZLUESM.js.map
|
|
@@ -86,8 +86,14 @@ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnaps
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// src/use-signal.ts
|
|
89
|
+
import { MutableSignal } from "@liveblocks/core";
|
|
89
90
|
var identity = (value) => value;
|
|
90
91
|
function useSignal(signal, selector, isEqual) {
|
|
92
|
+
if (signal instanceof MutableSignal) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
"Using a mutable Signal with useSignal will likely not work as expected."
|
|
95
|
+
);
|
|
96
|
+
}
|
|
91
97
|
return useSyncExternalStoreWithSelector(
|
|
92
98
|
signal.subscribe,
|
|
93
99
|
signal.get,
|
|
@@ -243,7 +249,7 @@ import {
|
|
|
243
249
|
getMentionedIdsFromCommentBody,
|
|
244
250
|
getSubscriptionKey,
|
|
245
251
|
kInternal,
|
|
246
|
-
MutableSignal as
|
|
252
|
+
MutableSignal as MutableSignal3,
|
|
247
253
|
nanoid,
|
|
248
254
|
nn,
|
|
249
255
|
patchNotificationSettings,
|
|
@@ -271,7 +277,7 @@ function autobind(self) {
|
|
|
271
277
|
}
|
|
272
278
|
|
|
273
279
|
// src/ThreadDB.ts
|
|
274
|
-
import { batch, MutableSignal, SortedList } from "@liveblocks/core";
|
|
280
|
+
import { batch, MutableSignal as MutableSignal2, SortedList } from "@liveblocks/core";
|
|
275
281
|
|
|
276
282
|
// src/lib/querying.ts
|
|
277
283
|
import { isStartsWithOperator } from "@liveblocks/core";
|
|
@@ -332,7 +338,7 @@ var ThreadDB = class _ThreadDB {
|
|
|
332
338
|
return d2 < d1 ? true : d2 === d1 ? t2.id < t1.id : false;
|
|
333
339
|
});
|
|
334
340
|
this.#byId = /* @__PURE__ */ new Map();
|
|
335
|
-
this.signal = new
|
|
341
|
+
this.signal = new MutableSignal2(this);
|
|
336
342
|
}
|
|
337
343
|
//
|
|
338
344
|
// Public APIs
|
|
@@ -583,7 +589,7 @@ var SinglePageResource = class {
|
|
|
583
589
|
}
|
|
584
590
|
};
|
|
585
591
|
function createStore_forNotifications() {
|
|
586
|
-
const signal = new
|
|
592
|
+
const signal = new MutableSignal3(/* @__PURE__ */ new Map());
|
|
587
593
|
function markRead(notificationId, readAt) {
|
|
588
594
|
signal.mutate((lut) => {
|
|
589
595
|
const existing = lut.get(notificationId);
|
|
@@ -659,7 +665,7 @@ function createStore_forNotifications() {
|
|
|
659
665
|
};
|
|
660
666
|
}
|
|
661
667
|
function createStore_forSubscriptions(updates, threads) {
|
|
662
|
-
const baseSignal = new
|
|
668
|
+
const baseSignal = new MutableSignal3(/* @__PURE__ */ new Map());
|
|
663
669
|
function applyDelta(newSubscriptions, deletedSubscriptions) {
|
|
664
670
|
baseSignal.mutate((lut) => {
|
|
665
671
|
let mutated = false;
|
|
@@ -697,7 +703,7 @@ function createStore_forSubscriptions(updates, threads) {
|
|
|
697
703
|
};
|
|
698
704
|
}
|
|
699
705
|
function createStore_forRoomSubscriptionSettings(updates) {
|
|
700
|
-
const baseSignal = new
|
|
706
|
+
const baseSignal = new MutableSignal3(/* @__PURE__ */ new Map());
|
|
701
707
|
function update(roomId, settings) {
|
|
702
708
|
baseSignal.mutate((lut) => {
|
|
703
709
|
lut.set(roomId, settings);
|
|
@@ -714,7 +720,7 @@ function createStore_forRoomSubscriptionSettings(updates) {
|
|
|
714
720
|
};
|
|
715
721
|
}
|
|
716
722
|
function createStore_forHistoryVersions() {
|
|
717
|
-
const baseSignal = new
|
|
723
|
+
const baseSignal = new MutableSignal3(
|
|
718
724
|
new DefaultMap(() => /* @__PURE__ */ new Map())
|
|
719
725
|
);
|
|
720
726
|
function update(roomId, versions) {
|
|
@@ -740,7 +746,7 @@ function createStore_forHistoryVersions() {
|
|
|
740
746
|
};
|
|
741
747
|
}
|
|
742
748
|
function createStore_forPermissionHints() {
|
|
743
|
-
const signal = new
|
|
749
|
+
const signal = new MutableSignal3(
|
|
744
750
|
new DefaultMap(() => /* @__PURE__ */ new Set())
|
|
745
751
|
);
|
|
746
752
|
function update(newHints) {
|
|
@@ -866,6 +872,8 @@ var UmbrellaStore = class {
|
|
|
866
872
|
#roomVersionsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
867
873
|
// Notification Settings
|
|
868
874
|
#notificationSettings;
|
|
875
|
+
// Copilot chats
|
|
876
|
+
#aiChats;
|
|
869
877
|
constructor(client) {
|
|
870
878
|
this.#client = client[kInternal].as();
|
|
871
879
|
this.optimisticUpdates = createStore_forOptimistic(this.#client);
|
|
@@ -895,6 +903,12 @@ var UmbrellaStore = class {
|
|
|
895
903
|
this.#notificationSettings = new SinglePageResource(
|
|
896
904
|
notificationSettingsFetcher
|
|
897
905
|
);
|
|
906
|
+
this.#aiChats = new PaginatedResource(async (cursor) => {
|
|
907
|
+
const result = await this.#client[kInternal].ai.getChats({
|
|
908
|
+
cursor
|
|
909
|
+
});
|
|
910
|
+
return result.nextCursor;
|
|
911
|
+
});
|
|
898
912
|
this.threads = new ThreadDB();
|
|
899
913
|
this.subscriptions = createStore_forSubscriptions(
|
|
900
914
|
this.optimisticUpdates.signal,
|
|
@@ -1101,6 +1115,43 @@ var UmbrellaStore = class {
|
|
|
1101
1115
|
}, shallow),
|
|
1102
1116
|
waitUntilLoaded: this.#notificationSettings.waitUntilLoaded
|
|
1103
1117
|
};
|
|
1118
|
+
const aiChats = {
|
|
1119
|
+
signal: DerivedSignal.from(() => {
|
|
1120
|
+
const result = this.#aiChats.get();
|
|
1121
|
+
if (result.isLoading || result.error) {
|
|
1122
|
+
return result;
|
|
1123
|
+
}
|
|
1124
|
+
return {
|
|
1125
|
+
isLoading: false,
|
|
1126
|
+
chats: this.#client[kInternal].ai.signals.chats\u03A3.get(),
|
|
1127
|
+
hasFetchedAll: result.data.hasFetchedAll,
|
|
1128
|
+
isFetchingMore: result.data.isFetchingMore,
|
|
1129
|
+
fetchMore: result.data.fetchMore,
|
|
1130
|
+
fetchMoreError: result.data.fetchMoreError
|
|
1131
|
+
};
|
|
1132
|
+
}, shallow),
|
|
1133
|
+
waitUntilLoaded: this.#aiChats.waitUntilLoaded
|
|
1134
|
+
};
|
|
1135
|
+
const messagesByChatId = new DefaultMap((chatId) => {
|
|
1136
|
+
const resource\u03A3 = new SinglePageResource(async () => {
|
|
1137
|
+
await this.#client[kInternal].ai.getMessageTree(chatId);
|
|
1138
|
+
});
|
|
1139
|
+
return new DefaultMap(
|
|
1140
|
+
(branch) => {
|
|
1141
|
+
const signal = DerivedSignal.from(() => {
|
|
1142
|
+
const result = resource\u03A3.get();
|
|
1143
|
+
if (result.isLoading || result.error) {
|
|
1144
|
+
return result;
|
|
1145
|
+
}
|
|
1146
|
+
return ASYNC_OK(
|
|
1147
|
+
"messages",
|
|
1148
|
+
this.#client[kInternal].ai.signals.getChatMessagesForBranch\u03A3(chatId, branch ?? void 0).get()
|
|
1149
|
+
);
|
|
1150
|
+
});
|
|
1151
|
+
return { signal, waitUntilLoaded: resource\u03A3.waitUntilLoaded };
|
|
1152
|
+
}
|
|
1153
|
+
);
|
|
1154
|
+
});
|
|
1104
1155
|
this.outputs = {
|
|
1105
1156
|
threadifications,
|
|
1106
1157
|
threads,
|
|
@@ -1111,7 +1162,9 @@ var UmbrellaStore = class {
|
|
|
1111
1162
|
roomSubscriptionSettingsByRoomId,
|
|
1112
1163
|
versionsByRoomId,
|
|
1113
1164
|
notificationSettings,
|
|
1114
|
-
threadSubscriptions
|
|
1165
|
+
threadSubscriptions,
|
|
1166
|
+
aiChats,
|
|
1167
|
+
messagesByChatId
|
|
1115
1168
|
};
|
|
1116
1169
|
autobind(this);
|
|
1117
1170
|
}
|
|
@@ -1990,6 +2043,10 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1990
2043
|
useUpdateNotificationSettings: useUpdateNotificationSettings2,
|
|
1991
2044
|
useInboxNotificationThread: useInboxNotificationThread2,
|
|
1992
2045
|
useUserThreads_experimental,
|
|
2046
|
+
useAiChats,
|
|
2047
|
+
useAiChatMessages,
|
|
2048
|
+
useCreateAiChat,
|
|
2049
|
+
useDeleteAiChat,
|
|
1993
2050
|
...shared.classic,
|
|
1994
2051
|
suspense: {
|
|
1995
2052
|
LiveblocksProvider: LiveblocksProvider2,
|
|
@@ -2003,6 +2060,10 @@ function makeLiveblocksContextBundle(client) {
|
|
|
2003
2060
|
useNotificationSettings: () => useNotificationSettingsSuspense_withClient(client),
|
|
2004
2061
|
useUpdateNotificationSettings: useUpdateNotificationSettings2,
|
|
2005
2062
|
useUserThreads_experimental: useUserThreadsSuspense_experimental,
|
|
2063
|
+
useAiChats: useAiChatsSuspense,
|
|
2064
|
+
useAiChatMessages: useAiChatMessagesSuspense,
|
|
2065
|
+
useCreateAiChat,
|
|
2066
|
+
useDeleteAiChat,
|
|
2006
2067
|
...shared.suspense
|
|
2007
2068
|
}
|
|
2008
2069
|
};
|
|
@@ -2375,6 +2436,88 @@ function useRoomInfoSuspense_withClient(client, roomId) {
|
|
|
2375
2436
|
error: void 0
|
|
2376
2437
|
};
|
|
2377
2438
|
}
|
|
2439
|
+
function useAiChats() {
|
|
2440
|
+
const client = useClient();
|
|
2441
|
+
const store = getUmbrellaStoreForClient(client);
|
|
2442
|
+
useEffect3(
|
|
2443
|
+
() => void store.outputs.aiChats.waitUntilLoaded()
|
|
2444
|
+
// NOTE: Deliberately *not* using a dependency array here!
|
|
2445
|
+
//
|
|
2446
|
+
// It is important to call waitUntil on *every* render.
|
|
2447
|
+
// This is harmless though, on most renders, except:
|
|
2448
|
+
// 1. The very first render, in which case we'll want to trigger the initial page fetch.
|
|
2449
|
+
// 2. All other subsequent renders now "just" return the same promise (a quick operation).
|
|
2450
|
+
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
2451
|
+
// *next* render after that, a *new* fetch/promise will get created.
|
|
2452
|
+
);
|
|
2453
|
+
return useSignal(store.outputs.aiChats.signal, identity2, shallow3);
|
|
2454
|
+
}
|
|
2455
|
+
function useAiChatsSuspense() {
|
|
2456
|
+
ensureNotServerSide();
|
|
2457
|
+
const client = useClient();
|
|
2458
|
+
const store = getUmbrellaStoreForClient(client);
|
|
2459
|
+
use(store.outputs.aiChats.waitUntilLoaded());
|
|
2460
|
+
const result = useAiChats();
|
|
2461
|
+
assert(!result.error, "Did not expect error");
|
|
2462
|
+
assert(!result.isLoading, "Did not expect loading");
|
|
2463
|
+
return result;
|
|
2464
|
+
}
|
|
2465
|
+
function useAiChatMessages(chatId, branch) {
|
|
2466
|
+
const client = useClient();
|
|
2467
|
+
const store = getUmbrellaStoreForClient(client);
|
|
2468
|
+
useEffect3(
|
|
2469
|
+
() => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(branch ?? null).waitUntilLoaded()
|
|
2470
|
+
// NOTE: Deliberately *not* using a dependency array here!
|
|
2471
|
+
//
|
|
2472
|
+
// It is important to call waitUntil on *every* render.
|
|
2473
|
+
// This is harmless though, on most renders, except:
|
|
2474
|
+
// 1. The very first render, in which case we'll want to trigger the initial page fetch.
|
|
2475
|
+
// 2. All other subsequent renders now "just" return the same promise (a quick operation).
|
|
2476
|
+
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
2477
|
+
// *next* render after that, a *new* fetch/promise will get created.
|
|
2478
|
+
);
|
|
2479
|
+
return useSignal(
|
|
2480
|
+
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(branch ?? null).signal
|
|
2481
|
+
);
|
|
2482
|
+
}
|
|
2483
|
+
function useAiChatMessagesSuspense(chatId, branch) {
|
|
2484
|
+
ensureNotServerSide();
|
|
2485
|
+
const client = useClient();
|
|
2486
|
+
const store = getUmbrellaStoreForClient(client);
|
|
2487
|
+
use(
|
|
2488
|
+
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(branch ?? null).waitUntilLoaded()
|
|
2489
|
+
);
|
|
2490
|
+
const result = useAiChatMessages(chatId, branch);
|
|
2491
|
+
assert(!result.error, "Did not expect error");
|
|
2492
|
+
assert(!result.isLoading, "Did not expect loading");
|
|
2493
|
+
return result;
|
|
2494
|
+
}
|
|
2495
|
+
function useCreateAiChat() {
|
|
2496
|
+
const client = useClient();
|
|
2497
|
+
return useCallback2(
|
|
2498
|
+
(options) => {
|
|
2499
|
+
client[kInternal2].ai.createChat(options.id).catch((err) => {
|
|
2500
|
+
console.error(
|
|
2501
|
+
`Failed to create chat with ID "${options.id}": ${String(err)}`
|
|
2502
|
+
);
|
|
2503
|
+
});
|
|
2504
|
+
},
|
|
2505
|
+
[client]
|
|
2506
|
+
);
|
|
2507
|
+
}
|
|
2508
|
+
function useDeleteAiChat() {
|
|
2509
|
+
const client = useClient();
|
|
2510
|
+
return useCallback2(
|
|
2511
|
+
(chatId) => {
|
|
2512
|
+
client[kInternal2].ai.deleteChat(chatId).catch((err) => {
|
|
2513
|
+
console.error(
|
|
2514
|
+
`Failed to delete chat with ID "${chatId}": ${String(err)}`
|
|
2515
|
+
);
|
|
2516
|
+
});
|
|
2517
|
+
},
|
|
2518
|
+
[client]
|
|
2519
|
+
);
|
|
2520
|
+
}
|
|
2378
2521
|
function createSharedContext(client) {
|
|
2379
2522
|
const useClient2 = () => client;
|
|
2380
2523
|
function useSyncStatus2(options) {
|
|
@@ -2445,6 +2588,12 @@ function LiveblocksProvider(props) {
|
|
|
2445
2588
|
)
|
|
2446
2589
|
};
|
|
2447
2590
|
const client = useMemo2(() => createClient(options), []);
|
|
2591
|
+
useEffect3(() => {
|
|
2592
|
+
client[kInternal2].ai.connect();
|
|
2593
|
+
return () => {
|
|
2594
|
+
client[kInternal2].ai.disconnect();
|
|
2595
|
+
};
|
|
2596
|
+
}, [client]);
|
|
2448
2597
|
return /* @__PURE__ */ jsx(LiveblocksProviderWithClient, { client, children });
|
|
2449
2598
|
}
|
|
2450
2599
|
function createLiveblocksContext(client) {
|
|
@@ -2545,6 +2694,10 @@ var _useUser = useUser;
|
|
|
2545
2694
|
var _useUserSuspense = useUserSuspense;
|
|
2546
2695
|
var _useUserThreads_experimental = useUserThreads_experimental;
|
|
2547
2696
|
var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
|
|
2697
|
+
var _useAiChats = useAiChats;
|
|
2698
|
+
var _useAiChatsSuspense = useAiChatsSuspense;
|
|
2699
|
+
var _useAiChatMessages = useAiChatMessages;
|
|
2700
|
+
var _useAiChatMessagesSuspense = useAiChatMessagesSuspense;
|
|
2548
2701
|
function useSyncStatus_withClient(client, options) {
|
|
2549
2702
|
const smooth = useInitial(options?.smooth ?? false);
|
|
2550
2703
|
if (smooth) {
|
|
@@ -4356,6 +4509,8 @@ export {
|
|
|
4356
4509
|
useSignal,
|
|
4357
4510
|
ClientContext,
|
|
4358
4511
|
getUmbrellaStoreForClient,
|
|
4512
|
+
useCreateAiChat,
|
|
4513
|
+
useDeleteAiChat,
|
|
4359
4514
|
useClientOrNull,
|
|
4360
4515
|
useClient,
|
|
4361
4516
|
LiveblocksProvider,
|
|
@@ -4378,6 +4533,10 @@ export {
|
|
|
4378
4533
|
_useUserSuspense,
|
|
4379
4534
|
_useUserThreads_experimental,
|
|
4380
4535
|
_useUserThreadsSuspense_experimental,
|
|
4536
|
+
_useAiChats,
|
|
4537
|
+
_useAiChatsSuspense,
|
|
4538
|
+
_useAiChatMessages,
|
|
4539
|
+
_useAiChatMessagesSuspense,
|
|
4381
4540
|
useSyncStatus,
|
|
4382
4541
|
useErrorListener,
|
|
4383
4542
|
useStatus,
|
|
@@ -4461,4 +4620,4 @@ export {
|
|
|
4461
4620
|
_useStorageRoot,
|
|
4462
4621
|
_useUpdateMyPresence
|
|
4463
4622
|
};
|
|
4464
|
-
//# sourceMappingURL=chunk-
|
|
4623
|
+
//# sourceMappingURL=chunk-E6PCFJWE.js.map
|