From dc66ac993f6736694990cce46e3b2c5b664c70f7 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Thu, 18 Jun 2026 21:30:29 +0700 Subject: [PATCH] fix: use global Capacitor object to hide splash screen (no package import) Co-authored-by: shakespeare.diy --- src/main.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index 887f34f..8ce3ce7 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -8,11 +8,12 @@ import App from './App.tsx'; import './index.css'; // Hide Capacitor splash screen once JS is ready -// Must be called manually when autoHide: false (or as a safety net) +// Uses the global Capacitor object to avoid a hard dependency on the package if (typeof window !== 'undefined') { - import('@capacitor/splash-screen').then(({ SplashScreen }) => { - SplashScreen.hide().catch(() => {/* not in Capacitor context */}); - }).catch(() => {/* web build - no Capacitor */}); + const cap = (window as unknown as { Capacitor?: { Plugins?: { SplashScreen?: { hide: () => Promise } } } }).Capacitor; + if (cap?.Plugins?.SplashScreen) { + cap.Plugins.SplashScreen.hide().catch(() => {}); + } } // Outfit font for body text