From f044a9dbb3fc9de55c6244d616d386986add3072 Mon Sep 17 00:00:00 2001 From: rgthree Date: Sat, 29 Mar 2025 14:49:35 -0400 Subject: [PATCH] Adds the comfyorg/comfyui-frontend-types to the codebase. --- package-lock.json | 316 +++++++++++++++++- package.json | 3 +- src_web/comfyui/any_switch.ts | 13 +- .../comfyui/base_any_input_connected_node.ts | 7 +- src_web/comfyui/base_node.ts | 33 +- src_web/comfyui/base_node_collector.ts | 2 +- src_web/comfyui/base_node_mode_changer.ts | 14 +- src_web/comfyui/base_power_prompt.ts | 16 +- src_web/comfyui/bookmark.ts | 6 +- src_web/comfyui/bypasser.ts | 2 +- src_web/comfyui/comfy_ui_bar.ts | 2 +- src_web/comfyui/config.ts | 3 +- src_web/comfyui/context.ts | 27 +- src_web/comfyui/display_any.ts | 9 +- src_web/comfyui/dynamic_context.ts | 7 +- src_web/comfyui/dynamic_context_base.ts | 8 +- src_web/comfyui/dynamic_context_switch.ts | 23 +- src_web/comfyui/fast_actions_button.ts | 18 +- src_web/comfyui/fast_groups_bypasser.ts | 4 +- src_web/comfyui/fast_groups_muter.ts | 24 +- src_web/comfyui/feature_group_fast_toggle.ts | 4 +- .../feature_import_individual_nodes.ts | 20 +- src_web/comfyui/image_comparer.ts | 61 ++-- src_web/comfyui/image_inset_crop.ts | 13 +- src_web/comfyui/label.ts | 32 +- src_web/comfyui/menu_auto_nest.ts | 4 +- src_web/comfyui/menu_copy_image.ts | 6 +- src_web/comfyui/menu_queue_node.ts | 6 +- src_web/comfyui/muter.ts | 5 +- src_web/comfyui/node_collector.ts | 16 +- src_web/comfyui/node_mode_relay.ts | 16 +- src_web/comfyui/node_mode_repeater.ts | 16 +- src_web/comfyui/power_lora_loader.ts | 17 +- src_web/comfyui/power_prompt.ts | 30 +- src_web/comfyui/random_unmuter.ts | 5 +- src_web/comfyui/reroute.ts | 14 +- src_web/comfyui/rgthree.ts | 38 ++- src_web/comfyui/seed.ts | 20 +- .../comfyui/services/bookmarks_services.ts | 6 +- src_web/comfyui/services/context_service.ts | 3 +- .../comfyui/services/fast_groups_service.ts | 8 +- src_web/comfyui/testing/comfyui_env.ts | 11 +- .../comfyui/tests/context_dynamic_tests.ts | 2 +- src_web/comfyui/utils.ts | 104 +++--- src_web/comfyui/utils_canvas.ts | 14 +- src_web/comfyui/utils_inputs_outputs.ts | 2 +- src_web/comfyui/utils_menu.ts | 8 +- src_web/comfyui/utils_widgets.ts | 6 +- src_web/common/dialog.ts | 2 +- src_web/common/link_fixer.ts | 64 ++-- src_web/common/prompt_service.ts | 2 +- src_web/common/utils_workflow.ts | 9 +- src_web/link_fixer/link_page.ts | 8 +- src_web/scripts_comfy/app.ts | 14 +- src_web/scripts_comfy/ui/components/button.ts | 10 +- src_web/scripts_comfy/widgets.ts | 6 +- src_web/typings/README.md | 3 - src_web/typings/comfy.d.ts | 190 ++++------- src_web/typings/index.d.ts | 79 ++--- src_web/typings/litegraph.d.ts | 162 +++++---- src_web/typings/rgthree.d.ts | 27 +- tsconfig.json | 8 +- web/comfyui/base_node.js | 9 +- web/comfyui/base_node_mode_changer.js | 7 - web/comfyui/config.js | 1 + web/comfyui/dynamic_context_base.js | 2 +- web/comfyui/fast_actions_button.js | 4 +- web/comfyui/fast_groups_muter.js | 9 +- .../feature_import_individual_nodes.js | 4 +- web/comfyui/image_comparer.js | 2 +- web/comfyui/image_inset_crop.js | 2 +- web/comfyui/node_collector.js | 7 - web/comfyui/node_mode_relay.js | 7 - web/comfyui/node_mode_repeater.js | 7 - web/comfyui/power_prompt.js | 2 +- web/comfyui/reroute.js | 9 +- web/comfyui/rgthree.js | 6 +- web/comfyui/utils.js | 14 +- web/common/link_fixer.js | 2 +- 79 files changed, 905 insertions(+), 797 deletions(-) delete mode 100644 src_web/typings/README.md diff --git a/package-lock.json b/package-lock.json index ab0658f..1f74417 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,18 +5,198 @@ "packages": { "": { "devDependencies": { + "@comfyorg/comfyui-frontend-types": "^1.15.5", "@comfyorg/litegraph": "^0.11.3", "prettier": "^3.3.3", "sass": "^1.77.8", "typescript": "^5.5.4" } }, + "node_modules/@babel/helper-string-parser": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", + "dev": true, + "peer": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "dev": true, + "peer": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.0.tgz", + "integrity": "sha512-iaepho73/2Pz7w2eMS0Q5f83+0RKI7i4xmiYeBmDzfRVbQtTOG7Ts0S4HzJVsTMGI9keU8rNfuZr8DKfSt7Yyg==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/types": "^7.27.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.0.tgz", + "integrity": "sha512-H45s8fVLYjbhFH62dIJ3WtmJ6RSPt/3DRO0ZcT2SUiYiQyz3BLVb9ADEnLl91m74aQPS3AzzeajZHYOalWe3bg==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@comfyorg/comfyui-frontend-types": { + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/@comfyorg/comfyui-frontend-types/-/comfyui-frontend-types-1.15.5.tgz", + "integrity": "sha512-SPxvpFabzTEoYczFoUHcc7hgUTXyHLjJh1yNjWkkvJgZrJAQAKeqD9/YT/EMKqzDSphPM2KPu2Yh9VJgpjXVcw==", + "dev": true, + "dependencies": { + "@comfyorg/litegraph": "^0.11.5" + }, + "peerDependencies": { + "vue": "^3.5.13", + "zod": "^3.23.8" + } + }, "node_modules/@comfyorg/litegraph": { - "version": "0.11.3", - "resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.11.3.tgz", - "integrity": "sha512-OEZJMFbC4WwsIW+w42MA8cwMY/Uu+OL5tQfvdhrlIj51G/TZv1yvU7tNPeu0gZM24Vm5rzF9IxXF8aajD9BIlw==", + "version": "0.11.5", + "resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.11.5.tgz", + "integrity": "sha512-GBNloRNLEI/R+7zFcrXauMND1VJAMYqjheX6hcbqucCzSHBNlkcJnbhstvILSPIuv0GP1tEgzN4EDe5JtKIqoQ==", "dev": true }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "peer": true + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz", + "integrity": "sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/parser": "^7.25.3", + "@vue/shared": "3.5.13", + "entities": "^4.5.0", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.0" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.13.tgz", + "integrity": "sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==", + "dev": true, + "peer": true, + "dependencies": { + "@vue/compiler-core": "3.5.13", + "@vue/shared": "3.5.13" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.13.tgz", + "integrity": "sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/parser": "^7.25.3", + "@vue/compiler-core": "3.5.13", + "@vue/compiler-dom": "3.5.13", + "@vue/compiler-ssr": "3.5.13", + "@vue/shared": "3.5.13", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.11", + "postcss": "^8.4.48", + "source-map-js": "^1.2.0" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.13.tgz", + "integrity": "sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==", + "dev": true, + "peer": true, + "dependencies": { + "@vue/compiler-dom": "3.5.13", + "@vue/shared": "3.5.13" + } + }, + "node_modules/@vue/reactivity": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.13.tgz", + "integrity": "sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==", + "dev": true, + "peer": true, + "dependencies": { + "@vue/shared": "3.5.13" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.13.tgz", + "integrity": "sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==", + "dev": true, + "peer": true, + "dependencies": { + "@vue/reactivity": "3.5.13", + "@vue/shared": "3.5.13" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.13.tgz", + "integrity": "sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==", + "dev": true, + "peer": true, + "dependencies": { + "@vue/reactivity": "3.5.13", + "@vue/runtime-core": "3.5.13", + "@vue/shared": "3.5.13", + "csstype": "^3.1.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.13.tgz", + "integrity": "sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==", + "dev": true, + "peer": true, + "dependencies": { + "@vue/compiler-ssr": "3.5.13", + "@vue/shared": "3.5.13" + }, + "peerDependencies": { + "vue": "3.5.13" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.13.tgz", + "integrity": "sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==", + "dev": true, + "peer": true + }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -78,6 +258,33 @@ "fsevents": "~2.3.2" } }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "dev": true, + "peer": true + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "peer": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "peer": true + }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -164,6 +371,35 @@ "node": ">=0.12.0" } }, + "node_modules/magic-string": { + "version": "0.30.17", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", + "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "dev": true, + "peer": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "peer": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -173,6 +409,13 @@ "node": ">=0.10.0" } }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "peer": true + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -185,6 +428,35 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/postcss": { + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz", + "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "peer": true, + "dependencies": { + "nanoid": "^3.3.8", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, "node_modules/prettier": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", @@ -230,9 +502,9 @@ } }, "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -262,6 +534,38 @@ "engines": { "node": ">=14.17" } + }, + "node_modules/vue": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.13.tgz", + "integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==", + "dev": true, + "peer": true, + "dependencies": { + "@vue/compiler-dom": "3.5.13", + "@vue/compiler-sfc": "3.5.13", + "@vue/runtime-dom": "3.5.13", + "@vue/server-renderer": "3.5.13", + "@vue/shared": "3.5.13" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/zod": { + "version": "3.24.2", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", + "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", + "dev": true, + "peer": true, + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/package.json b/package.json index 570b802..bd37504 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "prettier": "^3.3.3", "typescript": "^5.5.4", "sass": "^1.77.8", - "@comfyorg/litegraph": "^0.11.3" + "@comfyorg/litegraph": "^0.11.3", + "@comfyorg/comfyui-frontend-types": "^1.15.5" }, "scripts": { "build": "./__build__.py || python .\\__build__.py" diff --git a/src_web/comfyui/any_switch.ts b/src_web/comfyui/any_switch.ts index 7ecae45..cfbcd5e 100644 --- a/src_web/comfyui/any_switch.ts +++ b/src_web/comfyui/any_switch.ts @@ -1,5 +1,6 @@ -import type { INodeInputSlot, INodeOutputSlot, LLink } from "@litegraph/litegraph.js"; -import type { ComfyApp, ComfyNodeConstructor, ComfyObjectInfo } from "typings/comfy.js"; +import type { INodeInputSlot, INodeOutputSlot, LGraphNodeConstructor, LLink } from "@comfyorg/litegraph"; +import type { ComfyApp } from "@comfyorg/frontend"; +import type { ComfyNodeDef } from "typings/comfy.js"; import { app } from "scripts/app.js"; import { IoDirection, addConnectionLayoutSupport, followConnectionUntilType } from "./utils.js"; @@ -78,7 +79,7 @@ class RgthreeAnySwitch extends RgthreeBaseServerNode { } } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { RgthreeBaseServerNode.registerForOverride(comfyClass, nodeData, RgthreeAnySwitch); addConnectionLayoutSupport(RgthreeAnySwitch, app, [ ["Left", "Right"], @@ -89,11 +90,7 @@ class RgthreeAnySwitch extends RgthreeBaseServerNode { app.registerExtension({ name: "rgthree.AnySwitch", - async beforeRegisterNodeDef( - nodeType: ComfyNodeConstructor, - nodeData: ComfyObjectInfo, - app: ComfyApp, - ) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: any, app: ComfyApp) { if (nodeData.name === "Any Switch (rgthree)") { RgthreeAnySwitch.setUp(nodeType, nodeData); } diff --git a/src_web/comfyui/base_any_input_connected_node.ts b/src_web/comfyui/base_any_input_connected_node.ts index 5305acb..a2b1d49 100644 --- a/src_web/comfyui/base_any_input_connected_node.ts +++ b/src_web/comfyui/base_any_input_connected_node.ts @@ -6,12 +6,11 @@ import type { LGraphNode as TLGraphNode, IWidget, ISlotType, -} from "@litegraph/litegraph.js"; +} from "@comfyorg/litegraph"; import {app} from "scripts/app.js"; import {RgthreeBaseVirtualNode} from "./base_node.js"; import {rgthree} from "./rgthree.js"; - import { PassThroughFollowing, addConnectionLayoutSupport, @@ -21,8 +20,8 @@ import { getConnectedOutputNodes, getConnectedOutputNodesAndFilterPassThroughs, } from "./utils.js"; -import {ConnectByTypeOptions} from "@litegraph/LGraphNode.js"; -import {TWidgetType, IWidgetOptions} from "@litegraph/types/widgets.js"; +import {ConnectByTypeOptions} from "@comfyorg/litegraph/dist/LGraphNode.js"; +import {TWidgetType, IWidgetOptions} from "@comfyorg/litegraph/dist/types/widgets.js"; /** * A Virtual Node that allows any node's output to connect to it. diff --git a/src_web/comfyui/base_node.ts b/src_web/comfyui/base_node.ts index b8274c2..4c501b0 100644 --- a/src_web/comfyui/base_node.ts +++ b/src_web/comfyui/base_node.ts @@ -1,17 +1,17 @@ -import type {ComfyNodeConstructor, ComfyObjectInfo} from "typings/comfy.js"; import type { IWidget, LGraphCanvas, IContextMenuValue, IFoundSlot, LGraphEventMode, -} from "@litegraph/litegraph.js"; -import type {ISerialisedNode} from "@litegraph/types/serialisation.js"; + LGraphNodeConstructor, +} from "@comfyorg/litegraph"; +import type {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation.js"; +import type {ComfyNodeDef} from "typings/comfy.js"; import type {RgthreeBaseServerNodeConstructor} from "typings/rgthree.js"; import {ComfyWidgets} from "scripts/widgets.js"; import {SERVICE as KEY_EVENT_SERVICE} from "./services/key_events_services.js"; -import {app} from "scripts/app.js"; import {LogLevel, rgthree} from "./rgthree.js"; import {addHelpMenuItem} from "./utils.js"; import {RgthreeHelpDialog} from "rgthree/common/dialog.js"; @@ -25,13 +25,14 @@ import {defineProperty} from "rgthree/common/shared_utils.js"; * A base node with standard methods, directly extending the LGraphNode. * This can be used for ui-nodes and a further base for server nodes. */ -export abstract class RgthreeBaseNode extends LGraphNode { +abstract class RgthreeBaseNode extends LGraphNode { /** * Action strings that can be exposed and triggered from other nodes, like Fast Actions Button. */ static exposedActions: string[] = []; static override title: string = "__NEED_CLASS_TITLE__"; + static override type: string = "__NEED_CLASS_TYPE__"; static override category = "rgthree"; static _category = "rgthree"; // `category` seems to get reset by comfy, so reset to this after. @@ -44,12 +45,12 @@ export abstract class RgthreeBaseNode extends LGraphNode { * set it here so extensions that are none the wiser don't break on some unchecked string method * call on an undefined calue. */ - comfyClass: string = "__NEED_COMFY_CLASS__"; + override comfyClass: string = "__NEED_COMFY_CLASS__"; /** Used by the ComfyUI-Manager badge. */ readonly nickname = "rgthree"; /** Are we a virtual node? */ - readonly isVirtualNode: boolean = false; + override readonly isVirtualNode: boolean = false; /** Are we able to be dropped on (if config is enabled too). */ isDropEnabled = false; /** A state member determining if we're currently removed. */ @@ -83,6 +84,9 @@ export abstract class RgthreeBaseNode extends LGraphNode { if (this.comfyClass == "__NEED_COMFY_CLASS__") { throw new Error("RgthreeBaseNode needs a comfy class override."); } + if (this.constructor.type == "__NEED_CLASS_TYPE__") { + throw new Error("RgthreeBaseNode needs overrides."); + } // Ensure we've called onConstructed before we got here. this.checkAndRunOnConstructed(); }); @@ -113,12 +117,12 @@ export abstract class RgthreeBaseNode extends LGraphNode { return this.__constructed__; } - onDragOver(e: DragEvent): boolean { + override onDragOver(e: DragEvent): boolean { if (!this.isDropEnabled) return false; return importIndividualNodesInnerOnDragOver(this, e); } - async onDragDrop(e: DragEvent): Promise { + override async onDragDrop(e: DragEvent): Promise { if (!this.isDropEnabled) return false; return importIndividualNodesInnerOnDragDrop(this, e); } @@ -279,9 +283,6 @@ export abstract class RgthreeBaseNode extends LGraphNode { /** * A virtual node. Right now, this is just a wrapper for RgthreeBaseNode (which was the initial * base virtual node). - * - * TODO: Make RgthreeBaseNode private and move all virtual nodes to this class; cleanup - * RgthreeBaseNode assumptions that its virtual. */ export class RgthreeBaseVirtualNode extends RgthreeBaseNode { override isVirtualNode = true; @@ -307,8 +308,8 @@ export class RgthreeBaseVirtualNode extends RgthreeBaseNode { * seems safer than NOT overriding. */ export class RgthreeBaseServerNode extends RgthreeBaseNode { - static nodeData: ComfyObjectInfo | null = null; - static nodeType: ComfyNodeConstructor | null = null; + static nodeType: LGraphNodeConstructor | null = null; + static nodeData: ComfyNodeDef | null = null; // Drop is enabled by default for server nodes. override isDropEnabled = true; @@ -415,8 +416,8 @@ export class RgthreeBaseServerNode extends RgthreeBaseNode { static __registeredForOverride__: boolean = false; static registerForOverride( - comfyClass: ComfyNodeConstructor, - nodeData: ComfyObjectInfo, + comfyClass: LGraphNodeConstructor, + nodeData: ComfyNodeDef, rgthreeClass: RgthreeBaseServerNodeConstructor, ) { if (OVERRIDDEN_SERVER_NODES.has(comfyClass)) { diff --git a/src_web/comfyui/base_node_collector.ts b/src_web/comfyui/base_node_collector.ts index 099b6d6..be8157d 100644 --- a/src_web/comfyui/base_node_collector.ts +++ b/src_web/comfyui/base_node_collector.ts @@ -1,4 +1,4 @@ -import type { INodeOutputSlot, LGraphNode } from "@litegraph/litegraph.js"; +import type { INodeOutputSlot, LGraphNode } from "@comfyorg/litegraph"; import { rgthree } from "./rgthree.js"; import { BaseAnyInputConnectedNode } from "./base_any_input_connected_node.js"; import { diff --git a/src_web/comfyui/base_node_mode_changer.ts b/src_web/comfyui/base_node_mode_changer.ts index fdd2673..b54cf0d 100644 --- a/src_web/comfyui/base_node_mode_changer.ts +++ b/src_web/comfyui/base_node_mode_changer.ts @@ -1,5 +1,5 @@ -import type { LGraphNode, IWidget} from "@litegraph/litegraph.js"; -import type { ISerialisedNode } from "@litegraph/types/serialisation.js"; +import type { LGraphNode, IWidget} from "@comfyorg/litegraph"; +import type { ISerialisedNode } from "@comfyorg/litegraph/dist/types/serialisation.js"; import { BaseAnyInputConnectedNode } from "./base_any_input_connected_node.js"; import { PassThroughFollowing } from "./utils.js"; @@ -35,16 +35,6 @@ export class BaseNodeModeChanger extends BaseAnyInputConnectedNode { return super.onConstructed(); } - override configure(info: ISerialisedNode): void { - // Patch a small issue (~14h) where multiple OPT_CONNECTIONS may have been created. - // https://github.com/rgthree/rgthree-comfy/issues/206 - // TODO: This can probably be removed within a few weeks. - if (info.outputs?.length) { - info.outputs.length = 1; - } - super.configure(info); - } - override handleLinkedNodesStabilization(linkedNodes: LGraphNode[]) { let changed = false; for (const [index, node] of linkedNodes.entries()) { diff --git a/src_web/comfyui/base_power_prompt.ts b/src_web/comfyui/base_power_prompt.ts index 3c28bf9..7ca264a 100644 --- a/src_web/comfyui/base_power_prompt.ts +++ b/src_web/comfyui/base_power_prompt.ts @@ -4,10 +4,10 @@ import type { INodeOutputSlot, INodeInputSlot, IWidget, -} from "@litegraph/litegraph.js"; -import type {ISerialisedNode} from "@litegraph/types/serialisation.js"; -import type {IComboWidget} from "@litegraph/types/widgets.js"; -import type {ComfyObjectInfo, ComfyGraphNode} from "typings/comfy.js"; +} from "@comfyorg/litegraph"; +import type {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation.js"; +import type {IComboWidget} from "@comfyorg/litegraph/dist/types/widgets.js"; +import type {ComfyNodeDef} from "typings/comfy.js"; import {api} from "scripts/api.js"; import {wait} from "rgthree/common/shared_utils.js"; @@ -16,16 +16,16 @@ import {rgthree} from "./rgthree.js"; /** Wraps a node instance keeping closure without mucking the finicky types. */ export class PowerPrompt { readonly isSimple: boolean; - readonly node: ComfyGraphNode; + readonly node: LGraphNode; readonly promptEl: HTMLTextAreaElement; - nodeData: ComfyObjectInfo; + nodeData: ComfyNodeDef; readonly combos: {[key: string]: IComboWidget} = {}; readonly combosValues: {[key: string]: string[]} = {}; boundOnFreshNodeDefs!: (event: CustomEvent) => void; private configuring = false; - constructor(node: ComfyGraphNode, nodeData: ComfyObjectInfo) { + constructor(node: LGraphNode, nodeData: ComfyNodeDef) { this.node = node; this.node.properties = this.node.properties || {}; @@ -186,7 +186,7 @@ export class PowerPrompt { ); } - refreshCombos(nodeData: ComfyObjectInfo) { + refreshCombos(nodeData: ComfyNodeDef) { this.nodeData = nodeData; let filter: RegExp | null = null; if ((this.node.properties["combos_filter"] as string)?.trim()) { diff --git a/src_web/comfyui/bookmark.ts b/src_web/comfyui/bookmark.ts index e771e06..e637e1c 100644 --- a/src_web/comfyui/bookmark.ts +++ b/src_web/comfyui/bookmark.ts @@ -1,6 +1,6 @@ -import type {LGraph, LGraphCanvas, LGraphNode} from "@litegraph/litegraph.js"; -import type {Point} from "@litegraph/interfaces.js"; -import type {CanvasMouseEvent} from "@litegraph/types/events.js"; +import type {LGraph, LGraphCanvas, LGraphNode} from "@comfyorg/litegraph"; +import type {Point} from "@comfyorg/litegraph/dist/interfaces.js"; +import type {CanvasMouseEvent} from "@comfyorg/litegraph/dist/types/events.js"; import {app} from "scripts/app.js"; import {RgthreeBaseVirtualNode} from "./base_node.js"; diff --git a/src_web/comfyui/bypasser.ts b/src_web/comfyui/bypasser.ts index c7fb383..1b17079 100644 --- a/src_web/comfyui/bypasser.ts +++ b/src_web/comfyui/bypasser.ts @@ -1,4 +1,4 @@ -import type {LGraphNode} from "@litegraph/litegraph.js"; +import type {LGraphNode} from "@comfyorg/litegraph"; import {app} from "scripts/app.js"; import {BaseNodeModeChanger} from "./base_node_mode_changer.js"; diff --git a/src_web/comfyui/comfy_ui_bar.ts b/src_web/comfyui/comfy_ui_bar.ts index 92d37b3..c23219a 100644 --- a/src_web/comfyui/comfy_ui_bar.ts +++ b/src_web/comfyui/comfy_ui_bar.ts @@ -1,4 +1,4 @@ -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; import { ComfyButtonGroup } from "scripts/ui/components/buttonGroup.js"; import { ComfyButton } from "scripts/ui/components/button.js"; import { iconGear, iconStarFilled, logoRgthree } from "rgthree/common/media/svgs.js"; diff --git a/src_web/comfyui/config.ts b/src_web/comfyui/config.ts index fbb62c0..33dc41f 100644 --- a/src_web/comfyui/config.ts +++ b/src_web/comfyui/config.ts @@ -1,4 +1,4 @@ -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; import { RgthreeDialog, RgthreeDialogOptions } from "rgthree/common/dialog.js"; import { createElement as $el, query as $$ } from "rgthree/common/utils_dom.js"; import { checkmark, logoRgthree } from "rgthree/common/media/svgs.js"; @@ -383,6 +383,7 @@ export class RgthreeConfigDialog extends RgthreeDialog { app.ui.settings.addSetting({ id: "rgthree.config", + defaultValue: null, name: "Open rgthree-comfy config", type: () => { // Adds a row to open the dialog from the ComfyUI settings. diff --git a/src_web/comfyui/context.ts b/src_web/comfyui/context.ts index d0a6afc..90721c0 100644 --- a/src_web/comfyui/context.ts +++ b/src_web/comfyui/context.ts @@ -5,8 +5,10 @@ import type { LGraphNode as TLGraphNode, LLink, ISlotType, -} from "@litegraph/litegraph.js"; -import type {ComfyNodeConstructor, ComfyObjectInfo} from "typings/comfy.js"; + LGraphNodeConstructor, +} from "@comfyorg/litegraph"; +import type {ConnectByTypeOptions} from "@comfyorg/litegraph/dist/LGraphNode.js"; +import type {ComfyNodeDef} from "typings/comfy.js"; import {app} from "scripts/app.js"; import { @@ -22,7 +24,6 @@ import {RgthreeBaseServerNodeConstructor} from "typings/rgthree.js"; import {debounce, wait} from "rgthree/common/shared_utils.js"; import {removeUnusedInputsFromEnd} from "./utils_inputs_outputs.js"; import {NodeTypesString} from "./constants.js"; -import {ConnectByTypeOptions} from "@litegraph/LGraphNode.js"; /** * Takes a non-context node and determins for its input or output slot, if there is a valid @@ -187,8 +188,8 @@ export class BaseContextNode extends RgthreeBaseServerNode { } static override setUp( - comfyClass: ComfyNodeConstructor, - nodeData: ComfyObjectInfo, + comfyClass: LGraphNodeConstructor, + nodeData: ComfyNodeDef, ctxClass: RgthreeBaseServerNodeConstructor, ) { RgthreeBaseServerNode.registerForOverride(comfyClass, nodeData, ctxClass); @@ -227,7 +228,7 @@ class ContextNode extends BaseContextNode { super(title); } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { BaseContextNode.setUp(comfyClass, nodeData, ContextNode); } @@ -254,7 +255,7 @@ class ContextBigNode extends BaseContextNode { super(title); } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { BaseContextNode.setUp(comfyClass, nodeData, ContextBigNode); } @@ -327,7 +328,7 @@ class ContextSwitchNode extends BaseContextMultiCtxInputNode { super(title); } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { BaseContextNode.setUp(comfyClass, nodeData, ContextSwitchNode); } @@ -354,7 +355,7 @@ class ContextSwitchBigNode extends BaseContextMultiCtxInputNode { super(title); } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { BaseContextNode.setUp(comfyClass, nodeData, ContextSwitchBigNode); } @@ -381,7 +382,7 @@ class ContextMergeNode extends BaseContextMultiCtxInputNode { super(title); } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { BaseContextNode.setUp(comfyClass, nodeData, ContextMergeNode); } @@ -408,7 +409,7 @@ class ContextMergeBigNode extends BaseContextMultiCtxInputNode { super(title); } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { BaseContextNode.setUp(comfyClass, nodeData, ContextMergeBigNode); } @@ -431,7 +432,7 @@ const contextNodes = [ ContextMergeNode, ContextMergeBigNode, ]; -const contextTypeToServerDef: {[type: string]: ComfyObjectInfo} = {}; +const contextTypeToServerDef: {[type: string]: ComfyNodeDef} = {}; function fixBadConfigs(node: ContextNode) { // Dumb mistake, but let's fix our mispelling. This will probably need to stay in perpetuity to @@ -444,7 +445,7 @@ function fixBadConfigs(node: ContextNode) { app.registerExtension({ name: "rgthree.Context", - async beforeRegisterNodeDef(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: ComfyNodeDef) { // Loop over out context nodes and see if any match the server data. for (const ctxClass of contextNodes) { if (nodeData.name === ctxClass.type) { diff --git a/src_web/comfyui/display_any.ts b/src_web/comfyui/display_any.ts index e78b7f0..9cf4667 100644 --- a/src_web/comfyui/display_any.ts +++ b/src_web/comfyui/display_any.ts @@ -1,5 +1,6 @@ -import type {LGraphNode as TLGraphNode} from "@litegraph/litegraph.js"; -import type {ComfyApp, ComfyNodeConstructor, ComfyObjectInfo} from "typings/comfy.js"; +import type {LGraphNodeConstructor, LGraphNode as TLGraphNode} from "@comfyorg/litegraph"; +import type {ComfyNodeDef} from "typings/comfy.js"; +import type {ComfyApp} from "@comfyorg/frontend"; import {app} from "scripts/app.js"; import {ComfyWidgets} from "scripts/widgets.js"; @@ -11,8 +12,8 @@ let hasShownAlertForUpdatingInt = false; app.registerExtension({ name: "rgthree.DisplayAny", async beforeRegisterNodeDef( - nodeType: ComfyNodeConstructor, - nodeData: ComfyObjectInfo, + nodeType: LGraphNodeConstructor, + nodeData: ComfyNodeDef, app: ComfyApp, ) { if (nodeData.name === "Display Any (rgthree)" || nodeData.name === "Display Int (rgthree)") { diff --git a/src_web/comfyui/dynamic_context.ts b/src_web/comfyui/dynamic_context.ts index eaf4fbe..c6ca853 100644 --- a/src_web/comfyui/dynamic_context.ts +++ b/src_web/comfyui/dynamic_context.ts @@ -6,7 +6,9 @@ import type { ISlotType, LGraphNode, LLink, -} from "@litegraph/litegraph.js"; + LGraphNodeConstructor +} from "@comfyorg/litegraph"; +import type {ComfyNodeDef} from "typings/comfy.js"; import {app} from "scripts/app.js"; import { @@ -22,7 +24,6 @@ import { } from "./services/context_service.js"; import {NodeTypesString} from "./constants.js"; import {removeUnusedInputsFromEnd} from "./utils_inputs_outputs.js"; -import {ComfyNodeConstructor, ComfyObjectInfo} from "typings/comfy.js"; import {DynamicContextNodeBase} from "./dynamic_context_base.js"; import {SERVICE as CONFIG_SERVICE} from "./services/config_service.js"; @@ -291,7 +292,7 @@ export class DynamicContextNode extends DynamicContextNodeBase { const contextDynamicNodes = [DynamicContextNode]; app.registerExtension({ name: "rgthree.DynamicContext", - async beforeRegisterNodeDef(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: ComfyNodeDef) { if (!CONFIG_SERVICE.getConfigValue("unreleased.dynamic_context.enabled")) { return; } diff --git a/src_web/comfyui/dynamic_context_base.ts b/src_web/comfyui/dynamic_context_base.ts index a763264..f919ab2 100644 --- a/src_web/comfyui/dynamic_context_base.ts +++ b/src_web/comfyui/dynamic_context_base.ts @@ -1,7 +1,8 @@ -import type {INodeInputSlot} from "@litegraph/litegraph.js"; +import type {INodeInputSlot, LGraphNodeConstructor} from "@comfyorg/litegraph"; +import type {ComfyNodeDef} from "typings/comfy.js"; +import {app} from "scripts/app.js"; import {BaseContextNode} from "./context.js"; -import {ComfyNodeConstructor, ComfyObjectInfo} from "typings/comfy.js"; import {RgthreeBaseServerNode} from "./base_node.js"; import {moveArrayItem, wait} from "rgthree/common/shared_utils.js"; import {RgthreeInvisibleWidget} from "./utils_widgets.js"; @@ -10,7 +11,6 @@ import { InputMutation, InputMutationOperation, } from "./services/context_service.js"; -import {app} from "scripts/app.js"; import {SERVICE as CONTEXT_SERVICE} from "./services/context_service.js"; const OWNED_PREFIX = "+"; @@ -221,7 +221,7 @@ export class DynamicContextNodeBase extends BaseContextNode { } } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { RgthreeBaseServerNode.registerForOverride(comfyClass, nodeData, this); // [🤮] ComfyUI only adds "required" inputs to the outputs list when dragging an output to // empty space, but since RGTHREE_CONTEXT is optional, it doesn't get added to the menu because diff --git a/src_web/comfyui/dynamic_context_switch.ts b/src_web/comfyui/dynamic_context_switch.ts index d08c019..7bae5d6 100644 --- a/src_web/comfyui/dynamic_context_switch.ts +++ b/src_web/comfyui/dynamic_context_switch.ts @@ -1,5 +1,13 @@ -import type {ComfyNodeConstructor, ComfyObjectInfo} from "typings/comfy.js"; -import type {INodeSlot, LGraphNode, LLink, LGraphCanvas, INodeInputSlot, INodeOutputSlot, ISlotType} from "@litegraph/litegraph.js"; +import type { + LGraphNode, + LLink, + LGraphCanvas, + INodeInputSlot, + INodeOutputSlot, + ISlotType, + LGraphNodeConstructor, +} from "@comfyorg/litegraph"; +import type {ComfyNodeDef} from "typings/comfy.js"; import {app} from "scripts/app.js"; import {DynamicContextNodeBase, InputLike} from "./dynamic_context_base.js"; @@ -7,7 +15,6 @@ import {NodeTypesString} from "./constants.js"; import { InputMutation, SERVICE as CONTEXT_SERVICE, - stripContextInputPrefixes, getContextOutputName, } from "./services/context_service.js"; import {getConnectedInputNodesAndFilterPassThroughs} from "./utils.js"; @@ -65,7 +72,13 @@ class DynamicContextSwitchNode extends DynamicContextNodeBase { this.scheduleHardRefresh(); } - override onConnectionsChange(type: ISlotType, slotIndex: number, isConnected: boolean, link: LLink | null | undefined, inputOrOutput: INodeInputSlot | INodeOutputSlot): void { + override onConnectionsChange( + type: ISlotType, + slotIndex: number, + isConnected: boolean, + link: LLink | null | undefined, + inputOrOutput: INodeInputSlot | INodeOutputSlot, + ): void { super.onConnectionsChange?.call(this, type, slotIndex, isConnected, link, inputOrOutput); if (this.configuring) { return; @@ -190,7 +203,7 @@ class DynamicContextSwitchNode extends DynamicContextNodeBase { app.registerExtension({ name: "rgthree.DynamicContextSwitch", - async beforeRegisterNodeDef(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: ComfyNodeDef) { if (!CONFIG_SERVICE.getConfigValue("unreleased.dynamic_context.enabled")) { return; } diff --git a/src_web/comfyui/fast_actions_button.ts b/src_web/comfyui/fast_actions_button.ts index eea4380..67ef7a5 100644 --- a/src_web/comfyui/fast_actions_button.ts +++ b/src_web/comfyui/fast_actions_button.ts @@ -1,14 +1,14 @@ -import type {LGraph, LGraphNode} from "@litegraph/litegraph.js"; -import type {IButtonWidget, IComboWidget, IWidget} from "@litegraph/types/widgets.js"; -import type {ComfyApp} from "typings/comfy.js"; -import type {RgthreeBaseNode} from "./base_node.js"; +import type {LGraph, LGraphNode} from "@comfyorg/litegraph"; +import type {IButtonWidget, IComboWidget, IWidget} from "@comfyorg/litegraph/dist/types/widgets.js"; +import type {ComfyApp} from "@comfyorg/frontend"; +import type { RgthreeBaseVirtualNode } from "./base_node.js"; import {app} from "scripts/app.js"; import {BaseAnyInputConnectedNode} from "./base_any_input_connected_node.js"; import {NodeTypesString} from "./constants.js"; import {addMenuItem} from "./utils.js"; import {rgthree} from "./rgthree.js"; -import {ISerialisedNode} from "@litegraph/types/serialisation.js"; +import {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation.js"; const MODE_ALWAYS = 0; const MODE_MUTE = 2; @@ -273,11 +273,11 @@ class FastActionsButton extends BaseAnyInputConnectedNode { node.mode = MODE_ALWAYS; } // If there's a handleAction, always call it. - if ((node as RgthreeBaseNode).handleAction) { - if (typeof action !== 'string') { - throw new Error('Fast Actions Button action should be a string: ' + action); + if ((node as RgthreeBaseVirtualNode).handleAction) { + if (typeof action !== "string") { + throw new Error("Fast Actions Button action should be a string: " + action); } - await (node as RgthreeBaseNode).handleAction(action); + await (node as RgthreeBaseVirtualNode).handleAction(action); } app.graph.change(); continue; diff --git a/src_web/comfyui/fast_groups_bypasser.ts b/src_web/comfyui/fast_groups_bypasser.ts index ca82cb3..ad530a7 100644 --- a/src_web/comfyui/fast_groups_bypasser.ts +++ b/src_web/comfyui/fast_groups_bypasser.ts @@ -1,6 +1,6 @@ -import type { Size } from "@litegraph/litegraph.js"; +import type { Size } from "@comfyorg/litegraph"; -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; import { NodeTypesString } from "./constants.js"; import { BaseFastGroupsModeChanger } from "./fast_groups_muter.js"; diff --git a/src_web/comfyui/fast_groups_muter.ts b/src_web/comfyui/fast_groups_muter.ts index ebc1662..13019e3 100644 --- a/src_web/comfyui/fast_groups_muter.ts +++ b/src_web/comfyui/fast_groups_muter.ts @@ -5,17 +5,17 @@ import type { LGraphCanvas as TLGraphCanvas, Vector2, Size, -} from "@litegraph/litegraph.js"; -import type { ISerialisedNode } from "@litegraph/types/serialisation.js"; -import type { IBooleanWidget } from "@litegraph/types/widgets"; -import type { Point } from "@litegraph/interfaces.js"; +} from "@comfyorg/litegraph"; +import type { ISerialisedNode } from "@comfyorg/litegraph/dist/types/serialisation.js"; +import type { IBooleanWidget } from "@comfyorg/litegraph/dist/types/widgets"; +import type { Point } from "@comfyorg/litegraph/dist/interfaces.js"; -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; import { RgthreeBaseVirtualNode } from "./base_node.js"; import { NodeTypesString } from "./constants.js"; import { SERVICE as FAST_GROUPS_SERVICE } from "./services/fast_groups_service.js"; import { drawNodeWidget, fitString } from "./utils_canvas.js"; -import { CanvasMouseEvent } from "@litegraph/types/events.js"; +import { CanvasMouseEvent } from "@comfyorg/litegraph/dist/types/events.js"; const PROPERTY_SORT = "sort"; const PROPERTY_SORT_CUSTOM_ALPHA = "customSortAlphabet"; @@ -82,16 +82,6 @@ export abstract class BaseFastGroupsModeChanger extends RgthreeBaseVirtualNode { return super.onConstructed(); } - override configure(info: ISerialisedNode): void { - // Patch a small issue (~14h) where multiple OPT_CONNECTIONS may have been created. - // https://github.com/rgthree/rgthree-comfy/issues/206 - // TODO: This can probably be removed within a few weeks. - if (info.outputs?.length) { - info.outputs.length = 1; - } - super.configure(info); - } - override onAdded(graph: TLGraph): void { FAST_GROUPS_SERVICE.addFastGroupNode(this); } @@ -286,7 +276,7 @@ export abstract class BaseFastGroupsModeChanger extends RgthreeBaseVirtualNode { } } }, - serializeValue(serializedNode: ISerialisedNode, widgetIndex: number) { + serializeValue(...args: any[]) { return this.value; }, mouse(event: CanvasMouseEvent, pos: Vector2, node: LGraphNode) { diff --git a/src_web/comfyui/feature_group_fast_toggle.ts b/src_web/comfyui/feature_group_fast_toggle.ts index 560a736..93f1f4e 100644 --- a/src_web/comfyui/feature_group_fast_toggle.ts +++ b/src_web/comfyui/feature_group_fast_toggle.ts @@ -3,9 +3,9 @@ import type { LGraphGroup as TLGraphGroup, LGraph as TLGraph, Vector2, -} from "@litegraph/litegraph.js"; +} from "@comfyorg/litegraph"; import type {AdjustedMouseCustomEvent} from "typings/rgthree.js"; -import type { CanvasMouseEvent } from "@litegraph/types/events.js"; +import type { CanvasMouseEvent } from "@comfyorg/litegraph/dist/types/events.js"; import {app} from "scripts/app.js"; import {rgthree} from "./rgthree.js"; diff --git a/src_web/comfyui/feature_import_individual_nodes.ts b/src_web/comfyui/feature_import_individual_nodes.ts index 658d1d7..1984bf4 100644 --- a/src_web/comfyui/feature_import_individual_nodes.ts +++ b/src_web/comfyui/feature_import_individual_nodes.ts @@ -1,7 +1,9 @@ -import { tryToGetWorkflowDataFromEvent } from "rgthree/common/utils_workflow.js"; -import { app } from "scripts/app.js"; -import type { ComfyNode, ComfyNodeConstructor, ComfyObjectInfo } from "typings/comfy.js"; -import { SERVICE as CONFIG_SERVICE } from "./services/config_service.js"; +import type {LGraphNode, LGraphNodeConstructor} from "@comfyorg/litegraph"; +import type {ComfyNodeDef} from "typings/comfy.js"; + +import {app} from "scripts/app.js"; +import {tryToGetWorkflowDataFromEvent} from "rgthree/common/utils_workflow.js"; +import {SERVICE as CONFIG_SERVICE} from "./services/config_service.js"; /** * Registers the GroupHeaderToggles which places a mute and/or bypass icons in groups headers for @@ -9,7 +11,7 @@ import { SERVICE as CONFIG_SERVICE } from "./services/config_service.js"; */ app.registerExtension({ name: "rgthree.ImportIndividualNodes", - async beforeRegisterNodeDef(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: ComfyNodeDef) { const onDragOver = nodeType.prototype.onDragOver; nodeType.prototype.onDragOver = function (e: DragEvent) { let handled = onDragOver?.apply?.(this, [...arguments] as any); @@ -30,20 +32,20 @@ app.registerExtension({ }, }); -export function importIndividualNodesInnerOnDragOver(node: ComfyNode, e: DragEvent): boolean { +export function importIndividualNodesInnerOnDragOver(node: LGraphNode, e: DragEvent): boolean { return ( (node.widgets?.length && !!CONFIG_SERVICE.getFeatureValue("import_individual_nodes.enabled")) || false ); } -export async function importIndividualNodesInnerOnDragDrop(node: ComfyNode, e: DragEvent) { +export async function importIndividualNodesInnerOnDragDrop(node: LGraphNode, e: DragEvent) { if (!node.widgets?.length || !CONFIG_SERVICE.getFeatureValue("import_individual_nodes.enabled")) { return false; } let handled = false; - const { workflow, prompt } = await tryToGetWorkflowDataFromEvent(e); + const {workflow, prompt} = await tryToGetWorkflowDataFromEvent(e); if (!handled && workflow) { const exact = (workflow.nodes || []).find((n) => n.id === node.id && n.type === node.type); if ( @@ -55,7 +57,7 @@ export async function importIndividualNodesInnerOnDragDrop(node: ComfyNode, e: D node.configure({ // Title is overridden if it's not supplied; set it to the current then. title: node.title, - widgets_values: [...(exact?.widgets_values || [])] + widgets_values: [...(exact?.widgets_values || [])], } as any); handled = true; } diff --git a/src_web/comfyui/image_comparer.ts b/src_web/comfyui/image_comparer.ts index 8f14d4e..03f53ef 100644 --- a/src_web/comfyui/image_comparer.ts +++ b/src_web/comfyui/image_comparer.ts @@ -1,27 +1,19 @@ -import { - LGraphCanvas, - LGraphNode, - Vector2, -} from "@litegraph/litegraph.js"; -import type { CanvasMouseEvent } from "@litegraph/types/events.js"; -import type { ISerialisedNode } from "@litegraph/types/serialisation.js"; -import type { ComfyNodeConstructor, ComfyObjectInfo } from "typings/comfy.js"; +import {LGraphCanvas, LGraphNode, Vector2, LGraphNodeConstructor} from "@comfyorg/litegraph"; +import type {CanvasMouseEvent} from "@comfyorg/litegraph/dist/types/events.js"; +import type {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation.js"; +import type {ComfyNodeDef} from "typings/comfy.js"; -import { app } from "scripts/app.js"; -import { api } from "scripts/api.js"; -import { RgthreeBaseServerNode } from "./base_node.js"; -import { NodeTypesString } from "./constants.js"; -import { addConnectionLayoutSupport } from "./utils.js"; -import { - RgthreeBaseHitAreas, - RgthreeBaseWidget, - RgthreeBaseWidgetBounds, -} from "./utils_widgets.js"; -import { measureText } from "./utils_canvas.js"; -import { Point, Size } from "@litegraph/interfaces.js"; +import {app} from "scripts/app.js"; +import {api} from "scripts/api.js"; +import {RgthreeBaseServerNode} from "./base_node.js"; +import {NodeTypesString} from "./constants.js"; +import {addConnectionLayoutSupport} from "./utils.js"; +import {RgthreeBaseHitAreas, RgthreeBaseWidget, RgthreeBaseWidgetBounds} from "./utils_widgets.js"; +import {measureText} from "./utils_canvas.js"; +import {Point, Size} from "@comfyorg/litegraph/dist/interfaces.js"; -type ComfyImageServerData = { filename: string; type: string; subfolder: string }; -type ComfyImageData = { name: string; selected: boolean; url: string; img?: HTMLImageElement }; +type ComfyImageServerData = {filename: string; type: string; subfolder: string}; +type ComfyImageData = {name: string; selected: boolean; url: string; img?: HTMLImageElement}; type OldExecutedPayload = { images: ComfyImageServerData[]; }; @@ -49,8 +41,8 @@ export class RgthreeImageComparer extends RgthreeBaseServerNode { // These is what the core preview image node uses to show the context menu. May not be that helpful // since it likely will always be "0" when a context menu is invoked without manually changing // something. - imageIndex: number = 0; - imgs: InstanceType[] = []; + override imageIndex: number = 0; + override imgs: InstanceType[] = []; override serialize_widgets = true; @@ -101,7 +93,7 @@ export class RgthreeImageComparer extends RgthreeBaseServerNode { url: imageDataToUrl(d), }); } - this.canvasWidget!.value = { images: imagesToChoose }; + this.canvasWidget!.value = {images: imagesToChoose}; } } @@ -112,7 +104,7 @@ export class RgthreeImageComparer extends RgthreeBaseServerNode { serialised.widgets_values![index] = ( this.widgets[index] as unknown as RgthreeImageComparerWidget ).value.images.map((d) => { - d = { ...d }; + d = {...d}; delete d.img; return d; }); @@ -225,7 +217,7 @@ export class RgthreeImageComparer extends RgthreeBaseServerNode { `; } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { RgthreeBaseServerNode.registerForOverride(comfyClass, nodeData, RgthreeImageComparer); } @@ -258,7 +250,7 @@ class RgthreeImageComparerWidget extends RgthreeBaseWidget { if (!d || typeof d === "string") { // We usually only have two here, so they're selected. - d = { url: d, name: i == 0 ? "A" : "B", selected: true }; + d = {url: d, name: i == 0 ? "A" : "B", selected: true}; } return d; }); @@ -455,21 +447,24 @@ class RgthreeImageComparerWidget extends RgthreeBaseWidget { + override serializeValue( + node: LGraphNode, + index: number, + ): RgthreeImageComparerWidgetValue | Promise { const v = []; for (const data of this._value.images) { // Remove the img since it can't serialize. - const d = { ...data }; + const d = {...data}; delete d.img; v.push(d); } - return { images: v }; + return {images: v}; } } app.registerExtension({ name: "rgthree.ImageComparer", - async beforeRegisterNodeDef(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: ComfyNodeDef) { if (nodeData.name === RgthreeImageComparer.type) { RgthreeImageComparer.setUp(nodeType, nodeData); } diff --git a/src_web/comfyui/image_inset_crop.ts b/src_web/comfyui/image_inset_crop.ts index a5a5f78..025c749 100644 --- a/src_web/comfyui/image_inset_crop.ts +++ b/src_web/comfyui/image_inset_crop.ts @@ -1,6 +1,6 @@ -import type {LGraph} from "@litegraph/litegraph.js"; -import type {ComfyApp, ComfyNodeConstructor, ComfyObjectInfo} from "typings/comfy.js"; -import type {ISerialisedNode} from "@litegraph/types/serialisation.js"; +import type {LGraph, LGraphNodeConstructor} from "@comfyorg/litegraph"; +import type {ComfyNodeDef} from "typings/comfy.js"; +import type {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation.js"; import {app} from "scripts/app.js"; import {RgthreeBaseServerNode} from "./base_node.js"; @@ -56,7 +56,7 @@ class ImageInsetCrop extends RgthreeBaseServerNode { } } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { RgthreeBaseServerNode.registerForOverride(comfyClass, nodeData, ImageInsetCrop); } } @@ -64,9 +64,8 @@ class ImageInsetCrop extends RgthreeBaseServerNode { app.registerExtension({ name: "rgthree.ImageInsetCrop", async beforeRegisterNodeDef( - nodeType: ComfyNodeConstructor, - nodeData: ComfyObjectInfo, - _app: ComfyApp, + nodeType: LGraphNodeConstructor, + nodeData: ComfyNodeDef, ) { if (nodeData.name === NodeTypesString.IMAGE_INSET_CROP) { ImageInsetCrop.setUp(nodeType, nodeData); diff --git a/src_web/comfyui/label.ts b/src_web/comfyui/label.ts index 605d3bc..9a3e413 100644 --- a/src_web/comfyui/label.ts +++ b/src_web/comfyui/label.ts @@ -1,14 +1,10 @@ -import type { - LGraphCanvas as TLGraphCanvas, - LGraphNode, - Vector2, -} from "@litegraph/litegraph.js"; -import type { CanvasMouseEvent } from "@litegraph/types/events.js"; +import type {LGraphCanvas as TLGraphCanvas, LGraphNode, Vector2} from "@comfyorg/litegraph"; +import type {CanvasMouseEvent} from "@comfyorg/litegraph/dist/types/events.js"; -import { app } from "scripts/app.js"; -import { RgthreeBaseVirtualNode } from "./base_node.js"; -import { NodeTypesString } from "./constants.js"; -import { rgthree } from "./rgthree.js"; +import {app} from "scripts/app.js"; +import {RgthreeBaseVirtualNode} from "./base_node.js"; +import {NodeTypesString} from "./constants.js"; +import {rgthree} from "./rgthree.js"; /** * A label node that allows you to put floating text anywhere on the graph. The text is the `Title` @@ -24,13 +20,13 @@ export class Label extends RgthreeBaseVirtualNode { static readonly title_mode = LiteGraph.NO_TITLE; static collapsable = false; - static "@fontSize" = { type: "number" }; - static "@fontFamily" = { type: "string" }; - static "@fontColor" = { type: "string" }; - static "@textAlign" = { type: "combo", values: ["left", "center", "right"] }; - static "@backgroundColor" = { type: "string" }; - static "@padding" = { type: "number" }; - static "@borderRadius" = { type: "number" }; + static "@fontSize" = {type: "number"}; + static "@fontFamily" = {type: "string"}; + static "@fontColor" = {type: "string"}; + static "@textAlign" = {type: "combo", values: ["left", "center", "right"]}; + static "@backgroundColor" = {type: "string"}; + static "@padding" = {type: "number"}; + static "@borderRadius" = {type: "number"}; override properties!: RgthreeBaseVirtualNode["properties"] & { fontSize: number; @@ -185,7 +181,7 @@ LGraphCanvas.prototype.drawNode = function (node: LGraphNode, ctx: CanvasRenderi * click). */ const oldGetNodeOnPos = LGraph.prototype.getNodeOnPos; -LGraph.prototype.getNodeOnPos = function(x: number, y: number, nodes_list?: LGraphNode[]) { +LGraph.prototype.getNodeOnPos = function (x: number, y: number, nodes_list?: LGraphNode[]) { if ( // processMouseDown always passes in the nodes_list nodes_list && diff --git a/src_web/comfyui/menu_auto_nest.ts b/src_web/comfyui/menu_auto_nest.ts index 0c65c3f..e410612 100644 --- a/src_web/comfyui/menu_auto_nest.ts +++ b/src_web/comfyui/menu_auto_nest.ts @@ -3,9 +3,9 @@ import type { ContextMenu, IContextMenuOptions, IContextMenuValue, -} from "@litegraph/litegraph.js"; +} from "@comfyorg/litegraph"; -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; import { rgthree } from "./rgthree.js"; import { SERVICE as CONFIG_SERVICE } from "./services/config_service.js"; diff --git a/src_web/comfyui/menu_copy_image.ts b/src_web/comfyui/menu_copy_image.ts index ec1fab8..78b6f8d 100644 --- a/src_web/comfyui/menu_copy_image.ts +++ b/src_web/comfyui/menu_copy_image.ts @@ -1,5 +1,5 @@ -import type {IContextMenuValue, LGraphCanvas} from "@litegraph/litegraph.js"; -import type {ComfyNodeConstructor, ComfyObjectInfo} from "typings/comfy.js"; +import type {IContextMenuValue, LGraphCanvas, LGraphNodeConstructor} from "@comfyorg/litegraph"; +import type {ComfyNodeDef} from "typings/comfy.js"; import {app} from "scripts/app.js"; @@ -31,7 +31,7 @@ const clipboardSupportedPromise = new Promise(async (resolve) => { */ app.registerExtension({ name: "rgthree.CopyImageToClipboard", - async beforeRegisterNodeDef(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: ComfyNodeDef) { if (nodeData.name.toLowerCase().includes("image")) { if (await clipboardSupportedPromise) { const getExtraMenuOptions = nodeType.prototype.getExtraMenuOptions; diff --git a/src_web/comfyui/menu_queue_node.ts b/src_web/comfyui/menu_queue_node.ts index ca576aa..24d9d78 100644 --- a/src_web/comfyui/menu_queue_node.ts +++ b/src_web/comfyui/menu_queue_node.ts @@ -1,5 +1,5 @@ -import type {IContextMenuValue, LGraphCanvas as TLGraphCanvas} from "@litegraph/litegraph.js"; -import type {ComfyNodeConstructor, ComfyObjectInfo} from "typings/comfy.js"; +import type {IContextMenuValue, LGraphCanvas as TLGraphCanvas, LGraphNodeConstructor} from "@comfyorg/litegraph"; +import type {ComfyNodeDef} from "typings/comfy.js"; import {app} from "scripts/app.js"; import {rgthree} from "./rgthree.js"; @@ -64,7 +64,7 @@ function showQueueGroupNodesMenuIfGroupIsSelected( */ app.registerExtension({ name: "rgthree.QueueNode", - async beforeRegisterNodeDef(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: ComfyNodeDef) { const getExtraMenuOptions = nodeType.prototype.getExtraMenuOptions; nodeType.prototype.getExtraMenuOptions = function ( canvas: TLGraphCanvas, diff --git a/src_web/comfyui/muter.ts b/src_web/comfyui/muter.ts index 8ada542..d36dab6 100644 --- a/src_web/comfyui/muter.ts +++ b/src_web/comfyui/muter.ts @@ -1,7 +1,8 @@ -import { app } from "scripts/app.js"; +import type { LGraphNode } from "@comfyorg/litegraph"; + +import {app} from "scripts/app.js"; import { BaseNodeModeChanger } from "./base_node_mode_changer.js"; import { NodeTypesString } from "./constants.js"; -import type { LGraphNode } from "@litegraph/litegraph.js"; const MODE_MUTE = 2; const MODE_ALWAYS = 0; diff --git a/src_web/comfyui/node_collector.ts b/src_web/comfyui/node_collector.ts index 03e52be..ed3aded 100644 --- a/src_web/comfyui/node_collector.ts +++ b/src_web/comfyui/node_collector.ts @@ -7,9 +7,9 @@ import type { ContextMenu, IContextMenuValue, Size, -} from "@litegraph/litegraph.js"; -import type {ISerialisedNode} from "@litegraph/types/serialisation.js"; -import type {Point} from "@litegraph/interfaces"; +} from "@comfyorg/litegraph"; +import type {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation.js"; +import type {Point} from "@comfyorg/litegraph/dist/interfaces"; import {app} from "scripts/app.js"; import {addConnectionLayoutSupport} from "./utils.js"; @@ -38,16 +38,6 @@ class CollectorNode extends BaseCollectorNode { this.addOutput("Output", "*"); return super.onConstructed(); } - - override configure(info: ISerialisedNode) { - // Patch a small issue (~14h) where multiple OPT_CONNECTIONS may have been created. - // https://github.com/rgthree/rgthree-comfy/issues/206 - // TODO: This can probably be removed within a few weeks. - if (info.outputs?.length) { - info.outputs.length = 1; - } - super.configure(info); - } } /** Legacy "Combiner" */ diff --git a/src_web/comfyui/node_mode_relay.ts b/src_web/comfyui/node_mode_relay.ts index 71b9f99..0a0bbac 100644 --- a/src_web/comfyui/node_mode_relay.ts +++ b/src_web/comfyui/node_mode_relay.ts @@ -6,9 +6,9 @@ import type { LGraphNode, LLink, Vector2, -} from "@litegraph/litegraph.js"; +} from "@comfyorg/litegraph"; -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; import { PassThroughFollowing, addConnectionLayoutSupport, @@ -20,7 +20,7 @@ import { BaseCollectorNode } from "./base_node_collector.js"; import { NodeTypesString, stripRgthree } from "./constants.js"; import { fitString } from "./utils_canvas.js"; import { rgthree } from "./rgthree.js"; -import { ISerialisedNode } from "@litegraph/types/serialisation.js"; +import { ISerialisedNode } from "@comfyorg/litegraph/dist/types/serialisation.js"; const MODE_ALWAYS = 0; const MODE_MUTE = 2; @@ -109,16 +109,6 @@ class NodeModeRelay extends BaseCollectorNode { } } - override configure(info: ISerialisedNode): void { - // Patch a small issue (~14h) where multiple OPT_CONNECTIONS may have been created. - // https://github.com/rgthree/rgthree-comfy/issues/206 - // TODO: This can probably be removed within a few weeks. - if (info.outputs?.length) { - info.outputs.length = 1; - } - super.configure(info); - } - override onDrawForeground(ctx: CanvasRenderingContext2D, canvas: LGraphCanvas): void { if (this.flags?.collapsed) { return; diff --git a/src_web/comfyui/node_mode_repeater.ts b/src_web/comfyui/node_mode_repeater.ts index 0c61755..134445e 100644 --- a/src_web/comfyui/node_mode_repeater.ts +++ b/src_web/comfyui/node_mode_repeater.ts @@ -5,9 +5,9 @@ import type { LGraphGroup, LGraphNode, LLink, -} from "@litegraph/litegraph.js"; +} from "@comfyorg/litegraph"; -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; import { BaseCollectorNode } from "./base_node_collector.js"; import { NodeTypesString, stripRgthree } from "./constants.js"; import { @@ -16,7 +16,7 @@ import { getConnectedInputNodesAndFilterPassThroughs, getConnectedOutputNodesAndFilterPassThroughs, } from "./utils.js"; -import { ISerialisedNode } from "@litegraph/types/serialisation.js"; +import { ISerialisedNode } from "@comfyorg/litegraph/dist/types/serialisation.js"; class NodeModeRepeater extends BaseCollectorNode { override readonly inputsPassThroughFollowing: PassThroughFollowing = PassThroughFollowing.ALL; @@ -42,16 +42,6 @@ class NodeModeRepeater extends BaseCollectorNode { return super.onConstructed(); } - override configure(info: ISerialisedNode): void { - // Patch a small issue (~14h) where multiple OPT_CONNECTIONS may have been created. - // https://github.com/rgthree/rgthree-comfy/issues/206 - // TODO: This can probably be removed within a few weeks. - if (info.outputs?.length) { - info.outputs.length = 1; - } - super.configure(info); - } - override onConnectOutput( outputIndex: number, inputType: string | -1, diff --git a/src_web/comfyui/power_lora_loader.ts b/src_web/comfyui/power_lora_loader.ts index 7f16349..0b1f868 100644 --- a/src_web/comfyui/power_lora_loader.ts +++ b/src_web/comfyui/power_lora_loader.ts @@ -4,12 +4,13 @@ import type { Vector2, IContextMenuValue, IFoundSlot, -} from "@litegraph/litegraph.js"; -import type {CanvasMouseEvent} from "@litegraph/types/events.js"; -import type {ISerialisedNode} from "@litegraph/types/serialisation.js"; -import type {ICustomWidget} from "@litegraph/types/widgets"; + LGraphNodeConstructor +} from "@comfyorg/litegraph"; +import type {CanvasMouseEvent} from "@comfyorg/litegraph/dist/types/events.js"; +import type {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation.js"; +import type {ICustomWidget} from "@comfyorg/litegraph/dist/types/widgets"; import type {RgthreeModelInfo} from "typings/rgthree.js"; -import type {ComfyObjectInfo, ComfyNodeConstructor} from "typings/comfy.js"; +import type {ComfyNodeDef} from "typings/comfy.js"; import {app} from "scripts/app.js"; import {RgthreeBaseServerNode} from "./base_node.js"; @@ -276,7 +277,7 @@ class RgthreePowerLoraLoader extends RgthreeBaseServerNode { /** * When `refreshComboInNode` is called from ComfyUI, then we'll kick off a fresh loras fetch. */ - refreshComboInNode(defs: any) { + override refreshComboInNode(defs: any) { rgthreeApi.getLoras(true); } @@ -320,7 +321,7 @@ class RgthreePowerLoraLoader extends RgthreeBaseServerNode { } } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { RgthreeBaseServerNode.registerForOverride(comfyClass, nodeData, NODE_CLASS); } @@ -796,7 +797,7 @@ const NODE_CLASS = RgthreePowerLoraLoader; /** Register the node. */ app.registerExtension({ name: "rgthree.PowerLoraLoader", - async beforeRegisterNodeDef(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: ComfyNodeDef) { if (nodeData.name === NODE_CLASS.type) { NODE_CLASS.setUp(nodeType, nodeData); } diff --git a/src_web/comfyui/power_prompt.ts b/src_web/comfyui/power_prompt.ts index 9a5c57f..a80c7fd 100644 --- a/src_web/comfyui/power_prompt.ts +++ b/src_web/comfyui/power_prompt.ts @@ -1,29 +1,21 @@ -import { app } from "scripts/app.js"; -import type { LGraphNode as TLGraphNode } from "@litegraph/litegraph.js"; -import type { - ComfyApp, - ComfyObjectInfo, - ComfyGraphNode, - ComfyNodeConstructor, -} from "typings/comfy.js"; -import { addConnectionLayoutSupport } from "./utils.js"; -import { PowerPrompt } from "./base_power_prompt.js"; -import { NodeTypesString } from "./constants.js"; +import type {LGraphNode, LGraphNodeConstructor} from "@comfyorg/litegraph"; +import type {ComfyNodeDef} from "typings/comfy.js"; -let nodeData: ComfyObjectInfo | null = null; +import {app} from "scripts/app.js"; +import {addConnectionLayoutSupport} from "./utils.js"; +import {PowerPrompt} from "./base_power_prompt.js"; +import {NodeTypesString} from "./constants.js"; + +let nodeData: ComfyNodeDef | null = null; app.registerExtension({ name: "rgthree.PowerPrompt", - async beforeRegisterNodeDef( - nodeType: ComfyNodeConstructor, - passedNodeData: ComfyObjectInfo, - _app: ComfyApp, - ) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, passedNodeData: ComfyNodeDef) { if (passedNodeData.name.includes("Power Prompt") && passedNodeData.name.includes("rgthree")) { nodeData = passedNodeData; const onNodeCreated = nodeType.prototype.onNodeCreated; nodeType.prototype.onNodeCreated = function () { onNodeCreated ? onNodeCreated.apply(this, []) : undefined; - (this as any).powerPrompt = new PowerPrompt(this as ComfyGraphNode, passedNodeData); + (this as any).powerPrompt = new PowerPrompt(this as LGraphNode, passedNodeData); }; addConnectionLayoutSupport(nodeType, app, [ ["Left", "Right"], @@ -31,7 +23,7 @@ app.registerExtension({ ]); } }, - async loadedGraphNode(node: TLGraphNode) { + async loadedGraphNode(node: LGraphNode) { if (node.type === NodeTypesString.POWER_PROMPT) { setTimeout(() => { // If the first output is STRING, then it's the text output from the initial launch. diff --git a/src_web/comfyui/random_unmuter.ts b/src_web/comfyui/random_unmuter.ts index 46de38e..82c3816 100644 --- a/src_web/comfyui/random_unmuter.ts +++ b/src_web/comfyui/random_unmuter.ts @@ -1,7 +1,6 @@ -import type { LGraphNode } from "@litegraph/litegraph.js"; -import type { RgthreeBaseVirtualNodeConstructor } from "typings/rgthree.js"; +import type { LGraphNode } from "@comfyorg/litegraph"; -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; import { BaseAnyInputConnectedNode } from "./base_any_input_connected_node.js"; import { NodeTypesString } from "./constants.js"; import { rgthree } from "./rgthree.js"; diff --git a/src_web/comfyui/reroute.ts b/src_web/comfyui/reroute.ts index 8cedc51..cba7b08 100644 --- a/src_web/comfyui/reroute.ts +++ b/src_web/comfyui/reroute.ts @@ -6,10 +6,10 @@ import type { INodeInputSlot, INodeOutputSlot, LGraphNode as TLGraphNode, -} from "@litegraph/litegraph.js"; -import type {LinkDirection} from "@litegraph/types/globalEnums.js"; -import type {ISerialisedNode} from "@litegraph/types/serialisation.js"; -import type {Point, Size} from "@litegraph/interfaces.js"; +} from "@comfyorg/litegraph"; +import type {LinkDirection} from "@comfyorg/litegraph/dist/types/globalEnums.js"; +import type {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation.js"; +import type {Point, Size} from "@comfyorg/litegraph/dist/interfaces.js"; import {app} from "scripts/app.js"; import { @@ -451,12 +451,6 @@ class RerouteNode extends RgthreeBaseVirtualNode { } override configure(info: ISerialisedNode): void { - // Patch a small issue (~14h) where multiple OPT_CONNECTIONS may have been created. - // https://github.com/rgthree/rgthree-comfy/issues/206 - // TODO: This can probably be removed within a few weeks. - if (info.outputs?.length) { - info.outputs.length = 1; - } if (info.inputs?.length) { info.inputs.length = 1; } diff --git a/src_web/comfyui/rgthree.ts b/src_web/comfyui/rgthree.ts index 7a21a09..f4abdab 100644 --- a/src_web/comfyui/rgthree.ts +++ b/src_web/comfyui/rgthree.ts @@ -4,11 +4,16 @@ import type { IContextMenuValue, LGraph as TLGraph, IContextMenuOptions, -} from "@litegraph/litegraph.js"; -import type {CanvasMouseEvent, CanvasPointerExtensions} from "@litegraph/types/events.js"; -import type {NodeId} from "@litegraph/LGraphNode.js"; -import type {ComfyApiFormat, ComfyApiPrompt, ComfyApp} from "typings/comfy.js"; + ISerialisedGraph, +} from "@comfyorg/litegraph"; +import type { + CanvasMouseEvent, + CanvasPointerExtensions, +} from "@comfyorg/litegraph/dist/types/events.js"; +import type {NodeId} from "@comfyorg/litegraph/dist/LGraphNode.js"; +import type {ComfyApiFormat, ComfyApiPrompt} from "typings/comfy.js"; import type {Bookmark} from "./bookmark.js"; +import type {ComfyApp} from "@comfyorg/frontend"; import {app} from "scripts/app.js"; import {api} from "scripts/api.js"; @@ -28,6 +33,7 @@ import { logoRgthree, } from "rgthree/common/media/svgs.js"; import {createElement, query, queryOne} from "rgthree/common/utils_dom.js"; +import { ISerialisedNode } from "@comfyorg/litegraph/dist/types/serialisation.js"; export enum LogLevel { IMPORTANT = 1, @@ -411,13 +417,12 @@ class Rgthree extends EventTarget { const graph = app.graph as TLGraph; onGroupAdd.apply(this, [...args] as any); // [🤮] Bad typing here.. especially the last arg; it is LGraphNode but can really be anything - // with pos or size... pity. + // with pos or size... pity. See more in our litegraph.d.ts. LGraphCanvas.onShowPropertyEditor( {} as any, null as any, null as any, null as any, - // graph._groups[graph._groups.length - 1]! as unknown as LGraphNode, ); }; @@ -638,7 +643,7 @@ class Rgthree extends EventTarget { async queueOutputNodes(nodeIds: NodeId[]) { try { this.queueNodeIds = nodeIds; - await app.queuePrompt(); + await app.queuePrompt(0); } catch (e) { const [n, v] = this.logParts( LogLevel.ERROR, @@ -680,11 +685,11 @@ class Rgthree extends EventTarget { // understand if we're serializing because we're queueing (and return the random seed to use) or // for saving the workflow (and keep -1, etc.). const queuePrompt = app.queuePrompt as Function; - app.queuePrompt = async function () { + app.queuePrompt = async function (number: number, batchCount?: number) { rgthree.processingQueue = true; rgthree.dispatchCustomEvent("queue"); try { - await queuePrompt.apply(app, [...arguments]); + return await queuePrompt.apply(app, [...arguments]); } finally { rgthree.processingQueue = false; rgthree.dispatchCustomEvent("queue-end"); @@ -744,16 +749,17 @@ class Rgthree extends EventTarget { // Hook into a data load, like from an image or JSON drop-in. This is (currently) used to // monitor for bad linking data. const loadGraphData = app.loadGraphData; - // TODO: Pull in real ComfyUI Types. - app.loadGraphData = function (graph: any) { + // NOTE: This was "serializedLGraph" in pre-litegraph types, which maps to `ISerialisedGraph` + // now; though, @comfyorg/comfyui-frontend-types have the signature as `ComfyWorkflowJSON` which + // is not exported and a zod type. Looks like there's mostly an overlap with ISerialisedGraph. + app.loadGraphData = function (graph: ISerialisedGraph) { if (rgthree.monitorLinkTimeout) { clearTimeout(rgthree.monitorLinkTimeout); rgthree.monitorLinkTimeout = null; } rgthree.clearAllMessages(); // Try to make a copy to use, because ComfyUI's loadGraphData will modify it. - // TODO: Pull in real ComfyUI Types. - let graphCopy: any | null; + let graphCopy: ISerialisedGraph | null; try { graphCopy = JSON.parse(JSON.stringify(graph)); } catch (e) { @@ -846,12 +852,10 @@ class Rgthree extends EventTarget { */ getNodeFromInitialGraphToPromptSerializedWorkflowBecauseComfyUIBrokeStuff( node: LGraphNode, - // TODO: Pull in real ComfyUI Types. - ): any | null { + ): ISerialisedNode | null { return ( this.initialGraphToPromptSerializedWorkflowBecauseComfyUIBrokeStuff?.nodes?.find( - // TODO: Pull in real ComfyUI Types. - (n: any) => n.id === node.id, + (n: ISerialisedNode) => n.id === node.id, ) ?? null ); } diff --git a/src_web/comfyui/seed.ts b/src_web/comfyui/seed.ts index c259eee..f84e98b 100644 --- a/src_web/comfyui/seed.ts +++ b/src_web/comfyui/seed.ts @@ -5,21 +5,17 @@ import type { IWidget, LGraphCanvas, IContextMenuValue, -} from "@litegraph/litegraph.js"; -import type { - ComfyObjectInfo, - ComfyNodeConstructor, - ComfyApiPrompt, -} from "typings/comfy.js"; -import type { SerializedNode } from "typings/index.js"; + LGraphNodeConstructor +} from "@comfyorg/litegraph"; +import type {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation"; +import type {ComfyNodeDef, ComfyApiPrompt} from "typings/comfy.js"; -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; import { ComfyWidgets } from "scripts/widgets.js"; import { RgthreeBaseServerNode } from "./base_node.js"; import { rgthree } from "./rgthree.js"; import { addConnectionLayoutSupport } from "./utils.js"; import { NodeTypesString } from "./constants.js"; -import { ISerialisedNode } from "@litegraph/types/serialisation.js"; const LAST_SEED_BUTTON_LABEL = "♻️ (Use Last Queued Seed)"; @@ -209,7 +205,7 @@ class RgthreeSeed extends RgthreeBaseServerNode { const workflow = e.detail.workflow; const output = e.detail.output; - let workflowNode = workflow?.nodes?.find((n: SerializedNode) => n.id === this.id) ?? null; + let workflowNode = workflow?.nodes?.find((n: ISerialisedNode) => n.id === this.id) ?? null; let outputInputs = output?.[this.id]?.inputs; if ( @@ -276,7 +272,7 @@ class RgthreeSeed extends RgthreeBaseServerNode { return seedToUse ?? inputSeed; } - static override setUp(comfyClass: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) { RgthreeBaseServerNode.registerForOverride(comfyClass, nodeData, RgthreeSeed); } @@ -293,7 +289,7 @@ class RgthreeSeed extends RgthreeBaseServerNode { app.registerExtension({ name: "rgthree.Seed", - async beforeRegisterNodeDef(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo) { + async beforeRegisterNodeDef(nodeType: LGraphNodeConstructor, nodeData: ComfyNodeDef) { if (nodeData.name === RgthreeSeed.type) { RgthreeSeed.setUp(nodeType, nodeData); } diff --git a/src_web/comfyui/services/bookmarks_services.ts b/src_web/comfyui/services/bookmarks_services.ts index 20c170b..8f55c5c 100644 --- a/src_web/comfyui/services/bookmarks_services.ts +++ b/src_web/comfyui/services/bookmarks_services.ts @@ -1,7 +1,7 @@ -import type { Bookmark } from "../bookmark.js"; +import type {Bookmark} from "../bookmark.js"; -import { app } from "scripts/app.js"; -import { NodeTypesString } from "../constants.js"; +import {app} from "scripts/app.js"; +import {NodeTypesString} from "../constants.js"; class BookmarksService { /** diff --git a/src_web/comfyui/services/context_service.ts b/src_web/comfyui/services/context_service.ts index bb31dea..c0a8227 100644 --- a/src_web/comfyui/services/context_service.ts +++ b/src_web/comfyui/services/context_service.ts @@ -1,9 +1,8 @@ import type {DynamicContextNodeBase} from "../dynamic_context_base.js"; -import {app} from "scripts/app.js"; import {NodeTypesString} from "../constants.js"; import {getConnectedOutputNodesAndFilterPassThroughs} from "../utils.js"; -import {INodeInputSlot, INodeOutputSlot, INodeSlot, LGraphNode} from "@litegraph/litegraph.js"; +import {INodeInputSlot, INodeOutputSlot, INodeSlot, LGraphNode} from "@comfyorg/litegraph"; export let SERVICE: ContextService; diff --git a/src_web/comfyui/services/fast_groups_service.ts b/src_web/comfyui/services/fast_groups_service.ts index fe92f00..03ff6e0 100644 --- a/src_web/comfyui/services/fast_groups_service.ts +++ b/src_web/comfyui/services/fast_groups_service.ts @@ -1,12 +1,12 @@ -import type { BaseFastGroupsModeChanger } from "../fast_groups_muter.js"; +import type {BaseFastGroupsModeChanger} from "../fast_groups_muter.js"; import type { LGraph as TLGraph, LGraphCanvas as TLGraphCanvas, LGraphGroup, Vector4, -} from "@litegraph/litegraph.js"; +} from "@comfyorg/litegraph"; -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; /** * A service that keeps global state that can be shared by multiple FastGroupsMuter or @@ -28,7 +28,7 @@ class FastGroupsService { private runScheduleTimeout: number | null = null; private runScheduleAnimation: number | null = null; - private cachedNodeBoundings: { [key: number]: Vector4 } | null = null; + private cachedNodeBoundings: {[key: number]: Vector4} | null = null; constructor() { // Don't need to do anything, wait until a signal. diff --git a/src_web/comfyui/testing/comfyui_env.ts b/src_web/comfyui/testing/comfyui_env.ts index f89afa2..9a9e666 100644 --- a/src_web/comfyui/testing/comfyui_env.ts +++ b/src_web/comfyui/testing/comfyui_env.ts @@ -1,7 +1,8 @@ -import { app } from "scripts/app.js"; -import { NodeTypesString } from "../constants.js"; -import { wait } from "rgthree/common/shared_utils.js"; -import type { LGraphNode } from "@litegraph/litegraph.js"; +import type {LGraphNode} from "@comfyorg/litegraph"; + +import {app} from "scripts/app.js"; +import {wait} from "rgthree/common/shared_utils.js"; +import {NodeTypesString} from "../constants.js"; type addNodeOptions = { placement?: string; @@ -62,7 +63,7 @@ export class ComfyUITestEnvironment { } async queuePrompt() { - await app.queuePrompt(); + await app.queuePrompt(0); await wait(150); } } diff --git a/src_web/comfyui/tests/context_dynamic_tests.ts b/src_web/comfyui/tests/context_dynamic_tests.ts index e317a1b..b5d212f 100644 --- a/src_web/comfyui/tests/context_dynamic_tests.ts +++ b/src_web/comfyui/tests/context_dynamic_tests.ts @@ -2,7 +2,7 @@ import type { LiteGraph as TLiteGraph, LGraphNode as TLGraphNode, LGraphNode, -} from "@litegraph/litegraph.js"; +} from "@comfyorg/litegraph"; import {NodeTypesString} from "../constants.js"; import {wait} from "rgthree/common/shared_utils.js"; diff --git a/src_web/comfyui/utils.ts b/src_web/comfyui/utils.ts index a64366b..b77280a 100644 --- a/src_web/comfyui/utils.ts +++ b/src_web/comfyui/utils.ts @@ -1,4 +1,3 @@ -import type { ComfyApp, ComfyNodeConstructor, ComfyObjectInfo } from "typings/comfy.js"; import type { Vector2, LGraphCanvas, @@ -12,16 +11,19 @@ import type { INodeOutputSlot, IContextMenuValue, ISlotType, -} from "@litegraph/litegraph.js"; -import type { Constructor } from "typings/index.js"; + LGraphNodeConstructor, +} from "@comfyorg/litegraph"; +import type {ComfyApp} from "@comfyorg/frontend"; +import type {ComfyNodeDef} from "typings/comfy.js"; +import type {Constructor} from "typings/rgthree"; -import { app } from "scripts/app.js"; -import { api } from "scripts/api.js"; -import { Resolver, getResolver, wait } from "rgthree/common/shared_utils.js"; -import { RgthreeHelpDialog } from "rgthree/common/dialog.js"; -import { NodeProperty } from "@litegraph/LGraphNode"; -import { LinkDirection } from "@litegraph/types/globalEnums"; -import { Point } from "@litegraph/interfaces"; +import {app} from "scripts/app.js"; +import {api} from "scripts/api.js"; +import {Resolver, getResolver, wait} from "rgthree/common/shared_utils.js"; +import {RgthreeHelpDialog} from "rgthree/common/dialog.js"; +import {NodeProperty} from "@comfyorg/litegraph/dist/LGraphNode"; +import {LinkDirection} from "@comfyorg/litegraph/dist/types/globalEnums"; +import {Point} from "@comfyorg/litegraph/dist/interfaces"; /** * Override the api.getNodeDefs call to add a hook for refreshing node defs. @@ -31,7 +33,7 @@ import { Point } from "@litegraph/interfaces"; const oldApiGetNodeDefs = api.getNodeDefs; api.getNodeDefs = async function () { const defs = await oldApiGetNodeDefs.call(api); - this.dispatchEvent(new CustomEvent("fresh-node-defs", { detail: defs })); + this.dispatchEvent(new CustomEvent("fresh-node-defs", {detail: defs})); return defs; }; @@ -47,13 +49,13 @@ type LiteGraphDir = | typeof LiteGraph.RIGHT | typeof LiteGraph.UP | typeof LiteGraph.DOWN; -export const LAYOUT_LABEL_TO_DATA: { [label: string]: [LiteGraphDir, Vector2, Vector2] } = { +export const LAYOUT_LABEL_TO_DATA: {[label: string]: [LiteGraphDir, Vector2, Vector2]} = { Left: [LiteGraph.LEFT, [0, 0.5], [PADDING, 0]], Right: [LiteGraph.RIGHT, [1, 0.5], [-PADDING, 0]], Top: [LiteGraph.UP, [0.5, 0], [0, PADDING]], Bottom: [LiteGraph.DOWN, [0.5, 1], [0, -PADDING]], }; -export const LAYOUT_LABEL_OPPOSITES: { [label: string]: string } = { +export const LAYOUT_LABEL_OPPOSITES: {[label: string]: string} = { Left: "Right", Right: "Left", Top: "Bottom", @@ -70,7 +72,7 @@ interface MenuConfig { } export function addMenuItem( - node: Constructor, + node: LGraphNodeConstructor, _app: ComfyApp, config: MenuConfig, after = "Shape", @@ -167,7 +169,7 @@ export function addMenuItemOnExtraMenuOptions( ) => { if (!!subMenuOptions?.length) { new LiteGraph.ContextMenu( - subMenuOptions.map((option) => (option ? { content: option } : null)), + subMenuOptions.map((option) => (option ? {content: option} : null)), { event, parentMenu, @@ -181,8 +183,8 @@ export function addMenuItemOnExtraMenuOptions( if (config.property) { node.properties = node.properties || {}; node.properties[config.property] = config.prepareValue - ? config.prepareValue(subValue!.content || '', node) - : subValue!.content || ''; + ? config.prepareValue(subValue!.content || "", node) + : subValue!.content || ""; } config.callback && config.callback(node, subValue?.content); }, @@ -202,7 +204,7 @@ export function addMenuItemOnExtraMenuOptions( } export function addConnectionLayoutSupport( - node: Constructor, + node: LGraphNodeConstructor, app: ComfyApp, options = [ ["Left", "Right"], @@ -236,14 +238,14 @@ export function addConnectionLayoutSupport( // Purposefully do not need to call the old one. return getConnectionPosForLayout(this, isInput, slotNumber, out); }; - node.prototype.getInputPos = function(slotNumber: number) : Vector2 { + node.prototype.getInputPos = function (slotNumber: number): Vector2 { // Purposefully do not need to call the existing one because we're overriding. - return getConnectionPosForLayout(this, true, slotNumber, [0,0]); - } - node.prototype.getOutputPos = function(slotNumber: number) : Vector2 { + return getConnectionPosForLayout(this, true, slotNumber, [0, 0]); + }; + node.prototype.getOutputPos = function (slotNumber: number): Vector2 { // Purposefully do not need to call the existing one because we're overriding. - return getConnectionPosForLayout(this, false, slotNumber, [0,0]); - } + return getConnectionPosForLayout(this, false, slotNumber, [0, 0]); + }; } export function setConnectionsLayout(node: LGraphNode, newLayout: [string, string]) { @@ -403,7 +405,11 @@ function toggleConnectionLabel(cxn: any, hide = true) { return cxn; } -export function addHelpMenuItem(node: LGraphNode, content: string, menuOptions: (IContextMenuValue | null)[]) { +export function addHelpMenuItem( + node: LGraphNode, + content: string, + menuOptions: (IContextMenuValue | null)[], +) { addMenuItemOnExtraMenuOptions( node, { @@ -447,7 +453,6 @@ export function shouldPassThrough( ); } - function filterOutPassthroughNodes( infos: ConnectedNodeInfo[], passThroughFollowing = PassThroughFollowing.ALL, @@ -477,10 +482,12 @@ export function getConnectedInputInfosAndFilterPassThroughs( startNode: LGraphNode, currentNode?: LGraphNode, slot?: number, - passThroughFollowing = PassThroughFollowing.ALL) { - return filterOutPassthroughNodes( - getConnectedNodesInfo(startNode, IoDirection.INPUT, currentNode, slot, passThroughFollowing), - passThroughFollowing); + passThroughFollowing = PassThroughFollowing.ALL, +) { + return filterOutPassthroughNodes( + getConnectedNodesInfo(startNode, IoDirection.INPUT, currentNode, slot, passThroughFollowing), + passThroughFollowing, + ); } export function getConnectedInputNodesAndFilterPassThroughs( startNode: LGraphNode, @@ -488,7 +495,12 @@ export function getConnectedInputNodesAndFilterPassThroughs( slot?: number, passThroughFollowing = PassThroughFollowing.ALL, ): LGraphNode[] { - return getConnectedInputInfosAndFilterPassThroughs(startNode, currentNode, slot, passThroughFollowing).map(n => n.node); + return getConnectedInputInfosAndFilterPassThroughs( + startNode, + currentNode, + slot, + passThroughFollowing, + ).map((n) => n.node); } export function getConnectedOutputNodes( @@ -515,7 +527,7 @@ export function getConnectedOutputNodesAndFilterPassThroughs( return filterOutPassthroughNodes( getConnectedNodesInfo(startNode, IoDirection.OUTPUT, currentNode, slot, passThroughFollowing), passThroughFollowing, - ).map(n => n.node); + ).map((n) => n.node); } export type ConnectedNodeInfo = { @@ -578,7 +590,7 @@ export function getConnectedNodesInfo( ); } else { // Add the node and, if it's a pass through, let's collect all its nodes as well. - rootNodes.push({ node: originNode, travelFromSlot, travelToSlot, originTravelFromSlot }); + rootNodes.push({node: originNode, travelFromSlot, travelToSlot, originTravelFromSlot}); if (shouldPassThrough(originNode, passThroughFollowing)) { for (const foundNode of getConnectedNodesInfo( startNode, @@ -648,7 +660,7 @@ function getTypeFromSlot( let graph = app.graph as LGraph; let type = slot?.type; if (!skipSelf && type != null && type != "*") { - return { type: type as string, label: slot?.label, name: slot?.name }; + return {type: type as string, label: slot?.label, name: slot?.name}; } const links = getSlotLinks(slot); for (const link of links) { @@ -687,7 +699,7 @@ export async function replaceNode( newNode.title = existingNode.title; } newNode.pos = [...existingNode.pos] as Point; - newNode.properties = { ...existingNode.properties }; + newNode.properties = {...existingNode.properties}; const oldComputeSize = [...existingNode.computeSize()]; // oldSize to use. If we match the smallest size (computeSize) then don't record and we'll use // the smalles side after conversion. @@ -723,7 +735,7 @@ export async function replaceNode( const link: LLink = (app.graph as LGraph).links[linkId]!; if (!link) continue; const targetNode = app.graph.getNodeById(link.target_id)!; - links.push({ node: newNode, slot: output.name, targetNode, targetSlot: link.target_slot }); + links.push({node: newNode, slot: output.name, targetNode, targetSlot: link.target_slot}); } } for (const [index, input] of existingNode.inputs.entries()) { @@ -782,7 +794,7 @@ export function applyMixins(original: Constructor, constructors: any * Obviously, for an input, this will be a max of one. */ export function getSlotLinks(inputOrOutput?: INodeInputSlot | INodeOutputSlot | null) { - const links: { id: number; link: LLink }[] = []; + const links: {id: number; link: LLink}[] = []; if (!inputOrOutput) { return links; } @@ -791,7 +803,7 @@ export function getSlotLinks(inputOrOutput?: INodeInputSlot | INodeOutputSlot | for (const linkId of output.links || []) { const link: LLink = (app.graph as LGraph).links[linkId]!; if (link) { - links.push({ id: linkId, link: link }); + links.push({id: linkId, link: link}); } } } @@ -799,7 +811,7 @@ export function getSlotLinks(inputOrOutput?: INodeInputSlot | INodeOutputSlot | const input = inputOrOutput as INodeInputSlot; const link: LLink = (app.graph as LGraph).links[input.link!]!; if (link) { - links.push({ id: input.link!, link: link }); + links.push({id: input.link!, link: link}); } } return links; @@ -812,7 +824,7 @@ export function getSlotLinks(inputOrOutput?: INodeInputSlot | INodeOutputSlot | export async function matchLocalSlotsToServer( node: LGraphNode, direction: IoDirection, - serverNodeData: ComfyObjectInfo, + serverNodeData: ComfyNodeDef, ) { const serverSlotNames = direction == IoDirection.INPUT @@ -828,7 +840,7 @@ export async function matchLocalSlotsToServer( let firstIndex = slots.findIndex((o, i) => i !== serverSlotNames.indexOf(o.name)); if (firstIndex > -1) { // Have mismatches. First, let's go through and save all our links by name. - const links: { [key: string]: { id: number; link: LLink }[] } = {}; + const links: {[key: string]: {id: number; link: LLink}[]} = {}; slots.map((slot) => { // There's a chance we have duplicate names on an upgrade, so we'll collect all links to one // name so we don't ovewrite our list per name. @@ -879,10 +891,7 @@ export async function matchLocalSlotsToServer( const nextNode = app.graph.getNodeById(linkData.link.target_id); // (Check nextNode, as sometimes graphs seem to have very stale data and that node id // doesn't exist). - if ( - nextNode && - (nextNode.constructor as any)?.type!.includes("Reroute") - ) { + if (nextNode && (nextNode.constructor as any)?.type!.includes("Reroute")) { (nextNode as any).stabilize && (nextNode as any).stabilize(); } } @@ -947,9 +956,8 @@ export function getOutputNodes(nodes: LGraphNode[]) { return ( nodes?.filter((n) => { return ( - n.mode != LiteGraph.NEVER && - ((n.constructor as any).nodeData as ComfyObjectInfo)?.output_node + n.mode != LiteGraph.NEVER && ((n.constructor as any).nodeData as ComfyNodeDef)?.output_node ); }) || [] ); -} \ No newline at end of file +} diff --git a/src_web/comfyui/utils_canvas.ts b/src_web/comfyui/utils_canvas.ts index d787646..7010e26 100644 --- a/src_web/comfyui/utils_canvas.ts +++ b/src_web/comfyui/utils_canvas.ts @@ -1,6 +1,6 @@ -import type { LGraphCanvas as TLGraphCanvas, Vector2 } from "@litegraph/litegraph.js"; +import type {LGraphCanvas as TLGraphCanvas, Vector2} from "@comfyorg/litegraph"; -import { app } from "scripts/app.js"; +import {app} from "scripts/app.js"; function binarySearch(max: number, getValue: (n: number) => number, match: number) { let min = 0; @@ -113,7 +113,7 @@ export function drawRoundedRectangle( options: WidgetRenderingOptions, ) { const lowQuality = isLowQuality(); - options = { ...options }; + options = {...options}; ctx.strokeStyle = options.colorStroke || LiteGraph.WIDGET_OUTLINE_COLOR; ctx.fillStyle = options.colorBackground || LiteGraph.WIDGET_BGCOLOR; ctx.beginPath(); @@ -159,7 +159,7 @@ export function drawNumberWidgetPart( ctx.save(); let posX = options.posX; - const { posY, height, value, textColor } = options; + const {posY, height, value, textColor} = options; const midY = posY + height / 2; // If we're drawing parts from right to left (usually when something in the middle will be @@ -231,7 +231,7 @@ export function drawTogglePart( const lowQuality = isLowQuality(); ctx.save(); - const { posX, posY, height, value } = options; + const {posX, posY, height, value} = options; const toggleRadius = height * 0.36; // This is the standard toggle height calc. const toggleBgWidth = height * 1.5; // We don't draw a separate bg, but this would be it. @@ -252,8 +252,8 @@ export function drawTogglePart( lowQuality || value === false ? posX + height * 0.5 : value === true - ? posX + height - : posX + height * 0.75; + ? posX + height + : posX + height * 0.75; ctx.beginPath(); ctx.arc(toggleX, posY + height * 0.5, toggleRadius, 0, Math.PI * 2); ctx.fill(); diff --git a/src_web/comfyui/utils_inputs_outputs.ts b/src_web/comfyui/utils_inputs_outputs.ts index d69d791..63f6d93 100644 --- a/src_web/comfyui/utils_inputs_outputs.ts +++ b/src_web/comfyui/utils_inputs_outputs.ts @@ -1,4 +1,4 @@ -import type { LGraphNode } from "@litegraph/litegraph.js"; +import type { LGraphNode } from "@comfyorg/litegraph"; /** Removes all inputs from the end. */ export function removeUnusedInputsFromEnd(node: LGraphNode, minNumber = 1, nameMatch?: RegExp) { diff --git a/src_web/comfyui/utils_menu.ts b/src_web/comfyui/utils_menu.ts index 73f38a0..dc47d47 100644 --- a/src_web/comfyui/utils_menu.ts +++ b/src_web/comfyui/utils_menu.ts @@ -5,10 +5,10 @@ import type { ContextMenuEventListener, ContextMenu, IContextMenuItem, -} from "@litegraph/litegraph.js"; +} from "@comfyorg/litegraph"; -import { app } from "scripts/app.js"; -import { rgthreeApi } from "rgthree/common/rgthree_api.js"; +import {app} from "scripts/app.js"; +import {rgthreeApi} from "rgthree/common/rgthree_api.js"; const PASS_THROUGH = function (item: T) { return item as T; @@ -29,7 +29,7 @@ export async function showLoraChooser( } new LiteGraph.ContextMenu(loras, { event: event, - parentMenu: parentMenu != null ? parentMenu : undefined, + parentMenu: parentMenu != null ? parentMenu : undefined, title: "Choose a lora", scale: Math.max(1, canvas.ds?.scale ?? 1), className: "dark", diff --git a/src_web/comfyui/utils_widgets.ts b/src_web/comfyui/utils_widgets.ts index 61c0b9b..ad63d27 100644 --- a/src_web/comfyui/utils_widgets.ts +++ b/src_web/comfyui/utils_widgets.ts @@ -3,9 +3,9 @@ import type { LGraphCanvas as TLGraphCanvas, Vector2, Vector4, -} from "@litegraph/litegraph.js"; -import type {CanvasMouseEvent} from "@litegraph/types/events.js"; -import type {IBaseWidget, IWidgetOptions} from "@litegraph/types/widgets.js"; +} from "@comfyorg/litegraph"; +import type {CanvasMouseEvent} from "@comfyorg/litegraph/dist/types/events.js"; +import type {IBaseWidget, IWidgetOptions} from "@comfyorg/litegraph/dist/types/widgets.js"; import {app} from "scripts/app.js"; import {drawNodeWidget, drawRoundedRectangle, fitString, isLowQuality} from "./utils_canvas.js"; diff --git a/src_web/common/dialog.ts b/src_web/common/dialog.ts index 59ccb40..d421eb3 100644 --- a/src_web/common/dialog.ts +++ b/src_web/common/dialog.ts @@ -1,4 +1,4 @@ -import type { LGraphNode, LGraphNodeConstructor } from "@litegraph/litegraph.js"; +import type { LGraphNode, LGraphNodeConstructor } from "@comfyorg/litegraph"; import { createElement as $el, getClosestOrSelf, setAttributes } from "./utils_dom.js"; type RgthreeDialogButton = { diff --git a/src_web/common/link_fixer.ts b/src_web/common/link_fixer.ts index 7b3b0aa..da4de1f 100644 --- a/src_web/common/link_fixer.ts +++ b/src_web/common/link_fixer.ts @@ -1,26 +1,30 @@ -import type { BadLinksData, SerializedGraph, SerializedLink, SerializedNode } from "typings/index.js"; -import type { LGraph, LGraphNode, LLink} from "@litegraph/litegraph.js"; -import type { NodeId } from "@litegraph/LGraphNode"; +import type {LGraph, LGraphNode, LLink} from "@comfyorg/litegraph"; +import type {NodeId} from "@comfyorg/litegraph/dist/LGraphNode"; +import type {ISerialisedNode, ISerialisedGraph} from "@comfyorg/litegraph/dist/types/serialisation"; +import type {SerialisedLLinkArray} from "@comfyorg/litegraph/dist/LLink"; -// TODO: Fix comyui types. -type serializedLGraph = any; -type serializedLGraphNode = any; +export interface BadLinksData { + hasBadLinks: boolean; + fixed: boolean; + graph: T; + patched: number; + deleted: number; +} enum IoDirection { INPUT, OUTPUT, } - -function getNodeById(graph: SerializedGraph | LGraph | serializedLGraph, id: NodeId) { +function getNodeById(graph: ISerialisedGraph | LGraph, id: NodeId) { if ((graph as LGraph).getNodeById) { return (graph as LGraph).getNodeById(id); } - graph = graph as SerializedGraph; - return graph.nodes.find((node: serializedLGraphNode) => Number(node.id) === id)!; + graph = graph as ISerialisedGraph; + return graph.nodes.find((node: ISerialisedNode) => Number(node.id) === id)!; } -function extendLink(link: SerializedLink) { +function extendLink(link: SerialisedLLinkArray) { return { link: link, id: link[0], @@ -33,7 +37,7 @@ function extendLink(link: SerializedLink) { } /** - * Takes a SerializedGraph or live LGraph and inspects the links and nodes to ensure the linking + * Takes a ISerialisedGraph or live LGraph and inspects the links and nodes to ensure the linking * makes logical sense. Can apply fixes when passed the `fix` argument as true. * * Note that fixes are a best-effort attempt. Seems to get it correct in most cases, but there is a @@ -42,24 +46,24 @@ function extendLink(link: SerializedLink) { * result. */ export function fixBadLinks( - graph: SerializedGraph | LGraph, + graph: ISerialisedGraph | LGraph, fix = false, silent = false, - logger: { log: (...args: any[]) => void } = console, + logger: {log: (...args: any[]) => void} = console, ): BadLinksData { const patchedNodeSlots: { [nodeId: string]: { - inputs?: { [slot: number]: number | null }; + inputs?: {[slot: number]: number | null}; outputs?: { [slots: number]: { links: number[]; - changes: { [linkId: number]: "ADD" | "REMOVE" }; + changes: {[linkId: number]: "ADD" | "REMOVE"}; }; }; }; } = {}; // const logger = this.newLogSession("[findBadLinks]"); - const data: { patchedNodes: Array; deletedLinks: number[] } = { + const data: {patchedNodes: Array; deletedLinks: number[]} = { patchedNodes: [], deletedLinks: [], }; @@ -68,7 +72,7 @@ export function fixBadLinks( * Internal patch node. We keep track of changes in patchedNodeSlots in case we're in a dry run. */ async function patchNodeSlot( - node: SerializedNode | LGraphNode, + node: ISerialisedNode | LGraphNode, ioDir: IoDirection, slot: number, linkId: number, @@ -142,7 +146,7 @@ export function fixBadLinks( * Internal to check if a node (or patched data) has a linkId. */ function nodeHasLinkId( - node: SerializedNode | LGraphNode, + node: ISerialisedNode | LGraphNode, ioDir: IoDirection, slot: number, linkId: number, @@ -180,7 +184,7 @@ export function fixBadLinks( /** * Internal to check if a node (or patched data) has a linkId. */ - function nodeHasAnyLink(node: SerializedNode | LGraphNode, ioDir: IoDirection, slot: number) { + function nodeHasAnyLink(node: ISerialisedNode | LGraphNode, ioDir: IoDirection, slot: number) { // Patched data should be canonical. We can double check if fixing too. let hasAny = false; if (ioDir === IoDirection.INPUT) { @@ -211,9 +215,9 @@ export function fixBadLinks( return hasAny; } - let links: Array = []; + let links: Array = []; if (!Array.isArray(graph.links)) { - Object.values(graph.links).reduce((acc, v) => { + links = Object.values(graph.links).reduce((acc, v) => { acc[v.id] = v; return acc; }, links); @@ -225,7 +229,8 @@ export function fixBadLinks( linksReverse.reverse(); for (let l of linksReverse) { if (!l) continue; - const link = (l as LLink).origin_slot != null ? (l as LLink) : extendLink(l as SerializedLink); + const link = + (l as LLink).origin_slot != null ? (l as LLink) : extendLink(l as SerialisedLLinkArray); const originNode = getNodeById(graph, link.origin_id); const originHasLink = () => @@ -290,9 +295,9 @@ export function fixBadLinks( } else if (!targetHasLink()) { !silent && logger.log( - `${link.id} is funky... ${targetLog} is NOT correct (is ${targetNode.inputs?.[ - link.target_slot - ]?.link}), but ${originLog} contains it`, + `${link.id} is funky... ${targetLog} is NOT correct (is ${ + targetNode.inputs?.[link.target_slot]?.link + }), but ${originLog} contains it`, ); if (!targetHasAnyLink()) { !silent && logger.log(` > [PATCH] ${targetLog} is not defined, will set to ${link.id}.`); @@ -318,7 +323,8 @@ export function fixBadLinks( // Now that we've cleaned up the inputs, outputs, run through it looking for dangling links., for (let l of linksReverse) { if (!l) continue; - const link = (l as LLink).origin_slot != null ? (l as LLink) : extendLink(l as SerializedLink); + const link = + (l as LLink).origin_slot != null ? (l as LLink) : extendLink(l as SerialisedLLinkArray); const originNode = getNodeById(graph, link.origin_id); const targetNode = getNodeById(graph, link.target_id); // Now that we've manipulated the linking, check again if they both exist. @@ -347,7 +353,7 @@ export function fixBadLinks( if ((graph as LGraph).getNodeById) { delete graph.links[data.deletedLinks[i]!]; } else { - graph = graph as SerializedGraph; + graph = graph as ISerialisedGraph; // Sometimes we got objects for links if passed after ComfyUI's loadGraphData modifies the // data. We make a copy now, but can handle the bastardized objects just in case. const idx = graph.links.findIndex( @@ -362,7 +368,7 @@ export function fixBadLinks( } // If we're a serialized graph, we can filter out the links because it's just an array. if (!(graph as LGraph).getNodeById) { - graph.links = (graph as SerializedGraph).links.filter((l) => !!l); + graph.links = (graph as ISerialisedGraph).links.filter((l) => !!l); } } if (!data.patchedNodes.length && !data.deletedLinks.length) { diff --git a/src_web/common/prompt_service.ts b/src_web/common/prompt_service.ts index e2870a6..6e7b038 100644 --- a/src_web/common/prompt_service.ts +++ b/src_web/common/prompt_service.ts @@ -10,7 +10,7 @@ import type { ComfyApiPrompt, } from "typings/comfy.js"; import { api } from "scripts/api.js"; -import type { LGraph as TLGraph, LGraphCanvas as TLGraphCanvas } from "@litegraph/litegraph.js"; +import type { LGraph as TLGraph, LGraphCanvas as TLGraphCanvas } from "@comfyorg/litegraph"; import { Resolver, getResolver } from "./shared_utils.js"; /** diff --git a/src_web/common/utils_workflow.ts b/src_web/common/utils_workflow.ts index 5156948..dfdd8fb 100644 --- a/src_web/common/utils_workflow.ts +++ b/src_web/common/utils_workflow.ts @@ -1,7 +1,8 @@ +import type { ISerialisedGraph } from "@comfyorg/litegraph/dist/types/serialisation"; +import type { ComfyApiFormat } from "typings/comfy.js"; + import { getResolver } from "./shared_utils.js"; import { getPngMetadata, getWebpMetadata } from "./comfyui_shim.js"; -import type { SerializedGraph } from "typings/index.js"; -import type { ComfyApiFormat } from "typings/comfy.js"; /** * Parses the workflow JSON and do any necessary cleanup. @@ -17,7 +18,7 @@ function parseWorkflowJson(stringJson?: string) { export async function tryToGetWorkflowDataFromEvent( e: DragEvent, -): Promise<{ workflow: SerializedGraph | null; prompt: ComfyApiFormat | null }> { +): Promise<{ workflow: ISerialisedGraph | null; prompt: ComfyApiFormat | null }> { let work; for (const file of e.dataTransfer?.files || []) { const data = await tryToGetWorkflowDataFromFile(file); @@ -38,7 +39,7 @@ export async function tryToGetWorkflowDataFromEvent( export async function tryToGetWorkflowDataFromFile( file: File | Blob, -): Promise<{ workflow: SerializedGraph | null; prompt: ComfyApiFormat | null }> { +): Promise<{ workflow: ISerialisedGraph | null; prompt: ComfyApiFormat | null }> { if (file.type === "image/png") { const pngInfo = await getPngMetadata(file); return { diff --git a/src_web/link_fixer/link_page.ts b/src_web/link_fixer/link_page.ts index 4e43fa2..0fe3b3d 100644 --- a/src_web/link_fixer/link_page.ts +++ b/src_web/link_fixer/link_page.ts @@ -1,4 +1,6 @@ -import type { SerializedGraph, BadLinksData } from "typings/index.js"; +import type { ISerialisedGraph } from "@comfyorg/litegraph/dist/types/serialisation"; +import type { BadLinksData } from "../common/link_fixer.js"; + import { fixBadLinks } from "../common/link_fixer.js"; import { getPngMetadata } from "../common/comfyui_shim.js"; @@ -34,7 +36,7 @@ export class LinkPage { private outputImageEl: HTMLImageElement; private file?: File | Blob; - private graph?: SerializedGraph; + private graph?: ISerialisedGraph; private graphResults?: BadLinksData; private graphFinalResults?: BadLinksData; @@ -196,7 +198,7 @@ export class LinkPage { } } - private async loadGraphData(graphData: SerializedGraph) { + private async loadGraphData(graphData: ISerialisedGraph) { this.graphResults = await fixBadLinks(graphData); this.updateUi(); } diff --git a/src_web/scripts_comfy/app.ts b/src_web/scripts_comfy/app.ts index 8ef5f52..9bec3ee 100644 --- a/src_web/scripts_comfy/app.ts +++ b/src_web/scripts_comfy/app.ts @@ -1,7 +1,7 @@ -import { ComfyApp } from "../typings/comfy.js"; - -/** - * A dummy ComfyApp that we can import from our code, which we'll rewrite later to the comfyui - * hosted app.js - */ -export declare const app: ComfyApp; +import {ComfyApp} from "@comfyorg/frontend"; + +/** + * A dummy ComfyApp that we can import from our code, which we'll rewrite later to the comfyui + * hosted app.js + */ +export declare const app: ComfyApp; diff --git a/src_web/scripts_comfy/ui/components/button.ts b/src_web/scripts_comfy/ui/components/button.ts index 865eeba..44e3d49 100644 --- a/src_web/scripts_comfy/ui/components/button.ts +++ b/src_web/scripts_comfy/ui/components/button.ts @@ -1,4 +1,4 @@ -import type { ComfyApp } from "typings/comfy.js"; +import {ComfyApp} from "@comfyorg/frontend"; type ComfyButtonProps = { icon?: string; @@ -9,9 +9,9 @@ type ComfyButtonProps = { enabled?: boolean; action?: (e: Event, btn: ComfyButton) => void; classList?: string; - visibilitySetting?: { id: string, showValue: any }; + visibilitySetting?: {id: string; showValue: any}; app?: ComfyApp; -} +}; export declare class ComfyButton { element: HTMLElement; @@ -19,5 +19,5 @@ export declare class ComfyButton { contentElement: HTMLElement; constructor(props: ComfyButtonProps); updateIcon(): void; - withPopup(popup: any, mode: "click"|"hover"): this; -}; + withPopup(popup: any, mode: "click" | "hover"): this; +} diff --git a/src_web/scripts_comfy/widgets.ts b/src_web/scripts_comfy/widgets.ts index 3ef835b..7607289 100644 --- a/src_web/scripts_comfy/widgets.ts +++ b/src_web/scripts_comfy/widgets.ts @@ -1,12 +1,12 @@ -import type { LGraphNode } from "@litegraph/litegraph.js"; -import type { ComfyApp, ComfyWidget } from "../typings/comfy.js"; +import type {ComfyApp} from "@comfyorg/frontend"; +import type {IWidget, LGraphNode} from "@comfyorg/litegraph"; type ComfyWidgetFn = ( node: LGraphNode, inputName: string, inputData: any, app: ComfyApp, -) => { widget: ComfyWidget }; +) => {widget: IWidget}; /** * A dummy ComfyWidgets that we can import from our code, which we'll rewrite later to the comfyui diff --git a/src_web/typings/README.md b/src_web/typings/README.md deleted file mode 100644 index 3e4c19b..0000000 --- a/src_web/typings/README.md +++ /dev/null @@ -1,3 +0,0 @@ -The typings in node_modules or in ComfyUI's web/ directory were not that well covered. These typings are hacked together with some of the inconsistencies I found. - -To be honest, I have no idea why I needed a bizarre workaround for litegraph's types. Usually the '/// <reference>' comment should have picked up the types, but it wasn't having it. ¯\_(ツ)_/¯ \ No newline at end of file diff --git a/src_web/typings/comfy.d.ts b/src_web/typings/comfy.d.ts index f1e398f..f6f2e1b 100644 --- a/src_web/typings/comfy.d.ts +++ b/src_web/typings/comfy.d.ts @@ -1,6 +1,9 @@ -import type { LGraphGroup as TLGraphGroup, LGraphNode as TLGraphNode, IWidget, SerializedLGraphNode, LGraph as TLGraph, LGraphCanvas as TLGraphCanvas, LiteGraph as TLiteGraph, INodeSlot } from "@litegraph/litegraph.js"; -import type {Constructor, SerializedGraph} from './index.js'; - +/** + * These contain types from ComfyUI (or LiteGraph) that are either copied or manually determined + * added here mostly because @comfyorg/comfyui-frontend-types hasn't exported them oir they weren't + * available. + */ +import type {SerializedGraph} from './index.js'; export type getPngMetadata = (file: File | Blob) => { workflow?: string; prompt?: string }; export type getWebpMetadata = (file: File | Blob) => { @@ -10,128 +13,63 @@ export type getWebpMetadata = (file: File | Blob) => { prompt?: string; }; +// Below are types derived from the Serialized version of a workflow. -// @rgthree: Types on ComfyApp as needed. -export interface ComfyApp { - extensions: ComfyExtension[]; - async queuePrompt(number?: number, batchCount = 1): Promise; - graph: TLGraph; - canvas: TLGraphCanvas; - clean() : void; - registerExtension(extension: ComfyExtension): void; - getPreviewFormatParam(): string; - getRandParam(): string; - loadApiJson(apiData: {}, fileName: string): void; - async graphToPrompt(graph?: TLGraph, clean?: boolean): Promise; - // workflow: ComfyWorkflowInstance ??? - async loadGraphData(graphData: {}, clean?: boolean, restore_view?: boolean, workflow?: any|null): Promise - ui: { - settings: { - addSetting(config: {id: string, name: string, type: () => HTMLElement}) : void; - } - } - // Just marking as any for now. - menu?: any; -} +// export type SerializedLink = [ +// number, // this.id, +// number, // this.origin_id, +// number, // this.origin_slot, +// number, // this.target_id, +// number, // this.target_slot, +// string, // this.type +// ]; -export interface ComfyWidget extends IWidget { - // https://github.com/comfyanonymous/ComfyUI/issues/2193 Changes from SerializedLGraphNode to - // LGraphNode... - serializeValue(nodeType: TLGraphNode, index: number): Promise; - afterQueued(): void; - inputEl?: HTMLTextAreaElement; - width: number; -} +// interface SerializedNodeInput { +// name: string; +// type: string; +// link: number; +// } +// interface SerializedNodeOutput extends SerializedNodeInput { +// slot_index: number; +// links: number[]; +// } -export interface ComfyGraphNode extends TLGraphNode { - // getExtraMenuOptions: (node: TLGraphNode, options: ContextMenuItem[]) => void; - onExecuted(message: any): void; -} +// export interface SerializedNode { +// // id: number; +// // inputs: SerializedNodeInput[]; +// // outputs: SerializedNodeOutput[]; +// mode: number; +// order: number; +// pos: [number, number]; +// properties: any; +// size: [number, number]; +// type: string; +// widgets_values: Array; +// } -export interface ComfyNode extends TLGraphNode { - comfyClass: string; -} - -// @rgthree -export interface ComfyNodeConstructor extends Constructor { - static title: string; - static type?: string; - static comfyClass: string; -} - -// export type NodeMode = 0|1|2|3|4|undefined; +// export interface SerializedGraph { + // config: any; + // extra: any; + // groups: any; + // last_link_id: number; + // last_node_id: number; + // links: SerializedLink[]; + // nodes: SerializedNode[]; +// } -export interface ComfyExtension { - /** - * The name of the extension - */ - name: string; - /** - * Allows any initialisation, e.g. loading resources. Called after the canvas is created but before nodes are added - * @param app The ComfyUI app instance - */ - init?(app: ComfyApp): Promise; - /** - * Allows any additonal setup, called after the application is fully set up and running - * @param app The ComfyUI app instance - */ - setup?(app: ComfyApp): Promise; - /** - * Called before nodes are registered with the graph - * @param defs The collection of node definitions, add custom ones or edit existing ones - * @param app The ComfyUI app instance - */ - addCustomNodeDefs?(defs: Record, app: ComfyApp): Promise; - /** - * Allows the extension to add custom widgets - * @param app The ComfyUI app instance - * @returns An array of {[widget name]: widget data} - */ - getCustomWidgets?( - app: ComfyApp - ): Promise< - Record { widget?: IWidget; minWidth?: number; minHeight?: number }> - >; - /** - * Allows the extension to add additional handling to the node before it is registered with LGraph - * @rgthree changed nodeType from `typeof LGraphNode` to `ComfyNodeConstructor` - * @param nodeType The node class (not an instance) - * @param nodeData The original node object info config object - * @param app The ComfyUI app instance - */ - beforeRegisterNodeDef?(nodeType: ComfyNodeConstructor, nodeData: ComfyObjectInfo, app: ComfyApp): Promise; - /** - * Allows the extension to register additional nodes with LGraph after standard nodes are added - * @param app The ComfyUI app instance - */ - // @rgthree - add void for non async - registerCustomNodes?(app: ComfyApp): void|Promise; - /** - * Allows the extension to modify a node that has been reloaded onto the graph. - * If you break something in the backend and want to patch workflows in the frontend - * This is the place to do this - * @param node The node that has been loaded - * @param app The ComfyUI app instance - */ - loadedGraphNode?(node: TLGraphNode, app: ComfyApp); - /** - * Allows the extension to run code after the constructor of the node - * @param node The node that has been created - * @param app The ComfyUI app instance - */ - nodeCreated?(node: TLGraphNode, app: ComfyApp); -} - -export type ComfyObjectInfo = { +/** + * ComfyUI-Frontend defines a ComfyNodeDef from Zod, but doesn't expose it. This is a shim. + */ +export type ComfyNodeDef = { name: string; display_name?: string; description?: string; category: string; input?: { - required?: Record; - optional?: Record; - hidden?: Record; + required?: Record; + optional?: Record; + hidden?: Record; }; output?: string[]; output_name: string[]; @@ -139,7 +77,9 @@ export type ComfyObjectInfo = { output_node?: boolean; }; -export type ComfyObjectInfoConfig = [string | any[]] | [string | any[], any]; + + +// Below are types derived from the formats for the ComfyAPI. // @rgthree type ComfyApiInputLink = [ @@ -149,8 +89,8 @@ type ComfyApiInputLink = [ number, ] -// @rgthree -export type ComfyApiFormatNode = { + +type ComfyApiFormatNode = { "inputs": { [input_name: string]: string|number|boolean|ComfyApiInputLink, }, @@ -160,33 +100,27 @@ export type ComfyApiFormatNode = { } } -// @rgthree export type ComfyApiFormat = { [node_id: string]: ComfyApiFormatNode } -// @rgthree export type ComfyApiPrompt = { workflow: SerializedGraph, output: ComfyApiFormat, } -// @rgthree export type ComfyApiEventDetailStatus = { exec_info: { queue_remaining: number; }; }; -// @rgthree export type ComfyApiEventDetailExecutionStart = { prompt_id: string; }; -// @rgthree export type ComfyApiEventDetailExecuting = null | string; -// @rgthree export type ComfyApiEventDetailProgress = { node: string; prompt_id: string; @@ -194,27 +128,17 @@ export type ComfyApiEventDetailProgress = { value: number; }; -// @rgthree export type ComfyApiEventDetailExecuted = { node: string; prompt_id: string; output: any; }; -// @rgthree export type ComfyApiEventDetailCached = { nodes: string[]; prompt_id: string; }; -// @rgthree -export type ComfyApiEventDetailExecuted = { - prompt_id: string; - node: string; - output: any; -}; - -// @rgthree export type ComfyApiEventDetailError = { prompt_id: string; exception_type: string; diff --git a/src_web/typings/index.d.ts b/src_web/typings/index.d.ts index a574726..96e1732 100644 --- a/src_web/typings/index.d.ts +++ b/src_web/typings/index.d.ts @@ -1,55 +1,30 @@ -import { LGraph } from "./litegraph.js"; +/** + * Declare any global properties and import our other typings here. + */ +import "@comfyorg/frontend"; +import "./litegraph"; +import "./rgthree"; +import "./comfy"; -export type Constructor = new(...args: any[]) => T; +import type { + LGraphGroup as TLGraphGroup, + LGraphNode as TLGraphNode, + LGraph as TLGraph, + LGraphCanvas as TLGraphCanvas, + LiteGraph as TLiteGraph, +} from "@comfyorg/litegraph"; -export type SerializedLink = [ - number, // this.id, - number, // this.origin_id, - number, // this.origin_slot, - number, // this.target_id, - number, // this.target_slot, - string, // this.type -]; - -export interface SerializedNodeInput { - name: string; - type: string; - link: number; -} -export interface SerializedNodeOutput { - name: string; - type: string; - link: number; - slot_index: number; - links: number[]; -} -export interface SerializedNode { - id: number; - inputs: SerializedNodeInput[]; - outputs: SerializedNodeOutput[]; - mode: number; - order: number; - pos: [number, number]; - properties: any; - size: [number, number]; - type: string; - widgets_values: Array; -} - -export interface SerializedGraph { - config: any; - extra: any; - groups: any; - last_link_id: number; - last_node_id: number; - links: SerializedLink[]; - nodes: SerializedNode[]; -} - -export interface BadLinksData { - hasBadLinks: boolean; - fixed: boolean; - graph: T; - patched: number; - deleted: number; +declare global { + const LiteGraph: typeof TLiteGraph; + const LGraph: typeof TLGraph; + const LGraphNode: typeof TLGraphNode; + const LGraphCanvas: typeof TLGraphCanvas; + const LGraphGroup: typeof TLGraphGroup; + interface Window { + // Used in the common/comfyui_shim to determine if we're in the app or not. + comfyAPI: { + // So much more stuffed in here, add as needed. + [key: string]: any; + }; + } } diff --git a/src_web/typings/litegraph.d.ts b/src_web/typings/litegraph.d.ts index 43b21ac..eabced1 100644 --- a/src_web/typings/litegraph.d.ts +++ b/src_web/typings/litegraph.d.ts @@ -1,87 +1,75 @@ -/** - * This used to clean up the old LiteGraph types but now that we're importing the actual types - * from https://github.com/Comfy-Org/litegraph.js we just use this to declare the globally available - * code when inside ComfyUI; as well as any augmentations we do want/need that aren't in the actual - * LiteGraph types, for whatever reason. - * - * Notes: - * - Augmentations marked @rgthree are added specifically for rgthree-comfy. - * - Augmentations marked @ComfyUI_frontend are from ComfyUI_frontend and yet to be imported. - * https://github.com/Comfy-Org/ComfyUI_frontend/blob/main/src/types/litegraph-augmentation.d.ts - */ -import type { - LGraphGroup as TLGraphGroup, - LGraphNode as TLGraphNode, - LGraph as TLGraph, - LGraphCanvas as TLGraphCanvas, - LiteGraph as TLiteGraph, -} from "@litegraph/litegraph.js"; - -declare global { - const LiteGraph: typeof TLiteGraph; - const LGraph: typeof TLGraph; - const LGraphNode: typeof TLGraphNode; - const LGraphCanvas: typeof TLGraphCanvas; - const LGraphGroup: typeof TLGraphGroup; - interface Window { - // Used in the common/comfyui_shim to determine if we're in the app or not. - comfyAPI: { - // So much more stuffed in here, add as needed. - [key: string]: any; - }; - } -} - -declare module "@litegraph/litegraph.js" { - interface INodeSlot { - // @rgthree - hidden?: boolean; - - // @rgthree - Used to "disable" an input/output. Used in PowerPrompt to disallow connecting - // an output if there's no optional corresponding input (since, that would just break). - disabled?: boolean; - - // @rgthree - A status we put on some nodes so we can draw things around it. - rgthree_status?: "WARN" | "ERROR"; - } - - interface LGraphNode { - // @ComfyUI_frontend - onExecuted?(output: any): void; - } - - interface LGraphCanvas { - // @rgthree - Adding this for ComfyUI, since they add this in their own overload in app.js - selected_group_moving?: boolean; - - // @rgthree - Allows LGraphGroup to be centered (it could just be `{size: Point, pos: Point}`). - centerOnNode(node: LGraphNode | LGraphGroup); - } -} - -declare module "@litegraph/types/widgets" { - interface IBaseWidget { - // @ComfyUI_frontend - Kinda, made this a method instead of a member. - serializeValue?(node: LGraphNode, index: number): Promise | unknown; - - // @ComfyUI_frontend - inputEl?: HTMLInputElement; - - // @rgthree - A status we put on some nodes so we can draw things around it. - rgthree_lastValue?: any; - } -} - -declare module "@litegraph/interfaces" { - // @ComfyUI_frontend - interface IFoundSlot { - widget?: IBaseWidget; - } -} - -declare module "@litegraph/LiteGraphGlobal" { - interface LiteGraphGlobal { - // @rgthree - Fix: Window is actually optional in the code. - closeAllContextMenus(ref_window?: Window): void; - } -} +/** + * This used to augment the LiteGraph types, either to fix them for how they actually behave + * (e.g. marking args that are typed as required as optional because they actually are, etc.) or + * adding properties/methods that rgthree-comfy adds/uses. Mostly the latter are prefixed 'rgthree_' + * but not always. + */ +import "@comfyorg/litegraph"; + +declare module "@comfyorg/litegraph" { + interface INodeSlot { + // @rgthree: Hides a slot for rgthree-comfy draw methods. + hidden?: boolean; + + // @rgthree: Used to "disable" an input/output. Used in PowerPrompt to disallow connecting + // an output if there's no optional corresponding input (since, that would just break). + disabled?: boolean; + + // @rgthree: A status we put on some nodes so we can draw things around it. + rgthree_status?: "WARN" | "ERROR"; + } + + interface LGraphCanvas { + // @rgthree (Fix): At one point this was in ComfyUI's app.js. I don't see it now... perhaps it's + // been removed? We were using it in rgthree-comfy. + selected_group_moving?: boolean; + + // @rgthree (Fix): Allows LGraphGroup to be passed (it could be `{size: Point, pos: Point}`). + centerOnNode(node: LGraphNode | LGraphGroup); + + // @rgthree (Fix): Makes item's fields optiona, and other params nullable, as well as adds + // LGraphGroup to the node, since the implementation accomodates all of these as typed below. + // NOTE: [🤮] We can't actually augment this because it's static.. but keeping here because + // this is how it's actually implemented. + // static onShowPropertyEditor( + // item: { + // property?: keyof LGraphNode | undefined; + // type?: string; + // }, + // options: IContextMenuOptions | null, + // e: MouseEvent | null, + // menu: ContextMenu | null, + // node: LGraphNode | LGraphGroup, + // ): void; + } + + interface LGraphNodeConstructor { + // @rgthree (Fix): Fixes ComfyUI-Frontend which marks this as required, even through even though + // elsewhere it defines it as optional (like for the actual for LGraphNode). + comfyClass?: string; + } +} + +declare module "@comfyorg/litegraph/dist/types/widgets" { + interface IBaseWidget { + // @rgthree (Fix): Where is this in Comfy types? + inputEl?: HTMLInputElement; + + // @rgthree: A status we put on some nodes so we can draw things around it. + rgthree_lastValue?: any; + } +} + +declare module "@comfyorg/litegraph/dist/interfaces" { + // @rgthree (Fix): widget is (or was?) available when inputs were moved from a widget. + interface IFoundSlot { + widget?: IBaseWidget; + } +} + +declare module "@comfyorg/litegraph/dist/LiteGraphGlobal" { + interface LiteGraphGlobal { + // @rgthree (Fix): Window is actually optional in the code. + closeAllContextMenus(ref_window?: Window): void; + } +} diff --git a/src_web/typings/rgthree.d.ts b/src_web/typings/rgthree.d.ts index e812237..4731590 100644 --- a/src_web/typings/rgthree.d.ts +++ b/src_web/typings/rgthree.d.ts @@ -1,28 +1,17 @@ -import type { LGraphNode, Vector2 } from "@litegraph/litegraph.js"; -import type { CanvasMouseEvent } from "@litegraph/types/events.js"; -import type {Constructor} from "./index.js"; +/** + * Typings specific to rgthree-comfy. + */ +import type { LGraphNode, Vector2 } from "@comfyorg/litegraph"; +import type { CanvasMouseEvent } from "@comfyorg/litegraph/dist/types/events.js"; import type {RgthreeBaseVirtualNode} from '../comfyui/base_node.js' export type AdjustedMouseCustomEvent = CustomEvent<{ originalEvent: CanvasMouseEvent }>; - -export interface RgthreeBaseNodeConstructor extends Constructor { - static type: string; - static category: string; - static comfyClass: string; - static exposedActions: string[]; -} - -export interface RgthreeBaseVirtualNodeConstructor extends Constructor { - static type: string; - static category: string; - static _category: string; -} - +export type Constructor = new(...args: any[]) => T; export interface RgthreeBaseServerNodeConstructor extends Constructor { - static nodeType: ComfyNodeConstructor; - static nodeData: ComfyObjectInfo; + static nodeType: LGraphNodeConstructor; + static nodeData: ComfyNodeDef; static __registeredForOverride__: boolean; onRegisteredForOverride(comfyClass: any, rgthreeClass: any) : void; } diff --git a/tsconfig.json b/tsconfig.json index 9b39ae4..370ccf3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,13 @@ // ], "baseUrl": "./", "paths": { - "@litegraph/*": ["node_modules/@comfyorg/litegraph/dist/*"], + // `@comfyorg/litegraph` is how ComfyUi-Frontend augments litegraph.d.ts, so we should match. + "@comfyorg/litegraph": ["node_modules/@comfyorg/litegraph/dist/litegraph.d.ts"], + // ComfyUi-Frontend also augments one other module with the dist/ so we must keep it. + "@comfyorg/litegraph/dist/*": ["node_modules/@comfyorg/litegraph/dist/*"], + // Theser are just vanity. Currently nothing else augments it but, if a dependency were to we + // may need to change these. + "@comfyorg/frontend": ["node_modules/@comfyorg/comfyui-frontend-types/index.d.ts"], "typings/*": ["src_web/typings/*"], "rgthree/common/*": ["src_web/common/*"], "node_modules": ["node_modules/*"], diff --git a/web/comfyui/base_node.js b/web/comfyui/base_node.js index 9fe5f2e..3d77c0d 100644 --- a/web/comfyui/base_node.js +++ b/web/comfyui/base_node.js @@ -1,12 +1,11 @@ import { ComfyWidgets } from "../../scripts/widgets.js"; import { SERVICE as KEY_EVENT_SERVICE } from "./services/key_events_services.js"; -import { app } from "../../scripts/app.js"; import { LogLevel, rgthree } from "./rgthree.js"; import { addHelpMenuItem } from "./utils.js"; import { RgthreeHelpDialog } from "../../rgthree/common/dialog.js"; import { importIndividualNodesInnerOnDragDrop, importIndividualNodesInnerOnDragOver, } from "./feature_import_individual_nodes.js"; import { defineProperty } from "../../rgthree/common/shared_utils.js"; -export class RgthreeBaseNode extends LGraphNode { +class RgthreeBaseNode extends LGraphNode { constructor(title = RgthreeBaseNode.title, skipOnConstructedCall = true) { super(title); this.comfyClass = "__NEED_COMFY_CLASS__"; @@ -27,6 +26,9 @@ export class RgthreeBaseNode extends LGraphNode { if (this.comfyClass == "__NEED_COMFY_CLASS__") { throw new Error("RgthreeBaseNode needs a comfy class override."); } + if (this.constructor.type == "__NEED_CLASS_TYPE__") { + throw new Error("RgthreeBaseNode needs overrides."); + } this.checkAndRunOnConstructed(); }); defineProperty(this, "mode", { @@ -169,6 +171,7 @@ export class RgthreeBaseNode extends LGraphNode { } RgthreeBaseNode.exposedActions = []; RgthreeBaseNode.title = "__NEED_CLASS_TITLE__"; +RgthreeBaseNode.type = "__NEED_CLASS_TYPE__"; RgthreeBaseNode.category = "rgthree"; RgthreeBaseNode._category = "rgthree"; export class RgthreeBaseVirtualNode extends RgthreeBaseNode { @@ -278,8 +281,8 @@ export class RgthreeBaseServerNode extends RgthreeBaseNode { static onRegisteredForOverride(comfyClass, rgthreeClass) { } } -RgthreeBaseServerNode.nodeData = null; RgthreeBaseServerNode.nodeType = null; +RgthreeBaseServerNode.nodeData = null; RgthreeBaseServerNode.__registeredForOverride__ = false; const OVERRIDDEN_SERVER_NODES = new Map(); const oldregisterNodeType = LiteGraph.registerNodeType; diff --git a/web/comfyui/base_node_mode_changer.js b/web/comfyui/base_node_mode_changer.js index 4431fbb..ba7f907 100644 --- a/web/comfyui/base_node_mode_changer.js +++ b/web/comfyui/base_node_mode_changer.js @@ -19,13 +19,6 @@ export class BaseNodeModeChanger extends BaseAnyInputConnectedNode { this.addOutput("OPT_CONNECTION", "*"); return super.onConstructed(); } - configure(info) { - var _a; - if ((_a = info.outputs) === null || _a === void 0 ? void 0 : _a.length) { - info.outputs.length = 1; - } - super.configure(info); - } handleLinkedNodesStabilization(linkedNodes) { let changed = false; for (const [index, node] of linkedNodes.entries()) { diff --git a/web/comfyui/config.js b/web/comfyui/config.js index 19da3a6..9636e9f 100644 --- a/web/comfyui/config.js +++ b/web/comfyui/config.js @@ -346,6 +346,7 @@ export class RgthreeConfigDialog extends RgthreeDialog { } app.ui.settings.addSetting({ id: "rgthree.config", + defaultValue: null, name: "Open rgthree-comfy config", type: () => { return $el("tr.rgthree-comfyui-settings-row", { diff --git a/web/comfyui/dynamic_context_base.js b/web/comfyui/dynamic_context_base.js index 864aca9..a827567 100644 --- a/web/comfyui/dynamic_context_base.js +++ b/web/comfyui/dynamic_context_base.js @@ -1,9 +1,9 @@ +import { app } from "../../scripts/app.js"; import { BaseContextNode } from "./context.js"; import { RgthreeBaseServerNode } from "./base_node.js"; import { moveArrayItem, wait } from "../../rgthree/common/shared_utils.js"; import { RgthreeInvisibleWidget } from "./utils_widgets.js"; import { getContextOutputName, InputMutationOperation, } from "./services/context_service.js"; -import { app } from "../../scripts/app.js"; import { SERVICE as CONTEXT_SERVICE } from "./services/context_service.js"; const OWNED_PREFIX = "+"; const REGEX_OWNED_PREFIX = /^\+\s*/; diff --git a/web/comfyui/fast_actions_button.js b/web/comfyui/fast_actions_button.js index dc8e697..0cdf9ba 100644 --- a/web/comfyui/fast_actions_button.js +++ b/web/comfyui/fast_actions_button.js @@ -201,8 +201,8 @@ class FastActionsButton extends BaseAnyInputConnectedNode { node.mode = MODE_ALWAYS; } if (node.handleAction) { - if (typeof action !== 'string') { - throw new Error('Fast Actions Button action should be a string: ' + action); + if (typeof action !== "string") { + throw new Error("Fast Actions Button action should be a string: " + action); } await node.handleAction(action); } diff --git a/web/comfyui/fast_groups_muter.js b/web/comfyui/fast_groups_muter.js index aa2bc05..3577518 100644 --- a/web/comfyui/fast_groups_muter.js +++ b/web/comfyui/fast_groups_muter.js @@ -29,13 +29,6 @@ export class BaseFastGroupsModeChanger extends RgthreeBaseVirtualNode { this.addOutput("OPT_CONNECTION", "*"); return super.onConstructed(); } - configure(info) { - var _a; - if ((_a = info.outputs) === null || _a === void 0 ? void 0 : _a.length) { - info.outputs.length = 1; - } - super.configure(info); - } onAdded(graph) { FAST_GROUPS_SERVICE.addFastGroupNode(this); } @@ -191,7 +184,7 @@ export class BaseFastGroupsModeChanger extends RgthreeBaseVirtualNode { } } }, - serializeValue(serializedNode, widgetIndex) { + serializeValue(...args) { return this.value; }, mouse(event, pos, node) { diff --git a/web/comfyui/feature_import_individual_nodes.js b/web/comfyui/feature_import_individual_nodes.js index 1471475..e0ceba7 100644 --- a/web/comfyui/feature_import_individual_nodes.js +++ b/web/comfyui/feature_import_individual_nodes.js @@ -1,5 +1,5 @@ -import { tryToGetWorkflowDataFromEvent } from "../../rgthree/common/utils_workflow.js"; import { app } from "../../scripts/app.js"; +import { tryToGetWorkflowDataFromEvent } from "../../rgthree/common/utils_workflow.js"; import { SERVICE as CONFIG_SERVICE } from "./services/config_service.js"; app.registerExtension({ name: "rgthree.ImportIndividualNodes", @@ -42,7 +42,7 @@ export async function importIndividualNodesInnerOnDragDrop(node, e) { confirm("Found a node match from embedded workflow (same id & type) in this workflow. Would you like to set the widget values?")) { node.configure({ title: node.title, - widgets_values: [...((exact === null || exact === void 0 ? void 0 : exact.widgets_values) || [])] + widgets_values: [...((exact === null || exact === void 0 ? void 0 : exact.widgets_values) || [])], }); handled = true; } diff --git a/web/comfyui/image_comparer.js b/web/comfyui/image_comparer.js index 7123b26..eab33d5 100644 --- a/web/comfyui/image_comparer.js +++ b/web/comfyui/image_comparer.js @@ -3,7 +3,7 @@ import { api } from "../../scripts/api.js"; import { RgthreeBaseServerNode } from "./base_node.js"; import { NodeTypesString } from "./constants.js"; import { addConnectionLayoutSupport } from "./utils.js"; -import { RgthreeBaseWidget, } from "./utils_widgets.js"; +import { RgthreeBaseWidget } from "./utils_widgets.js"; import { measureText } from "./utils_canvas.js"; function imageDataToUrl(data) { return api.apiURL(`/view?filename=${encodeURIComponent(data.filename)}&type=${data.type}&subfolder=${data.subfolder}${app.getPreviewFormatParam()}${app.getRandParam()}`); diff --git a/web/comfyui/image_inset_crop.js b/web/comfyui/image_inset_crop.js index 17217d0..186e5c1 100644 --- a/web/comfyui/image_inset_crop.js +++ b/web/comfyui/image_inset_crop.js @@ -51,7 +51,7 @@ ImageInsetCrop.exposedActions = ["Reset Crop"]; ImageInsetCrop.maxResolution = 8192; app.registerExtension({ name: "rgthree.ImageInsetCrop", - async beforeRegisterNodeDef(nodeType, nodeData, _app) { + async beforeRegisterNodeDef(nodeType, nodeData) { if (nodeData.name === NodeTypesString.IMAGE_INSET_CROP) { ImageInsetCrop.setUp(nodeType, nodeData); } diff --git a/web/comfyui/node_collector.js b/web/comfyui/node_collector.js index 61e7cdb..a1f276d 100644 --- a/web/comfyui/node_collector.js +++ b/web/comfyui/node_collector.js @@ -14,13 +14,6 @@ class CollectorNode extends BaseCollectorNode { this.addOutput("Output", "*"); return super.onConstructed(); } - configure(info) { - var _a; - if ((_a = info.outputs) === null || _a === void 0 ? void 0 : _a.length) { - info.outputs.length = 1; - } - super.configure(info); - } } CollectorNode.type = NodeTypesString.NODE_COLLECTOR; CollectorNode.title = NodeTypesString.NODE_COLLECTOR; diff --git a/web/comfyui/node_mode_relay.js b/web/comfyui/node_mode_relay.js index e541b95..566d314 100644 --- a/web/comfyui/node_mode_relay.js +++ b/web/comfyui/node_mode_relay.js @@ -58,13 +58,6 @@ class NodeModeRelay extends BaseCollectorNode { this.dispatchModeToRepeater(to); } } - configure(info) { - var _a; - if ((_a = info.outputs) === null || _a === void 0 ? void 0 : _a.length) { - info.outputs.length = 1; - } - super.configure(info); - } onDrawForeground(ctx, canvas) { var _a; if ((_a = this.flags) === null || _a === void 0 ? void 0 : _a.collapsed) { diff --git a/web/comfyui/node_mode_repeater.js b/web/comfyui/node_mode_repeater.js index 22953d1..7dbea5c 100644 --- a/web/comfyui/node_mode_repeater.js +++ b/web/comfyui/node_mode_repeater.js @@ -18,13 +18,6 @@ class NodeModeRepeater extends BaseCollectorNode { }); return super.onConstructed(); } - configure(info) { - var _a; - if ((_a = info.outputs) === null || _a === void 0 ? void 0 : _a.length) { - info.outputs.length = 1; - } - super.configure(info); - } onConnectOutput(outputIndex, inputType, inputSlot, inputNode, inputIndex) { let canConnect = !this.hasRelayInput; canConnect = diff --git a/web/comfyui/power_prompt.js b/web/comfyui/power_prompt.js index c73cdfc..195cbaf 100644 --- a/web/comfyui/power_prompt.js +++ b/web/comfyui/power_prompt.js @@ -5,7 +5,7 @@ import { NodeTypesString } from "./constants.js"; let nodeData = null; app.registerExtension({ name: "rgthree.PowerPrompt", - async beforeRegisterNodeDef(nodeType, passedNodeData, _app) { + async beforeRegisterNodeDef(nodeType, passedNodeData) { if (passedNodeData.name.includes("Power Prompt") && passedNodeData.name.includes("rgthree")) { nodeData = passedNodeData; const onNodeCreated = nodeType.prototype.onNodeCreated; diff --git a/web/comfyui/reroute.js b/web/comfyui/reroute.js index 422fb46..2ba87ad 100644 --- a/web/comfyui/reroute.js +++ b/web/comfyui/reroute.js @@ -281,16 +281,13 @@ class RerouteNode extends RgthreeBaseVirtualNode { return super.onConstructed(); } configure(info) { - var _a, _b, _c; - if ((_a = info.outputs) === null || _a === void 0 ? void 0 : _a.length) { - info.outputs.length = 1; - } - if ((_b = info.inputs) === null || _b === void 0 ? void 0 : _b.length) { + var _a, _b; + if ((_a = info.inputs) === null || _a === void 0 ? void 0 : _a.length) { info.inputs.length = 1; } super.configure(info); this.configuring = true; - this.setResizable(!!((_c = this.properties["resizable"]) !== null && _c !== void 0 ? _c : configResizable)); + this.setResizable(!!((_b = this.properties["resizable"]) !== null && _b !== void 0 ? _b : configResizable)); this.applyNodeSize(); this.configuring = false; } diff --git a/web/comfyui/rgthree.js b/web/comfyui/rgthree.js index 5999664..30f182d 100644 --- a/web/comfyui/rgthree.js +++ b/web/comfyui/rgthree.js @@ -430,7 +430,7 @@ class Rgthree extends EventTarget { var _a; try { this.queueNodeIds = nodeIds; - await app.queuePrompt(); + await app.queuePrompt(0); } catch (e) { const [n, v] = this.logParts(LogLevel.ERROR, `There was an error queuing nodes ${nodeIds}`, e); @@ -456,11 +456,11 @@ class Rgthree extends EventTarget { initializeComfyUIHooks() { const rgthree = this; const queuePrompt = app.queuePrompt; - app.queuePrompt = async function () { + app.queuePrompt = async function (number, batchCount) { rgthree.processingQueue = true; rgthree.dispatchCustomEvent("queue"); try { - await queuePrompt.apply(app, [...arguments]); + return await queuePrompt.apply(app, [...arguments]); } finally { rgthree.processingQueue = false; diff --git a/web/comfyui/utils.js b/web/comfyui/utils.js index defec1f..5cde1c7 100644 --- a/web/comfyui/utils.js +++ b/web/comfyui/utils.js @@ -102,8 +102,8 @@ export function addMenuItemOnExtraMenuOptions(node, config, menuOptions, after = if (config.property) { node.properties = node.properties || {}; node.properties[config.property] = config.prepareValue - ? config.prepareValue(subValue.content || '', node) - : subValue.content || ''; + ? config.prepareValue(subValue.content || "", node) + : subValue.content || ""; } config.callback && config.callback(node, subValue === null || subValue === void 0 ? void 0 : subValue.content); }, @@ -328,13 +328,13 @@ export function getConnectedInputInfosAndFilterPassThroughs(startNode, currentNo return filterOutPassthroughNodes(getConnectedNodesInfo(startNode, IoDirection.INPUT, currentNode, slot, passThroughFollowing), passThroughFollowing); } export function getConnectedInputNodesAndFilterPassThroughs(startNode, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL) { - return getConnectedInputInfosAndFilterPassThroughs(startNode, currentNode, slot, passThroughFollowing).map(n => n.node); + return getConnectedInputInfosAndFilterPassThroughs(startNode, currentNode, slot, passThroughFollowing).map((n) => n.node); } export function getConnectedOutputNodes(startNode, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL) { return getConnectedNodesInfo(startNode, IoDirection.OUTPUT, currentNode, slot, passThroughFollowing).map((n) => n.node); } export function getConnectedOutputNodesAndFilterPassThroughs(startNode, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL) { - return filterOutPassthroughNodes(getConnectedNodesInfo(startNode, IoDirection.OUTPUT, currentNode, slot, passThroughFollowing), passThroughFollowing).map(n => n.node); + return filterOutPassthroughNodes(getConnectedNodesInfo(startNode, IoDirection.OUTPUT, currentNode, slot, passThroughFollowing), passThroughFollowing).map((n) => n.node); } export function getConnectedNodesInfo(startNode, dir = IoDirection.INPUT, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL, originTravelFromSlot) { var _a, _b, _c, _d, _e, _f; @@ -597,8 +597,7 @@ export async function matchLocalSlotsToServer(node, direction, serverNodeData) { else { linkData.link.origin_slot = currentNodeSlot; const nextNode = app.graph.getNodeById(linkData.link.target_id); - if (nextNode && - ((_c = nextNode.constructor) === null || _c === void 0 ? void 0 : _c.type.includes("Reroute"))) { + if (nextNode && ((_c = nextNode.constructor) === null || _c === void 0 ? void 0 : _c.type.includes("Reroute"))) { nextNode.stabilize && nextNode.stabilize(); } } @@ -638,7 +637,6 @@ LiteGraph.isValidConnection = function (typeA, typeB) { export function getOutputNodes(nodes) { return ((nodes === null || nodes === void 0 ? void 0 : nodes.filter((n) => { var _a; - return (n.mode != LiteGraph.NEVER && - ((_a = n.constructor.nodeData) === null || _a === void 0 ? void 0 : _a.output_node)); + return (n.mode != LiteGraph.NEVER && ((_a = n.constructor.nodeData) === null || _a === void 0 ? void 0 : _a.output_node)); })) || []); } diff --git a/web/common/link_fixer.js b/web/common/link_fixer.js index 777b4f0..0a98aed 100644 --- a/web/common/link_fixer.js +++ b/web/common/link_fixer.js @@ -149,7 +149,7 @@ export function fixBadLinks(graph, fix = false, silent = false, logger = console } let links = []; if (!Array.isArray(graph.links)) { - Object.values(graph.links).reduce((acc, v) => { + links = Object.values(graph.links).reduce((acc, v) => { acc[v.id] = v; return acc; }, links);