@rive-app/webgl 2.26.6 → 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
|
@@ -408,7 +408,7 @@ function Qa(a, b) {
|
|
|
408
408
|
return Pa(c, a, b);
|
|
409
409
|
}));
|
|
410
410
|
}
|
|
411
|
-
var Ra, Sa, Wa = {
|
|
411
|
+
var Ra, Sa, Wa = {704620:(a, b, c, d, e) => {
|
|
412
412
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
413
413
|
return 0;
|
|
414
414
|
}
|
|
@@ -471,9 +471,9 @@ var Ra, Sa, Wa = {704652:(a, b, c, d, e) => {
|
|
|
471
471
|
}
|
|
472
472
|
window.h.Ea += 1;
|
|
473
473
|
return 1;
|
|
474
|
-
},
|
|
474
|
+
}, 706798:() => {
|
|
475
475
|
"undefined" !== typeof window.h && (--window.h.Ea, 0 === window.h.Ea && delete window.h);
|
|
476
|
-
},
|
|
476
|
+
}, 706962:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 707066:() => {
|
|
477
477
|
try {
|
|
478
478
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
479
479
|
a.close();
|
|
@@ -481,7 +481,7 @@ var Ra, Sa, Wa = {704652:(a, b, c, d, e) => {
|
|
|
481
481
|
} catch (c) {
|
|
482
482
|
return 0;
|
|
483
483
|
}
|
|
484
|
-
},
|
|
484
|
+
}, 707237:(a, b, c, d, e, f) => {
|
|
485
485
|
if ("undefined" === typeof window.h) {
|
|
486
486
|
return -1;
|
|
487
487
|
}
|
|
@@ -527,7 +527,7 @@ var Ra, Sa, Wa = {704652:(a, b, c, d, e) => {
|
|
|
527
527
|
a == window.h.H.Ca && g.X.connect(g.I.destination);
|
|
528
528
|
g.lb = f;
|
|
529
529
|
return window.h.nc(g);
|
|
530
|
-
},
|
|
530
|
+
}, 710114:a => window.h.ta(a).I.sampleRate, 710187:a => {
|
|
531
531
|
a = window.h.ta(a);
|
|
532
532
|
void 0 !== a.X && (a.X.onaudioprocess = function() {
|
|
533
533
|
}, a.X.disconnect(), a.X = void 0);
|
|
@@ -535,13 +535,13 @@ var Ra, Sa, Wa = {704652:(a, b, c, d, e) => {
|
|
|
535
535
|
a.I.close();
|
|
536
536
|
a.I = void 0;
|
|
537
537
|
a.lb = void 0;
|
|
538
|
-
},
|
|
538
|
+
}, 710587:a => {
|
|
539
539
|
window.h.xb(a);
|
|
540
|
-
},
|
|
540
|
+
}, 710637:a => {
|
|
541
541
|
a = window.h.ta(a);
|
|
542
542
|
a.I.resume();
|
|
543
543
|
a.state = window.h.ha.sb;
|
|
544
|
-
},
|
|
544
|
+
}, 710776:a => {
|
|
545
545
|
a = window.h.ta(a);
|
|
546
546
|
a.I.suspend();
|
|
547
547
|
a.state = window.h.ha.stopped;
|
|
@@ -4063,7 +4063,7 @@ Je();
|
|
|
4063
4063
|
/* 2 */
|
|
4064
4064
|
/***/ ((module) => {
|
|
4065
4065
|
|
|
4066
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.26.
|
|
4066
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.26.7","description":"Rive\'s webgl 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.wasm","rive_fallback.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
4067
4067
|
|
|
4068
4068
|
/***/ }),
|
|
4069
4069
|
/* 3 */
|
|
@@ -4613,6 +4613,15 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
|
|
|
4613
4613
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
4614
4614
|
}
|
|
4615
4615
|
};
|
|
4616
|
+
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
4617
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4618
|
+
if (ar || !(i in from)) {
|
|
4619
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
4620
|
+
ar[i] = from[i];
|
|
4621
|
+
}
|
|
4622
|
+
}
|
|
4623
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
4624
|
+
};
|
|
4616
4625
|
|
|
4617
4626
|
|
|
4618
4627
|
|
|
@@ -6006,6 +6015,13 @@ var Rive = /** @class */ (function () {
|
|
|
6006
6015
|
useOffscreenRenderer: params.useOffscreenRenderer,
|
|
6007
6016
|
});
|
|
6008
6017
|
}
|
|
6018
|
+
Object.defineProperty(Rive.prototype, "viewModelCount", {
|
|
6019
|
+
get: function () {
|
|
6020
|
+
return this.file.viewModelCount();
|
|
6021
|
+
},
|
|
6022
|
+
enumerable: false,
|
|
6023
|
+
configurable: true
|
|
6024
|
+
});
|
|
6009
6025
|
// Alternative constructor to build a Rive instance from an interface/object
|
|
6010
6026
|
Rive.new = function (params) {
|
|
6011
6027
|
console.warn("This function is deprecated: please use `new Rive({})` instead");
|
|
@@ -7244,10 +7260,14 @@ var Rive = /** @class */ (function () {
|
|
|
7244
7260
|
viewModelInstance.internalIncrementReferenceCount();
|
|
7245
7261
|
(_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
7246
7262
|
this._viewModelInstance = viewModelInstance;
|
|
7247
|
-
this.
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7263
|
+
if (this.animator.stateMachines.length > 0) {
|
|
7264
|
+
this.animator.stateMachines.forEach(function (stateMachine) {
|
|
7265
|
+
return stateMachine.bindViewModelInstance(viewModelInstance);
|
|
7266
|
+
});
|
|
7267
|
+
}
|
|
7268
|
+
else {
|
|
7269
|
+
this.artboard.bindViewModelInstance(viewModelInstance.runtimeInstance);
|
|
7270
|
+
}
|
|
7251
7271
|
}
|
|
7252
7272
|
}
|
|
7253
7273
|
};
|
|
@@ -7381,12 +7401,26 @@ var DataEnum = /** @class */ (function () {
|
|
|
7381
7401
|
return DataEnum;
|
|
7382
7402
|
}());
|
|
7383
7403
|
|
|
7404
|
+
var PropertyType;
|
|
7405
|
+
(function (PropertyType) {
|
|
7406
|
+
PropertyType["Number"] = "number";
|
|
7407
|
+
PropertyType["String"] = "string";
|
|
7408
|
+
PropertyType["Boolean"] = "boolean";
|
|
7409
|
+
PropertyType["Color"] = "color";
|
|
7410
|
+
PropertyType["Trigger"] = "trigger";
|
|
7411
|
+
PropertyType["Enum"] = "enum";
|
|
7412
|
+
})(PropertyType || (PropertyType = {}));
|
|
7384
7413
|
var ViewModelInstance = /** @class */ (function () {
|
|
7385
|
-
function ViewModelInstance(runtimeInstance,
|
|
7414
|
+
function ViewModelInstance(runtimeInstance, parent) {
|
|
7415
|
+
this._parents = [];
|
|
7416
|
+
this._children = [];
|
|
7417
|
+
this._viewModelInstances = new Map();
|
|
7386
7418
|
this._propertiesWithCallbacks = [];
|
|
7387
7419
|
this._referenceCount = 0;
|
|
7388
7420
|
this._runtimeInstance = runtimeInstance;
|
|
7389
|
-
|
|
7421
|
+
if (parent !== null) {
|
|
7422
|
+
this._parents.push(parent);
|
|
7423
|
+
}
|
|
7390
7424
|
}
|
|
7391
7425
|
Object.defineProperty(ViewModelInstance.prototype, "runtimeInstance", {
|
|
7392
7426
|
get: function () {
|
|
@@ -7400,6 +7434,80 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
7400
7434
|
this._propertiesWithCallbacks.forEach(function (property) {
|
|
7401
7435
|
property.handleCallbacks();
|
|
7402
7436
|
});
|
|
7437
|
+
this._propertiesWithCallbacks.forEach(function (property) {
|
|
7438
|
+
property.clearChanges();
|
|
7439
|
+
});
|
|
7440
|
+
}
|
|
7441
|
+
this._children.forEach(function (child) { return child.handleCallbacks(); });
|
|
7442
|
+
};
|
|
7443
|
+
ViewModelInstance.prototype.addParent = function (parent) {
|
|
7444
|
+
this._parents.push(parent);
|
|
7445
|
+
if (this._propertiesWithCallbacks.length > 0 || this._children.length > 0) {
|
|
7446
|
+
parent.addToViewModelCallbacks(this);
|
|
7447
|
+
}
|
|
7448
|
+
};
|
|
7449
|
+
ViewModelInstance.prototype.removeParent = function (parent) {
|
|
7450
|
+
var index = this._parents.indexOf(parent);
|
|
7451
|
+
if (index !== -1) {
|
|
7452
|
+
var parent_1 = this._parents[index];
|
|
7453
|
+
parent_1.removeFromViewModelCallbacks(this);
|
|
7454
|
+
this._parents.splice(index, 1);
|
|
7455
|
+
}
|
|
7456
|
+
};
|
|
7457
|
+
/*
|
|
7458
|
+
* method for internal use, it shouldn't be called externally
|
|
7459
|
+
*/
|
|
7460
|
+
ViewModelInstance.prototype.addToPropertyCallbacks = function (property) {
|
|
7461
|
+
var _this = this;
|
|
7462
|
+
if (!this._propertiesWithCallbacks.includes(property)) {
|
|
7463
|
+
this._propertiesWithCallbacks.push(property);
|
|
7464
|
+
if (this._propertiesWithCallbacks.length > 0) {
|
|
7465
|
+
this._parents.forEach(function (parent) {
|
|
7466
|
+
parent.addToViewModelCallbacks(_this);
|
|
7467
|
+
});
|
|
7468
|
+
}
|
|
7469
|
+
}
|
|
7470
|
+
};
|
|
7471
|
+
/*
|
|
7472
|
+
* method for internal use, it shouldn't be called externally
|
|
7473
|
+
*/
|
|
7474
|
+
ViewModelInstance.prototype.removeFromPropertyCallbacks = function (property) {
|
|
7475
|
+
var _this = this;
|
|
7476
|
+
if (this._propertiesWithCallbacks.includes(property)) {
|
|
7477
|
+
this._propertiesWithCallbacks = this._propertiesWithCallbacks.filter(function (prop) { return prop !== property; });
|
|
7478
|
+
if (this._children.length === 0 &&
|
|
7479
|
+
this._propertiesWithCallbacks.length === 0) {
|
|
7480
|
+
this._parents.forEach(function (parent) {
|
|
7481
|
+
parent.removeFromViewModelCallbacks(_this);
|
|
7482
|
+
});
|
|
7483
|
+
}
|
|
7484
|
+
}
|
|
7485
|
+
};
|
|
7486
|
+
/*
|
|
7487
|
+
* method for internal use, it shouldn't be called externally
|
|
7488
|
+
*/
|
|
7489
|
+
ViewModelInstance.prototype.addToViewModelCallbacks = function (instance) {
|
|
7490
|
+
var _this = this;
|
|
7491
|
+
if (!this._children.includes(instance)) {
|
|
7492
|
+
this._children.push(instance);
|
|
7493
|
+
this._parents.forEach(function (parent) {
|
|
7494
|
+
parent.addToViewModelCallbacks(_this);
|
|
7495
|
+
});
|
|
7496
|
+
}
|
|
7497
|
+
};
|
|
7498
|
+
/*
|
|
7499
|
+
* method for internal use, it shouldn't be called externally
|
|
7500
|
+
*/
|
|
7501
|
+
ViewModelInstance.prototype.removeFromViewModelCallbacks = function (instance) {
|
|
7502
|
+
var _this = this;
|
|
7503
|
+
if (this._children.includes(instance)) {
|
|
7504
|
+
this._children = this._children.filter(function (child) { return child !== instance; });
|
|
7505
|
+
if (this._children.length === 0 &&
|
|
7506
|
+
this._propertiesWithCallbacks.length === 0) {
|
|
7507
|
+
this._parents.forEach(function (parent) {
|
|
7508
|
+
parent.removeFromViewModelCallbacks(_this);
|
|
7509
|
+
});
|
|
7510
|
+
}
|
|
7403
7511
|
}
|
|
7404
7512
|
};
|
|
7405
7513
|
ViewModelInstance.prototype.clearCallbacks = function () {
|
|
@@ -7407,97 +7515,179 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
7407
7515
|
property.clearCallbacks();
|
|
7408
7516
|
});
|
|
7409
7517
|
};
|
|
7518
|
+
ViewModelInstance.prototype.propertyFromPath = function (path, type) {
|
|
7519
|
+
var pathSegments = path.split("/");
|
|
7520
|
+
return this.propertyFromPathSegments(pathSegments, 0, type);
|
|
7521
|
+
};
|
|
7522
|
+
ViewModelInstance.prototype.viewModelFromPathSegments = function (pathSegments, index) {
|
|
7523
|
+
var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
|
|
7524
|
+
if (viewModelInstance !== null) {
|
|
7525
|
+
if (index == pathSegments.length - 1) {
|
|
7526
|
+
return viewModelInstance;
|
|
7527
|
+
}
|
|
7528
|
+
else {
|
|
7529
|
+
return viewModelInstance.viewModelFromPathSegments(pathSegments, index++);
|
|
7530
|
+
}
|
|
7531
|
+
}
|
|
7532
|
+
return null;
|
|
7533
|
+
};
|
|
7534
|
+
ViewModelInstance.prototype.propertyFromPathSegments = function (pathSegments, index, type) {
|
|
7535
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
7536
|
+
if (index < pathSegments.length - 1) {
|
|
7537
|
+
var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
|
|
7538
|
+
if (viewModelInstance !== null) {
|
|
7539
|
+
return viewModelInstance.propertyFromPathSegments(pathSegments, index + 1, type);
|
|
7540
|
+
}
|
|
7541
|
+
else {
|
|
7542
|
+
return null;
|
|
7543
|
+
}
|
|
7544
|
+
}
|
|
7545
|
+
var instance = null;
|
|
7546
|
+
switch (type) {
|
|
7547
|
+
case PropertyType.Number:
|
|
7548
|
+
instance = (_b = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.number(pathSegments[index])) !== null && _b !== void 0 ? _b : null;
|
|
7549
|
+
if (instance !== null) {
|
|
7550
|
+
return new ViewModelInstanceNumber(instance, this);
|
|
7551
|
+
}
|
|
7552
|
+
break;
|
|
7553
|
+
case PropertyType.String:
|
|
7554
|
+
instance = (_d = (_c = this._runtimeInstance) === null || _c === void 0 ? void 0 : _c.string(pathSegments[index])) !== null && _d !== void 0 ? _d : null;
|
|
7555
|
+
if (instance !== null) {
|
|
7556
|
+
return new ViewModelInstanceString(instance, this);
|
|
7557
|
+
}
|
|
7558
|
+
break;
|
|
7559
|
+
case PropertyType.Boolean:
|
|
7560
|
+
instance = (_f = (_e = this._runtimeInstance) === null || _e === void 0 ? void 0 : _e.boolean(pathSegments[index])) !== null && _f !== void 0 ? _f : null;
|
|
7561
|
+
if (instance !== null) {
|
|
7562
|
+
return new ViewModelInstanceBoolean(instance, this);
|
|
7563
|
+
}
|
|
7564
|
+
break;
|
|
7565
|
+
case PropertyType.Color:
|
|
7566
|
+
instance = (_h = (_g = this._runtimeInstance) === null || _g === void 0 ? void 0 : _g.color(pathSegments[index])) !== null && _h !== void 0 ? _h : null;
|
|
7567
|
+
if (instance !== null) {
|
|
7568
|
+
return new ViewModelInstanceColor(instance, this);
|
|
7569
|
+
}
|
|
7570
|
+
break;
|
|
7571
|
+
case PropertyType.Trigger:
|
|
7572
|
+
instance = (_k = (_j = this._runtimeInstance) === null || _j === void 0 ? void 0 : _j.trigger(pathSegments[index])) !== null && _k !== void 0 ? _k : null;
|
|
7573
|
+
if (instance !== null) {
|
|
7574
|
+
return new ViewModelInstanceTrigger(instance, this);
|
|
7575
|
+
}
|
|
7576
|
+
break;
|
|
7577
|
+
case PropertyType.Enum:
|
|
7578
|
+
instance = (_m = (_l = this._runtimeInstance) === null || _l === void 0 ? void 0 : _l.enum(pathSegments[index])) !== null && _m !== void 0 ? _m : null;
|
|
7579
|
+
if (instance !== null) {
|
|
7580
|
+
return new ViewModelInstanceEnum(instance, this);
|
|
7581
|
+
}
|
|
7582
|
+
break;
|
|
7583
|
+
}
|
|
7584
|
+
return null;
|
|
7585
|
+
};
|
|
7586
|
+
ViewModelInstance.prototype.internalViewModelInstance = function (name) {
|
|
7587
|
+
var _a;
|
|
7588
|
+
if (this._viewModelInstances.has(name)) {
|
|
7589
|
+
return this._viewModelInstances.get(name);
|
|
7590
|
+
}
|
|
7591
|
+
var viewModelRuntimeInstance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.viewModel(name);
|
|
7592
|
+
if (viewModelRuntimeInstance !== null) {
|
|
7593
|
+
var viewModelInstance = new ViewModelInstance(viewModelRuntimeInstance, this);
|
|
7594
|
+
viewModelInstance.internalIncrementReferenceCount();
|
|
7595
|
+
this._viewModelInstances.set(name, viewModelInstance);
|
|
7596
|
+
return viewModelInstance;
|
|
7597
|
+
}
|
|
7598
|
+
return null;
|
|
7599
|
+
};
|
|
7410
7600
|
/**
|
|
7411
7601
|
* method to access a property instance of type number belonging
|
|
7412
7602
|
* to the view model instance or to a nested view model instance
|
|
7413
7603
|
* @param path - path to the number property
|
|
7414
7604
|
*/
|
|
7415
7605
|
ViewModelInstance.prototype.number = function (path) {
|
|
7416
|
-
var
|
|
7417
|
-
|
|
7418
|
-
if (instance) {
|
|
7419
|
-
return new ViewModelInstanceNumber(instance, this._root);
|
|
7420
|
-
}
|
|
7421
|
-
return null;
|
|
7606
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Number);
|
|
7607
|
+
return viewmodelInstanceValue;
|
|
7422
7608
|
};
|
|
7423
7609
|
/**
|
|
7424
7610
|
* method to access a property instance of type string belonging
|
|
7425
7611
|
* to the view model instance or to a nested view model instance
|
|
7426
|
-
* @param path - path to the
|
|
7612
|
+
* @param path - path to the string property
|
|
7427
7613
|
*/
|
|
7428
7614
|
ViewModelInstance.prototype.string = function (path) {
|
|
7429
|
-
var
|
|
7430
|
-
|
|
7431
|
-
if (instance) {
|
|
7432
|
-
return new ViewModelInstanceString(instance, this._root);
|
|
7433
|
-
}
|
|
7434
|
-
return null;
|
|
7615
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.String);
|
|
7616
|
+
return viewmodelInstanceValue;
|
|
7435
7617
|
};
|
|
7436
7618
|
/**
|
|
7437
7619
|
* method to access a property instance of type boolean belonging
|
|
7438
7620
|
* to the view model instance or to a nested view model instance
|
|
7439
|
-
* @param path - path to the
|
|
7621
|
+
* @param path - path to the boolean property
|
|
7440
7622
|
*/
|
|
7441
7623
|
ViewModelInstance.prototype.boolean = function (path) {
|
|
7442
|
-
var
|
|
7443
|
-
|
|
7444
|
-
if (instance) {
|
|
7445
|
-
return new ViewModelInstanceBoolean(instance, this._root);
|
|
7446
|
-
}
|
|
7447
|
-
return null;
|
|
7624
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Boolean);
|
|
7625
|
+
return viewmodelInstanceValue;
|
|
7448
7626
|
};
|
|
7449
7627
|
/**
|
|
7450
7628
|
* method to access a property instance of type color belonging
|
|
7451
7629
|
* to the view model instance or to a nested view model instance
|
|
7452
|
-
* @param path - path to the
|
|
7630
|
+
* @param path - path to the ttrigger property
|
|
7453
7631
|
*/
|
|
7454
7632
|
ViewModelInstance.prototype.color = function (path) {
|
|
7455
|
-
var
|
|
7456
|
-
|
|
7457
|
-
if (instance) {
|
|
7458
|
-
return new ViewModelInstanceColor(instance, this._root);
|
|
7459
|
-
}
|
|
7460
|
-
return null;
|
|
7633
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Color);
|
|
7634
|
+
return viewmodelInstanceValue;
|
|
7461
7635
|
};
|
|
7462
7636
|
/**
|
|
7463
7637
|
* method to access a property instance of type trigger belonging
|
|
7464
7638
|
* to the view model instance or to a nested view model instance
|
|
7465
|
-
* @param path - path to the
|
|
7639
|
+
* @param path - path to the trigger property
|
|
7466
7640
|
*/
|
|
7467
7641
|
ViewModelInstance.prototype.trigger = function (path) {
|
|
7468
|
-
var
|
|
7469
|
-
|
|
7470
|
-
if (instance) {
|
|
7471
|
-
return new ViewModelInstanceTrigger(instance, this._root);
|
|
7472
|
-
}
|
|
7473
|
-
return null;
|
|
7642
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Trigger);
|
|
7643
|
+
return viewmodelInstanceValue;
|
|
7474
7644
|
};
|
|
7475
7645
|
/**
|
|
7476
7646
|
* method to access a property instance of type enum belonging
|
|
7477
7647
|
* to the view model instance or to a nested view model instance
|
|
7478
|
-
* @param path - path to the
|
|
7648
|
+
* @param path - path to the enum property
|
|
7479
7649
|
*/
|
|
7480
7650
|
ViewModelInstance.prototype.enum = function (path) {
|
|
7481
|
-
var
|
|
7482
|
-
|
|
7483
|
-
if (instance) {
|
|
7484
|
-
return new ViewModelInstanceEnum(instance, this._root);
|
|
7485
|
-
}
|
|
7486
|
-
return null;
|
|
7651
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Enum);
|
|
7652
|
+
return viewmodelInstanceValue;
|
|
7487
7653
|
};
|
|
7488
7654
|
/**
|
|
7489
7655
|
* method to access a view model property instance belonging
|
|
7490
7656
|
* to the view model instance or to a nested view model instance
|
|
7491
|
-
* @param path - path to the
|
|
7657
|
+
* @param path - path to the view model property
|
|
7492
7658
|
*/
|
|
7493
7659
|
ViewModelInstance.prototype.viewModel = function (path) {
|
|
7494
|
-
var
|
|
7495
|
-
var
|
|
7496
|
-
|
|
7497
|
-
|
|
7660
|
+
var pathSegments = path.split("/");
|
|
7661
|
+
var parentViewModelInstance = pathSegments.length > 1
|
|
7662
|
+
? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
|
|
7663
|
+
: this;
|
|
7664
|
+
if (parentViewModelInstance != null) {
|
|
7665
|
+
return parentViewModelInstance.internalViewModelInstance(pathSegments[pathSegments.length - 1]);
|
|
7498
7666
|
}
|
|
7499
7667
|
return null;
|
|
7500
7668
|
};
|
|
7669
|
+
ViewModelInstance.prototype.internalReplaceViewModel = function (name, value) {
|
|
7670
|
+
var _a;
|
|
7671
|
+
if (value.runtimeInstance !== null) {
|
|
7672
|
+
var result = ((_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.replaceViewModel(name, value.runtimeInstance)) ||
|
|
7673
|
+
false;
|
|
7674
|
+
if (result) {
|
|
7675
|
+
value.internalIncrementReferenceCount();
|
|
7676
|
+
var oldInstance_1 = this.internalViewModelInstance(name);
|
|
7677
|
+
if (oldInstance_1 !== null) {
|
|
7678
|
+
oldInstance_1.removeParent(this);
|
|
7679
|
+
if (this._children.includes(oldInstance_1)) {
|
|
7680
|
+
this._children = this._children.filter(function (child) { return child !== oldInstance_1; });
|
|
7681
|
+
}
|
|
7682
|
+
oldInstance_1.cleanup();
|
|
7683
|
+
}
|
|
7684
|
+
this._viewModelInstances.set(name, value);
|
|
7685
|
+
value.addParent(this);
|
|
7686
|
+
}
|
|
7687
|
+
return result;
|
|
7688
|
+
}
|
|
7689
|
+
return false;
|
|
7690
|
+
};
|
|
7501
7691
|
/**
|
|
7502
7692
|
* method to replace a view model property with another view model value
|
|
7503
7693
|
* @param path - path to the view model property
|
|
@@ -7505,27 +7695,11 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
7505
7695
|
*/
|
|
7506
7696
|
ViewModelInstance.prototype.replaceViewModel = function (path, value) {
|
|
7507
7697
|
var _a;
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
return false;
|
|
7513
|
-
};
|
|
7514
|
-
/*
|
|
7515
|
-
* method for internal use, it shouldn't be called externally
|
|
7516
|
-
*/
|
|
7517
|
-
ViewModelInstance.prototype.addToCallbacks = function (property) {
|
|
7518
|
-
if (!this._propertiesWithCallbacks.includes(property)) {
|
|
7519
|
-
this._propertiesWithCallbacks.push(property);
|
|
7520
|
-
}
|
|
7521
|
-
};
|
|
7522
|
-
/*
|
|
7523
|
-
* method for internal use, it shouldn't be called externally
|
|
7524
|
-
*/
|
|
7525
|
-
ViewModelInstance.prototype.removeFromCallbacks = function (property) {
|
|
7526
|
-
if (this._propertiesWithCallbacks.includes(property)) {
|
|
7527
|
-
this._propertiesWithCallbacks = this._propertiesWithCallbacks.filter(function (prop) { return prop !== property; });
|
|
7528
|
-
}
|
|
7698
|
+
var pathSegments = path.split("/");
|
|
7699
|
+
var viewModelInstance = pathSegments.length > 1
|
|
7700
|
+
? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
|
|
7701
|
+
: this;
|
|
7702
|
+
return ((_a = viewModelInstance === null || viewModelInstance === void 0 ? void 0 : viewModelInstance.internalReplaceViewModel(pathSegments[pathSegments.length - 1], value)) !== null && _a !== void 0 ? _a : false);
|
|
7529
7703
|
};
|
|
7530
7704
|
/*
|
|
7531
7705
|
* method to add one to the reference counter of the instance.
|
|
@@ -7557,21 +7731,36 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
7557
7731
|
this._referenceCount++;
|
|
7558
7732
|
};
|
|
7559
7733
|
ViewModelInstance.prototype.cleanup = function () {
|
|
7734
|
+
var _this = this;
|
|
7560
7735
|
this._referenceCount--;
|
|
7561
7736
|
if (this._referenceCount <= 0) {
|
|
7562
7737
|
this._runtimeInstance = null;
|
|
7563
7738
|
this.clearCallbacks();
|
|
7564
7739
|
this._propertiesWithCallbacks = [];
|
|
7740
|
+
this._viewModelInstances.forEach(function (value) {
|
|
7741
|
+
value.cleanup();
|
|
7742
|
+
});
|
|
7743
|
+
this._viewModelInstances.clear();
|
|
7744
|
+
var children = __spreadArray([], this._children, true);
|
|
7745
|
+
this._children.length = 0;
|
|
7746
|
+
var parents = __spreadArray([], this._parents, true);
|
|
7747
|
+
this._parents.length = 0;
|
|
7748
|
+
children.forEach(function (child) {
|
|
7749
|
+
child.removeParent(_this);
|
|
7750
|
+
});
|
|
7751
|
+
parents.forEach(function (parent) {
|
|
7752
|
+
parent.removeFromViewModelCallbacks(_this);
|
|
7753
|
+
});
|
|
7565
7754
|
}
|
|
7566
7755
|
};
|
|
7567
7756
|
return ViewModelInstance;
|
|
7568
7757
|
}());
|
|
7569
7758
|
|
|
7570
7759
|
var ViewModelInstanceValue = /** @class */ (function () {
|
|
7571
|
-
function ViewModelInstanceValue(instance,
|
|
7760
|
+
function ViewModelInstanceValue(instance, parent) {
|
|
7572
7761
|
this.callbacks = [];
|
|
7573
7762
|
this._viewModelInstanceValue = instance;
|
|
7574
|
-
this.
|
|
7763
|
+
this._parentViewModel = parent;
|
|
7575
7764
|
}
|
|
7576
7765
|
ViewModelInstanceValue.prototype.on = function (callback) {
|
|
7577
7766
|
// Since we don't clean the changed flag for properties that don't have listeners,
|
|
@@ -7581,7 +7770,7 @@ var ViewModelInstanceValue = /** @class */ (function () {
|
|
|
7581
7770
|
}
|
|
7582
7771
|
if (!this.callbacks.includes(callback)) {
|
|
7583
7772
|
this.callbacks.push(callback);
|
|
7584
|
-
this.
|
|
7773
|
+
this._parentViewModel.addToPropertyCallbacks(this);
|
|
7585
7774
|
}
|
|
7586
7775
|
};
|
|
7587
7776
|
ViewModelInstanceValue.prototype.off = function (callback) {
|
|
@@ -7592,19 +7781,21 @@ var ViewModelInstanceValue = /** @class */ (function () {
|
|
|
7592
7781
|
this.callbacks = this.callbacks.filter(function (cb) { return cb !== callback; });
|
|
7593
7782
|
}
|
|
7594
7783
|
if (this.callbacks.length === 0) {
|
|
7595
|
-
this.
|
|
7784
|
+
this._parentViewModel.removeFromPropertyCallbacks(this);
|
|
7596
7785
|
}
|
|
7597
7786
|
};
|
|
7598
7787
|
ViewModelInstanceValue.prototype.internalHandleCallback = function (callback) { };
|
|
7599
7788
|
ViewModelInstanceValue.prototype.handleCallbacks = function () {
|
|
7600
7789
|
var _this = this;
|
|
7601
7790
|
if (this._viewModelInstanceValue.hasChanged) {
|
|
7602
|
-
this._viewModelInstanceValue.clearChanges();
|
|
7603
7791
|
this.callbacks.forEach(function (callback) {
|
|
7604
7792
|
_this.internalHandleCallback(callback);
|
|
7605
7793
|
});
|
|
7606
7794
|
}
|
|
7607
7795
|
};
|
|
7796
|
+
ViewModelInstanceValue.prototype.clearChanges = function () {
|
|
7797
|
+
this._viewModelInstanceValue.clearChanges();
|
|
7798
|
+
};
|
|
7608
7799
|
ViewModelInstanceValue.prototype.clearCallbacks = function () {
|
|
7609
7800
|
this.callbacks.length = 0;
|
|
7610
7801
|
};
|
|
@@ -7620,8 +7811,8 @@ var ViewModelInstanceValue = /** @class */ (function () {
|
|
|
7620
7811
|
|
|
7621
7812
|
var ViewModelInstanceString = /** @class */ (function (_super) {
|
|
7622
7813
|
__extends(ViewModelInstanceString, _super);
|
|
7623
|
-
function ViewModelInstanceString(instance,
|
|
7624
|
-
return _super.call(this, instance,
|
|
7814
|
+
function ViewModelInstanceString(instance, parent) {
|
|
7815
|
+
return _super.call(this, instance, parent) || this;
|
|
7625
7816
|
}
|
|
7626
7817
|
Object.defineProperty(ViewModelInstanceString.prototype, "value", {
|
|
7627
7818
|
get: function () {
|
|
@@ -7641,8 +7832,8 @@ var ViewModelInstanceString = /** @class */ (function (_super) {
|
|
|
7641
7832
|
|
|
7642
7833
|
var ViewModelInstanceNumber = /** @class */ (function (_super) {
|
|
7643
7834
|
__extends(ViewModelInstanceNumber, _super);
|
|
7644
|
-
function ViewModelInstanceNumber(instance,
|
|
7645
|
-
return _super.call(this, instance,
|
|
7835
|
+
function ViewModelInstanceNumber(instance, parent) {
|
|
7836
|
+
return _super.call(this, instance, parent) || this;
|
|
7646
7837
|
}
|
|
7647
7838
|
Object.defineProperty(ViewModelInstanceNumber.prototype, "value", {
|
|
7648
7839
|
get: function () {
|
|
@@ -7662,8 +7853,8 @@ var ViewModelInstanceNumber = /** @class */ (function (_super) {
|
|
|
7662
7853
|
|
|
7663
7854
|
var ViewModelInstanceBoolean = /** @class */ (function (_super) {
|
|
7664
7855
|
__extends(ViewModelInstanceBoolean, _super);
|
|
7665
|
-
function ViewModelInstanceBoolean(instance,
|
|
7666
|
-
return _super.call(this, instance,
|
|
7856
|
+
function ViewModelInstanceBoolean(instance, parent) {
|
|
7857
|
+
return _super.call(this, instance, parent) || this;
|
|
7667
7858
|
}
|
|
7668
7859
|
Object.defineProperty(ViewModelInstanceBoolean.prototype, "value", {
|
|
7669
7860
|
get: function () {
|
|
@@ -7683,8 +7874,8 @@ var ViewModelInstanceBoolean = /** @class */ (function (_super) {
|
|
|
7683
7874
|
|
|
7684
7875
|
var ViewModelInstanceTrigger = /** @class */ (function (_super) {
|
|
7685
7876
|
__extends(ViewModelInstanceTrigger, _super);
|
|
7686
|
-
function ViewModelInstanceTrigger(instance,
|
|
7687
|
-
return _super.call(this, instance,
|
|
7877
|
+
function ViewModelInstanceTrigger(instance, parent) {
|
|
7878
|
+
return _super.call(this, instance, parent) || this;
|
|
7688
7879
|
}
|
|
7689
7880
|
ViewModelInstanceTrigger.prototype.trigger = function () {
|
|
7690
7881
|
return this._viewModelInstanceValue.trigger();
|
|
@@ -7697,8 +7888,8 @@ var ViewModelInstanceTrigger = /** @class */ (function (_super) {
|
|
|
7697
7888
|
|
|
7698
7889
|
var ViewModelInstanceEnum = /** @class */ (function (_super) {
|
|
7699
7890
|
__extends(ViewModelInstanceEnum, _super);
|
|
7700
|
-
function ViewModelInstanceEnum(instance,
|
|
7701
|
-
return _super.call(this, instance,
|
|
7891
|
+
function ViewModelInstanceEnum(instance, parent) {
|
|
7892
|
+
return _super.call(this, instance, parent) || this;
|
|
7702
7893
|
}
|
|
7703
7894
|
Object.defineProperty(ViewModelInstanceEnum.prototype, "value", {
|
|
7704
7895
|
get: function () {
|
|
@@ -7736,8 +7927,8 @@ var ViewModelInstanceEnum = /** @class */ (function (_super) {
|
|
|
7736
7927
|
|
|
7737
7928
|
var ViewModelInstanceColor = /** @class */ (function (_super) {
|
|
7738
7929
|
__extends(ViewModelInstanceColor, _super);
|
|
7739
|
-
function ViewModelInstanceColor(instance,
|
|
7740
|
-
return _super.call(this, instance,
|
|
7930
|
+
function ViewModelInstanceColor(instance, parent) {
|
|
7931
|
+
return _super.call(this, instance, parent) || this;
|
|
7741
7932
|
}
|
|
7742
7933
|
Object.defineProperty(ViewModelInstanceColor.prototype, "value", {
|
|
7743
7934
|
get: function () {
|