Move down
This commit is contained in:
parent
5c87bd0d6a
commit
7d56230b91
7 changed files with 34 additions and 12 deletions
|
@ -23,7 +23,6 @@
|
|||
"ffmpeg-wasm": "file:./thirdparty/ffmpeg-wasm",
|
||||
"formik": "^2.1.5",
|
||||
"hdbscan": "0.0.1-alpha.5",
|
||||
"heic-convert": "^2.0.0",
|
||||
"idb": "^7.1.1",
|
||||
"leaflet": "^1.9.4",
|
||||
"leaflet-defaulticon-compatibility": "^0.1.1",
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { createHEICConvertComlinkWorker } from "@/media/worker/heic-convert";
|
||||
import type { DedicatedHEICConvertWorker } from "@/media/worker/heic-convert.worker";
|
||||
import log from "@/next/log";
|
||||
import { ComlinkWorker } from "@/next/worker/comlink-worker";
|
||||
import { CustomError } from "@ente/shared/error";
|
||||
import { retryAsyncFunction } from "@ente/shared/utils";
|
||||
import QueueProcessor from "@ente/shared/utils/queueProcessor";
|
||||
import { type DedicatedHEICConvertWorker } from "worker/heic-convert.worker";
|
||||
|
||||
/**
|
||||
* Convert a HEIC image to a JPEG.
|
||||
|
@ -29,7 +30,7 @@ class HEICConverter {
|
|||
if (this.workerPool.length > 0) return;
|
||||
this.workerPool = [];
|
||||
for (let i = 0; i < WORKER_POOL_SIZE; i++)
|
||||
this.workerPool.push(createComlinkWorker());
|
||||
this.workerPool.push(createHEICConvertComlinkWorker());
|
||||
}
|
||||
|
||||
async convert(fileBlob: Blob): Promise<Blob> {
|
||||
|
@ -79,7 +80,7 @@ class HEICConverter {
|
|||
} catch (e) {
|
||||
log.error("HEIC conversion failed", e);
|
||||
convertWorker.terminate();
|
||||
this.workerPool.push(createComlinkWorker());
|
||||
this.workerPool.push(createHEICConvertComlinkWorker());
|
||||
throw e;
|
||||
}
|
||||
}, WAIT_TIME_BEFORE_NEXT_ATTEMPT_IN_MICROSECONDS),
|
||||
|
@ -99,9 +100,3 @@ class HEICConverter {
|
|||
|
||||
/** The singleton instance of {@link HEICConverter}. */
|
||||
const converter = new HEICConverter();
|
||||
|
||||
const createComlinkWorker = () =>
|
||||
new ComlinkWorker<typeof DedicatedHEICConvertWorker>(
|
||||
"heic-convert-worker",
|
||||
new Worker(new URL("worker/heic-convert.worker.ts", import.meta.url)),
|
||||
);
|
||||
|
|
|
@ -141,6 +141,14 @@ some cases.
|
|||
became ESM only - for our limited use case, the custom Webpack configuration
|
||||
that entails is not worth the upgrade.
|
||||
|
||||
- [heic-convert](https://github.com/catdad-experiments/heic-convert) is used
|
||||
for converting HEIC files (which browsers don't natively support) into JPEG.
|
||||
|
||||
## Processing
|
||||
|
||||
- [comlink](https://github.com/GoogleChromeLabs/comlink) provides a minimal
|
||||
layer on top of Web Workers to make them more easier to use.
|
||||
|
||||
## Photos app specific
|
||||
|
||||
- [react-dropzone](https://github.com/react-dropzone/react-dropzone/) is a
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
"dependencies": {
|
||||
"@/next": "*",
|
||||
"file-type": "16.5.4",
|
||||
"heic-convert": "^2.1",
|
||||
"jszip": "^3.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/heic-convert": "^1.2.3"
|
||||
}
|
||||
}
|
||||
|
|
11
web/packages/media/worker/heic-convert.ts
Normal file
11
web/packages/media/worker/heic-convert.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { ComlinkWorker } from "@/next/worker/comlink-worker";
|
||||
import type { DedicatedHEICConvertWorker } from "./heic-convert.worker";
|
||||
|
||||
export const createHEICConvertWebWorker = () =>
|
||||
new Worker(new URL("worker/heic-convert.worker.ts", import.meta.url));
|
||||
|
||||
export const createHEICConvertComlinkWorker = () =>
|
||||
new ComlinkWorker<typeof DedicatedHEICConvertWorker>(
|
||||
"heic-convert-worker",
|
||||
createHEICConvertWebWorker(),
|
||||
);
|
|
@ -1015,6 +1015,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.14.tgz#319b63ad6df705ee2a65a73ef042c8271e696613"
|
||||
integrity sha512-WCfD5Ht3ZesJUsONdhvm84dmzWOiOzOAqOncN0++w0lBw1o8OuDNJF2McvvCef/yBqb/HYRahp1BYtODFQ8bRg==
|
||||
|
||||
"@types/heic-convert@^1.2.3":
|
||||
version "1.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/heic-convert/-/heic-convert-1.2.3.tgz#0705f36e467e7b6180806edd0b3f1e673514ff8c"
|
||||
integrity sha512-5LJ2fGuVk/gnOLihoT56xJwrXxfnNepGvrHwlW5ZtT3HS4jO1AqBaAHCxXUpnY9UaD3zYcyxXMRM2fNN1AFF/Q==
|
||||
|
||||
"@types/hoist-non-react-statics@^3.3.1":
|
||||
version "3.3.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.5.tgz#dab7867ef789d87e2b4b0003c9d65c49cc44a494"
|
||||
|
@ -2839,7 +2844,7 @@ hdbscan@0.0.1-alpha.5:
|
|||
dependencies:
|
||||
kd-tree-javascript "^1.0.3"
|
||||
|
||||
heic-convert@^2.0.0:
|
||||
heic-convert@^2.1:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/heic-convert/-/heic-convert-2.1.0.tgz#7f764529e37591ae263ef49582d1d0c13491526e"
|
||||
integrity sha512-1qDuRvEHifTVAj3pFIgkqGgJIr0M3X7cxEPjEp0oG4mo8GFjq99DpCo8Eg3kg17Cy0MTjxpFdoBHOatj7ZVKtg==
|
||||
|
@ -3321,7 +3326,7 @@ libsodium-wrappers@0.7.9:
|
|||
dependencies:
|
||||
libsodium "^0.7.0"
|
||||
|
||||
libsodium@0.7.9, libsodium@^0.7.0:
|
||||
libsodium@^0.7.0:
|
||||
version "0.7.9"
|
||||
resolved "https://registry.yarnpkg.com/libsodium/-/libsodium-0.7.9.tgz#4bb7bcbf662ddd920d8795c227ae25bbbfa3821b"
|
||||
integrity sha512-gfeADtR4D/CM0oRUviKBViMGXZDgnFdMKMzHsvBdqLBHd9ySi6EtYnmuhHVDDYgYpAO8eU8hEY+F8vIUAPh08A==
|
||||
|
|
Loading…
Add table
Reference in a new issue