@liveblocks/react 2.25.0-aiprivatebeta1 → 2.25.0-aiprivatebeta11
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.cjs.map +1 -1
- package/dist/_private.d.cts +2 -2
- package/dist/_private.d.ts +2 -2
- package/dist/_private.js +1 -1
- package/dist/_private.js.map +1 -1
- package/dist/{chunk-GSA4MPRG.cjs → chunk-A4EPET3Z.cjs} +2 -2
- package/dist/{chunk-GSA4MPRG.cjs.map → chunk-A4EPET3Z.cjs.map} +1 -1
- package/dist/{chunk-ZGVKI7OM.cjs → chunk-CTSFL4KT.cjs} +193 -49
- package/dist/chunk-CTSFL4KT.cjs.map +1 -0
- package/dist/{chunk-EDEUY3EM.js → chunk-OWSOT5S6.js} +2 -2
- package/dist/{chunk-E6PCFJWE.js → chunk-X7TWWGKZ.js} +287 -143
- package/dist/chunk-X7TWWGKZ.js.map +1 -0
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -12
- package/dist/index.d.ts +3 -12
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/{room-DmsjrDvP.d.cts → room-BdfI6Vy7.d.cts} +215 -24
- package/dist/{room-DmsjrDvP.d.ts → room-BdfI6Vy7.d.ts} +215 -24
- package/dist/suspense.cjs +12 -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 +10 -2
- package/dist/suspense.js.map +1 -1
- package/package.json +13 -3
- package/dist/chunk-E6PCFJWE.js.map +0 -1
- package/dist/chunk-ZGVKI7OM.cjs.map +0 -1
- /package/dist/{chunk-EDEUY3EM.js.map → chunk-OWSOT5S6.js.map} +0 -0
|
@@ -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
|
-
|
|
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;
|
|
@@ -746,21 +794,26 @@ function createStore_forHistoryVersions() {
|
|
|
746
794
|
};
|
|
747
795
|
}
|
|
748
796
|
function createStore_forPermissionHints() {
|
|
749
|
-
const
|
|
750
|
-
new (0, _core.
|
|
797
|
+
const permissionsByRoomId = new (0, _core.DefaultMap)(
|
|
798
|
+
() => new (0, _core.Signal)(/* @__PURE__ */ new Set())
|
|
751
799
|
);
|
|
752
800
|
function update(newHints) {
|
|
753
|
-
|
|
754
|
-
for (const [roomId,
|
|
755
|
-
const
|
|
756
|
-
|
|
757
|
-
|
|
801
|
+
_core.batch.call(void 0, () => {
|
|
802
|
+
for (const [roomId, permissions] of Object.entries(newHints)) {
|
|
803
|
+
const signal = permissionsByRoomId.getOrCreate(roomId);
|
|
804
|
+
const existingPermissions = new Set(signal.get());
|
|
805
|
+
for (const permission of permissions) {
|
|
806
|
+
existingPermissions.add(permission);
|
|
758
807
|
}
|
|
808
|
+
signal.set(existingPermissions);
|
|
759
809
|
}
|
|
760
810
|
});
|
|
761
811
|
}
|
|
812
|
+
function getPermissionForRoom\u03A3(roomId) {
|
|
813
|
+
return permissionsByRoomId.getOrCreate(roomId);
|
|
814
|
+
}
|
|
762
815
|
return {
|
|
763
|
-
|
|
816
|
+
getPermissionForRoom\u03A3,
|
|
764
817
|
// Mutations
|
|
765
818
|
update
|
|
766
819
|
};
|
|
@@ -1152,6 +1205,31 @@ var UmbrellaStore = class {
|
|
|
1152
1205
|
}
|
|
1153
1206
|
);
|
|
1154
1207
|
});
|
|
1208
|
+
const aiChatById = new (0, _core.DefaultMap)((chatId) => {
|
|
1209
|
+
const resource = new SinglePageResource(async () => {
|
|
1210
|
+
await this.#client[_core.kInternal].ai.getOrCreateChat(chatId);
|
|
1211
|
+
});
|
|
1212
|
+
const signal = _core.DerivedSignal.from(() => {
|
|
1213
|
+
const chat = this.#client[_core.kInternal].ai.getChatById(chatId);
|
|
1214
|
+
if (chat === void 0) {
|
|
1215
|
+
const result = resource.get();
|
|
1216
|
+
if (result.isLoading || result.error) {
|
|
1217
|
+
return result;
|
|
1218
|
+
} else {
|
|
1219
|
+
return ASYNC_OK(
|
|
1220
|
+
"chat",
|
|
1221
|
+
_core.nn.call(void 0, this.#client[_core.kInternal].ai.getChatById(chatId))
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
} else {
|
|
1225
|
+
return ASYNC_OK(
|
|
1226
|
+
"chat",
|
|
1227
|
+
_core.nn.call(void 0, this.#client[_core.kInternal].ai.getChatById(chatId))
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
}, _core.shallow);
|
|
1231
|
+
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
1232
|
+
});
|
|
1155
1233
|
this.outputs = {
|
|
1156
1234
|
threadifications,
|
|
1157
1235
|
threads,
|
|
@@ -1164,7 +1242,8 @@ var UmbrellaStore = class {
|
|
|
1164
1242
|
notificationSettings,
|
|
1165
1243
|
threadSubscriptions,
|
|
1166
1244
|
aiChats,
|
|
1167
|
-
messagesByChatId
|
|
1245
|
+
messagesByChatId,
|
|
1246
|
+
aiChatById
|
|
1168
1247
|
};
|
|
1169
1248
|
autobind(this);
|
|
1170
1249
|
}
|
|
@@ -1885,7 +1964,6 @@ function isThreadParticipant(thread, userId) {
|
|
|
1885
1964
|
|
|
1886
1965
|
// src/liveblocks.tsx
|
|
1887
1966
|
var _jsxruntime = require('react/jsx-runtime');
|
|
1888
|
-
var ClientContext = _react.createContext.call(void 0, null);
|
|
1889
1967
|
function missingUserError(userId) {
|
|
1890
1968
|
return new Error(`resolveUsers didn't return anything for user '${userId}'`);
|
|
1891
1969
|
}
|
|
@@ -2044,9 +2122,11 @@ function makeLiveblocksContextBundle(client) {
|
|
|
2044
2122
|
useInboxNotificationThread: useInboxNotificationThread2,
|
|
2045
2123
|
useUserThreads_experimental,
|
|
2046
2124
|
useAiChats,
|
|
2125
|
+
useAiChat,
|
|
2047
2126
|
useAiChatMessages,
|
|
2048
2127
|
useCreateAiChat,
|
|
2049
2128
|
useDeleteAiChat,
|
|
2129
|
+
useSendAiMessage,
|
|
2050
2130
|
...shared.classic,
|
|
2051
2131
|
suspense: {
|
|
2052
2132
|
LiveblocksProvider: LiveblocksProvider2,
|
|
@@ -2061,9 +2141,11 @@ function makeLiveblocksContextBundle(client) {
|
|
|
2061
2141
|
useUpdateNotificationSettings: useUpdateNotificationSettings2,
|
|
2062
2142
|
useUserThreads_experimental: useUserThreadsSuspense_experimental,
|
|
2063
2143
|
useAiChats: useAiChatsSuspense,
|
|
2144
|
+
useAiChat: useAiChatSuspense,
|
|
2064
2145
|
useAiChatMessages: useAiChatMessagesSuspense,
|
|
2065
2146
|
useCreateAiChat,
|
|
2066
2147
|
useDeleteAiChat,
|
|
2148
|
+
useSendAiMessage,
|
|
2067
2149
|
...shared.suspense
|
|
2068
2150
|
}
|
|
2069
2151
|
};
|
|
@@ -2462,11 +2544,11 @@ function useAiChatsSuspense() {
|
|
|
2462
2544
|
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
2463
2545
|
return result;
|
|
2464
2546
|
}
|
|
2465
|
-
function useAiChatMessages(chatId,
|
|
2547
|
+
function useAiChatMessages(chatId, options) {
|
|
2466
2548
|
const client = useClient();
|
|
2467
2549
|
const store = getUmbrellaStoreForClient(client);
|
|
2468
2550
|
_react.useEffect.call(void 0,
|
|
2469
|
-
() => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(
|
|
2551
|
+
() => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _16 => _16.branchId]), () => ( null))).waitUntilLoaded()
|
|
2470
2552
|
// NOTE: Deliberately *not* using a dependency array here!
|
|
2471
2553
|
//
|
|
2472
2554
|
// It is important to call waitUntil on *every* render.
|
|
@@ -2477,17 +2559,43 @@ function useAiChatMessages(chatId, branch) {
|
|
|
2477
2559
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
2478
2560
|
);
|
|
2479
2561
|
return useSignal(
|
|
2480
|
-
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(
|
|
2562
|
+
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.branchId]), () => ( null))).signal
|
|
2481
2563
|
);
|
|
2482
2564
|
}
|
|
2483
|
-
function useAiChatMessagesSuspense(chatId,
|
|
2565
|
+
function useAiChatMessagesSuspense(chatId, options) {
|
|
2484
2566
|
ensureNotServerSide();
|
|
2485
2567
|
const client = useClient();
|
|
2486
2568
|
const store = getUmbrellaStoreForClient(client);
|
|
2487
2569
|
use(
|
|
2488
|
-
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(
|
|
2570
|
+
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _18 => _18.branchId]), () => ( null))).waitUntilLoaded()
|
|
2489
2571
|
);
|
|
2490
|
-
const result = useAiChatMessages(chatId,
|
|
2572
|
+
const result = useAiChatMessages(chatId, options);
|
|
2573
|
+
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
2574
|
+
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
2575
|
+
return result;
|
|
2576
|
+
}
|
|
2577
|
+
function useAiChat(chatId) {
|
|
2578
|
+
const client = useClient();
|
|
2579
|
+
const store = getUmbrellaStoreForClient(client);
|
|
2580
|
+
_react.useEffect.call(void 0,
|
|
2581
|
+
() => void store.outputs.aiChatById.getOrCreate(chatId).waitUntilLoaded()
|
|
2582
|
+
// NOTE: Deliberately *not* using a dependency array here!
|
|
2583
|
+
//
|
|
2584
|
+
// It is important to call waitUntil on *every* render.
|
|
2585
|
+
// This is harmless though, on most renders, except:
|
|
2586
|
+
// 1. The very first render, in which case we'll want to trigger the initial page fetch.
|
|
2587
|
+
// 2. All other subsequent renders now "just" return the same promise (a quick operation).
|
|
2588
|
+
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
2589
|
+
// *next* render after that, a *new* fetch/promise will get created.
|
|
2590
|
+
);
|
|
2591
|
+
return useSignal(store.outputs.aiChatById.getOrCreate(chatId).signal);
|
|
2592
|
+
}
|
|
2593
|
+
function useAiChatSuspense(chatId) {
|
|
2594
|
+
ensureNotServerSide();
|
|
2595
|
+
const client = useClient();
|
|
2596
|
+
const store = getUmbrellaStoreForClient(client);
|
|
2597
|
+
use(store.outputs.aiChatById.getOrCreate(chatId).waitUntilLoaded());
|
|
2598
|
+
const result = useAiChat(chatId);
|
|
2491
2599
|
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
2492
2600
|
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
2493
2601
|
return result;
|
|
@@ -2496,7 +2604,10 @@ function useCreateAiChat() {
|
|
|
2496
2604
|
const client = useClient();
|
|
2497
2605
|
return _react.useCallback.call(void 0,
|
|
2498
2606
|
(options) => {
|
|
2499
|
-
client[_core.kInternal].ai.
|
|
2607
|
+
client[_core.kInternal].ai.getOrCreateChat(options.id, {
|
|
2608
|
+
title: options.title,
|
|
2609
|
+
metadata: options.metadata
|
|
2610
|
+
}).catch((err) => {
|
|
2500
2611
|
console.error(
|
|
2501
2612
|
`Failed to create chat with ID "${options.id}": ${String(err)}`
|
|
2502
2613
|
);
|
|
@@ -2518,6 +2629,38 @@ function useDeleteAiChat() {
|
|
|
2518
2629
|
[client]
|
|
2519
2630
|
);
|
|
2520
2631
|
}
|
|
2632
|
+
function useSendAiMessage(chatId, options) {
|
|
2633
|
+
const client = useClient();
|
|
2634
|
+
const copilotId = _optionalChain([options, 'optionalAccess', _19 => _19.copilotId]);
|
|
2635
|
+
return _react.useCallback.call(void 0,
|
|
2636
|
+
(message) => {
|
|
2637
|
+
const messages = client[_core.kInternal].ai.signals.getChatMessagesForBranch\u03A3(chatId).get();
|
|
2638
|
+
const lastMessageId = _nullishCoalesce(_optionalChain([messages, 'access', _20 => _20[messages.length - 1], 'optionalAccess', _21 => _21.id]), () => ( null));
|
|
2639
|
+
const content = [{ type: "text", text: message }];
|
|
2640
|
+
const newMessageId = client[_core.kInternal].ai[_core.kInternal].context.messagesStore.createOptimistically(
|
|
2641
|
+
chatId,
|
|
2642
|
+
"user",
|
|
2643
|
+
lastMessageId,
|
|
2644
|
+
content
|
|
2645
|
+
);
|
|
2646
|
+
const targetMessageId = client[_core.kInternal].ai[_core.kInternal].context.messagesStore.createOptimistically(
|
|
2647
|
+
chatId,
|
|
2648
|
+
"assistant",
|
|
2649
|
+
newMessageId
|
|
2650
|
+
);
|
|
2651
|
+
void client[_core.kInternal].ai.askUserMessageInChat(
|
|
2652
|
+
chatId,
|
|
2653
|
+
{ id: newMessageId, parentMessageId: lastMessageId, content },
|
|
2654
|
+
targetMessageId,
|
|
2655
|
+
{
|
|
2656
|
+
stream: false,
|
|
2657
|
+
copilotId
|
|
2658
|
+
}
|
|
2659
|
+
);
|
|
2660
|
+
},
|
|
2661
|
+
[client, chatId, copilotId]
|
|
2662
|
+
);
|
|
2663
|
+
}
|
|
2521
2664
|
function createSharedContext(client) {
|
|
2522
2665
|
const useClient2 = () => client;
|
|
2523
2666
|
function useSyncStatus2(options) {
|
|
@@ -2530,7 +2673,9 @@ function createSharedContext(client) {
|
|
|
2530
2673
|
useRoomInfo: (roomId) => useRoomInfo_withClient(client, roomId),
|
|
2531
2674
|
useIsInsideRoom,
|
|
2532
2675
|
useErrorListener,
|
|
2533
|
-
useSyncStatus: useSyncStatus2
|
|
2676
|
+
useSyncStatus: useSyncStatus2,
|
|
2677
|
+
RegisterAiKnowledge,
|
|
2678
|
+
RegisterAiTool
|
|
2534
2679
|
},
|
|
2535
2680
|
suspense: {
|
|
2536
2681
|
useClient: useClient2,
|
|
@@ -2538,24 +2683,20 @@ function createSharedContext(client) {
|
|
|
2538
2683
|
useRoomInfo: (roomId) => useRoomInfoSuspense_withClient(client, roomId),
|
|
2539
2684
|
useIsInsideRoom,
|
|
2540
2685
|
useErrorListener,
|
|
2541
|
-
useSyncStatus: useSyncStatus2
|
|
2686
|
+
useSyncStatus: useSyncStatus2,
|
|
2687
|
+
RegisterAiKnowledge,
|
|
2688
|
+
RegisterAiTool
|
|
2542
2689
|
}
|
|
2543
2690
|
};
|
|
2544
2691
|
}
|
|
2545
2692
|
function useEnsureNoLiveblocksProvider(options) {
|
|
2546
2693
|
const existing = useClientOrNull();
|
|
2547
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
2694
|
+
if (!_optionalChain([options, 'optionalAccess', _22 => _22.allowNesting]) && existing !== null) {
|
|
2548
2695
|
throw new Error(
|
|
2549
2696
|
"You cannot nest multiple LiveblocksProvider instances in the same React tree."
|
|
2550
2697
|
);
|
|
2551
2698
|
}
|
|
2552
2699
|
}
|
|
2553
|
-
function useClientOrNull() {
|
|
2554
|
-
return _react.useContext.call(void 0, ClientContext);
|
|
2555
|
-
}
|
|
2556
|
-
function useClient() {
|
|
2557
|
-
return _nullishCoalesce(useClientOrNull(), () => ( _core.raise.call(void 0, "LiveblocksProvider is missing from the React tree.")));
|
|
2558
|
-
}
|
|
2559
2700
|
function LiveblocksProviderWithClient(props) {
|
|
2560
2701
|
useEnsureNoLiveblocksProvider(props);
|
|
2561
2702
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ClientContext.Provider, { value: props.client, children: props.children });
|
|
@@ -2696,10 +2837,12 @@ var _useUserThreads_experimental = useUserThreads_experimental;
|
|
|
2696
2837
|
var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
|
|
2697
2838
|
var _useAiChats = useAiChats;
|
|
2698
2839
|
var _useAiChatsSuspense = useAiChatsSuspense;
|
|
2840
|
+
var _useAiChat = useAiChat;
|
|
2841
|
+
var _useAiChatSuspense = useAiChatSuspense;
|
|
2699
2842
|
var _useAiChatMessages = useAiChatMessages;
|
|
2700
2843
|
var _useAiChatMessagesSuspense = useAiChatMessagesSuspense;
|
|
2701
2844
|
function useSyncStatus_withClient(client, options) {
|
|
2702
|
-
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2845
|
+
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.smooth]), () => ( false)));
|
|
2703
2846
|
if (smooth) {
|
|
2704
2847
|
return useSyncStatusSmooth_withClient(client);
|
|
2705
2848
|
} else {
|
|
@@ -2878,8 +3021,8 @@ function makeRoomExtrasForClient(client) {
|
|
|
2878
3021
|
if (innerError.status === 403) {
|
|
2879
3022
|
const detailedMessage = [
|
|
2880
3023
|
innerError.message,
|
|
2881
|
-
_optionalChain([innerError, 'access',
|
|
2882
|
-
_optionalChain([innerError, 'access',
|
|
3024
|
+
_optionalChain([innerError, 'access', _24 => _24.details, 'optionalAccess', _25 => _25.suggestion]),
|
|
3025
|
+
_optionalChain([innerError, 'access', _26 => _26.details, 'optionalAccess', _27 => _27.docs])
|
|
2883
3026
|
].filter(Boolean).join("\n");
|
|
2884
3027
|
_core.console.error(detailedMessage);
|
|
2885
3028
|
}
|
|
@@ -3179,7 +3322,7 @@ function RoomProviderInner(props) {
|
|
|
3179
3322
|
}
|
|
3180
3323
|
function useRoom(options) {
|
|
3181
3324
|
const room = useRoomOrNull();
|
|
3182
|
-
if (room === null && !_optionalChain([options, 'optionalAccess',
|
|
3325
|
+
if (room === null && !_optionalChain([options, 'optionalAccess', _28 => _28.allowOutsideRoom])) {
|
|
3183
3326
|
throw new Error("RoomProvider is missing from the React tree.");
|
|
3184
3327
|
}
|
|
3185
3328
|
return room;
|
|
@@ -3254,7 +3397,7 @@ function useMentionSuggestionsCache() {
|
|
|
3254
3397
|
return client[_core.kInternal].mentionSuggestionsCache;
|
|
3255
3398
|
}
|
|
3256
3399
|
function useStorageStatus(options) {
|
|
3257
|
-
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3400
|
+
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _29 => _29.smooth]), () => ( false)));
|
|
3258
3401
|
if (smooth) {
|
|
3259
3402
|
return useStorageStatusSmooth();
|
|
3260
3403
|
} else {
|
|
@@ -3568,7 +3711,7 @@ function useCreateRoomThread(roomId) {
|
|
|
3568
3711
|
thread: newThread,
|
|
3569
3712
|
roomId
|
|
3570
3713
|
});
|
|
3571
|
-
const attachmentIds = _optionalChain([attachments, 'optionalAccess',
|
|
3714
|
+
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _30 => _30.map, 'call', _31 => _31((attachment) => attachment.id)]);
|
|
3572
3715
|
client[_core.kInternal].httpClient.createThread({
|
|
3573
3716
|
roomId,
|
|
3574
3717
|
threadId,
|
|
@@ -3608,7 +3751,7 @@ function useDeleteRoomThread(roomId) {
|
|
|
3608
3751
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3609
3752
|
const userId = getCurrentUserId(client);
|
|
3610
3753
|
const existing = store.outputs.threads.get().get(threadId);
|
|
3611
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
3754
|
+
if (_optionalChain([existing, 'optionalAccess', _32 => _32.comments, 'optionalAccess', _33 => _33[0], 'optionalAccess', _34 => _34.userId]) !== userId) {
|
|
3612
3755
|
throw new Error("Only the thread creator can delete the thread");
|
|
3613
3756
|
}
|
|
3614
3757
|
const optimisticId = store.optimisticUpdates.add({
|
|
@@ -3696,7 +3839,7 @@ function useCreateRoomComment(roomId) {
|
|
|
3696
3839
|
type: "create-comment",
|
|
3697
3840
|
comment
|
|
3698
3841
|
});
|
|
3699
|
-
const attachmentIds = _optionalChain([attachments, 'optionalAccess',
|
|
3842
|
+
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _35 => _35.map, 'call', _36 => _36((attachment) => attachment.id)]);
|
|
3700
3843
|
client[_core.kInternal].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
3701
3844
|
(newComment) => {
|
|
3702
3845
|
store.createComment(newComment, optimisticId);
|
|
@@ -3752,7 +3895,7 @@ function useEditRoomComment(roomId) {
|
|
|
3752
3895
|
attachments: _nullishCoalesce(attachments, () => ( []))
|
|
3753
3896
|
}
|
|
3754
3897
|
});
|
|
3755
|
-
const attachmentIds = _optionalChain([attachments, 'optionalAccess',
|
|
3898
|
+
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _37 => _37.map, 'call', _38 => _38((attachment) => attachment.id)]);
|
|
3756
3899
|
client[_core.kInternal].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
3757
3900
|
(editedComment) => {
|
|
3758
3901
|
store.editComment(threadId, optimisticId, editedComment);
|
|
@@ -4093,7 +4236,7 @@ function useRoomThreadSubscription(roomId, threadId) {
|
|
|
4093
4236
|
}
|
|
4094
4237
|
return {
|
|
4095
4238
|
status: "subscribed",
|
|
4096
|
-
unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess',
|
|
4239
|
+
unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess', _39 => _39.readAt]), () => ( null)),
|
|
4097
4240
|
subscribe,
|
|
4098
4241
|
unsubscribe
|
|
4099
4242
|
};
|
|
@@ -4388,7 +4531,7 @@ function useThreadsSuspense(options = {}) {
|
|
|
4388
4531
|
return result;
|
|
4389
4532
|
}
|
|
4390
4533
|
function selectorFor_useAttachmentUrl(state) {
|
|
4391
|
-
if (state === void 0 || _optionalChain([state, 'optionalAccess',
|
|
4534
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _40 => _40.isLoading])) {
|
|
4392
4535
|
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
4393
4536
|
}
|
|
4394
4537
|
if (state.error) {
|
|
@@ -4450,14 +4593,10 @@ function useAttachmentUrlSuspense(attachmentId) {
|
|
|
4450
4593
|
error: void 0
|
|
4451
4594
|
};
|
|
4452
4595
|
}
|
|
4453
|
-
var NO_PERMISSIONS = /* @__PURE__ */ new Set();
|
|
4454
4596
|
function useRoomPermissions(roomId) {
|
|
4455
4597
|
const client = useClient();
|
|
4456
4598
|
const store = getRoomExtrasForClient(client).store;
|
|
4457
|
-
return useSignal(
|
|
4458
|
-
store.permissionHints.signal,
|
|
4459
|
-
(hints) => _nullishCoalesce(hints.get(roomId), () => ( NO_PERMISSIONS))
|
|
4460
|
-
);
|
|
4599
|
+
return useSignal(store.permissionHints.getPermissionForRoom\u03A3(roomId));
|
|
4461
4600
|
}
|
|
4462
4601
|
function createRoomContext(client) {
|
|
4463
4602
|
return getOrCreateRoomContextBundle(client);
|
|
@@ -4619,5 +4758,10 @@ var _useUpdateMyPresence = useUpdateMyPresence;
|
|
|
4619
4758
|
|
|
4620
4759
|
|
|
4621
4760
|
|
|
4622
|
-
|
|
4623
|
-
|
|
4761
|
+
|
|
4762
|
+
|
|
4763
|
+
|
|
4764
|
+
|
|
4765
|
+
|
|
4766
|
+
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.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;
|
|
4767
|
+
//# sourceMappingURL=chunk-CTSFL4KT.cjs.map
|