| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | import { app } from "../../scripts/app.js"; |
| | import { api } from "../../scripts/api.js"; |
| |
|
| | class WorkflowMetadataExtension { |
| | constructor() { |
| | this.name = "Comfy.CustomNodesManager.WorkflowMetadata"; |
| | this.installedNodes = {}; |
| | this.comfyCoreVersion = null; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | async getInstalledNodes() { |
| | const res = await api.fetchApi("/customnode/installed"); |
| | return await res.json(); |
| | } |
| |
|
| | async init() { |
| | this.installedNodes = await this.getInstalledNodes(); |
| | this.comfyCoreVersion = (await api.getSystemStats()).system.comfyui_version; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | nodeCreated(node) { |
| | try { |
| | |
| | if (!node?.constructor?.nodeData?.python_module) return; |
| |
|
| | const nodeProperties = (node.properties ??= {}); |
| | const modules = node.constructor.nodeData.python_module.split("."); |
| | const moduleType = modules[0]; |
| |
|
| | if (moduleType === "custom_nodes") { |
| | const nodePackageName = modules[1]; |
| | const { cnr_id, aux_id, ver } = |
| | this.installedNodes[nodePackageName] ?? |
| | this.installedNodes[nodePackageName.toLowerCase()] ?? |
| | {}; |
| |
|
| | if (cnr_id === "comfy-core") return; |
| | if (cnr_id) nodeProperties.cnr_id = cnr_id; |
| | else nodeProperties.aux_id = aux_id; |
| | if (ver) nodeProperties.ver = ver.trim(); |
| | } else if (["nodes", "comfy_extras", "comfy_api_nodes"].includes(moduleType)) { |
| | nodeProperties.cnr_id = "comfy-core"; |
| | nodeProperties.ver = this.comfyCoreVersion; |
| | } |
| | } catch (e) { |
| | console.error(e); |
| | } |
| | } |
| | } |
| |
|
| | app.registerExtension(new WorkflowMetadataExtension()); |
| |
|