@rive-app/webgl 2.25.0 → 2.25.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.25.0",
3
+ "version": "2.25.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
@@ -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
@@ -408,7 +408,7 @@ function Qa(a, b) {
408
408
  return Pa(c, a, b);
409
409
  }));
410
410
  }
411
- var Ra, Sa, Wa = {699884:(a, b, c, d, e) => {
411
+ var Ra, Sa, Wa = {700124:(a, b, c, d, e) => {
412
412
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
413
413
  return 0;
414
414
  }
@@ -471,9 +471,9 @@ var Ra, Sa, Wa = {699884:(a, b, c, d, e) => {
471
471
  }
472
472
  window.h.Ea += 1;
473
473
  return 1;
474
- }, 702062:() => {
474
+ }, 702302:() => {
475
475
  "undefined" !== typeof window.h && (--window.h.Ea, 0 === window.h.Ea && delete window.h);
476
- }, 702226:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 702330:() => {
476
+ }, 702466:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 702570:() => {
477
477
  try {
478
478
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
479
479
  a.close();
@@ -481,7 +481,7 @@ var Ra, Sa, Wa = {699884:(a, b, c, d, e) => {
481
481
  } catch (c) {
482
482
  return 0;
483
483
  }
484
- }, 702501:(a, b, c, d, e, f) => {
484
+ }, 702741:(a, b, c, d, e, f) => {
485
485
  if ("undefined" === typeof window.h) {
486
486
  return -1;
487
487
  }
@@ -527,7 +527,7 @@ var Ra, Sa, Wa = {699884:(a, b, c, d, e) => {
527
527
  a == window.h.H.Ca && g.X.connect(g.I.destination);
528
528
  g.lb = f;
529
529
  return window.h.nc(g);
530
- }, 705378:a => window.h.ta(a).I.sampleRate, 705451:a => {
530
+ }, 705618:a => window.h.ta(a).I.sampleRate, 705691:a => {
531
531
  a = window.h.ta(a);
532
532
  void 0 !== a.X && (a.X.onaudioprocess = function() {
533
533
  }, a.X.disconnect(), a.X = void 0);
@@ -535,13 +535,13 @@ var Ra, Sa, Wa = {699884:(a, b, c, d, e) => {
535
535
  a.I.close();
536
536
  a.I = void 0;
537
537
  a.lb = void 0;
538
- }, 705851:a => {
538
+ }, 706091:a => {
539
539
  window.h.xb(a);
540
- }, 705901:a => {
540
+ }, 706141:a => {
541
541
  a = window.h.ta(a);
542
542
  a.I.resume();
543
543
  a.state = window.h.ha.sb;
544
- }, 706040:a => {
544
+ }, 706280:a => {
545
545
  a = window.h.ta(a);
546
546
  a.I.suspend();
547
547
  a.state = window.h.ha.stopped;
@@ -4061,7 +4061,7 @@ Je();
4061
4061
  /* 2 */
4062
4062
  /***/ ((module) => {
4063
4063
 
4064
- module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.25.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}}');
4064
+ module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.25.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}}');
4065
4065
 
4066
4066
  /***/ }),
4067
4067
  /* 3 */
@@ -4914,6 +4914,13 @@ var StateMachine = /** @class */ (function () {
4914
4914
  StateMachine.prototype.advance = function (time) {
4915
4915
  this.instance.advance(time);
4916
4916
  };
4917
+ /**
4918
+ * Advances the state machine instance by a given time and apply changes to artboard.
4919
+ * @param time - the time to advance the animation by in seconds
4920
+ */
4921
+ StateMachine.prototype.advanceAndApply = function (time) {
4922
+ this.instance.advanceAndApply(time);
4923
+ };
4917
4924
  /**
4918
4925
  * Returns the number of events reported from the last advance call
4919
4926
  * @returns Number of events reported
@@ -5838,6 +5845,8 @@ var Rive = /** @class */ (function () {
5838
5845
  this._devicePixelRatioUsed = 1;
5839
5846
  // Whether the canvas element's size is 0
5840
5847
  this._hasZeroSize = false;
5848
+ // Audio event listener
5849
+ this._audioEventListener = null;
5841
5850
  // Durations to generate a frame for the last second. Used for performance profiling.
5842
5851
  this.durations = [];
5843
5852
  this.frameTimes = [];
@@ -6021,11 +6030,12 @@ var Rive = /** @class */ (function () {
6021
6030
  var _a;
6022
6031
  // Initialize audio if needed
6023
6032
  if (audioManager.status == SystemAudioStatus.UNAVAILABLE) {
6024
- if ((_a = this.artboard) === null || _a === void 0 ? void 0 : _a.hasAudio) {
6025
- audioManager.add({
6033
+ if (((_a = this.artboard) === null || _a === void 0 ? void 0 : _a.hasAudio) && this._audioEventListener === null) {
6034
+ this._audioEventListener = {
6026
6035
  type: EventType.AudioStatusChange,
6027
6036
  callback: function () { return _this.onSystemAudioChanged(); },
6028
- });
6037
+ };
6038
+ audioManager.add(this._audioEventListener);
6029
6039
  audioManager.establishAudio();
6030
6040
  }
6031
6041
  }
@@ -6215,12 +6225,14 @@ var Rive = /** @class */ (function () {
6215
6225
  }
6216
6226
  }
6217
6227
  }
6218
- stateMachine.advance(elapsedTime);
6228
+ stateMachine.advanceAndApply(elapsedTime);
6219
6229
  // stateMachine.instance.apply(this.artboard);
6220
6230
  }
6221
6231
  // Once the animations have been applied to the artboard, advance it
6222
6232
  // by the elapsed time.
6223
- this.artboard.advance(elapsedTime);
6233
+ if (this.animator.stateMachines.length == 0) {
6234
+ this.artboard.advance(elapsedTime);
6235
+ }
6224
6236
  var renderer = this.renderer;
6225
6237
  // Canvas must be wiped to prevent artifacts
6226
6238
  renderer.clear();
@@ -6319,6 +6331,10 @@ var Rive = /** @class */ (function () {
6319
6331
  this.riveFile = null;
6320
6332
  this.file = null;
6321
6333
  this.deleteRiveRenderer();
6334
+ if (this._audioEventListener !== null) {
6335
+ audioManager.remove(this._audioEventListener);
6336
+ this._audioEventListener = null;
6337
+ }
6322
6338
  };
6323
6339
  /**
6324
6340
  * Cleans up the Renderer object. Only call this API if you no longer