@liveblocks/core 1.5.2 → 1.5.3

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.mjs 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 = "1.5.2";
9
+ var PKG_VERSION = "1.5.3";
10
10
  var PKG_FORMAT = "esm";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -572,6 +572,9 @@ var FSM = class {
572
572
  };
573
573
 
574
574
  // src/lib/utils.ts
575
+ function raise(msg) {
576
+ throw new Error(msg);
577
+ }
575
578
  function isPlainObject(blob) {
576
579
  return blob !== null && typeof blob === "object" && Object.prototype.toString.call(blob) === "[object Object]";
577
580
  }
@@ -3759,17 +3762,14 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
3759
3762
  }
3760
3763
  const opId = pool?.generateOpId();
3761
3764
  const ops = [];
3762
- const op = parentId !== void 0 && parentKey !== void 0 ? {
3765
+ const op = {
3763
3766
  type: 4 /* CREATE_OBJECT */,
3764
3767
  id: this._id,
3765
3768
  opId,
3766
3769
  parentId,
3767
3770
  parentKey,
3768
3771
  data: {}
3769
- } : (
3770
- // Root object
3771
- { type: 4 /* CREATE_OBJECT */, id: this._id, opId, data: {} }
3772
- );
3772
+ };
3773
3773
  ops.push(op);
3774
3774
  for (const [key, value] of this._map) {
3775
3775
  if (isLiveNode(value)) {
@@ -4377,18 +4377,18 @@ function getTreesDiffOperations(currentItems, newItems) {
4377
4377
  });
4378
4378
  break;
4379
4379
  case 0 /* OBJECT */:
4380
- ops.push(
4381
- crdt.parentId ? {
4382
- type: 4 /* CREATE_OBJECT */,
4383
- id,
4384
- parentId: crdt.parentId,
4385
- parentKey: crdt.parentKey,
4386
- data: crdt.data
4387
- } : (
4388
- // Root object
4389
- { type: 4 /* CREATE_OBJECT */, id, data: crdt.data }
4390
- )
4391
- );
4380
+ if (crdt.parentId === void 0 || crdt.parentKey === void 0) {
4381
+ throw new Error(
4382
+ "Internal error. Cannot serialize storage root into an operation"
4383
+ );
4384
+ }
4385
+ ops.push({
4386
+ type: 4 /* CREATE_OBJECT */,
4387
+ id,
4388
+ parentId: crdt.parentId,
4389
+ parentKey: crdt.parentKey,
4390
+ data: crdt.data
4391
+ });
4392
4392
  break;
4393
4393
  case 2 /* MAP */:
4394
4394
  ops.push({
@@ -6772,6 +6772,7 @@ export {
6772
6772
  makePosition,
6773
6773
  nn,
6774
6774
  patchLiveObjectKey,
6775
+ raise,
6775
6776
  shallow,
6776
6777
  stringify,
6777
6778
  throwUsageError,