@rive-app/canvas-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/canvas-single",
3
- "version": "1.0.85",
3
+ "version": "1.0.86",
4
4
  "description": "Rive's high-level canvas based web api all in one js file.",
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
@@ -134,7 +134,7 @@ if(m.preInit)for("function"==typeof m.preInit&&(m.preInit=[m.preInit]);0<m.preIn
134
134
  /* 2 */
135
135
  /***/ ((module) => {
136
136
 
137
- module.exports = JSON.parse('{"name":"@rive-app/canvas-single","version":"1.0.85","description":"Rive\'s high-level canvas based web api all in one js file.","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}}');
137
+ module.exports = JSON.parse('{"name":"@rive-app/canvas-single","version":"1.0.86","description":"Rive\'s high-level canvas based web api all in one js file.","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}}');
138
138
 
139
139
  /***/ }),
140
140
  /* 3 */
@@ -398,7 +398,7 @@ var Layout = /** @class */ (function () {
398
398
  // Alternative constructor to build a Layout from an interface/object
399
399
  Layout.new = function (_a) {
400
400
  var fit = _a.fit, alignment = _a.alignment, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
401
- console.warn('This function is deprecated: please use `new Layout({})` instead');
401
+ console.warn("This function is deprecated: please use `new Layout({})` instead");
402
402
  return new Layout({ fit: fit, alignment: alignment, minX: minX, minY: minY, maxX: maxX, maxY: maxY });
403
403
  };
404
404
  /**
@@ -1231,7 +1231,7 @@ var Rive = /** @class */ (function () {
1231
1231
  }
1232
1232
  // Alternative constructor to build a Rive instance from an interface/object
1233
1233
  Rive.new = function (params) {
1234
- console.warn('This function is deprecated: please use `new Rive({})` instead');
1234
+ console.warn("This function is deprecated: please use `new Rive({})` instead");
1235
1235
  return new Rive(params);
1236
1236
  };
1237
1237
  // Initializes the Rive object either from constructor or load()
@@ -1313,7 +1313,7 @@ var Rive = /** @class */ (function () {
1313
1313
  this.loaded = true;
1314
1314
  this.eventManager.fire({
1315
1315
  type: EventType.Load,
1316
- data: (_a = this.src) !== null && _a !== void 0 ? _a : 'buffer',
1316
+ data: (_a = this.src) !== null && _a !== void 0 ? _a : "buffer",
1317
1317
  });
1318
1318
  // Flag ready for playback commands and clear the task queue; this order
1319
1319
  // is important or it may infinitely recurse
@@ -1323,7 +1323,7 @@ var Rive = /** @class */ (function () {
1323
1323
  return [2 /*return*/, Promise.resolve()];
1324
1324
  }
1325
1325
  else {
1326
- msg = 'Problem loading file; may be corrupt!';
1326
+ msg = "Problem loading file; may be corrupt!";
1327
1327
  console.warn(msg);
1328
1328
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
1329
1329
  return [2 /*return*/, Promise.reject(msg)];
@@ -1341,7 +1341,7 @@ var Rive = /** @class */ (function () {
1341
1341
  : this.file.defaultArtboard();
1342
1342
  // Check we have a working artboard
1343
1343
  if (!rootArtboard) {
1344
- var msg = 'Invalid artboard name or no default artboard';
1344
+ var msg = "Invalid artboard name or no default artboard";
1345
1345
  console.warn(msg);
1346
1346
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
1347
1347
  return;
@@ -1349,7 +1349,7 @@ var Rive = /** @class */ (function () {
1349
1349
  this.artboard = rootArtboard;
1350
1350
  // Check that the artboard has at least 1 animation
1351
1351
  if (this.artboard.animationCount() < 1) {
1352
- var msg = 'Artboard has no animations';
1352
+ var msg = "Artboard has no animations";
1353
1353
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
1354
1354
  throw msg;
1355
1355
  }
@@ -1498,6 +1498,26 @@ var Rive = /** @class */ (function () {
1498
1498
  enumerable: false,
1499
1499
  configurable: true
1500
1500
  });
1501
+ /**
1502
+ * Cleans up all Wasm-generated objects that need to be manually destroyed:
1503
+ * artboard instances, animation instances, state machine instances,
1504
+ * renderer instance, file and runtime.
1505
+ *
1506
+ * Once this is called, you will need to initialise a new instance of the
1507
+ * Rive class
1508
+ */
1509
+ Rive.prototype.cleanup = function () {
1510
+ // Stop the renderer if it hasn't already been stopped.
1511
+ this.stopRendering();
1512
+ // Clean up any artboard, animation or state machine instances.
1513
+ this.cleanupInstances();
1514
+ // Delete the renderer
1515
+ this.renderer.delete();
1516
+ // Delete the rive file
1517
+ this.file.delete();
1518
+ // Cleanup anything remaining on the runtime.
1519
+ this.runtime.cleanup();
1520
+ };
1501
1521
  /**
1502
1522
  * Cleans up any Wasm-generated objects that need to be manually destroyed:
1503
1523
  * artboard instances, animation instances, state machine instances.
@@ -1505,7 +1525,7 @@ var Rive = /** @class */ (function () {
1505
1525
  * Once this is called, things will need to be reinitialized or bad things
1506
1526
  * might happen.
1507
1527
  */
1508
- Rive.prototype.cleanup = function () {
1528
+ Rive.prototype.cleanupInstances = function () {
1509
1529
  if (this.eventCleanup !== null) {
1510
1530
  this.eventCleanup();
1511
1531
  }
@@ -1587,7 +1607,7 @@ var Rive = /** @class */ (function () {
1587
1607
  var stateMachineNames = mapToStringArray(params === null || params === void 0 ? void 0 : params.stateMachines);
1588
1608
  var autoplay = (_a = params === null || params === void 0 ? void 0 : params.autoplay) !== null && _a !== void 0 ? _a : false;
1589
1609
  // Stop everything and clean up
1590
- this.cleanup();
1610
+ this.cleanupInstances();
1591
1611
  // Reinitialize an artboard instance with the state
1592
1612
  this.initArtboard(artBoardName, animationNames, stateMachineNames, autoplay);
1593
1613
  this.taskQueue.process();
@@ -1936,7 +1956,7 @@ var Rive = /** @class */ (function () {
1936
1956
  configurable: true
1937
1957
  });
1938
1958
  // Error message for missing source or buffer
1939
- Rive.missingErrorMessage = 'Rive source file or data buffer required';
1959
+ Rive.missingErrorMessage = "Rive source file or data buffer required";
1940
1960
  return Rive;
1941
1961
  }());
1942
1962
 
@@ -1963,7 +1983,7 @@ var loadRiveFile = function (src) { return __awaiter(void 0, void 0, void 0, fun
1963
1983
  * Utility function to ensure an object is a string array
1964
1984
  */
1965
1985
  var mapToStringArray = function (obj) {
1966
- if (typeof obj === 'string') {
1986
+ if (typeof obj === "string") {
1967
1987
  return [obj];
1968
1988
  }
1969
1989
  else if (obj instanceof Array) {