@rive-app/canvas-single 2.27.5 → 2.28.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/canvas-single",
3
- "version": "2.27.5",
3
+ "version": "2.28.0",
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
@@ -317,6 +317,7 @@ export declare class RiveFile {
317
317
  constructor(params: RiveFileParameters);
318
318
  private initData;
319
319
  init(): Promise<void>;
320
+ private fireLoadError;
320
321
  /**
321
322
  * Subscribe to Rive-generated events
322
323
  * @param type the type of event to subscribe to
package/rive.js CHANGED
@@ -3358,7 +3358,7 @@ Xd();
3358
3358
  /* 2 */
3359
3359
  /***/ ((module) => {
3360
3360
 
3361
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-single","version":"2.27.5","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}}');
3361
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-single","version":"2.28.0","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}}');
3362
3362
 
3363
3363
  /***/ }),
3364
3364
  /* 3 */
@@ -5355,11 +5355,7 @@ var RiveFile = /** @class */ (function () {
5355
5355
  });
5356
5356
  }
5357
5357
  else {
5358
- this.eventManager.fire({
5359
- type: EventType.LoadError,
5360
- data: null,
5361
- });
5362
- throw new Error(RiveFile.fileLoadErrorMessage);
5358
+ this.fireLoadError(RiveFile.fileLoadErrorMessage);
5363
5359
  }
5364
5360
  return [2 /*return*/];
5365
5361
  }
@@ -5368,29 +5364,45 @@ var RiveFile = /** @class */ (function () {
5368
5364
  };
5369
5365
  RiveFile.prototype.init = function () {
5370
5366
  return __awaiter(this, void 0, void 0, function () {
5371
- var _a;
5367
+ var _a, error_1;
5372
5368
  return __generator(this, function (_b) {
5373
5369
  switch (_b.label) {
5374
5370
  case 0:
5375
5371
  // If no source file url specified, it's a bust
5376
5372
  if (!this.src && !this.buffer) {
5377
- throw new Error(RiveFile.missingErrorMessage);
5373
+ this.fireLoadError(RiveFile.missingErrorMessage);
5374
+ return [2 /*return*/];
5378
5375
  }
5376
+ _b.label = 1;
5377
+ case 1:
5378
+ _b.trys.push([1, 4, , 5]);
5379
5379
  _a = this;
5380
5380
  return [4 /*yield*/, RuntimeLoader.awaitInstance()];
5381
- case 1:
5381
+ case 2:
5382
5382
  _a.runtime = _b.sent();
5383
5383
  if (this.destroyed) {
5384
5384
  return [2 /*return*/];
5385
5385
  }
5386
5386
  return [4 /*yield*/, this.initData()];
5387
- case 2:
5387
+ case 3:
5388
5388
  _b.sent();
5389
- return [2 /*return*/];
5389
+ return [3 /*break*/, 5];
5390
+ case 4:
5391
+ error_1 = _b.sent();
5392
+ this.fireLoadError(error_1 instanceof Error ? error_1.message : RiveFile.fileLoadErrorMessage);
5393
+ return [3 /*break*/, 5];
5394
+ case 5: return [2 /*return*/];
5390
5395
  }
5391
5396
  });
5392
5397
  });
5393
5398
  };
5399
+ RiveFile.prototype.fireLoadError = function (message) {
5400
+ this.eventManager.fire({
5401
+ type: EventType.LoadError,
5402
+ data: message,
5403
+ });
5404
+ throw new Error(message);
5405
+ };
5394
5406
  /**
5395
5407
  * Subscribe to Rive-generated events
5396
5408
  * @param type the type of event to subscribe to
@@ -5721,7 +5733,7 @@ var Rive = /** @class */ (function () {
5721
5733
  // Returns true for successful initialization.
5722
5734
  Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
5723
5735
  return __awaiter(this, void 0, void 0, function () {
5724
- var error_1, msg;
5736
+ var error_2, msg;
5725
5737
  var _a;
5726
5738
  return __generator(this, function (_b) {
5727
5739
  switch (_b.label) {
@@ -5763,8 +5775,8 @@ var Rive = /** @class */ (function () {
5763
5775
  this.drawFrame();
5764
5776
  return [2 /*return*/, true];
5765
5777
  case 3:
5766
- error_1 = _b.sent();
5767
- msg = resolveErrorMessage(error_1);
5778
+ error_2 = _b.sent();
5779
+ msg = resolveErrorMessage(error_2);
5768
5780
  console.warn(msg);
5769
5781
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
5770
5782
  return [2 /*return*/, Promise.reject(msg)];