@colyseus/schema 3.0.0-alpha.47 → 3.0.0-alpha.49

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.
@@ -1337,7 +1337,10 @@ class ChangeTree {
1337
1337
  if (!parent) {
1338
1338
  return;
1339
1339
  }
1340
+ //
1340
1341
  // ArraySchema | MapSchema - get the child type
1342
+ // (if refType is typeof string, the parentFiltered[key] below will always be invalid)
1343
+ //
1341
1344
  const refType = Metadata.isValidInstance(this.ref)
1342
1345
  ? this.ref.constructor
1343
1346
  : this.ref[$childType];
@@ -1352,7 +1355,8 @@ class ChangeTree {
1352
1355
  key += `-${this.root.types.schemas.get(parentConstructor)}`;
1353
1356
  }
1354
1357
  key += `-${parentIndex}`;
1355
- this.isFiltered = this.root.types.parentFiltered[key];
1358
+ this.isFiltered = parent[$changes].isFiltered // in case parent is already filtered
1359
+ || this.root.types.parentFiltered[key];
1356
1360
  // const parentMetadata = parentConstructor?.[Symbol.metadata];
1357
1361
  // this.isFiltered = parentMetadata?.[$viewFieldIndexes]?.includes(parentIndex) || this.root.types.parentFiltered[key];
1358
1362
  //
@@ -3208,13 +3212,20 @@ class Schema {
3208
3212
  const metadata = this.constructor[Symbol.metadata];
3209
3213
  this[metadata[index].name] = undefined;
3210
3214
  }
3211
- static debugRefIds(instance, jsonContents = true, level = 0) {
3215
+ /**
3216
+ * Inspect the `refId` of all Schema instances in the tree. Optionally display the contents of the instance.
3217
+ *
3218
+ * @param instance Schema instance
3219
+ * @param showContents display JSON contents of the instance
3220
+ * @returns
3221
+ */
3222
+ static debugRefIds(instance, showContents = false, level = 0) {
3212
3223
  const ref = instance;
3213
3224
  const changeTree = ref[$changes];
3214
- const contents = (jsonContents) ? ` - ${JSON.stringify(ref.toJSON())}` : "";
3225
+ const contents = (showContents) ? ` - ${JSON.stringify(ref.toJSON())}` : "";
3215
3226
  let output = "";
3216
3227
  output += `${getIndent(level)}${ref.constructor.name} (refId: ${ref[$changes].refId})${contents}\n`;
3217
- changeTree.forEachChild((childChangeTree) => output += this.debugRefIds(childChangeTree.ref, jsonContents, level + 1));
3228
+ changeTree.forEachChild((childChangeTree) => output += this.debugRefIds(childChangeTree.ref, showContents, level + 1));
3218
3229
  return output;
3219
3230
  }
3220
3231
  /**