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