@rive-app/canvas-lite 2.23.1 → 2.23.3

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.23.1",
3
+ "version": "2.23.3",
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
@@ -73,6 +73,7 @@ export declare class RuntimeLoader {
73
73
  static getInstance(callback: RuntimeCallback): void;
74
74
  static awaitInstance(): Promise<rc.RiveCanvas>;
75
75
  static setWasmUrl(url: string): void;
76
+ static getWasmUrl(): string;
76
77
  }
77
78
  export declare enum StateMachineInputType {
78
79
  Number = 56,
@@ -662,26 +663,26 @@ export declare class Rive {
662
663
  /**
663
664
  * The width of the artboard.
664
665
  *
665
- * This will return undefined if the artboard is not loaded yet and a custom
666
+ * This will return 0 if the artboard is not loaded yet and a custom
666
667
  * width has not been set.
667
668
  *
668
669
  * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
669
670
  * with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard width is
670
671
  * automatically set.
671
672
  */
672
- get artboardWidth(): number | undefined;
673
+ get artboardWidth(): number;
673
674
  set artboardWidth(value: number);
674
675
  /**
675
676
  * The height of the artboard.
676
677
  *
677
- * This will return undefined if the artboard is not loaded yet and a custom
678
+ * This will return 0 if the artboard is not loaded yet and a custom
678
679
  * height has not been set.
679
680
  *
680
681
  * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
681
682
  * with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard height is
682
683
  * automatically set.
683
684
  */
684
- get artboardHeight(): number | undefined;
685
+ get artboardHeight(): number;
685
686
  set artboardHeight(value: number);
686
687
  /**
687
688
  * Reset the artboard size to its original values.
package/rive.js CHANGED
@@ -2269,7 +2269,7 @@ Qc();
2269
2269
  /* 2 */
2270
2270
  /***/ ((module) => {
2271
2271
 
2272
- module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.23.1","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}}');
2272
+ module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.23.3","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}}');
2273
2273
 
2274
2274
  /***/ }),
2275
2275
  /* 3 */
@@ -2934,20 +2934,44 @@ var RuntimeLoader = /** @class */ (function () {
2934
2934
  (_a = RuntimeLoader.callBackQueue.shift()) === null || _a === void 0 ? void 0 : _a(RuntimeLoader.runtime);
2935
2935
  }
2936
2936
  })
