@colyseus/schema 4.0.10 → 4.0.12
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 +11 -3
- package/build/index.cjs.map +1 -1
- package/build/index.js +11 -3
- package/build/index.mjs +11 -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 +1 -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
|
}
|
|
@@ -5187,7 +5195,7 @@ class StateCallbackStrategy {
|
|
|
5187
5195
|
const removeOnAdd = () => removeHandler();
|
|
5188
5196
|
const collection = instance[propertyName];
|
|
5189
5197
|
// Collection not available yet. Listen for its availability before attaching the handler.
|
|
5190
|
-
if (collection
|
|
5198
|
+
if (!collection || collection[$refId] === undefined) {
|
|
5191
5199
|
removeHandler = this.addCallback(instance[$refId], propertyName, (value, _) => {
|
|
5192
5200
|
if (value !== null && value !== undefined) {
|
|
5193
5201
|
removeHandler = this.addCallback(value[$refId], operation, handler);
|