@rive-app/webgl 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/webgl",
3
- "version": "2.27.4",
3
+ "version": "2.28.0",
4
4
  "description": "Rive's webgl 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
@@ -4065,7 +4065,7 @@ Je();
4065
4065
  /* 2 */
4066
4066
  /***/ ((module) => {
4067
4067
 
4068
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.27.4","description":"Rive\'s webgl 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.wasm","rive_fallback.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
4068
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.28.0","description":"Rive\'s webgl 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.wasm","rive_fallback.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
4069
4069
 
4070
4070
  /***/ }),
4071
4071
  /* 3 */
@@ -4671,8 +4671,8 @@ var FileAssetWrapper = /** @class */ (function () {
4671
4671
  */
4672
4672
  var ImageAssetWrapper = /** @class */ (function (_super) {
4673
4673
  __extends(ImageAssetWrapper, _super);
4674
- function ImageAssetWrapper(nativeAsset) {
4675
- return _super.call(this, nativeAsset) || this;
4674
+ function ImageAssetWrapper() {
4675
+ return _super !== null && _super.apply(this, arguments) || this;
4676
4676
  }
4677
4677
  ImageAssetWrapper.prototype.setRenderImage = function (image) {
4678
4678
  this._nativeFileAsset.setRenderImage(image.nativeImage);
@@ -4685,8 +4685,8 @@ var ImageAssetWrapper = /** @class */ (function (_super) {
4685
4685
  */
4686
4686
  var AudioAssetWrapper = /** @class */ (function (_super) {
4687
4687
  __extends(AudioAssetWrapper, _super);
4688
- function AudioAssetWrapper(nativeAsset) {
4689
- return _super.call(this, nativeAsset) || this;
4688
+ function AudioAssetWrapper() {
4689
+ return _super !== null && _super.apply(this, arguments) || this;
4690
4690
  }
4691
4691
  AudioAssetWrapper.prototype.setAudioSource = function (audio) {
4692
4692
  this._nativeFileAsset.setAudioSource(audio.nativeAudio);
@@ -6062,11 +6062,7 @@ var RiveFile = /** @class */ (function () {
6062
6062
  });
6063
6063
  }
6064
6064
  else {
6065
- this.eventManager.fire({
6066
- type: EventType.LoadError,
6067
- data: null,
6068
- });
6069
- throw new Error(RiveFile.fileLoadErrorMessage);
6065
+ this.fireLoadError(RiveFile.fileLoadErrorMessage);
6070
6066
  }
6071
6067
  return [2 /*return*/];
6072
6068
  }
@@ -6075,29 +6071,45 @@ var RiveFile = /** @class */ (function () {
6075
6071
  };
6076
6072
  RiveFile.prototype.init = function () {
6077
6073
  return __awaiter(this, void 0, void 0, function () {
6078
- var _a;
6074
+ var _a, error_1;
6079
6075
  return __generator(this, function (_b) {
6080
6076
  switch (_b.label) {
6081
6077
  case 0:
6082
6078
  // If no source file url specified, it's a bust
6083
6079
  if (!this.src && !this.buffer) {
6084
- throw new Error(RiveFile.missingErrorMessage);
6080
+ this.fireLoadError(RiveFile.missingErrorMessage);
6081
+ return [2 /*return*/];
6085
6082
  }
6083
+ _b.label = 1;
6084
+ case 1:
6085
+ _b.trys.push([1, 4, , 5]);
6086
6086
  _a = this;
6087
6087
  return [4 /*yield*/, RuntimeLoader.awaitInstance()];
6088
- case 1:
6088
+ case 2:
6089
6089
  _a.runtime = _b.sent();
6090
6090
  if (this.destroyed) {
6091
6091
  return [2 /*return*/];
6092
6092
  }
6093
6093
  return [4 /*yield*/, this.initData()];
6094
- case 2:
6094
+ case 3:
6095
6095
  _b.sent();
6096
- return [2 /*return*/];
6096
+ return [3 /*break*/, 5];
6097
+ case 4:
6098
+ error_1 = _b.sent();
6099
+ this.fireLoadError(error_1 instanceof Error ? error_1.message : RiveFile.fileLoadErrorMessage);
6100
+ return [3 /*break*/, 5];
6101
+ case 5: return [2 /*return*/];
6097
6102
  }
6098
6103
  });
6099
6104
  });
6100
6105
  };
6106
+ RiveFile.prototype.fireLoadError = function (message) {
6107
+ this.eventManager.fire({
6108
+ type: EventType.LoadError,
6109
+ data: message,
6110
+ });
6111
+ throw new Error(message);
6112
+ };
6101
6113
  /**
6102
6114
  * Subscribe to Rive-generated events
6103
6115
  * @param type the type of event to subscribe to
@@ -6424,11 +6436,11 @@ var Rive = /** @class */ (function () {
6424
6436
  this._artboardHeight = this.artboard.height =
6425
6437
  this._artboardHeight || this.artboard.height;
6426
6438
  };
6427
- // Initializes runtime with Rive data and preps for playing.
6439
+ // Initializes runtime with Rive data and preps for playing.
6428
6440
  // Returns true for successful initialization.
6429
6441
  Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
6430
6442
  return __awaiter(this, void 0, void 0, function () {
6431
- var error_1, msg;
6443
+ var error_2, msg;
6432
6444
  var _a;
6433
6445
  return __generator(this, function (_b) {
6434
6446
  switch (_b.label) {
@@ -6470,8 +6482,8 @@ var Rive = /** @class */ (function () {
6470
6482
  this.drawFrame();
6471
6483
  return [2 /*return*/, true];
6472
6484
  case 3:
6473
- error_1 = _b.sent();
6474
- msg = resolveErrorMessage(error_1);
6485
+ error_2 = _b.sent();
6486
+ msg = resolveErrorMessage(error_2);
6475
6487
  console.warn(msg);
6476
6488
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
6477
6489
  return [2 /*return*/, Promise.reject(msg)];
@@ -8317,8 +8329,7 @@ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
8317
8329
  }
8318
8330
  Object.defineProperty(ViewModelInstanceAssetImage.prototype, "value", {
8319
8331
  set: function (image) {
8320
- this._viewModelInstanceValue.value =
8321
- image.nativeImage;
8332
+ this._viewModelInstanceValue.value(image.nativeImage);
8322
8333
  },
8323
8334
  enumerable: false,
8324
8335
  configurable: true