2937
- .catch(function () {
2937
+ .catch(function (error) {
2938
+ // Capture specific error details
2939
+ var errorDetails = {
2940
+ message: (error === null || error === void 0 ? void 0 : error.message) || "Unknown error",
2941
+ type: (error === null || error === void 0 ? void 0 : error.name) || "Error",
2942
+ // Some browsers may provide additional WebAssembly-specific details
2943
+ wasmError: error instanceof WebAssembly.CompileError ||
2944
+ error instanceof WebAssembly.RuntimeError,
2945
+ originalError: error,
2946
+ };
2947
+ // Log detailed error for debugging
2948
+ console.debug("Rive WASM load error details:", errorDetails);
2938
2949
  // In case unpkg fails, or the wasm was not supported, we try to load the fallback module from jsdelivr.
2939
2950
  // This `rive_fallback.wasm` is compiled to support older architecture.
2940
2951
  // TODO: (Gordon): preemptively test browser support and load the correct wasm file. Then use jsdelvr only if unpkg fails.
2941
2952
  var backupJsdelivrUrl = "https://cdn.jsdelivr.net/npm/".concat(package_json__WEBPACK_IMPORTED_MODULE_1__.name, "@").concat(package_json__WEBPACK_IMPORTED_MODULE_1__.version, "/rive_fallback.wasm");
2942
2953
  if (RuntimeLoader.wasmURL.toLowerCase() !== backupJsdelivrUrl) {
2943
- console.warn("Failed to load WASM from ".concat(RuntimeLoader.wasmURL, ", trying jsdelivr as a backup"));
2954
+ console.warn("Failed to load WASM from ".concat(RuntimeLoader.wasmURL, " (").concat(errorDetails.message, "), trying jsdelivr as a backup"));
2944
2955
  RuntimeLoader.setWasmUrl(backupJsdelivrUrl);
2945
2956
  RuntimeLoader.loadRuntime();
2946
2957
  }
2947
2958
  else {
2948
- console.error("Could not load Rive WASM file from unpkg or jsdelivr, network connection may be down, or \
2949
- you may need to call set a new WASM source via RuntimeLoader.setWasmUrl() and call \
2950
- RuntimeLoader.loadRuntime() again");
2959
+ var errorMessage = [
2960
+ "Could not load Rive WASM file from ".concat(RuntimeLoader.wasmURL, " or ").concat(backupJsdelivrUrl, "."),
2961
+ "Possible reasons:",
2962
+ "- Network connection is down",
2963
+ "- WebAssembly is not supported in this environment",
2964
+ "- The WASM file is corrupted or incompatible",
2965
+ "\nError details:",
2966
+ "- Type: ".concat(errorDetails.type),
2967
+ "- Message: ".concat(errorDetails.message),
2968
+ "- WebAssembly-specific error: ".concat(errorDetails.wasmError),
2969
+ "\nTo resolve, you may need to:",
2970
+ "1. Check your network connection",
2971
+ "2. Set a new WASM source via RuntimeLoader.setWasmUrl()",
2972
+ "3. Call RuntimeLoader.loadRuntime() again",
2973
+ ].join("\n");
2974
+ console.error(errorMessage);
2951
2975
  }
2952
2976
  });
2953
2977
  };
@@ -2975,6 +2999,10 @@ var RuntimeLoader = /** @class */ (function () {
2975
2999
  RuntimeLoader.setWasmUrl = function (url) {
2976
3000
  RuntimeLoader.wasmURL = url;
2977
3001
  };
3002
+ // Gets the current wasm url
3003
+ RuntimeLoader.getWasmUrl = function () {
3004
+ return RuntimeLoader.wasmURL;
3005
+ };
2978
3006
  // Flag to indicate that loading has started/completed
2979
3007
  RuntimeLoader.isLoading = false;
2980
3008
  // List of callbacks for the runtime that come in while loading
@@ -5181,7 +5209,7 @@ var Rive = /** @class */ (function () {
5181
5209
  /**
5182
5210
  * The width of the artboard.
5183
5211
  *
5184
- * This will return undefined if the artboard is not loaded yet and a custom
5212
+ * This will return 0 if the artboard is not loaded yet and a custom
5185
5213
  * width has not been set.
5186
5214
  *
5187
5215
  * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
@@ -5189,10 +5217,11 @@ var Rive = /** @class */ (function () {
5189
5217
  * automatically set.
5190
5218
  */
5191
5219
  get: function () {
5220
+ var _a;
5192
5221
  if (this.artboard) {
5193
5222
  return this.artboard.width;
5194
5223
  }
5195
- return this._artboardWidth;
5224
+ return (_a = this._artboardWidth) !== null && _a !== void 0 ? _a : 0;
5196
5225
  },
5197
5226
  set: function (value) {
5198
5227
  this._artboardWidth = value;
@@ -5207,7 +5236,7 @@ var Rive = /** @class */ (function () {
5207
5236
  /**
5208
5237
  * The height of the artboard.
5209
5238
  *
5210
- * This will return undefined if the artboard is not loaded yet and a custom
5239
+ * This will return 0 if the artboard is not loaded yet and a custom
5211
5240
  * height has not been set.
5212
5241
  *
5213
5242
  * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
@@ -5215,10 +5244,11 @@ var Rive = /** @class */ (function () {
5215
5244
  * automatically set.
5216
5245
  */
5217
5246
  get: function () {
5247
+ var _a;
5218
5248
  if (this.artboard) {
5219
5249
  return this.artboard.height;
5220
5250
  }
5221
- return this._artboardHeight;
5251
+ return (_a = this._artboardHeight) !== null && _a !== void 0 ? _a : 0;
5222
5252
  },
5223
5253
  set: function (value) {
5224
5254
  this._artboardHeight = value;