@colyseus/schema 3.0.34 → 3.0.36
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/README.md +5 -5
- package/build/cjs/index.js +3 -3
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +3 -3
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +3 -3
- package/lib/decoder/ReferenceTracker.js +1 -1
- package/lib/decoder/ReferenceTracker.js.map +1 -1
- package/lib/encoder/StateView.js +2 -2
- package/lib/encoder/StateView.js.map +1 -1
- package/package.json +1 -1
- package/src/decoder/ReferenceTracker.ts +2 -2
- package/src/encoder/StateView.ts +2 -3
package/README.md
CHANGED
|
@@ -246,9 +246,9 @@ const decoder = new Decoder(state);
|
|
|
246
246
|
decoder.decode(encodedBytes);
|
|
247
247
|
```
|
|
248
248
|
|
|
249
|
-
### Backwards/forwards
|
|
249
|
+
### Backwards/forwards compatibility
|
|
250
250
|
|
|
251
|
-
Backwards/
|
|
251
|
+
Backwards/forwards compatibility is possible by declaring new fields at the
|
|
252
252
|
end of existing structures, and earlier declarations to not be removed, but
|
|
253
253
|
be marked `@deprecated()` when needed.
|
|
254
254
|
|
|
@@ -307,10 +307,10 @@ Each Colyseus SDK has its own decoder implementation of the `@colyseus/schema` p
|
|
|
307
307
|
|
|
308
308
|
## Why
|
|
309
309
|
|
|
310
|
-
Initial
|
|
310
|
+
Initial thoughts/assumptions, for Colyseus:
|
|
311
311
|
- little to no bottleneck for detecting state changes.
|
|
312
|
-
- have a schema definition on both server and client
|
|
313
|
-
- better experience on
|
|
312
|
+
- have a schema definition on both the server and the client
|
|
313
|
+
- better experience on statically-typed languages (C#, C++)
|
|
314
314
|
- mutations should be cheap.
|
|
315
315
|
|
|
316
316
|
Practical Colyseus issues this should solve:
|
package/build/cjs/index.js
CHANGED
|
@@ -4214,7 +4214,7 @@ class ReferenceTracker {
|
|
|
4214
4214
|
}
|
|
4215
4215
|
removeCallback(refId, field, callback) {
|
|
4216
4216
|
const index = this.callbacks?.[refId]?.[field]?.indexOf(callback);
|
|
4217
|
-
if (index !== -1) {
|
|
4217
|
+
if (index !== undefined && index !== -1) {
|
|
4218
4218
|
spliceOne(this.callbacks[refId][field], index);
|
|
4219
4219
|
}
|
|
4220
4220
|
}
|
|
@@ -4980,7 +4980,7 @@ class StateView {
|
|
|
4980
4980
|
if (tag === DEFAULT_VIEW_TAG) {
|
|
4981
4981
|
// parent is collection (Map/Array)
|
|
4982
4982
|
const parent = changeTree.parent;
|
|
4983
|
-
if (!Metadata.isValidInstance(parent)) {
|
|
4983
|
+
if (!Metadata.isValidInstance(parent) && changeTree.isFiltered) {
|
|
4984
4984
|
const parentChangeTree = parent[$changes];
|
|
4985
4985
|
let changes = this.changes.get(parentChangeTree.refId);
|
|
4986
4986
|
if (changes === undefined) {
|
|
@@ -4992,7 +4992,7 @@ class StateView {
|
|
|
4992
4992
|
}
|
|
4993
4993
|
else {
|
|
4994
4994
|
// delete all "tagged" properties.
|
|
4995
|
-
metadata?.[$viewFieldIndexes]
|
|
4995
|
+
metadata?.[$viewFieldIndexes]?.forEach((index) => changes[index] = exports.OPERATION.DELETE);
|
|
4996
4996
|
}
|
|
4997
4997
|
}
|
|
4998
4998
|
else {
|