소스 검색

Move electron API types to lower layer

Manav Rathi 1 년 전
부모
커밋
f4f041552f
34개의 변경된 파일77개의 추가작업 그리고 74개의 파일을 삭제
  1. 3 3
      desktop/src/main/ipc.ts
  2. 6 6
      desktop/src/preload.ts
  3. 1 1
      web/apps/photos/src/components/Directory/index.tsx
  4. 1 1
      web/apps/photos/src/components/FilesDownloadProgress.tsx
  5. 1 1
      web/apps/photos/src/components/Sidebar/DebugSection.tsx
  6. 1 1
      web/apps/photos/src/components/Upload/Uploader.tsx
  7. 1 1
      web/apps/photos/src/components/WatchFolder/index.tsx
  8. 2 2
      web/apps/photos/src/pages/_app.tsx
  9. 1 1
      web/apps/photos/src/pages/gallery/index.tsx
  10. 1 1
      web/apps/photos/src/pages/index.tsx
  11. 1 1
      web/apps/photos/src/services/clipService.ts
  12. 1 1
      web/apps/photos/src/services/export/index.ts
  13. 1 1
      web/apps/photos/src/services/ffmpeg/ffmpegFactory.ts
  14. 1 1
      web/apps/photos/src/services/importService.ts
  15. 1 1
      web/apps/photos/src/services/upload/thumbnailService.ts
  16. 1 1
      web/apps/photos/src/services/watchFolder/watchFolderService.ts
  17. 1 1
      web/apps/photos/src/utils/collection/index.ts
  18. 1 1
      web/apps/photos/src/utils/file/index.ts
  19. 2 2
      web/apps/photos/src/utils/ui/index.tsx
  20. 1 1
      web/apps/photos/tests/zip-file-reading.test.ts
  21. 1 1
      web/packages/accounts/pages/credentials.tsx
  22. 1 1
      web/packages/accounts/services/user.ts
  23. 10 0
      web/packages/next/electron.ts
  24. 27 0
      web/packages/next/types/file.ts
  25. 3 4
      web/packages/next/types/ipc.ts
  26. 1 1
      web/packages/shared/components/Directory/index.tsx
  27. 1 1
      web/packages/shared/crypto/helpers.ts
  28. 1 1
      web/packages/shared/crypto/types.ts
  29. 0 5
      web/packages/shared/electron/index.ts
  30. 1 1
      web/packages/shared/logging/index.ts
  31. 1 1
      web/packages/shared/logging/web.ts
  32. 0 4
      web/packages/shared/upload/constants.ts
  33. 0 24
      web/packages/shared/watchFolder/types.ts
  34. 1 1
      web/packages/shared/worker/comlinkWorker.ts

+ 3 - 3
desktop/src/main/ipc.ts

