@liveblocks/react 3.8.0-next3 → 3.8.0-tiptap1
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 +7 -7
- package/dist/_private.d.cts +2 -2
- package/dist/_private.d.ts +2 -2
- package/dist/_private.js +1 -1
- package/dist/{chunk-OYVPE6CV.cjs → chunk-4GCS3365.cjs} +63 -199
- package/dist/chunk-4GCS3365.cjs.map +1 -0
- package/dist/{chunk-DL5PAL6E.js → chunk-OKYUUXNY.js} +38 -174
- package/dist/chunk-OKYUUXNY.js.map +1 -0
- package/dist/{chunk-2A5VCDEZ.js → chunk-RCYYHORY.js} +2 -2
- package/dist/{chunk-4ZS65AZV.cjs → chunk-ZU7C6DJE.cjs} +2 -2
- package/dist/{chunk-4ZS65AZV.cjs.map → chunk-ZU7C6DJE.cjs.map} +1 -1
- package/dist/index.cjs +4 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/{room-C97RX2dB.d.cts → room-BtcL74U0.d.cts} +2 -102
- package/dist/{room-C97RX2dB.d.ts → room-BtcL74U0.d.ts} +2 -102
- package/dist/suspense.cjs +4 -6
- 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 +2 -4
- package/dist/suspense.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-DL5PAL6E.js.map +0 -1
- package/dist/chunk-OYVPE6CV.cjs.map +0 -1
- /package/dist/{chunk-2A5VCDEZ.js.map → chunk-RCYYHORY.js.map} +0 -0
|
@@ -186,7 +186,6 @@ function useSignal(signal, selector, isEqual) {
|
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
|
|
189
|
-
|
|
190
189
|
// src/config.ts
|
|
191
190
|
var SECONDS = 1e3;
|
|
192
191
|
var MINUTES = 60 * SECONDS;
|
|
@@ -217,6 +216,21 @@ function ASYNC_OK(fieldOrData, data) {
|
|
|
217
216
|
}
|
|
218
217
|
}
|
|
219
218
|
|
|
219
|
+
// src/lib/itertools.ts
|
|
220
|
+
function find(it, predicate) {
|
|
221
|
+
for (const item of it) {
|
|
222
|
+
if (predicate(item)) return item;
|
|
223
|
+
}
|
|
224
|
+
return void 0;
|
|
225
|
+
}
|
|
226
|
+
function count(it, predicate) {
|
|
227
|
+
let total = 0;
|
|
228
|
+
for (const item of it) {
|
|
229
|
+
if (predicate(item)) total++;
|
|
230
|
+
}
|
|
231
|
+
return total;
|
|
232
|
+
}
|
|
233
|
+
|
|
220
234
|
// src/lib/ssr.ts
|
|
221
235
|
function ensureNotServerSide() {
|
|
222
236
|
if (typeof window === "undefined") {
|
|
@@ -310,14 +324,6 @@ function autobind(self) {
|
|
|
310
324
|
} while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
|
|
311
325
|
}
|
|
312
326
|
|
|
313
|
-
// src/lib/itertools.ts
|
|
314
|
-
function find(it, predicate) {
|
|
315
|
-
for (const item of it) {
|
|
316
|
-
if (predicate(item)) return item;
|
|
317
|
-
}
|
|
318
|
-
return void 0;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
327
|
// src/lib/querying.ts
|
|
322
328
|
|
|
323
329
|
function makeThreadsFilter(query) {
|
|
@@ -716,21 +722,6 @@ function createStore_forNotifications() {
|
|
|
716
722
|
upsert
|
|
717
723
|
};
|
|
718
724
|
}
|
|
719
|
-
function createStore_forUnreadNotificationsCount() {
|
|
720
|
-
const baseSignal = new (0, _core.MutableSignal)(
|
|
721
|
-
/* @__PURE__ */ new Map()
|
|
722
|
-
);
|
|
723
|
-
function update(queryKey, count) {
|
|
724
|
-
baseSignal.mutate((lut) => {
|
|
725
|
-
lut.set(queryKey, count);
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
return {
|
|
729
|
-
signal: _core.DerivedSignal.from(baseSignal, (c) => Object.fromEntries(c)),
|
|
730
|
-
// Mutations
|
|
731
|
-
update
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
725
|
function createStore_forSubscriptions(updates, threads) {
|
|
735
726
|
const baseSignal = new (0, _core.MutableSignal)(/* @__PURE__ */ new Map());
|
|
736
727
|
function applyDelta(newSubscriptions, deletedSubscriptions) {
|
|
@@ -923,7 +914,6 @@ var UmbrellaStore = class {
|
|
|
923
914
|
|
|
924
915
|
|
|
925
916
|
|
|
926
|
-
|
|
927
917
|
//
|
|
928
918
|
// Output signals.
|
|
929
919
|
// (Readonly, clean, consistent. With optimistic updates applied.)
|
|
@@ -968,7 +958,6 @@ var UmbrellaStore = class {
|
|
|
968
958
|
this.optimisticUpdates.signal
|
|
969
959
|
);
|
|
970
960
|
this.historyVersions = createStore_forHistoryVersions();
|
|
971
|
-
this.unreadNotificationsCount = createStore_forUnreadNotificationsCount();
|
|
972
961
|
const threadifications = _core.DerivedSignal.from(
|
|
973
962
|
this.threads.signal,
|
|
974
963
|
this.notifications.signal,
|
|
@@ -1125,35 +1114,6 @@ var UmbrellaStore = class {
|
|
|
1125
1114
|
};
|
|
1126
1115
|
}
|
|
1127
1116
|
);
|
|
1128
|
-
const unreadNotificationsCount = new (0, _core.DefaultMap)(
|
|
1129
|
-
(queryKey) => {
|
|
1130
|
-
const query = JSON.parse(queryKey);
|
|
1131
|
-
const resource = new SinglePageResource(async () => {
|
|
1132
|
-
const result = await this.#client.getUnreadInboxNotificationsCount({
|
|
1133
|
-
query
|
|
1134
|
-
});
|
|
1135
|
-
this.unreadNotificationsCount.update(queryKey, result);
|
|
1136
|
-
});
|
|
1137
|
-
const signal = _core.DerivedSignal.from(
|
|
1138
|
-
() => {
|
|
1139
|
-
const result = resource.get();
|
|
1140
|
-
if (result.isLoading || result.error) {
|
|
1141
|
-
return result;
|
|
1142
|
-
} else {
|
|
1143
|
-
return ASYNC_OK(
|
|
1144
|
-
"count",
|
|
1145
|
-
_core.nn.call(void 0, this.unreadNotificationsCount.signal.get()[queryKey])
|
|
1146
|
-
);
|
|
1147
|
-
}
|
|
1148
|
-
},
|
|
1149
|
-
_core.shallow
|
|
1150
|
-
);
|
|
1151
|
-
return {
|
|
1152
|
-
signal,
|
|
1153
|
-
waitUntilLoaded: resource.waitUntilLoaded
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
|
-
);
|
|
1157
1117
|
const roomSubscriptionSettingsByRoomId = new (0, _core.DefaultMap)(
|
|
1158
1118
|
(roomId) => {
|
|
1159
1119
|
const resource = new SinglePageResource(async () => {
|
|
@@ -1302,7 +1262,6 @@ var UmbrellaStore = class {
|
|
|
1302
1262
|
loadingUserThreads,
|
|
1303
1263
|
notifications,
|
|
1304
1264
|
loadingNotifications,
|
|
1305
|
-
unreadNotificationsCount,
|
|
1306
1265
|
roomSubscriptionSettingsByRoomId,
|
|
1307
1266
|
versionsByRoomId,
|
|
1308
1267
|
notificationSettings,
|
|
@@ -1510,14 +1469,6 @@ var UmbrellaStore = class {
|
|
|
1510
1469
|
result.subscriptions.deleted
|
|
1511
1470
|
);
|
|
1512
1471
|
}
|
|
1513
|
-
async fetchUnreadNotificationsCount(queryKey, signal) {
|
|
1514
|
-
const query = JSON.parse(queryKey);
|
|
1515
|
-
const result = await this.#client.getUnreadInboxNotificationsCount({
|
|
1516
|
-
query,
|
|
1517
|
-
signal
|
|
1518
|
-
});
|
|
1519
|
-
this.unreadNotificationsCount.update(queryKey, result);
|
|
1520
|
-
}
|
|
1521
1472
|
async fetchRoomThreadsDeltaUpdate(roomId, signal) {
|
|
1522
1473
|
const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
1523
1474
|
if (lastRequestedAt === void 0) {
|
|
@@ -2032,10 +1983,16 @@ var _umbrellaStores = /* @__PURE__ */ new WeakMap();
|
|
|
2032
1983
|
var _extras = /* @__PURE__ */ new WeakMap();
|
|
2033
1984
|
var _bundles = /* @__PURE__ */ new WeakMap();
|
|
2034
1985
|
function selectorFor_useUnreadInboxNotificationsCount(result) {
|
|
2035
|
-
if (!
|
|
1986
|
+
if (!result.inboxNotifications) {
|
|
2036
1987
|
return result;
|
|
2037
1988
|
}
|
|
2038
|
-
return ASYNC_OK(
|
|
1989
|
+
return ASYNC_OK(
|
|
1990
|
+
"count",
|
|
1991
|
+
count(
|
|
1992
|
+
result.inboxNotifications,
|
|
1993
|
+
(n) => n.readAt === null || n.readAt < n.notifiedAt
|
|
1994
|
+
)
|
|
1995
|
+
);
|
|
2039
1996
|
}
|
|
2040
1997
|
function selectorFor_useUser(state, userId) {
|
|
2041
1998
|
if (state === void 0 || _optionalChain([state, 'optionalAccess', _10 => _10.isLoading])) {
|
|
@@ -2134,22 +2091,6 @@ function makeLiveblocksExtrasForClient(client) {
|
|
|
2134
2091
|
config.NOTIFICATIONS_POLL_INTERVAL,
|
|
2135
2092
|
{ maxStaleTimeMs: config.NOTIFICATIONS_MAX_STALE_TIME }
|
|
2136
2093
|
);
|
|
2137
|
-
const unreadNotificationsCountPollersByQueryKey = new (0, _core.DefaultMap)(
|
|
2138
|
-
(queryKey) => _core.makePoller.call(void 0,
|
|
2139
|
-
async (signal) => {
|
|
2140
|
-
try {
|
|
2141
|
-
return await store.fetchUnreadNotificationsCount(queryKey, signal);
|
|
2142
|
-
} catch (err) {
|
|
2143
|
-
_core.console.warn(
|
|
2144
|
-
`Polling unread inbox notifications countfailed: ${String(err)}`
|
|
2145
|
-
);
|
|
2146
|
-
throw err;
|
|
2147
|
-
}
|
|
2148
|
-
},
|
|
2149
|
-
config.NOTIFICATIONS_POLL_INTERVAL,
|
|
2150
|
-
{ maxStaleTimeMs: config.NOTIFICATIONS_MAX_STALE_TIME }
|
|
2151
|
-
)
|
|
2152
|
-
);
|
|
2153
2094
|
const userThreadsPoller = _core.makePoller.call(void 0,
|
|
2154
2095
|
async (signal) => {
|
|
2155
2096
|
try {
|
|
@@ -2180,8 +2121,7 @@ function makeLiveblocksExtrasForClient(client) {
|
|
|
2180
2121
|
store,
|
|
2181
2122
|
notificationsPoller,
|
|
2182
2123
|
userThreadsPoller,
|
|
2183
|
-
notificationSettingsPoller
|
|
2184
|
-
unreadNotificationsCountPollersByQueryKey
|
|
2124
|
+
notificationSettingsPoller
|
|
2185
2125
|
};
|
|
2186
2126
|
}
|
|
2187
2127
|
function makeLiveblocksContextBundle(client) {
|
|
@@ -2211,7 +2151,6 @@ function makeLiveblocksContextBundle(client) {
|
|
|
2211
2151
|
useAiChats,
|
|
2212
2152
|
useAiChat,
|
|
2213
2153
|
useAiChatMessages,
|
|
2214
|
-
useAiChatStatus,
|
|
2215
2154
|
useCreateAiChat,
|
|
2216
2155
|
useDeleteAiChat,
|
|
2217
2156
|
useSendAiMessage,
|
|
@@ -2231,7 +2170,6 @@ function makeLiveblocksContextBundle(client) {
|
|
|
2231
2170
|
useAiChats: useAiChatsSuspense,
|
|
2232
2171
|
useAiChat: useAiChatSuspense,
|
|
2233
2172
|
useAiChatMessages: useAiChatMessagesSuspense,
|
|
2234
|
-
useAiChatStatus,
|
|
2235
2173
|
useCreateAiChat,
|
|
2236
2174
|
useDeleteAiChat,
|
|
2237
2175
|
useSendAiMessage,
|
|
@@ -2285,39 +2223,19 @@ function useInboxNotificationsSuspense_withClient(client, options) {
|
|
|
2285
2223
|
return result;
|
|
2286
2224
|
}
|
|
2287
2225
|
function useUnreadInboxNotificationsCount_withClient(client, options) {
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
const poller = pollers.getOrCreate(queryKey);
|
|
2291
|
-
_react.useEffect.call(void 0,
|
|
2292
|
-
() => void store.outputs.unreadNotificationsCount.getOrCreate(queryKey).waitUntilLoaded()
|
|
2293
|
-
// NOTE: Deliberately *not* using a dependency array here!
|
|
2294
|
-
//
|
|
2295
|
-
// It is important to call waitUntil on *every* render.
|
|
2296
|
-
// This is harmless though, on most renders, except:
|
|
2297
|
-
// 1. The very first render, in which case we'll want to trigger the initial page fetch.
|
|
2298
|
-
// 2. All other subsequent renders now "just" return the same promise (a quick operation).
|
|
2299
|
-
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
2300
|
-
// *next* render after that, a *new* fetch/promise will get created.
|
|
2301
|
-
);
|
|
2302
|
-
_react.useEffect.call(void 0, () => {
|
|
2303
|
-
poller.inc();
|
|
2304
|
-
poller.pollNowIfStale();
|
|
2305
|
-
return () => {
|
|
2306
|
-
poller.dec();
|
|
2307
|
-
};
|
|
2308
|
-
}, [poller]);
|
|
2309
|
-
return useSignal(
|
|
2310
|
-
store.outputs.unreadNotificationsCount.getOrCreate(queryKey).signal,
|
|
2226
|
+
return useInboxNotifications_withClient(
|
|
2227
|
+
client,
|
|
2311
2228
|
selectorFor_useUnreadInboxNotificationsCount,
|
|
2312
|
-
_core.shallow
|
|
2229
|
+
_core.shallow,
|
|
2230
|
+
options
|
|
2313
2231
|
);
|
|
2314
2232
|
}
|
|
2315
2233
|
function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
|
|
2316
2234
|
ensureNotServerSide();
|
|
2317
2235
|
const store = getLiveblocksExtrasForClient(client).store;
|
|
2318
|
-
const queryKey = makeInboxNotificationsQueryKey(_optionalChain([options, 'optionalAccess',
|
|
2236
|
+
const queryKey = makeInboxNotificationsQueryKey(_optionalChain([options, 'optionalAccess', _15 => _15.query]));
|
|
2319
2237
|
use(
|
|
2320
|
-
store.outputs.
|
|
2238
|
+
store.outputs.loadingNotifications.getOrCreate(queryKey).waitUntilLoaded()
|
|
2321
2239
|
);
|
|
2322
2240
|
const result = useUnreadInboxNotificationsCount_withClient(client, options);
|
|
2323
2241
|
_core.assert.call(void 0, !result.isLoading, "Did not expect loading");
|
|
@@ -2327,7 +2245,7 @@ function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
|
|
|
2327
2245
|
function useMarkInboxNotificationAsRead_withClient(client) {
|
|
2328
2246
|
return _react.useCallback.call(void 0,
|
|
2329
2247
|
(inboxNotificationId) => {
|
|
2330
|
-
const { store
|
|
2248
|
+
const { store } = getLiveblocksExtrasForClient(client);
|
|
2331
2249
|
const readAt = /* @__PURE__ */ new Date();
|
|
2332
2250
|
const optimisticId = store.optimisticUpdates.add({
|
|
2333
2251
|
type: "mark-inbox-notification-as-read",
|
|
@@ -2341,10 +2259,6 @@ function useMarkInboxNotificationAsRead_withClient(client) {
|
|
|
2341
2259
|
readAt,
|
|
2342
2260
|
optimisticId
|
|
2343
2261
|
);
|
|
2344
|
-
for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
|
|
2345
|
-
poller.markAsStale();
|
|
2346
|
-
poller.pollNowIfStale();
|
|
2347
|
-
}
|
|
2348
2262
|
},
|
|
2349
2263
|
(err) => {
|
|
2350
2264
|
store.optimisticUpdates.remove(optimisticId);
|
|
@@ -2363,7 +2277,7 @@ function useMarkInboxNotificationAsRead_withClient(client) {
|
|
|
2363
2277
|
}
|
|
2364
2278
|
function useMarkAllInboxNotificationsAsRead_withClient(client) {
|
|
2365
2279
|
return _react.useCallback.call(void 0, () => {
|
|
2366
|
-
const { store
|
|
2280
|
+
const { store } = getLiveblocksExtrasForClient(client);
|
|
2367
2281
|
const readAt = /* @__PURE__ */ new Date();
|
|
2368
2282
|
const optimisticId = store.optimisticUpdates.add({
|
|
2369
2283
|
type: "mark-all-inbox-notifications-as-read",
|
|
@@ -2372,10 +2286,6 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
|
|
|
2372
2286
|
client.markAllInboxNotificationsAsRead().then(
|
|
2373
2287
|
() => {
|
|
2374
2288
|
store.markAllInboxNotificationsRead(optimisticId, readAt);
|
|
2375
|
-
for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
|
|
2376
|
-
poller.markAsStale();
|
|
2377
|
-
poller.pollNowIfStale();
|
|
2378
|
-
}
|
|
2379
2289
|
},
|
|
2380
2290
|
(err) => {
|
|
2381
2291
|
store.optimisticUpdates.remove(optimisticId);
|
|
@@ -2391,7 +2301,7 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
|
|
|
2391
2301
|
function useDeleteInboxNotification_withClient(client) {
|
|
2392
2302
|
return _react.useCallback.call(void 0,
|
|
2393
2303
|
(inboxNotificationId) => {
|
|
2394
|
-
const { store
|
|
2304
|
+
const { store } = getLiveblocksExtrasForClient(client);
|
|
2395
2305
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
2396
2306
|
const optimisticId = store.optimisticUpdates.add({
|
|
2397
2307
|
type: "delete-inbox-notification",
|
|
@@ -2401,10 +2311,6 @@ function useDeleteInboxNotification_withClient(client) {
|
|
|
2401
2311
|
client.deleteInboxNotification(inboxNotificationId).then(
|
|
2402
2312
|
() => {
|
|
2403
2313
|
store.deleteInboxNotification(inboxNotificationId, optimisticId);
|
|
2404
|
-
for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
|
|
2405
|
-
poller.markAsStale();
|
|
2406
|
-
poller.pollNowIfStale();
|
|
2407
|
-
}
|
|
2408
2314
|
},
|
|
2409
2315
|
(err) => {
|
|
2410
2316
|
store.optimisticUpdates.remove(optimisticId);
|
|
@@ -2420,7 +2326,7 @@ function useDeleteInboxNotification_withClient(client) {
|
|
|
2420
2326
|
}
|
|
2421
2327
|
function useDeleteAllInboxNotifications_withClient(client) {
|
|
2422
2328
|
return _react.useCallback.call(void 0, () => {
|
|
2423
|
-
const { store
|
|
2329
|
+
const { store } = getLiveblocksExtrasForClient(client);
|
|
2424
2330
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
2425
2331
|
const optimisticId = store.optimisticUpdates.add({
|
|
2426
2332
|
type: "delete-all-inbox-notifications",
|
|
@@ -2429,10 +2335,6 @@ function useDeleteAllInboxNotifications_withClient(client) {
|
|
|
2429
2335
|
client.deleteAllInboxNotifications().then(
|
|
2430
2336
|
() => {
|
|
2431
2337
|
store.deleteAllInboxNotifications(optimisticId);
|
|
2432
|
-
for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
|
|
2433
|
-
poller.markAsStale();
|
|
2434
|
-
poller.pollNowIfStale();
|
|
2435
|
-
}
|
|
2436
2338
|
},
|
|
2437
2339
|
(err) => {
|
|
2438
2340
|
store.optimisticUpdates.remove(optimisticId);
|
|
@@ -2486,7 +2388,7 @@ function useUpdateNotificationSettings_withClient(client) {
|
|
|
2486
2388
|
store.optimisticUpdates.remove(optimisticUpdateId);
|
|
2487
2389
|
if (err instanceof _core.HttpError) {
|
|
2488
2390
|
if (err.status === 422) {
|
|
2489
|
-
const msg = [_optionalChain([err, 'access',
|
|
2391
|
+
const msg = [_optionalChain([err, 'access', _16 => _16.details, 'optionalAccess', _17 => _17.error]), _optionalChain([err, 'access', _18 => _18.details, 'optionalAccess', _19 => _19.reason])].filter(Boolean).join("\n");
|
|
2490
2392
|
_core.console.error(msg);
|
|
2491
2393
|
}
|
|
2492
2394
|
client[_core.kInternal].emitError(
|
|
@@ -2721,7 +2623,7 @@ function useGroupInfoSuspense_withClient(client, groupId) {
|
|
|
2721
2623
|
function useAiChats(options) {
|
|
2722
2624
|
const client = useClient();
|
|
2723
2625
|
const store = getUmbrellaStoreForClient(client);
|
|
2724
|
-
const queryKey = makeAiChatsQueryKey(_optionalChain([options, 'optionalAccess',
|
|
2626
|
+
const queryKey = makeAiChatsQueryKey(_optionalChain([options, 'optionalAccess', _20 => _20.query]));
|
|
2725
2627
|
useEnsureAiConnection(client);
|
|
2726
2628
|
_react.useEffect.call(void 0,
|
|
2727
2629
|
() => void store.outputs.aiChats.getOrCreate(queryKey).waitUntilLoaded()
|
|
@@ -2745,7 +2647,7 @@ function useAiChatsSuspense(options) {
|
|
|
2745
2647
|
const client = useClient();
|
|
2746
2648
|
const store = getUmbrellaStoreForClient(client);
|
|
2747
2649
|
useEnsureAiConnection(client);
|
|
2748
|
-
const queryKey = makeAiChatsQueryKey(_optionalChain([options, 'optionalAccess',
|
|
2650
|
+
const queryKey = makeAiChatsQueryKey(_optionalChain([options, 'optionalAccess', _21 => _21.query]));
|
|
2749
2651
|
use(store.outputs.aiChats.getOrCreate(queryKey).waitUntilLoaded());
|
|
2750
2652
|
const result = useAiChats(options);
|
|
2751
2653
|
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
@@ -2757,7 +2659,7 @@ function useAiChatMessages(chatId, options) {
|
|
|
2757
2659
|
const store = getUmbrellaStoreForClient(client);
|
|
2758
2660
|
useEnsureAiConnection(client);
|
|
2759
2661
|
_react.useEffect.call(void 0,
|
|
2760
|
-
() => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2662
|
+
() => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.branchId]), () => ( null))).waitUntilLoaded()
|
|
2761
2663
|
// NOTE: Deliberately *not* using a dependency array here!
|
|
2762
2664
|
//
|
|
2763
2665
|
// It is important to call waitUntil on *every* render.
|
|
@@ -2768,7 +2670,7 @@ function useAiChatMessages(chatId, options) {
|
|
|
2768
2670
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
2769
2671
|
);
|
|
2770
2672
|
return useSignal(
|
|
2771
|
-
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2673
|
+
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.branchId]), () => ( null))).signal
|
|
2772
2674
|
);
|
|
2773
2675
|
}
|
|
2774
2676
|
function useAiChatMessagesSuspense(chatId, options) {
|
|
@@ -2777,7 +2679,7 @@ function useAiChatMessagesSuspense(chatId, options) {
|
|
|
2777
2679
|
const store = getUmbrellaStoreForClient(client);
|
|
2778
2680
|
useEnsureAiConnection(client);
|
|
2779
2681
|
use(
|
|
2780
|
-
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2682
|
+
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _24 => _24.branchId]), () => ( null))).waitUntilLoaded()
|
|
2781
2683
|
);
|
|
2782
2684
|
const result = useAiChatMessages(chatId, options);
|
|
2783
2685
|
_core.assert.call(void 0, !result.error, "Did not expect error");
|
|
@@ -2844,43 +2746,6 @@ function useDeleteAiChat() {
|
|
|
2844
2746
|
[client]
|
|
2845
2747
|
);
|
|
2846
2748
|
}
|
|
2847
|
-
var LOADING = Object.freeze({ status: "loading" });
|
|
2848
|
-
var IDLE = Object.freeze({ status: "idle" });
|
|
2849
|
-
function useAiChatStatus(chatId, branchId) {
|
|
2850
|
-
const client = useClient();
|
|
2851
|
-
const store = getUmbrellaStoreForClient(client);
|
|
2852
|
-
useEnsureAiConnection(client);
|
|
2853
|
-
_react.useEffect.call(void 0,
|
|
2854
|
-
() => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(branchId, () => ( null))).waitUntilLoaded()
|
|
2855
|
-
);
|
|
2856
|
-
return useSignal(
|
|
2857
|
-
// Signal
|
|
2858
|
-
store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(_nullishCoalesce(branchId, () => ( null))).signal,
|
|
2859
|
-
// Selector
|
|
2860
|
-
(result) => {
|
|
2861
|
-
if (result.isLoading) return LOADING;
|
|
2862
|
-
if (result.error) return IDLE;
|
|
2863
|
-
const messages = result.messages;
|
|
2864
|
-
const lastMessage = messages[messages.length - 1];
|
|
2865
|
-
if (_optionalChain([lastMessage, 'optionalAccess', _26 => _26.role]) !== "assistant") return IDLE;
|
|
2866
|
-
if (lastMessage.status !== "generating" && lastMessage.status !== "awaiting-tool")
|
|
2867
|
-
return IDLE;
|
|
2868
|
-
const contentSoFar = lastMessage.contentSoFar;
|
|
2869
|
-
const lastPart = contentSoFar[contentSoFar.length - 1];
|
|
2870
|
-
if (_optionalChain([lastPart, 'optionalAccess', _27 => _27.type]) === "tool-invocation") {
|
|
2871
|
-
return {
|
|
2872
|
-
status: "generating",
|
|
2873
|
-
partType: "tool-invocation",
|
|
2874
|
-
toolName: lastPart.name
|
|
2875
|
-
};
|
|
2876
|
-
} else {
|
|
2877
|
-
return { status: "generating", partType: _optionalChain([lastPart, 'optionalAccess', _28 => _28.type]) };
|
|
2878
|
-
}
|
|
2879
|
-
},
|
|
2880
|
-
// Consider { status: "generating", partType: "text" } and { status: "generating", partType: "text" } equal
|
|
2881
|
-
_core.shallow
|
|
2882
|
-
);
|
|
2883
|
-
}
|
|
2884
2749
|
function useSendAiMessage(chatId, options) {
|
|
2885
2750
|
const client = useClient();
|
|
2886
2751
|
return _react.useCallback.call(void 0,
|
|
@@ -2897,7 +2762,7 @@ function useSendAiMessage(chatId, options) {
|
|
|
2897
2762
|
"chatId must be provided to either `useSendAiMessage` or its returned function."
|
|
2898
2763
|
)));
|
|
2899
2764
|
const messages = client[_core.kInternal].ai.signals.getChatMessagesForBranch\u03A3(resolvedChatId).get();
|
|
2900
|
-
if (process.env.NODE_ENV !== "production" && !messageOptionsCopilotId && !_optionalChain([options, 'optionalAccess',
|
|
2765
|
+
if (process.env.NODE_ENV !== "production" && !messageOptionsCopilotId && !_optionalChain([options, 'optionalAccess', _25 => _25.copilotId])) {
|
|
2901
2766
|
_core.console.warn(
|
|
2902
2767
|
`No copilot ID was provided to useSendAiMessage when sending the message "${messageText.slice(
|
|
2903
2768
|
0,
|
|
@@ -2909,8 +2774,8 @@ To ensure the correct copilot ID is used, specify it either through the hook as
|
|
|
2909
2774
|
)}\u2026", copilotId: "co_xxx" })'`
|
|
2910
2775
|
);
|
|
2911
2776
|
}
|
|
2912
|
-
const resolvedCopilotId = _nullishCoalesce(_nullishCoalesce(messageOptionsCopilotId, () => ( _optionalChain([options, 'optionalAccess',
|
|
2913
|
-
const lastMessageId = _nullishCoalesce(_optionalChain([messages, 'access',
|
|
2777
|
+
const resolvedCopilotId = _nullishCoalesce(_nullishCoalesce(messageOptionsCopilotId, () => ( _optionalChain([options, 'optionalAccess', _26 => _26.copilotId]))), () => ( client[_core.kInternal].ai.getLastUsedCopilotId(resolvedChatId)));
|
|
2778
|
+
const lastMessageId = _nullishCoalesce(_optionalChain([messages, 'access', _27 => _27[messages.length - 1], 'optionalAccess', _28 => _28.id]), () => ( null));
|
|
2914
2779
|
const content = [{ type: "text", text: messageText }];
|
|
2915
2780
|
const newMessageId = client[_core.kInternal].ai[_core.kInternal].context.messagesStore.createOptimistically(
|
|
2916
2781
|
resolvedChatId,
|
|
@@ -2930,10 +2795,10 @@ To ensure the correct copilot ID is used, specify it either through the hook as
|
|
|
2930
2795
|
{ id: newMessageId, parentMessageId: lastMessageId, content },
|
|
2931
2796
|
targetMessageId,
|
|
2932
2797
|
{
|
|
2933
|
-
stream: _nullishCoalesce(messageOptions.stream, () => ( _optionalChain([options, 'optionalAccess',
|
|
2798
|
+
stream: _nullishCoalesce(messageOptions.stream, () => ( _optionalChain([options, 'optionalAccess', _29 => _29.stream]))),
|
|
2934
2799
|
copilotId: resolvedCopilotId,
|
|
2935
|
-
timeout: _nullishCoalesce(messageOptions.timeout, () => ( _optionalChain([options, 'optionalAccess',
|
|
2936
|
-
knowledge: _nullishCoalesce(messageOptions.knowledge, () => ( _optionalChain([options, 'optionalAccess',
|
|
2800
|
+
timeout: _nullishCoalesce(messageOptions.timeout, () => ( _optionalChain([options, 'optionalAccess', _30 => _30.timeout]))),
|
|
2801
|
+
knowledge: _nullishCoalesce(messageOptions.knowledge, () => ( _optionalChain([options, 'optionalAccess', _31 => _31.knowledge])))
|
|
2937
2802
|
}
|
|
2938
2803
|
);
|
|
2939
2804
|
return newMessage;
|
|
@@ -2941,10 +2806,10 @@ To ensure the correct copilot ID is used, specify it either through the hook as
|
|
|
2941
2806
|
[
|
|
2942
2807
|
client,
|
|
2943
2808
|
chatId,
|
|
2944
|
-
_optionalChain([options, 'optionalAccess',
|
|
2945
|
-
_optionalChain([options, 'optionalAccess',
|
|
2946
|
-
_optionalChain([options, 'optionalAccess',
|
|
2947
|
-
_optionalChain([options, 'optionalAccess',
|
|
2809
|
+
_optionalChain([options, 'optionalAccess', _32 => _32.copilotId]),
|
|
2810
|
+
_optionalChain([options, 'optionalAccess', _33 => _33.stream]),
|
|
2811
|
+
_optionalChain([options, 'optionalAccess', _34 => _34.timeout]),
|
|
2812
|
+
_optionalChain([options, 'optionalAccess', _35 => _35.knowledge])
|
|
2948
2813
|
]
|
|
2949
2814
|
);
|
|
2950
2815
|
}
|
|
@@ -2980,7 +2845,7 @@ function createSharedContext(client) {
|
|
|
2980
2845
|
}
|
|
2981
2846
|
function useEnsureNoLiveblocksProvider(options) {
|
|
2982
2847
|
const existing = useClientOrNull();
|
|
2983
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
2848
|
+
if (!_optionalChain([options, 'optionalAccess', _36 => _36.allowNesting]) && existing !== null) {
|
|
2984
2849
|
throw new Error(
|
|
2985
2850
|
"You cannot nest multiple LiveblocksProvider instances in the same React tree."
|
|
2986
2851
|
);
|
|
@@ -3144,7 +3009,7 @@ var _useAiChatSuspense = useAiChatSuspense;
|
|
|
3144
3009
|
var _useAiChatMessages = useAiChatMessages;
|
|
3145
3010
|
var _useAiChatMessagesSuspense = useAiChatMessagesSuspense;
|
|
3146
3011
|
function useSyncStatus_withClient(client, options) {
|
|
3147
|
-
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3012
|
+
const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _37 => _37.smooth]), () => ( false)));
|
|
3148
3013
|
if (smooth) {
|
|
3149
3014
|
return useSyncStatusSmooth_withClient(client);
|
|
3150
3015
|
} else {
|
|
@@ -3323,8 +3188,8 @@ function makeRoomExtrasForClient(client) {
|
|
|
3323
3188
|
if (innerError.status === 403) {
|
|
3324
3189
|
const detailedMessage = [
|
|
3325
3190
|
innerError.message,
|
|
3326
|
-
_optionalChain([innerError, 'access',
|
|
3327
|
-
_optionalChain([innerError, 'access',
|
|
3191
|
+
_optionalChain([innerError, 'access', _38 => _38.details, 'optionalAccess', _39 => _39.suggestion]),
|
|
3192
|
+
_optionalChain([innerError, 'access', _40 => _40.details, 'optionalAccess', _41 => _41.docs])
|
|
3328
3193
|
].filter(Boolean).join("\n");
|
|
3329
3194
|
_core.console.error(detailedMessage);
|
|
3330
3195
|
}
|
|
@@ -3619,7 +3484,7 @@ function RoomProviderInner(props) {
|
|
|
3619
3484
|
}
|
|
3620
3485
|
function useRoom(options) {
|
|
3621
3486
|
const room = useRoomOrNull();
|
|
3622
|
-
if (room === null && !_optionalChain([options, 'optionalAccess',
|
|
3487
|
+
if (room === null && !_optionalChain([options, 'optionalAccess', _42 => _42.allowOutsideRoom])) {
|
|
3623
3488
|
throw new Error("RoomProvider is missing from the React tree.");
|
|
3624
3489
|
}
|
|
3625
3490
|
return room;
|
|
@@ -3969,7 +3834,7 @@ function useCreateRoomThread(roomId) {
|
|
|
3969
3834
|
thread: newThread,
|
|
3970
3835
|
roomId
|
|
3971
3836
|
});
|
|
3972
|
-
const attachmentIds = _optionalChain([attachments, 'optionalAccess',
|
|
3837
|
+
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _43 => _43.map, 'call', _44 => _44((attachment) => attachment.id)]);
|
|
3973
3838
|
client[_core.kInternal].httpClient.createThread({
|
|
3974
3839
|
roomId,
|
|
3975
3840
|
threadId,
|
|
@@ -4009,7 +3874,7 @@ function useDeleteRoomThread(roomId) {
|
|
|
4009
3874
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
4010
3875
|
const userId = getCurrentUserId(client);
|
|
4011
3876
|
const existing = store.outputs.threads.get().get(threadId);
|
|
4012
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
3877
|
+
if (_optionalChain([existing, 'optionalAccess', _45 => _45.comments, 'optionalAccess', _46 => _46[0], 'optionalAccess', _47 => _47.userId]) !== userId) {
|
|
4013
3878
|
throw new Error("Only the thread creator can delete the thread");
|
|
4014
3879
|
}
|
|
4015
3880
|
const optimisticId = store.optimisticUpdates.add({
|
|
@@ -4097,7 +3962,7 @@ function useCreateRoomComment(roomId) {
|
|
|
4097
3962
|
type: "create-comment",
|
|
4098
3963
|
comment
|
|
4099
3964
|
});
|
|
4100
|
-
const attachmentIds = _optionalChain([attachments, 'optionalAccess',
|
|
3965
|
+
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _48 => _48.map, 'call', _49 => _49((attachment) => attachment.id)]);
|
|
4101
3966
|
client[_core.kInternal].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
4102
3967
|
(newComment) => {
|
|
4103
3968
|
store.createComment(newComment, optimisticId);
|
|
@@ -4153,7 +4018,7 @@ function useEditRoomComment(roomId) {
|
|
|
4153
4018
|
attachments: _nullishCoalesce(attachments, () => ( []))
|
|
4154
4019
|
}
|
|
4155
4020
|
});
|
|
4156
|
-
const attachmentIds = _optionalChain([attachments, 'optionalAccess',
|
|
4021
|
+
const attachmentIds = _optionalChain([attachments, 'optionalAccess', _50 => _50.map, 'call', _51 => _51((attachment) => attachment.id)]);
|
|
4157
4022
|
client[_core.kInternal].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
|
|
4158
4023
|
(editedComment) => {
|
|
4159
4024
|
store.editComment(threadId, optimisticId, editedComment);
|
|
@@ -4494,7 +4359,7 @@ function useRoomThreadSubscription(roomId, threadId) {
|
|
|
4494
4359
|
}
|
|
4495
4360
|
return {
|
|
4496
4361
|
status: "subscribed",
|
|
4497
|
-
unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess',
|
|
4362
|
+
unreadSince: _nullishCoalesce(_optionalChain([notification, 'optionalAccess', _52 => _52.readAt]), () => ( null)),
|
|
4498
4363
|
subscribe,
|
|
4499
4364
|
unsubscribe
|
|
4500
4365
|
};
|
|
@@ -4705,7 +4570,7 @@ function useThreadsSuspense(options = {}) {
|
|
|
4705
4570
|
return result;
|
|
4706
4571
|
}
|
|
4707
4572
|
function selectorFor_useAttachmentUrl(state) {
|
|
4708
|
-
if (state === void 0 || _optionalChain([state, 'optionalAccess',
|
|
4573
|
+
if (state === void 0 || _optionalChain([state, 'optionalAccess', _53 => _53.isLoading])) {
|
|
4709
4574
|
return _nullishCoalesce(state, () => ( { isLoading: true }));
|
|
4710
4575
|
}
|
|
4711
4576
|
if (state.error) {
|
|
@@ -4932,6 +4797,5 @@ var _useUpdateMyPresence = useUpdateMyPresence;
|
|
|
4932
4797
|
|
|
4933
4798
|
|
|
4934
4799
|
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
//# sourceMappingURL=chunk-OYVPE6CV.cjs.map
|
|
4800
|
+
exports.ClientContext = ClientContext; exports.useClientOrNull = useClientOrNull; exports.useClient = useClient; exports.RoomContext = RoomContext; exports.useLatest = useLatest; 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.useGroupInfo = useGroupInfo; exports.useGroupInfoSuspense = useGroupInfoSuspense; 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;
|
|
4801
|
+
//# sourceMappingURL=chunk-4GCS3365.cjs.map
|