@rive-app/webgl 2.33.2 → 2.34.0

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.33.2",
3
+ "version": "2.34.0",
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
@@ -128,7 +128,9 @@ declare class Artboard extends BaseArtboard {
128
128
  declare class BindableArtboard extends BaseArtboard implements rc.FinalizableTarget {
129
129
  selfUnref: boolean;
130
130
  nativeArtboard: rc.BindableArtboard;
131
+ nativeViewModel: rc.ViewModelInstance | null;
131
132
  constructor(artboard: rc.BindableArtboard);
133
+ set viewModel(value: ViewModelInstance);
132
134
  destroy(): void;
133
135
  }
134
136
  /**
@@ -386,6 +388,7 @@ export declare class RiveFile implements rc.FinalizableTarget {
386
388
  getBindableArtboard(name: string): BindableArtboard | null;
387
389
  getDefaultBindableArtboard(): BindableArtboard | null;
388
390
  internalBindableArtboardFromArtboard(artboard: rc.Artboard): BindableArtboard | null;
391
+ viewModelByName(name: string): ViewModel | null;
389
392
  }
390
393
  export declare class Rive {
391
394
  private readonly canvas;
@@ -425,6 +428,7 @@ export declare class Rive {
425
428
  private _artboardHeight;
426
429
  private _devicePixelRatioUsed;
427
430
  private _hasZeroSize;
431
+ private _needsRedraw;
428
432
  private _audioEventListener;
429
433
  private _boundDraw;
430
434
  private _viewModelInstance;
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 = {737794:(a, b, c, d, e) => {
396
+ var Sa, Ta, Xa = {739746:(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 = {737794:(a, b, c, d, e) => {
456
456
  }
457
457
  window.h.Ca += 1;
458
458
  return 1;
459
- }, 739972:() => {
459
+ }, 741924:() => {
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
- }, 740276:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 740380:() => {
463
+ }, 742228:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 742332:() => {
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 = {737794:(a, b, c, d, e) => {
468
468
  } catch (c) {
469
469
  return 0;
470
470
  }
471
- }, 740551:(a, b, c, d, e, f) => {
471
+ }, 742503:(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 = {737794:(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
- }, 743428:a => window.h.ra(a).J.sampleRate, 743501:a => {
517
+ }, 745380:a => window.h.ra(a).J.sampleRate, 745453: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 = {737794:(a, b, c, d, e) => {
522
522
  a.J.close();
523
523
  a.J = void 0;
524
524
  a.kb = void 0;
525
- }, 743901:a => {
525
+ }, 745853:a => {
526
526
  window.h.ub(a);
527
- }, 743951:a => {
527
+ }, 745903:a => {
528
528
  a = window.h.ra(a);
529
529
  a.J.resume();
530
530
  a.state = window.h.ga.qb;
531
- }, 744090:a => {
531
+ }, 746042: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.33.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}}');
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}}');
3939
3939
 
3940
3940
  /***/ }),
3941
3941
  /* 3 */
