@liveblocks/core 3.19.2 → 3.19.4-test1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +742 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +122 -10
- package/dist/index.d.ts +122 -10
- package/dist/index.js +672 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.19.
|
|
9
|
+
var PKG_VERSION = "3.19.4-test1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -5473,7 +5473,9 @@ var OpCode = Object.freeze({
|
|
|
5473
5473
|
DELETE_CRDT: 5,
|
|
5474
5474
|
DELETE_OBJECT_KEY: 6,
|
|
5475
5475
|
CREATE_MAP: 7,
|
|
5476
|
-
CREATE_REGISTER: 8
|
|
5476
|
+
CREATE_REGISTER: 8,
|
|
5477
|
+
CREATE_TEXT: 9,
|
|
5478
|
+
UPDATE_TEXT: 10
|
|
5477
5479
|
});
|
|
5478
5480
|
function isIgnoredOp(op) {
|
|
5479
5481
|
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
@@ -5484,7 +5486,8 @@ var CrdtType = Object.freeze({
|
|
|
5484
5486
|
OBJECT: 0,
|
|
5485
5487
|
LIST: 1,
|
|
5486
5488
|
MAP: 2,
|
|
5487
|
-
REGISTER: 3
|
|
5489
|
+
REGISTER: 3,
|
|
5490
|
+
TEXT: 4
|
|
5488
5491
|
});
|
|
5489
5492
|
function isRootStorageNode(node) {
|
|
5490
5493
|
return node[0] === "root";
|
|
@@ -5501,6 +5504,9 @@ function isMapStorageNode(node) {
|
|
|
5501
5504
|
function isRegisterStorageNode(node) {
|
|
5502
5505
|
return node[1].type === CrdtType.REGISTER;
|
|
5503
5506
|
}
|
|
5507
|
+
function isTextStorageNode(node) {
|
|
5508
|
+
return node[1].type === CrdtType.TEXT;
|
|
5509
|
+
}
|
|
5504
5510
|
function isCompactRootNode(node) {
|
|
5505
5511
|
return node[0] === "root";
|
|
5506
5512
|
}
|
|
@@ -5523,6 +5529,9 @@ function* compactNodesToNodeStream(compactNodes) {
|
|
|
5523
5529
|
case CrdtType.REGISTER:
|
|
5524
5530
|
yield [cnode[0], { type: CrdtType.REGISTER, parentId: cnode[2], parentKey: cnode[3], data: cnode[4] }];
|
|
5525
5531
|
break;
|
|
5532
|
+
case CrdtType.TEXT:
|
|
5533
|
+
yield [cnode[0], { type: CrdtType.TEXT, parentId: cnode[2], parentKey: cnode[3], data: cnode[4], version: cnode[5] }];
|
|
5534
|
+
break;
|
|
5526
5535
|
default:
|
|
5527
5536
|
}
|
|
5528
5537
|
}
|
|
@@ -5551,6 +5560,17 @@ function* nodeStreamToCompactNodes(nodes) {
|
|
|
5551
5560
|
const id = node[0];
|
|
5552
5561
|
const crdt = node[1];
|
|
5553
5562
|
yield [id, CrdtType.REGISTER, crdt.parentId, crdt.parentKey, crdt.data];
|
|
5563
|
+
} else if (isTextStorageNode(node)) {
|
|
5564
|
+
const id = node[0];
|
|
5565
|
+
const crdt = node[1];
|
|
5566
|
+
yield [
|
|
5567
|
+
id,
|
|
5568
|
+
CrdtType.TEXT,
|
|
5569
|
+
crdt.parentId,
|
|
5570
|
+
crdt.parentKey,
|
|
5571
|
+
crdt.data,
|
|
5572
|
+
crdt.version
|
|
5573
|
+
];
|
|
5554
5574
|
} else {
|
|
5555
5575
|
}
|
|
5556
5576
|
}
|
|
@@ -8207,6 +8227,581 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8207
8227
|
}
|
|
8208
8228
|
}, _class2.__initStatic(), _class2);
|
|
8209
8229
|
|
|
8230
|
+
// src/crdts/liveTextOps.ts
|
|
8231
|
+
function attributesEqual(left, right) {
|
|
8232
|
+
if (left === right) {
|
|
8233
|
+
return true;
|
|
8234
|
+
}
|
|
8235
|
+
if (left === void 0 || right === void 0) {
|
|
8236
|
+
return false;
|
|
8237
|
+
}
|
|
8238
|
+
const leftKeys = Object.keys(left);
|
|
8239
|
+
const rightKeys = Object.keys(right);
|
|
8240
|
+
if (leftKeys.length !== rightKeys.length) {
|
|
8241
|
+
return false;
|
|
8242
|
+
}
|
|
8243
|
+
for (const key of leftKeys) {
|
|
8244
|
+
if (left[key] !== right[key]) {
|
|
8245
|
+
return false;
|
|
8246
|
+
}
|
|
8247
|
+
}
|
|
8248
|
+
return true;
|
|
8249
|
+
}
|
|
8250
|
+
function cloneAttributes(attributes) {
|
|
8251
|
+
return attributes === void 0 ? void 0 : freeze({ ...attributes });
|
|
8252
|
+
}
|
|
8253
|
+
function normalizeSegments(segments) {
|
|
8254
|
+
const normalized = [];
|
|
8255
|
+
for (const segment of segments) {
|
|
8256
|
+
if (segment.text.length === 0) {
|
|
8257
|
+
continue;
|
|
8258
|
+
}
|
|
8259
|
+
const last = normalized.at(-1);
|
|
8260
|
+
const attributes = cloneAttributes(segment.attributes);
|
|
8261
|
+
if (last !== void 0 && attributesEqual(last.attributes, attributes)) {
|
|
8262
|
+
last.text += segment.text;
|
|
8263
|
+
} else {
|
|
8264
|
+
normalized.push({ text: segment.text, attributes });
|
|
8265
|
+
}
|
|
8266
|
+
}
|
|
8267
|
+
return normalized;
|
|
8268
|
+
}
|
|
8269
|
+
function deltaToSegments(delta) {
|
|
8270
|
+
return normalizeSegments(
|
|
8271
|
+
delta.map((item) => ({
|
|
8272
|
+
text: item.text,
|
|
8273
|
+
attributes: item.attributes
|
|
8274
|
+
}))
|
|
8275
|
+
);
|
|
8276
|
+
}
|
|
8277
|
+
function segmentsToDelta(segments) {
|
|
8278
|
+
return segments.map(
|
|
8279
|
+
(segment) => segment.attributes === void 0 ? { text: segment.text } : { text: segment.text, attributes: { ...segment.attributes } }
|
|
8280
|
+
);
|
|
8281
|
+
}
|
|
8282
|
+
function textLength(segments) {
|
|
8283
|
+
return segments.reduce((sum, segment) => sum + segment.text.length, 0);
|
|
8284
|
+
}
|
|
8285
|
+
function splitSegmentsAt(segments, index) {
|
|
8286
|
+
const result = [];
|
|
8287
|
+
let offset = 0;
|
|
8288
|
+
for (const segment of segments) {
|
|
8289
|
+
const end = offset + segment.text.length;
|
|
8290
|
+
if (index > offset && index < end) {
|
|
8291
|
+
const before2 = segment.text.slice(0, index - offset);
|
|
8292
|
+
const after2 = segment.text.slice(index - offset);
|
|
8293
|
+
result.push({ text: before2, attributes: segment.attributes });
|
|
8294
|
+
result.push({ text: after2, attributes: segment.attributes });
|
|
8295
|
+
} else {
|
|
8296
|
+
result.push({ text: segment.text, attributes: segment.attributes });
|
|
8297
|
+
}
|
|
8298
|
+
offset = end;
|
|
8299
|
+
}
|
|
8300
|
+
return result;
|
|
8301
|
+
}
|
|
8302
|
+
function clipRange(index, length, contentLength) {
|
|
8303
|
+
const clippedIndex = Math.max(0, Math.min(index, contentLength));
|
|
8304
|
+
const clippedEnd = Math.max(
|
|
8305
|
+
clippedIndex,
|
|
8306
|
+
Math.min(index + length, contentLength)
|
|
8307
|
+
);
|
|
8308
|
+
return { index: clippedIndex, length: clippedEnd - clippedIndex };
|
|
8309
|
+
}
|
|
8310
|
+
function applyInsert(segments, index, text, attributes) {
|
|
8311
|
+
if (text.length === 0) {
|
|
8312
|
+
return normalizeSegments(segments);
|
|
8313
|
+
}
|
|
8314
|
+
const split = splitSegmentsAt(segments, index);
|
|
8315
|
+
const result = [];
|
|
8316
|
+
let offset = 0;
|
|
8317
|
+
let inserted = false;
|
|
8318
|
+
for (const segment of split) {
|
|
8319
|
+
if (!inserted && offset === index) {
|
|
8320
|
+
result.push({ text, attributes });
|
|
8321
|
+
inserted = true;
|
|
8322
|
+
}
|
|
8323
|
+
result.push(segment);
|
|
8324
|
+
offset += segment.text.length;
|
|
8325
|
+
}
|
|
8326
|
+
if (!inserted) {
|
|
8327
|
+
result.push({ text, attributes });
|
|
8328
|
+
}
|
|
8329
|
+
return normalizeSegments(result);
|
|
8330
|
+
}
|
|
8331
|
+
function extractDeletedSegments(segments, index, length) {
|
|
8332
|
+
const split = splitSegmentsAt(
|
|
8333
|
+
splitSegmentsAt(segments, index),
|
|
8334
|
+
index + length
|
|
8335
|
+
);
|
|
8336
|
+
const deleted = [];
|
|
8337
|
+
let offset = 0;
|
|
8338
|
+
for (const segment of split) {
|
|
8339
|
+
const end = offset + segment.text.length;
|
|
8340
|
+
if (offset >= index && end <= index + length) {
|
|
8341
|
+
deleted.push({
|
|
8342
|
+
text: segment.text,
|
|
8343
|
+
attributes: segment.attributes
|
|
8344
|
+
});
|
|
8345
|
+
}
|
|
8346
|
+
offset = end;
|
|
8347
|
+
}
|
|
8348
|
+
return normalizeSegments(deleted);
|
|
8349
|
+
}
|
|
8350
|
+
function applyDelete(segments, index, length) {
|
|
8351
|
+
const deletedSegments = extractDeletedSegments(segments, index, length);
|
|
8352
|
+
const split = splitSegmentsAt(
|
|
8353
|
+
splitSegmentsAt(segments, index),
|
|
8354
|
+
index + length
|
|
8355
|
+
);
|
|
8356
|
+
const result = [];
|
|
8357
|
+
let offset = 0;
|
|
8358
|
+
let deletedText = "";
|
|
8359
|
+
for (const segment of split) {
|
|
8360
|
+
const end = offset + segment.text.length;
|
|
8361
|
+
if (offset >= index && end <= index + length) {
|
|
8362
|
+
deletedText += segment.text;
|
|
8363
|
+
} else {
|
|
8364
|
+
result.push(segment);
|
|
8365
|
+
}
|
|
8366
|
+
offset = end;
|
|
8367
|
+
}
|
|
8368
|
+
return {
|
|
8369
|
+
segments: normalizeSegments(result),
|
|
8370
|
+
deletedText,
|
|
8371
|
+
deletedSegments
|
|
8372
|
+
};
|
|
8373
|
+
}
|
|
8374
|
+
function applyFormat(segments, index, length, attributes) {
|
|
8375
|
+
const split = splitSegmentsAt(
|
|
8376
|
+
splitSegmentsAt(segments, index),
|
|
8377
|
+
index + length
|
|
8378
|
+
);
|
|
8379
|
+
const result = [];
|
|
8380
|
+
let offset = 0;
|
|
8381
|
+
for (const segment of split) {
|
|
8382
|
+
const end = offset + segment.text.length;
|
|
8383
|
+
if (offset >= index && end <= index + length) {
|
|
8384
|
+
const nextAttributes = {
|
|
8385
|
+
..._nullishCoalesce(segment.attributes, () => ( {}))
|
|
8386
|
+
};
|
|
8387
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
8388
|
+
if (value === null) {
|
|
8389
|
+
delete nextAttributes[key];
|
|
8390
|
+
} else {
|
|
8391
|
+
nextAttributes[key] = value;
|
|
8392
|
+
}
|
|
8393
|
+
}
|
|
8394
|
+
result.push({
|
|
8395
|
+
text: segment.text,
|
|
8396
|
+
attributes: Object.keys(nextAttributes).length === 0 ? void 0 : freeze(nextAttributes)
|
|
8397
|
+
});
|
|
8398
|
+
} else {
|
|
8399
|
+
result.push(segment);
|
|
8400
|
+
}
|
|
8401
|
+
offset = end;
|
|
8402
|
+
}
|
|
8403
|
+
return normalizeSegments(result);
|
|
8404
|
+
}
|
|
8405
|
+
function formatReverseOperations(segments, index, length, patch) {
|
|
8406
|
+
const split = splitSegmentsAt(
|
|
8407
|
+
splitSegmentsAt(segments, index),
|
|
8408
|
+
index + length
|
|
8409
|
+
);
|
|
8410
|
+
const result = [];
|
|
8411
|
+
let offset = 0;
|
|
8412
|
+
for (const segment of split) {
|
|
8413
|
+
const end = offset + segment.text.length;
|
|
8414
|
+
if (offset >= index && end <= index + length) {
|
|
8415
|
+
const attributes = {};
|
|
8416
|
+
for (const key of Object.keys(patch)) {
|
|
8417
|
+
attributes[key] = _nullishCoalesce(_optionalChain([segment, 'access', _202 => _202.attributes, 'optionalAccess', _203 => _203[key]]), () => ( null));
|
|
8418
|
+
}
|
|
8419
|
+
result.push({
|
|
8420
|
+
type: "format",
|
|
8421
|
+
index: offset,
|
|
8422
|
+
length: segment.text.length,
|
|
8423
|
+
attributes
|
|
8424
|
+
});
|
|
8425
|
+
}
|
|
8426
|
+
offset = end;
|
|
8427
|
+
}
|
|
8428
|
+
return result;
|
|
8429
|
+
}
|
|
8430
|
+
function mapIndexThroughOperation(index, op) {
|
|
8431
|
+
if (op.type === "insert") {
|
|
8432
|
+
return op.index <= index ? index + op.text.length : index;
|
|
8433
|
+
} else if (op.type === "delete") {
|
|
8434
|
+
if (op.index >= index) {
|
|
8435
|
+
return index;
|
|
8436
|
+
}
|
|
8437
|
+
return Math.max(op.index, index - op.length);
|
|
8438
|
+
} else {
|
|
8439
|
+
return index;
|
|
8440
|
+
}
|
|
8441
|
+
}
|
|
8442
|
+
function mapTextIndexThroughOperations(index, ops) {
|
|
8443
|
+
let mapped = index;
|
|
8444
|
+
for (const op of ops) {
|
|
8445
|
+
mapped = mapIndexThroughOperation(mapped, op);
|
|
8446
|
+
}
|
|
8447
|
+
return mapped;
|
|
8448
|
+
}
|
|
8449
|
+
function rebaseTextOperations(ops, acceptedOps) {
|
|
8450
|
+
return ops.map((op) => {
|
|
8451
|
+
if (op.type === "insert") {
|
|
8452
|
+
return {
|
|
8453
|
+
...op,
|
|
8454
|
+
index: mapTextIndexThroughOperations(op.index, acceptedOps)
|
|
8455
|
+
};
|
|
8456
|
+
} else if (op.type === "delete" || op.type === "format") {
|
|
8457
|
+
const start = mapTextIndexThroughOperations(op.index, acceptedOps);
|
|
8458
|
+
const end = mapTextIndexThroughOperations(
|
|
8459
|
+
op.index + op.length,
|
|
8460
|
+
acceptedOps
|
|
8461
|
+
);
|
|
8462
|
+
return { ...op, index: start, length: Math.max(0, end - start) };
|
|
8463
|
+
} else {
|
|
8464
|
+
return op;
|
|
8465
|
+
}
|
|
8466
|
+
});
|
|
8467
|
+
}
|
|
8468
|
+
function applyTextOperationsToSegments(segments, ops) {
|
|
8469
|
+
let next = [...segments];
|
|
8470
|
+
for (const op of ops) {
|
|
8471
|
+
if (op.type === "insert") {
|
|
8472
|
+
const index = Math.max(0, Math.min(op.index, textLength(next)));
|
|
8473
|
+
next = applyInsert(next, index, op.text, op.attributes);
|
|
8474
|
+
} else if (op.type === "delete") {
|
|
8475
|
+
const index = Math.max(0, Math.min(op.index, textLength(next)));
|
|
8476
|
+
const clipped = clipRange(index, op.length, textLength(next));
|
|
8477
|
+
next = applyDelete(next, clipped.index, clipped.length).segments;
|
|
8478
|
+
} else {
|
|
8479
|
+
const index = Math.max(0, Math.min(op.index, textLength(next)));
|
|
8480
|
+
const clipped = clipRange(index, op.length, textLength(next));
|
|
8481
|
+
next = applyFormat(next, clipped.index, clipped.length, op.attributes);
|
|
8482
|
+
}
|
|
8483
|
+
}
|
|
8484
|
+
return next;
|
|
8485
|
+
}
|
|
8486
|
+
function applyLiveTextOperations(delta, ops) {
|
|
8487
|
+
return segmentsToDelta(applyTextOperationsToSegments(deltaToSegments(delta), ops));
|
|
8488
|
+
}
|
|
8489
|
+
function invertTextOperations(segments, ops) {
|
|
8490
|
+
let shadow = [...segments];
|
|
8491
|
+
const reverse = [];
|
|
8492
|
+
for (const op of ops) {
|
|
8493
|
+
if (op.type === "insert") {
|
|
8494
|
+
shadow = applyInsert(shadow, op.index, op.text, op.attributes);
|
|
8495
|
+
reverse.unshift({
|
|
8496
|
+
type: "delete",
|
|
8497
|
+
index: op.index,
|
|
8498
|
+
length: op.text.length
|
|
8499
|
+
});
|
|
8500
|
+
} else if (op.type === "delete") {
|
|
8501
|
+
const deletedSegments = extractDeletedSegments(
|
|
8502
|
+
shadow,
|
|
8503
|
+
op.index,
|
|
8504
|
+
op.length
|
|
8505
|
+
);
|
|
8506
|
+
shadow = applyDelete(shadow, op.index, op.length).segments;
|
|
8507
|
+
const inserts = [];
|
|
8508
|
+
let insertIndex = op.index;
|
|
8509
|
+
for (const segment of deletedSegments) {
|
|
8510
|
+
inserts.push({
|
|
8511
|
+
type: "insert",
|
|
8512
|
+
index: insertIndex,
|
|
8513
|
+
text: segment.text,
|
|
8514
|
+
attributes: segment.attributes
|
|
8515
|
+
});
|
|
8516
|
+
insertIndex += segment.text.length;
|
|
8517
|
+
}
|
|
8518
|
+
for (let index = inserts.length - 1; index >= 0; index--) {
|
|
8519
|
+
reverse.unshift(inserts[index]);
|
|
8520
|
+
}
|
|
8521
|
+
} else {
|
|
8522
|
+
const inverse = formatReverseOperations(
|
|
8523
|
+
shadow,
|
|
8524
|
+
op.index,
|
|
8525
|
+
op.length,
|
|
8526
|
+
op.attributes
|
|
8527
|
+
);
|
|
8528
|
+
shadow = applyFormat(shadow, op.index, op.length, op.attributes);
|
|
8529
|
+
reverse.unshift(...inverse.reverse());
|
|
8530
|
+
}
|
|
8531
|
+
}
|
|
8532
|
+
return reverse;
|
|
8533
|
+
}
|
|
8534
|
+
|
|
8535
|
+
// src/crdts/LiveText.ts
|
|
8536
|
+
var LiveText = class _LiveText extends AbstractCrdt {
|
|
8537
|
+
#segments;
|
|
8538
|
+
#version;
|
|
8539
|
+
#pendingOps;
|
|
8540
|
+
constructor(textOrDelta = "", version = 0) {
|
|
8541
|
+
super();
|
|
8542
|
+
this.#segments = typeof textOrDelta === "string" ? textOrDelta.length === 0 ? [] : [{ text: textOrDelta }] : deltaToSegments(textOrDelta);
|
|
8543
|
+
this.#version = version;
|
|
8544
|
+
this.#pendingOps = /* @__PURE__ */ new Map();
|
|
8545
|
+
}
|
|
8546
|
+
get version() {
|
|
8547
|
+
return this.#version;
|
|
8548
|
+
}
|
|
8549
|
+
get length() {
|
|
8550
|
+
return this.toString().length;
|
|
8551
|
+
}
|
|
8552
|
+
/** @internal */
|
|
8553
|
+
static _deserialize([id, item], _parentToChildren, pool) {
|
|
8554
|
+
const text = new _LiveText(item.data, item.version);
|
|
8555
|
+
text._attach(id, pool);
|
|
8556
|
+
return text;
|
|
8557
|
+
}
|
|
8558
|
+
/** @internal */
|
|
8559
|
+
_toOps(parentId, parentKey) {
|
|
8560
|
+
if (this._id === void 0) {
|
|
8561
|
+
throw new Error("Cannot serialize LiveText if it is not attached");
|
|
8562
|
+
}
|
|
8563
|
+
return [
|
|
8564
|
+
{
|
|
8565
|
+
type: OpCode.CREATE_TEXT,
|
|
8566
|
+
id: this._id,
|
|
8567
|
+
parentId,
|
|
8568
|
+
parentKey,
|
|
8569
|
+
data: this.toDelta(),
|
|
8570
|
+
version: this.#version
|
|
8571
|
+
}
|
|
8572
|
+
];
|
|
8573
|
+
}
|
|
8574
|
+
/** @internal */
|
|
8575
|
+
_serialize() {
|
|
8576
|
+
if (this.parent.type !== "HasParent") {
|
|
8577
|
+
throw new Error("Cannot serialize LiveText if parent is missing");
|
|
8578
|
+
}
|
|
8579
|
+
return {
|
|
8580
|
+
type: CrdtType.TEXT,
|
|
8581
|
+
parentId: nn(this.parent.node._id, "Parent node expected to have ID"),
|
|
8582
|
+
parentKey: this.parent.key,
|
|
8583
|
+
data: this.toDelta(),
|
|
8584
|
+
version: this.#version
|
|
8585
|
+
};
|
|
8586
|
+
}
|
|
8587
|
+
/** @internal */
|
|
8588
|
+
_attachChild(_op) {
|
|
8589
|
+
throw new Error("LiveText cannot contain child nodes");
|
|
8590
|
+
}
|
|
8591
|
+
/** @internal */
|
|
8592
|
+
_detachChild(_crdt) {
|
|
8593
|
+
throw new Error("LiveText cannot contain child nodes");
|
|
8594
|
+
}
|
|
8595
|
+
/** @internal */
|
|
8596
|
+
_apply(op, isLocal) {
|
|
8597
|
+
if (op.type !== OpCode.UPDATE_TEXT) {
|
|
8598
|
+
return super._apply(op, isLocal);
|
|
8599
|
+
}
|
|
8600
|
+
if (isLocal) {
|
|
8601
|
+
this.#pendingOps.set(nn(op.opId), op.ops);
|
|
8602
|
+
return this.#applyOperations(op.ops, _nullishCoalesce(op.version, () => ( this.#version)));
|
|
8603
|
+
}
|
|
8604
|
+
if (op.opId !== void 0) {
|
|
8605
|
+
const pending2 = this.#pendingOps.get(op.opId);
|
|
8606
|
+
this.#pendingOps.delete(op.opId);
|
|
8607
|
+
const otherPending = Array.from(this.#pendingOps.values()).flat();
|
|
8608
|
+
if (pending2 !== void 0 && otherPending.length > 0) {
|
|
8609
|
+
this.#segments = applyTextOperationsToSegments(
|
|
8610
|
+
this.#segments,
|
|
8611
|
+
invertTextOperations(this.#segments, pending2)
|
|
8612
|
+
);
|
|
8613
|
+
const ops2 = rebaseTextOperations(op.ops, otherPending);
|
|
8614
|
+
return this.#applyOperations(
|
|
8615
|
+
ops2,
|
|
8616
|
+
_nullishCoalesce(op.version, () => ( Math.max(this.#version, op.baseVersion + 1)))
|
|
8617
|
+
);
|
|
8618
|
+
}
|
|
8619
|
+
this.#version = _nullishCoalesce(op.version, () => ( Math.max(this.#version, op.baseVersion + 1)));
|
|
8620
|
+
return { modified: false };
|
|
8621
|
+
}
|
|
8622
|
+
const pending = Array.from(this.#pendingOps.values()).flat();
|
|
8623
|
+
const ops = pending.length > 0 ? rebaseTextOperations(op.ops, pending) : op.ops;
|
|
8624
|
+
return this.#applyOperations(ops, _nullishCoalesce(op.version, () => ( this.#version + 1)));
|
|
8625
|
+
}
|
|
8626
|
+
insert(index, text, attributes) {
|
|
8627
|
+
const clippedIndex = Math.max(0, Math.min(index, this.length));
|
|
8628
|
+
this.#dispatch([{ type: "insert", index: clippedIndex, text, attributes }]);
|
|
8629
|
+
}
|
|
8630
|
+
delete(index, length) {
|
|
8631
|
+
const clipped = clipRange(index, length, this.length);
|
|
8632
|
+
if (clipped.length === 0) {
|
|
8633
|
+
return;
|
|
8634
|
+
}
|
|
8635
|
+
this.#dispatch([
|
|
8636
|
+
{ type: "delete", index: clipped.index, length: clipped.length }
|
|
8637
|
+
]);
|
|
8638
|
+
}
|
|
8639
|
+
replace(index, length, text, attributes) {
|
|
8640
|
+
const clipped = clipRange(index, length, this.length);
|
|
8641
|
+
const ops = [];
|
|
8642
|
+
if (clipped.length > 0) {
|
|
8643
|
+
ops.push({
|
|
8644
|
+
type: "delete",
|
|
8645
|
+
index: clipped.index,
|
|
8646
|
+
length: clipped.length
|
|
8647
|
+
});
|
|
8648
|
+
}
|
|
8649
|
+
if (text.length > 0) {
|
|
8650
|
+
ops.push({ type: "insert", index: clipped.index, text, attributes });
|
|
8651
|
+
}
|
|
8652
|
+
this.#dispatch(ops);
|
|
8653
|
+
}
|
|
8654
|
+
format(index, length, attributes) {
|
|
8655
|
+
const clipped = clipRange(index, length, this.length);
|
|
8656
|
+
if (clipped.length === 0) {
|
|
8657
|
+
return;
|
|
8658
|
+
}
|
|
8659
|
+
this.#dispatch([
|
|
8660
|
+
{
|
|
8661
|
+
type: "format",
|
|
8662
|
+
index: clipped.index,
|
|
8663
|
+
length: clipped.length,
|
|
8664
|
+
attributes
|
|
8665
|
+
}
|
|
8666
|
+
]);
|
|
8667
|
+
}
|
|
8668
|
+
#dispatch(ops) {
|
|
8669
|
+
if (ops.length === 0) {
|
|
8670
|
+
return;
|
|
8671
|
+
}
|
|
8672
|
+
_optionalChain([this, 'access', _204 => _204._pool, 'optionalAccess', _205 => _205.assertStorageIsWritable, 'call', _206 => _206()]);
|
|
8673
|
+
const baseVersion = this.#version;
|
|
8674
|
+
const reverse = this._pool !== void 0 && this._id !== void 0 ? this.#invertOperations(ops) : [];
|
|
8675
|
+
const changes = this.#applyOperationsLocally(ops);
|
|
8676
|
+
if (this._pool !== void 0 && this._id !== void 0) {
|
|
8677
|
+
const opId = this._pool.generateOpId();
|
|
8678
|
+
this.#pendingOps.set(opId, ops);
|
|
8679
|
+
this._pool.dispatch(
|
|
8680
|
+
[
|
|
8681
|
+
{
|
|
8682
|
+
type: OpCode.UPDATE_TEXT,
|
|
8683
|
+
id: this._id,
|
|
8684
|
+
opId,
|
|
8685
|
+
baseVersion,
|
|
8686
|
+
ops: [...ops]
|
|
8687
|
+
}
|
|
8688
|
+
],
|
|
8689
|
+
reverse,
|
|
8690
|
+
/* @__PURE__ */ new Map([
|
|
8691
|
+
[
|
|
8692
|
+
this._id,
|
|
8693
|
+
{
|
|
8694
|
+
type: "LiveText",
|
|
8695
|
+
node: this,
|
|
8696
|
+
version: this.#version,
|
|
8697
|
+
updates: changes
|
|
8698
|
+
}
|
|
8699
|
+
]
|
|
8700
|
+
])
|
|
8701
|
+
);
|
|
8702
|
+
}
|
|
8703
|
+
}
|
|
8704
|
+
#applyOperations(ops, version) {
|
|
8705
|
+
const reverse = this.#invertOperations(ops);
|
|
8706
|
+
const changes = this.#applyOperationsLocally(ops);
|
|
8707
|
+
this.#version = Math.max(this.#version, version);
|
|
8708
|
+
return {
|
|
8709
|
+
reverse,
|
|
8710
|
+
modified: {
|
|
8711
|
+
type: "LiveText",
|
|
8712
|
+
node: this,
|
|
8713
|
+
version: this.#version,
|
|
8714
|
+
updates: changes
|
|
8715
|
+
}
|
|
8716
|
+
};
|
|
8717
|
+
}
|
|
8718
|
+
#applyOperationsLocally(ops) {
|
|
8719
|
+
const changes = [];
|
|
8720
|
+
for (const op of ops) {
|
|
8721
|
+
if (op.type === "insert") {
|
|
8722
|
+
this.#segments = applyInsert(
|
|
8723
|
+
this.#segments,
|
|
8724
|
+
op.index,
|
|
8725
|
+
op.text,
|
|
8726
|
+
op.attributes
|
|
8727
|
+
);
|
|
8728
|
+
changes.push({
|
|
8729
|
+
type: "insert",
|
|
8730
|
+
index: op.index,
|
|
8731
|
+
text: op.text,
|
|
8732
|
+
attributes: op.attributes
|
|
8733
|
+
});
|
|
8734
|
+
} else if (op.type === "delete") {
|
|
8735
|
+
const result = applyDelete(this.#segments, op.index, op.length);
|
|
8736
|
+
this.#segments = result.segments;
|
|
8737
|
+
changes.push({
|
|
8738
|
+
type: "delete",
|
|
8739
|
+
index: op.index,
|
|
8740
|
+
length: op.length,
|
|
8741
|
+
deletedText: result.deletedText
|
|
8742
|
+
});
|
|
8743
|
+
} else {
|
|
8744
|
+
this.#segments = applyFormat(
|
|
8745
|
+
this.#segments,
|
|
8746
|
+
op.index,
|
|
8747
|
+
op.length,
|
|
8748
|
+
op.attributes
|
|
8749
|
+
);
|
|
8750
|
+
changes.push({
|
|
8751
|
+
type: "format",
|
|
8752
|
+
index: op.index,
|
|
8753
|
+
length: op.length,
|
|
8754
|
+
attributes: op.attributes
|
|
8755
|
+
});
|
|
8756
|
+
}
|
|
8757
|
+
}
|
|
8758
|
+
this.invalidate();
|
|
8759
|
+
return changes;
|
|
8760
|
+
}
|
|
8761
|
+
#invertOperations(ops) {
|
|
8762
|
+
return [
|
|
8763
|
+
{
|
|
8764
|
+
type: OpCode.UPDATE_TEXT,
|
|
8765
|
+
id: nn(this._id),
|
|
8766
|
+
baseVersion: this.#version,
|
|
8767
|
+
ops: invertTextOperations(this.#segments, ops)
|
|
8768
|
+
}
|
|
8769
|
+
];
|
|
8770
|
+
}
|
|
8771
|
+
toString() {
|
|
8772
|
+
return this.#segments.map((segment) => segment.text).join("");
|
|
8773
|
+
}
|
|
8774
|
+
toDelta() {
|
|
8775
|
+
return segmentsToDelta(this.#segments);
|
|
8776
|
+
}
|
|
8777
|
+
toJSON() {
|
|
8778
|
+
return super.toJSON();
|
|
8779
|
+
}
|
|
8780
|
+
/** @internal */
|
|
8781
|
+
_toJSON() {
|
|
8782
|
+
return this.toDelta();
|
|
8783
|
+
}
|
|
8784
|
+
/** @internal */
|
|
8785
|
+
_toTreeNode(key) {
|
|
8786
|
+
return {
|
|
8787
|
+
type: "LiveText",
|
|
8788
|
+
id: _nullishCoalesce(this._id, () => ( nanoid())),
|
|
8789
|
+
key,
|
|
8790
|
+
payload: [
|
|
8791
|
+
{
|
|
8792
|
+
type: "Json",
|
|
8793
|
+
id: `${_nullishCoalesce(this._id, () => ( nanoid()))}:text`,
|
|
8794
|
+
key: "text",
|
|
8795
|
+
payload: this.toString()
|
|
8796
|
+
}
|
|
8797
|
+
]
|
|
8798
|
+
};
|
|
8799
|
+
}
|
|
8800
|
+
clone() {
|
|
8801
|
+
return new _LiveText(this.toDelta(), this.#version);
|
|
8802
|
+
}
|
|
8803
|
+
};
|
|
8804
|
+
|
|
8210
8805
|
// src/crdts/liveblocks-helpers.ts
|
|
8211
8806
|
function creationOpToLiveNode(op) {
|
|
8212
8807
|
return lsonToLiveNode(creationOpToLson(op));
|
|
@@ -8221,6 +8816,8 @@ function creationOpToLson(op) {
|
|
|
8221
8816
|
return new LiveMap();
|
|
8222
8817
|
case OpCode.CREATE_LIST:
|
|
8223
8818
|
return new LiveList([]);
|
|
8819
|
+
case OpCode.CREATE_TEXT:
|
|
8820
|
+
return new LiveText(op.data, op.version);
|
|
8224
8821
|
default:
|
|
8225
8822
|
return assertNever(op, "Unknown creation Op");
|
|
8226
8823
|
}
|
|
@@ -8243,6 +8840,8 @@ function deserialize(node, parentToChildren, pool) {
|
|
|
8243
8840
|
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
8244
8841
|
} else if (isRegisterStorageNode(node)) {
|
|
8245
8842
|
return LiveRegister._deserialize(node, parentToChildren, pool);
|
|
8843
|
+
} else if (isTextStorageNode(node)) {
|
|
8844
|
+
return LiveText._deserialize(node, parentToChildren, pool);
|
|
8246
8845
|
} else {
|
|
8247
8846
|
throw new Error("Unexpected CRDT type");
|
|
8248
8847
|
}
|
|
@@ -8256,12 +8855,14 @@ function deserializeToLson(node, parentToChildren, pool) {
|
|
|
8256
8855
|
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
8257
8856
|
} else if (isRegisterStorageNode(node)) {
|
|
8258
8857
|
return node[1].data;
|
|
8858
|
+
} else if (isTextStorageNode(node)) {
|
|
8859
|
+
return LiveText._deserialize(node, parentToChildren, pool);
|
|
8259
8860
|
} else {
|
|
8260
8861
|
throw new Error("Unexpected CRDT type");
|
|
8261
8862
|
}
|
|
8262
8863
|
}
|
|
8263
8864
|
function isLiveStructure(value) {
|
|
8264
|
-
return isLiveList(value) || isLiveMap(value) || isLiveObject(value);
|
|
8865
|
+
return isLiveList(value) || isLiveMap(value) || isLiveObject(value) || isLiveText(value);
|
|
8265
8866
|
}
|
|
8266
8867
|
function isLiveNode(value) {
|
|
8267
8868
|
return isLiveStructure(value) || isLiveRegister(value);
|
|
@@ -8275,6 +8876,9 @@ function isLiveMap(value) {
|
|
|
8275
8876
|
function isLiveObject(value) {
|
|
8276
8877
|
return value instanceof LiveObject;
|
|
8277
8878
|
}
|
|
8879
|
+
function isLiveText(value) {
|
|
8880
|
+
return value instanceof LiveText;
|
|
8881
|
+
}
|
|
8278
8882
|
function isLiveRegister(value) {
|
|
8279
8883
|
return value instanceof LiveRegister;
|
|
8280
8884
|
}
|
|
@@ -8284,14 +8888,14 @@ function cloneLson(value) {
|
|
|
8284
8888
|
function liveNodeToLson(obj) {
|
|
8285
8889
|
if (obj instanceof LiveRegister) {
|
|
8286
8890
|
return obj.data;
|
|
8287
|
-
} else if (obj instanceof LiveList || obj instanceof LiveMap || obj instanceof LiveObject) {
|
|
8891
|
+
} else if (obj instanceof LiveList || obj instanceof LiveMap || obj instanceof LiveObject || obj instanceof LiveText) {
|
|
8288
8892
|
return obj;
|
|
8289
8893
|
} else {
|
|
8290
8894
|
return assertNever(obj, "Unknown AbstractCrdt");
|
|
8291
8895
|
}
|
|
8292
8896
|
}
|
|
8293
8897
|
function lsonToLiveNode(value) {
|
|
8294
|
-
if (value instanceof LiveObject || value instanceof LiveMap || value instanceof LiveList) {
|
|
8898
|
+
if (value instanceof LiveObject || value instanceof LiveMap || value instanceof LiveList || value instanceof LiveText) {
|
|
8295
8899
|
return value;
|
|
8296
8900
|
} else {
|
|
8297
8901
|
return new LiveRegister(value);
|
|
@@ -8316,6 +8920,38 @@ function getTreesDiffOperations(currentItems, newItems) {
|
|
|
8316
8920
|
});
|
|
8317
8921
|
}
|
|
8318
8922
|
}
|
|
8923
|
+
if (crdt.type === CrdtType.TEXT) {
|
|
8924
|
+
if (currentCrdt.type !== CrdtType.TEXT || stringifyOrLog(crdt.data) !== stringifyOrLog(currentCrdt.data) || crdt.version !== currentCrdt.version) {
|
|
8925
|
+
ops.push({
|
|
8926
|
+
type: OpCode.UPDATE_TEXT,
|
|
8927
|
+
id,
|
|
8928
|
+
baseVersion: currentCrdt.type === CrdtType.TEXT ? currentCrdt.version : 0,
|
|
8929
|
+
version: crdt.version,
|
|
8930
|
+
ops: [
|
|
8931
|
+
{
|
|
8932
|
+
type: "delete",
|
|
8933
|
+
index: 0,
|
|
8934
|
+
length: currentCrdt.type === CrdtType.TEXT ? currentCrdt.data.reduce(
|
|
8935
|
+
(sum, item) => sum + item.text.length,
|
|
8936
|
+
0
|
|
8937
|
+
) : 0
|
|
8938
|
+
},
|
|
8939
|
+
...crdt.data.map(
|
|
8940
|
+
(item, index, items) => item.attributes === void 0 ? {
|
|
8941
|
+
type: "insert",
|
|
8942
|
+
index: items.slice(0, index).reduce((sum, item2) => sum + item2.text.length, 0),
|
|
8943
|
+
text: item.text
|
|
8944
|
+
} : {
|
|
8945
|
+
type: "insert",
|
|
8946
|
+
index: items.slice(0, index).reduce((sum, item2) => sum + item2.text.length, 0),
|
|
8947
|
+
text: item.text,
|
|
8948
|
+
attributes: item.attributes
|
|
8949
|
+
}
|
|
8950
|
+
)
|
|
8951
|
+
]
|
|
8952
|
+
});
|
|
8953
|
+
}
|
|
8954
|
+
}
|
|
8319
8955
|
if (crdt.parentKey !== currentCrdt.parentKey) {
|
|
8320
8956
|
ops.push({
|
|
8321
8957
|
type: OpCode.SET_PARENT_KEY,
|
|
@@ -8364,6 +9000,16 @@ function getTreesDiffOperations(currentItems, newItems) {
|
|
|
8364
9000
|
parentKey: crdt.parentKey
|
|
8365
9001
|
});
|
|
8366
9002
|
break;
|
|
9003
|
+
case CrdtType.TEXT:
|
|
9004
|
+
ops.push({
|
|
9005
|
+
type: OpCode.CREATE_TEXT,
|
|
9006
|
+
id,
|
|
9007
|
+
parentId: crdt.parentId,
|
|
9008
|
+
parentKey: crdt.parentKey,
|
|
9009
|
+
data: crdt.data,
|
|
9010
|
+
version: crdt.version
|
|
9011
|
+
});
|
|
9012
|
+
break;
|
|
8367
9013
|
}
|
|
8368
9014
|
}
|
|
8369
9015
|
});
|
|
@@ -8396,6 +9042,12 @@ function mergeListStorageUpdates(first, second) {
|
|
|
8396
9042
|
updates: updates.concat(second.updates)
|
|
8397
9043
|
};
|
|
8398
9044
|
}
|
|
9045
|
+
function mergeTextStorageUpdates(first, second) {
|
|
9046
|
+
return {
|
|
9047
|
+
...second,
|
|
9048
|
+
updates: first.updates.concat(second.updates)
|
|
9049
|
+
};
|
|
9050
|
+
}
|
|
8399
9051
|
function mergeStorageUpdates(first, second) {
|
|
8400
9052
|
if (first === void 0) {
|
|
8401
9053
|
return second;
|
|
@@ -8406,6 +9058,8 @@ function mergeStorageUpdates(first, second) {
|
|
|
8406
9058
|
return mergeMapStorageUpdates(first, second);
|
|
8407
9059
|
} else if (first.type === "LiveList" && second.type === "LiveList") {
|
|
8408
9060
|
return mergeListStorageUpdates(first, second);
|
|
9061
|
+
} else if (first.type === "LiveText" && second.type === "LiveText") {
|
|
9062
|
+
return mergeTextStorageUpdates(first, second);
|
|
8409
9063
|
} else {
|
|
8410
9064
|
}
|
|
8411
9065
|
return second;
|
|
@@ -8424,7 +9078,7 @@ function sendToPanel(message, options) {
|
|
|
8424
9078
|
...message,
|
|
8425
9079
|
source: "liveblocks-devtools-client"
|
|
8426
9080
|
};
|
|
8427
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
9081
|
+
if (!(_optionalChain([options, 'optionalAccess', _207 => _207.force]) || _bridgeActive)) {
|
|
8428
9082
|
return;
|
|
8429
9083
|
}
|
|
8430
9084
|
window.postMessage(fullMsg, "*");
|
|
@@ -8432,7 +9086,7 @@ function sendToPanel(message, options) {
|
|
|
8432
9086
|
var eventSource = makeEventSource();
|
|
8433
9087
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
8434
9088
|
window.addEventListener("message", (event) => {
|
|
8435
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
9089
|
+
if (event.source === window && _optionalChain([event, 'access', _208 => _208.data, 'optionalAccess', _209 => _209.source]) === "liveblocks-devtools-panel") {
|
|
8436
9090
|
eventSource.notify(event.data);
|
|
8437
9091
|
} else {
|
|
8438
9092
|
}
|
|
@@ -8574,7 +9228,7 @@ function fullSync(room) {
|
|
|
8574
9228
|
msg: "room::sync::full",
|
|
8575
9229
|
roomId: room.id,
|
|
8576
9230
|
status: room.getStatus(),
|
|
8577
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
9231
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _210 => _210.toTreeNode, 'call', _211 => _211("root"), 'access', _212 => _212.payload]), () => ( null)),
|
|
8578
9232
|
me,
|
|
8579
9233
|
others
|
|
8580
9234
|
});
|
|
@@ -9253,15 +9907,15 @@ function installBackgroundTabSpy() {
|
|
|
9253
9907
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
9254
9908
|
const inBackgroundSince = { current: null };
|
|
9255
9909
|
function onVisibilityChange() {
|
|
9256
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
9910
|
+
if (_optionalChain([doc, 'optionalAccess', _213 => _213.visibilityState]) === "hidden") {
|
|
9257
9911
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
9258
9912
|
} else {
|
|
9259
9913
|
inBackgroundSince.current = null;
|
|
9260
9914
|
}
|
|
9261
9915
|
}
|
|
9262
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9916
|
+
_optionalChain([doc, 'optionalAccess', _214 => _214.addEventListener, 'call', _215 => _215("visibilitychange", onVisibilityChange)]);
|
|
9263
9917
|
const unsub = () => {
|
|
9264
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9918
|
+
_optionalChain([doc, 'optionalAccess', _216 => _216.removeEventListener, 'call', _217 => _217("visibilitychange", onVisibilityChange)]);
|
|
9265
9919
|
};
|
|
9266
9920
|
return [inBackgroundSince, unsub];
|
|
9267
9921
|
}
|
|
@@ -9452,7 +10106,7 @@ function createRoom(options, config) {
|
|
|
9452
10106
|
}
|
|
9453
10107
|
}
|
|
9454
10108
|
function isStorageWritable() {
|
|
9455
|
-
const scopes = _optionalChain([context, 'access',
|
|
10109
|
+
const scopes = _optionalChain([context, 'access', _218 => _218.dynamicSessionInfoSig, 'access', _219 => _219.get, 'call', _220 => _220(), 'optionalAccess', _221 => _221.scopes]);
|
|
9456
10110
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
9457
10111
|
}
|
|
9458
10112
|
const eventHub = {
|
|
@@ -9556,7 +10210,7 @@ function createRoom(options, config) {
|
|
|
9556
10210
|
context.pool
|
|
9557
10211
|
);
|
|
9558
10212
|
}
|
|
9559
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
10213
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _222 => _222.get, 'call', _223 => _223(), 'optionalAccess', _224 => _224.canWrite]), () => ( true));
|
|
9560
10214
|
const root = context.root;
|
|
9561
10215
|
disableHistory(() => {
|
|
9562
10216
|
for (const key in context.initialStorage) {
|
|
@@ -9687,7 +10341,7 @@ function createRoom(options, config) {
|
|
|
9687
10341
|
);
|
|
9688
10342
|
output.reverse.pushLeft(applyOpResult.reverse);
|
|
9689
10343
|
}
|
|
9690
|
-
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT) {
|
|
10344
|
+
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT || op.type === OpCode.CREATE_TEXT) {
|
|
9691
10345
|
createdNodeIds.add(op.id);
|
|
9692
10346
|
}
|
|
9693
10347
|
}
|
|
@@ -9707,6 +10361,7 @@ function createRoom(options, config) {
|
|
|
9707
10361
|
switch (op.type) {
|
|
9708
10362
|
case OpCode.DELETE_OBJECT_KEY:
|
|
9709
10363
|
case OpCode.UPDATE_OBJECT:
|
|
10364
|
+
case OpCode.UPDATE_TEXT:
|
|
9710
10365
|
case OpCode.DELETE_CRDT: {
|
|
9711
10366
|
const node = context.pool.nodes.get(op.id);
|
|
9712
10367
|
if (node === void 0) {
|
|
@@ -9731,6 +10386,7 @@ function createRoom(options, config) {
|
|
|
9731
10386
|
case OpCode.CREATE_OBJECT:
|
|
9732
10387
|
case OpCode.CREATE_LIST:
|
|
9733
10388
|
case OpCode.CREATE_MAP:
|
|
10389
|
+
case OpCode.CREATE_TEXT:
|
|
9734
10390
|
case OpCode.CREATE_REGISTER: {
|
|
9735
10391
|
if (op.parentId === void 0) {
|
|
9736
10392
|
return { modified: false };
|
|
@@ -9761,7 +10417,7 @@ function createRoom(options, config) {
|
|
|
9761
10417
|
}
|
|
9762
10418
|
context.myPresence.patch(patch);
|
|
9763
10419
|
if (context.activeBatch) {
|
|
9764
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
10420
|
+
if (_optionalChain([options2, 'optionalAccess', _225 => _225.addToHistory])) {
|
|
9765
10421
|
context.activeBatch.reverseOps.pushLeft({
|
|
9766
10422
|
type: "presence",
|
|
9767
10423
|
data: oldValues
|
|
@@ -9770,7 +10426,7 @@ function createRoom(options, config) {
|
|
|
9770
10426
|
context.activeBatch.updates.presence = true;
|
|
9771
10427
|
} else {
|
|
9772
10428
|
flushNowOrSoon();
|
|
9773
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
10429
|
+
if (_optionalChain([options2, 'optionalAccess', _226 => _226.addToHistory])) {
|
|
9774
10430
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
9775
10431
|
}
|
|
9776
10432
|
notify({ presence: true });
|
|
@@ -9948,11 +10604,11 @@ function createRoom(options, config) {
|
|
|
9948
10604
|
break;
|
|
9949
10605
|
}
|
|
9950
10606
|
case ServerMsgCode.STORAGE_CHUNK:
|
|
9951
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
10607
|
+
_optionalChain([stopwatch, 'optionalAccess', _227 => _227.lap, 'call', _228 => _228()]);
|
|
9952
10608
|
nodeMapBuffer.append(compactNodesToNodeStream(message.nodes));
|
|
9953
10609
|
break;
|
|
9954
10610
|
case ServerMsgCode.STORAGE_STREAM_END: {
|
|
9955
|
-
const timing = _optionalChain([stopwatch, 'optionalAccess',
|
|
10611
|
+
const timing = _optionalChain([stopwatch, 'optionalAccess', _229 => _229.stop, 'call', _230 => _230()]);
|
|
9956
10612
|
if (timing) {
|
|
9957
10613
|
const ms = (v) => `${v.toFixed(1)}ms`;
|
|
9958
10614
|
const rest = timing.laps.slice(1);
|
|
@@ -10087,11 +10743,11 @@ function createRoom(options, config) {
|
|
|
10087
10743
|
} else if (pendingFeedsRequests.has(requestId)) {
|
|
10088
10744
|
const pending = pendingFeedsRequests.get(requestId);
|
|
10089
10745
|
pendingFeedsRequests.delete(requestId);
|
|
10090
|
-
_optionalChain([pending, 'optionalAccess',
|
|
10746
|
+
_optionalChain([pending, 'optionalAccess', _231 => _231.reject, 'call', _232 => _232(err)]);
|
|
10091
10747
|
} else if (pendingFeedMessagesRequests.has(requestId)) {
|
|
10092
10748
|
const pending = pendingFeedMessagesRequests.get(requestId);
|
|
10093
10749
|
pendingFeedMessagesRequests.delete(requestId);
|
|
10094
|
-
_optionalChain([pending, 'optionalAccess',
|
|
10750
|
+
_optionalChain([pending, 'optionalAccess', _233 => _233.reject, 'call', _234 => _234(err)]);
|
|
10095
10751
|
}
|
|
10096
10752
|
eventHub.feeds.notify(message);
|
|
10097
10753
|
break;
|
|
@@ -10245,10 +10901,10 @@ function createRoom(options, config) {
|
|
|
10245
10901
|
timeoutId,
|
|
10246
10902
|
kind,
|
|
10247
10903
|
feedId,
|
|
10248
|
-
messageId: _optionalChain([options2, 'optionalAccess',
|
|
10249
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
10904
|
+
messageId: _optionalChain([options2, 'optionalAccess', _235 => _235.messageId]),
|
|
10905
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _236 => _236.expectedClientMessageId])
|
|
10250
10906
|
});
|
|
10251
|
-
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess',
|
|
10907
|
+
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess', _237 => _237.expectedClientMessageId]) === void 0) {
|
|
10252
10908
|
const q = _nullishCoalesce(pendingAddMessageFifoByFeed.get(feedId), () => ( []));
|
|
10253
10909
|
q.push(requestId);
|
|
10254
10910
|
pendingAddMessageFifoByFeed.set(feedId, q);
|
|
@@ -10299,10 +10955,10 @@ function createRoom(options, config) {
|
|
|
10299
10955
|
}
|
|
10300
10956
|
if (!matched) {
|
|
10301
10957
|
const q = pendingAddMessageFifoByFeed.get(message.feedId);
|
|
10302
|
-
const headId = _optionalChain([q, 'optionalAccess',
|
|
10958
|
+
const headId = _optionalChain([q, 'optionalAccess', _238 => _238[0]]);
|
|
10303
10959
|
if (headId !== void 0) {
|
|
10304
10960
|
const pending = pendingFeedMutations.get(headId);
|
|
10305
|
-
if (_optionalChain([pending, 'optionalAccess',
|
|
10961
|
+
if (_optionalChain([pending, 'optionalAccess', _239 => _239.kind]) === "add-message" && pending.expectedClientMessageId === void 0) {
|
|
10306
10962
|
settleFeedMutation(headId, "ok");
|
|
10307
10963
|
}
|
|
10308
10964
|
}
|
|
@@ -10338,7 +10994,7 @@ function createRoom(options, config) {
|
|
|
10338
10994
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
10339
10995
|
createOrUpdateRootFromMessage(nodes);
|
|
10340
10996
|
applyAndSendOfflineOps(unacknowledgedOps);
|
|
10341
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
10997
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _240 => _240()]);
|
|
10342
10998
|
notifyStorageStatus();
|
|
10343
10999
|
eventHub.storageDidLoad.notify();
|
|
10344
11000
|
}
|
|
@@ -10356,7 +11012,7 @@ function createRoom(options, config) {
|
|
|
10356
11012
|
} else if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
10357
11013
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
10358
11014
|
nodeMapBuffer.take();
|
|
10359
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
11015
|
+
_optionalChain([stopwatch, 'optionalAccess', _241 => _241.start, 'call', _242 => _242()]);
|
|
10360
11016
|
}
|
|
10361
11017
|
if (options2.flush) {
|
|
10362
11018
|
flushNowOrSoon();
|
|
@@ -10412,10 +11068,10 @@ function createRoom(options, config) {
|
|
|
10412
11068
|
const message = {
|
|
10413
11069
|
type: ClientMsgCode.FETCH_FEEDS,
|
|
10414
11070
|
requestId,
|
|
10415
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
10416
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
10417
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
10418
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
11071
|
+
cursor: _optionalChain([options2, 'optionalAccess', _243 => _243.cursor]),
|
|
11072
|
+
since: _optionalChain([options2, 'optionalAccess', _244 => _244.since]),
|
|
11073
|
+
limit: _optionalChain([options2, 'optionalAccess', _245 => _245.limit]),
|
|
11074
|
+
metadata: _optionalChain([options2, 'optionalAccess', _246 => _246.metadata])
|
|
10419
11075
|
};
|
|
10420
11076
|
context.buffer.messages.push(message);
|
|
10421
11077
|
flushNowOrSoon();
|
|
@@ -10435,9 +11091,9 @@ function createRoom(options, config) {
|
|
|
10435
11091
|
type: ClientMsgCode.FETCH_FEED_MESSAGES,
|
|
10436
11092
|
requestId,
|
|
10437
11093
|
feedId,
|
|
10438
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
10439
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
10440
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
11094
|
+
cursor: _optionalChain([options2, 'optionalAccess', _247 => _247.cursor]),
|
|
11095
|
+
since: _optionalChain([options2, 'optionalAccess', _248 => _248.since]),
|
|
11096
|
+
limit: _optionalChain([options2, 'optionalAccess', _249 => _249.limit])
|
|
10441
11097
|
};
|
|
10442
11098
|
context.buffer.messages.push(message);
|
|
10443
11099
|
flushNowOrSoon();
|
|
@@ -10456,8 +11112,8 @@ function createRoom(options, config) {
|
|
|
10456
11112
|
type: ClientMsgCode.ADD_FEED,
|
|
10457
11113
|
requestId,
|
|
10458
11114
|
feedId,
|
|
10459
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
10460
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
11115
|
+
metadata: _optionalChain([options2, 'optionalAccess', _250 => _250.metadata]),
|
|
11116
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _251 => _251.createdAt])
|
|
10461
11117
|
};
|
|
10462
11118
|
context.buffer.messages.push(message);
|
|
10463
11119
|
flushNowOrSoon();
|
|
@@ -10491,15 +11147,15 @@ function createRoom(options, config) {
|
|
|
10491
11147
|
function addFeedMessage(feedId, data, options2) {
|
|
10492
11148
|
const requestId = nanoid();
|
|
10493
11149
|
const promise = registerFeedMutation(requestId, "add-message", feedId, {
|
|
10494
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
11150
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _252 => _252.id])
|
|
10495
11151
|
});
|
|
10496
11152
|
const message = {
|
|
10497
11153
|
type: ClientMsgCode.ADD_FEED_MESSAGE,
|
|
10498
11154
|
requestId,
|
|
10499
11155
|
feedId,
|
|
10500
11156
|
data,
|
|
10501
|
-
id: _optionalChain([options2, 'optionalAccess',
|
|
10502
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
11157
|
+
id: _optionalChain([options2, 'optionalAccess', _253 => _253.id]),
|
|
11158
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _254 => _254.createdAt])
|
|
10503
11159
|
};
|
|
10504
11160
|
context.buffer.messages.push(message);
|
|
10505
11161
|
flushNowOrSoon();
|
|
@@ -10516,7 +11172,7 @@ function createRoom(options, config) {
|
|
|
10516
11172
|
feedId,
|
|
10517
11173
|
messageId,
|
|
10518
11174
|
data,
|
|
10519
|
-
updatedAt: _optionalChain([options2, 'optionalAccess',
|
|
11175
|
+
updatedAt: _optionalChain([options2, 'optionalAccess', _255 => _255.updatedAt])
|
|
10520
11176
|
};
|
|
10521
11177
|
context.buffer.messages.push(message);
|
|
10522
11178
|
flushNowOrSoon();
|
|
@@ -10723,8 +11379,8 @@ function createRoom(options, config) {
|
|
|
10723
11379
|
async function getThreads(options2) {
|
|
10724
11380
|
return httpClient.getThreads({
|
|
10725
11381
|
roomId,
|
|
10726
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
10727
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11382
|
+
query: _optionalChain([options2, 'optionalAccess', _256 => _256.query]),
|
|
11383
|
+
cursor: _optionalChain([options2, 'optionalAccess', _257 => _257.cursor])
|
|
10728
11384
|
});
|
|
10729
11385
|
}
|
|
10730
11386
|
async function getThread(threadId) {
|
|
@@ -10846,7 +11502,7 @@ function createRoom(options, config) {
|
|
|
10846
11502
|
function getSubscriptionSettings(options2) {
|
|
10847
11503
|
return httpClient.getSubscriptionSettings({
|
|
10848
11504
|
roomId,
|
|
10849
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
11505
|
+
signal: _optionalChain([options2, 'optionalAccess', _258 => _258.signal])
|
|
10850
11506
|
});
|
|
10851
11507
|
}
|
|
10852
11508
|
function updateSubscriptionSettings(settings) {
|
|
@@ -10868,7 +11524,7 @@ function createRoom(options, config) {
|
|
|
10868
11524
|
{
|
|
10869
11525
|
[kInternal]: {
|
|
10870
11526
|
get presenceBuffer() {
|
|
10871
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
11527
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _259 => _259.buffer, 'access', _260 => _260.presenceUpdates, 'optionalAccess', _261 => _261.data]), () => ( null)));
|
|
10872
11528
|
},
|
|
10873
11529
|
// prettier-ignore
|
|
10874
11530
|
get undoStack() {
|
|
@@ -10883,9 +11539,9 @@ function createRoom(options, config) {
|
|
|
10883
11539
|
return context.yjsProvider;
|
|
10884
11540
|
},
|
|
10885
11541
|
setYjsProvider(newProvider) {
|
|
10886
|
-
_optionalChain([context, 'access',
|
|
11542
|
+
_optionalChain([context, 'access', _262 => _262.yjsProvider, 'optionalAccess', _263 => _263.off, 'call', _264 => _264("status", yjsStatusDidChange)]);
|
|
10887
11543
|
context.yjsProvider = newProvider;
|
|
10888
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
11544
|
+
_optionalChain([newProvider, 'optionalAccess', _265 => _265.on, 'call', _266 => _266("status", yjsStatusDidChange)]);
|
|
10889
11545
|
context.yjsProviderDidChange.notify();
|
|
10890
11546
|
},
|
|
10891
11547
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -10938,7 +11594,7 @@ function createRoom(options, config) {
|
|
|
10938
11594
|
source.dispose();
|
|
10939
11595
|
}
|
|
10940
11596
|
eventHub.roomWillDestroy.notify();
|
|
10941
|
-
_optionalChain([context, 'access',
|
|
11597
|
+
_optionalChain([context, 'access', _267 => _267.yjsProvider, 'optionalAccess', _268 => _268.off, 'call', _269 => _269("status", yjsStatusDidChange)]);
|
|
10942
11598
|
syncSourceForStorage.destroy();
|
|
10943
11599
|
syncSourceForYjs.destroy();
|
|
10944
11600
|
uninstallBgTabSpy();
|
|
@@ -11098,7 +11754,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
11098
11754
|
}
|
|
11099
11755
|
if (isLiveNode(first)) {
|
|
11100
11756
|
const node = first;
|
|
11101
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11757
|
+
if (_optionalChain([options, 'optionalAccess', _270 => _270.isDeep])) {
|
|
11102
11758
|
const storageCallback = second;
|
|
11103
11759
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
11104
11760
|
} else {
|
|
@@ -11184,8 +11840,8 @@ function createClient(options) {
|
|
|
11184
11840
|
const authManager = createAuthManager(options, (token) => {
|
|
11185
11841
|
currentUserId.set(() => token.uid);
|
|
11186
11842
|
});
|
|
11187
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
11188
|
-
_optionalChain([globalThis, 'access',
|
|
11843
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _271 => _271.polyfills, 'optionalAccess', _272 => _272.fetch]) || /* istanbul ignore next */
|
|
11844
|
+
_optionalChain([globalThis, 'access', _273 => _273.fetch, 'optionalAccess', _274 => _274.bind, 'call', _275 => _275(globalThis)]);
|
|
11189
11845
|
const httpClient = createApiClient({
|
|
11190
11846
|
baseUrl,
|
|
11191
11847
|
fetchPolyfill,
|
|
@@ -11203,7 +11859,7 @@ function createClient(options) {
|
|
|
11203
11859
|
delegates: {
|
|
11204
11860
|
createSocket: makeCreateSocketDelegateForAi(
|
|
11205
11861
|
baseUrl,
|
|
11206
|
-
_optionalChain([clientOptions, 'access',
|
|
11862
|
+
_optionalChain([clientOptions, 'access', _276 => _276.polyfills, 'optionalAccess', _277 => _277.WebSocket])
|
|
11207
11863
|
),
|
|
11208
11864
|
authenticate: async () => {
|
|
11209
11865
|
const resp = await authManager.getAuthValue({
|
|
@@ -11273,7 +11929,7 @@ function createClient(options) {
|
|
|
11273
11929
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
11274
11930
|
roomId,
|
|
11275
11931
|
baseUrl,
|
|
11276
|
-
_optionalChain([clientOptions, 'access',
|
|
11932
|
+
_optionalChain([clientOptions, 'access', _278 => _278.polyfills, 'optionalAccess', _279 => _279.WebSocket])
|
|
11277
11933
|
),
|
|
11278
11934
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
11279
11935
|
})),
|
|
@@ -11296,7 +11952,7 @@ function createClient(options) {
|
|
|
11296
11952
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
11297
11953
|
if (shouldConnect) {
|
|
11298
11954
|
if (typeof atob === "undefined") {
|
|
11299
|
-
if (_optionalChain([clientOptions, 'access',
|
|
11955
|
+
if (_optionalChain([clientOptions, 'access', _280 => _280.polyfills, 'optionalAccess', _281 => _281.atob]) === void 0) {
|
|
11300
11956
|
throw new Error(
|
|
11301
11957
|
"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"
|
|
11302
11958
|
);
|
|
@@ -11308,7 +11964,7 @@ function createClient(options) {
|
|
|
11308
11964
|
return leaseRoom(newRoomDetails);
|
|
11309
11965
|
}
|
|
11310
11966
|
function getRoom(roomId) {
|
|
11311
|
-
const room = _optionalChain([roomsById, 'access',
|
|
11967
|
+
const room = _optionalChain([roomsById, 'access', _282 => _282.get, 'call', _283 => _283(roomId), 'optionalAccess', _284 => _284.room]);
|
|
11312
11968
|
return room ? room : null;
|
|
11313
11969
|
}
|
|
11314
11970
|
function logout() {
|
|
@@ -11324,7 +11980,7 @@ function createClient(options) {
|
|
|
11324
11980
|
const batchedResolveUsers = new Batch(
|
|
11325
11981
|
async (batchedUserIds) => {
|
|
11326
11982
|
const userIds = batchedUserIds.flat();
|
|
11327
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
11983
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _285 => _285({ userIds })]);
|
|
11328
11984
|
warnOnceIf(
|
|
11329
11985
|
!resolveUsers,
|
|
11330
11986
|
"Set the resolveUsers option in createClient to specify user info."
|
|
@@ -11341,7 +11997,7 @@ function createClient(options) {
|
|
|
11341
11997
|
const batchedResolveRoomsInfo = new Batch(
|
|
11342
11998
|
async (batchedRoomIds) => {
|
|
11343
11999
|
const roomIds = batchedRoomIds.flat();
|
|
11344
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
12000
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _286 => _286({ roomIds })]);
|
|
11345
12001
|
warnOnceIf(
|
|
11346
12002
|
!resolveRoomsInfo,
|
|
11347
12003
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
@@ -11358,7 +12014,7 @@ function createClient(options) {
|
|
|
11358
12014
|
const batchedResolveGroupsInfo = new Batch(
|
|
11359
12015
|
async (batchedGroupIds) => {
|
|
11360
12016
|
const groupIds = batchedGroupIds.flat();
|
|
11361
|
-
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall',
|
|
12017
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _287 => _287({ groupIds })]);
|
|
11362
12018
|
warnOnceIf(
|
|
11363
12019
|
!resolveGroupsInfo,
|
|
11364
12020
|
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
@@ -11417,7 +12073,7 @@ function createClient(options) {
|
|
|
11417
12073
|
}
|
|
11418
12074
|
};
|
|
11419
12075
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
11420
|
-
_optionalChain([win, 'optionalAccess',
|
|
12076
|
+
_optionalChain([win, 'optionalAccess', _288 => _288.addEventListener, 'call', _289 => _289("beforeunload", maybePreventClose)]);
|
|
11421
12077
|
}
|
|
11422
12078
|
async function getNotificationSettings(options2) {
|
|
11423
12079
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -11544,7 +12200,7 @@ var commentBodyElementsTypes = {
|
|
|
11544
12200
|
mention: "inline"
|
|
11545
12201
|
};
|
|
11546
12202
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
11547
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
12203
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _290 => _290.content])) {
|
|
11548
12204
|
return;
|
|
11549
12205
|
}
|
|
11550
12206
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -11554,13 +12210,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
11554
12210
|
for (const block of body.content) {
|
|
11555
12211
|
if (type === "all" || type === "block") {
|
|
11556
12212
|
if (guard(block)) {
|
|
11557
|
-
_optionalChain([visitor, 'optionalCall',
|
|
12213
|
+
_optionalChain([visitor, 'optionalCall', _291 => _291(block)]);
|
|
11558
12214
|
}
|
|
11559
12215
|
}
|
|
11560
12216
|
if (type === "all" || type === "inline") {
|
|
11561
12217
|
for (const inline of block.children) {
|
|
11562
12218
|
if (guard(inline)) {
|
|
11563
|
-
_optionalChain([visitor, 'optionalCall',
|
|
12219
|
+
_optionalChain([visitor, 'optionalCall', _292 => _292(inline)]);
|
|
11564
12220
|
}
|
|
11565
12221
|
}
|
|
11566
12222
|
}
|
|
@@ -11730,7 +12386,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
11730
12386
|
text: ({ element }) => element.text,
|
|
11731
12387
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
11732
12388
|
mention: ({ element, user, group }) => {
|
|
11733
|
-
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
12389
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _293 => _293.name]), () => ( _optionalChain([group, 'optionalAccess', _294 => _294.name]))), () => ( element.id))}`;
|
|
11734
12390
|
}
|
|
11735
12391
|
};
|
|
11736
12392
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -11760,7 +12416,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
11760
12416
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
11761
12417
|
},
|
|
11762
12418
|
mention: ({ element, user, group }) => {
|
|
11763
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
12419
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _295 => _295.name]) ? html`${_optionalChain([user, 'optionalAccess', _296 => _296.name])}` : _optionalChain([group, 'optionalAccess', _297 => _297.name]) ? html`${_optionalChain([group, 'optionalAccess', _298 => _298.name])}` : element.id}</span>`;
|
|
11764
12420
|
}
|
|
11765
12421
|
};
|
|
11766
12422
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -11790,20 +12446,20 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
11790
12446
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
11791
12447
|
},
|
|
11792
12448
|
mention: ({ element, user, group }) => {
|
|
11793
|
-
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
12449
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _299 => _299.name]), () => ( _optionalChain([group, 'optionalAccess', _300 => _300.name]))), () => ( element.id))}`;
|
|
11794
12450
|
}
|
|
11795
12451
|
};
|
|
11796
12452
|
async function stringifyCommentBody(body, options) {
|
|
11797
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11798
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12453
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _301 => _301.format]), () => ( "plain"));
|
|
12454
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _302 => _302.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
11799
12455
|
const elements = {
|
|
11800
12456
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
11801
|
-
..._optionalChain([options, 'optionalAccess',
|
|
12457
|
+
..._optionalChain([options, 'optionalAccess', _303 => _303.elements])
|
|
11802
12458
|
};
|
|
11803
12459
|
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
11804
12460
|
body,
|
|
11805
|
-
_optionalChain([options, 'optionalAccess',
|
|
11806
|
-
_optionalChain([options, 'optionalAccess',
|
|
12461
|
+
_optionalChain([options, 'optionalAccess', _304 => _304.resolveUsers]),
|
|
12462
|
+
_optionalChain([options, 'optionalAccess', _305 => _305.resolveGroupsInfo])
|
|
11807
12463
|
);
|
|
11808
12464
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
11809
12465
|
switch (block.type) {
|
|
@@ -11885,6 +12541,12 @@ function toPlainLson(lson) {
|
|
|
11885
12541
|
liveblocksType: "LiveList",
|
|
11886
12542
|
data: [...lson].map((item) => toPlainLson(item))
|
|
11887
12543
|
};
|
|
12544
|
+
} else if (lson instanceof LiveText) {
|
|
12545
|
+
return {
|
|
12546
|
+
liveblocksType: "LiveText",
|
|
12547
|
+
data: lson.toDelta(),
|
|
12548
|
+
version: lson.version
|
|
12549
|
+
};
|
|
11888
12550
|
} else {
|
|
11889
12551
|
return lson;
|
|
11890
12552
|
}
|
|
@@ -11938,9 +12600,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
11938
12600
|
const startTime = performance.now();
|
|
11939
12601
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
11940
12602
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
11941
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12603
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _306 => _306.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
11942
12604
|
const context = {
|
|
11943
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
12605
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _307 => _307.visibilityState]) !== "hidden",
|
|
11944
12606
|
lastSuccessfulPollAt: startTime,
|
|
11945
12607
|
count: 0,
|
|
11946
12608
|
backoff: 0
|
|
@@ -12021,11 +12683,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
12021
12683
|
pollNowIfStale();
|
|
12022
12684
|
}
|
|
12023
12685
|
function onVisibilityChange() {
|
|
12024
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
12686
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _308 => _308.visibilityState]) !== "hidden");
|
|
12025
12687
|
}
|
|
12026
|
-
_optionalChain([doc, 'optionalAccess',
|
|
12027
|
-
_optionalChain([win, 'optionalAccess',
|
|
12028
|
-
_optionalChain([win, 'optionalAccess',
|
|
12688
|
+
_optionalChain([doc, 'optionalAccess', _309 => _309.addEventListener, 'call', _310 => _310("visibilitychange", onVisibilityChange)]);
|
|
12689
|
+
_optionalChain([win, 'optionalAccess', _311 => _311.addEventListener, 'call', _312 => _312("online", onVisibilityChange)]);
|
|
12690
|
+
_optionalChain([win, 'optionalAccess', _313 => _313.addEventListener, 'call', _314 => _314("focus", pollNowIfStale)]);
|
|
12029
12691
|
fsm.start();
|
|
12030
12692
|
return {
|
|
12031
12693
|
inc,
|
|
@@ -12162,5 +12824,8 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
12162
12824
|
|
|
12163
12825
|
|
|
12164
12826
|
|
|
12165
|
-
|
|
12827
|
+
|
|
12828
|
+
|
|
12829
|
+
|
|
12830
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.FeedRequestErrorCode = FeedRequestErrorCode; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveText = LiveText; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.applyLiveTextOperations = applyLiveTextOperations; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactNodesToNodeStream = compactNodesToNodeStream; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isListStorageNode = isListStorageNode; exports.isLiveNode = isLiveNode; exports.isMapStorageNode = isMapStorageNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isObjectStorageNode = isObjectStorageNode; exports.isPlainObject = isPlainObject; exports.isRegisterStorageNode = isRegisterStorageNode; exports.isRootStorageNode = isRootStorageNode; exports.isStartsWithOperator = isStartsWithOperator; exports.isTextStorageNode = isTextStorageNode; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.nodeStreamToCompactNodes = nodeStreamToCompactNodes; exports.objectToQuery = objectToQuery; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
12166
12831
|
//# sourceMappingURL=index.cjs.map
|