From 58713ea6e0c4127dc8f5926c262434915c135f19 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Sun, 15 Mar 2026 20:12:49 +0800 Subject: [PATCH] fix(top-menu): use dynamic imports to eliminate deprecation warnings - Replace static imports of deprecated ComfyButton and ComfyButtonGroup with dynamic imports - Only loads legacy API files when frontend version < 1.33.9 (backward compatibility path) - Frontend >= 1.33.9 users no longer see deprecation warnings since legacy code is never loaded - Preserves full backward compatibility for older ComfyUI frontend versions - All existing tests pass (159 JS + 65 Vue tests) --- web/comfyui/top_menu_extension.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/web/comfyui/top_menu_extension.js b/web/comfyui/top_menu_extension.js index b5e5446a..716015d1 100644 --- a/web/comfyui/top_menu_extension.js +++ b/web/comfyui/top_menu_extension.js @@ -1,6 +1,4 @@ import { app } from "../../scripts/app.js"; -import { ComfyButtonGroup } from "../../scripts/ui/components/buttonGroup.js"; -import { ComfyButton } from "../../scripts/ui/components/button.js"; const BUTTON_TOOLTIP = "Launch LoRA Manager (Shift+Click opens in new window)"; const LORA_MANAGER_PATH = "/loras"; @@ -95,7 +93,9 @@ const fetchVersionInfo = async () => { return ""; }; -const createTopMenuButton = () => { +const createTopMenuButton = async () => { + const { ComfyButton } = await import("../../scripts/ui/components/button.js"); + const button = new ComfyButton({ icon: "loramanager", tooltip: BUTTON_TOOLTIP, @@ -117,7 +117,7 @@ const createTopMenuButton = () => { return button; }; -const attachTopMenuButton = (attempt = 0) => { +const attachTopMenuButton = async (attempt = 0) => { if (document.querySelector(`.${BUTTON_GROUP_CLASS}`)) { return; } @@ -133,7 +133,9 @@ const attachTopMenuButton = (attempt = 0) => { return; } - const loraManagerButton = createTopMenuButton(); + const loraManagerButton = await createTopMenuButton(); + const { ComfyButtonGroup } = await import("../../scripts/ui/components/buttonGroup.js"); + const buttonGroup = new ComfyButtonGroup(loraManagerButton); buttonGroup.element.classList.add(BUTTON_GROUP_CLASS); @@ -158,7 +160,7 @@ const createExtensionObject = (useActionBar) => { if (!useActionBar) { console.log("LoRA Manager: using legacy button attachment (frontend version < 1.33.9)"); - attachTopMenuButton(); + await attachTopMenuButton(); } else { console.log("LoRA Manager: using actionBarButtons API (frontend version >= 1.33.9)"); }