@@ -180,12 +180,12 @@ export const attachIPCHandlers = () => {
 
 
     ipcMain.handle(
     ipcMain.handle(
         "saveStreamToDisk",
         "saveStreamToDisk",
-        (_, path: string, fileStream: ReadableStream<any>) =>
+        (_, path: string, fileStream: ReadableStream) =>
             saveStreamToDisk(path, fileStream),
             saveStreamToDisk(path, fileStream),
     );
     );
 
 
-    ipcMain.handle("saveFileToDisk", (_, path: string, file: any) =>
-        saveFileToDisk(path, file),
+    ipcMain.handle("saveFileToDisk", (_, path: string, contents: string) =>
+        saveFileToDisk(path, contents),
     );
     );
 
 
     ipcMain.handle("readTextFile", (_, path: string) => readTextFile(path));
     ipcMain.handle("readTextFile", (_, path: string) => readTextFile(path));

+ 6 - 6
desktop/src/preload.ts

@@ -32,9 +32,9 @@
  * and when changing one of them, remember to see if the other two also need
  * and when changing one of them, remember to see if the other two also need
  * changing:
  * changing:
  *
  *
- * -    [renderer]  web/packages/shared/electron/types.ts     contains docs
- * -    [preload]   desktop/src/preload.ts                          ↕︎
- * -    [main]      desktop/src/main/ipc.ts                   contains impl
+ * -    [renderer]  web/packages/next/types/electron.ts      contains docs
+ * -    [preload]   desktop/src/preload.ts                         ↕︎
+ * -    [main]      desktop/src/main/ipc.ts                  contains impl
  */
  */
 
 
 import { contextBridge, ipcRenderer } from "electron/renderer";
 import { contextBridge, ipcRenderer } from "electron/renderer";
@@ -227,11 +227,11 @@ const checkExistsAndCreateDir = (dirPath: string): Promise<void> =>
 
 
 const saveStreamToDisk = (
 const saveStreamToDisk = (
     path: string,
     path: string,
-    fileStream: ReadableStream<any>,
+    fileStream: ReadableStream,
 ): Promise<void> => ipcRenderer.invoke("saveStreamToDisk", path, fileStream);
 ): Promise<void> => ipcRenderer.invoke("saveStreamToDisk", path, fileStream);
 
 
-const saveFileToDisk = (path: string, file: any): Promise<void> =>
-    ipcRenderer.invoke("saveFileToDisk", path, file);
+const saveFileToDisk = (path: string, contents: string): Promise<void> =>
+    ipcRenderer.invoke("saveFileToDisk", path, contents);
 
 
 const readTextFile = (path: string): Promise<string> =>
 const readTextFile = (path: string): Promise<string> =>
     ipcRenderer.invoke("readTextFile", path);
     ipcRenderer.invoke("readTextFile", path);

+ 1 - 1
web/apps/photos/src/components/Directory/index.tsx

@@ -1,5 +1,5 @@
+import ElectronAPIs from "@/next/electron";
 import LinkButton from "@ente/shared/components/LinkButton";
 import LinkButton from "@ente/shared/components/LinkButton";
-import ElectronAPIs from "@ente/shared/electron";
 import { logError } from "@ente/shared/sentry";
 import { logError } from "@ente/shared/sentry";
 import { Tooltip } from "@mui/material";
 import { Tooltip } from "@mui/material";
 import { styled } from "@mui/material/styles";
 import { styled } from "@mui/material/styles";

+ 1 - 1
web/apps/photos/src/components/FilesDownloadProgress.tsx

@@ -1,4 +1,4 @@
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import Notification from "components/Notification";
 import Notification from "components/Notification";
 import { t } from "i18next";
 import { t } from "i18next";
 import isElectron from "is-electron";
 import isElectron from "is-electron";

+ 1 - 1
web/apps/photos/src/components/Sidebar/DebugSection.tsx

@@ -3,7 +3,7 @@ import { AppContext } from "pages/_app";
 import { useContext, useEffect, useState } from "react";
 import { useContext, useEffect, useState } from "react";
 import { Trans } from "react-i18next";
 import { Trans } from "react-i18next";
 
 
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { addLogLine } from "@ente/shared/logging";
 import { addLogLine } from "@ente/shared/logging";
 import { getDebugLogs } from "@ente/shared/logging/web";
 import { getDebugLogs } from "@ente/shared/logging/web";
 import { downloadAsFile } from "@ente/shared/utils";
 import { downloadAsFile } from "@ente/shared/utils";

+ 1 - 1
web/apps/photos/src/components/Upload/Uploader.tsx

@@ -1,4 +1,4 @@
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { CustomError } from "@ente/shared/error";
 import { CustomError } from "@ente/shared/error";
 import { addLogLine } from "@ente/shared/logging";
 import { addLogLine } from "@ente/shared/logging";
 import { logError } from "@ente/shared/sentry";
 import { logError } from "@ente/shared/sentry";

+ 1 - 1
web/apps/photos/src/components/WatchFolder/index.tsx

@@ -6,8 +6,8 @@ import watchFolderService from "services/watchFolder/watchFolderService";
 import { WatchMapping } from "types/watchFolder";
 import { WatchMapping } from "types/watchFolder";
 import { MappingList } from "./mappingList";
 import { MappingList } from "./mappingList";
 
 
+import ElectronAPIs from "@/next/electron";
 import DialogTitleWithCloseButton from "@ente/shared/components/DialogBox/TitleWithCloseButton";
 import DialogTitleWithCloseButton from "@ente/shared/components/DialogBox/TitleWithCloseButton";
-import ElectronAPIs from "@ente/shared/electron";
 import UploadStrategyChoiceModal from "components/Upload/UploadStrategyChoiceModal";
 import UploadStrategyChoiceModal from "components/Upload/UploadStrategyChoiceModal";
 import { PICKED_UPLOAD_TYPE, UPLOAD_STRATEGY } from "constants/upload";
 import { PICKED_UPLOAD_TYPE, UPLOAD_STRATEGY } from "constants/upload";
 import isElectron from "is-electron";
 import isElectron from "is-electron";

+ 2 - 2
web/apps/photos/src/pages/_app.tsx

@@ -1,5 +1,7 @@
 import { CustomHead } from "@/next/components/Head";
 import { CustomHead } from "@/next/components/Head";
+import ElectronAPIs from "@/next/electron";
 import { setupI18n } from "@/next/i18n";
 import { setupI18n } from "@/next/i18n";
+import { AppUpdateInfo } from "@/next/types/ipc";
 import {
 import {
     APPS,
     APPS,
     APP_TITLES,
     APP_TITLES,
@@ -20,8 +22,6 @@ import EnteSpinner from "@ente/shared/components/EnteSpinner";
 import { MessageContainer } from "@ente/shared/components/MessageContainer";
 import { MessageContainer } from "@ente/shared/components/MessageContainer";
 import AppNavbar from "@ente/shared/components/Navbar/app";
 import AppNavbar from "@ente/shared/components/Navbar/app";
 import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
 import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
-import ElectronAPIs from "@ente/shared/electron";
-import { AppUpdateInfo } from "@ente/shared/electron/types";
 import { CustomError } from "@ente/shared/error";
 import { CustomError } from "@ente/shared/error";
 import { Events, eventBus } from "@ente/shared/events";
 import { Events, eventBus } from "@ente/shared/events";
 import { useLocalState } from "@ente/shared/hooks/useLocalState";
 import { useLocalState } from "@ente/shared/hooks/useLocalState";

+ 1 - 1
web/apps/photos/src/pages/gallery/index.tsx

@@ -89,9 +89,9 @@ import {
     splitNormalAndHiddenCollections,
     splitNormalAndHiddenCollections,
 } from "utils/collection";
 } from "utils/collection";
 
 
+import ElectronAPIs from "@/next/electron";
 import { APPS } from "@ente/shared/apps/constants";
 import { APPS } from "@ente/shared/apps/constants";
 import { CenteredFlex } from "@ente/shared/components/Container";
 import { CenteredFlex } from "@ente/shared/components/Container";
-import ElectronAPIs from "@ente/shared/electron";
 import useFileInput from "@ente/shared/hooks/useFileInput";
 import useFileInput from "@ente/shared/hooks/useFileInput";
 import useMemoSingleThreaded from "@ente/shared/hooks/useMemoSingleThreaded";
 import useMemoSingleThreaded from "@ente/shared/hooks/useMemoSingleThreaded";
 import InMemoryStore, { MS_KEYS } from "@ente/shared/storage/InMemoryStore";
 import InMemoryStore, { MS_KEYS } from "@ente/shared/storage/InMemoryStore";

+ 1 - 1
web/apps/photos/src/pages/index.tsx

@@ -1,3 +1,4 @@
+import ElectronAPIs from "@/next/electron";
 import Login from "@ente/accounts/components/Login";
 import Login from "@ente/accounts/components/Login";
 import SignUp from "@ente/accounts/components/SignUp";
 import SignUp from "@ente/accounts/components/SignUp";
 import { APPS } from "@ente/shared/apps/constants";
 import { APPS } from "@ente/shared/apps/constants";
@@ -5,7 +6,6 @@ import { EnteLogo } from "@ente/shared/components/EnteLogo";
 import EnteSpinner from "@ente/shared/components/EnteSpinner";
 import EnteSpinner from "@ente/shared/components/EnteSpinner";
 import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
 import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
 import { saveKeyInSessionStore } from "@ente/shared/crypto/helpers";
 import { saveKeyInSessionStore } from "@ente/shared/crypto/helpers";
-import ElectronAPIs from "@ente/shared/electron";
 import { getAlbumsURL } from "@ente/shared/network/api";
 import { getAlbumsURL } from "@ente/shared/network/api";
 import { logError } from "@ente/shared/sentry";
 import { logError } from "@ente/shared/sentry";
 import localForage from "@ente/shared/storage/localForage";
 import localForage from "@ente/shared/storage/localForage";

+ 1 - 1
web/apps/photos/src/services/clipService.ts

@@ -1,5 +1,5 @@
+import ElectronAPIs from "@/next/electron";
 import ComlinkCryptoWorker from "@ente/shared/crypto";
 import ComlinkCryptoWorker from "@ente/shared/crypto";
-import ElectronAPIs from "@ente/shared/electron";
 import { CustomError } from "@ente/shared/error";
 import { CustomError } from "@ente/shared/error";
 import { Events, eventBus } from "@ente/shared/events";
 import { Events, eventBus } from "@ente/shared/events";
 import { addLogLine } from "@ente/shared/logging";
 import { addLogLine } from "@ente/shared/logging";

+ 1 - 1
web/apps/photos/src/services/export/index.ts

@@ -37,7 +37,7 @@ import {
 } from "utils/file";
 } from "utils/file";
 import { decodeLivePhoto } from "../livePhotoService";
 import { decodeLivePhoto } from "../livePhotoService";
 
 
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { CustomError } from "@ente/shared/error";
 import { CustomError } from "@ente/shared/error";
 import { Events, eventBus } from "@ente/shared/events";
 import { Events, eventBus } from "@ente/shared/events";
 import { addLogLine } from "@ente/shared/logging";
 import { addLogLine } from "@ente/shared/logging";

+ 1 - 1
web/apps/photos/src/services/ffmpeg/ffmpegFactory.ts

@@ -1,4 +1,4 @@
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import isElectron from "is-electron";
 import isElectron from "is-electron";
 import { ElectronFile } from "types/upload";
 import { ElectronFile } from "types/upload";
 import ComlinkFFmpegWorker from "utils/comlink/ComlinkFFmpegWorker";
 import ComlinkFFmpegWorker from "utils/comlink/ComlinkFFmpegWorker";

+ 1 - 1
web/apps/photos/src/services/importService.ts

@@ -1,4 +1,4 @@
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { logError } from "@ente/shared/sentry";
 import { logError } from "@ente/shared/sentry";
 import { PICKED_UPLOAD_TYPE } from "constants/upload";
 import { PICKED_UPLOAD_TYPE } from "constants/upload";
 import { Collection } from "types/collection";
 import { Collection } from "types/collection";

+ 1 - 1
web/apps/photos/src/services/upload/thumbnailService.ts

@@ -1,4 +1,4 @@
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { CustomError } from "@ente/shared/error";
 import { CustomError } from "@ente/shared/error";
 import { addLogLine } from "@ente/shared/logging";
 import { addLogLine } from "@ente/shared/logging";
 import { getFileNameSize } from "@ente/shared/logging/web";
 import { getFileNameSize } from "@ente/shared/logging/web";

+ 1 - 1
web/apps/photos/src/services/watchFolder/watchFolderService.ts

@@ -1,4 +1,4 @@
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { addLocalLog, addLogLine } from "@ente/shared/logging";
 import { addLocalLog, addLogLine } from "@ente/shared/logging";
 import { logError } from "@ente/shared/sentry";
 import { logError } from "@ente/shared/sentry";
 import { UPLOAD_RESULT, UPLOAD_STRATEGY } from "constants/upload";
 import { UPLOAD_RESULT, UPLOAD_STRATEGY } from "constants/upload";

+ 1 - 1
web/apps/photos/src/utils/collection/index.ts

@@ -1,4 +1,4 @@
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { CustomError } from "@ente/shared/error";
 import { CustomError } from "@ente/shared/error";
 import { addLogLine } from "@ente/shared/logging";
 import { addLogLine } from "@ente/shared/logging";
 import { getAlbumsURL } from "@ente/shared/network/api";
 import { getAlbumsURL } from "@ente/shared/network/api";

+ 1 - 1
web/apps/photos/src/utils/file/index.ts

@@ -52,7 +52,7 @@ import {
 } from "services/fileService";
 } from "services/fileService";
 import { FileTypeInfo } from "types/upload";
 import { FileTypeInfo } from "types/upload";
 
 
