@colyseus/schema 4.0.24 → 4.0.25
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/index.cjs +16 -2
- package/build/index.cjs.map +1 -1
- package/build/index.js +16 -2
- package/build/index.mjs +16 -2
- package/build/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/encoder/ChangeTree.ts +17 -3
package/build/index.cjs
CHANGED
|
@@ -1371,7 +1371,8 @@ class ChangeTree {
|
|
|
1371
1371
|
key += `-${this.root.types.schemas.get(parentConstructor)}`;
|
|
1372
1372
|
}
|
|
1373
1373
|
key += `-${parentIndex}`;
|
|
1374
|
-
const
|
|
1374
|
+
const parentMetadata = parentConstructor?.[Symbol.metadata];
|
|
1375
|
+
const fieldHasViewTag = Metadata.hasViewTagAtIndex(parentMetadata, parentIndex);
|
|
1375
1376
|
this.isFiltered = parent[$changes].isFiltered // in case parent is already filtered
|
|
1376
1377
|
|| this.root.types.parentFiltered[key]
|
|
1377
1378
|
|| fieldHasViewTag;
|
|
@@ -1380,9 +1381,22 @@ class ChangeTree {
|
|
|
1380
1381
|
// when it's available, we need to enqueue the "changes" changeset into the "filteredChanges" changeset.
|
|
1381
1382
|
//
|
|
1382
1383
|
if (this.isFiltered) {
|
|
1384
|
+
//
|
|
1385
|
+
// Children of a `@view(N)` collection (non-default tag) inherit
|
|
1386
|
+
// visibility from their parent, so items pushed/set after the
|
|
1387
|
+
// initial `view.add(state, N)` show up automatically.
|
|
1388
|
+
//
|
|
1389
|
+
// Default-tag `@view()` collections deliberately keep per-item
|
|
1390
|
+
// gating — `view.add(item)` is required to opt each one in.
|
|
1391
|
+
//
|
|
1392
|
+
// The `parentMetadata[parentIndex].tag` access is safe inside
|
|
1393
|
+
// this branch: the OR's short-circuit means we only reach it
|
|
1394
|
+
// when `fieldHasViewTag` is true, which guarantees the metadata
|
|
1395
|
+
// entry and its `tag` property exist.
|
|
1396
|
+
//
|
|
1383
1397
|
this.isVisibilitySharedWithParent = (parentChangeTree.isFiltered &&
|
|
1384
1398
|
typeof (refType) !== "string" &&
|
|
1385
|
-
!fieldHasViewTag);
|
|
1399
|
+
(!fieldHasViewTag || (parentIsCollection && parentMetadata[parentIndex].tag !== DEFAULT_VIEW_TAG)));
|
|
1386
1400
|
if (!this.filteredChanges) {
|
|
1387
1401
|
this.filteredChanges = createChangeSet();
|
|
1388
1402
|
this.allFilteredChanges = createChangeSet();
|