@rive-app/webgl 2.34.0 → 2.34.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/webgl",
3
- "version": "2.34.0",
3
+ "version": "2.34.2",
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
@@ -429,6 +429,8 @@ export declare class Rive {
429
429
  private _devicePixelRatioUsed;
430
430
  private _hasZeroSize;
431
431
  private _needsRedraw;
432
+ private _currentCanvasWidth;
433
+ private _currentCanvasHeight;
432
434
  private _audioEventListener;
433
435
  private _boundDraw;
434
436
  private _viewModelInstance;
@@ -464,6 +466,7 @@ export declare class Rive {
464
466
  private initData;
465
467
  private initArtboard;
466
468
  drawFrame(): void;
469
+ private _canvasSizeChanged;
467
470
  private lastRenderTime;
468
471
  private frameRequestId;
469
472
  /**
package/rive.js CHANGED
@@ -393,7 +393,7 @@ function Ra(a, b) {
393
393
  return Qa(c, a, b);
394
394
  }));
395
395
  }
396
- var Sa, Ta, Xa = {739746:(a, b, c, d, e) => {
396
+ var Sa, Ta, Xa = {740450:(a, b, c, d, e) => {
397
397
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
398
398
  return 0;
399
399
  }
@@ -456,11 +456,11 @@ var Sa, Ta, Xa = {739746:(a, b, c, d, e) => {
456
456
  }
457
457
  window.h.Ca += 1;
458
458
  return 1;
459
- }, 741924:() => {
459
+ }, 742628:() => {
460
460
  "undefined" !== typeof window.h && (window.h.Ra.map(function(a) {
461
461
  document.removeEventListener(a, window.h.unlock, !0);
462
462
  }), --window.h.Ca, 0 === window.h.Ca && delete window.h);
463
- }, 742228:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 742332:() => {
463
+ }, 742932:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 743036:() => {
464
464
  try {
465
465
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
466
466
  a.close();
@@ -468,7 +468,7 @@ var Sa, Ta, Xa = {739746:(a, b, c, d, e) => {
468
468
  } catch (c) {
469
469
  return 0;
470
470
  }
471
- }, 742503:(a, b, c, d, e, f) => {
471
+ }, 743207:(a, b, c, d, e, f) => {
472
472
  if ("undefined" === typeof window.h) {
473
473
  return -1;
474
474
  }
@@ -514,7 +514,7 @@ var Sa, Ta, Xa = {739746:(a, b, c, d, e) => {
514
514
  a == window.h.H.Aa && g.W.connect(g.J.destination);
515
515
  g.kb = f;
516
516
  return window.h.fc(g);
517
- }, 745380:a => window.h.ra(a).J.sampleRate, 745453:a => {
517
+ }, 746084:a => window.h.ra(a).J.sampleRate, 746157:a => {
518
518
  a = window.h.ra(a);
519
519
  void 0 !== a.W && (a.W.onaudioprocess = function() {
520
520
  }, a.W.disconnect(), a.W = void 0);
@@ -522,13 +522,13 @@ var Sa, Ta, Xa = {739746:(a, b, c, d, e) => {
522
522
  a.J.close();
523
523
  a.J = void 0;
524
524
  a.kb = void 0;
525
- }, 745853:a => {
525
+ }, 746557:a => {
526
526
  window.h.ub(a);
527
- }, 745903:a => {
527
+ }, 746607:a => {
528
528
  a = window.h.ra(a);
529
529
  a.J.resume();
530
530
  a.state = window.h.ga.qb;
531
- }, 746042:a => {
531
+ }, 746746:a => {
532
532
  a = window.h.ra(a);
533
533
  a.J.suspend();
534
534
  a.state = window.h.ga.stopped;
@@ -3935,7 +3935,7 @@ moduleRtn = ca;
3935
3935
  /* 2 */
3936
3936
  /***/ ((module) => {
3937
3937
 
3938
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.34.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}}');
3938
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.34.2","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}}');
3939
3939
 
3940
3940
  /***/ }),
3941
3941
  /* 3 */
@@ -6280,6 +6280,10 @@ var Rive = /** @class */ (function () {
6280
6280
  this._hasZeroSize = false;
6281
6281
  // Whether a draw operation needs to be forced
6282
6282
  this._needsRedraw = false;
6283
+ // Canvas width and height. Values are lazily updated so they might
6284
+ // not be in sync with current canvas size.
6285
+ this._currentCanvasWidth = 0;
6286
+ this._currentCanvasHeight = 0;
6283
6287
  // Audio event listener
6284
6288
  this._audioEventListener = null;
6285
6289
  // draw method bound to the class
@@ -6314,6 +6318,8 @@ var Rive = /** @class */ (function () {
6314
6318
  if (params.canvas.constructor === HTMLCanvasElement) {
6315
6319
  this._observed = observers.add(this.canvas, this.onCanvasResize);
6316
6320
  }
6321
+ this._currentCanvasWidth = this.canvas.width;
6322
+ this._currentCanvasHeight = this.canvas.height;
6317
6323
  this.src = params.src;
6318
6324
  this.buffer = params.buffer;
6319
6325
  this.riveFile = params.riveFile;
@@ -6654,6 +6660,20 @@ var Rive = /** @class */ (function () {
6654
6660
  this.scheduleRendering();
6655
6661
  }
6656
6662
  };
6663
+ Rive.prototype._canvasSizeChanged = function () {
6664
+ var changed = false;
6665
+ if (this.canvas) {
6666
+ if (this.canvas.width !== this._currentCanvasWidth) {
6667
+ this._currentCanvasWidth = this.canvas.width;
6668
+ changed = true;
6669
+ }
6670
+ if (this.canvas.height !== this._currentCanvasHeight) {
6671
+ this._currentCanvasHeight = this.canvas.height;
6672
+ changed = true;
6673
+ }
6674
+ }
6675
+ return changed;
6676
+ };
6657
6677
  /**
6658
6678
  * Draw rendering loop; renders animation frames at the correct time interval.
6659
6679
  * @param time the time at which to render a frame
@@ -6742,7 +6762,9 @@ var Rive = /** @class */ (function () {
6742
6762
  if (!this._hasZeroSize) {
6743
6763
  // If there was no dirt on this frame, do not clear and draw
6744
6764
  if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
6745
- this.artboard.didChange() || this._needsRedraw) {
6765
+ this.artboard.didChange() ||
6766
+ this._needsRedraw ||
6767
+ this._canvasSizeChanged()) {
6746
6768
  // Canvas must be wiped to prevent artifacts
6747
6769
  renderer.clear();
6748
6770
  renderer.save();
@@ -7373,7 +7395,8 @@ var Rive = /** @class */ (function () {
7373
7395
  * @returns true if no animations are playing or paused
7374
7396
  */
7375
7397
  get: function () {
7376
- return this.animator.isStopped;
7398
+ var _a, _b;
7399
+ return (_b = (_a = this.animator) === null || _a === void 0 ? void 0 : _a.isStopped) !== null && _b !== void 0 ? _b : true;
7377
7400
  },
7378
7401
  enumerable: false,
7379
7402
  configurable: true