@rive-app/canvas-advanced 2.26.3 → 2.26.5

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.
@@ -5,10 +5,10 @@ var Rive = (() => {
5
5
  return (
6
6
  function(moduleArg = {}) {
7
7
 
8
- var m = moduleArg, aa, ea;
8
+ var m = moduleArg, aa, ba;
9
9
  m.ready = new Promise((a, b) => {
10
10
  aa = a;
11
- ea = b;
11
+ ba = b;
12
12
  });
13
13
  function fa() {
14
14
  function a(g) {
@@ -245,7 +245,7 @@ const ja = "createConicGradient createImageData createLinearGradient createPatte
245
245
  b.clearColor(0, 0, 0, 0);
246
246
  b.clear(b.COLOR_BUFFER_BIT);
247
247
  b.enable(b.SCISSOR_TEST);
248
- r.sort((H, ba) => ba.wb - H.wb);
248
+ r.sort((H, ca) => ca.wb - H.wb);
249
249
  w = v.push(B);
250
250
  g != w && (b.bufferData(b.ARRAY_BUFFER, 8 * w, b.DYNAMIC_DRAW), g = w);
251
251
  w = 0;
@@ -253,8 +253,8 @@ const ja = "createConicGradient createImageData createLinearGradient createPatte
253
253
  b.bufferSubData(b.ARRAY_BUFFER, w, T.Ta), w += 4 * T.Ta.length;
254
254
  }
255
255
  console.assert(w == 4 * B);
256
- for (var ca of r) {
257
- b.bufferSubData(b.ARRAY_BUFFER, w, ca.Db), w += 4 * ca.Db.length;
256
+ for (var da of r) {
257
+ b.bufferSubData(b.ARRAY_BUFFER, w, da.Db), w += 4 * da.Db.length;
258
258
  }
259
259
  console.assert(w == 8 * B);
260
260
  w = x.push(D);
@@ -265,15 +265,15 @@ const ja = "createConicGradient createImageData createLinearGradient createPatte
265
265
  }
266
266
  console.assert(T == 2 * D);
267
267
  ra = 0;
268
- ca = !0;
268
+ da = !0;
269
269
  w = T = 0;
270
270
  for (const H of r) {
271
271
  H.image.Ka != ra && (b.bindTexture(b.TEXTURE_2D, H.image.Ja || null), ra = H.image.Ka);
272
- H.mc ? (b.scissor(H.Ya, M - H.Za - H.jb, H.Ac, H.jb), ca = !0) : ca && (b.scissor(0, M - t, k, t), ca = !1);
272
+ H.mc ? (b.scissor(H.Ya, M - H.Za - H.jb, H.Ac, H.jb), da = !0) : da && (b.scissor(0, M - t, k, t), da = !1);
273
273
  r = 2 / k;
274
- const ba = -2 / t;
275
- b.uniform4f(e, H.ha[0] * r * H.Ba, H.ha[1] * ba * H.Ca, H.ha[2] * r * H.Ba, H.ha[3] * ba * H.Ca);
276
- b.uniform2f(f, H.ha[4] * r * H.Ba + r * (H.Ya - H.ic * H.Ba) - 1, H.ha[5] * ba * H.Ca + ba * (H.Za - H.jc * H.Ca) + 1);
274
+ const ca = -2 / t;
275
+ b.uniform4f(e, H.ha[0] * r * H.Ba, H.ha[1] * ca * H.Ca, H.ha[2] * r * H.Ba, H.ha[3] * ca * H.Ca);
276
+ b.uniform2f(f, H.ha[4] * r * H.Ba + r * (H.Ya - H.ic * H.Ba) - 1, H.ha[5] * ca * H.Ca + ca * (H.Za - H.jc * H.Ca) + 1);
277
277
  b.vertexAttribPointer(0, 2, b.FLOAT, !1, 0, w);
278
278
  b.vertexAttribPointer(1, 2, b.FLOAT, !1, 0, w + 4 * B);
279
279
  b.drawElements(b.TRIANGLES, H.indices.length, b.UNSIGNED_SHORT, T);
@@ -330,7 +330,7 @@ m.onRuntimeInitialized = function() {
330
330
  return "rgba(" + ((16711680 & q) >>> 16) + "," + ((65280 & q) >>> 8) + "," + ((255 & q) >>> 0) + "," + ((4278190080 & q) >>> 24) / 255 + ")";
331
331
  }
332
332
  function c() {
333
- 0 < M.length && (ka.Qb(w.drawWidth(), w.drawHeight(), M, T, ca), M = [], ca = T = 0, w.reset(512, 512));
333
+ 0 < M.length && (ka.Qb(w.drawWidth(), w.drawHeight(), M, T, da), M = [], da = T = 0, w.reset(512, 512));
334
334
  for (const q of D) {
335
335
  for (const y of q.H) {
336
336
  y();
@@ -440,8 +440,8 @@ m.onRuntimeInitialized = function() {
440
440
  var K = I.cb;
441
441
  const Q = I.Ra;
442
442
  I.ec ? (I = X - A, K -= J, A = q.createRadialGradient(A, J, 0, A, J, Math.sqrt(I * I + K * K))) : A = q.createLinearGradient(A, J, X, K);
443
- for (let da = 0, R = Q.length; da < R; da++) {
444
- J = Q[da], A.addColorStop(J.stop, b(J.color));
443
+ for (let ea = 0, R = Q.length; ea < R; ea++) {
444
+ J = Q[ea], A.addColorStop(J.stop, b(J.color));
445
445
  }
446
446
  this.Xa = A;
447
447
  this.ja = null;
@@ -459,7 +459,7 @@ m.onRuntimeInitialized = function() {
459
459
  }
460
460
  },});
461
461
  const D = new Set();
462
- let w = null, M = [], T = 0, ca = 0;
462
+ let w = null, M = [], T = 0, da = 0;
463
463
  var ra = m.CanvasRenderer = g.extend("Renderer", {__construct:function(q) {
464
464
  this.__parent.__construct.call(this);
465
465
  this.S = [1, 0, 0, 1, 0, 0];
@@ -503,29 +503,29 @@ m.onRuntimeInitialized = function() {
503
503
  q[G] = y[F + G];
504
504
  }
505
505
  }, _drawImageMesh:function(q, y, F, G, A, I, J, K, X, Q) {
506
- var da = this.C.canvas.width, R = this.C.canvas.height;
506
+ var ea = this.C.canvas.width, R = this.C.canvas.height;
507
507
  const Yb = X - J, Zb = Q - K;
508
508
  J = Math.max(J, 0);
509
509
  K = Math.max(K, 0);
510
- X = Math.min(X, da);
510
+ X = Math.min(X, ea);
511
511
  Q = Math.min(Q, R);
512
512
  const Ga = X - J, Ha = Q - K;
513
- console.assert(Ga <= Math.min(Yb, da));
513
+ console.assert(Ga <= Math.min(Yb, ea));
514
514
  console.assert(Ha <= Math.min(Zb, R));
515
515
  if (!(0 >= Ga || 0 >= Ha)) {
516
516
  X = Ga < Yb || Ha < Zb;
517
- da = Q = 1;
518
- var sa = Math.ceil(Ga * Q), ta = Math.ceil(Ha * da);
517
+ ea = Q = 1;
518
+ var sa = Math.ceil(Ga * Q), ta = Math.ceil(Ha * ea);
519
519
  R = ka.hc();
520
520
  sa > R && (Q *= R / sa, sa = R);
521
- ta > R && (da *= R / ta, ta = R);
521
+ ta > R && (ea *= R / ta, ta = R);
522
522
  w || (w = new m.DynamicRectanizer(R), w.reset(512, 512));
523
523
  R = w.addRect(sa, ta);
524
524
  0 > R && (c(), D.add(this), R = w.addRect(sa, ta), console.assert(0 <= R));
525
525
  var $b = R & 65535, ac = R >> 16;
526
- M.push({ha:this.S.slice(this.S.length - 6), image:q, Ya:$b, Za:ac, ic:J, jc:K, Ac:sa, jb:ta, Ba:Q, Ca:da, Ta:new Float32Array(G), Db:new Float32Array(A), indices:new Uint16Array(I), mc:X, wb:q.Ka << 1 | (X ? 1 : 0),});
526
+ M.push({ha:this.S.slice(this.S.length - 6), image:q, Ya:$b, Za:ac, ic:J, jc:K, Ac:sa, jb:ta, Ba:Q, Ca:ea, Ta:new Float32Array(G), Db:new Float32Array(A), indices:new Uint16Array(I), mc:X, wb:q.Ka << 1 | (X ? 1 : 0),});
527
527
  T += G.length;
528
- ca += I.length;
528
+ da += I.length;
529
529
  var za = this.C, qd = a(y);
530
530
  this.H.push(function() {
531
531
  za.save();
@@ -579,7 +579,7 @@ m.onRuntimeInitialized = function() {
579
579
  }, makeRenderPath:function() {
580
580
  return new r();
581
581
  }, makeRenderImage:function() {
582
- let q = ba;
582
+ let q = ca;
583
583
  return new t({xa:() => {
584
584
  q.total++;
585
585
  }, la:() => {
@@ -590,18 +590,18 @@ m.onRuntimeInitialized = function() {
590
590
  }
591
591
  },});
592
592
  },};
593
- let H = m.load, ba = null;
593
+ let H = m.load, ca = null;
594
594
  m.load = function(q, y, F = !0) {
595
595
  const G = new m.FallbackFileAssetLoader();
596
596
  void 0 !== y && G.addLoader(y);
597
597
  F && (y = new m.CDNFileAssetLoader(), G.addLoader(y));
598
598
  return new Promise(function(A) {
599
599
  let I = null;
600
- ba = {total:0, loaded:0, ready:function() {
600
+ ca = {total:0, loaded:0, ready:function() {
601
601
  A(I);
602
602
  },};
603
603
  I = H(q, G);
604
- 0 == ba.total && A(I);
604
+ 0 == ca.total && A(I);
605
605
  });
606
606
  };
607
607
  let rd = m.RendererWrapper.prototype.align;
@@ -672,7 +672,7 @@ function Aa(a) {
672
672
  xa(a);
673
673
  Ca = !0;
674
674
  a = new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
675
- ea(a);
675
+ ba(a);
676
676
  throw a;
677
677
  }
678
678
  function Sa(a) {
@@ -725,7 +725,7 @@ function Ya(a, b) {
725
725
  return Xa(c, a, b);
726
726
  }));
727
727
  }
728
- var Za, $a, db = {447324:(a, b, c, d, e) => {
728
+ var Za, $a, db = {449484:(a, b, c, d, e) => {
729
729
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
730
730
  return 0;
731
731
  }
@@ -788,9 +788,9 @@ var Za, $a, db = {447324:(a, b, c, d, e) => {
788
788
  }
789
789
  window.h.Aa += 1;
790
790
  return 1;
791
- }, 449502:() => {
791
+ }, 451662:() => {
792
792
  "undefined" !== typeof window.h && (--window.h.Aa, 0 === window.h.Aa && delete window.h);
793
- }, 449666:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 449770:() => {
793
+ }, 451826:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 451930:() => {
794
794
  try {
795
795
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
796
796
  a.close();
@@ -798,7 +798,7 @@ var Za, $a, db = {447324:(a, b, c, d, e) => {
798
798
  } catch (c) {
799
799
  return 0;
800
800
  }
801
- }, 449941:(a, b, c, d, e, f) => {
801
+ }, 452101:(a, b, c, d, e, f) => {
802
802
  if ("undefined" === typeof window.h) {
803
803
  return -1;
804
804
  }
@@ -844,7 +844,7 @@ var Za, $a, db = {447324:(a, b, c, d, e) => {
844
844
  a == window.h.I.ya && g.Z.connect(g.J.destination);
845
845
  g.pb = f;
846
846
  return window.h.yc(g);
847
- }, 452818:a => window.h.ra(a).J.sampleRate, 452891:a => {
847
+ }, 454978:a => window.h.ra(a).J.sampleRate, 455051:a => {
848
848
  a = window.h.ra(a);
849
849
  void 0 !== a.Z && (a.Z.onaudioprocess = function() {
850
850
  }, a.Z.disconnect(), a.Z = void 0);
@@ -852,13 +852,13 @@ var Za, $a, db = {447324:(a, b, c, d, e) => {
852
852
  a.J.close();
853
853
  a.J = void 0;
854
854
  a.pb = void 0;
855
- }, 453291:a => {
855
+ }, 455451:a => {
856
856
  window.h.Cb(a);
857
- }, 453341:a => {
857
+ }, 455501:a => {
858
858
  a = window.h.ra(a);
859
859
  a.J.resume();
860
860
  a.state = window.h.ga.xb;
861
- }, 453480:a => {
861
+ }, 455640:a => {
862
862
  a = window.h.ra(a);
863
863
  a.J.suspend();
864
864
  a.state = window.h.ga.stopped;
@@ -3018,6 +3018,8 @@ var Xd = {__syscall_fcntl64:function(a, b, c) {
3018
3018
  return sc(a[b]);
3019
3019
  }, _emval_incref:function(a) {
3020
3020
  4 < a && (U.get(a).tb += 1);
3021
+ }, _emval_new_array:function() {
3022
+ return sc([]);
3021
3023
  }, _emval_new_cstring:function(a) {
3022
3024
  return sc(Gd(a));
3023
3025
  }, _emval_new_object:function() {
@@ -3263,12 +3265,12 @@ var Xd = {__syscall_fcntl64:function(a, b, c) {
3263
3265
  try {
3264
3266
  return m.instantiateWasm(b, a);
3265
3267
  } catch (c) {
3266
- xa("Module.instantiateWasm callback failed with error: " + c), ea(c);
3268
+ xa("Module.instantiateWasm callback failed with error: " + c), ba(c);
3267
3269
  }
3268
3270
  }
3269
3271
  Ya(b, function(c) {
3270
3272
  a(c.instance);
3271
- }).catch(ea);
3273
+ }).catch(ba);
3272
3274
  return {};
3273
3275
  })();
3274
3276
  var Ec = a => (Ec = z.free)(a), Wd = a => (Wd = z.malloc)(a), ab = m._ma_device__on_notification_unlocked = a => (ab = m._ma_device__on_notification_unlocked = z.ma_device__on_notification_unlocked)(a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas-advanced",
3
- "version": "2.26.3",
3
+ "version": "2.26.5",
4
4
  "description": "Rive's lightweight low-level canvas based web api.",
5
5
  "main": "canvas_advanced.mjs",
6
6
  "homepage": "https://rive.app",
package/rive.wasm CHANGED
Binary file
@@ -335,6 +335,33 @@ export declare class File {
335
335
  * @returns Number of artboards in the Rive file
336
336
  */
337
337
  artboardCount(): number;
338
+ /**
339
+ * Returns the number of View Models in the Rive File
340
+ * @returns Number of view models in the Rive file
341
+ */
342
+ viewModelCount(): number;
343
+ /**
344
+ * Returns a view model by the index in which it is located in the file
345
+ * @returns ViewModel
346
+ */
347
+ viewModelByIndex(index: number): ViewModel;
348
+ /**
349
+ * Returns a view model by name
350
+ * @returns ViewModel
351
+ */
352
+ viewModelByName(name: string): ViewModel;
353
+
354
+ /**
355
+ * Returns the default view model for the provided artboard
356
+ * @returns ViewModel
357
+ */
358
+ defaultArtboardViewModel(artboard: Artboard): ViewModel;
359
+
360
+ /**
361
+ * Returns a list of all data enums
362
+ * @returns DataEnum array in the Rive file
363
+ */
364
+ enums(): DataEnum[];
338
365
 
339
366
  delete(): void;
340
367
  }
@@ -509,6 +536,11 @@ export declare class Artboard {
509
536
  * Reset the artboard size to the original value
510
537
  */
511
538
  resetArtboardSize(): void;
539
+ /**
540
+ * binds the view model instance to the artboard
541
+ * @param instance - Renderer context to draw with
542
+ */
543
+ bindViewModelInstance(instance: ViewModelInstance): void;
512
544
  }
513
545
 
514
546
  export declare class Bone extends TransformComponent {
@@ -796,6 +828,12 @@ export declare class StateMachineInstance {
796
828
  * when no longer in use
797
829
  */
798
830
  delete(): void;
831
+
832
+ /**
833
+ * binds the view model instance to the state machine
834
+ * @param instance - Renderer context to draw with
835
+ */
836
+ bindViewModelInstance(instance: ViewModelInstance): void;
799
837
  }
800
838
 
801
839
  export declare class SMIInput {
@@ -826,6 +864,85 @@ export declare class SMIInput {
826
864
  asTrigger(): SMIInput;
827
865
  }
828
866
 
867
+ export declare type ViewModelProperty = {
868
+ name: string;
869
+ type: DataType;
870
+ };
871
+
872
+ export declare class ViewModelInstanceValue {
873
+ get hasChanged(): boolean;
874
+ clearChanges(): void;
875
+ get name(): string;
876
+ }
877
+
878
+ export declare class ViewModelInstanceNumber extends ViewModelInstanceValue {
879
+ get value(): number;
880
+ set value(val: number);
881
+ }
882
+
883
+ export declare class ViewModelInstanceTrigger extends ViewModelInstanceValue {
884
+ trigger(): void;
885
+ }
886
+
887
+ export declare class ViewModelInstanceString extends ViewModelInstanceValue {
888
+ get value(): string;
889
+ set value(val: string);
890
+ }
891
+
892
+ export declare class ViewModelInstanceBoolean extends ViewModelInstanceValue {
893
+ get value(): boolean;
894
+ set value(val: boolean);
895
+ }
896
+
897
+ export declare class ViewModelInstanceColor extends ViewModelInstanceValue {
898
+ get value(): number;
899
+ set value(val: number);
900
+ rgb(r: number, g: number, b: number): void;
901
+ argb(a: number, r: number, g: number, b: number): void;
902
+ alpha(a: number): void;
903
+ }
904
+
905
+ export declare class ViewModelInstanceEnum extends ViewModelInstanceValue {
906
+ get value(): string;
907
+ set value(val: string);
908
+ get valueIndex(): number;
909
+ set valueIndex(val: number);
910
+ get values(): string[];
911
+ }
912
+
913
+ export declare class ViewModelInstance {
914
+ get propertyCount(): number;
915
+ number(path: string): ViewModelInstanceNumber;
916
+ string(path: string): ViewModelInstanceString;
917
+ boolean(path: string): ViewModelInstanceBoolean;
918
+ color(path: string): ViewModelInstanceColor;
919
+ enum(path: string): ViewModelInstanceEnum;
920
+ trigger(path: string): ViewModelInstanceTrigger;
921
+ viewModel(path: string): ViewModelInstance;
922
+ replaceViewModel(path: string, value: ViewModelInstance): boolean;
923
+ incrementReferenceCount(): void;
924
+ decrementReferenceCount(): void;
925
+ delete(): void;
926
+ getProperties(): ViewModelProperty[];
927
+ }
928
+
929
+ export declare class ViewModel {
930
+ get instanceCount(): number;
931
+ instanceByIndex(index: number): ViewModelInstance;
932
+ instanceByName(name: string): ViewModelInstance;
933
+ defaultInstance(): ViewModelInstance;
934
+ instance(): ViewModelInstance;
935
+ getProperties(): ViewModelProperty[];
936
+ getInstanceNames(): string[];
937
+ get propertyCount(): number;
938
+ get name(): string;
939
+ }
940
+
941
+ export declare class DataEnum {
942
+ get name(): string;
943
+ get values(): string[];
944
+ }
945
+
829
946
  export declare class SMIBool {}
830
947
 
831
948
  export declare class SMINumber {}
@@ -836,6 +953,18 @@ export declare class SMITrigger {}
836
953
  // ENUMS //
837
954
  ///////////
838
955
 
956
+ export enum DataType {
957
+ none,
958
+ string,
959
+ number,
960
+ boolean,
961
+ color,
962
+ list,
963
+ enumType,
964
+ trigger,
965
+ viewModel,
966
+ }
967
+
839
968
  export enum Fit {
840
969
  fill,
841
970
  contain,
Binary file