From 31af44c92a4a1686ba78afbe9e4f26a57a9b8956 Mon Sep 17 00:00:00 2001 From: Esteban Galvis Date: Thu, 2 Apr 2026 12:24:20 -0500 Subject: [PATCH] feat: remove non-Linux system references and clean up platform-specific code --- .erb/scripts/electron-rebuild.js | 13 ++-- assets/entitlements.mac.plist | 10 --- knip.json | 2 +- package-lock.json | 71 ------------------- package.json | 1 - src/apps/main/interface.d.ts | 6 ++ src/apps/main/platform/DesktopPlatform.ts | 1 - src/apps/main/platform/handlers.ts | 22 ++---- src/apps/main/preload.d.ts | 1 - src/apps/main/preload.js | 3 - src/apps/main/windows/auth.ts | 3 +- src/apps/main/windows/onboarding.ts | 3 +- src/apps/main/windows/process-issues.ts | 3 +- src/apps/main/windows/settings.ts | 3 +- src/apps/renderer/components/WindowTopBar.tsx | 21 +++--- src/apps/renderer/hooks/ClientPlatform.tsx | 13 ---- src/apps/renderer/localize/locales/en.json | 6 +- src/apps/renderer/localize/locales/es.json | 6 +- src/apps/renderer/localize/locales/fr.json | 6 +- .../renderer/pages/Onboarding/helpers.tsx | 1 - src/apps/renderer/pages/Onboarding/index.tsx | 14 ++-- .../pages/Onboarding/slides/drive-slide.tsx | 2 +- .../slides/onboarding-completed-slide.tsx | 2 +- .../application/PlatformPathConverter.test.ts | 18 ----- .../application/PlatformPathConverter.ts | 26 ------- 25 files changed, 40 insertions(+), 217 deletions(-) delete mode 100644 assets/entitlements.mac.plist delete mode 100644 src/apps/main/platform/DesktopPlatform.ts delete mode 100644 src/apps/renderer/hooks/ClientPlatform.tsx delete mode 100644 src/context/virtual-drive/shared/application/PlatformPathConverter.test.ts delete mode 100644 src/context/virtual-drive/shared/application/PlatformPathConverter.ts diff --git a/.erb/scripts/electron-rebuild.js b/.erb/scripts/electron-rebuild.js index 4f715f1f60..11e819578b 100644 --- a/.erb/scripts/electron-rebuild.js +++ b/.erb/scripts/electron-rebuild.js @@ -8,14 +8,11 @@ if ( Object.keys(dependencies || {}).length > 0 && fs.existsSync(path.join(webpackPaths.rootPath, 'node_modules')) ) { - const electronRebuildCmd = - './node_modules/.bin/electron-rebuild --sequential --force --types prod,dev,optional --module-dir .'; - const cmd = - process.platform === 'win32' - ? electronRebuildCmd.replace(/\//g, '\\') - : electronRebuildCmd; - execSync(cmd, { + execSync( + './node_modules/.bin/electron-rebuild --sequential --force --types prod,dev,optional --module-dir .', + { cwd: webpackPaths.rootPath, stdio: 'inherit', - }); + } + ); } diff --git a/assets/entitlements.mac.plist b/assets/entitlements.mac.plist deleted file mode 100644 index dad3e20e6a..0000000000 --- a/assets/entitlements.mac.plist +++ /dev/null @@ -1,10 +0,0 @@ - - - - - com.apple.security.cs.allow-unsigned-executable-memory - - com.apple.security.cs.allow-jit - - - diff --git a/knip.json b/knip.json index 871eb93f28..683d35d97a 100644 --- a/knip.json +++ b/knip.json @@ -4,7 +4,7 @@ "ignore": ["**/*.test.{ts,tsx}"], "ignoreBinaries": ["esbuild"], "ignoreExportsUsedInFile": true, - "project": ["src/**/*.{ts,tsx}"], + "project": ["src/**/*.{ts,tsx}", "!src/**/*.test.{ts,tsx}"], "vitest": false, "webpack": false, "rules": { diff --git a/package-lock.json b/package-lock.json index c93c0bc4f3..1c5c284a83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,6 @@ "@types/async": "^3.2.16", "@types/bytes": "^3.1.1", "@types/chance": "^1.1.3", - "@types/crypto-js": "^4.2.0", "@types/dotenv-webpack": "^7.0.3", "@types/jsonwebtoken": "^9.0.2", "@types/lodash": "^4.14.178", @@ -69,7 +68,6 @@ "concurrently": "^6.5.1", "core-js": "^3.20.1", "cross-env": "^7.0.3", - "crypto-js": "4.2.0", "css-loader": "^6.5.1", "css-minimizer-webpack-plugin": "^3.3.1", "dayjs": "^1.10.7", @@ -80,7 +78,6 @@ "electron-builder": "^23.6.0", "electron-debug": "^3.2.0", "electron-fetch": "^1.9.1", - "electron-notarize": "^1.1.1", "electron-rebuild": "^3.2.9", "electron-store": "^8.0.1", "eslint": "^8.5.0", @@ -6235,13 +6232,6 @@ "@types/node": "*" } }, - "node_modules/@types/crypto-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.2.tgz", - "integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/debug": { "version": "4.1.12", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", @@ -9832,13 +9822,6 @@ "node": ">= 8" } }, - "node_modules/crypto-js": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", - "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", - "dev": true, - "license": "MIT" - }, "node_modules/css-declaration-sorter": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz", @@ -11229,60 +11212,6 @@ "keyboardevents-areequal": "^0.2.1" } }, - "node_modules/electron-notarize": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-1.2.2.tgz", - "integrity": "sha512-ZStVWYcWI7g87/PgjPJSIIhwQXOaw4/XeXU+pWqMMktSLHaGMLHdyPPN7Cmao7+Cr7fYufA16npdtMndYciHNw==", - "deprecated": "Please use @electron/notarize moving forward. There is no API change, just a package name change", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.1.1", - "fs-extra": "^9.0.1" - }, - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/electron-notarize/node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/electron-notarize/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/electron-notarize/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/electron-osx-sign": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/electron-osx-sign/-/electron-osx-sign-0.6.0.tgz", diff --git a/package.json b/package.json index c67f23b62d..08466c3c27 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,6 @@ "electron-builder": "^23.6.0", "electron-debug": "^3.2.0", "electron-fetch": "^1.9.1", - "electron-notarize": "^1.1.1", "electron-rebuild": "^3.2.9", "electron-store": "^8.0.1", "eslint": "^8.5.0", diff --git a/src/apps/main/interface.d.ts b/src/apps/main/interface.d.ts index 9b59155dea..b81919f479 100644 --- a/src/apps/main/interface.d.ts +++ b/src/apps/main/interface.d.ts @@ -47,6 +47,8 @@ export interface IElectronAPI { abortDownloadBackups: (deviceId: string) => void; + addBackupsFromLocalPaths: (folderPaths: string[]) => Promise; + renameDevice: (deviceName: string) => Promise; devices: { getDevices: () => Promise>; @@ -64,6 +66,10 @@ export interface IElectronAPI { onUserLoggedInChanged(func: (value: boolean) => void): void; + closeWindow(): void; + + minimizeWindow(): void; + onRemoteChanges(func: (value: import('../main/realtime').EventPayload) => void): () => void; openVirtualDriveFolder(): Promise; diff --git a/src/apps/main/platform/DesktopPlatform.ts b/src/apps/main/platform/DesktopPlatform.ts deleted file mode 100644 index 1b83ebb8ad..0000000000 --- a/src/apps/main/platform/DesktopPlatform.ts +++ /dev/null @@ -1 +0,0 @@ -export type DesktopPlatform = 'linux' | 'win32' | 'darwin'; diff --git a/src/apps/main/platform/handlers.ts b/src/apps/main/platform/handlers.ts index 50ee9084b5..8c77004496 100644 --- a/src/apps/main/platform/handlers.ts +++ b/src/apps/main/platform/handlers.ts @@ -1,22 +1,12 @@ -import { ipcMain, shell } from 'electron'; +import { ipcMain } from 'electron'; import { exec } from 'child_process'; -ipcMain.handle('get-platform', () => { - return process.platform; -}); - ipcMain.handle('open-url', (_, url: string) => { - if (process.platform === 'linux') { - // shell.openExternal is not working as intended on the current verions of electron - // this is only a workaround to fix it - return new Promise((resolve, reject) => { - exec(`xdg-open ${url} &`, (error) => { - if (error) reject(error); + return new Promise((resolve, reject) => { + exec(`xdg-open ${url} &`, (error) => { + if (error) reject(error); - resolve(); - }); + resolve(); }); - } - - return shell.openExternal(url); + }); }); diff --git a/src/apps/main/preload.d.ts b/src/apps/main/preload.d.ts index 11a06ee726..98b674af70 100644 --- a/src/apps/main/preload.d.ts +++ b/src/apps/main/preload.d.ts @@ -143,7 +143,6 @@ declare interface Window { getUsage: () => Promise; - getPlatform: () => Promise; onRemoteSyncStatusChange(callback: (status: import('./remote-sync/helpers').RemoteSyncStatus) => void): () => void; getRemoteSyncStatus(): Promise; getVirtualDriveStatus(): Promise; diff --git a/src/apps/main/preload.js b/src/apps/main/preload.js index a4f3965764..208b601da9 100644 --- a/src/apps/main/preload.js +++ b/src/apps/main/preload.js @@ -239,9 +239,6 @@ contextBridge.exposeInMainWorld('electron', { getUsage() { return ipcRenderer.invoke('get-usage'); }, - getPlatform() { - return ipcRenderer.invoke('get-platform'); - }, resizeWindow(dimensions) { return ipcRenderer.invoke('resize-focused-window', dimensions); }, diff --git a/src/apps/main/windows/auth.ts b/src/apps/main/windows/auth.ts index e4b119adc4..ee1fc8df63 100644 --- a/src/apps/main/windows/auth.ts +++ b/src/apps/main/windows/auth.ts @@ -27,8 +27,7 @@ export const createAuthWindow = async () => { nodeIntegration: true, devTools: isDev(), }, - titleBarStyle: process.platform === 'darwin' ? 'hidden' : undefined, - frame: process.platform !== 'darwin' ? false : undefined, + frame: false, resizable: false, maximizable: false, skipTaskbar: true, diff --git a/src/apps/main/windows/onboarding.ts b/src/apps/main/windows/onboarding.ts index dd678b0b03..23b34d4d65 100644 --- a/src/apps/main/windows/onboarding.ts +++ b/src/apps/main/windows/onboarding.ts @@ -26,8 +26,7 @@ export const openOnboardingWindow = () => { nodeIntegration: true, devTools: isDev(), }, - titleBarStyle: process.platform === 'darwin' ? 'hidden' : undefined, - frame: process.platform !== 'darwin' ? false : undefined, + frame: false, resizable: false, maximizable: false, }); diff --git a/src/apps/main/windows/process-issues.ts b/src/apps/main/windows/process-issues.ts index f6262ded9d..1fd640cdc6 100644 --- a/src/apps/main/windows/process-issues.ts +++ b/src/apps/main/windows/process-issues.ts @@ -30,8 +30,7 @@ async function openProcessIssuesWindow() { nodeIntegration: true, devTools: isDev(), }, - titleBarStyle: process.platform === 'darwin' ? 'hidden' : undefined, - frame: process.platform !== 'darwin' ? false : undefined, + frame: false, resizable: false, maximizable: false, }); diff --git a/src/apps/main/windows/settings.ts b/src/apps/main/windows/settings.ts index 36178bf562..a7842a70b9 100644 --- a/src/apps/main/windows/settings.ts +++ b/src/apps/main/windows/settings.ts @@ -35,8 +35,7 @@ async function openSettingsWindow(section?: string) { nodeIntegration: true, devTools: isDev(), }, - titleBarStyle: process.platform === 'darwin' ? 'hidden' : undefined, - frame: process.platform !== 'darwin' ? false : undefined, + frame: false, resizable: false, maximizable: false, }); diff --git a/src/apps/renderer/components/WindowTopBar.tsx b/src/apps/renderer/components/WindowTopBar.tsx index 72b6e6c9d8..c18d78c075 100644 --- a/src/apps/renderer/components/WindowTopBar.tsx +++ b/src/apps/renderer/components/WindowTopBar.tsx @@ -2,19 +2,14 @@ import { X } from '@phosphor-icons/react'; export default function WindowTopBar({ title, className }: { title: string; className?: string }) { return ( -
- {process.env.platform !== 'darwin' && ( -
- -
- )} +
+
+ +

diff --git a/src/apps/renderer/hooks/ClientPlatform.tsx b/src/apps/renderer/hooks/ClientPlatform.tsx deleted file mode 100644 index 1f7e7336c2..0000000000 --- a/src/apps/renderer/hooks/ClientPlatform.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { useEffect, useState } from 'react'; - -import { DesktopPlatform } from '../../main/platform/DesktopPlatform'; - -export default function useClientPlatform(): DesktopPlatform | undefined { - const [clientPlatform, setPlatform] = useState(); - - useEffect(() => { - window.electron.getPlatform().then(setPlatform); - }, []); - - return clientPlatform; -} diff --git a/src/apps/renderer/localize/locales/en.json b/src/apps/renderer/localize/locales/en.json index fc2e29ea8d..a8cc8c16c9 100644 --- a/src/apps/renderer/localize/locales/en.json +++ b/src/apps/renderer/localize/locales/en.json @@ -68,11 +68,7 @@ "skip": "Skip", "open-drive": "Open Internxt Drive", "new": "New", - "platform-phrase": { - "windows": "file explorer", - "linux": "file browser", - "macos": "Finder" - } + "platform-phrase": "file explorer" } }, "migration": { diff --git a/src/apps/renderer/localize/locales/es.json b/src/apps/renderer/localize/locales/es.json index f87fb003b9..685e7967a1 100644 --- a/src/apps/renderer/localize/locales/es.json +++ b/src/apps/renderer/localize/locales/es.json @@ -68,11 +68,7 @@ "open-drive": "Abrir Internxt Drive", "skip": "Saltar", "new": "Nuevo", - "platform-phrase": { - "windows": "explorador de archivos", - "linux": "buscador de archivos", - "macos": "Finder" - } + "platform-phrase": "explorador de archivos" } }, "migration": { diff --git a/src/apps/renderer/localize/locales/fr.json b/src/apps/renderer/localize/locales/fr.json index d678d68a6c..173d2533d0 100644 --- a/src/apps/renderer/localize/locales/fr.json +++ b/src/apps/renderer/localize/locales/fr.json @@ -68,11 +68,7 @@ "continue": "Continuer", "skip": "Sauter", "new": "Nouveau", - "platform-phrase": { - "windows": "navigateur de fichiers", - "linux": "navigateur de fichiers", - "macos": "Finder" - } + "platform-phrase": "navigateur de fichiers" } }, "migration": { diff --git a/src/apps/renderer/pages/Onboarding/helpers.tsx b/src/apps/renderer/pages/Onboarding/helpers.tsx index 6bf237459d..f20919608b 100644 --- a/src/apps/renderer/pages/Onboarding/helpers.tsx +++ b/src/apps/renderer/pages/Onboarding/helpers.tsx @@ -9,7 +9,6 @@ export type OnboardingSlideProps = { backupFolders: BackupFolder[]; currentSlide: number; totalSlides: number; - platform: string; }; export type OnboardingSlide = { diff --git a/src/apps/renderer/pages/Onboarding/index.tsx b/src/apps/renderer/pages/Onboarding/index.tsx index b7975673b3..a532f32e8e 100644 --- a/src/apps/renderer/pages/Onboarding/index.tsx +++ b/src/apps/renderer/pages/Onboarding/index.tsx @@ -1,7 +1,6 @@ import { useMemo, useState } from 'react'; import { SLIDES } from './config'; import { BackupFolder, BackupsFoldersSelector } from '../../components/Backups/BackupsFoldersSelector'; -import useClientPlatform from '../../hooks/ClientPlatform'; // Slide 1 is welcome slide, last slide is summary, doesn't count const totalSlides = SLIDES.length - 2; @@ -10,7 +9,6 @@ export default function Onboarding() { const [backupFolders, setBackupFolders] = useState([]); const [slideIndex, setSlideIndex] = useState(0); const [backupsModalOpen, setBackupsModalOpen] = useState(false); - const desktopPlatform = useClientPlatform(); const finish = () => { if (backupFolders?.length) { @@ -19,9 +17,11 @@ export default function Onboarding() { * if this fails, the user can fix this * from the Desktop settings */ - window.electron.addBackupsFromLocalPaths(backupFolders.map((backupFolder) => backupFolder.path)).catch((err) => { - reportError(err); - }); + window.electron + .addBackupsFromLocalPaths(backupFolders.map((backupFolder) => backupFolder.path)) + .catch((err: unknown) => { + reportError(err); + }); } window.electron.finishOnboarding(); @@ -64,12 +64,10 @@ export default function Onboarding() { }, 300); }; - if (!desktopPlatform) return <>; return (

= () => {

{translate('onboarding.slides.drive.description', { - platform_app: translate('onboarding.common.platform-phrase.windows'), + platform_app: translate('onboarding.common.platform-phrase'), })}

diff --git a/src/apps/renderer/pages/Onboarding/slides/onboarding-completed-slide.tsx b/src/apps/renderer/pages/Onboarding/slides/onboarding-completed-slide.tsx index e916aea62a..2a8558886f 100644 --- a/src/apps/renderer/pages/Onboarding/slides/onboarding-completed-slide.tsx +++ b/src/apps/renderer/pages/Onboarding/slides/onboarding-completed-slide.tsx @@ -23,7 +23,7 @@ export const OnboardingCompletedSlide: React.FC = () => {

{translate('onboarding.slides.onboarding-completed.desktop-ready.description', { - platform_phrase: translate('onboarding.common.platform-phrase.windows'), + platform_phrase: translate('onboarding.common.platform-phrase'), })}

diff --git a/src/context/virtual-drive/shared/application/PlatformPathConverter.test.ts b/src/context/virtual-drive/shared/application/PlatformPathConverter.test.ts deleted file mode 100644 index 22301b8179..0000000000 --- a/src/context/virtual-drive/shared/application/PlatformPathConverter.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { PlatformPathConverter } from './PlatformPathConverter'; - -describe('PlatformPathConverter', () => { - describe('winToPosix', () => { - it('works with a single level', () => { - const win = '\\New Folder (4)'; - const posix = PlatformPathConverter.winToPosix(win); - - expect(posix).toBe('/New Folder (4)'); - }); - it('works with two levels', () => { - const win = '\\New Folder (4)\\Subfolder'; - const posix = PlatformPathConverter.winToPosix(win); - - expect(posix).toBe('/New Folder (4)/Subfolder'); - }); - }); -}); diff --git a/src/context/virtual-drive/shared/application/PlatformPathConverter.ts b/src/context/virtual-drive/shared/application/PlatformPathConverter.ts deleted file mode 100644 index 58bebe8eaf..0000000000 --- a/src/context/virtual-drive/shared/application/PlatformPathConverter.ts +++ /dev/null @@ -1,26 +0,0 @@ -import path from 'path'; - -export class PlatformPathConverter { - static convertAnyToCurrent(anyPlatformPath: string): string { - const fromPlatform = anyPlatformPath.includes(path.posix.sep) ? path.posix : path.win32; - - const toPlatform = path.sep === path.posix.sep ? path.posix : path.win32; - - return anyPlatformPath.split(fromPlatform.sep).join(toPlatform.sep); - } - - static winToPosix(win: string): string { - return win.split(path.win32.sep).join(path.posix.sep); - } - - static posixToWin(posix: string): string { - return posix.split(path.posix.sep).join(path.win32.sep); - } - - static getFatherPathPosix(posixPath: string): string { - const pathArray = posixPath.split('/'); - pathArray.pop(); - const parentPath = pathArray.join('/'); - return this.winToPosix(parentPath); - } -}