@liveblocks/core 3.13.0-vincent3 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +298 -313
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +232 -211
- package/dist/index.d.ts +232 -211
- package/dist/index.js +229 -244
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.13.0
|
|
9
|
+
var PKG_VERSION = "3.13.0";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -251,6 +251,19 @@ function findLastIndex(arr, predicate) {
|
|
|
251
251
|
}
|
|
252
252
|
return -1;
|
|
253
253
|
}
|
|
254
|
+
function partition(iterable, predicate) {
|
|
255
|
+
const good = [];
|
|
256
|
+
const bad = [];
|
|
257
|
+
let index = 0;
|
|
258
|
+
for (const item of iterable) {
|
|
259
|
+
if (predicate(item, index++)) {
|
|
260
|
+
good.push(item);
|
|
261
|
+
} else {
|
|
262
|
+
bad.push(item);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return [good, bad];
|
|
266
|
+
}
|
|
254
267
|
|
|
255
268
|
// src/lib/signals.ts
|
|
256
269
|
var kSinks = Symbol("kSinks");
|
|
@@ -1606,6 +1619,7 @@ function createApiClient({
|
|
|
1606
1619
|
comment: {
|
|
1607
1620
|
id: commentId,
|
|
1608
1621
|
body: options.body,
|
|
1622
|
+
metadata: options.commentMetadata,
|
|
1609
1623
|
attachmentIds: options.attachmentIds
|
|
1610
1624
|
},
|
|
1611
1625
|
metadata: options.metadata
|
|
@@ -1659,6 +1673,16 @@ function createApiClient({
|
|
|
1659
1673
|
options.metadata
|
|
1660
1674
|
);
|
|
1661
1675
|
}
|
|
1676
|
+
async function editCommentMetadata(options) {
|
|
1677
|
+
return await httpClient.post(
|
|
1678
|
+
url`/v2/c/rooms/${options.roomId}/threads/${options.threadId}/comments/${options.commentId}/metadata`,
|
|
1679
|
+
await authManager.getAuthValue({
|
|
1680
|
+
requestedScope: "comments:read",
|
|
1681
|
+
roomId: options.roomId
|
|
1682
|
+
}),
|
|
1683
|
+
options.metadata
|
|
1684
|
+
);
|
|
1685
|
+
}
|
|
1662
1686
|
async function createComment(options) {
|
|
1663
1687
|
const commentId = options.commentId ?? createCommentId();
|
|
1664
1688
|
const comment = await httpClient.post(
|
|
@@ -1670,6 +1694,7 @@ function createApiClient({
|
|
|
1670
1694
|
{
|
|
1671
1695
|
id: commentId,
|
|
1672
1696
|
body: options.body,
|
|
1697
|
+
metadata: options.metadata,
|
|
1673
1698
|
attachmentIds: options.attachmentIds
|
|
1674
1699
|
}
|
|
1675
1700
|
);
|
|
@@ -1684,7 +1709,8 @@ function createApiClient({
|
|
|
1684
1709
|
}),
|
|
1685
1710
|
{
|
|
1686
1711
|
body: options.body,
|
|
1687
|
-
attachmentIds: options.attachmentIds
|
|
1712
|
+
attachmentIds: options.attachmentIds,
|
|
1713
|
+
metadata: options.metadata
|
|
1688
1714
|
}
|
|
1689
1715
|
);
|
|
1690
1716
|
return convertToCommentData(comment);
|
|
@@ -2426,6 +2452,7 @@ function createApiClient({
|
|
|
2426
2452
|
editThreadMetadata,
|
|
2427
2453
|
createComment,
|
|
2428
2454
|
editComment,
|
|
2455
|
+
editCommentMetadata,
|
|
2429
2456
|
deleteComment,
|
|
2430
2457
|
addReaction,
|
|
2431
2458
|
removeReaction,
|
|
@@ -3090,12 +3117,7 @@ var ServerMsgCode = Object.freeze({
|
|
|
3090
3117
|
BROADCASTED_EVENT: 103,
|
|
3091
3118
|
ROOM_STATE: 104,
|
|
3092
3119
|
// For Storage
|
|
3093
|
-
|
|
3094
|
-
// Only sent in V7
|
|
3095
|
-
STORAGE_CHUNK: 210,
|
|
3096
|
-
// Used in V8+
|
|
3097
|
-
STORAGE_STREAM_END: 211,
|
|
3098
|
-
// Used in V8+
|
|
3120
|
+
STORAGE_STATE: 200,
|
|
3099
3121
|
UPDATE_STORAGE: 201,
|
|
3100
3122
|
// For Yjs Docs
|
|
3101
3123
|
UPDATE_YDOC: 300,
|
|
@@ -3109,6 +3131,7 @@ var ServerMsgCode = Object.freeze({
|
|
|
3109
3131
|
COMMENT_DELETED: 404,
|
|
3110
3132
|
COMMENT_REACTION_ADDED: 405,
|
|
3111
3133
|
COMMENT_REACTION_REMOVED: 406,
|
|
3134
|
+
COMMENT_METADATA_UPDATED: 409,
|
|
3112
3135
|
// Error codes
|
|
3113
3136
|
REJECT_STORAGE_OP: 299
|
|
3114
3137
|
// Sent if a mutation was not allowed on the server (i.e. due to permissions, limit exceeded, etc)
|
|
@@ -6094,6 +6117,19 @@ var AbstractCrdt = class {
|
|
|
6094
6117
|
}
|
|
6095
6118
|
this.#pool = void 0;
|
|
6096
6119
|
}
|
|
6120
|
+
/**
|
|
6121
|
+
* Serializes this CRDT and all its children into a list of creation ops
|
|
6122
|
+
* with opIds. Used for forward operations that will be sent over the wire
|
|
6123
|
+
* immediately. Each op gets a unique opId for server acknowledgement.
|
|
6124
|
+
*
|
|
6125
|
+
* @internal
|
|
6126
|
+
*/
|
|
6127
|
+
_toOpsWithOpId(parentId, parentKey, pool) {
|
|
6128
|
+
return this._toOps(parentId, parentKey).map((op) => ({
|
|
6129
|
+
opId: pool.generateOpId(),
|
|
6130
|
+
...op
|
|
6131
|
+
}));
|
|
6132
|
+
}
|
|
6097
6133
|
/** This caches the result of the last .toImmutable() call for this Live node. */
|
|
6098
6134
|
#cachedImmutable;
|
|
6099
6135
|
#cachedTreeNodeKey;
|
|
@@ -6145,57 +6181,6 @@ var CrdtType = Object.freeze({
|
|
|
6145
6181
|
MAP: 2,
|
|
6146
6182
|
REGISTER: 3
|
|
6147
6183
|
});
|
|
6148
|
-
function isRootNode(node) {
|
|
6149
|
-
return node[0] === "root";
|
|
6150
|
-
}
|
|
6151
|
-
function isRootCrdt(id, _) {
|
|
6152
|
-
return id === "root";
|
|
6153
|
-
}
|
|
6154
|
-
function* compactNodesToNodeStream(nodes) {
|
|
6155
|
-
for (const node of nodes) {
|
|
6156
|
-
const id = node[0];
|
|
6157
|
-
if (isRootNode(node)) {
|
|
6158
|
-
yield [id, { type: CrdtType.OBJECT, data: node[1] }];
|
|
6159
|
-
continue;
|
|
6160
|
-
}
|
|
6161
|
-
switch (node[1]) {
|
|
6162
|
-
case CrdtType.OBJECT:
|
|
6163
|
-
yield [id, { type: CrdtType.OBJECT, parentId: node[2], parentKey: node[3], data: node[4] }];
|
|
6164
|
-
break;
|
|
6165
|
-
case CrdtType.LIST:
|
|
6166
|
-
yield [id, { type: CrdtType.LIST, parentId: node[2], parentKey: node[3] }];
|
|
6167
|
-
break;
|
|
6168
|
-
case CrdtType.MAP:
|
|
6169
|
-
yield [id, { type: CrdtType.MAP, parentId: node[2], parentKey: node[3] }];
|
|
6170
|
-
break;
|
|
6171
|
-
case CrdtType.REGISTER:
|
|
6172
|
-
yield [id, { type: CrdtType.REGISTER, parentId: node[2], parentKey: node[3], data: node[4] }];
|
|
6173
|
-
break;
|
|
6174
|
-
}
|
|
6175
|
-
}
|
|
6176
|
-
}
|
|
6177
|
-
function* nodeStreamToCompactNodes(nodes) {
|
|
6178
|
-
for (const [id, node] of nodes) {
|
|
6179
|
-
switch (node.type) {
|
|
6180
|
-
case CrdtType.OBJECT:
|
|
6181
|
-
if (isRootCrdt(id, node)) {
|
|
6182
|
-
yield [id, node.data];
|
|
6183
|
-
} else {
|
|
6184
|
-
yield [id, CrdtType.OBJECT, node.parentId, node.parentKey, node.data];
|
|
6185
|
-
}
|
|
6186
|
-
break;
|
|
6187
|
-
case CrdtType.LIST:
|
|
6188
|
-
yield [id, CrdtType.LIST, node.parentId, node.parentKey];
|
|
6189
|
-
break;
|
|
6190
|
-
case CrdtType.MAP:
|
|
6191
|
-
yield [id, CrdtType.MAP, node.parentId, node.parentKey];
|
|
6192
|
-
break;
|
|
6193
|
-
case CrdtType.REGISTER:
|
|
6194
|
-
yield [id, CrdtType.REGISTER, node.parentId, node.parentKey, node.data];
|
|
6195
|
-
break;
|
|
6196
|
-
}
|
|
6197
|
-
}
|
|
6198
|
-
}
|
|
6199
6184
|
|
|
6200
6185
|
// src/crdts/LiveRegister.ts
|
|
6201
6186
|
var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
@@ -6214,7 +6199,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
6214
6199
|
return register;
|
|
6215
6200
|
}
|
|
6216
6201
|
/** @internal */
|
|
6217
|
-
_toOps(parentId, parentKey
|
|
6202
|
+
_toOps(parentId, parentKey) {
|
|
6218
6203
|
if (this._id === void 0) {
|
|
6219
6204
|
throw new Error(
|
|
6220
6205
|
"Cannot serialize register if parentId or parentKey is undefined"
|
|
@@ -6223,7 +6208,6 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
6223
6208
|
return [
|
|
6224
6209
|
{
|
|
6225
6210
|
type: OpCode.CREATE_REGISTER,
|
|
6226
|
-
opId: pool?.generateOpId(),
|
|
6227
6211
|
id: this._id,
|
|
6228
6212
|
parentId,
|
|
6229
6213
|
parentKey,
|
|
@@ -6322,14 +6306,13 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6322
6306
|
* This is quite unintuitive and should disappear as soon as
|
|
6323
6307
|
* we introduce an explicit LiveList.Set operation
|
|
6324
6308
|
*/
|
|
6325
|
-
_toOps(parentId, parentKey
|
|
6309
|
+
_toOps(parentId, parentKey) {
|
|
6326
6310
|
if (this._id === void 0) {
|
|
6327
6311
|
throw new Error("Cannot serialize item is not attached");
|
|
6328
6312
|
}
|
|
6329
6313
|
const ops = [];
|
|
6330
6314
|
const op = {
|
|
6331
6315
|
id: this._id,
|
|
6332
|
-
opId: pool?.generateOpId(),
|
|
6333
6316
|
type: OpCode.CREATE_LIST,
|
|
6334
6317
|
parentId,
|
|
6335
6318
|
parentKey
|
|
@@ -6338,13 +6321,9 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6338
6321
|
for (const item of this.#items) {
|
|
6339
6322
|
const parentKey2 = item._getParentKeyOrThrow();
|
|
6340
6323
|
const childOps = HACK_addIntentAndDeletedIdToOperation(
|
|
6341
|
-
item._toOps(this._id, parentKey2
|
|
6324
|
+
item._toOps(this._id, parentKey2),
|
|
6342
6325
|
void 0
|
|
6343
6326
|
);
|
|
6344
|
-
const childOpId = childOps[0].opId;
|
|
6345
|
-
if (childOpId !== void 0) {
|
|
6346
|
-
this.#unacknowledgedSets.set(parentKey2, childOpId);
|
|
6347
|
-
}
|
|
6348
6327
|
ops.push(...childOps);
|
|
6349
6328
|
}
|
|
6350
6329
|
return ops;
|
|
@@ -6636,7 +6615,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6636
6615
|
existingItem._detach();
|
|
6637
6616
|
this.#items[indexOfItemWithSameKey] = child;
|
|
6638
6617
|
const reverse = HACK_addIntentAndDeletedIdToOperation(
|
|
6639
|
-
existingItem._toOps(nn(this._id), key
|
|
6618
|
+
existingItem._toOps(nn(this._id), key),
|
|
6640
6619
|
op.id
|
|
6641
6620
|
);
|
|
6642
6621
|
const delta = [setDelta(indexOfItemWithSameKey, child)];
|
|
@@ -6692,7 +6671,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6692
6671
|
_detachChild(child) {
|
|
6693
6672
|
if (child) {
|
|
6694
6673
|
const parentKey = nn(child._parentKey);
|
|
6695
|
-
const reverse = child._toOps(nn(this._id), parentKey
|
|
6674
|
+
const reverse = child._toOps(nn(this._id), parentKey);
|
|
6696
6675
|
const indexToDelete = this.#items.indexOf(child);
|
|
6697
6676
|
if (indexToDelete === -1) {
|
|
6698
6677
|
return {
|
|
@@ -6899,7 +6878,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6899
6878
|
const id = this._pool.generateId();
|
|
6900
6879
|
value._attach(id, this._pool);
|
|
6901
6880
|
this._pool.dispatch(
|
|
6902
|
-
value.
|
|
6881
|
+
value._toOpsWithOpId(this._id, position, this._pool),
|
|
6903
6882
|
[{ type: OpCode.DELETE_CRDT, id }],
|
|
6904
6883
|
/* @__PURE__ */ new Map([
|
|
6905
6884
|
[this._id, makeUpdate(this, [insertDelta(index, value)])]
|
|
@@ -7058,12 +7037,12 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7058
7037
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
7059
7038
|
storageUpdates.set(this._id, makeUpdate(this, [setDelta(index, value)]));
|
|
7060
7039
|
const ops = HACK_addIntentAndDeletedIdToOperation(
|
|
7061
|
-
value.
|
|
7040
|
+
value._toOpsWithOpId(this._id, position, this._pool),
|
|
7062
7041
|
existingId
|
|
7063
7042
|
);
|
|
7064
7043
|
this.#unacknowledgedSets.set(position, nn(ops[0].opId));
|
|
7065
7044
|
const reverseOps = HACK_addIntentAndDeletedIdToOperation(
|
|
7066
|
-
existingItem._toOps(this._id, position
|
|
7045
|
+
existingItem._toOps(this._id, position),
|
|
7067
7046
|
id
|
|
7068
7047
|
);
|
|
7069
7048
|
this._pool.dispatch(ops, reverseOps, storageUpdates);
|
|
@@ -7302,21 +7281,20 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7302
7281
|
}
|
|
7303
7282
|
}
|
|
7304
7283
|
/** @internal */
|
|
7305
|
-
_toOps(parentId, parentKey
|
|
7284
|
+
_toOps(parentId, parentKey) {
|
|
7306
7285
|
if (this._id === void 0) {
|
|
7307
7286
|
throw new Error("Cannot serialize item is not attached");
|
|
7308
7287
|
}
|
|
7309
7288
|
const ops = [];
|
|
7310
7289
|
const op = {
|
|
7311
7290
|
id: this._id,
|
|
7312
|
-
opId: pool?.generateOpId(),
|
|
7313
7291
|
type: OpCode.CREATE_MAP,
|
|
7314
7292
|
parentId,
|
|
7315
7293
|
parentKey
|
|
7316
7294
|
};
|
|
7317
7295
|
ops.push(op);
|
|
7318
7296
|
for (const [key, value] of this.#map) {
|
|
7319
|
-
ops.push(...value._toOps(this._id, key
|
|
7297
|
+
ops.push(...value._toOps(this._id, key));
|
|
7320
7298
|
}
|
|
7321
7299
|
return ops;
|
|
7322
7300
|
}
|
|
@@ -7400,7 +7378,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7400
7378
|
_detachChild(child) {
|
|
7401
7379
|
const id = nn(this._id);
|
|
7402
7380
|
const parentKey = nn(child._parentKey);
|
|
7403
|
-
const reverse = child._toOps(id, parentKey
|
|
7381
|
+
const reverse = child._toOps(id, parentKey);
|
|
7404
7382
|
for (const [key, value] of this.#map) {
|
|
7405
7383
|
if (value === child) {
|
|
7406
7384
|
this.#map.delete(key);
|
|
@@ -7467,10 +7445,10 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7467
7445
|
type: "LiveMap",
|
|
7468
7446
|
updates: { [key]: { type: "update" } }
|
|
7469
7447
|
});
|
|
7470
|
-
const ops = item.
|
|
7448
|
+
const ops = item._toOpsWithOpId(this._id, key, this._pool);
|
|
7471
7449
|
this.#unacknowledgedSet.set(key, nn(ops[0].opId));
|
|
7472
7450
|
this._pool.dispatch(
|
|
7473
|
-
|
|
7451
|
+
ops,
|
|
7474
7452
|
oldValue ? oldValue._toOps(this._id, key) : [{ type: OpCode.DELETE_CRDT, id }],
|
|
7475
7453
|
storageUpdates
|
|
7476
7454
|
);
|
|
@@ -7630,12 +7608,25 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7630
7608
|
|
|
7631
7609
|
// src/crdts/LiveObject.ts
|
|
7632
7610
|
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
7633
|
-
function
|
|
7611
|
+
function isRootCrdt(id, _) {
|
|
7634
7612
|
return id === "root";
|
|
7635
7613
|
}
|
|
7636
7614
|
var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
7637
7615
|
#map;
|
|
7638
|
-
|
|
7616
|
+
/**
|
|
7617
|
+
* Tracks unacknowledged local changes per property to preserve optimistic
|
|
7618
|
+
* updates. Maps property keys to their pending operation IDs.
|
|
7619
|
+
*
|
|
7620
|
+
* INVARIANT: Only locally-generated opIds are ever stored here. Remote opIds
|
|
7621
|
+
* are only compared against (to detect ACKs), never stored.
|
|
7622
|
+
*
|
|
7623
|
+
* When a local change is made, the opId is stored here. When a remote op
|
|
7624
|
+
* arrives for the same key:
|
|
7625
|
+
* - If no entry exists → apply remote op
|
|
7626
|
+
* - If opId matches → it's an ACK, clear the entry
|
|
7627
|
+
* - If opId differs → ignore remote op to preserve optimistic update
|
|
7628
|
+
*/
|
|
7629
|
+
#unackedOpsByKey;
|
|
7639
7630
|
/**
|
|
7640
7631
|
* Enable or disable detection of too large LiveObjects.
|
|
7641
7632
|
* When enabled, throws an error if LiveObject static data exceeds 128KB, which
|
|
@@ -7650,7 +7641,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7650
7641
|
const parentToChildren = /* @__PURE__ */ new Map();
|
|
7651
7642
|
let root = null;
|
|
7652
7643
|
for (const [id, crdt] of items) {
|
|
7653
|
-
if (
|
|
7644
|
+
if (isRootCrdt(id, crdt)) {
|
|
7654
7645
|
root = crdt;
|
|
7655
7646
|
} else {
|
|
7656
7647
|
const tuple = [id, crdt];
|
|
@@ -7668,8 +7659,8 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7668
7659
|
return [root, parentToChildren];
|
|
7669
7660
|
}
|
|
7670
7661
|
/** @private Do not use this API directly */
|
|
7671
|
-
static _fromItems(
|
|
7672
|
-
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(
|
|
7662
|
+
static _fromItems(items, pool) {
|
|
7663
|
+
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(items);
|
|
7673
7664
|
return _LiveObject._deserialize(
|
|
7674
7665
|
["root", root],
|
|
7675
7666
|
parentToChildren,
|
|
@@ -7678,7 +7669,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7678
7669
|
}
|
|
7679
7670
|
constructor(obj = {}) {
|
|
7680
7671
|
super();
|
|
7681
|
-
this.#
|
|
7672
|
+
this.#unackedOpsByKey = /* @__PURE__ */ new Map();
|
|
7682
7673
|
const o = compactObject(obj);
|
|
7683
7674
|
for (const key of Object.keys(o)) {
|
|
7684
7675
|
const value = o[key];
|
|
@@ -7689,16 +7680,14 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7689
7680
|
this.#map = new Map(Object.entries(o));
|
|
7690
7681
|
}
|
|
7691
7682
|
/** @internal */
|
|
7692
|
-
_toOps(parentId, parentKey
|
|
7683
|
+
_toOps(parentId, parentKey) {
|
|
7693
7684
|
if (this._id === void 0) {
|
|
7694
7685
|
throw new Error("Cannot serialize item is not attached");
|
|
7695
7686
|
}
|
|
7696
|
-
const opId = pool?.generateOpId();
|
|
7697
7687
|
const ops = [];
|
|
7698
7688
|
const op = {
|
|
7699
7689
|
type: OpCode.CREATE_OBJECT,
|
|
7700
7690
|
id: this._id,
|
|
7701
|
-
opId,
|
|
7702
7691
|
parentId,
|
|
7703
7692
|
parentKey,
|
|
7704
7693
|
data: {}
|
|
@@ -7706,7 +7695,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7706
7695
|
ops.push(op);
|
|
7707
7696
|
for (const [key, value] of this.#map) {
|
|
7708
7697
|
if (isLiveNode(value)) {
|
|
7709
|
-
ops.push(...value._toOps(this._id, key
|
|
7698
|
+
ops.push(...value._toOps(this._id, key));
|
|
7710
7699
|
} else {
|
|
7711
7700
|
op.data[key] = value;
|
|
7712
7701
|
}
|
|
@@ -7752,16 +7741,16 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7752
7741
|
const { id, opId, parentKey: key } = op;
|
|
7753
7742
|
const child = creationOpToLson(op);
|
|
7754
7743
|
if (this._pool.getNode(id) !== void 0) {
|
|
7755
|
-
if (this.#
|
|
7756
|
-
this.#
|
|
7744
|
+
if (this.#unackedOpsByKey.get(key) === opId) {
|
|
7745
|
+
this.#unackedOpsByKey.delete(key);
|
|
7757
7746
|
}
|
|
7758
7747
|
return { modified: false };
|
|
7759
7748
|
}
|
|
7760
7749
|
if (source === 0 /* LOCAL */) {
|
|
7761
|
-
this.#
|
|
7762
|
-
} else if (this.#
|
|
7763
|
-
} else if (this.#
|
|
7764
|
-
this.#
|
|
7750
|
+
this.#unackedOpsByKey.set(key, nn(opId));
|
|
7751
|
+
} else if (this.#unackedOpsByKey.get(key) === void 0) {
|
|
7752
|
+
} else if (this.#unackedOpsByKey.get(key) === opId) {
|
|
7753
|
+
this.#unackedOpsByKey.delete(key);
|
|
7765
7754
|
return { modified: false };
|
|
7766
7755
|
} else {
|
|
7767
7756
|
return { modified: false };
|
|
@@ -7803,7 +7792,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7803
7792
|
if (child) {
|
|
7804
7793
|
const id = nn(this._id);
|
|
7805
7794
|
const parentKey = nn(child._parentKey);
|
|
7806
|
-
const reverse = child._toOps(id, parentKey
|
|
7795
|
+
const reverse = child._toOps(id, parentKey);
|
|
7807
7796
|
for (const [key, value] of this.#map) {
|
|
7808
7797
|
if (value === child) {
|
|
7809
7798
|
this.#map.delete(key);
|
|
@@ -7889,11 +7878,11 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7889
7878
|
continue;
|
|
7890
7879
|
}
|
|
7891
7880
|
if (isLocal) {
|
|
7892
|
-
this.#
|
|
7893
|
-
} else if (this.#
|
|
7881
|
+
this.#unackedOpsByKey.set(key, nn(op.opId));
|
|
7882
|
+
} else if (this.#unackedOpsByKey.get(key) === void 0) {
|
|
7894
7883
|
isModified = true;
|
|
7895
|
-
} else if (this.#
|
|
7896
|
-
this.#
|
|
7884
|
+
} else if (this.#unackedOpsByKey.get(key) === op.opId) {
|
|
7885
|
+
this.#unackedOpsByKey.delete(key);
|
|
7897
7886
|
continue;
|
|
7898
7887
|
} else {
|
|
7899
7888
|
continue;
|
|
@@ -7925,7 +7914,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7925
7914
|
if (oldValue === void 0) {
|
|
7926
7915
|
return { modified: false };
|
|
7927
7916
|
}
|
|
7928
|
-
if (!isLocal && this.#
|
|
7917
|
+
if (!isLocal && this.#unackedOpsByKey.get(key) !== void 0) {
|
|
7929
7918
|
return { modified: false };
|
|
7930
7919
|
}
|
|
7931
7920
|
const id = nn(this._id);
|
|
@@ -8108,17 +8097,21 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
8108
8097
|
if (isLiveNode(newValue)) {
|
|
8109
8098
|
newValue._setParentLink(this, key);
|
|
8110
8099
|
newValue._attach(this._pool.generateId(), this._pool);
|
|
8111
|
-
const newAttachChildOps = newValue.
|
|
8100
|
+
const newAttachChildOps = newValue._toOpsWithOpId(
|
|
8101
|
+
this._id,
|
|
8102
|
+
key,
|
|
8103
|
+
this._pool
|
|
8104
|
+
);
|
|
8112
8105
|
const createCrdtOp = newAttachChildOps.find(
|
|
8113
8106
|
(op) => op.parentId === this._id
|
|
8114
8107
|
);
|
|
8115
8108
|
if (createCrdtOp) {
|
|
8116
|
-
this.#
|
|
8109
|
+
this.#unackedOpsByKey.set(key, nn(createCrdtOp.opId));
|
|
8117
8110
|
}
|
|
8118
8111
|
ops.push(...newAttachChildOps);
|
|
8119
8112
|
} else {
|
|
8120
8113
|
updatedProps[key] = newValue;
|
|
8121
|
-
this.#
|
|
8114
|
+
this.#unackedOpsByKey.set(key, opId);
|
|
8122
8115
|
}
|
|
8123
8116
|
this.#map.set(key, newValue);
|
|
8124
8117
|
this.invalidate();
|
|
@@ -8288,7 +8281,10 @@ function getTreesDiffOperations(currentItems, newItems) {
|
|
|
8288
8281
|
const ops = [];
|
|
8289
8282
|
currentItems.forEach((_, id) => {
|
|
8290
8283
|
if (!newItems.get(id)) {
|
|
8291
|
-
ops.push({
|
|
8284
|
+
ops.push({
|
|
8285
|
+
type: OpCode.DELETE_CRDT,
|
|
8286
|
+
id
|
|
8287
|
+
});
|
|
8292
8288
|
}
|
|
8293
8289
|
});
|
|
8294
8290
|
newItems.forEach((crdt, id) => {
|
|
@@ -8713,6 +8709,8 @@ function defaultMessageFromContext(context) {
|
|
|
8713
8709
|
return "Could not delete thread";
|
|
8714
8710
|
case "EDIT_THREAD_METADATA_ERROR":
|
|
8715
8711
|
return "Could not edit thread metadata";
|
|
8712
|
+
case "EDIT_COMMENT_METADATA_ERROR":
|
|
8713
|
+
return "Could not edit comment metadata";
|
|
8716
8714
|
case "MARK_THREAD_AS_RESOLVED_ERROR":
|
|
8717
8715
|
return "Could not mark thread as resolved";
|
|
8718
8716
|
case "MARK_THREAD_AS_UNRESOLVED_ERROR":
|
|
@@ -8786,21 +8784,6 @@ function installBackgroundTabSpy() {
|
|
|
8786
8784
|
};
|
|
8787
8785
|
return [inBackgroundSince, unsub];
|
|
8788
8786
|
}
|
|
8789
|
-
function makePartialNodeMap() {
|
|
8790
|
-
let map = /* @__PURE__ */ new Map();
|
|
8791
|
-
return {
|
|
8792
|
-
append(chunk2) {
|
|
8793
|
-
for (const [id, node] of chunk2) {
|
|
8794
|
-
map.set(id, node);
|
|
8795
|
-
}
|
|
8796
|
-
},
|
|
8797
|
-
clear() {
|
|
8798
|
-
const result = map;
|
|
8799
|
-
map = /* @__PURE__ */ new Map();
|
|
8800
|
-
return result;
|
|
8801
|
-
}
|
|
8802
|
-
};
|
|
8803
|
-
}
|
|
8804
8787
|
function createRoom(options, config) {
|
|
8805
8788
|
const roomId = config.roomId;
|
|
8806
8789
|
const initialPresence = options.initialPresence;
|
|
@@ -8861,7 +8844,6 @@ function createRoom(options, config) {
|
|
|
8861
8844
|
activeBatch: null,
|
|
8862
8845
|
unacknowledgedOps: /* @__PURE__ */ new Map()
|
|
8863
8846
|
};
|
|
8864
|
-
const partialNodes = makePartialNodeMap();
|
|
8865
8847
|
let lastTokenKey;
|
|
8866
8848
|
function onStatusDidChange(newStatus) {
|
|
8867
8849
|
const authValue = managedSocket.authValue;
|
|
@@ -9143,11 +9125,14 @@ function createRoom(options, config) {
|
|
|
9143
9125
|
self,
|
|
9144
9126
|
(me) => me !== null ? userToTreeNode("Me", me) : null
|
|
9145
9127
|
);
|
|
9146
|
-
function createOrUpdateRootFromMessage(
|
|
9128
|
+
function createOrUpdateRootFromMessage(message) {
|
|
9129
|
+
if (message.items.length === 0) {
|
|
9130
|
+
throw new Error("Internal error: cannot load storage without items");
|
|
9131
|
+
}
|
|
9147
9132
|
if (context.root !== void 0) {
|
|
9148
|
-
updateRoot(
|
|
9133
|
+
updateRoot(message.items);
|
|
9149
9134
|
} else {
|
|
9150
|
-
context.root = LiveObject._fromItems(
|
|
9135
|
+
context.root = LiveObject._fromItems(message.items, context.pool);
|
|
9151
9136
|
}
|
|
9152
9137
|
const canWrite = self.get()?.canWrite ?? true;
|
|
9153
9138
|
const stackSizeBefore = context.undoStack.length;
|
|
@@ -9164,10 +9149,7 @@ function createRoom(options, config) {
|
|
|
9164
9149
|
}
|
|
9165
9150
|
context.undoStack.length = stackSizeBefore;
|
|
9166
9151
|
}
|
|
9167
|
-
function updateRoot(
|
|
9168
|
-
if (nodes.size === 0) {
|
|
9169
|
-
throw new Error("Internal error: cannot load storage without items");
|
|
9170
|
-
}
|
|
9152
|
+
function updateRoot(items) {
|
|
9171
9153
|
if (context.root === void 0) {
|
|
9172
9154
|
return;
|
|
9173
9155
|
}
|
|
@@ -9175,26 +9157,22 @@ function createRoom(options, config) {
|
|
|
9175
9157
|
for (const [id, node] of context.pool.nodes) {
|
|
9176
9158
|
currentItems.set(id, node._serialize());
|
|
9177
9159
|
}
|
|
9178
|
-
const ops = getTreesDiffOperations(currentItems,
|
|
9179
|
-
const result =
|
|
9180
|
-
ops,
|
|
9181
|
-
/* isLocal */
|
|
9182
|
-
false
|
|
9183
|
-
);
|
|
9160
|
+
const ops = getTreesDiffOperations(currentItems, new Map(items));
|
|
9161
|
+
const result = applyRemoteOps(ops);
|
|
9184
9162
|
notify(result.updates);
|
|
9185
9163
|
}
|
|
9186
|
-
function _addToRealUndoStack(
|
|
9164
|
+
function _addToRealUndoStack(frames) {
|
|
9187
9165
|
if (context.undoStack.length >= 50) {
|
|
9188
9166
|
context.undoStack.shift();
|
|
9189
9167
|
}
|
|
9190
|
-
context.undoStack.push(
|
|
9168
|
+
context.undoStack.push(frames);
|
|
9191
9169
|
onHistoryChange();
|
|
9192
9170
|
}
|
|
9193
|
-
function addToUndoStack(
|
|
9171
|
+
function addToUndoStack(frames) {
|
|
9194
9172
|
if (context.pausedHistory !== null) {
|
|
9195
|
-
context.pausedHistory.pushLeft(
|
|
9173
|
+
context.pausedHistory.pushLeft(frames);
|
|
9196
9174
|
} else {
|
|
9197
|
-
_addToRealUndoStack(
|
|
9175
|
+
_addToRealUndoStack(frames);
|
|
9198
9176
|
}
|
|
9199
9177
|
}
|
|
9200
9178
|
function notify(updates) {
|
|
@@ -9225,69 +9203,85 @@ function createRoom(options, config) {
|
|
|
9225
9203
|
"Internal. Tried to get connection id but connection was never open"
|
|
9226
9204
|
);
|
|
9227
9205
|
}
|
|
9228
|
-
function
|
|
9206
|
+
function applyLocalOps(frames) {
|
|
9207
|
+
const [pframes, ops] = partition(
|
|
9208
|
+
frames,
|
|
9209
|
+
(f) => f.type === "presence"
|
|
9210
|
+
);
|
|
9211
|
+
const opsWithOpIds = ops.map(
|
|
9212
|
+
(op) => op.opId === void 0 ? { ...op, opId: context.pool.generateOpId() } : op
|
|
9213
|
+
);
|
|
9214
|
+
const { reverse, updates } = applyOps(
|
|
9215
|
+
pframes,
|
|
9216
|
+
opsWithOpIds,
|
|
9217
|
+
/* isLocal */
|
|
9218
|
+
true
|
|
9219
|
+
);
|
|
9220
|
+
return { opsToEmit: opsWithOpIds, reverse, updates };
|
|
9221
|
+
}
|
|
9222
|
+
function applyRemoteOps(ops) {
|
|
9223
|
+
return applyOps(
|
|
9224
|
+
[],
|
|
9225
|
+
ops,
|
|
9226
|
+
/* isLocal */
|
|
9227
|
+
false
|
|
9228
|
+
);
|
|
9229
|
+
}
|
|
9230
|
+
function applyOps(pframes, ops, isLocal) {
|
|
9229
9231
|
const output = {
|
|
9230
9232
|
reverse: new Deque(),
|
|
9231
9233
|
storageUpdates: /* @__PURE__ */ new Map(),
|
|
9232
9234
|
presence: false
|
|
9233
9235
|
};
|
|
9234
|
-
const
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9236
|
+
for (const pf of pframes) {
|
|
9237
|
+
const reverse = {
|
|
9238
|
+
type: "presence",
|
|
9239
|
+
data: {}
|
|
9240
|
+
};
|
|
9241
|
+
for (const key in pf.data) {
|
|
9242
|
+
reverse.data[key] = context.myPresence.get()[key];
|
|
9243
|
+
}
|
|
9244
|
+
context.myPresence.patch(pf.data);
|
|
9245
|
+
if (context.buffer.presenceUpdates === null) {
|
|
9246
|
+
context.buffer.presenceUpdates = { type: "partial", data: pf.data };
|
|
9238
9247
|
} else {
|
|
9239
|
-
|
|
9248
|
+
for (const key in pf.data) {
|
|
9249
|
+
context.buffer.presenceUpdates.data[key] = pf.data[key];
|
|
9250
|
+
}
|
|
9240
9251
|
}
|
|
9241
|
-
|
|
9252
|
+
output.reverse.pushLeft(reverse);
|
|
9253
|
+
output.presence = true;
|
|
9254
|
+
}
|
|
9255
|
+
const createdNodeIds = /* @__PURE__ */ new Set();
|
|
9242
9256
|
for (const op of ops) {
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
reverse.data[key] = context.myPresence.get()[key];
|
|
9250
|
-
}
|
|
9251
|
-
context.myPresence.patch(op.data);
|
|
9252
|
-
if (context.buffer.presenceUpdates === null) {
|
|
9253
|
-
context.buffer.presenceUpdates = { type: "partial", data: op.data };
|
|
9254
|
-
} else {
|
|
9255
|
-
for (const key in op.data) {
|
|
9256
|
-
context.buffer.presenceUpdates.data[key] = op.data[key];
|
|
9257
|
-
}
|
|
9258
|
-
}
|
|
9259
|
-
output.reverse.pushLeft(reverse);
|
|
9260
|
-
output.presence = true;
|
|
9257
|
+
let source;
|
|
9258
|
+
if (isLocal) {
|
|
9259
|
+
source = 0 /* LOCAL */;
|
|
9260
|
+
} else if (op.opId !== void 0) {
|
|
9261
|
+
context.unacknowledgedOps.delete(op.opId);
|
|
9262
|
+
source = 2 /* OURS */;
|
|
9261
9263
|
} else {
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
|
|
9268
|
-
|
|
9264
|
+
source = 1 /* THEIRS */;
|
|
9265
|
+
}
|
|
9266
|
+
const applyOpResult = applyOp(op, source);
|
|
9267
|
+
if (applyOpResult.modified) {
|
|
9268
|
+
const nodeId = applyOpResult.modified.node._id;
|
|
9269
|
+
if (!(nodeId && createdNodeIds.has(nodeId))) {
|
|
9270
|
+
output.storageUpdates.set(
|
|
9271
|
+
nn(applyOpResult.modified.node._id),
|
|
9272
|
+
mergeStorageUpdates(
|
|
9273
|
+
output.storageUpdates.get(nn(applyOpResult.modified.node._id)),
|
|
9274
|
+
applyOpResult.modified
|
|
9275
|
+
)
|
|
9276
|
+
);
|
|
9277
|
+
output.reverse.pushLeft(applyOpResult.reverse);
|
|
9269
9278
|
}
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
const nodeId = applyOpResult.modified.node._id;
|
|
9273
|
-
if (!(nodeId && createdNodeIds.has(nodeId))) {
|
|
9274
|
-
output.storageUpdates.set(
|
|
9275
|
-
nn(applyOpResult.modified.node._id),
|
|
9276
|
-
mergeStorageUpdates(
|
|
9277
|
-
output.storageUpdates.get(nn(applyOpResult.modified.node._id)),
|
|
9278
|
-
applyOpResult.modified
|
|
9279
|
-
)
|
|
9280
|
-
);
|
|
9281
|
-
output.reverse.pushLeft(applyOpResult.reverse);
|
|
9282
|
-
}
|
|
9283
|
-
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT) {
|
|
9284
|
-
createdNodeIds.add(nn(op.id));
|
|
9285
|
-
}
|
|
9279
|
+
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT) {
|
|
9280
|
+
createdNodeIds.add(op.id);
|
|
9286
9281
|
}
|
|
9287
9282
|
}
|
|
9288
9283
|
}
|
|
9289
9284
|
return {
|
|
9290
|
-
ops,
|
|
9291
9285
|
reverse: Array.from(output.reverse),
|
|
9292
9286
|
updates: {
|
|
9293
9287
|
storageUpdates: output.storageUpdates,
|
|
@@ -9472,20 +9466,16 @@ function createRoom(options, config) {
|
|
|
9472
9466
|
return compact([parseServerMessage(data)]);
|
|
9473
9467
|
}
|
|
9474
9468
|
}
|
|
9475
|
-
function
|
|
9476
|
-
if (
|
|
9469
|
+
function applyAndSendOfflineOps(unackedOps) {
|
|
9470
|
+
if (unackedOps.size === 0) {
|
|
9477
9471
|
return;
|
|
9478
9472
|
}
|
|
9479
9473
|
const messages = [];
|
|
9480
|
-
const inOps = Array.from(
|
|
9481
|
-
const result =
|
|
9482
|
-
inOps,
|
|
9483
|
-
/* isLocal */
|
|
9484
|
-
true
|
|
9485
|
-
);
|
|
9474
|
+
const inOps = Array.from(unackedOps.values());
|
|
9475
|
+
const result = applyLocalOps(inOps);
|
|
9486
9476
|
messages.push({
|
|
9487
9477
|
type: ClientMsgCode.UPDATE_STORAGE,
|
|
9488
|
-
ops: result.
|
|
9478
|
+
ops: result.opsToEmit
|
|
9489
9479
|
});
|
|
9490
9480
|
notify(result.updates);
|
|
9491
9481
|
sendMessages(messages);
|
|
@@ -9542,18 +9532,12 @@ function createRoom(options, config) {
|
|
|
9542
9532
|
updates.others.push(onRoomStateMessage(message));
|
|
9543
9533
|
break;
|
|
9544
9534
|
}
|
|
9545
|
-
case ServerMsgCode.
|
|
9546
|
-
|
|
9547
|
-
break;
|
|
9548
|
-
case ServerMsgCode.STORAGE_STREAM_END:
|
|
9549
|
-
processInitialStorage(partialNodes.clear());
|
|
9535
|
+
case ServerMsgCode.STORAGE_STATE: {
|
|
9536
|
+
processInitialStorage(message);
|
|
9550
9537
|
break;
|
|
9538
|
+
}
|
|
9551
9539
|
case ServerMsgCode.UPDATE_STORAGE: {
|
|
9552
|
-
const applyResult =
|
|
9553
|
-
message.ops,
|
|
9554
|
-
/* isLocal */
|
|
9555
|
-
false
|
|
9556
|
-
);
|
|
9540
|
+
const applyResult = applyRemoteOps(message.ops);
|
|
9557
9541
|
for (const [key, value] of applyResult.updates.storageUpdates) {
|
|
9558
9542
|
updates.storageUpdates.set(
|
|
9559
9543
|
key,
|
|
@@ -9586,12 +9570,11 @@ function createRoom(options, config) {
|
|
|
9586
9570
|
case ServerMsgCode.COMMENT_REACTION_REMOVED:
|
|
9587
9571
|
case ServerMsgCode.COMMENT_CREATED:
|
|
9588
9572
|
case ServerMsgCode.COMMENT_EDITED:
|
|
9589
|
-
case ServerMsgCode.COMMENT_DELETED:
|
|
9573
|
+
case ServerMsgCode.COMMENT_DELETED:
|
|
9574
|
+
case ServerMsgCode.COMMENT_METADATA_UPDATED: {
|
|
9590
9575
|
eventHub.comments.notify(message);
|
|
9591
9576
|
break;
|
|
9592
9577
|
}
|
|
9593
|
-
case ServerMsgCode.STORAGE_STATE_V7:
|
|
9594
|
-
// No longer used in V8
|
|
9595
9578
|
default:
|
|
9596
9579
|
break;
|
|
9597
9580
|
}
|
|
@@ -9602,7 +9585,7 @@ function createRoom(options, config) {
|
|
|
9602
9585
|
const storageOps = context.buffer.storageOperations;
|
|
9603
9586
|
if (storageOps.length > 0) {
|
|
9604
9587
|
for (const op of storageOps) {
|
|
9605
|
-
context.unacknowledgedOps.set(
|
|
9588
|
+
context.unacknowledgedOps.set(op.opId, op);
|
|
9606
9589
|
}
|
|
9607
9590
|
notifyStorageStatus();
|
|
9608
9591
|
}
|
|
@@ -9693,18 +9676,18 @@ function createRoom(options, config) {
|
|
|
9693
9676
|
}
|
|
9694
9677
|
let _getStorage$ = null;
|
|
9695
9678
|
let _resolveStoragePromise = null;
|
|
9696
|
-
function processInitialStorage(
|
|
9679
|
+
function processInitialStorage(message) {
|
|
9697
9680
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
9698
|
-
createOrUpdateRootFromMessage(
|
|
9699
|
-
|
|
9681
|
+
createOrUpdateRootFromMessage(message);
|
|
9682
|
+
applyAndSendOfflineOps(unacknowledgedOps);
|
|
9700
9683
|
_resolveStoragePromise?.();
|
|
9701
9684
|
notifyStorageStatus();
|
|
9702
9685
|
eventHub.storageDidLoad.notify();
|
|
9703
9686
|
}
|
|
9704
9687
|
async function streamStorage() {
|
|
9705
9688
|
if (!managedSocket.authValue) return;
|
|
9706
|
-
const
|
|
9707
|
-
processInitialStorage(
|
|
9689
|
+
const items = await httpClient.streamStorage({ roomId });
|
|
9690
|
+
processInitialStorage({ type: ServerMsgCode.STORAGE_STATE, items });
|
|
9708
9691
|
}
|
|
9709
9692
|
function refreshStorage(options2) {
|
|
9710
9693
|
const messages = context.buffer.messages;
|
|
@@ -9712,7 +9695,6 @@ function createRoom(options, config) {
|
|
|
9712
9695
|
void streamStorage();
|
|
9713
9696
|
} else if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
9714
9697
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
9715
|
-
partialNodes.clear();
|
|
9716
9698
|
}
|
|
9717
9699
|
if (options2.flush) {
|
|
9718
9700
|
flushNowOrSoon();
|
|
@@ -9765,23 +9747,17 @@ function createRoom(options, config) {
|
|
|
9765
9747
|
if (context.activeBatch) {
|
|
9766
9748
|
throw new Error("undo is not allowed during a batch");
|
|
9767
9749
|
}
|
|
9768
|
-
const
|
|
9769
|
-
if (
|
|
9750
|
+
const frames = context.undoStack.pop();
|
|
9751
|
+
if (frames === void 0) {
|
|
9770
9752
|
return;
|
|
9771
9753
|
}
|
|
9772
9754
|
context.pausedHistory = null;
|
|
9773
|
-
const result =
|
|
9774
|
-
historyOps,
|
|
9775
|
-
/* isLocal */
|
|
9776
|
-
true
|
|
9777
|
-
);
|
|
9755
|
+
const result = applyLocalOps(frames);
|
|
9778
9756
|
notify(result.updates);
|
|
9779
9757
|
context.redoStack.push(result.reverse);
|
|
9780
9758
|
onHistoryChange();
|
|
9781
|
-
for (const op of result.
|
|
9782
|
-
|
|
9783
|
-
context.buffer.storageOperations.push(op);
|
|
9784
|
-
}
|
|
9759
|
+
for (const op of result.opsToEmit) {
|
|
9760
|
+
context.buffer.storageOperations.push(op);
|
|
9785
9761
|
}
|
|
9786
9762
|
flushNowOrSoon();
|
|
9787
9763
|
}
|
|
@@ -9789,23 +9765,17 @@ function createRoom(options, config) {
|
|
|
9789
9765
|
if (context.activeBatch) {
|
|
9790
9766
|
throw new Error("redo is not allowed during a batch");
|
|
9791
9767
|
}
|
|
9792
|
-
const
|
|
9793
|
-
if (
|
|
9768
|
+
const frames = context.redoStack.pop();
|
|
9769
|
+
if (frames === void 0) {
|
|
9794
9770
|
return;
|
|
9795
9771
|
}
|
|
9796
9772
|
context.pausedHistory = null;
|
|
9797
|
-
const result =
|
|
9798
|
-
historyOps,
|
|
9799
|
-
/* isLocal */
|
|
9800
|
-
true
|
|
9801
|
-
);
|
|
9773
|
+
const result = applyLocalOps(frames);
|
|
9802
9774
|
notify(result.updates);
|
|
9803
9775
|
context.undoStack.push(result.reverse);
|
|
9804
9776
|
onHistoryChange();
|
|
9805
|
-
for (const op of result.
|
|
9806
|
-
|
|
9807
|
-
context.buffer.storageOperations.push(op);
|
|
9808
|
-
}
|
|
9777
|
+
for (const op of result.opsToEmit) {
|
|
9778
|
+
context.buffer.storageOperations.push(op);
|
|
9809
9779
|
}
|
|
9810
9780
|
flushNowOrSoon();
|
|
9811
9781
|
}
|
|
@@ -9852,10 +9822,10 @@ function createRoom(options, config) {
|
|
|
9852
9822
|
}
|
|
9853
9823
|
}
|
|
9854
9824
|
function resumeHistory() {
|
|
9855
|
-
const
|
|
9825
|
+
const frames = context.pausedHistory;
|
|
9856
9826
|
context.pausedHistory = null;
|
|
9857
|
-
if (
|
|
9858
|
-
_addToRealUndoStack(Array.from(
|
|
9827
|
+
if (frames !== null && frames.length > 0) {
|
|
9828
|
+
_addToRealUndoStack(Array.from(frames));
|
|
9859
9829
|
}
|
|
9860
9830
|
}
|
|
9861
9831
|
const syncSourceForStorage = config.createSyncSource();
|
|
@@ -9941,6 +9911,7 @@ function createRoom(options, config) {
|
|
|
9941
9911
|
commentId: options2.commentId,
|
|
9942
9912
|
metadata: options2.metadata,
|
|
9943
9913
|
body: options2.body,
|
|
9914
|
+
commentMetadata: options2.commentMetadata,
|
|
9944
9915
|
attachmentIds: options2.attachmentIds
|
|
9945
9916
|
});
|
|
9946
9917
|
}
|
|
@@ -9953,6 +9924,18 @@ function createRoom(options, config) {
|
|
|
9953
9924
|
}) {
|
|
9954
9925
|
return httpClient.editThreadMetadata({ roomId, threadId, metadata });
|
|
9955
9926
|
}
|
|
9927
|
+
async function editCommentMetadata({
|
|
9928
|
+
threadId,
|
|
9929
|
+
commentId,
|
|
9930
|
+
metadata
|
|
9931
|
+
}) {
|
|
9932
|
+
return httpClient.editCommentMetadata({
|
|
9933
|
+
roomId,
|
|
9934
|
+
threadId,
|
|
9935
|
+
commentId,
|
|
9936
|
+
metadata
|
|
9937
|
+
});
|
|
9938
|
+
}
|
|
9956
9939
|
async function markThreadAsResolved(threadId) {
|
|
9957
9940
|
return httpClient.markThreadAsResolved({ roomId, threadId });
|
|
9958
9941
|
}
|
|
@@ -9974,6 +9957,7 @@ function createRoom(options, config) {
|
|
|
9974
9957
|
threadId: options2.threadId,
|
|
9975
9958
|
commentId: options2.commentId,
|
|
9976
9959
|
body: options2.body,
|
|
9960
|
+
metadata: options2.metadata,
|
|
9977
9961
|
attachmentIds: options2.attachmentIds
|
|
9978
9962
|
});
|
|
9979
9963
|
}
|
|
@@ -9983,6 +9967,7 @@ function createRoom(options, config) {
|
|
|
9983
9967
|
threadId: options2.threadId,
|
|
9984
9968
|
commentId: options2.commentId,
|
|
9985
9969
|
body: options2.body,
|
|
9970
|
+
metadata: options2.metadata,
|
|
9986
9971
|
attachmentIds: options2.attachmentIds
|
|
9987
9972
|
});
|
|
9988
9973
|
}
|
|
@@ -10170,6 +10155,7 @@ function createRoom(options, config) {
|
|
|
10170
10155
|
unsubscribeFromThread,
|
|
10171
10156
|
createComment,
|
|
10172
10157
|
editComment,
|
|
10158
|
+
editCommentMetadata,
|
|
10173
10159
|
deleteComment,
|
|
10174
10160
|
addReaction,
|
|
10175
10161
|
removeReaction,
|
|
@@ -10302,7 +10288,7 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill, eng
|
|
|
10302
10288
|
}
|
|
10303
10289
|
const url2 = new URL(baseUrl);
|
|
10304
10290
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
10305
|
-
url2.pathname = "/
|
|
10291
|
+
url2.pathname = "/v7";
|
|
10306
10292
|
url2.searchParams.set("roomId", roomId);
|
|
10307
10293
|
if (authValue.type === "secret") {
|
|
10308
10294
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
@@ -11601,7 +11587,6 @@ export {
|
|
|
11601
11587
|
memoizeOnSuccess,
|
|
11602
11588
|
nanoid,
|
|
11603
11589
|
nn,
|
|
11604
|
-
nodeStreamToCompactNodes,
|
|
11605
11590
|
objectToQuery,
|
|
11606
11591
|
patchLiveObjectKey,
|
|
11607
11592
|
patchNotificationSettings,
|