mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 09:00:05 +00:00
Add type annotation for missingNodeTypes (#1349)
* Add type annotation for missingNodeTypes * nit * nit
This commit is contained in:
@@ -37,18 +37,10 @@ import { computed } from 'vue'
|
||||
import ListBox from 'primevue/listbox'
|
||||
import Button from 'primevue/button'
|
||||
import NoResultsPlaceholder from '@/components/common/NoResultsPlaceholder.vue'
|
||||
|
||||
interface NodeType {
|
||||
type: string
|
||||
hint?: string
|
||||
action?: {
|
||||
text: string
|
||||
callback: () => void
|
||||
}
|
||||
}
|
||||
import type { MissingNodeType } from '@/types/comfy'
|
||||
|
||||
const props = defineProps<{
|
||||
missingNodeTypes: (string | NodeType)[]
|
||||
missingNodeTypes: MissingNodeType[]
|
||||
}>()
|
||||
|
||||
const uniqueNodes = computed(() => {
|
||||
|
||||
@@ -15,7 +15,7 @@ import { addDomClippingSetting } from './domWidget'
|
||||
import { createImageHost, calculateImageGrid } from './ui/imagePreview'
|
||||
import { DraggableList } from './ui/draggableList'
|
||||
import { applyTextReplacements, addStylesheet } from './utils'
|
||||
import type { ComfyExtension } from '@/types/comfy'
|
||||
import type { ComfyExtension, MissingNodeType } from '@/types/comfy'
|
||||
import {
|
||||
type ComfyWorkflowJSON,
|
||||
type NodeId,
|
||||
@@ -2188,7 +2188,7 @@ export class ComfyApp {
|
||||
localStorage.setItem('litegrapheditor_clipboard', old)
|
||||
}
|
||||
|
||||
#showMissingNodesError(missingNodeTypes) {
|
||||
#showMissingNodesError(missingNodeTypes: MissingNodeType[]) {
|
||||
if (useSettingStore().get('Comfy.Workflow.ShowMissingNodesWarning')) {
|
||||
showLoadWorkflowWarning({ missingNodeTypes })
|
||||
}
|
||||
@@ -2268,7 +2268,7 @@ export class ComfyApp {
|
||||
graphData = validatedGraphData ?? graphData
|
||||
}
|
||||
|
||||
const missingNodeTypes = []
|
||||
const missingNodeTypes: MissingNodeType[] = []
|
||||
const missingModels = []
|
||||
await this.#invokeExtensionsAsync(
|
||||
'beforeConfigureGraph',
|
||||
|
||||
@@ -11,9 +11,10 @@ import ExecutionErrorDialogContent from '@/components/dialog/content/ExecutionEr
|
||||
import TemplateWorkflowsContent from '@/components/templates/TemplateWorkflowsContent.vue'
|
||||
import PromptDialogContent from '@/components/dialog/content/PromptDialogContent.vue'
|
||||
import { i18n } from '@/i18n'
|
||||
import type { MissingNodeType } from '@/types/comfy'
|
||||
|
||||
export function showLoadWorkflowWarning(props: {
|
||||
missingNodeTypes: any[]
|
||||
missingNodeTypes: MissingNodeType[]
|
||||
[key: string]: any
|
||||
}) {
|
||||
const dialogStore = useDialogStore()
|
||||
|
||||
30
src/types/comfy.d.ts
vendored
30
src/types/comfy.d.ts
vendored
@@ -28,6 +28,18 @@ export type MenuCommandGroup = {
|
||||
commands: string[]
|
||||
}
|
||||
|
||||
export type MissingNodeType =
|
||||
| string
|
||||
// Primarily used by group nodes.
|
||||
| {
|
||||
type: string
|
||||
hint?: string
|
||||
action?: {
|
||||
text: string
|
||||
callback: () => void
|
||||
}
|
||||
}
|
||||
|
||||
export interface ComfyExtension {
|
||||
/**
|
||||
* The name of the extension
|
||||
@@ -121,6 +133,24 @@ export interface ComfyExtension {
|
||||
*/
|
||||
nodeCreated?(node: LGraphNode, app: ComfyApp): void
|
||||
|
||||
/**
|
||||
* Allows the extension to modify the graph data before it is configured.
|
||||
* @param graphData The graph data
|
||||
* @param missingNodeTypes The missing node types
|
||||
*/
|
||||
beforeConfigureGraph?(
|
||||
graphData: ComfyWorkflowJSON,
|
||||
missingNodeTypes: MissingNodeType[]
|
||||
): Promise<void> | void
|
||||
|
||||
/**
|
||||
* Allows the extension to run code after the graph is configured.
|
||||
* @param missingNodeTypes The missing node types
|
||||
*/
|
||||
afterConfigureGraph?(
|
||||
missingNodeTypes: MissingNodeType[]
|
||||
): Promise<void> | void
|
||||
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user