@liveblocks/core 3.13.0-metadata1 → 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 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-metadata2";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -3104,7 +3104,7 @@ var ServerMsgCode = Object.freeze({
3104
3104
  BROADCASTED_EVENT: 103,
3105
3105
  ROOM_STATE: 104,
3106
3106
  // For Storage
3107
- INITIAL_STORAGE_STATE: 200,
3107
+ STORAGE_STATE: 200,
3108
3108
  UPDATE_STORAGE: 201,
3109
3109
  // For Yjs Docs
3110
3110
  UPDATE_YDOC: 300,
@@ -5941,9 +5941,8 @@ var OpCode = Object.freeze({
5941
5941
  ACK: 9
5942
5942
  // Will only appear in v8+
5943
5943
  });
5944
- function isAck(op) {
5945
- return op.type === OpCode.ACK || // >= v8
5946
- op.type === OpCode.DELETE_CRDT && op.id === "ACK";
5944
+ function isAckOp(op) {
5945
+ return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
5947
5946
  }
5948
5947
 
5949
5948
  // src/crdts/AbstractCrdt.ts
@@ -6629,17 +6628,17 @@ var LiveList = class _LiveList extends AbstractCrdt {
6629
6628
  }
6630
6629
  let result;
6631
6630
  if (op.intent === "set") {
6632
- if (source === 1 /* REMOTE */) {
6631
+ if (source === 1 /* THEIRS */) {
6633
6632
  result = this.#applySetRemote(op);
6634
- } else if (source === 2 /* ACK */) {
6633
+ } else if (source === 2 /* OURS */) {
6635
6634
  result = this.#applySetAck(op);
6636
6635
  } else {
6637
6636
  result = this.#applySetUndoRedo(op);
6638
6637
  }
6639
6638
  } else {
6640
- if (source === 1 /* REMOTE */) {
6639
+ if (source === 1 /* THEIRS */) {
6641
6640
  result = this.#applyRemoteInsert(op);
6642
- } else if (source === 2 /* ACK */) {
6641
+ } else if (source === 2 /* OURS */) {
6643
6642
  result = this.#applyInsertAck(op);
6644
6643
  } else {
6645
6644
  result = this.#applyInsertUndoRedo(op);
@@ -6802,9 +6801,9 @@ var LiveList = class _LiveList extends AbstractCrdt {
6802
6801
  }
6803
6802
  /** @internal */
6804
6803
  _setChildKey(newKey, child, source) {
6805
- if (source === 1 /* REMOTE */) {
6804
+ if (source === 1 /* THEIRS */) {
6806
6805
  return this.#applySetChildKeyRemote(newKey, child);
6807
- } else if (source === 2 /* ACK */) {
6806
+ } else if (source === 2 /* OURS */) {
6808
6807
  return this.#applySetChildKeyAck(newKey, child);
6809
6808
  } else {
6810
6809
  return this.#applySetChildKeyUndoRedo(newKey, child);
@@ -7318,7 +7317,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7318
7317
  if (this._pool.getNode(id) !== void 0) {
7319
7318
  return { modified: false };
7320
7319
  }
7321
- if (source === 2 /* ACK */) {
7320
+ if (source === 2 /* OURS */) {
7322
7321
  const lastUpdateOpId = this.#unacknowledgedSet.get(key);
7323
7322
  if (lastUpdateOpId === opId) {
7324
7323
  this.#unacknowledgedSet.delete(key);
@@ -7326,7 +7325,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7326
7325
  } else if (lastUpdateOpId !== void 0) {
7327
7326
  return { modified: false };
7328
7327
  }
7329
- } else if (source === 1 /* REMOTE */) {
7328
+ } else if (source === 1 /* THEIRS */) {
7330
7329
  this.#unacknowledgedSet.delete(key);
7331
7330
  }
7332
7331
  const previousValue = this.#map.get(key);
@@ -7719,7 +7718,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7719
7718
  }
7720
7719
  return { modified: false };
7721
7720
  }
7722
- if (source === 0 /* UNDOREDO_RECONNECT */) {
7721
+ if (source === 0 /* LOCAL */) {
7723
7722
  this.#propToLastUpdate.set(key, nn(opId));
7724
7723
  } else if (this.#propToLastUpdate.get(key) === void 0) {
7725
7724
  } else if (this.#propToLastUpdate.get(key) === opId) {
@@ -9127,7 +9126,11 @@ function createRoom(options, config) {
9127
9126
  currentItems.set(id, node._serialize());
9128
9127
  }
9129
9128
  const ops = getTreesDiffOperations(currentItems, new Map(items));
9130
- const result = applyOps(ops, false);
9129
+ const result = applyOps(
9130
+ ops,
9131
+ /* isLocal */
9132
+ false
9133
+ );
9131
9134
  notify(result.updates);
9132
9135
  }
9133
9136
  function _addToRealUndoStack(historyOps) {
@@ -9208,11 +9211,11 @@ function createRoom(options, config) {
9208
9211
  } else {
9209
9212
  let source;
9210
9213
  if (isLocal) {
9211
- source = 0 /* UNDOREDO_RECONNECT */;
9214
+ source = 0 /* LOCAL */;
9212
9215
  } else {
9213
9216
  const opId = nn(op.opId);
9214
9217
  const deleted = context.unacknowledgedOps.delete(opId);
9215
- source = deleted ? 2 /* ACK */ : 1 /* REMOTE */;
9218
+ source = deleted ? 2 /* OURS */ : 1 /* THEIRS */;
9216
9219
  }
9217
9220
  const applyOpResult = applyOp(op, source);
9218
9221
  if (applyOpResult.modified) {
@@ -9243,7 +9246,7 @@ function createRoom(options, config) {
9243
9246
  };
9244
9247
  }
9245
9248
  function applyOp(op, source) {
9246
- if (isAck(op)) {
9249
+ if (isAckOp(op)) {
9247
9250
  return { modified: false };
9248
9251
  }
9249
9252
  switch (op.type) {
@@ -9254,7 +9257,7 @@ function createRoom(options, config) {
9254
9257
  if (node === void 0) {
9255
9258
  return { modified: false };
9256
9259
  }
9257
- return node._apply(op, source === 0 /* UNDOREDO_RECONNECT */);
9260
+ return node._apply(op, source === 0 /* LOCAL */);
9258
9261
  }
9259
9262
  case OpCode.SET_PARENT_KEY: {
9260
9263
  const node = context.pool.nodes.get(op.id);
@@ -9425,7 +9428,11 @@ function createRoom(options, config) {
9425
9428
  }
9426
9429
  const messages = [];
9427
9430
  const inOps = Array.from(offlineOps.values());
9428
- const result = applyOps(inOps, true);
9431
+ const result = applyOps(
9432
+ inOps,
9433
+ /* isLocal */
9434
+ true
9435
+ );
9429
9436
  messages.push({
9430
9437
  type: ClientMsgCode.UPDATE_STORAGE,
9431
9438
  ops: result.ops
@@ -9485,13 +9492,16 @@ function createRoom(options, config) {
9485
9492
  updates.others.push(onRoomStateMessage(message));
9486
9493
  break;
9487
9494
  }
9488
- case ServerMsgCode.INITIAL_STORAGE_STATE: {
9495
+ case ServerMsgCode.STORAGE_STATE: {
9489
9496
  processInitialStorage(message);
9490
9497
  break;
9491
9498
  }
9492
- // Write event
9493
9499
  case ServerMsgCode.UPDATE_STORAGE: {
9494
- const applyResult = applyOps(message.ops, false);
9500
+ const applyResult = applyOps(
9501
+ message.ops,
9502
+ /* isLocal */
9503
+ false
9504
+ );
9495
9505
  for (const [key, value] of applyResult.updates.storageUpdates) {
9496
9506
  updates.storageUpdates.set(
9497
9507
  key,
@@ -9641,7 +9651,7 @@ function createRoom(options, config) {
9641
9651
  async function streamStorage() {
9642
9652
  if (!managedSocket.authValue) return;
9643
9653
  const items = await httpClient.streamStorage({ roomId });
9644
- processInitialStorage({ type: ServerMsgCode.INITIAL_STORAGE_STATE, items });
9654
+ processInitialStorage({ type: ServerMsgCode.STORAGE_STATE, items });
9645
9655
  }
9646
9656
  function refreshStorage(options2) {
9647
9657
  const messages = context.buffer.messages;
@@ -9706,7 +9716,11 @@ function createRoom(options, config) {
9706
9716
  return;
9707
9717
  }
9708
9718
  context.pausedHistory = null;
9709
- const result = applyOps(historyOps, true);
9719
+ const result = applyOps(
9720
+ historyOps,
9721
+ /* isLocal */
9722
+ true
9723
+ );
9710
9724
  notify(result.updates);
9711
9725
  context.redoStack.push(result.reverse);
9712
9726
  onHistoryChange();
@@ -9726,7 +9740,11 @@ function createRoom(options, config) {
9726
9740
  return;
9727
9741
  }
9728
9742
  context.pausedHistory = null;
9729
- const result = applyOps(historyOps, true);
9743
+ const result = applyOps(
9744
+ historyOps,
9745
+ /* isLocal */
9746
+ true
9747
+ );
9730
9748
  notify(result.updates);
9731
9749
  context.undoStack.push(result.reverse);
9732
9750
  onHistoryChange();
@@ -10236,7 +10254,7 @@ function makeAuthDelegateForRoom(roomId, authManager) {
10236
10254
  return authManager.getAuthValue({ requestedScope: "room:read", roomId });
10237
10255
  };
10238
10256
  }
10239
- function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
10257
+ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill, engine) {
10240
10258
  return (authValue) => {
10241
10259
  const ws = _nullishCoalesce(WebSocketPolyfill, () => ( (typeof WebSocket === "undefined" ? void 0 : WebSocket)));
10242
10260
  if (ws === void 0) {
@@ -10256,6 +10274,9 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
10256
10274
  return assertNever(authValue, "Unhandled case");
10257
10275
  }
10258
10276
  url2.searchParams.set("version", PKG_VERSION || "dev");
10277
+ if (engine !== void 0) {
10278
+ url2.searchParams.set("e", String(engine));
10279
+ }
10259
10280
  return new ws(url2.toString());
10260
10281
  };
10261
10282
  }
@@ -10375,7 +10396,8 @@ function createClient(options) {
10375
10396
  createSocket: makeCreateSocketDelegateForRoom(
10376
10397
  roomId,
10377
10398
  baseUrl,
10378
- _optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket])
10399
+ _optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket]),
10400
+ options2.engine
10379
10401
  ),
10380
10402
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
10381
10403
  })),