Add TS types - API (#1736)

* nit

* Add TS types - API events

* Replace all API event emits with type-safe variants

* Add missing API type

* nit

* Remove test code, nit
This commit is contained in:
filtered
2024-11-30 05:15:25 +11:00
committed by GitHub
parent 0bf30e7621
commit 2017b9016b
8 changed files with 225 additions and 112 deletions

View File

@@ -4,7 +4,7 @@ import { ComfyDialog as _ComfyDialog } from './ui/dialog'
import { toggleSwitch } from './ui/toggleSwitch'
import { ComfySettingsDialog } from './ui/settings'
import { ComfyApp, app } from './app'
import { TaskItem } from '@/types/apiTypes'
import { TaskItem, type StatusWsMessageStatus } from '@/types/apiTypes'
import { showSettingsDialog } from '@/services/dialogService'
import { useSettingStore } from '@/stores/settingStore'
import { useCommandStore } from '@/stores/commandStore'
@@ -611,7 +611,7 @@ export class ComfyUI {
app.clean()
app.graph.clear()
app.resetView()
api.dispatchEvent(new CustomEvent('graphCleared'))
api.dispatchCustomEvent('graphCleared')
}
}
}),
@@ -641,10 +641,11 @@ export class ComfyUI {
this.restoreMenuPosition = dragElement(this.menuContainer, this.settings)
// @ts-expect-error
this.setStatus({ exec_info: { queue_remaining: 'X' } })
}
setStatus(status) {
setStatus(status: StatusWsMessageStatus | null) {
this.queueSize.textContent =
'Queue size: ' + (status ? status.exec_info.queue_remaining : 'ERR')
if (status) {