@liveblocks/core 3.23.1-exp1 → 3.23.1-exp2
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 +371 -252
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +172 -167
- package/dist/index.d.ts +172 -167
- package/dist/index.js +297 -178
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.23.1-
|
|
9
|
+
var PKG_VERSION = "3.23.1-exp2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1107,7 +1107,6 @@ function* nodeStreamToCompactNodes(nodes) {
|
|
|
1107
1107
|
|
|
1108
1108
|
// src/internal.ts
|
|
1109
1109
|
var kInternal = /* @__PURE__ */ Symbol();
|
|
1110
|
-
var kStorageUpdateSource = /* @__PURE__ */ Symbol();
|
|
1111
1110
|
|
|
1112
1111
|
// src/lib/position.ts
|
|
1113
1112
|
var MIN_CODE = 32;
|
|
@@ -1288,6 +1287,18 @@ function asPos(str) {
|
|
|
1288
1287
|
return isPos(str) ? str : convertToPos(str);
|
|
1289
1288
|
}
|
|
1290
1289
|
|
|
1290
|
+
// src/crdts/StorageUpdates.ts
|
|
1291
|
+
var REMOTE = freeze({ origin: "remote" });
|
|
1292
|
+
var LOCAL_EDIT = freeze({ origin: "local", via: "edit" });
|
|
1293
|
+
var LOCAL_UNDO = freeze({ origin: "local", via: "undo" });
|
|
1294
|
+
var LOCAL_REDO = freeze({ origin: "local", via: "redo" });
|
|
1295
|
+
function toUpdateSource(source) {
|
|
1296
|
+
return source.origin === "remote" ? source : (
|
|
1297
|
+
// Removes `optimistic` field, which is not public
|
|
1298
|
+
{ origin: "local", via: source.via }
|
|
1299
|
+
);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1291
1302
|
// src/crdts/UnacknowledgedOps.ts
|
|
1292
1303
|
var UnacknowledgedOps = class {
|
|
1293
1304
|
// opId -> op
|
|
@@ -1496,11 +1507,14 @@ var AbstractCrdt = class {
|
|
|
1496
1507
|
}
|
|
1497
1508
|
}
|
|
1498
1509
|
/** @internal */
|
|
1499
|
-
_apply(op,
|
|
1510
|
+
_apply(op, source) {
|
|
1500
1511
|
switch (op.type) {
|
|
1501
1512
|
case OpCode.DELETE_CRDT: {
|
|
1502
1513
|
if (this.parent.type === "HasParent") {
|
|
1503
|
-
return this.parent.node._detachChild(
|
|
1514
|
+
return this.parent.node._detachChild(
|
|
1515
|
+
crdtAsLiveNode(this),
|
|
1516
|
+
toUpdateSource(source)
|
|
1517
|
+
);
|
|
1504
1518
|
}
|
|
1505
1519
|
return { modified: false };
|
|
1506
1520
|
}
|
|
@@ -1690,8 +1704,8 @@ var LiveFile = class _LiveFile extends AbstractCrdt {
|
|
|
1690
1704
|
throw new Error("A LiveFile node cannot have children");
|
|
1691
1705
|
}
|
|
1692
1706
|
/** @internal */
|
|
1693
|
-
_apply(op,
|
|
1694
|
-
return super._apply(op,
|
|
1707
|
+
_apply(op, source) {
|
|
1708
|
+
return super._apply(op, source);
|
|
1695
1709
|
}
|
|
1696
1710
|
/** @internal */
|
|
1697
1711
|
_toTreeNode(key) {
|
|
@@ -6911,8 +6925,8 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
6911
6925
|
throw new Error("Method not implemented.");
|
|
6912
6926
|
}
|
|
6913
6927
|
/** @internal */
|
|
6914
|
-
_apply(op,
|
|
6915
|
-
return super._apply(op,
|
|
6928
|
+
_apply(op, source) {
|
|
6929
|
+
return super._apply(op, source);
|
|
6916
6930
|
}
|
|
6917
6931
|
/** @internal */
|
|
6918
6932
|
_toTreeNode(key) {
|
|
@@ -7073,7 +7087,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7073
7087
|
item._detach();
|
|
7074
7088
|
}
|
|
7075
7089
|
}
|
|
7076
|
-
#
|
|
7090
|
+
#applyRemoteSet(op) {
|
|
7077
7091
|
if (this._pool === void 0) {
|
|
7078
7092
|
throw new Error("Can't attach child if managed pool is not present");
|
|
7079
7093
|
}
|
|
@@ -7091,9 +7105,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7091
7105
|
itemWithSamePosition._detach();
|
|
7092
7106
|
this.#items.add(child);
|
|
7093
7107
|
return {
|
|
7094
|
-
modified: makeUpdate(
|
|
7095
|
-
|
|
7096
|
-
|
|
7108
|
+
modified: makeUpdate(
|
|
7109
|
+
this,
|
|
7110
|
+
[setDelta(indexOfItemWithSamePosition, child)],
|
|
7111
|
+
REMOTE
|
|
7112
|
+
),
|
|
7097
7113
|
reverse: []
|
|
7098
7114
|
};
|
|
7099
7115
|
} else {
|
|
@@ -7104,20 +7120,22 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7104
7120
|
setDelta(indexOfItemWithSamePosition, child)
|
|
7105
7121
|
];
|
|
7106
7122
|
const deleteDelta2 = this.#detachItemAssociatedToSetOperation(
|
|
7107
|
-
op.deletedId
|
|
7123
|
+
op.deletedId,
|
|
7124
|
+
REMOTE
|
|
7108
7125
|
);
|
|
7109
7126
|
if (deleteDelta2) {
|
|
7110
7127
|
delta.push(deleteDelta2);
|
|
7111
7128
|
}
|
|
7112
7129
|
return {
|
|
7113
|
-
modified: makeUpdate(this, delta),
|
|
7130
|
+
modified: makeUpdate(this, delta, REMOTE),
|
|
7114
7131
|
reverse: []
|
|
7115
7132
|
};
|
|
7116
7133
|
}
|
|
7117
7134
|
} else {
|
|
7118
7135
|
const updates = [];
|
|
7119
7136
|
const deleteDelta2 = this.#detachItemAssociatedToSetOperation(
|
|
7120
|
-
op.deletedId
|
|
7137
|
+
op.deletedId,
|
|
7138
|
+
REMOTE
|
|
7121
7139
|
);
|
|
7122
7140
|
if (deleteDelta2) {
|
|
7123
7141
|
updates.push(deleteDelta2);
|
|
@@ -7126,29 +7144,32 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7126
7144
|
updates.push(insertDelta(this._indexOfPosition(key), child));
|
|
7127
7145
|
return {
|
|
7128
7146
|
reverse: [],
|
|
7129
|
-
modified: makeUpdate(this, updates)
|
|
7147
|
+
modified: makeUpdate(this, updates, REMOTE)
|
|
7130
7148
|
};
|
|
7131
7149
|
}
|
|
7132
7150
|
}
|
|
7133
|
-
#applySetAck(op) {
|
|
7151
|
+
#applySetAck(op, source) {
|
|
7134
7152
|
if (this._pool === void 0) {
|
|
7135
7153
|
throw new Error("Can't attach child if managed pool is not present");
|
|
7136
7154
|
}
|
|
7137
7155
|
const delta = [];
|
|
7138
|
-
const deletedDelta = this.#detachItemAssociatedToSetOperation(
|
|
7156
|
+
const deletedDelta = this.#detachItemAssociatedToSetOperation(
|
|
7157
|
+
op.deletedId,
|
|
7158
|
+
source
|
|
7159
|
+
);
|
|
7139
7160
|
if (deletedDelta) {
|
|
7140
7161
|
delta.push(deletedDelta);
|
|
7141
7162
|
}
|
|
7142
7163
|
const unacknowledgedOpId = this.#unacknowledgedSetOpIdAt(op.parentKey);
|
|
7143
7164
|
if (unacknowledgedOpId !== void 0 && unacknowledgedOpId !== op.opId) {
|
|
7144
|
-
return delta.length === 0 ? { modified: false } : { modified: makeUpdate(this, delta), reverse: [] };
|
|
7165
|
+
return delta.length === 0 ? { modified: false } : { modified: makeUpdate(this, delta, source), reverse: [] };
|
|
7145
7166
|
}
|
|
7146
7167
|
const indexOfItemWithSamePosition = this._indexOfPosition(op.parentKey);
|
|
7147
7168
|
const existingItem = this.#items.find((item) => item._id === op.id);
|
|
7148
7169
|
if (existingItem !== void 0) {
|
|
7149
7170
|
if (existingItem._parentKey === op.parentKey) {
|
|
7150
7171
|
return {
|
|
7151
|
-
modified: delta.length > 0 ? makeUpdate(this, delta) : false,
|
|
7172
|
+
modified: delta.length > 0 ? makeUpdate(this, delta, source) : false,
|
|
7152
7173
|
reverse: []
|
|
7153
7174
|
};
|
|
7154
7175
|
}
|
|
@@ -7166,7 +7187,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7166
7187
|
delta.push(moveDelta(prevIndex, newIndex, existingItem));
|
|
7167
7188
|
}
|
|
7168
7189
|
return {
|
|
7169
|
-
modified: delta.length > 0 ? makeUpdate(this, delta) : false,
|
|
7190
|
+
modified: delta.length > 0 ? makeUpdate(this, delta, source) : false,
|
|
7170
7191
|
reverse: []
|
|
7171
7192
|
};
|
|
7172
7193
|
} else {
|
|
@@ -7176,11 +7197,15 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7176
7197
|
this.#implicitlyDeletedItems.delete(orphan);
|
|
7177
7198
|
const recreatedItemIndex = this.#insert(orphan);
|
|
7178
7199
|
return {
|
|
7179
|
-
modified: makeUpdate(
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7200
|
+
modified: makeUpdate(
|
|
7201
|
+
this,
|
|
7202
|
+
[
|
|
7203
|
+
// If there is an item at this position, update is a set, else it's an insert
|
|
7204
|
+
indexOfItemWithSamePosition === -1 ? insertDelta(recreatedItemIndex, orphan) : setDelta(recreatedItemIndex, orphan),
|
|
7205
|
+
...delta
|
|
7206
|
+
],
|
|
7207
|
+
source
|
|
7208
|
+
),
|
|
7184
7209
|
reverse: []
|
|
7185
7210
|
};
|
|
7186
7211
|
} else {
|
|
@@ -7195,11 +7220,15 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7195
7220
|
op.parentKey
|
|
7196
7221
|
);
|
|
7197
7222
|
return {
|
|
7198
|
-
modified: makeUpdate(
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7223
|
+
modified: makeUpdate(
|
|
7224
|
+
this,
|
|
7225
|
+
[
|
|
7226
|
+
// If there is an item at this position, update is a set, else it's an insert
|
|
7227
|
+
indexOfItemWithSamePosition === -1 ? insertDelta(newIndex, newItem) : setDelta(newIndex, newItem),
|
|
7228
|
+
...delta
|
|
7229
|
+
],
|
|
7230
|
+
source
|
|
7231
|
+
),
|
|
7203
7232
|
reverse: []
|
|
7204
7233
|
};
|
|
7205
7234
|
}
|
|
@@ -7208,7 +7237,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7208
7237
|
/**
|
|
7209
7238
|
* Returns the update delta of the deletion or null
|
|
7210
7239
|
*/
|
|
7211
|
-
#detachItemAssociatedToSetOperation(deletedId) {
|
|
7240
|
+
#detachItemAssociatedToSetOperation(deletedId, source) {
|
|
7212
7241
|
if (deletedId === void 0 || this._pool === void 0) {
|
|
7213
7242
|
return null;
|
|
7214
7243
|
}
|
|
@@ -7216,7 +7245,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7216
7245
|
if (deletedItem === void 0) {
|
|
7217
7246
|
return null;
|
|
7218
7247
|
}
|
|
7219
|
-
const result = this._detachChild(deletedItem);
|
|
7248
|
+
const result = this._detachChild(deletedItem, source);
|
|
7220
7249
|
if (result.modified === false) {
|
|
7221
7250
|
return null;
|
|
7222
7251
|
}
|
|
@@ -7234,10 +7263,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7234
7263
|
const { newItem, newIndex } = this.#createAttachItemAndSort(op, key);
|
|
7235
7264
|
const bumpDeltas = this.#bumpUnackedPushesAbove(key);
|
|
7236
7265
|
return {
|
|
7237
|
-
modified: makeUpdate(
|
|
7238
|
-
|
|
7239
|
-
...bumpDeltas
|
|
7240
|
-
|
|
7266
|
+
modified: makeUpdate(
|
|
7267
|
+
this,
|
|
7268
|
+
[insertDelta(newIndex, newItem), ...bumpDeltas],
|
|
7269
|
+
REMOTE
|
|
7270
|
+
),
|
|
7241
7271
|
reverse: []
|
|
7242
7272
|
};
|
|
7243
7273
|
}
|
|
@@ -7318,7 +7348,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7318
7348
|
}
|
|
7319
7349
|
return deltas;
|
|
7320
7350
|
}
|
|
7321
|
-
#applyInsertAck(op) {
|
|
7351
|
+
#applyInsertAck(op, source) {
|
|
7322
7352
|
const existingItem = this.#items.find((item) => item._id === op.id);
|
|
7323
7353
|
const key = asPos(op.parentKey);
|
|
7324
7354
|
const itemIndexAtPosition = this._indexOfPosition(key);
|
|
@@ -7340,9 +7370,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7340
7370
|
return { modified: false };
|
|
7341
7371
|
}
|
|
7342
7372
|
return {
|
|
7343
|
-
modified: makeUpdate(
|
|
7344
|
-
|
|
7345
|
-
|
|
7373
|
+
modified: makeUpdate(
|
|
7374
|
+
this,
|
|
7375
|
+
[moveDelta(oldPositionIndex, newIndex, existingItem)],
|
|
7376
|
+
source
|
|
7377
|
+
),
|
|
7346
7378
|
reverse: []
|
|
7347
7379
|
};
|
|
7348
7380
|
}
|
|
@@ -7354,7 +7386,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7354
7386
|
this.#insert(orphan);
|
|
7355
7387
|
const newIndex = this._indexOfPosition(key);
|
|
7356
7388
|
return {
|
|
7357
|
-
modified: makeUpdate(this, [insertDelta(newIndex, orphan)]),
|
|
7389
|
+
modified: makeUpdate(this, [insertDelta(newIndex, orphan)], source),
|
|
7358
7390
|
reverse: []
|
|
7359
7391
|
};
|
|
7360
7392
|
} else {
|
|
@@ -7363,13 +7395,13 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7363
7395
|
}
|
|
7364
7396
|
const { newItem, newIndex } = this.#createAttachItemAndSort(op, key);
|
|
7365
7397
|
return {
|
|
7366
|
-
modified: makeUpdate(this, [insertDelta(newIndex, newItem)]),
|
|
7398
|
+
modified: makeUpdate(this, [insertDelta(newIndex, newItem)], source),
|
|
7367
7399
|
reverse: []
|
|
7368
7400
|
};
|
|
7369
7401
|
}
|
|
7370
7402
|
}
|
|
7371
7403
|
}
|
|
7372
|
-
#
|
|
7404
|
+
#applyLocalInsert(op, source) {
|
|
7373
7405
|
const { id, parentKey: key } = op;
|
|
7374
7406
|
const child = creationOpToLiveNode(op);
|
|
7375
7407
|
if (_optionalChain([this, 'access', _151 => _151._pool, 'optionalAccess', _152 => _152.getNode, 'call', _153 => _153(id)]) !== void 0) {
|
|
@@ -7388,11 +7420,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7388
7420
|
this.#insert(child);
|
|
7389
7421
|
const newIndex = this._indexOfPosition(newKey);
|
|
7390
7422
|
return {
|
|
7391
|
-
modified: makeUpdate(this, [insertDelta(newIndex, child)]),
|
|
7423
|
+
modified: makeUpdate(this, [insertDelta(newIndex, child)], source),
|
|
7392
7424
|
reverse: [{ type: OpCode.DELETE_CRDT, id }]
|
|
7393
7425
|
};
|
|
7394
7426
|
}
|
|
7395
|
-
#
|
|
7427
|
+
#applyLocalSet(op, source) {
|
|
7396
7428
|
const { id, parentKey: key } = op;
|
|
7397
7429
|
const child = creationOpToLiveNode(op);
|
|
7398
7430
|
if (_optionalChain([this, 'access', _162 => _162._pool, 'optionalAccess', _163 => _163.getNode, 'call', _164 => _164(id)]) !== void 0) {
|
|
@@ -7414,46 +7446,48 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7414
7446
|
);
|
|
7415
7447
|
const delta = [setDelta(indexOfItemWithSameKey, child)];
|
|
7416
7448
|
const deletedDelta = this.#detachItemAssociatedToSetOperation(
|
|
7417
|
-
op.deletedId
|
|
7449
|
+
op.deletedId,
|
|
7450
|
+
source
|
|
7418
7451
|
);
|
|
7419
7452
|
if (deletedDelta) {
|
|
7420
7453
|
delta.push(deletedDelta);
|
|
7421
7454
|
}
|
|
7422
7455
|
return {
|
|
7423
|
-
modified: makeUpdate(this, delta),
|
|
7456
|
+
modified: makeUpdate(this, delta, source),
|
|
7424
7457
|
reverse
|
|
7425
7458
|
};
|
|
7426
7459
|
} else {
|
|
7427
7460
|
this.#insert(child);
|
|
7428
|
-
this.#detachItemAssociatedToSetOperation(op.deletedId);
|
|
7461
|
+
this.#detachItemAssociatedToSetOperation(op.deletedId, source);
|
|
7429
7462
|
const newIndex = this._indexOfPosition(newKey);
|
|
7430
7463
|
return {
|
|
7431
7464
|
reverse: [{ type: OpCode.DELETE_CRDT, id }],
|
|
7432
|
-
modified: makeUpdate(this, [insertDelta(newIndex, child)])
|
|
7465
|
+
modified: makeUpdate(this, [insertDelta(newIndex, child)], source)
|
|
7433
7466
|
};
|
|
7434
7467
|
}
|
|
7435
7468
|
}
|
|
7436
7469
|
/** @internal */
|
|
7437
|
-
_attachChild(op,
|
|
7470
|
+
_attachChild(op, opSource) {
|
|
7471
|
+
const source = toUpdateSource(opSource);
|
|
7438
7472
|
if (this._pool === void 0) {
|
|
7439
7473
|
throw new Error("Can't attach child if managed pool is not present");
|
|
7440
7474
|
}
|
|
7441
7475
|
let result;
|
|
7442
7476
|
if (op.intent === "set") {
|
|
7443
|
-
if (
|
|
7444
|
-
result = this.#
|
|
7445
|
-
} else if (
|
|
7446
|
-
result = this.#applySetAck(op);
|
|
7477
|
+
if (opSource.origin === "remote") {
|
|
7478
|
+
result = this.#applyRemoteSet(op);
|
|
7479
|
+
} else if (!opSource.optimistic) {
|
|
7480
|
+
result = this.#applySetAck(op, source);
|
|
7447
7481
|
} else {
|
|
7448
|
-
result = this.#
|
|
7482
|
+
result = this.#applyLocalSet(op, source);
|
|
7449
7483
|
}
|
|
7450
7484
|
} else {
|
|
7451
|
-
if (
|
|
7485
|
+
if (opSource.origin === "remote") {
|
|
7452
7486
|
result = this.#applyRemoteInsert(op);
|
|
7453
|
-
} else if (
|
|
7454
|
-
result = this.#applyInsertAck(op);
|
|
7487
|
+
} else if (!opSource.optimistic) {
|
|
7488
|
+
result = this.#applyInsertAck(op, source);
|
|
7455
7489
|
} else {
|
|
7456
|
-
result = this.#
|
|
7490
|
+
result = this.#applyLocalInsert(op, source);
|
|
7457
7491
|
}
|
|
7458
7492
|
}
|
|
7459
7493
|
if (result.modified !== false) {
|
|
@@ -7462,7 +7496,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7462
7496
|
return result;
|
|
7463
7497
|
}
|
|
7464
7498
|
/** @internal */
|
|
7465
|
-
_detachChild(child) {
|
|
7499
|
+
_detachChild(child, source) {
|
|
7466
7500
|
if (child) {
|
|
7467
7501
|
const parentKey = nn(child._parentKey);
|
|
7468
7502
|
const reverse = child._toOps(nn(this._id), parentKey);
|
|
@@ -7477,19 +7511,23 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7477
7511
|
this.invalidate();
|
|
7478
7512
|
child._detach();
|
|
7479
7513
|
return {
|
|
7480
|
-
modified: makeUpdate(
|
|
7514
|
+
modified: makeUpdate(
|
|
7515
|
+
this,
|
|
7516
|
+
[deleteDelta(indexToDelete, previousNode)],
|
|
7517
|
+
source
|
|
7518
|
+
),
|
|
7481
7519
|
reverse
|
|
7482
7520
|
};
|
|
7483
7521
|
}
|
|
7484
7522
|
return { modified: false };
|
|
7485
7523
|
}
|
|
7486
|
-
#
|
|
7524
|
+
#applyRemoteSetChildKey(newKey, child) {
|
|
7487
7525
|
if (this.#implicitlyDeletedItems.has(child)) {
|
|
7488
7526
|
this.#implicitlyDeletedItems.delete(child);
|
|
7489
7527
|
child._setParentLink(this, newKey);
|
|
7490
7528
|
const newIndex = this.#insert(child);
|
|
7491
7529
|
return {
|
|
7492
|
-
modified: makeUpdate(this, [insertDelta(newIndex, child)]),
|
|
7530
|
+
modified: makeUpdate(this, [insertDelta(newIndex, child)], REMOTE),
|
|
7493
7531
|
reverse: []
|
|
7494
7532
|
};
|
|
7495
7533
|
}
|
|
@@ -7510,7 +7548,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7510
7548
|
};
|
|
7511
7549
|
}
|
|
7512
7550
|
return {
|
|
7513
|
-
modified: makeUpdate(
|
|
7551
|
+
modified: makeUpdate(
|
|
7552
|
+
this,
|
|
7553
|
+
[moveDelta(previousIndex, newIndex, child)],
|
|
7554
|
+
REMOTE
|
|
7555
|
+
),
|
|
7514
7556
|
reverse: []
|
|
7515
7557
|
};
|
|
7516
7558
|
} else {
|
|
@@ -7527,12 +7569,16 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7527
7569
|
};
|
|
7528
7570
|
}
|
|
7529
7571
|
return {
|
|
7530
|
-
modified: makeUpdate(
|
|
7572
|
+
modified: makeUpdate(
|
|
7573
|
+
this,
|
|
7574
|
+
[moveDelta(previousIndex, newIndex, child)],
|
|
7575
|
+
REMOTE
|
|
7576
|
+
),
|
|
7531
7577
|
reverse: []
|
|
7532
7578
|
};
|
|
7533
7579
|
}
|
|
7534
7580
|
}
|
|
7535
|
-
#applySetChildKeyAck(newKey, child) {
|
|
7581
|
+
#applySetChildKeyAck(newKey, child, source) {
|
|
7536
7582
|
const previousKey = nn(child._parentKey);
|
|
7537
7583
|
if (this.#implicitlyDeletedItems.has(child)) {
|
|
7538
7584
|
const existingItemIndex = this._indexOfPosition(newKey);
|
|
@@ -7551,7 +7597,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7551
7597
|
child._setParentLink(this, newKey);
|
|
7552
7598
|
const newIndex = this.#insert(child);
|
|
7553
7599
|
return {
|
|
7554
|
-
modified: makeUpdate(this, [insertDelta(newIndex, child)]),
|
|
7600
|
+
modified: makeUpdate(this, [insertDelta(newIndex, child)], source),
|
|
7555
7601
|
reverse: []
|
|
7556
7602
|
};
|
|
7557
7603
|
} else {
|
|
@@ -7579,15 +7625,17 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7579
7625
|
};
|
|
7580
7626
|
} else {
|
|
7581
7627
|
return {
|
|
7582
|
-
modified: makeUpdate(
|
|
7583
|
-
|
|
7584
|
-
|
|
7628
|
+
modified: makeUpdate(
|
|
7629
|
+
this,
|
|
7630
|
+
[moveDelta(previousIndex, newIndex, child)],
|
|
7631
|
+
source
|
|
7632
|
+
),
|
|
7585
7633
|
reverse: []
|
|
7586
7634
|
};
|
|
7587
7635
|
}
|
|
7588
7636
|
}
|
|
7589
7637
|
}
|
|
7590
|
-
#
|
|
7638
|
+
#applyLocalSetChildKey(newKey, child, source) {
|
|
7591
7639
|
const previousKey = nn(child._parentKey);
|
|
7592
7640
|
const previousIndex = this.#items.findIndex((item) => item === child);
|
|
7593
7641
|
const existingItemIndex = this._indexOfPosition(newKey);
|
|
@@ -7606,7 +7654,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7606
7654
|
};
|
|
7607
7655
|
}
|
|
7608
7656
|
return {
|
|
7609
|
-
modified: makeUpdate(
|
|
7657
|
+
modified: makeUpdate(
|
|
7658
|
+
this,
|
|
7659
|
+
[moveDelta(previousIndex, newIndex, child)],
|
|
7660
|
+
source
|
|
7661
|
+
),
|
|
7610
7662
|
reverse: [
|
|
7611
7663
|
{
|
|
7612
7664
|
type: OpCode.SET_PARENT_KEY,
|
|
@@ -7617,18 +7669,19 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7617
7669
|
};
|
|
7618
7670
|
}
|
|
7619
7671
|
/** @internal */
|
|
7620
|
-
_setChildKey(newKey, child,
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7672
|
+
_setChildKey(newKey, child, opSource) {
|
|
7673
|
+
const source = toUpdateSource(opSource);
|
|
7674
|
+
if (opSource.origin === "remote") {
|
|
7675
|
+
return this.#applyRemoteSetChildKey(newKey, child);
|
|
7676
|
+
} else if (!opSource.optimistic) {
|
|
7677
|
+
return this.#applySetChildKeyAck(newKey, child, source);
|
|
7625
7678
|
} else {
|
|
7626
|
-
return this.#
|
|
7679
|
+
return this.#applyLocalSetChildKey(newKey, child, source);
|
|
7627
7680
|
}
|
|
7628
7681
|
}
|
|
7629
7682
|
/** @internal */
|
|
7630
|
-
_apply(op,
|
|
7631
|
-
return super._apply(op,
|
|
7683
|
+
_apply(op, source) {
|
|
7684
|
+
return super._apply(op, source);
|
|
7632
7685
|
}
|
|
7633
7686
|
/** @internal */
|
|
7634
7687
|
_serialize() {
|
|
@@ -7689,7 +7742,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7689
7742
|
intent === "push" ? addIntentToRootOp(ops, "push") : ops,
|
|
7690
7743
|
[{ type: OpCode.DELETE_CRDT, id }],
|
|
7691
7744
|
/* @__PURE__ */ new Map([
|
|
7692
|
-
[this._id, makeUpdate(this, [insertDelta(index, value)])]
|
|
7745
|
+
[this._id, makeUpdate(this, [insertDelta(index, value)], LOCAL_EDIT)]
|
|
7693
7746
|
])
|
|
7694
7747
|
);
|
|
7695
7748
|
}
|
|
@@ -7730,7 +7783,10 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7730
7783
|
this.#updateItemPositionAt(index, position);
|
|
7731
7784
|
if (this._pool && this._id) {
|
|
7732
7785
|
const storageUpdates = /* @__PURE__ */ new Map([
|
|
7733
|
-
[
|
|
7786
|
+
[
|
|
7787
|
+
this._id,
|
|
7788
|
+
makeUpdate(this, [moveDelta(index, targetIndex, item)], LOCAL_EDIT)
|
|
7789
|
+
]
|
|
7734
7790
|
]);
|
|
7735
7791
|
this._pool.dispatch(
|
|
7736
7792
|
[
|
|
@@ -7773,7 +7829,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7773
7829
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
7774
7830
|
storageUpdates.set(
|
|
7775
7831
|
nn(this._id),
|
|
7776
|
-
makeUpdate(this, [deleteDelta(index, item)])
|
|
7832
|
+
makeUpdate(this, [deleteDelta(index, item)], LOCAL_EDIT)
|
|
7777
7833
|
);
|
|
7778
7834
|
this._pool.dispatch(
|
|
7779
7835
|
[
|
|
@@ -7813,7 +7869,10 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7813
7869
|
this.#items.clear();
|
|
7814
7870
|
this.invalidate();
|
|
7815
7871
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
7816
|
-
storageUpdates.set(
|
|
7872
|
+
storageUpdates.set(
|
|
7873
|
+
nn(this._id),
|
|
7874
|
+
makeUpdate(this, updateDelta, LOCAL_EDIT)
|
|
7875
|
+
);
|
|
7817
7876
|
this._pool.dispatch(ops, reverseOps, storageUpdates);
|
|
7818
7877
|
} else {
|
|
7819
7878
|
for (const item of this.#items) {
|
|
@@ -7843,7 +7902,10 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7843
7902
|
const id = this._pool.generateId();
|
|
7844
7903
|
value._attach(id, this._pool);
|
|
7845
7904
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
7846
|
-
storageUpdates.set(
|
|
7905
|
+
storageUpdates.set(
|
|
7906
|
+
this._id,
|
|
7907
|
+
makeUpdate(this, [setDelta(index, value)], LOCAL_EDIT)
|
|
7908
|
+
);
|
|
7847
7909
|
const ops = addIntentToRootOp(
|
|
7848
7910
|
value._toOpsWithOpId(this._id, position, this._pool),
|
|
7849
7911
|
"set",
|
|
@@ -8016,11 +8078,12 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
8016
8078
|
);
|
|
8017
8079
|
}
|
|
8018
8080
|
};
|
|
8019
|
-
function makeUpdate(liveList, deltaUpdates) {
|
|
8081
|
+
function makeUpdate(liveList, deltaUpdates, source) {
|
|
8020
8082
|
return {
|
|
8021
8083
|
node: liveList,
|
|
8022
8084
|
type: "LiveList",
|
|
8023
|
-
updates: deltaUpdates
|
|
8085
|
+
updates: deltaUpdates,
|
|
8086
|
+
source
|
|
8024
8087
|
};
|
|
8025
8088
|
}
|
|
8026
8089
|
function setDelta(index, item) {
|
|
@@ -8139,7 +8202,9 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8139
8202
|
if (this._pool.getNode(id) !== void 0) {
|
|
8140
8203
|
return { modified: false };
|
|
8141
8204
|
}
|
|
8142
|
-
if (source ===
|
|
8205
|
+
if (source.origin === "remote") {
|
|
8206
|
+
this.#unacknowledgedSet.delete(key);
|
|
8207
|
+
} else if (!source.optimistic) {
|
|
8143
8208
|
const lastUpdateOpId = this.#unacknowledgedSet.get(key);
|
|
8144
8209
|
if (lastUpdateOpId === opId) {
|
|
8145
8210
|
this.#unacknowledgedSet.delete(key);
|
|
@@ -8147,8 +8212,6 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8147
8212
|
} else if (lastUpdateOpId !== void 0) {
|
|
8148
8213
|
return { modified: false };
|
|
8149
8214
|
}
|
|
8150
|
-
} else if (source === 1 /* THEIRS */) {
|
|
8151
|
-
this.#unacknowledgedSet.delete(key);
|
|
8152
8215
|
}
|
|
8153
8216
|
const previousValue = this.#map.get(key);
|
|
8154
8217
|
let reverse;
|
|
@@ -8167,7 +8230,8 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8167
8230
|
modified: {
|
|
8168
8231
|
node: this,
|
|
8169
8232
|
type: "LiveMap",
|
|
8170
|
-
updates: { [key]: { type: "update" } }
|
|
8233
|
+
updates: { [key]: { type: "update" } },
|
|
8234
|
+
source: toUpdateSource(source)
|
|
8171
8235
|
},
|
|
8172
8236
|
reverse
|
|
8173
8237
|
};
|
|
@@ -8180,7 +8244,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8180
8244
|
}
|
|
8181
8245
|
}
|
|
8182
8246
|
/** @internal */
|
|
8183
|
-
_detachChild(child) {
|
|
8247
|
+
_detachChild(child, source) {
|
|
8184
8248
|
const id = nn(this._id);
|
|
8185
8249
|
const parentKey = nn(child._parentKey);
|
|
8186
8250
|
const reverse = child._toOps(id, parentKey);
|
|
@@ -8199,7 +8263,8 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8199
8263
|
type: "delete",
|
|
8200
8264
|
deletedItem: liveNodeToLson(child)
|
|
8201
8265
|
}
|
|
8202
|
-
}
|
|
8266
|
+
},
|
|
8267
|
+
source
|
|
8203
8268
|
};
|
|
8204
8269
|
return { modified: storageUpdate, reverse };
|
|
8205
8270
|
}
|
|
@@ -8248,7 +8313,8 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8248
8313
|
storageUpdates.set(this._id, {
|
|
8249
8314
|
node: this,
|
|
8250
8315
|
type: "LiveMap",
|
|
8251
|
-
updates: { [key]: { type: "update" } }
|
|
8316
|
+
updates: { [key]: { type: "update" } },
|
|
8317
|
+
source: LOCAL_EDIT
|
|
8252
8318
|
});
|
|
8253
8319
|
const ops = item._toOpsWithOpId(this._id, key, this._pool);
|
|
8254
8320
|
this.#unacknowledgedSet.set(key, nn(ops[0].opId));
|
|
@@ -8297,7 +8363,8 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8297
8363
|
type: "delete",
|
|
8298
8364
|
deletedItem: liveNodeToLson(item)
|
|
8299
8365
|
}
|
|
8300
|
-
}
|
|
8366
|
+
},
|
|
8367
|
+
source: LOCAL_EDIT
|
|
8301
8368
|
});
|
|
8302
8369
|
this._pool.dispatch(
|
|
8303
8370
|
[
|
|
@@ -8662,7 +8729,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8662
8729
|
}
|
|
8663
8730
|
return { modified: false };
|
|
8664
8731
|
}
|
|
8665
|
-
if (source ===
|
|
8732
|
+
if (source.origin === "local" && source.optimistic) {
|
|
8666
8733
|
this.#unackedOpsByKey.set(key, nn(opId));
|
|
8667
8734
|
} else if (this.#unackedOpsByKey.get(key) === void 0) {
|
|
8668
8735
|
} else if (this.#unackedOpsByKey.get(key) === opId) {
|
|
@@ -8700,12 +8767,13 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8700
8767
|
modified: {
|
|
8701
8768
|
node: this,
|
|
8702
8769
|
type: "LiveObject",
|
|
8703
|
-
updates: { [key]: { type: "update" } }
|
|
8770
|
+
updates: { [key]: { type: "update" } },
|
|
8771
|
+
source: toUpdateSource(source)
|
|
8704
8772
|
}
|
|
8705
8773
|
};
|
|
8706
8774
|
}
|
|
8707
8775
|
/** @internal */
|
|
8708
|
-
_detachChild(child) {
|
|
8776
|
+
_detachChild(child, source) {
|
|
8709
8777
|
if (child) {
|
|
8710
8778
|
const id = nn(this._id);
|
|
8711
8779
|
const parentKey = nn(child._parentKey);
|
|
@@ -8723,7 +8791,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8723
8791
|
type: "LiveObject",
|
|
8724
8792
|
updates: {
|
|
8725
8793
|
[parentKey]: { type: "delete", deletedItem }
|
|
8726
|
-
}
|
|
8794
|
+
},
|
|
8795
|
+
source
|
|
8727
8796
|
};
|
|
8728
8797
|
return { modified: storageUpdate, reverse };
|
|
8729
8798
|
}
|
|
@@ -8739,13 +8808,13 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8739
8808
|
}
|
|
8740
8809
|
}
|
|
8741
8810
|
/** @internal */
|
|
8742
|
-
_apply(op,
|
|
8811
|
+
_apply(op, source) {
|
|
8743
8812
|
if (op.type === OpCode.UPDATE_OBJECT) {
|
|
8744
|
-
return this.#applyUpdate(op,
|
|
8813
|
+
return this.#applyUpdate(op, source);
|
|
8745
8814
|
} else if (op.type === OpCode.DELETE_OBJECT_KEY) {
|
|
8746
|
-
return this.#applyDeleteObjectKey(op,
|
|
8815
|
+
return this.#applyDeleteObjectKey(op, source);
|
|
8747
8816
|
}
|
|
8748
|
-
return super._apply(op,
|
|
8817
|
+
return super._apply(op, source);
|
|
8749
8818
|
}
|
|
8750
8819
|
/** @internal */
|
|
8751
8820
|
_serialize() {
|
|
@@ -8769,7 +8838,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8769
8838
|
};
|
|
8770
8839
|
}
|
|
8771
8840
|
}
|
|
8772
|
-
#applyUpdate(op,
|
|
8841
|
+
#applyUpdate(op, source) {
|
|
8773
8842
|
let isModified = false;
|
|
8774
8843
|
const id = nn(this._id);
|
|
8775
8844
|
const reverse = [];
|
|
@@ -8797,7 +8866,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8797
8866
|
if (value === void 0) {
|
|
8798
8867
|
continue;
|
|
8799
8868
|
}
|
|
8800
|
-
if (
|
|
8869
|
+
if (source.origin === "local" && source.optimistic) {
|
|
8801
8870
|
this.#unackedOpsByKey.set(key, nn(op.opId));
|
|
8802
8871
|
} else if (this.#unackedOpsByKey.get(key) === void 0) {
|
|
8803
8872
|
isModified = true;
|
|
@@ -8824,18 +8893,19 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8824
8893
|
modified: {
|
|
8825
8894
|
node: this,
|
|
8826
8895
|
type: "LiveObject",
|
|
8827
|
-
updates: updateDelta
|
|
8896
|
+
updates: updateDelta,
|
|
8897
|
+
source: toUpdateSource(source)
|
|
8828
8898
|
},
|
|
8829
8899
|
reverse
|
|
8830
8900
|
} : { modified: false };
|
|
8831
8901
|
}
|
|
8832
|
-
#applyDeleteObjectKey(op,
|
|
8902
|
+
#applyDeleteObjectKey(op, source) {
|
|
8833
8903
|
const key = op.key;
|
|
8834
8904
|
const oldValue = this.#synced.get(key);
|
|
8835
8905
|
if (oldValue === void 0) {
|
|
8836
8906
|
return { modified: false };
|
|
8837
8907
|
}
|
|
8838
|
-
if (!
|
|
8908
|
+
if (!(source.origin === "local" && source.optimistic) && this.#unackedOpsByKey.get(key) !== void 0) {
|
|
8839
8909
|
return { modified: false };
|
|
8840
8910
|
}
|
|
8841
8911
|
const id = nn(this._id);
|
|
@@ -8861,7 +8931,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8861
8931
|
type: "LiveObject",
|
|
8862
8932
|
updates: {
|
|
8863
8933
|
[op.key]: { type: "delete", deletedItem: oldValue }
|
|
8864
|
-
}
|
|
8934
|
+
},
|
|
8935
|
+
source: toUpdateSource(source)
|
|
8865
8936
|
},
|
|
8866
8937
|
reverse
|
|
8867
8938
|
};
|
|
@@ -8907,7 +8978,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8907
8978
|
updates: {
|
|
8908
8979
|
..._optionalChain([existing, 'optionalAccess', _228 => _228.updates]),
|
|
8909
8980
|
[key]: { type: "update" }
|
|
8910
|
-
}
|
|
8981
|
+
},
|
|
8982
|
+
source: LOCAL_EDIT
|
|
8911
8983
|
});
|
|
8912
8984
|
this._pool.dispatch(ops, reverse, storageUpdates);
|
|
8913
8985
|
}
|
|
@@ -8941,7 +9013,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8941
9013
|
type: "delete",
|
|
8942
9014
|
deletedItem: oldValue2
|
|
8943
9015
|
}
|
|
8944
|
-
}
|
|
9016
|
+
},
|
|
9017
|
+
source: LOCAL_EDIT
|
|
8945
9018
|
});
|
|
8946
9019
|
return [[], [], storageUpdates2];
|
|
8947
9020
|
}
|
|
@@ -8989,7 +9062,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8989
9062
|
type: "LiveObject",
|
|
8990
9063
|
updates: {
|
|
8991
9064
|
[key]: { type: "delete", deletedItem: oldValue }
|
|
8992
|
-
}
|
|
9065
|
+
},
|
|
9066
|
+
source: LOCAL_EDIT
|
|
8993
9067
|
});
|
|
8994
9068
|
return [ops, reverse, storageUpdates];
|
|
8995
9069
|
}
|
|
@@ -9127,7 +9201,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
9127
9201
|
storageUpdates.set(this._id, {
|
|
9128
9202
|
node: this,
|
|
9129
9203
|
type: "LiveObject",
|
|
9130
|
-
updates: updateDelta
|
|
9204
|
+
updates: updateDelta,
|
|
9205
|
+
source: LOCAL_EDIT
|
|
9131
9206
|
});
|
|
9132
9207
|
this._pool.dispatch(ops, reverseOps, storageUpdates);
|
|
9133
9208
|
}
|
|
@@ -9289,6 +9364,31 @@ function clipRange(index, length, contentLength) {
|
|
|
9289
9364
|
);
|
|
9290
9365
|
return { index: clippedIndex, length: clippedEnd - clippedIndex };
|
|
9291
9366
|
}
|
|
9367
|
+
function isInSurrogatePair(text, index) {
|
|
9368
|
+
const previous = text.charCodeAt(index - 1);
|
|
9369
|
+
const next = text.charCodeAt(index);
|
|
9370
|
+
return previous >= 55296 && previous <= 56319 && next >= 56320 && next <= 57343;
|
|
9371
|
+
}
|
|
9372
|
+
function clipIndexToCodePointBoundary(text, index) {
|
|
9373
|
+
const clippedIndex = Math.max(0, Math.min(index, text.length));
|
|
9374
|
+
return isInSurrogatePair(text, clippedIndex) ? clippedIndex - 1 : clippedIndex;
|
|
9375
|
+
}
|
|
9376
|
+
function clipRangeToCodePointBoundaries(text, index, length) {
|
|
9377
|
+
const clipped = clipRange(index, length, text.length);
|
|
9378
|
+
if (clipped.length === 0) {
|
|
9379
|
+
return {
|
|
9380
|
+
index: clipIndexToCodePointBoundary(text, clipped.index),
|
|
9381
|
+
length: 0
|
|
9382
|
+
};
|
|
9383
|
+
}
|
|
9384
|
+
const clippedEnd = clipped.index + clipped.length;
|
|
9385
|
+
const normalizedIndex = isInSurrogatePair(text, clipped.index) ? clipped.index - 1 : clipped.index;
|
|
9386
|
+
const normalizedEnd = isInSurrogatePair(text, clippedEnd) ? clippedEnd + 1 : clippedEnd;
|
|
9387
|
+
return {
|
|
9388
|
+
index: normalizedIndex,
|
|
9389
|
+
length: normalizedEnd - normalizedIndex
|
|
9390
|
+
};
|
|
9391
|
+
}
|
|
9292
9392
|
function applyInsert(segments, index, text, attributes) {
|
|
9293
9393
|
if (text.length === 0) {
|
|
9294
9394
|
return normalizeSegments(segments);
|
|
@@ -9770,21 +9870,21 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
9770
9870
|
throw new Error("LiveText cannot contain child nodes");
|
|
9771
9871
|
}
|
|
9772
9872
|
/** @internal */
|
|
9773
|
-
_apply(op,
|
|
9873
|
+
_apply(op, source) {
|
|
9774
9874
|
if (op.type !== OpCode.UPDATE_TEXT) {
|
|
9775
|
-
return super._apply(op,
|
|
9875
|
+
return super._apply(op, source);
|
|
9776
9876
|
}
|
|
9777
|
-
if (
|
|
9778
|
-
return this.#applyLocal(op);
|
|
9877
|
+
if (source.origin === "local" && source.optimistic) {
|
|
9878
|
+
return this.#applyLocal(op, toUpdateSource(source));
|
|
9779
9879
|
}
|
|
9780
9880
|
if (op.opId !== void 0 && op.opId === this.#inFlightOpId) {
|
|
9781
|
-
return this.#applyAck(op);
|
|
9881
|
+
return this.#applyAck(op, toUpdateSource(source));
|
|
9782
9882
|
}
|
|
9783
9883
|
if (op.opId !== void 0 && this.#acceptedOps.some((entry) => entry.opId === op.opId)) {
|
|
9784
9884
|
this.#version = Math.max(this.#version, _nullishCoalesce(op.version, () => ( op.baseVersion + 1)));
|
|
9785
9885
|
return { modified: false };
|
|
9786
9886
|
}
|
|
9787
|
-
return this.#applyRemote(op);
|
|
9887
|
+
return this.#applyRemote(op, toUpdateSource(source));
|
|
9788
9888
|
}
|
|
9789
9889
|
/**
|
|
9790
9890
|
* Inserts text at the given index.
|
|
@@ -9800,7 +9900,7 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
9800
9900
|
* text.insert(0, "Say: ", { italic: true });
|
|
9801
9901
|
*/
|
|
9802
9902
|
insert(index, text, attributes) {
|
|
9803
|
-
const clippedIndex =
|
|
9903
|
+
const clippedIndex = clipIndexToCodePointBoundary(this.toString(), index);
|
|
9804
9904
|
this.#dispatch([{ type: "insert", index: clippedIndex, text, attributes }]);
|
|
9805
9905
|
}
|
|
9806
9906
|
/**
|
|
@@ -9811,7 +9911,11 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
9811
9911
|
* text.delete(5, 6); // "Hello"
|
|
9812
9912
|
*/
|
|
9813
9913
|
delete(index, length) {
|
|
9814
|
-
const clipped =
|
|
9914
|
+
const clipped = clipRangeToCodePointBoundaries(
|
|
9915
|
+
this.toString(),
|
|
9916
|
+
index,
|
|
9917
|
+
length
|
|
9918
|
+
);
|
|
9815
9919
|
if (clipped.length === 0) {
|
|
9816
9920
|
return;
|
|
9817
9921
|
}
|
|
@@ -9827,7 +9931,11 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
9827
9931
|
* text.replace(0, 5, "Hi"); // "Hi world"
|
|
9828
9932
|
*/
|
|
9829
9933
|
replace(index, length, text, attributes) {
|
|
9830
|
-
const clipped =
|
|
9934
|
+
const clipped = clipRangeToCodePointBoundaries(
|
|
9935
|
+
this.toString(),
|
|
9936
|
+
index,
|
|
9937
|
+
length
|
|
9938
|
+
);
|
|
9831
9939
|
const ops = [];
|
|
9832
9940
|
if (clipped.length > 0) {
|
|
9833
9941
|
ops.push({
|
|
@@ -9920,7 +10028,11 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
9920
10028
|
* text.format(0, 5, { bold: null });
|
|
9921
10029
|
*/
|
|
9922
10030
|
format(index, length, attributes) {
|
|
9923
|
-
const clipped =
|
|
10031
|
+
const clipped = clipRangeToCodePointBoundaries(
|
|
10032
|
+
this.toString(),
|
|
10033
|
+
index,
|
|
10034
|
+
length
|
|
10035
|
+
);
|
|
9924
10036
|
if (clipped.length === 0) {
|
|
9925
10037
|
return;
|
|
9926
10038
|
}
|
|
@@ -9954,7 +10066,8 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
9954
10066
|
type: "LiveText",
|
|
9955
10067
|
node: this,
|
|
9956
10068
|
version: this.#version,
|
|
9957
|
-
updates: changes
|
|
10069
|
+
updates: changes,
|
|
10070
|
+
source: LOCAL_EDIT
|
|
9958
10071
|
}
|
|
9959
10072
|
]
|
|
9960
10073
|
]);
|
|
@@ -9984,7 +10097,7 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
9984
10097
|
* A local replay of an existing wire op: an undo/redo frame, or an
|
|
9985
10098
|
* unacknowledged op re-sent after a reconnect.
|
|
9986
10099
|
*/
|
|
9987
|
-
#applyLocal(op) {
|
|
10100
|
+
#applyLocal(op, source) {
|
|
9988
10101
|
const mutableOp = op;
|
|
9989
10102
|
if (op.opId !== void 0 && op.opId === this.#inFlightOpId) {
|
|
9990
10103
|
this.#inFlightOps = [...this.#inFlightOps, ...this.#queuedOps];
|
|
@@ -10020,12 +10133,13 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
10020
10133
|
type: "LiveText",
|
|
10021
10134
|
node: this,
|
|
10022
10135
|
version: this.#version,
|
|
10023
|
-
updates: changes
|
|
10136
|
+
updates: changes,
|
|
10137
|
+
source
|
|
10024
10138
|
}
|
|
10025
10139
|
};
|
|
10026
10140
|
}
|
|
10027
10141
|
/** Server acknowledgement of our in-flight op. */
|
|
10028
|
-
#applyAck(op) {
|
|
10142
|
+
#applyAck(op, source) {
|
|
10029
10143
|
const ackedVersion = _nullishCoalesce(op.version, () => ( Math.max(this.#version, op.baseVersion + 1)));
|
|
10030
10144
|
const predicted = this.#inFlightOps;
|
|
10031
10145
|
const opId = this.#inFlightOpId;
|
|
@@ -10047,7 +10161,8 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
10047
10161
|
type: "LiveText",
|
|
10048
10162
|
node: this,
|
|
10049
10163
|
version: ackedVersion,
|
|
10050
|
-
updates: rebuilt.changes
|
|
10164
|
+
updates: rebuilt.changes,
|
|
10165
|
+
source
|
|
10051
10166
|
}
|
|
10052
10167
|
};
|
|
10053
10168
|
}
|
|
@@ -10058,7 +10173,7 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
10058
10173
|
return result;
|
|
10059
10174
|
}
|
|
10060
10175
|
/** An accepted op from another client (or a server-fabricated fix op). */
|
|
10061
|
-
#applyRemote(op) {
|
|
10176
|
+
#applyRemote(op, source) {
|
|
10062
10177
|
const version = _nullishCoalesce(op.version, () => ( this.#version + 1));
|
|
10063
10178
|
this.#confirmed = applyTextOperationsToSegments(this.#confirmed, op.ops);
|
|
10064
10179
|
const [overInFlight, inFlight] = transformTextOperationsX(
|
|
@@ -10087,7 +10202,8 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
10087
10202
|
type: "LiveText",
|
|
10088
10203
|
node: this,
|
|
10089
10204
|
version: this.#version,
|
|
10090
|
-
updates: changes
|
|
10205
|
+
updates: changes,
|
|
10206
|
+
source
|
|
10091
10207
|
}
|
|
10092
10208
|
};
|
|
10093
10209
|
}
|
|
@@ -10171,7 +10287,7 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
10171
10287
|
*
|
|
10172
10288
|
* @internal
|
|
10173
10289
|
*/
|
|
10174
|
-
_resyncText(data, version) {
|
|
10290
|
+
_resyncText(data, version, source) {
|
|
10175
10291
|
this.#confirmed = dataToSegments(data);
|
|
10176
10292
|
this.#version = version;
|
|
10177
10293
|
this.#acceptedOps = [];
|
|
@@ -10183,7 +10299,8 @@ var LiveText = class _LiveText extends AbstractCrdt {
|
|
|
10183
10299
|
type: "LiveText",
|
|
10184
10300
|
node: this,
|
|
10185
10301
|
version: this.#version,
|
|
10186
|
-
updates: rebuilt.changes
|
|
10302
|
+
updates: rebuilt.changes,
|
|
10303
|
+
source
|
|
10187
10304
|
};
|
|
10188
10305
|
}
|
|
10189
10306
|
/**
|
|
@@ -10697,37 +10814,30 @@ function mergeTextStorageUpdates(first, second) {
|
|
|
10697
10814
|
updates: first.updates.concat(second.updates)
|
|
10698
10815
|
};
|
|
10699
10816
|
}
|
|
10817
|
+
function mergeUpdateSources(first, second) {
|
|
10818
|
+
if (first.origin === "remote" || second.origin === "remote") {
|
|
10819
|
+
return REMOTE;
|
|
10820
|
+
}
|
|
10821
|
+
if (second.via !== "edit") return second;
|
|
10822
|
+
if (first.via !== "edit") return first;
|
|
10823
|
+
return LOCAL_EDIT;
|
|
10824
|
+
}
|
|
10700
10825
|
function mergeStorageUpdates(first, second) {
|
|
10701
10826
|
if (first === void 0) {
|
|
10702
10827
|
return second;
|
|
10703
10828
|
}
|
|
10704
|
-
|
|
10829
|
+
const source = mergeUpdateSources(first.source, second.source);
|
|
10705
10830
|
if (first.type === "LiveObject" && second.type === "LiveObject") {
|
|
10706
|
-
|
|
10831
|
+
return { ...mergeObjectStorageUpdates(first, second), source };
|
|
10707
10832
|
} else if (first.type === "LiveMap" && second.type === "LiveMap") {
|
|
10708
|
-
|
|
10833
|
+
return { ...mergeMapStorageUpdates(first, second), source };
|
|
10709
10834
|
} else if (first.type === "LiveList" && second.type === "LiveList") {
|
|
10710
|
-
|
|
10835
|
+
return { ...mergeListStorageUpdates(first, second), source };
|
|
10711
10836
|
} else if (first.type === "LiveText" && second.type === "LiveText") {
|
|
10712
|
-
|
|
10837
|
+
return { ...mergeTextStorageUpdates(first, second), source };
|
|
10713
10838
|
} else {
|
|
10714
|
-
|
|
10715
|
-
}
|
|
10716
|
-
const sa = first[kStorageUpdateSource];
|
|
10717
|
-
const sb = second[kStorageUpdateSource];
|
|
10718
|
-
if (sa !== void 0 || sb !== void 0) {
|
|
10719
|
-
if (_optionalChain([sa, 'optionalAccess', _245 => _245.origin]) === "remote" || _optionalChain([sb, 'optionalAccess', _246 => _246.origin]) === "remote") {
|
|
10720
|
-
merged[kStorageUpdateSource] = { origin: "remote" };
|
|
10721
|
-
} else if (_optionalChain([sa, 'optionalAccess', _247 => _247.via]) === "history" || _optionalChain([sb, 'optionalAccess', _248 => _248.via]) === "history") {
|
|
10722
|
-
const historySource = _optionalChain([sb, 'optionalAccess', _249 => _249.via]) === "history" ? sb : _optionalChain([sa, 'optionalAccess', _250 => _250.via]) === "history" ? sa : void 0;
|
|
10723
|
-
if (_optionalChain([historySource, 'optionalAccess', _251 => _251.via]) === "history") {
|
|
10724
|
-
merged[kStorageUpdateSource] = historySource;
|
|
10725
|
-
}
|
|
10726
|
-
} else {
|
|
10727
|
-
merged[kStorageUpdateSource] = { origin: "local", via: "mutation" };
|
|
10728
|
-
}
|
|
10839
|
+
return { ...second, source };
|
|
10729
10840
|
}
|
|
10730
|
-
return merged;
|
|
10731
10841
|
}
|
|
10732
10842
|
|
|
10733
10843
|
// src/devtools/bridge.ts
|
|
@@ -10743,7 +10853,7 @@ function sendToPanel(message, options) {
|
|
|
10743
10853
|
...message,
|
|
10744
10854
|
source: "liveblocks-devtools-client"
|
|
10745
10855
|
};
|
|
10746
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
10856
|
+
if (!(_optionalChain([options, 'optionalAccess', _245 => _245.force]) || _bridgeActive)) {
|
|
10747
10857
|
return;
|
|
10748
10858
|
}
|
|
10749
10859
|
window.postMessage(fullMsg, "*");
|
|
@@ -10751,7 +10861,7 @@ function sendToPanel(message, options) {
|
|
|
10751
10861
|
var eventSource = makeEventSource();
|
|
10752
10862
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
10753
10863
|
window.addEventListener("message", (event) => {
|
|
10754
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
10864
|
+
if (event.source === window && _optionalChain([event, 'access', _246 => _246.data, 'optionalAccess', _247 => _247.source]) === "liveblocks-devtools-panel") {
|
|
10755
10865
|
eventSource.notify(event.data);
|
|
10756
10866
|
} else {
|
|
10757
10867
|
}
|
|
@@ -10893,7 +11003,7 @@ function fullSync(room) {
|
|
|
10893
11003
|
msg: "room::sync::full",
|
|
10894
11004
|
roomId: room.id,
|
|
10895
11005
|
status: room.getStatus(),
|
|
10896
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
11006
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _248 => _248.toTreeNode, 'call', _249 => _249("root"), 'access', _250 => _250.payload]), () => ( null)),
|
|
10897
11007
|
me,
|
|
10898
11008
|
others
|
|
10899
11009
|
});
|
|
@@ -11580,15 +11690,15 @@ function installBackgroundTabSpy() {
|
|
|
11580
11690
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
11581
11691
|
const inBackgroundSince = { current: null };
|
|
11582
11692
|
function onVisibilityChange() {
|
|
11583
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
11693
|
+
if (_optionalChain([doc, 'optionalAccess', _251 => _251.visibilityState]) === "hidden") {
|
|
11584
11694
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
11585
11695
|
} else {
|
|
11586
11696
|
inBackgroundSince.current = null;
|
|
11587
11697
|
}
|
|
11588
11698
|
}
|
|
11589
|
-
_optionalChain([doc, 'optionalAccess',
|
|
11699
|
+
_optionalChain([doc, 'optionalAccess', _252 => _252.addEventListener, 'call', _253 => _253("visibilitychange", onVisibilityChange)]);
|
|
11590
11700
|
const unsub = () => {
|
|
11591
|
-
_optionalChain([doc, 'optionalAccess',
|
|
11701
|
+
_optionalChain([doc, 'optionalAccess', _254 => _254.removeEventListener, 'call', _255 => _255("visibilitychange", onVisibilityChange)]);
|
|
11592
11702
|
};
|
|
11593
11703
|
return [inBackgroundSince, unsub];
|
|
11594
11704
|
}
|
|
@@ -11612,7 +11722,7 @@ function makeNodeMapBuffer() {
|
|
|
11612
11722
|
function topLevelKeysOf(nodes) {
|
|
11613
11723
|
const keys2 = /* @__PURE__ */ new Set();
|
|
11614
11724
|
const root = nodes.get("root");
|
|
11615
|
-
for (const key in _optionalChain([root, 'optionalAccess',
|
|
11725
|
+
for (const key in _optionalChain([root, 'optionalAccess', _256 => _256.data])) {
|
|
11616
11726
|
keys2.add(key);
|
|
11617
11727
|
}
|
|
11618
11728
|
for (const node of nodes.values()) {
|
|
@@ -11771,9 +11881,6 @@ function createRoom(options, config) {
|
|
|
11771
11881
|
}
|
|
11772
11882
|
});
|
|
11773
11883
|
function onDispatch(ops, reverse, storageUpdates, options2) {
|
|
11774
|
-
for (const value of storageUpdates.values()) {
|
|
11775
|
-
value[kStorageUpdateSource] = { origin: "local", via: "mutation" };
|
|
11776
|
-
}
|
|
11777
11884
|
if (context.activeBatch) {
|
|
11778
11885
|
for (const op of ops) {
|
|
11779
11886
|
context.activeBatch.ops.push(op);
|
|
@@ -11788,14 +11895,14 @@ function createRoom(options, config) {
|
|
|
11788
11895
|
);
|
|
11789
11896
|
}
|
|
11790
11897
|
context.activeBatch.reverseOps.pushLeft(reverse);
|
|
11791
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
11898
|
+
if (_optionalChain([options2, 'optionalAccess', _257 => _257.clearRedoStack])) {
|
|
11792
11899
|
context.activeBatch.clearRedoStack = true;
|
|
11793
11900
|
}
|
|
11794
11901
|
} else {
|
|
11795
11902
|
if (reverse.length > 0) {
|
|
11796
11903
|
addToUndoStack(reverse);
|
|
11797
11904
|
}
|
|
11798
|
-
if (_nullishCoalesce(_optionalChain([options2, 'optionalAccess',
|
|
11905
|
+
if (_nullishCoalesce(_optionalChain([options2, 'optionalAccess', _258 => _258.clearRedoStack]), () => ( ops.length > 0))) {
|
|
11799
11906
|
clearRedoStack();
|
|
11800
11907
|
}
|
|
11801
11908
|
if (ops.length > 0) {
|
|
@@ -11805,7 +11912,7 @@ function createRoom(options, config) {
|
|
|
11805
11912
|
}
|
|
11806
11913
|
}
|
|
11807
11914
|
function isStorageWritable() {
|
|
11808
|
-
const permissionMatrix = _optionalChain([context, 'access',
|
|
11915
|
+
const permissionMatrix = _optionalChain([context, 'access', _259 => _259.dynamicSessionInfoSig, 'access', _260 => _260.get, 'call', _261 => _261(), 'optionalAccess', _262 => _262.permissionMatrix]);
|
|
11809
11916
|
return permissionMatrix !== void 0 ? hasPermissionAccess(permissionMatrix, "storage", "write") : true;
|
|
11810
11917
|
}
|
|
11811
11918
|
const eventHub = {
|
|
@@ -11923,7 +12030,7 @@ function createRoom(options, config) {
|
|
|
11923
12030
|
if (crdt.type === CrdtType.TEXT) {
|
|
11924
12031
|
const node = context.pool.nodes.get(id);
|
|
11925
12032
|
if (node !== void 0 && isLiveText(node)) {
|
|
11926
|
-
const update = node._resyncText(crdt.data, crdt.version);
|
|
12033
|
+
const update = node._resyncText(crdt.data, crdt.version, REMOTE);
|
|
11927
12034
|
if (update !== void 0) {
|
|
11928
12035
|
result.updates.storageUpdates.set(
|
|
11929
12036
|
id,
|
|
@@ -11943,7 +12050,7 @@ function createRoom(options, config) {
|
|
|
11943
12050
|
context.pool
|
|
11944
12051
|
);
|
|
11945
12052
|
}
|
|
11946
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
12053
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _263 => _263.get, 'call', _264 => _264(), 'optionalAccess', _265 => _265.canWrite]), () => ( true));
|
|
11947
12054
|
const serverTopLevelKeys = topLevelKeysOf(nodes);
|
|
11948
12055
|
const root = context.root;
|
|
11949
12056
|
disableHistory(() => {
|
|
@@ -12026,7 +12133,10 @@ function createRoom(options, config) {
|
|
|
12026
12133
|
eventHub.myPresence.notify(context.myPresence.get());
|
|
12027
12134
|
}
|
|
12028
12135
|
if (storageUpdates !== void 0 && storageUpdates.size > 0) {
|
|
12029
|
-
const updates2 = Array.from(storageUpdates.values())
|
|
12136
|
+
const updates2 = Array.from(storageUpdates.values(), (update) => ({
|
|
12137
|
+
...update,
|
|
12138
|
+
source: toUpdateSource(update.source)
|
|
12139
|
+
}));
|
|
12030
12140
|
eventHub.storageBatch.notify(updates2);
|
|
12031
12141
|
}
|
|
12032
12142
|
notifyStorageStatus();
|
|
@@ -12040,7 +12150,16 @@ function createRoom(options, config) {
|
|
|
12040
12150
|
"Internal. Tried to get connection id but connection was never open"
|
|
12041
12151
|
);
|
|
12042
12152
|
}
|
|
12043
|
-
|
|
12153
|
+
const viaByOpId = /* @__PURE__ */ new Map();
|
|
12154
|
+
function viaOfAckedOp(opId) {
|
|
12155
|
+
const via = viaByOpId.get(opId);
|
|
12156
|
+
if (via === void 0) {
|
|
12157
|
+
return "edit";
|
|
12158
|
+
}
|
|
12159
|
+
viaByOpId.delete(opId);
|
|
12160
|
+
return via;
|
|
12161
|
+
}
|
|
12162
|
+
function applyLocalOps(frames, localSource = LOCAL_EDIT) {
|
|
12044
12163
|
const [pframes, ops] = partition(
|
|
12045
12164
|
frames,
|
|
12046
12165
|
(f) => f.type === "presence"
|
|
@@ -12083,12 +12202,17 @@ function createRoom(options, config) {
|
|
|
12083
12202
|
const opsWithOpIds = remappedOps.map(
|
|
12084
12203
|
(op) => op.opId === void 0 ? { ...op, opId: context.pool.generateOpId() } : op
|
|
12085
12204
|
);
|
|
12205
|
+
if (localSource.via !== "edit") {
|
|
12206
|
+
for (const op of opsWithOpIds) {
|
|
12207
|
+
viaByOpId.set(op.opId, localSource.via);
|
|
12208
|
+
}
|
|
12209
|
+
}
|
|
12086
12210
|
const { reverse, updates } = applyOps(
|
|
12087
12211
|
pframes,
|
|
12088
12212
|
opsWithOpIds,
|
|
12089
12213
|
/* isLocal */
|
|
12090
12214
|
true,
|
|
12091
|
-
|
|
12215
|
+
localSource
|
|
12092
12216
|
);
|
|
12093
12217
|
return { opsToEmit: opsWithOpIds, reverse, updates };
|
|
12094
12218
|
}
|
|
@@ -12100,7 +12224,7 @@ function createRoom(options, config) {
|
|
|
12100
12224
|
false
|
|
12101
12225
|
);
|
|
12102
12226
|
}
|
|
12103
|
-
function applyOps(pframes, ops, isLocal,
|
|
12227
|
+
function applyOps(pframes, ops, isLocal, localSource = LOCAL_EDIT) {
|
|
12104
12228
|
const output = {
|
|
12105
12229
|
reverse: new Deque(),
|
|
12106
12230
|
storageUpdates: /* @__PURE__ */ new Map(),
|
|
@@ -12129,16 +12253,19 @@ function createRoom(options, config) {
|
|
|
12129
12253
|
for (const op of ops) {
|
|
12130
12254
|
let source;
|
|
12131
12255
|
if (isLocal) {
|
|
12132
|
-
source =
|
|
12256
|
+
source = { ...localSource, optimistic: true };
|
|
12133
12257
|
} else if (op.opId !== void 0) {
|
|
12134
12258
|
context.unacknowledgedOps.delete(op.opId);
|
|
12135
|
-
source =
|
|
12259
|
+
source = {
|
|
12260
|
+
origin: "local",
|
|
12261
|
+
via: viaOfAckedOp(op.opId),
|
|
12262
|
+
optimistic: false
|
|
12263
|
+
};
|
|
12136
12264
|
} else {
|
|
12137
|
-
source =
|
|
12265
|
+
source = REMOTE;
|
|
12138
12266
|
}
|
|
12139
12267
|
const applyOpResult = applyOp(op, source);
|
|
12140
12268
|
if (applyOpResult.modified) {
|
|
12141
|
-
applyOpResult.modified[kStorageUpdateSource] = source === 1 /* THEIRS */ ? { origin: "remote" } : localStorageUpdateSource;
|
|
12142
12269
|
const nodeId = applyOpResult.modified.node._id;
|
|
12143
12270
|
if (!(nodeId && createdNodeIds.has(nodeId))) {
|
|
12144
12271
|
output.storageUpdates.set(
|
|
@@ -12176,7 +12303,7 @@ function createRoom(options, config) {
|
|
|
12176
12303
|
if (node === void 0) {
|
|
12177
12304
|
return { modified: false };
|
|
12178
12305
|
}
|
|
12179
|
-
return node._apply(op, source
|
|
12306
|
+
return node._apply(op, source);
|
|
12180
12307
|
}
|
|
12181
12308
|
case OpCode.SET_PARENT_KEY: {
|
|
12182
12309
|
const node = context.pool.nodes.get(op.id);
|
|
@@ -12231,7 +12358,7 @@ function createRoom(options, config) {
|
|
|
12231
12358
|
}
|
|
12232
12359
|
context.myPresence.patch(patch);
|
|
12233
12360
|
if (context.activeBatch) {
|
|
12234
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
12361
|
+
if (_optionalChain([options2, 'optionalAccess', _266 => _266.addToHistory])) {
|
|
12235
12362
|
context.activeBatch.reverseOps.pushLeft({
|
|
12236
12363
|
type: "presence",
|
|
12237
12364
|
data: oldValues
|
|
@@ -12240,7 +12367,7 @@ function createRoom(options, config) {
|
|
|
12240
12367
|
context.activeBatch.updates.presence = true;
|
|
12241
12368
|
} else {
|
|
12242
12369
|
flushNowOrSoon();
|
|
12243
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
12370
|
+
if (_optionalChain([options2, 'optionalAccess', _267 => _267.addToHistory])) {
|
|
12244
12371
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
12245
12372
|
}
|
|
12246
12373
|
notify({ presence: true });
|
|
@@ -12419,11 +12546,11 @@ function createRoom(options, config) {
|
|
|
12419
12546
|
break;
|
|
12420
12547
|
}
|
|
12421
12548
|
case ServerMsgCode.STORAGE_CHUNK:
|
|
12422
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
12549
|
+
_optionalChain([stopwatch, 'optionalAccess', _268 => _268.lap, 'call', _269 => _269()]);
|
|
12423
12550
|
nodeMapBuffer.append(compactNodesToNodeStream(message.nodes));
|
|
12424
12551
|
break;
|
|
12425
12552
|
case ServerMsgCode.STORAGE_STREAM_END: {
|
|
12426
|
-
const timing = _optionalChain([stopwatch, 'optionalAccess',
|
|
12553
|
+
const timing = _optionalChain([stopwatch, 'optionalAccess', _270 => _270.stop, 'call', _271 => _271()]);
|
|
12427
12554
|
if (timing) {
|
|
12428
12555
|
const ms = (v) => `${v.toFixed(1)}ms`;
|
|
12429
12556
|
const rest = timing.laps.slice(1);
|
|
@@ -12469,6 +12596,7 @@ function createRoom(options, config) {
|
|
|
12469
12596
|
const rejectedOp = context.unacknowledgedOps.get(opId);
|
|
12470
12597
|
context.unacknowledgedOps.delete(opId);
|
|
12471
12598
|
context.buffer.storageOperations = context.buffer.storageOperations.filter((op) => op.opId !== opId);
|
|
12599
|
+
viaByOpId.delete(opId);
|
|
12472
12600
|
if (rejectedOp !== void 0 && rejectedOp.type === OpCode.UPDATE_TEXT) {
|
|
12473
12601
|
const node = context.pool.nodes.get(rejectedOp.id);
|
|
12474
12602
|
if (node !== void 0 && isLiveText(node)) {
|
|
@@ -12579,11 +12707,11 @@ function createRoom(options, config) {
|
|
|
12579
12707
|
} else if (pendingFeedsRequests.has(requestId)) {
|
|
12580
12708
|
const pending = pendingFeedsRequests.get(requestId);
|
|
12581
12709
|
pendingFeedsRequests.delete(requestId);
|
|
12582
|
-
_optionalChain([pending, 'optionalAccess',
|
|
12710
|
+
_optionalChain([pending, 'optionalAccess', _272 => _272.reject, 'call', _273 => _273(err)]);
|
|
12583
12711
|
} else if (pendingFeedMessagesRequests.has(requestId)) {
|
|
12584
12712
|
const pending = pendingFeedMessagesRequests.get(requestId);
|
|
12585
12713
|
pendingFeedMessagesRequests.delete(requestId);
|
|
12586
|
-
_optionalChain([pending, 'optionalAccess',
|
|
12714
|
+
_optionalChain([pending, 'optionalAccess', _274 => _274.reject, 'call', _275 => _275(err)]);
|
|
12587
12715
|
}
|
|
12588
12716
|
eventHub.feeds.notify(message);
|
|
12589
12717
|
break;
|
|
@@ -12737,10 +12865,10 @@ function createRoom(options, config) {
|
|
|
12737
12865
|
timeoutId,
|
|
12738
12866
|
kind,
|
|
12739
12867
|
feedId,
|
|
12740
|
-
messageId: _optionalChain([options2, 'optionalAccess',
|
|
12741
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
12868
|
+
messageId: _optionalChain([options2, 'optionalAccess', _276 => _276.messageId]),
|
|
12869
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _277 => _277.expectedClientMessageId])
|
|
12742
12870
|
});
|
|
12743
|
-
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess',
|
|
12871
|
+
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess', _278 => _278.expectedClientMessageId]) === void 0) {
|
|
12744
12872
|
const q = _nullishCoalesce(pendingAddMessageFifoByFeed.get(feedId), () => ( []));
|
|
12745
12873
|
q.push(requestId);
|
|
12746
12874
|
pendingAddMessageFifoByFeed.set(feedId, q);
|
|
@@ -12791,10 +12919,10 @@ function createRoom(options, config) {
|
|
|
12791
12919
|
}
|
|
12792
12920
|
if (!matched) {
|
|
12793
12921
|
const q = pendingAddMessageFifoByFeed.get(message.feedId);
|
|
12794
|
-
const headId = _optionalChain([q, 'optionalAccess',
|
|
12922
|
+
const headId = _optionalChain([q, 'optionalAccess', _279 => _279[0]]);
|
|
12795
12923
|
if (headId !== void 0) {
|
|
12796
12924
|
const pending = pendingFeedMutations.get(headId);
|
|
12797
|
-
if (_optionalChain([pending, 'optionalAccess',
|
|
12925
|
+
if (_optionalChain([pending, 'optionalAccess', _280 => _280.kind]) === "add-message" && pending.expectedClientMessageId === void 0) {
|
|
12798
12926
|
settleFeedMutation(headId, "ok");
|
|
12799
12927
|
}
|
|
12800
12928
|
}
|
|
@@ -12830,7 +12958,7 @@ function createRoom(options, config) {
|
|
|
12830
12958
|
const unacknowledgedOps2 = [...context.unacknowledgedOps.values()];
|
|
12831
12959
|
createOrUpdateRootFromMessage(nodes);
|
|
12832
12960
|
applyAndSendOfflineOps(unacknowledgedOps2);
|
|
12833
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
12961
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _281 => _281()]);
|
|
12834
12962
|
notifyStorageStatus();
|
|
12835
12963
|
eventHub.storageDidLoad.notify();
|
|
12836
12964
|
}
|
|
@@ -12839,7 +12967,7 @@ function createRoom(options, config) {
|
|
|
12839
12967
|
if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
12840
12968
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
12841
12969
|
nodeMapBuffer.take();
|
|
12842
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
12970
|
+
_optionalChain([stopwatch, 'optionalAccess', _282 => _282.start, 'call', _283 => _283()]);
|
|
12843
12971
|
}
|
|
12844
12972
|
}
|
|
12845
12973
|
function startLoadingStorage() {
|
|
@@ -12893,10 +13021,10 @@ function createRoom(options, config) {
|
|
|
12893
13021
|
const message = {
|
|
12894
13022
|
type: ClientMsgCode.FETCH_FEEDS,
|
|
12895
13023
|
requestId,
|
|
12896
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
12897
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
12898
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
12899
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
13024
|
+
cursor: _optionalChain([options2, 'optionalAccess', _284 => _284.cursor]),
|
|
13025
|
+
since: _optionalChain([options2, 'optionalAccess', _285 => _285.since]),
|
|
13026
|
+
limit: _optionalChain([options2, 'optionalAccess', _286 => _286.limit]),
|
|
13027
|
+
metadata: _optionalChain([options2, 'optionalAccess', _287 => _287.metadata])
|
|
12900
13028
|
};
|
|
12901
13029
|
context.buffer.messages.push(message);
|
|
12902
13030
|
flushNowOrSoon();
|
|
@@ -12916,9 +13044,9 @@ function createRoom(options, config) {
|
|
|
12916
13044
|
type: ClientMsgCode.FETCH_FEED_MESSAGES,
|
|
12917
13045
|
requestId,
|
|
12918
13046
|
feedId,
|
|
12919
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
12920
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
12921
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
13047
|
+
cursor: _optionalChain([options2, 'optionalAccess', _288 => _288.cursor]),
|
|
13048
|
+
since: _optionalChain([options2, 'optionalAccess', _289 => _289.since]),
|
|
13049
|
+
limit: _optionalChain([options2, 'optionalAccess', _290 => _290.limit])
|
|
12922
13050
|
};
|
|
12923
13051
|
context.buffer.messages.push(message);
|
|
12924
13052
|
flushNowOrSoon();
|
|
@@ -12937,8 +13065,8 @@ function createRoom(options, config) {
|
|
|
12937
13065
|
type: ClientMsgCode.ADD_FEED,
|
|
12938
13066
|
requestId,
|
|
12939
13067
|
feedId,
|
|
12940
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
12941
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
13068
|
+
metadata: _optionalChain([options2, 'optionalAccess', _291 => _291.metadata]),
|
|
13069
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _292 => _292.createdAt])
|
|
12942
13070
|
};
|
|
12943
13071
|
context.buffer.messages.push(message);
|
|
12944
13072
|
flushNowOrSoon();
|
|
@@ -12972,15 +13100,15 @@ function createRoom(options, config) {
|
|
|
12972
13100
|
function addFeedMessage(feedId, data, options2) {
|
|
12973
13101
|
const requestId = nanoid();
|
|
12974
13102
|
const promise = registerFeedMutation(requestId, "add-message", feedId, {
|
|
12975
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
13103
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _293 => _293.id])
|
|
12976
13104
|
});
|
|
12977
13105
|
const message = {
|
|
12978
13106
|
type: ClientMsgCode.ADD_FEED_MESSAGE,
|
|
12979
13107
|
requestId,
|
|
12980
13108
|
feedId,
|
|
12981
13109
|
data,
|
|
12982
|
-
id: _optionalChain([options2, 'optionalAccess',
|
|
12983
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
13110
|
+
id: _optionalChain([options2, 'optionalAccess', _294 => _294.id]),
|
|
13111
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _295 => _295.createdAt])
|
|
12984
13112
|
};
|
|
12985
13113
|
context.buffer.messages.push(message);
|
|
12986
13114
|
flushNowOrSoon();
|
|
@@ -12997,7 +13125,7 @@ function createRoom(options, config) {
|
|
|
12997
13125
|
feedId,
|
|
12998
13126
|
messageId,
|
|
12999
13127
|
data,
|
|
13000
|
-
updatedAt: _optionalChain([options2, 'optionalAccess',
|
|
13128
|
+
updatedAt: _optionalChain([options2, 'optionalAccess', _296 => _296.updatedAt])
|
|
13001
13129
|
};
|
|
13002
13130
|
context.buffer.messages.push(message);
|
|
13003
13131
|
flushNowOrSoon();
|
|
@@ -13027,11 +13155,7 @@ function createRoom(options, config) {
|
|
|
13027
13155
|
return;
|
|
13028
13156
|
}
|
|
13029
13157
|
context.pausedHistory = null;
|
|
13030
|
-
const result = applyLocalOps(item.frames,
|
|
13031
|
-
origin: "local",
|
|
13032
|
-
via: "history",
|
|
13033
|
-
action: "undo"
|
|
13034
|
-
});
|
|
13158
|
+
const result = applyLocalOps(item.frames, LOCAL_UNDO);
|
|
13035
13159
|
context.redoStack.push({ id: item.id, frames: result.reverse });
|
|
13036
13160
|
notifyPrivateHistory({ action: "undo", id: item.id });
|
|
13037
13161
|
notify(result.updates);
|
|
@@ -13050,11 +13174,7 @@ function createRoom(options, config) {
|
|
|
13050
13174
|
return;
|
|
13051
13175
|
}
|
|
13052
13176
|
context.pausedHistory = null;
|
|
13053
|
-
const result = applyLocalOps(item.frames,
|
|
13054
|
-
origin: "local",
|
|
13055
|
-
via: "history",
|
|
13056
|
-
action: "redo"
|
|
13057
|
-
});
|
|
13177
|
+
const result = applyLocalOps(item.frames, LOCAL_REDO);
|
|
13058
13178
|
context.undoStack.push({ id: item.id, frames: result.reverse });
|
|
13059
13179
|
notifyPrivateHistory({ action: "redo", id: item.id });
|
|
13060
13180
|
notify(result.updates);
|
|
@@ -13215,8 +13335,8 @@ function createRoom(options, config) {
|
|
|
13215
13335
|
async function getThreads(options2) {
|
|
13216
13336
|
return httpClient.getThreads({
|
|
13217
13337
|
roomId,
|
|
13218
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
13219
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
13338
|
+
query: _optionalChain([options2, 'optionalAccess', _297 => _297.query]),
|
|
13339
|
+
cursor: _optionalChain([options2, 'optionalAccess', _298 => _298.cursor])
|
|
13220
13340
|
});
|
|
13221
13341
|
}
|
|
13222
13342
|
async function getThread(threadId) {
|
|
@@ -13349,7 +13469,7 @@ function createRoom(options, config) {
|
|
|
13349
13469
|
function getSubscriptionSettings(options2) {
|
|
13350
13470
|
return httpClient.getSubscriptionSettings({
|
|
13351
13471
|
roomId,
|
|
13352
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
13472
|
+
signal: _optionalChain([options2, 'optionalAccess', _299 => _299.signal])
|
|
13353
13473
|
});
|
|
13354
13474
|
}
|
|
13355
13475
|
function updateSubscriptionSettings(settings) {
|
|
@@ -13371,7 +13491,7 @@ function createRoom(options, config) {
|
|
|
13371
13491
|
{
|
|
13372
13492
|
[kInternal]: {
|
|
13373
13493
|
get presenceBuffer() {
|
|
13374
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
13494
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _300 => _300.buffer, 'access', _301 => _301.presenceUpdates, 'optionalAccess', _302 => _302.data]), () => ( null)));
|
|
13375
13495
|
},
|
|
13376
13496
|
// prettier-ignore
|
|
13377
13497
|
get undoStack() {
|
|
@@ -13401,15 +13521,15 @@ function createRoom(options, config) {
|
|
|
13401
13521
|
return context.yjsProvider;
|
|
13402
13522
|
},
|
|
13403
13523
|
setYjsProvider(newProvider) {
|
|
13404
|
-
_optionalChain([context, 'access',
|
|
13524
|
+
_optionalChain([context, 'access', _303 => _303.yjsProvider, 'optionalAccess', _304 => _304.off, 'call', _305 => _305("status", yjsStatusDidChange)]);
|
|
13405
13525
|
context.yjsProvider = newProvider;
|
|
13406
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
13526
|
+
_optionalChain([newProvider, 'optionalAccess', _306 => _306.on, 'call', _307 => _307("status", yjsStatusDidChange)]);
|
|
13407
13527
|
context.yjsProviderDidChange.notify();
|
|
13408
13528
|
},
|
|
13409
13529
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
13410
13530
|
// send metadata when using a text editor
|
|
13411
13531
|
reportTextEditor,
|
|
13412
|
-
getPermissionMatrix: () => _optionalChain([context, 'access',
|
|
13532
|
+
getPermissionMatrix: () => _optionalChain([context, 'access', _308 => _308.dynamicSessionInfoSig, 'access', _309 => _309.get, 'call', _310 => _310(), 'optionalAccess', _311 => _311.permissionMatrix]),
|
|
13413
13533
|
// create a text mention when using a text editor
|
|
13414
13534
|
createTextMention,
|
|
13415
13535
|
// delete a text mention when using a text editor
|
|
@@ -13472,7 +13592,7 @@ ${dumpPool(
|
|
|
13472
13592
|
source.dispose();
|
|
13473
13593
|
}
|
|
13474
13594
|
eventHub.roomWillDestroy.notify();
|
|
13475
|
-
_optionalChain([context, 'access',
|
|
13595
|
+
_optionalChain([context, 'access', _312 => _312.yjsProvider, 'optionalAccess', _313 => _313.off, 'call', _314 => _314("status", yjsStatusDidChange)]);
|
|
13476
13596
|
syncSourceForStorage.destroy();
|
|
13477
13597
|
syncSourceForYjs.destroy();
|
|
13478
13598
|
uninstallBgTabSpy();
|
|
@@ -13636,7 +13756,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
13636
13756
|
}
|
|
13637
13757
|
if (isLiveNode(first)) {
|
|
13638
13758
|
const node = first;
|
|
13639
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
13759
|
+
if (_optionalChain([options, 'optionalAccess', _315 => _315.isDeep])) {
|
|
13640
13760
|
const storageCallback = second;
|
|
13641
13761
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
13642
13762
|
} else {
|
|
@@ -13726,8 +13846,8 @@ function createClient(options) {
|
|
|
13726
13846
|
const authManager = createAuthManager(options, (token) => {
|
|
13727
13847
|
currentUserId.set(() => token.uid);
|
|
13728
13848
|
});
|
|
13729
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
13730
|
-
_optionalChain([globalThis, 'access',
|
|
13849
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _316 => _316.polyfills, 'optionalAccess', _317 => _317.fetch]) || /* istanbul ignore next */
|
|
13850
|
+
_optionalChain([globalThis, 'access', _318 => _318.fetch, 'optionalAccess', _319 => _319.bind, 'call', _320 => _320(globalThis)]);
|
|
13731
13851
|
const httpClient = createApiClient({
|
|
13732
13852
|
baseUrl,
|
|
13733
13853
|
fetchPolyfill,
|
|
@@ -13744,7 +13864,7 @@ function createClient(options) {
|
|
|
13744
13864
|
delegates: {
|
|
13745
13865
|
createSocket: makeCreateSocketDelegateForAi(
|
|
13746
13866
|
baseUrl,
|
|
13747
|
-
_optionalChain([clientOptions, 'access',
|
|
13867
|
+
_optionalChain([clientOptions, 'access', _321 => _321.polyfills, 'optionalAccess', _322 => _322.WebSocket])
|
|
13748
13868
|
),
|
|
13749
13869
|
authenticate: async () => {
|
|
13750
13870
|
const resp = await authManager.getAuthValue({
|
|
@@ -13815,7 +13935,7 @@ function createClient(options) {
|
|
|
13815
13935
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
13816
13936
|
roomId,
|
|
13817
13937
|
baseUrl,
|
|
13818
|
-
_optionalChain([clientOptions, 'access',
|
|
13938
|
+
_optionalChain([clientOptions, 'access', _323 => _323.polyfills, 'optionalAccess', _324 => _324.WebSocket])
|
|
13819
13939
|
),
|
|
13820
13940
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
13821
13941
|
})),
|
|
@@ -13837,7 +13957,7 @@ function createClient(options) {
|
|
|
13837
13957
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
13838
13958
|
if (shouldConnect) {
|
|
13839
13959
|
if (typeof atob === "undefined") {
|
|
13840
|
-
if (_optionalChain([clientOptions, 'access',
|
|
13960
|
+
if (_optionalChain([clientOptions, 'access', _325 => _325.polyfills, 'optionalAccess', _326 => _326.atob]) === void 0) {
|
|
13841
13961
|
throw new Error(
|
|
13842
13962
|
"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"
|
|
13843
13963
|
);
|
|
@@ -13849,7 +13969,7 @@ function createClient(options) {
|
|
|
13849
13969
|
return leaseRoom(newRoomDetails);
|
|
13850
13970
|
}
|
|
13851
13971
|
function getRoom(roomId) {
|
|
13852
|
-
const room = _optionalChain([roomsById, 'access',
|
|
13972
|
+
const room = _optionalChain([roomsById, 'access', _327 => _327.get, 'call', _328 => _328(roomId), 'optionalAccess', _329 => _329.room]);
|
|
13853
13973
|
return room ? room : null;
|
|
13854
13974
|
}
|
|
13855
13975
|
function logout() {
|
|
@@ -13865,7 +13985,7 @@ function createClient(options) {
|
|
|
13865
13985
|
const batchedResolveUsers = new Batch(
|
|
13866
13986
|
async (batchedUserIds) => {
|
|
13867
13987
|
const userIds = batchedUserIds.flat();
|
|
13868
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
13988
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _330 => _330({ userIds })]);
|
|
13869
13989
|
warnOnceIf(
|
|
13870
13990
|
!resolveUsers,
|
|
13871
13991
|
"Set the resolveUsers option in createClient to specify user info."
|
|
@@ -13882,7 +14002,7 @@ function createClient(options) {
|
|
|
13882
14002
|
const batchedResolveRoomsInfo = new Batch(
|
|
13883
14003
|
async (batchedRoomIds) => {
|
|
13884
14004
|
const roomIds = batchedRoomIds.flat();
|
|
13885
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
14005
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _331 => _331({ roomIds })]);
|
|
13886
14006
|
warnOnceIf(
|
|
13887
14007
|
!resolveRoomsInfo,
|
|
13888
14008
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
@@ -13899,7 +14019,7 @@ function createClient(options) {
|
|
|
13899
14019
|
const batchedResolveGroupsInfo = new Batch(
|
|
13900
14020
|
async (batchedGroupIds) => {
|
|
13901
14021
|
const groupIds = batchedGroupIds.flat();
|
|
13902
|
-
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall',
|
|
14022
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _332 => _332({ groupIds })]);
|
|
13903
14023
|
warnOnceIf(
|
|
13904
14024
|
!resolveGroupsInfo,
|
|
13905
14025
|
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
@@ -13958,7 +14078,7 @@ function createClient(options) {
|
|
|
13958
14078
|
}
|
|
13959
14079
|
};
|
|
13960
14080
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
13961
|
-
_optionalChain([win, 'optionalAccess',
|
|
14081
|
+
_optionalChain([win, 'optionalAccess', _333 => _333.addEventListener, 'call', _334 => _334("beforeunload", maybePreventClose)]);
|
|
13962
14082
|
}
|
|
13963
14083
|
async function getNotificationSettings(options2) {
|
|
13964
14084
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -14086,7 +14206,7 @@ var commentBodyElementsTypes = {
|
|
|
14086
14206
|
mention: "inline"
|
|
14087
14207
|
};
|
|
14088
14208
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
14089
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
14209
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _335 => _335.content])) {
|
|
14090
14210
|
return;
|
|
14091
14211
|
}
|
|
14092
14212
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -14096,13 +14216,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
14096
14216
|
for (const block of body.content) {
|
|
14097
14217
|
if (type === "all" || type === "block") {
|
|
14098
14218
|
if (guard(block)) {
|
|
14099
|
-
_optionalChain([visitor, 'optionalCall',
|
|
14219
|
+
_optionalChain([visitor, 'optionalCall', _336 => _336(block)]);
|
|
14100
14220
|
}
|
|
14101
14221
|
}
|
|
14102
14222
|
if (type === "all" || type === "inline") {
|
|
14103
14223
|
for (const inline of block.children) {
|
|
14104
14224
|
if (guard(inline)) {
|
|
14105
|
-
_optionalChain([visitor, 'optionalCall',
|
|
14225
|
+
_optionalChain([visitor, 'optionalCall', _337 => _337(inline)]);
|
|
14106
14226
|
}
|
|
14107
14227
|
}
|
|
14108
14228
|
}
|
|
@@ -14272,7 +14392,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
14272
14392
|
text: ({ element }) => element.text,
|
|
14273
14393
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
14274
14394
|
mention: ({ element, user, group }) => {
|
|
14275
|
-
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
14395
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _338 => _338.name]), () => ( _optionalChain([group, 'optionalAccess', _339 => _339.name]))), () => ( element.id))}`;
|
|
14276
14396
|
}
|
|
14277
14397
|
};
|
|
14278
14398
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -14302,7 +14422,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
14302
14422
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
14303
14423
|
},
|
|
14304
14424
|
mention: ({ element, user, group }) => {
|
|
14305
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
14425
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _340 => _340.name]) ? html`${_optionalChain([user, 'optionalAccess', _341 => _341.name])}` : _optionalChain([group, 'optionalAccess', _342 => _342.name]) ? html`${_optionalChain([group, 'optionalAccess', _343 => _343.name])}` : element.id}</span>`;
|
|
14306
14426
|
}
|
|
14307
14427
|
};
|
|
14308
14428
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -14332,20 +14452,20 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
14332
14452
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
14333
14453
|
},
|
|
14334
14454
|
mention: ({ element, user, group }) => {
|
|
14335
|
-
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
14455
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _344 => _344.name]), () => ( _optionalChain([group, 'optionalAccess', _345 => _345.name]))), () => ( element.id))}`;
|
|
14336
14456
|
}
|
|
14337
14457
|
};
|
|
14338
14458
|
async function stringifyCommentBody(body, options) {
|
|
14339
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
14340
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
14459
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _346 => _346.format]), () => ( "plain"));
|
|
14460
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _347 => _347.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
14341
14461
|
const elements = {
|
|
14342
14462
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
14343
|
-
..._optionalChain([options, 'optionalAccess',
|
|
14463
|
+
..._optionalChain([options, 'optionalAccess', _348 => _348.elements])
|
|
14344
14464
|
};
|
|
14345
14465
|
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
14346
14466
|
body,
|
|
14347
|
-
_optionalChain([options, 'optionalAccess',
|
|
14348
|
-
_optionalChain([options, 'optionalAccess',
|
|
14467
|
+
_optionalChain([options, 'optionalAccess', _349 => _349.resolveUsers]),
|
|
14468
|
+
_optionalChain([options, 'optionalAccess', _350 => _350.resolveGroupsInfo])
|
|
14349
14469
|
);
|
|
14350
14470
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
14351
14471
|
switch (block.type) {
|
|
@@ -14491,9 +14611,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
14491
14611
|
const startTime = performance.now();
|
|
14492
14612
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
14493
14613
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
14494
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
14614
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _351 => _351.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
14495
14615
|
const context = {
|
|
14496
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
14616
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _352 => _352.visibilityState]) !== "hidden",
|
|
14497
14617
|
lastSuccessfulPollAt: startTime,
|
|
14498
14618
|
count: 0,
|
|
14499
14619
|
backoff: 0
|
|
@@ -14574,11 +14694,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
14574
14694
|
pollNowIfStale();
|
|
14575
14695
|
}
|
|
14576
14696
|
function onVisibilityChange() {
|
|
14577
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
14697
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _353 => _353.visibilityState]) !== "hidden");
|
|
14578
14698
|
}
|
|
14579
|
-
_optionalChain([doc, 'optionalAccess',
|
|
14580
|
-
_optionalChain([win, 'optionalAccess',
|
|
14581
|
-
_optionalChain([win, 'optionalAccess',
|
|
14699
|
+
_optionalChain([doc, 'optionalAccess', _354 => _354.addEventListener, 'call', _355 => _355("visibilitychange", onVisibilityChange)]);
|
|
14700
|
+
_optionalChain([win, 'optionalAccess', _356 => _356.addEventListener, 'call', _357 => _357("online", onVisibilityChange)]);
|
|
14701
|
+
_optionalChain([win, 'optionalAccess', _358 => _358.addEventListener, 'call', _359 => _359("focus", pollNowIfStale)]);
|
|
14582
14702
|
fsm.start();
|
|
14583
14703
|
return {
|
|
14584
14704
|
inc,
|
|
@@ -14731,6 +14851,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
14731
14851
|
|
|
14732
14852
|
|
|
14733
14853
|
|
|
14734
|
-
|
|
14735
|
-
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.FeedRequestErrorCode = FeedRequestErrorCode; exports.HttpError = HttpError; exports.LiveFile = LiveFile; 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.createStorageFileId = createStorageFileId; exports.createThreadId = createThreadId; exports.deepLiveify = deepLiveify; 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.getLiveFileId = getLiveFileId; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.hasPermissionAccess = hasPermissionAccess; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isFileStorageNode = isFileStorageNode; 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.kStorageUpdateSource = kStorageUpdateSource; exports.keys = keys; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.mergeRoomPermissionScopes = mergeRoomPermissionScopes; exports.nanoid = nanoid; exports.nn = nn; exports.nodeStreamToCompactNodes = nodeStreamToCompactNodes; exports.normalizeRoomAccesses = normalizeRoomAccesses; exports.normalizeRoomPermissions = normalizeRoomPermissions; exports.normalizeUpdateRoomAccesses = normalizeUpdateRoomAccesses; exports.objectToQuery = objectToQuery; exports.patchNotificationSettings = patchNotificationSettings; exports.permissionMatrixFromScopes = permissionMatrixFromScopes; 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.transformTextOperations = transformTextOperations; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.validatePermissionsSet = validatePermissionsSet; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
14854
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.FeedRequestErrorCode = FeedRequestErrorCode; exports.HttpError = HttpError; exports.LiveFile = LiveFile; 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.createStorageFileId = createStorageFileId; exports.createThreadId = createThreadId; exports.deepLiveify = deepLiveify; 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.getLiveFileId = getLiveFileId; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.hasPermissionAccess = hasPermissionAccess; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isFileStorageNode = isFileStorageNode; 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.mergeRoomPermissionScopes = mergeRoomPermissionScopes; exports.nanoid = nanoid; exports.nn = nn; exports.nodeStreamToCompactNodes = nodeStreamToCompactNodes; exports.normalizeRoomAccesses = normalizeRoomAccesses; exports.normalizeRoomPermissions = normalizeRoomPermissions; exports.normalizeUpdateRoomAccesses = normalizeUpdateRoomAccesses; exports.objectToQuery = objectToQuery; exports.patchNotificationSettings = patchNotificationSettings; exports.permissionMatrixFromScopes = permissionMatrixFromScopes; 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.transformTextOperations = transformTextOperations; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.validatePermissionsSet = validatePermissionsSet; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
14736
14855
|
//# sourceMappingURL=index.cjs.map
|