-import { default as ElectronAPIs } from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { workerBridge } from "@ente/shared/worker/worker-bridge";
 import { workerBridge } from "@ente/shared/worker/worker-bridge";
 import { t } from "i18next";
 import { t } from "i18next";
 import { getFileExportPath, getUniqueFileExportName } from "utils/export";
 import { getFileExportPath, getUniqueFileExportName } from "utils/export";

+ 2 - 2
web/apps/photos/src/utils/ui/index.tsx

@@ -1,7 +1,7 @@
+import ElectronAPIs from "@/next/electron";
+import { AppUpdateInfo } from "@/next/types/ipc";
 import { logoutUser } from "@ente/accounts/services/user";
 import { logoutUser } from "@ente/accounts/services/user";
 import { DialogBoxAttributes } from "@ente/shared/components/DialogBox/types";
 import { DialogBoxAttributes } from "@ente/shared/components/DialogBox/types";
-import ElectronAPIs from "@ente/shared/electron";
-import { AppUpdateInfo } from "@ente/shared/electron/types";
 import AutoAwesomeOutlinedIcon from "@mui/icons-material/AutoAwesomeOutlined";
 import AutoAwesomeOutlinedIcon from "@mui/icons-material/AutoAwesomeOutlined";
 import InfoOutlined from "@mui/icons-material/InfoRounded";
 import InfoOutlined from "@mui/icons-material/InfoRounded";
 import { Link } from "@mui/material";
 import { Link } from "@mui/material";

