@colyseus/schema 3.0.64 → 3.0.66
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 +12 -2
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +12 -2
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +12 -2
- package/lib/Schema.js +3 -1
- package/lib/Schema.js.map +1 -1
- package/lib/encoder/ChangeTree.js +3 -0
- package/lib/encoder/ChangeTree.js.map +1 -1
- package/lib/encoding/decode.js +6 -1
- package/lib/encoding/decode.js.map +1 -1
- package/package.json +1 -1
- package/src/Schema.ts +4 -1
- package/src/encoder/ChangeTree.ts +1 -0
- package/src/encoding/decode.ts +6 -1
package/build/esm/index.mjs
CHANGED
|
@@ -336,6 +336,10 @@ const _float64 = new Float64Array(_convoBuffer);
|
|
|
336
336
|
const _uint64 = new BigUint64Array(_convoBuffer);
|
|
337
337
|
const _int64 = new BigInt64Array(_convoBuffer);
|
|
338
338
|
function utf8Read(bytes, it, length) {
|
|
339
|
+
// boundary check
|
|
340
|
+
if (length > bytes.length - it.offset) {
|
|
341
|
+
length = bytes.length - it.offset;
|
|
342
|
+
}
|
|
339
343
|
var string = '', chr = 0;
|
|
340
344
|
for (var i = it.offset, end = it.offset + length; i < end; i++) {
|
|
341
345
|
var byte = bytes[i];
|
|
@@ -368,9 +372,10 @@ function utf8Read(bytes, it, length) {
|
|
|
368
372
|
}
|
|
369
373
|
continue;
|
|
370
374
|
}
|
|
371
|
-
console.error('Invalid byte ' + byte.toString(16));
|
|
372
375
|
// (do not throw error to avoid server/client from crashing due to hack attemps)
|
|
373
376
|
// throw new Error('Invalid byte ' + byte.toString(16));
|
|
377
|
+
console.error('decode.utf8Read(): Invalid byte ' + byte + ' at offset ' + i + '. Skip to end of string: ' + (it.offset + length));
|
|
378
|
+
break;
|
|
374
379
|
}
|
|
375
380
|
it.offset += length;
|
|
376
381
|
return string;
|
|
@@ -1057,6 +1062,9 @@ class ChangeTree {
|
|
|
1057
1062
|
if (typeof (this.ref[$childType]) !== "string") {
|
|
1058
1063
|
// MapSchema / ArraySchema, etc.
|
|
1059
1064
|
for (const [key, value] of this.ref.entries()) {
|
|
1065
|
+
if (!value) {
|
|
1066
|
+
continue;
|
|
1067
|
+
} // sparse arrays can have undefined values
|
|
1060
1068
|
callback(value[$changes], this.indexes?.[key] ?? key);
|
|
1061
1069
|
}
|
|
1062
1070
|
}
|
|
@@ -3697,7 +3705,9 @@ class Schema {
|
|
|
3697
3705
|
this[$changes].change(metadata[metadata[property]].index, operation);
|
|
3698
3706
|
}
|
|
3699
3707
|
clone() {
|
|
3700
|
-
|
|
3708
|
+
// Create instance without calling custom constructor
|
|
3709
|
+
const cloned = Object.create(this.constructor.prototype);
|
|
3710
|
+
Schema.initialize(cloned);
|
|
3701
3711
|
const metadata = this.constructor[Symbol.metadata];
|
|
3702
3712
|
//
|
|
3703
3713
|
// TODO: clone all properties, not only annotated ones
|