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