π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
DOMParser is not available in web workers
Manav Rathi0290991e2cb1
diff --git a/web/apps/photos/package.json b/web/apps/photos/package.jsonindex 78f850a3c5..b881b9ac6b 100644--- a/web/apps/photos/package.json+++ b/web/apps/photos/package.json@@ -12,6 +12,7 @@"@ente/shared": "*","@mui/x-date-pickers": "^5.0.0-alpha.6","@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/packages/new/photos/services/ml/worker.ts b/web/packages/new/photos/services/ml/worker.tsindex 9070536da5..e50781fe20 100644--- a/web/packages/new/photos/services/ml/worker.ts+++ b/web/packages/new/photos/services/ml/worker.ts@@ -7,6 +7,7 @@ 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 } from "comlink";import downloadManager from "../download";import { cmpNewLib2, extractRawExif } from "../exif";@@ -94,6 +95,21 @@ 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());++ // Take an explicit dependency on the DOMParser provided by xmldom so+ // that webpack does not tree shake it.+ //+ // 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 want to use the @xmldom/xmldom version. For this, we need to+ // also explicitly refer to it so that webpack does not tree shake it,+ // since inside ExifReader it is weakly referenced using+ // `__non_webpack_require__('@xmldom/xmldom')`.+ DOMParser;}/**