@rive-app/webgl-single 1.1.4 → 1.1.5

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-single",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Rive's webgl based web api with bundled wasm.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -268,12 +268,14 @@ export declare class Rive {
268
268
  private taskQueue;
269
269
  private animator;
270
270
  private static readonly missingErrorMessage;
271
+ private shouldDisableRiveListeners;
271
272
  durations: number[];
272
273
  frameTimes: number[];
273
274
  frameCount: number;
274
275
  constructor(params: RiveParameters);
275
276
  static new(params: RiveParameters): Rive;
276
277
  private init;
278
+ private setupRiveListeners;
277
279
  private initData;
278
280
  private initArtboard;
279
281
  drawFrame(): void;
package/rive.js CHANGED
@@ -167,7 +167,7 @@ if(h.preInit)for("function"==typeof h.preInit&&(h.preInit=[h.preInit]);0<h.preIn
167
167
  /* 2 */
168
168
  /***/ ((module) => {
169
169
 
170
- module.exports = JSON.parse('{"name":"@rive-app/webgl-single","version":"1.1.4","description":"Rive\'s webgl based web api with bundled wasm.","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.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
170
+ module.exports = JSON.parse('{"name":"@rive-app/webgl-single","version":"1.1.5","description":"Rive\'s webgl based web api with bundled wasm.","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.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
171
171
 
172
172
  /***/ }),
173
173
  /* 3 */
@@ -1244,6 +1244,7 @@ var Rive = /** @class */ (function () {
1244
1244
  this.artboard = null;
1245
1245
  // place to clear up event listeners
1246
1246
  this.eventCleanup = null;
1247
+ this.shouldDisableRiveListeners = false;
1247
1248
  // Durations to generate a frame for the last second. Used for performance profiling.
1248
1249
  this.durations = [];
1249
1250
  this.frameTimes = [];
@@ -1257,6 +1258,7 @@ var Rive = /** @class */ (function () {
1257
1258
  this.src = params.src;
1258
1259
  this.buffer = params.buffer;
1259
1260
  this.layout = (_a = params.layout) !== null && _a !== void 0 ? _a : new Layout();
1261
+ this.shouldDisableRiveListeners = !!params.shouldDisableRiveListeners;
1260
1262
  // New event management system
1261
1263
  this.eventManager = new EventManager();
1262
1264
  if (params.onLoad)
@@ -1300,7 +1302,6 @@ var Rive = /** @class */ (function () {
1300
1302
  stateMachines: params.stateMachines,
1301
1303
  artboard: params.artboard,
1302
1304
  useOffscreenRenderer: params.useOffscreenRenderer,
1303
- shouldDisableRiveListeners: params.shouldDisableRiveListeners,
1304
1305
  });
1305
1306
  }
1306
1307
  // Alternative constructor to build a Rive instance from an interface/object
@@ -1311,7 +1312,7 @@ var Rive = /** @class */ (function () {
1311
1312
  // Initializes the Rive object either from constructor or load()
1312
1313
  Rive.prototype.init = function (_a) {
1313
1314
  var _this = this;
1314
- var src = _a.src, buffer = _a.buffer, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c, _d = _a.shouldDisableRiveListeners, shouldDisableRiveListeners = _d === void 0 ? false : _d;
1315
+ var src = _a.src, buffer = _a.buffer, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c;
1315
1316
  this.src = src;
1316
1317
  this.buffer = buffer;
1317
1318
  // If no source file url specified, it's a bust
@@ -1338,22 +1339,7 @@ var Rive = /** @class */ (function () {
1338
1339
  }
1339
1340
  // Load Rive data from a source uri or a data buffer
1340
1341
  _this.initData(artboard, startingAnimationNames, startingStateMachineNames, autoplay)
1341
- .then(function () {
1342
- if (!shouldDisableRiveListeners) {
1343
- var activeStateMachines = (_this.animator.stateMachines || [])
1344
- .filter(function (sm) { return sm.playing && _this.runtime.hasListeners(sm.instance); })
1345
- .map(function (sm) { return sm.instance; });
1346
- _this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
1347
- canvas: _this.canvas,
1348
- artboard: _this.artboard,
1349
- stateMachines: activeStateMachines,
1350
- renderer: _this.renderer,
1351
- rive: _this.runtime,
1352
- fit: _this._layout.runtimeFit(_this.runtime),
1353
- alignment: _this._layout.runtimeAlignment(_this.runtime),
1354
- });
1355
- }
1356
- })
1342
+ .then(function () { return _this.setupRiveListeners(); })
1357
1343
  .catch(function (e) {
1358
1344
  console.error(e);
1359
1345
  });
@@ -1362,6 +1348,23 @@ var Rive = /** @class */ (function () {
1362
1348
  console.error(e);
1363
1349
  });
1364
1350
  };
1351
+ Rive.prototype.setupRiveListeners = function () {
1352
+ var _this = this;
1353
+ if (!this.shouldDisableRiveListeners) {
1354
+ var activeStateMachines = (this.animator.stateMachines || [])
1355
+ .filter(function (sm) { return sm.playing && _this.runtime.hasListeners(sm.instance); })
1356
+ .map(function (sm) { return sm.instance; });
1357
+ this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
1358
+ canvas: this.canvas,
1359
+ artboard: this.artboard,
1360
+ stateMachines: activeStateMachines,
1361
+ renderer: this.renderer,
1362
+ rive: this.runtime,
1363
+ fit: this._layout.runtimeFit(this.runtime),
1364
+ alignment: this._layout.runtimeAlignment(this.runtime),
1365
+ });
1366
+ }
1367
+ };
1365
1368
  // Initializes runtime with Rive data and preps for playing
1366
1369
  Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
1367
1370
  var _a;
@@ -1625,6 +1628,10 @@ var Rive = /** @class */ (function () {
1625
1628
  return;
1626
1629
  }
1627
1630
  this.animator.play(animationNames);
1631
+ if (this.eventCleanup) {
1632
+ this.eventCleanup();
1633
+ }
1634
+ this.setupRiveListeners();
1628
1635
  this.startRendering();
1629
1636
  };
1630
1637
  // Pauses specified animations; if none specified, pauses all.
@@ -1667,6 +1674,9 @@ var Rive = /** @class */ (function () {
1667
1674
  return;
1668
1675
  }
1669
1676
  this.animator.stop(animationNames);
1677
+ if (this.eventCleanup) {
1678
+ this.eventCleanup();
1679
+ }
1670
1680
  };
1671
1681
  /**
1672
1682
  * Resets the animation