diff --git a/__init__.py b/__init__.py index d30f823..a26d67e 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,4 @@ from .adv_control.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS -__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] +WEB_DIRECTORY = "./web" +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', "WEB_DIRECTORY"] diff --git a/web/js/autosize.js b/web/js/autosize.js new file mode 100644 index 0000000..0b7af4e --- /dev/null +++ b/web/js/autosize.js @@ -0,0 +1,32 @@ +import { app } from '../../../scripts/app.js' +app.registerExtension({ + name: "AdvancedControlNet.autosize", + async nodeCreated(node) { + if(node.acnAutosize) { + let size = node.computeSize(0); + size[0] += node.acnAutosize?.padding || 0; + node.setSize(size); + } + }, + async getCustomWidgets() { + return { + ACNAUTOSIZE(node, inputName, inputData) { + let w = { + name : inputName, + type : "ACN.AUTOSIZE", + value : "", + options : {"serialize": false}, + computeSize : function(width) { + return [0, -4]; + } + } + node.acnAutosize = inputData[1]; + if (!node.widgets) { + node.widgets = [] + } + node.widgets.push(w) + return w; + } + } + } +});