@rive-app/canvas-lite 2.27.2 → 2.27.4

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.2",
3
+ "version": "2.27.4",
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,10 +1,10 @@
1
1
  import * as rc from "./rive_advanced.mjs";
2
- export type { FileAsset, AudioAsset, FontAsset, ImageAsset, } 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";
3
4
  /**
4
5
  * Generic type for a parameterless void callback
5
6
  */
6
7
  export type VoidCallback = () => void;
7
- export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) => Boolean;
8
8
  interface SetupRiveListenersOptions {
9
9
  isTouchScrollEnabled?: boolean;
10
10
  }
@@ -245,7 +245,7 @@ export interface RiveParameters {
245
245
  onLoop?: EventCallback;
246
246
  onStateChange?: EventCallback;
247
247
  onAdvance?: EventCallback;
248
- assetLoader?: AssetLoadCallback;
248
+ assetLoader?: AssetLoadCallbackWrapper;
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?: AssetLoadCallback;
300
+ assetLoader?: AssetLoadCallbackWrapper;
301
301
  enableRiveAssetCDN?: boolean;
302
302
  onLoad?: EventCallback;
303
303
  onLoadError?: EventCallback;
@@ -805,6 +805,12 @@ export declare class ViewModelInstance {
805
805
  * @param path - path to the list property
806
806
  */
807
807
  list(path: string): ViewModelInstanceList | null;
808
+ /**
809
+ * method to access a view model property instance belonging
810
+ * to the view model instance or to a nested view model instance
811
+ * @param path - path to the image property
812
+ */
813
+ image(path: string): ViewModelInstanceAssetImage | null;
808
814
  /**
809
815
  * method to access a view model property instance belonging
810
816
  * to the view model instance or to a nested view model instance
@@ -889,6 +895,11 @@ export declare class ViewModelInstanceColor extends ViewModelInstanceValue {
889
895
  opacity(o: number): void;
890
896
  internalHandleCallback(callback: Function): void;
891
897
  }
898
+ export declare class ViewModelInstanceAssetImage extends ViewModelInstanceValue {
899
+ constructor(instance: rc.ViewModelInstanceAssetImage, root: ViewModelInstance);
900
+ set value(image: ImageWrapper);
901
+ internalHandleCallback(callback: Function): void;
902
+ }
892
903
  /**
893
904
  * Contents of a state machine input
894
905
  */
@@ -935,7 +946,7 @@ export declare const decodeAudio: (bytes: Uint8Array) => Promise<rc.Audio>;
935
946
  * Be sure to call `.unref()` on the image once it is no longer needed. This
936
947
  * allows the engine to clean it up when it is not used by any more animations.
937
948
  */
938
- export declare const decodeImage: (bytes: Uint8Array) => Promise<rc.Image>;
949
+ export declare const decodeImage: (bytes: Uint8Array) => Promise<ImageWrapper>;
939
950
  /**
940
951
  * Decodes bytes into a font.
941
952
  *
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.2","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.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}}');
2275
2275
 
2276
2276
  /***/ }),
2277
2277
  /* 3 */
@@ -2413,12 +2413,24 @@ var Animation = /** @class */ (function () {
2413
2413
 
2414
2414
  __webpack_require__.r(__webpack_exports__);
2415
2415
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2416
+ /* harmony export */ AudioAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.AudioAssetWrapper),
2417
+ /* harmony export */ AudioWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.AudioWrapper),
2416
2418
  /* harmony export */ BLANK_URL: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.BLANK_URL),
2419
+ /* harmony export */ CustomFileAssetLoaderWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.CustomFileAssetLoaderWrapper),
2420
+ /* harmony export */ FileAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FileAssetWrapper),
2421
+ /* harmony export */ Finalizable: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.Finalizable),
2422
+ /* harmony export */ FontAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FontAssetWrapper),
2423
+ /* harmony export */ FontWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FontWrapper),
2424
+ /* harmony export */ ImageAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.ImageAssetWrapper),
2425
+ /* harmony export */ ImageWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.ImageWrapper),
2426
+ /* harmony export */ finalizationRegistry: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry),
2417
2427
  /* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
2418
2428
  /* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.sanitizeUrl)
2419
2429
  /* harmony export */ });
