- Add 'withGlobalTauri: true' to tauri.conf.json — required for window.__TAURI__ to be available in vanilla JS (no npm bundler) - Replace top-level destructuring with lazy arrow functions to avoid TDZ errors before __TAURI__ is injected - Remove unused _router prefix to prevent potential early drop
- commit
- 16b51a4cfc09e3166ffb9561aee6d35cf82b5f63
- parent
- 933139c93e35300c66c07875f445a9211676e606
- author
- dami etoile <dami.etoile@gmail.com>
| M | src-tauri/ | 6 | +++--- |
| M | src-tauri/ | 3 | ++- |
| M | src/ | 7 | ++++--- |
@@ -183,13 +183,13 @@ pub async fn iroh_host_start(state: State<'_, AppState>) -> Result<HostStatus, S
183183 serde_json::to_string(&addr).map_err(|e| format!("Failed to serialize addr: {}", e))?;184184 185185 let handler = Arc::new(FrameStreamHandler);186- let _router = Router::builder(endpoint.clone())186+ let router = Router::builder(endpoint.clone())187187 .accept(ALPN, handler)188188 .spawn();189189 190- // Keep endpoint alive by leaking — MVP tradeoff190+ // Keep endpoint and router alive by leaking — MVP tradeoff191191 std::mem::forget(endpoint);192- std::mem::forget(_router);192+ std::mem::forget(router);193193 194194 let mut host = state.host.lock().map_err(|e| format!("Lock error: {}", e))?;195195 *host = Some(HostState {@@ -195,11 +195,12 @@
195195 </div>196196 197197 <script>198- const { invoke } = window.__TAURI__.core;199- const { listen } = window.__TAURI__.event;200-201198 let hostAddrJson = '';202199 200+ // Access Tauri API lazily — avoids TDZ errors if __TAURI__ isn't ready yet201+ const invoke = (...args) => window.__TAURI__.core.invoke(...args);202+ const listen = (...args) => window.__TAURI__.event.listen(...args);203+203204 // ─── FIDO2 ─────────────────────────────────────────────────────────204205 async function scanFido() {205206 const status = document.getElementById('fido-status');