@liveblocks/core 3.10.1 → 3.11.1
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/index.cjs +182 -150
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -5
- package/dist/index.d.ts +31 -5
- package/dist/index.js +48 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.
|
|
9
|
+
var PKG_VERSION = "3.11.1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1572,6 +1572,26 @@ function createApiClient({
|
|
|
1572
1572
|
throw err;
|
|
1573
1573
|
}
|
|
1574
1574
|
}
|
|
1575
|
+
async function searchComments(options, requestOptions) {
|
|
1576
|
+
const result = await httpClient.get(
|
|
1577
|
+
url`/v2/c/rooms/${options.roomId}/threads/comments/search`,
|
|
1578
|
+
await authManager.getAuthValue({
|
|
1579
|
+
requestedScope: "comments:read",
|
|
1580
|
+
roomId: options.roomId
|
|
1581
|
+
}),
|
|
1582
|
+
{
|
|
1583
|
+
text: options.query.text,
|
|
1584
|
+
query: objectToQuery({
|
|
1585
|
+
threadMetadata: options.query.threadMetadata,
|
|
1586
|
+
threadResolved: options.query.threadResolved,
|
|
1587
|
+
hasAttachments: options.query.hasAttachments,
|
|
1588
|
+
hasMentions: options.query.hasMentions
|
|
1589
|
+
})
|
|
1590
|
+
},
|
|
1591
|
+
{ signal: _optionalChain([requestOptions, 'optionalAccess', _15 => _15.signal]) }
|
|
1592
|
+
);
|
|
1593
|
+
return result;
|
|
1594
|
+
}
|
|
1575
1595
|
async function createThread(options) {
|
|
1576
1596
|
const commentId = _nullishCoalesce(options.commentId, () => ( createCommentId()));
|
|
1577
1597
|
const threadId = _nullishCoalesce(options.threadId, () => ( createThreadId()));
|
|
@@ -1743,11 +1763,11 @@ function createApiClient({
|
|
|
1743
1763
|
`Upload of attachment ${options.attachment.id} was aborted.`,
|
|
1744
1764
|
"AbortError"
|
|
1745
1765
|
) : void 0;
|
|
1746
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1766
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _16 => _16.aborted])) {
|
|
1747
1767
|
throw abortError;
|
|
1748
1768
|
}
|
|
1749
1769
|
const handleRetryError = (err) => {
|
|
1750
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1770
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _17 => _17.aborted])) {
|
|
1751
1771
|
throw abortError;
|
|
1752
1772
|
}
|
|
1753
1773
|
if (err instanceof HttpError && err.status === 413) {
|
|
@@ -1819,7 +1839,7 @@ function createApiClient({
|
|
|
1819
1839
|
try {
|
|
1820
1840
|
uploadId = createMultiPartUpload.uploadId;
|
|
1821
1841
|
const parts = splitFileIntoParts(attachment.file);
|
|
1822
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1842
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _18 => _18.aborted])) {
|
|
1823
1843
|
throw abortError;
|
|
1824
1844
|
}
|
|
1825
1845
|
const batches = chunk(parts, 5);
|
|
@@ -1846,7 +1866,7 @@ function createApiClient({
|
|
|
1846
1866
|
}
|
|
1847
1867
|
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
1848
1868
|
}
|
|
1849
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1869
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _19 => _19.aborted])) {
|
|
1850
1870
|
throw abortError;
|
|
1851
1871
|
}
|
|
1852
1872
|
const sortedUploadedParts = uploadedParts.sort(
|
|
@@ -1862,7 +1882,7 @@ function createApiClient({
|
|
|
1862
1882
|
{ signal: abortSignal }
|
|
1863
1883
|
);
|
|
1864
1884
|
} catch (error3) {
|
|
1865
|
-
if (uploadId && _optionalChain([error3, 'optionalAccess',
|
|
1885
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _20 => _20.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
1866
1886
|
try {
|
|
1867
1887
|
await httpClient.rawDelete(
|
|
1868
1888
|
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
@@ -2191,14 +2211,14 @@ function createApiClient({
|
|
|
2191
2211
|
async function getInboxNotifications(options) {
|
|
2192
2212
|
const PAGE_SIZE = 50;
|
|
2193
2213
|
let query;
|
|
2194
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2214
|
+
if (_optionalChain([options, 'optionalAccess', _21 => _21.query])) {
|
|
2195
2215
|
query = objectToQuery(options.query);
|
|
2196
2216
|
}
|
|
2197
2217
|
const json = await httpClient.get(
|
|
2198
2218
|
url`/v2/c/inbox-notifications`,
|
|
2199
2219
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2200
2220
|
{
|
|
2201
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2221
|
+
cursor: _optionalChain([options, 'optionalAccess', _22 => _22.cursor]),
|
|
2202
2222
|
limit: PAGE_SIZE,
|
|
2203
2223
|
query
|
|
2204
2224
|
}
|
|
@@ -2217,7 +2237,7 @@ function createApiClient({
|
|
|
2217
2237
|
}
|
|
2218
2238
|
async function getInboxNotificationsSince(options) {
|
|
2219
2239
|
let query;
|
|
2220
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2240
|
+
if (_optionalChain([options, 'optionalAccess', _23 => _23.query])) {
|
|
2221
2241
|
query = objectToQuery(options.query);
|
|
2222
2242
|
}
|
|
2223
2243
|
const json = await httpClient.get(
|
|
@@ -2246,14 +2266,14 @@ function createApiClient({
|
|
|
2246
2266
|
}
|
|
2247
2267
|
async function getUnreadInboxNotificationsCount(options) {
|
|
2248
2268
|
let query;
|
|
2249
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2269
|
+
if (_optionalChain([options, 'optionalAccess', _24 => _24.query])) {
|
|
2250
2270
|
query = objectToQuery(options.query);
|
|
2251
2271
|
}
|
|
2252
2272
|
const { count } = await httpClient.get(
|
|
2253
2273
|
url`/v2/c/inbox-notifications/count`,
|
|
2254
2274
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2255
2275
|
{ query },
|
|
2256
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2276
|
+
{ signal: _optionalChain([options, 'optionalAccess', _25 => _25.signal]) }
|
|
2257
2277
|
);
|
|
2258
2278
|
return count;
|
|
2259
2279
|
}
|
|
@@ -2303,7 +2323,7 @@ function createApiClient({
|
|
|
2303
2323
|
url`/v2/c/notification-settings`,
|
|
2304
2324
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2305
2325
|
void 0,
|
|
2306
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2326
|
+
{ signal: _optionalChain([options, 'optionalAccess', _26 => _26.signal]) }
|
|
2307
2327
|
);
|
|
2308
2328
|
}
|
|
2309
2329
|
async function updateNotificationSettings(settings) {
|
|
@@ -2315,7 +2335,7 @@ function createApiClient({
|
|
|
2315
2335
|
}
|
|
2316
2336
|
async function getUserThreads_experimental(options) {
|
|
2317
2337
|
let query;
|
|
2318
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2338
|
+
if (_optionalChain([options, 'optionalAccess', _27 => _27.query])) {
|
|
2319
2339
|
query = objectToQuery(options.query);
|
|
2320
2340
|
}
|
|
2321
2341
|
const PAGE_SIZE = 50;
|
|
@@ -2323,7 +2343,7 @@ function createApiClient({
|
|
|
2323
2343
|
url`/v2/c/threads`,
|
|
2324
2344
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2325
2345
|
{
|
|
2326
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2346
|
+
cursor: _optionalChain([options, 'optionalAccess', _28 => _28.cursor]),
|
|
2327
2347
|
query,
|
|
2328
2348
|
limit: PAGE_SIZE
|
|
2329
2349
|
}
|
|
@@ -2399,6 +2419,7 @@ function createApiClient({
|
|
|
2399
2419
|
// Room threads
|
|
2400
2420
|
getThreads,
|
|
2401
2421
|
getThreadsSince,
|
|
2422
|
+
searchComments,
|
|
2402
2423
|
createThread,
|
|
2403
2424
|
getThread,
|
|
2404
2425
|
deleteThread,
|
|
@@ -2498,7 +2519,7 @@ var HttpClient = class {
|
|
|
2498
2519
|
// These headers are default, but can be overriden by custom headers
|
|
2499
2520
|
"Content-Type": "application/json; charset=utf-8",
|
|
2500
2521
|
// Possible header overrides
|
|
2501
|
-
..._optionalChain([options, 'optionalAccess',
|
|
2522
|
+
..._optionalChain([options, 'optionalAccess', _29 => _29.headers]),
|
|
2502
2523
|
// Cannot be overriden by custom headers
|
|
2503
2524
|
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
2504
2525
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
@@ -2955,7 +2976,7 @@ var FSM = class {
|
|
|
2955
2976
|
});
|
|
2956
2977
|
}
|
|
2957
2978
|
#getTargetFn(eventName) {
|
|
2958
|
-
return _optionalChain([this, 'access',
|
|
2979
|
+
return _optionalChain([this, 'access', _30 => _30.#allowedTransitions, 'access', _31 => _31.get, 'call', _32 => _32(this.currentState), 'optionalAccess', _33 => _33.get, 'call', _34 => _34(eventName)]);
|
|
2959
2980
|
}
|
|
2960
2981
|
/**
|
|
2961
2982
|
* Exits the current state, and executes any necessary cleanup functions.
|
|
@@ -2972,7 +2993,7 @@ var FSM = class {
|
|
|
2972
2993
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
2973
2994
|
levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
|
|
2974
2995
|
for (let i = 0; i < levels; i++) {
|
|
2975
|
-
_optionalChain([this, 'access',
|
|
2996
|
+
_optionalChain([this, 'access', _35 => _35.#cleanupStack, 'access', _36 => _36.pop, 'call', _37 => _37(), 'optionalCall', _38 => _38(patchableContext)]);
|
|
2976
2997
|
}
|
|
2977
2998
|
});
|
|
2978
2999
|
}
|
|
@@ -2988,7 +3009,7 @@ var FSM = class {
|
|
|
2988
3009
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
2989
3010
|
for (const pattern of enterPatterns) {
|
|
2990
3011
|
const enterFn = this.#enterFns.get(pattern);
|
|
2991
|
-
const cleanupFn = _optionalChain([enterFn, 'optionalCall',
|
|
3012
|
+
const cleanupFn = _optionalChain([enterFn, 'optionalCall', _39 => _39(patchableContext)]);
|
|
2992
3013
|
if (typeof cleanupFn === "function") {
|
|
2993
3014
|
this.#cleanupStack.push(cleanupFn);
|
|
2994
3015
|
} else {
|
|
@@ -3177,12 +3198,12 @@ function log(level, message) {
|
|
|
3177
3198
|
function logPrematureErrorOrCloseEvent(e) {
|
|
3178
3199
|
const conn = "Connection to Liveblocks websocket server";
|
|
3179
3200
|
return (ctx) => {
|
|
3180
|
-
if (e
|
|
3181
|
-
warn(`${conn} could not be established. ${String(e)}`);
|
|
3182
|
-
} else {
|
|
3201
|
+
if (isCloseEvent(e)) {
|
|
3183
3202
|
warn(
|
|
3184
|
-
|
|
3203
|
+
`${conn} closed prematurely (code: ${e.code}). Retrying in ${ctx.backoffDelay}ms.`
|
|
3185
3204
|
);
|
|
3205
|
+
} else {
|
|
3206
|
+
warn(`${conn} could not be established.`, e);
|
|
3186
3207
|
}
|
|
3187
3208
|
};
|
|
3188
3209
|
}
|
|
@@ -3382,7 +3403,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3382
3403
|
}
|
|
3383
3404
|
function waitForActorId(event) {
|
|
3384
3405
|
const serverMsg = tryParseJson(event.data);
|
|
3385
|
-
if (_optionalChain([serverMsg, 'optionalAccess',
|
|
3406
|
+
if (_optionalChain([serverMsg, 'optionalAccess', _40 => _40.type]) === 104 /* ROOM_STATE */) {
|
|
3386
3407
|
didReceiveActor();
|
|
3387
3408
|
}
|
|
3388
3409
|
}
|
|
@@ -3491,12 +3512,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3491
3512
|
const sendHeartbeat = {
|
|
3492
3513
|
target: "@ok.awaiting-pong",
|
|
3493
3514
|
effect: (ctx) => {
|
|
3494
|
-
_optionalChain([ctx, 'access',
|
|
3515
|
+
_optionalChain([ctx, 'access', _41 => _41.socket, 'optionalAccess', _42 => _42.send, 'call', _43 => _43("ping")]);
|
|
3495
3516
|
}
|
|
3496
3517
|
};
|
|
3497
3518
|
const maybeHeartbeat = () => {
|
|
3498
3519
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
3499
|
-
const canZombie = _optionalChain([doc, 'optionalAccess',
|
|
3520
|
+
const canZombie = _optionalChain([doc, 'optionalAccess', _44 => _44.visibilityState]) === "hidden" && delegates.canZombie();
|
|
3500
3521
|
return canZombie ? "@idle.zombie" : sendHeartbeat;
|
|
3501
3522
|
};
|
|
3502
3523
|
machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
|
|
@@ -3535,7 +3556,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3535
3556
|
// socket, or not. So always check to see if the socket is still OPEN or
|
|
3536
3557
|
// not. When still OPEN, don't transition.
|
|
3537
3558
|
EXPLICIT_SOCKET_ERROR: (_, context) => {
|
|
3538
|
-
if (_optionalChain([context, 'access',
|
|
3559
|
+
if (_optionalChain([context, 'access', _45 => _45.socket, 'optionalAccess', _46 => _46.readyState]) === 1) {
|
|
3539
3560
|
return null;
|
|
3540
3561
|
}
|
|
3541
3562
|
return {
|
|
@@ -3587,17 +3608,17 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3587
3608
|
machine.send({ type: "NAVIGATOR_ONLINE" });
|
|
3588
3609
|
}
|
|
3589
3610
|
function onVisibilityChange() {
|
|
3590
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
3611
|
+
if (_optionalChain([doc, 'optionalAccess', _47 => _47.visibilityState]) === "visible") {
|
|
3591
3612
|
machine.send({ type: "WINDOW_GOT_FOCUS" });
|
|
3592
3613
|
}
|
|
3593
3614
|
}
|
|
3594
|
-
_optionalChain([win, 'optionalAccess',
|
|
3595
|
-
_optionalChain([win, 'optionalAccess',
|
|
3596
|
-
_optionalChain([root, 'optionalAccess',
|
|
3615
|
+
_optionalChain([win, 'optionalAccess', _48 => _48.addEventListener, 'call', _49 => _49("online", onNetworkBackOnline)]);
|
|
3616
|
+
_optionalChain([win, 'optionalAccess', _50 => _50.addEventListener, 'call', _51 => _51("offline", onNetworkOffline)]);
|
|
3617
|
+
_optionalChain([root, 'optionalAccess', _52 => _52.addEventListener, 'call', _53 => _53("visibilitychange", onVisibilityChange)]);
|
|
3597
3618
|
return () => {
|
|
3598
|
-
_optionalChain([root, 'optionalAccess',
|
|
3599
|
-
_optionalChain([win, 'optionalAccess',
|
|
3600
|
-
_optionalChain([win, 'optionalAccess',
|
|
3619
|
+
_optionalChain([root, 'optionalAccess', _54 => _54.removeEventListener, 'call', _55 => _55("visibilitychange", onVisibilityChange)]);
|
|
3620
|
+
_optionalChain([win, 'optionalAccess', _56 => _56.removeEventListener, 'call', _57 => _57("online", onNetworkBackOnline)]);
|
|
3621
|
+
_optionalChain([win, 'optionalAccess', _58 => _58.removeEventListener, 'call', _59 => _59("offline", onNetworkOffline)]);
|
|
3601
3622
|
teardownSocket(ctx.socket);
|
|
3602
3623
|
};
|
|
3603
3624
|
});
|
|
@@ -3686,7 +3707,7 @@ var ManagedSocket = class {
|
|
|
3686
3707
|
* message if this is somehow impossible.
|
|
3687
3708
|
*/
|
|
3688
3709
|
send(data) {
|
|
3689
|
-
const socket = _optionalChain([this, 'access',
|
|
3710
|
+
const socket = _optionalChain([this, 'access', _60 => _60.#machine, 'access', _61 => _61.context, 'optionalAccess', _62 => _62.socket]);
|
|
3690
3711
|
if (socket === null) {
|
|
3691
3712
|
warn("Cannot send: not connected yet", data);
|
|
3692
3713
|
} else if (socket.readyState !== 1) {
|
|
@@ -4183,7 +4204,7 @@ function createStore_forKnowledge() {
|
|
|
4183
4204
|
}
|
|
4184
4205
|
function getKnowledgeForChat(chatId) {
|
|
4185
4206
|
const globalKnowledge = knowledgeByChatId.getOrCreate(kWILDCARD).get();
|
|
4186
|
-
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access',
|
|
4207
|
+
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access', _63 => _63.get, 'call', _64 => _64(chatId), 'optionalAccess', _65 => _65.get, 'call', _66 => _66()]), () => ( []));
|
|
4187
4208
|
return [...globalKnowledge, ...scopedKnowledge];
|
|
4188
4209
|
}
|
|
4189
4210
|
return {
|
|
@@ -4208,7 +4229,7 @@ function createStore_forTools() {
|
|
|
4208
4229
|
return DerivedSignal.from(() => {
|
|
4209
4230
|
return (
|
|
4210
4231
|
// A tool that's registered and scoped to a specific chat ID...
|
|
4211
|
-
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess',
|
|
4232
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _67 => _67.get, 'call', _68 => _68()]), () => ( // ...or a globally registered tool
|
|
4212
4233
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
4213
4234
|
);
|
|
4214
4235
|
});
|
|
@@ -4238,8 +4259,8 @@ function createStore_forTools() {
|
|
|
4238
4259
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
4239
4260
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
4240
4261
|
return Array.from([
|
|
4241
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
4242
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
4262
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _69 => _69.entries, 'call', _70 => _70()]), () => ( [])),
|
|
4263
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _71 => _71.entries, 'call', _72 => _72()]), () => ( []))
|
|
4243
4264
|
]).flatMap(([name, tool\u03A3]) => {
|
|
4244
4265
|
const tool = tool\u03A3.get();
|
|
4245
4266
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -4342,7 +4363,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4342
4363
|
} else {
|
|
4343
4364
|
continue;
|
|
4344
4365
|
}
|
|
4345
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
4366
|
+
const executeFn = _optionalChain([toolsStore, 'access', _73 => _73.getTool\u03A3, 'call', _74 => _74(toolInvocation.name, message.chatId), 'access', _75 => _75.get, 'call', _76 => _76(), 'optionalAccess', _77 => _77.execute]);
|
|
4346
4367
|
if (executeFn) {
|
|
4347
4368
|
(async () => {
|
|
4348
4369
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -4441,8 +4462,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4441
4462
|
const spine = [];
|
|
4442
4463
|
let lastVisitedMessage = null;
|
|
4443
4464
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4444
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4445
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4465
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _78 => _78(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _79 => _79.id]), () => ( null));
|
|
4466
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _80 => _80(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _81 => _81.id]), () => ( null));
|
|
4446
4467
|
if (!message2.deletedAt || prev || next) {
|
|
4447
4468
|
const node = {
|
|
4448
4469
|
...message2,
|
|
@@ -4508,7 +4529,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4508
4529
|
const latest = pool.sorted.findRight(
|
|
4509
4530
|
(m) => m.role === "assistant" && !m.deletedAt
|
|
4510
4531
|
);
|
|
4511
|
-
return _optionalChain([latest, 'optionalAccess',
|
|
4532
|
+
return _optionalChain([latest, 'optionalAccess', _82 => _82.copilotId]);
|
|
4512
4533
|
}
|
|
4513
4534
|
return {
|
|
4514
4535
|
// Readers
|
|
@@ -4539,11 +4560,11 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4539
4560
|
*getAutoExecutingMessageIds() {
|
|
4540
4561
|
for (const messageId of myMessages) {
|
|
4541
4562
|
const message = getMessageById(messageId);
|
|
4542
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
4563
|
+
if (_optionalChain([message, 'optionalAccess', _83 => _83.role]) === "assistant" && message.status === "awaiting-tool") {
|
|
4543
4564
|
const isAutoExecuting = message.contentSoFar.some((part) => {
|
|
4544
4565
|
if (part.type === "tool-invocation" && part.stage === "executing") {
|
|
4545
4566
|
const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
|
|
4546
|
-
return typeof _optionalChain([tool, 'optionalAccess',
|
|
4567
|
+
return typeof _optionalChain([tool, 'optionalAccess', _84 => _84.execute]) === "function";
|
|
4547
4568
|
}
|
|
4548
4569
|
return false;
|
|
4549
4570
|
});
|
|
@@ -4691,7 +4712,7 @@ function createAi(config) {
|
|
|
4691
4712
|
flushPendingDeltas();
|
|
4692
4713
|
switch (msg.event) {
|
|
4693
4714
|
case "cmd-failed":
|
|
4694
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4715
|
+
_optionalChain([pendingCmd, 'optionalAccess', _85 => _85.reject, 'call', _86 => _86(new Error(msg.error))]);
|
|
4695
4716
|
break;
|
|
4696
4717
|
case "settle": {
|
|
4697
4718
|
context.messagesStore.upsert(msg.message);
|
|
@@ -4768,7 +4789,7 @@ function createAi(config) {
|
|
|
4768
4789
|
return assertNever(msg, "Unhandled case");
|
|
4769
4790
|
}
|
|
4770
4791
|
}
|
|
4771
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4792
|
+
_optionalChain([pendingCmd, 'optionalAccess', _87 => _87.resolve, 'call', _88 => _88(msg)]);
|
|
4772
4793
|
}
|
|
4773
4794
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
4774
4795
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -4844,9 +4865,9 @@ function createAi(config) {
|
|
|
4844
4865
|
invocationId,
|
|
4845
4866
|
result,
|
|
4846
4867
|
generationOptions: {
|
|
4847
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4848
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4849
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4868
|
+
copilotId: _optionalChain([options, 'optionalAccess', _89 => _89.copilotId]),
|
|
4869
|
+
stream: _optionalChain([options, 'optionalAccess', _90 => _90.stream]),
|
|
4870
|
+
timeout: _optionalChain([options, 'optionalAccess', _91 => _91.timeout]),
|
|
4850
4871
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4851
4872
|
// from the global context
|
|
4852
4873
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -4864,7 +4885,7 @@ function createAi(config) {
|
|
|
4864
4885
|
}
|
|
4865
4886
|
}
|
|
4866
4887
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
4867
|
-
_optionalChain([win, 'optionalAccess',
|
|
4888
|
+
_optionalChain([win, 'optionalAccess', _92 => _92.addEventListener, 'call', _93 => _93("beforeunload", handleBeforeUnload, { once: true })]);
|
|
4868
4889
|
return Object.defineProperty(
|
|
4869
4890
|
{
|
|
4870
4891
|
[kInternal]: {
|
|
@@ -4883,7 +4904,7 @@ function createAi(config) {
|
|
|
4883
4904
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
4884
4905
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
4885
4906
|
const knowledge = context.knowledgeStore.getKnowledgeForChat(chatId);
|
|
4886
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
4907
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _94 => _94.knowledge]) || [];
|
|
4887
4908
|
const combinedKnowledge = [...knowledge, ...requestKnowledge];
|
|
4888
4909
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4889
4910
|
messagesStore.markMine(targetMessageId);
|
|
@@ -4893,9 +4914,9 @@ function createAi(config) {
|
|
|
4893
4914
|
sourceMessage: userMessage,
|
|
4894
4915
|
targetMessageId,
|
|
4895
4916
|
generationOptions: {
|
|
4896
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4897
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4898
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4917
|
+
copilotId: _optionalChain([options, 'optionalAccess', _95 => _95.copilotId]),
|
|
4918
|
+
stream: _optionalChain([options, 'optionalAccess', _96 => _96.stream]),
|
|
4919
|
+
timeout: _optionalChain([options, 'optionalAccess', _97 => _97.timeout]),
|
|
4899
4920
|
// Combine global knowledge with request-specific knowledge
|
|
4900
4921
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
4901
4922
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -4967,7 +4988,7 @@ function replaceOrAppend(content, newItem, keyFn, now2) {
|
|
|
4967
4988
|
}
|
|
4968
4989
|
}
|
|
4969
4990
|
function closePart(prevPart, endedAt) {
|
|
4970
|
-
if (_optionalChain([prevPart, 'optionalAccess',
|
|
4991
|
+
if (_optionalChain([prevPart, 'optionalAccess', _98 => _98.type]) === "reasoning") {
|
|
4971
4992
|
prevPart.endedAt ??= endedAt;
|
|
4972
4993
|
}
|
|
4973
4994
|
}
|
|
@@ -4982,7 +5003,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
4982
5003
|
const lastPart = parts[parts.length - 1];
|
|
4983
5004
|
switch (delta.type) {
|
|
4984
5005
|
case "text-delta":
|
|
4985
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5006
|
+
if (_optionalChain([lastPart, 'optionalAccess', _99 => _99.type]) === "text") {
|
|
4986
5007
|
lastPart.text += delta.textDelta;
|
|
4987
5008
|
} else {
|
|
4988
5009
|
closePart(lastPart, now2);
|
|
@@ -4990,7 +5011,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
4990
5011
|
}
|
|
4991
5012
|
break;
|
|
4992
5013
|
case "reasoning-delta":
|
|
4993
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5014
|
+
if (_optionalChain([lastPart, 'optionalAccess', _100 => _100.type]) === "reasoning") {
|
|
4994
5015
|
lastPart.text += delta.textDelta;
|
|
4995
5016
|
} else {
|
|
4996
5017
|
closePart(lastPart, now2);
|
|
@@ -5010,8 +5031,8 @@ function patchContentWithDelta(content, delta) {
|
|
|
5010
5031
|
break;
|
|
5011
5032
|
}
|
|
5012
5033
|
case "tool-delta": {
|
|
5013
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5014
|
-
_optionalChain([lastPart, 'access',
|
|
5034
|
+
if (_optionalChain([lastPart, 'optionalAccess', _101 => _101.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
5035
|
+
_optionalChain([lastPart, 'access', _102 => _102.__appendDelta, 'optionalCall', _103 => _103(delta.delta)]);
|
|
5015
5036
|
}
|
|
5016
5037
|
break;
|
|
5017
5038
|
}
|
|
@@ -5125,7 +5146,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5125
5146
|
return void 0;
|
|
5126
5147
|
}
|
|
5127
5148
|
async function makeAuthRequest(options) {
|
|
5128
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
5149
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _104 => _104.polyfills, 'optionalAccess', _105 => _105.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
5129
5150
|
if (authentication.type === "private") {
|
|
5130
5151
|
if (fetcher === void 0) {
|
|
5131
5152
|
throw new StopRetrying(
|
|
@@ -5141,7 +5162,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5141
5162
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
5142
5163
|
);
|
|
5143
5164
|
}
|
|
5144
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5165
|
+
_optionalChain([onAuthenticate, 'optionalCall', _106 => _106(parsed.parsed)]);
|
|
5145
5166
|
return parsed;
|
|
5146
5167
|
}
|
|
5147
5168
|
if (authentication.type === "custom") {
|
|
@@ -5149,7 +5170,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5149
5170
|
if (response && typeof response === "object") {
|
|
5150
5171
|
if (typeof response.token === "string") {
|
|
5151
5172
|
const parsed = parseAuthToken(response.token);
|
|
5152
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5173
|
+
_optionalChain([onAuthenticate, 'optionalCall', _107 => _107(parsed.parsed)]);
|
|
5153
5174
|
return parsed;
|
|
5154
5175
|
} else if (typeof response.error === "string") {
|
|
5155
5176
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -5308,7 +5329,7 @@ function sendToPanel(message, options) {
|
|
|
5308
5329
|
...message,
|
|
5309
5330
|
source: "liveblocks-devtools-client"
|
|
5310
5331
|
};
|
|
5311
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
5332
|
+
if (!(_optionalChain([options, 'optionalAccess', _108 => _108.force]) || _bridgeActive)) {
|
|
5312
5333
|
return;
|
|
5313
5334
|
}
|
|
5314
5335
|
window.postMessage(fullMsg, "*");
|
|
@@ -5316,7 +5337,7 @@ function sendToPanel(message, options) {
|
|
|
5316
5337
|
var eventSource = makeEventSource();
|
|
5317
5338
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
5318
5339
|
window.addEventListener("message", (event) => {
|
|
5319
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
5340
|
+
if (event.source === window && _optionalChain([event, 'access', _109 => _109.data, 'optionalAccess', _110 => _110.source]) === "liveblocks-devtools-panel") {
|
|
5320
5341
|
eventSource.notify(event.data);
|
|
5321
5342
|
} else {
|
|
5322
5343
|
}
|
|
@@ -5458,7 +5479,7 @@ function fullSync(room) {
|
|
|
5458
5479
|
msg: "room::sync::full",
|
|
5459
5480
|
roomId: room.id,
|
|
5460
5481
|
status: room.getStatus(),
|
|
5461
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
5482
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _111 => _111.toTreeNode, 'call', _112 => _112("root"), 'access', _113 => _113.payload]), () => ( null)),
|
|
5462
5483
|
me,
|
|
5463
5484
|
others
|
|
5464
5485
|
});
|
|
@@ -5765,7 +5786,7 @@ function createManagedPool(roomId, options) {
|
|
|
5765
5786
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
5766
5787
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
5767
5788
|
dispatch(ops, reverse, storageUpdates) {
|
|
5768
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
5789
|
+
_optionalChain([onDispatch, 'optionalCall', _114 => _114(ops, reverse, storageUpdates)]);
|
|
5769
5790
|
},
|
|
5770
5791
|
assertStorageIsWritable: () => {
|
|
5771
5792
|
if (!isStorageWritable()) {
|
|
@@ -5959,12 +5980,6 @@ var CrdtType = /* @__PURE__ */ ((CrdtType2) => {
|
|
|
5959
5980
|
CrdtType2[CrdtType2["REGISTER"] = 3] = "REGISTER";
|
|
5960
5981
|
return CrdtType2;
|
|
5961
5982
|
})(CrdtType || {});
|
|
5962
|
-
function isRootCrdt(crdt) {
|
|
5963
|
-
return crdt.type === 0 /* OBJECT */ && !isChildCrdt(crdt);
|
|
5964
|
-
}
|
|
5965
|
-
function isChildCrdt(crdt) {
|
|
5966
|
-
return crdt.parentId !== void 0 && crdt.parentKey !== void 0;
|
|
5967
|
-
}
|
|
5968
5983
|
|
|
5969
5984
|
// src/crdts/LiveRegister.ts
|
|
5970
5985
|
var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
@@ -5992,7 +6007,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
5992
6007
|
return [
|
|
5993
6008
|
{
|
|
5994
6009
|
type: 8 /* CREATE_REGISTER */,
|
|
5995
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
6010
|
+
opId: _optionalChain([pool, 'optionalAccess', _115 => _115.generateOpId, 'call', _116 => _116()]),
|
|
5996
6011
|
id: this._id,
|
|
5997
6012
|
parentId,
|
|
5998
6013
|
parentKey,
|
|
@@ -6098,7 +6113,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6098
6113
|
const ops = [];
|
|
6099
6114
|
const op = {
|
|
6100
6115
|
id: this._id,
|
|
6101
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
6116
|
+
opId: _optionalChain([pool, 'optionalAccess', _117 => _117.generateOpId, 'call', _118 => _118()]),
|
|
6102
6117
|
type: 2 /* CREATE_LIST */,
|
|
6103
6118
|
parentId,
|
|
6104
6119
|
parentKey
|
|
@@ -6369,7 +6384,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6369
6384
|
#applyInsertUndoRedo(op) {
|
|
6370
6385
|
const { id, parentKey: key } = op;
|
|
6371
6386
|
const child = creationOpToLiveNode(op);
|
|
6372
|
-
if (_optionalChain([this, 'access',
|
|
6387
|
+
if (_optionalChain([this, 'access', _119 => _119._pool, 'optionalAccess', _120 => _120.getNode, 'call', _121 => _121(id)]) !== void 0) {
|
|
6373
6388
|
return { modified: false };
|
|
6374
6389
|
}
|
|
6375
6390
|
child._attach(id, nn(this._pool));
|
|
@@ -6377,8 +6392,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6377
6392
|
const existingItemIndex = this._indexOfPosition(key);
|
|
6378
6393
|
let newKey = key;
|
|
6379
6394
|
if (existingItemIndex !== -1) {
|
|
6380
|
-
const before2 = _optionalChain([this, 'access',
|
|
6381
|
-
const after2 = _optionalChain([this, 'access',
|
|
6395
|
+
const before2 = _optionalChain([this, 'access', _122 => _122.#items, 'access', _123 => _123[existingItemIndex], 'optionalAccess', _124 => _124._parentPos]);
|
|
6396
|
+
const after2 = _optionalChain([this, 'access', _125 => _125.#items, 'access', _126 => _126[existingItemIndex + 1], 'optionalAccess', _127 => _127._parentPos]);
|
|
6382
6397
|
newKey = makePosition(before2, after2);
|
|
6383
6398
|
child._setParentLink(this, newKey);
|
|
6384
6399
|
}
|
|
@@ -6392,7 +6407,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6392
6407
|
#applySetUndoRedo(op) {
|
|
6393
6408
|
const { id, parentKey: key } = op;
|
|
6394
6409
|
const child = creationOpToLiveNode(op);
|
|
6395
|
-
if (_optionalChain([this, 'access',
|
|
6410
|
+
if (_optionalChain([this, 'access', _128 => _128._pool, 'optionalAccess', _129 => _129.getNode, 'call', _130 => _130(id)]) !== void 0) {
|
|
6396
6411
|
return { modified: false };
|
|
6397
6412
|
}
|
|
6398
6413
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -6513,7 +6528,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6513
6528
|
} else {
|
|
6514
6529
|
this.#items[existingItemIndex]._setParentLink(
|
|
6515
6530
|
this,
|
|
6516
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6531
|
+
makePosition(newKey, _optionalChain([this, 'access', _131 => _131.#items, 'access', _132 => _132[existingItemIndex + 1], 'optionalAccess', _133 => _133._parentPos]))
|
|
6517
6532
|
);
|
|
6518
6533
|
const previousIndex = this.#items.indexOf(child);
|
|
6519
6534
|
child._setParentLink(this, newKey);
|
|
@@ -6538,7 +6553,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6538
6553
|
if (existingItemIndex !== -1) {
|
|
6539
6554
|
this.#items[existingItemIndex]._setParentLink(
|
|
6540
6555
|
this,
|
|
6541
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6556
|
+
makePosition(newKey, _optionalChain([this, 'access', _134 => _134.#items, 'access', _135 => _135[existingItemIndex + 1], 'optionalAccess', _136 => _136._parentPos]))
|
|
6542
6557
|
);
|
|
6543
6558
|
}
|
|
6544
6559
|
child._setParentLink(this, newKey);
|
|
@@ -6557,7 +6572,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6557
6572
|
if (existingItemIndex !== -1) {
|
|
6558
6573
|
this.#items[existingItemIndex]._setParentLink(
|
|
6559
6574
|
this,
|
|
6560
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6575
|
+
makePosition(newKey, _optionalChain([this, 'access', _137 => _137.#items, 'access', _138 => _138[existingItemIndex + 1], 'optionalAccess', _139 => _139._parentPos]))
|
|
6561
6576
|
);
|
|
6562
6577
|
}
|
|
6563
6578
|
child._setParentLink(this, newKey);
|
|
@@ -6585,7 +6600,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6585
6600
|
if (existingItemIndex !== -1) {
|
|
6586
6601
|
actualNewKey = makePosition(
|
|
6587
6602
|
newKey,
|
|
6588
|
-
_optionalChain([this, 'access',
|
|
6603
|
+
_optionalChain([this, 'access', _140 => _140.#items, 'access', _141 => _141[existingItemIndex + 1], 'optionalAccess', _142 => _142._parentPos])
|
|
6589
6604
|
);
|
|
6590
6605
|
}
|
|
6591
6606
|
child._setParentLink(this, actualNewKey);
|
|
@@ -6643,7 +6658,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6643
6658
|
* @param element The element to add to the end of the LiveList.
|
|
6644
6659
|
*/
|
|
6645
6660
|
push(element) {
|
|
6646
|
-
_optionalChain([this, 'access',
|
|
6661
|
+
_optionalChain([this, 'access', _143 => _143._pool, 'optionalAccess', _144 => _144.assertStorageIsWritable, 'call', _145 => _145()]);
|
|
6647
6662
|
return this.insert(element, this.length);
|
|
6648
6663
|
}
|
|
6649
6664
|
/**
|
|
@@ -6652,7 +6667,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6652
6667
|
* @param index The index at which you want to insert the element.
|
|
6653
6668
|
*/
|
|
6654
6669
|
insert(element, index) {
|
|
6655
|
-
_optionalChain([this, 'access',
|
|
6670
|
+
_optionalChain([this, 'access', _146 => _146._pool, 'optionalAccess', _147 => _147.assertStorageIsWritable, 'call', _148 => _148()]);
|
|
6656
6671
|
if (index < 0 || index > this.#items.length) {
|
|
6657
6672
|
throw new Error(
|
|
6658
6673
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -6682,7 +6697,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6682
6697
|
* @param targetIndex The index where the element should be after moving.
|
|
6683
6698
|
*/
|
|
6684
6699
|
move(index, targetIndex) {
|
|
6685
|
-
_optionalChain([this, 'access',
|
|
6700
|
+
_optionalChain([this, 'access', _149 => _149._pool, 'optionalAccess', _150 => _150.assertStorageIsWritable, 'call', _151 => _151()]);
|
|
6686
6701
|
if (targetIndex < 0) {
|
|
6687
6702
|
throw new Error("targetIndex cannot be less than 0");
|
|
6688
6703
|
}
|
|
@@ -6740,7 +6755,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6740
6755
|
* @param index The index of the element to delete
|
|
6741
6756
|
*/
|
|
6742
6757
|
delete(index) {
|
|
6743
|
-
_optionalChain([this, 'access',
|
|
6758
|
+
_optionalChain([this, 'access', _152 => _152._pool, 'optionalAccess', _153 => _153.assertStorageIsWritable, 'call', _154 => _154()]);
|
|
6744
6759
|
if (index < 0 || index >= this.#items.length) {
|
|
6745
6760
|
throw new Error(
|
|
6746
6761
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6773,7 +6788,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6773
6788
|
}
|
|
6774
6789
|
}
|
|
6775
6790
|
clear() {
|
|
6776
|
-
_optionalChain([this, 'access',
|
|
6791
|
+
_optionalChain([this, 'access', _155 => _155._pool, 'optionalAccess', _156 => _156.assertStorageIsWritable, 'call', _157 => _157()]);
|
|
6777
6792
|
if (this._pool) {
|
|
6778
6793
|
const ops = [];
|
|
6779
6794
|
const reverseOps = [];
|
|
@@ -6807,7 +6822,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6807
6822
|
}
|
|
6808
6823
|
}
|
|
6809
6824
|
set(index, item) {
|
|
6810
|
-
_optionalChain([this, 'access',
|
|
6825
|
+
_optionalChain([this, 'access', _158 => _158._pool, 'optionalAccess', _159 => _159.assertStorageIsWritable, 'call', _160 => _160()]);
|
|
6811
6826
|
if (index < 0 || index >= this.#items.length) {
|
|
6812
6827
|
throw new Error(
|
|
6813
6828
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6953,7 +6968,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6953
6968
|
#shiftItemPosition(index, key) {
|
|
6954
6969
|
const shiftedPosition = makePosition(
|
|
6955
6970
|
key,
|
|
6956
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
6971
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _161 => _161.#items, 'access', _162 => _162[index + 1], 'optionalAccess', _163 => _163._parentPos]) : void 0
|
|
6957
6972
|
);
|
|
6958
6973
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
6959
6974
|
}
|
|
@@ -7078,7 +7093,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7078
7093
|
const ops = [];
|
|
7079
7094
|
const op = {
|
|
7080
7095
|
id: this._id,
|
|
7081
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
7096
|
+
opId: _optionalChain([pool, 'optionalAccess', _164 => _164.generateOpId, 'call', _165 => _165()]),
|
|
7082
7097
|
type: 7 /* CREATE_MAP */,
|
|
7083
7098
|
parentId,
|
|
7084
7099
|
parentKey
|
|
@@ -7218,7 +7233,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7218
7233
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
7219
7234
|
*/
|
|
7220
7235
|
set(key, value) {
|
|
7221
|
-
_optionalChain([this, 'access',
|
|
7236
|
+
_optionalChain([this, 'access', _166 => _166._pool, 'optionalAccess', _167 => _167.assertStorageIsWritable, 'call', _168 => _168()]);
|
|
7222
7237
|
const oldValue = this.#map.get(key);
|
|
7223
7238
|
if (oldValue) {
|
|
7224
7239
|
oldValue._detach();
|
|
@@ -7264,7 +7279,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7264
7279
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
7265
7280
|
*/
|
|
7266
7281
|
delete(key) {
|
|
7267
|
-
_optionalChain([this, 'access',
|
|
7282
|
+
_optionalChain([this, 'access', _169 => _169._pool, 'optionalAccess', _170 => _170.assertStorageIsWritable, 'call', _171 => _171()]);
|
|
7268
7283
|
const item = this.#map.get(key);
|
|
7269
7284
|
if (item === void 0) {
|
|
7270
7285
|
return false;
|
|
@@ -7399,6 +7414,9 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7399
7414
|
|
|
7400
7415
|
// src/crdts/LiveObject.ts
|
|
7401
7416
|
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
7417
|
+
function isRootCrdt(id, _) {
|
|
7418
|
+
return id === "root";
|
|
7419
|
+
}
|
|
7402
7420
|
var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
7403
7421
|
#map;
|
|
7404
7422
|
#propToLastUpdate;
|
|
@@ -7416,8 +7434,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7416
7434
|
const parentToChildren = /* @__PURE__ */ new Map();
|
|
7417
7435
|
let root = null;
|
|
7418
7436
|
for (const [id, crdt] of items) {
|
|
7419
|
-
if (isRootCrdt(crdt)) {
|
|
7420
|
-
root =
|
|
7437
|
+
if (isRootCrdt(id, crdt)) {
|
|
7438
|
+
root = crdt;
|
|
7421
7439
|
} else {
|
|
7422
7440
|
const tuple = [id, crdt];
|
|
7423
7441
|
const children = parentToChildren.get(crdt.parentId);
|
|
@@ -7437,7 +7455,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7437
7455
|
static _fromItems(items, pool) {
|
|
7438
7456
|
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(items);
|
|
7439
7457
|
return _LiveObject._deserialize(
|
|
7440
|
-
root,
|
|
7458
|
+
["root", root],
|
|
7441
7459
|
parentToChildren,
|
|
7442
7460
|
pool
|
|
7443
7461
|
);
|
|
@@ -7459,7 +7477,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7459
7477
|
if (this._id === void 0) {
|
|
7460
7478
|
throw new Error("Cannot serialize item is not attached");
|
|
7461
7479
|
}
|
|
7462
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
7480
|
+
const opId = _optionalChain([pool, 'optionalAccess', _172 => _172.generateOpId, 'call', _173 => _173()]);
|
|
7463
7481
|
const ops = [];
|
|
7464
7482
|
const op = {
|
|
7465
7483
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -7733,7 +7751,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7733
7751
|
* @param value The value of the property to add
|
|
7734
7752
|
*/
|
|
7735
7753
|
set(key, value) {
|
|
7736
|
-
_optionalChain([this, 'access',
|
|
7754
|
+
_optionalChain([this, 'access', _174 => _174._pool, 'optionalAccess', _175 => _175.assertStorageIsWritable, 'call', _176 => _176()]);
|
|
7737
7755
|
this.update({ [key]: value });
|
|
7738
7756
|
}
|
|
7739
7757
|
/**
|
|
@@ -7748,7 +7766,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7748
7766
|
* @param key The key of the property to delete
|
|
7749
7767
|
*/
|
|
7750
7768
|
delete(key) {
|
|
7751
|
-
_optionalChain([this, 'access',
|
|
7769
|
+
_optionalChain([this, 'access', _177 => _177._pool, 'optionalAccess', _178 => _178.assertStorageIsWritable, 'call', _179 => _179()]);
|
|
7752
7770
|
const keyAsString = key;
|
|
7753
7771
|
const oldValue = this.#map.get(keyAsString);
|
|
7754
7772
|
if (oldValue === void 0) {
|
|
@@ -7803,7 +7821,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7803
7821
|
* @param patch The object used to overrides properties
|
|
7804
7822
|
*/
|
|
7805
7823
|
update(patch) {
|
|
7806
|
-
_optionalChain([this, 'access',
|
|
7824
|
+
_optionalChain([this, 'access', _180 => _180._pool, 'optionalAccess', _181 => _181.assertStorageIsWritable, 'call', _182 => _182()]);
|
|
7807
7825
|
if (_LiveObject.detectLargeObjects) {
|
|
7808
7826
|
const data = {};
|
|
7809
7827
|
for (const [key, value] of this.#map) {
|
|
@@ -8541,15 +8559,15 @@ function installBackgroundTabSpy() {
|
|
|
8541
8559
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8542
8560
|
const inBackgroundSince = { current: null };
|
|
8543
8561
|
function onVisibilityChange() {
|
|
8544
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
8562
|
+
if (_optionalChain([doc, 'optionalAccess', _183 => _183.visibilityState]) === "hidden") {
|
|
8545
8563
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
8546
8564
|
} else {
|
|
8547
8565
|
inBackgroundSince.current = null;
|
|
8548
8566
|
}
|
|
8549
8567
|
}
|
|
8550
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8568
|
+
_optionalChain([doc, 'optionalAccess', _184 => _184.addEventListener, 'call', _185 => _185("visibilitychange", onVisibilityChange)]);
|
|
8551
8569
|
const unsub = () => {
|
|
8552
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8570
|
+
_optionalChain([doc, 'optionalAccess', _186 => _186.removeEventListener, 'call', _187 => _187("visibilitychange", onVisibilityChange)]);
|
|
8553
8571
|
};
|
|
8554
8572
|
return [inBackgroundSince, unsub];
|
|
8555
8573
|
}
|
|
@@ -8717,7 +8735,7 @@ function createRoom(options, config) {
|
|
|
8717
8735
|
}
|
|
8718
8736
|
}
|
|
8719
8737
|
function isStorageWritable() {
|
|
8720
|
-
const scopes = _optionalChain([context, 'access',
|
|
8738
|
+
const scopes = _optionalChain([context, 'access', _188 => _188.dynamicSessionInfoSig, 'access', _189 => _189.get, 'call', _190 => _190(), 'optionalAccess', _191 => _191.scopes]);
|
|
8721
8739
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
8722
8740
|
}
|
|
8723
8741
|
const eventHub = {
|
|
@@ -8848,7 +8866,7 @@ function createRoom(options, config) {
|
|
|
8848
8866
|
// be stuck in "synchronizing" forever).
|
|
8849
8867
|
case "experimental-fallback-to-http": {
|
|
8850
8868
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
8851
|
-
const nonce = _nullishCoalesce(_optionalChain([context, 'access',
|
|
8869
|
+
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _192 => _192.dynamicSessionInfoSig, 'access', _193 => _193.get, 'call', _194 => _194(), 'optionalAccess', _195 => _195.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
8852
8870
|
void httpClient.sendMessagesOverHTTP({ roomId, nonce, messages }).then((resp) => {
|
|
8853
8871
|
if (!resp.ok && resp.status === 403) {
|
|
8854
8872
|
managedSocket.reconnect();
|
|
@@ -8903,7 +8921,7 @@ function createRoom(options, config) {
|
|
|
8903
8921
|
} else {
|
|
8904
8922
|
context.root = LiveObject._fromItems(message.items, context.pool);
|
|
8905
8923
|
}
|
|
8906
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
8924
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _196 => _196.get, 'call', _197 => _197(), 'optionalAccess', _198 => _198.canWrite]), () => ( true));
|
|
8907
8925
|
const stackSizeBefore = context.undoStack.length;
|
|
8908
8926
|
for (const key in context.initialStorage) {
|
|
8909
8927
|
if (context.root.get(key) === void 0) {
|
|
@@ -9103,7 +9121,7 @@ function createRoom(options, config) {
|
|
|
9103
9121
|
}
|
|
9104
9122
|
context.myPresence.patch(patch);
|
|
9105
9123
|
if (context.activeBatch) {
|
|
9106
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
9124
|
+
if (_optionalChain([options2, 'optionalAccess', _199 => _199.addToHistory])) {
|
|
9107
9125
|
context.activeBatch.reverseOps.pushLeft({
|
|
9108
9126
|
type: "presence",
|
|
9109
9127
|
data: oldValues
|
|
@@ -9112,7 +9130,7 @@ function createRoom(options, config) {
|
|
|
9112
9130
|
context.activeBatch.updates.presence = true;
|
|
9113
9131
|
} else {
|
|
9114
9132
|
flushNowOrSoon();
|
|
9115
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
9133
|
+
if (_optionalChain([options2, 'optionalAccess', _200 => _200.addToHistory])) {
|
|
9116
9134
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
9117
9135
|
}
|
|
9118
9136
|
notify({ presence: true });
|
|
@@ -9296,6 +9314,22 @@ function createRoom(options, config) {
|
|
|
9296
9314
|
}
|
|
9297
9315
|
break;
|
|
9298
9316
|
}
|
|
9317
|
+
// Receiving a RejectedOps message in the client means that the server is no
|
|
9318
|
+
// longer in sync with the client. Trying to synchronize the client again by
|
|
9319
|
+
// rolling back particular Ops may be hard/impossible. It's fine to not try and
|
|
9320
|
+
// accept the out-of-sync reality and throw an error.
|
|
9321
|
+
case 299 /* REJECT_STORAGE_OP */: {
|
|
9322
|
+
errorWithTitle(
|
|
9323
|
+
"Storage mutation rejection error",
|
|
9324
|
+
message.reason
|
|
9325
|
+
);
|
|
9326
|
+
if (process.env.NODE_ENV !== "production") {
|
|
9327
|
+
throw new Error(
|
|
9328
|
+
`Storage mutations rejected by server: ${message.reason}`
|
|
9329
|
+
);
|
|
9330
|
+
}
|
|
9331
|
+
break;
|
|
9332
|
+
}
|
|
9299
9333
|
case 400 /* THREAD_CREATED */:
|
|
9300
9334
|
case 407 /* THREAD_DELETED */:
|
|
9301
9335
|
case 401 /* THREAD_METADATA_UPDATED */:
|
|
@@ -9413,7 +9447,7 @@ function createRoom(options, config) {
|
|
|
9413
9447
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
9414
9448
|
createOrUpdateRootFromMessage(message);
|
|
9415
9449
|
applyAndSendOps(unacknowledgedOps);
|
|
9416
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
9450
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _201 => _201()]);
|
|
9417
9451
|
notifyStorageStatus();
|
|
9418
9452
|
eventHub.storageDidLoad.notify();
|
|
9419
9453
|
}
|
|
@@ -9634,8 +9668,8 @@ function createRoom(options, config) {
|
|
|
9634
9668
|
async function getThreads(options2) {
|
|
9635
9669
|
return httpClient.getThreads({
|
|
9636
9670
|
roomId,
|
|
9637
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
9638
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
9671
|
+
query: _optionalChain([options2, 'optionalAccess', _202 => _202.query]),
|
|
9672
|
+
cursor: _optionalChain([options2, 'optionalAccess', _203 => _203.cursor])
|
|
9639
9673
|
});
|
|
9640
9674
|
}
|
|
9641
9675
|
async function getThread(threadId) {
|
|
@@ -9742,7 +9776,7 @@ function createRoom(options, config) {
|
|
|
9742
9776
|
function getSubscriptionSettings(options2) {
|
|
9743
9777
|
return httpClient.getSubscriptionSettings({
|
|
9744
9778
|
roomId,
|
|
9745
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
9779
|
+
signal: _optionalChain([options2, 'optionalAccess', _204 => _204.signal])
|
|
9746
9780
|
});
|
|
9747
9781
|
}
|
|
9748
9782
|
function updateSubscriptionSettings(settings) {
|
|
@@ -9764,7 +9798,7 @@ function createRoom(options, config) {
|
|
|
9764
9798
|
{
|
|
9765
9799
|
[kInternal]: {
|
|
9766
9800
|
get presenceBuffer() {
|
|
9767
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
9801
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _205 => _205.buffer, 'access', _206 => _206.presenceUpdates, 'optionalAccess', _207 => _207.data]), () => ( null)));
|
|
9768
9802
|
},
|
|
9769
9803
|
// prettier-ignore
|
|
9770
9804
|
get undoStack() {
|
|
@@ -9779,9 +9813,9 @@ function createRoom(options, config) {
|
|
|
9779
9813
|
return context.yjsProvider;
|
|
9780
9814
|
},
|
|
9781
9815
|
setYjsProvider(newProvider) {
|
|
9782
|
-
_optionalChain([context, 'access',
|
|
9816
|
+
_optionalChain([context, 'access', _208 => _208.yjsProvider, 'optionalAccess', _209 => _209.off, 'call', _210 => _210("status", yjsStatusDidChange)]);
|
|
9783
9817
|
context.yjsProvider = newProvider;
|
|
9784
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
9818
|
+
_optionalChain([newProvider, 'optionalAccess', _211 => _211.on, 'call', _212 => _212("status", yjsStatusDidChange)]);
|
|
9785
9819
|
context.yjsProviderDidChange.notify();
|
|
9786
9820
|
},
|
|
9787
9821
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -9827,7 +9861,7 @@ function createRoom(options, config) {
|
|
|
9827
9861
|
source.dispose();
|
|
9828
9862
|
}
|
|
9829
9863
|
eventHub.roomWillDestroy.notify();
|
|
9830
|
-
_optionalChain([context, 'access',
|
|
9864
|
+
_optionalChain([context, 'access', _213 => _213.yjsProvider, 'optionalAccess', _214 => _214.off, 'call', _215 => _215("status", yjsStatusDidChange)]);
|
|
9831
9865
|
syncSourceForStorage.destroy();
|
|
9832
9866
|
syncSourceForYjs.destroy();
|
|
9833
9867
|
uninstallBgTabSpy();
|
|
@@ -9977,7 +10011,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
9977
10011
|
}
|
|
9978
10012
|
if (isLiveNode(first)) {
|
|
9979
10013
|
const node = first;
|
|
9980
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10014
|
+
if (_optionalChain([options, 'optionalAccess', _216 => _216.isDeep])) {
|
|
9981
10015
|
const storageCallback = second;
|
|
9982
10016
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
9983
10017
|
} else {
|
|
@@ -10057,8 +10091,8 @@ function createClient(options) {
|
|
|
10057
10091
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
10058
10092
|
currentUserId.set(() => userId);
|
|
10059
10093
|
});
|
|
10060
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
10061
|
-
_optionalChain([globalThis, 'access',
|
|
10094
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _217 => _217.polyfills, 'optionalAccess', _218 => _218.fetch]) || /* istanbul ignore next */
|
|
10095
|
+
_optionalChain([globalThis, 'access', _219 => _219.fetch, 'optionalAccess', _220 => _220.bind, 'call', _221 => _221(globalThis)]);
|
|
10062
10096
|
const httpClient = createApiClient({
|
|
10063
10097
|
baseUrl,
|
|
10064
10098
|
fetchPolyfill,
|
|
@@ -10076,7 +10110,7 @@ function createClient(options) {
|
|
|
10076
10110
|
delegates: {
|
|
10077
10111
|
createSocket: makeCreateSocketDelegateForAi(
|
|
10078
10112
|
baseUrl,
|
|
10079
|
-
_optionalChain([clientOptions, 'access',
|
|
10113
|
+
_optionalChain([clientOptions, 'access', _222 => _222.polyfills, 'optionalAccess', _223 => _223.WebSocket])
|
|
10080
10114
|
),
|
|
10081
10115
|
authenticate: async () => {
|
|
10082
10116
|
const resp = await authManager.getAuthValue({
|
|
@@ -10138,7 +10172,7 @@ function createClient(options) {
|
|
|
10138
10172
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
10139
10173
|
roomId,
|
|
10140
10174
|
baseUrl,
|
|
10141
|
-
_optionalChain([clientOptions, 'access',
|
|
10175
|
+
_optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket])
|
|
10142
10176
|
),
|
|
10143
10177
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
10144
10178
|
})),
|
|
@@ -10161,7 +10195,7 @@ function createClient(options) {
|
|
|
10161
10195
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
10162
10196
|
if (shouldConnect) {
|
|
10163
10197
|
if (typeof atob === "undefined") {
|
|
10164
|
-
if (_optionalChain([clientOptions, 'access',
|
|
10198
|
+
if (_optionalChain([clientOptions, 'access', _226 => _226.polyfills, 'optionalAccess', _227 => _227.atob]) === void 0) {
|
|
10165
10199
|
throw new Error(
|
|
10166
10200
|
"You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill"
|
|
10167
10201
|
);
|
|
@@ -10173,7 +10207,7 @@ function createClient(options) {
|
|
|
10173
10207
|
return leaseRoom(newRoomDetails);
|
|
10174
10208
|
}
|
|
10175
10209
|
function getRoom(roomId) {
|
|
10176
|
-
const room = _optionalChain([roomsById, 'access',
|
|
10210
|
+
const room = _optionalChain([roomsById, 'access', _228 => _228.get, 'call', _229 => _229(roomId), 'optionalAccess', _230 => _230.room]);
|
|
10177
10211
|
return room ? room : null;
|
|
10178
10212
|
}
|
|
10179
10213
|
function logout() {
|
|
@@ -10189,7 +10223,7 @@ function createClient(options) {
|
|
|
10189
10223
|
const batchedResolveUsers = new Batch(
|
|
10190
10224
|
async (batchedUserIds) => {
|
|
10191
10225
|
const userIds = batchedUserIds.flat();
|
|
10192
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
10226
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _231 => _231({ userIds })]);
|
|
10193
10227
|
warnOnceIf(
|
|
10194
10228
|
!resolveUsers,
|
|
10195
10229
|
"Set the resolveUsers option in createClient to specify user info."
|
|
@@ -10206,7 +10240,7 @@ function createClient(options) {
|
|
|
10206
10240
|
const batchedResolveRoomsInfo = new Batch(
|
|
10207
10241
|
async (batchedRoomIds) => {
|
|
10208
10242
|
const roomIds = batchedRoomIds.flat();
|
|
10209
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
10243
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _232 => _232({ roomIds })]);
|
|
10210
10244
|
warnOnceIf(
|
|
10211
10245
|
!resolveRoomsInfo,
|
|
10212
10246
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
@@ -10223,7 +10257,7 @@ function createClient(options) {
|
|
|
10223
10257
|
const batchedResolveGroupsInfo = new Batch(
|
|
10224
10258
|
async (batchedGroupIds) => {
|
|
10225
10259
|
const groupIds = batchedGroupIds.flat();
|
|
10226
|
-
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall',
|
|
10260
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _233 => _233({ groupIds })]);
|
|
10227
10261
|
warnOnceIf(
|
|
10228
10262
|
!resolveGroupsInfo,
|
|
10229
10263
|
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
@@ -10279,7 +10313,7 @@ function createClient(options) {
|
|
|
10279
10313
|
}
|
|
10280
10314
|
};
|
|
10281
10315
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10282
|
-
_optionalChain([win, 'optionalAccess',
|
|
10316
|
+
_optionalChain([win, 'optionalAccess', _234 => _234.addEventListener, 'call', _235 => _235("beforeunload", maybePreventClose)]);
|
|
10283
10317
|
}
|
|
10284
10318
|
async function getNotificationSettings(options2) {
|
|
10285
10319
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -10406,7 +10440,7 @@ var commentBodyElementsTypes = {
|
|
|
10406
10440
|
mention: "inline"
|
|
10407
10441
|
};
|
|
10408
10442
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
10409
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
10443
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _236 => _236.content])) {
|
|
10410
10444
|
return;
|
|
10411
10445
|
}
|
|
10412
10446
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -10416,13 +10450,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
10416
10450
|
for (const block of body.content) {
|
|
10417
10451
|
if (type === "all" || type === "block") {
|
|
10418
10452
|
if (guard(block)) {
|
|
10419
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10453
|
+
_optionalChain([visitor, 'optionalCall', _237 => _237(block)]);
|
|
10420
10454
|
}
|
|
10421
10455
|
}
|
|
10422
10456
|
if (type === "all" || type === "inline") {
|
|
10423
10457
|
for (const inline of block.children) {
|
|
10424
10458
|
if (guard(inline)) {
|
|
10425
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10459
|
+
_optionalChain([visitor, 'optionalCall', _238 => _238(inline)]);
|
|
10426
10460
|
}
|
|
10427
10461
|
}
|
|
10428
10462
|
}
|
|
@@ -10592,7 +10626,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
10592
10626
|
text: ({ element }) => element.text,
|
|
10593
10627
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
10594
10628
|
mention: ({ element, user, group }) => {
|
|
10595
|
-
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10629
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _239 => _239.name]), () => ( _optionalChain([group, 'optionalAccess', _240 => _240.name]))), () => ( element.id))}`;
|
|
10596
10630
|
}
|
|
10597
10631
|
};
|
|
10598
10632
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -10622,7 +10656,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
10622
10656
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
10623
10657
|
},
|
|
10624
10658
|
mention: ({ element, user, group }) => {
|
|
10625
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
10659
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _241 => _241.name]) ? html`${_optionalChain([user, 'optionalAccess', _242 => _242.name])}` : _optionalChain([group, 'optionalAccess', _243 => _243.name]) ? html`${_optionalChain([group, 'optionalAccess', _244 => _244.name])}` : element.id}</span>`;
|
|
10626
10660
|
}
|
|
10627
10661
|
};
|
|
10628
10662
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -10652,20 +10686,20 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
10652
10686
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
10653
10687
|
},
|
|
10654
10688
|
mention: ({ element, user, group }) => {
|
|
10655
|
-
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10689
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _245 => _245.name]), () => ( _optionalChain([group, 'optionalAccess', _246 => _246.name]))), () => ( element.id))}`;
|
|
10656
10690
|
}
|
|
10657
10691
|
};
|
|
10658
10692
|
async function stringifyCommentBody(body, options) {
|
|
10659
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10660
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10693
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _247 => _247.format]), () => ( "plain"));
|
|
10694
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _248 => _248.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
10661
10695
|
const elements = {
|
|
10662
10696
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
10663
|
-
..._optionalChain([options, 'optionalAccess',
|
|
10697
|
+
..._optionalChain([options, 'optionalAccess', _249 => _249.elements])
|
|
10664
10698
|
};
|
|
10665
10699
|
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
10666
10700
|
body,
|
|
10667
|
-
_optionalChain([options, 'optionalAccess',
|
|
10668
|
-
_optionalChain([options, 'optionalAccess',
|
|
10701
|
+
_optionalChain([options, 'optionalAccess', _250 => _250.resolveUsers]),
|
|
10702
|
+
_optionalChain([options, 'optionalAccess', _251 => _251.resolveGroupsInfo])
|
|
10669
10703
|
);
|
|
10670
10704
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
10671
10705
|
switch (block.type) {
|
|
@@ -10952,12 +10986,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10952
10986
|
}
|
|
10953
10987
|
const newState = Object.assign({}, state);
|
|
10954
10988
|
for (const key in update.updates) {
|
|
10955
|
-
if (_optionalChain([update, 'access',
|
|
10989
|
+
if (_optionalChain([update, 'access', _252 => _252.updates, 'access', _253 => _253[key], 'optionalAccess', _254 => _254.type]) === "update") {
|
|
10956
10990
|
const val = update.node.get(key);
|
|
10957
10991
|
if (val !== void 0) {
|
|
10958
10992
|
newState[key] = lsonToJson(val);
|
|
10959
10993
|
}
|
|
10960
|
-
} else if (_optionalChain([update, 'access',
|
|
10994
|
+
} else if (_optionalChain([update, 'access', _255 => _255.updates, 'access', _256 => _256[key], 'optionalAccess', _257 => _257.type]) === "delete") {
|
|
10961
10995
|
delete newState[key];
|
|
10962
10996
|
}
|
|
10963
10997
|
}
|
|
@@ -11018,12 +11052,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
11018
11052
|
}
|
|
11019
11053
|
const newState = Object.assign({}, state);
|
|
11020
11054
|
for (const key in update.updates) {
|
|
11021
|
-
if (_optionalChain([update, 'access',
|
|
11055
|
+
if (_optionalChain([update, 'access', _258 => _258.updates, 'access', _259 => _259[key], 'optionalAccess', _260 => _260.type]) === "update") {
|
|
11022
11056
|
const value = update.node.get(key);
|
|
11023
11057
|
if (value !== void 0) {
|
|
11024
11058
|
newState[key] = lsonToJson(value);
|
|
11025
11059
|
}
|
|
11026
|
-
} else if (_optionalChain([update, 'access',
|
|
11060
|
+
} else if (_optionalChain([update, 'access', _261 => _261.updates, 'access', _262 => _262[key], 'optionalAccess', _263 => _263.type]) === "delete") {
|
|
11027
11061
|
delete newState[key];
|
|
11028
11062
|
}
|
|
11029
11063
|
}
|
|
@@ -11103,9 +11137,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
11103
11137
|
const startTime = performance.now();
|
|
11104
11138
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
11105
11139
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
11106
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11140
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _264 => _264.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
11107
11141
|
const context = {
|
|
11108
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
11142
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _265 => _265.visibilityState]) !== "hidden",
|
|
11109
11143
|
lastSuccessfulPollAt: startTime,
|
|
11110
11144
|
count: 0,
|
|
11111
11145
|
backoff: 0
|
|
@@ -11186,11 +11220,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
11186
11220
|
pollNowIfStale();
|
|
11187
11221
|
}
|
|
11188
11222
|
function onVisibilityChange() {
|
|
11189
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
11223
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _266 => _266.visibilityState]) !== "hidden");
|
|
11190
11224
|
}
|
|
11191
|
-
_optionalChain([doc, 'optionalAccess',
|
|
11192
|
-
_optionalChain([win, 'optionalAccess',
|
|
11193
|
-
_optionalChain([win, 'optionalAccess',
|
|
11225
|
+
_optionalChain([doc, 'optionalAccess', _267 => _267.addEventListener, 'call', _268 => _268("visibilitychange", onVisibilityChange)]);
|
|
11226
|
+
_optionalChain([win, 'optionalAccess', _269 => _269.addEventListener, 'call', _270 => _270("online", onVisibilityChange)]);
|
|
11227
|
+
_optionalChain([win, 'optionalAccess', _271 => _271.addEventListener, 'call', _272 => _272("focus", pollNowIfStale)]);
|
|
11194
11228
|
fsm.start();
|
|
11195
11229
|
return {
|
|
11196
11230
|
inc,
|
|
@@ -11323,7 +11357,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
11323
11357
|
|
|
11324
11358
|
|
|
11325
11359
|
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
11360
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isPlainObject = isPlainObject; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
11329
11361
|
//# sourceMappingURL=index.cjs.map
|