diff --git a/desktop/src/main.ts b/desktop/src/main.ts index b1e89b40c..68b2cc51c 100644 --- a/desktop/src/main.ts +++ b/desktop/src/main.ts @@ -26,9 +26,9 @@ import { import { attachFSWatchIPCHandlers, attachIPCHandlers } from "./main/ipc"; import log, { initLogging } from "./main/log"; import { createApplicationMenu } from "./main/menu"; +import { setupAutoUpdater } from "./main/services/app-update"; +import { initWatcher } from "./main/services/chokidar"; import { isDev } from "./main/util"; -import { setupAutoUpdater } from "./services/app-update"; -import { initWatcher } from "./services/chokidar"; let appIsQuitting = false; diff --git a/desktop/src/main/dialogs.ts b/desktop/src/main/dialogs.ts index 5f18878b5..2f91f5c40 100644 --- a/desktop/src/main/dialogs.ts +++ b/desktop/src/main/dialogs.ts @@ -1,8 +1,8 @@ import { dialog } from "electron/main"; import path from "node:path"; -import { getDirFilePaths, getElectronFile } from "../services/fs"; -import { getElectronFilesFromGoogleZip } from "../services/upload"; import type { ElectronFile } from "../types/ipc"; +import { getDirFilePaths, getElectronFile } from "./services/fs"; +import { getElectronFilesFromGoogleZip } from "./services/upload"; export const selectDirectory = async () => { const result = await dialog.showOpenDialog({ diff --git a/desktop/src/main/init.ts b/desktop/src/main/init.ts index 81a4cf631..2bea075a3 100644 --- a/desktop/src/main/init.ts +++ b/desktop/src/main/init.ts @@ -2,11 +2,11 @@ import { BrowserWindow, Tray, app, nativeImage, shell } from "electron"; import { existsSync } from "node:fs"; import path from "node:path"; import { isAppQuitting, rendererURL } from "../main"; -import autoLauncher from "../services/autoLauncher"; -import { getHideDockIconPreference } from "../services/userPreference"; -import { isPlatform } from "../utils/common/platform"; import log from "./log"; import { createTrayContextMenu } from "./menu"; +import { isPlatform } from "./platform"; +import autoLauncher from "./services/autoLauncher"; +import { getHideDockIconPreference } from "./services/userPreference"; import { isDev } from "./util"; /** diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.ts index ecb3e2010..2b328bb98 100644 --- a/desktop/src/main/ipc.ts +++ b/desktop/src/main/ipc.ts @@ -10,37 +10,6 @@ import type { FSWatcher } from "chokidar"; import { ipcMain } from "electron/main"; -import { - appVersion, - skipAppUpdate, - updateAndRestart, - updateOnNextRestart, -} from "../services/app-update"; -import { clipImageEmbedding, clipTextEmbedding } from "../services/clip"; -import { runFFmpegCmd } from "../services/ffmpeg"; -import { getDirFiles } from "../services/fs"; -import { - convertToJPEG, - generateImageThumbnail, -} from "../services/imageProcessor"; -import { - clearStores, - encryptionKey, - saveEncryptionKey, -} from "../services/store"; -import { - getElectronFilesFromGoogleZip, - getPendingUploads, - setToUploadCollection, - setToUploadFiles, -} from "../services/upload"; -import { - addWatchMapping, - getWatchMappings, - removeWatchMapping, - updateWatchMappingIgnoredFiles, - updateWatchMappingSyncedFiles, -} from "../services/watch"; import type { ElectronFile, FILE_PATH_TYPE, WatchMapping } from "../types/ipc"; import { selectDirectory, @@ -61,6 +30,37 @@ import { saveStreamToDisk, } from "./fs"; import { logToDisk } from "./log"; +import { + appVersion, + skipAppUpdate, + updateAndRestart, + updateOnNextRestart, +} from "./services/app-update"; +import { clipImageEmbedding, clipTextEmbedding } from "./services/clip"; +import { runFFmpegCmd } from "./services/ffmpeg"; +import { getDirFiles } from "./services/fs"; +import { + convertToJPEG, + generateImageThumbnail, +} from "./services/imageProcessor"; +import { + clearStores, + encryptionKey, + saveEncryptionKey, +} from "./services/store"; +import { + getElectronFilesFromGoogleZip, + getPendingUploads, + setToUploadCollection, + setToUploadFiles, +} from "./services/upload"; +import { + addWatchMapping, + getWatchMappings, + removeWatchMapping, + updateWatchMappingIgnoredFiles, + updateWatchMappingSyncedFiles, +} from "./services/watch"; import { openDirectory, openLogDirectory } from "./util"; /** diff --git a/desktop/src/main/menu.ts b/desktop/src/main/menu.ts index f6b37e9b0..7801e77ae 100644 --- a/desktop/src/main/menu.ts +++ b/desktop/src/main/menu.ts @@ -6,12 +6,12 @@ import { shell, } from "electron"; import { setIsAppQuitting } from "../main"; -import { forceCheckForAppUpdates } from "../services/app-update"; -import autoLauncher from "../services/autoLauncher"; +import { forceCheckForAppUpdates } from "./services/app-update"; +import autoLauncher from "./services/autoLauncher"; import { getHideDockIconPreference, setHideDockIconPreference, -} from "../services/userPreference"; +} from "./services/userPreference"; import { openLogDirectory } from "./util"; /** Create and return the entries in the app's main menu bar */ diff --git a/desktop/src/utils/common/platform.ts b/desktop/src/main/platform.ts similarity index 100% rename from desktop/src/utils/common/platform.ts rename to desktop/src/main/platform.ts diff --git a/desktop/src/services/app-update.ts b/desktop/src/main/services/app-update.ts similarity index 95% rename from desktop/src/services/app-update.ts rename to desktop/src/main/services/app-update.ts index 507ef3e64..272a1ca6c 100644 --- a/desktop/src/services/app-update.ts +++ b/desktop/src/main/services/app-update.ts @@ -2,10 +2,10 @@ import { compareVersions } from "compare-versions"; import { app, BrowserWindow } from "electron"; import { default as electronLog } from "electron-log"; import { autoUpdater } from "electron-updater"; -import { setIsAppQuitting, setIsUpdateAvailable } from "../main"; -import log from "../main/log"; +import { setIsAppQuitting, setIsUpdateAvailable } from "../../main"; +import { AppUpdateInfo } from "../../types/ipc"; +import log from "../log"; import { userPreferencesStore } from "../stores/user-preferences"; -import { AppUpdateInfo } from "../types/ipc"; export const setupAutoUpdater = (mainWindow: BrowserWindow) => { autoUpdater.logger = electronLog; diff --git a/desktop/src/services/autoLauncher.ts b/desktop/src/main/services/autoLauncher.ts similarity index 91% rename from desktop/src/services/autoLauncher.ts rename to desktop/src/main/services/autoLauncher.ts index bc1270ac9..614c151ba 100644 --- a/desktop/src/services/autoLauncher.ts +++ b/desktop/src/main/services/autoLauncher.ts @@ -1,5 +1,5 @@ -import { AutoLauncherClient } from "../types/main"; -import { isPlatform } from "../utils/common/platform"; +import { AutoLauncherClient } from "../../types/main"; +import { isPlatform } from "../platform"; import linuxAndWinAutoLauncher from "./autoLauncherClients/linuxAndWinAutoLauncher"; import macAutoLauncher from "./autoLauncherClients/macAutoLauncher"; diff --git a/desktop/src/services/autoLauncherClients/linuxAndWinAutoLauncher.ts b/desktop/src/main/services/autoLauncherClients/linuxAndWinAutoLauncher.ts similarity index 94% rename from desktop/src/services/autoLauncherClients/linuxAndWinAutoLauncher.ts rename to desktop/src/main/services/autoLauncherClients/linuxAndWinAutoLauncher.ts index 761b58a06..0d2c1bb42 100644 --- a/desktop/src/services/autoLauncherClients/linuxAndWinAutoLauncher.ts +++ b/desktop/src/main/services/autoLauncherClients/linuxAndWinAutoLauncher.ts @@ -1,6 +1,6 @@ import AutoLaunch from "auto-launch"; import { app } from "electron"; -import { AutoLauncherClient } from "../../types/main"; +import { AutoLauncherClient } from "../../../types/main"; const LAUNCHED_AS_HIDDEN_FLAG = "hidden"; diff --git a/desktop/src/services/autoLauncherClients/macAutoLauncher.ts b/desktop/src/main/services/autoLauncherClients/macAutoLauncher.ts similarity index 92% rename from desktop/src/services/autoLauncherClients/macAutoLauncher.ts rename to desktop/src/main/services/autoLauncherClients/macAutoLauncher.ts index d4fc343b0..00320e870 100644 --- a/desktop/src/services/autoLauncherClients/macAutoLauncher.ts +++ b/desktop/src/main/services/autoLauncherClients/macAutoLauncher.ts @@ -1,5 +1,5 @@ import { app } from "electron"; -import { AutoLauncherClient } from "../../types/main"; +import { AutoLauncherClient } from "../../../types/main"; class MacAutoLauncher implements AutoLauncherClient { async isEnabled() { diff --git a/desktop/src/services/chokidar.ts b/desktop/src/main/services/chokidar.ts similarity index 93% rename from desktop/src/services/chokidar.ts rename to desktop/src/main/services/chokidar.ts index cef386ea3..5d7284d2a 100644 --- a/desktop/src/services/chokidar.ts +++ b/desktop/src/main/services/chokidar.ts @@ -1,9 +1,9 @@ import chokidar from "chokidar"; import { BrowserWindow } from "electron"; import path from "path"; -import log from "../main/log"; -import { getWatchMappings } from "../services/watch"; +import log from "../log"; import { getElectronFile } from "./fs"; +import { getWatchMappings } from "./watch"; /** * Convert a file system {@link filePath} that uses the local system specific diff --git a/desktop/src/services/clip.ts b/desktop/src/main/services/clip.ts similarity index 97% rename from desktop/src/services/clip.ts rename to desktop/src/main/services/clip.ts index 535f9312e..0ef605318 100644 --- a/desktop/src/services/clip.ts +++ b/desktop/src/main/services/clip.ts @@ -14,11 +14,11 @@ import { existsSync } from "fs"; import jpeg from "jpeg-js"; import fs from "node:fs/promises"; import path from "node:path"; -import { writeStream } from "../main/fs"; -import log from "../main/log"; -import { CustomErrors } from "../types/ipc"; -import Tokenizer from "../utils/clip-bpe-ts/mod"; -import { generateTempFilePath } from "../utils/temp"; +import { CustomErrors } from "../../types/ipc"; +import Tokenizer from "../../thirdparty/clip-bpe-ts/mod"; +import { writeStream } from "../fs"; +import log from "../log"; +import { generateTempFilePath } from "../temp"; import { deleteTempFile } from "./ffmpeg"; const ort = require("onnxruntime-node"); diff --git a/desktop/src/services/ffmpeg.ts b/desktop/src/main/services/ffmpeg.ts similarity index 95% rename from desktop/src/services/ffmpeg.ts rename to desktop/src/main/services/ffmpeg.ts index 468034046..e9639a26f 100644 --- a/desktop/src/services/ffmpeg.ts +++ b/desktop/src/main/services/ffmpeg.ts @@ -1,11 +1,11 @@ import pathToFfmpeg from "ffmpeg-static"; import { existsSync } from "node:fs"; import fs from "node:fs/promises"; -import { writeStream } from "../main/fs"; -import log from "../main/log"; -import { execAsync } from "../main/util"; -import { ElectronFile } from "../types/ipc"; -import { generateTempFilePath, getTempDirPath } from "../utils/temp"; +import { ElectronFile } from "../../types/ipc"; +import { writeStream } from "../fs"; +import log from "../log"; +import { generateTempFilePath, getTempDirPath } from "../temp"; +import { execAsync } from "../util"; const INPUT_PATH_PLACEHOLDER = "INPUT"; const FFMPEG_PLACEHOLDER = "FFMPEG"; diff --git a/desktop/src/services/fs.ts b/desktop/src/main/services/fs.ts similarity index 98% rename from desktop/src/services/fs.ts rename to desktop/src/main/services/fs.ts index 5a8fb265c..7a29d581b 100644 --- a/desktop/src/services/fs.ts +++ b/desktop/src/main/services/fs.ts @@ -2,8 +2,8 @@ import StreamZip from "node-stream-zip"; import { existsSync } from "node:fs"; import fs from "node:fs/promises"; import path from "node:path"; -import log from "../main/log"; -import { ElectronFile } from "../types/ipc"; +import { ElectronFile } from "../../types/ipc"; +import log from "../log"; const FILE_STREAM_CHUNK_SIZE: number = 4 * 1024 * 1024; diff --git a/desktop/src/services/imageProcessor.ts b/desktop/src/main/services/imageProcessor.ts similarity index 96% rename from desktop/src/services/imageProcessor.ts rename to desktop/src/main/services/imageProcessor.ts index 8f81ba287..890e0e634 100644 --- a/desktop/src/services/imageProcessor.ts +++ b/desktop/src/main/services/imageProcessor.ts @@ -1,12 +1,12 @@ import { existsSync } from "fs"; import fs from "node:fs/promises"; import path from "path"; -import { writeStream } from "../main/fs"; -import log from "../main/log"; -import { execAsync, isDev } from "../main/util"; -import { CustomErrors, ElectronFile } from "../types/ipc"; -import { isPlatform } from "../utils/common/platform"; -import { generateTempFilePath } from "../utils/temp"; +import { CustomErrors, ElectronFile } from "../../types/ipc"; +import { writeStream } from "../fs"; +import log from "../log"; +import { isPlatform } from "../platform"; +import { generateTempFilePath } from "../temp"; +import { execAsync, isDev } from "../util"; import { deleteTempFile } from "./ffmpeg"; const IMAGE_MAGICK_PLACEHOLDER = "IMAGE_MAGICK"; diff --git a/desktop/src/services/store.ts b/desktop/src/main/services/store.ts similarity index 100% rename from desktop/src/services/store.ts rename to desktop/src/main/services/store.ts diff --git a/desktop/src/services/upload.ts b/desktop/src/main/services/upload.ts similarity index 93% rename from desktop/src/services/upload.ts rename to desktop/src/main/services/upload.ts index ae51e8218..e3fbc16e6 100644 --- a/desktop/src/services/upload.ts +++ b/desktop/src/main/services/upload.ts @@ -1,10 +1,9 @@ import StreamZip from "node-stream-zip"; import path from "path"; -import { getElectronFile } from "../services/fs"; +import { ElectronFile, FILE_PATH_TYPE } from "../../types/ipc"; +import { FILE_PATH_KEYS } from "../../types/main"; import { uploadStatusStore } from "../stores/upload.store"; -import { ElectronFile, FILE_PATH_TYPE } from "../types/ipc"; -import { FILE_PATH_KEYS } from "../types/main"; -import { getValidPaths, getZipFileStream } from "./fs"; +import { getElectronFile, getValidPaths, getZipFileStream } from "./fs"; export const getPendingUploads = async () => { const filePaths = getSavedFilePaths(FILE_PATH_TYPE.FILES); diff --git a/desktop/src/services/userPreference.ts b/desktop/src/main/services/userPreference.ts similarity index 100% rename from desktop/src/services/userPreference.ts rename to desktop/src/main/services/userPreference.ts diff --git a/desktop/src/services/watch.ts b/desktop/src/main/services/watch.ts similarity index 97% rename from desktop/src/services/watch.ts rename to desktop/src/main/services/watch.ts index 59ef842f7..8a3414c58 100644 --- a/desktop/src/services/watch.ts +++ b/desktop/src/main/services/watch.ts @@ -1,7 +1,7 @@ import type { FSWatcher } from "chokidar"; import ElectronLog from "electron-log"; +import { WatchMapping, WatchStoreType } from "../../types/ipc"; import { watchStore } from "../stores/watch.store"; -import { WatchMapping, WatchStoreType } from "../types/ipc"; export const addWatchMapping = async ( watcher: FSWatcher, diff --git a/desktop/src/stores/keys.store.ts b/desktop/src/main/stores/keys.store.ts similarity index 86% rename from desktop/src/stores/keys.store.ts rename to desktop/src/main/stores/keys.store.ts index d112f045a..4f8618cea 100644 --- a/desktop/src/stores/keys.store.ts +++ b/desktop/src/main/stores/keys.store.ts @@ -1,5 +1,5 @@ import Store, { Schema } from "electron-store"; -import type { KeysStoreType } from "../types/main"; +import type { KeysStoreType } from "../../types/main"; const keysStoreSchema: Schema = { AnonymizeUserID: { diff --git a/desktop/src/stores/safeStorage.store.ts b/desktop/src/main/stores/safeStorage.store.ts similarity index 81% rename from desktop/src/stores/safeStorage.store.ts rename to desktop/src/main/stores/safeStorage.store.ts index 809c9623f..da95df3be 100644 --- a/desktop/src/stores/safeStorage.store.ts +++ b/desktop/src/main/stores/safeStorage.store.ts @@ -1,5 +1,5 @@ import Store, { Schema } from "electron-store"; -import type { SafeStorageStoreType } from "../types/main"; +import type { SafeStorageStoreType } from "../../types/main"; const safeStorageSchema: Schema = { encryptionKey: { diff --git a/desktop/src/stores/upload.store.ts b/desktop/src/main/stores/upload.store.ts similarity index 89% rename from desktop/src/stores/upload.store.ts rename to desktop/src/main/stores/upload.store.ts index 5ede1fb99..20b1f419d 100644 --- a/desktop/src/stores/upload.store.ts +++ b/desktop/src/main/stores/upload.store.ts @@ -1,5 +1,5 @@ import Store, { Schema } from "electron-store"; -import type { UploadStoreType } from "../types/main"; +import type { UploadStoreType } from "../../types/main"; const uploadStoreSchema: Schema = { filePaths: { diff --git a/desktop/src/stores/user-preferences.ts b/desktop/src/main/stores/user-preferences.ts similarity index 100% rename from desktop/src/stores/user-preferences.ts rename to desktop/src/main/stores/user-preferences.ts diff --git a/desktop/src/stores/watch.store.ts b/desktop/src/main/stores/watch.store.ts similarity index 96% rename from desktop/src/stores/watch.store.ts rename to desktop/src/main/stores/watch.store.ts index cbc71dde7..55470ce86 100644 --- a/desktop/src/stores/watch.store.ts +++ b/desktop/src/main/stores/watch.store.ts @@ -1,5 +1,5 @@ import Store, { Schema } from "electron-store"; -import { WatchStoreType } from "../types/ipc"; +import { WatchStoreType } from "../../types/ipc"; const watchStoreSchema: Schema = { mappings: { diff --git a/desktop/src/utils/temp.ts b/desktop/src/main/temp.ts similarity index 100% rename from desktop/src/utils/temp.ts rename to desktop/src/main/temp.ts diff --git a/desktop/src/types/any-shell-escape.d.ts b/desktop/src/main/types/any-shell-escape.d.ts similarity index 100% rename from desktop/src/types/any-shell-escape.d.ts rename to desktop/src/main/types/any-shell-escape.d.ts diff --git a/desktop/src/utils/clip-bpe-ts/LICENSE b/desktop/src/thirdparty/clip-bpe-ts/LICENSE similarity index 100% rename from desktop/src/utils/clip-bpe-ts/LICENSE rename to desktop/src/thirdparty/clip-bpe-ts/LICENSE diff --git a/desktop/src/utils/clip-bpe-ts/README.md b/desktop/src/thirdparty/clip-bpe-ts/README.md similarity index 100% rename from desktop/src/utils/clip-bpe-ts/README.md rename to desktop/src/thirdparty/clip-bpe-ts/README.md diff --git a/desktop/src/utils/clip-bpe-ts/bpe_simple_vocab_16e6.ts b/desktop/src/thirdparty/clip-bpe-ts/bpe_simple_vocab_16e6.ts similarity index 100% rename from desktop/src/utils/clip-bpe-ts/bpe_simple_vocab_16e6.ts rename to desktop/src/thirdparty/clip-bpe-ts/bpe_simple_vocab_16e6.ts diff --git a/desktop/src/utils/clip-bpe-ts/mod.ts b/desktop/src/thirdparty/clip-bpe-ts/mod.ts similarity index 100% rename from desktop/src/utils/clip-bpe-ts/mod.ts rename to desktop/src/thirdparty/clip-bpe-ts/mod.ts