@rive-app/canvas-lite 2.26.6 → 2.26.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/package.json +1 -1
- package/rive.d.ts +31 -18
- package/rive.js +282 -91
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_fallback.wasm +0 -0
package/rive.js
CHANGED
|
@@ -2271,7 +2271,7 @@ Qc();
|
|
|
2271
2271
|
/* 2 */
|
|
2272
2272
|
/***/ ((module) => {
|
|
2273
2273
|
|
|
2274
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.26.
|
|
2274
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.26.8","description":"A lite version of 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}}');
|
|
2275
2275
|
|
|
2276
2276
|
/***/ }),
|
|
2277
2277
|
/* 3 */
|
|
@@ -2821,6 +2821,15 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
|
|
|
2821
2821
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2822
2822
|
}
|
|
2823
2823
|
};
|
|
2824
|
+
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
2825
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2826
|
+
if (ar || !(i in from)) {
|
|
2827
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2828
|
+
ar[i] = from[i];
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2832
|
+
};
|
|
2824
2833
|
|
|
2825
2834
|
|
|
2826
2835
|
|
|
@@ -4214,6 +4223,13 @@ var Rive = /** @class */ (function () {
|
|
|
4214
4223
|
useOffscreenRenderer: params.useOffscreenRenderer,
|
|
4215
4224
|
});
|
|
4216
4225
|
}
|
|
4226
|
+
Object.defineProperty(Rive.prototype, "viewModelCount", {
|
|
4227
|
+
get: function () {
|
|
4228
|
+
return this.file.viewModelCount();
|
|
4229
|
+
},
|
|
4230
|
+
enumerable: false,
|
|
4231
|
+
configurable: true
|
|
4232
|
+
});
|
|
4217
4233
|
// Alternative constructor to build a Rive instance from an interface/object
|
|
4218
4234
|
Rive.new = function (params) {
|
|
4219
4235
|
console.warn("This function is deprecated: please use `new Rive({})` instead");
|
|
@@ -5452,10 +5468,14 @@ var Rive = /** @class */ (function () {
|
|
|
5452
5468
|
viewModelInstance.internalIncrementReferenceCount();
|
|
5453
5469
|
(_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
5454
5470
|
this._viewModelInstance = viewModelInstance;
|
|
5455
|
-
this.
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5471
|
+
if (this.animator.stateMachines.length > 0) {
|
|
5472
|
+
this.animator.stateMachines.forEach(function (stateMachine) {
|
|
5473
|
+
return stateMachine.bindViewModelInstance(viewModelInstance);
|
|
5474
|
+
});
|
|
5475
|
+
}
|
|
5476
|
+
else {
|
|
5477
|
+
this.artboard.bindViewModelInstance(viewModelInstance.runtimeInstance);
|
|
5478
|
+
}
|
|
5459
5479
|
}
|
|
5460
5480
|
}
|
|
5461
5481
|
};
|
|
@@ -5589,12 +5609,26 @@ var DataEnum = /** @class */ (function () {
|
|
|
5589
5609
|
return DataEnum;
|
|
5590
5610
|
}());
|
|
5591
5611
|
|
|
5612
|
+
var PropertyType;
|
|
5613
|
+
(function (PropertyType) {
|
|
5614
|
+
PropertyType["Number"] = "number";
|
|
5615
|
+
PropertyType["String"] = "string";
|
|
5616
|
+
PropertyType["Boolean"] = "boolean";
|
|
5617
|
+
PropertyType["Color"] = "color";
|
|
5618
|
+
PropertyType["Trigger"] = "trigger";
|
|
5619
|
+
PropertyType["Enum"] = "enum";
|
|
5620
|
+
})(PropertyType || (PropertyType = {}));
|
|
5592
5621
|
var ViewModelInstance = /** @class */ (function () {
|
|
5593
|
-
function ViewModelInstance(runtimeInstance,
|
|
5622
|
+
function ViewModelInstance(runtimeInstance, parent) {
|
|
5623
|
+
this._parents = [];
|
|
5624
|
+
this._children = [];
|
|
5625
|
+
this._viewModelInstances = new Map();
|
|
5594
5626
|
this._propertiesWithCallbacks = [];
|
|
5595
5627
|
this._referenceCount = 0;
|
|
5596
5628
|
this._runtimeInstance = runtimeInstance;
|
|
5597
|
-
|
|
5629
|
+
if (parent !== null) {
|
|
5630
|
+
this._parents.push(parent);
|
|
5631
|
+
}
|
|
5598
5632
|
}
|
|
5599
5633
|
Object.defineProperty(ViewModelInstance.prototype, "runtimeInstance", {
|
|
5600
5634
|
get: function () {
|
|
@@ -5608,6 +5642,80 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
5608
5642
|
this._propertiesWithCallbacks.forEach(function (property) {
|
|
5609
5643
|
property.handleCallbacks();
|
|
5610
5644
|
});
|
|
5645
|
+
this._propertiesWithCallbacks.forEach(function (property) {
|
|
5646
|
+
property.clearChanges();
|
|
5647
|
+
});
|
|
5648
|
+
}
|
|
5649
|
+
this._children.forEach(function (child) { return child.handleCallbacks(); });
|
|
5650
|
+
};
|
|
5651
|
+
ViewModelInstance.prototype.addParent = function (parent) {
|
|
5652
|
+
this._parents.push(parent);
|
|
5653
|
+
if (this._propertiesWithCallbacks.length > 0 || this._children.length > 0) {
|
|
5654
|
+
parent.addToViewModelCallbacks(this);
|
|
5655
|
+
}
|
|
5656
|
+
};
|
|
5657
|
+
ViewModelInstance.prototype.removeParent = function (parent) {
|
|
5658
|
+
var index = this._parents.indexOf(parent);
|
|
5659
|
+
if (index !== -1) {
|
|
5660
|
+
var parent_1 = this._parents[index];
|
|
5661
|
+
parent_1.removeFromViewModelCallbacks(this);
|
|
5662
|
+
this._parents.splice(index, 1);
|
|
5663
|
+
}
|
|
5664
|
+
};
|
|
5665
|
+
/*
|
|
5666
|
+
* method for internal use, it shouldn't be called externally
|
|
5667
|
+
*/
|
|
5668
|
+
ViewModelInstance.prototype.addToPropertyCallbacks = function (property) {
|
|
5669
|
+
var _this = this;
|
|
5670
|
+
if (!this._propertiesWithCallbacks.includes(property)) {
|
|
5671
|
+
this._propertiesWithCallbacks.push(property);
|
|
5672
|
+
if (this._propertiesWithCallbacks.length > 0) {
|
|
5673
|
+
this._parents.forEach(function (parent) {
|
|
5674
|
+
parent.addToViewModelCallbacks(_this);
|
|
5675
|
+
});
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
};
|
|
5679
|
+
/*
|
|
5680
|
+
* method for internal use, it shouldn't be called externally
|
|
5681
|
+
*/
|
|
5682
|
+
ViewModelInstance.prototype.removeFromPropertyCallbacks = function (property) {
|
|
5683
|
+
var _this = this;
|
|
5684
|
+
if (this._propertiesWithCallbacks.includes(property)) {
|
|
5685
|
+
this._propertiesWithCallbacks = this._propertiesWithCallbacks.filter(function (prop) { return prop !== property; });
|
|
5686
|
+
if (this._children.length === 0 &&
|
|
5687
|
+
this._propertiesWithCallbacks.length === 0) {
|
|
5688
|
+
this._parents.forEach(function (parent) {
|
|
5689
|
+
parent.removeFromViewModelCallbacks(_this);
|
|
5690
|
+
});
|
|
5691
|
+
}
|
|
5692
|
+
}
|
|
5693
|
+
};
|
|
5694
|
+
/*
|
|
5695
|
+
* method for internal use, it shouldn't be called externally
|
|
5696
|
+
*/
|
|
5697
|
+
ViewModelInstance.prototype.addToViewModelCallbacks = function (instance) {
|
|
5698
|
+
var _this = this;
|
|
5699
|
+
if (!this._children.includes(instance)) {
|
|
5700
|
+
this._children.push(instance);
|
|
5701
|
+
this._parents.forEach(function (parent) {
|
|
5702
|
+
parent.addToViewModelCallbacks(_this);
|
|
5703
|
+
});
|
|
5704
|
+
}
|
|
5705
|
+
};
|
|
5706
|
+
/*
|
|
5707
|
+
* method for internal use, it shouldn't be called externally
|
|
5708
|
+
*/
|
|
5709
|
+
ViewModelInstance.prototype.removeFromViewModelCallbacks = function (instance) {
|
|
5710
|
+
var _this = this;
|
|
5711
|
+
if (this._children.includes(instance)) {
|
|
5712
|
+
this._children = this._children.filter(function (child) { return child !== instance; });
|
|
5713
|
+
if (this._children.length === 0 &&
|
|
5714
|
+
this._propertiesWithCallbacks.length === 0) {
|
|
5715
|
+
this._parents.forEach(function (parent) {
|
|
5716
|
+
parent.removeFromViewModelCallbacks(_this);
|
|
5717
|
+
});
|
|
5718
|
+
}
|
|
5611
5719
|
}
|
|
5612
5720
|
};
|
|
5613
5721
|
ViewModelInstance.prototype.clearCallbacks = function () {
|
|
@@ -5615,97 +5723,179 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
5615
5723
|
property.clearCallbacks();
|
|
5616
5724
|
});
|
|
5617
5725
|
};
|
|
5726
|
+
ViewModelInstance.prototype.propertyFromPath = function (path, type) {
|
|
5727
|
+
var pathSegments = path.split("/");
|
|
5728
|
+
return this.propertyFromPathSegments(pathSegments, 0, type);
|
|
5729
|
+
};
|
|
5730
|
+
ViewModelInstance.prototype.viewModelFromPathSegments = function (pathSegments, index) {
|
|
5731
|
+
var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
|
|
5732
|
+
if (viewModelInstance !== null) {
|
|
5733
|
+
if (index == pathSegments.length - 1) {
|
|
5734
|
+
return viewModelInstance;
|
|
5735
|
+
}
|
|
5736
|
+
else {
|
|
5737
|
+
return viewModelInstance.viewModelFromPathSegments(pathSegments, index++);
|
|
5738
|
+
}
|
|
5739
|
+
}
|
|
5740
|
+
return null;
|
|
5741
|
+
};
|
|
5742
|
+
ViewModelInstance.prototype.propertyFromPathSegments = function (pathSegments, index, type) {
|
|
5743
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
5744
|
+
if (index < pathSegments.length - 1) {
|
|
5745
|
+
var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
|
|
5746
|
+
if (viewModelInstance !== null) {
|
|
5747
|
+
return viewModelInstance.propertyFromPathSegments(pathSegments, index + 1, type);
|
|
5748
|
+
}
|
|
5749
|
+
else {
|
|
5750
|
+
return null;
|
|
5751
|
+
}
|
|
5752
|
+
}
|
|
5753
|
+
var instance = null;
|
|
5754
|
+
switch (type) {
|
|
5755
|
+
case PropertyType.Number:
|
|
5756
|
+
instance = (_b = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.number(pathSegments[index])) !== null && _b !== void 0 ? _b : null;
|
|
5757
|
+
if (instance !== null) {
|
|
5758
|
+
return new ViewModelInstanceNumber(instance, this);
|
|
5759
|
+
}
|
|
5760
|
+
break;
|
|
5761
|
+
case PropertyType.String:
|
|
5762
|
+
instance = (_d = (_c = this._runtimeInstance) === null || _c === void 0 ? void 0 : _c.string(pathSegments[index])) !== null && _d !== void 0 ? _d : null;
|
|
5763
|
+
if (instance !== null) {
|
|
5764
|
+
return new ViewModelInstanceString(instance, this);
|
|
5765
|
+
}
|
|
5766
|
+
break;
|
|
5767
|
+
case PropertyType.Boolean:
|
|
5768
|
+
instance = (_f = (_e = this._runtimeInstance) === null || _e === void 0 ? void 0 : _e.boolean(pathSegments[index])) !== null && _f !== void 0 ? _f : null;
|
|
5769
|
+
if (instance !== null) {
|
|
5770
|
+
return new ViewModelInstanceBoolean(instance, this);
|
|
5771
|
+
}
|
|
5772
|
+
break;
|
|
5773
|
+
case PropertyType.Color:
|
|
5774
|
+
instance = (_h = (_g = this._runtimeInstance) === null || _g === void 0 ? void 0 : _g.color(pathSegments[index])) !== null && _h !== void 0 ? _h : null;
|
|
5775
|
+
if (instance !== null) {
|
|
5776
|
+
return new ViewModelInstanceColor(instance, this);
|
|
5777
|
+
}
|
|
5778
|
+
break;
|
|
5779
|
+
case PropertyType.Trigger:
|
|
5780
|
+
instance = (_k = (_j = this._runtimeInstance) === null || _j === void 0 ? void 0 : _j.trigger(pathSegments[index])) !== null && _k !== void 0 ? _k : null;
|
|
5781
|
+
if (instance !== null) {
|
|
5782
|
+
return new ViewModelInstanceTrigger(instance, this);
|
|
5783
|
+
}
|
|
5784
|
+
break;
|
|
5785
|
+
case PropertyType.Enum:
|
|
5786
|
+
instance = (_m = (_l = this._runtimeInstance) === null || _l === void 0 ? void 0 : _l.enum(pathSegments[index])) !== null && _m !== void 0 ? _m : null;
|
|
5787
|
+
if (instance !== null) {
|
|
5788
|
+
return new ViewModelInstanceEnum(instance, this);
|
|
5789
|
+
}
|
|
5790
|
+
break;
|
|
5791
|
+
}
|
|
5792
|
+
return null;
|
|
5793
|
+
};
|
|
5794
|
+
ViewModelInstance.prototype.internalViewModelInstance = function (name) {
|
|
5795
|
+
var _a;
|
|
5796
|
+
if (this._viewModelInstances.has(name)) {
|
|
5797
|
+
return this._viewModelInstances.get(name);
|
|
5798
|
+
}
|
|
5799
|
+
var viewModelRuntimeInstance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.viewModel(name);
|
|
5800
|
+
if (viewModelRuntimeInstance !== null) {
|
|
5801
|
+
var viewModelInstance = new ViewModelInstance(viewModelRuntimeInstance, this);
|
|
5802
|
+
viewModelInstance.internalIncrementReferenceCount();
|
|
5803
|
+
this._viewModelInstances.set(name, viewModelInstance);
|
|
5804
|
+
return viewModelInstance;
|
|
5805
|
+
}
|
|
5806
|
+
return null;
|
|
5807
|
+
};
|
|
5618
5808
|
/**
|
|
5619
5809
|
* method to access a property instance of type number belonging
|
|
5620
5810
|
* to the view model instance or to a nested view model instance
|
|
5621
5811
|
* @param path - path to the number property
|
|
5622
5812
|
*/
|
|
5623
5813
|
ViewModelInstance.prototype.number = function (path) {
|
|
5624
|
-
var
|
|
5625
|
-
|
|
5626
|
-
if (instance) {
|
|
5627
|
-
return new ViewModelInstanceNumber(instance, this._root);
|
|
5628
|
-
}
|
|
5629
|
-
return null;
|
|
5814
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Number);
|
|
5815
|
+
return viewmodelInstanceValue;
|
|
5630
5816
|
};
|
|
5631
5817
|
/**
|
|
5632
5818
|
* method to access a property instance of type string belonging
|
|
5633
5819
|
* to the view model instance or to a nested view model instance
|
|
5634
|
-
* @param path - path to the
|
|
5820
|
+
* @param path - path to the string property
|
|
5635
5821
|
*/
|
|
5636
5822
|
ViewModelInstance.prototype.string = function (path) {
|
|
5637
|
-
var
|
|
5638
|
-
|
|
5639
|
-
if (instance) {
|
|
5640
|
-
return new ViewModelInstanceString(instance, this._root);
|
|
5641
|
-
}
|
|
5642
|
-
return null;
|
|
5823
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.String);
|
|
5824
|
+
return viewmodelInstanceValue;
|
|
5643
5825
|
};
|
|
5644
5826
|
/**
|
|
5645
5827
|
* method to access a property instance of type boolean belonging
|
|
5646
5828
|
* to the view model instance or to a nested view model instance
|
|
5647
|
-
* @param path - path to the
|
|
5829
|
+
* @param path - path to the boolean property
|
|
5648
5830
|
*/
|
|
5649
5831
|
ViewModelInstance.prototype.boolean = function (path) {
|
|
5650
|
-
var
|
|
5651
|
-
|
|
5652
|
-
if (instance) {
|
|
5653
|
-
return new ViewModelInstanceBoolean(instance, this._root);
|
|
5654
|
-
}
|
|
5655
|
-
return null;
|
|
5832
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Boolean);
|
|
5833
|
+
return viewmodelInstanceValue;
|
|
5656
5834
|
};
|
|
5657
5835
|
/**
|
|
5658
5836
|
* method to access a property instance of type color belonging
|
|
5659
5837
|
* to the view model instance or to a nested view model instance
|
|
5660
|
-
* @param path - path to the
|
|
5838
|
+
* @param path - path to the ttrigger property
|
|
5661
5839
|
*/
|
|
5662
5840
|
ViewModelInstance.prototype.color = function (path) {
|
|
5663
|
-
var
|
|
5664
|
-
|
|
5665
|
-
if (instance) {
|
|
5666
|
-
return new ViewModelInstanceColor(instance, this._root);
|
|
5667
|
-
}
|
|
5668
|
-
return null;
|
|
5841
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Color);
|
|
5842
|
+
return viewmodelInstanceValue;
|
|
5669
5843
|
};
|
|
5670
5844
|
/**
|
|
5671
5845
|
* method to access a property instance of type trigger belonging
|
|
5672
5846
|
* to the view model instance or to a nested view model instance
|
|
5673
|
-
* @param path - path to the
|
|
5847
|
+
* @param path - path to the trigger property
|
|
5674
5848
|
*/
|
|
5675
5849
|
ViewModelInstance.prototype.trigger = function (path) {
|
|
5676
|
-
var
|
|
5677
|
-
|
|
5678
|
-
if (instance) {
|
|
5679
|
-
return new ViewModelInstanceTrigger(instance, this._root);
|
|
5680
|
-
}
|
|
5681
|
-
return null;
|
|
5850
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Trigger);
|
|
5851
|
+
return viewmodelInstanceValue;
|
|
5682
5852
|
};
|
|
5683
5853
|
/**
|
|
5684
5854
|
* method to access a property instance of type enum belonging
|
|
5685
5855
|
* to the view model instance or to a nested view model instance
|
|
5686
|
-
* @param path - path to the
|
|
5856
|
+
* @param path - path to the enum property
|
|
5687
5857
|
*/
|
|
5688
5858
|
ViewModelInstance.prototype.enum = function (path) {
|
|
5689
|
-
var
|
|
5690
|
-
|
|
5691
|
-
if (instance) {
|
|
5692
|
-
return new ViewModelInstanceEnum(instance, this._root);
|
|
5693
|
-
}
|
|
5694
|
-
return null;
|
|
5859
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Enum);
|
|
5860
|
+
return viewmodelInstanceValue;
|
|
5695
5861
|
};
|
|
5696
5862
|
/**
|
|
5697
5863
|
* method to access a view model property instance belonging
|
|
5698
5864
|
* to the view model instance or to a nested view model instance
|
|
5699
|
-
* @param path - path to the
|
|
5865
|
+
* @param path - path to the view model property
|
|
5700
5866
|
*/
|
|
5701
5867
|
ViewModelInstance.prototype.viewModel = function (path) {
|
|
5702
|
-
var
|
|
5703
|
-
var
|
|
5704
|
-
|
|
5705
|
-
|
|
5868
|
+
var pathSegments = path.split("/");
|
|
5869
|
+
var parentViewModelInstance = pathSegments.length > 1
|
|
5870
|
+
? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
|
|
5871
|
+
: this;
|
|
5872
|
+
if (parentViewModelInstance != null) {
|
|
5873
|
+
return parentViewModelInstance.internalViewModelInstance(pathSegments[pathSegments.length - 1]);
|
|
5706
5874
|
}
|
|
5707
5875
|
return null;
|
|
5708
5876
|
};
|
|
5877
|
+
ViewModelInstance.prototype.internalReplaceViewModel = function (name, value) {
|
|
5878
|
+
var _a;
|
|
5879
|
+
if (value.runtimeInstance !== null) {
|
|
5880
|
+
var result = ((_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.replaceViewModel(name, value.runtimeInstance)) ||
|
|
5881
|
+
false;
|
|
5882
|
+
if (result) {
|
|
5883
|
+
value.internalIncrementReferenceCount();
|
|
5884
|
+
var oldInstance_1 = this.internalViewModelInstance(name);
|
|
5885
|
+
if (oldInstance_1 !== null) {
|
|
5886
|
+
oldInstance_1.removeParent(this);
|
|
5887
|
+
if (this._children.includes(oldInstance_1)) {
|
|
5888
|
+
this._children = this._children.filter(function (child) { return child !== oldInstance_1; });
|
|
5889
|
+
}
|
|
5890
|
+
oldInstance_1.cleanup();
|
|
5891
|
+
}
|
|
5892
|
+
this._viewModelInstances.set(name, value);
|
|
5893
|
+
value.addParent(this);
|
|
5894
|
+
}
|
|
5895
|
+
return result;
|
|
5896
|
+
}
|
|
5897
|
+
return false;
|
|
5898
|
+
};
|
|
5709
5899
|
/**
|
|
5710
5900
|
* method to replace a view model property with another view model value
|
|
5711
5901
|
* @param path - path to the view model property
|
|
@@ -5713,27 +5903,11 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
5713
5903
|
*/
|
|
5714
5904
|
ViewModelInstance.prototype.replaceViewModel = function (path, value) {
|
|
5715
5905
|
var _a;
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
return false;
|
|
5721
|
-
};
|
|
5722
|
-
/*
|
|
5723
|
-
* method for internal use, it shouldn't be called externally
|
|
5724
|
-
*/
|
|
5725
|
-
ViewModelInstance.prototype.addToCallbacks = function (property) {
|
|
5726
|
-
if (!this._propertiesWithCallbacks.includes(property)) {
|
|
5727
|
-
this._propertiesWithCallbacks.push(property);
|
|
5728
|
-
}
|
|
5729
|
-
};
|
|
5730
|
-
/*
|
|
5731
|
-
* method for internal use, it shouldn't be called externally
|
|
5732
|
-
*/
|
|
5733
|
-
ViewModelInstance.prototype.removeFromCallbacks = function (property) {
|
|
5734
|
-
if (this._propertiesWithCallbacks.includes(property)) {
|
|
5735
|
-
this._propertiesWithCallbacks = this._propertiesWithCallbacks.filter(function (prop) { return prop !== property; });
|
|
5736
|
-
}
|
|
5906
|
+
var pathSegments = path.split("/");
|
|
5907
|
+
var viewModelInstance = pathSegments.length > 1
|
|
5908
|
+
? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
|
|
5909
|
+
: this;
|
|
5910
|
+
return ((_a = viewModelInstance === null || viewModelInstance === void 0 ? void 0 : viewModelInstance.internalReplaceViewModel(pathSegments[pathSegments.length - 1], value)) !== null && _a !== void 0 ? _a : false);
|
|
5737
5911
|
};
|
|
5738
5912
|
/*
|
|
5739
5913
|
* method to add one to the reference counter of the instance.
|
|
@@ -5765,21 +5939,36 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
5765
5939
|
this._referenceCount++;
|
|
5766
5940
|
};
|
|
5767
5941
|
ViewModelInstance.prototype.cleanup = function () {
|
|
5942
|
+
var _this = this;
|
|
5768
5943
|
this._referenceCount--;
|
|
5769
5944
|
if (this._referenceCount <= 0) {
|
|
5770
5945
|
this._runtimeInstance = null;
|
|
5771
5946
|
this.clearCallbacks();
|
|
5772
5947
|
this._propertiesWithCallbacks = [];
|
|
5948
|
+
this._viewModelInstances.forEach(function (value) {
|
|
5949
|
+
value.cleanup();
|
|
5950
|
+
});
|
|
5951
|
+
this._viewModelInstances.clear();
|
|
5952
|
+
var children = __spreadArray([], this._children, true);
|
|
5953
|
+
this._children.length = 0;
|
|
5954
|
+
var parents = __spreadArray([], this._parents, true);
|
|
5955
|
+
this._parents.length = 0;
|
|
5956
|
+
children.forEach(function (child) {
|
|
5957
|
+
child.removeParent(_this);
|
|
5958
|
+
});
|
|
5959
|
+
parents.forEach(function (parent) {
|
|
5960
|
+
parent.removeFromViewModelCallbacks(_this);
|
|
5961
|
+
});
|
|
5773
5962
|
}
|
|
5774
5963
|
};
|
|
5775
5964
|
return ViewModelInstance;
|
|
5776
5965
|
}());
|
|
5777
5966
|
|
|
5778
5967
|
var ViewModelInstanceValue = /** @class */ (function () {
|
|
5779
|
-
function ViewModelInstanceValue(instance,
|
|
5968
|
+
function ViewModelInstanceValue(instance, parent) {
|
|
5780
5969
|
this.callbacks = [];
|
|
5781
5970
|
this._viewModelInstanceValue = instance;
|
|
5782
|
-
this.
|
|
5971
|
+
this._parentViewModel = parent;
|
|
5783
5972
|
}
|
|
5784
5973
|
ViewModelInstanceValue.prototype.on = function (callback) {
|
|
5785
5974
|
// Since we don't clean the changed flag for properties that don't have listeners,
|
|
@@ -5789,7 +5978,7 @@ var ViewModelInstanceValue = /** @class */ (function () {
|
|
|
5789
5978
|
}
|
|
5790
5979
|
if (!this.callbacks.includes(callback)) {
|
|
5791
5980
|
this.callbacks.push(callback);
|
|
5792
|
-
this.
|
|
5981
|
+
this._parentViewModel.addToPropertyCallbacks(this);
|
|
5793
5982
|
}
|
|
5794
5983
|
};
|
|
5795
5984
|
ViewModelInstanceValue.prototype.off = function (callback) {
|
|
@@ -5800,19 +5989,21 @@ var ViewModelInstanceValue = /** @class */ (function () {
|
|
|
5800
5989
|
this.callbacks = this.callbacks.filter(function (cb) { return cb !== callback; });
|
|
5801
5990
|
}
|
|
5802
5991
|
if (this.callbacks.length === 0) {
|
|
5803
|
-
this.
|
|
5992
|
+
this._parentViewModel.removeFromPropertyCallbacks(this);
|
|
5804
5993
|
}
|
|
5805
5994
|
};
|
|
5806
5995
|
ViewModelInstanceValue.prototype.internalHandleCallback = function (callback) { };
|
|
5807
5996
|
ViewModelInstanceValue.prototype.handleCallbacks = function () {
|
|
5808
5997
|
var _this = this;
|
|
5809
5998
|
if (this._viewModelInstanceValue.hasChanged) {
|
|
5810
|
-
this._viewModelInstanceValue.clearChanges();
|
|
5811
5999
|
this.callbacks.forEach(function (callback) {
|
|
5812
6000
|
_this.internalHandleCallback(callback);
|
|
5813
6001
|
});
|
|
5814
6002
|
}
|
|
5815
6003
|
};
|
|
6004
|
+
ViewModelInstanceValue.prototype.clearChanges = function () {
|
|
6005
|
+
this._viewModelInstanceValue.clearChanges();
|
|
6006
|
+
};
|
|
5816
6007
|
ViewModelInstanceValue.prototype.clearCallbacks = function () {
|
|
5817
6008
|
this.callbacks.length = 0;
|
|
5818
6009
|
};
|
|
@@ -5828,8 +6019,8 @@ var ViewModelInstanceValue = /** @class */ (function () {
|
|
|
5828
6019
|
|
|
5829
6020
|
var ViewModelInstanceString = /** @class */ (function (_super) {
|
|
5830
6021
|
__extends(ViewModelInstanceString, _super);
|
|
5831
|
-
function ViewModelInstanceString(instance,
|
|
5832
|
-
return _super.call(this, instance,
|
|
6022
|
+
function ViewModelInstanceString(instance, parent) {
|
|
6023
|
+
return _super.call(this, instance, parent) || this;
|
|
5833
6024
|
}
|
|
5834
6025
|
Object.defineProperty(ViewModelInstanceString.prototype, "value", {
|
|
5835
6026
|
get: function () {
|
|
@@ -5849,8 +6040,8 @@ var ViewModelInstanceString = /** @class */ (function (_super) {
|
|
|
5849
6040
|
|
|
5850
6041
|
var ViewModelInstanceNumber = /** @class */ (function (_super) {
|
|
5851
6042
|
__extends(ViewModelInstanceNumber, _super);
|
|
5852
|
-
function ViewModelInstanceNumber(instance,
|
|
5853
|
-
return _super.call(this, instance,
|
|
6043
|
+
function ViewModelInstanceNumber(instance, parent) {
|
|
6044
|
+
return _super.call(this, instance, parent) || this;
|
|
5854
6045
|
}
|
|
5855
6046
|
Object.defineProperty(ViewModelInstanceNumber.prototype, "value", {
|
|
5856
6047
|
get: function () {
|
|
@@ -5870,8 +6061,8 @@ var ViewModelInstanceNumber = /** @class */ (function (_super) {
|
|
|
5870
6061
|
|
|
5871
6062
|
var ViewModelInstanceBoolean = /** @class */ (function (_super) {
|
|
5872
6063
|
__extends(ViewModelInstanceBoolean, _super);
|
|
5873
|
-
function ViewModelInstanceBoolean(instance,
|
|
5874
|
-
return _super.call(this, instance,
|
|
6064
|
+
function ViewModelInstanceBoolean(instance, parent) {
|
|
6065
|
+
return _super.call(this, instance, parent) || this;
|
|
5875
6066
|
}
|
|
5876
6067
|
Object.defineProperty(ViewModelInstanceBoolean.prototype, "value", {
|
|
5877
6068
|
get: function () {
|
|
@@ -5891,8 +6082,8 @@ var ViewModelInstanceBoolean = /** @class */ (function (_super) {
|
|
|
5891
6082
|
|
|
5892
6083
|
var ViewModelInstanceTrigger = /** @class */ (function (_super) {
|
|
5893
6084
|
__extends(ViewModelInstanceTrigger, _super);
|
|
5894
|
-
function ViewModelInstanceTrigger(instance,
|
|
5895
|
-
return _super.call(this, instance,
|
|
6085
|
+
function ViewModelInstanceTrigger(instance, parent) {
|
|
6086
|
+
return _super.call(this, instance, parent) || this;
|
|
5896
6087
|
}
|
|
5897
6088
|
ViewModelInstanceTrigger.prototype.trigger = function () {
|
|
5898
6089
|
return this._viewModelInstanceValue.trigger();
|
|
@@ -5905,8 +6096,8 @@ var ViewModelInstanceTrigger = /** @class */ (function (_super) {
|
|
|
5905
6096
|
|
|
5906
6097
|
var ViewModelInstanceEnum = /** @class */ (function (_super) {
|
|
5907
6098
|
__extends(ViewModelInstanceEnum, _super);
|
|
5908
|
-
function ViewModelInstanceEnum(instance,
|
|
5909
|
-
return _super.call(this, instance,
|
|
6099
|
+
function ViewModelInstanceEnum(instance, parent) {
|
|
6100
|
+
return _super.call(this, instance, parent) || this;
|
|
5910
6101
|
}
|
|
5911
6102
|
Object.defineProperty(ViewModelInstanceEnum.prototype, "value", {
|
|
5912
6103
|
get: function () {
|
|
@@ -5944,8 +6135,8 @@ var ViewModelInstanceEnum = /** @class */ (function (_super) {
|
|
|
5944
6135
|
|
|
5945
6136
|
var ViewModelInstanceColor = /** @class */ (function (_super) {
|
|
5946
6137
|
__extends(ViewModelInstanceColor, _super);
|
|
5947
|
-
function ViewModelInstanceColor(instance,
|
|
5948
|
-
return _super.call(this, instance,
|
|
6138
|
+
function ViewModelInstanceColor(instance, parent) {
|
|
6139
|
+
return _super.call(this, instance, parent) || this;
|
|
5949
6140
|
}
|
|
5950
6141
|
Object.defineProperty(ViewModelInstanceColor.prototype, "value", {
|
|
5951
6142
|
get: function () {
|