diff --git a/glob/manager_core.py b/glob/manager_core.py index 0e7400bf..08bd0c7c 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -23,7 +23,7 @@ import cm_global from manager_util import * -version = [2, 50, 3] +version = [2, 51] version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '') diff --git a/js/comfyui-manager.js b/js/comfyui-manager.js index 1b074a1d..b0189326 100644 --- a/js/comfyui-manager.js +++ b/js/comfyui-manager.js @@ -202,6 +202,40 @@ docStyle.innerHTML = ` } `; +function is_legacy_front() { + let compareVersion = '1.2.49'; + try { + const frontendVersion = window['__COMFYUI_FRONTEND_VERSION__']; + if (typeof frontendVersion !== 'string') { + return false; + } + + function parseVersion(versionString) { + const parts = versionString.split('.').map(Number); + return parts.length === 3 && parts.every(part => !isNaN(part)) ? parts : null; + } + + const currentVersion = parseVersion(frontendVersion); + const comparisonVersion = parseVersion(compareVersion); + + if (!currentVersion || !comparisonVersion) { + return false; + } + + for (let i = 0; i < 3; i++) { + if (currentVersion[i] > comparisonVersion[i]) { + return false; + } else if (currentVersion[i] < comparisonVersion[i]) { + return true; + } + } + + return false; + } catch { + return true; + } +} + document.head.appendChild(docStyle); var update_comfyui_button = null; @@ -842,24 +876,27 @@ class ManagerMenuDialog extends ComfyDialog { }); // nickname - let badge_combo = document.createElement("select"); - badge_combo.setAttribute("title", "Configure the content to be displayed on the badge at the top right corner of the node. The ID is the identifier of the node. If 'hide built-in' is selected, both unknown nodes and built-in nodes will be omitted, making them indistinguishable"); - badge_combo.className = "cm-menu-combo"; - badge_combo.appendChild($el('option', { value: 'none', text: 'Badge: None' }, [])); - badge_combo.appendChild($el('option', { value: 'nick', text: 'Badge: Nickname' }, [])); - badge_combo.appendChild($el('option', { value: 'nick_hide', text: 'Badge: Nickname (hide built-in)' }, [])); - badge_combo.appendChild($el('option', { value: 'id_nick', text: 'Badge: #ID Nickname' }, [])); - badge_combo.appendChild($el('option', { value: 'id_nick_hide', text: 'Badge: #ID Nickname (hide built-in)' }, [])); - - api.fetchApi('/manager/badge_mode') - .then(response => response.text()) - .then(data => { badge_combo.value = data; badge_mode = data; }); - - badge_combo.addEventListener('change', function (event) { - api.fetchApi(`/manager/badge_mode?value=${event.target.value}`); - badge_mode = event.target.value; - app.graph.setDirtyCanvas(true); - }); + let badge_combo = ""; + if(is_legacy_front()) { + badge_combo = document.createElement("select"); + badge_combo.setAttribute("title", "Configure the content to be displayed on the badge at the top right corner of the node. The ID is the identifier of the node. If 'hide built-in' is selected, both unknown nodes and built-in nodes will be omitted, making them indistinguishable"); + badge_combo.className = "cm-menu-combo"; + badge_combo.appendChild($el('option', { value: 'none', text: 'Badge: None' }, [])); + badge_combo.appendChild($el('option', { value: 'nick', text: 'Badge: Nickname' }, [])); + badge_combo.appendChild($el('option', { value: 'nick_hide', text: 'Badge: Nickname (hide built-in)' }, [])); + badge_combo.appendChild($el('option', { value: 'id_nick', text: 'Badge: #ID Nickname' }, [])); + badge_combo.appendChild($el('option', { value: 'id_nick_hide', text: 'Badge: #ID Nickname (hide built-in)' }, [])); + + api.fetchApi('/manager/badge_mode') + .then(response => response.text()) + .then(data => { badge_combo.value = data; badge_mode = data; }); + + badge_combo.addEventListener('change', function (event) { + api.fetchApi(`/manager/badge_mode?value=${event.target.value}`); + badge_mode = event.target.value; + app.graph.setDirtyCanvas(true); + }); + } // channel let channel_combo = document.createElement("select"); @@ -1411,24 +1448,28 @@ app.registerExtension({ }, async nodeCreated(node, app) { - if(!node.badge_enabled) { - node.getNickname = function () { return getNickname(node, node.comfyClass.trim()) }; - let orig = node.onDrawForeground; - if(!orig) - orig = node.__proto__.onDrawForeground; - - node.onDrawForeground = function (ctx) { - drawBadge(node, orig, arguments) - }; - node.badge_enabled = true; + if(is_legacy_front()) { + if(!node.badge_enabled) { + node.getNickname = function () { return getNickname(node, node.comfyClass.trim()) }; + let orig = node.onDrawForeground; + if(!orig) + orig = node.__proto__.onDrawForeground; + + node.onDrawForeground = function (ctx) { + drawBadge(node, orig, arguments) + }; + node.badge_enabled = true; + } } }, async loadedGraphNode(node, app) { - if(!node.badge_enabled) { - const orig = node.onDrawForeground; - node.getNickname = function () { return getNickname(node, node.type.trim()) }; - node.onDrawForeground = function (ctx) { drawBadge(node, orig, arguments) }; + if(is_legacy_front()) { + if(!node.badge_enabled) { + const orig = node.onDrawForeground; + node.getNickname = function () { return getNickname(node, node.type.trim()) }; + node.onDrawForeground = function (ctx) { drawBadge(node, orig, arguments) }; + } } }, diff --git a/pyproject.toml b/pyproject.toml index f893f54b..ce8790d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-manager" description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI." -version = "2.50.3" +version = "2.51" license = { file = "LICENSE.txt" } dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]