π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Can't circumvert that way
Manav Rathi180389f3e25b
diff --git a/desktop/src/preload.ts b/desktop/src/preload.tsindex 16b271ce9f..699e1ebc52 100644--- a/desktop/src/preload.ts+++ b/desktop/src/preload.ts@@ -163,20 +163,7 @@ const ffmpegExec = (// - ML-const createMLSession = () => {- ipcRenderer.send("createMLSession");-- // The main process will do its thing, and send back the port it created to- // us by sending an message on the "createMLSession/port" channel via the- // postMessage API. This roundabout way is needed because MessagePorts- // cannot be transferred via the usual send/invoke pattern.-- return new Promise((resolve) => {- ipcRenderer.on("createMLSession/port", (event) => {- resolve(event.ports[0]);- });- });-};+const createMLSession = () => ipcRenderer.send("createMLSession");const computeCLIPImageEmbedding = (input: Float32Array) =>ipcRenderer.invoke("computeCLIPImageEmbedding", input);diff --git a/web/packages/base/types/ipc.ts b/web/packages/base/types/ipc.tsindex 7188019408..122735e31a 100644--- a/web/packages/base/types/ipc.ts+++ b/web/packages/base/types/ipc.ts@@ -339,14 +339,14 @@ export interface Electron {** This creates a new Node.js utility process, and sets things up so that we* can communicate directly with that utility process using a- * {@link MessagePort} we get back.+ * {@link MessagePort} that gets posted using "createMLSession/port".** For more details about the IPC flow, see: [Note: ML IPC].** Note: For simplicity of implementation, we assume that there is at most* one outstanding call to {@link createMLSession}.*/- createMLSession: () => Promise<MessagePort>;+ createMLSession: () => void;/*** Return a CLIP embedding of the given image.diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.tsindex 493ac6612f..1c5d5e9437 100644--- a/web/packages/new/photos/services/ml/index.ts+++ b/web/packages/new/photos/services/ml/index.ts@@ -9,6 +9,7 @@ import log from "@/base/log";import { ComlinkWorker } from "@/base/worker/comlink-worker";import { FileType } from "@/media/file-type";import type { EnteFile } from "@/new/photos/types/file";+import { ensure } from "@/utils/ensure";import { throttled } from "@/utils/promise";import { proxy } from "comlink";import { isInternalUser } from "../feature-flags";@@ -116,11 +117,29 @@ export const initML = () => {_isMLEnabled = isMLEnabledLocal();void (async () => {console.log("yyy", 1);- const port = await ensureElectron().createMLSession();+ const port = await createMLSession();console.log("yyy", port);})();};+const createMLSession = async () => {+ ensureElectron().createMLSession();++ // The main process will do its thing, and send back the port it created to+ // us by sending an message on the "createMLSession/port" channel via the+ // postMessage API. This roundabout way is needed because MessagePorts+ // cannot be transferred via the usual send/invoke pattern.++ return new Promise((resolve) => {+ window.onmessage = ({ source, data, ports }: MessageEvent) => {+ // The source check verifies that the message is coming from the+ // preload script. The data is used as an arbitrary identifying tag.+ if (source == window && data == "createMLSession/port")+ resolve(ensure(ports[0]));+ };+ });+};+export const logoutML = async () => {// `terminateMLWorker` is conceptually also part of this sequence, but for// the reasons mentioned in [Note: Caching IDB instances in separate