diff --git a/__init__.py b/__init__.py index bb650ed..fcd3fa7 100644 --- a/__init__.py +++ b/__init__.py @@ -1,11 +1,8 @@ from .adv_control.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS -from .adv_control import documentation from .adv_control.dinklink import init_dinklink from .adv_control.sampling import prepare_dinklink_acn_wrapper -WEB_DIRECTORY = "./web" -__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', "WEB_DIRECTORY"] -documentation.format_descriptions(NODE_CLASS_MAPPINGS) +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] init_dinklink() prepare_dinklink_acn_wrapper() diff --git a/adv_control/documentation.py b/adv_control/documentation.py deleted file mode 100644 index f6ccd48..0000000 --- a/adv_control/documentation.py +++ /dev/null @@ -1,47 +0,0 @@ -from .logger import logger - -def image(src): - return f'' -def video(src): - return f'' -def short_desc(desc): - return f'{desc}' - -descriptions = { -} - -sizes = ['1.4','1.2','1'] -def as_html(entry, depth=0): - if isinstance(entry, dict): - size = 0.8 if depth < 2 else 1 - html = '' - for k in entry: - if k == "collapsed": - continue - collapse_single = k.endswith("_collapsed") - if collapse_single: - name = k[:-len("_collapsed")] - else: - name = k - collapse_flag = ' VHS_precollapse' if entry.get("collapsed", False) or collapse_single else '' - html += f'[-]{name}: {as_html(entry[k], depth=depth+1)}' - return html - if isinstance(entry, list): - html = '' - for i in entry: - html += f'{as_html(i, depth=depth)}' - return html - return str(entry) - -def format_descriptions(nodes): - for k in descriptions: - if k.endswith("_collapsed"): - k = k[:-len("_collapsed")] - nodes[k].DESCRIPTION = as_html(descriptions[k]) - # undocumented_nodes = [] - # for k in nodes: - # if not hasattr(nodes[k], "DESCRIPTION"): - # undocumented_nodes.append(k) - # if len(undocumented_nodes) > 0: - # logger.info(f"Undocumented nodes: {undocumented_nodes}") - diff --git a/adv_control/nodes_deprecated.py b/adv_control/nodes_deprecated.py index 0a4905e..cabd1f1 100644 --- a/adv_control/nodes_deprecated.py +++ b/adv_control/nodes_deprecated.py @@ -86,9 +86,6 @@ class ScaledSoftUniversalWeightsDeprecated: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -126,9 +123,6 @@ class SoftControlNetWeightsDeprecated: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } DEPRECATED = True @@ -172,9 +166,6 @@ class CustomControlNetWeightsDeprecated: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } DEPRECATED = True @@ -209,9 +200,6 @@ class SoftT2IAdapterWeightsDeprecated: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } DEPRECATED = True @@ -244,9 +232,6 @@ class CustomT2IAdapterWeightsDeprecated: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } DEPRECATED = True @@ -285,9 +270,6 @@ class AdvancedControlNetApplyDEPR: "model_optional": ("MODEL",), "vae_optional": ("VAE",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } DEPRECATED = True @@ -328,9 +310,6 @@ class AdvancedControlNetApplySingleDEPR: "model_optional": ("MODEL",), "vae_optional": ("VAE",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } DEPRECATED = True @@ -392,9 +371,6 @@ class DiffControlNetLoaderAdvancedDEPR: "optional": { "tk_optional": ("TIMESTEP_KEYFRAME", ), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } DEPRECATED = True diff --git a/adv_control/nodes_keyframes.py b/adv_control/nodes_keyframes.py index bbcf599..bc4f1b8 100644 --- a/adv_control/nodes_keyframes.py +++ b/adv_control/nodes_keyframes.py @@ -26,9 +26,6 @@ class TimestepKeyframeNode: "guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}), "mask_optional": ("MASK", ), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_NAMES = ("TIMESTEP_KF", ) @@ -85,9 +82,6 @@ class TimestepKeyframeInterpolationNode: "mask_optional": ("MASK", ), "print_keyframes": ("BOOLEAN", {"default": False}), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_NAMES = ("TIMESTEP_KF", ) @@ -146,9 +140,6 @@ class TimestepKeyframeFromStrengthListNode: "mask_optional": ("MASK", ), "print_keyframes": ("BOOLEAN", {"default": False}), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_NAMES = ("TIMESTEP_KF", ) @@ -205,9 +196,6 @@ class LatentKeyframeNode: "optional": { "prev_latent_kf": ("LATENT_KEYFRAME", ), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_NAMES = ("LATENT_KF", ) @@ -244,9 +232,6 @@ class LatentKeyframeGroupNode: "latent_optional": ("LATENT", ), "print_keyframes": ("BOOLEAN", {"default": False}), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_NAMES = ("LATENT_KF", ) @@ -366,9 +351,6 @@ class LatentKeyframeInterpolationNode: "prev_latent_kf": ("LATENT_KEYFRAME", ), "print_keyframes": ("BOOLEAN", {"default": False}), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_NAMES = ("LATENT_KF", ) @@ -439,9 +421,6 @@ class LatentKeyframeBatchedGroupNode: "prev_latent_kf": ("LATENT_KEYFRAME", ), "print_keyframes": ("BOOLEAN", {"default": False}), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_NAMES = ("LATENT_KF", ) diff --git a/adv_control/nodes_main.py b/adv_control/nodes_main.py index 4d68910..a0cd536 100644 --- a/adv_control/nodes_main.py +++ b/adv_control/nodes_main.py @@ -46,9 +46,6 @@ class DiffControlNetLoaderAdvanced: "optional": { "_tk_opt": ("TIMESTEP_KEYFRAME", ), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET", ) @@ -107,9 +104,6 @@ class AdvancedControlNetApply: "weights_override": ("CONTROL_NET_WEIGHTS", ), "vae_optional": ("VAE",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONDITIONING","CONDITIONING",) @@ -211,9 +205,6 @@ class AdvancedControlNetApplySingle: "weights_override": ("CONTROL_NET_WEIGHTS", ), "vae_optional": ("VAE",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONDITIONING","MODEL",) diff --git a/adv_control/nodes_plusplus.py b/adv_control/nodes_plusplus.py index aabe4a1..f4241d0 100644 --- a/adv_control/nodes_plusplus.py +++ b/adv_control/nodes_plusplus.py @@ -65,9 +65,6 @@ class PlusPlusInputNode: "prev_plus_input": ("PLUS_INPUT",), #"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": BIGMAX, "step": 0.01}), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("PLUS_INPUT", ) diff --git a/adv_control/nodes_sparsectrl.py b/adv_control/nodes_sparsectrl.py index fe1c05b..25812f9 100644 --- a/adv_control/nodes_sparsectrl.py +++ b/adv_control/nodes_sparsectrl.py @@ -134,9 +134,6 @@ class RgbSparseCtrlPreprocessor: "vae": ("VAE", ), "latent_size": ("LATENT", ), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("IMAGE",) @@ -169,9 +166,6 @@ class SparseWeightExtras: "sparse_nonhint_mult": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ), "sparse_mask_mult": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CN_WEIGHTS_EXTRAS", ) diff --git a/adv_control/nodes_weight.py b/adv_control/nodes_weight.py index 7f3aad0..5a94fb7 100644 --- a/adv_control/nodes_weight.py +++ b/adv_control/nodes_weight.py @@ -15,9 +15,6 @@ class DefaultWeights: "optional": { "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -46,9 +43,6 @@ class ScaledSoftMaskedUniversalWeights: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -82,9 +76,6 @@ class ScaledSoftUniversalWeights: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -121,9 +112,6 @@ class SoftControlNetWeightsSD15: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -166,9 +154,6 @@ class CustomControlNetWeightsSD15: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -217,9 +202,6 @@ class CustomControlNetWeightsFlux: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -252,9 +234,6 @@ class CustomControlNetWeightsAnima: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - }, } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -286,9 +265,6 @@ class SoftT2IAdapterWeights: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -317,9 +293,6 @@ class CustomT2IAdapterWeights: "uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ), "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",) @@ -346,9 +319,6 @@ class ExtrasMiddleMultNode: "optional": { "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - } } RETURN_TYPES = ("CN_WEIGHTS_EXTRAS",) @@ -373,9 +343,6 @@ class AnimaLLLiteExtras: "optional": { "cn_extras": ("CN_WEIGHTS_EXTRAS",), }, - "hidden": { - "autosize": ("ACNAUTOSIZE", {"padding": 0}), - }, } RETURN_TYPES = ("CN_WEIGHTS_EXTRAS",) diff --git a/web/js/autosize.js b/web/js/autosize.js deleted file mode 100644 index 905c442..0000000 --- a/web/js/autosize.js +++ /dev/null @@ -1,53 +0,0 @@ -import { app } from '../../../scripts/app.js' - -function addResizeHook(node, padding, useOldMin=false) { - let origOnCreated = node.onNodeCreated - node.onNodeCreated = function() { - let r = origOnCreated?.apply(this, arguments) - let size = this.computeSize(); - size[0] += padding || 0; - if (useOldMin) { - //equal to LiteGraph.NODE_WIDTH*1.5*1.5 - size[0] = Math.max(size[0], 315) - } - this.setSize(size); - return r - } -} - -app.registerExtension({ - name: "AdvancedControlNet.autosize", - async beforeRegisterNodeDef(nodeType, nodeData, app) { - //since python_module is based off folder path, - //it could be changed by users and should only be used as fallback - if (nodeData?.name?.startsWith("ACN_") - || nodeData.python_module == 'custom_nodes.ComfyUI-Advanced-ControlNet') { - if (nodeData?.input?.hidden?.autosize) { - addResizeHook(nodeType.prototype, nodeData.input.hidden.autosize[1]?.padding) - } else if (!nodeData?.input?.optional?.autosize) { - addResizeHook(nodeType.prototype, 0, true) - } - } - }, - async getCustomWidgets() { - return { - ACNAUTOSIZE(node, inputName, inputData) { - let w = { - name : inputName, - type : "ACN.AUTOSIZE", - value : "", - options : {"serialize": false}, - computeSize : function(width) { - return [0, -4]; - } - } - if (!node.widgets) { - node.widgets = [] - } - node.widgets.push(w) - addResizeHook(node, inputData[1].padding); - return w; - } - } - } -}); diff --git a/web/js/documentation.js b/web/js/documentation.js deleted file mode 100644 index 745a3cb..0000000 --- a/web/js/documentation.js +++ /dev/null @@ -1,293 +0,0 @@ -import { app } from '../../../scripts/app.js' - -function chainCallback(object, property, callback) { - if (object == undefined) { - //This should not happen. - console.error("Tried to add callback to non-existant object") - return; - } - if (property in object && object[property]) { - const callback_orig = object[property] - object[property] = function () { - const r = callback_orig.apply(this, arguments); - callback.apply(this, arguments); - return r - }; - } else { - object[property] = callback; - } -} -var helpDOM; -function initHelpDOM() { - let parentDOM = document.createElement("div"); - document.body.appendChild(parentDOM) - parentDOM.appendChild(helpDOM) - helpDOM.className = "litegraph"; - let scrollbarStyle = document.createElement('style'); - scrollbarStyle.innerHTML = ` - - ` - parentDOM.appendChild(scrollbarStyle) - chainCallback(app.canvas, "onDrawForeground", function (ctx, visible_rect){ - let n = helpDOM.node - if (!n || !n?.graph) { - parentDOM.style['left'] = '-5000px' - return - } - //draw : function(ctx, node, widgetWidth, widgetY, height) { - //update widget position, even if off screen - const transform = ctx.getTransform(); - const scale = app.canvas.ds.scale;//gets the litegraph zoom - //calculate coordinates with account for browser zoom - const bcr = app.canvas.canvas.getBoundingClientRect() - const x = transform.e*scale/transform.a + bcr.x; - const y = transform.f*scale/transform.a + bcr.y; - //TODO: text reflows at low zoom. investigate alternatives - Object.assign(parentDOM.style, { - left: (x+(n.pos[0] + n.size[0]+15)*scale) + "px", - top: (y+(n.pos[1]-LiteGraph.NODE_TITLE_HEIGHT)*scale) + "px", - width: "400px", - minHeight: "100px", - maxHeight: "600px", - overflowY: 'scroll', - transformOrigin: '0 0', - transform: 'scale(' + scale + ',' + scale +')', - fontSize: '18px', - backgroundColor: LiteGraph.NODE_DEFAULT_BGCOLOR, - boxShadow: '0 0 10px black', - borderRadius: '4px', - padding: '3px', - zIndex: 3, - position: "absolute", - display: 'inline', - }); - }); - function setCollapse(el, doCollapse) { - if (doCollapse) { - el.children[0].children[0].innerHTML = '+' - Object.assign(el.children[1].style, { - color: '#CCC', - overflowX: 'hidden', - width: '0px', - minWidth: 'calc(100% - 20px)', - textOverflow: 'ellipsis', - whiteSpace: 'nowrap', - }) - for (let child of el.children[1].children) { - if (child.style.display != 'none'){ - child.origDisplay = child.style.display - } - child.style.display = 'none' - } - } else { - el.children[0].children[0].innerHTML = '-' - Object.assign(el.children[1].style, { - color: '', - overflowX: '', - width: '100%', - minWidth: '', - textOverflow: '', - whiteSpace: '', - }) - for (let child of el.children[1].children) { - child.style.display = child.origDisplay - } - } - } - helpDOM.collapseOnClick = function() { - let doCollapse = this.children[0].innerHTML == '-' - setCollapse(this.parentElement, doCollapse) - } - helpDOM.selectHelp = function(name, value) { - //attempt to navigate to name in help - function collapseUnlessMatch(items,t) { - var match = items.querySelector('[vhs_title="' + t + '"]') - if (!match) { - for (let i of items.children) { - if (i.innerHTML.slice(0,t.length+5).includes(t)) { - match = i - break - } - } - } - if (!match) { - return null - } - //For longer documentation items with fewer collapsable elements, - //scroll to make sure the entirety of the selected item is visible - //This has the unfortunate side effect of trying to scroll the main - //window if the documentation windows is forcibly offscreen, - //but it's easy to simply scroll the main window back and seems to - //have no visual side effects - match.scrollIntoView(false) - window.scrollTo(0,0) - for (let i of items.querySelectorAll('.VHS_collapse')) { - if (i.contains(match)) { - setCollapse(i, false) - } else { - setCollapse(i, true) - } - } - return match - } - let target = collapseUnlessMatch(helpDOM, name) - if (target && value) { - collapseUnlessMatch(target, value) - } - } - - helpDOM.addHelp = function(node, nodeType, description) { - if (!description) { - return - } - //Pad computed size for the clickable question mark - let originalComputeSize = node.computeSize - node.computeSize = function() { - let size = originalComputeSize.apply(this, arguments) - if (!this.title) { - return size - } - let title_width = this.title.length * 0.6 * LiteGraph.NODE_TEXT_SIZE - size[0] = Math.max(size[0], title_width + LiteGraph.NODE_TITLE_HEIGHT) - return size - } - - node.description = description - chainCallback(node, "onDrawForeground", function (ctx) { - //draw question mark - ctx.save() - ctx.font = 'bold 20px Arial' - ctx.fillText("?", this.size[0]-17, -8) - ctx.restore() - }) - chainCallback(node, "onMouseDown", function (e, pos, canvas) { - //On click would be preferred, but this'll be good enough - if (pos[1] < 0 && pos[0] + LiteGraph.NODE_TITLE_HEIGHT > this.size[0]) { - //corner question mark clicked - if (helpDOM.node == this) { - helpDOM.node = undefined - } else { - helpDOM.node = this; - helpDOM.innerHTML = this.description || "no help provided ".repeat(20) - for (let e of helpDOM.querySelectorAll('.VHS_collapse')) { - e.children[0].onclick = helpDOM.collapseOnClick - e.children[0].style.cursor = 'pointer' - } - for (let e of helpDOM.querySelectorAll('.VHS_precollapse')) { - setCollapse(e, true) - } - } - return true - } - }) - let timeout = null - chainCallback(node, "onMouseMove", function (e, pos, canvas) { - if (timeout) { - clearTimeout(timeout) - timeout = null - } - if (helpDOM.node != this) { - return - } - timeout = setTimeout(() => { - let n = this - if (pos[0] > 0 && pos[0] < n.size[0] - && pos[1] > 0 && pos[1] < n.size[1]) { - //TODO: provide help specific to element clicked - let inputRows = Math.max(n.inputs.length, n.outputs.length) - if (pos[1] < LiteGraph.NODE_SLOT_HEIGHT * inputRows) { - let row = Math.floor((pos[1] - 7) / LiteGraph.NODE_SLOT_HEIGHT) - if (pos[0] < n.size[0]/2) { - if (row < n.inputs.length) { - helpDOM.selectHelp(n.inputs[row].name) - } - } else { - if (row < n.outputs.length) { - helpDOM.selectHelp(n.outputs[row].name) - } - } - } else { - //probably widget, but widgets have variable height. - let basey = LiteGraph.NODE_SLOT_HEIGHT * inputRows + 6 - for (let w of n.widgets) { - if (w.y) { - basey = w.y - } - let wheight = LiteGraph.NODE_WIDGET_HEIGHT+4 - if (w.computeSize) { - wheight = w.computeSize(n.size[0])[1] - } - if (pos[1] < basey + wheight) { - helpDOM.selectHelp(w.name, w.value) - break - } - basey += wheight - } - } - } - }, 500) - }) - chainCallback(node, "onMouseLeave", function (e, pos, canvas) { - if (timeout) { - clearTimeout(timeout) - timeout = null - } - }); - } -} - - - -app.registerExtension({ - name: "AdvancedControlNet.documentation", - async init() { - if (app.VHSHelp) { - helpDOM = app.VHSHelp - } else { - helpDOM = document.createElement("div"); - initHelpDOM() - app.VHSHelp = helpDOM - } - }, - async beforeRegisterNodeDef(nodeType, nodeData, app) { - // NOTE: May need manual adjusting for the few non-namespaced nodes - if(nodeData?.name?.startsWith("ACN_") && nodeData.description) { - let description = nodeData.description - let el = document.createElement("div") - el.innerHTML = description - if (!el.children.length) { - //Is plaintext. Do minor convenience formatting - let chunks = description.split('\n') - nodeData.description = chunks[0] - description = chunks.join('') - } else { - nodeData.description = el.querySelector('#VHS_shortdesc')?.innerHTML || el.children[1]?.firstChild?.innerHTML - } - chainCallback(nodeType.prototype, "onNodeCreated", function () { - helpDOM.addHelp(this, nodeType, description) - }) - } - }, -});