π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
- @xmldom/xmldom
Manav Rathi777f9e9704bd
diff --git a/web/apps/photos/package.json b/web/apps/photos/package.jsonindex f8b043adce..1a4f265b3e 100644--- a/web/apps/photos/package.json+++ b/web/apps/photos/package.json@@ -10,7 +10,6 @@"@ente/eslint-config": "*","@ente/shared": "*","@stripe/stripe-js": "^1.13.2",- "@xmldom/xmldom": "^0.8.10","bip39": "^3.0.4","bs58": "^5.0.0","chrono-node": "^2.2.6",diff --git a/web/docs/dependencies.md b/web/docs/dependencies.mdindex 506df1c0ad..c28824b288 100644--- a/web/docs/dependencies.md+++ b/web/docs/dependencies.md@@ -201,11 +201,8 @@ For more details, see [translations.md](translations.md).## Media- [ExifReader](https://github.com/mattiasw/ExifReader) is used for Exif- parsing. We also need its optional peer dependency- [@xmldom/xmldom](https://github.com/xmldom/xmldom) since the browser's- DOMParser is not available in web workers.- [piexifjs](https://github.com/hMatoba/piexifjs) is used for writing back- Exif (only supports JPEG).+ parsing. [piexifjs](https://github.com/hMatoba/piexifjs) is used for writing+ back Exif (only supports JPEG).- [jszip](https://github.com/Stuk/jszip) is used for reading zip files in theweb code (Live photos are zip files under the hood). Note that the desktopdiff --git a/web/packages/new/photos/services/exif.ts b/web/packages/new/photos/services/exif.tsindex 5e7a7ea8ec..544d367419 100644--- a/web/packages/new/photos/services/exif.ts+++ b/web/packages/new/photos/services/exif.ts@@ -1,3 +1,4 @@+import { inWorker } from "@/base/env";import log from "@/base/log";import {parseMetadataDate,@@ -477,6 +478,17 @@ export type RawExifTags = Omit<ExifReader.ExpandedTags, "Thumbnail" | "xmp"> & {* to know about ExifReader specifically.*/export const extractRawExif = async (blob: Blob): Promise<RawExifTags> => {+ // The browser's DOMParser is not available in web workers. So if this+ // function gets called in from a web worker, then it would not be able to+ // parse XMP tags.+ //+ // There is a way around this problem, by also installing ExifReader's+ // optional peer dependency "@xmldom/xmldom". But since we currently have no+ // use case for calling this code in a web worker, we just abort immediately+ // to let future us know that we need to install it.+ if (inWorker())+ throw new Error("DOMParser is not available in web workers");+const tags = await ExifReader.load(await blob.arrayBuffer(), {async: true,expanded: true,diff --git a/web/packages/new/photos/services/ml/worker.ts b/web/packages/new/photos/services/ml/worker.tsindex 2fe408f9bb..2434b30779 100644--- a/web/packages/new/photos/services/ml/worker.ts+++ b/web/packages/new/photos/services/ml/worker.ts@@ -8,10 +8,8 @@ import type { EnteFile } from "@/new/photos/types/file";import { fileLogID } from "@/new/photos/utils/file";import { ensure } from "@/utils/ensure";import { wait } from "@/utils/promise";-import { DOMParser } from "@xmldom/xmldom";import { expose, wrap } from "comlink";import downloadManager from "../download";-import { extractRawExif, type RawExifTags } from "../exif";import { getAllLocalFiles, getLocalTrashedFiles } from "../files";import type { UploadItem } from "../upload/types";import {@@ -105,24 +103,6 @@ export class MLWorker {// Initialize the downloadManager running in the web worker with the// user's token. It'll be used to download files to index if needed.await downloadManager.init(await ensureAuthToken());-- // Normally, DOMParser is available to web code, so our Exif library- // (ExifReader) has an optional dependency on the the non-browser- // alternative DOMParser provided by @xmldom/xmldom.- //- // But window.DOMParser is not available to web workers.- //- // So we need to get ExifReader to use the @xmldom/xmldom version.- // ExifReader references it using the following code:- //- // __non_webpack_require__('@xmldom/xmldom')- //- // So we need to explicitly reference it to ensure that it does not get- // tree shaken by webpack. But ensuring it is part of the bundle does- // not seem to work (for reasons I don't yet understand), so we also- // need to monkey patch it (This also ensures that it is not tree- // shaken).- globalThis.DOMParser = DOMParser;}/**