@colyseus/schema 4.0.23 → 4.0.24
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 +17 -7
- package/build/index.cjs.map +1 -1
- package/build/index.js +17 -7
- package/build/index.mjs +17 -7
- package/build/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/encoder/ChangeTree.ts +17 -8
package/package.json
CHANGED
|
@@ -403,13 +403,27 @@ export class ChangeTree<T extends Ref = any> {
|
|
|
403
403
|
return;
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
-
|
|
406
|
+
// Mirror `change()`: a field's add/delete must target the same
|
|
407
|
+
// changeset family (filtered vs non-filtered). Otherwise
|
|
408
|
+
// `deleteOperationAtIndex` falls through to its "find last
|
|
409
|
+
// operation" branch and evicts an unrelated sibling field —
|
|
410
|
+
// surfaced as encodeAll() dropping a non-@view field after a
|
|
411
|
+
// sibling @view field is set to undefined on a Schema with
|
|
412
|
+
// mixed @view / non-@view fields (filteredChanges defined,
|
|
413
|
+
// isFiltered false).
|
|
414
|
+
const isFiltered = this.isFiltered || (this.metadata?.[index]?.tag !== undefined);
|
|
415
|
+
const changeSet = (isFiltered)
|
|
407
416
|
? this.filteredChanges
|
|
408
417
|
: this.changes;
|
|
409
418
|
|
|
410
419
|
this.indexedOperations[index] = operation ?? OPERATION.DELETE;
|
|
411
420
|
setOperationAtIndex(changeSet, index);
|
|
412
|
-
|
|
421
|
+
|
|
422
|
+
if (isFiltered) {
|
|
423
|
+
deleteOperationAtIndex(this.allFilteredChanges, allChangesIndex);
|
|
424
|
+
} else {
|
|
425
|
+
deleteOperationAtIndex(this.allChanges, allChangesIndex);
|
|
426
|
+
}
|
|
413
427
|
|
|
414
428
|
const previousValue = this.getValue(index);
|
|
415
429
|
|
|
@@ -428,13 +442,8 @@ export class ChangeTree<T extends Ref = any> {
|
|
|
428
442
|
this.root?.remove(previousValue[$changes]);
|
|
429
443
|
}
|
|
430
444
|
|
|
431
|
-
|
|
432
|
-
// FIXME: this is looking a ugly and repeated
|
|
433
|
-
//
|
|
434
|
-
if (this.filteredChanges !== undefined) {
|
|
435
|
-
deleteOperationAtIndex(this.allFilteredChanges, allChangesIndex);
|
|
445
|
+
if (isFiltered) {
|
|
436
446
|
this.root?.enqueueChangeTree(this, 'filteredChanges');
|
|
437
|
-
|
|
438
447
|
} else {
|
|
439
448
|
this.root?.enqueueChangeTree(this, 'changes');
|
|
440
449
|
}
|