Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions js/src/rive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions js/src/rive_advanced.mjs.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
interface RiveOptions {
locateFile(file: string): string;
wasmBinary?: ArrayBuffer;
}

declare function Rive(options?: RiveOptions): Promise<RiveCanvas>;
Expand Down