@rive-app/canvas-lite 2.27.4 → 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-lite",
3
- "version": "2.27.4",
3
+ "version": "2.28.0",
4
4
  "description": "A lite version of Rive's canvas based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rc from "./rive_advanced.mjs";
2
- import { ImageWrapper, AssetLoadCallbackWrapper } from "./utils";
3
- export type { FileAssetWrapper as FileAsset, ImageAssetWrapper as ImageAsset, AudioAssetWrapper as AudioAsset, FontAssetWrapper as FontAsset, AssetLoadCallbackWrapper as AssetLoadCallback, } from "./utils";
2
+ export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) => Boolean;
3
+ export type { FileAsset, AudioAsset, FontAsset, ImageAsset, } from "./rive_advanced.mjs";
4
4
  /**
5
5
  * Generic type for a parameterless void callback
6
6
  */
@@ -245,7 +245,7 @@ export interface RiveParameters {
245
245
  onLoop?: EventCallback;
246
246
  onStateChange?: EventCallback;
247
247
  onAdvance?: EventCallback;
248
- assetLoader?: AssetLoadCallbackWrapper;
248
+ assetLoader?: AssetLoadCallback;
249
249
  /**
250
250
  * @deprecated Use `onLoad()` instead
251
251
  */
@@ -297,7 +297,7 @@ export interface RiveResetParameters {
297
297
  export interface RiveFileParameters {
298
298
  src?: string;
299
299
  buffer?: ArrayBuffer;
300
- assetLoader?: AssetLoadCallbackWrapper;
300
+ assetLoader?: AssetLoadCallback;
301
301
  enableRiveAssetCDN?: boolean;
302
302
  onLoad?: EventCallback;
303
303
  onLoadError?: EventCallback;
@@ -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
@@ -897,7 +898,7 @@ export declare class ViewModelInstanceColor extends ViewModelInstanceValue {
897
898
  }
898
899
  export declare class ViewModelInstanceAssetImage extends ViewModelInstanceValue {
899
900
  constructor(instance: rc.ViewModelInstanceAssetImage, root: ViewModelInstance);
900
- set value(image: ImageWrapper);
901
+ set value(image: rc.Image);
901
902
  internalHandleCallback(callback: Function): void;
902
903
  }
903
904
  /**
@@ -946,7 +947,7 @@ export declare const decodeAudio: (bytes: Uint8Array) => Promise<rc.Audio>;
946
947
  * Be sure to call `.unref()` on the image once it is no longer needed. This
947
948
  * allows the engine to clean it up when it is not used by any more animations.
948
949
  */
949
- export declare const decodeImage: (bytes: Uint8Array) => Promise<ImageWrapper>;
950
+ export declare const decodeImage: (bytes: Uint8Array) => Promise<rc.Image>;
950
951
  /**
951
952
  * Decodes bytes into a font.
952
953
  *
package/rive.js CHANGED
@@ -2271,7 +2271,7 @@ Qc();
2271
2271
  /* 2 */
2272
2272
  /***/ ((module) => {
2273
2273
 
2274
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.27.4","description":"A lite version of Rive\'s canvas 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.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2274
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.28.0","description":"A lite version of Rive\'s canvas 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.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2275
2275
 
2276
2276
  /***/ }),
2277
2277
  /* 3 */
@@ -2877,8 +2877,8 @@ var FileAssetWrapper = /** @class */ (function () {
2877
2877
  */
2878
2878
  var ImageAssetWrapper = /** @class */ (function (_super) {
2879
2879
  __extends(ImageAssetWrapper, _super);
2880
- function ImageAssetWrapper(nativeAsset) {
2881
- return _super.call(this, nativeAsset) || this;
2880
+ function ImageAssetWrapper() {
2881
+ return _super !== null && _super.apply(this, arguments) || this;
2882
2882
  }
2883
2883
  ImageAssetWrapper.prototype.setRenderImage = function (image) {
2884
2884
  this._nativeFileAsset.setRenderImage(image.nativeImage);
@@ -2891,8 +2891,8 @@ var ImageAssetWrapper = /** @class */ (function (_super) {
2891
2891
  */
2892
2892
  var AudioAssetWrapper = /** @class */ (function (_super) {
2893
2893
  __extends(AudioAssetWrapper, _super);
2894
- function AudioAssetWrapper(nativeAsset) {
2895
- return _super.call(this, nativeAsset) || this;
2894
+ function AudioAssetWrapper() {
2895
+ return _super !== null && _super.apply(this, arguments) || this;
2896
2896
  }
2897
2897
  AudioAssetWrapper.prototype.setAudioSource = function (audio) {
2898
2898
  this._nativeFileAsset.setAudioSource(audio.nativeAudio);
@@ -4268,11 +4268,7 @@ var RiveFile = /** @class */ (function () {
4268
4268
  });
4269
4269
  }
4270
4270
  else {
4271
- this.eventManager.fire({
4272
- type: EventType.LoadError,
4273
- data: null,
4274
- });
4275
- throw new Error(RiveFile.fileLoadErrorMessage);
4271
+ this.fireLoadError(RiveFile.fileLoadErrorMessage);
4276
4272
  }
4277
4273
  return [2 /*return*/];
4278
4274
  }
@@ -4281,29 +4277,45 @@ var RiveFile = /** @class */ (function () {
4281
4277
  };
4282
4278
  RiveFile.prototype.init = function () {
4283
4279
  return __awaiter(this, void 0, void 0, function () {
4284
- var _a;
4280
+ var _a, error_1;
4285
4281
  return __generator(this, function (_b) {
4286
4282
  switch (_b.label) {
4287
4283
  case 0:
4288
4284
  // If no source file url specified, it's a bust
4289
4285
  if (!this.src && !this.buffer) {
4290
- throw new Error(RiveFile.missingErrorMessage);
4286
+ this.fireLoadError(RiveFile.missingErrorMessage);
4287
+ return [2 /*return*/];
4291
4288
  }
4289
+ _b.label = 1;
4290
+ case 1:
4291
+ _b.trys.push([1, 4, , 5]);
4292
4292
  _a = this;
4293
4293
  return [4 /*yield*/, RuntimeLoader.awaitInstance()];
4294
- case 1:
4294
+ case 2:
4295
4295
  _a.runtime = _b.sent();
4296
4296
  if (this.destroyed) {
4297
4297
  return [2 /*return*/];
4298
4298
  }
4299
4299
  return [4 /*yield*/, this.initData()];
4300
- case 2:
4300
+ case 3:
4301
4301
  _b.sent();
4302
- return [2 /*return*/];
4302
+ return [3 /*break*/, 5];
4303
+ case 4:
4304
+ error_1 = _b.sent();
4305
+ this.fireLoadError(error_1 instanceof Error ? error_1.message : RiveFile.fileLoadErrorMessage);
4306
+ return [3 /*break*/, 5];
4307
+ case 5: return [2 /*return*/];
4303
4308
  }
4304
4309
  });
4305
4310
  });
4306
4311
  };
4312
+ RiveFile.prototype.fireLoadError = function (message) {
4313
+ this.eventManager.fire({
4314
+ type: EventType.LoadError,
4315
+ data: message,
4316
+ });
4317
+ throw new Error(message);
4318
+ };
4307
4319
  /**
4308
4320
  * Subscribe to Rive-generated events
4309
4321
  * @param type the type of event to subscribe to
@@ -4630,11 +4642,11 @@ var Rive = /** @class */ (function () {
4630
4642
  this._artboardHeight = this.artboard.height =
4631
4643
  this._artboardHeight || this.artboard.height;
4632
4644
  };
4633
- // Initializes runtime with Rive data and preps for playing.
4645
+ // Initializes runtime with Rive data and preps for playing.
4634
4646
  // Returns true for successful initialization.
4635
4647
  Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
4636
4648
  return __awaiter(this, void 0, void 0, function () {
4637
- var error_1, msg;
4649
+ var error_2, msg;
4638
4650
  var _a;
4639
4651
  return __generator(this, function (_b) {
4640
4652
  switch (_b.label) {
@@ -4676,8 +4688,8 @@ var Rive = /** @class */ (function () {
4676
4688
  this.drawFrame();
4677
4689
  return [2 /*return*/, true];
4678
4690
  case 3:
4679
- error_1 = _b.sent();
4680
- msg = resolveErrorMessage(error_1);
4691
+ error_2 = _b.sent();
4692
+ msg = resolveErrorMessage(error_2);
4681
4693
  console.warn(msg);
4682
4694
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
4683
4695
  return [2 /*return*/, Promise.reject(msg)];
@@ -6523,8 +6535,7 @@ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
6523
6535
  }
6524
6536
  Object.defineProperty(ViewModelInstanceAssetImage.prototype, "value", {
6525
6537
  set: function (image) {
6526
- this._viewModelInstanceValue.value =
6527
- image.nativeImage;
6538
+ this._viewModelInstanceValue.value(image.nativeImage);
6528
6539
  },
6529
6540
  enumerable: false,
6530
6541
  configurable: true