@rive-app/webgl2 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/webgl2",
3
- "version": "2.34.0",
3
+ "version": "2.34.2",
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
@@ -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
@@ -427,7 +427,7 @@ function Na(a, b) {
427
427
  return Ma(c, a, b);
428
428
  }));
429
429
  }
430
- var Oa, Pa, Ta = {570833:(a, b, c, d, e) => {
430
+ var Oa, Pa, Ta = {571633:(a, b, c, d, e) => {
431
431
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
432
432
  return 0;
433
433
  }
@@ -490,11 +490,11 @@ var Oa, Pa, Ta = {570833:(a, b, c, d, e) => {
490
490
  }
491
491
  window.h.Ea += 1;
492
492
  return 1;
493
- }, 573011:() => {
493
+ }, 573811:() => {
494
494
  "undefined" !== typeof window.h && (window.h.Xa.map(function(a) {
495
495
  document.removeEventListener(a, window.h.unlock, !0);
496
496
  }), --window.h.Ea, 0 === window.h.Ea && delete window.h);
497
- }, 573315:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 573419:() => {
497
+ }, 574115:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 574219:() => {
498
498
  try {
499
499
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
500
500
  a.close();
@@ -502,7 +502,7 @@ var Oa, Pa, Ta = {570833:(a, b, c, d, e) => {
502
502
  } catch (c) {
503
503
  return 0;
504
504
  }
505
- }, 573590:(a, b, c, d, e, f) => {
505
+ }, 574390:(a, b, c, d, e, f) => {
506
506
  if ("undefined" === typeof window.h) {
507
507
  return -1;
508
508
  }
@@ -548,7 +548,7 @@ var Oa, Pa, Ta = {570833:(a, b, c, d, e) => {
548
548
  a == window.h.I.Ca && g.Y.connect(g.K.destination);
549
549
  g.nb = f;
550
550
  return window.h.lc(g);
551
- }, 576467:a => window.h.ta(a).K.sampleRate, 576540:a => {
551
+ }, 577267:a => window.h.ta(a).K.sampleRate, 577340:a => {
552
552
  a = window.h.ta(a);
553
553
  void 0 !== a.Y && (a.Y.onaudioprocess = function() {
554
554
  }, a.Y.disconnect(), a.Y = void 0);
@@ -556,13 +556,13 @@ var Oa, Pa, Ta = {570833:(a, b, c, d, e) => {
556
556
  a.K.close();
557
557
  a.K = void 0;
558
558
  a.nb = void 0;
559
- }, 576940:a => {
559
+ }, 577740:a => {
560
560
  window.h.yb(a);
561
- }, 576990:a => {
561
+ }, 577790:a => {
562
562
  a = window.h.ta(a);
563
563
  a.K.resume();
564
564
  a.state = window.h.ia.ub;
565
- }, 577129:a => {
565
+ }, 577929:a => {
566
566
  a = window.h.ta(a);
567
567
  a.K.suspend();
568
568
  a.state = window.h.ia.stopped;
@@ -3546,7 +3546,7 @@ moduleRtn = ca;
3546
3546
  /* 2 */
3547
3547
  /***/ ((module) => {
3548
3548
 
3549
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.34.0","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}}');
3549
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.34.2","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}}');
3550
3550
 
3551
3551
  /***/ }),
3552
3552
  /* 3 */
@@ -5891,6 +5891,10 @@ var Rive = /** @class */ (function () {
5891
5891
  this._hasZeroSize = false;
5892
5892
  // Whether a draw operation needs to be forced
5893
5893
  this._needsRedraw = false;
5894
+ // Canvas width and height. Values are lazily updated so they might
5895
+ // not be in sync with current canvas size.
5896
+ this._currentCanvasWidth = 0;
5897
+ this._currentCanvasHeight = 0;
5894
5898
  // Audio event listener
5895
5899
  this._audioEventListener = null;
5896
5900
  // draw method bound to the class
@@ -5925,6 +5929,8 @@ var Rive = /** @class */ (function () {
5925
5929
  if (params.canvas.constructor === HTMLCanvasElement) {
5926
5930
  this._observed = observers.add(this.canvas, this.onCanvasResize);
5927
5931
  }
5932
+ this._currentCanvasWidth = this.canvas.width;
5933
+ this._currentCanvasHeight = this.canvas.height;
5928
5934
  this.src = params.src;
5929
5935
  this.buffer = params.buffer;
5930
5936
  this.riveFile = params.riveFile;
@@ -6265,6 +6271,20 @@ var Rive = /** @class */ (function () {
6265
6271
  this.scheduleRendering();
6266
6272
  }
6267
6273
  };
6274
+ Rive.prototype._canvasSizeChanged = function () {
6275
+ var changed = false;
6276
+ if (this.canvas) {
6277
+ if (this.canvas.width !== this._currentCanvasWidth) {
6278
+ this._currentCanvasWidth = this.canvas.width;
6279
+ changed = true;
6280
+ }
6281
+ if (this.canvas.height !== this._currentCanvasHeight) {
6282
+ this._currentCanvasHeight = this.canvas.height;
6283
+ changed = true;
6284
+ }
6285
+ }
6286
+ return changed;
6287
+ };
6268
6288
  /**
6269
6289
  * Draw rendering loop; renders animation frames at the correct time interval.
6270
6290
  * @param time the time at which to render a frame
@@ -6353,7 +6373,9 @@ var Rive = /** @class */ (function () {
6353
6373
  if (!this._hasZeroSize) {
6354
6374
  // If there was no dirt on this frame, do not clear and draw
6355
6375
  if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
6356
- this.artboard.didChange() || this._needsRedraw) {
6376
+ this.artboard.didChange() ||
6377
+ this._needsRedraw ||
6378
+ this._canvasSizeChanged()) {
6357
6379
  // Canvas must be wiped to prevent artifacts
6358
6380
  renderer.clear();
6359
6381
  renderer.save();
@@ -6984,7 +7006,8 @@ var Rive = /** @class */ (function () {
6984
7006
  * @returns true if no animations are playing or paused
6985
7007
  */
6986
7008
  get: function () {
6987
- return this.animator.isStopped;
7009
+ var _a, _b;
7010
+ return (_b = (_a = this.animator) === null || _a === void 0 ? void 0 : _a.isStopped) !== null && _b !== void 0 ? _b : true;
6988
7011
  },
6989
7012
  enumerable: false,
6990
7013
  configurable: true