This commit is contained in:
Chris
2025-11-26 12:43:07 +11:00
parent 956a7bda4a
commit 6099d9fc10
5 changed files with 48 additions and 8 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ from .list_utility_nodes import PickFromList, BatchFromImageList, ImageListFromB
from .string_utility_nodes import SplitByCommas, StringToFloat, StringToInt, AnyListToString
from .mask_utility_nodes import MaskedSection
VERSION = "1.6.5"
VERSION = "1.7"
WEB_DIRECTORY = "./js"
NODE_CLASS_MAPPINGS= {
+18 -4
View File
@@ -4,7 +4,7 @@ import { api } from "../../scripts/api.js";
import { create } from "./utils.js";
import { popup } from "./popup.js";
import { ComfyWidgets } from "../../scripts/widgets.js";
import { FloatingWindow } from "./floating_window.js";
import { unique_to_tab } from "./weak_map.js";
const FILTER_TYPES = ["Image Filter","Text Image Filter","Text Image Filter with Extras","Mask Image Filter"]
@@ -13,7 +13,7 @@ app.registerExtension({
settings: [
{
id: "Image Filter. Image Filter",
name: "Version 1.6.5",
name: "Version 1.7",
type: () => {
const x = document.createElement('span')
const a = document.createElement('a')
@@ -109,16 +109,30 @@ app.registerExtension({
nodeType.prototype.onNodeCreated = function () {
this._ni_widget = this.widgets.find((n)=>n.name=='node_identifier')
if (!(this._ni_widget)) {
this._ni_widget = ComfyWidgets["INT"](this, "node_identifier", ["INT", { "default":0 }], app).widget
this._ni_widget = ComfyWidgets["STRING"](this, "node_identifier", ["STRING", { "default":"" }], app).widget
}
this._ni_widget.hidden = true
this._ni_widget.computeSize = () => [0,0]
this._ni_widget.value = Math.floor(Math.random() * 1000000)
return onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined;
}
}
},
afterConfigureGraph() {
setTimeout( ()=> {
const checked = document.getElementsByClassName('p-togglebutton-checked')[0]
app.graph.nodes.forEach( (node)=> {
const unique_id_widget = node.widgets?.find((n)=>n.name=='node_identifier')
if (unique_id_widget) {
unique_id_widget.value = `${node.graph.id}:${node.id}`
unique_to_tab.set(unique_id_widget.value, checked )
}
})
}, 1000)
}
})
+12 -2
View File
@@ -5,6 +5,7 @@ import { mask_editor_listen_for_cancel, mask_editor_showing, hide_mask_editor, p
import { Log } from "./log.js";
import { create } from "./utils.js";
import { FloatingWindow } from "./floating_window.js";
import { unique_to_tab } from "./weak_map.js";
//const EXTENSION_NODES = ["Image Filter", "Text Image Filter", "Mask Image Filter", "Text Image Filter with Extras",]
const POPUP_NODES = ["Image Filter", "Text Image Filter", "Text Image Filter with Extras",]
@@ -272,9 +273,18 @@ class Popup extends HTMLElement {
const the_node = this.find_node(uid)
if (this.node!=the_node) this.on_new_node(the_node)
const tab = unique_to_tab.get(message.detail.unique)
if (!this.node) return console.log(`Message was for ${uid} which doesn't exist`)
if (this.node._ni_widget?.value != message.detail.unique) return console.log(`Message unique id wasn't mine`)
if (!this.node || this.node._ni_widget?.value != message.detail.unique) {
if (tab) {
if (!tab.innerHTML.endsWith('! ')) tab.innerHTML += '! '
}
return console.log(`Message unique id wasn't mine`)
} else {
if (tab) {
if (tab.innerHTML.endsWith('! ')) tab.innerHTML = tab.innerHTML.substring(0, tab.innerHTML.length-7)
}
}
if (detail.tick) {
this.counter_text.innerText = `${detail.tick}s`
+16
View File
@@ -0,0 +1,16 @@
class WeakMap {
constructor() {
this.map = {}
}
set(key, value) {
this.map[key] = new WeakRef(value)
}
get(key) {
return this.map[key]?.deref()
}
}
export const unique_to_tab = new WeakMap()
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "cg-image-filter"
description = "A set of custom nodes that pause a workflow while you select images, add masks, or edit text."
version = "1.6.5"
version = "1.7"
license = { file = "LICENSE" }
[project.urls]