diff --git a/src/extensions/core/widgetInputs.ts b/src/extensions/core/widgetInputs.ts index 7d9528663..221b74e08 100644 --- a/src/extensions/core/widgetInputs.ts +++ b/src/extensions/core/widgetInputs.ts @@ -3,8 +3,13 @@ import { ComfyWidgets, addValueControlWidgets } from '../../scripts/widgets' import { app } from '../../scripts/app' import { applyTextReplacements } from '../../scripts/utils' import { LiteGraph, LGraphNode } from '@comfyorg/litegraph' -import type { INodeInputSlot, IWidget } from '@comfyorg/litegraph' +import type { + INodeInputSlot, + IWidget, + LiteGraphCanvasEvent +} from '@comfyorg/litegraph' import type { InputSpec } from '@/types/apiTypes' +import { useNodeDefStore } from '@/stores/nodeDefStore' const CONVERTED_TYPE = 'converted-widget' const VALID_TYPES = [ @@ -721,6 +726,40 @@ app.registerExtension({ defaultValue: true }) }, + setup() { + app.canvas.getWidgetLinkType = function (widget, node) { + const nodeDefStore = useNodeDefStore() + const nodeDef = nodeDefStore.nodeDefsByName[node.type] + const input = nodeDef.inputs.getInput(widget.name) + return input?.type + } + + document.addEventListener( + 'litegraph:canvas', + async (e: LiteGraphCanvasEvent) => { + if (e.detail.subType === 'connectingWidgetLink') { + const { node, link, widget } = e.detail + if (!node || !link || !widget) return + + const nodeData = node.constructor.nodeData + if (!nodeData) return + const all = { + ...nodeData?.input?.required, + ...nodeData?.input?.optional + } + const inputSpec = all[widget.name] + if (!inputSpec) return + + const input = convertToInput(node, widget, inputSpec) + if (!input) return + + const originNode = link.node + + originNode.connect(link.slot, node, node.inputs.lastIndexOf(input)) + } + } + ) + }, async beforeRegisterNodeDef(nodeType, nodeData, app) { // Add menu options to convert to/from widgets const origGetExtraMenuOptions = nodeType.prototype.getExtraMenuOptions diff --git a/src/locales/en/nodeDefs.json b/src/locales/en/nodeDefs.json index bb49ff823..25f920f78 100644 --- a/src/locales/en/nodeDefs.json +++ b/src/locales/en/nodeDefs.json @@ -312,6 +312,24 @@ } } }, + "CLIPTextEncodePixArtAlpha": { + "display_name": "CLIPTextEncodePixArtAlpha", + "description": "Encodes text and sets the resolution conditioning for PixArt Alpha. Does not apply to PixArt Sigma.", + "inputs": { + "width": { + "name": "width" + }, + "height": { + "name": "height" + }, + "text": { + "name": "text" + }, + "clip": { + "name": "clip" + } + } + }, "CLIPTextEncodeSD3": { "display_name": "CLIPTextEncodeSD3", "inputs": { diff --git a/src/locales/ja/nodeDefs.json b/src/locales/ja/nodeDefs.json index 16328c3f6..ed9cb812a 100644 --- a/src/locales/ja/nodeDefs.json +++ b/src/locales/ja/nodeDefs.json @@ -249,6 +249,24 @@ } } }, + "CLIPTextEncodePixArtAlpha": { + "description": "テキストをエンコードし、PixArt Alphaの解像度条件を設定します。PixArt Sigmaには適用されません。", + "display_name": "CLIPTextEncodePixArtAlpha", + "inputs": { + "clip": { + "name": "clip" + }, + "height": { + "name": "高さ" + }, + "text": { + "name": "テキスト" + }, + "width": { + "name": "幅" + } + } + }, "CLIPTextEncodeSD3": { "display_name": "CLIPテキストエンコードSD3", "inputs": { diff --git a/src/locales/ko/nodeDefs.json b/src/locales/ko/nodeDefs.json index 26b86f12e..95c39a7b2 100644 --- a/src/locales/ko/nodeDefs.json +++ b/src/locales/ko/nodeDefs.json @@ -249,6 +249,24 @@ } } }, + "CLIPTextEncodePixArtAlpha": { + "description": "텍스트를 인코딩하고 PixArt Alpha의 해상도 조건을 설정합니다. PixArt Sigma에는 적용되지 않습니다.", + "display_name": "CLIPTextEncodePixArtAlpha", + "inputs": { + "clip": { + "name": "클립" + }, + "height": { + "name": "높이" + }, + "text": { + "name": "텍스트" + }, + "width": { + "name": "너비" + } + } + }, "CLIPTextEncodeSD3": { "display_name": "CLIP 텍스트 인코딩 (SD3)", "inputs": { diff --git a/src/locales/ru/nodeDefs.json b/src/locales/ru/nodeDefs.json index 6700f99bd..672004b3d 100644 --- a/src/locales/ru/nodeDefs.json +++ b/src/locales/ru/nodeDefs.json @@ -249,6 +249,24 @@ } } }, + "CLIPTextEncodePixArtAlpha": { + "description": "Кодирует текст и устанавливает условие разрешения для PixArt Alpha. Не применяется к PixArt Sigma.", + "display_name": "CLIPTextEncodePixArtAlpha", + "inputs": { + "clip": { + "name": "clip" + }, + "height": { + "name": "высота" + }, + "text": { + "name": "текст" + }, + "width": { + "name": "ширина" + } + } + }, "CLIPTextEncodeSD3": { "display_name": "Кодирование текста CLIP SD3", "inputs": { diff --git a/src/locales/zh/nodeDefs.json b/src/locales/zh/nodeDefs.json index d7a70dc7c..500ccc841 100644 --- a/src/locales/zh/nodeDefs.json +++ b/src/locales/zh/nodeDefs.json @@ -249,6 +249,24 @@ } } }, + "CLIPTextEncodePixArtAlpha": { + "description": "对文本进行编码并为PixArt Alpha设置分辨率条件。不适用于PixArt Sigma。", + "display_name": "CLIPTextEncodePixArtAlpha", + "inputs": { + "clip": { + "name": "clip" + }, + "height": { + "name": "高度" + }, + "text": { + "name": "文本" + }, + "width": { + "name": "宽度" + } + } + }, "CLIPTextEncodeSD3": { "display_name": "CLIP文本编码SD3", "inputs": { diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 5d40cb9e3..1feac222a 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -63,7 +63,6 @@ import { useWidgetStore } from '@/stores/widgetStore' import { deserialiseAndCreate } from '@/extensions/core/vintageClipboard' import { st } from '@/i18n' import { normalizeI18nKey } from '@/utils/formatUtil' -import { ISerialisedGraph } from '@comfyorg/litegraph' export const ANIM_PREVIEW_WIDGET = '$$comfy_animation_preview' @@ -1610,52 +1609,6 @@ export class ComfyApp { } } - #addWidgetLinkHandling() { - app.canvas.getWidgetLinkType = function (widget, node) { - const nodeDefStore = useNodeDefStore() - const nodeDef = nodeDefStore.nodeDefsByName[node.type] - const input = nodeDef.inputs.getInput(widget.name) - return input?.type - } - - type ConnectingWidgetLink = { - subType: 'connectingWidgetLink' - widget: IWidget - node: LGraphNode - link: { node: LGraphNode; slot: number } - } - - document.addEventListener( - 'litegraph:canvas', - async (e: CustomEvent) => { - if (e.detail.subType === 'connectingWidgetLink') { - const { convertToInput } = await import( - '@/extensions/core/widgetInputs' - ) - - const { node, link, widget } = e.detail - if (!node || !link || !widget) return - - const nodeData = node.constructor.nodeData - if (!nodeData) return - const all = { - ...nodeData?.input?.required, - ...nodeData?.input?.optional - } - const inputSpec = all[widget.name] - if (!inputSpec) return - - const input = convertToInput(node, widget, inputSpec) - if (!input) return - - const originNode = link.node - - originNode.connect(link.slot, node, node.inputs.lastIndexOf(input)) - } - } - ) - } - #addAfterConfigureHandler() { const app = this const onConfigure = app.graph.onConfigure @@ -1782,7 +1735,6 @@ export class ComfyApp { this.#addDropHandler() this.#addCopyHandler() this.#addPasteHandler() - this.#addWidgetLinkHandling() await this.#invokeExtensionsAsync('setup') }