@rive-app/canvas 2.16.0 → 2.17.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas",
3
- "version": "2.16.0",
3
+ "version": "2.17.0",
4
4
  "description": "Rive's canvas based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -495,6 +495,27 @@ export declare class Rive {
495
495
  * @returns the inputs for the named state machine
496
496
  */
497
497
  stateMachineInputs(name: string): StateMachineInput[];
498
+ private retrieveInputAtPath;
499
+ /**
500
+ * Set the boolean input with the provided name at the given path with value
501
+ * @param input the state machine input name
502
+ * @param value the value to set the input to
503
+ * @param path the path the input is located at an artboard level
504
+ */
505
+ setBooleanStateAtPath(inputName: string, value: boolean, path: string): void;
506
+ /**
507
+ * Set the number input with the provided name at the given path with value
508
+ * @param input the state machine input name
509
+ * @param value the value to set the input to
510
+ * @param path the path the input is located at an artboard level
511
+ */
512
+ setNumberStateAtPath(inputName: string, value: number, path: string): void;
513
+ /**
514
+ * Fire the trigger with the provided name at the given path
515
+ * @param input the state machine input name
516
+ * @param path the path the input is located at an artboard level
517
+ */
518
+ fireStateAtPath(inputName: string, path: string): void;
498
519
  get playingStateMachineNames(): string[];
499
520
  get playingAnimationNames(): string[];
500
521
  get pausedAnimationNames(): string[];
package/rive.js CHANGED
@@ -736,7 +736,7 @@ function Ya(a, b) {
736
736
  return Xa(c, a, b);
737
737
  }));
738
738
  }
739
- var Za, $a, db = {430204:(a, b, c, d, e) => {
739
+ var Za, $a, db = {430252:(a, b, c, d, e) => {
740
740
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
741
741
  return 0;
742
742
  }
@@ -799,9 +799,9 @@ var Za, $a, db = {430204:(a, b, c, d, e) => {
799
799
  }
800
800
  window.h.Aa += 1;
801
801
  return 1;
802
- }, 432382:() => {
802
+ }, 432430:() => {
803
803
  "undefined" !== typeof window.h && (--window.h.Aa, 0 === window.h.Aa && delete window.h);
804
- }, 432546:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 432650:() => {
804
+ }, 432594:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 432698:() => {
805
805
  try {
806
806
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
807
807
  a.close();
@@ -809,7 +809,7 @@ var Za, $a, db = {430204:(a, b, c, d, e) => {
809
809
  } catch (c) {
810
810
  return 0;
811
811
  }
812
- }, 432821:(a, b, c, d, e, f) => {
812
+ }, 432869:(a, b, c, d, e, f) => {
813
813
  if ("undefined" === typeof window.h) {
814
814
  return -1;
815
815
  }
@@ -855,7 +855,7 @@ var Za, $a, db = {430204:(a, b, c, d, e) => {
855
855
  a == window.h.H.ya && g.Z.connect(g.I.destination);
856
856
  g.pb = f;
857
857
  return window.h.yc(g);
858
- }, 435698:a => window.h.ra(a).I.sampleRate, 435771:a => {
858
+ }, 435746:a => window.h.ra(a).I.sampleRate, 435819:a => {
859
859
  a = window.h.ra(a);
860
860
  void 0 !== a.Z && (a.Z.onaudioprocess = function() {
861
861
  }, a.Z.disconnect(), a.Z = void 0);
@@ -863,13 +863,13 @@ var Za, $a, db = {430204:(a, b, c, d, e) => {
863
863
  a.I.close();
864
864
  a.I = void 0;
865
865
  a.pb = void 0;
866
- }, 436171:a => {
866
+ }, 436219:a => {
867
867
  window.h.Cb(a);
868
- }, 436221:a => {
868
+ }, 436269:a => {
869
869
  a = window.h.ra(a);
870
870
  a.I.resume();
871
871
  a.state = window.h.ga.xb;
872
- }, 436360:a => {
872
+ }, 436408:a => {
873
873
  a = window.h.ra(a);
874
874
  a.I.suspend();
875
875
  a.state = window.h.ga.stopped;
@@ -3355,7 +3355,7 @@ Zd();
3355
3355
  /* 2 */
3356
3356
  /***/ ((module) => {
3357
3357
 
3358
- module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.16.0","description":"Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3358
+ module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.17.0","description":"Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3359
3359
 
3360
3360
  /***/ }),
3361
3361
  /* 3 */
@@ -5746,6 +5746,73 @@ var Rive = /** @class */ (function () {
5746
5746
  var stateMachine = this.animator.stateMachines.find(function (m) { return m.name === name; });
5747
5747
  return stateMachine === null || stateMachine === void 0 ? void 0 : stateMachine.inputs;
5748
5748
  };
5749
+ // Returns the input with the provided name at the given path
5750
+ Rive.prototype.retrieveInputAtPath = function (name, path) {
5751
+ if (!name) {
5752
+ console.warn("No input name provided for path '".concat(path, "'"));
5753
+ return;
5754
+ }
5755
+ if (!this.artboard) {
5756
+ console.warn("Tried to access input: '".concat(name, "', at path: '").concat(path, "', but the Artboard is null"));
5757
+ return;
5758
+ }
5759
+ var input = this.artboard.inputByPath(name, path);
5760
+ if (!input) {
5761
+ console.warn("Could not access an input with name: '".concat(name, "', at path:'").concat(path, "'"));
5762
+ return;
5763
+ }
5764
+ return input;
5765
+ };
5766
+ /**
5767
+ * Set the boolean input with the provided name at the given path with value
5768
+ * @param input the state machine input name
5769
+ * @param value the value to set the input to
5770
+ * @param path the path the input is located at an artboard level
5771
+ */
5772
+ Rive.prototype.setBooleanStateAtPath = function (inputName, value, path) {
5773
+ var input = this.retrieveInputAtPath(inputName, path);
5774
+ if (!input)
5775
+ return;
5776
+ if (input.type === StateMachineInputType.Boolean) {
5777
+ input.asBool().value = value;
5778
+ }
5779
+ else {
5780
+ console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a boolean"));
5781
+ }
5782
+ };
5783
+ /**
5784
+ * Set the number input with the provided name at the given path with value
5785
+ * @param input the state machine input name
5786
+ * @param value the value to set the input to
5787
+ * @param path the path the input is located at an artboard level
5788
+ */
5789
+ Rive.prototype.setNumberStateAtPath = function (inputName, value, path) {
5790
+ var input = this.retrieveInputAtPath(inputName, path);
5791
+ if (!input)
5792
+ return;
5793
+ if (input.type === StateMachineInputType.Number) {
5794
+ input.asNumber().value = value;
5795
+ }
5796
+ else {
5797
+ console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a number"));
5798
+ }
5799
+ };
5800
+ /**
5801
+ * Fire the trigger with the provided name at the given path
5802
+ * @param input the state machine input name
5803
+ * @param path the path the input is located at an artboard level
5804
+ */
5805
+ Rive.prototype.fireStateAtPath = function (inputName, path) {
5806
+ var input = this.retrieveInputAtPath(inputName, path);
5807
+ if (!input)
5808
+ return;
5809
+ if (input.type === StateMachineInputType.Trigger) {
5810
+ input.asTrigger().fire();
5811
+ }
5812
+ else {
5813
+ console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a trigger"));
5814
+ }
5815
+ };
5749
5816
  Object.defineProperty(Rive.prototype, "playingStateMachineNames", {
5750
5817
  // Returns a list of playing machine names
5751
5818
  get: function () {