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