Fix loading analyzer and bust caches

This commit is contained in:
momo5502
2025-07-09 19:09:16 +02:00
parent b7dc284a9d
commit 7f15b42d18
3 changed files with 18 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ onmessage = async (event) => {
payload.options,
payload.persist,
payload.wasm64,
payload.cacheBuster,
);
break;
case "event":
@@ -70,12 +71,19 @@ function getMessageFromQueue() {
return msgQueue.shift();
}
function runEmulation(file, options, persist, wasm64) {
function runEmulation(file, options, persist, wasm64, cacheBuster) {
const mainArguments = [...options, "-e", "./root", file];
globalThis.Module = {
arguments: mainArguments,
noInitialRun: true,
locateFile: (path, scriptDirectory) => {
console.log(path);
console.log(scriptDirectory);
const bitness = wasm64 ? "64" : "32";
return `${scriptDirectory}${bitness}/${path}?${cacheBuster}`;
},
onRuntimeInitialized: function () {
FS.mkdir("/root");
FS.mount(IDBFS, {}, "/root");
@@ -93,8 +101,8 @@ function runEmulation(file, options, persist, wasm64) {
};
if (wasm64) {
importScripts("./64/analyzer.js");
importScripts("./64/analyzer.js?" + cacheBuster);
} else {
importScripts("./32/analyzer.js");
importScripts("./32/analyzer.js?" + cacheBuster);
}
}

View File

@@ -76,8 +76,11 @@ export class Emulator {
this.terminateReject = reject;
});
const cacheBuster = import.meta.env.VITE_BUILD_TIME || Date.now();
this.worker = new Worker(
/*new URL('./emulator-worker.js', import.meta.url)*/ "./emulator-worker.js",
/*new URL('./emulator-worker.js', import.meta.url)*/ "./emulator-worker.js?" +
cacheBuster,
);
this.worker.onerror = this._onError.bind(this);
@@ -93,6 +96,7 @@ export class Emulator {
options: translateSettings(settings),
persist: settings.persist,
wasm64: settings.wasm64,
cacheBuster: import.meta.env.VITE_BUILD_TIME || Date.now(),
},
});
}

View File

@@ -98,7 +98,9 @@ export class Playground extends React.Component<
application: undefined,
allowWasm64: false,
};
}
componentDidMount(): void {
memory64().then((allowWasm64) => {
this.setState({ allowWasm64 });
});