@rive-app/canvas-lite 2.25.0 → 2.25.2

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.25.0",
3
+ "version": "2.25.2",
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
@@ -366,6 +366,7 @@ export declare class Rive {
366
366
  private _artboardHeight;
367
367
  private _devicePixelRatioUsed;
368
368
  private _hasZeroSize;
369
+ private _audioEventListener;
369
370
  durations: number[];
370
371
  frameTimes: number[];
371
372
  frameCount: number;
package/rive.js CHANGED
@@ -2269,7 +2269,7 @@ Qc();
2269
2269
  /* 2 */
2270
2270
  /***/ ((module) => {
2271
2271
 
2272
- module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.25.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}}');
2272
+ module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.25.2","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}}');
2273
2273
 
2274
2274
  /***/ }),
2275
2275
  /* 3 */
@@ -3122,6 +3122,13 @@ var StateMachine = /** @class */ (function () {
3122
3122
  StateMachine.prototype.advance = function (time) {
3123
3123
  this.instance.advance(time);
3124
3124
  };
3125
+ /**
3126
+ * Advances the state machine instance by a given time and apply changes to artboard.
3127
+ * @param time - the time to advance the animation by in seconds
3128
+ */
3129
+ StateMachine.prototype.advanceAndApply = function (time) {
3130
+ this.instance.advanceAndApply(time);
3131
+ };
3125
3132
  /**
3126
3133
  * Returns the number of events reported from the last advance call
3127
3134
  * @returns Number of events reported
@@ -4046,6 +4053,8 @@ var Rive = /** @class */ (function () {
4046
4053
  this._devicePixelRatioUsed = 1;
4047
4054
  // Whether the canvas element's size is 0
4048
4055
  this._hasZeroSize = false;
4056
+ // Audio event listener
4057
+ this._audioEventListener = null;
4049
4058
  // Durations to generate a frame for the last second. Used for performance profiling.
4050
4059
  this.durations = [];
4051
4060
  this.frameTimes = [];
@@ -4229,11 +4238,12 @@ var Rive = /** @class */ (function () {
4229
4238
  var _a;
4230
4239
  // Initialize audio if needed
4231
4240
  if (audioManager.status == SystemAudioStatus.UNAVAILABLE) {
4232
- if ((_a = this.artboard) === null || _a === void 0 ? void 0 : _a.hasAudio) {
4233
- audioManager.add({
4241
+ if (((_a = this.artboard) === null || _a === void 0 ? void 0 : _a.hasAudio) && this._audioEventListener === null) {
4242
+ this._audioEventListener = {
4234
4243
  type: EventType.AudioStatusChange,
4235
4244
  callback: function () { return _this.onSystemAudioChanged(); },
4236
- });
4245
+ };
4246
+ audioManager.add(this._audioEventListener);
4237
4247
  audioManager.establishAudio();
4238
4248
  }
4239
4249
  }
@@ -4423,12 +4433,14 @@ var Rive = /** @class */ (function () {
4423
4433
  }
4424
4434
  }
4425
4435
  }
4426
- stateMachine.advance(elapsedTime);
4436
+ stateMachine.advanceAndApply(elapsedTime);
4427
4437
  // stateMachine.instance.apply(this.artboard);
4428
4438
  }
4429
4439
  // Once the animations have been applied to the artboard, advance it
4430
4440
  // by the elapsed time.
4431
- this.artboard.advance(elapsedTime);
4441
+ if (this.animator.stateMachines.length == 0) {
4442
+ this.artboard.advance(elapsedTime);
4443
+ }
4432
4444
  var renderer = this.renderer;
4433
4445
  // Canvas must be wiped to prevent artifacts
4434
4446
  renderer.clear();
@@ -4527,6 +4539,10 @@ var Rive = /** @class */ (function () {
4527
4539
  this.riveFile = null;
4528
4540
  this.file = null;
4529
4541
  this.deleteRiveRenderer();
4542
+ if (this._audioEventListener !== null) {
4543
+ audioManager.remove(this._audioEventListener);
4544
+ this._audioEventListener = null;
4545
+ }
4530
4546
  };
4531
4547
  /**
4532
4548
  * Cleans up the Renderer object. Only call this API if you no longer