@rive-app/canvas 2.37.0 → 2.37.2
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 +4 -2
- package/rive.d.ts +2 -2
- package/rive.js +75 -20
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +1 -0
- package/rive_fallback.wasm +0 -0
- package/runtimeLoader.d.ts +32 -0
- package/utils/finalizationRegistry.d.ts +94 -0
- package/utils/index.d.ts +4 -0
- package/utils/registerTouchInteractions.d.ts +19 -0
- package/utils/riveFont.d.ts +15 -0
- package/utils/sanitizeUrl.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rive-app/canvas",
|
|
3
|
-
"version": "2.37.
|
|
3
|
+
"version": "2.37.2",
|
|
4
4
|
"description": "Rive's canvas based web api.",
|
|
5
5
|
"main": "rive.js",
|
|
6
6
|
"homepage": "https://rive.app",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"rive.wasm",
|
|
28
28
|
"rive_fallback.wasm",
|
|
29
29
|
"rive.d.ts",
|
|
30
|
-
"rive_advanced.mjs.d.ts"
|
|
30
|
+
"rive_advanced.mjs.d.ts",
|
|
31
|
+
"runtimeLoader.d.ts",
|
|
32
|
+
"utils"
|
|
31
33
|
],
|
|
32
34
|
"typings": "rive.d.ts",
|
|
33
35
|
"dependencies": {},
|
package/rive.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as rc from "./rive_advanced.mjs";
|
|
2
2
|
import { RuntimeLoader, type RuntimeCallback } from "./runtimeLoader";
|
|
3
3
|
import { ImageWrapper, AudioWrapper, FontWrapper, RiveFont as RiveFontClassUtil } from "./utils";
|
|
4
|
-
export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) =>
|
|
4
|
+
export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) => boolean;
|
|
5
5
|
export { RiveFontClassUtil as RiveFont };
|
|
6
6
|
export type { FileAsset, AudioAsset, FontAsset, ImageAsset, } from "./rive_advanced.mjs";
|
|
7
7
|
/**
|
|
@@ -285,7 +285,7 @@ export interface RiveParameters {
|
|
|
285
285
|
*/
|
|
286
286
|
onloaderror?: EventCallback;
|
|
287
287
|
/**
|
|
288
|
-
* @deprecated Use `
|
|
288
|
+
* @deprecated Use `onPlay()` instead
|
|
289
289
|
*/
|
|
290
290
|
onplay?: EventCallback;
|
|
291
291
|
/**
|
package/rive.js
CHANGED
|
@@ -155,6 +155,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
155
155
|
/* harmony export */ });
|
|
156
156
|
/* harmony import */ var _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
|
|
157
157
|
/* harmony import */ var package_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
|
|
158
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
159
|
+
__assign = Object.assign || function(t) {
|
|
160
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
161
|
+
s = arguments[i];
|
|
162
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
163
|
+
t[p] = s[p];
|
|
164
|
+
}
|
|
165
|
+
return t;
|
|
166
|
+
};
|
|
167
|
+
return __assign.apply(this, arguments);
|
|
168
|
+
};
|
|
158
169
|
|
|
159
170
|
|
|
160
171
|
// Runtime singleton; use getInstance to provide a callback that returns the
|
|
@@ -165,12 +176,15 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
165
176
|
}
|
|
166
177
|
// Loads the runtime
|
|
167
178
|
RuntimeLoader.loadRuntime = function () {
|
|
179
|
+
// Capture the URL at call time so the catch closure always refers to the
|
|
180
|
+
// URL this particular attempt used, even if wasmURL is mutated for a retry.
|
|
181
|
+
var attemptedUrl = RuntimeLoader.wasmURL;
|
|
182
|
+
var wasmBinary = RuntimeLoader.wasmBinary;
|
|
168
183
|
if (RuntimeLoader.enablePerfMarks)
|
|
169
184
|
performance.mark('rive:wasm-init:start');
|
|
170
|
-
_rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__["default"]({
|
|
185
|
+
_rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__["default"](__assign({
|
|
171
186
|
// Loads Wasm bundle
|
|
172
|
-
locateFile: function () { return
|
|
173
|
-
})
|
|
187
|
+
locateFile: function () { return attemptedUrl; } }, (wasmBinary ? { wasmBinary: wasmBinary } : {})))
|
|
174
188
|
.then(function (rive) {
|
|
175
189
|
var _a;
|
|
176
190
|
if (RuntimeLoader.enablePerfMarks) {
|
|
@@ -195,18 +209,30 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
195
209
|
};
|
|
196
210
|
// Log detailed error for debugging
|
|
197
211
|
console.debug("Rive WASM load error details:", errorDetails);
|
|
198
|
-
// In case
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
212
|
+
// In case the primary URL fails, or the wasm was not supported, try the
|
|
213
|
+
// fallback URL (a rive_fallback.wasm compiled for older architectures).
|
|
214
|
+
// The fallback can be customised or disabled via setWasmFallbackUrl().
|
|
215
|
+
// TODO: (Gordon): preemptively test browser support and load the correct wasm file. Then use the fallback only if the primary fails.
|
|
216
|
+
var fallbackUrl = RuntimeLoader.wasmFallbackURL;
|
|
217
|
+
var alreadyOnFallback = fallbackUrl !== null &&
|
|
218
|
+
attemptedUrl.toLowerCase() === fallbackUrl.toLowerCase();
|
|
219
|
+
if (fallbackUrl !== null && !alreadyOnFallback) {
|
|
220
|
+
console.warn("Failed to load WASM from ".concat(attemptedUrl, " (").concat(errorDetails.message, "), trying fallback URL: ").concat(fallbackUrl));
|
|
221
|
+
// Clear wasmBinary so the retry actually fetches via locateFile
|
|
222
|
+
// instead of re-using the same (failing) in-memory binary.
|
|
223
|
+
RuntimeLoader.wasmBinary = null;
|
|
224
|
+
RuntimeLoader.setWasmUrl(fallbackUrl);
|
|
205
225
|
RuntimeLoader.loadRuntime();
|
|
206
226
|
}
|
|
207
227
|
else {
|
|
228
|
+
// When alreadyOnFallback is true, wasmURL has already been overwritten
|
|
229
|
+
// with the fallback URL, so we can no longer recover the original
|
|
230
|
+
// primary URL here. The primary URL was logged in the earlier warning.
|
|
231
|
+
var triedUrls = alreadyOnFallback
|
|
232
|
+
? "the configured WASM URL or its fallback (".concat(fallbackUrl, ")")
|
|
233
|
+
: attemptedUrl;
|
|
208
234
|
var errorMessage = [
|
|
209
|
-
"Could not load Rive WASM file from ".concat(
|
|
235
|
+
"Could not load Rive WASM file from ".concat(triedUrls, "."),
|
|
210
236
|
"Possible reasons:",
|
|
211
237
|
"- Network connection is down",
|
|
212
238
|
"- WebAssembly is not supported in this environment",
|
|
@@ -252,6 +278,31 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
252
278
|
RuntimeLoader.getWasmUrl = function () {
|
|
253
279
|
return RuntimeLoader.wasmURL;
|
|
254
280
|
};
|
|
281
|
+
/**
|
|
282
|
+
* Sets the URL used as a fallback when the primary WASM URL fails to load.
|
|
283
|
+
* Pass `null` to disable the fallback entirely.
|
|
284
|
+
*
|
|
285
|
+
* Defaults to pulling from the jsdelivr CDN.
|
|
286
|
+
*/
|
|
287
|
+
RuntimeLoader.setWasmFallbackUrl = function (url) {
|
|
288
|
+
RuntimeLoader.wasmFallbackURL = url;
|
|
289
|
+
};
|
|
290
|
+
// Gets the current fallback wasm url (null means fallback is disabled)
|
|
291
|
+
RuntimeLoader.getWasmFallbackUrl = function () {
|
|
292
|
+
return RuntimeLoader.wasmFallbackURL;
|
|
293
|
+
};
|
|
294
|
+
// Manually sets the wasm binary or clears it with null
|
|
295
|
+
RuntimeLoader.setWasmBinary = function (value) {
|
|
296
|
+
if ((value instanceof ArrayBuffer) || value === null) {
|
|
297
|
+
RuntimeLoader.wasmBinary = value;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
console.error("setWasmBinary expects an ArrayBuffer or null");
|
|
301
|
+
};
|
|
302
|
+
// Gets the current wasm build as ArrayBuffer or null
|
|
303
|
+
RuntimeLoader.getWasmBinary = function () {
|
|
304
|
+
return RuntimeLoader.wasmBinary;
|
|
305
|
+
};
|
|
255
306
|
// Flag to indicate that loading has started/completed
|
|
256
307
|
RuntimeLoader.isLoading = false;
|
|
257
308
|
// List of callbacks for the runtime that come in while loading
|
|
@@ -259,6 +310,10 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
259
310
|
// Path to the Wasm file; default path works for testing only;
|
|
260
311
|
// if embedded wasm is used then this is never used.
|
|
261
312
|
RuntimeLoader.wasmURL = "https://unpkg.com/".concat(package_json__WEBPACK_IMPORTED_MODULE_1__.name, "@").concat(package_json__WEBPACK_IMPORTED_MODULE_1__.version, "/rive.wasm");
|
|
313
|
+
// Fallback WASM URL tried when the primary URL fails. Set to null to disable
|
|
314
|
+
// the fallback entirely. Defaults to pulling from the jsdelivr CDN.
|
|
315
|
+
RuntimeLoader.wasmFallbackURL = "https://cdn.jsdelivr.net/npm/".concat(package_json__WEBPACK_IMPORTED_MODULE_1__.name, "@").concat(package_json__WEBPACK_IMPORTED_MODULE_1__.version, "/rive_fallback.wasm");
|
|
316
|
+
RuntimeLoader.wasmBinary = null;
|
|
262
317
|
/**
|
|
263
318
|
* When true, performance.mark / performance.measure entries are emitted for
|
|
264
319
|
* WASM initialization.
|
|
@@ -1012,7 +1067,7 @@ function Za(a, b) {
|
|
|
1012
1067
|
return Ya(c, a, b);
|
|
1013
1068
|
}));
|
|
1014
1069
|
}
|
|
1015
|
-
var $a, ab, eb = {
|
|
1070
|
+
var $a, ab, eb = {480002:(a, b, c, d, e) => {
|
|
1016
1071
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
1017
1072
|
return 0;
|
|
1018
1073
|
}
|
|
@@ -1075,11 +1130,11 @@ var $a, ab, eb = {479682:(a, b, c, d, e) => {
|
|
|
1075
1130
|
}
|
|
1076
1131
|
window.h.za += 1;
|
|
1077
1132
|
return 1;
|
|
1078
|
-
},
|
|
1133
|
+
}, 482180:() => {
|
|
1079
1134
|
"undefined" !== typeof window.h && (window.h.Sa.map(function(a) {
|
|
1080
1135
|
document.removeEventListener(a, window.h.unlock, !0);
|
|
1081
1136
|
}), --window.h.za, 0 === window.h.za && delete window.h);
|
|
1082
|
-
},
|
|
1137
|
+
}, 482484:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 482588:() => {
|
|
1083
1138
|
try {
|
|
1084
1139
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
1085
1140
|
a.close();
|
|
@@ -1087,7 +1142,7 @@ var $a, ab, eb = {479682:(a, b, c, d, e) => {
|
|
|
1087
1142
|
} catch (c) {
|
|
1088
1143
|
return 0;
|
|
1089
1144
|
}
|
|
1090
|
-
},
|
|
1145
|
+
}, 482759:(a, b, c, d, e, f) => {
|
|
1091
1146
|
if ("undefined" === typeof window.h) {
|
|
1092
1147
|
return -1;
|
|
1093
1148
|
}
|
|
@@ -1133,7 +1188,7 @@ var $a, ab, eb = {479682:(a, b, c, d, e) => {
|
|
|
1133
1188
|
a == window.h.J.xa && g.Z.connect(g.L.destination);
|
|
1134
1189
|
g.pb = f;
|
|
1135
1190
|
return window.h.sc(g);
|
|
1136
|
-
},
|
|
1191
|
+
}, 485636:a => window.h.qa(a).L.sampleRate, 485709:a => {
|
|
1137
1192
|
a = window.h.qa(a);
|
|
1138
1193
|
void 0 !== a.Z && (a.Z.onaudioprocess = function() {
|
|
1139
1194
|
}, a.Z.disconnect(), a.Z = void 0);
|
|
@@ -1141,13 +1196,13 @@ var $a, ab, eb = {479682:(a, b, c, d, e) => {
|
|
|
1141
1196
|
a.L.close();
|
|
1142
1197
|
a.L = void 0;
|
|
1143
1198
|
a.pb = void 0;
|
|
1144
|
-
},
|
|
1199
|
+
}, 486109:a => {
|
|
1145
1200
|
window.h.Ab(a);
|
|
1146
|
-
},
|
|
1201
|
+
}, 486159:a => {
|
|
1147
1202
|
a = window.h.qa(a);
|
|
1148
1203
|
a.L.resume();
|
|
1149
1204
|
a.state = window.h.ga.wb;
|
|
1150
|
-
},
|
|
1205
|
+
}, 486298:a => {
|
|
1151
1206
|
a = window.h.qa(a);
|
|
1152
1207
|
a.L.suspend();
|
|
1153
1208
|
a.state = window.h.ga.stopped;
|
|
@@ -3659,7 +3714,7 @@ moduleRtn = ea;
|
|
|
3659
3714
|
/* 5 */
|
|
3660
3715
|
/***/ ((module) => {
|
|
3661
3716
|
|
|
3662
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.37.
|
|
3717
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.37.2","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","runtimeLoader.d.ts","utils"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3663
3718
|
|
|
3664
3719
|
/***/ }),
|
|
3665
3720
|
/* 6 */
|