@liveblocks/core 3.13.0-metadata1 → 3.13.0-vincent1
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 +145 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -134
- package/dist/index.d.ts +138 -134
- package/dist/index.js +144 -85
- 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.13.0-
|
|
9
|
+
var PKG_VERSION = "3.13.0-vincent1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1606,7 +1606,6 @@ function createApiClient({
|
|
|
1606
1606
|
comment: {
|
|
1607
1607
|
id: commentId,
|
|
1608
1608
|
body: options.body,
|
|
1609
|
-
metadata: options.commentMetadata,
|
|
1610
1609
|
attachmentIds: options.attachmentIds
|
|
1611
1610
|
},
|
|
1612
1611
|
metadata: options.metadata
|
|
@@ -1660,16 +1659,6 @@ function createApiClient({
|
|
|
1660
1659
|
options.metadata
|
|
1661
1660
|
);
|
|
1662
1661
|
}
|
|
1663
|
-
async function editCommentMetadata(options) {
|
|
1664
|
-
return await httpClient.post(
|
|
1665
|
-
url`/v2/c/rooms/${options.roomId}/threads/${options.threadId}/comments/${options.commentId}/metadata`,
|
|
1666
|
-
await authManager.getAuthValue({
|
|
1667
|
-
requestedScope: "comments:read",
|
|
1668
|
-
roomId: options.roomId
|
|
1669
|
-
}),
|
|
1670
|
-
options.metadata
|
|
1671
|
-
);
|
|
1672
|
-
}
|
|
1673
1662
|
async function createComment(options) {
|
|
1674
1663
|
const commentId = _nullishCoalesce(options.commentId, () => ( createCommentId()));
|
|
1675
1664
|
const comment = await httpClient.post(
|
|
@@ -1681,7 +1670,6 @@ function createApiClient({
|
|
|
1681
1670
|
{
|
|
1682
1671
|
id: commentId,
|
|
1683
1672
|
body: options.body,
|
|
1684
|
-
metadata: options.metadata,
|
|
1685
1673
|
attachmentIds: options.attachmentIds
|
|
1686
1674
|
}
|
|
1687
1675
|
);
|
|
@@ -1696,8 +1684,7 @@ function createApiClient({
|
|
|
1696
1684
|
}),
|
|
1697
1685
|
{
|
|
1698
1686
|
body: options.body,
|
|
1699
|
-
attachmentIds: options.attachmentIds
|
|
1700
|
-
metadata: options.metadata
|
|
1687
|
+
attachmentIds: options.attachmentIds
|
|
1701
1688
|
}
|
|
1702
1689
|
);
|
|
1703
1690
|
return convertToCommentData(comment);
|
|
@@ -2439,7 +2426,6 @@ function createApiClient({
|
|
|
2439
2426
|
editThreadMetadata,
|
|
2440
2427
|
createComment,
|
|
2441
2428
|
editComment,
|
|
2442
|
-
editCommentMetadata,
|
|
2443
2429
|
deleteComment,
|
|
2444
2430
|
addReaction,
|
|
2445
2431
|
removeReaction,
|
|
@@ -3104,7 +3090,10 @@ var ServerMsgCode = Object.freeze({
|
|
|
3104
3090
|
BROADCASTED_EVENT: 103,
|
|
3105
3091
|
ROOM_STATE: 104,
|
|
3106
3092
|
// For Storage
|
|
3107
|
-
|
|
3093
|
+
STORAGE_STATE_V7: 200,
|
|
3094
|
+
// Only sent in V7
|
|
3095
|
+
STORAGE_CHUNK: 210,
|
|
3096
|
+
// Used in V8+
|
|
3108
3097
|
UPDATE_STORAGE: 201,
|
|
3109
3098
|
// For Yjs Docs
|
|
3110
3099
|
UPDATE_YDOC: 300,
|
|
@@ -3118,7 +3107,6 @@ var ServerMsgCode = Object.freeze({
|
|
|
3118
3107
|
COMMENT_DELETED: 404,
|
|
3119
3108
|
COMMENT_REACTION_ADDED: 405,
|
|
3120
3109
|
COMMENT_REACTION_REMOVED: 406,
|
|
3121
|
-
COMMENT_METADATA_UPDATED: 409,
|
|
3122
3110
|
// Error codes
|
|
3123
3111
|
REJECT_STORAGE_OP: 299
|
|
3124
3112
|
// Sent if a mutation was not allowed on the server (i.e. due to permissions, limit exceeded, etc)
|
|
@@ -5941,9 +5929,8 @@ var OpCode = Object.freeze({
|
|
|
5941
5929
|
ACK: 9
|
|
5942
5930
|
// Will only appear in v8+
|
|
5943
5931
|
});
|
|
5944
|
-
function
|
|
5945
|
-
return op.type === OpCode.
|
|
5946
|
-
op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5932
|
+
function isAckOp(op) {
|
|
5933
|
+
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5947
5934
|
}
|
|
5948
5935
|
|
|
5949
5936
|
// src/crdts/AbstractCrdt.ts
|
|
@@ -6158,6 +6145,54 @@ var CrdtType = Object.freeze({
|
|
|
6158
6145
|
MAP: 2,
|
|
6159
6146
|
REGISTER: 3
|
|
6160
6147
|
});
|
|
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
|
+
switch (node[1]) {
|
|
6157
|
+
case CrdtType.OBJECT:
|
|
6158
|
+
yield isRootNode(node) ? [node[0], { type: CrdtType.OBJECT, data: node[2] }] : (
|
|
6159
|
+
// prettier-ignore
|
|
6160
|
+
[node[0], { type: CrdtType.OBJECT, parentId: node[2], parentKey: node[3], data: node[4] }]
|
|
6161
|
+
);
|
|
6162
|
+
break;
|
|
6163
|
+
case CrdtType.LIST:
|
|
6164
|
+
yield [node[0], { type: CrdtType.LIST, parentId: node[2], parentKey: node[3] }];
|
|
6165
|
+
break;
|
|
6166
|
+
case CrdtType.MAP:
|
|
6167
|
+
yield [node[0], { type: CrdtType.MAP, parentId: node[2], parentKey: node[3] }];
|
|
6168
|
+
break;
|
|
6169
|
+
case CrdtType.REGISTER:
|
|
6170
|
+
yield [node[0], { type: CrdtType.REGISTER, parentId: node[2], parentKey: node[3], data: node[4] }];
|
|
6171
|
+
break;
|
|
6172
|
+
}
|
|
6173
|
+
}
|
|
6174
|
+
}
|
|
6175
|
+
function* nodeStreamToCompactNodes(nodes) {
|
|
6176
|
+
for (const [id, node] of nodes) {
|
|
6177
|
+
switch (node.type) {
|
|
6178
|
+
case CrdtType.OBJECT:
|
|
6179
|
+
if (isRootCrdt(id, node))
|
|
6180
|
+
yield [id, CrdtType.OBJECT, node.data];
|
|
6181
|
+
else
|
|
6182
|
+
yield [id, CrdtType.OBJECT, node.parentId, node.parentKey, node.data];
|
|
6183
|
+
break;
|
|
6184
|
+
case CrdtType.LIST:
|
|
6185
|
+
yield [id, CrdtType.LIST, node.parentId, node.parentKey];
|
|
6186
|
+
break;
|
|
6187
|
+
case CrdtType.MAP:
|
|
6188
|
+
yield [id, CrdtType.MAP, node.parentId, node.parentKey];
|
|
6189
|
+
break;
|
|
6190
|
+
case CrdtType.REGISTER:
|
|
6191
|
+
yield [id, CrdtType.REGISTER, node.parentId, node.parentKey, node.data];
|
|
6192
|
+
break;
|
|
6193
|
+
}
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6161
6196
|
|
|
6162
6197
|
// src/crdts/LiveRegister.ts
|
|
6163
6198
|
var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
@@ -6629,17 +6664,17 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6629
6664
|
}
|
|
6630
6665
|
let result;
|
|
6631
6666
|
if (op.intent === "set") {
|
|
6632
|
-
if (source === 1 /*
|
|
6667
|
+
if (source === 1 /* THEIRS */) {
|
|
6633
6668
|
result = this.#applySetRemote(op);
|
|
6634
|
-
} else if (source === 2 /*
|
|
6669
|
+
} else if (source === 2 /* OURS */) {
|
|
6635
6670
|
result = this.#applySetAck(op);
|
|
6636
6671
|
} else {
|
|
6637
6672
|
result = this.#applySetUndoRedo(op);
|
|
6638
6673
|
}
|
|
6639
6674
|
} else {
|
|
6640
|
-
if (source === 1 /*
|
|
6675
|
+
if (source === 1 /* THEIRS */) {
|
|
6641
6676
|
result = this.#applyRemoteInsert(op);
|
|
6642
|
-
} else if (source === 2 /*
|
|
6677
|
+
} else if (source === 2 /* OURS */) {
|
|
6643
6678
|
result = this.#applyInsertAck(op);
|
|
6644
6679
|
} else {
|
|
6645
6680
|
result = this.#applyInsertUndoRedo(op);
|
|
@@ -6802,9 +6837,9 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6802
6837
|
}
|
|
6803
6838
|
/** @internal */
|
|
6804
6839
|
_setChildKey(newKey, child, source) {
|
|
6805
|
-
if (source === 1 /*
|
|
6840
|
+
if (source === 1 /* THEIRS */) {
|
|
6806
6841
|
return this.#applySetChildKeyRemote(newKey, child);
|
|
6807
|
-
} else if (source === 2 /*
|
|
6842
|
+
} else if (source === 2 /* OURS */) {
|
|
6808
6843
|
return this.#applySetChildKeyAck(newKey, child);
|
|
6809
6844
|
} else {
|
|
6810
6845
|
return this.#applySetChildKeyUndoRedo(newKey, child);
|
|
@@ -7318,7 +7353,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7318
7353
|
if (this._pool.getNode(id) !== void 0) {
|
|
7319
7354
|
return { modified: false };
|
|
7320
7355
|
}
|
|
7321
|
-
if (source === 2 /*
|
|
7356
|
+
if (source === 2 /* OURS */) {
|
|
7322
7357
|
const lastUpdateOpId = this.#unacknowledgedSet.get(key);
|
|
7323
7358
|
if (lastUpdateOpId === opId) {
|
|
7324
7359
|
this.#unacknowledgedSet.delete(key);
|
|
@@ -7326,7 +7361,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7326
7361
|
} else if (lastUpdateOpId !== void 0) {
|
|
7327
7362
|
return { modified: false };
|
|
7328
7363
|
}
|
|
7329
|
-
} else if (source === 1 /*
|
|
7364
|
+
} else if (source === 1 /* THEIRS */) {
|
|
7330
7365
|
this.#unacknowledgedSet.delete(key);
|
|
7331
7366
|
}
|
|
7332
7367
|
const previousValue = this.#map.get(key);
|
|
@@ -7592,7 +7627,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7592
7627
|
|
|
7593
7628
|
// src/crdts/LiveObject.ts
|
|
7594
7629
|
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
7595
|
-
function
|
|
7630
|
+
function isRootCrdt2(id, _) {
|
|
7596
7631
|
return id === "root";
|
|
7597
7632
|
}
|
|
7598
7633
|
var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
@@ -7612,7 +7647,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7612
7647
|
const parentToChildren = /* @__PURE__ */ new Map();
|
|
7613
7648
|
let root = null;
|
|
7614
7649
|
for (const [id, crdt] of items) {
|
|
7615
|
-
if (
|
|
7650
|
+
if (isRootCrdt2(id, crdt)) {
|
|
7616
7651
|
root = crdt;
|
|
7617
7652
|
} else {
|
|
7618
7653
|
const tuple = [id, crdt];
|
|
@@ -7630,8 +7665,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7630
7665
|
return [root, parentToChildren];
|
|
7631
7666
|
}
|
|
7632
7667
|
/** @private Do not use this API directly */
|
|
7633
|
-
static _fromItems(
|
|
7634
|
-
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(
|
|
7668
|
+
static _fromItems(nodes, pool) {
|
|
7669
|
+
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(nodes);
|
|
7635
7670
|
return _LiveObject._deserialize(
|
|
7636
7671
|
["root", root],
|
|
7637
7672
|
parentToChildren,
|
|
@@ -7719,7 +7754,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7719
7754
|
}
|
|
7720
7755
|
return { modified: false };
|
|
7721
7756
|
}
|
|
7722
|
-
if (source === 0 /*
|
|
7757
|
+
if (source === 0 /* LOCAL */) {
|
|
7723
7758
|
this.#propToLastUpdate.set(key, nn(opId));
|
|
7724
7759
|
} else if (this.#propToLastUpdate.get(key) === void 0) {
|
|
7725
7760
|
} else if (this.#propToLastUpdate.get(key) === opId) {
|
|
@@ -8250,10 +8285,7 @@ function getTreesDiffOperations(currentItems, newItems) {
|
|
|
8250
8285
|
const ops = [];
|
|
8251
8286
|
currentItems.forEach((_, id) => {
|
|
8252
8287
|
if (!newItems.get(id)) {
|
|
8253
|
-
ops.push({
|
|
8254
|
-
type: OpCode.DELETE_CRDT,
|
|
8255
|
-
id
|
|
8256
|
-
});
|
|
8288
|
+
ops.push({ type: OpCode.DELETE_CRDT, id });
|
|
8257
8289
|
}
|
|
8258
8290
|
});
|
|
8259
8291
|
newItems.forEach((crdt, id) => {
|
|
@@ -8678,8 +8710,6 @@ function defaultMessageFromContext(context) {
|
|
|
8678
8710
|
return "Could not delete thread";
|
|
8679
8711
|
case "EDIT_THREAD_METADATA_ERROR":
|
|
8680
8712
|
return "Could not edit thread metadata";
|
|
8681
|
-
case "EDIT_COMMENT_METADATA_ERROR":
|
|
8682
|
-
return "Could not edit comment metadata";
|
|
8683
8713
|
case "MARK_THREAD_AS_RESOLVED_ERROR":
|
|
8684
8714
|
return "Could not mark thread as resolved";
|
|
8685
8715
|
case "MARK_THREAD_AS_UNRESOLVED_ERROR":
|
|
@@ -8753,6 +8783,21 @@ function installBackgroundTabSpy() {
|
|
|
8753
8783
|
};
|
|
8754
8784
|
return [inBackgroundSince, unsub];
|
|
8755
8785
|
}
|
|
8786
|
+
function makePartialNodeMap() {
|
|
8787
|
+
let map = /* @__PURE__ */ new Map();
|
|
8788
|
+
return {
|
|
8789
|
+
append(chunk2) {
|
|
8790
|
+
for (const [id, node] of chunk2) {
|
|
8791
|
+
map.set(id, node);
|
|
8792
|
+
}
|
|
8793
|
+
},
|
|
8794
|
+
clear() {
|
|
8795
|
+
const result = map;
|
|
8796
|
+
map = /* @__PURE__ */ new Map();
|
|
8797
|
+
return result;
|
|
8798
|
+
}
|
|
8799
|
+
};
|
|
8800
|
+
}
|
|
8756
8801
|
function createRoom(options, config) {
|
|
8757
8802
|
const roomId = config.roomId;
|
|
8758
8803
|
const initialPresence = options.initialPresence;
|
|
@@ -8813,6 +8858,7 @@ function createRoom(options, config) {
|
|
|
8813
8858
|
activeBatch: null,
|
|
8814
8859
|
unacknowledgedOps: /* @__PURE__ */ new Map()
|
|
8815
8860
|
};
|
|
8861
|
+
const partialNodes = makePartialNodeMap();
|
|
8816
8862
|
let lastTokenKey;
|
|
8817
8863
|
function onStatusDidChange(newStatus) {
|
|
8818
8864
|
const authValue = managedSocket.authValue;
|
|
@@ -9094,14 +9140,11 @@ function createRoom(options, config) {
|
|
|
9094
9140
|
self,
|
|
9095
9141
|
(me) => me !== null ? userToTreeNode("Me", me) : null
|
|
9096
9142
|
);
|
|
9097
|
-
function createOrUpdateRootFromMessage(
|
|
9098
|
-
if (message.items.length === 0) {
|
|
9099
|
-
throw new Error("Internal error: cannot load storage without items");
|
|
9100
|
-
}
|
|
9143
|
+
function createOrUpdateRootFromMessage(nodes) {
|
|
9101
9144
|
if (context.root !== void 0) {
|
|
9102
|
-
updateRoot(
|
|
9145
|
+
updateRoot(new Map(nodes));
|
|
9103
9146
|
} else {
|
|
9104
|
-
context.root = LiveObject._fromItems(
|
|
9147
|
+
context.root = LiveObject._fromItems(nodes, context.pool);
|
|
9105
9148
|
}
|
|
9106
9149
|
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _196 => _196.get, 'call', _197 => _197(), 'optionalAccess', _198 => _198.canWrite]), () => ( true));
|
|
9107
9150
|
const stackSizeBefore = context.undoStack.length;
|
|
@@ -9118,7 +9161,10 @@ function createRoom(options, config) {
|
|
|
9118
9161
|
}
|
|
9119
9162
|
context.undoStack.length = stackSizeBefore;
|
|
9120
9163
|
}
|
|
9121
|
-
function updateRoot(
|
|
9164
|
+
function updateRoot(nodes) {
|
|
9165
|
+
if (nodes.size === 0) {
|
|
9166
|
+
throw new Error("Internal error: cannot load storage without items");
|
|
9167
|
+
}
|
|
9122
9168
|
if (context.root === void 0) {
|
|
9123
9169
|
return;
|
|
9124
9170
|
}
|
|
@@ -9126,8 +9172,12 @@ function createRoom(options, config) {
|
|
|
9126
9172
|
for (const [id, node] of context.pool.nodes) {
|
|
9127
9173
|
currentItems.set(id, node._serialize());
|
|
9128
9174
|
}
|
|
9129
|
-
const ops = getTreesDiffOperations(currentItems,
|
|
9130
|
-
const result = applyOps(
|
|
9175
|
+
const ops = getTreesDiffOperations(currentItems, nodes);
|
|
9176
|
+
const result = applyOps(
|
|
9177
|
+
ops,
|
|
9178
|
+
/* isLocal */
|
|
9179
|
+
false
|
|
9180
|
+
);
|
|
9131
9181
|
notify(result.updates);
|
|
9132
9182
|
}
|
|
9133
9183
|
function _addToRealUndoStack(historyOps) {
|
|
@@ -9208,11 +9258,11 @@ function createRoom(options, config) {
|
|
|
9208
9258
|
} else {
|
|
9209
9259
|
let source;
|
|
9210
9260
|
if (isLocal) {
|
|
9211
|
-
source = 0 /*
|
|
9261
|
+
source = 0 /* LOCAL */;
|
|
9212
9262
|
} else {
|
|
9213
9263
|
const opId = nn(op.opId);
|
|
9214
9264
|
const deleted = context.unacknowledgedOps.delete(opId);
|
|
9215
|
-
source = deleted ? 2 /*
|
|
9265
|
+
source = deleted ? 2 /* OURS */ : 1 /* THEIRS */;
|
|
9216
9266
|
}
|
|
9217
9267
|
const applyOpResult = applyOp(op, source);
|
|
9218
9268
|
if (applyOpResult.modified) {
|
|
@@ -9243,7 +9293,7 @@ function createRoom(options, config) {
|
|
|
9243
9293
|
};
|
|
9244
9294
|
}
|
|
9245
9295
|
function applyOp(op, source) {
|
|
9246
|
-
if (
|
|
9296
|
+
if (isAckOp(op)) {
|
|
9247
9297
|
return { modified: false };
|
|
9248
9298
|
}
|
|
9249
9299
|
switch (op.type) {
|
|
@@ -9254,7 +9304,7 @@ function createRoom(options, config) {
|
|
|
9254
9304
|
if (node === void 0) {
|
|
9255
9305
|
return { modified: false };
|
|
9256
9306
|
}
|
|
9257
|
-
return node._apply(op, source === 0 /*
|
|
9307
|
+
return node._apply(op, source === 0 /* LOCAL */);
|
|
9258
9308
|
}
|
|
9259
9309
|
case OpCode.SET_PARENT_KEY: {
|
|
9260
9310
|
const node = context.pool.nodes.get(op.id);
|
|
@@ -9425,7 +9475,11 @@ function createRoom(options, config) {
|
|
|
9425
9475
|
}
|
|
9426
9476
|
const messages = [];
|
|
9427
9477
|
const inOps = Array.from(offlineOps.values());
|
|
9428
|
-
const result = applyOps(
|
|
9478
|
+
const result = applyOps(
|
|
9479
|
+
inOps,
|
|
9480
|
+
/* isLocal */
|
|
9481
|
+
true
|
|
9482
|
+
);
|
|
9429
9483
|
messages.push({
|
|
9430
9484
|
type: ClientMsgCode.UPDATE_STORAGE,
|
|
9431
9485
|
ops: result.ops
|
|
@@ -9485,13 +9539,19 @@ function createRoom(options, config) {
|
|
|
9485
9539
|
updates.others.push(onRoomStateMessage(message));
|
|
9486
9540
|
break;
|
|
9487
9541
|
}
|
|
9488
|
-
case ServerMsgCode.
|
|
9489
|
-
|
|
9542
|
+
case ServerMsgCode.STORAGE_CHUNK: {
|
|
9543
|
+
partialNodes.append(compactNodesToNodeStream(message.nodes));
|
|
9544
|
+
if (message.done) {
|
|
9545
|
+
processInitialStorage(partialNodes.clear());
|
|
9546
|
+
}
|
|
9490
9547
|
break;
|
|
9491
9548
|
}
|
|
9492
|
-
// Write event
|
|
9493
9549
|
case ServerMsgCode.UPDATE_STORAGE: {
|
|
9494
|
-
const applyResult = applyOps(
|
|
9550
|
+
const applyResult = applyOps(
|
|
9551
|
+
message.ops,
|
|
9552
|
+
/* isLocal */
|
|
9553
|
+
false
|
|
9554
|
+
);
|
|
9495
9555
|
for (const [key, value] of applyResult.updates.storageUpdates) {
|
|
9496
9556
|
updates.storageUpdates.set(
|
|
9497
9557
|
key,
|
|
@@ -9524,11 +9584,12 @@ function createRoom(options, config) {
|
|
|
9524
9584
|
case ServerMsgCode.COMMENT_REACTION_REMOVED:
|
|
9525
9585
|
case ServerMsgCode.COMMENT_CREATED:
|
|
9526
9586
|
case ServerMsgCode.COMMENT_EDITED:
|
|
9527
|
-
case ServerMsgCode.COMMENT_DELETED:
|
|
9528
|
-
case ServerMsgCode.COMMENT_METADATA_UPDATED: {
|
|
9587
|
+
case ServerMsgCode.COMMENT_DELETED: {
|
|
9529
9588
|
eventHub.comments.notify(message);
|
|
9530
9589
|
break;
|
|
9531
9590
|
}
|
|
9591
|
+
case ServerMsgCode.STORAGE_STATE_V7:
|
|
9592
|
+
// No longer used in V8
|
|
9532
9593
|
default:
|
|
9533
9594
|
break;
|
|
9534
9595
|
}
|
|
@@ -9630,9 +9691,9 @@ function createRoom(options, config) {
|
|
|
9630
9691
|
}
|
|
9631
9692
|
let _getStorage$ = null;
|
|
9632
9693
|
let _resolveStoragePromise = null;
|
|
9633
|
-
function processInitialStorage(
|
|
9694
|
+
function processInitialStorage(nodes) {
|
|
9634
9695
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
9635
|
-
createOrUpdateRootFromMessage(
|
|
9696
|
+
createOrUpdateRootFromMessage(nodes);
|
|
9636
9697
|
applyAndSendOps(unacknowledgedOps);
|
|
9637
9698
|
_optionalChain([_resolveStoragePromise, 'optionalCall', _201 => _201()]);
|
|
9638
9699
|
notifyStorageStatus();
|
|
@@ -9640,8 +9701,8 @@ function createRoom(options, config) {
|
|
|
9640
9701
|
}
|
|
9641
9702
|
async function streamStorage() {
|
|
9642
9703
|
if (!managedSocket.authValue) return;
|
|
9643
|
-
const
|
|
9644
|
-
processInitialStorage(
|
|
9704
|
+
const nodes = new Map(await httpClient.streamStorage({ roomId }));
|
|
9705
|
+
processInitialStorage(nodes);
|
|
9645
9706
|
}
|
|
9646
9707
|
function refreshStorage(options2) {
|
|
9647
9708
|
const messages = context.buffer.messages;
|
|
@@ -9649,6 +9710,7 @@ function createRoom(options, config) {
|
|
|
9649
9710
|
void streamStorage();
|
|
9650
9711
|
} else if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
9651
9712
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
9713
|
+
partialNodes.clear();
|
|
9652
9714
|
}
|
|
9653
9715
|
if (options2.flush) {
|
|
9654
9716
|
flushNowOrSoon();
|
|
@@ -9706,7 +9768,11 @@ function createRoom(options, config) {
|
|
|
9706
9768
|
return;
|
|
9707
9769
|
}
|
|
9708
9770
|
context.pausedHistory = null;
|
|
9709
|
-
const result = applyOps(
|
|
9771
|
+
const result = applyOps(
|
|
9772
|
+
historyOps,
|
|
9773
|
+
/* isLocal */
|
|
9774
|
+
true
|
|
9775
|
+
);
|
|
9710
9776
|
notify(result.updates);
|
|
9711
9777
|
context.redoStack.push(result.reverse);
|
|
9712
9778
|
onHistoryChange();
|
|
@@ -9726,7 +9792,11 @@ function createRoom(options, config) {
|
|
|
9726
9792
|
return;
|
|
9727
9793
|
}
|
|
9728
9794
|
context.pausedHistory = null;
|
|
9729
|
-
const result = applyOps(
|
|
9795
|
+
const result = applyOps(
|
|
9796
|
+
historyOps,
|
|
9797
|
+
/* isLocal */
|
|
9798
|
+
true
|
|
9799
|
+
);
|
|
9730
9800
|
notify(result.updates);
|
|
9731
9801
|
context.undoStack.push(result.reverse);
|
|
9732
9802
|
onHistoryChange();
|
|
@@ -9869,7 +9939,6 @@ function createRoom(options, config) {
|
|
|
9869
9939
|
commentId: options2.commentId,
|
|
9870
9940
|
metadata: options2.metadata,
|
|
9871
9941
|
body: options2.body,
|
|
9872
|
-
commentMetadata: options2.commentMetadata,
|
|
9873
9942
|
attachmentIds: options2.attachmentIds
|
|
9874
9943
|
});
|
|
9875
9944
|
}
|
|
@@ -9882,18 +9951,6 @@ function createRoom(options, config) {
|
|
|
9882
9951
|
}) {
|
|
9883
9952
|
return httpClient.editThreadMetadata({ roomId, threadId, metadata });
|
|
9884
9953
|
}
|
|
9885
|
-
async function editCommentMetadata({
|
|
9886
|
-
threadId,
|
|
9887
|
-
commentId,
|
|
9888
|
-
metadata
|
|
9889
|
-
}) {
|
|
9890
|
-
return httpClient.editCommentMetadata({
|
|
9891
|
-
roomId,
|
|
9892
|
-
threadId,
|
|
9893
|
-
commentId,
|
|
9894
|
-
metadata
|
|
9895
|
-
});
|
|
9896
|
-
}
|
|
9897
9954
|
async function markThreadAsResolved(threadId) {
|
|
9898
9955
|
return httpClient.markThreadAsResolved({ roomId, threadId });
|
|
9899
9956
|
}
|
|
@@ -9915,7 +9972,6 @@ function createRoom(options, config) {
|
|
|
9915
9972
|
threadId: options2.threadId,
|
|
9916
9973
|
commentId: options2.commentId,
|
|
9917
9974
|
body: options2.body,
|
|
9918
|
-
metadata: options2.metadata,
|
|
9919
9975
|
attachmentIds: options2.attachmentIds
|
|
9920
9976
|
});
|
|
9921
9977
|
}
|
|
@@ -9925,7 +9981,6 @@ function createRoom(options, config) {
|
|
|
9925
9981
|
threadId: options2.threadId,
|
|
9926
9982
|
commentId: options2.commentId,
|
|
9927
9983
|
body: options2.body,
|
|
9928
|
-
metadata: options2.metadata,
|
|
9929
9984
|
attachmentIds: options2.attachmentIds
|
|
9930
9985
|
});
|
|
9931
9986
|
}
|
|
@@ -10113,7 +10168,6 @@ function createRoom(options, config) {
|
|
|
10113
10168
|
unsubscribeFromThread,
|
|
10114
10169
|
createComment,
|
|
10115
10170
|
editComment,
|
|
10116
|
-
editCommentMetadata,
|
|
10117
10171
|
deleteComment,
|
|
10118
10172
|
addReaction,
|
|
10119
10173
|
removeReaction,
|
|
@@ -10236,7 +10290,7 @@ function makeAuthDelegateForRoom(roomId, authManager) {
|
|
|
10236
10290
|
return authManager.getAuthValue({ requestedScope: "room:read", roomId });
|
|
10237
10291
|
};
|
|
10238
10292
|
}
|
|
10239
|
-
function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
10293
|
+
function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill, engine) {
|
|
10240
10294
|
return (authValue) => {
|
|
10241
10295
|
const ws = _nullishCoalesce(WebSocketPolyfill, () => ( (typeof WebSocket === "undefined" ? void 0 : WebSocket)));
|
|
10242
10296
|
if (ws === void 0) {
|
|
@@ -10246,7 +10300,7 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
10246
10300
|
}
|
|
10247
10301
|
const url2 = new URL(baseUrl);
|
|
10248
10302
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
10249
|
-
url2.pathname = "/
|
|
10303
|
+
url2.pathname = "/v8";
|
|
10250
10304
|
url2.searchParams.set("roomId", roomId);
|
|
10251
10305
|
if (authValue.type === "secret") {
|
|
10252
10306
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
@@ -10256,6 +10310,9 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
10256
10310
|
return assertNever(authValue, "Unhandled case");
|
|
10257
10311
|
}
|
|
10258
10312
|
url2.searchParams.set("version", PKG_VERSION || "dev");
|
|
10313
|
+
if (engine !== void 0) {
|
|
10314
|
+
url2.searchParams.set("e", String(engine));
|
|
10315
|
+
}
|
|
10259
10316
|
return new ws(url2.toString());
|
|
10260
10317
|
};
|
|
10261
10318
|
}
|
|
@@ -10375,7 +10432,8 @@ function createClient(options) {
|
|
|
10375
10432
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
10376
10433
|
roomId,
|
|
10377
10434
|
baseUrl,
|
|
10378
|
-
_optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket])
|
|
10435
|
+
_optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket]),
|
|
10436
|
+
options2.engine
|
|
10379
10437
|
),
|
|
10380
10438
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
10381
10439
|
})),
|
|
@@ -11560,5 +11618,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
11560
11618
|
|
|
11561
11619
|
|
|
11562
11620
|
|
|
11563
|
-
|
|
11621
|
+
|
|
11622
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; 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.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.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isPlainObject = isPlainObject; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.nodeStreamToCompactNodes = nodeStreamToCompactNodes; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
11564
11623
|
//# sourceMappingURL=index.cjs.map
|