@colyseus/schema 3.0.9 → 3.0.10

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.
@@ -1846,7 +1846,6 @@ class ArraySchema {
1846
1846
  * - Then, the encoder iterates over all "owned" properties per instance and encodes them.
1847
1847
  */
1848
1848
  static [(_a$4 = $encoder, _b$4 = $decoder, $filter)](ref, index, view) {
1849
- // console.log("ArraSchema[$filter] VIEW??", !view)
1850
1849
  return (!view ||
1851
1850
  typeof (ref[$childType]) === "string" ||
1852
1851
  // view.items.has(ref[$getByIndex](index)[$changes])
@@ -2446,6 +2445,7 @@ class ArraySchema {
2446
2445
  }
2447
2446
  [$deleteByIndex](index) {
2448
2447
  this.items[index] = undefined;
2448
+ this.tmpItems[index] = undefined; // TODO: do not try to get "tmpItems" at decoding time.
2449
2449
  }
2450
2450
  [$onEncodeEnd]() {
2451
2451
  this.tmpItems = this.items.slice();
@@ -2453,6 +2453,7 @@ class ArraySchema {
2453
2453
  }
2454
2454
  [$onDecodeEnd]() {
2455
2455
  this.items = this.items.filter((item) => item !== undefined);
2456
+ this.tmpItems = this.items.slice(); // TODO: do no use "tmpItems" at decoding time.
2456
2457
  }
2457
2458
  toArray() {
2458
2459
  return this.items.slice(0);
@@ -3079,7 +3080,6 @@ var _a$2, _b$2;
3079
3080
  class Schema {
3080
3081
  static { this[_a$2] = encodeSchemaOperation; }
3081
3082
  static { this[_b$2] = decodeSchemaOperation; }
3082
- // public [$changes]: ChangeTree;
3083
3083
  /**
3084
3084
  * Assign the property descriptors required to track changes on this instance.
3085
3085
  * @param instance
@@ -3211,16 +3211,16 @@ class Schema {
3211
3211
  /**
3212
3212
  * Inspect the `refId` of all Schema instances in the tree. Optionally display the contents of the instance.
3213
3213
  *
3214
- * @param instance Schema instance
3214
+ * @param ref Schema instance
3215
3215
  * @param showContents display JSON contents of the instance
3216
3216
  * @returns
3217
3217
  */
3218
- static debugRefIds(instance, showContents = false, level = 0) {
3219
- const ref = instance;
3220
- const changeTree = ref[$changes];
3218
+ static debugRefIds(ref, showContents = false, level = 0) {
3221
3219
  const contents = (showContents) ? ` - ${JSON.stringify(ref.toJSON())}` : "";
3220
+ const changeTree = ref[$changes];
3221
+ const refId = changeTree.refId;
3222
3222
  let output = "";
3223
- output += `${getIndent(level)}${ref.constructor.name} (refId: ${ref[$changes].refId})${contents}\n`;
3223
+ output += `${getIndent(level)}${ref.constructor.name} (refId: ${refId})${contents}\n`;
3224
3224
  changeTree.forEachChild((childChangeTree) => output += this.debugRefIds(childChangeTree.ref, showContents, level + 1));
3225
3225
  return output;
3226
3226
  }
@@ -4035,7 +4035,7 @@ class ReferenceTracker {
4035
4035
  const refCount = this.refCounts[refId];
4036
4036
  if (refCount === undefined) {
4037
4037
  try {
4038
- throw new DecodingWarning("trying to remove refId that doesn't exist");
4038
+ throw new DecodingWarning("trying to remove refId that doesn't exist: " + refId);
4039
4039
  }
4040
4040
  catch (e) {
4041
4041
  console.warn(e);