@rive-app/canvas 2.26.5 → 2.26.7
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/package.json +1 -1
- package/rive.d.ts +31 -18
- package/rive.js +290 -99
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_fallback.wasm +0 -0
package/rive.js
CHANGED
|
@@ -746,7 +746,7 @@ function Ya(a, b) {
|
|
|
746
746
|
return Xa(c, a, b);
|
|
747
747
|
}));
|
|
748
748
|
}
|
|
749
|
-
var Za, $a, db = {
|
|
749
|
+
var Za, $a, db = {449468:(a, b, c, d, e) => {
|
|
750
750
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
751
751
|
return 0;
|
|
752
752
|
}
|
|
@@ -809,9 +809,9 @@ var Za, $a, db = {449484:(a, b, c, d, e) => {
|
|
|
809
809
|
}
|
|
810
810
|
window.h.Aa += 1;
|
|
811
811
|
return 1;
|
|
812
|
-
},
|
|
812
|
+
}, 451646:() => {
|
|
813
813
|
"undefined" !== typeof window.h && (--window.h.Aa, 0 === window.h.Aa && delete window.h);
|
|
814
|
-
},
|
|
814
|
+
}, 451810:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 451914:() => {
|
|
815
815
|
try {
|
|
816
816
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
817
817
|
a.close();
|
|
@@ -819,7 +819,7 @@ var Za, $a, db = {449484:(a, b, c, d, e) => {
|
|
|
819
819
|
} catch (c) {
|
|
820
820
|
return 0;
|
|
821
821
|
}
|
|
822
|
-
},
|
|
822
|
+
}, 452085:(a, b, c, d, e, f) => {
|
|
823
823
|
if ("undefined" === typeof window.h) {
|
|
824
824
|
return -1;
|
|
825
825
|
}
|
|
@@ -865,7 +865,7 @@ var Za, $a, db = {449484:(a, b, c, d, e) => {
|
|
|
865
865
|
a == window.h.I.ya && g.Z.connect(g.J.destination);
|
|
866
866
|
g.pb = f;
|
|
867
867
|
return window.h.yc(g);
|
|
868
|
-
},
|
|
868
|
+
}, 454962:a => window.h.ra(a).J.sampleRate, 455035:a => {
|
|
869
869
|
a = window.h.ra(a);
|
|
870
870
|
void 0 !== a.Z && (a.Z.onaudioprocess = function() {
|
|
871
871
|
}, a.Z.disconnect(), a.Z = void 0);
|
|
@@ -873,13 +873,13 @@ var Za, $a, db = {449484:(a, b, c, d, e) => {
|
|
|
873
873
|
a.J.close();
|
|
874
874
|
a.J = void 0;
|
|
875
875
|
a.pb = void 0;
|
|
876
|
-
},
|
|
876
|
+
}, 455435:a => {
|
|
877
877
|
window.h.Cb(a);
|
|
878
|
-
},
|
|
878
|
+
}, 455485:a => {
|
|
879
879
|
a = window.h.ra(a);
|
|
880
880
|
a.J.resume();
|
|
881
881
|
a.state = window.h.ga.xb;
|
|
882
|
-
},
|
|
882
|
+
}, 455624:a => {
|
|
883
883
|
a = window.h.ra(a);
|
|
884
884
|
a.J.suspend();
|
|
885
885
|
a.state = window.h.ga.stopped;
|
|
@@ -3367,7 +3367,7 @@ $d();
|
|
|
3367
3367
|
/* 2 */
|
|
3368
3368
|
/***/ ((module) => {
|
|
3369
3369
|
|
|
3370
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.26.
|
|
3370
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.26.7","description":"Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3371
3371
|
|
|
3372
3372
|
/***/ }),
|
|
3373
3373
|
/* 3 */
|
|
@@ -3917,6 +3917,15 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
|
|
|
3917
3917
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
3918
3918
|
}
|
|
3919
3919
|
};
|
|
3920
|
+
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
3921
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3922
|
+
if (ar || !(i in from)) {
|
|
3923
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
3924
|
+
ar[i] = from[i];
|
|
3925
|
+
}
|
|
3926
|
+
}
|
|
3927
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
3928
|
+
};
|
|
3920
3929
|
|
|
3921
3930
|
|
|
3922
3931
|
|
|
@@ -5310,6 +5319,13 @@ var Rive = /** @class */ (function () {
|
|
|
5310
5319
|
useOffscreenRenderer: params.useOffscreenRenderer,
|
|
5311
5320
|
});
|
|
5312
5321
|
}
|
|
5322
|
+
Object.defineProperty(Rive.prototype, "viewModelCount", {
|
|
5323
|
+
get: function () {
|
|
5324
|
+
return this.file.viewModelCount();
|
|
5325
|
+
},
|
|
5326
|
+
enumerable: false,
|
|
5327
|
+
configurable: true
|
|
5328
|
+
});
|
|
5313
5329
|
// Alternative constructor to build a Rive instance from an interface/object
|
|
5314
5330
|
Rive.new = function (params) {
|
|
5315
5331
|
console.warn("This function is deprecated: please use `new Rive({})` instead");
|
|
@@ -6548,10 +6564,14 @@ var Rive = /** @class */ (function () {
|
|
|
6548
6564
|
viewModelInstance.internalIncrementReferenceCount();
|
|
6549
6565
|
(_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
6550
6566
|
this._viewModelInstance = viewModelInstance;
|
|
6551
|
-
this.
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6567
|
+
if (this.animator.stateMachines.length > 0) {
|
|
6568
|
+
this.animator.stateMachines.forEach(function (stateMachine) {
|
|
6569
|
+
return stateMachine.bindViewModelInstance(viewModelInstance);
|
|
6570
|
+
});
|
|
6571
|
+
}
|
|
6572
|
+
else {
|
|
6573
|
+
this.artboard.bindViewModelInstance(viewModelInstance.runtimeInstance);
|
|
6574
|
+
}
|
|
6555
6575
|
}
|
|
6556
6576
|
}
|
|
6557
6577
|
};
|
|
@@ -6685,12 +6705,26 @@ var DataEnum = /** @class */ (function () {
|
|
|
6685
6705
|
return DataEnum;
|
|
6686
6706
|
}());
|
|
6687
6707
|
|
|
6708
|
+
var PropertyType;
|
|
6709
|
+
(function (PropertyType) {
|
|
6710
|
+
PropertyType["Number"] = "number";
|
|
6711
|
+
PropertyType["String"] = "string";
|
|
6712
|
+
PropertyType["Boolean"] = "boolean";
|
|
6713
|
+
PropertyType["Color"] = "color";
|
|
6714
|
+
PropertyType["Trigger"] = "trigger";
|
|
6715
|
+
PropertyType["Enum"] = "enum";
|
|
6716
|
+
})(PropertyType || (PropertyType = {}));
|
|
6688
6717
|
var ViewModelInstance = /** @class */ (function () {
|
|
6689
|
-
function ViewModelInstance(runtimeInstance,
|
|
6718
|
+
function ViewModelInstance(runtimeInstance, parent) {
|
|
6719
|
+
this._parents = [];
|
|
6720
|
+
this._children = [];
|
|
6721
|
+
this._viewModelInstances = new Map();
|
|
6690
6722
|
this._propertiesWithCallbacks = [];
|
|
6691
6723
|
this._referenceCount = 0;
|
|
6692
6724
|
this._runtimeInstance = runtimeInstance;
|
|
6693
|
-
|
|
6725
|
+
if (parent !== null) {
|
|
6726
|
+
this._parents.push(parent);
|
|
6727
|
+
}
|
|
6694
6728
|
}
|
|
6695
6729
|
Object.defineProperty(ViewModelInstance.prototype, "runtimeInstance", {
|
|
6696
6730
|
get: function () {
|
|
@@ -6704,6 +6738,80 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
6704
6738
|
this._propertiesWithCallbacks.forEach(function (property) {
|
|
6705
6739
|
property.handleCallbacks();
|
|
6706
6740
|
});
|
|
6741
|
+
this._propertiesWithCallbacks.forEach(function (property) {
|
|
6742
|
+
property.clearChanges();
|
|
6743
|
+
});
|
|
6744
|
+
}
|
|
6745
|
+
this._children.forEach(function (child) { return child.handleCallbacks(); });
|
|
6746
|
+
};
|
|
6747
|
+
ViewModelInstance.prototype.addParent = function (parent) {
|
|
6748
|
+
this._parents.push(parent);
|
|
6749
|
+
if (this._propertiesWithCallbacks.length > 0 || this._children.length > 0) {
|
|
6750
|
+
parent.addToViewModelCallbacks(this);
|
|
6751
|
+
}
|
|
6752
|
+
};
|
|
6753
|
+
ViewModelInstance.prototype.removeParent = function (parent) {
|
|
6754
|
+
var index = this._parents.indexOf(parent);
|
|
6755
|
+
if (index !== -1) {
|
|
6756
|
+
var parent_1 = this._parents[index];
|
|
6757
|
+
parent_1.removeFromViewModelCallbacks(this);
|
|
6758
|
+
this._parents.splice(index, 1);
|
|
6759
|
+
}
|
|
6760
|
+
};
|
|
6761
|
+
/*
|
|
6762
|
+
* method for internal use, it shouldn't be called externally
|
|
6763
|
+
*/
|
|
6764
|
+
ViewModelInstance.prototype.addToPropertyCallbacks = function (property) {
|
|
6765
|
+
var _this = this;
|
|
6766
|
+
if (!this._propertiesWithCallbacks.includes(property)) {
|
|
6767
|
+
this._propertiesWithCallbacks.push(property);
|
|
6768
|
+
if (this._propertiesWithCallbacks.length > 0) {
|
|
6769
|
+
this._parents.forEach(function (parent) {
|
|
6770
|
+
parent.addToViewModelCallbacks(_this);
|
|
6771
|
+
});
|
|
6772
|
+
}
|
|
6773
|
+
}
|
|
6774
|
+
};
|
|
6775
|
+
/*
|
|
6776
|
+
* method for internal use, it shouldn't be called externally
|
|
6777
|
+
*/
|
|
6778
|
+
ViewModelInstance.prototype.removeFromPropertyCallbacks = function (property) {
|
|
6779
|
+
var _this = this;
|
|
6780
|
+
if (this._propertiesWithCallbacks.includes(property)) {
|
|
6781
|
+
this._propertiesWithCallbacks = this._propertiesWithCallbacks.filter(function (prop) { return prop !== property; });
|
|
6782
|
+
if (this._children.length === 0 &&
|
|
6783
|
+
this._propertiesWithCallbacks.length === 0) {
|
|
6784
|
+
this._parents.forEach(function (parent) {
|
|
6785
|
+
parent.removeFromViewModelCallbacks(_this);
|
|
6786
|
+
});
|
|
6787
|
+
}
|
|
6788
|
+
}
|
|
6789
|
+
};
|
|
6790
|
+
/*
|
|
6791
|
+
* method for internal use, it shouldn't be called externally
|
|
6792
|
+
*/
|
|
6793
|
+
ViewModelInstance.prototype.addToViewModelCallbacks = function (instance) {
|
|
6794
|
+
var _this = this;
|
|
6795
|
+
if (!this._children.includes(instance)) {
|
|
6796
|
+
this._children.push(instance);
|
|
6797
|
+
this._parents.forEach(function (parent) {
|
|
6798
|
+
parent.addToViewModelCallbacks(_this);
|
|
6799
|
+
});
|
|
6800
|
+
}
|
|
6801
|
+
};
|
|
6802
|
+
/*
|
|
6803
|
+
* method for internal use, it shouldn't be called externally
|
|
6804
|
+
*/
|
|
6805
|
+
ViewModelInstance.prototype.removeFromViewModelCallbacks = function (instance) {
|
|
6806
|
+
var _this = this;
|
|
6807
|
+
if (this._children.includes(instance)) {
|
|
6808
|
+
this._children = this._children.filter(function (child) { return child !== instance; });
|
|
6809
|
+
if (this._children.length === 0 &&
|
|
6810
|
+
this._propertiesWithCallbacks.length === 0) {
|
|
6811
|
+
this._parents.forEach(function (parent) {
|
|
6812
|
+
parent.removeFromViewModelCallbacks(_this);
|
|
6813
|
+
});
|
|
6814
|
+
}
|
|
6707
6815
|
}
|
|
6708
6816
|
};
|
|
6709
6817
|
ViewModelInstance.prototype.clearCallbacks = function () {
|
|
@@ -6711,97 +6819,179 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
6711
6819
|
property.clearCallbacks();
|
|
6712
6820
|
});
|
|
6713
6821
|
};
|
|
6822
|
+
ViewModelInstance.prototype.propertyFromPath = function (path, type) {
|
|
6823
|
+
var pathSegments = path.split("/");
|
|
6824
|
+
return this.propertyFromPathSegments(pathSegments, 0, type);
|
|
6825
|
+
};
|
|
6826
|
+
ViewModelInstance.prototype.viewModelFromPathSegments = function (pathSegments, index) {
|
|
6827
|
+
var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
|
|
6828
|
+
if (viewModelInstance !== null) {
|
|
6829
|
+
if (index == pathSegments.length - 1) {
|
|
6830
|
+
return viewModelInstance;
|
|
6831
|
+
}
|
|
6832
|
+
else {
|
|
6833
|
+
return viewModelInstance.viewModelFromPathSegments(pathSegments, index++);
|
|
6834
|
+
}
|
|
6835
|
+
}
|
|
6836
|
+
return null;
|
|
6837
|
+
};
|
|
6838
|
+
ViewModelInstance.prototype.propertyFromPathSegments = function (pathSegments, index, type) {
|
|
6839
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
6840
|
+
if (index < pathSegments.length - 1) {
|
|
6841
|
+
var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
|
|
6842
|
+
if (viewModelInstance !== null) {
|
|
6843
|
+
return viewModelInstance.propertyFromPathSegments(pathSegments, index + 1, type);
|
|
6844
|
+
}
|
|
6845
|
+
else {
|
|
6846
|
+
return null;
|
|
6847
|
+
}
|
|
6848
|
+
}
|
|
6849
|
+
var instance = null;
|
|
6850
|
+
switch (type) {
|
|
6851
|
+
case PropertyType.Number:
|
|
6852
|
+
instance = (_b = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.number(pathSegments[index])) !== null && _b !== void 0 ? _b : null;
|
|
6853
|
+
if (instance !== null) {
|
|
6854
|
+
return new ViewModelInstanceNumber(instance, this);
|
|
6855
|
+
}
|
|
6856
|
+
break;
|
|
6857
|
+
case PropertyType.String:
|
|
6858
|
+
instance = (_d = (_c = this._runtimeInstance) === null || _c === void 0 ? void 0 : _c.string(pathSegments[index])) !== null && _d !== void 0 ? _d : null;
|
|
6859
|
+
if (instance !== null) {
|
|
6860
|
+
return new ViewModelInstanceString(instance, this);
|
|
6861
|
+
}
|
|
6862
|
+
break;
|
|
6863
|
+
case PropertyType.Boolean:
|
|
6864
|
+
instance = (_f = (_e = this._runtimeInstance) === null || _e === void 0 ? void 0 : _e.boolean(pathSegments[index])) !== null && _f !== void 0 ? _f : null;
|
|
6865
|
+
if (instance !== null) {
|
|
6866
|
+
return new ViewModelInstanceBoolean(instance, this);
|
|
6867
|
+
}
|
|
6868
|
+
break;
|
|
6869
|
+
case PropertyType.Color:
|
|
6870
|
+
instance = (_h = (_g = this._runtimeInstance) === null || _g === void 0 ? void 0 : _g.color(pathSegments[index])) !== null && _h !== void 0 ? _h : null;
|
|
6871
|
+
if (instance !== null) {
|
|
6872
|
+
return new ViewModelInstanceColor(instance, this);
|
|
6873
|
+
}
|
|
6874
|
+
break;
|
|
6875
|
+
case PropertyType.Trigger:
|
|
6876
|
+
instance = (_k = (_j = this._runtimeInstance) === null || _j === void 0 ? void 0 : _j.trigger(pathSegments[index])) !== null && _k !== void 0 ? _k : null;
|
|
6877
|
+
if (instance !== null) {
|
|
6878
|
+
return new ViewModelInstanceTrigger(instance, this);
|
|
6879
|
+
}
|
|
6880
|
+
break;
|
|
6881
|
+
case PropertyType.Enum:
|
|
6882
|
+
instance = (_m = (_l = this._runtimeInstance) === null || _l === void 0 ? void 0 : _l.enum(pathSegments[index])) !== null && _m !== void 0 ? _m : null;
|
|
6883
|
+
if (instance !== null) {
|
|
6884
|
+
return new ViewModelInstanceEnum(instance, this);
|
|
6885
|
+
}
|
|
6886
|
+
break;
|
|
6887
|
+
}
|
|
6888
|
+
return null;
|
|
6889
|
+
};
|
|
6890
|
+
ViewModelInstance.prototype.internalViewModelInstance = function (name) {
|
|
6891
|
+
var _a;
|
|
6892
|
+
if (this._viewModelInstances.has(name)) {
|
|
6893
|
+
return this._viewModelInstances.get(name);
|
|
6894
|
+
}
|
|
6895
|
+
var viewModelRuntimeInstance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.viewModel(name);
|
|
6896
|
+
if (viewModelRuntimeInstance !== null) {
|
|
6897
|
+
var viewModelInstance = new ViewModelInstance(viewModelRuntimeInstance, this);
|
|
6898
|
+
viewModelInstance.internalIncrementReferenceCount();
|
|
6899
|
+
this._viewModelInstances.set(name, viewModelInstance);
|
|
6900
|
+
return viewModelInstance;
|
|
6901
|
+
}
|
|
6902
|
+
return null;
|
|
6903
|
+
};
|
|
6714
6904
|
/**
|
|
6715
6905
|
* method to access a property instance of type number belonging
|
|
6716
6906
|
* to the view model instance or to a nested view model instance
|
|
6717
6907
|
* @param path - path to the number property
|
|
6718
6908
|
*/
|
|
6719
6909
|
ViewModelInstance.prototype.number = function (path) {
|
|
6720
|
-
var
|
|
6721
|
-
|
|
6722
|
-
if (instance) {
|
|
6723
|
-
return new ViewModelInstanceNumber(instance, this._root);
|
|
6724
|
-
}
|
|
6725
|
-
return null;
|
|
6910
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Number);
|
|
6911
|
+
return viewmodelInstanceValue;
|
|
6726
6912
|
};
|
|
6727
6913
|
/**
|
|
6728
6914
|
* method to access a property instance of type string belonging
|
|
6729
6915
|
* to the view model instance or to a nested view model instance
|
|
6730
|
-
* @param path - path to the
|
|
6916
|
+
* @param path - path to the string property
|
|
6731
6917
|
*/
|
|
6732
6918
|
ViewModelInstance.prototype.string = function (path) {
|
|
6733
|
-
var
|
|
6734
|
-
|
|
6735
|
-
if (instance) {
|
|
6736
|
-
return new ViewModelInstanceString(instance, this._root);
|
|
6737
|
-
}
|
|
6738
|
-
return null;
|
|
6919
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.String);
|
|
6920
|
+
return viewmodelInstanceValue;
|
|
6739
6921
|
};
|
|
6740
6922
|
/**
|
|
6741
6923
|
* method to access a property instance of type boolean belonging
|
|
6742
6924
|
* to the view model instance or to a nested view model instance
|
|
6743
|
-
* @param path - path to the
|
|
6925
|
+
* @param path - path to the boolean property
|
|
6744
6926
|
*/
|
|
6745
6927
|
ViewModelInstance.prototype.boolean = function (path) {
|
|
6746
|
-
var
|
|
6747
|
-
|
|
6748
|
-
if (instance) {
|
|
6749
|
-
return new ViewModelInstanceBoolean(instance, this._root);
|
|
6750
|
-
}
|
|
6751
|
-
return null;
|
|
6928
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Boolean);
|
|
6929
|
+
return viewmodelInstanceValue;
|
|
6752
6930
|
};
|
|
6753
6931
|
/**
|
|
6754
6932
|
* method to access a property instance of type color belonging
|
|
6755
6933
|
* to the view model instance or to a nested view model instance
|
|
6756
|
-
* @param path - path to the
|
|
6934
|
+
* @param path - path to the ttrigger property
|
|
6757
6935
|
*/
|
|
6758
6936
|
ViewModelInstance.prototype.color = function (path) {
|
|
6759
|
-
var
|
|
6760
|
-
|
|
6761
|
-
if (instance) {
|
|
6762
|
-
return new ViewModelInstanceColor(instance, this._root);
|
|
6763
|
-
}
|
|
6764
|
-
return null;
|
|
6937
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Color);
|
|
6938
|
+
return viewmodelInstanceValue;
|
|
6765
6939
|
};
|
|
6766
6940
|
/**
|
|
6767
6941
|
* method to access a property instance of type trigger belonging
|
|
6768
6942
|
* to the view model instance or to a nested view model instance
|
|
6769
|
-
* @param path - path to the
|
|
6943
|
+
* @param path - path to the trigger property
|
|
6770
6944
|
*/
|
|
6771
6945
|
ViewModelInstance.prototype.trigger = function (path) {
|
|
6772
|
-
var
|
|
6773
|
-
|
|
6774
|
-
if (instance) {
|
|
6775
|
-
return new ViewModelInstanceTrigger(instance, this._root);
|
|
6776
|
-
}
|
|
6777
|
-
return null;
|
|
6946
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Trigger);
|
|
6947
|
+
return viewmodelInstanceValue;
|
|
6778
6948
|
};
|
|
6779
6949
|
/**
|
|
6780
6950
|
* method to access a property instance of type enum belonging
|
|
6781
6951
|
* to the view model instance or to a nested view model instance
|
|
6782
|
-
* @param path - path to the
|
|
6952
|
+
* @param path - path to the enum property
|
|
6783
6953
|
*/
|
|
6784
6954
|
ViewModelInstance.prototype.enum = function (path) {
|
|
6785
|
-
var
|
|
6786
|
-
|
|
6787
|
-
if (instance) {
|
|
6788
|
-
return new ViewModelInstanceEnum(instance, this._root);
|
|
6789
|
-
}
|
|
6790
|
-
return null;
|
|
6955
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Enum);
|
|
6956
|
+
return viewmodelInstanceValue;
|
|
6791
6957
|
};
|
|
6792
6958
|
/**
|
|
6793
6959
|
* method to access a view model property instance belonging
|
|
6794
6960
|
* to the view model instance or to a nested view model instance
|
|
6795
|
-
* @param path - path to the
|
|
6961
|
+
* @param path - path to the view model property
|
|
6796
6962
|
*/
|
|
6797
6963
|
ViewModelInstance.prototype.viewModel = function (path) {
|
|
6798
|
-
var
|
|
6799
|
-
var
|
|
6800
|
-
|
|
6801
|
-
|
|
6964
|
+
var pathSegments = path.split("/");
|
|
6965
|
+
var parentViewModelInstance = pathSegments.length > 1
|
|
6966
|
+
? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
|
|
6967
|
+
: this;
|
|
6968
|
+
if (parentViewModelInstance != null) {
|
|
6969
|
+
return parentViewModelInstance.internalViewModelInstance(pathSegments[pathSegments.length - 1]);
|
|
6802
6970
|
}
|
|
6803
6971
|
return null;
|
|
6804
6972
|
};
|
|
6973
|
+
ViewModelInstance.prototype.internalReplaceViewModel = function (name, value) {
|
|
6974
|
+
var _a;
|
|
6975
|
+
if (value.runtimeInstance !== null) {
|
|
6976
|
+
var result = ((_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.replaceViewModel(name, value.runtimeInstance)) ||
|
|
6977
|
+
false;
|
|
6978
|
+
if (result) {
|
|
6979
|
+
value.internalIncrementReferenceCount();
|
|
6980
|
+
var oldInstance_1 = this.internalViewModelInstance(name);
|
|
6981
|
+
if (oldInstance_1 !== null) {
|
|
6982
|
+
oldInstance_1.removeParent(this);
|
|
6983
|
+
if (this._children.includes(oldInstance_1)) {
|
|
6984
|
+
this._children = this._children.filter(function (child) { return child !== oldInstance_1; });
|
|
6985
|
+
}
|
|
6986
|
+
oldInstance_1.cleanup();
|
|
6987
|
+
}
|
|
6988
|
+
this._viewModelInstances.set(name, value);
|
|
6989
|
+
value.addParent(this);
|
|
6990
|
+
}
|
|
6991
|
+
return result;
|
|
6992
|
+
}
|
|
6993
|
+
return false;
|
|
6994
|
+
};
|
|
6805
6995
|
/**
|
|
6806
6996
|
* method to replace a view model property with another view model value
|
|
6807
6997
|
* @param path - path to the view model property
|
|
@@ -6809,27 +6999,11 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
6809
6999
|
*/
|
|
6810
7000
|
ViewModelInstance.prototype.replaceViewModel = function (path, value) {
|
|
6811
7001
|
var _a;
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
return false;
|
|
6817
|
-
};
|
|
6818
|
-
/*
|
|
6819
|
-
* method for internal use, it shouldn't be called externally
|
|
6820
|
-
*/
|
|
6821
|
-
ViewModelInstance.prototype.addToCallbacks = function (property) {
|
|
6822
|
-
if (!this._propertiesWithCallbacks.includes(property)) {
|
|
6823
|
-
this._propertiesWithCallbacks.push(property);
|
|
6824
|
-
}
|
|
6825
|
-
};
|
|
6826
|
-
/*
|
|
6827
|
-
* method for internal use, it shouldn't be called externally
|
|
6828
|
-
*/
|
|
6829
|
-
ViewModelInstance.prototype.removeFromCallbacks = function (property) {
|
|
6830
|
-
if (this._propertiesWithCallbacks.includes(property)) {
|
|
6831
|
-
this._propertiesWithCallbacks = this._propertiesWithCallbacks.filter(function (prop) { return prop !== property; });
|
|
6832
|
-
}
|
|
7002
|
+
var pathSegments = path.split("/");
|
|
7003
|
+
var viewModelInstance = pathSegments.length > 1
|
|
7004
|
+
? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
|
|
7005
|
+
: this;
|
|
7006
|
+
return ((_a = viewModelInstance === null || viewModelInstance === void 0 ? void 0 : viewModelInstance.internalReplaceViewModel(pathSegments[pathSegments.length - 1], value)) !== null && _a !== void 0 ? _a : false);
|
|
6833
7007
|
};
|
|
6834
7008
|
/*
|
|
6835
7009
|
* method to add one to the reference counter of the instance.
|
|
@@ -6861,21 +7035,36 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
6861
7035
|
this._referenceCount++;
|
|
6862
7036
|
};
|
|
6863
7037
|
ViewModelInstance.prototype.cleanup = function () {
|
|
7038
|
+
var _this = this;
|
|
6864
7039
|
this._referenceCount--;
|
|
6865
7040
|
if (this._referenceCount <= 0) {
|
|
6866
7041
|
this._runtimeInstance = null;
|
|
6867
7042
|
this.clearCallbacks();
|
|
6868
7043
|
this._propertiesWithCallbacks = [];
|
|
7044
|
+
this._viewModelInstances.forEach(function (value) {
|
|
7045
|
+
value.cleanup();
|
|
7046
|
+
});
|
|
7047
|
+
this._viewModelInstances.clear();
|
|
7048
|
+
var children = __spreadArray([], this._children, true);
|
|
7049
|
+
this._children.length = 0;
|
|
7050
|
+
var parents = __spreadArray([], this._parents, true);
|
|
7051
|
+
this._parents.length = 0;
|
|
7052
|
+
children.forEach(function (child) {
|
|
7053
|
+
child.removeParent(_this);
|
|
7054
|
+
});
|
|
7055
|
+
parents.forEach(function (parent) {
|
|
7056
|
+
parent.removeFromViewModelCallbacks(_this);
|
|
7057
|
+
});
|
|
6869
7058
|
}
|
|
6870
7059
|
};
|
|
6871
7060
|
return ViewModelInstance;
|
|
6872
7061
|
}());
|
|
6873
7062
|
|
|
6874
7063
|
var ViewModelInstanceValue = /** @class */ (function () {
|
|
6875
|
-
function ViewModelInstanceValue(instance,
|
|
7064
|
+
function ViewModelInstanceValue(instance, parent) {
|
|
6876
7065
|
this.callbacks = [];
|
|
6877
7066
|
this._viewModelInstanceValue = instance;
|
|
6878
|
-
this.
|
|
7067
|
+
this._parentViewModel = parent;
|
|
6879
7068
|
}
|
|
6880
7069
|
ViewModelInstanceValue.prototype.on = function (callback) {
|
|
6881
7070
|
// Since we don't clean the changed flag for properties that don't have listeners,
|
|
@@ -6885,7 +7074,7 @@ var ViewModelInstanceValue = /** @class */ (function () {
|
|
|
6885
7074
|
}
|
|
6886
7075
|
if (!this.callbacks.includes(callback)) {
|
|
6887
7076
|
this.callbacks.push(callback);
|
|
6888
|
-
this.
|
|
7077
|
+
this._parentViewModel.addToPropertyCallbacks(this);
|
|
6889
7078
|
}
|
|
6890
7079
|
};
|
|
6891
7080
|
ViewModelInstanceValue.prototype.off = function (callback) {
|
|
@@ -6896,19 +7085,21 @@ var ViewModelInstanceValue = /** @class */ (function () {
|
|
|
6896
7085
|
this.callbacks = this.callbacks.filter(function (cb) { return cb !== callback; });
|
|
6897
7086
|
}
|
|
6898
7087
|
if (this.callbacks.length === 0) {
|
|
6899
|
-
this.
|
|
7088
|
+
this._parentViewModel.removeFromPropertyCallbacks(this);
|
|
6900
7089
|
}
|
|
6901
7090
|
};
|
|
6902
7091
|
ViewModelInstanceValue.prototype.internalHandleCallback = function (callback) { };
|
|
6903
7092
|
ViewModelInstanceValue.prototype.handleCallbacks = function () {
|
|
6904
7093
|
var _this = this;
|
|
6905
7094
|
if (this._viewModelInstanceValue.hasChanged) {
|
|
6906
|
-
this._viewModelInstanceValue.clearChanges();
|
|
6907
7095
|
this.callbacks.forEach(function (callback) {
|
|
6908
7096
|
_this.internalHandleCallback(callback);
|
|
6909
7097
|
});
|
|
6910
7098
|
}
|
|
6911
7099
|
};
|
|
7100
|
+
ViewModelInstanceValue.prototype.clearChanges = function () {
|
|
7101
|
+
this._viewModelInstanceValue.clearChanges();
|
|
7102
|
+
};
|
|
6912
7103
|
ViewModelInstanceValue.prototype.clearCallbacks = function () {
|
|
6913
7104
|
this.callbacks.length = 0;
|
|
6914
7105
|
};
|
|
@@ -6924,8 +7115,8 @@ var ViewModelInstanceValue = /** @class */ (function () {
|
|
|
6924
7115
|
|
|
6925
7116
|
var ViewModelInstanceString = /** @class */ (function (_super) {
|
|
6926
7117
|
__extends(ViewModelInstanceString, _super);
|
|
6927
|
-
function ViewModelInstanceString(instance,
|
|
6928
|
-
return _super.call(this, instance,
|
|
7118
|
+
function ViewModelInstanceString(instance, parent) {
|
|
7119
|
+
return _super.call(this, instance, parent) || this;
|
|
6929
7120
|
}
|
|
6930
7121
|
Object.defineProperty(ViewModelInstanceString.prototype, "value", {
|
|
6931
7122
|
get: function () {
|
|
@@ -6945,8 +7136,8 @@ var ViewModelInstanceString = /** @class */ (function (_super) {
|
|
|
6945
7136
|
|
|
6946
7137
|
var ViewModelInstanceNumber = /** @class */ (function (_super) {
|
|
6947
7138
|
__extends(ViewModelInstanceNumber, _super);
|
|
6948
|
-
function ViewModelInstanceNumber(instance,
|
|
6949
|
-
return _super.call(this, instance,
|
|
7139
|
+
function ViewModelInstanceNumber(instance, parent) {
|
|
7140
|
+
return _super.call(this, instance, parent) || this;
|
|
6950
7141
|
}
|
|
6951
7142
|
Object.defineProperty(ViewModelInstanceNumber.prototype, "value", {
|
|
6952
7143
|
get: function () {
|
|
@@ -6966,8 +7157,8 @@ var ViewModelInstanceNumber = /** @class */ (function (_super) {
|
|
|
6966
7157
|
|
|
6967
7158
|
var ViewModelInstanceBoolean = /** @class */ (function (_super) {
|
|
6968
7159
|
__extends(ViewModelInstanceBoolean, _super);
|
|
6969
|
-
function ViewModelInstanceBoolean(instance,
|
|
6970
|
-
return _super.call(this, instance,
|
|
7160
|
+
function ViewModelInstanceBoolean(instance, parent) {
|
|
7161
|
+
return _super.call(this, instance, parent) || this;
|
|
6971
7162
|
}
|
|
6972
7163
|
Object.defineProperty(ViewModelInstanceBoolean.prototype, "value", {
|
|
6973
7164
|
get: function () {
|
|
@@ -6987,8 +7178,8 @@ var ViewModelInstanceBoolean = /** @class */ (function (_super) {
|
|
|
6987
7178
|
|
|
6988
7179
|
var ViewModelInstanceTrigger = /** @class */ (function (_super) {
|
|
6989
7180
|
__extends(ViewModelInstanceTrigger, _super);
|
|
6990
|
-
function ViewModelInstanceTrigger(instance,
|
|
6991
|
-
return _super.call(this, instance,
|
|
7181
|
+
function ViewModelInstanceTrigger(instance, parent) {
|
|
7182
|
+
return _super.call(this, instance, parent) || this;
|
|
6992
7183
|
}
|
|
6993
7184
|
ViewModelInstanceTrigger.prototype.trigger = function () {
|
|
6994
7185
|
return this._viewModelInstanceValue.trigger();
|
|
@@ -7001,8 +7192,8 @@ var ViewModelInstanceTrigger = /** @class */ (function (_super) {
|
|
|
7001
7192
|
|
|
7002
7193
|
var ViewModelInstanceEnum = /** @class */ (function (_super) {
|
|
7003
7194
|
__extends(ViewModelInstanceEnum, _super);
|
|
7004
|
-
function ViewModelInstanceEnum(instance,
|
|
7005
|
-
return _super.call(this, instance,
|
|
7195
|
+
function ViewModelInstanceEnum(instance, parent) {
|
|
7196
|
+
return _super.call(this, instance, parent) || this;
|
|
7006
7197
|
}
|
|
7007
7198
|
Object.defineProperty(ViewModelInstanceEnum.prototype, "value", {
|
|
7008
7199
|
get: function () {
|
|
@@ -7040,8 +7231,8 @@ var ViewModelInstanceEnum = /** @class */ (function (_super) {
|
|
|
7040
7231
|
|
|
7041
7232
|
var ViewModelInstanceColor = /** @class */ (function (_super) {
|
|
7042
7233
|
__extends(ViewModelInstanceColor, _super);
|
|
7043
|
-
function ViewModelInstanceColor(instance,
|
|
7044
|
-
return _super.call(this, instance,
|
|
7234
|
+
function ViewModelInstanceColor(instance, parent) {
|
|
7235
|
+
return _super.call(this, instance, parent) || this;
|
|
7045
7236
|
}
|
|
7046
7237
|
Object.defineProperty(ViewModelInstanceColor.prototype, "value", {
|
|
7047
7238
|
get: function () {
|