2420
2430
  /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6);
2421
2431
  /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
2432
+ /* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
2433
+
2422
2434
 
2423
2435
 
2424
2436
 
@@ -2667,6 +2679,258 @@ function sanitizeUrl(url) {
2667
2679
  }
2668
2680
 
2669
2681
 
2682
+ /***/ }),
2683
+ /* 8 */
2684
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2685
+
2686
+ __webpack_require__.r(__webpack_exports__);
2687
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2688
+ /* harmony export */ AudioAssetWrapper: () => (/* binding */ AudioAssetWrapper),
2689
+ /* harmony export */ AudioWrapper: () => (/* binding */ AudioWrapper),
2690
+ /* harmony export */ CustomFileAssetLoaderWrapper: () => (/* binding */ CustomFileAssetLoaderWrapper),
2691
+ /* harmony export */ FileAssetWrapper: () => (/* binding */ FileAssetWrapper),
2692
+ /* harmony export */ Finalizable: () => (/* binding */ Finalizable),
2693
+ /* harmony export */ FontAssetWrapper: () => (/* binding */ FontAssetWrapper),
2694
+ /* harmony export */ FontWrapper: () => (/* binding */ FontWrapper),
2695
+ /* harmony export */ ImageAssetWrapper: () => (/* binding */ ImageAssetWrapper),
2696
+ /* harmony export */ ImageWrapper: () => (/* binding */ ImageWrapper),
2697
+ /* harmony export */ finalizationRegistry: () => (/* binding */ finalizationRegistry)
2698
+ /* harmony export */ });
2699
+ var __extends = (undefined && undefined.__extends) || (function () {
2700
+ var extendStatics = function (d, b) {
2701
+ extendStatics = Object.setPrototypeOf ||
2702
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2703
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
2704
+ return extendStatics(d, b);
2705
+ };
2706
+ return function (d, b) {
2707
+ if (typeof b !== "function" && b !== null)
2708
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2709
+ extendStatics(d, b);
2710
+ function __() { this.constructor = d; }
2711
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2712
+ };
2713
+ })();
2714
+ var Finalizable = /** @class */ (function () {
2715
+ function Finalizable() {
2716
+ this.selfUnref = false;
2717
+ }
2718
+ return Finalizable;
2719
+ }());
2720
+ var ImageWrapper = /** @class */ (function (_super) {
2721
+ __extends(ImageWrapper, _super);
2722
+ function ImageWrapper(image) {
2723
+ var _this = _super.call(this) || this;
2724
+ _this._nativeImage = image;
2725
+ return _this;
2726
+ }
2727
+ Object.defineProperty(ImageWrapper.prototype, "nativeImage", {
2728
+ get: function () {
2729
+ return this._nativeImage;
2730
+ },
2731
+ enumerable: false,
2732
+ configurable: true
2733
+ });
2734
+ ImageWrapper.prototype.unref = function () {
2735
+ if (this.selfUnref) {
2736
+ this._nativeImage.unref();
2737
+ }
2738
+ };
2739
+ return ImageWrapper;
2740
+ }(Finalizable));
2741
+ var AudioWrapper = /** @class */ (function (_super) {
2742
+ __extends(AudioWrapper, _super);
2743
+ function AudioWrapper(audio) {
2744
+ var _this = _super.call(this) || this;
2745
+ _this._nativeAudio = audio;
2746
+ return _this;
2747
+ }
2748
+ Object.defineProperty(AudioWrapper.prototype, "nativeAudio", {
2749
+ get: function () {
2750
+ return this._nativeAudio;
2751
+ },
2752
+ enumerable: false,
2753
+ configurable: true
2754
+ });
2755
+ AudioWrapper.prototype.unref = function () {
2756
+ if (this.selfUnref) {
2757
+ this._nativeAudio.unref();
2758
+ }
2759
+ };
2760
+ return AudioWrapper;
2761
+ }(Finalizable));
2762
+ var FontWrapper = /** @class */ (function (_super) {
2763
+ __extends(FontWrapper, _super);
2764
+ function FontWrapper(font) {
2765
+ var _this = _super.call(this) || this;
2766
+ _this._nativeFont = font;
2767
+ return _this;
2768
+ }
2769
+ Object.defineProperty(FontWrapper.prototype, "nativeFont", {
2770
+ get: function () {
2771
+ return this._nativeFont;
2772
+ },
2773
+ enumerable: false,
2774
+ configurable: true
2775
+ });
2776
+ FontWrapper.prototype.unref = function () {
2777
+ if (this.selfUnref) {
2778
+ this._nativeFont.unref();
2779
+ }
2780
+ };
2781
+ return FontWrapper;
2782
+ }(Finalizable));
2783
+ var CustomFileAssetLoaderWrapper = /** @class */ (function () {
2784
+ function CustomFileAssetLoaderWrapper(runtime, loaderCallback) {
2785
+ this._assetLoaderCallback = loaderCallback;
2786
+ this.assetLoader = new runtime.CustomFileAssetLoader({
2787
+ loadContents: this.loadContents.bind(this),
2788
+ });
2789
+ }
2790
+ CustomFileAssetLoaderWrapper.prototype.loadContents = function (asset, bytes) {
2791
+ var assetWrapper;
2792
+ if (asset.isImage) {
2793
+ assetWrapper = new ImageAssetWrapper(asset);
2794
+ }
2795
+ else if (asset.isAudio) {
2796
+ assetWrapper = new AudioAssetWrapper(asset);
2797
+ }
2798
+ else if (asset.isFont) {
2799
+ assetWrapper = new FontAssetWrapper(asset);
2800
+ }
2801
+ return this._assetLoaderCallback(assetWrapper, bytes);
2802
+ };
2803
+ return CustomFileAssetLoaderWrapper;
2804
+ }());
2805
+ /**
2806
+ * Rive class representing a FileAsset with relevant metadata fields to describe
2807
+ * an asset associated wtih the Rive File
2808
+ */
2809
+ var FileAssetWrapper = /** @class */ (function () {
2810
+ function FileAssetWrapper(nativeAsset) {
2811
+ this._nativeFileAsset = nativeAsset;
2812
+ }
2813
+ FileAssetWrapper.prototype.decode = function (bytes) {
2814
+ this._nativeFileAsset.decode(bytes);
2815
+ };
2816
+ Object.defineProperty(FileAssetWrapper.prototype, "name", {
2817
+ get: function () {
2818
+ return this._nativeFileAsset.name;
2819
+ },
2820
+ enumerable: false,
2821
+ configurable: true
2822
+ });
2823
+ Object.defineProperty(FileAssetWrapper.prototype, "fileExtension", {
2824
+ get: function () {
2825
+ return this._nativeFileAsset.fileExtension;
2826
+ },
2827
+ enumerable: false,
2828
+ configurable: true
2829
+ });
2830
+ Object.defineProperty(FileAssetWrapper.prototype, "uniqueFilename", {
2831
+ get: function () {
2832
+ return this._nativeFileAsset.uniqueFilename;
2833
+ },
2834
+ enumerable: false,
2835
+ configurable: true
2836
+ });
2837
+ Object.defineProperty(FileAssetWrapper.prototype, "isAudio", {
2838
+ get: function () {
2839
+ return this._nativeFileAsset.isAudio;
2840
+ },
2841
+ enumerable: false,
2842
+ configurable: true
2843
+ });
2844
+ Object.defineProperty(FileAssetWrapper.prototype, "isImage", {
2845
+ get: function () {
2846
+ return this._nativeFileAsset.isImage;
2847
+ },
2848
+ enumerable: false,
2849
+ configurable: true
2850
+ });
2851
+ Object.defineProperty(FileAssetWrapper.prototype, "isFont", {
2852
+ get: function () {
2853
+ return this._nativeFileAsset.isFont;
2854
+ },
2855
+ enumerable: false,
2856
+ configurable: true
2857
+ });
2858
+ Object.defineProperty(FileAssetWrapper.prototype, "cdnUuid", {
2859
+ get: function () {
2860
+ return this._nativeFileAsset.cdnUuid;
2861
+ },
2862
+ enumerable: false,
2863
+ configurable: true
2864
+ });
2865
+ Object.defineProperty(FileAssetWrapper.prototype, "nativeFileAsset", {
2866
+ get: function () {
2867
+ return this._nativeFileAsset;
2868
+ },
2869
+ enumerable: false,
2870
+ configurable: true
2871
+ });
2872
+ return FileAssetWrapper;
2873
+ }());
2874
+ /**
2875
+ * Rive class extending the FileAsset that exposes a `setRenderImage()` API with a
2876
+ * decoded Image (via the `decodeImage()` API) to set a new Image on the Rive FileAsset
2877
+ */
2878
+ var ImageAssetWrapper = /** @class */ (function (_super) {
2879
+ __extends(ImageAssetWrapper, _super);
2880
+ function ImageAssetWrapper(nativeAsset) {
2881
+ return _super.call(this, nativeAsset) || this;
2882
+ }
2883
+ ImageAssetWrapper.prototype.setRenderImage = function (image) {
2884
+ this._nativeFileAsset.setRenderImage(image.nativeImage);
2885
+ };
2886
+ return ImageAssetWrapper;
2887
+ }(FileAssetWrapper));
2888
+ /**
2889
+ * Rive class extending the FileAsset that exposes a `setAudioSource()` API with a
2890
+ * decoded Audio (via the `decodeAudio()` API) to set a new Audio on the Rive FileAsset
2891
+ */
2892
+ var AudioAssetWrapper = /** @class */ (function (_super) {
2893
+ __extends(AudioAssetWrapper, _super);
2894
+ function AudioAssetWrapper(nativeAsset) {
2895
+ return _super.call(this, nativeAsset) || this;
2896
+ }
2897
+ AudioAssetWrapper.prototype.setAudioSource = function (audio) {
2898
+ this._nativeFileAsset.setAudioSource(audio.nativeAudio);
2899
+ };
2900
+ return AudioAssetWrapper;
2901
+ }(FileAssetWrapper));
2902
+ /**
2903
+ * Rive class extending the FileAsset that exposes a `setFont()` API with a
2904
+ * decoded Font (via the `decodeFont()` API) to set a new Font on the Rive FileAsset
2905
+ */
2906
+ var FontAssetWrapper = /** @class */ (function (_super) {
2907
+ __extends(FontAssetWrapper, _super);
2908
+ function FontAssetWrapper() {
2909
+ return _super !== null && _super.apply(this, arguments) || this;
2910
+ }
2911
+ FontAssetWrapper.prototype.setFont = function (font) {
2912
+ this._nativeFileAsset.setFont(font.nativeFont);
2913
+ };
2914
+ return FontAssetWrapper;
2915
+ }(FileAssetWrapper));
2916
+ var FakeFinalizationRegistry = /** @class */ (function (_super) {
2917
+ __extends(FakeFinalizationRegistry, _super);
2918
+ function FakeFinalizationRegistry(fn) {
2919
+ return _super.call(this, fn) || this;
2920
+ }
2921
+ FakeFinalizationRegistry.prototype.register = function (object) {
2922
+ object.selfUnref = true;
2923
+ };
2924
+ FakeFinalizationRegistry.prototype.unregister = function (_) { };
2925
+ return FakeFinalizationRegistry;
2926
+ }(FinalizationRegistry));
2927
+ var MyFinalizationRegistry = FinalizationRegistry || FakeFinalizationRegistry;
2928
+ var finalizationRegistry = new MyFinalizationRegistry(function (ob) {
2929
+ ob.unref();
2930
+ });
2931
+
2932
+
2933
+
2670
2934
  /***/ })
