Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add Rust Core init preload (#1473)
Leendert de Borst98869eaf2c5d
diff --git a/apps/server/AliasVault.Client/wwwroot/index.template.html b/apps/server/AliasVault.Client/wwwroot/index.template.htmlindex cddfdabb3..ec6620ef4 100644--- a/apps/server/AliasVault.Client/wwwroot/index.template.html+++ b/apps/server/AliasVault.Client/wwwroot/index.template.html@@ -32,8 +32,8 @@<link rel="apple-touch-icon" sizes="500x500" href="img/icon-500.png" /><link rel="apple-touch-icon" sizes="192x192" href="img/icon-192.png" /><!-- Preload Rust WASM module for faster initialization -->- <link rel="preload" href="/wasm/aliasvault_core_bg.wasm" as="fetch" type="application/wasm" crossorigin />- <link rel="modulepreload" href="/wasm/aliasvault_core.js" />+ <link rel="preload" href="/wasm/aliasvault_core_bg.wasm?v=@CacheBuster" as="fetch" type="application/wasm" crossorigin />+ <link rel="modulepreload" href="/wasm/aliasvault_core.js?v=@CacheBuster" /></head><body class="bg-gray-100 dark:bg-gray-900" av-disable="true">@@ -336,6 +336,7 @@};</script>+ <script>window.__CACHE_BUSTER__ = '@CacheBuster';</script><script src="js/crypto.js?v=@CacheBuster" async></script><script src="js/utilities.js?v=@CacheBuster" async></script><script src="js/rustCoreInterop.js?v=@CacheBuster"></script>diff --git a/apps/server/AliasVault.Client/wwwroot/js/rustCoreInterop.js b/apps/server/AliasVault.Client/wwwroot/js/rustCoreInterop.jsindex 17d39fd3c..7cf0337bf 100644--- a/apps/server/AliasVault.Client/wwwroot/js/rustCoreInterop.js+++ b/apps/server/AliasVault.Client/wwwroot/js/rustCoreInterop.js@@ -6,6 +6,11 @@ let wasmModule = null;let isInitialized = false;let initPromise = null;+// Get cache buster from global variable set by index.html+const cacheBuster = window.__CACHE_BUSTER__ || 'dev';+const wasmUrl = `/wasm/aliasvault_core_bg.wasm?v=${cacheBuster}`;+const wasmJsUrl = `/wasm/aliasvault_core.js?v=${cacheBuster}`;+/*** Fetch with retry for more robust WASM loading.* @param {string} url - URL to fetch.@@ -50,12 +55,12 @@ async function initRustCore() {initPromise = (async () => {try {- // Fetch the WASM binary with retry- const wasmResponse = await fetchWithRetry('/wasm/aliasvault_core_bg.wasm');+ // Fetch the WASM binary with retry (uses same URL as preload hint for cache hit)+ const wasmResponse = await fetchWithRetry(wasmUrl);const wasmBytes = await wasmResponse.arrayBuffer();- // Dynamically import the ES module- const module = await import('/wasm/aliasvault_core.js');+ // Dynamically import the ES module (uses same URL as modulepreload hint)+ const module = await import(wasmJsUrl);// Initialize the WASM module with the binary bytesawait module.default(wasmBytes);