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