@rive-app/webgl2 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/rive.js CHANGED
@@ -175,8 +175,8 @@ k.onRuntimeInitialized = function() {
175
175
  this.transform = function(u) {
176
176
  this.S.push(d.transform.bind(d, u));
177
177
  };
178
- this.align = function(u, y, z, A, G = 1.0) {
179
- this.S.push(d.align.bind(d, u, y, z, A, G));
178
+ this.align = function(u, y, z, A, H = 1.0) {
179
+ this.S.push(d.align.bind(d, u, y, z, A, H));
180
180
  };
181
181
  this.flush = function() {
182
182
  console.assert(0 == this.la);
@@ -203,19 +203,19 @@ k.onRuntimeInitialized = function() {
203
203
  var A = z.delete;
204
204
  z.delete = function() {
205
205
  A.call(this);
206
- var G = this.Ka;
207
- r === w[G] && (r = null);
208
- "object" == typeof JSEvents && JSEvents.Oc(w[G].D.canvas);
209
- w[G] && w[G].D.canvas && (w[G].D.canvas.zb = void 0);
210
- this.Ka = this.F = this.La = this.T = w[G] = null;
206
+ var H = this.Ka;
207
+ r === w[H] && (r = null);
208
+ "object" == typeof JSEvents && JSEvents.Oc(w[H].D.canvas);
209
+ w[H] && w[H].D.canvas && (w[H].D.canvas.zb = void 0);
210
+ this.Ka = this.F = this.La = this.T = w[H] = null;
211
211
  };
212
212
  return z;
213
213
  }
214
214
  function c() {
215
215
  if (d) {
216
- var q = d.Cb, u = 0, y = 0, z = 0, A = Array(e.size), G = 0;
216
+ var q = d.Cb, u = 0, y = 0, z = 0, A = Array(e.size), H = 0;
217
217
  for (var I of e) {
218
- I.fa = Math.min(I.F.width, q), I.ea = Math.min(I.F.height, q), I.Ia = I.ea * I.fa, u = Math.max(u, I.fa), y = Math.max(y, I.ea), z += I.Ia, A[G++] = I;
218
+ I.fa = Math.min(I.F.width, q), I.ea = Math.min(I.F.height, q), I.Ia = I.ea * I.fa, u = Math.max(u, I.fa), y = Math.max(y, I.ea), z += I.Ia, A[H++] = I;
219
219
  }
220
220
  e.clear();
221
221
  if (!(0 >= z)) {
@@ -229,10 +229,10 @@ k.onRuntimeInitialized = function() {
229
229
  z = new k.DynamicRectanizer(q);
230
230
  for (I = 0; I < A.length;) {
231
231
  z.reset(u, y);
232
- for (G = I; G < A.length; ++G) {
233
- var L = A[G], E = z.addRect(L.fa, L.ea);
232
+ for (H = I; H < A.length; ++H) {
233
+ var L = A[H], E = z.addRect(L.fa, L.ea);
234
234
  if (0 > E) {
235
- console.assert(G > I);
235
+ console.assert(H > I);
236
236
  break;
237
237
  }
238
238
  L.ra = E & 65535;
@@ -247,7 +247,7 @@ k.onRuntimeInitialized = function() {
247
247
  d.F.width != L && (d.F.width = L);
248
248
  d.F.height != E && (d.F.height = E);
249
249
  d.clear();
250
- for (L = I; L < G; ++L) {
250
+ for (L = I; L < H; ++L) {
251
251
  E = A[L];
252
252
  d.saveClipRect(E.ra, E.sa, E.ra + E.fa, E.sa + E.ea);
253
253
  let ba = new k.Mat2D();
@@ -263,10 +263,10 @@ k.onRuntimeInitialized = function() {
263
263
  d.restoreClipRect();
264
264
  E.S = [];
265
265
  }
266
- for (d.flush(); I < G; ++I) {
266
+ for (d.flush(); I < H; ++I) {
267
267
  L = A[I], E = L.Ab, E.globalCompositeOperation = "copy", E.drawImage(d.F, L.ra, L.sa, L.fa, L.ea, 0, 0, L.F.width, L.F.height);
268
268
  }
269
- I = G;
269
+ I = H;
270
270
  }
271
271
  }
272
272
  }
@@ -363,11 +363,11 @@ var sa;
363
363
  k.wasmBinary && (sa = k.wasmBinary);
364
364
  var noExitRuntime = k.noExitRuntime || !0;
365
365
  "object" != typeof WebAssembly && ta("no native wasm support detected");
366
- var ua, C, va = !1, D, F, H, wa, J, K, xa, ya;
366
+ var ua, C, va = !1, D, F, G, wa, J, K, xa, ya;
367
367
  function za() {
368
368
  var a = ua.buffer;
369
369
  k.HEAP8 = D = new Int8Array(a);
370
- k.HEAP16 = H = new Int16Array(a);
370
+ k.HEAP16 = G = new Int16Array(a);
371
371
  k.HEAP32 = J = new Int32Array(a);
372
372
  k.HEAPU8 = F = new Uint8Array(a);
373
373
  k.HEAPU16 = wa = new Uint16Array(a);
@@ -442,7 +442,7 @@ function Oa(a, b) {
442
442
  return Na(c, a, b);
443
443
  }));
444
444
  }
445
- var Pa, Qa, Ua = {509966:(a, b, c, d, e) => {
445
+ var Pa, Qa, Ua = {510302:(a, b, c, d, e) => {
446
446
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
447
447
  return 0;
448
448
  }
@@ -505,9 +505,9 @@ var Pa, Qa, Ua = {509966:(a, b, c, d, e) => {
505
505
  }
506
506
  window.h.Da += 1;
507
507
  return 1;
508
- }, 512144:() => {
508
+ }, 512480:() => {
509
509
  "undefined" !== typeof window.h && (--window.h.Da, 0 === window.h.Da && delete window.h);
510
- }, 512308:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 512412:() => {
510
+ }, 512644:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 512748:() => {
511
511
  try {
512
512
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
513
513
  a.close();
@@ -515,7 +515,7 @@ var Pa, Qa, Ua = {509966:(a, b, c, d, e) => {
515
515
  } catch (c) {
516
516
  return 0;
517
517
  }
518
- }, 512583:(a, b, c, d, e, f) => {
518
+ }, 512919:(a, b, c, d, e, f) => {
519
519
  if ("undefined" === typeof window.h) {
520
520
  return -1;
521
521
  }
@@ -561,7 +561,7 @@ var Pa, Qa, Ua = {509966:(a, b, c, d, e) => {
561
561
  a == window.h.I.Ba && g.Z.connect(g.J.destination);
562
562
  g.lb = f;
563
563
  return window.h.oc(g);
564
- }, 515460:a => window.h.va(a).J.sampleRate, 515533:a => {
564
+ }, 515796:a => window.h.va(a).J.sampleRate, 515869:a => {
565
565
  a = window.h.va(a);
566
566
  void 0 !== a.Z && (a.Z.onaudioprocess = function() {
567
567
  }, a.Z.disconnect(), a.Z = void 0);
@@ -569,13 +569,13 @@ var Pa, Qa, Ua = {509966:(a, b, c, d, e) => {
569
569
  a.J.close();
570
570
  a.J = void 0;
571
571
  a.lb = void 0;
572
- }, 515933:a => {
572
+ }, 516269:a => {
573
573
  window.h.yb(a);
574
- }, 515983:a => {
574
+ }, 516319:a => {
575
575
  a = window.h.va(a);
576
576
  a.J.resume();
577
577
  a.state = window.h.ia.tb;
578
- }, 516122:a => {
578
+ }, 516458:a => {
579
579
  a = window.h.va(a);
580
580
  a.J.suspend();
581
581
  a.state = window.h.ia.stopped;
@@ -1684,7 +1684,7 @@ function ad(a, b, c) {
1684
1684
  };
1685
1685
  case 1:
1686
1686
  return function(d) {
1687
- return this.fromWireType((c ? H : wa)[d >> 1]);
1687
+ return this.fromWireType((c ? G : wa)[d >> 1]);
1688
1688
  };
1689
1689
  case 2:
1690
1690
  return function(d) {
@@ -1725,7 +1725,7 @@ function cd(a, b, c) {
1725
1725
  };
1726
1726
  case 1:
1727
1727
  return c ? function(d) {
1728
- return H[d >> 1];
1728
+ return G[d >> 1];
1729
1729
  } : function(d) {
1730
1730
  return wa[d >> 1];
1731
1731
  };
@@ -1750,7 +1750,7 @@ var dd = "undefined" != typeof TextDecoder ? new TextDecoder("utf-16le") : void
1750
1750
  }
1751
1751
  c = "";
1752
1752
  for (d = 0; !(d >= b / 2); ++d) {
1753
- var e = H[a + 2 * d >> 1];
1753
+ var e = G[a + 2 * d >> 1];
1754
1754
  if (0 == e) {
1755
1755
  break;
1756
1756
  }
@@ -1766,9 +1766,9 @@ var dd = "undefined" != typeof TextDecoder ? new TextDecoder("utf-16le") : void
1766
1766
  var d = b;
1767
1767
  c = c < 2 * a.length ? c / 2 : a.length;
1768
1768
  for (var e = 0; e < c; ++e) {
1769
- H[b >> 1] = a.charCodeAt(e), b += 2;
1769
+ G[b >> 1] = a.charCodeAt(e), b += 2;
1770
1770
  }
1771
- H[b >> 1] = 0;
1771
+ G[b >> 1] = 0;
1772
1772
  return b - d;
1773
1773
  }, gd = a => 2 * a.length, hd = (a, b) => {
1774
1774
  for (var c = 0, d = ""; !(c >= b / 4);) {
@@ -2311,7 +2311,7 @@ var Yd = {__syscall_fcntl64:function(a, b, c) {
2311
2311
  case 4:
2312
2312
  return e = Yb(), d.flags |= e, 0;
2313
2313
  case 5:
2314
- return e = Yb(), H[e + 0 >> 1] = 2, 0;
2314
+ return e = Yb(), G[e + 0 >> 1] = 2, 0;
2315
2315
  case 6:
2316
2316
  case 7:
2317
2317
  return 0;
@@ -2386,7 +2386,7 @@ var Yd = {__syscall_fcntl64:function(a, b, c) {
2386
2386
  if (!d.s) {
2387
2387
  return -59;
2388
2388
  }
2389
- d.s.V.Zb && (f = [24, 80], e = Yb(), H[e >> 1] = f[0], H[e + 2 >> 1] = f[1]);
2389
+ d.s.V.Zb && (f = [24, 80], e = Yb(), G[e >> 1] = f[0], G[e + 2 >> 1] = f[1]);
2390
2390
  return 0;
2391
2391
  case 21524:
2392
2392
  return d.s ? 0 : -59;
@@ -2509,7 +2509,7 @@ var Yd = {__syscall_fcntl64:function(a, b, c) {
2509
2509
  if (1 === c) {
2510
2510
  var l = D;
2511
2511
  } else if (2 === c) {
2512
- l = H;
2512
+ l = G;
2513
2513
  } else if (4 === c) {
2514
2514
  l = J;
2515
2515
  } else {
@@ -2554,10 +2554,10 @@ var Yd = {__syscall_fcntl64:function(a, b, c) {
2554
2554
  A.A && (void 0 === A.A.qa && (A.A.qa = []), A.A.qa.push(A));
2555
2555
  u = new Qc(t, A, !0, !1);
2556
2556
  y = new Qc(t + "*", A, !1, !1);
2557
- var G = new Qc(t + " const*", A, !1, !0);
2558
- tc[a] = {pointerType:y, Gb:G};
2557
+ var H = new Qc(t + " const*", A, !1, !0);
2558
+ tc[a] = {pointerType:y, Gb:H};
2559
2559
  Rc(n, q);
2560
- return [u, y, G];
2560
+ return [u, y, H];
2561
2561
  });
2562
2562
  }, _embind_register_class_class_function:function(a, b, c, d, e, f, g) {
2563
2563
  var l = Yc(c, d);
@@ -2677,9 +2677,9 @@ var Yd = {__syscall_fcntl64:function(a, b, c) {
2677
2677
  p = X(l, p);
2678
2678
  var y = n[1];
2679
2679
  u.set = function(z) {
2680
- var A = Zc(this, t, v + " setter"), G = [];
2681
- p(m, A, y.toWireType(G, z));
2682
- Ac(G);
2680
+ var A = Zc(this, t, v + " setter"), H = [];
2681
+ p(m, A, y.toWireType(H, z));
2682
+ Ac(H);
2683
2683
  };
2684
2684
  }
2685
2685
  Object.defineProperty(t.i.N, b, u);
@@ -3408,7 +3408,7 @@ var Yd = {__syscall_fcntl64:function(a, b, c) {
3408
3408
  Z.texSubImage2D(a, b, c, d, e, f, g, l, p);
3409
3409
  } else if (p) {
3410
3410
  var m = l - 5120;
3411
- m = 0 == m ? D : 1 == m ? F : 2 == m ? H : 4 == m ? J : 6 == m ? xa : 5 == m || 28922 == m || 28520 == m || 30779 == m || 30782 == m ? K : wa;
3411
+ m = 0 == m ? D : 1 == m ? F : 2 == m ? G : 4 == m ? J : 6 == m ? xa : 5 == m || 28922 == m || 28520 == m || 30779 == m || 30782 == m ? K : wa;
3412
3412
  Z.texSubImage2D(a, b, c, d, e, f, g, l, m, p >> 31 - Math.clz32(m.BYTES_PER_ELEMENT));
3413
3413
  } else {
3414
3414
  Z.texSubImage2D(a, b, c, d, e, f, g, l, null);
@@ -3487,13 +3487,14 @@ k.dynCall_iiji = (a, b, c, d, e) => (k.dynCall_iiji = C.dynCall_iiji)(a, b, c, d
3487
3487
  k.dynCall_iiiji = (a, b, c, d, e, f) => (k.dynCall_iiiji = C.dynCall_iiiji)(a, b, c, d, e, f);
3488
3488
  k.dynCall_iij = (a, b, c, d) => (k.dynCall_iij = C.dynCall_iij)(a, b, c, d);
3489
3489
  k.dynCall_jii = (a, b, c) => (k.dynCall_jii = C.dynCall_jii)(a, b, c);
3490
+ k.dynCall_vijj = (a, b, c, d, e, f) => (k.dynCall_vijj = C.dynCall_vijj)(a, b, c, d, e, f);
3490
3491
  k.dynCall_jiji = (a, b, c, d, e) => (k.dynCall_jiji = C.dynCall_jiji)(a, b, c, d, e);
3491
3492
  k.dynCall_viijii = (a, b, c, d, e, f, g) => (k.dynCall_viijii = C.dynCall_viijii)(a, b, c, d, e, f, g);
3492
3493
  k.dynCall_iiiiij = (a, b, c, d, e, f, g) => (k.dynCall_iiiiij = C.dynCall_iiiiij)(a, b, c, d, e, f, g);
3493
3494
  k.dynCall_iiiiijj = (a, b, c, d, e, f, g, l, p) => (k.dynCall_iiiiijj = C.dynCall_iiiiijj)(a, b, c, d, e, f, g, l, p);
3494
3495
  k.dynCall_iiiiiijj = (a, b, c, d, e, f, g, l, p, m) => (k.dynCall_iiiiiijj = C.dynCall_iiiiiijj)(a, b, c, d, e, f, g, l, p, m);
3495
- k.___start_em_js = 507532;
3496
- k.___stop_em_js = 509966;
3496
+ k.___start_em_js = 507868;
3497
+ k.___stop_em_js = 510302;
3497
3498
  var Zd;
3498
3499
  Ha = function $d() {
3499
3500
  Zd || ae();
@@ -3553,7 +3554,7 @@ ae();
3553
3554
  /* 2 */
3554
3555
  /***/ ((module) => {
3555
3556
 
3556
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.26.5","description":"Rive\'s webgl2 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)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3557
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.26.7","description":"Rive\'s webgl2 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)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3557
3558
 
3558
3559
  /***/ }),
3559
3560
  /* 3 */
@@ -4103,6 +4104,15 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
4103
4104
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4104
4105
  }
4105
4106
  };
4107
+ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
4108
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4109
+ if (ar || !(i in from)) {
4110
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4111
+ ar[i] = from[i];
4112
+ }
4113
+ }
4114
+ return to.concat(ar || Array.prototype.slice.call(from));
4115
+ };
4106
4116
 
4107
4117
 
4108
4118
 
@@ -5496,6 +5506,13 @@ var Rive = /** @class */ (function () {
5496
5506
  useOffscreenRenderer: params.useOffscreenRenderer,
5497
5507
  });
5498
5508
  }
5509
+ Object.defineProperty(Rive.prototype, "viewModelCount", {
5510
+ get: function () {
5511
+ return this.file.viewModelCount();
5512
+ },
5513
+ enumerable: false,
5514
+ configurable: true
5515
+ });
5499
5516
  // Alternative constructor to build a Rive instance from an interface/object
5500
5517
  Rive.new = function (params) {
5501
5518
  console.warn("This function is deprecated: please use `new Rive({})` instead");
@@ -6734,10 +6751,14 @@ var Rive = /** @class */ (function () {
6734
6751
  viewModelInstance.internalIncrementReferenceCount();
6735
6752
  (_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.cleanup();
6736
6753
  this._viewModelInstance = viewModelInstance;
6737
- this.artboard.bindViewModelInstance(viewModelInstance.runtimeInstance);
6738
- this.animator.stateMachines.forEach(function (stateMachine) {
6739
- return stateMachine.bindViewModelInstance(viewModelInstance);
6740
- });
6754
+ if (this.animator.stateMachines.length > 0) {
6755
+ this.animator.stateMachines.forEach(function (stateMachine) {
6756
+ return stateMachine.bindViewModelInstance(viewModelInstance);
6757
+ });
6758
+ }
6759
+ else {
6760
+ this.artboard.bindViewModelInstance(viewModelInstance.runtimeInstance);
6761
+ }
6741
6762
  }
6742
6763
  }
6743
6764
  };
@@ -6871,12 +6892,26 @@ var DataEnum = /** @class */ (function () {
6871
6892
  return DataEnum;
6872
6893
  }());
6873
6894
 
6895
+ var PropertyType;
6896
+ (function (PropertyType) {
6897
+ PropertyType["Number"] = "number";
6898
+ PropertyType["String"] = "string";
6899
+ PropertyType["Boolean"] = "boolean";
6900
+ PropertyType["Color"] = "color";
6901
+ PropertyType["Trigger"] = "trigger";
6902
+ PropertyType["Enum"] = "enum";
6903
+ })(PropertyType || (PropertyType = {}));
6874
6904
  var ViewModelInstance = /** @class */ (function () {
6875
- function ViewModelInstance(runtimeInstance, root) {
6905
+ function ViewModelInstance(runtimeInstance, parent) {
6906
+ this._parents = [];
6907
+ this._children = [];
6908
+ this._viewModelInstances = new Map();
6876
6909
  this._propertiesWithCallbacks = [];
6877
6910
  this._referenceCount = 0;
6878
6911
  this._runtimeInstance = runtimeInstance;
6879
- this._root = root || this;
6912
+ if (parent !== null) {
6913
+ this._parents.push(parent);
6914
+ }
6880
6915
  }
6881
6916
  Object.defineProperty(ViewModelInstance.prototype, "runtimeInstance", {
6882
6917
  get: function () {
@@ -6890,6 +6925,80 @@ var ViewModelInstance = /** @class */ (function () {
6890
6925
  this._propertiesWithCallbacks.forEach(function (property) {
6891
6926
  property.handleCallbacks();
6892
6927
  });
6928
+ this._propertiesWithCallbacks.forEach(function (property) {
6929
+ property.clearChanges();
6930
+ });
6931
+ }
6932
+ this._children.forEach(function (child) { return child.handleCallbacks(); });
6933
+ };
6934
+ ViewModelInstance.prototype.addParent = function (parent) {
6935
+ this._parents.push(parent);
6936
+ if (this._propertiesWithCallbacks.length > 0 || this._children.length > 0) {
6937
+ parent.addToViewModelCallbacks(this);
6938
+ }
6939
+ };
6940
+ ViewModelInstance.prototype.removeParent = function (parent) {
6941
+ var index = this._parents.indexOf(parent);
6942
+ if (index !== -1) {
6943
+ var parent_1 = this._parents[index];
6944
+ parent_1.removeFromViewModelCallbacks(this);
6945
+ this._parents.splice(index, 1);
6946
+ }
6947
+ };
6948
+ /*
6949
+ * method for internal use, it shouldn't be called externally
6950
+ */
6951
+ ViewModelInstance.prototype.addToPropertyCallbacks = function (property) {
6952
+ var _this = this;
6953
+ if (!this._propertiesWithCallbacks.includes(property)) {
6954
+ this._propertiesWithCallbacks.push(property);
6955
+ if (this._propertiesWithCallbacks.length > 0) {
6956
+ this._parents.forEach(function (parent) {
6957
+ parent.addToViewModelCallbacks(_this);
6958
+ });
6959
+ }
6960
+ }
6961
+ };
6962
+ /*
6963
+ * method for internal use, it shouldn't be called externally
6964
+ */
6965
+ ViewModelInstance.prototype.removeFromPropertyCallbacks = function (property) {
6966
+ var _this = this;
6967
+ if (this._propertiesWithCallbacks.includes(property)) {
6968
+ this._propertiesWithCallbacks = this._propertiesWithCallbacks.filter(function (prop) { return prop !== property; });
6969
+ if (this._children.length === 0 &&
6970
+ this._propertiesWithCallbacks.length === 0) {
6971
+ this._parents.forEach(function (parent) {
6972
+ parent.removeFromViewModelCallbacks(_this);
6973
+ });
6974
+ }
6975
+ }
6976
+ };
6977
+ /*
6978
+ * method for internal use, it shouldn't be called externally
6979
+ */
6980
+ ViewModelInstance.prototype.addToViewModelCallbacks = function (instance) {
6981
+ var _this = this;
6982
+ if (!this._children.includes(instance)) {
6983
+ this._children.push(instance);
6984
+ this._parents.forEach(function (parent) {
6985
+ parent.addToViewModelCallbacks(_this);
6986
+ });
6987
+ }
6988
+ };
6989
+ /*
6990
+ * method for internal use, it shouldn't be called externally
6991
+ */
6992
+ ViewModelInstance.prototype.removeFromViewModelCallbacks = function (instance) {
6993
+ var _this = this;
6994
+ if (this._children.includes(instance)) {
6995
+ this._children = this._children.filter(function (child) { return child !== instance; });
6996
+ if (this._children.length === 0 &&
6997
+ this._propertiesWithCallbacks.length === 0) {
6998
+ this._parents.forEach(function (parent) {
6999
+ parent.removeFromViewModelCallbacks(_this);
7000
+ });
7001
+ }
6893
7002
  }
6894
7003
  };
6895
7004
  ViewModelInstance.prototype.clearCallbacks = function () {
@@ -6897,97 +7006,179 @@ var ViewModelInstance = /** @class */ (function () {
6897
7006
  property.clearCallbacks();
6898
7007
  });
6899
7008
  };
7009
+ ViewModelInstance.prototype.propertyFromPath = function (path, type) {
7010
+ var pathSegments = path.split("/");
7011
+ return this.propertyFromPathSegments(pathSegments, 0, type);
7012
+ };
7013
+ ViewModelInstance.prototype.viewModelFromPathSegments = function (pathSegments, index) {
7014
+ var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
7015
+ if (viewModelInstance !== null) {
7016
+ if (index == pathSegments.length - 1) {
7017
+ return viewModelInstance;
7018
+ }
7019
+ else {
7020
+ return viewModelInstance.viewModelFromPathSegments(pathSegments, index++);
7021
+ }
7022
+ }
7023
+ return null;
7024
+ };
7025
+ ViewModelInstance.prototype.propertyFromPathSegments = function (pathSegments, index, type) {
7026
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
7027
+ if (index < pathSegments.length - 1) {
7028
+ var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
7029
+ if (viewModelInstance !== null) {
7030
+ return viewModelInstance.propertyFromPathSegments(pathSegments, index + 1, type);
7031
+ }
7032
+ else {
7033
+ return null;
7034
+ }
7035
+ }
7036
+ var instance = null;
7037
+ switch (type) {
7038
+ case PropertyType.Number:
7039
+ instance = (_b = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.number(pathSegments[index])) !== null && _b !== void 0 ? _b : null;
7040
+ if (instance !== null) {
7041
+ return new ViewModelInstanceNumber(instance, this);
7042
+ }
7043
+ break;
7044
+ case PropertyType.String:
7045
+ instance = (_d = (_c = this._runtimeInstance) === null || _c === void 0 ? void 0 : _c.string(pathSegments[index])) !== null && _d !== void 0 ? _d : null;
7046
+ if (instance !== null) {
7047
+ return new ViewModelInstanceString(instance, this);
7048
+ }
7049
+ break;
7050
+ case PropertyType.Boolean:
7051
+ instance = (_f = (_e = this._runtimeInstance) === null || _e === void 0 ? void 0 : _e.boolean(pathSegments[index])) !== null && _f !== void 0 ? _f : null;
7052
+ if (instance !== null) {
7053
+ return new ViewModelInstanceBoolean(instance, this);
7054
+ }
7055
+ break;
7056
+ case PropertyType.Color:
7057
+ instance = (_h = (_g = this._runtimeInstance) === null || _g === void 0 ? void 0 : _g.color(pathSegments[index])) !== null && _h !== void 0 ? _h : null;
7058
+ if (instance !== null) {
7059
+ return new ViewModelInstanceColor(instance, this);
7060
+ }
7061
+ break;
7062
+ case PropertyType.Trigger:
7063
+ instance = (_k = (_j = this._runtimeInstance) === null || _j === void 0 ? void 0 : _j.trigger(pathSegments[index])) !== null && _k !== void 0 ? _k : null;
7064
+ if (instance !== null) {
7065
+ return new ViewModelInstanceTrigger(instance, this);
7066
+ }
7067
+ break;
7068
+ case PropertyType.Enum:
7069
+ instance = (_m = (_l = this._runtimeInstance) === null || _l === void 0 ? void 0 : _l.enum(pathSegments[index])) !== null && _m !== void 0 ? _m : null;
7070
+ if (instance !== null) {
7071
+ return new ViewModelInstanceEnum(instance, this);
7072
+ }
7073
+ break;
7074
+ }
7075
+ return null;
7076
+ };
7077
+ ViewModelInstance.prototype.internalViewModelInstance = function (name) {
7078
+ var _a;
7079
+ if (this._viewModelInstances.has(name)) {
7080
+ return this._viewModelInstances.get(name);
7081
+ }
7082
+ var viewModelRuntimeInstance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.viewModel(name);
7083
+ if (viewModelRuntimeInstance !== null) {
7084
+ var viewModelInstance = new ViewModelInstance(viewModelRuntimeInstance, this);
7085
+ viewModelInstance.internalIncrementReferenceCount();
7086
+ this._viewModelInstances.set(name, viewModelInstance);
7087
+ return viewModelInstance;
7088
+ }
7089
+ return null;
7090
+ };
6900
7091
  /**
6901
7092
  * method to access a property instance of type number belonging
6902
7093
  * to the view model instance or to a nested view model instance
6903
7094
  * @param path - path to the number property
6904
7095
  */
6905
7096
  ViewModelInstance.prototype.number = function (path) {
6906
- var _a;
6907
- var instance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.number(path);
6908
- if (instance) {
6909
- return new ViewModelInstanceNumber(instance, this._root);
6910
- }
6911
- return null;
7097
+ var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Number);
7098
+ return viewmodelInstanceValue;
6912
7099
  };
6913
7100
  /**
6914
7101
  * method to access a property instance of type string belonging
6915
7102
  * to the view model instance or to a nested view model instance
6916
- * @param path - path to the number property
7103
+ * @param path - path to the string property
6917
7104
  */
6918
7105
  ViewModelInstance.prototype.string = function (path) {
6919
- var _a;
6920
- var instance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.string(path);
6921
- if (instance) {
6922
- return new ViewModelInstanceString(instance, this._root);
6923
- }
6924
- return null;
7106
+ var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.String);
7107
+ return viewmodelInstanceValue;
6925
7108
  };
6926
7109
  /**
6927
7110
  * method to access a property instance of type boolean belonging
6928
7111
  * to the view model instance or to a nested view model instance
6929
- * @param path - path to the number property
7112
+ * @param path - path to the boolean property
6930
7113
  */
6931
7114
  ViewModelInstance.prototype.boolean = function (path) {
6932
- var _a;
6933
- var instance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.boolean(path);
6934
- if (instance) {
6935
- return new ViewModelInstanceBoolean(instance, this._root);
6936
- }
6937
- return null;
7115
+ var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Boolean);
7116
+ return viewmodelInstanceValue;
6938
7117
  };
6939
7118
  /**
6940
7119
  * method to access a property instance of type color belonging
6941
7120
  * to the view model instance or to a nested view model instance
6942
- * @param path - path to the number property
7121
+ * @param path - path to the ttrigger property
6943
7122
  */
6944
7123
  ViewModelInstance.prototype.color = function (path) {
6945
- var _a;
6946
- var instance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.color(path);
6947
- if (instance) {
6948
- return new ViewModelInstanceColor(instance, this._root);
6949
- }
6950
- return null;
7124
+ var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Color);
7125
+ return viewmodelInstanceValue;
6951
7126
  };
6952
7127
  /**
6953
7128
  * method to access a property instance of type trigger belonging
6954
7129
  * to the view model instance or to a nested view model instance
6955
- * @param path - path to the number property
7130
+ * @param path - path to the trigger property
6956
7131
  */
6957
7132
  ViewModelInstance.prototype.trigger = function (path) {
6958
- var _a;
6959
- var instance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.trigger(path);
6960
- if (instance) {
6961
- return new ViewModelInstanceTrigger(instance, this._root);
6962
- }
6963
- return null;
7133
+ var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Trigger);
7134
+ return viewmodelInstanceValue;
6964
7135
  };
6965
7136
  /**
6966
7137
  * method to access a property instance of type enum belonging
6967
7138
  * to the view model instance or to a nested view model instance
6968
- * @param path - path to the number property
7139
+ * @param path - path to the enum property
6969
7140
  */
6970
7141
  ViewModelInstance.prototype.enum = function (path) {
6971
- var _a;
6972
- var instance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.enum(path);
6973
- if (instance) {
6974
- return new ViewModelInstanceEnum(instance, this._root);
6975
- }
6976
- return null;
7142
+ var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Enum);
7143
+ return viewmodelInstanceValue;
6977
7144
  };
6978
7145
  /**
6979
7146
  * method to access a view model property instance belonging
6980
7147
  * to the view model instance or to a nested view model instance
6981
- * @param path - path to the number property
7148
+ * @param path - path to the view model property
6982
7149
  */
6983
7150
  ViewModelInstance.prototype.viewModel = function (path) {
6984
- var _a;
6985
- var viewModelInstance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.viewModel(path);
6986
- if (viewModelInstance) {
6987
- return new ViewModelInstance(viewModelInstance, this._root);
7151
+ var pathSegments = path.split("/");
7152
+ var parentViewModelInstance = pathSegments.length > 1
7153
+ ? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
7154
+ : this;
7155
+ if (parentViewModelInstance != null) {
7156
+ return parentViewModelInstance.internalViewModelInstance(pathSegments[pathSegments.length - 1]);
6988
7157
  }
6989
7158
  return null;
6990
7159
  };
7160
+ ViewModelInstance.prototype.internalReplaceViewModel = function (name, value) {
7161
+ var _a;
7162
+ if (value.runtimeInstance !== null) {
7163
+ var result = ((_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.replaceViewModel(name, value.runtimeInstance)) ||
7164
+ false;
7165
+ if (result) {
7166
+ value.internalIncrementReferenceCount();
7167
+ var oldInstance_1 = this.internalViewModelInstance(name);
7168
+ if (oldInstance_1 !== null) {
7169
+ oldInstance_1.removeParent(this);
7170
+ if (this._children.includes(oldInstance_1)) {
7171
+ this._children = this._children.filter(function (child) { return child !== oldInstance_1; });
7172
+ }
7173
+ oldInstance_1.cleanup();
7174
+ }
7175
+ this._viewModelInstances.set(name, value);
7176
+ value.addParent(this);
7177
+ }
7178
+ return result;
7179
+ }
7180
+ return false;
7181
+ };
6991
7182
  /**
6992
7183
  * method to replace a view model property with another view model value
6993
7184
  * @param path - path to the view model property
@@ -6995,27 +7186,11 @@ var ViewModelInstance = /** @class */ (function () {
6995
7186
  */
6996
7187
  ViewModelInstance.prototype.replaceViewModel = function (path, value) {
6997
7188
  var _a;
6998
- if (value.runtimeInstance !== null) {
6999
- return (((_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.replaceViewModel(path, value.runtimeInstance)) ||
7000
- false);
7001
- }
7002
- return false;
7003
- };
7004
- /*
7005
- * method for internal use, it shouldn't be called externally
7006
- */
7007
- ViewModelInstance.prototype.addToCallbacks = function (property) {
7008
- if (!this._propertiesWithCallbacks.includes(property)) {
7009
- this._propertiesWithCallbacks.push(property);
7010
- }
7011
- };
7012
- /*
7013
- * method for internal use, it shouldn't be called externally
7014
- */
7015
- ViewModelInstance.prototype.removeFromCallbacks = function (property) {
7016
- if (this._propertiesWithCallbacks.includes(property)) {
7017
- this._propertiesWithCallbacks = this._propertiesWithCallbacks.filter(function (prop) { return prop !== property; });
7018
- }
7189
+ var pathSegments = path.split("/");
7190
+ var viewModelInstance = pathSegments.length > 1
7191
+ ? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
7192
+ : this;
7193
+ return ((_a = viewModelInstance === null || viewModelInstance === void 0 ? void 0 : viewModelInstance.internalReplaceViewModel(pathSegments[pathSegments.length - 1], value)) !== null && _a !== void 0 ? _a : false);
7019
7194
  };
7020
7195
  /*
7021
7196
  * method to add one to the reference counter of the instance.
@@ -7047,21 +7222,36 @@ var ViewModelInstance = /** @class */ (function () {
7047
7222
  this._referenceCount++;
7048
7223
  };
7049
7224
  ViewModelInstance.prototype.cleanup = function () {
7225
+ var _this = this;
7050
7226
  this._referenceCount--;
7051
7227
  if (this._referenceCount <= 0) {
7052
7228
  this._runtimeInstance = null;
7053
7229
  this.clearCallbacks();
7054
7230
  this._propertiesWithCallbacks = [];
7231
+ this._viewModelInstances.forEach(function (value) {
7232
+ value.cleanup();
7233
+ });
7234
+ this._viewModelInstances.clear();
7235
+ var children = __spreadArray([], this._children, true);
7236
+ this._children.length = 0;
7237
+ var parents = __spreadArray([], this._parents, true);
7238
+ this._parents.length = 0;
7239
+ children.forEach(function (child) {
7240
+ child.removeParent(_this);
7241
+ });
7242
+ parents.forEach(function (parent) {
7243
+ parent.removeFromViewModelCallbacks(_this);
7244
+ });
7055
7245
  }
7056
7246
  };
7057
7247
  return ViewModelInstance;
7058
7248
  }());
7059
7249
 
7060
7250
  var ViewModelInstanceValue = /** @class */ (function () {
7061
- function ViewModelInstanceValue(instance, root) {
7251
+ function ViewModelInstanceValue(instance, parent) {
7062
7252
  this.callbacks = [];
7063
7253
  this._viewModelInstanceValue = instance;
7064
- this._rootViewModel = root;
7254
+ this._parentViewModel = parent;
7065
7255
  }
7066
7256
  ViewModelInstanceValue.prototype.on = function (callback) {
7067
7257
  // Since we don't clean the changed flag for properties that don't have listeners,
@@ -7071,7 +7261,7 @@ var ViewModelInstanceValue = /** @class */ (function () {
7071
7261
  }
7072
7262
  if (!this.callbacks.includes(callback)) {
7073
7263
  this.callbacks.push(callback);
7074
- this._rootViewModel.addToCallbacks(this);
7264
+ this._parentViewModel.addToPropertyCallbacks(this);
7075
7265
  }
7076
7266
  };
7077
7267
  ViewModelInstanceValue.prototype.off = function (callback) {
@@ -7082,19 +7272,21 @@ var ViewModelInstanceValue = /** @class */ (function () {
7082
7272
  this.callbacks = this.callbacks.filter(function (cb) { return cb !== callback; });
7083
7273
  }
7084
7274
  if (this.callbacks.length === 0) {
7085
- this._rootViewModel.removeFromCallbacks(this);
7275
+ this._parentViewModel.removeFromPropertyCallbacks(this);
7086
7276
  }
7087
7277
  };
7088
7278
  ViewModelInstanceValue.prototype.internalHandleCallback = function (callback) { };
7089
7279
  ViewModelInstanceValue.prototype.handleCallbacks = function () {
7090
7280
  var _this = this;
7091
7281
  if (this._viewModelInstanceValue.hasChanged) {
7092
- this._viewModelInstanceValue.clearChanges();
7093
7282
  this.callbacks.forEach(function (callback) {
7094
7283
  _this.internalHandleCallback(callback);
7095
7284
  });
7096
7285
  }
7097
7286
  };
7287
+ ViewModelInstanceValue.prototype.clearChanges = function () {
7288
+ this._viewModelInstanceValue.clearChanges();
7289
+ };
7098
7290
  ViewModelInstanceValue.prototype.clearCallbacks = function () {
7099
7291
  this.callbacks.length = 0;
7100
7292
  };
@@ -7110,8 +7302,8 @@ var ViewModelInstanceValue = /** @class */ (function () {
7110
7302
 
7111
7303
  var ViewModelInstanceString = /** @class */ (function (_super) {
7112
7304
  __extends(ViewModelInstanceString, _super);
7113
- function ViewModelInstanceString(instance, root) {
7114
- return _super.call(this, instance, root) || this;
7305
+ function ViewModelInstanceString(instance, parent) {
7306
+ return _super.call(this, instance, parent) || this;
7115
7307
  }
7116
7308
  Object.defineProperty(ViewModelInstanceString.prototype, "value", {
7117
7309
  get: function () {
@@ -7131,8 +7323,8 @@ var ViewModelInstanceString = /** @class */ (function (_super) {
7131
7323
 
7132
7324
  var ViewModelInstanceNumber = /** @class */ (function (_super) {
7133
7325
  __extends(ViewModelInstanceNumber, _super);
7134
- function ViewModelInstanceNumber(instance, root) {
7135
- return _super.call(this, instance, root) || this;
7326
+ function ViewModelInstanceNumber(instance, parent) {
7327
+ return _super.call(this, instance, parent) || this;
7136
7328
  }
7137
7329
  Object.defineProperty(ViewModelInstanceNumber.prototype, "value", {
7138
7330
  get: function () {
@@ -7152,8 +7344,8 @@ var ViewModelInstanceNumber = /** @class */ (function (_super) {
7152
7344
 
7153
7345
  var ViewModelInstanceBoolean = /** @class */ (function (_super) {
7154
7346
  __extends(ViewModelInstanceBoolean, _super);
7155
- function ViewModelInstanceBoolean(instance, root) {
7156
- return _super.call(this, instance, root) || this;
7347
+ function ViewModelInstanceBoolean(instance, parent) {
7348
+ return _super.call(this, instance, parent) || this;
7157
7349
  }
7158
7350
  Object.defineProperty(ViewModelInstanceBoolean.prototype, "value", {
7159
7351
  get: function () {
@@ -7173,8 +7365,8 @@ var ViewModelInstanceBoolean = /** @class */ (function (_super) {
7173
7365
 
7174
7366
  var ViewModelInstanceTrigger = /** @class */ (function (_super) {
7175
7367
  __extends(ViewModelInstanceTrigger, _super);
7176
- function ViewModelInstanceTrigger(instance, root) {
7177
- return _super.call(this, instance, root) || this;
7368
+ function ViewModelInstanceTrigger(instance, parent) {
7369
+ return _super.call(this, instance, parent) || this;
7178
7370
  }
7179
7371
  ViewModelInstanceTrigger.prototype.trigger = function () {
7180
7372
  return this._viewModelInstanceValue.trigger();
@@ -7187,8 +7379,8 @@ var ViewModelInstanceTrigger = /** @class */ (function (_super) {
7187
7379
 
7188
7380
  var ViewModelInstanceEnum = /** @class */ (function (_super) {
7189
7381
  __extends(ViewModelInstanceEnum, _super);
7190
- function ViewModelInstanceEnum(instance, root) {
7191
- return _super.call(this, instance, root) || this;
7382
+ function ViewModelInstanceEnum(instance, parent) {
7383
+ return _super.call(this, instance, parent) || this;
7192
7384
  }
7193
7385
  Object.defineProperty(ViewModelInstanceEnum.prototype, "value", {
7194
7386
  get: function () {
@@ -7226,8 +7418,8 @@ var ViewModelInstanceEnum = /** @class */ (function (_super) {
7226
7418
 
7227
7419
  var ViewModelInstanceColor = /** @class */ (function (_super) {
7228
7420
  __extends(ViewModelInstanceColor, _super);
7229
- function ViewModelInstanceColor(instance, root) {
7230
- return _super.call(this, instance, root) || this;
7421
+ function ViewModelInstanceColor(instance, parent) {
7422
+ return _super.call(this, instance, parent) || this;
7231
7423
  }
7232
7424
  Object.defineProperty(ViewModelInstanceColor.prototype, "value", {
7233
7425
  get: function () {