@rive-app/canvas 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",
3
- "version": "2.23.1",
3
+ "version": "2.23.3",
4
4
  "description": "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
@@ -746,7 +746,7 @@ function Ya(a, b) {
746
746
  return Xa(c, a, b);
747
747
  }));
748
748
  }
749
- var Za, $a, db = {441740:(a, b, c, d, e) => {
749
+ var Za, $a, db = {441900:(a, b, c, d, e) => {
750
750
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
751
751
  return 0;
752
752
  }
@@ -809,9 +809,9 @@ var Za, $a, db = {441740:(a, b, c, d, e) => {
809
809
  }
810
810
  window.h.Aa += 1;
811
811
  return 1;
812
- }, 443918:() => {
812
+ }, 444078:() => {
813
813
  "undefined" !== typeof window.h && (--window.h.Aa, 0 === window.h.Aa && delete window.h);
814
- }, 444082:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 444186:() => {
814
+ }, 444242:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 444346:() => {
815
815
  try {
816
816
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
817
817
  a.close();
@@ -819,7 +819,7 @@ var Za, $a, db = {441740:(a, b, c, d, e) => {
819
819
  } catch (c) {
820
820
  return 0;
821
821
  }
822
- }, 444357:(a, b, c, d, e, f) => {
822
+ }, 444517:(a, b, c, d, e, f) => {
823
823
  if ("undefined" === typeof window.h) {
824
824
  return -1;
825
825
  }
@@ -865,7 +865,7 @@ var Za, $a, db = {441740:(a, b, c, d, e) => {
865
865
  a == window.h.I.ya && g.Z.connect(g.J.destination);
866
866
  g.pb = f;
867
867
  return window.h.yc(g);
868
- }, 447234:a => window.h.ra(a).J.sampleRate, 447307:a => {
868
+ }, 447394:a => window.h.ra(a).J.sampleRate, 447467:a => {
869
869
  a = window.h.ra(a);
870
870
  void 0 !== a.Z && (a.Z.onaudioprocess = function() {
871
871
  }, a.Z.disconnect(), a.Z = void 0);
@@ -873,13 +873,13 @@ var Za, $a, db = {441740:(a, b, c, d, e) => {
873
873
  a.J.close();
874
874
  a.J = void 0;
875
875
  a.pb = void 0;
876
- }, 447707:a => {
876
+ }, 447867:a => {
877
877
  window.h.Cb(a);
878
- }, 447757:a => {
878
+ }, 447917:a => {
879
879
  a = window.h.ra(a);
880
880
  a.J.resume();
881
881
  a.state = window.h.ga.xb;
882
- }, 447896:a => {
882
+ }, 448056:a => {
883
883
  a = window.h.ra(a);
884
884
  a.J.suspend();
885
885
  a.state = window.h.ga.stopped;
@@ -3365,7 +3365,7 @@ $d();
3365
3365
  /* 2 */
3366
3366
  /***/ ((module) => {
3367
3367
 
3368
- module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.23.1","description":"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}}');
3368
+ module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.23.3","description":"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}}');
3369
3369
 
3370
3370
  /***/ }),
3371
3371
  /* 3 */
@@ -4030,20 +4030,44 @@ var RuntimeLoader = /** @class */ (function () {
4030
4030
  (_a = RuntimeLoader.callBackQueue.shift()) === null || _a === void 0 ? void 0 : _a(RuntimeLoader.runtime);
4031
4031
  }
4032
4032
  })
4033
- .catch(function () {
4033
+ .catch(function (error) {
4034
+ // Capture specific error details
4035
+ var errorDetails = {
4036
+ message: (error === null || error === void 0 ? void 0 : error.message) || "Unknown error",
4037
+ type: (error === null || error === void 0 ? void 0 : error.name) || "Error",
4038
+ // Some browsers may provide additional WebAssembly-specific details
4039
+ wasmError: error instanceof WebAssembly.CompileError ||
4040
+ error instanceof WebAssembly.RuntimeError,
4041
+ originalError: error,
4042
+ };
4043
+ // Log detailed error for debugging
4044
+ console.debug("Rive WASM load error details:", errorDetails);
4034
4045
  // In case unpkg fails, or the wasm was not supported, we try to load the fallback module from jsdelivr.
4035
4046
  // This `rive_fallback.wasm` is compiled to support older architecture.
4036
4047
  // TODO: (Gordon): preemptively test browser support and load the correct wasm file. Then use jsdelvr only if unpkg fails.
4037
4048
  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");
4038
4049
  if (RuntimeLoader.wasmURL.toLowerCase() !== backupJsdelivrUrl) {
4039
- console.warn("Failed to load WASM from ".concat(RuntimeLoader.wasmURL, ", trying jsdelivr as a backup"));
4050
+ console.warn("Failed to load WASM from ".concat(RuntimeLoader.wasmURL, " (").concat(errorDetails.message, "), trying jsdelivr as a backup"));
4040
4051
  RuntimeLoader.setWasmUrl(backupJsdelivrUrl);
4041
4052
  RuntimeLoader.loadRuntime();
4042
4053
  }
4043
4054
  else {
4044
- console.error("Could not load Rive WASM file from unpkg or jsdelivr, network connection may be down, or \
4045
- you may need to call set a new WASM source via RuntimeLoader.setWasmUrl() and call \
4046
- RuntimeLoader.loadRuntime() again");
4055
+ var errorMessage = [
4056
+ "Could not load Rive WASM file from ".concat(RuntimeLoader.wasmURL, " or ").concat(backupJsdelivrUrl, "."),
4057
+ "Possible reasons:",
4058
+ "- Network connection is down",
4059
+ "- WebAssembly is not supported in this environment",
4060
+ "- The WASM file is corrupted or incompatible",
4061
+ "\nError details:",
4062
+ "- Type: ".concat(errorDetails.type),
4063
+ "- Message: ".concat(errorDetails.message),
4064
+ "- WebAssembly-specific error: ".concat(errorDetails.wasmError),
4065
+ "\nTo resolve, you may need to:",
4066
+ "1. Check your network connection",
4067
+ "2. Set a new WASM source via RuntimeLoader.setWasmUrl()",
4068
+ "3. Call RuntimeLoader.loadRuntime() again",
4069
+ ].join("\n");
4070
+ console.error(errorMessage);
4047
4071
  }
4048
4072
  });
4049
4073
  };
@@ -4071,6 +4095,10 @@ var RuntimeLoader = /** @class */ (function () {
4071
4095
  RuntimeLoader.setWasmUrl = function (url) {
4072
4096
  RuntimeLoader.wasmURL = url;
4073
4097
  };
4098
+ // Gets the current wasm url
4099
+ RuntimeLoader.getWasmUrl = function () {
4100
+ return RuntimeLoader.wasmURL;
4101
+ };
4074
4102
  // Flag to indicate that loading has started/completed
4075
4103
  RuntimeLoader.isLoading = false;
4076
4104
  // List of callbacks for the runtime that come in while loading
@@ -6277,7 +6305,7 @@ var Rive = /** @class */ (function () {
6277
6305
  /**
6278
6306
  * The width of the artboard.
6279
6307
  *
6280
- * This will return undefined if the artboard is not loaded yet and a custom
6308
+ * This will return 0 if the artboard is not loaded yet and a custom
6281
6309
  * width has not been set.
6282
6310
  *
6283
6311
  * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
@@ -6285,10 +6313,11 @@ var Rive = /** @class */ (function () {
6285
6313
  * automatically set.
6286
6314
  */
6287
6315
  get: function () {
6316
+ var _a;
6288
6317
  if (this.artboard) {
6289
6318
  return this.artboard.width;
6290
6319
  }
6291
- return this._artboardWidth;
6320
+ return (_a = this._artboardWidth) !== null && _a !== void 0 ? _a : 0;
6292
6321
  },
6293
6322
  set: function (value) {
6294
6323
  this._artboardWidth = value;
@@ -6303,7 +6332,7 @@ var Rive = /** @class */ (function () {
6303
6332
  /**
6304
6333
  * The height of the artboard.
6305
6334
  *
6306
- * This will return undefined if the artboard is not loaded yet and a custom
6335
+ * This will return 0 if the artboard is not loaded yet and a custom
6307
6336
  * height has not been set.
6308
6337
  *
6309
6338
  * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
@@ -6311,10 +6340,11 @@ var Rive = /** @class */ (function () {
6311
6340
  * automatically set.
6312
6341
  */
6313
6342
  get: function () {
6343
+ var _a;
6314
6344
  if (this.artboard) {
6315
6345
  return this.artboard.height;
6316
6346
  }
6317
- return this._artboardHeight;
6347
+ return (_a = this._artboardHeight) !== null && _a !== void 0 ? _a : 0;
6318
6348
  },
6319
6349
  set: function (value) {
6320
6350
  this._artboardHeight = value;