@rive-app/canvas 2.20.2 → 2.21.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.20.2",
3
+ "version": "2.21.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
@@ -516,6 +516,44 @@ export declare class Rive {
516
516
  * @param path the path the input is located at an artboard level
517
517
  */
518
518
  fireStateAtPath(inputName: string, path: string): void;
519
+ private retrieveTextAtPath;
520
+ /**
521
+ * Retrieves the text value for a specified text run at a given path
522
+ * @param textName The name of the text run
523
+ * @param path The path to the text run within the artboard
524
+ * @returns The text value of the text run, or undefined if not found
525
+ *
526
+ * @example
527
+ * // Get the text value for a text run named "title" at one nested artboard deep
528
+ * const titleText = riveInstance.getTextRunValueAtPath("title", "artboard1");
529
+ *
530
+ * @example
531
+ * // Get the text value for a text run named "subtitle" within a nested group two artboards deep
532
+ * const subtitleText = riveInstance.getTextRunValueAtPath("subtitle", "group/nestedGroup");
533
+ *
534
+ * @remarks
535
+ * If the text run cannot be found at the specified path, a warning will be logged to the console.
536
+ */
537
+ getTextRunValueAtPath(textName: string, path: string): string | undefined;
538
+ /**
539
+ * Sets the text value for a specified text run at a given path
540
+ * @param textName The name of the text run
541
+ * @param value The new text value to set
542
+ * @param path The path to the text run within the artboard
543
+ * @returns void
544
+ *
545
+ * @example
546
+ * // Set the text value for a text run named "title" at one nested artboard deep
547
+ * riveInstance.setTextRunValueAtPath("title", "New Title", "artboard1");
548
+ *
549
+ * @example
550
+ * // Set the text value for a text run named "subtitle" within a nested group two artboards deep
551
+ * riveInstance.setTextRunValueAtPath("subtitle", "New Subtitle", "group/nestedGroup");
552
+ *
553
+ * @remarks
554
+ * If the text run cannot be found at the specified path, a warning will be logged to the console.
555
+ */
556
+ setTextRunValueAtPath(textName: string, value: string, path: string): void;
519
557
  get playingStateMachineNames(): string[];
520
558
  get playingAnimationNames(): string[];
521
559
  get pausedAnimationNames(): string[];
package/rive.js CHANGED
@@ -738,7 +738,7 @@ function Ya(a, b) {
738
738
  return Xa(c, a, b);
739
739
  }));
740
740
  }
