@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.
- package/build/cjs/index.js +15 -4
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +15 -4
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +15 -4
- package/lib/Reflection.js.map +1 -1
- package/lib/Schema.d.ts +8 -1
- package/lib/Schema.js +10 -3
- package/lib/Schema.js.map +1 -1
- package/lib/encoder/ChangeTree.js +5 -1
- package/lib/encoder/ChangeTree.js.map +1 -1
- package/lib/types/custom/MapSchema.d.ts +14 -14
- package/lib/types/custom/MapSchema.js.map +1 -1
- package/package.json +1 -1
- package/src/Reflection.ts +1 -2
- package/src/Schema.ts +10 -3
- package/src/encoder/ChangeTree.ts +9 -3
- package/src/types/custom/MapSchema.ts +12 -12
package/build/cjs/index.js
CHANGED
|
@@ -1339,7 +1339,10 @@ class ChangeTree {
|
|
|
1339
1339
|
if (!parent) {
|
|
1340
1340
|
return;
|
|
1341
1341
|
}
|
|
1342
|
+
//
|
|
1342
1343
|
// ArraySchema | MapSchema - get the child type
|
|
1344
|
+
// (if refType is typeof string, the parentFiltered[key] below will always be invalid)
|
|
1345
|
+
//
|
|
1343
1346
|
const refType = Metadata.isValidInstance(this.ref)
|
|
1344
1347
|
? this.ref.constructor
|
|
1345
1348
|
: this.ref[$childType];
|
|
@@ -1354,7 +1357,8 @@ class ChangeTree {
|
|
|
1354
1357
|
key += `-${this.root.types.schemas.get(parentConstructor)}`;
|
|
1355
1358
|
}
|
|
1356
1359
|
key += `-${parentIndex}`;
|
|
1357
|
-
this.isFiltered =
|
|
1360
|
+
this.isFiltered = parent[$changes].isFiltered // in case parent is already filtered
|
|
1361
|
+
|| this.root.types.parentFiltered[key];
|
|
1358
1362
|
// const parentMetadata = parentConstructor?.[Symbol.metadata];
|
|
1359
1363
|
// this.isFiltered = parentMetadata?.[$viewFieldIndexes]?.includes(parentIndex) || this.root.types.parentFiltered[key];
|
|
1360
1364
|
//
|
|
@@ -3210,13 +3214,20 @@ class Schema {
|
|
|
3210
3214
|
const metadata = this.constructor[Symbol.metadata];
|
|
3211
3215
|
this[metadata[index].name] = undefined;
|
|
3212
3216
|
}
|
|
3213
|
-
|
|
3217
|
+
/**
|
|
3218
|
+
* Inspect the `refId` of all Schema instances in the tree. Optionally display the contents of the instance.
|
|
3219
|
+
*
|
|
3220
|
+
* @param instance Schema instance
|
|
3221
|
+
* @param showContents display JSON contents of the instance
|
|
3222
|
+
* @returns
|
|
3223
|
+
*/
|
|
3224
|
+
static debugRefIds(instance, showContents = false, level = 0) {
|
|
3214
3225
|
const ref = instance;
|
|
3215
3226
|
const changeTree = ref[$changes];
|
|
3216
|
-
const contents = (
|
|
3227
|
+
const contents = (showContents) ? ` - ${JSON.stringify(ref.toJSON())}` : "";
|
|
3217
3228
|
let output = "";
|
|
3218
3229
|
output += `${getIndent(level)}${ref.constructor.name} (refId: ${ref[$changes].refId})${contents}\n`;
|
|
3219
|
-
changeTree.forEachChild((childChangeTree) => output += this.debugRefIds(childChangeTree.ref,
|
|
3230
|
+
changeTree.forEachChild((childChangeTree) => output += this.debugRefIds(childChangeTree.ref, showContents, level + 1));
|
|
3220
3231
|
return output;
|
|
3221
3232
|
}
|
|
3222
3233
|
/**
|