diff --git a/js/src/rive.ts b/js/src/rive.ts index 90b45447..89ec12e0 100644 --- a/js/src/rive.ts +++ b/js/src/rive.ts @@ -222,6 +222,8 @@ export class RuntimeLoader { // if embedded wasm is used then this is never used. private static wasmURL = `https://unpkg.com/${packageData.name}@${packageData.version}/rive.wasm`; + private static wasmBinary: ArrayBuffer; + // Class is never instantiated private constructor() {} @@ -230,6 +232,7 @@ export class RuntimeLoader { rc.default({ // Loads Wasm bundle locateFile: () => RuntimeLoader.wasmURL, + wasmBinary: RuntimeLoader.wasmBinary }) .then((rive: rc.RiveCanvas) => { RuntimeLoader.runtime = rive; @@ -315,6 +318,15 @@ export class RuntimeLoader { public static getWasmUrl(): string { return RuntimeLoader.wasmURL; } + // Manually sets the wasm binary + public static setWasmBinary(ab: ArrayBuffer): void { + RuntimeLoader.wasmBinary = ab; + } + + // Gets the current wasm url + public static getWasmBinary(): ArrayBuffer { + return RuntimeLoader.wasmBinary; + } } // #endregion diff --git a/js/src/rive_advanced.mjs.d.ts b/js/src/rive_advanced.mjs.d.ts index 6ae26014..4d7bb140 100644 --- a/js/src/rive_advanced.mjs.d.ts +++ b/js/src/rive_advanced.mjs.d.ts @@ -1,5 +1,6 @@ interface RiveOptions { locateFile(file: string): string; + wasmBinary?: ArrayBuffer; } declare function Rive(options?: RiveOptions): Promise;