diff --git a/web/apps/cast/src/constants/ffmpeg.ts b/web/apps/cast/src/constants/ffmpeg.ts deleted file mode 100644 index 9ecc41eb5..000000000 --- a/web/apps/cast/src/constants/ffmpeg.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const INPUT_PATH_PLACEHOLDER = "INPUT"; -export const FFMPEG_PLACEHOLDER = "FFMPEG"; -export const OUTPUT_PATH_PLACEHOLDER = "OUTPUT"; diff --git a/web/apps/cast/src/services/ffmpeg/ffmpegFactory.ts b/web/apps/cast/src/services/ffmpeg/ffmpegFactory.ts deleted file mode 100644 index 0f7d226c8..000000000 --- a/web/apps/cast/src/services/ffmpeg/ffmpegFactory.ts +++ /dev/null @@ -1,22 +0,0 @@ -import ComlinkFFmpegWorker from "utils/comlink/ComlinkFFmpegWorker"; - -export interface IFFmpeg { - run: ( - cmd: string[], - inputFile: File, - outputFilename: string, - dontTimeout?: boolean, - ) => Promise; -} - -class FFmpegFactory { - private client: IFFmpeg; - async getFFmpegClient() { - if (!this.client) { - this.client = await ComlinkFFmpegWorker.getInstance(); - } - return this.client; - } -} - -export default new FFmpegFactory(); diff --git a/web/apps/cast/src/services/ffmpeg/ffmpegService.ts b/web/apps/cast/src/services/ffmpeg/ffmpegService.ts deleted file mode 100644 index 325f1d66b..000000000 --- a/web/apps/cast/src/services/ffmpeg/ffmpegService.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { logError } from "@ente/shared/sentry"; -import { - FFMPEG_PLACEHOLDER, - INPUT_PATH_PLACEHOLDER, - OUTPUT_PATH_PLACEHOLDER, -} from "constants/ffmpeg"; -import ffmpegFactory from "./ffmpegFactory"; - -export async function convertToMP4(file: File) { - try { - const ffmpegClient = await ffmpegFactory.getFFmpegClient(); - return await ffmpegClient.run( - [ - FFMPEG_PLACEHOLDER, - "-i", - INPUT_PATH_PLACEHOLDER, - "-preset", - "ultrafast", - OUTPUT_PATH_PLACEHOLDER, - ], - file, - "output.mp4", - true, - ); - } catch (e) { - logError(e, "ffmpeg convertToMP4 failed"); - throw e; - } -} diff --git a/web/apps/cast/src/services/wasm/ffmpeg.ts b/web/apps/cast/src/services/wasm/ffmpeg.ts deleted file mode 100644 index 154f5ac61..000000000 --- a/web/apps/cast/src/services/wasm/ffmpeg.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { addLogLine } from "@ente/shared/logging"; -import { logError } from "@ente/shared/sentry"; -import { promiseWithTimeout } from "@ente/shared/utils"; -import QueueProcessor from "@ente/shared/utils/queueProcessor"; -import { generateTempName } from "@ente/shared/utils/temp"; -import { createFFmpeg, FFmpeg } from "ffmpeg-wasm"; -import { getUint8ArrayView } from "services/readerService"; - -const INPUT_PATH_PLACEHOLDER = "INPUT"; -const FFMPEG_PLACEHOLDER = "FFMPEG"; -const OUTPUT_PATH_PLACEHOLDER = "OUTPUT"; - -const FFMPEG_EXECUTION_WAIT_TIME = 30 * 1000; - -export class WasmFFmpeg { - private ffmpeg: FFmpeg; - private ready: Promise = null; - private ffmpegTaskQueue = new QueueProcessor(); - - constructor() { - this.ffmpeg = createFFmpeg({ - corePath: "/js/ffmpeg/ffmpeg-core.js", - mt: false, - }); - - this.ready = this.init(); - } - - private async init() { - if (!this.ffmpeg.isLoaded()) { - await this.ffmpeg.load(); - } - } - - async run( - cmd: string[], - inputFile: File, - outputFileName: string, - dontTimeout = false, - ) { - const response = this.ffmpegTaskQueue.queueUpRequest(() => { - if (dontTimeout) { - return this.execute(cmd, inputFile, outputFileName); - } else { - return promiseWithTimeout( - this.execute(cmd, inputFile, outputFileName), - FFMPEG_EXECUTION_WAIT_TIME, - ); - } - }); - try { - return await response.promise; - } catch (e) { - logError(e, "ffmpeg run failed"); - throw e; - } - } - - private async execute( - cmd: string[], - inputFile: File, - outputFileName: string, - ) { - let tempInputFilePath: string; - let tempOutputFilePath: string; - try { - await this.ready; - const extension = getFileExtension(inputFile.name); - const tempNameSuffix = extension ? `input.${extension}` : "input"; - tempInputFilePath = `${generateTempName(10, tempNameSuffix)}`; - this.ffmpeg.FS( - "writeFile", - tempInputFilePath, - await getUint8ArrayView(inputFile), - ); - tempOutputFilePath = `${generateTempName(10, outputFileName)}`; - - cmd = cmd.map((cmdPart) => { - if (cmdPart === FFMPEG_PLACEHOLDER) { - return ""; - } else if (cmdPart === INPUT_PATH_PLACEHOLDER) { - return tempInputFilePath; - } else if (cmdPart === OUTPUT_PATH_PLACEHOLDER) { - return tempOutputFilePath; - } else { - return cmdPart; - } - }); - addLogLine(`${cmd}`); - await this.ffmpeg.run(...cmd); - return new File( - [this.ffmpeg.FS("readFile", tempOutputFilePath)], - outputFileName, - ); - } finally { - try { - this.ffmpeg.FS("unlink", tempInputFilePath); - } catch (e) { - logError(e, "unlink input file failed"); - } - try { - this.ffmpeg.FS("unlink", tempOutputFilePath); - } catch (e) { - logError(e, "unlink output file failed"); - } - } - } -} - -function getFileExtension(filename: string) { - const lastDotPosition = filename.lastIndexOf("."); - if (lastDotPosition === -1) return null; - else { - return filename.slice(lastDotPosition + 1); - } -} diff --git a/web/apps/cast/src/utils/comlink/ComlinkFFmpegWorker.ts b/web/apps/cast/src/utils/comlink/ComlinkFFmpegWorker.ts deleted file mode 100644 index 77d140bdb..000000000 --- a/web/apps/cast/src/utils/comlink/ComlinkFFmpegWorker.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Remote } from "comlink"; -import { DedicatedFFmpegWorker } from "worker/ffmpeg.worker"; -import { ComlinkWorker } from "./comlinkWorker"; - -class ComlinkFFmpegWorker { - private comlinkWorkerInstance: Promise>; - - async getInstance() { - if (!this.comlinkWorkerInstance) { - const comlinkWorker = getDedicatedFFmpegWorker(); - this.comlinkWorkerInstance = comlinkWorker.remote; - } - return this.comlinkWorkerInstance; - } -} - -const getDedicatedFFmpegWorker = () => { - const cryptoComlinkWorker = new ComlinkWorker( - "ente-ffmpeg-worker", - new Worker(new URL("worker/ffmpeg.worker.ts", import.meta.url)), - ); - return cryptoComlinkWorker; -}; - -export default new ComlinkFFmpegWorker(); diff --git a/web/apps/cast/src/worker/ffmpeg.worker.ts b/web/apps/cast/src/worker/ffmpeg.worker.ts deleted file mode 100644 index d3f503abb..000000000 --- a/web/apps/cast/src/worker/ffmpeg.worker.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as Comlink from "comlink"; -import { WasmFFmpeg } from "services/wasm/ffmpeg"; - -export class DedicatedFFmpegWorker { - wasmFFmpeg: WasmFFmpeg; - constructor() { - this.wasmFFmpeg = new WasmFFmpeg(); - } - - run(cmd, inputFile, outputFileName, dontTimeout) { - return this.wasmFFmpeg.run(cmd, inputFile, outputFileName, dontTimeout); - } -} - -Comlink.expose(DedicatedFFmpegWorker, self); diff --git a/web/apps/photos/package.json b/web/apps/photos/package.json index deac7ad04..59d928c1e 100644 --- a/web/apps/photos/package.json +++ b/web/apps/photos/package.json @@ -44,7 +44,6 @@ "photoswipe": "file:./thirdparty/photoswipe", "piexifjs": "^1.0.6", "pure-react-carousel": "^1.30.1", - "react-datepicker": "^4.16.0", "react-dropzone": "^11.2.4", "react-otp-input": "^2.3.1", "react-select": "^4.3.1", @@ -65,14 +64,11 @@ "@types/bs58": "^4.0.1", "@types/leaflet": "^1.9.3", "@types/photoswipe": "^4.1.1", - "@types/react-collapse": "^5.0.1", - "@types/react-datepicker": "^4.15.0", "@types/react-select": "^4.0.15", "@types/react-virtualized-auto-sizer": "^1.0.1", "@types/react-window": "^1.8.2", "@types/react-window-infinite-loader": "^1.0.3", "@types/uuid": "^9.0.2", - "@types/wicg-file-system-access": "^2020.9.5", "@types/zxcvbn": "^4.4.1" } } diff --git a/web/apps/photos/src/components/PhotoViewer/index.tsx b/web/apps/photos/src/components/PhotoViewer/index.tsx index 425290023..344a7722a 100644 --- a/web/apps/photos/src/components/PhotoViewer/index.tsx +++ b/web/apps/photos/src/components/PhotoViewer/index.tsx @@ -1,5 +1,4 @@ import { logError } from "@ente/shared/sentry"; -import classnames from "classnames"; import Photoswipe from "photoswipe"; import PhotoswipeUIDefault from "photoswipe/dist/photoswipe-ui-default"; import { useContext, useEffect, useMemo, useRef, useState } from "react"; @@ -84,7 +83,6 @@ interface Iprops { gettingData: (instance: any, index: number, item: EnteFile) => void; getConvertedItem: (instance: any, index: number, item: EnteFile) => void; id?: string; - className?: string; favItemIds: Set; tempDeletedFileIds: Set; setTempDeletedFileIds?: (value: Set) => void; @@ -724,13 +722,11 @@ function PhotoViewer(props: Iprops) { const scheduleUpdate = () => (needUpdate.current = true); const { id } = props; - let { className } = props; - className = classnames(["pswp", className]).trim(); return ( <>