@colyseus/schema 4.0.14 → 4.0.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colyseus/schema",
3
- "version": "4.0.14",
3
+ "version": "4.0.16",
4
4
  "description": "Binary state serializer with delta encoding for games",
5
5
  "type": "module",
6
6
  "bin": {
@@ -77,12 +77,15 @@ function inspectNode(node: ts.Node, context: Context, decoratorName: string) {
77
77
 
78
78
  case ts.SyntaxKind.PropertySignature:
79
79
  if (currentStructure instanceof Interface) {
80
- const interfaceDeclaration = node.parent;
80
+ const parent = node.parent;
81
81
 
82
- if (
83
- currentStructure.name !== (interfaceDeclaration as ts.TypeParameterDeclaration).name.escapedText.toString()
84
- ) {
85
- // skip if property if for a another interface than the one we're interested in.
82
+ // Only process direct children of InterfaceDeclaration, skip TypeLiterals
83
+ if (!ts.isInterfaceDeclaration(parent)) {
84
+ break;
85
+ }
86
+
87
+ // Skip if property if for a another interface than the one we're interested in.
88
+ if (currentStructure.name !== parent.name.escapedText.toString()) {
86
89
  break;
87
90
  }
88
91
 
@@ -261,14 +261,31 @@ export class StateView {
261
261
 
262
262
  } else {
263
263
  // delete all "tagged" properties.
264
- metadata?.[$viewFieldIndexes]?.forEach((index) =>
265
- changes[index] = OPERATION.DELETE);
264
+ metadata?.[$viewFieldIndexes]?.forEach((index) => {
265
+ changes[index] = OPERATION.DELETE;
266
+
267
+ // Remove child structures of @view() fields from visible set.
268
+ // (They were added during view.add() via forEachChild)
269
+ const value = changeTree.ref[metadata[index].name as keyof Ref];
270
+ if (value?.[$changes]) {
271
+ this.visible.delete(value[$changes]);
272
+ this._recursiveDeleteVisibleChangeTree(value[$changes]);
273
+ }
274
+ });
266
275
  }
267
276
 
268
277
  } else {
269
278
  // delete only tagged properties
270
- metadata?.[$fieldIndexesByViewTag][tag].forEach((index) =>
271
- changes[index] = OPERATION.DELETE);
279
+ metadata?.[$fieldIndexesByViewTag][tag].forEach((index) => {
280
+ changes[index] = OPERATION.DELETE;
281
+
282
+ // Remove child structures from visible set
283
+ const value = changeTree.ref[metadata[index].name as keyof Ref];
284
+ if (value?.[$changes]) {
285
+ this.visible.delete(value[$changes]);
286
+ this._recursiveDeleteVisibleChangeTree(value[$changes]);
287
+ }
288
+ });
272
289
  }
273
290
 
274
291
  // remove tag