@colyseus/schema 3.0.17 → 3.0.19

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.
@@ -1356,9 +1356,8 @@ class ChangeTree {
1356
1356
  }
1357
1357
  key += `-${parentIndex}`;
1358
1358
  this.isFiltered = parent[$changes].isFiltered // in case parent is already filtered
1359
- || this.root.types.parentFiltered[key];
1360
- // const parentMetadata = parentConstructor?.[Symbol.metadata];
1361
- // this.isFiltered = parentMetadata?.[$viewFieldIndexes]?.includes(parentIndex) || this.root.types.parentFiltered[key];
1359
+ || this.root.types.parentFiltered[key]
1360
+ || parentConstructor?.[Symbol.metadata]?.[$viewFieldIndexes]?.includes(parentIndex);
1362
1361
  //
1363
1362
  // TODO: refactor this!
1364
1363
  //
@@ -1573,7 +1572,6 @@ function decodeValue(decoder, operation, ref, index, type, bytes, it, allChanges
1573
1572
  while ((iter = entries.next()) && !iter.done) {
1574
1573
  const [key, value] = iter.value;
1575
1574
  // if value is a schema, remove its reference
1576
- // FIXME: not sure if this is necessary, add more tests to confirm
1577
1575
  if (typeof (value) === "object") {
1578
1576
  previousRefId = $root.refIds.get(value);
1579
1577
  $root.removeRef(previousRefId);
@@ -4066,7 +4064,7 @@ class ReferenceTracker {
4066
4064
  for (const index in metadata) {
4067
4065
  const field = metadata[index].name;
4068
4066
  const childRefId = typeof (ref[field]) === "object" && this.refIds.get(ref[field]);
4069
- if (childRefId) {
4067
+ if (childRefId && !this.deletedRefs.has(childRefId)) {
4070
4068
  this.removeRef(childRefId);
4071
4069
  }
4072
4070
  }
@@ -4074,7 +4072,12 @@ class ReferenceTracker {
4074
4072
  else {
4075
4073
  if (typeof (Object.values(ref[$childType])[0]) === "function") {
4076
4074
  Array.from(ref.values())
4077
- .forEach((child) => this.removeRef(this.refIds.get(child)));
4075
+ .forEach((child) => {
4076
+ const childRefId = this.refIds.get(child);
4077
+ if (!this.deletedRefs.has(childRefId)) {
4078
+ this.removeRef(childRefId);
4079
+ }
4080
+ });
4078
4081
  }
4079
4082
  }
4080
4083
  this.refs.delete(refId); // remove ref