Skip to content

Commit f09ccb8

Browse files
committed
fix(wasm): update generateWasmConfig to return an empty config when not using file object/webgpu
1 parent ef5379f commit f09ccb8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/wasmLoader.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,32 @@ function isSameConfig(a, b) {
3535
return a.rendering === b.rendering && a.exec === b.exec;
3636
}
3737

38+
/**
39+
* Generate a WebAssembly configuration object from a wasmLoader config.
40+
* @param {*} config - wasmLoader config with 'rendering' and 'exec' keys.
41+
* @returns wasmConfig object
42+
*/
3843
export function generateWasmConfig(config) {
44+
let wasmConfig = {}
3945
if (WASM_FILE_OBJECT) {
40-
config.locateFile = (fileName) => {
46+
wasmConfig.locateFile = (fileName) => {
4147
if (WASM_FILE_OBJECT && fileName == WASM_FILE_OBJECT.name) {
4248
return URL.createObjectURL(WASM_FILE_OBJECT);
4349
}
4450
return new URL(fileName, import.meta.url).href;
4551
};
46-
config.onRuntimeInitialized = () => {
52+
wasmConfig.onRuntimeInitialized = () => {
4753
// Free the object URL after runtime is initialized
4854
URL.revokeObjectURL(WASM_FILE_OBJECT);
4955
WASM_FILE_OBJECT = null;
5056
};
5157
}
5258
if (config?.rendering === "webgpu") {
53-
config.preRun = [(module) => {
59+
wasmConfig.preRun = [(module) => {
5460
module.ENV.VTK_GRAPHICS_BACKEND = "WEBGPU";
5561
}];
5662
}
57-
return config;
63+
return wasmConfig;
5864
}
5965

6066
/**

0 commit comments

Comments
 (0)