@colyseus/schema 3.0.44 → 3.0.45

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.
@@ -2008,7 +2008,7 @@ class ArraySchema {
2008
2008
  }
2009
2009
  if (previousValue !== undefined) {
2010
2010
  // remove root reference from previous value
2011
- previousValue[$changes].root?.remove(previousValue[$changes], obj);
2011
+ previousValue[$changes].root?.remove(previousValue[$changes]);
2012
2012
  }
2013
2013
  }
2014
2014
  else {
@@ -2165,7 +2165,7 @@ class ArraySchema {
2165
2165
  const changeTree = this[$changes];
2166
2166
  // remove children references
2167
2167
  changeTree.forEachChild((childChangeTree, _) => {
2168
- changeTree.root?.remove(childChangeTree, this);
2168
+ changeTree.root?.remove(childChangeTree);
2169
2169
  });
2170
2170
  changeTree.discard(true);
2171
2171
  changeTree.operation(OPERATION.CLEAR);
@@ -2719,7 +2719,7 @@ class MapSchema {
2719
2719
  operation = OPERATION.DELETE_AND_ADD;
2720
2720
  // remove reference from previous value
2721
2721
  if (previousValue !== undefined) {
2722
- previousValue[$changes].root?.remove(previousValue[$changes], this);
2722
+ previousValue[$changes].root?.remove(previousValue[$changes]);
2723
2723
  }
2724
2724
  }
2725
2725
  }
@@ -2756,7 +2756,7 @@ class MapSchema {
2756
2756
  changeTree.indexes = {};
2757
2757
  // remove children references
2758
2758
  changeTree.forEachChild((childChangeTree, _) => {
2759
- changeTree.root?.remove(childChangeTree, this);
2759
+ changeTree.root?.remove(childChangeTree);
2760
2760
  });
2761
2761
  // clear previous indexes
2762
2762
  this.$indexes.clear();
@@ -3598,7 +3598,7 @@ class CollectionSchema {
3598
3598
  changeTree.indexes = {};
3599
3599
  // remove children references
3600
3600
  changeTree.forEachChild((childChangeTree, _) => {
3601
- changeTree.root?.remove(childChangeTree, this);
3601
+ changeTree.root?.remove(childChangeTree);
3602
3602
  });
3603
3603
  // clear previous indexes
3604
3604
  this.$indexes.clear();
@@ -3920,7 +3920,7 @@ class Root {
3920
3920
  // console.log("ADD", { refId: changeTree.refId, refCount: this.refCount[changeTree.refId] });
3921
3921
  return isNewChangeTree;
3922
3922
  }
3923
- remove(changeTree, parent) {
3923
+ remove(changeTree) {
3924
3924
  const refCount = (this.refCount[changeTree.refId]) - 1;
3925
3925
  // console.log("REMOVE", { refId: changeTree.refId, refCount });
3926
3926
  if (refCount <= 0) {
@@ -3941,7 +3941,7 @@ class Root {
3941
3941
  if ((child.parentChain === undefined || // no parent, remove it
3942
3942
  (child.parentChain && this.refCount[child.refId] > 1) // parent is still in use, but has more than one reference, remove it
3943
3943
  )) {
3944
- this.remove(child, changeTree.ref);
3944
+ this.remove(child);
3945
3945
  }
3946
3946
  else if (child.parentChain) {
3947
3947
  // re-assigning a child of the same root, move it to the end
@@ -4422,7 +4422,11 @@ class Decoder {
4422
4422
  // Trying to access a reference that haven't been decoded yet.
4423
4423
  //
4424
4424
  if (!nextRef) {
4425
- throw new Error(`"refId" not found: ${nextRefId}`);
4425
+ // throw new Error(`"refId" not found: ${nextRefId}`);
4426
+ console.error(`"refId" not found: ${nextRefId}`, { previousRef: ref, previousRefId: this.currentRefId });
4427
+ console.warn("Please report this to the developers. All refIds =>");
4428
+ console.warn(Schema.debugRefIdsFromDecoder(this));
4429
+ this.skipCurrentStructure(bytes, it, totalBytes);
4426
4430
  }
4427
4431
  else {
4428
4432
  ref = nextRef;