@rive-app/webgl 2.16.0 → 2.17.1

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/webgl",
3
- "version": "2.16.0",
3
+ "version": "2.17.1",
4
4
  "description": "Rive's webgl 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
@@ -400,7 +400,7 @@ function Qa(a, b) {
400
400
  return Pa(c, a, b);
401
401
  }));
402
402
  }
403
- var Ra, Sa, Wa = {685260:(a, b, c, d, e) => {
403
+ var Ra, Sa, Wa = {685308:(a, b, c, d, e) => {
404
404
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
405
405
  return 0;
406
406
  }
@@ -463,9 +463,9 @@ var Ra, Sa, Wa = {685260:(a, b, c, d, e) => {
463
463
  }
464
464
  window.h.Ea += 1;
465
465
  return 1;
466
- }, 687438:() => {
466
+ }, 687486:() => {
467
467
  "undefined" !== typeof window.h && (--window.h.Ea, 0 === window.h.Ea && delete window.h);
468
- }, 687602:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 687706:() => {
468
+ }, 687650:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 687754:() => {
469
469
  try {
470
470
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
471
471
  a.close();
@@ -473,7 +473,7 @@ var Ra, Sa, Wa = {685260:(a, b, c, d, e) => {
473
473
  } catch (c) {
474
474
  return 0;
475
475
  }
476
- }, 687877:(a, b, c, d, e, f) => {
476
+ }, 687925:(a, b, c, d, e, f) => {
477
477
  if ("undefined" === typeof window.h) {
478
478
  return -1;
479
479
  }
@@ -519,7 +519,7 @@ var Ra, Sa, Wa = {685260:(a, b, c, d, e) => {
519
519
  a == window.h.H.Ca && g.X.connect(g.I.destination);
520
520
  g.lb = f;
521
521
  return window.h.nc(g);
522
- }, 690754:a => window.h.ta(a).I.sampleRate, 690827:a => {
522
+ }, 690802:a => window.h.ta(a).I.sampleRate, 690875:a => {
523
523
  a = window.h.ta(a);
524
524
  void 0 !== a.X && (a.X.onaudioprocess = function() {
525
525
  }, a.X.disconnect(), a.X = void 0);
@@ -527,13 +527,13 @@ var Ra, Sa, Wa = {685260:(a, b, c, d, e) => {
527
527
  a.I.close();
528
528
  a.I = void 0;
529
529
  a.lb = void 0;
530
- }, 691227:a => {
530
+ }, 691275:a => {
531
531
  window.h.xb(a);
532
- }, 691277:a => {
532
+ }, 691325:a => {
533
533
  a = window.h.ta(a);
534
534
  a.I.resume();
535
535
  a.state = window.h.ha.sb;
536
- }, 691416:a => {
536
+ }, 691464:a => {
537
537
  a = window.h.ta(a);
538
538
  a.I.suspend();
539
539
  a.state = window.h.ha.stopped;
@@ -4053,7 +4053,7 @@ Ie();
4053
4053
  /* 2 */
4054
4054
  /***/ ((module) => {
4055
4055
 
4056
- module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.16.0","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}}');
4056
+ module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.17.1","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}}');
4057
4057
 
4058
4058
  /***/ }),
4059
4059
  /* 3 */
@@ -6444,6 +6444,73 @@ var Rive = /** @class */ (function () {
6444
6444
  var stateMachine = this.animator.stateMachines.find(function (m) { return m.name === name; });
6445
6445
  return stateMachine === null || stateMachine === void 0 ? void 0 : stateMachine.inputs;
6446
6446
  };
6447
+ // Returns the input with the provided name at the given path
6448
+ Rive.prototype.retrieveInputAtPath = function (name, path) {
6449
+ if (!name) {
6450
+ console.warn("No input name provided for path '".concat(path, "'"));
6451
+ return;
6452
+ }
6453
+ if (!this.artboard) {
6454
+ console.warn("Tried to access input: '".concat(name, "', at path: '").concat(path, "', but the Artboard is null"));
6455
+ return;
6456
+ }
6457
+ var input = this.artboard.inputByPath(name, path);
6458
+ if (!input) {
6459
+ console.warn("Could not access an input with name: '".concat(name, "', at path:'").concat(path, "'"));
6460
+ return;
6461
+ }
6462
+ return input;
6463
+ };
6464
+ /**
6465
+ * Set the boolean input with the provided name at the given path with value
6466
+ * @param input the state machine input name
6467
+ * @param value the value to set the input to
6468
+ * @param path the path the input is located at an artboard level
6469
+ */
6470
+ Rive.prototype.setBooleanStateAtPath = function (inputName, value, path) {
6471
+ var input = this.retrieveInputAtPath(inputName, path);
6472
+ if (!input)
6473
+ return;
6474
+ if (input.type === StateMachineInputType.Boolean) {
6475
+ input.asBool().value = value;
6476
+ }
6477
+ else {
6478
+ console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a boolean"));
6479
+ }
6480
+ };
6481
+ /**
6482
+ * Set the number input with the provided name at the given path with value
6483
+ * @param input the state machine input name
6484
+ * @param value the value to set the input to
6485
+ * @param path the path the input is located at an artboard level
6486
+ */
6487
+ Rive.prototype.setNumberStateAtPath = function (inputName, value, path) {
6488
+ var input = this.retrieveInputAtPath(inputName, path);
6489
+ if (!input)
6490
+ return;
6491
+ if (input.type === StateMachineInputType.Number) {
6492
+ input.asNumber().value = value;
6493
+ }
6494
+ else {
6495
+ console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a number"));
6496
+ }
6497
+ };
6498
+ /**
6499
+ * Fire the trigger with the provided name at the given path
6500
+ * @param input the state machine input name
6501
+ * @param path the path the input is located at an artboard level
6502
+ */
6503
+ Rive.prototype.fireStateAtPath = function (inputName, path) {
6504
+ var input = this.retrieveInputAtPath(inputName, path);
6505
+ if (!input)
6506
+ return;
6507
+ if (input.type === StateMachineInputType.Trigger) {
6508
+ input.asTrigger().fire();
6509
+ }
6510
+ else {
6511
+ console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a trigger"));
6512
+ }
6513
+ };
6447
6514
  Object.defineProperty(Rive.prototype, "playingStateMachineNames", {
6448
6515
  // Returns a list of playing machine names
6449
6516
  get: function () {