+ 1 - 1
web/apps/photos/tests/zip-file-reading.test.ts

@@ -1,4 +1,4 @@
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { getFileNameSize } from "@ente/shared/logging/web";
 import { getFileNameSize } from "@ente/shared/logging/web";
 import { FILE_READER_CHUNK_SIZE, PICKED_UPLOAD_TYPE } from "constants/upload";
 import { FILE_READER_CHUNK_SIZE, PICKED_UPLOAD_TYPE } from "constants/upload";
 import isElectron from "is-electron";
 import isElectron from "is-electron";

+ 1 - 1
web/packages/accounts/pages/credentials.tsx

@@ -24,6 +24,7 @@ import { PAGES } from "../constants/pages";
 import { generateSRPSetupAttributes } from "../services/srp";
 import { generateSRPSetupAttributes } from "../services/srp";
 import { logoutUser } from "../services/user";
 import { logoutUser } from "../services/user";
 
 
+import ElectronAPIs from "@/next/electron";
 import { APP_HOMES } from "@ente/shared/apps/constants";
 import { APP_HOMES } from "@ente/shared/apps/constants";
 import { PageProps } from "@ente/shared/apps/types";
 import { PageProps } from "@ente/shared/apps/types";
 import { VerticallyCentered } from "@ente/shared/components/Container";
 import { VerticallyCentered } from "@ente/shared/components/Container";
