diff --git a/package-lock.json b/package-lock.json index 5f25ec828..0ccf21cf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.4.5", "dependencies": { "@atlaskit/pragmatic-drag-and-drop": "^1.3.1", - "@comfyorg/comfyui-electron-types": "^0.2.16", + "@comfyorg/comfyui-electron-types": "^0.3.1", "@comfyorg/litegraph": "^0.8.31", "@primevue/themes": "^4.0.5", "@vueuse/core": "^11.0.0", @@ -1917,10 +1917,9 @@ "dev": true }, "node_modules/@comfyorg/comfyui-electron-types": { - "version": "0.2.16", - "resolved": "https://registry.npmjs.org/@comfyorg/comfyui-electron-types/-/comfyui-electron-types-0.2.16.tgz", - "integrity": "sha512-Hm6NeyMK4sd2V5AyOnvfI+tvCsXr5NBG8wOZlWyyD17ADpbQnpm6qPMWzvm4vCp/YvTR7cUbDGiY0quhofuQGg==", - "license": "GPL-3.0-only" + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@comfyorg/comfyui-electron-types/-/comfyui-electron-types-0.3.2.tgz", + "integrity": "sha512-3vpAAZq4rNd6oUFvX5s1kor2U7xN3Br8gftdO40IvhLLikttK2cZhPra6YlnzuYIU1gK+PBGEJClvjFnQyIYlA==" }, "node_modules/@comfyorg/litegraph": { "version": "0.8.31", diff --git a/package.json b/package.json index 9eddec9af..ee13243ad 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ }, "dependencies": { "@atlaskit/pragmatic-drag-and-drop": "^1.3.1", - "@comfyorg/comfyui-electron-types": "^0.2.16", + "@comfyorg/comfyui-electron-types": "^0.3.1", "@comfyorg/litegraph": "^0.8.31", "@primevue/themes": "^4.0.5", "@vueuse/core": "^11.0.0", diff --git a/src/stores/electronDownloadStore.ts b/src/stores/electronDownloadStore.ts index 5b9cccce5..93d3aa6f4 100644 --- a/src/stores/electronDownloadStore.ts +++ b/src/stores/electronDownloadStore.ts @@ -1,13 +1,13 @@ import { ref } from 'vue' import { defineStore } from 'pinia' import { isElectron, electronAPI } from '@/utils/envUtil' +import { DownloadState, DownloadStatus } from '@comfyorg/comfyui-electron-types' -export interface ElectronDownload { - url: string - status: 'paused' | 'in_progress' | 'cancelled' - progress: number - savePath: string - filename: string +export interface ElectronDownload + extends Pick { + progress?: number + savePath?: string + status?: DownloadStatus } /** Electron donwloads store handler */ @@ -20,15 +20,14 @@ export const useElectronDownloadStore = defineStore('downloads', () => { const initialize = async () => { if (isElectron()) { - const allDownloads: ElectronDownload[] = - (await DownloadManager.getAllDownloads()) as unknown as ElectronDownload[] + const allDownloads = await DownloadManager.getAllDownloads() for (const download of allDownloads) { downloads.value.push(download) } // ToDO: replace with ElectronDownload type - DownloadManager.onDownloadProgress((data: any) => { + DownloadManager.onDownloadProgress((data) => { if (!findByUrl(data.url)) { downloads.value.push(data) } @@ -51,8 +50,11 @@ export const useElectronDownloadStore = defineStore('downloads', () => { url, savePath, filename - }: Pick) => - DownloadManager.startDownload(url, savePath, filename) + }: { + url: string + savePath: string + filename: string + }) => DownloadManager.startDownload(url, savePath, filename) const pause = (url: string) => DownloadManager.pauseDownload(url) const resume = (url: string) => DownloadManager.resumeDownload(url) const cancel = (url: string) => DownloadManager.cancelDownload(url) diff --git a/vite.config.mts b/vite.config.mts index 7d454479b..a64062c7d 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -150,7 +150,10 @@ export default defineConfig({ rollupOptions: { // Disabling tree-shaking // Prevent vite remove unused exports - treeshake: false + treeshake: false, + external: [ + 'electron' + ] } },