@rive-app/canvas-lite 2.52.0 → 2.54.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 +1 -1
- package/rive.d.ts +2 -2
- package/rive.js +65 -23
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_fallback.wasm +0 -0
- package/runtimeLoader.d.ts +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rive-app/canvas-lite",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.54.0",
|
|
4
4
|
"description": "Rive web runtime, lite version, canvas renderer. Rive is an agent-native 2D and 3D engine for games, apps, and interactive UI.",
|
|
5
5
|
"main": "rive.js",
|
|
6
6
|
"homepage": "https://rive.app",
|
package/rive.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as rc from "./rive_advanced.mjs";
|
|
2
|
-
import { RuntimeLoader, type RuntimeCallback, type ScriptFetchOptions } from "./runtimeLoader";
|
|
2
|
+
import { RuntimeLoader, type RuntimeCallback, type ScriptFetchOptions, type ThreadsRefusal } from "./runtimeLoader";
|
|
3
3
|
import { SemanticTreeModel, AccessibilityOverlay, SemanticMode, type RiveSemanticsOptions } from "./semantics";
|
|
4
4
|
import { ImageWrapper, AudioWrapper, FontWrapper, RiveFont as RiveFontClassUtil } from "./utils";
|
|
5
5
|
export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) => boolean;
|
|
@@ -97,7 +97,7 @@ export declare class Layout {
|
|
|
97
97
|
runtimeFit(rive: rc.RiveCanvas): rc.Fit;
|
|
98
98
|
runtimeAlignment(rive: rc.RiveCanvas): rc.Alignment;
|
|
99
99
|
}
|
|
100
|
-
export { RuntimeLoader, type RuntimeCallback, type ScriptFetchOptions };
|
|
100
|
+
export { RuntimeLoader, type RuntimeCallback, type ScriptFetchOptions, type ThreadsRefusal, };
|
|
101
101
|
/**
|
|
102
102
|
* @deprecated State machine inputs are deprecated and will be removed in a
|
|
103
103
|
* future major version: please use data binding properties instead. See
|
package/rive.js
CHANGED
|
@@ -190,20 +190,30 @@ var threadsProbe = new Uint8Array([
|
|
|
190
190
|
0x02, 0x00, 0x0b, 0x14, 0x00, 0xfd, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
191
191
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b,
|
|
192
192
|
]);
|
|
193
|
-
//
|
|
194
|
-
//
|
|
195
|
-
|
|
193
|
+
// Words for the refusals the loader warns about when it decides; the
|
|
194
|
+
// package's and host's choices stay silent.
|
|
195
|
+
var pageRefusalWords = {
|
|
196
|
+
notIsolated: "the page is not cross origin isolated",
|
|
197
|
+
isolationUnsupported: "the page is not cross origin isolated",
|
|
198
|
+
noSharedMemory: "the page cannot share memory with workers",
|
|
199
|
+
noWasmThreads: "the browser cannot run wasm threads with SIMD",
|
|
200
|
+
};
|
|
201
|
+
// A page that is not isolated gets no shared memory, and the threaded build
|
|
202
|
+
// never loads.
|
|
203
|
+
function pageThreadsRefusal() {
|
|
196
204
|
if (globalThis.crossOriginIsolated !== true) {
|
|
197
|
-
return
|
|
205
|
+
return globalThis.crossOriginIsolated === undefined
|
|
206
|
+
? "isolationUnsupported"
|
|
207
|
+
: "notIsolated";
|
|
198
208
|
}
|
|
199
209
|
try {
|
|
200
210
|
new MessageChannel().port1.postMessage(new SharedArrayBuffer(1));
|
|
201
211
|
}
|
|
202
212
|
catch (_a) {
|
|
203
|
-
return "
|
|
213
|
+
return "noSharedMemory";
|
|
204
214
|
}
|
|
205
|
-
if (!WebAssembly.validate(threadsProbe)) {
|
|
206
|
-
return "
|
|
215
|
+
if (typeof WebAssembly !== "object" || !WebAssembly.validate(threadsProbe)) {
|
|
216
|
+
return "noWasmThreads";
|
|
207
217
|
}
|
|
208
218
|
return null;
|
|
209
219
|
}
|
|
@@ -264,6 +274,10 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
264
274
|
RuntimeLoader.notifyError = function (error) {
|
|
265
275
|
var _a;
|
|
266
276
|
RuntimeLoader.isLoading = false;
|
|
277
|
+
// The retry decides again, so the answer follows the settings until then.
|
|
278
|
+
if (!RuntimeLoader.triedThreads) {
|
|
279
|
+
RuntimeLoader.threadsOutcome = undefined;
|
|
280
|
+
}
|
|
267
281
|
while (RuntimeLoader.errorCallbackQueue.length > 0) {
|
|
268
282
|
(_a = RuntimeLoader.errorCallbackQueue.shift()) === null || _a === void 0 ? void 0 : _a(error);
|
|
269
283
|
}
|
|
@@ -318,34 +332,51 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
318
332
|
// Loads the runtime, threaded once per page where it can be, and otherwise
|
|
319
333
|
// without threads.
|
|
320
334
|
RuntimeLoader.loadRuntime = function () {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
335
|
+
if (RuntimeLoader.triedThreads) {
|
|
336
|
+
RuntimeLoader.loadUnthreaded();
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
var refusal = RuntimeLoader.decideThreads();
|
|
340
|
+
RuntimeLoader.threadsOutcome = refusal;
|
|
341
|
+
var words = refusal && pageRefusalWords[refusal];
|
|
342
|
+
// A package's or host's choice stays silent, and a retry decides again.
|
|
343
|
+
if (refusal !== null && !words) {
|
|
330
344
|
RuntimeLoader.loadUnthreaded();
|
|
331
345
|
return;
|
|
332
346
|
}
|
|
333
347
|
RuntimeLoader.triedThreads = true;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
console.warn("Rive is running without threads: ".concat(refusal, "."));
|
|
348
|
+
if (words) {
|
|
349
|
+
console.warn("Rive is running without threads: ".concat(words, "."));
|
|
337
350
|
RuntimeLoader.loadUnthreaded();
|
|
338
351
|
return;
|
|
339
352
|
}
|
|
353
|
+
var threadsUrl = RuntimeLoader.wasmThreadsURL;
|
|
340
354
|
if (RuntimeLoader.enablePerfMarks)
|
|
341
355
|
performance.mark('rive:wasm-init:start');
|
|
342
356
|
// Not a catch, which would also take a throw from a callback.
|
|
343
|
-
|
|
357
|
+
_rive_threads_mjs__WEBPACK_IMPORTED_MODULE_1___default()({ locateFile: function () { return threadsUrl; } }).then(RuntimeLoader.loaded, function (error) {
|
|
344
358
|
var _a;
|
|
359
|
+
RuntimeLoader.threadsOutcome = "loadFailed";
|
|
345
360
|
console.warn("Rive is running without threads: the threaded build failed to load (".concat((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error, ")."));
|
|
346
361
|
RuntimeLoader.loadUnthreaded();
|
|
347
362
|
});
|
|
348
363
|
};
|
|
364
|
+
// Shared by the loader and threadsRefusal, so the two never disagree.
|
|
365
|
+
RuntimeLoader.decideThreads = function () {
|
|
366
|
+
// Other packages bundle an empty module here, which webpack's interop
|
|
367
|
+
// hands over as an object rather than undefined.
|
|
368
|
+
if (typeof (_rive_threads_mjs__WEBPACK_IMPORTED_MODULE_1___default()) !== "function") {
|
|
369
|
+
return "noThreadedBuild";
|
|
370
|
+
}
|
|
371
|
+
if (RuntimeLoader.wasmThreadsURL === null) {
|
|
372
|
+
return "threadsOff";
|
|
373
|
+
}
|
|
374
|
+
// A host's own binary is a build without threads.
|
|
375
|
+
if (RuntimeLoader.wasmBinary !== null) {
|
|
376
|
+
return "wasmBinary";
|
|
377
|
+
}
|
|
378
|
+
return pageThreadsRefusal();
|
|
379
|
+
};
|
|
349
380
|
RuntimeLoader.loadUnthreaded = function () {
|
|
350
381
|
// Capture the URL at call time so the catch closure always refers to the
|
|
351
382
|
// URL this particular attempt used, even if wasmURL is mutated for a retry.
|
|
@@ -363,8 +394,9 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
363
394
|
message: (error === null || error === void 0 ? void 0 : error.message) || "Unknown error",
|
|
364
395
|
type: (error === null || error === void 0 ? void 0 : error.name) || "Error",
|
|
365
396
|
// Some browsers may provide additional WebAssembly-specific details
|
|
366
|
-
wasmError:
|
|
367
|
-
error instanceof WebAssembly.
|
|
397
|
+
wasmError: typeof WebAssembly !== "undefined" &&
|
|
398
|
+
(error instanceof WebAssembly.CompileError ||
|
|
399
|
+
error instanceof WebAssembly.RuntimeError),
|
|
368
400
|
originalError: error,
|
|
369
401
|
};
|
|
370
402
|
// Log detailed error for debugging
|
|
@@ -493,6 +525,16 @@ var RuntimeLoader = /** @class */ (function () {
|
|
|
493
525
|
RuntimeLoader.getWasmThreadsUrl = function () {
|
|
494
526
|
return RuntimeLoader.wasmThreadsURL;
|
|
495
527
|
};
|
|
528
|
+
/**
|
|
529
|
+
* @experimental Why this page doesn't run the threaded build, or null when
|
|
530
|
+
* it does. Before load, what the loader would do with the current settings;
|
|
531
|
+
* after, what it did. Never loads or logs.
|
|
532
|
+
*/
|
|
533
|
+
RuntimeLoader.threadsRefusal = function () {
|
|
534
|
+
return RuntimeLoader.threadsOutcome === undefined
|
|
535
|
+
? RuntimeLoader.decideThreads()
|
|
536
|
+
: RuntimeLoader.threadsOutcome;
|
|
537
|
+
};
|
|
496
538
|
/**
|
|
497
539
|
* Sets how many parts a script's parallel call gets on a page that runs
|
|
498
540
|
* the threaded build, the page's thread and one worker thread for each
|
|
@@ -801,7 +843,7 @@ Lc=await (async function(){function b(c){c=Lc=c.exports;pb=c.free;Jc=c.malloc;ob
|
|
|
801
843
|
/***/ ((module) => {
|
|
802
844
|
|
|
803
845
|
"use strict";
|
|
804
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.
|
|
846
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.54.0","description":"Rive web runtime, lite version, canvas renderer. Rive is an agent-native 2D and 3D engine for games, apps, and interactive UI.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation","interactive","ui","game-engine","graphics"],"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","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
805
847
|
|
|
806
848
|
/***/ }),
|
|
807
849
|
/* 7 */
|