@colyseus/schema 3.0.16 → 3.0.18
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/cjs/index.js +9 -13
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +9 -13
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +9 -13
- package/lib/Metadata.d.ts +3 -3
- package/lib/Metadata.js +6 -0
- package/lib/Metadata.js.map +1 -1
- package/lib/annotations.js.map +1 -1
- package/lib/decoder/DecodeOperation.js +2 -11
- package/lib/decoder/DecodeOperation.js.map +1 -1
- package/lib/decoder/ReferenceTracker.js +7 -2
- package/lib/decoder/ReferenceTracker.js.map +1 -1
- package/package.json +1 -1
- package/src/Metadata.ts +8 -1
- package/src/annotations.ts +1 -1
- package/src/decoder/DecodeOperation.ts +4 -16
- package/src/decoder/ReferenceTracker.ts +7 -2
|
@@ -73,18 +73,6 @@ export function decodeValue(
|
|
|
73
73
|
const refId = decode.number(bytes, it);
|
|
74
74
|
value = $root.refs.get(refId);
|
|
75
75
|
|
|
76
|
-
if (previousValue) {
|
|
77
|
-
const previousRefId = $root.refIds.get(previousValue);
|
|
78
|
-
if (
|
|
79
|
-
previousRefId &&
|
|
80
|
-
refId !== previousRefId &&
|
|
81
|
-
// FIXME: we may need to check for REPLACE operation as well
|
|
82
|
-
((operation & OPERATION.DELETE) === OPERATION.DELETE)
|
|
83
|
-
) {
|
|
84
|
-
$root.removeRef(previousRefId);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
76
|
if ((operation & OPERATION.ADD) === OPERATION.ADD) {
|
|
89
77
|
const childType = decoder.getInstanceType(bytes, it, type);
|
|
90
78
|
if (!value) {
|
|
@@ -101,7 +89,6 @@ export function decodeValue(
|
|
|
101
89
|
);
|
|
102
90
|
}
|
|
103
91
|
|
|
104
|
-
|
|
105
92
|
} else if (typeof(type) === "string") {
|
|
106
93
|
//
|
|
107
94
|
// primitive value (number, string, boolean, etc)
|
|
@@ -123,8 +110,6 @@ export function decodeValue(
|
|
|
123
110
|
let previousRefId = $root.refIds.get(previousValue);
|
|
124
111
|
|
|
125
112
|
if (previousRefId !== undefined && refId !== previousRefId) {
|
|
126
|
-
$root.removeRef(previousRefId);
|
|
127
|
-
|
|
128
113
|
//
|
|
129
114
|
// enqueue onRemove if structure has been replaced.
|
|
130
115
|
//
|
|
@@ -153,7 +138,10 @@ export function decodeValue(
|
|
|
153
138
|
}
|
|
154
139
|
}
|
|
155
140
|
|
|
156
|
-
$root.addRef(refId, value, (
|
|
141
|
+
$root.addRef(refId, value, (
|
|
142
|
+
valueRef !== previousValue ||
|
|
143
|
+
(operation === OPERATION.DELETE_AND_ADD && valueRef === previousValue)
|
|
144
|
+
));
|
|
157
145
|
}
|
|
158
146
|
|
|
159
147
|
return { value, previousValue };
|
|
@@ -103,7 +103,7 @@ export class ReferenceTracker {
|
|
|
103
103
|
for (const index in metadata) {
|
|
104
104
|
const field = metadata[index as any as number].name;
|
|
105
105
|
const childRefId = typeof(ref[field]) === "object" && this.refIds.get(ref[field]);
|
|
106
|
-
if (childRefId) {
|
|
106
|
+
if (childRefId && !this.deletedRefs.has(childRefId)) {
|
|
107
107
|
this.removeRef(childRefId);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -111,7 +111,12 @@ export class ReferenceTracker {
|
|
|
111
111
|
} else {
|
|
112
112
|
if (typeof (Object.values(ref[$childType])[0]) === "function") {
|
|
113
113
|
Array.from((ref as MapSchema).values())
|
|
114
|
-
.forEach((child) =>
|
|
114
|
+
.forEach((child) => {
|
|
115
|
+
const childRefId = this.refIds.get(child);
|
|
116
|
+
if (!this.deletedRefs.has(childRefId)) {
|
|
117
|
+
this.removeRef(childRefId);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
122
|
|