@rive-app/canvas 2.15.6 → 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.15.6",
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
@@ -123,7 +123,7 @@ export declare enum EventType {
123
123
  export type RiveEventPayload = rc.RiveEvent | rc.OpenUrlEvent;
124
124
  export interface Event {
125
125
  type: EventType;
126
- data?: string | string[] | LoopEvent | number | RiveEventPayload;
126
+ data?: string | string[] | LoopEvent | number | RiveEventPayload | RiveFile;
127
127
  }
128
128
  /**
129
129
  * Looping types: one-shot, loop, and ping-pong
@@ -189,6 +189,7 @@ export interface RiveParameters {
189
189
  canvas: HTMLCanvasElement | OffscreenCanvas;
190
190
  src?: string;
191
191
  buffer?: ArrayBuffer;
192
+ riveFile?: RiveFile;
192
193
  artboard?: string;
193
194
  animations?: string | string[];
194
195
  stateMachines?: string | string[];
@@ -265,6 +266,7 @@ export interface RiveParameters {
265
266
  export interface RiveLoadParameters {
266
267
  src?: string;
267
268
  buffer?: ArrayBuffer;
269
+ riveFile?: RiveFile;
268
270
  autoplay?: boolean;
269
271
  artboard?: string;
270
272
  animations?: string | string[];
@@ -278,6 +280,50 @@ export interface RiveResetParameters {
278
280
  stateMachines?: string | string[];
279
281
  autoplay?: boolean;
280
282
  }
283
+ export interface RiveFileParameters {
284
+ src?: string;
285
+ buffer?: ArrayBuffer;
286
+ assetLoader?: AssetLoadCallback;
287
+ enableRiveAssetCDN?: boolean;
288
+ onLoad?: EventCallback;
289
+ onLoadError?: EventCallback;
290
+ }
291
+ export declare class RiveFile {
292
+ private static readonly missingErrorMessage;
293
+ private static readonly fileLoadErrorMessage;
294
+ private src;
295
+ private buffer;
296
+ private runtime;
297
+ private file;
298
+ private assetLoader;
299
+ private enableRiveAssetCDN;
300
+ private eventManager;
301
+ private referenceCount;
302
+ constructor(params: RiveFileParameters);
303
+ private initData;
304
+ init(): Promise<void>;
305
+ /**
306
+ * Subscribe to Rive-generated events
307
+ * @param type the type of event to subscribe to
308
+ * @param callback callback to fire when the event occurs
309
+ */
310
+ on(type: EventType, callback: EventCallback): void;
311
+ /**
312
+ * Unsubscribes from a Rive-generated event
313
+ * @param type the type of event to unsubscribe from
314
+ * @param callback the callback to unsubscribe
315
+ */
316
+ off(type: EventType, callback: EventCallback): void;
317
+ cleanup(): void;
318
+ /**
319
+ * Unsubscribes all Rive listeners from an event type, or everything if no type is
320
+ * given
321
+ * @param type the type of event to unsubscribe from, or all types if
322
+ * undefined
323
+ */
324
+ removeAllRiveEventListeners(type?: EventType): void;
325
+ getInstance(): rc.File;
326
+ }
281
327
  export declare class Rive {
282
328
  private readonly canvas;
283
329
  private src;
@@ -298,6 +344,7 @@ export declare class Rive {
298
344
  private artboard;
299
345
  private eventCleanup;
300
346
  private file;
347
+ private riveFile;
301
348
  private eventManager;
302
349
  private taskQueue;
303
350
  private animator;
@@ -448,6 +495,27 @@ export declare class Rive {
448
495
  * @returns the inputs for the named state machine
449
496
  */
450
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;
451
519
  get playingStateMachineNames(): string[];
452
520
  get playingAnimationNames(): string[];
453
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 = {430124:(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 = {430124:(a, b, c, d, e) => {
799
799
  }
800
800
  window.h.Aa += 1;
801
801
  return 1;
802
- }, 432302:() => {
802
+ }, 432430:() => {
803
803
  "undefined" !== typeof window.h && (--window.h.Aa, 0 === window.h.Aa && delete window.h);
804
- }, 432466:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 432570:() => {
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 = {430124:(a, b, c, d, e) => {
809
809
  } catch (c) {
810
810
  return 0;
811
811
  }
812
- }, 432741:(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 = {430124:(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
- }, 435618:a => window.h.ra(a).I.sampleRate, 435691: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 = {430124:(a, b, c, d, e) => {
863
863
  a.I.close();
864
864
  a.I = void 0;
865
865
  a.pb = void 0;
866
- }, 436091:a => {
866
+ }, 436219:a => {
867
867
  window.h.Cb(a);
868
- }, 436141: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
- }, 436280:a => {
872
+ }, 436408:a => {
873
873
  a = window.h.ra(a);
874
874
  a.I.suspend();
875
875
  a.state = window.h.ga.stopped;
@@ -2979,7 +2979,7 @@ var Wd = {__syscall_fcntl64:function(a, b, c) {
2979
2979
  Vc(a, {fc:!0, name:b, argPackAdvance:0, fromWireType:function() {
2980
2980
  }, toWireType:function() {
2981
2981
  },});
2982
- }, _emval_as:function(a, b, c) {
2982
+ }, _emscripten_get_now_is_monotonic:() => !0, _emval_as:function(a, b, c) {
2983
2983
  a = rc(a);
2984
2984
  b = Fc(b, "emval::as");
2985
2985
  var d = [], e = sc(d);
@@ -3055,7 +3055,9 @@ var Wd = {__syscall_fcntl64:function(a, b, c) {
3055
3055
  c += 105 != d & c, Kd.push(105 == d ? L[c] : Ia[c++ >> 1]), ++c;
3056
3056
  }
3057
3057
  return db[a].apply(null, Kd);
3058
- }, emscripten_memcpy_big:(a, b, c) => E.copyWithin(a, b, b + c), emscripten_resize_heap:a => {
3058
+ }, emscripten_date_now:function() {
3059
+ return Date.now();
3060
+ }, emscripten_get_now:() => performance.now(), emscripten_memcpy_big:(a, b, c) => E.copyWithin(a, b, b + c), emscripten_resize_heap:a => {
3059
3061
  var b = E.length;
3060
3062
  a >>>= 0;
3061
3063
  if (2147483648 < a) {
@@ -3353,7 +3355,7 @@ Zd();
3353
3355
  /* 2 */
3354
3356
  /***/ ((module) => {
3355
3357
 
3356
- module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.15.6","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}}');
3357
3359
 
3358
3360
  /***/ }),
3359
3361
  /* 3 */
@@ -3647,6 +3649,7 @@ __webpack_require__.r(__webpack_exports__);
3647
3649
  /* harmony export */ LoopType: () => (/* binding */ LoopType),
3648
3650
  /* harmony export */ Rive: () => (/* binding */ Rive),
3649
3651
  /* harmony export */ RiveEventType: () => (/* binding */ RiveEventType),
3652
+ /* harmony export */ RiveFile: () => (/* binding */ RiveFile),
3650
3653
  /* harmony export */ RuntimeLoader: () => (/* binding */ RuntimeLoader),
3651
3654
  /* harmony export */ StateMachineInput: () => (/* binding */ StateMachineInput),
3652
3655
  /* harmony export */ StateMachineInputType: () => (/* binding */ StateMachineInputType),
@@ -4832,6 +4835,142 @@ var ObjectObservers = /** @class */ (function () {
4832
4835
  return ObjectObservers;
4833
4836
  }());
4834
4837
  var observers = new ObjectObservers();
4838
+ var RiveFile = /** @class */ (function () {
4839
+ function RiveFile(params) {
4840
+ // Allow the runtime to automatically load assets hosted in Rive's runtime.
4841
+ this.enableRiveAssetCDN = true;
4842
+ this.referenceCount = 0;
4843
+ this.src = params.src;
4844
+ this.buffer = params.buffer;
4845
+ if (params.assetLoader)
4846
+ this.assetLoader = params.assetLoader;
4847
+ this.enableRiveAssetCDN =
4848
+ typeof params.enableRiveAssetCDN == "boolean"
4849
+ ? params.enableRiveAssetCDN
4850
+ : true;
4851
+ // New event management system
4852
+ this.eventManager = new EventManager();
4853
+ if (params.onLoad)
4854
+ this.on(EventType.Load, params.onLoad);
4855
+ if (params.onLoadError)
4856
+ this.on(EventType.LoadError, params.onLoadError);
4857
+ }
4858
+ RiveFile.prototype.initData = function () {
4859
+ return __awaiter(this, void 0, void 0, function () {
4860
+ var _a, loader, _b;
4861
+ return __generator(this, function (_c) {
4862
+ switch (_c.label) {
4863
+ case 0:
4864
+ if (!this.src) return [3 /*break*/, 2];
4865
+ _a = this;
4866
+ return [4 /*yield*/, loadRiveFile(this.src)];
4867
+ case 1:
4868
+ _a.buffer = _c.sent();
4869
+ _c.label = 2;
4870
+ case 2:
4871
+ if (this.assetLoader) {
4872
+ loader = new this.runtime.CustomFileAssetLoader({
4873
+ loadContents: this.assetLoader,
4874
+ });
4875
+ }
4876
+ // Load the Rive file
4877
+ _b = this;
4878
+ return [4 /*yield*/, this.runtime.load(new Uint8Array(this.buffer), loader, this.enableRiveAssetCDN)];
4879
+ case 3:
4880
+ // Load the Rive file
4881
+ _b.file = _c.sent();
4882
+ if (this.file !== null) {
4883
+ this.eventManager.fire({
4884
+ type: EventType.Load,
4885
+ data: this,
4886
+ });
4887
+ }
4888
+ else {
4889
+ this.eventManager.fire({
4890
+ type: EventType.LoadError,
4891
+ data: null,
4892
+ });
4893
+ throw new Error(RiveFile.fileLoadErrorMessage);
4894
+ }
4895
+ return [2 /*return*/];
4896
+ }
4897
+ });
4898
+ });
4899
+ };
4900
+ RiveFile.prototype.init = function () {
4901
+ return __awaiter(this, void 0, void 0, function () {
4902
+ var _a;
4903
+ return __generator(this, function (_b) {
4904
+ switch (_b.label) {
4905
+ case 0:
4906
+ // If no source file url specified, it's a bust
4907
+ if (!this.src && !this.buffer) {
4908
+ throw new Error(RiveFile.missingErrorMessage);
4909
+ }
4910
+ _a = this;
4911
+ return [4 /*yield*/, RuntimeLoader.awaitInstance()];
4912
+ case 1:
4913
+ _a.runtime = _b.sent();
4914
+ return [4 /*yield*/, this.initData()];
4915
+ case 2:
4916
+ _b.sent();
4917
+ return [2 /*return*/];
4918
+ }
4919
+ });
4920
+ });
4921
+ };
4922
+ /**
4923
+ * Subscribe to Rive-generated events
4924
+ * @param type the type of event to subscribe to
4925
+ * @param callback callback to fire when the event occurs
4926
+ */
4927
+ RiveFile.prototype.on = function (type, callback) {
4928
+ this.eventManager.add({
4929
+ type: type,
4930
+ callback: callback,
4931
+ });
4932
+ };
4933
+ /**
4934
+ * Unsubscribes from a Rive-generated event
4935
+ * @param type the type of event to unsubscribe from
4936
+ * @param callback the callback to unsubscribe
4937
+ */
4938
+ RiveFile.prototype.off = function (type, callback) {
4939
+ this.eventManager.remove({
4940
+ type: type,
4941
+ callback: callback,
4942
+ });
4943
+ };
4944
+ RiveFile.prototype.cleanup = function () {
4945
+ var _a;
4946
+ this.referenceCount -= 1;
4947
+ if (this.referenceCount <= 0) {
4948
+ this.removeAllRiveEventListeners();
4949
+ (_a = this.file) === null || _a === void 0 ? void 0 : _a.delete();
4950
+ }
4951
+ };
4952
+ /**
4953
+ * Unsubscribes all Rive listeners from an event type, or everything if no type is
4954
+ * given
4955
+ * @param type the type of event to unsubscribe from, or all types if
4956
+ * undefined
4957
+ */
4958
+ RiveFile.prototype.removeAllRiveEventListeners = function (type) {
4959
+ this.eventManager.removeAll(type);
4960
+ };
4961
+ RiveFile.prototype.getInstance = function () {
4962
+ if (this.file !== null) {
4963
+ this.referenceCount += 1;
4964
+ return this.file;
4965
+ }
4966
+ };
4967
+ // Error message for missing source or buffer
4968
+ RiveFile.missingErrorMessage = "Rive source file or data buffer required";
4969
+ // Error message for file load error
4970
+ RiveFile.fileLoadErrorMessage = "The file failed to load";
4971
+ return RiveFile;
4972
+ }());
4973
+
4835
4974
  var Rive = /** @class */ (function () {
4836
4975
  function Rive(params) {
4837
4976
  var _this = this;
@@ -4880,6 +5019,7 @@ var Rive = /** @class */ (function () {
4880
5019
  }
4881
5020
  this.src = params.src;
4882
5021
  this.buffer = params.buffer;
5022
+ this.riveFile = params.riveFile;
4883
5023
  this.layout = (_a = params.layout) !== null && _a !== void 0 ? _a : new Layout();
4884
5024
  this.shouldDisableRiveListeners = !!params.shouldDisableRiveListeners;
4885
5025
  this.isTouchScrollEnabled = !!params.isTouchScrollEnabled;
@@ -4933,6 +5073,7 @@ var Rive = /** @class */ (function () {
4933
5073
  this.init({
4934
5074
  src: this.src,
4935
5075
  buffer: this.buffer,
5076
+ riveFile: this.riveFile,
4936
5077
  autoplay: params.autoplay,
4937
5078
  animations: params.animations,
4938
5079
  stateMachines: params.stateMachines,
@@ -4952,11 +5093,12 @@ var Rive = /** @class */ (function () {
4952
5093
  // Initializes the Rive object either from constructor or load()
4953
5094
  Rive.prototype.init = function (_a) {
4954
5095
  var _this = this;
4955
- var src = _a.src, buffer = _a.buffer, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c;
5096
+ var src = _a.src, buffer = _a.buffer, riveFile = _a.riveFile, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c;
4956
5097
  this.src = src;
4957
5098
  this.buffer = buffer;
5099
+ this.riveFile = riveFile;
4958
5100
  // If no source file url specified, it's a bust
4959
- if (!this.src && !this.buffer) {
5101
+ if (!this.src && !this.buffer && !this.riveFile) {
4960
5102
  throw new Error(Rive.missingErrorMessage);
4961
5103
  }
4962
5104
  // List of animations that should be initialized.
@@ -5047,59 +5189,56 @@ var Rive = /** @class */ (function () {
5047
5189
  Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
5048
5190
  var _a;
5049
5191
  return __awaiter(this, void 0, void 0, function () {
5050
- var _b, loader, _c, msg;
5051
- return __generator(this, function (_d) {
5052
- switch (_d.label) {
5192
+ var error_1, msg;
5193
+ return __generator(this, function (_b) {
5194
+ switch (_b.label) {
5053
5195
  case 0:
5054
- if (!this.src) return [3 /*break*/, 2];
5055
- _b = this;
5056
- return [4 /*yield*/, loadRiveFile(this.src)];
5196
+ _b.trys.push([0, 3, , 4]);
5197
+ if (!(this.riveFile == null)) return [3 /*break*/, 2];
5198
+ this.riveFile = new RiveFile({
5199
+ src: this.src,
5200
+ buffer: this.buffer,
5201
+ enableRiveAssetCDN: this.enableRiveAssetCDN,
5202
+ assetLoader: this.assetLoader,
5203
+ });
5204
+ return [4 /*yield*/, this.riveFile.init()];
5057
5205
  case 1:
5058
- _b.buffer = _d.sent();
5059
- _d.label = 2;
5206
+ _b.sent();
5207
+ _b.label = 2;
5060
5208
  case 2:
5061
- if (this.assetLoader) {
5062
- loader = new this.runtime.CustomFileAssetLoader({
5063
- loadContents: this.assetLoader,
5064
- });
5065
- }
5066
- // Load the Rive file
5067
- _c = this;
5068
- return [4 /*yield*/, this.runtime.load(new Uint8Array(this.buffer), loader, this.enableRiveAssetCDN)];
5209
+ this.file = this.riveFile.getInstance();
5210
+ // Initialize and draw frame
5211
+ this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay);
5212
+ // Check for audio
5213
+ this.initializeAudio();
5214
+ // Everything's set up, emit a load event
5215
+ this.loaded = true;
5216
+ this.eventManager.fire({
5217
+ type: EventType.Load,
5218
+ data: (_a = this.src) !== null && _a !== void 0 ? _a : "buffer",
5219
+ });
5220
+ // Flag ready for playback commands and clear the task queue; this order
5221
+ // is important or it may infinitely recurse
5222
+ this.readyForPlaying = true;
5223
+ this.taskQueue.process();
5224
+ this.drawFrame();
5225
+ return [2 /*return*/, Promise.resolve()];
5069
5226
  case 3:
5070
- // Load the Rive file
5071
- _c.file = _d.sent();
5072
- if (this.file) {
5073
- // Initialize and draw frame
5074
- this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay);
5075
- // Check for audio
5076
- this.initializeAudio();
5077
- // Everything's set up, emit a load event
5078
- this.loaded = true;
5079
- this.eventManager.fire({
5080
- type: EventType.Load,
5081
- data: (_a = this.src) !== null && _a !== void 0 ? _a : "buffer",
5082
- });
5083
- // Flag ready for playback commands and clear the task queue; this order
5084
- // is important or it may infinitely recurse
5085
- this.readyForPlaying = true;
5086
- this.taskQueue.process();
5087
- this.drawFrame();
5088
- return [2 /*return*/, Promise.resolve()];
5089
- }
5090
- else {
5091
- msg = "Problem loading file; may be corrupt!";
5092
- console.warn(msg);
5093
- this.eventManager.fire({ type: EventType.LoadError, data: msg });
5094
- return [2 /*return*/, Promise.reject(msg)];
5095
- }
5096
- return [2 /*return*/];
5227
+ error_1 = _b.sent();
5228
+ msg = "Problem loading file; may be corrupt!";
5229
+ console.warn(msg);
5230
+ this.eventManager.fire({ type: EventType.LoadError, data: msg });
5231
+ return [2 /*return*/, Promise.reject(msg)];
5232
+ case 4: return [2 /*return*/];
5097
5233
  }
5098
5234
  });
5099
5235
  });
5100
5236
  };
5101
5237
  // Initialize for playback
5102
5238
  Rive.prototype.initArtboard = function (artboardName, animationNames, stateMachineNames, autoplay) {
5239
+ if (!this.file) {
5240
+ return;
5241
+ }
5103
5242
  // Fetch the artboard
5104
5243
  var rootArtboard = artboardName
5105
5244
  ? this.file.artboardByName(artboardName)
@@ -5319,8 +5458,8 @@ var Rive = /** @class */ (function () {
5319
5458
  if (this._observed !== null) {
5320
5459
  observers.remove(this._observed);
5321
5460
  }
5322
- // Delete the rive file
5323
- (_a = this.file) === null || _a === void 0 ? void 0 : _a.delete();
5461
+ (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.cleanup();
5462
+ this.riveFile = null;
5324
5463
  this.file = null;
5325
5464
  };
5326
5465
  /**
@@ -5484,6 +5623,7 @@ var Rive = /** @class */ (function () {
5484
5623
  };
5485
5624
  // Loads a new Rive file, keeping listeners in place
5486
5625
  Rive.prototype.load = function (params) {
5626
+ this.file = null;
5487
5627
  // Stop all animations
5488
5628
  this.stop();
5489
5629
  // Reinitialize
@@ -5562,7 +5702,7 @@ var Rive = /** @class */ (function () {
5562
5702
  // Returns a list of animation names on the chosen artboard
5563
5703
  get: function () {
5564
5704
  // If the file's not loaded, we got nothing to return
5565
- if (!this.loaded) {
5705
+ if (!this.loaded || !this.artboard) {
5566
5706
  return [];
5567
5707
  }
5568
5708
  var animationNames = [];
@@ -5580,7 +5720,7 @@ var Rive = /** @class */ (function () {
5580
5720
  */
5581
5721
  get: function () {
5582
5722
  // If the file's not loaded, we got nothing to return
5583
- if (!this.loaded) {
5723
+ if (!this.loaded || !this.artboard) {
5584
5724
  return [];
5585
5725
  }
5586
5726
  var stateMachineNames = [];
@@ -5606,6 +5746,73 @@ var Rive = /** @class */ (function () {
5606
5746
  var stateMachine = this.animator.stateMachines.find(function (m) { return m.name === name; });
5607
5747
  return stateMachine === null || stateMachine === void 0 ? void 0 : stateMachine.inputs;
5608
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
+ };
5609
5816
  Object.defineProperty(Rive.prototype, "playingStateMachineNames", {
5610
5817
  // Returns a list of playing machine names
5611
5818
  get: function () {