diff --git a/__init__.py b/__init__.py index 336447fc..2928a6bf 100644 --- a/__init__.py +++ b/__init__.py @@ -13,6 +13,7 @@ print("### Loading: ComfyUI-Manager") comfy_path = os.path.dirname(folder_paths.__file__) custom_nodes_path = os.path.join(comfy_path, 'custom_nodes') +js_path = os.path.join(comfy_path, "web", "extensions") comfyui_manager_path = os.path.dirname(__file__) local_db_model = os.path.join(comfyui_manager_path, "model-list.json") @@ -41,7 +42,7 @@ def setup_js(): os.remove(old_js_path) # setup js - js_dest_path = os.path.join(comfy_path, "web", "extensions", "comfyui-manager") + js_dest_path = os.path.join(js_path, "comfyui-manager") if not os.path.exists(js_dest_path): os.makedirs(js_dest_path) js_src_path = os.path.join(comfyui_manager_path, "js", "comfyui-manager.js") @@ -104,12 +105,14 @@ def check_a_custom_node_installed(item): elif item['install_type'] == 'copy' and len(item['files']) == 1: dir_name = os.path.basename(item['files'][0]) - dir_path = os.path.join(custom_nodes_path, dir_name) - if os.path.exists(dir_path): + base_path = custom_nodes_path if item['files'][0].endswith('.py') else js_path + file_path = os.path.join(base_path, dir_name) + if os.path.exists(file_path): item['installed'] = 'True' else: item['installed'] = 'False' + def check_custom_nodes_installed(json_obj): for item in json_obj['custom_nodes']: check_a_custom_node_installed(item) @@ -122,14 +125,10 @@ async def fetch_customnode_list(request): else: uri = 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json' - async with aiohttp.ClientSession() as session: - async with session.get(uri) as resp: - json_text = await resp.text() - json_obj = json.loads(json_text) + json_obj = await get_data(uri) + check_custom_nodes_installed(json_obj) - check_custom_nodes_installed(json_obj) - - return web.json_response(json_obj, content_type='application/json') + return web.json_response(json_obj, content_type='application/json') @server.PromptServer.instance.routes.get("/alternatives/getlist") @@ -179,14 +178,11 @@ async def fetch_externalmodel_list(request): else: uri = 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json' - async with aiohttp.ClientSession() as session: - async with session.get(uri) as resp: - json_text = await resp.text() - json_obj = json.loads(json_text) - check_model_installed(json_obj) + json_obj = await get_data(uri) + check_model_installed(json_obj) - return web.json_response(json_obj, content_type='application/json') + return web.json_response(json_obj, content_type='application/json') def unzip_install(files): @@ -234,10 +230,17 @@ def download_url_with_agent(url, save_path): return True -def copy_install(files): +def copy_install(files, js_path_name=None): for url in files: try: - download_url(url, custom_nodes_path) + if url.endswith(".py"): + download_url(url, custom_nodes_path) + else: + path = os.path.join(js_path, js_path_name) if js_path_name is not None else js_path + if not os.path.exists(path): + os.makedirs(path) + download_url(url, path) + except Exception as e: print(f"Install(copy) error: {url} / {e}") return False @@ -304,7 +307,8 @@ async def install_custom_node(request): res = unzip_install(json_data['files']) if install_type == "copy": - res = copy_install(json_data['files']) + js_path_name = json_data['js_path'] if 'js_path' in json_data else None + res = copy_install(json_data['files'], js_path_name) elif install_type == "git-clone": res = gitclone_install(json_data['files']) diff --git a/custom-node-list.json b/custom-node-list.json index 3344f9e9..b84104a8 100644 --- a/custom-node-list.json +++ b/custom-node-list.json @@ -360,6 +360,34 @@ "install_type": "copy", "description": "Custom node for ComfyUI, translate promt from other languages into english" }, + { + "author": "pythongosssss", + "title": "ComfyUI-Custom-Scripts", + "reference": "https://github.com/pythongosssss/ComfyUI-Custom-Scripts", + "js_path": "ComfyUI-Custom-Scripts", + "files": [ + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/anime-segmentation/anime_segmentation.py", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/auto-arrange-graph/graphArrange.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/export-workflow-svg/exportAsSvg.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/follow-execution/followExecution.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/image-feed/imageFeed.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/latent-upscale-by/latent_upscale_by.py", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/lock-nodes-and-groups/locking.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/lora-subfolders/loraSubfolders.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/preset-text/presetText.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/quick-nodes/quickNodes.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/show-text/showText.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/show-text/show_text.py", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/touch-support/touchEvents.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/wd14-tagger/wd14tagger.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/wd14-tagger/wd14tagger.py", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/widget-defaults/widgetDefaults.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/workflows/index.js", + "https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/workflows/workflows.py" + ], + "install_type": "copy", + "description": "This extension provides: Auto Arrange Graph, Workflow SVG, Favicon Status, Image Feed, Latent Upscale By, Lock Nodes & Groups, Lora Subfolders, Preset Text, Show Text, Touch Support, WD14 Tagger" + }, { "author": "theally", "title": "TheAlly's Custom Nodes", diff --git a/js/comfyui-manager.js b/js/comfyui-manager.js index 128f612b..8f781cff 100644 --- a/js/comfyui-manager.js +++ b/js/comfyui-manager.js @@ -57,7 +57,8 @@ async function install_custom_node(target, caller) { return false; } finally { - caller.invalidateControl(); + await caller.invalidateControl(); + caller.updateMessage('
To apply the installed custom node, please restart ComfyUI.'); } } } @@ -84,7 +85,8 @@ async function install_model(target) { return false; } finally { - ModelInstaller.instance.invalidateControl(); + await ModelInstaller.instance.invalidateControl(); + ModelInstaller.instance.updateMessage("
To apply the installed model, please click the 'Refresh' button on the main menu."); } } } @@ -110,7 +112,7 @@ class CustomNodesInstaller extends ComfyDialog { } startInstall(target) { - this.message_box.innerHTML = `
Installing '${target.title}'`; + this.updateMessage(`
Installing '${target.title}'`); for(let i in this.install_buttons) { this.install_buttons[i].disabled = true; @@ -130,6 +132,10 @@ class CustomNodesInstaller extends ComfyDialog { this.createControls(); } + updateMessage(msg) { + this.message_box.innerHTML = msg; + } + async createGrid() { var grid = document.createElement('table'); grid.setAttribute('id', 'custom-nodes-grid'); @@ -275,7 +281,7 @@ class AlternativesInstaller extends ComfyDialog { } startInstall(target) { - this.message_box.innerHTML = `
Installing '${target.title}'`; + this.updateMessage(`
Installing '${target.title}'`); for(let i in this.install_buttons) { this.install_buttons[i].disabled = true; @@ -295,6 +301,10 @@ class AlternativesInstaller extends ComfyDialog { this.createControls(); } + updateMessage(msg) { + this.message_box.innerHTML = msg; + } + async createGrid() { var grid = document.createElement('table'); grid.setAttribute('id', 'alternatives-grid'); @@ -466,7 +476,7 @@ class ModelInstaller extends ComfyDialog { } startInstall(target) { - this.message_box.innerHTML = `
Installing '${target.name}'`; + this.updateMessage(`
Installing '${target.name}'`); for(let i in this.install_buttons) { this.install_buttons[i].disabled = true; @@ -486,6 +496,10 @@ class ModelInstaller extends ComfyDialog { this.createControls(); } + updateMessage(msg) { + this.message_box.innerHTML = msg; + } + async createGrid(models_json) { var grid = document.createElement('table'); grid.setAttribute('id', 'external-models-grid');