@rive-app/webgl-single 1.0.85 → 1.0.86

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.0.85",
3
+ "version": "1.0.86",
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
@@ -1,4 +1,4 @@
1
- import * as rc from './rive_advanced.mjs';
1
+ import * as rc from "./rive_advanced.mjs";
2
2
  /**
3
3
  * Generic type for a parameterless void callback
4
4
  */
@@ -288,6 +288,15 @@ export declare class Rive {
288
288
  private alignRenderer;
289
289
  get fps(): number;
290
290
  get frameTime(): string | 0;
291
+ /**
292
+ * Cleans up all Wasm-generated objects that need to be manually destroyed:
293
+ * artboard instances, animation instances, state machine instances,
294
+ * renderer instance, file and runtime.
295
+ *
296
+ * Once this is called, you will need to initialise a new instance of the
297
+ * Rive class
298
+ */
299
+ cleanup(): void;
291
300
  /**
292
301
  * Cleans up any Wasm-generated objects that need to be manually destroyed:
293
302
  * artboard instances, animation instances, state machine instances.
@@ -295,7 +304,7 @@ export declare class Rive {
295
304
  * Once this is called, things will need to be reinitialized or bad things
296
305
  * might happen.
297
306
  */
298
- cleanup(): void;
307
+ cleanupInstances(): void;
299
308
  play(animationNames?: string | string[], autoplay?: true): void;
300
309
  pause(animationNames?: string | string[]): void;
301
310
  scrub(animationNames?: string | string[], value?: number): 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.0.85","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.0.86","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 */
@@ -431,7 +431,7 @@ var Layout = /** @class */ (function () {
431
431
  // Alternative constructor to build a Layout from an interface/object
432
432
  Layout.new = function (_a) {
433
433
  var fit = _a.fit, alignment = _a.alignment, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
434
- console.warn('This function is deprecated: please use `new Layout({})` instead');
434
+ console.warn("This function is deprecated: please use `new Layout({})` instead");
435
435
  return new Layout({ fit: fit, alignment: alignment, minX: minX, minY: minY, maxX: maxX, maxY: maxY });
436
436
  };
437
437
  /**
@@ -1264,7 +1264,7 @@ var Rive = /** @class */ (function () {
1264
1264
  }
1265
1265
  // Alternative constructor to build a Rive instance from an interface/object
1266
1266
  Rive.new = function (params) {
1267
- console.warn('This function is deprecated: please use `new Rive({})` instead');
1267
+ console.warn("This function is deprecated: please use `new Rive({})` instead");
1268
1268
  return new Rive(params);
1269
1269
  };
1270
1270
  // Initializes the Rive object either from constructor or load()
@@ -1346,7 +1346,7 @@ var Rive = /** @class */ (function () {
1346
1346
  this.loaded = true;
1347
1347
  this.eventManager.fire({
1348
1348
  type: EventType.Load,
1349
- data: (_a = this.src) !== null && _a !== void 0 ? _a : 'buffer',
1349
+ data: (_a = this.src) !== null && _a !== void 0 ? _a : "buffer",
1350
1350
  });
1351
1351
  // Flag ready for playback commands and clear the task queue; this order
1352
1352
  // is important or it may infinitely recurse
@@ -1356,7 +1356,7 @@ var Rive = /** @class */ (function () {
1356
1356
  return [2 /*return*/, Promise.resolve()];
1357
1357
  }
1358
1358
  else {
1359
- msg = 'Problem loading file; may be corrupt!';
1359
+ msg = "Problem loading file; may be corrupt!";
1360
1360
  console.warn(msg);
1361
1361
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
1362
1362
  return [2 /*return*/, Promise.reject(msg)];
@@ -1374,7 +1374,7 @@ var Rive = /** @class */ (function () {
1374
1374
  : this.file.defaultArtboard();
1375
1375
  // Check we have a working artboard
1376
1376
  if (!rootArtboard) {
1377
- var msg = 'Invalid artboard name or no default artboard';
1377
+ var msg = "Invalid artboard name or no default artboard";
1378
1378
  console.warn(msg);
1379
1379
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
1380
1380
  return;
@@ -1382,7 +1382,7 @@ var Rive = /** @class */ (function () {
1382
1382
  this.artboard = rootArtboard;
1383
1383
  // Check that the artboard has at least 1 animation
1384
1384
  if (this.artboard.animationCount() < 1) {
1385
- var msg = 'Artboard has no animations';
1385
+ var msg = "Artboard has no animations";
1386
1386
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
1387
1387
  throw msg;
1388
1388
  }
@@ -1531,6 +1531,26 @@ var Rive = /** @class */ (function () {
1531
1531
  enumerable: false,
1532
1532
  configurable: true
1533
1533
  });
1534
+ /**
1535
+ * Cleans up all Wasm-generated objects that need to be manually destroyed:
1536
+ * artboard instances, animation instances, state machine instances,
1537
+ * renderer instance, file and runtime.
1538
+ *
1539
+ * Once this is called, you will need to initialise a new instance of the
1540
+ * Rive class
1541
+ */
1542
+ Rive.prototype.cleanup = function () {
1543
+ // Stop the renderer if it hasn't already been stopped.
1544
+ this.stopRendering();
1545
+ // Clean up any artboard, animation or state machine instances.
1546
+ this.cleanupInstances();
1547
+ // Delete the renderer
1548
+ this.renderer.delete();
1549
+ // Delete the rive file
1550
+ this.file.delete();
1551
+ // Cleanup anything remaining on the runtime.
1552
+ this.runtime.cleanup();
1553
+ };
1534
1554
  /**
1535
1555
  * Cleans up any Wasm-generated objects that need to be manually destroyed:
1536
1556
  * artboard instances, animation instances, state machine instances.
@@ -1538,7 +1558,7 @@ var Rive = /** @class */ (function () {
1538
1558
  * Once this is called, things will need to be reinitialized or bad things
1539
1559
  * might happen.
1540
1560
  */
1541
- Rive.prototype.cleanup = function () {
1561
+ Rive.prototype.cleanupInstances = function () {
1542
1562
  if (this.eventCleanup !== null) {
1543
1563
  this.eventCleanup();
1544
1564
  }
@@ -1620,7 +1640,7 @@ var Rive = /** @class */ (function () {
1620
1640
  var stateMachineNames = mapToStringArray(params === null || params === void 0 ? void 0 : params.stateMachines);
1621
1641
  var autoplay = (_a = params === null || params === void 0 ? void 0 : params.autoplay) !== null && _a !== void 0 ? _a : false;
1622
1642
  // Stop everything and clean up
1623
- this.cleanup();
1643
+ this.cleanupInstances();
1624
1644
  // Reinitialize an artboard instance with the state
1625
1645
  this.initArtboard(artBoardName, animationNames, stateMachineNames, autoplay);
1626
1646
  this.taskQueue.process();
@@ -1969,7 +1989,7 @@ var Rive = /** @class */ (function () {
1969
1989
  configurable: true
1970
1990
  });
1971
1991
  // Error message for missing source or buffer
1972
- Rive.missingErrorMessage = 'Rive source file or data buffer required';
1992
+ Rive.missingErrorMessage = "Rive source file or data buffer required";
1973
1993
  return Rive;
1974
1994
  }());
1975
1995
 
@@ -1996,7 +2016,7 @@ var loadRiveFile = function (src) { return __awaiter(void 0, void 0, void 0, fun
1996
2016
  * Utility function to ensure an object is a string array
1997
2017
  */
1998
2018
  var mapToStringArray = function (obj) {
1999
- if (typeof obj === 'string') {
2019
+ if (typeof obj === "string") {
2000
2020
  return [obj];
2001
2021
  }
2002
2022
  else if (obj instanceof Array) {