[Extension API] Custom commands and keybindings (#1075)

* Add keybinding schema

* nit

* Keybinding store

* nit

* wip

* Bind condition on ComfyCommand

* Add settings

* nit

* Revamp keybinding store

* Add tests

* Add load keybinding

* load extension keybindings

* Load extension commands

* Handle keybindings

* test

* Keybinding playwright test

* Update README

* nit

* Remove log

* Remove system stats fromt logging.ts
This commit is contained in:
Chenlei Hu
2024-10-02 21:38:04 -04:00
committed by GitHub
parent ea3d8cf728
commit 77aaa38a92
14 changed files with 478 additions and 13 deletions

View File

@@ -53,6 +53,8 @@ import type { ToastMessageOptions } from 'primevue/toast'
import { useWorkspaceStore } from '@/stores/workspaceStateStore'
import { useExecutionStore } from '@/stores/executionStore'
import { IWidget } from '@comfyorg/litegraph'
import { useKeybindingStore } from '@/stores/keybindingStore'
import { useCommandStore } from '@/stores/commandStore'
export const ANIM_PREVIEW_WIDGET = '$$comfy_animation_preview'
@@ -2951,6 +2953,10 @@ export class ComfyApp {
if (this.extensions.find((ext) => ext.name === extension.name)) {
throw new Error(`Extension named '${extension.name}' already registered.`)
}
if (this.vueAppReady) {
useKeybindingStore().loadExtensionKeybindings(extension)
useCommandStore().loadExtensionCommands(extension)
}
this.extensions.push(extension)
}

View File

@@ -377,7 +377,5 @@ export class ComfyLogging {
if (!this.enabled) return
const source = 'ComfyUI.Logging'
this.addEntry(source, 'debug', { UserAgent: navigator.userAgent })
const systemStats = await api.getSystemStats()
this.addEntry(source, 'debug', systemStats)
}
}

View File

@@ -4,13 +4,10 @@ import { downloadBlob } from '../../utils'
import { ComfyButtonGroup } from '../components/buttonGroup'
import './menu.css'
// Import ComfyButton to make sure it's shimmed and exported by vite
import { ComfyButton } from '../components/button'
import { ComfySplitButton } from '../components/splitButton'
import { ComfyPopup } from '../components/popup'
console.debug(
`Keep following definitions ${ComfyButton} ${ComfySplitButton} ${ComfyPopup}`
)
// Export to make sure following components are shimmed and exported by vite
export { ComfyButton } from '../components/button'
export { ComfySplitButton } from '../components/splitButton'
export { ComfyPopup } from '../components/popup'
export class ComfyAppMenu {
app: ComfyApp