From a50037e556ab1aa5dbc8a03ff84fbc645ffacec4 Mon Sep 17 00:00:00 2001 From: Aditya30ag Date: Fri, 11 Jul 2025 16:37:15 +0530 Subject: [PATCH 1/3] fix: update Tauri environment detection for v2 compatibility --- frontend/src/utils/tauriUtils.ts | 44 ++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/tauriUtils.ts b/frontend/src/utils/tauriUtils.ts index 9f95193c7..473c4e300 100644 --- a/frontend/src/utils/tauriUtils.ts +++ b/frontend/src/utils/tauriUtils.ts @@ -2,8 +2,48 @@ * Utility functions for Tauri environment detection */ +// Type declarations for Tauri window properties +declare global { + interface Window { + __TAURI_INTERNALS__?: unknown; + __TAURI__?: unknown; + isTauri?: boolean; + } +} + // Check if we're running in a Tauri environment export const isTauriEnvironment = (): boolean => { - // return typeof window !== 'undefined' && '__TAURI__' in window; - return true; + // Method 1: Use official Tauri API (recommended) + try { + // This is the official way to detect Tauri environment + // Available since Tauri 2.0.0-beta.9 + if (typeof window !== 'undefined' && window.isTauri) { + return true; + } + } catch (error) { + // Fallback to manual detection if official API fails + } + + // Method 2: Check for __TAURI_INTERNALS__ (Tauri v2 manual detection) + if (typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window) { + return true; + } + + // Method 3: Fallback to __TAURI__ for backward compatibility (requires withGlobalTauri: true) + if (typeof window !== 'undefined' && '__TAURI__' in window) { + return true; + } + + return false; +}; + +// Alternative: You can also use the official API directly +export const isTauriEnvironmentOfficial = async (): Promise => { + try { + const { isTauri } = await import('@tauri-apps/api/core'); + return isTauri(); + } catch (error) { + // Fallback if @tauri-apps/api is not available + return isTauriEnvironment(); + } }; From 5fff735ff3d7be1eb9243faa0038b25ef2db6b60 Mon Sep 17 00:00:00 2001 From: Aditya30ag Date: Fri, 11 Jul 2025 16:41:32 +0530 Subject: [PATCH 2/3] chore: fix formatting issues --- frontend/src/utils/tauriUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/tauriUtils.ts b/frontend/src/utils/tauriUtils.ts index 473c4e300..6d20108a6 100644 --- a/frontend/src/utils/tauriUtils.ts +++ b/frontend/src/utils/tauriUtils.ts @@ -28,12 +28,12 @@ export const isTauriEnvironment = (): boolean => { if (typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window) { return true; } - + // Method 3: Fallback to __TAURI__ for backward compatibility (requires withGlobalTauri: true) if (typeof window !== 'undefined' && '__TAURI__' in window) { return true; } - + return false; }; From 9432445b5459d13c1e24b47fb58a0960bc2ac4dc Mon Sep 17 00:00:00 2001 From: Rahul Harpal <51887323+rahulharpal1603@users.noreply.github.com> Date: Fri, 11 Jul 2025 19:25:16 +0530 Subject: [PATCH 3/3] Update tauriUtils.ts --- frontend/src/utils/tauriUtils.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/frontend/src/utils/tauriUtils.ts b/frontend/src/utils/tauriUtils.ts index 6d20108a6..4504a870d 100644 --- a/frontend/src/utils/tauriUtils.ts +++ b/frontend/src/utils/tauriUtils.ts @@ -36,14 +36,3 @@ export const isTauriEnvironment = (): boolean => { return false; }; - -// Alternative: You can also use the official API directly -export const isTauriEnvironmentOfficial = async (): Promise => { - try { - const { isTauri } = await import('@tauri-apps/api/core'); - return isTauri(); - } catch (error) { - // Fallback if @tauri-apps/api is not available - return isTauriEnvironment(); - } -};