| import { app } from '../../scripts/app.js'; |
| import { ComfyWidgets } from '../../scripts/widgets.js'; |
|
|
| app.registerExtension({ |
| name: 'Comfy.Oz.APIModelSelector', |
| async beforeRegisterNodeDef(nodeType, nodeData, app) { |
| if (nodeData.name === 'ozW_API_ModelSelector') { |
| |
| const onNodeCreated = nodeType.prototype.onNodeCreated; |
| nodeType.prototype.onNodeCreated = function () { |
| onNodeCreated?.apply(this, arguments); |
|
|
| |
| const warningWidget = ComfyWidgets["STRING"](this, "unreliable_provider_warning", ["STRING", { multiline: true }], app).widget; |
| warningWidget.inputEl.readOnly = true; |
| warningWidget.inputEl.style.backgroundColor = '#442222'; |
| warningWidget.inputEl.style.color = '#FFCCCC'; |
| warningWidget.inputEl.style.opacity = '0.8'; |
| warningWidget.value = '⚠️ For this model, the fal.ai provider is unreliable for Image-to-Image (Edit) tasks. wavespeed.ai recommended.'; |
| warningWidget.hidden = true; |
|
|
| const modelWidget = this.widgets.find((w) => w.name === 'model'); |
| if (modelWidget) { |
| const originalCallback = modelWidget.callback; |
| |
| modelWidget.callback = (value) => { |
| originalCallback?.(value); |
| this.updateWarningWidget(); |
| }; |
| } |
|
|
| |
| this.updateWarningWidget = () => { |
| const isProblematic = (modelWidget.value === 'Nano Banana'); |
| warningWidget.hidden = !isProblematic; |
| this.computeSize(); |
| this.setDirtyCanvas(true, true); |
| }; |
| |
| |
| setTimeout(() => this.updateWarningWidget(), 1); |
| }; |
| } |
| }, |
| }); |