@liveblocks/core 2.18.2 → 2.18.4-uns1
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.mjs → index.cjs} +373 -285
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +81 -12
- package/dist/index.d.ts +81 -12
- package/dist/index.js +372 -284
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/index.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
|
|
2
2
|
var __export = (target, all) => {
|
|
3
3
|
for (var name in all)
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -6,8 +6,8 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "2.18.
|
|
10
|
-
var PKG_FORMAT = "
|
|
9
|
+
var PKG_VERSION = "2.18.4-uns1";
|
|
10
|
+
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
13
13
|
var g = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
@@ -187,6 +187,12 @@ function keys(obj) {
|
|
|
187
187
|
function values(obj) {
|
|
188
188
|
return Object.values(obj);
|
|
189
189
|
}
|
|
190
|
+
function create(obj, descriptors) {
|
|
191
|
+
if (typeof descriptors !== "undefined") {
|
|
192
|
+
return Object.create(obj, descriptors);
|
|
193
|
+
}
|
|
194
|
+
return Object.create(obj);
|
|
195
|
+
}
|
|
190
196
|
function mapValues(obj, mapFn) {
|
|
191
197
|
const result = {};
|
|
192
198
|
for (const pair of Object.entries(obj)) {
|
|
@@ -266,8 +272,8 @@ function memoizeOnSuccess(factoryFn) {
|
|
|
266
272
|
|
|
267
273
|
// src/lib/autoRetry.ts
|
|
268
274
|
var HttpError = class _HttpError extends Error {
|
|
269
|
-
|
|
270
|
-
|
|
275
|
+
|
|
276
|
+
|
|
271
277
|
constructor(message, response, details) {
|
|
272
278
|
super(message);
|
|
273
279
|
this.name = "HttpError";
|
|
@@ -278,7 +284,7 @@ var HttpError = class _HttpError extends Error {
|
|
|
278
284
|
let bodyAsText;
|
|
279
285
|
try {
|
|
280
286
|
bodyAsText = await response.text();
|
|
281
|
-
} catch {
|
|
287
|
+
} catch (e2) {
|
|
282
288
|
}
|
|
283
289
|
const bodyAsJson = bodyAsText ? tryParseJson(bodyAsText) : void 0;
|
|
284
290
|
let bodyAsJsonObject;
|
|
@@ -286,8 +292,8 @@ var HttpError = class _HttpError extends Error {
|
|
|
286
292
|
bodyAsJsonObject = bodyAsJson;
|
|
287
293
|
}
|
|
288
294
|
let message = "";
|
|
289
|
-
message ||= typeof bodyAsJsonObject
|
|
290
|
-
message ||= typeof bodyAsJsonObject
|
|
295
|
+
message ||= typeof _optionalChain([bodyAsJsonObject, 'optionalAccess', _2 => _2.message]) === "string" ? bodyAsJsonObject.message : "";
|
|
296
|
+
message ||= typeof _optionalChain([bodyAsJsonObject, 'optionalAccess', _3 => _3.error]) === "string" ? bodyAsJsonObject.error : "";
|
|
291
297
|
if (bodyAsJson === void 0) {
|
|
292
298
|
message ||= bodyAsText || "";
|
|
293
299
|
}
|
|
@@ -295,7 +301,7 @@ var HttpError = class _HttpError extends Error {
|
|
|
295
301
|
let path;
|
|
296
302
|
try {
|
|
297
303
|
path = new URL(response.url).pathname;
|
|
298
|
-
} catch {
|
|
304
|
+
} catch (e3) {
|
|
299
305
|
}
|
|
300
306
|
message += path !== void 0 ? ` (got status ${response.status} from ${path})` : ` (got status ${response.status})`;
|
|
301
307
|
const details = bodyAsJsonObject;
|
|
@@ -324,7 +330,7 @@ async function autoRetry(promiseFn, maxTries, backoff, shouldStopRetrying = DONT
|
|
|
324
330
|
throw new Error(`Failed after ${maxTries} attempts: ${String(err)}`);
|
|
325
331
|
}
|
|
326
332
|
}
|
|
327
|
-
const delay = backoff[attempt - 1]
|
|
333
|
+
const delay = _nullishCoalesce(backoff[attempt - 1], () => ( fallbackBackoff));
|
|
328
334
|
warn(
|
|
329
335
|
`Attempt ${attempt} was unsuccessful. Retrying in ${delay} milliseconds.`
|
|
330
336
|
);
|
|
@@ -369,7 +375,7 @@ function makeEventSource() {
|
|
|
369
375
|
res(event);
|
|
370
376
|
}
|
|
371
377
|
});
|
|
372
|
-
}).finally(() => unsub
|
|
378
|
+
}).finally(() => _optionalChain([unsub, 'optionalCall', _4 => _4()]));
|
|
373
379
|
}
|
|
374
380
|
function notify(event) {
|
|
375
381
|
let called = false;
|
|
@@ -486,12 +492,12 @@ function merge(target, patch) {
|
|
|
486
492
|
}
|
|
487
493
|
var AbstractSignal = class {
|
|
488
494
|
/** @internal */
|
|
489
|
-
|
|
495
|
+
|
|
490
496
|
#eventSource;
|
|
491
497
|
/** @internal */
|
|
492
|
-
|
|
498
|
+
|
|
493
499
|
constructor(equals) {
|
|
494
|
-
this.equals = equals
|
|
500
|
+
this.equals = _nullishCoalesce(equals, () => ( Object.is));
|
|
495
501
|
this.#eventSource = makeEventSource();
|
|
496
502
|
this[kSinks] = /* @__PURE__ */ new Set();
|
|
497
503
|
this.get = this.get.bind(this);
|
|
@@ -560,7 +566,7 @@ var Signal = class extends AbstractSignal {
|
|
|
560
566
|
this.#value = "(disposed)";
|
|
561
567
|
}
|
|
562
568
|
get() {
|
|
563
|
-
trackedReads
|
|
569
|
+
_optionalChain([trackedReads, 'optionalAccess', _5 => _5.add, 'call', _6 => _6(this)]);
|
|
564
570
|
return this.#value;
|
|
565
571
|
}
|
|
566
572
|
set(newValue) {
|
|
@@ -670,7 +676,7 @@ var DerivedSignal = class _DerivedSignal extends AbstractSignal {
|
|
|
670
676
|
if (this.#dirty) {
|
|
671
677
|
this.#recompute();
|
|
672
678
|
}
|
|
673
|
-
trackedReads
|
|
679
|
+
_optionalChain([trackedReads, 'optionalAccess', _7 => _7.add, 'call', _8 => _8(this)]);
|
|
674
680
|
return this.#prevValue;
|
|
675
681
|
}
|
|
676
682
|
/**
|
|
@@ -700,7 +706,7 @@ var MutableSignal = class extends AbstractSignal {
|
|
|
700
706
|
this.#state = "(disposed)";
|
|
701
707
|
}
|
|
702
708
|
get() {
|
|
703
|
-
trackedReads
|
|
709
|
+
_optionalChain([trackedReads, 'optionalAccess', _9 => _9.add, 'call', _10 => _10(this)]);
|
|
704
710
|
return this.#state;
|
|
705
711
|
}
|
|
706
712
|
/**
|
|
@@ -731,17 +737,26 @@ function replacer(_key, value) {
|
|
|
731
737
|
return sorted;
|
|
732
738
|
}, {}) : value;
|
|
733
739
|
}
|
|
734
|
-
function
|
|
740
|
+
function stableStringify(value) {
|
|
735
741
|
return JSON.stringify(value, replacer);
|
|
736
742
|
}
|
|
743
|
+
function stringifyOrLog(value) {
|
|
744
|
+
try {
|
|
745
|
+
return JSON.stringify(value);
|
|
746
|
+
} catch (err) {
|
|
747
|
+
console.error(`Could not stringify: ${err.message}`);
|
|
748
|
+
console.error(value);
|
|
749
|
+
throw err;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
737
752
|
|
|
738
753
|
// src/lib/batch.ts
|
|
739
754
|
var DEFAULT_SIZE = 50;
|
|
740
755
|
var BatchCall = class {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
745
760
|
constructor(input) {
|
|
746
761
|
this.input = input;
|
|
747
762
|
const { promise, resolve, reject } = Promise_withResolvers();
|
|
@@ -750,16 +765,16 @@ var BatchCall = class {
|
|
|
750
765
|
this.reject = reject;
|
|
751
766
|
}
|
|
752
767
|
};
|
|
753
|
-
var Batch = class {
|
|
768
|
+
var Batch = (_class = class {
|
|
754
769
|
#queue = [];
|
|
755
770
|
#callback;
|
|
756
771
|
#size;
|
|
757
772
|
#delay;
|
|
758
773
|
#delayTimeoutId;
|
|
759
|
-
error = false
|
|
760
|
-
constructor(callback, options) {
|
|
774
|
+
__init() {this.error = false}
|
|
775
|
+
constructor(callback, options) {;_class.prototype.__init.call(this);
|
|
761
776
|
this.#callback = callback;
|
|
762
|
-
this.#size = options.size
|
|
777
|
+
this.#size = _nullishCoalesce(options.size, () => ( DEFAULT_SIZE));
|
|
763
778
|
this.#delay = options.delay;
|
|
764
779
|
}
|
|
765
780
|
#clearDelayTimeout() {
|
|
@@ -786,7 +801,7 @@ var Batch = class {
|
|
|
786
801
|
const results = await this.#callback(inputs);
|
|
787
802
|
this.error = false;
|
|
788
803
|
calls.forEach((call, index) => {
|
|
789
|
-
const result = results
|
|
804
|
+
const result = _optionalChain([results, 'optionalAccess', _11 => _11[index]]);
|
|
790
805
|
if (!Array.isArray(results)) {
|
|
791
806
|
call.reject(new Error("Callback must return an array."));
|
|
792
807
|
} else if (calls.length !== results.length) {
|
|
@@ -810,7 +825,7 @@ var Batch = class {
|
|
|
810
825
|
}
|
|
811
826
|
get(input) {
|
|
812
827
|
const existingCall = this.#queue.find(
|
|
813
|
-
(call2) =>
|
|
828
|
+
(call2) => stableStringify(call2.input) === stableStringify(input)
|
|
814
829
|
);
|
|
815
830
|
if (existingCall) {
|
|
816
831
|
return existingCall.promise;
|
|
@@ -825,11 +840,11 @@ var Batch = class {
|
|
|
825
840
|
this.error = false;
|
|
826
841
|
this.#clearDelayTimeout();
|
|
827
842
|
}
|
|
828
|
-
};
|
|
843
|
+
}, _class);
|
|
829
844
|
function createBatchStore(batch2) {
|
|
830
845
|
const signal = new MutableSignal(/* @__PURE__ */ new Map());
|
|
831
846
|
function getCacheKey(args) {
|
|
832
|
-
return
|
|
847
|
+
return stableStringify(args);
|
|
833
848
|
}
|
|
834
849
|
function update(cacheKey, state) {
|
|
835
850
|
signal.mutate((cache) => {
|
|
@@ -941,7 +956,7 @@ var DefaultMap = class extends Map {
|
|
|
941
956
|
if (super.has(key)) {
|
|
942
957
|
return super.get(key);
|
|
943
958
|
} else {
|
|
944
|
-
const fn = defaultFn
|
|
959
|
+
const fn = _nullishCoalesce(_nullishCoalesce(defaultFn, () => ( this.#defaultFn)), () => ( raise("DefaultMap used without a factory function")));
|
|
945
960
|
const value = fn(key);
|
|
946
961
|
this.set(key, value);
|
|
947
962
|
return value;
|
|
@@ -1066,7 +1081,7 @@ function urljoin(baseUrl, path, params) {
|
|
|
1066
1081
|
}
|
|
1067
1082
|
function url(strings, ...values2) {
|
|
1068
1083
|
return strings.reduce(
|
|
1069
|
-
(result, str, i) => result + encodeURIComponent(values2[i - 1]
|
|
1084
|
+
(result, str, i) => result + encodeURIComponent(_nullishCoalesce(values2[i - 1], () => ( ""))) + str
|
|
1070
1085
|
);
|
|
1071
1086
|
}
|
|
1072
1087
|
|
|
@@ -1154,8 +1169,8 @@ function createApiClient({
|
|
|
1154
1169
|
}
|
|
1155
1170
|
}
|
|
1156
1171
|
async function createThread(options) {
|
|
1157
|
-
const commentId = options.commentId
|
|
1158
|
-
const threadId = options.threadId
|
|
1172
|
+
const commentId = _nullishCoalesce(options.commentId, () => ( createCommentId()));
|
|
1173
|
+
const threadId = _nullishCoalesce(options.threadId, () => ( createThreadId()));
|
|
1159
1174
|
const thread = await httpClient.post(
|
|
1160
1175
|
url`/v2/c/rooms/${options.roomId}/threads`,
|
|
1161
1176
|
await authManager.getAuthValue({
|
|
@@ -1219,7 +1234,7 @@ function createApiClient({
|
|
|
1219
1234
|
);
|
|
1220
1235
|
}
|
|
1221
1236
|
async function createComment(options) {
|
|
1222
|
-
const commentId = options.commentId
|
|
1237
|
+
const commentId = _nullishCoalesce(options.commentId, () => ( createCommentId()));
|
|
1223
1238
|
const comment = await httpClient.post(
|
|
1224
1239
|
url`/v2/c/rooms/${options.roomId}/threads/${options.threadId}/comments`,
|
|
1225
1240
|
await authManager.getAuthValue({
|
|
@@ -1303,11 +1318,11 @@ function createApiClient({
|
|
|
1303
1318
|
`Upload of attachment ${options.attachment.id} was aborted.`,
|
|
1304
1319
|
"AbortError"
|
|
1305
1320
|
) : void 0;
|
|
1306
|
-
if (abortSignal
|
|
1321
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _12 => _12.aborted])) {
|
|
1307
1322
|
throw abortError;
|
|
1308
1323
|
}
|
|
1309
1324
|
const handleRetryError = (err) => {
|
|
1310
|
-
if (abortSignal
|
|
1325
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _13 => _13.aborted])) {
|
|
1311
1326
|
throw abortError;
|
|
1312
1327
|
}
|
|
1313
1328
|
if (err instanceof HttpError && err.status === 413) {
|
|
@@ -1379,7 +1394,7 @@ function createApiClient({
|
|
|
1379
1394
|
try {
|
|
1380
1395
|
uploadId = createMultiPartUpload.uploadId;
|
|
1381
1396
|
const parts = splitFileIntoParts(attachment.file);
|
|
1382
|
-
if (abortSignal
|
|
1397
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _14 => _14.aborted])) {
|
|
1383
1398
|
throw abortError;
|
|
1384
1399
|
}
|
|
1385
1400
|
const batches = chunk(parts, 5);
|
|
@@ -1406,7 +1421,7 @@ function createApiClient({
|
|
|
1406
1421
|
}
|
|
1407
1422
|
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
1408
1423
|
}
|
|
1409
|
-
if (abortSignal
|
|
1424
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _15 => _15.aborted])) {
|
|
1410
1425
|
throw abortError;
|
|
1411
1426
|
}
|
|
1412
1427
|
const sortedUploadedParts = uploadedParts.sort(
|
|
@@ -1422,7 +1437,7 @@ function createApiClient({
|
|
|
1422
1437
|
{ signal: abortSignal }
|
|
1423
1438
|
);
|
|
1424
1439
|
} catch (error3) {
|
|
1425
|
-
if (uploadId && error3
|
|
1440
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _16 => _16.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
1426
1441
|
try {
|
|
1427
1442
|
await httpClient.rawDelete(
|
|
1428
1443
|
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
@@ -1451,7 +1466,7 @@ function createApiClient({
|
|
|
1451
1466
|
{ attachmentIds }
|
|
1452
1467
|
);
|
|
1453
1468
|
return urls.map(
|
|
1454
|
-
(url2) => url2
|
|
1469
|
+
(url2) => _nullishCoalesce(url2, () => ( new Error("There was an error while getting this attachment's URL")))
|
|
1455
1470
|
);
|
|
1456
1471
|
},
|
|
1457
1472
|
{ delay: 50 }
|
|
@@ -1652,7 +1667,7 @@ function createApiClient({
|
|
|
1652
1667
|
url`/v2/c/inbox-notifications`,
|
|
1653
1668
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
1654
1669
|
{
|
|
1655
|
-
cursor: options
|
|
1670
|
+
cursor: _optionalChain([options, 'optionalAccess', _17 => _17.cursor]),
|
|
1656
1671
|
limit: PAGE_SIZE
|
|
1657
1672
|
}
|
|
1658
1673
|
);
|
|
@@ -1739,7 +1754,7 @@ function createApiClient({
|
|
|
1739
1754
|
url`/v2/c/notification-settings`,
|
|
1740
1755
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
1741
1756
|
void 0,
|
|
1742
|
-
{ signal: options
|
|
1757
|
+
{ signal: _optionalChain([options, 'optionalAccess', _18 => _18.signal]) }
|
|
1743
1758
|
);
|
|
1744
1759
|
}
|
|
1745
1760
|
async function updateUserNotificationSettings(settings) {
|
|
@@ -1751,7 +1766,7 @@ function createApiClient({
|
|
|
1751
1766
|
}
|
|
1752
1767
|
async function getUserThreads_experimental(options) {
|
|
1753
1768
|
let query;
|
|
1754
|
-
if (options
|
|
1769
|
+
if (_optionalChain([options, 'optionalAccess', _19 => _19.query])) {
|
|
1755
1770
|
query = objectToQuery(options.query);
|
|
1756
1771
|
}
|
|
1757
1772
|
const PAGE_SIZE = 50;
|
|
@@ -1759,7 +1774,7 @@ function createApiClient({
|
|
|
1759
1774
|
url`/v2/c/threads`,
|
|
1760
1775
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
1761
1776
|
{
|
|
1762
|
-
cursor: options
|
|
1777
|
+
cursor: _optionalChain([options, 'optionalAccess', _20 => _20.cursor]),
|
|
1763
1778
|
query,
|
|
1764
1779
|
limit: PAGE_SIZE
|
|
1765
1780
|
}
|
|
@@ -1888,7 +1903,7 @@ var HttpClient = class {
|
|
|
1888
1903
|
// These headers are default, but can be overriden by custom headers
|
|
1889
1904
|
"Content-Type": "application/json; charset=utf-8",
|
|
1890
1905
|
// Possible header overrides
|
|
1891
|
-
...options
|
|
1906
|
+
..._optionalChain([options, 'optionalAccess', _21 => _21.headers]),
|
|
1892
1907
|
// Cannot be overriden by custom headers
|
|
1893
1908
|
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
1894
1909
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
@@ -1917,7 +1932,7 @@ var HttpClient = class {
|
|
|
1917
1932
|
let body;
|
|
1918
1933
|
try {
|
|
1919
1934
|
body = await response.json();
|
|
1920
|
-
} catch {
|
|
1935
|
+
} catch (e4) {
|
|
1921
1936
|
body = {};
|
|
1922
1937
|
}
|
|
1923
1938
|
return body;
|
|
@@ -1938,7 +1953,7 @@ var HttpClient = class {
|
|
|
1938
1953
|
async rawPost(endpoint, authValue, body) {
|
|
1939
1954
|
return await this.#rawFetch(endpoint, authValue, {
|
|
1940
1955
|
method: "POST",
|
|
1941
|
-
body:
|
|
1956
|
+
body: stringifyOrLog(body)
|
|
1942
1957
|
});
|
|
1943
1958
|
}
|
|
1944
1959
|
/**
|
|
@@ -1967,7 +1982,7 @@ var HttpClient = class {
|
|
|
1967
1982
|
{
|
|
1968
1983
|
...options,
|
|
1969
1984
|
method: "POST",
|
|
1970
|
-
body:
|
|
1985
|
+
body: stringifyOrLog(body)
|
|
1971
1986
|
},
|
|
1972
1987
|
params
|
|
1973
1988
|
);
|
|
@@ -2093,7 +2108,7 @@ var SafeContext = class {
|
|
|
2093
2108
|
};
|
|
2094
2109
|
var nextId = 1;
|
|
2095
2110
|
var FSM = class {
|
|
2096
|
-
|
|
2111
|
+
|
|
2097
2112
|
// Indicates whether this state machine is still being configured, has
|
|
2098
2113
|
// started, or has terminated
|
|
2099
2114
|
#runningState;
|
|
@@ -2102,7 +2117,7 @@ var FSM = class {
|
|
|
2102
2117
|
#currentStateOrNull;
|
|
2103
2118
|
#allowedTransitions;
|
|
2104
2119
|
#eventHub;
|
|
2105
|
-
|
|
2120
|
+
|
|
2106
2121
|
//
|
|
2107
2122
|
// The cleanup stack is a stack of (optional) callback functions that will
|
|
2108
2123
|
// be run when exiting the current state. If a state (or state group) does
|
|
@@ -2363,7 +2378,7 @@ var FSM = class {
|
|
|
2363
2378
|
});
|
|
2364
2379
|
}
|
|
2365
2380
|
#getTargetFn(eventName) {
|
|
2366
|
-
return this.#allowedTransitions.get(this.currentState)
|
|
2381
|
+
return _optionalChain([this, 'access', _22 => _22.#allowedTransitions, 'access', _23 => _23.get, 'call', _24 => _24(this.currentState), 'optionalAccess', _25 => _25.get, 'call', _26 => _26(eventName)]);
|
|
2367
2382
|
}
|
|
2368
2383
|
/**
|
|
2369
2384
|
* Exits the current state, and executes any necessary cleanup functions.
|
|
@@ -2378,9 +2393,9 @@ var FSM = class {
|
|
|
2378
2393
|
#exit(levels) {
|
|
2379
2394
|
this.#eventHub.willExitState.notify(this.currentState);
|
|
2380
2395
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
2381
|
-
levels = levels
|
|
2396
|
+
levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
|
|
2382
2397
|
for (let i = 0; i < levels; i++) {
|
|
2383
|
-
this.#cleanupStack.pop()
|
|
2398
|
+
_optionalChain([this, 'access', _27 => _27.#cleanupStack, 'access', _28 => _28.pop, 'call', _29 => _29(), 'optionalCall', _30 => _30(patchableContext)]);
|
|
2384
2399
|
}
|
|
2385
2400
|
});
|
|
2386
2401
|
}
|
|
@@ -2391,12 +2406,12 @@ var FSM = class {
|
|
|
2391
2406
|
#enter(levels) {
|
|
2392
2407
|
const enterPatterns = patterns(
|
|
2393
2408
|
this.currentState,
|
|
2394
|
-
levels
|
|
2409
|
+
_nullishCoalesce(levels, () => ( this.currentState.split(".").length + 1))
|
|
2395
2410
|
);
|
|
2396
2411
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
2397
2412
|
for (const pattern of enterPatterns) {
|
|
2398
2413
|
const enterFn = this.#enterFns.get(pattern);
|
|
2399
|
-
const cleanupFn = enterFn
|
|
2414
|
+
const cleanupFn = _optionalChain([enterFn, 'optionalCall', _31 => _31(patchableContext)]);
|
|
2400
2415
|
if (typeof cleanupFn === "function") {
|
|
2401
2416
|
this.#cleanupStack.push(cleanupFn);
|
|
2402
2417
|
} else {
|
|
@@ -2557,7 +2572,7 @@ var StopRetrying = class extends Error {
|
|
|
2557
2572
|
}
|
|
2558
2573
|
};
|
|
2559
2574
|
function nextBackoffDelay(currentDelay, delays) {
|
|
2560
|
-
return delays.find((delay) => delay > currentDelay)
|
|
2575
|
+
return _nullishCoalesce(delays.find((delay) => delay > currentDelay), () => ( delays[delays.length - 1]));
|
|
2561
2576
|
}
|
|
2562
2577
|
function increaseBackoffDelay(context) {
|
|
2563
2578
|
context.patch({
|
|
@@ -2790,7 +2805,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2790
2805
|
}
|
|
2791
2806
|
function waitForActorId(event) {
|
|
2792
2807
|
const serverMsg = tryParseJson(event.data);
|
|
2793
|
-
if (serverMsg
|
|
2808
|
+
if (_optionalChain([serverMsg, 'optionalAccess', _32 => _32.type]) === 104 /* ROOM_STATE */) {
|
|
2794
2809
|
didReceiveActor();
|
|
2795
2810
|
}
|
|
2796
2811
|
}
|
|
@@ -2899,12 +2914,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2899
2914
|
const sendHeartbeat = {
|
|
2900
2915
|
target: "@ok.awaiting-pong",
|
|
2901
2916
|
effect: (ctx) => {
|
|
2902
|
-
ctx.socket
|
|
2917
|
+
_optionalChain([ctx, 'access', _33 => _33.socket, 'optionalAccess', _34 => _34.send, 'call', _35 => _35("ping")]);
|
|
2903
2918
|
}
|
|
2904
2919
|
};
|
|
2905
2920
|
const maybeHeartbeat = () => {
|
|
2906
2921
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
2907
|
-
const canZombie = doc
|
|
2922
|
+
const canZombie = _optionalChain([doc, 'optionalAccess', _36 => _36.visibilityState]) === "hidden" && delegates.canZombie();
|
|
2908
2923
|
return canZombie ? "@idle.zombie" : sendHeartbeat;
|
|
2909
2924
|
};
|
|
2910
2925
|
machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
|
|
@@ -2943,7 +2958,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2943
2958
|
// socket, or not. So always check to see if the socket is still OPEN or
|
|
2944
2959
|
// not. When still OPEN, don't transition.
|
|
2945
2960
|
EXPLICIT_SOCKET_ERROR: (_, context) => {
|
|
2946
|
-
if (context.socket
|
|
2961
|
+
if (_optionalChain([context, 'access', _37 => _37.socket, 'optionalAccess', _38 => _38.readyState]) === 1) {
|
|
2947
2962
|
return null;
|
|
2948
2963
|
}
|
|
2949
2964
|
return {
|
|
@@ -2986,7 +3001,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2986
3001
|
if (typeof document !== "undefined") {
|
|
2987
3002
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
2988
3003
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
2989
|
-
const root = win
|
|
3004
|
+
const root = _nullishCoalesce(win, () => ( doc));
|
|
2990
3005
|
machine.onEnter("*", (ctx) => {
|
|
2991
3006
|
function onNetworkOffline() {
|
|
2992
3007
|
machine.send({ type: "NAVIGATOR_OFFLINE" });
|
|
@@ -2995,17 +3010,17 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2995
3010
|
machine.send({ type: "NAVIGATOR_ONLINE" });
|
|
2996
3011
|
}
|
|
2997
3012
|
function onVisibilityChange() {
|
|
2998
|
-
if (doc
|
|
3013
|
+
if (_optionalChain([doc, 'optionalAccess', _39 => _39.visibilityState]) === "visible") {
|
|
2999
3014
|
machine.send({ type: "WINDOW_GOT_FOCUS" });
|
|
3000
3015
|
}
|
|
3001
3016
|
}
|
|
3002
|
-
win
|
|
3003
|
-
win
|
|
3004
|
-
root
|
|
3017
|
+
_optionalChain([win, 'optionalAccess', _40 => _40.addEventListener, 'call', _41 => _41("online", onNetworkBackOnline)]);
|
|
3018
|
+
_optionalChain([win, 'optionalAccess', _42 => _42.addEventListener, 'call', _43 => _43("offline", onNetworkOffline)]);
|
|
3019
|
+
_optionalChain([root, 'optionalAccess', _44 => _44.addEventListener, 'call', _45 => _45("visibilitychange", onVisibilityChange)]);
|
|
3005
3020
|
return () => {
|
|
3006
|
-
root
|
|
3007
|
-
win
|
|
3008
|
-
win
|
|
3021
|
+
_optionalChain([root, 'optionalAccess', _46 => _46.removeEventListener, 'call', _47 => _47("visibilitychange", onVisibilityChange)]);
|
|
3022
|
+
_optionalChain([win, 'optionalAccess', _48 => _48.removeEventListener, 'call', _49 => _49("online", onNetworkBackOnline)]);
|
|
3023
|
+
_optionalChain([win, 'optionalAccess', _50 => _50.removeEventListener, 'call', _51 => _51("offline", onNetworkOffline)]);
|
|
3009
3024
|
teardownSocket(ctx.socket);
|
|
3010
3025
|
};
|
|
3011
3026
|
});
|
|
@@ -3033,7 +3048,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3033
3048
|
var ManagedSocket = class {
|
|
3034
3049
|
#machine;
|
|
3035
3050
|
#cleanups;
|
|
3036
|
-
|
|
3051
|
+
|
|
3037
3052
|
constructor(delegates, enableDebugLogging = false, waitForActorId = true) {
|
|
3038
3053
|
const { machine, events, cleanups } = createConnectionStateMachine(
|
|
3039
3054
|
delegates,
|
|
@@ -3046,7 +3061,7 @@ var ManagedSocket = class {
|
|
|
3046
3061
|
getStatus() {
|
|
3047
3062
|
try {
|
|
3048
3063
|
return toNewConnectionStatus(this.#machine);
|
|
3049
|
-
} catch {
|
|
3064
|
+
} catch (e5) {
|
|
3050
3065
|
return "initial";
|
|
3051
3066
|
}
|
|
3052
3067
|
}
|
|
@@ -3094,7 +3109,7 @@ var ManagedSocket = class {
|
|
|
3094
3109
|
* message if this is somehow impossible.
|
|
3095
3110
|
*/
|
|
3096
3111
|
send(data) {
|
|
3097
|
-
const socket = this.#machine.context
|
|
3112
|
+
const socket = _optionalChain([this, 'access', _52 => _52.#machine, 'access', _53 => _53.context, 'optionalAccess', _54 => _54.socket]);
|
|
3098
3113
|
if (socket === null) {
|
|
3099
3114
|
warn("Cannot send: not connected yet", data);
|
|
3100
3115
|
} else if (socket.readyState !== 1) {
|
|
@@ -3198,7 +3213,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
3198
3213
|
return void 0;
|
|
3199
3214
|
}
|
|
3200
3215
|
async function makeAuthRequest(options) {
|
|
3201
|
-
const fetcher = authOptions.polyfills
|
|
3216
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _55 => _55.polyfills, 'optionalAccess', _56 => _56.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
3202
3217
|
if (authentication.type === "private") {
|
|
3203
3218
|
if (fetcher === void 0) {
|
|
3204
3219
|
throw new StopRetrying(
|
|
@@ -3214,7 +3229,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
3214
3229
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
3215
3230
|
);
|
|
3216
3231
|
}
|
|
3217
|
-
onAuthenticate
|
|
3232
|
+
_optionalChain([onAuthenticate, 'optionalCall', _57 => _57(parsed.parsed)]);
|
|
3218
3233
|
return parsed;
|
|
3219
3234
|
}
|
|
3220
3235
|
if (authentication.type === "custom") {
|
|
@@ -3222,7 +3237,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
3222
3237
|
if (response && typeof response === "object") {
|
|
3223
3238
|
if (typeof response.token === "string") {
|
|
3224
3239
|
const parsed = parseAuthToken(response.token);
|
|
3225
|
-
onAuthenticate
|
|
3240
|
+
_optionalChain([onAuthenticate, 'optionalCall', _58 => _58(parsed.parsed)]);
|
|
3226
3241
|
return parsed;
|
|
3227
3242
|
} else if (typeof response.error === "string") {
|
|
3228
3243
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -3333,7 +3348,7 @@ async function fetchAuthEndpoint(fetch, endpoint, body) {
|
|
|
3333
3348
|
headers: {
|
|
3334
3349
|
"Content-Type": "application/json"
|
|
3335
3350
|
},
|
|
3336
|
-
body:
|
|
3351
|
+
body: stringifyOrLog(body)
|
|
3337
3352
|
});
|
|
3338
3353
|
if (!res.ok) {
|
|
3339
3354
|
const reason = `${(await res.text()).trim() || "reason not provided in auth response"} (${res.status} returned by POST ${endpoint})`;
|
|
@@ -3355,7 +3370,7 @@ async function fetchAuthEndpoint(fetch, endpoint, body) {
|
|
|
3355
3370
|
}
|
|
3356
3371
|
if (!isPlainObject(data) || typeof data.token !== "string") {
|
|
3357
3372
|
throw new Error(
|
|
3358
|
-
`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${endpoint}", but got ${
|
|
3373
|
+
`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${endpoint}", but got ${stringifyOrLog(
|
|
3359
3374
|
data
|
|
3360
3375
|
)}`
|
|
3361
3376
|
);
|
|
@@ -3383,7 +3398,7 @@ function sendToPanel(message, options) {
|
|
|
3383
3398
|
...message,
|
|
3384
3399
|
source: "liveblocks-devtools-client"
|
|
3385
3400
|
};
|
|
3386
|
-
if (!(options
|
|
3401
|
+
if (!(_optionalChain([options, 'optionalAccess', _59 => _59.force]) || _bridgeActive)) {
|
|
3387
3402
|
return;
|
|
3388
3403
|
}
|
|
3389
3404
|
window.postMessage(fullMsg, "*");
|
|
@@ -3391,7 +3406,7 @@ function sendToPanel(message, options) {
|
|
|
3391
3406
|
var eventSource = makeEventSource();
|
|
3392
3407
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
3393
3408
|
window.addEventListener("message", (event) => {
|
|
3394
|
-
if (event.source === window && event.data
|
|
3409
|
+
if (event.source === window && _optionalChain([event, 'access', _60 => _60.data, 'optionalAccess', _61 => _61.source]) === "liveblocks-devtools-panel") {
|
|
3395
3410
|
eventSource.notify(event.data);
|
|
3396
3411
|
} else {
|
|
3397
3412
|
}
|
|
@@ -3435,7 +3450,7 @@ function setupDevTools(getAllRooms) {
|
|
|
3435
3450
|
}
|
|
3436
3451
|
var unsubsByRoomId = /* @__PURE__ */ new Map();
|
|
3437
3452
|
function stopSyncStream(roomId) {
|
|
3438
|
-
const unsubs = unsubsByRoomId.get(roomId)
|
|
3453
|
+
const unsubs = _nullishCoalesce(unsubsByRoomId.get(roomId), () => ( []));
|
|
3439
3454
|
unsubsByRoomId.delete(roomId);
|
|
3440
3455
|
for (const unsub of unsubs) {
|
|
3441
3456
|
unsub();
|
|
@@ -3533,7 +3548,7 @@ function fullSync(room) {
|
|
|
3533
3548
|
msg: "room::sync::full",
|
|
3534
3549
|
roomId: room.id,
|
|
3535
3550
|
status: room.getStatus(),
|
|
3536
|
-
storage: root
|
|
3551
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _62 => _62.toTreeNode, 'call', _63 => _63("root"), 'access', _64 => _64.payload]), () => ( null)),
|
|
3537
3552
|
me,
|
|
3538
3553
|
others
|
|
3539
3554
|
});
|
|
@@ -3588,6 +3603,72 @@ function unlinkDevTools(roomId) {
|
|
|
3588
3603
|
});
|
|
3589
3604
|
}
|
|
3590
3605
|
|
|
3606
|
+
// src/protocol/UserNotificationSettings.ts
|
|
3607
|
+
var kPrivate = Symbol("user-notification-settings-private");
|
|
3608
|
+
function createUserNotificationSettings(plain) {
|
|
3609
|
+
const channels = [
|
|
3610
|
+
"email",
|
|
3611
|
+
"slack",
|
|
3612
|
+
"teams",
|
|
3613
|
+
"webPush"
|
|
3614
|
+
];
|
|
3615
|
+
const descriptors = {
|
|
3616
|
+
[kPrivate]: {
|
|
3617
|
+
value: {
|
|
3618
|
+
__plain__: plain
|
|
3619
|
+
},
|
|
3620
|
+
enumerable: false
|
|
3621
|
+
}
|
|
3622
|
+
};
|
|
3623
|
+
for (const channel of channels) {
|
|
3624
|
+
descriptors[channel] = {
|
|
3625
|
+
enumerable: true,
|
|
3626
|
+
/**
|
|
3627
|
+
* In the TypeScript standard library definitions, the built-in interface for a property descriptor
|
|
3628
|
+
* does not include a specialized type for the “this” context in the getter or setter functions.
|
|
3629
|
+
* As a result, both the get and set methods implicitly have this: any.
|
|
3630
|
+
* The reason is that property descriptors in JavaScript are used across various objects with
|
|
3631
|
+
* no enforced shape for this. And so the standard library definitions have to remain as broad as possible
|
|
3632
|
+
* to support any valid JavaScript usage (e.g `Object.defineProperty`).
|
|
3633
|
+
*
|
|
3634
|
+
* So we can safely tells that this getter is typed as `this: UserNotificationSettings` because we're
|
|
3635
|
+
* creating a well known shaped object → `UserNotificationSettings`.
|
|
3636
|
+
*/
|
|
3637
|
+
get() {
|
|
3638
|
+
const value = this[kPrivate].__plain__[channel];
|
|
3639
|
+
if (!value) {
|
|
3640
|
+
raise(
|
|
3641
|
+
`In order to use the '${channel}' channel, please set up your project first. See <link to docs>`
|
|
3642
|
+
);
|
|
3643
|
+
}
|
|
3644
|
+
return value;
|
|
3645
|
+
}
|
|
3646
|
+
};
|
|
3647
|
+
}
|
|
3648
|
+
return create(null, descriptors);
|
|
3649
|
+
}
|
|
3650
|
+
function patchUserNotificationSettings(existing, patch) {
|
|
3651
|
+
const outcoming = createUserNotificationSettings({
|
|
3652
|
+
...existing[kPrivate].__plain__
|
|
3653
|
+
});
|
|
3654
|
+
for (const channel of keys(patch)) {
|
|
3655
|
+
const updates = patch[channel];
|
|
3656
|
+
if (updates !== void 0) {
|
|
3657
|
+
const kindUpdates = Object.fromEntries(
|
|
3658
|
+
entries(updates).filter(([, value]) => value !== void 0)
|
|
3659
|
+
);
|
|
3660
|
+
outcoming[kPrivate].__plain__[channel] = {
|
|
3661
|
+
...outcoming[kPrivate].__plain__[channel],
|
|
3662
|
+
...kindUpdates
|
|
3663
|
+
};
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
return outcoming;
|
|
3667
|
+
}
|
|
3668
|
+
function isNotificationChannelEnabled(settings) {
|
|
3669
|
+
return values(settings).every((enabled) => enabled === true);
|
|
3670
|
+
}
|
|
3671
|
+
|
|
3591
3672
|
// src/lib/position.ts
|
|
3592
3673
|
var MIN_CODE = 32;
|
|
3593
3674
|
var MAX_CODE = 126;
|
|
@@ -3957,7 +4038,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
3957
4038
|
return [
|
|
3958
4039
|
{
|
|
3959
4040
|
type: 8 /* CREATE_REGISTER */,
|
|
3960
|
-
opId: pool
|
|
4041
|
+
opId: _optionalChain([pool, 'optionalAccess', _65 => _65.generateOpId, 'call', _66 => _66()]),
|
|
3961
4042
|
id: this._id,
|
|
3962
4043
|
parentId,
|
|
3963
4044
|
parentKey,
|
|
@@ -3993,7 +4074,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
3993
4074
|
_toTreeNode(key) {
|
|
3994
4075
|
return {
|
|
3995
4076
|
type: "Json",
|
|
3996
|
-
id: this._id
|
|
4077
|
+
id: _nullishCoalesce(this._id, () => ( nanoid())),
|
|
3997
4078
|
key,
|
|
3998
4079
|
payload: this.#data
|
|
3999
4080
|
};
|
|
@@ -4063,7 +4144,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4063
4144
|
const ops = [];
|
|
4064
4145
|
const op = {
|
|
4065
4146
|
id: this._id,
|
|
4066
|
-
opId: pool
|
|
4147
|
+
opId: _optionalChain([pool, 'optionalAccess', _67 => _67.generateOpId, 'call', _68 => _68()]),
|
|
4067
4148
|
type: 2 /* CREATE_LIST */,
|
|
4068
4149
|
parentId,
|
|
4069
4150
|
parentKey
|
|
@@ -4334,7 +4415,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4334
4415
|
#applyInsertUndoRedo(op) {
|
|
4335
4416
|
const { id, parentKey: key } = op;
|
|
4336
4417
|
const child = creationOpToLiveNode(op);
|
|
4337
|
-
if (this._pool
|
|
4418
|
+
if (_optionalChain([this, 'access', _69 => _69._pool, 'optionalAccess', _70 => _70.getNode, 'call', _71 => _71(id)]) !== void 0) {
|
|
4338
4419
|
return { modified: false };
|
|
4339
4420
|
}
|
|
4340
4421
|
child._attach(id, nn(this._pool));
|
|
@@ -4342,8 +4423,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4342
4423
|
const existingItemIndex = this._indexOfPosition(key);
|
|
4343
4424
|
let newKey = key;
|
|
4344
4425
|
if (existingItemIndex !== -1) {
|
|
4345
|
-
const before2 = this.#items[existingItemIndex]
|
|
4346
|
-
const after2 = this.#items[existingItemIndex + 1]
|
|
4426
|
+
const before2 = _optionalChain([this, 'access', _72 => _72.#items, 'access', _73 => _73[existingItemIndex], 'optionalAccess', _74 => _74._parentPos]);
|
|
4427
|
+
const after2 = _optionalChain([this, 'access', _75 => _75.#items, 'access', _76 => _76[existingItemIndex + 1], 'optionalAccess', _77 => _77._parentPos]);
|
|
4347
4428
|
newKey = makePosition(before2, after2);
|
|
4348
4429
|
child._setParentLink(this, newKey);
|
|
4349
4430
|
}
|
|
@@ -4357,7 +4438,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4357
4438
|
#applySetUndoRedo(op) {
|
|
4358
4439
|
const { id, parentKey: key } = op;
|
|
4359
4440
|
const child = creationOpToLiveNode(op);
|
|
4360
|
-
if (this._pool
|
|
4441
|
+
if (_optionalChain([this, 'access', _78 => _78._pool, 'optionalAccess', _79 => _79.getNode, 'call', _80 => _80(id)]) !== void 0) {
|
|
4361
4442
|
return { modified: false };
|
|
4362
4443
|
}
|
|
4363
4444
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -4478,7 +4559,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4478
4559
|
} else {
|
|
4479
4560
|
this.#items[existingItemIndex]._setParentLink(
|
|
4480
4561
|
this,
|
|
4481
|
-
makePosition(newKey, this.#items[existingItemIndex + 1]
|
|
4562
|
+
makePosition(newKey, _optionalChain([this, 'access', _81 => _81.#items, 'access', _82 => _82[existingItemIndex + 1], 'optionalAccess', _83 => _83._parentPos]))
|
|
4482
4563
|
);
|
|
4483
4564
|
const previousIndex = this.#items.indexOf(child);
|
|
4484
4565
|
child._setParentLink(this, newKey);
|
|
@@ -4503,7 +4584,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4503
4584
|
if (existingItemIndex !== -1) {
|
|
4504
4585
|
this.#items[existingItemIndex]._setParentLink(
|
|
4505
4586
|
this,
|
|
4506
|
-
makePosition(newKey, this.#items[existingItemIndex + 1]
|
|
4587
|
+
makePosition(newKey, _optionalChain([this, 'access', _84 => _84.#items, 'access', _85 => _85[existingItemIndex + 1], 'optionalAccess', _86 => _86._parentPos]))
|
|
4507
4588
|
);
|
|
4508
4589
|
}
|
|
4509
4590
|
child._setParentLink(this, newKey);
|
|
@@ -4522,7 +4603,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4522
4603
|
if (existingItemIndex !== -1) {
|
|
4523
4604
|
this.#items[existingItemIndex]._setParentLink(
|
|
4524
4605
|
this,
|
|
4525
|
-
makePosition(newKey, this.#items[existingItemIndex + 1]
|
|
4606
|
+
makePosition(newKey, _optionalChain([this, 'access', _87 => _87.#items, 'access', _88 => _88[existingItemIndex + 1], 'optionalAccess', _89 => _89._parentPos]))
|
|
4526
4607
|
);
|
|
4527
4608
|
}
|
|
4528
4609
|
child._setParentLink(this, newKey);
|
|
@@ -4549,7 +4630,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4549
4630
|
if (existingItemIndex !== -1) {
|
|
4550
4631
|
this.#items[existingItemIndex]._setParentLink(
|
|
4551
4632
|
this,
|
|
4552
|
-
makePosition(newKey, this.#items[existingItemIndex + 1]
|
|
4633
|
+
makePosition(newKey, _optionalChain([this, 'access', _90 => _90.#items, 'access', _91 => _91[existingItemIndex + 1], 'optionalAccess', _92 => _92._parentPos]))
|
|
4553
4634
|
);
|
|
4554
4635
|
}
|
|
4555
4636
|
child._setParentLink(this, newKey);
|
|
@@ -4607,7 +4688,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4607
4688
|
* @param element The element to add to the end of the LiveList.
|
|
4608
4689
|
*/
|
|
4609
4690
|
push(element) {
|
|
4610
|
-
this._pool
|
|
4691
|
+
_optionalChain([this, 'access', _93 => _93._pool, 'optionalAccess', _94 => _94.assertStorageIsWritable, 'call', _95 => _95()]);
|
|
4611
4692
|
return this.insert(element, this.length);
|
|
4612
4693
|
}
|
|
4613
4694
|
/**
|
|
@@ -4616,7 +4697,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4616
4697
|
* @param index The index at which you want to insert the element.
|
|
4617
4698
|
*/
|
|
4618
4699
|
insert(element, index) {
|
|
4619
|
-
this._pool
|
|
4700
|
+
_optionalChain([this, 'access', _96 => _96._pool, 'optionalAccess', _97 => _97.assertStorageIsWritable, 'call', _98 => _98()]);
|
|
4620
4701
|
if (index < 0 || index > this.#items.length) {
|
|
4621
4702
|
throw new Error(
|
|
4622
4703
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -4646,7 +4727,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4646
4727
|
* @param targetIndex The index where the element should be after moving.
|
|
4647
4728
|
*/
|
|
4648
4729
|
move(index, targetIndex) {
|
|
4649
|
-
this._pool
|
|
4730
|
+
_optionalChain([this, 'access', _99 => _99._pool, 'optionalAccess', _100 => _100.assertStorageIsWritable, 'call', _101 => _101()]);
|
|
4650
4731
|
if (targetIndex < 0) {
|
|
4651
4732
|
throw new Error("targetIndex cannot be less than 0");
|
|
4652
4733
|
}
|
|
@@ -4704,7 +4785,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4704
4785
|
* @param index The index of the element to delete
|
|
4705
4786
|
*/
|
|
4706
4787
|
delete(index) {
|
|
4707
|
-
this._pool
|
|
4788
|
+
_optionalChain([this, 'access', _102 => _102._pool, 'optionalAccess', _103 => _103.assertStorageIsWritable, 'call', _104 => _104()]);
|
|
4708
4789
|
if (index < 0 || index >= this.#items.length) {
|
|
4709
4790
|
throw new Error(
|
|
4710
4791
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -4737,7 +4818,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4737
4818
|
}
|
|
4738
4819
|
}
|
|
4739
4820
|
clear() {
|
|
4740
|
-
this._pool
|
|
4821
|
+
_optionalChain([this, 'access', _105 => _105._pool, 'optionalAccess', _106 => _106.assertStorageIsWritable, 'call', _107 => _107()]);
|
|
4741
4822
|
if (this._pool) {
|
|
4742
4823
|
const ops = [];
|
|
4743
4824
|
const reverseOps = [];
|
|
@@ -4771,7 +4852,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4771
4852
|
}
|
|
4772
4853
|
}
|
|
4773
4854
|
set(index, item) {
|
|
4774
|
-
this._pool
|
|
4855
|
+
_optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.assertStorageIsWritable, 'call', _110 => _110()]);
|
|
4775
4856
|
if (index < 0 || index >= this.#items.length) {
|
|
4776
4857
|
throw new Error(
|
|
4777
4858
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -4917,7 +4998,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4917
4998
|
#shiftItemPosition(index, key) {
|
|
4918
4999
|
const shiftedPosition = makePosition(
|
|
4919
5000
|
key,
|
|
4920
|
-
this.#items.length > index + 1 ? this.#items[index + 1]
|
|
5001
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _111 => _111.#items, 'access', _112 => _112[index + 1], 'optionalAccess', _113 => _113._parentPos]) : void 0
|
|
4921
5002
|
);
|
|
4922
5003
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
4923
5004
|
}
|
|
@@ -4925,7 +5006,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4925
5006
|
_toTreeNode(key) {
|
|
4926
5007
|
return {
|
|
4927
5008
|
type: "LiveList",
|
|
4928
|
-
id: this._id
|
|
5009
|
+
id: _nullishCoalesce(this._id, () => ( nanoid())),
|
|
4929
5010
|
key,
|
|
4930
5011
|
payload: this.#items.map(
|
|
4931
5012
|
(item, index) => item.toTreeNode(index.toString())
|
|
@@ -5042,7 +5123,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
5042
5123
|
const ops = [];
|
|
5043
5124
|
const op = {
|
|
5044
5125
|
id: this._id,
|
|
5045
|
-
opId: pool
|
|
5126
|
+
opId: _optionalChain([pool, 'optionalAccess', _114 => _114.generateOpId, 'call', _115 => _115()]),
|
|
5046
5127
|
type: 7 /* CREATE_MAP */,
|
|
5047
5128
|
parentId,
|
|
5048
5129
|
parentKey
|
|
@@ -5177,7 +5258,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
5177
5258
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
5178
5259
|
*/
|
|
5179
5260
|
set(key, value) {
|
|
5180
|
-
this._pool
|
|
5261
|
+
_optionalChain([this, 'access', _116 => _116._pool, 'optionalAccess', _117 => _117.assertStorageIsWritable, 'call', _118 => _118()]);
|
|
5181
5262
|
const oldValue = this.#map.get(key);
|
|
5182
5263
|
if (oldValue) {
|
|
5183
5264
|
oldValue._detach();
|
|
@@ -5223,7 +5304,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
5223
5304
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
5224
5305
|
*/
|
|
5225
5306
|
delete(key) {
|
|
5226
|
-
this._pool
|
|
5307
|
+
_optionalChain([this, 'access', _119 => _119._pool, 'optionalAccess', _120 => _120.assertStorageIsWritable, 'call', _121 => _121()]);
|
|
5227
5308
|
const item = this.#map.get(key);
|
|
5228
5309
|
if (item === void 0) {
|
|
5229
5310
|
return false;
|
|
@@ -5326,7 +5407,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
5326
5407
|
_toTreeNode(key) {
|
|
5327
5408
|
return {
|
|
5328
5409
|
type: "LiveMap",
|
|
5329
|
-
id: this._id
|
|
5410
|
+
id: _nullishCoalesce(this._id, () => ( nanoid())),
|
|
5330
5411
|
key,
|
|
5331
5412
|
payload: Array.from(this.#map.entries()).map(
|
|
5332
5413
|
([key2, val]) => val.toTreeNode(key2)
|
|
@@ -5402,7 +5483,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5402
5483
|
if (this._id === void 0) {
|
|
5403
5484
|
throw new Error("Cannot serialize item is not attached");
|
|
5404
5485
|
}
|
|
5405
|
-
const opId = pool
|
|
5486
|
+
const opId = _optionalChain([pool, 'optionalAccess', _122 => _122.generateOpId, 'call', _123 => _123()]);
|
|
5406
5487
|
const ops = [];
|
|
5407
5488
|
const op = {
|
|
5408
5489
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -5674,7 +5755,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5674
5755
|
* @param value The value of the property to add
|
|
5675
5756
|
*/
|
|
5676
5757
|
set(key, value) {
|
|
5677
|
-
this._pool
|
|
5758
|
+
_optionalChain([this, 'access', _124 => _124._pool, 'optionalAccess', _125 => _125.assertStorageIsWritable, 'call', _126 => _126()]);
|
|
5678
5759
|
this.update({ [key]: value });
|
|
5679
5760
|
}
|
|
5680
5761
|
/**
|
|
@@ -5689,7 +5770,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5689
5770
|
* @param key The key of the property to delete
|
|
5690
5771
|
*/
|
|
5691
5772
|
delete(key) {
|
|
5692
|
-
this._pool
|
|
5773
|
+
_optionalChain([this, 'access', _127 => _127._pool, 'optionalAccess', _128 => _128.assertStorageIsWritable, 'call', _129 => _129()]);
|
|
5693
5774
|
const keyAsString = key;
|
|
5694
5775
|
const oldValue = this.#map.get(keyAsString);
|
|
5695
5776
|
if (oldValue === void 0) {
|
|
@@ -5742,7 +5823,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5742
5823
|
* @param patch The object used to overrides properties
|
|
5743
5824
|
*/
|
|
5744
5825
|
update(patch) {
|
|
5745
|
-
this._pool
|
|
5826
|
+
_optionalChain([this, 'access', _130 => _130._pool, 'optionalAccess', _131 => _131.assertStorageIsWritable, 'call', _132 => _132()]);
|
|
5746
5827
|
if (this._pool === void 0 || this._id === void 0) {
|
|
5747
5828
|
for (const key in patch) {
|
|
5748
5829
|
const newValue = patch[key];
|
|
@@ -5832,7 +5913,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5832
5913
|
}
|
|
5833
5914
|
/** @internal */
|
|
5834
5915
|
_toTreeNode(key) {
|
|
5835
|
-
const nodeId = this._id
|
|
5916
|
+
const nodeId = _nullishCoalesce(this._id, () => ( nanoid()));
|
|
5836
5917
|
return {
|
|
5837
5918
|
type: "LiveObject",
|
|
5838
5919
|
id: nodeId,
|
|
@@ -5978,7 +6059,7 @@ function getTreesDiffOperations(currentItems, newItems) {
|
|
|
5978
6059
|
const currentCrdt = currentItems.get(id);
|
|
5979
6060
|
if (currentCrdt) {
|
|
5980
6061
|
if (crdt.type === 0 /* OBJECT */) {
|
|
5981
|
-
if (currentCrdt.type !== 0 /* OBJECT */ ||
|
|
6062
|
+
if (currentCrdt.type !== 0 /* OBJECT */ || stringifyOrLog(crdt.data) !== stringifyOrLog(currentCrdt.data)) {
|
|
5982
6063
|
ops.push({
|
|
5983
6064
|
type: 3 /* UPDATE_OBJECT */,
|
|
5984
6065
|
id,
|
|
@@ -6228,7 +6309,7 @@ var ManagedOthers = class {
|
|
|
6228
6309
|
#internal;
|
|
6229
6310
|
#userCache;
|
|
6230
6311
|
// The "clean" signal that is exposed to the outside world
|
|
6231
|
-
|
|
6312
|
+
|
|
6232
6313
|
constructor() {
|
|
6233
6314
|
this.#internal = new MutableSignal({
|
|
6234
6315
|
connections: /* @__PURE__ */ new Map(),
|
|
@@ -6350,7 +6431,7 @@ var ManagedOthers = class {
|
|
|
6350
6431
|
|
|
6351
6432
|
// src/types/LiveblocksError.ts
|
|
6352
6433
|
var LiveblocksError = class _LiveblocksError extends Error {
|
|
6353
|
-
|
|
6434
|
+
|
|
6354
6435
|
constructor(message, context, cause) {
|
|
6355
6436
|
super(message, { cause });
|
|
6356
6437
|
this.context = context;
|
|
@@ -6451,15 +6532,15 @@ function installBackgroundTabSpy() {
|
|
|
6451
6532
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
6452
6533
|
const inBackgroundSince = { current: null };
|
|
6453
6534
|
function onVisibilityChange() {
|
|
6454
|
-
if (doc
|
|
6455
|
-
inBackgroundSince.current = inBackgroundSince.current
|
|
6535
|
+
if (_optionalChain([doc, 'optionalAccess', _133 => _133.visibilityState]) === "hidden") {
|
|
6536
|
+
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
6456
6537
|
} else {
|
|
6457
6538
|
inBackgroundSince.current = null;
|
|
6458
6539
|
}
|
|
6459
6540
|
}
|
|
6460
|
-
doc
|
|
6541
|
+
_optionalChain([doc, 'optionalAccess', _134 => _134.addEventListener, 'call', _135 => _135("visibilitychange", onVisibilityChange)]);
|
|
6461
6542
|
const unsub = () => {
|
|
6462
|
-
doc
|
|
6543
|
+
_optionalChain([doc, 'optionalAccess', _136 => _136.removeEventListener, 'call', _137 => _137("visibilitychange", onVisibilityChange)]);
|
|
6463
6544
|
};
|
|
6464
6545
|
return [inBackgroundSince, unsub];
|
|
6465
6546
|
}
|
|
@@ -6644,7 +6725,7 @@ function createRoom(options, config) {
|
|
|
6644
6725
|
}
|
|
6645
6726
|
},
|
|
6646
6727
|
assertStorageIsWritable: () => {
|
|
6647
|
-
const scopes = context.dynamicSessionInfoSig.get()
|
|
6728
|
+
const scopes = _optionalChain([context, 'access', _138 => _138.dynamicSessionInfoSig, 'access', _139 => _139.get, 'call', _140 => _140(), 'optionalAccess', _141 => _141.scopes]);
|
|
6648
6729
|
if (scopes === void 0) {
|
|
6649
6730
|
return;
|
|
6650
6731
|
}
|
|
@@ -6714,7 +6795,7 @@ function createRoom(options, config) {
|
|
|
6714
6795
|
const secondHalf = ops.slice(mid);
|
|
6715
6796
|
for (const halfOps of [firstHalf, secondHalf]) {
|
|
6716
6797
|
const half = { ops: halfOps, ...rest };
|
|
6717
|
-
const text =
|
|
6798
|
+
const text = stringifyOrLog([half]);
|
|
6718
6799
|
if (!isTooBigForWebSocket(text)) {
|
|
6719
6800
|
yield text;
|
|
6720
6801
|
} else {
|
|
@@ -6737,7 +6818,7 @@ function createRoom(options, config) {
|
|
|
6737
6818
|
const firstHalf = messages.slice(0, mid);
|
|
6738
6819
|
const secondHalf = messages.slice(mid);
|
|
6739
6820
|
for (const half of [firstHalf, secondHalf]) {
|
|
6740
|
-
const text =
|
|
6821
|
+
const text = stringifyOrLog(half);
|
|
6741
6822
|
if (!isTooBigForWebSocket(text)) {
|
|
6742
6823
|
yield text;
|
|
6743
6824
|
} else {
|
|
@@ -6752,8 +6833,8 @@ function createRoom(options, config) {
|
|
|
6752
6833
|
return new TextEncoder().encode(text).length >= MAX_SOCKET_MESSAGE_SIZE;
|
|
6753
6834
|
}
|
|
6754
6835
|
function sendMessages(messages) {
|
|
6755
|
-
const strategy = config.largeMessageStrategy
|
|
6756
|
-
const text =
|
|
6836
|
+
const strategy = _nullishCoalesce(config.largeMessageStrategy, () => ( "default"));
|
|
6837
|
+
const text = stringifyOrLog(messages);
|
|
6757
6838
|
if (!isTooBigForWebSocket(text)) {
|
|
6758
6839
|
return managedSocket.send(text);
|
|
6759
6840
|
}
|
|
@@ -6771,7 +6852,7 @@ function createRoom(options, config) {
|
|
|
6771
6852
|
}
|
|
6772
6853
|
case "experimental-fallback-to-http": {
|
|
6773
6854
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
6774
|
-
const nonce = context.dynamicSessionInfoSig.get()
|
|
6855
|
+
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _142 => _142.dynamicSessionInfoSig, 'access', _143 => _143.get, 'call', _144 => _144(), 'optionalAccess', _145 => _145.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
6775
6856
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
6776
6857
|
if (!resp.ok && resp.status === 403) {
|
|
6777
6858
|
managedSocket.reconnect();
|
|
@@ -6822,7 +6903,7 @@ function createRoom(options, config) {
|
|
|
6822
6903
|
} else {
|
|
6823
6904
|
context.root = LiveObject._fromItems(message.items, pool);
|
|
6824
6905
|
}
|
|
6825
|
-
const canWrite = self.get()
|
|
6906
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _146 => _146.get, 'call', _147 => _147(), 'optionalAccess', _148 => _148.canWrite]), () => ( true));
|
|
6826
6907
|
const stackSizeBefore = context.undoStack.length;
|
|
6827
6908
|
for (const key in context.initialStorage) {
|
|
6828
6909
|
if (context.root.get(key) === void 0) {
|
|
@@ -6872,7 +6953,7 @@ function createRoom(options, config) {
|
|
|
6872
6953
|
eventHub.others.notify({ ...event, others });
|
|
6873
6954
|
}
|
|
6874
6955
|
}
|
|
6875
|
-
if (updates.presence
|
|
6956
|
+
if (_nullishCoalesce(updates.presence, () => ( false))) {
|
|
6876
6957
|
notifySelfChanged();
|
|
6877
6958
|
eventHub.myPresence.notify(context.myPresence.get());
|
|
6878
6959
|
}
|
|
@@ -7025,7 +7106,7 @@ function createRoom(options, config) {
|
|
|
7025
7106
|
}
|
|
7026
7107
|
context.myPresence.patch(patch);
|
|
7027
7108
|
if (context.activeBatch) {
|
|
7028
|
-
if (options2
|
|
7109
|
+
if (_optionalChain([options2, 'optionalAccess', _149 => _149.addToHistory])) {
|
|
7029
7110
|
context.activeBatch.reverseOps.pushLeft({
|
|
7030
7111
|
type: "presence",
|
|
7031
7112
|
data: oldValues
|
|
@@ -7034,7 +7115,7 @@ function createRoom(options, config) {
|
|
|
7034
7115
|
context.activeBatch.updates.presence = true;
|
|
7035
7116
|
} else {
|
|
7036
7117
|
flushNowOrSoon();
|
|
7037
|
-
if (options2
|
|
7118
|
+
if (_optionalChain([options2, 'optionalAccess', _150 => _150.addToHistory])) {
|
|
7038
7119
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
7039
7120
|
}
|
|
7040
7121
|
notify({ presence: true });
|
|
@@ -7183,7 +7264,7 @@ function createRoom(options, config) {
|
|
|
7183
7264
|
const others = context.others.get();
|
|
7184
7265
|
eventHub.customEvent.notify({
|
|
7185
7266
|
connectionId: message.actor,
|
|
7186
|
-
user: message.actor < 0 ? null : others.find((u) => u.connectionId === message.actor)
|
|
7267
|
+
user: message.actor < 0 ? null : _nullishCoalesce(others.find((u) => u.connectionId === message.actor), () => ( null)),
|
|
7187
7268
|
event: message.event
|
|
7188
7269
|
});
|
|
7189
7270
|
break;
|
|
@@ -7231,7 +7312,7 @@ function createRoom(options, config) {
|
|
|
7231
7312
|
if (process.env.NODE_ENV !== "production") {
|
|
7232
7313
|
const traces = /* @__PURE__ */ new Set();
|
|
7233
7314
|
for (const opId of message.opIds) {
|
|
7234
|
-
const trace = context.opStackTraces
|
|
7315
|
+
const trace = _optionalChain([context, 'access', _151 => _151.opStackTraces, 'optionalAccess', _152 => _152.get, 'call', _153 => _153(opId)]);
|
|
7235
7316
|
if (trace) {
|
|
7236
7317
|
traces.add(trace);
|
|
7237
7318
|
}
|
|
@@ -7365,7 +7446,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7365
7446
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
7366
7447
|
createOrUpdateRootFromMessage(message);
|
|
7367
7448
|
applyAndSendOps(unacknowledgedOps);
|
|
7368
|
-
_resolveStoragePromise
|
|
7449
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _154 => _154()]);
|
|
7369
7450
|
notifyStorageStatus();
|
|
7370
7451
|
eventHub.storageDidLoad.notify();
|
|
7371
7452
|
}
|
|
@@ -7588,8 +7669,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7588
7669
|
async function getThreads(options2) {
|
|
7589
7670
|
return httpClient.getThreads({
|
|
7590
7671
|
roomId,
|
|
7591
|
-
query: options2
|
|
7592
|
-
cursor: options2
|
|
7672
|
+
query: _optionalChain([options2, 'optionalAccess', _155 => _155.query]),
|
|
7673
|
+
cursor: _optionalChain([options2, 'optionalAccess', _156 => _156.cursor])
|
|
7593
7674
|
});
|
|
7594
7675
|
}
|
|
7595
7676
|
async function getThread(threadId) {
|
|
@@ -7690,7 +7771,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7690
7771
|
function getNotificationSettings(options2) {
|
|
7691
7772
|
return httpClient.getNotificationSettings({
|
|
7692
7773
|
roomId,
|
|
7693
|
-
signal: options2
|
|
7774
|
+
signal: _optionalChain([options2, 'optionalAccess', _157 => _157.signal])
|
|
7694
7775
|
});
|
|
7695
7776
|
}
|
|
7696
7777
|
function updateNotificationSettings(settings) {
|
|
@@ -7712,7 +7793,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7712
7793
|
{
|
|
7713
7794
|
[kInternal]: {
|
|
7714
7795
|
get presenceBuffer() {
|
|
7715
|
-
return deepClone(context.buffer.presenceUpdates
|
|
7796
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _158 => _158.buffer, 'access', _159 => _159.presenceUpdates, 'optionalAccess', _160 => _160.data]), () => ( null)));
|
|
7716
7797
|
},
|
|
7717
7798
|
// prettier-ignore
|
|
7718
7799
|
get undoStack() {
|
|
@@ -7727,9 +7808,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7727
7808
|
return context.yjsProvider;
|
|
7728
7809
|
},
|
|
7729
7810
|
setYjsProvider(newProvider) {
|
|
7730
|
-
context.yjsProvider
|
|
7811
|
+
_optionalChain([context, 'access', _161 => _161.yjsProvider, 'optionalAccess', _162 => _162.off, 'call', _163 => _163("status", yjsStatusDidChange)]);
|
|
7731
7812
|
context.yjsProvider = newProvider;
|
|
7732
|
-
newProvider
|
|
7813
|
+
_optionalChain([newProvider, 'optionalAccess', _164 => _164.on, 'call', _165 => _165("status", yjsStatusDidChange)]);
|
|
7733
7814
|
context.yjsProviderDidChange.notify();
|
|
7734
7815
|
},
|
|
7735
7816
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -7775,7 +7856,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7775
7856
|
source[Symbol.dispose]();
|
|
7776
7857
|
}
|
|
7777
7858
|
eventHub.roomWillDestroy.notify();
|
|
7778
|
-
context.yjsProvider
|
|
7859
|
+
_optionalChain([context, 'access', _166 => _166.yjsProvider, 'optionalAccess', _167 => _167.off, 'call', _168 => _168("status", yjsStatusDidChange)]);
|
|
7779
7860
|
syncSourceForStorage.destroy();
|
|
7780
7861
|
syncSourceForYjs.destroy();
|
|
7781
7862
|
uninstallBgTabSpy();
|
|
@@ -7921,7 +8002,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
7921
8002
|
}
|
|
7922
8003
|
if (isLiveNode(first)) {
|
|
7923
8004
|
const node = first;
|
|
7924
|
-
if (options
|
|
8005
|
+
if (_optionalChain([options, 'optionalAccess', _169 => _169.isDeep])) {
|
|
7925
8006
|
const storageCallback = second;
|
|
7926
8007
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
7927
8008
|
} else {
|
|
@@ -7945,7 +8026,7 @@ function makeAuthDelegateForRoom(roomId, authManager) {
|
|
|
7945
8026
|
}
|
|
7946
8027
|
function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
7947
8028
|
return (authValue) => {
|
|
7948
|
-
const ws = WebSocketPolyfill
|
|
8029
|
+
const ws = _nullishCoalesce(WebSocketPolyfill, () => ( (typeof WebSocket === "undefined" ? void 0 : WebSocket)));
|
|
7949
8030
|
if (ws === void 0) {
|
|
7950
8031
|
throw new StopRetrying(
|
|
7951
8032
|
"To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill."
|
|
@@ -7987,9 +8068,9 @@ function getBaseUrl(baseUrl) {
|
|
|
7987
8068
|
}
|
|
7988
8069
|
function createClient(options) {
|
|
7989
8070
|
const clientOptions = options;
|
|
7990
|
-
const throttleDelay = getThrottle(clientOptions.throttle
|
|
8071
|
+
const throttleDelay = getThrottle(_nullishCoalesce(clientOptions.throttle, () => ( DEFAULT_THROTTLE)));
|
|
7991
8072
|
const lostConnectionTimeout = getLostConnectionTimeout(
|
|
7992
|
-
clientOptions.lostConnectionTimeout
|
|
8073
|
+
_nullishCoalesce(clientOptions.lostConnectionTimeout, () => ( DEFAULT_LOST_CONNECTION_TIMEOUT))
|
|
7993
8074
|
);
|
|
7994
8075
|
const backgroundKeepAliveTimeout = getBackgroundKeepAliveTimeout(
|
|
7995
8076
|
clientOptions.backgroundKeepAliveTimeout
|
|
@@ -8000,8 +8081,8 @@ function createClient(options) {
|
|
|
8000
8081
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
8001
8082
|
currentUserId.set(() => userId);
|
|
8002
8083
|
});
|
|
8003
|
-
const fetchPolyfill = clientOptions.polyfills
|
|
8004
|
-
globalThis.fetch
|
|
8084
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _170 => _170.polyfills, 'optionalAccess', _171 => _171.fetch]) || /* istanbul ignore next */
|
|
8085
|
+
_optionalChain([globalThis, 'access', _172 => _172.fetch, 'optionalAccess', _173 => _173.bind, 'call', _174 => _174(globalThis)]);
|
|
8005
8086
|
const httpClient = createApiClient({
|
|
8006
8087
|
baseUrl,
|
|
8007
8088
|
fetchPolyfill,
|
|
@@ -8037,9 +8118,9 @@ function createClient(options) {
|
|
|
8037
8118
|
if (existing !== void 0) {
|
|
8038
8119
|
return leaseRoom(existing);
|
|
8039
8120
|
}
|
|
8040
|
-
const options2 = args[0]
|
|
8041
|
-
const initialPresence = (typeof options2.initialPresence === "function" ? options2.initialPresence(roomId) : options2.initialPresence)
|
|
8042
|
-
const initialStorage = (typeof options2.initialStorage === "function" ? options2.initialStorage(roomId) : options2.initialStorage)
|
|
8121
|
+
const options2 = _nullishCoalesce(args[0], () => ( {}));
|
|
8122
|
+
const initialPresence = _nullishCoalesce((typeof options2.initialPresence === "function" ? options2.initialPresence(roomId) : options2.initialPresence), () => ( {}));
|
|
8123
|
+
const initialStorage = _nullishCoalesce((typeof options2.initialStorage === "function" ? options2.initialStorage(roomId) : options2.initialStorage), () => ( {}));
|
|
8043
8124
|
const newRoom = createRoom(
|
|
8044
8125
|
{ initialPresence, initialStorage },
|
|
8045
8126
|
{
|
|
@@ -8048,18 +8129,18 @@ function createClient(options) {
|
|
|
8048
8129
|
lostConnectionTimeout,
|
|
8049
8130
|
backgroundKeepAliveTimeout,
|
|
8050
8131
|
polyfills: clientOptions.polyfills,
|
|
8051
|
-
delegates: clientOptions.mockedDelegates
|
|
8132
|
+
delegates: _nullishCoalesce(clientOptions.mockedDelegates, () => ( {
|
|
8052
8133
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
8053
8134
|
roomId,
|
|
8054
8135
|
baseUrl,
|
|
8055
|
-
clientOptions.polyfills
|
|
8136
|
+
_optionalChain([clientOptions, 'access', _175 => _175.polyfills, 'optionalAccess', _176 => _176.WebSocket])
|
|
8056
8137
|
),
|
|
8057
8138
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
8058
|
-
},
|
|
8139
|
+
})),
|
|
8059
8140
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
8060
8141
|
baseUrl,
|
|
8061
8142
|
errorEventSource: liveblocksErrorSource,
|
|
8062
|
-
largeMessageStrategy: clientOptions.largeMessageStrategy
|
|
8143
|
+
largeMessageStrategy: _nullishCoalesce(clientOptions.largeMessageStrategy, () => ( (clientOptions.unstable_fallbackToHTTP ? "experimental-fallback-to-http" : void 0))),
|
|
8063
8144
|
unstable_streamData: !!clientOptions.unstable_streamData,
|
|
8064
8145
|
roomHttpClient: httpClient,
|
|
8065
8146
|
createSyncSource
|
|
@@ -8072,10 +8153,10 @@ function createClient(options) {
|
|
|
8072
8153
|
roomsById.set(roomId, newRoomDetails);
|
|
8073
8154
|
setupDevTools(() => Array.from(roomsById.keys()));
|
|
8074
8155
|
linkDevTools(roomId, newRoom);
|
|
8075
|
-
const shouldConnect = options2.autoConnect
|
|
8156
|
+
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
8076
8157
|
if (shouldConnect) {
|
|
8077
8158
|
if (typeof atob === "undefined") {
|
|
8078
|
-
if (clientOptions.polyfills
|
|
8159
|
+
if (_optionalChain([clientOptions, 'access', _177 => _177.polyfills, 'optionalAccess', _178 => _178.atob]) === void 0) {
|
|
8079
8160
|
throw new Error(
|
|
8080
8161
|
"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"
|
|
8081
8162
|
);
|
|
@@ -8087,7 +8168,7 @@ function createClient(options) {
|
|
|
8087
8168
|
return leaseRoom(newRoomDetails);
|
|
8088
8169
|
}
|
|
8089
8170
|
function getRoom(roomId) {
|
|
8090
|
-
const room = roomsById.get(roomId)
|
|
8171
|
+
const room = _optionalChain([roomsById, 'access', _179 => _179.get, 'call', _180 => _180(roomId), 'optionalAccess', _181 => _181.room]);
|
|
8091
8172
|
return room ? room : null;
|
|
8092
8173
|
}
|
|
8093
8174
|
function logout() {
|
|
@@ -8107,9 +8188,9 @@ function createClient(options) {
|
|
|
8107
8188
|
const batchedResolveUsers = new Batch(
|
|
8108
8189
|
async (batchedUserIds) => {
|
|
8109
8190
|
const userIds = batchedUserIds.flat();
|
|
8110
|
-
const users = await resolveUsers
|
|
8191
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _182 => _182({ userIds })]);
|
|
8111
8192
|
warnIfNoResolveUsers();
|
|
8112
|
-
return users
|
|
8193
|
+
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
8113
8194
|
},
|
|
8114
8195
|
{ delay: RESOLVE_USERS_BATCH_DELAY }
|
|
8115
8196
|
);
|
|
@@ -8125,9 +8206,9 @@ function createClient(options) {
|
|
|
8125
8206
|
const batchedResolveRoomsInfo = new Batch(
|
|
8126
8207
|
async (batchedRoomIds) => {
|
|
8127
8208
|
const roomIds = batchedRoomIds.flat();
|
|
8128
|
-
const roomsInfo = await resolveRoomsInfo
|
|
8209
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _183 => _183({ roomIds })]);
|
|
8129
8210
|
warnIfNoResolveRoomsInfo();
|
|
8130
|
-
return roomsInfo
|
|
8211
|
+
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
8131
8212
|
},
|
|
8132
8213
|
{ delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
|
|
8133
8214
|
);
|
|
@@ -8178,7 +8259,17 @@ function createClient(options) {
|
|
|
8178
8259
|
}
|
|
8179
8260
|
};
|
|
8180
8261
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
8181
|
-
win
|
|
8262
|
+
_optionalChain([win, 'optionalAccess', _184 => _184.addEventListener, 'call', _185 => _185("beforeunload", maybePreventClose)]);
|
|
8263
|
+
}
|
|
8264
|
+
async function getNotificationSettings(options2) {
|
|
8265
|
+
const plainSettings = await httpClient.getUserNotificationSettings(options2);
|
|
8266
|
+
const settings = createUserNotificationSettings(plainSettings);
|
|
8267
|
+
return settings;
|
|
8268
|
+
}
|
|
8269
|
+
async function updateNotificationSettings(settings) {
|
|
8270
|
+
const plainSettings = await httpClient.updateUserNotificationSettings(settings);
|
|
8271
|
+
const settingsObject = createUserNotificationSettings(plainSettings);
|
|
8272
|
+
return settingsObject;
|
|
8182
8273
|
}
|
|
8183
8274
|
const client = Object.defineProperty(
|
|
8184
8275
|
{
|
|
@@ -8193,9 +8284,9 @@ function createClient(options) {
|
|
|
8193
8284
|
markInboxNotificationAsRead: httpClient.markInboxNotificationAsRead,
|
|
8194
8285
|
deleteAllInboxNotifications: httpClient.deleteAllInboxNotifications,
|
|
8195
8286
|
deleteInboxNotification: httpClient.deleteInboxNotification,
|
|
8196
|
-
// Public
|
|
8197
|
-
getNotificationSettings
|
|
8198
|
-
updateNotificationSettings
|
|
8287
|
+
// Public user notification settings API
|
|
8288
|
+
getNotificationSettings,
|
|
8289
|
+
updateNotificationSettings,
|
|
8199
8290
|
// Advanced resolvers APIs
|
|
8200
8291
|
resolvers: {
|
|
8201
8292
|
invalidateUsers: invalidateResolvedUsers,
|
|
@@ -8240,7 +8331,7 @@ function createClient(options) {
|
|
|
8240
8331
|
function checkBounds(option, value, min, max, recommendedMin) {
|
|
8241
8332
|
if (typeof value !== "number" || value < min || max !== void 0 && value > max) {
|
|
8242
8333
|
throw new Error(
|
|
8243
|
-
max !== void 0 ? `${option} should be between ${recommendedMin
|
|
8334
|
+
max !== void 0 ? `${option} should be between ${_nullishCoalesce(recommendedMin, () => ( min))} and ${max}.` : `${option} should be at least ${_nullishCoalesce(recommendedMin, () => ( min))}.`
|
|
8244
8335
|
);
|
|
8245
8336
|
}
|
|
8246
8337
|
return value;
|
|
@@ -8306,7 +8397,7 @@ var commentBodyElementsTypes = {
|
|
|
8306
8397
|
mention: "inline"
|
|
8307
8398
|
};
|
|
8308
8399
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
8309
|
-
if (!body || !body
|
|
8400
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _186 => _186.content])) {
|
|
8310
8401
|
return;
|
|
8311
8402
|
}
|
|
8312
8403
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -8316,13 +8407,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
8316
8407
|
for (const block of body.content) {
|
|
8317
8408
|
if (type === "all" || type === "block") {
|
|
8318
8409
|
if (guard(block)) {
|
|
8319
|
-
visitor
|
|
8410
|
+
_optionalChain([visitor, 'optionalCall', _187 => _187(block)]);
|
|
8320
8411
|
}
|
|
8321
8412
|
}
|
|
8322
8413
|
if (type === "all" || type === "inline") {
|
|
8323
8414
|
for (const inline of block.children) {
|
|
8324
8415
|
if (guard(inline)) {
|
|
8325
|
-
visitor
|
|
8416
|
+
_optionalChain([visitor, 'optionalCall', _188 => _188(inline)]);
|
|
8326
8417
|
}
|
|
8327
8418
|
}
|
|
8328
8419
|
}
|
|
@@ -8347,7 +8438,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
8347
8438
|
userIds
|
|
8348
8439
|
});
|
|
8349
8440
|
for (const [index, userId] of userIds.entries()) {
|
|
8350
|
-
const user = users
|
|
8441
|
+
const user = _optionalChain([users, 'optionalAccess', _189 => _189[index]]);
|
|
8351
8442
|
if (user) {
|
|
8352
8443
|
resolvedUsers.set(userId, user);
|
|
8353
8444
|
}
|
|
@@ -8472,9 +8563,9 @@ function toAbsoluteUrl(url2) {
|
|
|
8472
8563
|
var stringifyCommentBodyPlainElements = {
|
|
8473
8564
|
paragraph: ({ children }) => children,
|
|
8474
8565
|
text: ({ element }) => element.text,
|
|
8475
|
-
link: ({ element }) => element.text
|
|
8566
|
+
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
8476
8567
|
mention: ({ element, user }) => {
|
|
8477
|
-
return `@${user
|
|
8568
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _190 => _190.name]), () => ( element.id))}`;
|
|
8478
8569
|
}
|
|
8479
8570
|
};
|
|
8480
8571
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -8484,7 +8575,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
8484
8575
|
text: ({ element }) => {
|
|
8485
8576
|
let children = element.text;
|
|
8486
8577
|
if (!children) {
|
|
8487
|
-
return children
|
|
8578
|
+
return html`${children}`;
|
|
8488
8579
|
}
|
|
8489
8580
|
if (element.bold) {
|
|
8490
8581
|
children = html`<strong>${children}</strong>`;
|
|
@@ -8498,13 +8589,13 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
8498
8589
|
if (element.code) {
|
|
8499
8590
|
children = html`<code>${children}</code>`;
|
|
8500
8591
|
}
|
|
8501
|
-
return children
|
|
8592
|
+
return html`${children}`;
|
|
8502
8593
|
},
|
|
8503
8594
|
link: ({ element, href }) => {
|
|
8504
|
-
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text
|
|
8595
|
+
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
8505
8596
|
},
|
|
8506
8597
|
mention: ({ element, user }) => {
|
|
8507
|
-
return html`<span data-mention>@${user
|
|
8598
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _191 => _191.name]) ? html`${_optionalChain([user, 'optionalAccess', _192 => _192.name])}` : element.id}</span>`;
|
|
8508
8599
|
}
|
|
8509
8600
|
};
|
|
8510
8601
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -8531,22 +8622,22 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
8531
8622
|
return children;
|
|
8532
8623
|
},
|
|
8533
8624
|
link: ({ element, href }) => {
|
|
8534
|
-
return markdown`[${element.text
|
|
8625
|
+
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
8535
8626
|
},
|
|
8536
8627
|
mention: ({ element, user }) => {
|
|
8537
|
-
return markdown`@${user
|
|
8628
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _193 => _193.name]), () => ( element.id))}`;
|
|
8538
8629
|
}
|
|
8539
8630
|
};
|
|
8540
8631
|
async function stringifyCommentBody(body, options) {
|
|
8541
|
-
const format = options
|
|
8542
|
-
const separator = options
|
|
8632
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _194 => _194.format]), () => ( "plain"));
|
|
8633
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _195 => _195.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
8543
8634
|
const elements = {
|
|
8544
8635
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
8545
|
-
...options
|
|
8636
|
+
..._optionalChain([options, 'optionalAccess', _196 => _196.elements])
|
|
8546
8637
|
};
|
|
8547
8638
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
8548
8639
|
body,
|
|
8549
|
-
options
|
|
8640
|
+
_optionalChain([options, 'optionalAccess', _197 => _197.resolveUsers])
|
|
8550
8641
|
);
|
|
8551
8642
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
8552
8643
|
switch (block.type) {
|
|
@@ -8568,7 +8659,7 @@ async function stringifyCommentBody(body, options) {
|
|
|
8568
8659
|
elements.link(
|
|
8569
8660
|
{
|
|
8570
8661
|
element: inline,
|
|
8571
|
-
href: toAbsoluteUrl(inline.url)
|
|
8662
|
+
href: _nullishCoalesce(toAbsoluteUrl(inline.url), () => ( inline.url))
|
|
8572
8663
|
},
|
|
8573
8664
|
inlineIndex
|
|
8574
8665
|
)
|
|
@@ -8837,12 +8928,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8837
8928
|
}
|
|
8838
8929
|
const newState = Object.assign({}, state);
|
|
8839
8930
|
for (const key in update.updates) {
|
|
8840
|
-
if (update.updates[key]
|
|
8931
|
+
if (_optionalChain([update, 'access', _198 => _198.updates, 'access', _199 => _199[key], 'optionalAccess', _200 => _200.type]) === "update") {
|
|
8841
8932
|
const val = update.node.get(key);
|
|
8842
8933
|
if (val !== void 0) {
|
|
8843
8934
|
newState[key] = lsonToJson(val);
|
|
8844
8935
|
}
|
|
8845
|
-
} else if (update.updates[key]
|
|
8936
|
+
} else if (_optionalChain([update, 'access', _201 => _201.updates, 'access', _202 => _202[key], 'optionalAccess', _203 => _203.type]) === "delete") {
|
|
8846
8937
|
delete newState[key];
|
|
8847
8938
|
}
|
|
8848
8939
|
}
|
|
@@ -8903,12 +8994,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8903
8994
|
}
|
|
8904
8995
|
const newState = Object.assign({}, state);
|
|
8905
8996
|
for (const key in update.updates) {
|
|
8906
|
-
if (update.updates[key]
|
|
8997
|
+
if (_optionalChain([update, 'access', _204 => _204.updates, 'access', _205 => _205[key], 'optionalAccess', _206 => _206.type]) === "update") {
|
|
8907
8998
|
const value = update.node.get(key);
|
|
8908
8999
|
if (value !== void 0) {
|
|
8909
9000
|
newState[key] = lsonToJson(value);
|
|
8910
9001
|
}
|
|
8911
|
-
} else if (update.updates[key]
|
|
9002
|
+
} else if (_optionalChain([update, 'access', _207 => _207.updates, 'access', _208 => _208[key], 'optionalAccess', _209 => _209.type]) === "delete") {
|
|
8912
9003
|
delete newState[key];
|
|
8913
9004
|
}
|
|
8914
9005
|
}
|
|
@@ -8979,9 +9070,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
8979
9070
|
const startTime = performance.now();
|
|
8980
9071
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8981
9072
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
8982
|
-
const maxStaleTimeMs = options
|
|
9073
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _210 => _210.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
8983
9074
|
const context = {
|
|
8984
|
-
inForeground: doc
|
|
9075
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _211 => _211.visibilityState]) !== "hidden",
|
|
8985
9076
|
lastSuccessfulPollAt: startTime,
|
|
8986
9077
|
count: 0,
|
|
8987
9078
|
backoff: 0
|
|
@@ -9023,7 +9114,7 @@ function makePoller(callback, intervalMs, options) {
|
|
|
9023
9114
|
return {
|
|
9024
9115
|
target: mayPoll() ? "@enabled" : "@idle",
|
|
9025
9116
|
effect: () => {
|
|
9026
|
-
context.backoff = BACKOFF_DELAYS2.find((delay) => delay > context.backoff)
|
|
9117
|
+
context.backoff = _nullishCoalesce(BACKOFF_DELAYS2.find((delay) => delay > context.backoff), () => ( BACKOFF_DELAYS2[BACKOFF_DELAYS2.length - 1]));
|
|
9027
9118
|
}
|
|
9028
9119
|
};
|
|
9029
9120
|
},
|
|
@@ -9059,11 +9150,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
9059
9150
|
pollNowIfStale();
|
|
9060
9151
|
}
|
|
9061
9152
|
function onVisibilityChange() {
|
|
9062
|
-
setInForeground(doc
|
|
9153
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _212 => _212.visibilityState]) !== "hidden");
|
|
9063
9154
|
}
|
|
9064
|
-
doc
|
|
9065
|
-
win
|
|
9066
|
-
win
|
|
9155
|
+
_optionalChain([doc, 'optionalAccess', _213 => _213.addEventListener, 'call', _214 => _214("visibilitychange", onVisibilityChange)]);
|
|
9156
|
+
_optionalChain([win, 'optionalAccess', _215 => _215.addEventListener, 'call', _216 => _216("online", onVisibilityChange)]);
|
|
9157
|
+
_optionalChain([win, 'optionalAccess', _217 => _217.addEventListener, 'call', _218 => _218("focus", pollNowIfStale)]);
|
|
9067
9158
|
fsm.start();
|
|
9068
9159
|
return {
|
|
9069
9160
|
inc,
|
|
@@ -9185,11 +9276,6 @@ var SortedList = class _SortedList {
|
|
|
9185
9276
|
}
|
|
9186
9277
|
};
|
|
9187
9278
|
|
|
9188
|
-
// src/protocol/UserNotificationSettings.ts
|
|
9189
|
-
function isNotificationChannelEnabled(settings) {
|
|
9190
|
-
return values(settings).every((enabled) => enabled === true);
|
|
9191
|
-
}
|
|
9192
|
-
|
|
9193
9279
|
// src/types/Others.ts
|
|
9194
9280
|
var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
|
|
9195
9281
|
TextEditorType2["Lexical"] = "lexical";
|
|
@@ -9201,94 +9287,96 @@ var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
|
|
|
9201
9287
|
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
9202
9288
|
var CommentsApiError = HttpError;
|
|
9203
9289
|
var NotificationsApiError = HttpError;
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9290
|
+
|
|
9291
|
+
|
|
9292
|
+
|
|
9293
|
+
|
|
9294
|
+
|
|
9295
|
+
|
|
9296
|
+
|
|
9297
|
+
|
|
9298
|
+
|
|
9299
|
+
|
|
9300
|
+
|
|
9301
|
+
|
|
9302
|
+
|
|
9303
|
+
|
|
9304
|
+
|
|
9305
|
+
|
|
9306
|
+
|
|
9307
|
+
|
|
9308
|
+
|
|
9309
|
+
|
|
9310
|
+
|
|
9311
|
+
|
|
9312
|
+
|
|
9313
|
+
|
|
9314
|
+
|
|
9315
|
+
|
|
9316
|
+
|
|
9317
|
+
|
|
9318
|
+
|
|
9319
|
+
|
|
9320
|
+
|
|
9321
|
+
|
|
9322
|
+
|
|
9323
|
+
|
|
9324
|
+
|
|
9325
|
+
|
|
9326
|
+
|
|
9327
|
+
|
|
9328
|
+
|
|
9329
|
+
|
|
9330
|
+
|
|
9331
|
+
|
|
9332
|
+
|
|
9333
|
+
|
|
9334
|
+
|
|
9335
|
+
|
|
9336
|
+
|
|
9337
|
+
|
|
9338
|
+
|
|
9339
|
+
|
|
9340
|
+
|
|
9341
|
+
|
|
9342
|
+
|
|
9343
|
+
|
|
9344
|
+
|
|
9345
|
+
|
|
9346
|
+
|
|
9347
|
+
|
|
9348
|
+
|
|
9349
|
+
|
|
9350
|
+
|
|
9351
|
+
|
|
9352
|
+
|
|
9353
|
+
|
|
9354
|
+
|
|
9355
|
+
|
|
9356
|
+
|
|
9357
|
+
|
|
9358
|
+
|
|
9359
|
+
|
|
9360
|
+
|
|
9361
|
+
|
|
9362
|
+
|
|
9363
|
+
|
|
9364
|
+
|
|
9365
|
+
|
|
9366
|
+
|
|
9367
|
+
|
|
9368
|
+
|
|
9369
|
+
|
|
9370
|
+
|
|
9371
|
+
|
|
9372
|
+
|
|
9373
|
+
|
|
9374
|
+
|
|
9375
|
+
|
|
9376
|
+
|
|
9377
|
+
|
|
9378
|
+
|
|
9379
|
+
|
|
9380
|
+
|
|
9381
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MutableSignal = MutableSignal; exports.NotificationsApiError = NotificationsApiError; 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.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.createUserNotificationSettings = createUserNotificationSettings; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.freeze = freeze; exports.generateCommentUrl = generateCommentUrl; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; 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.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; 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.patchUserNotificationSettings = patchUserNotificationSettings; exports.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toAbsoluteUrl = toAbsoluteUrl; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.withTimeout = withTimeout;
|
|
9382
|
+
//# sourceMappingURL=index.cjs.map
|