fix wasm path passing
This commit is contained in:
parent
c08d830127
commit
80f72d0a7f
@ -8,8 +8,11 @@ var performance = {
|
||||
Module['instantiateWasm'] = (info, receiveInstance) => {
|
||||
console.log("loading wasm...", info);
|
||||
|
||||
// Use provided wasmPath parameter, fallback to hardcoded path
|
||||
var wasmPath = Module.wasmFilePath || "pages/emblemscanner/qrtool.wx.wasm.br";
|
||||
// Use global wasmFilePath (should always be set by the main app)
|
||||
var wasmPath = global.wasmFilePath;
|
||||
if (!wasmPath) {
|
||||
throw new Error("wasmFilePath must be provided via global.wasmFilePath");
|
||||
}
|
||||
console.log("Using WASM path:", wasmPath);
|
||||
|
||||
WebAssembly.instantiate(wasmPath, info).then((result) => {
|
||||
|
||||
@ -164,6 +164,7 @@ function get_current_package_path() {
|
||||
*/
|
||||
function get_wasm_file_path(filename) {
|
||||
const packagePath = get_current_package_path();
|
||||
console.log('current package path', packagePath);
|
||||
return `${packagePath}/${filename}`;
|
||||
}
|
||||
|
||||
|
||||
@ -8,12 +8,12 @@ var qrtool_ready = false;
|
||||
* Load qrtool WASM module
|
||||
*/
|
||||
function load_qrtool(wasmFilePath) {
|
||||
// Set global WASM file path before loading the module
|
||||
global.wasmFilePath = wasmFilePath;
|
||||
|
||||
// Load the WASM module
|
||||
var m = require('./qrtool.wx.js');
|
||||
|
||||
// Set the WASM file path
|
||||
m.wasmFilePath = wasmFilePath;
|
||||
|
||||
m.onRuntimeInitialized = () => {
|
||||
qrtool_ready = true;
|
||||
qrtool = m;
|
||||
|
||||
@ -34,8 +34,11 @@ var performance = {
|
||||
};
|
||||
Module["instantiateWasm"] = (info, receiveInstance) => {
|
||||
console.log("loading wasm...", info);
|
||||
// Use provided wasmPath parameter, fallback to hardcoded path
|
||||
var wasmPath = Module.wasmFilePath || "pages/emblemscanner/qrtool.wx.wasm.br";
|
||||
// Use global wasmFilePath (should always be set by the main app)
|
||||
var wasmPath = global.wasmFilePath;
|
||||
if (!wasmPath) {
|
||||
throw new Error("wasmFilePath must be provided via global.wasmFilePath");
|
||||
}
|
||||
console.log("Using WASM path:", wasmPath);
|
||||
WebAssembly.instantiate(wasmPath, info).then(result => {
|
||||
console.log("result:", result);
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
console.log("hello from emblemscanner worker");
|
||||
|
||||
// Set WASM file path before loading qrtool
|
||||
// Set global WASM file path before loading qrtool
|
||||
// The wasmFilePath will be passed from the main thread when the worker is created
|
||||
if (typeof worker !== "undefined" && worker.wasmFilePath) {
|
||||
let qrtoolModule = require('./qrtool.wx.js');
|
||||
qrtoolModule.wasmFilePath = worker.wasmFilePath;
|
||||
let qrtool = qrtoolModule;
|
||||
global.wasmFilePath = worker.wasmFilePath;
|
||||
let qrtool = require('./qrtool.wx.js');
|
||||
} else {
|
||||
let qrtool = require('./qrtool.wx.js');
|
||||
}
|
||||
|
||||
@ -34,8 +34,11 @@ var performance = {
|
||||
};
|
||||
Module["instantiateWasm"] = (info, receiveInstance) => {
|
||||
console.log("loading wasm...", info);
|
||||
// Use provided wasmPath parameter, fallback to hardcoded path
|
||||
var wasmPath = Module.wasmFilePath || "pages/emblemscanner/qrtool.wx.wasm.br";
|
||||
// Use global wasmFilePath (should always be set by the main app)
|
||||
var wasmPath = global.wasmFilePath;
|
||||
if (!wasmPath) {
|
||||
throw new Error("wasmFilePath must be provided via global.wasmFilePath");
|
||||
}
|
||||
console.log("Using WASM path:", wasmPath);
|
||||
WebAssembly.instantiate(wasmPath, info).then(result => {
|
||||
console.log("result:", result);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user