@rive-app/webgl2 2.24.1 → 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/webgl2",
3
- "version": "2.24.1",
3
+ "version": "2.25.1",
4
4
  "description": "Rive's webgl2 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
@@ -427,7 +427,7 @@ function Na(a, b) {
427
427
  return Ma(c, a, b);
428
428
  }));
429
429
  }
430
- var Oa, Pa, Ta = {494190:(a, b, c, d, e) => {
430
+ var Oa, Pa, Ta = {494414:(a, b, c, d, e) => {
431
431
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
432
432
  return 0;
433
433
  }
@@ -490,9 +490,9 @@ var Oa, Pa, Ta = {494190:(a, b, c, d, e) => {
490
490
  }
491
491
  window.h.Da += 1;
492
492
  return 1;
493
- }, 496368:() => {
493
+ }, 496592:() => {
494
494
  "undefined" !== typeof window.h && (--window.h.Da, 0 === window.h.Da && delete window.h);
495
- }, 496532:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 496636:() => {
495
+ }, 496756:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 496860:() => {
496
496
  try {
497
497
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
498
498
  a.close();
@@ -500,7 +500,7 @@ var Oa, Pa, Ta = {494190:(a, b, c, d, e) => {
500
500
  } catch (c) {
501
501
  return 0;
502
502
  }
503
- }, 496807:(a, b, c, d, e, f) => {
503
+ }, 497031:(a, b, c, d, e, f) => {
504
504
  if ("undefined" === typeof window.h) {
505
505
  return -1;
506
506
  }
@@ -546,7 +546,7 @@ var Oa, Pa, Ta = {494190:(a, b, c, d, e) => {
546
546
  a == window.h.H.Ba && g.Z.connect(g.I.destination);
547
547
  g.kb = f;
548
548
  return window.h.mc(g);
549
- }, 499684:a => window.h.va(a).I.sampleRate, 499757:a => {
549
+ }, 499908:a => window.h.va(a).I.sampleRate, 499981:a => {
550
550
  a = window.h.va(a);
551
551
  void 0 !== a.Z && (a.Z.onaudioprocess = function() {
552
552
  }, a.Z.disconnect(), a.Z = void 0);
@@ -554,13 +554,13 @@ var Oa, Pa, Ta = {494190:(a, b, c, d, e) => {
554
554
  a.I.close();
555
555
  a.I = void 0;
556
556
  a.kb = void 0;
557
- }, 500157:a => {
557
+ }, 500381:a => {
558
558
  window.h.xb(a);
559
- }, 500207:a => {
559
+ }, 500431:a => {
560
560
  a = window.h.va(a);
561
561
  a.I.resume();
562
562
  a.state = window.h.ia.sb;
563
- }, 500346:a => {
563
+ }, 500570:a => {
564
564
  a = window.h.va(a);
565
565
  a.I.suspend();
566
566
  a.state = window.h.ia.stopped;
@@ -3466,8 +3466,8 @@ m.dynCall_viijii = (a, b, c, d, e, f, g) => (m.dynCall_viijii = A.dynCall_viijii
3466
3466
  m.dynCall_iiiiij = (a, b, c, d, e, f, g) => (m.dynCall_iiiiij = A.dynCall_iiiiij)(a, b, c, d, e, f, g);
3467
3467
  m.dynCall_iiiiijj = (a, b, c, d, e, f, g, n, p) => (m.dynCall_iiiiijj = A.dynCall_iiiiijj)(a, b, c, d, e, f, g, n, p);
3468
3468
  m.dynCall_iiiiiijj = (a, b, c, d, e, f, g, n, p, l) => (m.dynCall_iiiiiijj = A.dynCall_iiiiiijj)(a, b, c, d, e, f, g, n, p, l);
3469
- m.___start_em_js = 491756;
3470
- m.___stop_em_js = 494190;
3469
+ m.___start_em_js = 491980;
3470
+ m.___stop_em_js = 494414;
3471
3471
  var Xd;
3472
3472
  Ga = function Yd() {
3473
3473
  Xd || Zd();
@@ -3527,7 +3527,7 @@ Zd();
3527
3527
  /* 2 */
3528
3528
  /***/ ((module) => {
3529
3529
 
3530
- module.exports = JSON.parse('{"name":"@rive-app/webgl2","version":"2.24.1","description":"Rive\'s webgl2 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)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3530
+ module.exports = JSON.parse('{"name":"@rive-app/webgl2","version":"2.25.1","description":"Rive\'s webgl2 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)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3531
3531
 
3532
3532
  /***/ }),
3533
3533
  /* 3 */
@@ -3810,7 +3810,7 @@ var registerTouchInteractions = function (_a) {
3810
3810
  case "mouseout":
3811
3811
  for (var _i = 0, stateMachines_1 = stateMachines; _i < stateMachines_1.length; _i++) {
3812
3812
  var stateMachine = stateMachines_1[_i];
3813
- stateMachine.pointerMove(transformedX < 0 ? transformedX - 10000 : transformedX + 10000, transformedY < 0 ? transformedY - 10000 : transformedY + 10000);
3813
+ stateMachine.pointerMove(transformedX, transformedY);
3814
3814
  }
3815
3815
  break;
3816
3816
  // Pointer moving/hovering on the canvas
@@ -4380,6 +4380,13 @@ var StateMachine = /** @class */ (function () {
4380
4380
  StateMachine.prototype.advance = function (time) {
4381
4381
  this.instance.advance(time);
4382
4382
  };
4383
+ /**
4384
+ * Advances the state machine instance by a given time and apply changes to artboard.
4385
+ * @param time - the time to advance the animation by in seconds
4386
+ */
4387
+ StateMachine.prototype.advanceAndApply = function (time) {
4388
+ this.instance.advanceAndApply(time);
4389
+ };
4383
4390
  /**
4384
4391
  * Returns the number of events reported from the last advance call
4385
4392
  * @returns Number of events reported
@@ -5304,6 +5311,8 @@ var Rive = /** @class */ (function () {
5304
5311
  this._devicePixelRatioUsed = 1;
5305
5312
  // Whether the canvas element's size is 0
5306
5313
  this._hasZeroSize = false;
5314
+ // Audio event listener
5315
+ this._audioEventListener = null;
5307
5316
  // Durations to generate a frame for the last second. Used for performance profiling.
5308
5317
  this.durations = [];
5309
5318
  this.frameTimes = [];
@@ -5487,11 +5496,12 @@ var Rive = /** @class */ (function () {
5487
5496
  var _a;
5488
5497
  // Initialize audio if needed
5489
5498
  if (audioManager.status == SystemAudioStatus.UNAVAILABLE) {
5490
- if ((_a = this.artboard) === null || _a === void 0 ? void 0 : _a.hasAudio) {
5491
- audioManager.add({
5499
+ if (((_a = this.artboard) === null || _a === void 0 ? void 0 : _a.hasAudio) && this._audioEventListener === null) {
5500
+ this._audioEventListener = {
5492
5501
  type: EventType.AudioStatusChange,
5493
5502
  callback: function () { return _this.onSystemAudioChanged(); },
5494
- });
5503
+ };
5504
+ audioManager.add(this._audioEventListener);
5495
5505
  audioManager.establishAudio();
5496
5506
  }
5497
5507
  }
@@ -5681,12 +5691,14 @@ var Rive = /** @class */ (function () {
5681
5691
  }
5682
5692
  }
5683
5693
  }
5684
- stateMachine.advance(elapsedTime);
5694
+ stateMachine.advanceAndApply(elapsedTime);
5685
5695
  // stateMachine.instance.apply(this.artboard);
5686
5696
  }
5687
5697
  // Once the animations have been applied to the artboard, advance it
5688
5698
  // by the elapsed time.
5689
- this.artboard.advance(elapsedTime);
5699
+ if (this.animator.stateMachines.length == 0) {
5700
+ this.artboard.advance(elapsedTime);
5701
+ }
5690
5702
  var renderer = this.renderer;
5691
5703
  // Canvas must be wiped to prevent artifacts
5692
5704
  renderer.clear();
@@ -5785,6 +5797,10 @@ var Rive = /** @class */ (function () {
5785
5797
  this.riveFile = null;
5786
5798
  this.file = null;
5787
5799
  this.deleteRiveRenderer();
5800
+ if (this._audioEventListener !== null) {
5801
+ audioManager.remove(this._audioEventListener);
5802
+ this._audioEventListener = null;
5803
+ }
5788
5804
  };
5789
5805
  /**
5790
5806
  * Cleans up the Renderer object. Only call this API if you no longer