diff --git a/__init__.py b/__init__.py index 7312832..5e3e0b2 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,9 @@ from .adv_control.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS from .adv_control import documentation +from .adv_control.dinklink import init_dinklink WEB_DIRECTORY = "./web" __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', "WEB_DIRECTORY"] documentation.format_descriptions(NODE_CLASS_MAPPINGS) + +init_dinklink() diff --git a/adv_control/dinklink.py b/adv_control/dinklink.py new file mode 100644 index 0000000..d3874fb --- /dev/null +++ b/adv_control/dinklink.py @@ -0,0 +1,35 @@ +#################################################################################################### +# DinkLink is my method of sharing classes/functions between my nodes. +# +# My DinkLink-compatible nodes will inject comfy.hooks with a __DINKLINK attr +# that stores a dictionary, where any of my node packs can store their stuff. +# +# It is not intended to be accessed by node packs that I don't develop, so things may change +# at any time. +# +# DinkLink also serves as a proof-of-concept for a future ComfyUI implementation of +# purposely exposing node pack classes/functions with other node packs. +#################################################################################################### +from __future__ import annotations +import comfy.hooks +from .sampling import acn_sampler_sample_wrapper + +DINKLINK = "__DINKLINK" + +def init_dinklink(): + if not hasattr(comfy.hooks, DINKLINK): + setattr(comfy.hooks, DINKLINK, {}) + prepare_dinklink() + + +def get_dinklink() -> dict[str, dict[str]]: + return getattr(comfy.hooks, DINKLINK) + +class Consts: + ACN = "ACN" + CREATE_SAMPLER_SAMPLE_WRAPPER = "create_sampler_sample_wrapper" + +def prepare_dinklink(): + # expose acn_sampler_sample_wrapper + d = get_dinklink() + d.setdefault(Consts.ACN, {})[Consts.CREATE_SAMPLER_SAMPLE_WRAPPER] = None