741
- var Za, $a, db = {437404:(a, b, c, d, e) => {
741
+ var Za, $a, db = {437468:(a, b, c, d, e) => {
742
742
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
743
743
  return 0;
744
744
  }
@@ -801,9 +801,9 @@ var Za, $a, db = {437404:(a, b, c, d, e) => {
801
801
  }
802
802
  window.h.Aa += 1;
803
803
  return 1;
804
- }, 439582:() => {
804
+ }, 439646:() => {
805
805
  "undefined" !== typeof window.h && (--window.h.Aa, 0 === window.h.Aa && delete window.h);
806
- }, 439746:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 439850:() => {
806
+ }, 439810:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 439914:() => {
807
807
  try {
808
808
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
809
809
  a.close();
@@ -811,7 +811,7 @@ var Za, $a, db = {437404:(a, b, c, d, e) => {
811
811
  } catch (c) {
812
812
  return 0;
813
813
  }
814
- }, 440021:(a, b, c, d, e, f) => {
814
+ }, 440085:(a, b, c, d, e, f) => {
815
815
  if ("undefined" === typeof window.h) {
816
816
  return -1;
817
817
  }
@@ -857,7 +857,7 @@ var Za, $a, db = {437404:(a, b, c, d, e) => {
857
857
  a == window.h.I.ya && g.Z.connect(g.J.destination);
858
858
  g.pb = f;
859
859
  return window.h.yc(g);
860
- }, 442898:a => window.h.ra(a).J.sampleRate, 442971:a => {
860
+ }, 442962:a => window.h.ra(a).J.sampleRate, 443035:a => {
861
861
  a = window.h.ra(a);
862
862
  void 0 !== a.Z && (a.Z.onaudioprocess = function() {
863
863
  }, a.Z.disconnect(), a.Z = void 0);
@@ -865,13 +865,13 @@ var Za, $a, db = {437404:(a, b, c, d, e) => {
865
865
  a.J.close();
866
866
  a.J = void 0;
867
867
  a.pb = void 0;
868
- }, 443371:a => {
868
+ }, 443435:a => {
869
869
  window.h.Cb(a);
870
- }, 443421:a => {
870
+ }, 443485:a => {
871
871
  a = window.h.ra(a);
872
872
  a.J.resume();
873
873
  a.state = window.h.ga.xb;
874
- }, 443560:a => {
874
+ }, 443624:a => {
875
875
  a = window.h.ra(a);
876
876
  a.J.suspend();
877
877
  a.state = window.h.ga.stopped;
@@ -3357,7 +3357,7 @@ Zd();
3357
3357
  /* 2 */
3358
3358
  /***/ ((module) => {
3359
3359
 
3360
- module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.20.2","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}}');
3360
+ module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.21.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}}');
3361
3361
 
3362
3362
  /***/ }),
3363
3363
  /* 3 */
@@ -5899,6 +5899,78 @@ var Rive = /** @class */ (function () {
5899
5899
  console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a trigger"));
5900
5900
  }
5901
5901
  };
5902
+ // Returns the TextValueRun object for the provided name at the given path
5903
+ Rive.prototype.retrieveTextAtPath = function (name, path) {
5904
+ if (!name) {
5905
+ console.warn("No text name provided for path '".concat(path, "'"));
5906
+ return;
5907
+ }
5908
+ if (!path) {
5909
+ console.warn("No path provided for text '".concat(name, "'"));
5910
+ return;
5911
+ }
5912
+ if (!this.artboard) {
5913
+ console.warn("Tried to access text: '".concat(name, "', at path: '").concat(path, "', but the Artboard is null"));
5914
+ return;
5915
+ }
5916
+ var text = this.artboard.textByPath(name, path);
5917
+ if (!text) {
5918
+ console.warn("Could not access text with name: '".concat(name, "', at path:'").concat(path, "'"));
5919
+ return;
5920
+ }
5921
+ return text;
5922
+ };
5923
+ /**
5924
+ * Retrieves the text value for a specified text run at a given path
5925
+ * @param textName The name of the text run
5926
+ * @param path The path to the text run within the artboard
5927
+ * @returns The text value of the text run, or undefined if not found
5928
+ *
5929
+ * @example
5930
+ * // Get the text value for a text run named "title" at one nested artboard deep
5931
+ * const titleText = riveInstance.getTextRunValueAtPath("title", "artboard1");
5932
+ *
5933
+ * @example
5934
+ * // Get the text value for a text run named "subtitle" within a nested group two artboards deep
5935
+ * const subtitleText = riveInstance.getTextRunValueAtPath("subtitle", "group/nestedGroup");
5936
+ *
5937
+ * @remarks
5938
+ * If the text run cannot be found at the specified path, a warning will be logged to the console.
5939
+ */
5940
+ Rive.prototype.getTextRunValueAtPath = function (textName, path) {
5941
+ var run = this.retrieveTextAtPath(textName, path);
5942
+ if (!run) {
5943
+ console.warn("Could not get text with name: '".concat(textName, "', at path:'").concat(path, "'"));
5944
+ return;
5945
+ }
5946
+ return run.text;
5947
+ };
5948
+ /**
5949
+ * Sets the text value for a specified text run at a given path
5950
+ * @param textName The name of the text run
5951
+ * @param value The new text value to set
5952
+ * @param path The path to the text run within the artboard
5953
+ * @returns void
5954
+ *
5955
+ * @example
5956
+ * // Set the text value for a text run named "title" at one nested artboard deep
5957
+ * riveInstance.setTextRunValueAtPath("title", "New Title", "artboard1");
5958
+ *
5959
+ * @example
5960
+ * // Set the text value for a text run named "subtitle" within a nested group two artboards deep
5961
+ * riveInstance.setTextRunValueAtPath("subtitle", "New Subtitle", "group/nestedGroup");
5962
+ *
5963
+ * @remarks
5964
+ * If the text run cannot be found at the specified path, a warning will be logged to the console.
5965
+ */
5966
+ Rive.prototype.setTextRunValueAtPath = function (textName, value, path) {
5967
+ var run = this.retrieveTextAtPath(textName, path);
5968
+ if (!run) {
5969
+ console.warn("Could not set text with name: '".concat(textName, "', at path:'").concat(path, "'"));
5970
+ return;
5971
+ }
5972
+ run.text = value;
5973
+ };
5902
5974
  Object.defineProperty(Rive.prototype, "playingStateMachineNames", {
5903
5975
  // Returns a list of playing machine names
5904
5976
  get: function () {