Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 18 additions & 42 deletions src/stores/executionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,50 +92,26 @@ export const useExecutionStore = defineStore('execution', () => {
})

function bindExecutionEvents() {
api.addEventListener(
'execution_start',
handleExecutionStart as EventListener
)
api.addEventListener(
'execution_cached',
handleExecutionCached as EventListener
)
api.addEventListener('executed', handleExecuted as EventListener)
api.addEventListener('executing', handleExecuting as EventListener)
api.addEventListener('progress', handleProgress as EventListener)
api.addEventListener('status', handleStatus as EventListener)
api.addEventListener(
'execution_error',
handleExecutionError as EventListener
)
api.addEventListener('execution_start', handleExecutionStart)
api.addEventListener('execution_cached', handleExecutionCached)
api.addEventListener('executed', handleExecuted)
api.addEventListener('executing', handleExecuting)
api.addEventListener('progress', handleProgress)
api.addEventListener('status', handleStatus)
api.addEventListener('execution_error', handleExecutionError)
}
api.addEventListener('progress_text', handleProgressText as EventListener)
api.addEventListener(
'display_component',
handleDisplayComponent as EventListener
)
api.addEventListener('progress_text', handleProgressText)
api.addEventListener('display_component', handleDisplayComponent)

function unbindExecutionEvents() {
api.removeEventListener(
'execution_start',
handleExecutionStart as EventListener
)
api.removeEventListener(
'execution_cached',
handleExecutionCached as EventListener
)
api.removeEventListener('executed', handleExecuted as EventListener)
api.removeEventListener('executing', handleExecuting as EventListener)
api.removeEventListener('progress', handleProgress as EventListener)
api.removeEventListener('status', handleStatus as EventListener)
api.removeEventListener(
'execution_error',
handleExecutionError as EventListener
)
api.removeEventListener(
'progress_text',
handleProgressText as EventListener
)
api.removeEventListener('execution_start', handleExecutionStart)
api.removeEventListener('execution_cached', handleExecutionCached)
api.removeEventListener('executed', handleExecuted)
api.removeEventListener('executing', handleExecuting)
api.removeEventListener('progress', handleProgress)
api.removeEventListener('status', handleStatus)
api.removeEventListener('execution_error', handleExecutionError)
api.removeEventListener('progress_text', handleProgressText)
}

function handleExecutionStart(e: CustomEvent<ExecutionStartWsMessage>) {
Expand Down Expand Up @@ -184,7 +160,7 @@ export const useExecutionStore = defineStore('execution', () => {
clientId.value = api.clientId

// Once we've received the clientId we no longer need to listen
api.removeEventListener('status', handleStatus as EventListener)
api.removeEventListener('status', handleStatus)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/types/treeExplorerTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import type { InjectionKey, ModelRef } from 'vue'

export interface TreeNode extends PrimeVueTreeNode {
label: string
children?: TreeNode[]
children?: this[]
}

export interface TreeExplorerNode<T = any> extends TreeNode {
data?: T
children?: TreeExplorerNode<T>[]
children?: this[]
icon?: string
/**
* Function to override what icon to use for the node.
Expand Down Expand Up @@ -62,7 +62,7 @@ export interface TreeExplorerNode<T = any> extends TreeNode {
}

export interface RenderedTreeExplorerNode<T = any> extends TreeExplorerNode<T> {
children?: RenderedTreeExplorerNode<T>[]
children?: this[]
icon: string
type: 'folder' | 'node'
/** Total number of leaves in the subtree */
Expand Down
12 changes: 5 additions & 7 deletions src/utils/nodeDefUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const mergeNumericInputSpec = <T extends IntInputSpec | FloatInputSpec>(
}

return mergeCommonInputSpec(
[type, { ...options1, ...mergedOptions }] as unknown as T,
[type, { ...options2, ...mergedOptions }] as unknown as T
[type, { ...options1, ...mergedOptions }] as T,
[type, { ...options2, ...mergedOptions }] as T
)
}

Expand All @@ -84,8 +84,8 @@ const mergeComboInputSpec = <T extends ComboInputSpec | ComboInputSpecV2>(
}

return mergeCommonInputSpec(
['COMBO', { ...options1, options: intersection }] as unknown as T,
['COMBO', { ...options2, options: intersection }] as unknown as T
['COMBO', { ...options1, options: intersection }] as T,
['COMBO', { ...options2, options: intersection }] as T
)
}

Expand All @@ -107,9 +107,7 @@ const mergeCommonInputSpec = <T extends InputSpec>(
return value1 === value2 || (_.isNil(value1) && _.isNil(value2))
})

return mergeIsValid
? ([type, { ...options1, ...options2 }] as unknown as T)
: null
return mergeIsValid ? ([type, { ...options1, ...options2 }] as T) : null
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/utils/treeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const findNodeByKey = <T extends TreeNode>(
return null
}
for (const child of root.children) {
const result = findNodeByKey(child as T, key)
const result = findNodeByKey(child, key)
if (result) {
return result
}
Expand All @@ -130,11 +130,11 @@ export const findNodeByKey = <T extends TreeNode>(
* @returns A deep clone of the node.
*/
export function cloneTree<T extends TreeNode>(node: T): T {
const clone: T = { ...node } as T
const clone = { ...node }

// Clone children recursively
if (node.children && node.children.length > 0) {
clone.children = node.children.map((child) => cloneTree(child as T))
clone.children = node.children.map((child) => cloneTree(child))
}

return clone
Expand Down
5 changes: 2 additions & 3 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import dotenv from 'dotenv'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
import { type UserConfig, defineConfig } from 'vite'
import { createHtmlPlugin } from 'vite-plugin-html'
import vueDevTools from 'vite-plugin-vue-devtools'
import type { UserConfigExport } from 'vitest/config'

import {
addElementVnodeExportPlugin,
Expand Down Expand Up @@ -154,4 +153,4 @@ export default defineConfig({
optimizeDeps: {
exclude: ['@comfyorg/litegraph', '@comfyorg/comfyui-electron-types']
}
}) as UserConfigExport
}) satisfies UserConfig as UserConfig
3 changes: 1 addition & 2 deletions vite.electron.config.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Plugin, defineConfig } from 'vite'
import { mergeConfig } from 'vite'
import type { UserConfig } from 'vitest/config'

import baseConfig from './vite.config.mts'

Expand Down Expand Up @@ -83,7 +82,7 @@ const mockElectronAPI: Plugin = {
}

export default mergeConfig(
baseConfig as unknown as UserConfig,
baseConfig,
defineConfig({
plugins: [mockElectronAPI]
})
Expand Down