@@ -37,7 +38,6 @@ import VerifyMasterPasswordForm, {
 } from "@ente/shared/components/VerifyMasterPasswordForm";
 } from "@ente/shared/components/VerifyMasterPasswordForm";
 import ComlinkCryptoWorker from "@ente/shared/crypto";
 import ComlinkCryptoWorker from "@ente/shared/crypto";
 import { B64EncryptionResult } from "@ente/shared/crypto/types";
 import { B64EncryptionResult } from "@ente/shared/crypto/types";
-import ElectronAPIs from "@ente/shared/electron";
 import { CustomError } from "@ente/shared/error";
 import { CustomError } from "@ente/shared/error";
 import { addLocalLog } from "@ente/shared/logging";
 import { addLocalLog } from "@ente/shared/logging";
 import { getAccountsURL } from "@ente/shared/network/api";
 import { getAccountsURL } from "@ente/shared/network/api";

+ 1 - 1
web/packages/accounts/services/user.ts

@@ -1,4 +1,4 @@
-import ElectronAPIs from "@ente/shared/electron";
+import ElectronAPIs from "@/next/electron";
 import { Events, eventBus } from "@ente/shared/events";
 import { Events, eventBus } from "@ente/shared/events";
 import { logError } from "@ente/shared/sentry";
 import { logError } from "@ente/shared/sentry";
 import InMemoryStore from "@ente/shared/storage/InMemoryStore";
 import InMemoryStore from "@ente/shared/storage/InMemoryStore";

+ 10 - 0
web/packages/next/electron.ts

@@ -0,0 +1,10 @@
+import type { ElectronAPIsType } from "./types/ipc";
+
+// TODO (MR):
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+const ElectronAPIs = (globalThis as unknown as any)[
+    // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access
+    "ElectronAPIs"
+] as ElectronAPIsType;
+
+export default ElectronAPIs;

