@liveblocks/core 3.23.0-file3 → 3.23.0-file4
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 +231 -191
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -112
- package/dist/index.d.ts +112 -112
- package/dist/index.js +72 -32
- 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.23.0-
|
|
9
|
+
var PKG_VERSION = "3.23.0-file4";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -2362,7 +2362,7 @@ function isUrl(string) {
|
|
|
2362
2362
|
var ROOM_FILE_PART_SIZE = 5 * 1024 * 1024;
|
|
2363
2363
|
var ROOM_FILE_RETRY_ATTEMPTS = 10;
|
|
2364
2364
|
var FILE_URL_EXPIRY_BUFFER = 3e4;
|
|
2365
|
-
var
|
|
2365
|
+
var FILE_URL_ERROR_CACHE_TTL = 1e3;
|
|
2366
2366
|
var FILE_URL_ERROR_MAX_ATTEMPTS = 3;
|
|
2367
2367
|
var FILE_URL_ERROR_ATTEMPTS_EXPIRY = 3e4;
|
|
2368
2368
|
var ROOM_FILE_RETRY_DELAYS = [
|
|
@@ -2377,7 +2377,7 @@ var ROOM_FILE_RETRY_DELAYS = [
|
|
|
2377
2377
|
2e3,
|
|
2378
2378
|
2e3
|
|
2379
2379
|
];
|
|
2380
|
-
var
|
|
2380
|
+
var FileUrlUnavailableError = class extends Error {
|
|
2381
2381
|
};
|
|
2382
2382
|
async function uploadRoomFile({
|
|
2383
2383
|
file,
|
|
@@ -2410,28 +2410,69 @@ async function uploadRoomFile({
|
|
|
2410
2410
|
}
|
|
2411
2411
|
let uploadId;
|
|
2412
2412
|
const uploadedParts = [];
|
|
2413
|
-
const multipartUpload = await
|
|
2413
|
+
const multipartUpload = await autoRetry(
|
|
2414
|
+
createMultipartUpload,
|
|
2415
|
+
ROOM_FILE_RETRY_ATTEMPTS,
|
|
2416
|
+
ROOM_FILE_RETRY_DELAYS,
|
|
2417
|
+
handleRetryError
|
|
2418
|
+
);
|
|
2419
|
+
const partUploadController = new AbortController();
|
|
2420
|
+
const partUploadSignal = partUploadController.signal;
|
|
2421
|
+
const abortPartUploads = (reason) => {
|
|
2422
|
+
partUploadController.abort(reason);
|
|
2423
|
+
};
|
|
2424
|
+
const handleExternalAbort = () => abortPartUploads();
|
|
2425
|
+
if (_optionalChain([signal, 'optionalAccess', _47 => _47.aborted])) {
|
|
2426
|
+
handleExternalAbort();
|
|
2427
|
+
} else {
|
|
2428
|
+
_optionalChain([signal, 'optionalAccess', _48 => _48.addEventListener, 'call', _49 => _49("abort", handleExternalAbort, { once: true })]);
|
|
2429
|
+
}
|
|
2414
2430
|
try {
|
|
2415
2431
|
uploadId = multipartUpload.uploadId;
|
|
2416
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
2432
|
+
if (_optionalChain([signal, 'optionalAccess', _50 => _50.aborted])) {
|
|
2417
2433
|
throw abortError;
|
|
2418
2434
|
}
|
|
2419
2435
|
const batches = chunk(splitFileIntoParts(file), 5);
|
|
2420
2436
|
for (const parts of batches) {
|
|
2421
|
-
const
|
|
2437
|
+
const firstPartUploadFailure = {};
|
|
2438
|
+
const partUploads$ = [];
|
|
2422
2439
|
for (const { part, partNumber } of parts) {
|
|
2423
|
-
|
|
2440
|
+
partUploads$.push(
|
|
2424
2441
|
autoRetry(
|
|
2425
|
-
() => uploadMultipartPart(
|
|
2442
|
+
() => uploadMultipartPart(
|
|
2443
|
+
multipartUpload.uploadId,
|
|
2444
|
+
partNumber,
|
|
2445
|
+
part,
|
|
2446
|
+
partUploadSignal
|
|
2447
|
+
),
|
|
2426
2448
|
ROOM_FILE_RETRY_ATTEMPTS,
|
|
2427
2449
|
ROOM_FILE_RETRY_DELAYS,
|
|
2428
|
-
|
|
2429
|
-
|
|
2450
|
+
(error3) => {
|
|
2451
|
+
if (_optionalChain([signal, 'optionalAccess', _51 => _51.aborted])) {
|
|
2452
|
+
throw abortError;
|
|
2453
|
+
}
|
|
2454
|
+
return partUploadSignal.aborted || handleRetryError(error3);
|
|
2455
|
+
}
|
|
2456
|
+
).catch((error3) => {
|
|
2457
|
+
if (firstPartUploadFailure.value === void 0) {
|
|
2458
|
+
firstPartUploadFailure.value = { error: error3 };
|
|
2459
|
+
abortPartUploads(error3);
|
|
2460
|
+
}
|
|
2461
|
+
throw error3;
|
|
2462
|
+
})
|
|
2430
2463
|
);
|
|
2431
2464
|
}
|
|
2432
|
-
|
|
2465
|
+
const settledPartUploads = await Promise.allSettled(partUploads$);
|
|
2466
|
+
if (firstPartUploadFailure.value !== void 0) {
|
|
2467
|
+
throw firstPartUploadFailure.value.error;
|
|
2468
|
+
}
|
|
2469
|
+
for (const settledPartUpload of settledPartUploads) {
|
|
2470
|
+
if (settledPartUpload.status === "fulfilled") {
|
|
2471
|
+
uploadedParts.push(settledPartUpload.value);
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2433
2474
|
}
|
|
2434
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
2475
|
+
if (_optionalChain([signal, 'optionalAccess', _52 => _52.aborted])) {
|
|
2435
2476
|
throw abortError;
|
|
2436
2477
|
}
|
|
2437
2478
|
const sortedParts = uploadedParts.sort(
|
|
@@ -2451,6 +2492,8 @@ async function uploadRoomFile({
|
|
|
2451
2492
|
}
|
|
2452
2493
|
}
|
|
2453
2494
|
throw error3;
|
|
2495
|
+
} finally {
|
|
2496
|
+
_optionalChain([signal, 'optionalAccess', _53 => _53.removeEventListener, 'call', _54 => _54("abort", handleExternalAbort)]);
|
|
2454
2497
|
}
|
|
2455
2498
|
}
|
|
2456
2499
|
function splitFileIntoParts(file) {
|
|
@@ -2534,7 +2577,7 @@ function createApiClient({
|
|
|
2534
2577
|
url`/v2/c/rooms/${options.roomId}/threads`,
|
|
2535
2578
|
await authManager.getAuthValue({
|
|
2536
2579
|
roomId: options.roomId,
|
|
2537
|
-
resource: commentsResourceForVisibility(_optionalChain([options, 'access',
|
|
2580
|
+
resource: commentsResourceForVisibility(_optionalChain([options, 'access', _55 => _55.query, 'optionalAccess', _56 => _56.visibility])),
|
|
2538
2581
|
access: "read"
|
|
2539
2582
|
}),
|
|
2540
2583
|
{
|
|
@@ -2592,7 +2635,7 @@ function createApiClient({
|
|
|
2592
2635
|
hasMentions: options.query.hasMentions
|
|
2593
2636
|
})
|
|
2594
2637
|
},
|
|
2595
|
-
{ signal: _optionalChain([requestOptions, 'optionalAccess',
|
|
2638
|
+
{ signal: _optionalChain([requestOptions, 'optionalAccess', _57 => _57.signal]) }
|
|
2596
2639
|
);
|
|
2597
2640
|
return result;
|
|
2598
2641
|
}
|
|
@@ -2817,7 +2860,7 @@ function createApiClient({
|
|
|
2817
2860
|
{ signal: options.signal },
|
|
2818
2861
|
{ fileSize: attachment.size }
|
|
2819
2862
|
),
|
|
2820
|
-
uploadMultipartPart: async (uploadId, partNumber, part) => httpClient.putBlob(
|
|
2863
|
+
uploadMultipartPart: async (uploadId, partNumber, part, signal) => httpClient.putBlob(
|
|
2821
2864
|
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}/${String(partNumber)}`,
|
|
2822
2865
|
await authManager.getAuthValue({
|
|
2823
2866
|
roomId,
|
|
@@ -2826,7 +2869,7 @@ function createApiClient({
|
|
|
2826
2869
|
}),
|
|
2827
2870
|
part,
|
|
2828
2871
|
void 0,
|
|
2829
|
-
{ signal
|
|
2872
|
+
{ signal }
|
|
2830
2873
|
),
|
|
2831
2874
|
completeMultipartUpload: async (uploadId, parts) => httpClient.post(
|
|
2832
2875
|
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}/complete`,
|
|
@@ -2881,7 +2924,7 @@ function createApiClient({
|
|
|
2881
2924
|
{ signal: options.signal },
|
|
2882
2925
|
{ fileSize: file.size }
|
|
2883
2926
|
),
|
|
2884
|
-
uploadMultipartPart: async (uploadId, partNumber, part) => httpClient.putBlob(
|
|
2927
|
+
uploadMultipartPart: async (uploadId, partNumber, part, signal) => httpClient.putBlob(
|
|
2885
2928
|
url`/v2/c/rooms/${roomId}/storage/files/${fileId}/multipart/${uploadId}/${String(partNumber)}`,
|
|
2886
2929
|
await authManager.getAuthValue({
|
|
2887
2930
|
roomId,
|
|
@@ -2890,7 +2933,7 @@ function createApiClient({
|
|
|
2890
2933
|
}),
|
|
2891
2934
|
part,
|
|
2892
2935
|
void 0,
|
|
2893
|
-
{ signal
|
|
2936
|
+
{ signal }
|
|
2894
2937
|
),
|
|
2895
2938
|
completeMultipartUpload: async (uploadId, parts) => httpClient.post(
|
|
2896
2939
|
url`/v2/c/rooms/${roomId}/storage/files/${fileId}/multipart/${uploadId}/complete`,
|
|
@@ -2944,28 +2987,28 @@ function createApiClient({
|
|
|
2944
2987
|
return batch2.get(options.attachmentId);
|
|
2945
2988
|
}
|
|
2946
2989
|
const fileUrlsBatchStoresByRoom = new DefaultMap((roomId) => {
|
|
2947
|
-
const
|
|
2948
|
-
const
|
|
2949
|
-
const attempts =
|
|
2990
|
+
const pendingFileUrlAttempts = /* @__PURE__ */ new Map();
|
|
2991
|
+
const clearPendingFileUrlAttempts = (fileId) => {
|
|
2992
|
+
const attempts = pendingFileUrlAttempts.get(fileId);
|
|
2950
2993
|
if (attempts !== void 0) {
|
|
2951
2994
|
clearTimeout(attempts.cleanupTimeoutId);
|
|
2952
|
-
|
|
2995
|
+
pendingFileUrlAttempts.delete(fileId);
|
|
2953
2996
|
}
|
|
2954
2997
|
};
|
|
2955
|
-
const
|
|
2956
|
-
const previousAttempts =
|
|
2998
|
+
const shouldRetryPendingFileUrl = (fileId) => {
|
|
2999
|
+
const previousAttempts = pendingFileUrlAttempts.get(fileId);
|
|
2957
3000
|
if (previousAttempts !== void 0) {
|
|
2958
3001
|
clearTimeout(previousAttempts.cleanupTimeoutId);
|
|
2959
3002
|
}
|
|
2960
|
-
const count = (_nullishCoalesce(_optionalChain([previousAttempts, 'optionalAccess',
|
|
3003
|
+
const count = (_nullishCoalesce(_optionalChain([previousAttempts, 'optionalAccess', _58 => _58.count]), () => ( 0))) + 1;
|
|
2961
3004
|
if (count >= FILE_URL_ERROR_MAX_ATTEMPTS) {
|
|
2962
|
-
|
|
3005
|
+
pendingFileUrlAttempts.delete(fileId);
|
|
2963
3006
|
return false;
|
|
2964
3007
|
}
|
|
2965
|
-
|
|
3008
|
+
pendingFileUrlAttempts.set(fileId, {
|
|
2966
3009
|
count,
|
|
2967
3010
|
cleanupTimeoutId: setTimeout(
|
|
2968
|
-
() =>
|
|
3011
|
+
() => pendingFileUrlAttempts.delete(fileId),
|
|
2969
3012
|
FILE_URL_ERROR_ATTEMPTS_EXPIRY
|
|
2970
3013
|
)
|
|
2971
3014
|
});
|
|
@@ -2986,23 +3029,20 @@ function createApiClient({
|
|
|
2986
3029
|
const expiresAtTimestamp = Date.parse(expiresAt);
|
|
2987
3030
|
return urls.map((url2, index) => {
|
|
2988
3031
|
const fileId = fileIds[index];
|
|
2989
|
-
if (url2
|
|
2990
|
-
|
|
2991
|
-
return { url: url2, expiresAt: expiresAtTimestamp };
|
|
2992
|
-
}
|
|
2993
|
-
if (shouldRetryFileUrlError(fileId)) {
|
|
2994
|
-
return new FileUrlRetryableError(
|
|
3032
|
+
if (url2 === false) {
|
|
3033
|
+
return shouldRetryPendingFileUrl(fileId) ? new FileUrlUnavailableError(
|
|
2995
3034
|
"There was an error while getting this file's URL"
|
|
2996
|
-
);
|
|
3035
|
+
) : new Error("There was an error while getting this file's URL");
|
|
2997
3036
|
}
|
|
2998
|
-
|
|
3037
|
+
clearPendingFileUrlAttempts(fileId);
|
|
3038
|
+
return url2 !== null ? { url: url2, expiresAt: expiresAtTimestamp } : new Error("There was an error while getting this file's URL");
|
|
2999
3039
|
});
|
|
3000
3040
|
},
|
|
3001
3041
|
{ delay: 50 }
|
|
3002
3042
|
);
|
|
3003
3043
|
return createBatchStore(batch2, {
|
|
3004
3044
|
getCacheExpiry: ({ expiresAt }) => expiresAt - FILE_URL_EXPIRY_BUFFER,
|
|
3005
|
-
getErrorCacheExpiry: (error3) => error3 instanceof
|
|
3045
|
+
getErrorCacheExpiry: (error3) => error3 instanceof FileUrlUnavailableError ? Date.now() + FILE_URL_ERROR_CACHE_TTL : void 0
|
|
3006
3046
|
});
|
|
3007
3047
|
});
|
|
3008
3048
|
function getOrCreateFileUrlsStore(roomId) {
|
|
@@ -3220,14 +3260,14 @@ function createApiClient({
|
|
|
3220
3260
|
async function getInboxNotifications(options) {
|
|
3221
3261
|
const PAGE_SIZE = 50;
|
|
3222
3262
|
let query;
|
|
3223
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3263
|
+
if (_optionalChain([options, 'optionalAccess', _59 => _59.query])) {
|
|
3224
3264
|
query = objectToQuery(options.query);
|
|
3225
3265
|
}
|
|
3226
3266
|
const json = await httpClient.get(
|
|
3227
3267
|
url`/v2/c/inbox-notifications`,
|
|
3228
3268
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
3229
3269
|
{
|
|
3230
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
3270
|
+
cursor: _optionalChain([options, 'optionalAccess', _60 => _60.cursor]),
|
|
3231
3271
|
limit: PAGE_SIZE,
|
|
3232
3272
|
query
|
|
3233
3273
|
}
|
|
@@ -3246,7 +3286,7 @@ function createApiClient({
|
|
|
3246
3286
|
}
|
|
3247
3287
|
async function getInboxNotificationsSince(options) {
|
|
3248
3288
|
let query;
|
|
3249
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3289
|
+
if (_optionalChain([options, 'optionalAccess', _61 => _61.query])) {
|
|
3250
3290
|
query = objectToQuery(options.query);
|
|
3251
3291
|
}
|
|
3252
3292
|
const json = await httpClient.get(
|
|
@@ -3275,14 +3315,14 @@ function createApiClient({
|
|
|
3275
3315
|
}
|
|
3276
3316
|
async function getUnreadInboxNotificationsCount(options) {
|
|
3277
3317
|
let query;
|
|
3278
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3318
|
+
if (_optionalChain([options, 'optionalAccess', _62 => _62.query])) {
|
|
3279
3319
|
query = objectToQuery(options.query);
|
|
3280
3320
|
}
|
|
3281
3321
|
const { count } = await httpClient.get(
|
|
3282
3322
|
url`/v2/c/inbox-notifications/count`,
|
|
3283
3323
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
3284
3324
|
{ query },
|
|
3285
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
3325
|
+
{ signal: _optionalChain([options, 'optionalAccess', _63 => _63.signal]) }
|
|
3286
3326
|
);
|
|
3287
3327
|
return count;
|
|
3288
3328
|
}
|
|
@@ -3332,7 +3372,7 @@ function createApiClient({
|
|
|
3332
3372
|
url`/v2/c/notification-settings`,
|
|
3333
3373
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
3334
3374
|
void 0,
|
|
3335
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
3375
|
+
{ signal: _optionalChain([options, 'optionalAccess', _64 => _64.signal]) }
|
|
3336
3376
|
);
|
|
3337
3377
|
}
|
|
3338
3378
|
async function updateNotificationSettings(settings) {
|
|
@@ -3344,7 +3384,7 @@ function createApiClient({
|
|
|
3344
3384
|
}
|
|
3345
3385
|
async function getUserThreads_experimental(options) {
|
|
3346
3386
|
let query;
|
|
3347
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3387
|
+
if (_optionalChain([options, 'optionalAccess', _65 => _65.query])) {
|
|
3348
3388
|
query = objectToQuery(options.query);
|
|
3349
3389
|
}
|
|
3350
3390
|
const PAGE_SIZE = 50;
|
|
@@ -3352,7 +3392,7 @@ function createApiClient({
|
|
|
3352
3392
|
url`/v2/c/threads`,
|
|
3353
3393
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
3354
3394
|
{
|
|
3355
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
3395
|
+
cursor: _optionalChain([options, 'optionalAccess', _66 => _66.cursor]),
|
|
3356
3396
|
query,
|
|
3357
3397
|
limit: PAGE_SIZE
|
|
3358
3398
|
}
|
|
@@ -3531,7 +3571,7 @@ var HttpClient = class {
|
|
|
3531
3571
|
// These headers are default, but can be overriden by custom headers
|
|
3532
3572
|
"Content-Type": "application/json; charset=utf-8",
|
|
3533
3573
|
// Possible header overrides
|
|
3534
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3574
|
+
..._optionalChain([options, 'optionalAccess', _67 => _67.headers]),
|
|
3535
3575
|
// Cannot be overriden by custom headers
|
|
3536
3576
|
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
3537
3577
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
@@ -3539,7 +3579,7 @@ var HttpClient = class {
|
|
|
3539
3579
|
});
|
|
3540
3580
|
const xwarn = response.headers.get("X-LB-Warn");
|
|
3541
3581
|
if (xwarn) {
|
|
3542
|
-
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
3582
|
+
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _68 => _68.method, 'optionalAccess', _69 => _69.toUpperCase, 'call', _70 => _70()]), () => ( "GET"));
|
|
3543
3583
|
const msg = `${xwarn} (${method} ${endpoint})`;
|
|
3544
3584
|
if (response.ok) {
|
|
3545
3585
|
warn(msg);
|
|
@@ -4021,7 +4061,7 @@ var FSM = class {
|
|
|
4021
4061
|
});
|
|
4022
4062
|
}
|
|
4023
4063
|
#getTargetFn(eventName) {
|
|
4024
|
-
return _optionalChain([this, 'access',
|
|
4064
|
+
return _optionalChain([this, 'access', _71 => _71.#allowedTransitions, 'access', _72 => _72.get, 'call', _73 => _73(this.currentState), 'optionalAccess', _74 => _74.get, 'call', _75 => _75(eventName)]);
|
|
4025
4065
|
}
|
|
4026
4066
|
/**
|
|
4027
4067
|
* Exits the current state, and executes any necessary cleanup functions.
|
|
@@ -4040,7 +4080,7 @@ var FSM = class {
|
|
|
4040
4080
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
4041
4081
|
levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
|
|
4042
4082
|
for (let i = 0; i < levels; i++) {
|
|
4043
|
-
_optionalChain([this, 'access',
|
|
4083
|
+
_optionalChain([this, 'access', _76 => _76.#cleanupStack, 'access', _77 => _77.pop, 'call', _78 => _78(), 'optionalCall', _79 => _79(patchableContext)]);
|
|
4044
4084
|
const entryTime = this.#entryTimesStack.pop();
|
|
4045
4085
|
if (entryTime !== void 0 && // ...but avoid computing state names if nobody is listening
|
|
4046
4086
|
this.#eventHub.didExitState.count() > 0) {
|
|
@@ -4068,7 +4108,7 @@ var FSM = class {
|
|
|
4068
4108
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
4069
4109
|
for (const pattern of enterPatterns) {
|
|
4070
4110
|
const enterFn = this.#enterFns.get(pattern);
|
|
4071
|
-
const cleanupFn = _optionalChain([enterFn, 'optionalCall',
|
|
4111
|
+
const cleanupFn = _optionalChain([enterFn, 'optionalCall', _80 => _80(patchableContext)]);
|
|
4072
4112
|
if (typeof cleanupFn === "function") {
|
|
4073
4113
|
this.#cleanupStack.push(cleanupFn);
|
|
4074
4114
|
} else {
|
|
@@ -4495,7 +4535,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
4495
4535
|
}
|
|
4496
4536
|
function waitForActorId(event) {
|
|
4497
4537
|
const serverMsg = tryParseJson(event.data);
|
|
4498
|
-
if (_optionalChain([serverMsg, 'optionalAccess',
|
|
4538
|
+
if (_optionalChain([serverMsg, 'optionalAccess', _81 => _81.type]) === ServerMsgCode.ROOM_STATE) {
|
|
4499
4539
|
if (options.enableDebugLogging && socketOpenAt !== null) {
|
|
4500
4540
|
const elapsed = performance.now() - socketOpenAt;
|
|
4501
4541
|
warn(
|
|
@@ -4623,12 +4663,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
4623
4663
|
const sendHeartbeat = {
|
|
4624
4664
|
target: "@ok.awaiting-pong",
|
|
4625
4665
|
effect: (ctx) => {
|
|
4626
|
-
_optionalChain([ctx, 'access',
|
|
4666
|
+
_optionalChain([ctx, 'access', _82 => _82.socket, 'optionalAccess', _83 => _83.send, 'call', _84 => _84("ping")]);
|
|
4627
4667
|
}
|
|
4628
4668
|
};
|
|
4629
4669
|
const maybeHeartbeat = () => {
|
|
4630
4670
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
4631
|
-
const canZombie = _optionalChain([doc, 'optionalAccess',
|
|
4671
|
+
const canZombie = _optionalChain([doc, 'optionalAccess', _85 => _85.visibilityState]) === "hidden" && delegates.canZombie();
|
|
4632
4672
|
return canZombie ? "@idle.zombie" : sendHeartbeat;
|
|
4633
4673
|
};
|
|
4634
4674
|
machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
|
|
@@ -4668,7 +4708,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
4668
4708
|
// socket, or not. So always check to see if the socket is still OPEN or
|
|
4669
4709
|
// not. When still OPEN, don't transition.
|
|
4670
4710
|
EXPLICIT_SOCKET_ERROR: (_, context) => {
|
|
4671
|
-
if (_optionalChain([context, 'access',
|
|
4711
|
+
if (_optionalChain([context, 'access', _86 => _86.socket, 'optionalAccess', _87 => _87.readyState]) === 1) {
|
|
4672
4712
|
return IGNORE;
|
|
4673
4713
|
}
|
|
4674
4714
|
return {
|
|
@@ -4720,17 +4760,17 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
4720
4760
|
machine.send({ type: "NAVIGATOR_ONLINE" });
|
|
4721
4761
|
}
|
|
4722
4762
|
function onVisibilityChange() {
|
|
4723
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
4763
|
+
if (_optionalChain([doc, 'optionalAccess', _88 => _88.visibilityState]) === "visible") {
|
|
4724
4764
|
machine.send({ type: "WINDOW_GOT_FOCUS" });
|
|
4725
4765
|
}
|
|
4726
4766
|
}
|
|
4727
|
-
_optionalChain([win, 'optionalAccess',
|
|
4728
|
-
_optionalChain([win, 'optionalAccess',
|
|
4729
|
-
_optionalChain([root, 'optionalAccess',
|
|
4767
|
+
_optionalChain([win, 'optionalAccess', _89 => _89.addEventListener, 'call', _90 => _90("online", onNetworkBackOnline)]);
|
|
4768
|
+
_optionalChain([win, 'optionalAccess', _91 => _91.addEventListener, 'call', _92 => _92("offline", onNetworkOffline)]);
|
|
4769
|
+
_optionalChain([root, 'optionalAccess', _93 => _93.addEventListener, 'call', _94 => _94("visibilitychange", onVisibilityChange)]);
|
|
4730
4770
|
return () => {
|
|
4731
|
-
_optionalChain([root, 'optionalAccess',
|
|
4732
|
-
_optionalChain([win, 'optionalAccess',
|
|
4733
|
-
_optionalChain([win, 'optionalAccess',
|
|
4771
|
+
_optionalChain([root, 'optionalAccess', _95 => _95.removeEventListener, 'call', _96 => _96("visibilitychange", onVisibilityChange)]);
|
|
4772
|
+
_optionalChain([win, 'optionalAccess', _97 => _97.removeEventListener, 'call', _98 => _98("online", onNetworkBackOnline)]);
|
|
4773
|
+
_optionalChain([win, 'optionalAccess', _99 => _99.removeEventListener, 'call', _100 => _100("offline", onNetworkOffline)]);
|
|
4734
4774
|
teardownSocket(ctx.socket);
|
|
4735
4775
|
};
|
|
4736
4776
|
});
|
|
@@ -4819,7 +4859,7 @@ var ManagedSocket = class {
|
|
|
4819
4859
|
* message if this is somehow impossible.
|
|
4820
4860
|
*/
|
|
4821
4861
|
send(data) {
|
|
4822
|
-
const socket = _optionalChain([this, 'access',
|
|
4862
|
+
const socket = _optionalChain([this, 'access', _101 => _101.#machine, 'access', _102 => _102.context, 'optionalAccess', _103 => _103.socket]);
|
|
4823
4863
|
if (socket === null) {
|
|
4824
4864
|
warn("Cannot send: not connected yet", data);
|
|
4825
4865
|
} else if (socket.readyState !== 1) {
|
|
@@ -5281,7 +5321,7 @@ function createStore_forKnowledge() {
|
|
|
5281
5321
|
}
|
|
5282
5322
|
function getKnowledgeForChat(chatId) {
|
|
5283
5323
|
const globalKnowledge = knowledgeByChatId.getOrCreate(kWILDCARD).get();
|
|
5284
|
-
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access',
|
|
5324
|
+
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access', _104 => _104.get, 'call', _105 => _105(chatId), 'optionalAccess', _106 => _106.get, 'call', _107 => _107()]), () => ( []));
|
|
5285
5325
|
return [...globalKnowledge, ...scopedKnowledge];
|
|
5286
5326
|
}
|
|
5287
5327
|
return {
|
|
@@ -5306,7 +5346,7 @@ function createStore_forTools() {
|
|
|
5306
5346
|
return DerivedSignal.from(() => {
|
|
5307
5347
|
return (
|
|
5308
5348
|
// A tool that's registered and scoped to a specific chat ID...
|
|
5309
|
-
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess',
|
|
5349
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _108 => _108.get, 'call', _109 => _109()]), () => ( // ...or a globally registered tool
|
|
5310
5350
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
5311
5351
|
);
|
|
5312
5352
|
});
|
|
@@ -5336,8 +5376,8 @@ function createStore_forTools() {
|
|
|
5336
5376
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
5337
5377
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
5338
5378
|
return Array.from([
|
|
5339
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
5340
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
5379
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _110 => _110.entries, 'call', _111 => _111()]), () => ( [])),
|
|
5380
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _112 => _112.entries, 'call', _113 => _113()]), () => ( []))
|
|
5341
5381
|
]).flatMap(([name, tool\u03A3]) => {
|
|
5342
5382
|
const tool = tool\u03A3.get();
|
|
5343
5383
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -5440,7 +5480,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
5440
5480
|
} else {
|
|
5441
5481
|
continue;
|
|
5442
5482
|
}
|
|
5443
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
5483
|
+
const executeFn = _optionalChain([toolsStore, 'access', _114 => _114.getTool\u03A3, 'call', _115 => _115(toolInvocation.name, message.chatId), 'access', _116 => _116.get, 'call', _117 => _117(), 'optionalAccess', _118 => _118.execute]);
|
|
5444
5484
|
if (executeFn) {
|
|
5445
5485
|
(async () => {
|
|
5446
5486
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -5539,8 +5579,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
5539
5579
|
const spine = [];
|
|
5540
5580
|
let lastVisitedMessage = null;
|
|
5541
5581
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
5542
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
5543
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
5582
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _119 => _119(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _120 => _120.id]), () => ( null));
|
|
5583
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _121 => _121(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _122 => _122.id]), () => ( null));
|
|
5544
5584
|
if (!message2.deletedAt || prev || next) {
|
|
5545
5585
|
const node = {
|
|
5546
5586
|
...message2,
|
|
@@ -5606,7 +5646,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
5606
5646
|
const latest = pool.sorted.findRight(
|
|
5607
5647
|
(m) => m.role === "assistant" && !m.deletedAt
|
|
5608
5648
|
);
|
|
5609
|
-
return _optionalChain([latest, 'optionalAccess',
|
|
5649
|
+
return _optionalChain([latest, 'optionalAccess', _123 => _123.copilotId]);
|
|
5610
5650
|
}
|
|
5611
5651
|
return {
|
|
5612
5652
|
// Readers
|
|
@@ -5637,11 +5677,11 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
5637
5677
|
*getAutoExecutingMessageIds() {
|
|
5638
5678
|
for (const messageId of myMessages) {
|
|
5639
5679
|
const message = getMessageById(messageId);
|
|
5640
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
5680
|
+
if (_optionalChain([message, 'optionalAccess', _124 => _124.role]) === "assistant" && message.status === "awaiting-tool") {
|
|
5641
5681
|
const isAutoExecuting = message.contentSoFar.some((part) => {
|
|
5642
5682
|
if (part.type === "tool-invocation" && part.stage === "executing") {
|
|
5643
5683
|
const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
|
|
5644
|
-
return typeof _optionalChain([tool, 'optionalAccess',
|
|
5684
|
+
return typeof _optionalChain([tool, 'optionalAccess', _125 => _125.execute]) === "function";
|
|
5645
5685
|
}
|
|
5646
5686
|
return false;
|
|
5647
5687
|
});
|
|
@@ -5789,7 +5829,7 @@ function createAi(config) {
|
|
|
5789
5829
|
flushPendingDeltas();
|
|
5790
5830
|
switch (msg.event) {
|
|
5791
5831
|
case "cmd-failed":
|
|
5792
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
5832
|
+
_optionalChain([pendingCmd, 'optionalAccess', _126 => _126.reject, 'call', _127 => _127(new Error(msg.error))]);
|
|
5793
5833
|
break;
|
|
5794
5834
|
case "settle": {
|
|
5795
5835
|
context.messagesStore.upsert(msg.message);
|
|
@@ -5866,7 +5906,7 @@ function createAi(config) {
|
|
|
5866
5906
|
return assertNever(msg, "Unhandled case");
|
|
5867
5907
|
}
|
|
5868
5908
|
}
|
|
5869
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
5909
|
+
_optionalChain([pendingCmd, 'optionalAccess', _128 => _128.resolve, 'call', _129 => _129(msg)]);
|
|
5870
5910
|
}
|
|
5871
5911
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
5872
5912
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -5942,9 +5982,9 @@ function createAi(config) {
|
|
|
5942
5982
|
invocationId,
|
|
5943
5983
|
result,
|
|
5944
5984
|
generationOptions: {
|
|
5945
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
5946
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
5947
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
5985
|
+
copilotId: _optionalChain([options, 'optionalAccess', _130 => _130.copilotId]),
|
|
5986
|
+
stream: _optionalChain([options, 'optionalAccess', _131 => _131.stream]),
|
|
5987
|
+
timeout: _optionalChain([options, 'optionalAccess', _132 => _132.timeout]),
|
|
5948
5988
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
5949
5989
|
// from the global context
|
|
5950
5990
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -5962,7 +6002,7 @@ function createAi(config) {
|
|
|
5962
6002
|
}
|
|
5963
6003
|
}
|
|
5964
6004
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
5965
|
-
_optionalChain([win, 'optionalAccess',
|
|
6005
|
+
_optionalChain([win, 'optionalAccess', _133 => _133.addEventListener, 'call', _134 => _134("beforeunload", handleBeforeUnload, { once: true })]);
|
|
5966
6006
|
return Object.defineProperty(
|
|
5967
6007
|
{
|
|
5968
6008
|
[kInternal]: {
|
|
@@ -5981,7 +6021,7 @@ function createAi(config) {
|
|
|
5981
6021
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
5982
6022
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
5983
6023
|
const knowledge = context.knowledgeStore.getKnowledgeForChat(chatId);
|
|
5984
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
6024
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _135 => _135.knowledge]) || [];
|
|
5985
6025
|
const combinedKnowledge = [...knowledge, ...requestKnowledge];
|
|
5986
6026
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
5987
6027
|
messagesStore.markMine(targetMessageId);
|
|
@@ -5991,9 +6031,9 @@ function createAi(config) {
|
|
|
5991
6031
|
sourceMessage: userMessage,
|
|
5992
6032
|
targetMessageId,
|
|
5993
6033
|
generationOptions: {
|
|
5994
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
5995
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
5996
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
6034
|
+
copilotId: _optionalChain([options, 'optionalAccess', _136 => _136.copilotId]),
|
|
6035
|
+
stream: _optionalChain([options, 'optionalAccess', _137 => _137.stream]),
|
|
6036
|
+
timeout: _optionalChain([options, 'optionalAccess', _138 => _138.timeout]),
|
|
5997
6037
|
// Combine global knowledge with request-specific knowledge
|
|
5998
6038
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
5999
6039
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -6065,7 +6105,7 @@ function replaceOrAppend(content, newItem, keyFn, now2) {
|
|
|
6065
6105
|
}
|
|
6066
6106
|
}
|
|
6067
6107
|
function closePart(prevPart, endedAt) {
|
|
6068
|
-
if (_optionalChain([prevPart, 'optionalAccess',
|
|
6108
|
+
if (_optionalChain([prevPart, 'optionalAccess', _139 => _139.type]) === "reasoning") {
|
|
6069
6109
|
prevPart.endedAt ??= endedAt;
|
|
6070
6110
|
}
|
|
6071
6111
|
}
|
|
@@ -6080,7 +6120,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
6080
6120
|
const lastPart = parts[parts.length - 1];
|
|
6081
6121
|
switch (delta.type) {
|
|
6082
6122
|
case "text-delta":
|
|
6083
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
6123
|
+
if (_optionalChain([lastPart, 'optionalAccess', _140 => _140.type]) === "text") {
|
|
6084
6124
|
lastPart.text += delta.textDelta;
|
|
6085
6125
|
} else {
|
|
6086
6126
|
closePart(lastPart, now2);
|
|
@@ -6088,7 +6128,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
6088
6128
|
}
|
|
6089
6129
|
break;
|
|
6090
6130
|
case "reasoning-delta":
|
|
6091
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
6131
|
+
if (_optionalChain([lastPart, 'optionalAccess', _141 => _141.type]) === "reasoning") {
|
|
6092
6132
|
lastPart.text += delta.textDelta;
|
|
6093
6133
|
} else {
|
|
6094
6134
|
closePart(lastPart, now2);
|
|
@@ -6108,8 +6148,8 @@ function patchContentWithDelta(content, delta) {
|
|
|
6108
6148
|
break;
|
|
6109
6149
|
}
|
|
6110
6150
|
case "tool-delta": {
|
|
6111
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
6112
|
-
_optionalChain([lastPart, 'access',
|
|
6151
|
+
if (_optionalChain([lastPart, 'optionalAccess', _142 => _142.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
6152
|
+
_optionalChain([lastPart, 'access', _143 => _143.__appendDelta, 'optionalCall', _144 => _144(delta.delta)]);
|
|
6113
6153
|
}
|
|
6114
6154
|
break;
|
|
6115
6155
|
}
|
|
@@ -6464,7 +6504,7 @@ function explicitAccessForResource(source, resource) {
|
|
|
6464
6504
|
}
|
|
6465
6505
|
function permissionForAccessLevel(resource, access, field = resource) {
|
|
6466
6506
|
const permissions = PERMISSIONS_BY_RESOURCE[resource][access];
|
|
6467
|
-
const permission = _optionalChain([permissions, 'optionalAccess',
|
|
6507
|
+
const permission = _optionalChain([permissions, 'optionalAccess', _145 => _145[0]]);
|
|
6468
6508
|
if (permission !== void 0) {
|
|
6469
6509
|
return permission;
|
|
6470
6510
|
}
|
|
@@ -6574,7 +6614,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
6574
6614
|
return void 0;
|
|
6575
6615
|
}
|
|
6576
6616
|
async function makeAuthRequest(options) {
|
|
6577
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
6617
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _146 => _146.polyfills, 'optionalAccess', _147 => _147.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
6578
6618
|
if (authentication.type === "private") {
|
|
6579
6619
|
if (fetcher === void 0) {
|
|
6580
6620
|
throw new StopRetrying(
|
|
@@ -6587,14 +6627,14 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
6587
6627
|
const parsed = parseAuthToken(response.token);
|
|
6588
6628
|
if (seenTokens.has(parsed.raw)) {
|
|
6589
6629
|
const cachedToken = getCachedToken(options);
|
|
6590
|
-
if (_optionalChain([cachedToken, 'optionalAccess',
|
|
6630
|
+
if (_optionalChain([cachedToken, 'optionalAccess', _148 => _148.raw]) === parsed.raw) {
|
|
6591
6631
|
return cachedToken;
|
|
6592
6632
|
}
|
|
6593
6633
|
throw new StopRetrying(
|
|
6594
6634
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
6595
6635
|
);
|
|
6596
6636
|
}
|
|
6597
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
6637
|
+
_optionalChain([onAuthenticate, 'optionalCall', _149 => _149(parsed.parsed)]);
|
|
6598
6638
|
return parsed;
|
|
6599
6639
|
}
|
|
6600
6640
|
if (authentication.type === "custom") {
|
|
@@ -6602,7 +6642,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
6602
6642
|
if (response && typeof response === "object") {
|
|
6603
6643
|
if (typeof response.token === "string") {
|
|
6604
6644
|
const parsed = parseAuthToken(response.token);
|
|
6605
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
6645
|
+
_optionalChain([onAuthenticate, 'optionalCall', _150 => _150(parsed.parsed)]);
|
|
6606
6646
|
return parsed;
|
|
6607
6647
|
} else if (typeof response.error === "string") {
|
|
6608
6648
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -7302,7 +7342,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7302
7342
|
#applyInsertUndoRedo(op) {
|
|
7303
7343
|
const { id, parentKey: key } = op;
|
|
7304
7344
|
const child = creationOpToLiveNode(op);
|
|
7305
|
-
if (_optionalChain([this, 'access',
|
|
7345
|
+
if (_optionalChain([this, 'access', _151 => _151._pool, 'optionalAccess', _152 => _152.getNode, 'call', _153 => _153(id)]) !== void 0) {
|
|
7306
7346
|
return { modified: false };
|
|
7307
7347
|
}
|
|
7308
7348
|
child._attach(id, nn(this._pool));
|
|
@@ -7310,8 +7350,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7310
7350
|
const existingItemIndex = this._indexOfPosition(key);
|
|
7311
7351
|
let newKey = key;
|
|
7312
7352
|
if (existingItemIndex !== -1) {
|
|
7313
|
-
const before2 = _optionalChain([this, 'access',
|
|
7314
|
-
const after2 = _optionalChain([this, 'access',
|
|
7353
|
+
const before2 = _optionalChain([this, 'access', _154 => _154.#items, 'access', _155 => _155.at, 'call', _156 => _156(existingItemIndex), 'optionalAccess', _157 => _157._parentPos]);
|
|
7354
|
+
const after2 = _optionalChain([this, 'access', _158 => _158.#items, 'access', _159 => _159.at, 'call', _160 => _160(existingItemIndex + 1), 'optionalAccess', _161 => _161._parentPos]);
|
|
7315
7355
|
newKey = makePosition(before2, after2);
|
|
7316
7356
|
child._setParentLink(this, newKey);
|
|
7317
7357
|
}
|
|
@@ -7325,7 +7365,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7325
7365
|
#applySetUndoRedo(op) {
|
|
7326
7366
|
const { id, parentKey: key } = op;
|
|
7327
7367
|
const child = creationOpToLiveNode(op);
|
|
7328
|
-
if (_optionalChain([this, 'access',
|
|
7368
|
+
if (_optionalChain([this, 'access', _162 => _162._pool, 'optionalAccess', _163 => _163.getNode, 'call', _164 => _164(id)]) !== void 0) {
|
|
7329
7369
|
return { modified: false };
|
|
7330
7370
|
}
|
|
7331
7371
|
const indexOfItemWithSameKey = this._indexOfPosition(key);
|
|
@@ -7446,7 +7486,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7446
7486
|
} else {
|
|
7447
7487
|
this.#updateItemPositionAt(
|
|
7448
7488
|
existingItemIndex,
|
|
7449
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
7489
|
+
makePosition(newKey, _optionalChain([this, 'access', _165 => _165.#items, 'access', _166 => _166.at, 'call', _167 => _167(existingItemIndex + 1), 'optionalAccess', _168 => _168._parentPos]))
|
|
7450
7490
|
);
|
|
7451
7491
|
const previousIndex = this.#items.findIndex((item) => item === child);
|
|
7452
7492
|
this.#updateItemPosition(child, newKey);
|
|
@@ -7473,7 +7513,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7473
7513
|
this,
|
|
7474
7514
|
makePosition(
|
|
7475
7515
|
newKey,
|
|
7476
|
-
_optionalChain([this, 'access',
|
|
7516
|
+
_optionalChain([this, 'access', _169 => _169.#items, 'access', _170 => _170.at, 'call', _171 => _171(existingItemIndex + 1), 'optionalAccess', _172 => _172._parentPos])
|
|
7477
7517
|
)
|
|
7478
7518
|
);
|
|
7479
7519
|
this.#items.reposition(existingItem);
|
|
@@ -7497,7 +7537,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7497
7537
|
existingItemIndex,
|
|
7498
7538
|
makePosition(
|
|
7499
7539
|
newKey,
|
|
7500
|
-
_optionalChain([this, 'access',
|
|
7540
|
+
_optionalChain([this, 'access', _173 => _173.#items, 'access', _174 => _174.at, 'call', _175 => _175(existingItemIndex + 1), 'optionalAccess', _176 => _176._parentPos])
|
|
7501
7541
|
)
|
|
7502
7542
|
);
|
|
7503
7543
|
}
|
|
@@ -7525,7 +7565,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7525
7565
|
if (existingItemIndex !== -1) {
|
|
7526
7566
|
actualNewKey = makePosition(
|
|
7527
7567
|
newKey,
|
|
7528
|
-
_optionalChain([this, 'access',
|
|
7568
|
+
_optionalChain([this, 'access', _177 => _177.#items, 'access', _178 => _178.at, 'call', _179 => _179(existingItemIndex + 1), 'optionalAccess', _180 => _180._parentPos])
|
|
7529
7569
|
);
|
|
7530
7570
|
}
|
|
7531
7571
|
this.#updateItemPosition(child, actualNewKey);
|
|
@@ -7599,14 +7639,14 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7599
7639
|
* instead of resolving its position against the client's stale view.
|
|
7600
7640
|
*/
|
|
7601
7641
|
#injectAt(element, index, intent) {
|
|
7602
|
-
_optionalChain([this, 'access',
|
|
7642
|
+
_optionalChain([this, 'access', _181 => _181._pool, 'optionalAccess', _182 => _182.assertStorageIsWritable, 'call', _183 => _183()]);
|
|
7603
7643
|
if (index < 0 || index > this.#items.length) {
|
|
7604
7644
|
throw new Error(
|
|
7605
7645
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
7606
7646
|
);
|
|
7607
7647
|
}
|
|
7608
|
-
const before2 = _optionalChain([this, 'access',
|
|
7609
|
-
const after2 = _optionalChain([this, 'access',
|
|
7648
|
+
const before2 = _optionalChain([this, 'access', _184 => _184.#items, 'access', _185 => _185.at, 'call', _186 => _186(index - 1), 'optionalAccess', _187 => _187._parentPos]);
|
|
7649
|
+
const after2 = _optionalChain([this, 'access', _188 => _188.#items, 'access', _189 => _189.at, 'call', _190 => _190(index), 'optionalAccess', _191 => _191._parentPos]);
|
|
7610
7650
|
const position = makePosition(before2, after2);
|
|
7611
7651
|
const value = lsonToLiveNode(element);
|
|
7612
7652
|
value._setParentLink(this, position);
|
|
@@ -7630,7 +7670,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7630
7670
|
* @param targetIndex The index where the element should be after moving.
|
|
7631
7671
|
*/
|
|
7632
7672
|
move(index, targetIndex) {
|
|
7633
|
-
_optionalChain([this, 'access',
|
|
7673
|
+
_optionalChain([this, 'access', _192 => _192._pool, 'optionalAccess', _193 => _193.assertStorageIsWritable, 'call', _194 => _194()]);
|
|
7634
7674
|
if (targetIndex < 0) {
|
|
7635
7675
|
throw new Error("targetIndex cannot be less than 0");
|
|
7636
7676
|
}
|
|
@@ -7648,11 +7688,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7648
7688
|
let beforePosition = null;
|
|
7649
7689
|
let afterPosition = null;
|
|
7650
7690
|
if (index < targetIndex) {
|
|
7651
|
-
afterPosition = targetIndex === this.#items.length - 1 ? void 0 : _optionalChain([this, 'access',
|
|
7691
|
+
afterPosition = targetIndex === this.#items.length - 1 ? void 0 : _optionalChain([this, 'access', _195 => _195.#items, 'access', _196 => _196.at, 'call', _197 => _197(targetIndex + 1), 'optionalAccess', _198 => _198._parentPos]);
|
|
7652
7692
|
beforePosition = this.#items.at(targetIndex)._parentPos;
|
|
7653
7693
|
} else {
|
|
7654
7694
|
afterPosition = this.#items.at(targetIndex)._parentPos;
|
|
7655
|
-
beforePosition = targetIndex === 0 ? void 0 : _optionalChain([this, 'access',
|
|
7695
|
+
beforePosition = targetIndex === 0 ? void 0 : _optionalChain([this, 'access', _199 => _199.#items, 'access', _200 => _200.at, 'call', _201 => _201(targetIndex - 1), 'optionalAccess', _202 => _202._parentPos]);
|
|
7656
7696
|
}
|
|
7657
7697
|
const position = makePosition(beforePosition, afterPosition);
|
|
7658
7698
|
const item = this.#items.at(index);
|
|
@@ -7687,7 +7727,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7687
7727
|
* @param index The index of the element to delete
|
|
7688
7728
|
*/
|
|
7689
7729
|
delete(index) {
|
|
7690
|
-
_optionalChain([this, 'access',
|
|
7730
|
+
_optionalChain([this, 'access', _203 => _203._pool, 'optionalAccess', _204 => _204.assertStorageIsWritable, 'call', _205 => _205()]);
|
|
7691
7731
|
if (index < 0 || index >= this.#items.length) {
|
|
7692
7732
|
throw new Error(
|
|
7693
7733
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -7720,7 +7760,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7720
7760
|
}
|
|
7721
7761
|
}
|
|
7722
7762
|
clear() {
|
|
7723
|
-
_optionalChain([this, 'access',
|
|
7763
|
+
_optionalChain([this, 'access', _206 => _206._pool, 'optionalAccess', _207 => _207.assertStorageIsWritable, 'call', _208 => _208()]);
|
|
7724
7764
|
if (this._pool) {
|
|
7725
7765
|
const ops = [];
|
|
7726
7766
|
const reverseOps = [];
|
|
@@ -7754,7 +7794,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7754
7794
|
}
|
|
7755
7795
|
}
|
|
7756
7796
|
set(index, item) {
|
|
7757
|
-
_optionalChain([this, 'access',
|
|
7797
|
+
_optionalChain([this, 'access', _209 => _209._pool, 'optionalAccess', _210 => _210.assertStorageIsWritable, 'call', _211 => _211()]);
|
|
7758
7798
|
if (index < 0 || index >= this.#items.length) {
|
|
7759
7799
|
throw new Error(
|
|
7760
7800
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -7913,7 +7953,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7913
7953
|
#shiftItemPosition(index, key) {
|
|
7914
7954
|
const shiftedPosition = makePosition(
|
|
7915
7955
|
key,
|
|
7916
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
7956
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _212 => _212.#items, 'access', _213 => _213.at, 'call', _214 => _214(index + 1), 'optionalAccess', _215 => _215._parentPos]) : void 0
|
|
7917
7957
|
);
|
|
7918
7958
|
this.#updateItemPositionAt(index, shiftedPosition);
|
|
7919
7959
|
}
|
|
@@ -8162,7 +8202,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8162
8202
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
8163
8203
|
*/
|
|
8164
8204
|
set(key, value) {
|
|
8165
|
-
_optionalChain([this, 'access',
|
|
8205
|
+
_optionalChain([this, 'access', _216 => _216._pool, 'optionalAccess', _217 => _217.assertStorageIsWritable, 'call', _218 => _218()]);
|
|
8166
8206
|
const oldValue = this.#map.get(key);
|
|
8167
8207
|
if (oldValue) {
|
|
8168
8208
|
oldValue._detach();
|
|
@@ -8208,7 +8248,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8208
8248
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
8209
8249
|
*/
|
|
8210
8250
|
delete(key) {
|
|
8211
|
-
_optionalChain([this, 'access',
|
|
8251
|
+
_optionalChain([this, 'access', _219 => _219._pool, 'optionalAccess', _220 => _220.assertStorageIsWritable, 'call', _221 => _221()]);
|
|
8212
8252
|
const item = this.#map.get(key);
|
|
8213
8253
|
if (item === void 0) {
|
|
8214
8254
|
return false;
|
|
@@ -8822,20 +8862,20 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8822
8862
|
* Caveat: this method will not add changes to the undo/redo stack.
|
|
8823
8863
|
*/
|
|
8824
8864
|
setLocal(key, value) {
|
|
8825
|
-
_optionalChain([this, 'access',
|
|
8865
|
+
_optionalChain([this, 'access', _222 => _222._pool, 'optionalAccess', _223 => _223.assertStorageIsWritable, 'call', _224 => _224()]);
|
|
8826
8866
|
const deleteResult = this.#prepareDelete(key);
|
|
8827
8867
|
this.#local.set(key, value);
|
|
8828
8868
|
this.invalidate();
|
|
8829
8869
|
if (this._pool !== void 0 && this._id !== void 0) {
|
|
8830
|
-
const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess',
|
|
8831
|
-
const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess',
|
|
8832
|
-
const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess',
|
|
8870
|
+
const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _225 => _225[0]]), () => ( []));
|
|
8871
|
+
const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _226 => _226[1]]), () => ( []));
|
|
8872
|
+
const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _227 => _227[2]]), () => ( /* @__PURE__ */ new Map()));
|
|
8833
8873
|
const existing = storageUpdates.get(this._id);
|
|
8834
8874
|
storageUpdates.set(this._id, {
|
|
8835
8875
|
node: this,
|
|
8836
8876
|
type: "LiveObject",
|
|
8837
8877
|
updates: {
|
|
8838
|
-
..._optionalChain([existing, 'optionalAccess',
|
|
8878
|
+
..._optionalChain([existing, 'optionalAccess', _228 => _228.updates]),
|
|
8839
8879
|
[key]: { type: "update" }
|
|
8840
8880
|
}
|
|
8841
8881
|
});
|
|
@@ -8855,7 +8895,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8855
8895
|
* #synced or pool/id are unavailable. Does NOT dispatch.
|
|
8856
8896
|
*/
|
|
8857
8897
|
#prepareDelete(key) {
|
|
8858
|
-
_optionalChain([this, 'access',
|
|
8898
|
+
_optionalChain([this, 'access', _229 => _229._pool, 'optionalAccess', _230 => _230.assertStorageIsWritable, 'call', _231 => _231()]);
|
|
8859
8899
|
const k = key;
|
|
8860
8900
|
if (this.#local.has(k) && !this.#synced.has(k)) {
|
|
8861
8901
|
const oldValue2 = this.#local.get(k);
|
|
@@ -8931,7 +8971,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8931
8971
|
const result = this.#prepareDelete(key);
|
|
8932
8972
|
if (result) {
|
|
8933
8973
|
const [ops, reverse, storageUpdates] = result;
|
|
8934
|
-
_optionalChain([this, 'access',
|
|
8974
|
+
_optionalChain([this, 'access', _232 => _232._pool, 'optionalAccess', _233 => _233.dispatch, 'call', _234 => _234(ops, reverse, storageUpdates)]);
|
|
8935
8975
|
}
|
|
8936
8976
|
}
|
|
8937
8977
|
/**
|
|
@@ -8939,7 +8979,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8939
8979
|
* @param patch The object used to overrides properties
|
|
8940
8980
|
*/
|
|
8941
8981
|
update(patch) {
|
|
8942
|
-
_optionalChain([this, 'access',
|
|
8982
|
+
_optionalChain([this, 'access', _235 => _235._pool, 'optionalAccess', _236 => _236.assertStorageIsWritable, 'call', _237 => _237()]);
|
|
8943
8983
|
if (_LiveObject.detectLargeObjects) {
|
|
8944
8984
|
const data = {};
|
|
8945
8985
|
for (const [key, value] of this.#synced) {
|
|
@@ -9490,7 +9530,7 @@ function sendToPanel(message, options) {
|
|
|
9490
9530
|
...message,
|
|
9491
9531
|
source: "liveblocks-devtools-client"
|
|
9492
9532
|
};
|
|
9493
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
9533
|
+
if (!(_optionalChain([options, 'optionalAccess', _238 => _238.force]) || _bridgeActive)) {
|
|
9494
9534
|
return;
|
|
9495
9535
|
}
|
|
9496
9536
|
window.postMessage(fullMsg, "*");
|
|
@@ -9498,7 +9538,7 @@ function sendToPanel(message, options) {
|
|
|
9498
9538
|
var eventSource = makeEventSource();
|
|
9499
9539
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
9500
9540
|
window.addEventListener("message", (event) => {
|
|
9501
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
9541
|
+
if (event.source === window && _optionalChain([event, 'access', _239 => _239.data, 'optionalAccess', _240 => _240.source]) === "liveblocks-devtools-panel") {
|
|
9502
9542
|
eventSource.notify(event.data);
|
|
9503
9543
|
} else {
|
|
9504
9544
|
}
|
|
@@ -9640,7 +9680,7 @@ function fullSync(room) {
|
|
|
9640
9680
|
msg: "room::sync::full",
|
|
9641
9681
|
roomId: room.id,
|
|
9642
9682
|
status: room.getStatus(),
|
|
9643
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
9683
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _241 => _241.toTreeNode, 'call', _242 => _242("root"), 'access', _243 => _243.payload]), () => ( null)),
|
|
9644
9684
|
me,
|
|
9645
9685
|
others
|
|
9646
9686
|
});
|
|
@@ -10327,15 +10367,15 @@ function installBackgroundTabSpy() {
|
|
|
10327
10367
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
10328
10368
|
const inBackgroundSince = { current: null };
|
|
10329
10369
|
function onVisibilityChange() {
|
|
10330
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
10370
|
+
if (_optionalChain([doc, 'optionalAccess', _244 => _244.visibilityState]) === "hidden") {
|
|
10331
10371
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
10332
10372
|
} else {
|
|
10333
10373
|
inBackgroundSince.current = null;
|
|
10334
10374
|
}
|
|
10335
10375
|
}
|
|
10336
|
-
_optionalChain([doc, 'optionalAccess',
|
|
10376
|
+
_optionalChain([doc, 'optionalAccess', _245 => _245.addEventListener, 'call', _246 => _246("visibilitychange", onVisibilityChange)]);
|
|
10337
10377
|
const unsub = () => {
|
|
10338
|
-
_optionalChain([doc, 'optionalAccess',
|
|
10378
|
+
_optionalChain([doc, 'optionalAccess', _247 => _247.removeEventListener, 'call', _248 => _248("visibilitychange", onVisibilityChange)]);
|
|
10339
10379
|
};
|
|
10340
10380
|
return [inBackgroundSince, unsub];
|
|
10341
10381
|
}
|
|
@@ -10359,7 +10399,7 @@ function makeNodeMapBuffer() {
|
|
|
10359
10399
|
function topLevelKeysOf(nodes) {
|
|
10360
10400
|
const keys2 = /* @__PURE__ */ new Set();
|
|
10361
10401
|
const root = nodes.get("root");
|
|
10362
|
-
for (const key in _optionalChain([root, 'optionalAccess',
|
|
10402
|
+
for (const key in _optionalChain([root, 'optionalAccess', _249 => _249.data])) {
|
|
10363
10403
|
keys2.add(key);
|
|
10364
10404
|
}
|
|
10365
10405
|
for (const node of nodes.values()) {
|
|
@@ -10542,7 +10582,7 @@ function createRoom(options, config) {
|
|
|
10542
10582
|
}
|
|
10543
10583
|
}
|
|
10544
10584
|
function isStorageWritable() {
|
|
10545
|
-
const permissionMatrix = _optionalChain([context, 'access',
|
|
10585
|
+
const permissionMatrix = _optionalChain([context, 'access', _250 => _250.dynamicSessionInfoSig, 'access', _251 => _251.get, 'call', _252 => _252(), 'optionalAccess', _253 => _253.permissionMatrix]);
|
|
10546
10586
|
return permissionMatrix !== void 0 ? hasPermissionAccess(permissionMatrix, "storage", "write") : true;
|
|
10547
10587
|
}
|
|
10548
10588
|
const eventHub = {
|
|
@@ -10662,7 +10702,7 @@ function createRoom(options, config) {
|
|
|
10662
10702
|
context.pool
|
|
10663
10703
|
);
|
|
10664
10704
|
}
|
|
10665
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
10705
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _254 => _254.get, 'call', _255 => _255(), 'optionalAccess', _256 => _256.canWrite]), () => ( true));
|
|
10666
10706
|
const serverTopLevelKeys = topLevelKeysOf(nodes);
|
|
10667
10707
|
const root = context.root;
|
|
10668
10708
|
disableHistory(() => {
|
|
@@ -10895,7 +10935,7 @@ function createRoom(options, config) {
|
|
|
10895
10935
|
}
|
|
10896
10936
|
context.myPresence.patch(patch);
|
|
10897
10937
|
if (context.activeBatch) {
|
|
10898
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
10938
|
+
if (_optionalChain([options2, 'optionalAccess', _257 => _257.addToHistory])) {
|
|
10899
10939
|
context.activeBatch.reverseOps.pushLeft({
|
|
10900
10940
|
type: "presence",
|
|
10901
10941
|
data: oldValues
|
|
@@ -10904,7 +10944,7 @@ function createRoom(options, config) {
|
|
|
10904
10944
|
context.activeBatch.updates.presence = true;
|
|
10905
10945
|
} else {
|
|
10906
10946
|
flushNowOrSoon();
|
|
10907
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
10947
|
+
if (_optionalChain([options2, 'optionalAccess', _258 => _258.addToHistory])) {
|
|
10908
10948
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
10909
10949
|
}
|
|
10910
10950
|
notify({ presence: true });
|
|
@@ -11083,11 +11123,11 @@ function createRoom(options, config) {
|
|
|
11083
11123
|
break;
|
|
11084
11124
|
}
|
|
11085
11125
|
case ServerMsgCode.STORAGE_CHUNK:
|
|
11086
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
11126
|
+
_optionalChain([stopwatch, 'optionalAccess', _259 => _259.lap, 'call', _260 => _260()]);
|
|
11087
11127
|
nodeMapBuffer.append(compactNodesToNodeStream(message.nodes));
|
|
11088
11128
|
break;
|
|
11089
11129
|
case ServerMsgCode.STORAGE_STREAM_END: {
|
|
11090
|
-
const timing = _optionalChain([stopwatch, 'optionalAccess',
|
|
11130
|
+
const timing = _optionalChain([stopwatch, 'optionalAccess', _261 => _261.stop, 'call', _262 => _262()]);
|
|
11091
11131
|
if (timing) {
|
|
11092
11132
|
const ms = (v) => `${v.toFixed(1)}ms`;
|
|
11093
11133
|
const rest = timing.laps.slice(1);
|
|
@@ -11222,11 +11262,11 @@ function createRoom(options, config) {
|
|
|
11222
11262
|
} else if (pendingFeedsRequests.has(requestId)) {
|
|
11223
11263
|
const pending = pendingFeedsRequests.get(requestId);
|
|
11224
11264
|
pendingFeedsRequests.delete(requestId);
|
|
11225
|
-
_optionalChain([pending, 'optionalAccess',
|
|
11265
|
+
_optionalChain([pending, 'optionalAccess', _263 => _263.reject, 'call', _264 => _264(err)]);
|
|
11226
11266
|
} else if (pendingFeedMessagesRequests.has(requestId)) {
|
|
11227
11267
|
const pending = pendingFeedMessagesRequests.get(requestId);
|
|
11228
11268
|
pendingFeedMessagesRequests.delete(requestId);
|
|
11229
|
-
_optionalChain([pending, 'optionalAccess',
|
|
11269
|
+
_optionalChain([pending, 'optionalAccess', _265 => _265.reject, 'call', _266 => _266(err)]);
|
|
11230
11270
|
}
|
|
11231
11271
|
eventHub.feeds.notify(message);
|
|
11232
11272
|
break;
|
|
@@ -11380,10 +11420,10 @@ function createRoom(options, config) {
|
|
|
11380
11420
|
timeoutId,
|
|
11381
11421
|
kind,
|
|
11382
11422
|
feedId,
|
|
11383
|
-
messageId: _optionalChain([options2, 'optionalAccess',
|
|
11384
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
11423
|
+
messageId: _optionalChain([options2, 'optionalAccess', _267 => _267.messageId]),
|
|
11424
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _268 => _268.expectedClientMessageId])
|
|
11385
11425
|
});
|
|
11386
|
-
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess',
|
|
11426
|
+
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess', _269 => _269.expectedClientMessageId]) === void 0) {
|
|
11387
11427
|
const q = _nullishCoalesce(pendingAddMessageFifoByFeed.get(feedId), () => ( []));
|
|
11388
11428
|
q.push(requestId);
|
|
11389
11429
|
pendingAddMessageFifoByFeed.set(feedId, q);
|
|
@@ -11434,10 +11474,10 @@ function createRoom(options, config) {
|
|
|
11434
11474
|
}
|
|
11435
11475
|
if (!matched) {
|
|
11436
11476
|
const q = pendingAddMessageFifoByFeed.get(message.feedId);
|
|
11437
|
-
const headId = _optionalChain([q, 'optionalAccess',
|
|
11477
|
+
const headId = _optionalChain([q, 'optionalAccess', _270 => _270[0]]);
|
|
11438
11478
|
if (headId !== void 0) {
|
|
11439
11479
|
const pending = pendingFeedMutations.get(headId);
|
|
11440
|
-
if (_optionalChain([pending, 'optionalAccess',
|
|
11480
|
+
if (_optionalChain([pending, 'optionalAccess', _271 => _271.kind]) === "add-message" && pending.expectedClientMessageId === void 0) {
|
|
11441
11481
|
settleFeedMutation(headId, "ok");
|
|
11442
11482
|
}
|
|
11443
11483
|
}
|
|
@@ -11473,7 +11513,7 @@ function createRoom(options, config) {
|
|
|
11473
11513
|
const unacknowledgedOps2 = [...context.unacknowledgedOps.values()];
|
|
11474
11514
|
createOrUpdateRootFromMessage(nodes);
|
|
11475
11515
|
applyAndSendOfflineOps(unacknowledgedOps2);
|
|
11476
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
11516
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _272 => _272()]);
|
|
11477
11517
|
notifyStorageStatus();
|
|
11478
11518
|
eventHub.storageDidLoad.notify();
|
|
11479
11519
|
}
|
|
@@ -11482,7 +11522,7 @@ function createRoom(options, config) {
|
|
|
11482
11522
|
if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
11483
11523
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
11484
11524
|
nodeMapBuffer.take();
|
|
11485
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
11525
|
+
_optionalChain([stopwatch, 'optionalAccess', _273 => _273.start, 'call', _274 => _274()]);
|
|
11486
11526
|
}
|
|
11487
11527
|
}
|
|
11488
11528
|
function startLoadingStorage() {
|
|
@@ -11536,10 +11576,10 @@ function createRoom(options, config) {
|
|
|
11536
11576
|
const message = {
|
|
11537
11577
|
type: ClientMsgCode.FETCH_FEEDS,
|
|
11538
11578
|
requestId,
|
|
11539
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11540
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
11541
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
11542
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
11579
|
+
cursor: _optionalChain([options2, 'optionalAccess', _275 => _275.cursor]),
|
|
11580
|
+
since: _optionalChain([options2, 'optionalAccess', _276 => _276.since]),
|
|
11581
|
+
limit: _optionalChain([options2, 'optionalAccess', _277 => _277.limit]),
|
|
11582
|
+
metadata: _optionalChain([options2, 'optionalAccess', _278 => _278.metadata])
|
|
11543
11583
|
};
|
|
11544
11584
|
context.buffer.messages.push(message);
|
|
11545
11585
|
flushNowOrSoon();
|
|
@@ -11559,9 +11599,9 @@ function createRoom(options, config) {
|
|
|
11559
11599
|
type: ClientMsgCode.FETCH_FEED_MESSAGES,
|
|
11560
11600
|
requestId,
|
|
11561
11601
|
feedId,
|
|
11562
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11563
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
11564
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
11602
|
+
cursor: _optionalChain([options2, 'optionalAccess', _279 => _279.cursor]),
|
|
11603
|
+
since: _optionalChain([options2, 'optionalAccess', _280 => _280.since]),
|
|
11604
|
+
limit: _optionalChain([options2, 'optionalAccess', _281 => _281.limit])
|
|
11565
11605
|
};
|
|
11566
11606
|
context.buffer.messages.push(message);
|
|
11567
11607
|
flushNowOrSoon();
|
|
@@ -11580,8 +11620,8 @@ function createRoom(options, config) {
|
|
|
11580
11620
|
type: ClientMsgCode.ADD_FEED,
|
|
11581
11621
|
requestId,
|
|
11582
11622
|
feedId,
|
|
11583
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
11584
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
11623
|
+
metadata: _optionalChain([options2, 'optionalAccess', _282 => _282.metadata]),
|
|
11624
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _283 => _283.createdAt])
|
|
11585
11625
|
};
|
|
11586
11626
|
context.buffer.messages.push(message);
|
|
11587
11627
|
flushNowOrSoon();
|
|
@@ -11615,15 +11655,15 @@ function createRoom(options, config) {
|
|
|
11615
11655
|
function addFeedMessage(feedId, data, options2) {
|
|
11616
11656
|
const requestId = nanoid();
|
|
11617
11657
|
const promise = registerFeedMutation(requestId, "add-message", feedId, {
|
|
11618
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
11658
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _284 => _284.id])
|
|
11619
11659
|
});
|
|
11620
11660
|
const message = {
|
|
11621
11661
|
type: ClientMsgCode.ADD_FEED_MESSAGE,
|
|
11622
11662
|
requestId,
|
|
11623
11663
|
feedId,
|
|
11624
11664
|
data,
|
|
11625
|
-
id: _optionalChain([options2, 'optionalAccess',
|
|
11626
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
11665
|
+
id: _optionalChain([options2, 'optionalAccess', _285 => _285.id]),
|
|
11666
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _286 => _286.createdAt])
|
|
11627
11667
|
};
|
|
11628
11668
|
context.buffer.messages.push(message);
|
|
11629
11669
|
flushNowOrSoon();
|
|
@@ -11640,7 +11680,7 @@ function createRoom(options, config) {
|
|
|
11640
11680
|
feedId,
|
|
11641
11681
|
messageId,
|
|
11642
11682
|
data,
|
|
11643
|
-
updatedAt: _optionalChain([options2, 'optionalAccess',
|
|
11683
|
+
updatedAt: _optionalChain([options2, 'optionalAccess', _287 => _287.updatedAt])
|
|
11644
11684
|
};
|
|
11645
11685
|
context.buffer.messages.push(message);
|
|
11646
11686
|
flushNowOrSoon();
|
|
@@ -11847,8 +11887,8 @@ function createRoom(options, config) {
|
|
|
11847
11887
|
async function getThreads(options2) {
|
|
11848
11888
|
return httpClient.getThreads({
|
|
11849
11889
|
roomId,
|
|
11850
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
11851
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11890
|
+
query: _optionalChain([options2, 'optionalAccess', _288 => _288.query]),
|
|
11891
|
+
cursor: _optionalChain([options2, 'optionalAccess', _289 => _289.cursor])
|
|
11852
11892
|
});
|
|
11853
11893
|
}
|
|
11854
11894
|
async function getThread(threadId) {
|
|
@@ -11981,7 +12021,7 @@ function createRoom(options, config) {
|
|
|
11981
12021
|
function getSubscriptionSettings(options2) {
|
|
11982
12022
|
return httpClient.getSubscriptionSettings({
|
|
11983
12023
|
roomId,
|
|
11984
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
12024
|
+
signal: _optionalChain([options2, 'optionalAccess', _290 => _290.signal])
|
|
11985
12025
|
});
|
|
11986
12026
|
}
|
|
11987
12027
|
function updateSubscriptionSettings(settings) {
|
|
@@ -12003,7 +12043,7 @@ function createRoom(options, config) {
|
|
|
12003
12043
|
{
|
|
12004
12044
|
[kInternal]: {
|
|
12005
12045
|
get presenceBuffer() {
|
|
12006
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
12046
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _291 => _291.buffer, 'access', _292 => _292.presenceUpdates, 'optionalAccess', _293 => _293.data]), () => ( null)));
|
|
12007
12047
|
},
|
|
12008
12048
|
// prettier-ignore
|
|
12009
12049
|
get undoStack() {
|
|
@@ -12018,15 +12058,15 @@ function createRoom(options, config) {
|
|
|
12018
12058
|
return context.yjsProvider;
|
|
12019
12059
|
},
|
|
12020
12060
|
setYjsProvider(newProvider) {
|
|
12021
|
-
_optionalChain([context, 'access',
|
|
12061
|
+
_optionalChain([context, 'access', _294 => _294.yjsProvider, 'optionalAccess', _295 => _295.off, 'call', _296 => _296("status", yjsStatusDidChange)]);
|
|
12022
12062
|
context.yjsProvider = newProvider;
|
|
12023
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
12063
|
+
_optionalChain([newProvider, 'optionalAccess', _297 => _297.on, 'call', _298 => _298("status", yjsStatusDidChange)]);
|
|
12024
12064
|
context.yjsProviderDidChange.notify();
|
|
12025
12065
|
},
|
|
12026
12066
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
12027
12067
|
// send metadata when using a text editor
|
|
12028
12068
|
reportTextEditor,
|
|
12029
|
-
getPermissionMatrix: () => _optionalChain([context, 'access',
|
|
12069
|
+
getPermissionMatrix: () => _optionalChain([context, 'access', _299 => _299.dynamicSessionInfoSig, 'access', _300 => _300.get, 'call', _301 => _301(), 'optionalAccess', _302 => _302.permissionMatrix]),
|
|
12030
12070
|
// create a text mention when using a text editor
|
|
12031
12071
|
createTextMention,
|
|
12032
12072
|
// delete a text mention when using a text editor
|
|
@@ -12089,7 +12129,7 @@ ${dumpPool(
|
|
|
12089
12129
|
source.dispose();
|
|
12090
12130
|
}
|
|
12091
12131
|
eventHub.roomWillDestroy.notify();
|
|
12092
|
-
_optionalChain([context, 'access',
|
|
12132
|
+
_optionalChain([context, 'access', _303 => _303.yjsProvider, 'optionalAccess', _304 => _304.off, 'call', _305 => _305("status", yjsStatusDidChange)]);
|
|
12093
12133
|
syncSourceForStorage.destroy();
|
|
12094
12134
|
syncSourceForYjs.destroy();
|
|
12095
12135
|
uninstallBgTabSpy();
|
|
@@ -12253,7 +12293,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
12253
12293
|
}
|
|
12254
12294
|
if (isLiveNode(first)) {
|
|
12255
12295
|
const node = first;
|
|
12256
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
12296
|
+
if (_optionalChain([options, 'optionalAccess', _306 => _306.isDeep])) {
|
|
12257
12297
|
const storageCallback = second;
|
|
12258
12298
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
12259
12299
|
} else {
|
|
@@ -12343,8 +12383,8 @@ function createClient(options) {
|
|
|
12343
12383
|
const authManager = createAuthManager(options, (token) => {
|
|
12344
12384
|
currentUserId.set(() => token.uid);
|
|
12345
12385
|
});
|
|
12346
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
12347
|
-
_optionalChain([globalThis, 'access',
|
|
12386
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _307 => _307.polyfills, 'optionalAccess', _308 => _308.fetch]) || /* istanbul ignore next */
|
|
12387
|
+
_optionalChain([globalThis, 'access', _309 => _309.fetch, 'optionalAccess', _310 => _310.bind, 'call', _311 => _311(globalThis)]);
|
|
12348
12388
|
const httpClient = createApiClient({
|
|
12349
12389
|
baseUrl,
|
|
12350
12390
|
fetchPolyfill,
|
|
@@ -12361,7 +12401,7 @@ function createClient(options) {
|
|
|
12361
12401
|
delegates: {
|
|
12362
12402
|
createSocket: makeCreateSocketDelegateForAi(
|
|
12363
12403
|
baseUrl,
|
|
12364
|
-
_optionalChain([clientOptions, 'access',
|
|
12404
|
+
_optionalChain([clientOptions, 'access', _312 => _312.polyfills, 'optionalAccess', _313 => _313.WebSocket])
|
|
12365
12405
|
),
|
|
12366
12406
|
authenticate: async () => {
|
|
12367
12407
|
const resp = await authManager.getAuthValue({
|
|
@@ -12432,7 +12472,7 @@ function createClient(options) {
|
|
|
12432
12472
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
12433
12473
|
roomId,
|
|
12434
12474
|
baseUrl,
|
|
12435
|
-
_optionalChain([clientOptions, 'access',
|
|
12475
|
+
_optionalChain([clientOptions, 'access', _314 => _314.polyfills, 'optionalAccess', _315 => _315.WebSocket])
|
|
12436
12476
|
),
|
|
12437
12477
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
12438
12478
|
})),
|
|
@@ -12454,7 +12494,7 @@ function createClient(options) {
|
|
|
12454
12494
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
12455
12495
|
if (shouldConnect) {
|
|
12456
12496
|
if (typeof atob === "undefined") {
|
|
12457
|
-
if (_optionalChain([clientOptions, 'access',
|
|
12497
|
+
if (_optionalChain([clientOptions, 'access', _316 => _316.polyfills, 'optionalAccess', _317 => _317.atob]) === void 0) {
|
|
12458
12498
|
throw new Error(
|
|
12459
12499
|
"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"
|
|
12460
12500
|
);
|
|
@@ -12466,7 +12506,7 @@ function createClient(options) {
|
|
|
12466
12506
|
return leaseRoom(newRoomDetails);
|
|
12467
12507
|
}
|
|
12468
12508
|
function getRoom(roomId) {
|
|
12469
|
-
const room = _optionalChain([roomsById, 'access',
|
|
12509
|
+
const room = _optionalChain([roomsById, 'access', _318 => _318.get, 'call', _319 => _319(roomId), 'optionalAccess', _320 => _320.room]);
|
|
12470
12510
|
return room ? room : null;
|
|
12471
12511
|
}
|
|
12472
12512
|
function logout() {
|
|
@@ -12482,7 +12522,7 @@ function createClient(options) {
|
|
|
12482
12522
|
const batchedResolveUsers = new Batch(
|
|
12483
12523
|
async (batchedUserIds) => {
|
|
12484
12524
|
const userIds = batchedUserIds.flat();
|
|
12485
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
12525
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _321 => _321({ userIds })]);
|
|
12486
12526
|
warnOnceIf(
|
|
12487
12527
|
!resolveUsers,
|
|
12488
12528
|
"Set the resolveUsers option in createClient to specify user info."
|
|
@@ -12499,7 +12539,7 @@ function createClient(options) {
|
|
|
12499
12539
|
const batchedResolveRoomsInfo = new Batch(
|
|
12500
12540
|
async (batchedRoomIds) => {
|
|
12501
12541
|
const roomIds = batchedRoomIds.flat();
|
|
12502
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
12542
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _322 => _322({ roomIds })]);
|
|
12503
12543
|
warnOnceIf(
|
|
12504
12544
|
!resolveRoomsInfo,
|
|
12505
12545
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
@@ -12516,7 +12556,7 @@ function createClient(options) {
|
|
|
12516
12556
|
const batchedResolveGroupsInfo = new Batch(
|
|
12517
12557
|
async (batchedGroupIds) => {
|
|
12518
12558
|
const groupIds = batchedGroupIds.flat();
|
|
12519
|
-
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall',
|
|
12559
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _323 => _323({ groupIds })]);
|
|
12520
12560
|
warnOnceIf(
|
|
12521
12561
|
!resolveGroupsInfo,
|
|
12522
12562
|
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
@@ -12575,7 +12615,7 @@ function createClient(options) {
|
|
|
12575
12615
|
}
|
|
12576
12616
|
};
|
|
12577
12617
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
12578
|
-
_optionalChain([win, 'optionalAccess',
|
|
12618
|
+
_optionalChain([win, 'optionalAccess', _324 => _324.addEventListener, 'call', _325 => _325("beforeunload", maybePreventClose)]);
|
|
12579
12619
|
}
|
|
12580
12620
|
async function getNotificationSettings(options2) {
|
|
12581
12621
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -12703,7 +12743,7 @@ var commentBodyElementsTypes = {
|
|
|
12703
12743
|
mention: "inline"
|
|
12704
12744
|
};
|
|
12705
12745
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
12706
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
12746
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _326 => _326.content])) {
|
|
12707
12747
|
return;
|
|
12708
12748
|
}
|
|
12709
12749
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -12713,13 +12753,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
12713
12753
|
for (const block of body.content) {
|
|
12714
12754
|
if (type === "all" || type === "block") {
|
|
12715
12755
|
if (guard(block)) {
|
|
12716
|
-
_optionalChain([visitor, 'optionalCall',
|
|
12756
|
+
_optionalChain([visitor, 'optionalCall', _327 => _327(block)]);
|
|
12717
12757
|
}
|
|
12718
12758
|
}
|
|
12719
12759
|
if (type === "all" || type === "inline") {
|
|
12720
12760
|
for (const inline of block.children) {
|
|
12721
12761
|
if (guard(inline)) {
|
|
12722
|
-
_optionalChain([visitor, 'optionalCall',
|
|
12762
|
+
_optionalChain([visitor, 'optionalCall', _328 => _328(inline)]);
|
|
12723
12763
|
}
|
|
12724
12764
|
}
|
|
12725
12765
|
}
|
|
@@ -12889,7 +12929,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
12889
12929
|
text: ({ element }) => element.text,
|
|
12890
12930
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
12891
12931
|
mention: ({ element, user, group }) => {
|
|
12892
|
-
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
12932
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _329 => _329.name]), () => ( _optionalChain([group, 'optionalAccess', _330 => _330.name]))), () => ( element.id))}`;
|
|
12893
12933
|
}
|
|
12894
12934
|
};
|
|
12895
12935
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -12919,7 +12959,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
12919
12959
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
12920
12960
|
},
|
|
12921
12961
|
mention: ({ element, user, group }) => {
|
|
12922
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
12962
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _331 => _331.name]) ? html`${_optionalChain([user, 'optionalAccess', _332 => _332.name])}` : _optionalChain([group, 'optionalAccess', _333 => _333.name]) ? html`${_optionalChain([group, 'optionalAccess', _334 => _334.name])}` : element.id}</span>`;
|
|
12923
12963
|
}
|
|
12924
12964
|
};
|
|
12925
12965
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -12949,20 +12989,20 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
12949
12989
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
12950
12990
|
},
|
|
12951
12991
|
mention: ({ element, user, group }) => {
|
|
12952
|
-
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
12992
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _335 => _335.name]), () => ( _optionalChain([group, 'optionalAccess', _336 => _336.name]))), () => ( element.id))}`;
|
|
12953
12993
|
}
|
|
12954
12994
|
};
|
|
12955
12995
|
async function stringifyCommentBody(body, options) {
|
|
12956
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12957
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12996
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _337 => _337.format]), () => ( "plain"));
|
|
12997
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _338 => _338.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
12958
12998
|
const elements = {
|
|
12959
12999
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
12960
|
-
..._optionalChain([options, 'optionalAccess',
|
|
13000
|
+
..._optionalChain([options, 'optionalAccess', _339 => _339.elements])
|
|
12961
13001
|
};
|
|
12962
13002
|
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
12963
13003
|
body,
|
|
12964
|
-
_optionalChain([options, 'optionalAccess',
|
|
12965
|
-
_optionalChain([options, 'optionalAccess',
|
|
13004
|
+
_optionalChain([options, 'optionalAccess', _340 => _340.resolveUsers]),
|
|
13005
|
+
_optionalChain([options, 'optionalAccess', _341 => _341.resolveGroupsInfo])
|
|
12966
13006
|
);
|
|
12967
13007
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
12968
13008
|
switch (block.type) {
|
|
@@ -13102,9 +13142,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
13102
13142
|
const startTime = performance.now();
|
|
13103
13143
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
13104
13144
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
13105
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
13145
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _342 => _342.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
13106
13146
|
const context = {
|
|
13107
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
13147
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _343 => _343.visibilityState]) !== "hidden",
|
|
13108
13148
|
lastSuccessfulPollAt: startTime,
|
|
13109
13149
|
count: 0,
|
|
13110
13150
|
backoff: 0
|
|
@@ -13185,11 +13225,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
13185
13225
|
pollNowIfStale();
|
|
13186
13226
|
}
|
|
13187
13227
|
function onVisibilityChange() {
|
|
13188
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
13228
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _344 => _344.visibilityState]) !== "hidden");
|
|
13189
13229
|
}
|
|
13190
|
-
_optionalChain([doc, 'optionalAccess',
|
|
13191
|
-
_optionalChain([win, 'optionalAccess',
|
|
13192
|
-
_optionalChain([win, 'optionalAccess',
|
|
13230
|
+
_optionalChain([doc, 'optionalAccess', _345 => _345.addEventListener, 'call', _346 => _346("visibilitychange", onVisibilityChange)]);
|
|
13231
|
+
_optionalChain([win, 'optionalAccess', _347 => _347.addEventListener, 'call', _348 => _348("online", onVisibilityChange)]);
|
|
13232
|
+
_optionalChain([win, 'optionalAccess', _349 => _349.addEventListener, 'call', _350 => _350("focus", pollNowIfStale)]);
|
|
13193
13233
|
fsm.start();
|
|
13194
13234
|
return {
|
|
13195
13235
|
inc,
|