Skip to content

Commit a6cd96e

Browse files
Verify version
1 parent 7c537f4 commit a6cd96e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

public/app.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ let wasm = null;
3434
let loadedImage = null;
3535
let renderToken = 0;
3636

37+
function urlWasmVersionnee() {
38+
try {
39+
if (typeof document.querySelector !== "function") return "hexagonify.wasm";
40+
const scriptCourant = document.querySelector('script[src*="app.js"]');
41+
if (!scriptCourant?.src) return "hexagonify.wasm";
42+
const urlScript = new URL(scriptCourant.src, window.location.href);
43+
const urlWasm = new URL("hexagonify.wasm", urlScript);
44+
if (urlScript.search) urlWasm.search = urlScript.search;
45+
return urlWasm.toString();
46+
} catch (err) {
47+
return "hexagonify.wasm";
48+
}
49+
}
50+
3751
function afficherOverlay(actif) {
3852
const overlay = document.getElementById("processing-overlay");
3953
if (overlay) overlay.classList.toggle("actif", actif);
@@ -43,7 +57,7 @@ async function chargerWasm() {
4357
const status = document.getElementById("wasm-status");
4458
const btnApply = document.getElementById("btn-apply");
4559
try {
46-
const response = await fetch("hexagonify.wasm");
60+
const response = await fetch(urlWasmVersionnee());
4761
if (!response.ok) throw new Error(`Fichier WASM indisponible (${response.status}).`);
4862
const bytes = await response.arrayBuffer();
4963
if (bytes.byteLength < 8) throw new Error("Fichier WASM vide ou tronque.");

0 commit comments

Comments
 (0)