@liveblocks/react 2.25.0-aiprivatebeta7 → 2.25.0-aiprivatebeta9
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-M6D2NTTI.cjs +60 -0
- package/dist/chunk-M6D2NTTI.cjs.map +1 -0
- package/dist/{chunk-4DYOIL3C.cjs → chunk-RB4LUCGL.cjs} +60 -4
- package/dist/chunk-RB4LUCGL.cjs.map +1 -0
- package/dist/{chunk-S4TM7L5S.js → chunk-TMKZ6U2Y.js} +59 -3
- package/dist/chunk-TMKZ6U2Y.js.map +1 -0
- package/dist/chunk-Z2N4O6IQ.js +60 -0
- package/dist/chunk-Z2N4O6IQ.js.map +1 -0
- package/dist/index.cjs +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -3
- package/dist/index.d.ts +30 -3
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/{room-DnGQ1o0B.d.cts → room-BSt58hY4.d.cts} +33 -2
- package/dist/{room-DnGQ1o0B.d.ts → room-BSt58hY4.d.ts} +33 -2
- package/dist/suspense.cjs +8 -4
- package/dist/suspense.cjs.map +1 -1
- package/dist/suspense.d.cts +2 -2
- package/dist/suspense.d.ts +2 -2
- package/dist/suspense.js +7 -3
- package/dist/suspense.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-4DYOIL3C.cjs.map +0 -1
- package/dist/chunk-BJ6T5M3P.cjs +0 -23
- package/dist/chunk-BJ6T5M3P.cjs.map +0 -1
- package/dist/chunk-IXWATLVF.js +0 -23
- package/dist/chunk-IXWATLVF.js.map +0 -1
- package/dist/chunk-S4TM7L5S.js.map +0 -1
|
@@ -1157,6 +1157,31 @@ var UmbrellaStore = class {
|
|
|
1157
1157
|
}
|
|
1158
1158
|
);
|
|
1159
1159
|
});
|
|
1160
|
+
const aiChatById = new DefaultMap((chatId) => {
|
|
1161
|
+
const resource = new SinglePageResource(async () => {
|
|
1162
|
+
await this.#client[kInternal].ai.getOrCreateChat(chatId);
|
|
1163
|
+
});
|
|
1164
|
+
const signal = DerivedSignal.from(() => {
|
|
1165
|
+
const chat = this.#client[kInternal].ai.getChatById(chatId);
|
|
1166
|
+
if (chat === void 0) {
|
|
1167
|
+
const result = resource.get();
|
|
1168
|
+
if (result.isLoading || result.error) {
|
|
1169
|
+
return result;
|
|
1170
|
+
} else {
|
|
1171
|
+
return ASYNC_OK(
|
|
1172
|
+
"chat",
|
|
1173
|
+
nn(this.#client[kInternal].ai.getChatById(chatId))
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1176
|
+
} else {
|
|
1177
|
+
return ASYNC_OK(
|
|
1178
|
+
"chat",
|
|
1179
|
+
nn(this.#client[kInternal].ai.getChatById(chatId))
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
}, shallow);
|
|
1183
|
+
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
1184
|
+
});
|
|
1160
1185
|
this.outputs = {
|
|
1161
1186
|
threadifications,
|
|
1162
1187
|
threads,
|
|
@@ -1169,7 +1194,8 @@ var UmbrellaStore = class {
|
|
|
1169
1194
|
notificationSettings,
|
|
1170
1195
|
threadSubscriptions,
|
|
1171
1196
|
aiChats,
|
|
1172
|
-
messagesByChatId
|
|
1197
|
+
messagesByChatId,
|
|
1198
|
+
aiChatById
|
|
1173
1199
|
};
|
|
1174
1200
|
autobind(this);
|
|
1175
1201
|
}
|
|
@@ -2049,6 +2075,7 @@ function makeLiveblocksContextBundle(client) {
|
|
|
2049
2075
|
useInboxNotificationThread: useInboxNotificationThread2,
|
|
2050
2076
|
useUserThreads_experimental,
|
|
2051
2077
|
useAiChats,
|
|
2078
|
+
useAiChat,
|
|
2052
2079
|
useAiChatMessages,
|
|
2053
2080
|
useCreateAiChat,
|
|
2054
2081
|
useDeleteAiChat,
|
|
@@ -2066,6 +2093,7 @@ function makeLiveblocksContextBundle(client) {
|
|
|
2066
2093
|
useUpdateNotificationSettings: useUpdateNotificationSettings2,
|
|
2067
2094
|
useUserThreads_experimental: useUserThreadsSuspense_experimental,
|
|
2068
2095
|
useAiChats: useAiChatsSuspense,
|
|
2096
|
+
useAiChat: useAiChatSuspense,
|
|
2069
2097
|
useAiChatMessages: useAiChatMessagesSuspense,
|
|
2070
2098
|
useCreateAiChat,
|
|
2071
2099
|
useDeleteAiChat,
|
|
@@ -2497,11 +2525,37 @@ function useAiChatMessagesSuspense(chatId, branch) {
|
|
|
2497
2525
|
assert(!result.isLoading, "Did not expect loading");
|
|
2498
2526
|
return result;
|
|
2499
2527
|
}
|
|
2528
|
+
function useAiChat(chatId) {
|
|
2529
|
+
const client = useClient();
|
|
2530
|
+
const store = getUmbrellaStoreForClient(client);
|
|
2531
|
+
useEffect3(
|
|
2532
|
+
() => void store.outputs.aiChatById.getOrCreate(chatId).waitUntilLoaded()
|
|
2533
|
+
// NOTE: Deliberately *not* using a dependency array here!
|
|
2534
|
+
//
|
|
2535
|
+
// It is important to call waitUntil on *every* render.
|
|
2536
|
+
// This is harmless though, on most renders, except:
|
|
2537
|
+
// 1. The very first render, in which case we'll want to trigger the initial page fetch.
|
|
2538
|
+
// 2. All other subsequent renders now "just" return the same promise (a quick operation).
|
|
2539
|
+
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
2540
|
+
// *next* render after that, a *new* fetch/promise will get created.
|
|
2541
|
+
);
|
|
2542
|
+
return useSignal(store.outputs.aiChatById.getOrCreate(chatId).signal);
|
|
2543
|
+
}
|
|
2544
|
+
function useAiChatSuspense(chatId) {
|
|
2545
|
+
ensureNotServerSide();
|
|
2546
|
+
const client = useClient();
|
|
2547
|
+
const store = getUmbrellaStoreForClient(client);
|
|
2548
|
+
use(store.outputs.aiChatById.getOrCreate(chatId).waitUntilLoaded());
|
|
2549
|
+
const result = useAiChat(chatId);
|
|
2550
|
+
assert(!result.error, "Did not expect error");
|
|
2551
|
+
assert(!result.isLoading, "Did not expect loading");
|
|
2552
|
+
return result;
|
|
2553
|
+
}
|
|
2500
2554
|
function useCreateAiChat() {
|
|
2501
2555
|
const client = useClient();
|
|
2502
2556
|
return useCallback2(
|
|
2503
2557
|
(options) => {
|
|
2504
|
-
client[kInternal2].ai.getOrCreateChat(options.id).catch((err) => {
|
|
2558
|
+
client[kInternal2].ai.getOrCreateChat(options.id, options).catch((err) => {
|
|
2505
2559
|
console.error(
|
|
2506
2560
|
`Failed to create chat with ID "${options.id}": ${String(err)}`
|
|
2507
2561
|
);
|
|
@@ -2701,6 +2755,7 @@ var _useUserThreads_experimental = useUserThreads_experimental;
|
|
|
2701
2755
|
var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
|
|
2702
2756
|
var _useAiChats = useAiChats;
|
|
2703
2757
|
var _useAiChatsSuspense = useAiChatsSuspense;
|
|
2758
|
+
var _useAiChatSuspense = useAiChatSuspense;
|
|
2704
2759
|
var _useAiChatMessages = useAiChatMessages;
|
|
2705
2760
|
var _useAiChatMessagesSuspense = useAiChatMessagesSuspense;
|
|
2706
2761
|
function useSyncStatus_withClient(client, options) {
|
|
@@ -4536,6 +4591,7 @@ export {
|
|
|
4536
4591
|
_useUserThreadsSuspense_experimental,
|
|
4537
4592
|
_useAiChats,
|
|
4538
4593
|
_useAiChatsSuspense,
|
|
4594
|
+
_useAiChatSuspense,
|
|
4539
4595
|
_useAiChatMessages,
|
|
4540
4596
|
_useAiChatMessagesSuspense,
|
|
4541
4597
|
useSyncStatus,
|
|
@@ -4621,4 +4677,4 @@ export {
|
|
|
4621
4677
|
_useStorageRoot,
|
|
4622
4678
|
_useUpdateMyPresence
|
|
4623
4679
|
};
|
|
4624
|
-
//# sourceMappingURL=chunk-
|
|
4680
|
+
//# sourceMappingURL=chunk-TMKZ6U2Y.js.map
|