From e98a92ba5df1fb0b2a1445d6622a6a31e53b3d2b Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Wed, 23 Aug 2023 17:31:11 +0100 Subject: [PATCH] update to support comfyui native web file handling --- __init__.py | 5 ++-- pysssss.py | 35 ++++++++++++++++++----- {js => web/js}/assets/canvas2svg.js | 0 {js => web/js}/assets/favicon-active.ico | Bin {js => web/js}/assets/favicon.ico | Bin {js => web/js}/assets/notify.mp3 | Bin {js => web/js}/betterCombos.js | 0 {js => web/js}/common/lightbox.css | 0 {js => web/js}/common/lightbox.js | 0 {js => web/js}/common/spinner.css | 0 {js => web/js}/common/spinner.js | 0 {js => web/js}/common/utils.js | 0 {js => web/js}/contextMenuHook.js | 0 {js => web/js}/customColors.js | 0 {js => web/js}/faviconStatus.js | 0 {js => web/js}/graphArrange.js | 0 {js => web/js}/imageFeed.js | 0 {js => web/js}/kSamplerAdvDenoise.js | 0 {js => web/js}/linkRenderMode.js | 0 {js => web/js}/locking.js | 0 {js => web/js}/loraInfo.css | 0 {js => web/js}/loraInfo.js | 0 {js => web/js}/mathExpression.js | 0 {js => web/js}/nodeFinder.js | 0 {js => web/js}/playSound.js | 0 {js => web/js}/presetText.js | 0 {js => web/js}/quickNodes.js | 0 {js => web/js}/repeater.js | 0 {js => web/js}/reroutePrimitive.js | 0 {js => web/js}/showImageOnMenu.js | 0 {js => web/js}/showText.js | 0 {js => web/js}/snapToGrid.js | 0 {js => web/js}/stringFunction.js | 0 {js => web/js}/touchEvents.js | 0 {js => web/js}/widgetDefaults.js | 0 {js => web/js}/workflowImage.js | 0 {js => web/js}/workflows.js | 0 37 files changed, 31 insertions(+), 9 deletions(-) rename {js => web/js}/assets/canvas2svg.js (100%) rename {js => web/js}/assets/favicon-active.ico (100%) rename {js => web/js}/assets/favicon.ico (100%) rename {js => web/js}/assets/notify.mp3 (100%) rename {js => web/js}/betterCombos.js (100%) rename {js => web/js}/common/lightbox.css (100%) rename {js => web/js}/common/lightbox.js (100%) rename {js => web/js}/common/spinner.css (100%) rename {js => web/js}/common/spinner.js (100%) rename {js => web/js}/common/utils.js (100%) rename {js => web/js}/contextMenuHook.js (100%) rename {js => web/js}/customColors.js (100%) rename {js => web/js}/faviconStatus.js (100%) rename {js => web/js}/graphArrange.js (100%) rename {js => web/js}/imageFeed.js (100%) rename {js => web/js}/kSamplerAdvDenoise.js (100%) rename {js => web/js}/linkRenderMode.js (100%) rename {js => web/js}/locking.js (100%) rename {js => web/js}/loraInfo.css (100%) rename {js => web/js}/loraInfo.js (100%) rename {js => web/js}/mathExpression.js (100%) rename {js => web/js}/nodeFinder.js (100%) rename {js => web/js}/playSound.js (100%) rename {js => web/js}/presetText.js (100%) rename {js => web/js}/quickNodes.js (100%) rename {js => web/js}/repeater.js (100%) rename {js => web/js}/reroutePrimitive.js (100%) rename {js => web/js}/showImageOnMenu.js (100%) rename {js => web/js}/showText.js (100%) rename {js => web/js}/snapToGrid.js (100%) rename {js => web/js}/stringFunction.js (100%) rename {js => web/js}/touchEvents.js (100%) rename {js => web/js}/widgetDefaults.js (100%) rename {js => web/js}/workflowImage.js (100%) rename {js => web/js}/workflows.js (100%) diff --git a/__init__.py b/__init__.py index 22ee396..1655408 100644 --- a/__init__.py +++ b/__init__.py @@ -20,5 +20,6 @@ if init(): NODE_CLASS_MAPPINGS.update(module.NODE_CLASS_MAPPINGS) if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS") and getattr(module, "NODE_DISPLAY_NAME_MAPPINGS") is not None: NODE_DISPLAY_NAME_MAPPINGS.update(module.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/pysssss.py b/pysssss.py index ce223b0..70563ac 100644 --- a/pysssss.py +++ b/pysssss.py @@ -98,6 +98,7 @@ def link_js(src, dst): logging.exception('') return False + def is_junction(path): if os.name != "nt": return False @@ -106,19 +107,35 @@ def is_junction(path): except OSError: return False + def install_js(): - src_dir = get_ext_dir("js") + src_dir = get_ext_dir("web/js") if not os.path.exists(src_dir): log("No JS") return + should_install = should_install_js() + if should_install: + log("it looks like you're running an old version of ComfyUI that requires manual setup of web files, it is recommended you update your installation.", "warning", True) dst_dir = get_web_ext_dir() - - if os.path.exists(dst_dir): - if os.path.islink(dst_dir) or is_junction(dst_dir): - log("JS already linked") - return - elif link_js(src_dir, dst_dir): + linked = os.path.islink(dst_dir) or is_junction(dst_dir) + if linked or os.path.exists(dst_dir): + if linked: + if should_install: + log("JS already linked") + else: + os.unlink(dst_dir) + log("JS unlinked, PromptServer will serve extension") + elif not should_install: + shutil.rmtree(dst_dir) + log("JS deleted, PromptServer will serve extension") + return + + if not should_install: + log("JS skipped, PromptServer will serve extension") + return + + if link_js(src_dir, dst_dir): log("JS linked") return @@ -126,6 +143,10 @@ def install_js(): shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True) +def should_install_js(): + return not hasattr(PromptServer.instance, "supports") or "custom_nodes_from_web" not in PromptServer.instance.supports + + def init(check_imports=None): log("Init") diff --git a/js/assets/canvas2svg.js b/web/js/assets/canvas2svg.js similarity index 100% rename from js/assets/canvas2svg.js rename to web/js/assets/canvas2svg.js diff --git a/js/assets/favicon-active.ico b/web/js/assets/favicon-active.ico similarity index 100% rename from js/assets/favicon-active.ico rename to web/js/assets/favicon-active.ico diff --git a/js/assets/favicon.ico b/web/js/assets/favicon.ico similarity index 100% rename from js/assets/favicon.ico rename to web/js/assets/favicon.ico diff --git a/js/assets/notify.mp3 b/web/js/assets/notify.mp3 similarity index 100% rename from js/assets/notify.mp3 rename to web/js/assets/notify.mp3 diff --git a/js/betterCombos.js b/web/js/betterCombos.js similarity index 100% rename from js/betterCombos.js rename to web/js/betterCombos.js diff --git a/js/common/lightbox.css b/web/js/common/lightbox.css similarity index 100% rename from js/common/lightbox.css rename to web/js/common/lightbox.css diff --git a/js/common/lightbox.js b/web/js/common/lightbox.js similarity index 100% rename from js/common/lightbox.js rename to web/js/common/lightbox.js diff --git a/js/common/spinner.css b/web/js/common/spinner.css similarity index 100% rename from js/common/spinner.css rename to web/js/common/spinner.css diff --git a/js/common/spinner.js b/web/js/common/spinner.js similarity index 100% rename from js/common/spinner.js rename to web/js/common/spinner.js diff --git a/js/common/utils.js b/web/js/common/utils.js similarity index 100% rename from js/common/utils.js rename to web/js/common/utils.js diff --git a/js/contextMenuHook.js b/web/js/contextMenuHook.js similarity index 100% rename from js/contextMenuHook.js rename to web/js/contextMenuHook.js diff --git a/js/customColors.js b/web/js/customColors.js similarity index 100% rename from js/customColors.js rename to web/js/customColors.js diff --git a/js/faviconStatus.js b/web/js/faviconStatus.js similarity index 100% rename from js/faviconStatus.js rename to web/js/faviconStatus.js diff --git a/js/graphArrange.js b/web/js/graphArrange.js similarity index 100% rename from js/graphArrange.js rename to web/js/graphArrange.js diff --git a/js/imageFeed.js b/web/js/imageFeed.js similarity index 100% rename from js/imageFeed.js rename to web/js/imageFeed.js diff --git a/js/kSamplerAdvDenoise.js b/web/js/kSamplerAdvDenoise.js similarity index 100% rename from js/kSamplerAdvDenoise.js rename to web/js/kSamplerAdvDenoise.js diff --git a/js/linkRenderMode.js b/web/js/linkRenderMode.js similarity index 100% rename from js/linkRenderMode.js rename to web/js/linkRenderMode.js diff --git a/js/locking.js b/web/js/locking.js similarity index 100% rename from js/locking.js rename to web/js/locking.js diff --git a/js/loraInfo.css b/web/js/loraInfo.css similarity index 100% rename from js/loraInfo.css rename to web/js/loraInfo.css diff --git a/js/loraInfo.js b/web/js/loraInfo.js similarity index 100% rename from js/loraInfo.js rename to web/js/loraInfo.js diff --git a/js/mathExpression.js b/web/js/mathExpression.js similarity index 100% rename from js/mathExpression.js rename to web/js/mathExpression.js diff --git a/js/nodeFinder.js b/web/js/nodeFinder.js similarity index 100% rename from js/nodeFinder.js rename to web/js/nodeFinder.js diff --git a/js/playSound.js b/web/js/playSound.js similarity index 100% rename from js/playSound.js rename to web/js/playSound.js diff --git a/js/presetText.js b/web/js/presetText.js similarity index 100% rename from js/presetText.js rename to web/js/presetText.js diff --git a/js/quickNodes.js b/web/js/quickNodes.js similarity index 100% rename from js/quickNodes.js rename to web/js/quickNodes.js diff --git a/js/repeater.js b/web/js/repeater.js similarity index 100% rename from js/repeater.js rename to web/js/repeater.js diff --git a/js/reroutePrimitive.js b/web/js/reroutePrimitive.js similarity index 100% rename from js/reroutePrimitive.js rename to web/js/reroutePrimitive.js diff --git a/js/showImageOnMenu.js b/web/js/showImageOnMenu.js similarity index 100% rename from js/showImageOnMenu.js rename to web/js/showImageOnMenu.js diff --git a/js/showText.js b/web/js/showText.js similarity index 100% rename from js/showText.js rename to web/js/showText.js diff --git a/js/snapToGrid.js b/web/js/snapToGrid.js similarity index 100% rename from js/snapToGrid.js rename to web/js/snapToGrid.js diff --git a/js/stringFunction.js b/web/js/stringFunction.js similarity index 100% rename from js/stringFunction.js rename to web/js/stringFunction.js diff --git a/js/touchEvents.js b/web/js/touchEvents.js similarity index 100% rename from js/touchEvents.js rename to web/js/touchEvents.js diff --git a/js/widgetDefaults.js b/web/js/widgetDefaults.js similarity index 100% rename from js/widgetDefaults.js rename to web/js/widgetDefaults.js diff --git a/js/workflowImage.js b/web/js/workflowImage.js similarity index 100% rename from js/workflowImage.js rename to web/js/workflowImage.js diff --git a/js/workflows.js b/web/js/workflows.js similarity index 100% rename from js/workflows.js rename to web/js/workflows.js