@liveblocks/core 3.13.0-metadata1 → 3.13.0-rc1

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 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-metadata1";
9
+ var PKG_VERSION = "3.13.0-rc1";
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,
@@ -3118,7 +3104,6 @@ var ServerMsgCode = Object.freeze({
3118
3104
  COMMENT_DELETED: 404,
3119
3105
  COMMENT_REACTION_ADDED: 405,
3120
3106
  COMMENT_REACTION_REMOVED: 406,
3121
- COMMENT_METADATA_UPDATED: 409,
3122
3107
  // Error codes
3123
3108
  REJECT_STORAGE_OP: 299
3124
3109
  // Sent if a mutation was not allowed on the server (i.e. due to permissions, limit exceeded, etc)
@@ -5941,9 +5926,8 @@ var OpCode = Object.freeze({
5941
5926
  ACK: 9
5942
5927
  // Will only appear in v8+
5943
5928
  });
5944
- function isAck(op) {
5945
- return op.type === OpCode.ACK || // >= v8
5946
- op.type === OpCode.DELETE_CRDT && op.id === "ACK";
5929
+ function isAckOp(op) {
5930
+ return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
5947
5931
  }
5948
5932
 
5949
5933
  // src/crdts/AbstractCrdt.ts
@@ -6629,17 +6613,17 @@ var LiveList = class _LiveList extends AbstractCrdt {
6629
6613
  }
6630
6614
  let result;
6631
6615
  if (op.intent === "set") {
6632
- if (source === 1 /* REMOTE */) {
6616
+ if (source === 1 /* THEIRS */) {
6633
6617
  result = this.#applySetRemote(op);
6634
- } else if (source === 2 /* ACK */) {
6618
+ } else if (source === 2 /* OURS */) {
6635
6619
  result = this.#applySetAck(op);
6636
6620
  } else {
6637
6621
  result = this.#applySetUndoRedo(op);
6638
6622
  }
6639
6623
  } else {
6640
- if (source === 1 /* REMOTE */) {
6624
+ if (source === 1 /* THEIRS */) {
6641
6625
  result = this.#applyRemoteInsert(op);
6642
- } else if (source === 2 /* ACK */) {
6626
+ } else if (source === 2 /* OURS */) {
6643
6627
  result = this.#applyInsertAck(op);
6644
6628
  } else {
6645
6629
  result = this.#applyInsertUndoRedo(op);
@@ -6802,9 +6786,9 @@ var LiveList = class _LiveList extends AbstractCrdt {
6802
6786
  }
6803
6787
  /** @internal */
6804
6788
  _setChildKey(newKey, child, source) {
6805
- if (source === 1 /* REMOTE */) {
6789
+ if (source === 1 /* THEIRS */) {
6806
6790
  return this.#applySetChildKeyRemote(newKey, child);
6807
- } else if (source === 2 /* ACK */) {
6791
+ } else if (source === 2 /* OURS */) {
6808
6792
  return this.#applySetChildKeyAck(newKey, child);
6809
6793
  } else {
6810
6794
  return this.#applySetChildKeyUndoRedo(newKey, child);
@@ -7318,7 +7302,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7318
7302
  if (this._pool.getNode(id) !== void 0) {
7319
7303
  return { modified: false };
7320
7304
  }
7321
- if (source === 2 /* ACK */) {
7305
+ if (source === 2 /* OURS */) {
7322
7306
  const lastUpdateOpId = this.#unacknowledgedSet.get(key);
7323
7307
  if (lastUpdateOpId === opId) {
7324
7308
  this.#unacknowledgedSet.delete(key);
@@ -7326,7 +7310,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7326
7310
  } else if (lastUpdateOpId !== void 0) {
7327
7311
  return { modified: false };
7328
7312
  }
7329
- } else if (source === 1 /* REMOTE */) {
7313
+ } else if (source === 1 /* THEIRS */) {
7330
7314
  this.#unacknowledgedSet.delete(key);
7331
7315
  }
7332
7316
  const previousValue = this.#map.get(key);
@@ -7719,7 +7703,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7719
7703
  }
7720
7704
  return { modified: false };
7721
7705
  }
7722
- if (source === 0 /* UNDOREDO_RECONNECT */) {
7706
+ if (source === 0 /* LOCAL */) {
7723
7707
  this.#propToLastUpdate.set(key, nn(opId));
7724
7708
  } else if (this.#propToLastUpdate.get(key) === void 0) {
7725
7709
  } else if (this.#propToLastUpdate.get(key) === opId) {
@@ -8678,8 +8662,6 @@ function defaultMessageFromContext(context) {
8678
8662
  return "Could not delete thread";
8679
8663
  case "EDIT_THREAD_METADATA_ERROR":
8680
8664
  return "Could not edit thread metadata";
8681
- case "EDIT_COMMENT_METADATA_ERROR":
8682
- return "Could not edit comment metadata";
8683
8665
  case "MARK_THREAD_AS_RESOLVED_ERROR":
8684
8666
  return "Could not mark thread as resolved";
8685
8667
  case "MARK_THREAD_AS_UNRESOLVED_ERROR":
@@ -9127,7 +9109,11 @@ function createRoom(options, config) {
9127
9109
  currentItems.set(id, node._serialize());
9128
9110
  }
9129
9111
  const ops = getTreesDiffOperations(currentItems, new Map(items));
9130
- const result = applyOps(ops, false);
9112
+ const result = applyOps(
9113
+ ops,
9114
+ /* isLocal */
9115
+ false
9116
+ );
9131
9117
  notify(result.updates);
9132
9118
  }
9133
9119
  function _addToRealUndoStack(historyOps) {
@@ -9208,11 +9194,11 @@ function createRoom(options, config) {
9208
9194
  } else {
9209
9195
  let source;
9210
9196
  if (isLocal) {
9211
- source = 0 /* UNDOREDO_RECONNECT */;
9197
+ source = 0 /* LOCAL */;
9212
9198
  } else {
9213
9199
  const opId = nn(op.opId);
9214
9200
  const deleted = context.unacknowledgedOps.delete(opId);
9215
- source = deleted ? 2 /* ACK */ : 1 /* REMOTE */;
9201
+ source = deleted ? 2 /* OURS */ : 1 /* THEIRS */;
9216
9202
  }
9217
9203
  const applyOpResult = applyOp(op, source);
9218
9204
  if (applyOpResult.modified) {
@@ -9243,7 +9229,7 @@ function createRoom(options, config) {
9243
9229
  };
9244
9230
  }
9245
9231
  function applyOp(op, source) {
9246
- if (isAck(op)) {
9232
+ if (isAckOp(op)) {
9247
9233
  return { modified: false };
9248
9234
  }
9249
9235
  switch (op.type) {
@@ -9254,7 +9240,7 @@ function createRoom(options, config) {
9254
9240
  if (node === void 0) {
9255
9241
  return { modified: false };
9256
9242
  }
9257
- return node._apply(op, source === 0 /* UNDOREDO_RECONNECT */);
9243
+ return node._apply(op, source === 0 /* LOCAL */);
9258
9244
  }
9259
9245
  case OpCode.SET_PARENT_KEY: {
9260
9246
  const node = context.pool.nodes.get(op.id);
@@ -9425,7 +9411,11 @@ function createRoom(options, config) {
9425
9411
  }
9426
9412
  const messages = [];
9427
9413
  const inOps = Array.from(offlineOps.values());
9428
- const result = applyOps(inOps, true);
9414
+ const result = applyOps(
9415
+ inOps,
9416
+ /* isLocal */
9417
+ true
9418
+ );
9429
9419
  messages.push({
9430
9420
  type: ClientMsgCode.UPDATE_STORAGE,
9431
9421
  ops: result.ops
@@ -9489,9 +9479,12 @@ function createRoom(options, config) {
9489
9479
  processInitialStorage(message);
9490
9480
  break;
9491
9481
  }
9492
- // Write event
9493
9482
  case ServerMsgCode.UPDATE_STORAGE: {
9494
- const applyResult = applyOps(message.ops, false);
9483
+ const applyResult = applyOps(
9484
+ message.ops,
9485
+ /* isLocal */
9486
+ false
9487
+ );
9495
9488
  for (const [key, value] of applyResult.updates.storageUpdates) {
9496
9489
  updates.storageUpdates.set(
9497
9490
  key,
@@ -9524,8 +9517,7 @@ function createRoom(options, config) {
9524
9517
  case ServerMsgCode.COMMENT_REACTION_REMOVED:
9525
9518
  case ServerMsgCode.COMMENT_CREATED:
9526
9519
  case ServerMsgCode.COMMENT_EDITED:
9527
- case ServerMsgCode.COMMENT_DELETED:
9528
- case ServerMsgCode.COMMENT_METADATA_UPDATED: {
9520
+ case ServerMsgCode.COMMENT_DELETED: {
9529
9521
  eventHub.comments.notify(message);
9530
9522
  break;
9531
9523
  }
@@ -9706,7 +9698,11 @@ function createRoom(options, config) {
9706
9698
  return;
9707
9699
  }
9708
9700
  context.pausedHistory = null;
9709
- const result = applyOps(historyOps, true);
9701
+ const result = applyOps(
9702
+ historyOps,
9703
+ /* isLocal */
9704
+ true
9705
+ );
9710
9706
  notify(result.updates);
9711
9707
  context.redoStack.push(result.reverse);
9712
9708
  onHistoryChange();
@@ -9726,7 +9722,11 @@ function createRoom(options, config) {
9726
9722
  return;
9727
9723
  }
9728
9724
  context.pausedHistory = null;
9729
- const result = applyOps(historyOps, true);
9725
+ const result = applyOps(
9726
+ historyOps,
9727
+ /* isLocal */
9728
+ true
9729
+ );
9730
9730
  notify(result.updates);
9731
9731
  context.undoStack.push(result.reverse);
9732
9732
  onHistoryChange();
@@ -9869,7 +9869,6 @@ function createRoom(options, config) {
9869
9869
  commentId: options2.commentId,
9870
9870
  metadata: options2.metadata,
9871
9871
  body: options2.body,
9872
- commentMetadata: options2.commentMetadata,
9873
9872
  attachmentIds: options2.attachmentIds
9874
9873
  });
9875
9874
  }
@@ -9882,18 +9881,6 @@ function createRoom(options, config) {
9882
9881
  }) {
9883
9882
  return httpClient.editThreadMetadata({ roomId, threadId, metadata });
9884
9883
  }
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
9884
  async function markThreadAsResolved(threadId) {
9898
9885
  return httpClient.markThreadAsResolved({ roomId, threadId });
9899
9886
  }
@@ -9915,7 +9902,6 @@ function createRoom(options, config) {
9915
9902
  threadId: options2.threadId,
9916
9903
  commentId: options2.commentId,
9917
9904
  body: options2.body,
9918
- metadata: options2.metadata,
9919
9905
  attachmentIds: options2.attachmentIds
9920
9906
  });
9921
9907
  }
@@ -9925,7 +9911,6 @@ function createRoom(options, config) {
9925
9911
  threadId: options2.threadId,
9926
9912
  commentId: options2.commentId,
9927
9913
  body: options2.body,
9928
- metadata: options2.metadata,
9929
9914
  attachmentIds: options2.attachmentIds
9930
9915
  });
9931
9916
  }
@@ -10113,7 +10098,6 @@ function createRoom(options, config) {
10113
10098
  unsubscribeFromThread,
10114
10099
  createComment,
10115
10100
  editComment,
10116
- editCommentMetadata,
10117
10101
  deleteComment,
10118
10102
  addReaction,
10119
10103
  removeReaction,
@@ -10236,7 +10220,7 @@ function makeAuthDelegateForRoom(roomId, authManager) {
10236
10220
  return authManager.getAuthValue({ requestedScope: "room:read", roomId });
10237
10221
  };
10238
10222
  }
10239
- function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
10223
+ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill, engine) {
10240
10224
  return (authValue) => {
10241
10225
  const ws = _nullishCoalesce(WebSocketPolyfill, () => ( (typeof WebSocket === "undefined" ? void 0 : WebSocket)));
10242
10226
  if (ws === void 0) {
@@ -10256,6 +10240,9 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
10256
10240
  return assertNever(authValue, "Unhandled case");
10257
10241
  }
10258
10242
  url2.searchParams.set("version", PKG_VERSION || "dev");
10243
+ if (engine !== void 0) {
10244
+ url2.searchParams.set("e", String(engine));
10245
+ }
10259
10246
  return new ws(url2.toString());
10260
10247
  };
10261
10248
  }
@@ -10375,7 +10362,8 @@ function createClient(options) {
10375
10362
  createSocket: makeCreateSocketDelegateForRoom(
10376
10363
  roomId,
10377
10364
  baseUrl,
10378
- _optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket])
10365
+ _optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket]),
10366
+ options2.engine
10379
10367
  ),
10380
10368
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
10381
10369
  })),