@colyseus/schema 3.0.0-alpha.22 → 3.0.0-alpha.24
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 +22 -6
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +22 -6
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +22 -6
- package/lib/debug.d.ts +1 -0
- package/lib/debug.js +52 -0
- package/lib/debug.js.map +1 -0
- package/lib/decoder/Decoder.d.ts +3 -3
- package/lib/decoder/Decoder.js.map +1 -1
- package/lib/decoder/strategy/StateCallbacks.d.ts +8 -4
- package/lib/decoder/strategy/StateCallbacks.js +17 -5
- package/lib/decoder/strategy/StateCallbacks.js.map +1 -1
- package/lib/encoder/ChangeTree.js.map +1 -1
- package/lib/encoder/Encoder.js +5 -1
- package/lib/encoder/Encoder.js.map +1 -1
- package/package.json +1 -1
- package/src/debug.ts +56 -0
- package/src/decoder/Decoder.ts +3 -3
- package/src/decoder/strategy/StateCallbacks.ts +31 -12
- package/src/encoder/ChangeTree.ts +0 -1
- package/src/encoder/Encoder.ts +7 -2
package/build/cjs/index.js
CHANGED
|
@@ -3510,7 +3510,11 @@ class Encoder {
|
|
|
3510
3510
|
}
|
|
3511
3511
|
if (it.offset > buffer.byteLength) {
|
|
3512
3512
|
const newSize = getNextPowerOf2(buffer.byteLength * 2);
|
|
3513
|
-
console.warn(
|
|
3513
|
+
console.warn(`@colyseus/schema buffer overflow. Encoded state is higher than default BUFFER_SIZE. Use the following to increase default BUFFER_SIZE:
|
|
3514
|
+
|
|
3515
|
+
import { Encoder } from "@colyseus/schema";
|
|
3516
|
+
Encoder.BUFFER_SIZE = ${Math.round(newSize / 1024)} * 1024; // ${Math.round(newSize / 1024)} KB
|
|
3517
|
+
`);
|
|
3514
3518
|
//
|
|
3515
3519
|
// resize buffer and re-encode (TODO: can we avoid re-encoding here?)
|
|
3516
3520
|
//
|
|
@@ -4142,7 +4146,11 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4142
4146
|
}
|
|
4143
4147
|
else {
|
|
4144
4148
|
// collection instance not received yet
|
|
4145
|
-
|
|
4149
|
+
let detachCallback = () => { };
|
|
4150
|
+
context.onInstanceAvailable((ref, existing) => {
|
|
4151
|
+
detachCallback = onAdd(ref, prop, callback, immediate && existing);
|
|
4152
|
+
});
|
|
4153
|
+
return () => detachCallback();
|
|
4146
4154
|
}
|
|
4147
4155
|
},
|
|
4148
4156
|
onChange: function onChange(callback) {
|
|
@@ -4217,19 +4225,27 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4217
4225
|
//
|
|
4218
4226
|
if (context.onInstanceAvailable) {
|
|
4219
4227
|
// collection instance not received yet
|
|
4220
|
-
|
|
4228
|
+
let detachCallback = () => { };
|
|
4229
|
+
context.onInstanceAvailable((ref, existing) => {
|
|
4230
|
+
detachCallback = onAdd(ref, callback, immediate && existing && !isTriggeringOnAdd);
|
|
4231
|
+
});
|
|
4232
|
+
return () => detachCallback();
|
|
4221
4233
|
}
|
|
4222
4234
|
else if (context.instance) {
|
|
4223
|
-
onAdd(context.instance, callback, immediate && !isTriggeringOnAdd);
|
|
4235
|
+
return onAdd(context.instance, callback, immediate && !isTriggeringOnAdd);
|
|
4224
4236
|
}
|
|
4225
4237
|
},
|
|
4226
4238
|
onRemove: function (callback) {
|
|
4227
4239
|
if (context.onInstanceAvailable) {
|
|
4228
4240
|
// collection instance not received yet
|
|
4229
|
-
|
|
4241
|
+
let detachCallback = () => { };
|
|
4242
|
+
context.onInstanceAvailable((ref) => {
|
|
4243
|
+
detachCallback = onRemove(ref, callback);
|
|
4244
|
+
});
|
|
4245
|
+
return () => detachCallback();
|
|
4230
4246
|
}
|
|
4231
4247
|
else if (context.instance) {
|
|
4232
|
-
onRemove(context.instance, callback);
|
|
4248
|
+
return onRemove(context.instance, callback);
|
|
4233
4249
|
}
|
|
4234
4250
|
},
|
|
4235
4251
|
}, {
|