From 51530a9eb7d34c418a5d00329fc873fecee5f7f4 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 00:18:01 +0000 Subject: [PATCH 01/10] Update custom-nodes/js/javascript_hooks.mdx --- custom-nodes/js/javascript_hooks.mdx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/custom-nodes/js/javascript_hooks.mdx b/custom-nodes/js/javascript_hooks.mdx index a4d4dfb4..41a7cdd4 100644 --- a/custom-nodes/js/javascript_hooks.mdx +++ b/custom-nodes/js/javascript_hooks.mdx @@ -50,6 +50,11 @@ might modify yours!), in which case care should be taken to ensure interoperabil And play nicely - isolate your changes wherever possible. A very common idiom in `beforeRegisterNodeDef` is to 'hijack' an existing method: + + +**Deprecated:** The prototype hijacking pattern shown below is deprecated and subject to change at any point in the near future. For context menus, use the official [Context Menu API](/custom-nodes/js/context-menu-migration) instead. For other use cases, prefer using the official [extension hooks](/custom-nodes/js/javascript_hooks) where available. + + ```Javascript async beforeRegisterNodeDef(nodeType, nodeData, app) { if (nodeType.comfyClass=="MyNodeClass") { @@ -70,6 +75,8 @@ or even make calling it conditional. When hijacking a method in this way, you will want to look at the core comfy code (breakpoints are your friend) to check and conform with the method signature. +This approach is fragile and may break with future ComfyUI updates. Use official APIs whenever possible. + #### nodeCreated() ```Javascript From 1bca2de3213c8aaa8e24f6998a1f68c82f91170b Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 00:18:13 +0000 Subject: [PATCH 02/10] Update custom-nodes/js/javascript_objects_and_hijacking.mdx --- custom-nodes/js/javascript_objects_and_hijacking.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom-nodes/js/javascript_objects_and_hijacking.mdx b/custom-nodes/js/javascript_objects_and_hijacking.mdx index 6a6571c2..7477a708 100644 --- a/custom-nodes/js/javascript_objects_and_hijacking.mdx +++ b/custom-nodes/js/javascript_objects_and_hijacking.mdx @@ -14,6 +14,10 @@ which can be found at `doc/index.html`. The `app` object (always accessible by `import { app } from "../../scripts/app.js";`) represents the Comfy application running in the browser, and contains a number of useful properties and functions, some of which are listed below. + +**Deprecated:** Hijacking/monkey-patching functions on `app` or prototypes is deprecated and subject to change at any point in the near future. Use the official [extension hooks](/custom-nodes/js/javascript_hooks) and [Context Menu API](/custom-nodes/js/context-menu-migration) instead. + + Hijacking functions on `app` is not recommended, as Comfy is under constant development, and core behavior may change. ### Properties From c280e8a2eb1c8852c74aca0987b5b05eed8cd8fb Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 00:18:25 +0000 Subject: [PATCH 03/10] Update custom-nodes/js/javascript_objects_and_hijacking.mdx --- custom-nodes/js/javascript_objects_and_hijacking.mdx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom-nodes/js/javascript_objects_and_hijacking.mdx b/custom-nodes/js/javascript_objects_and_hijacking.mdx index 7477a708..284b8fb6 100644 --- a/custom-nodes/js/javascript_objects_and_hijacking.mdx +++ b/custom-nodes/js/javascript_objects_and_hijacking.mdx @@ -85,7 +85,11 @@ Group nodes, primitive nodes, notes, and redirect nodes have different propertie A `ComfyNode` object represents a node in the current workflow. It has a number of important properties that you may wish to make use of, a very large number of functions that you may wish to use, or hijack to -modify behavior. +modify behavior. + + +**Deprecated:** Hijacking prototype methods on `ComfyNode` or `LGraphNode` is deprecated and subject to change at any point in the near future. Use the official [extension hooks](/custom-nodes/js/javascript_hooks) where available, such as `getNodeMenuItems` for context menus. See the [Context Menu Migration Guide](/custom-nodes/js/context-menu-migration) for examples. + To get a more complete sense of the node object, you may find it helpful to insert the following code into your extension and place a breakpoint on the `console.log` command. When you then create a new node From 066e967e3f60a37dd7a396bae9cb221e1b406f65 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 00:18:38 +0000 Subject: [PATCH 04/10] Update custom-nodes/js/javascript_examples.mdx --- custom-nodes/js/javascript_examples.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom-nodes/js/javascript_examples.mdx b/custom-nodes/js/javascript_examples.mdx index 3c3d5eed..4cb5a7b8 100644 --- a/custom-nodes/js/javascript_examples.mdx +++ b/custom-nodes/js/javascript_examples.mdx @@ -119,6 +119,10 @@ import { api } from "../../scripts/api.js"; ## Detect an interrupted workflow + +**Deprecated:** The API hijacking pattern shown below is deprecated and subject to change at any point in the near future. Use the official [extension hooks](/custom-nodes/js/javascript_hooks) and API event listeners where available. + + A simple example of hijacking the api: ```Javascript From 0993555cf6053f986029833075604eff4e989786 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 00:18:48 +0000 Subject: [PATCH 05/10] Update custom-nodes/js/javascript_examples.mdx --- custom-nodes/js/javascript_examples.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom-nodes/js/javascript_examples.mdx b/custom-nodes/js/javascript_examples.mdx index 4cb5a7b8..864d9eff 100644 --- a/custom-nodes/js/javascript_examples.mdx +++ b/custom-nodes/js/javascript_examples.mdx @@ -138,6 +138,10 @@ import { api } from "../../scripts/api.js"; ## Catch clicks on your node + +**Deprecated:** The node method hijacking pattern shown below is deprecated and subject to change at any point in the near future. Use the official [extension hooks](/custom-nodes/js/javascript_hooks) where available. + + `node` has a mouseDown method you can hijack. This time we're careful to pass on any return value. From cecc4a150ffa115a8e515532274a3ec6445a4434 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 04:00:01 +0000 Subject: [PATCH 06/10] Update zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx --- zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx b/zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx index abcf24ac..4c66085d 100644 --- a/zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx +++ b/zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx @@ -11,6 +11,10 @@ Comfy 的许多功能都由 LiteGraph 提供,因此如果你要开发更复杂 `app` 对象(始终可通过 `import { app } from "../../scripts/app.js";` 获取)代表在浏览器中运行的 Comfy 应用,包含许多有用的属性和函数,部分如下所示。 + +**已弃用:** 劫持/猴子补丁 `app` 上的函数或原型方法已被弃用,可能在不久的将来随时更改。请改用官方的 [扩展钩子](/zh-CN/custom-nodes/js/javascript_hooks) 和 [右键菜单 API](/zh-CN/custom-nodes/js/context-menu-migration)。 + + 不建议劫持 `app` 上的函数,因为 Comfy 正在持续开发,核心行为可能会变化。 ### 属性 From 5c2cce3dca760c78c33fb426af317e25f8873c51 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 04:00:09 +0000 Subject: [PATCH 07/10] Update zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx --- zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx b/zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx index 4c66085d..bbedfc91 100644 --- a/zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx +++ b/zh-CN/custom-nodes/js/javascript_objects_and_hijacking.mdx @@ -78,6 +78,10 @@ ComfyNode_object_for_my_node.inputs.forEach(input => { `ComfyNode` 对象代表当前工作流中的一个节点。它有许多重要属性和大量可用或可劫持的函数,用于修改行为。 + +**已弃用:** 劫持 `ComfyNode` 或 `LGraphNode` 上的原型方法已被弃用,可能在不久的将来随时更改。请尽可能使用官方的 [扩展钩子](/zh-CN/custom-nodes/js/javascript_hooks),例如使用 `getNodeMenuItems` 处理右键菜单。参见 [右键菜单迁移指南](/zh-CN/custom-nodes/js/context-menu-migration) 获取示例。 + + 为了更全面地了解节点对象,你可以在扩展中插入如下代码,并在 `console.log` 处打断点。创建新节点时即可用调试器查看节点。 ```Javascript From 1defddbbc9db6415a5c9ef8f3e43ce5016b4de71 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 04:00:18 +0000 Subject: [PATCH 08/10] Update zh-CN/custom-nodes/js/javascript_examples.mdx --- zh-CN/custom-nodes/js/javascript_examples.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zh-CN/custom-nodes/js/javascript_examples.mdx b/zh-CN/custom-nodes/js/javascript_examples.mdx index 472b4bec..c990948c 100644 --- a/zh-CN/custom-nodes/js/javascript_examples.mdx +++ b/zh-CN/custom-nodes/js/javascript_examples.mdx @@ -116,6 +116,10 @@ import { api } from "../../scripts/api.js"; ## 检测工作流被中断 + +**已弃用:** 下面展示的 API 劫持模式已被弃用,可能在不久的将来随时更改。请尽可能使用官方的 [扩展钩子](/zh-CN/custom-nodes/js/javascript_hooks) 和 API 事件监听器。 + + 这是一个劫持 api 的简单例子: ```Javascript From 5fe5dda4126fa4abb80a1bd63c1f34bee0520cb0 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 04:00:21 +0000 Subject: [PATCH 09/10] Update zh-CN/custom-nodes/js/javascript_examples.mdx --- zh-CN/custom-nodes/js/javascript_examples.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zh-CN/custom-nodes/js/javascript_examples.mdx b/zh-CN/custom-nodes/js/javascript_examples.mdx index c990948c..03646f63 100644 --- a/zh-CN/custom-nodes/js/javascript_examples.mdx +++ b/zh-CN/custom-nodes/js/javascript_examples.mdx @@ -135,6 +135,10 @@ import { api } from "../../scripts/api.js"; ## 捕获节点点击 + +**已弃用:** 下面展示的节点方法劫持模式已被弃用,可能在不久的将来随时更改。请尽可能使用官方的 [扩展钩子](/zh-CN/custom-nodes/js/javascript_hooks)。 + + `node` 有一个 mouseDown 方法可以被劫持。 这次我们注意传递任何返回值。 From 8b2365fa2372b454d186b8db9e1f981391f2aaf6 Mon Sep 17 00:00:00 2001 From: ComfyUI Wiki Date: Thu, 27 Nov 2025 23:28:22 +0800 Subject: [PATCH 10/10] Update Chinese version --- zh-CN/custom-nodes/js/javascript_hooks.mdx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zh-CN/custom-nodes/js/javascript_hooks.mdx b/zh-CN/custom-nodes/js/javascript_hooks.mdx index 286b014e..761b08ae 100644 --- a/zh-CN/custom-nodes/js/javascript_hooks.mdx +++ b/zh-CN/custom-nodes/js/javascript_hooks.mdx @@ -35,6 +35,11 @@ async beforeRegisterNodeDef(nodeType, nodeData, app) 由于其他扩展也可能会修改节点,建议尽量减少假设,并尽量隔离你的更改,友好共存。 在 `beforeRegisterNodeDef` 中非常常见的做法是"劫持"已有方法: + + +**已弃用:** 下面展示的原型劫持模式已被弃用,可能在不久的将来随时更改。对于右键菜单,请改用官方的 [右键菜单 API](/zh-CN/custom-nodes/js/context-menu-migration)。对于其他用例,请尽可能使用官方的 [扩展钩子](/zh-CN/custom-nodes/js/javascript_hooks)。 + + ```Javascript async beforeRegisterNodeDef(nodeType, nodeData, app) { if (nodeType.comfyClass=="MyNodeClass") { @@ -51,6 +56,8 @@ async beforeRegisterNodeDef(nodeType, nodeData, app) { 以这种方式劫持方法时,建议查看核心 comfy 代码(断点调试很有用),以确保方法签名一致。 +这种方法比较脆弱,可能会在未来的 ComfyUI 更新中失效。请尽可能使用官方 API。 + #### nodeCreated() ```Javascript