@colyseus/schema 4.0.11 → 4.0.13

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.js CHANGED
@@ -4058,7 +4058,11 @@
4058
4058
  const ref = changeTree.ref;
4059
4059
  // Assign unique `refId` to ref if it doesn't have one yet.
4060
4060
  if (ref[$refId] === undefined) {
4061
- ref[$refId] = this.getNextUniqueId();
4061
+ Object.defineProperty(ref, $refId, {
4062
+ value: this.getNextUniqueId(),
4063
+ enumerable: false,
4064
+ writable: true
4065
+ });
4062
4066
  }
4063
4067
  const refId = ref[$refId];
4064
4068
  const isNewChangeTree = (this.changeTrees[refId] === undefined);
@@ -4500,7 +4504,11 @@
4500
4504
  // for decoding
4501
4505
  addRef(refId, ref, incrementCount = true) {
4502
4506
  this.refs.set(refId, ref);
4503
- ref[$refId] = refId;
4507
+ Object.defineProperty(ref, $refId, {
4508
+ value: refId,
4509
+ enumerable: false,
4510
+ writable: true
4511
+ });
4504
4512
  if (incrementCount) {
4505
4513
  this.refCount[refId] = (this.refCount[refId] || 0) + 1;
4506
4514
  }
@@ -5192,11 +5200,15 @@
5192
5200
  const collection = instance[propertyName];
5193
5201
  // Collection not available yet. Listen for its availability before attaching the handler.
5194
5202
  if (!collection || collection[$refId] === undefined) {
5195
- removeHandler = this.addCallback(instance[$refId], propertyName, (value, _) => {
5203
+ let removePropertyCallback;
5204
+ removePropertyCallback = this.addCallback(instance[$refId], propertyName, (value, _) => {
5196
5205
  if (value !== null && value !== undefined) {
5206
+ // Remove the property listener now that collection is available
5207
+ removePropertyCallback();
5197
5208
  removeHandler = this.addCallback(value[$refId], operation, handler);
5198
5209
  }
5199
5210
  });
5211
+ removeHandler = removePropertyCallback;
5200
5212
  return removeOnAdd;
5201
5213
  }
5202
5214
  else {
package/build/index.mjs CHANGED
@@ -4052,7 +4052,11 @@ class Root {
4052
4052
  const ref = changeTree.ref;
4053
4053
  // Assign unique `refId` to ref if it doesn't have one yet.
4054
4054
  if (ref[$refId] === undefined) {
4055
- ref[$refId] = this.getNextUniqueId();
4055
+ Object.defineProperty(ref, $refId, {
4056
+ value: this.getNextUniqueId(),
4057
+ enumerable: false,
4058
+ writable: true
4059
+ });
4056
4060
  }
4057
4061
  const refId = ref[$refId];
4058
4062
  const isNewChangeTree = (this.changeTrees[refId] === undefined);
@@ -4494,7 +4498,11 @@ class ReferenceTracker {
4494
4498
  // for decoding
4495
4499
  addRef(refId, ref, incrementCount = true) {
4496
4500
  this.refs.set(refId, ref);
4497
- ref[$refId] = refId;
4501
+ Object.defineProperty(ref, $refId, {
4502
+ value: refId,
4503
+ enumerable: false,
4504
+ writable: true
4505
+ });
4498
4506
  if (incrementCount) {
4499
4507
  this.refCount[refId] = (this.refCount[refId] || 0) + 1;
4500
4508
  }
@@ -5186,11 +5194,15 @@ class StateCallbackStrategy {
5186
5194
  const collection = instance[propertyName];
5187
5195
  // Collection not available yet. Listen for its availability before attaching the handler.
5188
5196
  if (!collection || collection[$refId] === undefined) {
5189
- removeHandler = this.addCallback(instance[$refId], propertyName, (value, _) => {
5197
+ let removePropertyCallback;
5198
+ removePropertyCallback = this.addCallback(instance[$refId], propertyName, (value, _) => {
5190
5199
  if (value !== null && value !== undefined) {
5200
+ // Remove the property listener now that collection is available
5201
+ removePropertyCallback();
5191
5202
  removeHandler = this.addCallback(value[$refId], operation, handler);
5192
5203
  }
5193
5204
  });
5205
+ removeHandler = removePropertyCallback;
5194
5206
  return removeOnAdd;
5195
5207
  }
5196
5208
  else {