@rive-app/webgl 2.29.4 → 2.30.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.29.4",
3
+ "version": "2.30.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
@@ -339,6 +339,7 @@ export declare class RiveFile {
339
339
  */
340
340
  removeAllRiveEventListeners(type?: EventType): void;
341
341
  getInstance(): rc.File;
342
+ destroyIfUnused(): void;
342
343
  }
343
344
  export declare class Rive {
344
345
  private readonly canvas;
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 = {711388:(a, b, c, d, e) => {
411
+ var Ra, Sa, Wa = {713148:(a, b, c, d, e) => {
412
412
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
413
413
  return 0;
414
414
  }
@@ -471,11 +471,11 @@ var Ra, Sa, Wa = {711388:(a, b, c, d, e) => {
471
471
  }
472
472
  window.h.Ea += 1;
473
473
  return 1;
474
- }, 713566:() => {
474
+ }, 715326:() => {
475
475
  "undefined" !== typeof window.h && (window.h.Ta.map(function(a) {
476
476
  document.removeEventListener(a, window.h.unlock, !0);
477
477
  }), --window.h.Ea, 0 === window.h.Ea && delete window.h);
478
- }, 713870:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 713974:() => {
478
+ }, 715630:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 715734:() => {
479
479
  try {
480
480
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
481
481
  a.close();
@@ -483,7 +483,7 @@ var Ra, Sa, Wa = {711388:(a, b, c, d, e) => {
483
483
  } catch (c) {
484
484
  return 0;
485
485
  }
486
- }, 714145:(a, b, c, d, e, f) => {
486
+ }, 715905:(a, b, c, d, e, f) => {
487
487
  if ("undefined" === typeof window.h) {
488
488
  return -1;
489
489
  }
@@ -529,7 +529,7 @@ var Ra, Sa, Wa = {711388:(a, b, c, d, e) => {
529
529
  a == window.h.H.Ca && g.X.connect(g.I.destination);
530
530
  g.mb = f;
531
531
  return window.h.nc(g);
532
- }, 717022:a => window.h.ta(a).I.sampleRate, 717095:a => {
532
+ }, 718782:a => window.h.ta(a).I.sampleRate, 718855:a => {
533
533
  a = window.h.ta(a);
534
534
  void 0 !== a.X && (a.X.onaudioprocess = function() {
535
535
  }, a.X.disconnect(), a.X = void 0);
@@ -537,13 +537,13 @@ var Ra, Sa, Wa = {711388:(a, b, c, d, e) => {
537
537
  a.I.close();
538
538
  a.I = void 0;
539
539
  a.mb = void 0;
540
- }, 717495:a => {
540
+ }, 719255:a => {
541
541
  window.h.xb(a);
542
- }, 717545:a => {
542
+ }, 719305:a => {
543
543
  a = window.h.ta(a);
544
544
  a.I.resume();
545
545
  a.state = window.h.ha.tb;
546
- }, 717684:a => {
546
+ }, 719444:a => {
547
547
  a = window.h.ta(a);
548
548
  a.I.suspend();
549
549
  a.state = window.h.ha.stopped;
@@ -4065,7 +4065,7 @@ Je();
4065
4065
  /* 2 */
4066
4066
  /***/ ((module) => {
4067
4067
 
4068
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.29.4","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}}');
4068
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.30.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}}');
4069
4069
 
4070
4070
  /***/ }),
4071
4071
  /* 3 */
@@ -4707,18 +4707,18 @@ var FontAssetWrapper = /** @class */ (function (_super) {
4707
4707
  };
4708
4708
  return FontAssetWrapper;
4709
4709
  }(FileAssetWrapper));
4710
- var FakeFinalizationRegistry = /** @class */ (function (_super) {
4711
- __extends(FakeFinalizationRegistry, _super);
4712
- function FakeFinalizationRegistry(fn) {
4713
- return _super.call(this, fn) || this;
4710
+ var FakeFinalizationRegistry = /** @class */ (function () {
4711
+ function FakeFinalizationRegistry(_) {
4714
4712
  }
4715
4713
  FakeFinalizationRegistry.prototype.register = function (object) {
4716
4714
  object.selfUnref = true;
4717
4715
  };
4718
4716
  FakeFinalizationRegistry.prototype.unregister = function (_) { };
4719
4717
  return FakeFinalizationRegistry;
4720
- }(FinalizationRegistry));
4721
- var MyFinalizationRegistry = FinalizationRegistry || FakeFinalizationRegistry;
4718
+ }());
4719
+ var MyFinalizationRegistry = typeof FinalizationRegistry !== "undefined"
4720
+ ? FinalizationRegistry
4721
+ : FakeFinalizationRegistry;
4722
4722
  var finalizationRegistry = new MyFinalizationRegistry(function (ob) {
4723
4723
  ob.unref();
4724
4724
  });
@@ -6157,6 +6157,11 @@ var RiveFile = /** @class */ (function () {
6157
6157
  return this.file;
6158
6158
  }
6159
6159
  };
6160
+ RiveFile.prototype.destroyIfUnused = function () {
6161
+ if (this.referenceCount <= 0) {
6162
+ this.cleanup();
6163
+ }
6164
+ };
6160
6165
  // Error message for missing source or buffer
6161
6166
  RiveFile.missingErrorMessage = "Rive source file or data buffer required";
6162
6167
  // Error message for file load error
@@ -6440,28 +6445,31 @@ var Rive = /** @class */ (function () {
6440
6445
  // Returns true for successful initialization.
6441
6446
  Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
6442
6447
  return __awaiter(this, void 0, void 0, function () {
6443
- var error_2, msg;
6448
+ var riveFile, error_2, msg;
6444
6449
  var _a;
6445
6450
  return __generator(this, function (_b) {
6446
6451
  switch (_b.label) {
6447
6452
  case 0:
6448
6453
  _b.trys.push([0, 3, , 4]);
6449
6454
  if (!(this.riveFile == null)) return [3 /*break*/, 2];
6450
- this.riveFile = new RiveFile({
6455
+ riveFile = new RiveFile({
6451
6456
  src: this.src,
6452
6457
  buffer: this.buffer,
6453
6458
  enableRiveAssetCDN: this.enableRiveAssetCDN,
6454
6459
  assetLoader: this.assetLoader,
6455
6460
  });
6456
- return [4 /*yield*/, this.riveFile.init()];
6461
+ this.riveFile = riveFile;
6462
+ return [4 /*yield*/, riveFile.init()];
6457
6463
  case 1:
6458
6464
  _b.sent();
6459
- _b.label = 2;
6460
- case 2:
6461
- // Check for riveFile in case it has been cleaned up while initializing;
6462
- if (!this.riveFile) {
6465
+ if (this.destroyed) {
6466
+ // In the very unlikely scenario where the rive file created by this Rive is shared by
6467
+ // another rive file, we only want to destroy it if this file is the only owner.
6468
+ riveFile.destroyIfUnused();
6463
6469
  return [2 /*return*/, false];
6464
6470
  }
6471
+ _b.label = 2;
6472
+ case 2:
6465
6473
  this.file = this.riveFile.getInstance();
6466
6474
  // Initialize and draw frame
6467
6475
  this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay, autoBind);