@colyseus/schema 3.0.7 → 3.0.8
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 +13 -8
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +13 -8
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +13 -8
- package/lib/decoder/strategy/StateCallbacks.js +13 -8
- package/lib/decoder/strategy/StateCallbacks.js.map +1 -1
- package/package.json +1 -1
- package/src/decoder/strategy/StateCallbacks.ts +15 -8
package/build/cjs/index.js
CHANGED
|
@@ -4418,6 +4418,7 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4418
4418
|
const onAddCalls = new WeakMap();
|
|
4419
4419
|
let currentOnAddCallback;
|
|
4420
4420
|
decoder.triggerChanges = function (allChanges) {
|
|
4421
|
+
// console.log("ALL CHANGES =>", allChanges);
|
|
4421
4422
|
const uniqueRefIds = new Set();
|
|
4422
4423
|
for (let i = 0, l = allChanges.length; i < l; i++) {
|
|
4423
4424
|
const change = allChanges[i];
|
|
@@ -4560,7 +4561,9 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4560
4561
|
if (metadataField) {
|
|
4561
4562
|
const instance = context.instance?.[prop];
|
|
4562
4563
|
const onInstanceAvailable = ((callback) => {
|
|
4564
|
+
console.log("onInstanceAvailable!!");
|
|
4563
4565
|
const unbind = $(context.instance).listen(prop, (value, _) => {
|
|
4566
|
+
console.log("prop changed!", prop);
|
|
4564
4567
|
callback(value, false);
|
|
4565
4568
|
// FIXME: by "unbinding" the callback here,
|
|
4566
4569
|
// it will not support when the server
|
|
@@ -4608,9 +4611,11 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4608
4611
|
});
|
|
4609
4612
|
};
|
|
4610
4613
|
const onRemove = function (ref, callback) {
|
|
4614
|
+
console.log("REGISTER ON REMOVE ON", $root.refIds.get(ref));
|
|
4611
4615
|
return $root.addCallback($root.refIds.get(ref), exports.OPERATION.DELETE, callback);
|
|
4612
4616
|
};
|
|
4613
4617
|
const onChange = function (ref, callback) {
|
|
4618
|
+
console.log("REGISTER ON CHANGE ON", $root.refIds.get(ref));
|
|
4614
4619
|
return $root.addCallback($root.refIds.get(ref), exports.OPERATION.REPLACE, callback);
|
|
4615
4620
|
};
|
|
4616
4621
|
return new Proxy({
|
|
@@ -4632,7 +4637,10 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4632
4637
|
}
|
|
4633
4638
|
},
|
|
4634
4639
|
onRemove: function (callback) {
|
|
4635
|
-
if (context.
|
|
4640
|
+
if (context.instance) {
|
|
4641
|
+
return onRemove(context.instance, callback);
|
|
4642
|
+
}
|
|
4643
|
+
else if (context.onInstanceAvailable) {
|
|
4636
4644
|
// collection instance not received yet
|
|
4637
4645
|
let detachCallback = () => { };
|
|
4638
4646
|
context.onInstanceAvailable((ref) => {
|
|
@@ -4640,12 +4648,12 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4640
4648
|
});
|
|
4641
4649
|
return () => detachCallback();
|
|
4642
4650
|
}
|
|
4643
|
-
else if (context.instance) {
|
|
4644
|
-
return onRemove(context.instance, callback);
|
|
4645
|
-
}
|
|
4646
4651
|
},
|
|
4647
4652
|
onChange: function (callback) {
|
|
4648
|
-
if (context.
|
|
4653
|
+
if (context.instance) {
|
|
4654
|
+
return onChange(context.instance, callback);
|
|
4655
|
+
}
|
|
4656
|
+
else if (context.onInstanceAvailable) {
|
|
4649
4657
|
// collection instance not received yet
|
|
4650
4658
|
let detachCallback = () => { };
|
|
4651
4659
|
context.onInstanceAvailable((ref) => {
|
|
@@ -4653,9 +4661,6 @@ function getDecoderStateCallbacks(decoder) {
|
|
|
4653
4661
|
});
|
|
4654
4662
|
return () => detachCallback();
|
|
4655
4663
|
}
|
|
4656
|
-
else if (context.instance) {
|
|
4657
|
-
return onChange(context.instance, callback);
|
|
4658
|
-
}
|
|
4659
4664
|
},
|
|
4660
4665
|
}, {
|
|
4661
4666
|
get(target, prop) {
|