+ 27 - 0
web/packages/shared/upload/types.ts → web/packages/next/types/file.ts

@@ -1,3 +1,8 @@
+export enum UPLOAD_STRATEGY {
+    SINGLE_COLLECTION,
+    COLLECTION_PER_FOLDER,
+}
+
 /*
 /*
  * ElectronFile is a custom interface that is used to represent
  * ElectronFile is a custom interface that is used to represent
  * any file on disk as a File-like object in the Electron desktop app.
  * any file on disk as a File-like object in the Electron desktop app.
@@ -20,3 +25,25 @@ export interface DataStream {
     stream: ReadableStream<Uint8Array>;
     stream: ReadableStream<Uint8Array>;
     chunkCount: number;
     chunkCount: number;
 }
 }
+
+export interface WatchMappingSyncedFile {
+    path: string;
+    uploadedFileID: number;
+    collectionID: number;
+}
+
+export interface WatchMapping {
+    rootFolderName: string;
+    folderPath: string;
+    uploadStrategy: UPLOAD_STRATEGY;
+    syncedFiles: WatchMappingSyncedFile[];
+    ignoredFiles: string[];
+}
+
+export interface EventQueueItem {
+    type: "upload" | "trash";
+    folderPath: string;
+    collectionName?: string;
+    paths?: string[];
+    files?: ElectronFile[];
+}

+ 3 - 4
web/packages/shared/electron/types.ts → web/packages/next/types/ipc.ts

@@ -3,8 +3,7 @@
 //
 //
 // See [Note: types.ts <-> preload.ts <-> ipc.ts]
 // See [Note: types.ts <-> preload.ts <-> ipc.ts]
 
 
-import type { ElectronFile } from "@ente/shared/upload/types";
-import type { WatchMapping } from "@ente/shared/watchFolder/types";
+import type { ElectronFile, WatchMapping } from "./file";
 
 
 export interface AppUpdateInfo {
 export interface AppUpdateInfo {
     autoUpdatable: boolean;
     autoUpdatable: boolean;
@@ -199,9 +198,9 @@ export interface ElectronAPIsType {
     checkExistsAndCreateDir: (dirPath: string) => Promise<void>;
     checkExistsAndCreateDir: (dirPath: string) => Promise<void>;
     saveStreamToDisk: (
     saveStreamToDisk: (
         path: string,
         path: string,
-        fileStream: ReadableStream<any>,
+        fileStream: ReadableStream,
     ) => Promise<void>;
     ) => Promise<void>;
-    saveFileToDisk: (path: string, file: any) => Promise<void>;
+    saveFileToDisk: (path: string, contents: string) => Promise<void>;
     readTextFile: (path: string) => Promise<string>;
     readTextFile: (path: string) => Promise<string>;
     isFolder: (dirPath: string) => Promise<boolean>;
     isFolder: (dirPath: string) => Promise<boolean>;
     moveFile: (oldPath: string, newPath: string) => Promise<void>;
     moveFile: (oldPath: string, newPath: string) => Promise<void>;

+ 1 - 1
web/packages/shared/components/Directory/index.tsx

@@ -1,5 +1,5 @@
+import ElectronAPIs from "@/next/electron";
 import LinkButton from "@ente/shared/components/LinkButton";
 import LinkButton from "@ente/shared/components/LinkButton";
-import ElectronAPIs from "@ente/shared/electron";
 import { logError } from "@ente/shared/sentry";
 import { logError } from "@ente/shared/sentry";
 import { Tooltip } from "@mui/material";
 import { Tooltip } from "@mui/material";
 import { styled } from "@mui/material/styles";
 import { styled } from "@mui/material/styles";

+ 1 - 1
web/packages/shared/crypto/helpers.ts

@@ -7,7 +7,7 @@ import { getActualKey } from "@ente/shared/user";
 import { KeyAttributes } from "@ente/shared/user/types";
 import { KeyAttributes } from "@ente/shared/user/types";
 import isElectron from "is-electron";
 import isElectron from "is-electron";
 import ComlinkCryptoWorker from ".";
 import ComlinkCryptoWorker from ".";
-import ElectronAPIs from "../electron";
+import ElectronAPIs from "@/next/electron";
 import { addLogLine } from "../logging";
 import { addLogLine } from "../logging";
 
 
 const LOGIN_SUB_KEY_LENGTH = 32;
 const LOGIN_SUB_KEY_LENGTH = 32;

+ 1 - 1
web/packages/shared/crypto/types.ts

@@ -1,4 +1,4 @@
-import { DataStream } from "@ente/shared/upload/types";
+import { DataStream } from "@/next/types/file";
 
 
 export interface LocalFileAttributes<
 export interface LocalFileAttributes<
     T extends string | Uint8Array | DataStream,
     T extends string | Uint8Array | DataStream,

+ 0 - 5
web/packages/shared/electron/index.ts

@@ -1,5 +0,0 @@
-import { ElectronAPIsType } from "./types";
-
-const ElectronAPIs: ElectronAPIsType = globalThis["ElectronAPIs"];
-
-export default ElectronAPIs;

+ 1 - 1
web/packages/shared/logging/index.ts

@@ -1,7 +1,7 @@
 import { inWorker, isDevBuild } from "@/next/env";
 import { inWorker, isDevBuild } from "@/next/env";
 import { logError } from "@ente/shared/sentry";
 import { logError } from "@ente/shared/sentry";
 import isElectron from "is-electron";
 import isElectron from "is-electron";
-import ElectronAPIs from "../electron";
+import ElectronAPIs from "@/next/electron";
 import { workerBridge } from "../worker/worker-bridge";
 import { workerBridge } from "../worker/worker-bridge";
 import { formatLog, logWeb } from "./web";
 import { formatLog, logWeb } from "./web";
 
 

+ 1 - 1
web/packages/shared/logging/web.ts

@@ -1,4 +1,5 @@
 import { isDevBuild } from "@/next/env";
 import { isDevBuild } from "@/next/env";
+import { ElectronFile } from "@/next/types/file";
 import { logError } from "@ente/shared/sentry";
 import { logError } from "@ente/shared/sentry";
 import {
 import {
     LS_KEYS,
     LS_KEYS,
@@ -8,7 +9,6 @@ import {
 } from "@ente/shared/storage/localStorage";
 } from "@ente/shared/storage/localStorage";
 import { addLogLine } from ".";
 import { addLogLine } from ".";
 import { formatDateTimeShort } from "../time/format";
 import { formatDateTimeShort } from "../time/format";
-import { ElectronFile } from "../upload/types";
 import type { User } from "../user/types";
 import type { User } from "../user/types";
 import { convertBytesToHumanReadable } from "../utils/size";
 import { convertBytesToHumanReadable } from "../utils/size";
 
 

+ 0 - 4
web/packages/shared/upload/constants.ts

@@ -1,4 +0,0 @@
-export enum UPLOAD_STRATEGY {
-    SINGLE_COLLECTION,
-    COLLECTION_PER_FOLDER,
-}

+ 0 - 24
web/packages/shared/watchFolder/types.ts

@@ -1,24 +0,0 @@
-import { UPLOAD_STRATEGY } from "@ente/shared/upload/constants";
-import { ElectronFile } from "@ente/shared/upload/types";
-
-export interface WatchMappingSyncedFile {
-    path: string;
-    uploadedFileID: number;
-    collectionID: number;
-}
-
-export interface WatchMapping {
-    rootFolderName: string;
-    folderPath: string;
-    uploadStrategy: UPLOAD_STRATEGY;
-    syncedFiles: WatchMappingSyncedFile[];
-    ignoredFiles: string[];
-}
-
-export interface EventQueueItem {
-    type: "upload" | "trash";
-    folderPath: string;
-    collectionName?: string;
-    paths?: string[];
-    files?: ElectronFile[];
-}

+ 1 - 1
web/packages/shared/worker/comlinkWorker.ts

@@ -1,6 +1,6 @@
 import { addLocalLog, logToDisk } from "@ente/shared/logging";
 import { addLocalLog, logToDisk } from "@ente/shared/logging";
 import { Remote, expose, wrap } from "comlink";
 import { Remote, expose, wrap } from "comlink";
-import ElectronAPIs from "../electron";
+import ElectronAPIs from "@/next/electron";
 import { logError } from "../sentry";
 import { logError } from "../sentry";
 
 
 export class ComlinkWorker<T extends new () => InstanceType<T>> {
 export class ComlinkWorker<T extends new () => InstanceType<T>> {