@liveblocks/core 3.13.0-ack1 → 3.13.0-metadata2
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 +70 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +117 -79
- package/dist/index.d.ts +117 -79
- package/dist/index.js +70 -36
- 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-metadata2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1606,6 +1606,7 @@ function createApiClient({
|
|
|
1606
1606
|
comment: {
|
|
1607
1607
|
id: commentId,
|
|
1608
1608
|
body: options.body,
|
|
1609
|
+
metadata: options.commentMetadata,
|
|
1609
1610
|
attachmentIds: options.attachmentIds
|
|
1610
1611
|
},
|
|
1611
1612
|
metadata: options.metadata
|
|
@@ -1659,6 +1660,16 @@ function createApiClient({
|
|
|
1659
1660
|
options.metadata
|
|
1660
1661
|
);
|
|
1661
1662
|
}
|
|
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
|
+
}
|
|
1662
1673
|
async function createComment(options) {
|
|
1663
1674
|
const commentId = _nullishCoalesce(options.commentId, () => ( createCommentId()));
|
|
1664
1675
|
const comment = await httpClient.post(
|
|
@@ -1670,6 +1681,7 @@ function createApiClient({
|
|
|
1670
1681
|
{
|
|
1671
1682
|
id: commentId,
|
|
1672
1683
|
body: options.body,
|
|
1684
|
+
metadata: options.metadata,
|
|
1673
1685
|
attachmentIds: options.attachmentIds
|
|
1674
1686
|
}
|
|
1675
1687
|
);
|
|
@@ -1684,7 +1696,8 @@ function createApiClient({
|
|
|
1684
1696
|
}),
|
|
1685
1697
|
{
|
|
1686
1698
|
body: options.body,
|
|
1687
|
-
attachmentIds: options.attachmentIds
|
|
1699
|
+
attachmentIds: options.attachmentIds,
|
|
1700
|
+
metadata: options.metadata
|
|
1688
1701
|
}
|
|
1689
1702
|
);
|
|
1690
1703
|
return convertToCommentData(comment);
|
|
@@ -2426,6 +2439,7 @@ function createApiClient({
|
|
|
2426
2439
|
editThreadMetadata,
|
|
2427
2440
|
createComment,
|
|
2428
2441
|
editComment,
|
|
2442
|
+
editCommentMetadata,
|
|
2429
2443
|
deleteComment,
|
|
2430
2444
|
addReaction,
|
|
2431
2445
|
removeReaction,
|
|
@@ -3090,9 +3104,8 @@ var ServerMsgCode = Object.freeze({
|
|
|
3090
3104
|
BROADCASTED_EVENT: 103,
|
|
3091
3105
|
ROOM_STATE: 104,
|
|
3092
3106
|
// For Storage
|
|
3093
|
-
|
|
3107
|
+
STORAGE_STATE: 200,
|
|
3094
3108
|
UPDATE_STORAGE: 201,
|
|
3095
|
-
STORAGE_ACK: 202,
|
|
3096
3109
|
// For Yjs Docs
|
|
3097
3110
|
UPDATE_YDOC: 300,
|
|
3098
3111
|
// For Comments
|
|
@@ -3105,6 +3118,7 @@ var ServerMsgCode = Object.freeze({
|
|
|
3105
3118
|
COMMENT_DELETED: 404,
|
|
3106
3119
|
COMMENT_REACTION_ADDED: 405,
|
|
3107
3120
|
COMMENT_REACTION_REMOVED: 406,
|
|
3121
|
+
COMMENT_METADATA_UPDATED: 409,
|
|
3108
3122
|
// Error codes
|
|
3109
3123
|
REJECT_STORAGE_OP: 299
|
|
3110
3124
|
// Sent if a mutation was not allowed on the server (i.e. due to permissions, limit exceeded, etc)
|
|
@@ -5927,6 +5941,9 @@ var OpCode = Object.freeze({
|
|
|
5927
5941
|
ACK: 9
|
|
5928
5942
|
// Will only appear in v8+
|
|
5929
5943
|
});
|
|
5944
|
+
function isAckOp(op) {
|
|
5945
|
+
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5946
|
+
}
|
|
5930
5947
|
|
|
5931
5948
|
// src/crdts/AbstractCrdt.ts
|
|
5932
5949
|
function createManagedPool(roomId, options) {
|
|
@@ -6381,7 +6398,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6381
6398
|
};
|
|
6382
6399
|
}
|
|
6383
6400
|
}
|
|
6384
|
-
#
|
|
6401
|
+
#applySetAck(op) {
|
|
6385
6402
|
if (this._pool === void 0) {
|
|
6386
6403
|
throw new Error("Can't attach child if managed pool is not present");
|
|
6387
6404
|
}
|
|
@@ -6491,7 +6508,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6491
6508
|
reverse: []
|
|
6492
6509
|
};
|
|
6493
6510
|
}
|
|
6494
|
-
#
|
|
6511
|
+
#applyInsertAck(op) {
|
|
6495
6512
|
const existingItem = this.#items.find((item) => item._id === op.id);
|
|
6496
6513
|
const key = asPos(op.parentKey);
|
|
6497
6514
|
const itemIndexAtPosition = this._indexOfPosition(key);
|
|
@@ -6611,18 +6628,18 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6611
6628
|
}
|
|
6612
6629
|
let result;
|
|
6613
6630
|
if (op.intent === "set") {
|
|
6614
|
-
if (source === 1 /*
|
|
6631
|
+
if (source === 1 /* THEIRS */) {
|
|
6615
6632
|
result = this.#applySetRemote(op);
|
|
6616
|
-
} else if (source === 2 /*
|
|
6617
|
-
result = this.#
|
|
6633
|
+
} else if (source === 2 /* OURS */) {
|
|
6634
|
+
result = this.#applySetAck(op);
|
|
6618
6635
|
} else {
|
|
6619
6636
|
result = this.#applySetUndoRedo(op);
|
|
6620
6637
|
}
|
|
6621
6638
|
} else {
|
|
6622
|
-
if (source === 1 /*
|
|
6639
|
+
if (source === 1 /* THEIRS */) {
|
|
6623
6640
|
result = this.#applyRemoteInsert(op);
|
|
6624
|
-
} else if (source === 2 /*
|
|
6625
|
-
result = this.#
|
|
6641
|
+
} else if (source === 2 /* OURS */) {
|
|
6642
|
+
result = this.#applyInsertAck(op);
|
|
6626
6643
|
} else {
|
|
6627
6644
|
result = this.#applyInsertUndoRedo(op);
|
|
6628
6645
|
}
|
|
@@ -6705,7 +6722,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6705
6722
|
};
|
|
6706
6723
|
}
|
|
6707
6724
|
}
|
|
6708
|
-
#
|
|
6725
|
+
#applySetChildKeyAck(newKey, child) {
|
|
6709
6726
|
const previousKey = nn(child._parentKey);
|
|
6710
6727
|
if (this.#implicitlyDeletedItems.has(child)) {
|
|
6711
6728
|
const existingItemIndex = this._indexOfPosition(newKey);
|
|
@@ -6784,10 +6801,10 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6784
6801
|
}
|
|
6785
6802
|
/** @internal */
|
|
6786
6803
|
_setChildKey(newKey, child, source) {
|
|
6787
|
-
if (source === 1 /*
|
|
6804
|
+
if (source === 1 /* THEIRS */) {
|
|
6788
6805
|
return this.#applySetChildKeyRemote(newKey, child);
|
|
6789
|
-
} else if (source === 2 /*
|
|
6790
|
-
return this.#
|
|
6806
|
+
} else if (source === 2 /* OURS */) {
|
|
6807
|
+
return this.#applySetChildKeyAck(newKey, child);
|
|
6791
6808
|
} else {
|
|
6792
6809
|
return this.#applySetChildKeyUndoRedo(newKey, child);
|
|
6793
6810
|
}
|
|
@@ -7300,7 +7317,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7300
7317
|
if (this._pool.getNode(id) !== void 0) {
|
|
7301
7318
|
return { modified: false };
|
|
7302
7319
|
}
|
|
7303
|
-
if (source === 2 /*
|
|
7320
|
+
if (source === 2 /* OURS */) {
|
|
7304
7321
|
const lastUpdateOpId = this.#unacknowledgedSet.get(key);
|
|
7305
7322
|
if (lastUpdateOpId === opId) {
|
|
7306
7323
|
this.#unacknowledgedSet.delete(key);
|
|
@@ -7308,7 +7325,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7308
7325
|
} else if (lastUpdateOpId !== void 0) {
|
|
7309
7326
|
return { modified: false };
|
|
7310
7327
|
}
|
|
7311
|
-
} else if (source === 1 /*
|
|
7328
|
+
} else if (source === 1 /* THEIRS */) {
|
|
7312
7329
|
this.#unacknowledgedSet.delete(key);
|
|
7313
7330
|
}
|
|
7314
7331
|
const previousValue = this.#map.get(key);
|
|
@@ -8660,6 +8677,8 @@ function defaultMessageFromContext(context) {
|
|
|
8660
8677
|
return "Could not delete thread";
|
|
8661
8678
|
case "EDIT_THREAD_METADATA_ERROR":
|
|
8662
8679
|
return "Could not edit thread metadata";
|
|
8680
|
+
case "EDIT_COMMENT_METADATA_ERROR":
|
|
8681
|
+
return "Could not edit comment metadata";
|
|
8663
8682
|
case "MARK_THREAD_AS_RESOLVED_ERROR":
|
|
8664
8683
|
return "Could not mark thread as resolved";
|
|
8665
8684
|
case "MARK_THREAD_AS_UNRESOLVED_ERROR":
|
|
@@ -9193,11 +9212,10 @@ function createRoom(options, config) {
|
|
|
9193
9212
|
let source;
|
|
9194
9213
|
if (isLocal) {
|
|
9195
9214
|
source = 0 /* LOCAL */;
|
|
9196
|
-
} else if (op.opId) {
|
|
9197
|
-
context.unacknowledgedOps.delete(op.opId);
|
|
9198
|
-
source = 2 /* FIXOP */;
|
|
9199
9215
|
} else {
|
|
9200
|
-
|
|
9216
|
+
const opId = nn(op.opId);
|
|
9217
|
+
const deleted = context.unacknowledgedOps.delete(opId);
|
|
9218
|
+
source = deleted ? 2 /* OURS */ : 1 /* THEIRS */;
|
|
9201
9219
|
}
|
|
9202
9220
|
const applyOpResult = applyOp(op, source);
|
|
9203
9221
|
if (applyOpResult.modified) {
|
|
@@ -9228,6 +9246,9 @@ function createRoom(options, config) {
|
|
|
9228
9246
|
};
|
|
9229
9247
|
}
|
|
9230
9248
|
function applyOp(op, source) {
|
|
9249
|
+
if (isAckOp(op)) {
|
|
9250
|
+
return { modified: false };
|
|
9251
|
+
}
|
|
9231
9252
|
switch (op.type) {
|
|
9232
9253
|
case OpCode.DELETE_OBJECT_KEY:
|
|
9233
9254
|
case OpCode.UPDATE_OBJECT:
|
|
@@ -9471,7 +9492,7 @@ function createRoom(options, config) {
|
|
|
9471
9492
|
updates.others.push(onRoomStateMessage(message));
|
|
9472
9493
|
break;
|
|
9473
9494
|
}
|
|
9474
|
-
case ServerMsgCode.
|
|
9495
|
+
case ServerMsgCode.STORAGE_STATE: {
|
|
9475
9496
|
processInitialStorage(message);
|
|
9476
9497
|
break;
|
|
9477
9498
|
}
|
|
@@ -9489,14 +9510,6 @@ function createRoom(options, config) {
|
|
|
9489
9510
|
}
|
|
9490
9511
|
break;
|
|
9491
9512
|
}
|
|
9492
|
-
// Since V8. On V7, acks were sent disguised as an Ops in UPDATE_STORAGE messages.
|
|
9493
|
-
case ServerMsgCode.STORAGE_ACK: {
|
|
9494
|
-
for (const opId of message.opIds) {
|
|
9495
|
-
context.unacknowledgedOps.delete(opId);
|
|
9496
|
-
}
|
|
9497
|
-
notifyStorageStatus();
|
|
9498
|
-
break;
|
|
9499
|
-
}
|
|
9500
9513
|
// Receiving a RejectedOps message in the client means that the server is no
|
|
9501
9514
|
// longer in sync with the client. Trying to synchronize the client again by
|
|
9502
9515
|
// rolling back particular Ops may be hard/impossible. It's fine to not try and
|
|
@@ -9521,7 +9534,8 @@ function createRoom(options, config) {
|
|
|
9521
9534
|
case ServerMsgCode.COMMENT_REACTION_REMOVED:
|
|
9522
9535
|
case ServerMsgCode.COMMENT_CREATED:
|
|
9523
9536
|
case ServerMsgCode.COMMENT_EDITED:
|
|
9524
|
-
case ServerMsgCode.COMMENT_DELETED:
|
|
9537
|
+
case ServerMsgCode.COMMENT_DELETED:
|
|
9538
|
+
case ServerMsgCode.COMMENT_METADATA_UPDATED: {
|
|
9525
9539
|
eventHub.comments.notify(message);
|
|
9526
9540
|
break;
|
|
9527
9541
|
}
|
|
@@ -9637,7 +9651,7 @@ function createRoom(options, config) {
|
|
|
9637
9651
|
async function streamStorage() {
|
|
9638
9652
|
if (!managedSocket.authValue) return;
|
|
9639
9653
|
const items = await httpClient.streamStorage({ roomId });
|
|
9640
|
-
processInitialStorage({ type: ServerMsgCode.
|
|
9654
|
+
processInitialStorage({ type: ServerMsgCode.STORAGE_STATE, items });
|
|
9641
9655
|
}
|
|
9642
9656
|
function refreshStorage(options2) {
|
|
9643
9657
|
const messages = context.buffer.messages;
|
|
@@ -9873,6 +9887,7 @@ function createRoom(options, config) {
|
|
|
9873
9887
|
commentId: options2.commentId,
|
|
9874
9888
|
metadata: options2.metadata,
|
|
9875
9889
|
body: options2.body,
|
|
9890
|
+
commentMetadata: options2.commentMetadata,
|
|
9876
9891
|
attachmentIds: options2.attachmentIds
|
|
9877
9892
|
});
|
|
9878
9893
|
}
|
|
@@ -9885,6 +9900,18 @@ function createRoom(options, config) {
|
|
|
9885
9900
|
}) {
|
|
9886
9901
|
return httpClient.editThreadMetadata({ roomId, threadId, metadata });
|
|
9887
9902
|
}
|
|
9903
|
+
async function editCommentMetadata({
|
|
9904
|
+
threadId,
|
|
9905
|
+
commentId,
|
|
9906
|
+
metadata
|
|
9907
|
+
}) {
|
|
9908
|
+
return httpClient.editCommentMetadata({
|
|
9909
|
+
roomId,
|
|
9910
|
+
threadId,
|
|
9911
|
+
commentId,
|
|
9912
|
+
metadata
|
|
9913
|
+
});
|
|
9914
|
+
}
|
|
9888
9915
|
async function markThreadAsResolved(threadId) {
|
|
9889
9916
|
return httpClient.markThreadAsResolved({ roomId, threadId });
|
|
9890
9917
|
}
|
|
@@ -9906,6 +9933,7 @@ function createRoom(options, config) {
|
|
|
9906
9933
|
threadId: options2.threadId,
|
|
9907
9934
|
commentId: options2.commentId,
|
|
9908
9935
|
body: options2.body,
|
|
9936
|
+
metadata: options2.metadata,
|
|
9909
9937
|
attachmentIds: options2.attachmentIds
|
|
9910
9938
|
});
|
|
9911
9939
|
}
|
|
@@ -9915,6 +9943,7 @@ function createRoom(options, config) {
|
|
|
9915
9943
|
threadId: options2.threadId,
|
|
9916
9944
|
commentId: options2.commentId,
|
|
9917
9945
|
body: options2.body,
|
|
9946
|
+
metadata: options2.metadata,
|
|
9918
9947
|
attachmentIds: options2.attachmentIds
|
|
9919
9948
|
});
|
|
9920
9949
|
}
|
|
@@ -10102,6 +10131,7 @@ function createRoom(options, config) {
|
|
|
10102
10131
|
unsubscribeFromThread,
|
|
10103
10132
|
createComment,
|
|
10104
10133
|
editComment,
|
|
10134
|
+
editCommentMetadata,
|
|
10105
10135
|
deleteComment,
|
|
10106
10136
|
addReaction,
|
|
10107
10137
|
removeReaction,
|
|
@@ -10224,7 +10254,7 @@ function makeAuthDelegateForRoom(roomId, authManager) {
|
|
|
10224
10254
|
return authManager.getAuthValue({ requestedScope: "room:read", roomId });
|
|
10225
10255
|
};
|
|
10226
10256
|
}
|
|
10227
|
-
function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
10257
|
+
function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill, engine) {
|
|
10228
10258
|
return (authValue) => {
|
|
10229
10259
|
const ws = _nullishCoalesce(WebSocketPolyfill, () => ( (typeof WebSocket === "undefined" ? void 0 : WebSocket)));
|
|
10230
10260
|
if (ws === void 0) {
|
|
@@ -10234,7 +10264,7 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
10234
10264
|
}
|
|
10235
10265
|
const url2 = new URL(baseUrl);
|
|
10236
10266
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
10237
|
-
url2.pathname = "/
|
|
10267
|
+
url2.pathname = "/v7";
|
|
10238
10268
|
url2.searchParams.set("roomId", roomId);
|
|
10239
10269
|
if (authValue.type === "secret") {
|
|
10240
10270
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
@@ -10244,6 +10274,9 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
10244
10274
|
return assertNever(authValue, "Unhandled case");
|
|
10245
10275
|
}
|
|
10246
10276
|
url2.searchParams.set("version", PKG_VERSION || "dev");
|
|
10277
|
+
if (engine !== void 0) {
|
|
10278
|
+
url2.searchParams.set("e", String(engine));
|
|
10279
|
+
}
|
|
10247
10280
|
return new ws(url2.toString());
|
|
10248
10281
|
};
|
|
10249
10282
|
}
|
|
@@ -10363,7 +10396,8 @@ function createClient(options) {
|
|
|
10363
10396
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
10364
10397
|
roomId,
|
|
10365
10398
|
baseUrl,
|
|
10366
|
-
_optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket])
|
|
10399
|
+
_optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket]),
|
|
10400
|
+
options2.engine
|
|
10367
10401
|
),
|
|
10368
10402
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
10369
10403
|
})),
|