@colyseus/schema 3.0.25 → 3.0.26

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.
@@ -1137,7 +1137,7 @@ class ChangeTree {
1137
1137
  const newIndexes = {};
1138
1138
  for (const index in this.indexedOperations) {
1139
1139
  newIndexedOperations[Number(index) + shiftIndex] = this.indexedOperations[index];
1140
- newIndexes[Number(index) + shiftIndex] = changeSet[index];
1140
+ newIndexes[Number(index) + shiftIndex] = changeSet.indexes[index];
1141
1141
  }
1142
1142
  this.indexedOperations = newIndexedOperations;
1143
1143
  changeSet.indexes = newIndexes;
@@ -1231,6 +1231,7 @@ class ChangeTree {
1231
1231
  : this.changes;
1232
1232
  this.indexedOperations[index] = operation ?? OPERATION.DELETE;
1233
1233
  setOperationAtIndex(changeSet, index);
1234
+ deleteOperationAtIndex(this.allChanges, allChangesIndex);
1234
1235
  const previousValue = this.getValue(index);
1235
1236
  // remove `root` reference
1236
1237
  if (previousValue && previousValue[$changes]) {
@@ -1246,7 +1247,6 @@ class ChangeTree {
1246
1247
  //
1247
1248
  this.root?.remove(previousValue[$changes]);
1248
1249
  }
1249
- deleteOperationAtIndex(this.allChanges, allChangesIndex);
1250
1250
  //
1251
1251
  // FIXME: this is looking a ugly and repeated
1252
1252
  //
@@ -2099,10 +2099,11 @@ class ArraySchema {
2099
2099
  return undefined;
2100
2100
  }
2101
2101
  // const index = Number(Object.keys(changeTree.indexes)[0]);
2102
- const index = this.tmpItems.findIndex((item, i) => item === this.items[0]);
2103
2102
  const changeTree = this[$changes];
2104
- changeTree.delete(index);
2105
- changeTree.shiftAllChangeIndexes(-1, index);
2103
+ const index = this.tmpItems.findIndex(item => item === this.items[0]);
2104
+ const allChangesIndex = this.items.findIndex(item => item === this.items[0]);
2105
+ changeTree.delete(index, OPERATION.DELETE, allChangesIndex);
2106
+ changeTree.shiftAllChangeIndexes(-1, allChangesIndex);
2106
2107
  // this.deletedIndexes[index] = true;
2107
2108
  return this.items.shift();
2108
2109
  }