@rive-app/canvas-lite 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-lite",
3
- "version": "2.16.0",
3
+ "version": "2.17.0",
4
4
  "description": "A lite version of 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
@@ -2259,7 +2259,7 @@ Pc();
2259
2259
  /* 2 */
2260
2260
  /***/ ((module) => {
2261
2261
 
2262
- module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.16.0","description":"A lite version of Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2262
+ module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.17.0","description":"A lite version of Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2263
2263
 
2264
2264
  /***/ }),
2265
2265
  /* 3 */
@@ -4650,6 +4650,73 @@ var Rive = /** @class */ (function () {
4650
4650
  var stateMachine = this.animator.stateMachines.find(function (m) { return m.name === name; });
4651
4651
  return stateMachine === null || stateMachine === void 0 ? void 0 : stateMachine.inputs;
4652
4652
  };
4653
+ // Returns the input with the provided name at the given path
4654
+ Rive.prototype.retrieveInputAtPath = function (name, path) {
4655
+ if (!name) {
4656
+ console.warn("No input name provided for path '".concat(path, "'"));
4657
+ return;
4658
+ }
4659
+ if (!this.artboard) {
4660
+ console.warn("Tried to access input: '".concat(name, "', at path: '").concat(path, "', but the Artboard is null"));
4661
+ return;
4662
+ }
4663
+ var input = this.artboard.inputByPath(name, path);
4664
+ if (!input) {
4665
+ console.warn("Could not access an input with name: '".concat(name, "', at path:'").concat(path, "'"));
4666
+ return;
4667
+ }
4668
+ return input;
4669
+ };
4670
+ /**
4671
+ * Set the boolean input with the provided name at the given path with value
4672
+ * @param input the state machine input name
4673
+ * @param value the value to set the input to
4674
+ * @param path the path the input is located at an artboard level
4675
+ */
4676
+ Rive.prototype.setBooleanStateAtPath = function (inputName, value, path) {
4677
+ var input = this.retrieveInputAtPath(inputName, path);
4678
+ if (!input)
4679
+ return;
4680
+ if (input.type === StateMachineInputType.Boolean) {
4681
+ input.asBool().value = value;
4682
+ }
4683
+ else {
4684
+ console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a boolean"));
4685
+ }
4686
+ };
4687
+ /**
4688
+ * Set the number input with the provided name at the given path with value
4689
+ * @param input the state machine input name
4690
+ * @param value the value to set the input to
4691
+ * @param path the path the input is located at an artboard level
4692
+ */
4693
+ Rive.prototype.setNumberStateAtPath = function (inputName, value, path) {
4694
+ var input = this.retrieveInputAtPath(inputName, path);
4695
+ if (!input)
4696
+ return;
4697
+ if (input.type === StateMachineInputType.Number) {
4698
+ input.asNumber().value = value;
4699
+ }
4700
+ else {
4701
+ console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a number"));
4702
+ }
4703
+ };
4704
+ /**
4705
+ * Fire the trigger with the provided name at the given path
4706
+ * @param input the state machine input name
4707
+ * @param path the path the input is located at an artboard level
4708
+ */
4709
+ Rive.prototype.fireStateAtPath = function (inputName, path) {
4710
+ var input = this.retrieveInputAtPath(inputName, path);
4711
+ if (!input)
4712
+ return;
4713
+ if (input.type === StateMachineInputType.Trigger) {
4714
+ input.asTrigger().fire();
4715
+ }
4716
+ else {
4717
+ console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a trigger"));
4718
+ }
4719
+ };
4653
4720
  Object.defineProperty(Rive.prototype, "playingStateMachineNames", {
4654
4721
  // Returns a list of playing machine names
4655
4722
  get: function () {