diff --git a/src/schemas/nodeDefSchema.ts b/src/schemas/nodeDefSchema.ts index 4be1765ef1..a144533dc0 100644 --- a/src/schemas/nodeDefSchema.ts +++ b/src/schemas/nodeDefSchema.ts @@ -25,6 +25,7 @@ export const zBaseInputOptions = z tooltip: z.string().optional(), hidden: z.boolean().optional(), advanced: z.boolean().optional(), + widgetType: z.string().optional(), /** Backend-only properties. */ rawLink: z.boolean().optional(), lazy: z.boolean().optional() diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index 8cb6a5b4af..f0276d4fd7 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -113,7 +113,9 @@ export const useLitegraphService = () => { #addInputSocket(inputSpec: InputSpec) { const inputName = inputSpec.name const nameKey = `${this.#nodeKey}.inputs.${normalizeI18nKey(inputName)}.name` - const widgetConstructor = widgetStore.widgets.get(inputSpec.type) + const widgetConstructor = widgetStore.widgets.get( + inputSpec.widgetType ?? inputSpec.type + ) if (widgetConstructor && !inputSpec.forceInput) return this.addInput(inputName, inputSpec.type, { @@ -127,9 +129,13 @@ export const useLitegraphService = () => { * (unless `socketless`), an input socket is also added. */ #addInputWidget(inputSpec: InputSpec) { + const widgetInputSpec = { ...inputSpec } + if (inputSpec.widgetType) { + widgetInputSpec.type = inputSpec.widgetType + } const inputName = inputSpec.name const nameKey = `${this.#nodeKey}.inputs.${normalizeI18nKey(inputName)}.name` - const widgetConstructor = widgetStore.widgets.get(inputSpec.type) + const widgetConstructor = widgetStore.widgets.get(widgetInputSpec.type) if (!widgetConstructor || inputSpec.forceInput) return const { @@ -139,7 +145,7 @@ export const useLitegraphService = () => { } = widgetConstructor( this, inputName, - transformInputSpecV2ToV1(inputSpec), + transformInputSpecV2ToV1(widgetInputSpec), app ) ?? {} @@ -153,7 +159,7 @@ export const useLitegraphService = () => { } if (!widget?.options?.socketless) { - const inputSpecV1 = transformInputSpecV2ToV1(inputSpec) + const inputSpecV1 = transformInputSpecV2ToV1(widgetInputSpec) this.addInput(inputName, inputSpec.type, { shape: inputSpec.isOptional ? RenderShape.HollowCircle : undefined, localized_name: st(nameKey, inputName),