@liveblocks/core 2.16.0-toolbars5 → 2.16.0
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.d.mts +165 -75
- package/dist/index.d.ts +165 -75
- package/dist/index.js +302 -196
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +195 -89
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
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 = "2.16.0
|
|
9
|
+
var PKG_VERSION = "2.16.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -166,6 +166,14 @@ function wrapWithTitle(method) {
|
|
|
166
166
|
var warnWithTitle = wrapWithTitle("warn");
|
|
167
167
|
var errorWithTitle = wrapWithTitle("error");
|
|
168
168
|
|
|
169
|
+
// src/lib/guards.ts
|
|
170
|
+
function isPlainObject(blob) {
|
|
171
|
+
return blob !== null && typeof blob === "object" && Object.prototype.toString.call(blob) === "[object Object]";
|
|
172
|
+
}
|
|
173
|
+
function isStartsWithOperator(blob) {
|
|
174
|
+
return isPlainObject(blob) && typeof blob.startsWith === "string";
|
|
175
|
+
}
|
|
176
|
+
|
|
169
177
|
// src/lib/utils.ts
|
|
170
178
|
function raise(msg) {
|
|
171
179
|
throw new Error(msg);
|
|
@@ -251,13 +259,48 @@ function memoizeOnSuccess(factoryFn) {
|
|
|
251
259
|
}
|
|
252
260
|
|
|
253
261
|
// src/lib/autoRetry.ts
|
|
254
|
-
var HttpError = class extends Error {
|
|
255
|
-
|
|
262
|
+
var HttpError = class _HttpError extends Error {
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
constructor(message, response, details) {
|
|
256
266
|
super(message);
|
|
257
|
-
this.
|
|
258
|
-
this.
|
|
267
|
+
this.name = "HttpError";
|
|
268
|
+
this.response = response;
|
|
259
269
|
this.details = details;
|
|
260
270
|
}
|
|
271
|
+
static async fromResponse(response) {
|
|
272
|
+
let bodyAsText;
|
|
273
|
+
try {
|
|
274
|
+
bodyAsText = await response.text();
|
|
275
|
+
} catch (e2) {
|
|
276
|
+
}
|
|
277
|
+
const bodyAsJson = bodyAsText ? tryParseJson(bodyAsText) : void 0;
|
|
278
|
+
let bodyAsJsonObject;
|
|
279
|
+
if (isPlainObject(bodyAsJson)) {
|
|
280
|
+
bodyAsJsonObject = bodyAsJson;
|
|
281
|
+
}
|
|
282
|
+
let message = "";
|
|
283
|
+
message ||= typeof _optionalChain([bodyAsJsonObject, 'optionalAccess', _2 => _2.message]) === "string" ? bodyAsJsonObject.message : "";
|
|
284
|
+
message ||= typeof _optionalChain([bodyAsJsonObject, 'optionalAccess', _3 => _3.error]) === "string" ? bodyAsJsonObject.error : "";
|
|
285
|
+
if (bodyAsJson === void 0) {
|
|
286
|
+
message ||= bodyAsText || "";
|
|
287
|
+
}
|
|
288
|
+
message ||= response.statusText;
|
|
289
|
+
let path;
|
|
290
|
+
try {
|
|
291
|
+
path = new URL(response.url).pathname;
|
|
292
|
+
} catch (e3) {
|
|
293
|
+
}
|
|
294
|
+
message += path !== void 0 ? ` (got status ${response.status} from ${path})` : ` (got status ${response.status})`;
|
|
295
|
+
const details = bodyAsJsonObject;
|
|
296
|
+
return new _HttpError(message, response, details);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Convenience accessor for response.status.
|
|
300
|
+
*/
|
|
301
|
+
get status() {
|
|
302
|
+
return this.response.status;
|
|
303
|
+
}
|
|
261
304
|
};
|
|
262
305
|
var DONT_RETRY_4XX = (x) => x instanceof HttpError && x.status >= 400 && x.status < 500;
|
|
263
306
|
async function autoRetry(promiseFn, maxTries, backoff, shouldStopRetrying = DONT_RETRY_4XX) {
|
|
@@ -320,10 +363,15 @@ function makeEventSource() {
|
|
|
320
363
|
res(event);
|
|
321
364
|
}
|
|
322
365
|
});
|
|
323
|
-
}).finally(() => _optionalChain([unsub, 'optionalCall',
|
|
366
|
+
}).finally(() => _optionalChain([unsub, 'optionalCall', _4 => _4()]));
|
|
324
367
|
}
|
|
325
368
|
function notify(event) {
|
|
326
|
-
|
|
369
|
+
let called = false;
|
|
370
|
+
for (const callback of _observers) {
|
|
371
|
+
callback(event);
|
|
372
|
+
called = true;
|
|
373
|
+
}
|
|
374
|
+
return called;
|
|
327
375
|
}
|
|
328
376
|
function count() {
|
|
329
377
|
return _observers.size;
|
|
@@ -364,8 +412,9 @@ function makeBufferableEventSource() {
|
|
|
364
412
|
function notifyOrBuffer(event) {
|
|
365
413
|
if (_buffer !== null) {
|
|
366
414
|
_buffer.push(event);
|
|
415
|
+
return false;
|
|
367
416
|
} else {
|
|
368
|
-
eventSource2.notify(event);
|
|
417
|
+
return eventSource2.notify(event);
|
|
369
418
|
}
|
|
370
419
|
}
|
|
371
420
|
return {
|
|
@@ -505,7 +554,7 @@ var Signal = class extends AbstractSignal {
|
|
|
505
554
|
this.#value = "(disposed)";
|
|
506
555
|
}
|
|
507
556
|
get() {
|
|
508
|
-
_optionalChain([trackedReads, 'optionalAccess',
|
|
557
|
+
_optionalChain([trackedReads, 'optionalAccess', _5 => _5.add, 'call', _6 => _6(this)]);
|
|
509
558
|
return this.#value;
|
|
510
559
|
}
|
|
511
560
|
set(newValue) {
|
|
@@ -615,7 +664,7 @@ var DerivedSignal = class _DerivedSignal extends AbstractSignal {
|
|
|
615
664
|
if (this.#dirty) {
|
|
616
665
|
this.#recompute();
|
|
617
666
|
}
|
|
618
|
-
_optionalChain([trackedReads, 'optionalAccess',
|
|
667
|
+
_optionalChain([trackedReads, 'optionalAccess', _7 => _7.add, 'call', _8 => _8(this)]);
|
|
619
668
|
return this.#prevValue;
|
|
620
669
|
}
|
|
621
670
|
/**
|
|
@@ -645,7 +694,7 @@ var MutableSignal = class extends AbstractSignal {
|
|
|
645
694
|
this.#state = "(disposed)";
|
|
646
695
|
}
|
|
647
696
|
get() {
|
|
648
|
-
_optionalChain([trackedReads, 'optionalAccess',
|
|
697
|
+
_optionalChain([trackedReads, 'optionalAccess', _9 => _9.add, 'call', _10 => _10(this)]);
|
|
649
698
|
return this.#state;
|
|
650
699
|
}
|
|
651
700
|
/**
|
|
@@ -670,32 +719,15 @@ var MutableSignal = class extends AbstractSignal {
|
|
|
670
719
|
};
|
|
671
720
|
|
|
672
721
|
// src/lib/stringify.ts
|
|
673
|
-
var EXPLICIT_UNDEFINED_PLACEHOLDER = "_explicit_undefined";
|
|
674
722
|
function replacer(_key, value) {
|
|
675
723
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? Object.keys(value).sort().reduce((sorted, key) => {
|
|
676
724
|
sorted[key] = value[key];
|
|
677
725
|
return sorted;
|
|
678
|
-
}, {}) : value
|
|
679
|
-
}
|
|
680
|
-
function reviver(key, value) {
|
|
681
|
-
if (!key && value === EXPLICIT_UNDEFINED_PLACEHOLDER) {
|
|
682
|
-
return void 0;
|
|
683
|
-
}
|
|
684
|
-
if (value && typeof value === "object") {
|
|
685
|
-
for (const k in value) {
|
|
686
|
-
if (value[k] === EXPLICIT_UNDEFINED_PLACEHOLDER) {
|
|
687
|
-
Object.defineProperty(value, k, { value: void 0 });
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
return value;
|
|
726
|
+
}, {}) : value;
|
|
692
727
|
}
|
|
693
728
|
function stringify(value) {
|
|
694
729
|
return JSON.stringify(value, replacer);
|
|
695
730
|
}
|
|
696
|
-
function unstringify(value) {
|
|
697
|
-
return JSON.parse(value, reviver);
|
|
698
|
-
}
|
|
699
731
|
|
|
700
732
|
// src/lib/batch.ts
|
|
701
733
|
var DEFAULT_SIZE = 50;
|
|
@@ -748,7 +780,7 @@ var Batch = (_class = class {
|
|
|
748
780
|
const results = await this.#callback(inputs);
|
|
749
781
|
this.error = false;
|
|
750
782
|
calls.forEach((call, index) => {
|
|
751
|
-
const result = _optionalChain([results, 'optionalAccess',
|
|
783
|
+
const result = _optionalChain([results, 'optionalAccess', _11 => _11[index]]);
|
|
752
784
|
if (!Array.isArray(results)) {
|
|
753
785
|
call.reject(new Error("Callback must return an array."));
|
|
754
786
|
} else if (calls.length !== results.length) {
|
|
@@ -911,14 +943,6 @@ var DefaultMap = class extends Map {
|
|
|
911
943
|
}
|
|
912
944
|
};
|
|
913
945
|
|
|
914
|
-
// src/lib/guards.ts
|
|
915
|
-
function isPlainObject(blob) {
|
|
916
|
-
return blob !== null && typeof blob === "object" && Object.prototype.toString.call(blob) === "[object Object]";
|
|
917
|
-
}
|
|
918
|
-
function isStartsWithOperator(blob) {
|
|
919
|
-
return isPlainObject(blob) && typeof blob.startsWith === "string";
|
|
920
|
-
}
|
|
921
|
-
|
|
922
946
|
// src/lib/objectToQuery.ts
|
|
923
947
|
var identifierRegex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
924
948
|
function objectToQuery(obj) {
|
|
@@ -968,9 +992,7 @@ function objectToQuery(obj) {
|
|
|
968
992
|
...getFiltersFromKeyValuePairsWithOperator(nKeyValuePairsWithOperator)
|
|
969
993
|
];
|
|
970
994
|
});
|
|
971
|
-
return filterList.map(
|
|
972
|
-
({ key, operator, value }) => formatFilter(key, operator, formatFilterValue(value))
|
|
973
|
-
).join(" AND ");
|
|
995
|
+
return filterList.map(({ key, operator, value }) => `${key}${operator}${quote(value)}`).join(" ");
|
|
974
996
|
}
|
|
975
997
|
var getFiltersFromKeyValuePairs = (keyValuePairs) => {
|
|
976
998
|
const filters = [];
|
|
@@ -997,29 +1019,27 @@ var getFiltersFromKeyValuePairsWithOperator = (keyValuePairsWithOperator) => {
|
|
|
997
1019
|
return filters;
|
|
998
1020
|
};
|
|
999
1021
|
var isSimpleValue = (value) => {
|
|
1000
|
-
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
1001
|
-
};
|
|
1002
|
-
var formatFilter = (key, operator, value) => {
|
|
1003
|
-
return `${key}${operator}${value}`;
|
|
1022
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null;
|
|
1004
1023
|
};
|
|
1005
1024
|
var formatFilterKey = (key, nestedKey) => {
|
|
1006
1025
|
if (nestedKey) {
|
|
1007
|
-
return `${key}[${
|
|
1026
|
+
return `${key}[${quote(nestedKey)}]`;
|
|
1008
1027
|
}
|
|
1009
1028
|
return key;
|
|
1010
1029
|
};
|
|
1011
|
-
var formatFilterValue = (value) => {
|
|
1012
|
-
if (typeof value === "string") {
|
|
1013
|
-
if (isStringEmpty(value)) {
|
|
1014
|
-
throw new Error("Value cannot be empty");
|
|
1015
|
-
}
|
|
1016
|
-
return JSON.stringify(value);
|
|
1017
|
-
}
|
|
1018
|
-
return value.toString();
|
|
1019
|
-
};
|
|
1020
1030
|
var isStringEmpty = (value) => {
|
|
1021
1031
|
return !value || value.toString().trim() === "";
|
|
1022
1032
|
};
|
|
1033
|
+
function quote(input) {
|
|
1034
|
+
const result = JSON.stringify(input);
|
|
1035
|
+
if (typeof input !== "string") {
|
|
1036
|
+
return result;
|
|
1037
|
+
}
|
|
1038
|
+
if (result.includes("'")) {
|
|
1039
|
+
return result;
|
|
1040
|
+
}
|
|
1041
|
+
return `'${result.slice(1, -1).replace(/\\"/g, '"')}'`;
|
|
1042
|
+
}
|
|
1023
1043
|
|
|
1024
1044
|
// src/lib/url.ts
|
|
1025
1045
|
function toURLSearchParams(params) {
|
|
@@ -1277,11 +1297,11 @@ function createApiClient({
|
|
|
1277
1297
|
`Upload of attachment ${options.attachment.id} was aborted.`,
|
|
1278
1298
|
"AbortError"
|
|
1279
1299
|
) : void 0;
|
|
1280
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1300
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _12 => _12.aborted])) {
|
|
1281
1301
|
throw abortError;
|
|
1282
1302
|
}
|
|
1283
1303
|
const handleRetryError = (err) => {
|
|
1284
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1304
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _13 => _13.aborted])) {
|
|
1285
1305
|
throw abortError;
|
|
1286
1306
|
}
|
|
1287
1307
|
if (err instanceof HttpError && err.status === 413) {
|
|
@@ -1353,7 +1373,7 @@ function createApiClient({
|
|
|
1353
1373
|
try {
|
|
1354
1374
|
uploadId = createMultiPartUpload.uploadId;
|
|
1355
1375
|
const parts = splitFileIntoParts(attachment.file);
|
|
1356
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1376
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _14 => _14.aborted])) {
|
|
1357
1377
|
throw abortError;
|
|
1358
1378
|
}
|
|
1359
1379
|
const batches = chunk(parts, 5);
|
|
@@ -1380,7 +1400,7 @@ function createApiClient({
|
|
|
1380
1400
|
}
|
|
1381
1401
|
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
1382
1402
|
}
|
|
1383
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1403
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _15 => _15.aborted])) {
|
|
1384
1404
|
throw abortError;
|
|
1385
1405
|
}
|
|
1386
1406
|
const sortedUploadedParts = uploadedParts.sort(
|
|
@@ -1396,7 +1416,7 @@ function createApiClient({
|
|
|
1396
1416
|
{ signal: abortSignal }
|
|
1397
1417
|
);
|
|
1398
1418
|
} catch (error3) {
|
|
1399
|
-
if (uploadId && _optionalChain([error3, 'optionalAccess',
|
|
1419
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _16 => _16.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
1400
1420
|
try {
|
|
1401
1421
|
await httpClient.rawDelete(
|
|
1402
1422
|
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
@@ -1603,7 +1623,7 @@ function createApiClient({
|
|
|
1603
1623
|
url`/v2/c/inbox-notifications`,
|
|
1604
1624
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
1605
1625
|
{
|
|
1606
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
1626
|
+
cursor: _optionalChain([options, 'optionalAccess', _17 => _17.cursor]),
|
|
1607
1627
|
limit: PAGE_SIZE
|
|
1608
1628
|
}
|
|
1609
1629
|
);
|
|
@@ -1687,7 +1707,7 @@ function createApiClient({
|
|
|
1687
1707
|
}
|
|
1688
1708
|
async function getUserThreads_experimental(options) {
|
|
1689
1709
|
let query;
|
|
1690
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1710
|
+
if (_optionalChain([options, 'optionalAccess', _18 => _18.query])) {
|
|
1691
1711
|
query = objectToQuery(options.query);
|
|
1692
1712
|
}
|
|
1693
1713
|
const PAGE_SIZE = 50;
|
|
@@ -1695,7 +1715,7 @@ function createApiClient({
|
|
|
1695
1715
|
url`/v2/c/threads`,
|
|
1696
1716
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
1697
1717
|
{
|
|
1698
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
1718
|
+
cursor: _optionalChain([options, 'optionalAccess', _19 => _19.cursor]),
|
|
1699
1719
|
query,
|
|
1700
1720
|
limit: PAGE_SIZE
|
|
1701
1721
|
}
|
|
@@ -1820,7 +1840,7 @@ var HttpClient = class {
|
|
|
1820
1840
|
// These headers are default, but can be overriden by custom headers
|
|
1821
1841
|
"Content-Type": "application/json; charset=utf-8",
|
|
1822
1842
|
// Possible header overrides
|
|
1823
|
-
..._optionalChain([options, 'optionalAccess',
|
|
1843
|
+
..._optionalChain([options, 'optionalAccess', _20 => _20.headers]),
|
|
1824
1844
|
// Cannot be overriden by custom headers
|
|
1825
1845
|
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
1826
1846
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
@@ -1844,19 +1864,12 @@ var HttpClient = class {
|
|
|
1844
1864
|
async #fetch(endpoint, authValue, options, params) {
|
|
1845
1865
|
const response = await this.#rawFetch(endpoint, authValue, options, params);
|
|
1846
1866
|
if (!response.ok) {
|
|
1847
|
-
|
|
1848
|
-
try {
|
|
1849
|
-
const errorBody = await response.json();
|
|
1850
|
-
error3 = new HttpError(errorBody.message, response.status, errorBody);
|
|
1851
|
-
} catch (e2) {
|
|
1852
|
-
error3 = new HttpError(response.statusText, response.status);
|
|
1853
|
-
}
|
|
1854
|
-
throw error3;
|
|
1867
|
+
throw await HttpError.fromResponse(response);
|
|
1855
1868
|
}
|
|
1856
1869
|
let body;
|
|
1857
1870
|
try {
|
|
1858
1871
|
body = await response.json();
|
|
1859
|
-
} catch (
|
|
1872
|
+
} catch (e4) {
|
|
1860
1873
|
body = {};
|
|
1861
1874
|
}
|
|
1862
1875
|
return body;
|
|
@@ -2302,7 +2315,7 @@ var FSM = class {
|
|
|
2302
2315
|
});
|
|
2303
2316
|
}
|
|
2304
2317
|
#getTargetFn(eventName) {
|
|
2305
|
-
return _optionalChain([this, 'access',
|
|
2318
|
+
return _optionalChain([this, 'access', _21 => _21.#allowedTransitions, 'access', _22 => _22.get, 'call', _23 => _23(this.currentState), 'optionalAccess', _24 => _24.get, 'call', _25 => _25(eventName)]);
|
|
2306
2319
|
}
|
|
2307
2320
|
/**
|
|
2308
2321
|
* Exits the current state, and executes any necessary cleanup functions.
|
|
@@ -2319,7 +2332,7 @@ var FSM = class {
|
|
|
2319
2332
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
2320
2333
|
levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
|
|
2321
2334
|
for (let i = 0; i < levels; i++) {
|
|
2322
|
-
_optionalChain([this, 'access',
|
|
2335
|
+
_optionalChain([this, 'access', _26 => _26.#cleanupStack, 'access', _27 => _27.pop, 'call', _28 => _28(), 'optionalCall', _29 => _29(patchableContext)]);
|
|
2323
2336
|
}
|
|
2324
2337
|
});
|
|
2325
2338
|
}
|
|
@@ -2335,7 +2348,7 @@ var FSM = class {
|
|
|
2335
2348
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
2336
2349
|
for (const pattern of enterPatterns) {
|
|
2337
2350
|
const enterFn = this.#enterFns.get(pattern);
|
|
2338
|
-
const cleanupFn = _optionalChain([enterFn, 'optionalCall',
|
|
2351
|
+
const cleanupFn = _optionalChain([enterFn, 'optionalCall', _30 => _30(patchableContext)]);
|
|
2339
2352
|
if (typeof cleanupFn === "function") {
|
|
2340
2353
|
this.#cleanupStack.push(cleanupFn);
|
|
2341
2354
|
} else {
|
|
@@ -2495,13 +2508,6 @@ var StopRetrying = class extends Error {
|
|
|
2495
2508
|
super(reason);
|
|
2496
2509
|
}
|
|
2497
2510
|
};
|
|
2498
|
-
var LiveblocksError = class extends Error {
|
|
2499
|
-
/** @internal */
|
|
2500
|
-
constructor(message, code) {
|
|
2501
|
-
super(message);
|
|
2502
|
-
this.code = code;
|
|
2503
|
-
}
|
|
2504
|
-
};
|
|
2505
2511
|
function nextBackoffDelay(currentDelay, delays) {
|
|
2506
2512
|
return _nullishCoalesce(delays.find((delay) => delay > currentDelay), () => ( delays[delays.length - 1]));
|
|
2507
2513
|
}
|
|
@@ -2611,11 +2617,10 @@ var assign = (patch) => (ctx) => ctx.patch(patch);
|
|
|
2611
2617
|
function createConnectionStateMachine(delegates, options) {
|
|
2612
2618
|
const onMessage = makeBufferableEventSource();
|
|
2613
2619
|
onMessage.pause();
|
|
2614
|
-
const
|
|
2615
|
-
function fireErrorEvent(
|
|
2620
|
+
const onConnectionError = makeEventSource();
|
|
2621
|
+
function fireErrorEvent(message, code) {
|
|
2616
2622
|
return () => {
|
|
2617
|
-
|
|
2618
|
-
onLiveblocksError.notify(err);
|
|
2623
|
+
onConnectionError.notify({ message, code });
|
|
2619
2624
|
};
|
|
2620
2625
|
}
|
|
2621
2626
|
const initialContext = {
|
|
@@ -2737,7 +2742,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2737
2742
|
}
|
|
2738
2743
|
function waitForActorId(event) {
|
|
2739
2744
|
const serverMsg = tryParseJson(event.data);
|
|
2740
|
-
if (_optionalChain([serverMsg, 'optionalAccess',
|
|
2745
|
+
if (_optionalChain([serverMsg, 'optionalAccess', _31 => _31.type]) === 104 /* ROOM_STATE */) {
|
|
2741
2746
|
didReceiveActor();
|
|
2742
2747
|
}
|
|
2743
2748
|
}
|
|
@@ -2846,12 +2851,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2846
2851
|
const sendHeartbeat = {
|
|
2847
2852
|
target: "@ok.awaiting-pong",
|
|
2848
2853
|
effect: (ctx) => {
|
|
2849
|
-
_optionalChain([ctx, 'access',
|
|
2854
|
+
_optionalChain([ctx, 'access', _32 => _32.socket, 'optionalAccess', _33 => _33.send, 'call', _34 => _34("ping")]);
|
|
2850
2855
|
}
|
|
2851
2856
|
};
|
|
2852
2857
|
const maybeHeartbeat = () => {
|
|
2853
2858
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
2854
|
-
const canZombie = _optionalChain([doc, 'optionalAccess',
|
|
2859
|
+
const canZombie = _optionalChain([doc, 'optionalAccess', _35 => _35.visibilityState]) === "hidden" && delegates.canZombie();
|
|
2855
2860
|
return canZombie ? "@idle.zombie" : sendHeartbeat;
|
|
2856
2861
|
};
|
|
2857
2862
|
machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
|
|
@@ -2890,7 +2895,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2890
2895
|
// socket, or not. So always check to see if the socket is still OPEN or
|
|
2891
2896
|
// not. When still OPEN, don't transition.
|
|
2892
2897
|
EXPLICIT_SOCKET_ERROR: (_, context) => {
|
|
2893
|
-
if (_optionalChain([context, 'access',
|
|
2898
|
+
if (_optionalChain([context, 'access', _36 => _36.socket, 'optionalAccess', _37 => _37.readyState]) === 1) {
|
|
2894
2899
|
return null;
|
|
2895
2900
|
}
|
|
2896
2901
|
return {
|
|
@@ -2942,17 +2947,17 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2942
2947
|
machine.send({ type: "NAVIGATOR_ONLINE" });
|
|
2943
2948
|
}
|
|
2944
2949
|
function onVisibilityChange() {
|
|
2945
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
2950
|
+
if (_optionalChain([doc, 'optionalAccess', _38 => _38.visibilityState]) === "visible") {
|
|
2946
2951
|
machine.send({ type: "WINDOW_GOT_FOCUS" });
|
|
2947
2952
|
}
|
|
2948
2953
|
}
|
|
2949
|
-
_optionalChain([win, 'optionalAccess',
|
|
2950
|
-
_optionalChain([win, 'optionalAccess',
|
|
2951
|
-
_optionalChain([root, 'optionalAccess',
|
|
2954
|
+
_optionalChain([win, 'optionalAccess', _39 => _39.addEventListener, 'call', _40 => _40("online", onNetworkBackOnline)]);
|
|
2955
|
+
_optionalChain([win, 'optionalAccess', _41 => _41.addEventListener, 'call', _42 => _42("offline", onNetworkOffline)]);
|
|
2956
|
+
_optionalChain([root, 'optionalAccess', _43 => _43.addEventListener, 'call', _44 => _44("visibilitychange", onVisibilityChange)]);
|
|
2952
2957
|
return () => {
|
|
2953
|
-
_optionalChain([root, 'optionalAccess',
|
|
2954
|
-
_optionalChain([win, 'optionalAccess',
|
|
2955
|
-
_optionalChain([win, 'optionalAccess',
|
|
2958
|
+
_optionalChain([root, 'optionalAccess', _45 => _45.removeEventListener, 'call', _46 => _46("visibilitychange", onVisibilityChange)]);
|
|
2959
|
+
_optionalChain([win, 'optionalAccess', _47 => _47.removeEventListener, 'call', _48 => _48("online", onNetworkBackOnline)]);
|
|
2960
|
+
_optionalChain([win, 'optionalAccess', _49 => _49.removeEventListener, 'call', _50 => _50("offline", onNetworkOffline)]);
|
|
2956
2961
|
teardownSocket(ctx.socket);
|
|
2957
2962
|
};
|
|
2958
2963
|
});
|
|
@@ -2973,7 +2978,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
2973
2978
|
didConnect,
|
|
2974
2979
|
didDisconnect,
|
|
2975
2980
|
onMessage: onMessage.observable,
|
|
2976
|
-
|
|
2981
|
+
onConnectionError: onConnectionError.observable
|
|
2977
2982
|
}
|
|
2978
2983
|
};
|
|
2979
2984
|
}
|
|
@@ -2993,7 +2998,7 @@ var ManagedSocket = class {
|
|
|
2993
2998
|
getStatus() {
|
|
2994
2999
|
try {
|
|
2995
3000
|
return toNewConnectionStatus(this.#machine);
|
|
2996
|
-
} catch (
|
|
3001
|
+
} catch (e5) {
|
|
2997
3002
|
return "initial";
|
|
2998
3003
|
}
|
|
2999
3004
|
}
|
|
@@ -3041,7 +3046,7 @@ var ManagedSocket = class {
|
|
|
3041
3046
|
* message if this is somehow impossible.
|
|
3042
3047
|
*/
|
|
3043
3048
|
send(data) {
|
|
3044
|
-
const socket = _optionalChain([this, 'access',
|
|
3049
|
+
const socket = _optionalChain([this, 'access', _51 => _51.#machine, 'access', _52 => _52.context, 'optionalAccess', _53 => _53.socket]);
|
|
3045
3050
|
if (socket === null) {
|
|
3046
3051
|
warn("Cannot send: not connected yet", data);
|
|
3047
3052
|
} else if (socket.readyState !== 1) {
|
|
@@ -3145,7 +3150,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
3145
3150
|
return void 0;
|
|
3146
3151
|
}
|
|
3147
3152
|
async function makeAuthRequest(options) {
|
|
3148
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
3153
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _54 => _54.polyfills, 'optionalAccess', _55 => _55.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
3149
3154
|
if (authentication.type === "private") {
|
|
3150
3155
|
if (fetcher === void 0) {
|
|
3151
3156
|
throw new StopRetrying(
|
|
@@ -3161,7 +3166,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
3161
3166
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
3162
3167
|
);
|
|
3163
3168
|
}
|
|
3164
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
3169
|
+
_optionalChain([onAuthenticate, 'optionalCall', _56 => _56(parsed.parsed)]);
|
|
3165
3170
|
return parsed;
|
|
3166
3171
|
}
|
|
3167
3172
|
if (authentication.type === "custom") {
|
|
@@ -3169,7 +3174,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
3169
3174
|
if (response && typeof response === "object") {
|
|
3170
3175
|
if (typeof response.token === "string") {
|
|
3171
3176
|
const parsed = parseAuthToken(response.token);
|
|
3172
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
3177
|
+
_optionalChain([onAuthenticate, 'optionalCall', _57 => _57(parsed.parsed)]);
|
|
3173
3178
|
return parsed;
|
|
3174
3179
|
} else if (typeof response.error === "string") {
|
|
3175
3180
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -3330,7 +3335,7 @@ function sendToPanel(message, options) {
|
|
|
3330
3335
|
...message,
|
|
3331
3336
|
source: "liveblocks-devtools-client"
|
|
3332
3337
|
};
|
|
3333
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
3338
|
+
if (!(_optionalChain([options, 'optionalAccess', _58 => _58.force]) || _bridgeActive)) {
|
|
3334
3339
|
return;
|
|
3335
3340
|
}
|
|
3336
3341
|
window.postMessage(fullMsg, "*");
|
|
@@ -3338,7 +3343,7 @@ function sendToPanel(message, options) {
|
|
|
3338
3343
|
var eventSource = makeEventSource();
|
|
3339
3344
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
3340
3345
|
window.addEventListener("message", (event) => {
|
|
3341
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
3346
|
+
if (event.source === window && _optionalChain([event, 'access', _59 => _59.data, 'optionalAccess', _60 => _60.source]) === "liveblocks-devtools-panel") {
|
|
3342
3347
|
eventSource.notify(event.data);
|
|
3343
3348
|
} else {
|
|
3344
3349
|
}
|
|
@@ -3480,7 +3485,7 @@ function fullSync(room) {
|
|
|
3480
3485
|
msg: "room::sync::full",
|
|
3481
3486
|
roomId: room.id,
|
|
3482
3487
|
status: room.getStatus(),
|
|
3483
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
3488
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _61 => _61.toTreeNode, 'call', _62 => _62("root"), 'access', _63 => _63.payload]), () => ( null)),
|
|
3484
3489
|
me,
|
|
3485
3490
|
others
|
|
3486
3491
|
});
|
|
@@ -3904,7 +3909,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
3904
3909
|
return [
|
|
3905
3910
|
{
|
|
3906
3911
|
type: 8 /* CREATE_REGISTER */,
|
|
3907
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
3912
|
+
opId: _optionalChain([pool, 'optionalAccess', _64 => _64.generateOpId, 'call', _65 => _65()]),
|
|
3908
3913
|
id: this._id,
|
|
3909
3914
|
parentId,
|
|
3910
3915
|
parentKey,
|
|
@@ -4010,7 +4015,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4010
4015
|
const ops = [];
|
|
4011
4016
|
const op = {
|
|
4012
4017
|
id: this._id,
|
|
4013
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
4018
|
+
opId: _optionalChain([pool, 'optionalAccess', _66 => _66.generateOpId, 'call', _67 => _67()]),
|
|
4014
4019
|
type: 2 /* CREATE_LIST */,
|
|
4015
4020
|
parentId,
|
|
4016
4021
|
parentKey
|
|
@@ -4281,7 +4286,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4281
4286
|
#applyInsertUndoRedo(op) {
|
|
4282
4287
|
const { id, parentKey: key } = op;
|
|
4283
4288
|
const child = creationOpToLiveNode(op);
|
|
4284
|
-
if (_optionalChain([this, 'access',
|
|
4289
|
+
if (_optionalChain([this, 'access', _68 => _68._pool, 'optionalAccess', _69 => _69.getNode, 'call', _70 => _70(id)]) !== void 0) {
|
|
4285
4290
|
return { modified: false };
|
|
4286
4291
|
}
|
|
4287
4292
|
child._attach(id, nn(this._pool));
|
|
@@ -4289,8 +4294,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4289
4294
|
const existingItemIndex = this._indexOfPosition(key);
|
|
4290
4295
|
let newKey = key;
|
|
4291
4296
|
if (existingItemIndex !== -1) {
|
|
4292
|
-
const before2 = _optionalChain([this, 'access',
|
|
4293
|
-
const after2 = _optionalChain([this, 'access',
|
|
4297
|
+
const before2 = _optionalChain([this, 'access', _71 => _71.#items, 'access', _72 => _72[existingItemIndex], 'optionalAccess', _73 => _73._parentPos]);
|
|
4298
|
+
const after2 = _optionalChain([this, 'access', _74 => _74.#items, 'access', _75 => _75[existingItemIndex + 1], 'optionalAccess', _76 => _76._parentPos]);
|
|
4294
4299
|
newKey = makePosition(before2, after2);
|
|
4295
4300
|
child._setParentLink(this, newKey);
|
|
4296
4301
|
}
|
|
@@ -4304,7 +4309,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4304
4309
|
#applySetUndoRedo(op) {
|
|
4305
4310
|
const { id, parentKey: key } = op;
|
|
4306
4311
|
const child = creationOpToLiveNode(op);
|
|
4307
|
-
if (_optionalChain([this, 'access',
|
|
4312
|
+
if (_optionalChain([this, 'access', _77 => _77._pool, 'optionalAccess', _78 => _78.getNode, 'call', _79 => _79(id)]) !== void 0) {
|
|
4308
4313
|
return { modified: false };
|
|
4309
4314
|
}
|
|
4310
4315
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -4425,7 +4430,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4425
4430
|
} else {
|
|
4426
4431
|
this.#items[existingItemIndex]._setParentLink(
|
|
4427
4432
|
this,
|
|
4428
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
4433
|
+
makePosition(newKey, _optionalChain([this, 'access', _80 => _80.#items, 'access', _81 => _81[existingItemIndex + 1], 'optionalAccess', _82 => _82._parentPos]))
|
|
4429
4434
|
);
|
|
4430
4435
|
const previousIndex = this.#items.indexOf(child);
|
|
4431
4436
|
child._setParentLink(this, newKey);
|
|
@@ -4450,7 +4455,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4450
4455
|
if (existingItemIndex !== -1) {
|
|
4451
4456
|
this.#items[existingItemIndex]._setParentLink(
|
|
4452
4457
|
this,
|
|
4453
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
4458
|
+
makePosition(newKey, _optionalChain([this, 'access', _83 => _83.#items, 'access', _84 => _84[existingItemIndex + 1], 'optionalAccess', _85 => _85._parentPos]))
|
|
4454
4459
|
);
|
|
4455
4460
|
}
|
|
4456
4461
|
child._setParentLink(this, newKey);
|
|
@@ -4469,7 +4474,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4469
4474
|
if (existingItemIndex !== -1) {
|
|
4470
4475
|
this.#items[existingItemIndex]._setParentLink(
|
|
4471
4476
|
this,
|
|
4472
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
4477
|
+
makePosition(newKey, _optionalChain([this, 'access', _86 => _86.#items, 'access', _87 => _87[existingItemIndex + 1], 'optionalAccess', _88 => _88._parentPos]))
|
|
4473
4478
|
);
|
|
4474
4479
|
}
|
|
4475
4480
|
child._setParentLink(this, newKey);
|
|
@@ -4496,7 +4501,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4496
4501
|
if (existingItemIndex !== -1) {
|
|
4497
4502
|
this.#items[existingItemIndex]._setParentLink(
|
|
4498
4503
|
this,
|
|
4499
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
4504
|
+
makePosition(newKey, _optionalChain([this, 'access', _89 => _89.#items, 'access', _90 => _90[existingItemIndex + 1], 'optionalAccess', _91 => _91._parentPos]))
|
|
4500
4505
|
);
|
|
4501
4506
|
}
|
|
4502
4507
|
child._setParentLink(this, newKey);
|
|
@@ -4554,7 +4559,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4554
4559
|
* @param element The element to add to the end of the LiveList.
|
|
4555
4560
|
*/
|
|
4556
4561
|
push(element) {
|
|
4557
|
-
_optionalChain([this, 'access',
|
|
4562
|
+
_optionalChain([this, 'access', _92 => _92._pool, 'optionalAccess', _93 => _93.assertStorageIsWritable, 'call', _94 => _94()]);
|
|
4558
4563
|
return this.insert(element, this.length);
|
|
4559
4564
|
}
|
|
4560
4565
|
/**
|
|
@@ -4563,7 +4568,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4563
4568
|
* @param index The index at which you want to insert the element.
|
|
4564
4569
|
*/
|
|
4565
4570
|
insert(element, index) {
|
|
4566
|
-
_optionalChain([this, 'access',
|
|
4571
|
+
_optionalChain([this, 'access', _95 => _95._pool, 'optionalAccess', _96 => _96.assertStorageIsWritable, 'call', _97 => _97()]);
|
|
4567
4572
|
if (index < 0 || index > this.#items.length) {
|
|
4568
4573
|
throw new Error(
|
|
4569
4574
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -4593,7 +4598,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4593
4598
|
* @param targetIndex The index where the element should be after moving.
|
|
4594
4599
|
*/
|
|
4595
4600
|
move(index, targetIndex) {
|
|
4596
|
-
_optionalChain([this, 'access',
|
|
4601
|
+
_optionalChain([this, 'access', _98 => _98._pool, 'optionalAccess', _99 => _99.assertStorageIsWritable, 'call', _100 => _100()]);
|
|
4597
4602
|
if (targetIndex < 0) {
|
|
4598
4603
|
throw new Error("targetIndex cannot be less than 0");
|
|
4599
4604
|
}
|
|
@@ -4651,7 +4656,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4651
4656
|
* @param index The index of the element to delete
|
|
4652
4657
|
*/
|
|
4653
4658
|
delete(index) {
|
|
4654
|
-
_optionalChain([this, 'access',
|
|
4659
|
+
_optionalChain([this, 'access', _101 => _101._pool, 'optionalAccess', _102 => _102.assertStorageIsWritable, 'call', _103 => _103()]);
|
|
4655
4660
|
if (index < 0 || index >= this.#items.length) {
|
|
4656
4661
|
throw new Error(
|
|
4657
4662
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -4684,7 +4689,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4684
4689
|
}
|
|
4685
4690
|
}
|
|
4686
4691
|
clear() {
|
|
4687
|
-
_optionalChain([this, 'access',
|
|
4692
|
+
_optionalChain([this, 'access', _104 => _104._pool, 'optionalAccess', _105 => _105.assertStorageIsWritable, 'call', _106 => _106()]);
|
|
4688
4693
|
if (this._pool) {
|
|
4689
4694
|
const ops = [];
|
|
4690
4695
|
const reverseOps = [];
|
|
@@ -4718,7 +4723,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4718
4723
|
}
|
|
4719
4724
|
}
|
|
4720
4725
|
set(index, item) {
|
|
4721
|
-
_optionalChain([this, 'access',
|
|
4726
|
+
_optionalChain([this, 'access', _107 => _107._pool, 'optionalAccess', _108 => _108.assertStorageIsWritable, 'call', _109 => _109()]);
|
|
4722
4727
|
if (index < 0 || index >= this.#items.length) {
|
|
4723
4728
|
throw new Error(
|
|
4724
4729
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -4864,7 +4869,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4864
4869
|
#shiftItemPosition(index, key) {
|
|
4865
4870
|
const shiftedPosition = makePosition(
|
|
4866
4871
|
key,
|
|
4867
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
4872
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _110 => _110.#items, 'access', _111 => _111[index + 1], 'optionalAccess', _112 => _112._parentPos]) : void 0
|
|
4868
4873
|
);
|
|
4869
4874
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
4870
4875
|
}
|
|
@@ -4989,7 +4994,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
4989
4994
|
const ops = [];
|
|
4990
4995
|
const op = {
|
|
4991
4996
|
id: this._id,
|
|
4992
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
4997
|
+
opId: _optionalChain([pool, 'optionalAccess', _113 => _113.generateOpId, 'call', _114 => _114()]),
|
|
4993
4998
|
type: 7 /* CREATE_MAP */,
|
|
4994
4999
|
parentId,
|
|
4995
5000
|
parentKey
|
|
@@ -5124,7 +5129,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
5124
5129
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
5125
5130
|
*/
|
|
5126
5131
|
set(key, value) {
|
|
5127
|
-
_optionalChain([this, 'access',
|
|
5132
|
+
_optionalChain([this, 'access', _115 => _115._pool, 'optionalAccess', _116 => _116.assertStorageIsWritable, 'call', _117 => _117()]);
|
|
5128
5133
|
const oldValue = this.#map.get(key);
|
|
5129
5134
|
if (oldValue) {
|
|
5130
5135
|
oldValue._detach();
|
|
@@ -5170,7 +5175,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
5170
5175
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
5171
5176
|
*/
|
|
5172
5177
|
delete(key) {
|
|
5173
|
-
_optionalChain([this, 'access',
|
|
5178
|
+
_optionalChain([this, 'access', _118 => _118._pool, 'optionalAccess', _119 => _119.assertStorageIsWritable, 'call', _120 => _120()]);
|
|
5174
5179
|
const item = this.#map.get(key);
|
|
5175
5180
|
if (item === void 0) {
|
|
5176
5181
|
return false;
|
|
@@ -5349,7 +5354,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5349
5354
|
if (this._id === void 0) {
|
|
5350
5355
|
throw new Error("Cannot serialize item is not attached");
|
|
5351
5356
|
}
|
|
5352
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
5357
|
+
const opId = _optionalChain([pool, 'optionalAccess', _121 => _121.generateOpId, 'call', _122 => _122()]);
|
|
5353
5358
|
const ops = [];
|
|
5354
5359
|
const op = {
|
|
5355
5360
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -5621,7 +5626,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5621
5626
|
* @param value The value of the property to add
|
|
5622
5627
|
*/
|
|
5623
5628
|
set(key, value) {
|
|
5624
|
-
_optionalChain([this, 'access',
|
|
5629
|
+
_optionalChain([this, 'access', _123 => _123._pool, 'optionalAccess', _124 => _124.assertStorageIsWritable, 'call', _125 => _125()]);
|
|
5625
5630
|
this.update({ [key]: value });
|
|
5626
5631
|
}
|
|
5627
5632
|
/**
|
|
@@ -5636,7 +5641,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5636
5641
|
* @param key The key of the property to delete
|
|
5637
5642
|
*/
|
|
5638
5643
|
delete(key) {
|
|
5639
|
-
_optionalChain([this, 'access',
|
|
5644
|
+
_optionalChain([this, 'access', _126 => _126._pool, 'optionalAccess', _127 => _127.assertStorageIsWritable, 'call', _128 => _128()]);
|
|
5640
5645
|
const keyAsString = key;
|
|
5641
5646
|
const oldValue = this.#map.get(keyAsString);
|
|
5642
5647
|
if (oldValue === void 0) {
|
|
@@ -5689,7 +5694,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5689
5694
|
* @param patch The object used to overrides properties
|
|
5690
5695
|
*/
|
|
5691
5696
|
update(patch) {
|
|
5692
|
-
_optionalChain([this, 'access',
|
|
5697
|
+
_optionalChain([this, 'access', _129 => _129._pool, 'optionalAccess', _130 => _130.assertStorageIsWritable, 'call', _131 => _131()]);
|
|
5693
5698
|
if (this._pool === void 0 || this._id === void 0) {
|
|
5694
5699
|
for (const key in patch) {
|
|
5695
5700
|
const newValue = patch[key];
|
|
@@ -6237,6 +6242,83 @@ var ManagedOthers = class {
|
|
|
6237
6242
|
}
|
|
6238
6243
|
};
|
|
6239
6244
|
|
|
6245
|
+
// src/types/LiveblocksError.ts
|
|
6246
|
+
var LiveblocksError = class _LiveblocksError extends Error {
|
|
6247
|
+
|
|
6248
|
+
constructor(message, context, cause) {
|
|
6249
|
+
super(message, { cause });
|
|
6250
|
+
this.context = context;
|
|
6251
|
+
this.name = "LiveblocksError";
|
|
6252
|
+
}
|
|
6253
|
+
/** Convenience accessor for error.context.roomId (if available) */
|
|
6254
|
+
get roomId() {
|
|
6255
|
+
return this.context.roomId;
|
|
6256
|
+
}
|
|
6257
|
+
/** @deprecated Prefer using `context.code` instead, to enable type narrowing */
|
|
6258
|
+
get code() {
|
|
6259
|
+
return this.context.code;
|
|
6260
|
+
}
|
|
6261
|
+
/**
|
|
6262
|
+
* Creates a LiveblocksError from a generic error, by attaching Liveblocks
|
|
6263
|
+
* contextual information like room ID, thread ID, etc.
|
|
6264
|
+
*/
|
|
6265
|
+
static from(context, cause) {
|
|
6266
|
+
return new _LiveblocksError(
|
|
6267
|
+
defaultMessageFromContext(context),
|
|
6268
|
+
context,
|
|
6269
|
+
cause
|
|
6270
|
+
);
|
|
6271
|
+
}
|
|
6272
|
+
};
|
|
6273
|
+
function defaultMessageFromContext(context) {
|
|
6274
|
+
switch (context.type) {
|
|
6275
|
+
case "ROOM_CONNECTION_ERROR": {
|
|
6276
|
+
switch (context.code) {
|
|
6277
|
+
case 4001:
|
|
6278
|
+
return "Not allowed to connect to the room";
|
|
6279
|
+
case 4005:
|
|
6280
|
+
return "Room is already full";
|
|
6281
|
+
case 4006:
|
|
6282
|
+
return "Kicked out of the room, because the room ID changed";
|
|
6283
|
+
default:
|
|
6284
|
+
return "Could not connect to the room";
|
|
6285
|
+
}
|
|
6286
|
+
}
|
|
6287
|
+
case "CREATE_THREAD_ERROR":
|
|
6288
|
+
return "Could not create new thread";
|
|
6289
|
+
case "DELETE_THREAD_ERROR":
|
|
6290
|
+
return "Could not delete thread";
|
|
6291
|
+
case "EDIT_THREAD_METADATA_ERROR":
|
|
6292
|
+
return "Could not edit thread metadata";
|
|
6293
|
+
case "MARK_THREAD_AS_RESOLVED_ERROR":
|
|
6294
|
+
return "Could not mark thread as resolved";
|
|
6295
|
+
case "MARK_THREAD_AS_UNRESOLVED_ERROR":
|
|
6296
|
+
return "Could not mark thread as unresolved";
|
|
6297
|
+
case "CREATE_COMMENT_ERROR":
|
|
6298
|
+
return "Could not create new comment";
|
|
6299
|
+
case "EDIT_COMMENT_ERROR":
|
|
6300
|
+
return "Could not edit comment";
|
|
6301
|
+
case "DELETE_COMMENT_ERROR":
|
|
6302
|
+
return "Could not delete comment";
|
|
6303
|
+
case "ADD_REACTION_ERROR":
|
|
6304
|
+
return "Could not add reaction";
|
|
6305
|
+
case "REMOVE_REACTION_ERROR":
|
|
6306
|
+
return "Could not remove reaction";
|
|
6307
|
+
case "MARK_INBOX_NOTIFICATION_AS_READ_ERROR":
|
|
6308
|
+
return "Could not mark inbox notification as read";
|
|
6309
|
+
case "DELETE_INBOX_NOTIFICATION_ERROR":
|
|
6310
|
+
return "Could not delete inbox notification";
|
|
6311
|
+
case "MARK_ALL_INBOX_NOTIFICATIONS_AS_READ_ERROR":
|
|
6312
|
+
return "Could not mark all inbox notifications as read";
|
|
6313
|
+
case "DELETE_ALL_INBOX_NOTIFICATIONS_ERROR":
|
|
6314
|
+
return "Could not delete all inbox notifications";
|
|
6315
|
+
case "UPDATE_NOTIFICATION_SETTINGS_ERROR":
|
|
6316
|
+
return "Could not update notification settings";
|
|
6317
|
+
default:
|
|
6318
|
+
return assertNever(context, "Unhandled case");
|
|
6319
|
+
}
|
|
6320
|
+
}
|
|
6321
|
+
|
|
6240
6322
|
// src/room.ts
|
|
6241
6323
|
var MAX_SOCKET_MESSAGE_SIZE = 1024 * 1024 - 1024;
|
|
6242
6324
|
function makeIdFactory(connectionId) {
|
|
@@ -6261,15 +6343,15 @@ function installBackgroundTabSpy() {
|
|
|
6261
6343
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
6262
6344
|
const inBackgroundSince = { current: null };
|
|
6263
6345
|
function onVisibilityChange() {
|
|
6264
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
6346
|
+
if (_optionalChain([doc, 'optionalAccess', _132 => _132.visibilityState]) === "hidden") {
|
|
6265
6347
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
6266
6348
|
} else {
|
|
6267
6349
|
inBackgroundSince.current = null;
|
|
6268
6350
|
}
|
|
6269
6351
|
}
|
|
6270
|
-
_optionalChain([doc, 'optionalAccess',
|
|
6352
|
+
_optionalChain([doc, 'optionalAccess', _133 => _133.addEventListener, 'call', _134 => _134("visibilitychange", onVisibilityChange)]);
|
|
6271
6353
|
const unsub = () => {
|
|
6272
|
-
_optionalChain([doc, 'optionalAccess',
|
|
6354
|
+
_optionalChain([doc, 'optionalAccess', _135 => _135.removeEventListener, 'call', _136 => _136("visibilitychange", onVisibilityChange)]);
|
|
6273
6355
|
};
|
|
6274
6356
|
return [inBackgroundSince, unsub];
|
|
6275
6357
|
}
|
|
@@ -6401,13 +6483,17 @@ function createRoom(options, config) {
|
|
|
6401
6483
|
managedSocket.events.statusDidChange.subscribe(handleConnectionLossEvent);
|
|
6402
6484
|
managedSocket.events.didConnect.subscribe(onDidConnect);
|
|
6403
6485
|
managedSocket.events.didDisconnect.subscribe(onDidDisconnect);
|
|
6404
|
-
managedSocket.events.
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6486
|
+
managedSocket.events.onConnectionError.subscribe(({ message, code }) => {
|
|
6487
|
+
const type = "ROOM_CONNECTION_ERROR";
|
|
6488
|
+
const err = new LiveblocksError(message, { type, code, roomId });
|
|
6489
|
+
const didNotify = config.errorEventSource.notify(err);
|
|
6490
|
+
if (!didNotify) {
|
|
6491
|
+
if (process.env.NODE_ENV !== "production") {
|
|
6492
|
+
error2(
|
|
6493
|
+
`Connection to websocket server closed. Reason: ${message} (code: ${code}).`
|
|
6494
|
+
);
|
|
6495
|
+
}
|
|
6409
6496
|
}
|
|
6410
|
-
eventHub.error.notify(err);
|
|
6411
6497
|
});
|
|
6412
6498
|
const pool = {
|
|
6413
6499
|
roomId: config.roomId,
|
|
@@ -6450,7 +6536,7 @@ function createRoom(options, config) {
|
|
|
6450
6536
|
}
|
|
6451
6537
|
},
|
|
6452
6538
|
assertStorageIsWritable: () => {
|
|
6453
|
-
const scopes = _optionalChain([context, 'access',
|
|
6539
|
+
const scopes = _optionalChain([context, 'access', _137 => _137.dynamicSessionInfoSig, 'access', _138 => _138.get, 'call', _139 => _139(), 'optionalAccess', _140 => _140.scopes]);
|
|
6454
6540
|
if (scopes === void 0) {
|
|
6455
6541
|
return;
|
|
6456
6542
|
}
|
|
@@ -6470,7 +6556,6 @@ function createRoom(options, config) {
|
|
|
6470
6556
|
self: makeEventSource(),
|
|
6471
6557
|
myPresence: makeEventSource(),
|
|
6472
6558
|
others: makeEventSource(),
|
|
6473
|
-
error: makeEventSource(),
|
|
6474
6559
|
storageBatch: makeEventSource(),
|
|
6475
6560
|
history: makeEventSource(),
|
|
6476
6561
|
storageDidLoad: makeEventSource(),
|
|
@@ -6506,7 +6591,7 @@ function createRoom(options, config) {
|
|
|
6506
6591
|
}
|
|
6507
6592
|
function sendMessages(messages) {
|
|
6508
6593
|
const serializedPayload = JSON.stringify(messages);
|
|
6509
|
-
const nonce = _optionalChain([context, 'access',
|
|
6594
|
+
const nonce = _optionalChain([context, 'access', _141 => _141.dynamicSessionInfoSig, 'access', _142 => _142.get, 'call', _143 => _143(), 'optionalAccess', _144 => _144.nonce]);
|
|
6510
6595
|
if (config.unstable_fallbackToHTTP && nonce) {
|
|
6511
6596
|
const size = new TextEncoder().encode(serializedPayload).length;
|
|
6512
6597
|
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
@@ -6564,7 +6649,7 @@ function createRoom(options, config) {
|
|
|
6564
6649
|
} else {
|
|
6565
6650
|
context.root = LiveObject._fromItems(message.items, pool);
|
|
6566
6651
|
}
|
|
6567
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
6652
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _145 => _145.get, 'call', _146 => _146(), 'optionalAccess', _147 => _147.canWrite]), () => ( true));
|
|
6568
6653
|
const stackSizeBefore = context.undoStack.length;
|
|
6569
6654
|
for (const key in context.initialStorage) {
|
|
6570
6655
|
if (context.root.get(key) === void 0) {
|
|
@@ -6767,7 +6852,7 @@ function createRoom(options, config) {
|
|
|
6767
6852
|
}
|
|
6768
6853
|
context.myPresence.patch(patch);
|
|
6769
6854
|
if (context.activeBatch) {
|
|
6770
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6855
|
+
if (_optionalChain([options2, 'optionalAccess', _148 => _148.addToHistory])) {
|
|
6771
6856
|
context.activeBatch.reverseOps.unshift({
|
|
6772
6857
|
type: "presence",
|
|
6773
6858
|
data: oldValues
|
|
@@ -6776,7 +6861,7 @@ function createRoom(options, config) {
|
|
|
6776
6861
|
context.activeBatch.updates.presence = true;
|
|
6777
6862
|
} else {
|
|
6778
6863
|
flushNowOrSoon();
|
|
6779
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6864
|
+
if (_optionalChain([options2, 'optionalAccess', _149 => _149.addToHistory])) {
|
|
6780
6865
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
6781
6866
|
}
|
|
6782
6867
|
notify({ presence: true });
|
|
@@ -6973,7 +7058,7 @@ function createRoom(options, config) {
|
|
|
6973
7058
|
if (process.env.NODE_ENV !== "production") {
|
|
6974
7059
|
const traces = /* @__PURE__ */ new Set();
|
|
6975
7060
|
for (const opId of message.opIds) {
|
|
6976
|
-
const trace = _optionalChain([context, 'access',
|
|
7061
|
+
const trace = _optionalChain([context, 'access', _150 => _150.opStackTraces, 'optionalAccess', _151 => _151.get, 'call', _152 => _152(opId)]);
|
|
6977
7062
|
if (trace) {
|
|
6978
7063
|
traces.add(trace);
|
|
6979
7064
|
}
|
|
@@ -7071,11 +7156,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7071
7156
|
}
|
|
7072
7157
|
return messages;
|
|
7073
7158
|
}
|
|
7074
|
-
function updateYDoc(update, guid) {
|
|
7159
|
+
function updateYDoc(update, guid, isV2) {
|
|
7075
7160
|
const clientMsg = {
|
|
7076
7161
|
type: 301 /* UPDATE_YDOC */,
|
|
7077
7162
|
update,
|
|
7078
|
-
guid
|
|
7163
|
+
guid,
|
|
7164
|
+
v2: isV2
|
|
7079
7165
|
};
|
|
7080
7166
|
context.buffer.messages.push(clientMsg);
|
|
7081
7167
|
eventHub.ydoc.notify(clientMsg);
|
|
@@ -7106,7 +7192,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7106
7192
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
7107
7193
|
createOrUpdateRootFromMessage(message);
|
|
7108
7194
|
applyAndSendOps(unacknowledgedOps);
|
|
7109
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
7195
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _153 => _153()]);
|
|
7110
7196
|
notifyStorageStatus();
|
|
7111
7197
|
eventHub.storageDidLoad.notify();
|
|
7112
7198
|
}
|
|
@@ -7156,14 +7242,15 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7156
7242
|
root: nn(context.root)
|
|
7157
7243
|
};
|
|
7158
7244
|
}
|
|
7159
|
-
function fetchYDoc(vector, guid) {
|
|
7245
|
+
function fetchYDoc(vector, guid, isV2) {
|
|
7160
7246
|
if (!context.buffer.messages.find((m) => {
|
|
7161
|
-
return m.type === 300 /* FETCH_YDOC */ && m.vector === vector && m.guid === guid;
|
|
7247
|
+
return m.type === 300 /* FETCH_YDOC */ && m.vector === vector && m.guid === guid && m.v2 === isV2;
|
|
7162
7248
|
})) {
|
|
7163
7249
|
context.buffer.messages.push({
|
|
7164
7250
|
type: 300 /* FETCH_YDOC */,
|
|
7165
7251
|
vector,
|
|
7166
|
-
guid
|
|
7252
|
+
guid,
|
|
7253
|
+
v2: isV2
|
|
7167
7254
|
});
|
|
7168
7255
|
}
|
|
7169
7256
|
flushNowOrSoon();
|
|
@@ -7308,7 +7395,6 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7308
7395
|
others: eventHub.others.observable,
|
|
7309
7396
|
self: eventHub.self.observable,
|
|
7310
7397
|
myPresence: eventHub.myPresence.observable,
|
|
7311
|
-
error: eventHub.error.observable,
|
|
7312
7398
|
/** @deprecated */
|
|
7313
7399
|
storage: eventHub.storageBatch.observable,
|
|
7314
7400
|
storageBatch: eventHub.storageBatch.observable,
|
|
@@ -7328,8 +7414,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7328
7414
|
async function getThreads(options2) {
|
|
7329
7415
|
return httpClient.getThreads({
|
|
7330
7416
|
roomId,
|
|
7331
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
7332
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
7417
|
+
query: _optionalChain([options2, 'optionalAccess', _154 => _154.query]),
|
|
7418
|
+
cursor: _optionalChain([options2, 'optionalAccess', _155 => _155.cursor])
|
|
7333
7419
|
});
|
|
7334
7420
|
}
|
|
7335
7421
|
async function getThread(threadId) {
|
|
@@ -7430,7 +7516,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7430
7516
|
function getNotificationSettings(options2) {
|
|
7431
7517
|
return httpClient.getNotificationSettings({
|
|
7432
7518
|
roomId,
|
|
7433
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
7519
|
+
signal: _optionalChain([options2, 'optionalAccess', _156 => _156.signal])
|
|
7434
7520
|
});
|
|
7435
7521
|
}
|
|
7436
7522
|
function updateNotificationSettings(settings) {
|
|
@@ -7452,7 +7538,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7452
7538
|
{
|
|
7453
7539
|
[kInternal]: {
|
|
7454
7540
|
get presenceBuffer() {
|
|
7455
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
7541
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _157 => _157.buffer, 'access', _158 => _158.presenceUpdates, 'optionalAccess', _159 => _159.data]), () => ( null)));
|
|
7456
7542
|
},
|
|
7457
7543
|
// prettier-ignore
|
|
7458
7544
|
get undoStack() {
|
|
@@ -7467,9 +7553,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7467
7553
|
return context.yjsProvider;
|
|
7468
7554
|
},
|
|
7469
7555
|
setYjsProvider(newProvider) {
|
|
7470
|
-
_optionalChain([context, 'access',
|
|
7556
|
+
_optionalChain([context, 'access', _160 => _160.yjsProvider, 'optionalAccess', _161 => _161.off, 'call', _162 => _162("status", yjsStatusDidChange)]);
|
|
7471
7557
|
context.yjsProvider = newProvider;
|
|
7472
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
7558
|
+
_optionalChain([newProvider, 'optionalAccess', _163 => _163.on, 'call', _164 => _164("status", yjsStatusDidChange)]);
|
|
7473
7559
|
context.yjsProviderDidChange.notify();
|
|
7474
7560
|
},
|
|
7475
7561
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -7499,13 +7585,17 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7499
7585
|
attachmentUrlsStore: httpClient.getOrCreateAttachmentUrlsStore(roomId)
|
|
7500
7586
|
},
|
|
7501
7587
|
id: config.roomId,
|
|
7502
|
-
subscribe: makeClassicSubscribeFn(
|
|
7588
|
+
subscribe: makeClassicSubscribeFn(
|
|
7589
|
+
config.roomId,
|
|
7590
|
+
events,
|
|
7591
|
+
config.errorEventSource
|
|
7592
|
+
),
|
|
7503
7593
|
connect: () => managedSocket.connect(),
|
|
7504
7594
|
reconnect: () => managedSocket.reconnect(),
|
|
7505
7595
|
disconnect: () => managedSocket.disconnect(),
|
|
7506
7596
|
destroy: () => {
|
|
7507
7597
|
syncSourceForStorage.destroy();
|
|
7508
|
-
_optionalChain([context, 'access',
|
|
7598
|
+
_optionalChain([context, 'access', _165 => _165.yjsProvider, 'optionalAccess', _166 => _166.off, 'call', _167 => _167("status", yjsStatusDidChange)]);
|
|
7509
7599
|
syncSourceForYjs.destroy();
|
|
7510
7600
|
uninstallBgTabSpy();
|
|
7511
7601
|
managedSocket.destroy();
|
|
@@ -7568,7 +7658,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7568
7658
|
{ enumerable: false }
|
|
7569
7659
|
);
|
|
7570
7660
|
}
|
|
7571
|
-
function makeClassicSubscribeFn(events) {
|
|
7661
|
+
function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
7572
7662
|
function subscribeToLiveStructureDeeply(node, callback) {
|
|
7573
7663
|
return events.storageBatch.subscribe((updates) => {
|
|
7574
7664
|
const relatedUpdates = updates.filter(
|
|
@@ -7608,8 +7698,13 @@ function makeClassicSubscribeFn(events) {
|
|
|
7608
7698
|
return cb(others, internalEvent);
|
|
7609
7699
|
});
|
|
7610
7700
|
}
|
|
7611
|
-
case "error":
|
|
7612
|
-
return
|
|
7701
|
+
case "error": {
|
|
7702
|
+
return errorEvents.subscribe((err) => {
|
|
7703
|
+
if (err.roomId === roomId) {
|
|
7704
|
+
return callback(err);
|
|
7705
|
+
}
|
|
7706
|
+
});
|
|
7707
|
+
}
|
|
7613
7708
|
case "status":
|
|
7614
7709
|
return events.status.subscribe(callback);
|
|
7615
7710
|
case "lost-connection":
|
|
@@ -7644,7 +7739,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
7644
7739
|
}
|
|
7645
7740
|
if (isLiveNode(first)) {
|
|
7646
7741
|
const node = first;
|
|
7647
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
7742
|
+
if (_optionalChain([options, 'optionalAccess', _168 => _168.isDeep])) {
|
|
7648
7743
|
const storageCallback = second;
|
|
7649
7744
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
7650
7745
|
} else {
|
|
@@ -7723,8 +7818,8 @@ function createClient(options) {
|
|
|
7723
7818
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
7724
7819
|
currentUserId.set(() => userId);
|
|
7725
7820
|
});
|
|
7726
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
7727
|
-
_optionalChain([globalThis, 'access',
|
|
7821
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _169 => _169.polyfills, 'optionalAccess', _170 => _170.fetch]) || /* istanbul ignore next */
|
|
7822
|
+
_optionalChain([globalThis, 'access', _171 => _171.fetch, 'optionalAccess', _172 => _172.bind, 'call', _173 => _173(globalThis)]);
|
|
7728
7823
|
const httpClient = createApiClient({
|
|
7729
7824
|
baseUrl,
|
|
7730
7825
|
fetchPolyfill,
|
|
@@ -7775,12 +7870,13 @@ function createClient(options) {
|
|
|
7775
7870
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7776
7871
|
roomId,
|
|
7777
7872
|
baseUrl,
|
|
7778
|
-
_optionalChain([clientOptions, 'access',
|
|
7873
|
+
_optionalChain([clientOptions, 'access', _174 => _174.polyfills, 'optionalAccess', _175 => _175.WebSocket])
|
|
7779
7874
|
),
|
|
7780
7875
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7781
7876
|
})),
|
|
7782
7877
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7783
7878
|
baseUrl,
|
|
7879
|
+
errorEventSource: liveblocksErrorSource,
|
|
7784
7880
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7785
7881
|
unstable_streamData: !!clientOptions.unstable_streamData,
|
|
7786
7882
|
roomHttpClient: httpClient,
|
|
@@ -7797,7 +7893,7 @@ function createClient(options) {
|
|
|
7797
7893
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7798
7894
|
if (shouldConnect) {
|
|
7799
7895
|
if (typeof atob === "undefined") {
|
|
7800
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7896
|
+
if (_optionalChain([clientOptions, 'access', _176 => _176.polyfills, 'optionalAccess', _177 => _177.atob]) === void 0) {
|
|
7801
7897
|
throw new Error(
|
|
7802
7898
|
"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"
|
|
7803
7899
|
);
|
|
@@ -7809,7 +7905,7 @@ function createClient(options) {
|
|
|
7809
7905
|
return leaseRoom(newRoomDetails);
|
|
7810
7906
|
}
|
|
7811
7907
|
function getRoom(roomId) {
|
|
7812
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7908
|
+
const room = _optionalChain([roomsById, 'access', _178 => _178.get, 'call', _179 => _179(roomId), 'optionalAccess', _180 => _180.room]);
|
|
7813
7909
|
return room ? room : null;
|
|
7814
7910
|
}
|
|
7815
7911
|
function logout() {
|
|
@@ -7829,7 +7925,7 @@ function createClient(options) {
|
|
|
7829
7925
|
const batchedResolveUsers = new Batch(
|
|
7830
7926
|
async (batchedUserIds) => {
|
|
7831
7927
|
const userIds = batchedUserIds.flat();
|
|
7832
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7928
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _181 => _181({ userIds })]);
|
|
7833
7929
|
warnIfNoResolveUsers();
|
|
7834
7930
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7835
7931
|
},
|
|
@@ -7847,7 +7943,7 @@ function createClient(options) {
|
|
|
7847
7943
|
const batchedResolveRoomsInfo = new Batch(
|
|
7848
7944
|
async (batchedRoomIds) => {
|
|
7849
7945
|
const roomIds = batchedRoomIds.flat();
|
|
7850
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7946
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _182 => _182({ roomIds })]);
|
|
7851
7947
|
warnIfNoResolveRoomsInfo();
|
|
7852
7948
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7853
7949
|
},
|
|
@@ -7863,6 +7959,7 @@ function createClient(options) {
|
|
|
7863
7959
|
}
|
|
7864
7960
|
const syncStatusSources = [];
|
|
7865
7961
|
const syncStatusSignal = new Signal("synchronized");
|
|
7962
|
+
const liveblocksErrorSource = makeEventSource();
|
|
7866
7963
|
function getSyncStatus() {
|
|
7867
7964
|
const status = syncStatusSignal.get();
|
|
7868
7965
|
return status === "synchronizing" ? status : "synchronized";
|
|
@@ -7899,7 +7996,7 @@ function createClient(options) {
|
|
|
7899
7996
|
}
|
|
7900
7997
|
};
|
|
7901
7998
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
7902
|
-
_optionalChain([win, 'optionalAccess',
|
|
7999
|
+
_optionalChain([win, 'optionalAccess', _183 => _183.addEventListener, 'call', _184 => _184("beforeunload", maybePreventClose)]);
|
|
7903
8000
|
}
|
|
7904
8001
|
const client = Object.defineProperty(
|
|
7905
8002
|
{
|
|
@@ -7922,6 +8019,7 @@ function createClient(options) {
|
|
|
7922
8019
|
},
|
|
7923
8020
|
getSyncStatus,
|
|
7924
8021
|
events: {
|
|
8022
|
+
error: liveblocksErrorSource,
|
|
7925
8023
|
syncStatus: syncStatusSignal
|
|
7926
8024
|
},
|
|
7927
8025
|
// Internal
|
|
@@ -7937,7 +8035,14 @@ function createClient(options) {
|
|
|
7937
8035
|
httpClient,
|
|
7938
8036
|
// Type-level helper only, it's effectively only an identity-function at runtime
|
|
7939
8037
|
as: () => client,
|
|
7940
|
-
createSyncSource
|
|
8038
|
+
createSyncSource,
|
|
8039
|
+
emitError: (context, cause) => {
|
|
8040
|
+
const error3 = LiveblocksError.from(context, cause);
|
|
8041
|
+
const didNotify = liveblocksErrorSource.notify(error3);
|
|
8042
|
+
if (!didNotify) {
|
|
8043
|
+
error2(error3.message);
|
|
8044
|
+
}
|
|
8045
|
+
}
|
|
7941
8046
|
}
|
|
7942
8047
|
},
|
|
7943
8048
|
kInternal,
|
|
@@ -8016,7 +8121,7 @@ var commentBodyElementsTypes = {
|
|
|
8016
8121
|
mention: "inline"
|
|
8017
8122
|
};
|
|
8018
8123
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
8019
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
8124
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _185 => _185.content])) {
|
|
8020
8125
|
return;
|
|
8021
8126
|
}
|
|
8022
8127
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -8026,13 +8131,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
8026
8131
|
for (const block of body.content) {
|
|
8027
8132
|
if (type === "all" || type === "block") {
|
|
8028
8133
|
if (guard(block)) {
|
|
8029
|
-
_optionalChain([visitor, 'optionalCall',
|
|
8134
|
+
_optionalChain([visitor, 'optionalCall', _186 => _186(block)]);
|
|
8030
8135
|
}
|
|
8031
8136
|
}
|
|
8032
8137
|
if (type === "all" || type === "inline") {
|
|
8033
8138
|
for (const inline of block.children) {
|
|
8034
8139
|
if (guard(inline)) {
|
|
8035
|
-
_optionalChain([visitor, 'optionalCall',
|
|
8140
|
+
_optionalChain([visitor, 'optionalCall', _187 => _187(inline)]);
|
|
8036
8141
|
}
|
|
8037
8142
|
}
|
|
8038
8143
|
}
|
|
@@ -8057,7 +8162,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
8057
8162
|
userIds
|
|
8058
8163
|
});
|
|
8059
8164
|
for (const [index, userId] of userIds.entries()) {
|
|
8060
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
8165
|
+
const user = _optionalChain([users, 'optionalAccess', _188 => _188[index]]);
|
|
8061
8166
|
if (user) {
|
|
8062
8167
|
resolvedUsers.set(userId, user);
|
|
8063
8168
|
}
|
|
@@ -8184,7 +8289,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
8184
8289
|
text: ({ element }) => element.text,
|
|
8185
8290
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
8186
8291
|
mention: ({ element, user }) => {
|
|
8187
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8292
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _189 => _189.name]), () => ( element.id))}`;
|
|
8188
8293
|
}
|
|
8189
8294
|
};
|
|
8190
8295
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -8214,7 +8319,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
8214
8319
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
8215
8320
|
},
|
|
8216
8321
|
mention: ({ element, user }) => {
|
|
8217
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8322
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _190 => _190.name]), () => ( element.id))}</span>`;
|
|
8218
8323
|
}
|
|
8219
8324
|
};
|
|
8220
8325
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -8244,19 +8349,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
8244
8349
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
8245
8350
|
},
|
|
8246
8351
|
mention: ({ element, user }) => {
|
|
8247
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8352
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _191 => _191.name]), () => ( element.id))}`;
|
|
8248
8353
|
}
|
|
8249
8354
|
};
|
|
8250
8355
|
async function stringifyCommentBody(body, options) {
|
|
8251
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8252
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8356
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _192 => _192.format]), () => ( "plain"));
|
|
8357
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _193 => _193.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
8253
8358
|
const elements = {
|
|
8254
8359
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
8255
|
-
..._optionalChain([options, 'optionalAccess',
|
|
8360
|
+
..._optionalChain([options, 'optionalAccess', _194 => _194.elements])
|
|
8256
8361
|
};
|
|
8257
8362
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
8258
8363
|
body,
|
|
8259
|
-
_optionalChain([options, 'optionalAccess',
|
|
8364
|
+
_optionalChain([options, 'optionalAccess', _195 => _195.resolveUsers])
|
|
8260
8365
|
);
|
|
8261
8366
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
8262
8367
|
switch (block.type) {
|
|
@@ -8547,12 +8652,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8547
8652
|
}
|
|
8548
8653
|
const newState = Object.assign({}, state);
|
|
8549
8654
|
for (const key in update.updates) {
|
|
8550
|
-
if (_optionalChain([update, 'access',
|
|
8655
|
+
if (_optionalChain([update, 'access', _196 => _196.updates, 'access', _197 => _197[key], 'optionalAccess', _198 => _198.type]) === "update") {
|
|
8551
8656
|
const val = update.node.get(key);
|
|
8552
8657
|
if (val !== void 0) {
|
|
8553
8658
|
newState[key] = lsonToJson(val);
|
|
8554
8659
|
}
|
|
8555
|
-
} else if (_optionalChain([update, 'access',
|
|
8660
|
+
} else if (_optionalChain([update, 'access', _199 => _199.updates, 'access', _200 => _200[key], 'optionalAccess', _201 => _201.type]) === "delete") {
|
|
8556
8661
|
delete newState[key];
|
|
8557
8662
|
}
|
|
8558
8663
|
}
|
|
@@ -8613,12 +8718,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8613
8718
|
}
|
|
8614
8719
|
const newState = Object.assign({}, state);
|
|
8615
8720
|
for (const key in update.updates) {
|
|
8616
|
-
if (_optionalChain([update, 'access',
|
|
8721
|
+
if (_optionalChain([update, 'access', _202 => _202.updates, 'access', _203 => _203[key], 'optionalAccess', _204 => _204.type]) === "update") {
|
|
8617
8722
|
const value = update.node.get(key);
|
|
8618
8723
|
if (value !== void 0) {
|
|
8619
8724
|
newState[key] = lsonToJson(value);
|
|
8620
8725
|
}
|
|
8621
|
-
} else if (_optionalChain([update, 'access',
|
|
8726
|
+
} else if (_optionalChain([update, 'access', _205 => _205.updates, 'access', _206 => _206[key], 'optionalAccess', _207 => _207.type]) === "delete") {
|
|
8622
8727
|
delete newState[key];
|
|
8623
8728
|
}
|
|
8624
8729
|
}
|
|
@@ -8689,9 +8794,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
8689
8794
|
const startTime = performance.now();
|
|
8690
8795
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8691
8796
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
8692
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8797
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _208 => _208.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
8693
8798
|
const context = {
|
|
8694
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
8799
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _209 => _209.visibilityState]) !== "hidden",
|
|
8695
8800
|
lastSuccessfulPollAt: startTime,
|
|
8696
8801
|
count: 0,
|
|
8697
8802
|
backoff: 0
|
|
@@ -8769,10 +8874,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
8769
8874
|
pollNowIfStale();
|
|
8770
8875
|
}
|
|
8771
8876
|
function onVisibilityChange() {
|
|
8772
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
8877
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _210 => _210.visibilityState]) !== "hidden");
|
|
8773
8878
|
}
|
|
8774
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8775
|
-
_optionalChain([win, 'optionalAccess',
|
|
8879
|
+
_optionalChain([doc, 'optionalAccess', _211 => _211.addEventListener, 'call', _212 => _212("visibilitychange", onVisibilityChange)]);
|
|
8880
|
+
_optionalChain([win, 'optionalAccess', _213 => _213.addEventListener, 'call', _214 => _214("online", onVisibilityChange)]);
|
|
8881
|
+
_optionalChain([win, 'optionalAccess', _215 => _215.addEventListener, 'call', _216 => _216("focus", pollNowIfStale)]);
|
|
8776
8882
|
fsm.start();
|
|
8777
8883
|
return {
|
|
8778
8884
|
inc,
|
|
@@ -8991,5 +9097,5 @@ var NotificationsApiError = HttpError;
|
|
|
8991
9097
|
|
|
8992
9098
|
|
|
8993
9099
|
|
|
8994
|
-
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.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.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; 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.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.kInternal = kInternal; 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.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toAbsoluteUrl = toAbsoluteUrl; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.
|
|
9100
|
+
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.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; 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.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.kInternal = kInternal; 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.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stringify = stringify; 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;
|
|
8995
9101
|
//# sourceMappingURL=index.js.map
|