@@ -5178,9 +5178,18 @@ var BindableArtboard = /** @class */ (function (_super) {
5178
5178
  _this.nativeArtboard = artboard;
5179
5179
  return _this;
5180
5180
  }
5181
+ Object.defineProperty(BindableArtboard.prototype, "viewModel", {
5182
+ set: function (value) {
5183
+ this.nativeViewModel = value.nativeInstance;
5184
+ },
5185
+ enumerable: false,
5186
+ configurable: true
5187
+ });
5181
5188
  BindableArtboard.prototype.destroy = function () {
5189
+ var _a;
5182
5190
  if (this.selfUnref) {
5183
5191
  this.nativeArtboard.unref();
5192
+ (_a = this.nativeViewModel) === null || _a === void 0 ? void 0 : _a.unref();
5184
5193
  }
5185
5194
  };
5186
5195
  return BindableArtboard;
@@ -6216,6 +6225,13 @@ var RiveFile = /** @class */ (function () {
6216
6225
  var nativeBindableArtboard = this.file.internalBindableArtboardFromArtboard(artboard);
6217
6226
  return this.createBindableArtboard(nativeBindableArtboard);
6218
6227
  };
6228
+ RiveFile.prototype.viewModelByName = function (name) {
6229
+ var viewModel = this.file.viewModelByName(name);
6230
+ if (viewModel !== null) {
6231
+ return new ViewModel(viewModel);
6232
+ }
6233
+ return null;
6234
+ };
6219
6235
  // Error message for missing source or buffer
6220
6236
  RiveFile.missingErrorMessage = "Rive source file or data buffer required";
6221
6237
  // Error message for file load error
@@ -6262,6 +6278,8 @@ var Rive = /** @class */ (function () {
6262
6278
  this._devicePixelRatioUsed = 1;
6263
6279
  // Whether the canvas element's size is 0
6264
6280
  this._hasZeroSize = false;
6281
+ // Whether a draw operation needs to be forced
6282
+ this._needsRedraw = false;
6265
6283
  // Audio event listener
6266
6284
  this._audioEventListener = null;
6267
6285
  // draw method bound to the class
@@ -6724,7 +6742,7 @@ var Rive = /** @class */ (function () {
6724
6742
  if (!this._hasZeroSize) {
6725
6743
  // If there was no dirt on this frame, do not clear and draw
6726
6744
  if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
6727
- this.artboard.didChange()) {
6745
+ this.artboard.didChange() || this._needsRedraw) {
6728
6746
  // Canvas must be wiped to prevent artifacts
6729
6747
  renderer.clear();
6730
6748
  renderer.save();
@@ -6733,6 +6751,7 @@ var Rive = /** @class */ (function () {
6733
6751
  this.artboard.draw(renderer);
6734
6752
  renderer.restore();
6735
6753
  renderer.flush();
6754
+ this._needsRedraw = false;
6736
6755
  }
6737
6756
  }
6738
6757
  // Check for any animations that looped
@@ -7057,6 +7076,7 @@ var Rive = /** @class */ (function () {
7057
7076
  this.devicePixelRatioUsed = dpr;
7058
7077
  this.canvas.width = dpr * width;
7059
7078
  this.canvas.height = dpr * height;
7079
+ this._needsRedraw = true;
7060
7080
  this.resizeToCanvas();
7061
7081
  this.drawFrame();
7062
7082
  if (this.layout.fit === Fit.Layout) {
@@ -7655,11 +7675,8 @@ var Rive = /** @class */ (function () {
7655
7675
  return null;
7656
7676
  };
7657
7677
  Rive.prototype.viewModelByName = function (name) {
7658
- var viewModel = this.file.viewModelByName(name);
7659
- if (viewModel !== null) {
7660
- return new ViewModel(viewModel);
7661
- }
7662
- return null;
7678
+ var _a;
7679
+ return (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.viewModelByName(name);
7663
7680
  };
7664
7681
  Rive.prototype.enums = function () {
7665
7682
  if (this._dataEnums === null) {
@@ -8502,7 +8519,7 @@ var ViewModelInstanceArtboard = /** @class */ (function (_super) {
8502
8519
  }
8503
8520
  Object.defineProperty(ViewModelInstanceArtboard.prototype, "value", {
8504
8521
  set: function (artboard) {
8505
- var _a;
8522
+ var _a, _b;
8506
8523
  var bindableArtboard;
8507
8524
  if (artboard.isBindableArtboard) {
8508
8525
  bindableArtboard = artboard;
@@ -8511,6 +8528,9 @@ var ViewModelInstanceArtboard = /** @class */ (function (_super) {
8511
8528
  bindableArtboard = artboard.file.internalBindableArtboardFromArtboard(artboard.nativeArtboard);
8512
8529
  }
8513
8530
  this._viewModelInstanceValue.value((_a = bindableArtboard === null || bindableArtboard === void 0 ? void 0 : bindableArtboard.nativeArtboard) !== null && _a !== void 0 ? _a : null);
8531
+ if (bindableArtboard === null || bindableArtboard === void 0 ? void 0 : bindableArtboard.nativeViewModel) {
8532
+ this._viewModelInstanceValue.viewModelInstance((_b = bindableArtboard === null || bindableArtboard === void 0 ? void 0 : bindableArtboard.nativeViewModel) !== null && _b !== void 0 ? _b : null);
8533
+ }
8514
8534
  },
8515
8535
  enumerable: false,
8516
8536
  configurable: true