Download ComfyUI_INSTARAW/js/api_nodes.js from MarkLilly/mis-custom-nodes: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/MarkLilly/mis-custom-nodes/resolve/main/ComfyUI_INSTARAW/js/api_nodes.js
- Command line
-
hf download hf://MarkLilly/mis-custom-nodes/ComfyUI_INSTARAW/js/api_nodes.js
-
curl -L -o api_nodes.js https://huggingface.co/MarkLilly/mis-custom-nodes/resolve/main/ComfyUI_INSTARAW/js/api_nodes.js
1.85 kB
| import { app } from '../../scripts/app.js'; | |
| const _al = Array.isArray([]); | |
| app.registerExtension({ | |
| name: 'Comfy.INSTARAW.DynamicAPINodes', | |
| async beforeRegisterNodeDef(nodeType, nodeData, app) { | |
| if (nodeData.name === 'INSTARAW_APITextToImage' || nodeData.name === 'INSTARAW_APIImageToImage') { | |
| const onNodeCreated = nodeType.prototype.onNodeCreated; | |
| nodeType.prototype.onNodeCreated = function () { | |
| onNodeCreated?.apply(this, arguments); | |
| this.last_model = null; // Cache property | |
| }; | |
| const onDrawForeground = nodeType.prototype.onDrawForeground; | |
| nodeType.prototype.onDrawForeground = function(ctx) { | |
| onDrawForeground?.apply(this, arguments); | |
| const modelInput = this.inputs?.find((i) => i.name === 'model'); | |
| let current_model = null; | |
| if (modelInput && modelInput.link != null) { | |
| const link = app.graph.links[modelInput.link]; | |
| if (link) { | |
| const origin_node = app.graph.getNodeById(link.origin_id); | |
| const origin_widget = origin_node?.widgets.find(w => w.name === 'model'); | |
| if (origin_widget) current_model = origin_widget.value; | |
| } | |
| } | |
| if (this.last_model === current_model) { | |
| return; // No change, do nothing | |
| } | |
| this.last_model = current_model; | |
| const isSeeDream = current_model?.startsWith('SeeDream'); | |
| this.widgets.find(w => w.name === 'width').hidden = !isSeeDream; | |
| this.widgets.find(w => w.name === 'height').hidden = !isSeeDream; | |
| this.widgets.find(w => w.name === 'enable_safety_checker').hidden = !isSeeDream; | |
| const aspectRatioWidget = this.widgets.find(w => w.name === 'aspect_ratio'); | |
| if (aspectRatioWidget) { | |
| aspectRatioWidget.hidden = isSeeDream; | |
| } | |
| this.computeSize(); | |
| this.setDirtyCanvas(true, true); | |
| }; | |
| } | |
| }, | |
| }); |