Fix: Update to new ComfyUI API and fix asset paths

- Migrate from deprecated imports (../../scripts/app.js) to window.comfyAPI
- Fix asset paths for /extensions/ directory structure
- Update Vite base path from /ComfyUI-ultimate-openpose-editor/ to /extensions/ComfyUI-ultimate-openpose-editor/ui/
- Resolves browser reload loop and 404 errors on newer ComfyUI versions
This commit is contained in:
unknown
2025-12-09 22:11:45 +01:00
parent 273beff403
commit 8048f7cbef
3 changed files with 38 additions and 25 deletions
+30 -20
View File
@@ -1,6 +1,13 @@
import { app } from "../../scripts/app.js";
import { ComfyDialog, $el } from "../../scripts/ui.js";
import { ComfyApp } from "../../scripts/app.js";
// Use new ComfyUI API directly to avoid deprecation issues
const app = window.comfyAPI?.app?.app;
const ComfyDialog = window.comfyAPI?.ui?.ComfyDialog;
const $el = window.comfyAPI?.ui?.$el;
const ComfyApp = window.comfyAPI?.app?.ComfyApp;
// Fallback for older versions
if (!app || !ComfyDialog || !$el || !ComfyApp) {
console.error('[OpenposeEditor] ComfyUI API not available, extension disabled');
}
function addMenuHandler(nodeType, cb) {
@@ -149,24 +156,27 @@ class OpenposeEditorDialog extends ComfyDialog {
}
}
app.registerExtension({
name: "OpenposeEditor",
// Only register if API is available
if (app && ComfyDialog && $el && ComfyApp) {
app.registerExtension({
name: "OpenposeEditor",
async beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData.name === "OpenposeEditorNode") {
addMenuHandler(nodeType, function (_, options) {
options.unshift({
content: "Open in Openpose Editor",
callback: () => {
// `this` is the node instance
ComfyApp.copyToClipspace(this);
ComfyApp.clipspace_return_node = this;
async beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData.name === "OpenposeEditorNode") {
addMenuHandler(nodeType, function (_, options) {
options.unshift({
content: "Open in Openpose Editor",
callback: () => {
// `this` is the node instance
ComfyApp.copyToClipspace(this);
ComfyApp.clipspace_return_node = this;
const dlg = OpenposeEditorDialog.getInstance();
dlg.show();
},
const dlg = OpenposeEditorDialog.getInstance();
dlg.show();
},
});
});
});
}
}
}
});
});
}
+5 -3
View File
@@ -57,9 +57,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Openpose Editor</title>
<script type="module" crossorigin="" src="./assets/index-cd1939ba.js"></script>
<link rel="stylesheet" href="./assets/index-22cc811d.css">
<link rel="stylesheet" href="./assets/antd.dark-4fd6fdfe.css"></head>
<script type="module" crossorigin="" src="/extensions/ComfyUI-ultimate-openpose-editor/ui/assets/index-cd1939ba.js"></script>
<link rel="stylesheet" href="/extensions/ComfyUI-ultimate-openpose-editor/ui/assets/index-22cc811d.css">
<link rel="stylesheet" href="/extensions/ComfyUI-ultimate-openpose-editor/ui/assets/antd.dark-4fd6fdfe.css"></head>
<body class="dark-theme">
<div id="app" data-v-app=""><div class="ant-row" style="row-gap: 0px;"><div class="ant-col ant-col-8" id="control-panel"><header><div><div class=""><div class="ant-page-header ant-page-header-ghost ant-page-header-compact"><!----><div class="ant-page-header-heading"><div class="ant-page-header-heading-left"><!----><!----><span class="ant-page-header-heading-title"><div class="ant-space ant-space-horizontal ant-space-align-center" style="gap: 8px;"><div class="ant-space-item" style=""><a
href="https://github.com/westNeighbor/ComfyUI-ultimate-openpose-editor" target="_blank"><span role="img" aria-label="github" class="anticon anticon-github"><svg focusable="false" class="" data-icon="github" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M511.6 76.3C264.3 76.2 64 276.4 64 523.5 64 718.9 189.3 885 363.8 946c23.5 5.9 19.9-10.8 19.9-22.2v-77.5c-135.7 15.9-141.2-73.9-150.3-88.9C215 726 171.5 718 184.5 703c30.9-15.9 62.4 4
@@ -93,3 +93,5 @@
</body></html>
File diff suppressed because one or more lines are too long