From 130cb7055a2a79d8367cedd7f2ca800c1a505e20 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 25 Oct 2025 01:28:19 -0500 Subject: [PATCH] Remove isElectron --- electron/electron.d.ts | 6 ------ electron/preload.js | 3 --- src/App.tsx | 4 ++-- src/AppRouter.tsx | 2 +- src/main.tsx | 2 +- 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/electron/electron.d.ts b/electron/electron.d.ts index 8532e71b..ef41da91 100644 --- a/electron/electron.d.ts +++ b/electron/electron.d.ts @@ -60,12 +60,6 @@ interface ElectronShellAPI { } interface ElectronAPI { - /** - * Flag indicating the app is running in Electron. - * Always `true` when running in Electron. - */ - isElectron: boolean; - /** * Get the current platform. * @returns 'darwin' | 'win32' | 'linux' diff --git a/electron/preload.js b/electron/preload.js index 5bd6d124..dd554c3c 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -9,9 +9,6 @@ contextBridge.exposeInMainWorld('electron', { // App version version: () => ipcRenderer.invoke('get-app-version'), - // Flag to indicate we're running in Electron - isElectron: true, - // Filesystem API - paths support tilde (~) expansion for home directory fs: { readFile: (path, encoding) => ipcRenderer.invoke('fs:readFile', path, encoding), diff --git a/src/App.tsx b/src/App.tsx index dfbf4af6..ec3e5f97 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -44,7 +44,7 @@ const queryClient = new QueryClient({ // Get OS-specific default paths for Electron function getElectronDefaultPaths(): { fsPathProjects: string; fsPathConfig: string; fsPathTmp: string } { - if (!window.electron?.isElectron) { + if (!globalThis.electron) { // Browser defaults - use virtual filesystem paths return { fsPathProjects: "/projects", @@ -109,7 +109,7 @@ const presetRelays = [ // Initialize filesystem adapter based on environment // In Electron, use Electron filesystem at ~/shakespeare // In browser, use LightningFS (IndexedDB-backed virtual filesystem) -const fs = window.electron?.isElectron +const fs = globalThis.electron ? new ElectronFSAdapter() : new LightningFSAdapter(new LightningFS('shakespeare-fs').promises); diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index 508f767c..34ac7607 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -25,7 +25,7 @@ import { SettingsLayout } from "./components/SettingsLayout"; export function AppRouter() { // Use HashRouter in Electron, BrowserRouter in web - const Router = window.electron?.isElectron ? HashRouter : BrowserRouter; + const Router = globalThis.electron ? HashRouter : BrowserRouter; return ( diff --git a/src/main.tsx b/src/main.tsx index c6d8fdb0..ea3bcd1a 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -18,7 +18,7 @@ import 'prismjs/themes/prism.css'; createRoot(document.getElementById("root")!).render(); // Register service worker (skip in Electron - doesn't work with file:// protocol) -if ('serviceWorker' in navigator && !window.electron?.isElectron) { +if ('serviceWorker' in navigator && !globalThis.electron) { window.addEventListener('load', () => { navigator.serviceWorker .register('/sw.js')