2671
2935
  /******/ ]);
2672
2936
  /************************************************************************/
@@ -2744,6 +3008,7 @@ __webpack_require__.r(__webpack_exports__);
2744
3008
  /* harmony export */ Testing: () => (/* binding */ Testing),
2745
3009
  /* harmony export */ ViewModel: () => (/* binding */ ViewModel),
2746
3010
  /* harmony export */ ViewModelInstance: () => (/* binding */ ViewModelInstance),
3011
+ /* harmony export */ ViewModelInstanceAssetImage: () => (/* binding */ ViewModelInstanceAssetImage),
2747
3012
  /* harmony export */ ViewModelInstanceBoolean: () => (/* binding */ ViewModelInstanceBoolean),
2748
3013
  /* harmony export */ ViewModelInstanceColor: () => (/* binding */ ViewModelInstanceColor),
2749
3014
  /* harmony export */ ViewModelInstanceEnum: () => (/* binding */ ViewModelInstanceEnum),
@@ -3966,7 +4231,7 @@ var RiveFile = /** @class */ (function () {
3966
4231
  }
3967
4232
  RiveFile.prototype.initData = function () {
3968
4233
  return __awaiter(this, void 0, void 0, function () {
3969
- var _a, loader, _b;
4234
+ var _a, loader, loaderWrapper, _b;
3970
4235
  var _c;
3971
4236
  return __generator(this, function (_d) {
3972
4237
  switch (_d.label) {
@@ -3982,9 +4247,8 @@ var RiveFile = /** @class */ (function () {
3982
4247
  return [2 /*return*/];
3983
4248
  }
3984
4249
  if (this.assetLoader) {
3985
- loader = new this.runtime.CustomFileAssetLoader({
3986
- loadContents: this.assetLoader,
3987
- });
4250
+ loaderWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.CustomFileAssetLoaderWrapper(this.runtime, this.assetLoader);
4251
+ loader = loaderWrapper.assetLoader;
3988
4252
  }
3989
4253
  // Load the Rive file
3990
4254
  _b = this;
@@ -4283,7 +4547,11 @@ var Rive = /** @class */ (function () {
4283
4547
  }
4284
4548
  // Load Rive data from a source uri or a data buffer
4285
4549
  _this.initData(artboard, startingAnimationNames, startingStateMachineNames, autoplay, autoBind)
4286
- .then(function () { return _this.setupRiveListeners(); })
4550
+ .then(function (hasInitialized) {
4551
+ if (hasInitialized) {
4552
+ return _this.setupRiveListeners();
4553
+ }
4554
+ })
4287
4555
  .catch(function (e) {
4288
4556
  console.error(e);
4289
4557
  });
@@ -4362,7 +4630,8 @@ var Rive = /** @class */ (function () {
4362
4630
  this._artboardHeight = this.artboard.height =
4363
4631
  this._artboardHeight || this.artboard.height;
4364
4632
  };
4365
- // Initializes runtime with Rive data and preps for playing
4633
+ // Initializes runtime with Rive data and preps for playing.
4634
+ // Returns true for successful initialization.
4366
4635
  Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
4367
4636
  return __awaiter(this, void 0, void 0, function () {
4368
4637
  var error_1, msg;
@@ -4385,7 +4654,7 @@ var Rive = /** @class */ (function () {
4385
4654
  case 2:
4386
4655
  // Check for riveFile in case it has been cleaned up while initializing;
4387
4656
  if (!this.riveFile) {
4388
- throw new RiveError(Rive.cleanupErrorMessage);
4657
+ return [2 /*return*/, false];
4389
4658
  }
4390
4659
  this.file = this.riveFile.getInstance();
4391
4660
  // Initialize and draw frame
@@ -4405,7 +4674,7 @@ var Rive = /** @class */ (function () {
4405
4674
  this.readyForPlaying = true;
4406
4675
  this.taskQueue.process();
4407
4676
  this.drawFrame();
4408
- return [2 /*return*/, Promise.resolve()];
4677
+ return [2 /*return*/, true];
4409
4678
  case 3:
4410
4679
  error_1 = _b.sent();
4411
4680
  msg = resolveErrorMessage(error_1);
@@ -5623,6 +5892,7 @@ var PropertyType;
5623
5892
  PropertyType["Trigger"] = "trigger";
5624
5893
  PropertyType["Enum"] = "enum";
5625
5894
  PropertyType["List"] = "list";
5895
+ PropertyType["Image"] = "image";
5626
5896
  })(PropertyType || (PropertyType = {}));
5627
5897
  var ViewModelInstance = /** @class */ (function () {
5628
5898
  function ViewModelInstance(runtimeInstance, parent) {
@@ -5746,7 +6016,7 @@ var ViewModelInstance = /** @class */ (function () {
5746
6016
  return null;
5747
6017
  };
5748
6018
  ViewModelInstance.prototype.propertyFromPathSegments = function (pathSegments, index, type) {
5749
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
6019
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
5750
6020
  if (index < pathSegments.length - 1) {
5751
6021
  var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
5752
6022
  if (viewModelInstance !== null) {
@@ -5800,6 +6070,12 @@ var ViewModelInstance = /** @class */ (function () {
5800
6070
  return new ViewModelInstanceList(instance, this);
5801
6071
  }
5802
6072
  break;
6073
+ case PropertyType.Image:
6074
+ instance = (_r = (_q = this._runtimeInstance) === null || _q === void 0 ? void 0 : _q.image(pathSegments[index])) !== null && _r !== void 0 ? _r : null;
6075
+ if (instance !== null) {
6076
+ return new ViewModelInstanceAssetImage(instance, this);
6077
+ }
6078
+ break;
5803
6079
  }
5804
6080
  return null;
5805
6081
  };
@@ -5880,6 +6156,15 @@ var ViewModelInstance = /** @class */ (function () {
5880
6156
  var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.List);
5881
6157
  return viewmodelInstanceValue;
5882
6158
  };
6159
+ /**
6160
+ * method to access a view model property instance belonging
6161
+ * to the view model instance or to a nested view model instance
6162
+ * @param path - path to the image property
6163
+ */
6164
+ ViewModelInstance.prototype.image = function (path) {
6165
+ var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Image);
6166
+ return viewmodelInstanceValue;
6167
+ };
5883
6168
  /**
5884
6169
  * method to access a view model property instance belonging
5885
6170
  * to the view model instance or to a nested view model instance
@@ -6231,6 +6516,25 @@ var ViewModelInstanceColor = /** @class */ (function (_super) {
6231
6516
  return ViewModelInstanceColor;
6232
6517
  }(ViewModelInstanceValue));
6233
6518
 
6519
+ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
6520
+ __extends(ViewModelInstanceAssetImage, _super);
6521
+ function ViewModelInstanceAssetImage(instance, root) {
6522
+ return _super.call(this, instance, root) || this;
6523
+ }
6524
+ Object.defineProperty(ViewModelInstanceAssetImage.prototype, "value", {
6525
+ set: function (image) {
6526
+ this._viewModelInstanceValue.value =
6527
+ image.nativeImage;
6528
+ },
6529
+ enumerable: false,
6530
+ configurable: true
6531
+ });
6532
+ ViewModelInstanceAssetImage.prototype.internalHandleCallback = function (callback) {
6533
+ callback();
6534
+ };
6535
+ return ViewModelInstanceAssetImage;
6536
+ }(ViewModelInstanceValue));
6537
+
6234
6538
  // Loads Rive data from a URI via fetch.
6235
6539
  var loadRiveFile = function (src) { return __awaiter(void 0, void 0, void 0, function () {
6236
6540
  var req, res, buffer;
@@ -6278,39 +6582,75 @@ var Testing = {
6278
6582
  * Be sure to call `.unref()` on the audio once it is no longer needed. This
6279
6583
  * allows the engine to clean it up when it is not used by any more animations.
6280
6584
  */
6281
- var decodeAudio = function (bytes) {
6282
- return new Promise(function (resolve) {
6283
- return RuntimeLoader.getInstance(function (rive) {
6284
- rive.decodeAudio(bytes, resolve);
6285
- });
6585
+ var decodeAudio = function (bytes) { return __awaiter(void 0, void 0, void 0, function () {
6586
+ var decodedPromise, audio, audioWrapper;
6587
+ return __generator(this, function (_a) {
6588
+ switch (_a.label) {
6589
+ case 0:
6590
+ decodedPromise = new Promise(function (resolve) {
6591
+ return RuntimeLoader.getInstance(function (rive) {
6592
+ rive.decodeAudio(bytes, resolve);
6593
+ });
6594
+ });
6595
+ return [4 /*yield*/, decodedPromise];
6596
+ case 1:
6597
+ audio = _a.sent();
6598
+ audioWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.AudioWrapper(audio);
6599
+ _utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(audioWrapper, audio);
6600
+ return [2 /*return*/, audioWrapper];
6601
+ }
6286
6602
  });
6287
- };
6603
+ }); };
6288
6604
  /**
6289
6605
  * Decodes bytes into an image.
6290
6606
  *
6291
6607
  * Be sure to call `.unref()` on the image once it is no longer needed. This
6292
6608
  * allows the engine to clean it up when it is not used by any more animations.
6293
6609
  */
6294
- var decodeImage = function (bytes) {
6295
- return new Promise(function (resolve) {
6296
- return RuntimeLoader.getInstance(function (rive) {
6297
- rive.decodeImage(bytes, resolve);
6298
- });
6610
+ var decodeImage = function (bytes) { return __awaiter(void 0, void 0, void 0, function () {
6611
+ var decodedPromise, image, imageWrapper;
6612
+ return __generator(this, function (_a) {
6613
+ switch (_a.label) {
6614
+ case 0:
6615
+ decodedPromise = new Promise(function (resolve) {
6616
+ return RuntimeLoader.getInstance(function (rive) {
6617
+ rive.decodeImage(bytes, resolve);
6618
+ });
6619
+ });
6620
+ return [4 /*yield*/, decodedPromise];
6621
+ case 1:
6622
+ image = _a.sent();
6623
+ imageWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.ImageWrapper(image);
6624
+ _utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(imageWrapper, image);
6625
+ return [2 /*return*/, imageWrapper];
6626
+ }
6299
6627
  });
6300
- };
6628
+ }); };
6301
6629
  /**
6302
6630
  * Decodes bytes into a font.
6303
6631
  *
6304
6632
  * Be sure to call `.unref()` on the font once it is no longer needed. This
6305
6633
  * allows the engine to clean it up when it is not used by any more animations.
6306
6634
  */
6307
- var decodeFont = function (bytes) {
6308
- return new Promise(function (resolve) {
6309
- return RuntimeLoader.getInstance(function (rive) {
6310
- rive.decodeFont(bytes, resolve);
6311
- });
6635
+ var decodeFont = function (bytes) { return __awaiter(void 0, void 0, void 0, function () {
6636
+ var decodedPromise, font, fontWrapper;
6637
+ return __generator(this, function (_a) {
6638
+ switch (_a.label) {
6639
+ case 0:
6640
+ decodedPromise = new Promise(function (resolve) {
6641
+ return RuntimeLoader.getInstance(function (rive) {
6642
+ rive.decodeFont(bytes, resolve);
6643
+ });
6644
+ });
6645
+ return [4 /*yield*/, decodedPromise];
6646
+ case 1:
6647
+ font = _a.sent();
6648
+ fontWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.FontWrapper(font);
6649
+ _utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(fontWrapper, font);
6650
+ return [2 /*return*/, fontWrapper];
6651
+ }
6312
6652
  });
6313
- };
6653
+ }); };
6314
6654
  // #endregion
6315
6655
 
6316
6656
  })();