Pārlūkot izejas kodu

[web] Fix SSR build

Fixes the following error on the nightly build

    Error: Attempting to assert globalThis.electron in a non-electron context
        at r (/home/runner/work/ente/ente/web/apps/photos/.next/server/chunks/676.js:1:25418)
        ...

    > Build error occurred
    Error: Failed to collect page data for /gallery
        at /home/runner/work/ente/ente/web/node_modules/next/dist/build/utils.js:1258:15 {
      type: 'Error'
    }
Manav Rathi 1 gadu atpakaļ
vecāks
revīzija
d828bcb071
1 mainītis faili ar 2 papildinājumiem un 5 dzēšanām
  1. 2 5
      web/apps/photos/src/services/clip-service.ts

+ 2 - 5
web/apps/photos/src/services/clip-service.ts

@@ -1,6 +1,5 @@
 import { ensureElectron } from "@/next/electron";
 import { ensureElectron } from "@/next/electron";
 import log from "@/next/log";
 import log from "@/next/log";
-import type { Electron } from "@/next/types/ipc";
 import ComlinkCryptoWorker from "@ente/shared/crypto";
 import ComlinkCryptoWorker from "@ente/shared/crypto";
 import { CustomError } from "@ente/shared/error";
 import { CustomError } from "@ente/shared/error";
 import { Events, eventBus } from "@ente/shared/events";
 import { Events, eventBus } from "@ente/shared/events";
@@ -65,7 +64,6 @@ export interface CLIPIndexingStatus {
  * itself, is the same across clients - web and mobile.
  * itself, is the same across clients - web and mobile.
  */
  */
 class CLIPService {
 class CLIPService {
-    private electron: Electron;
     private embeddingExtractionInProgress: AbortController | null = null;
     private embeddingExtractionInProgress: AbortController | null = null;
     private reRunNeeded = false;
     private reRunNeeded = false;
     private indexingStatus: CLIPIndexingStatus = {
     private indexingStatus: CLIPIndexingStatus = {
@@ -80,7 +78,6 @@ class CLIPService {
     private unsupportedPlatform = false;
     private unsupportedPlatform = false;
 
 
     constructor() {
     constructor() {
-        this.electron = ensureElectron();
         this.liveEmbeddingExtractionQueue = new PQueue({
         this.liveEmbeddingExtractionQueue = new PQueue({
             concurrency: 1,
             concurrency: 1,
         });
         });
@@ -193,7 +190,7 @@ class CLIPService {
 
 
     getTextEmbedding = async (text: string): Promise<Float32Array> => {
     getTextEmbedding = async (text: string): Promise<Float32Array> => {
         try {
         try {
-            return electron.clipTextEmbedding(text);
+            return ensureElectron().clipTextEmbedding(text);
         } catch (e) {
         } catch (e) {
             if (e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)) {
             if (e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)) {
                 this.unsupportedPlatform = true;
                 this.unsupportedPlatform = true;
@@ -321,7 +318,7 @@ class CLIPService {
         const file = await localFile
         const file = await localFile
             .arrayBuffer()
             .arrayBuffer()
             .then((buffer) => new Uint8Array(buffer));
             .then((buffer) => new Uint8Array(buffer));
-        return await electron.clipImageEmbedding(file);
+        return await ensureElectron().clipImageEmbedding(file);
     };
     };
 
 
     private encryptAndUploadEmbedding = async (
     private encryptAndUploadEmbedding = async (