Skip to content

Commit 90d6030

Browse files
committed
add edit workflow app
1 parent 597bd1d commit 90d6030

File tree

6 files changed

+79
-8
lines changed

6 files changed

+79
-8
lines changed

web/scripts/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ class ComfyApi extends EventTarget {
353353
* @returns { Promise<string, unknown> } A dictionary of id -> value
354354
*/
355355
async getSettings() {
356+
return {};
356357
return (await this.fetchApi("/settings")).json();
357358
}
358359

web/scripts/app.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class ComfyApp {
5454
static clipspace_return_node = null;
5555

5656
constructor() {
57-
this.ui = new ComfyUI(this);
57+
// this.ui = new ComfyUI(this);
5858
// this.logging = new ComfyLogging(this);
5959

6060
/**
@@ -1454,7 +1454,7 @@ export class ComfyApp {
14541454
*/
14551455
async setup() {
14561456
// await this.#setUser();
1457-
// await this.ui.settings.load();
1457+
await this.ui.settings.load();
14581458
await this.#loadExtensions();
14591459

14601460
// Create and mount the LiteGraph in the DOM
@@ -2239,7 +2239,8 @@ export async function loadModuleBasedOnPath() {
22392239
app = new ComfyViewNodePackageApp();
22402240
} else {
22412241
// For any other path, import app.js and perform setup
2242-
app = new ComfyApp()
2242+
const {ComfyEditWorkflowApp} = await import("./comfyspace_editWorkflowApp.js");
2243+
app = new ComfyEditWorkflowApp()
22432244
}
22442245
}
22452246

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
import { ComfyApp } from "./app.js";
3+
import {serverNodeDefs} from '../../serverNodeDefs.js'
4+
import { ComfyUI, $el } from "./ui.js";
5+
6+
const COMFYUI_CORE_EXTENSIONS = [
7+
"/extensions/core/clipspace.js",
8+
"/extensions/core/colorPalette.js",
9+
"/extensions/core/contextMenuFilter.js",
10+
"/extensions/core/dynamicPrompts.js",
11+
"/extensions/core/editAttention.js",
12+
"/extensions/core/groupNode.js",
13+
"/extensions/core/groupNodeManage.js",
14+
"/extensions/core/groupOptions.js",
15+
"/extensions/core/invertMenuScrolling.js",
16+
"/extensions/core/keybinds.js",
17+
"/extensions/core/linkRenderMode.js",
18+
"/extensions/core/maskeditor.js",
19+
"/extensions/core/nodeTemplates.js",
20+
"/extensions/core/noteNode.js",
21+
"/extensions/core/rerouteNode.js",
22+
"/extensions/core/saveImageExtraOutput.js",
23+
"/extensions/core/slotDefaults.js",
24+
"/extensions/core/snapToGrid.js",
25+
"/extensions/core/undoRedo.js",
26+
"/extensions/core/uploadImage.js",
27+
"/extensions/core/widgetInputs.js",
28+
"/extensions/dp.js",
29+
]
30+
31+
export class ComfyEditWorkflowApp extends ComfyApp {
32+
extensionFilesPath = COMFYUI_CORE_EXTENSIONS;
33+
/** comfyspace cloud @type {string[]} */
34+
nodeDefs = serverNodeDefs;
35+
36+
constructor() {
37+
super();
38+
this.ui = new ComfyUI(this);
39+
}
40+
async setup() {
41+
await super.setup();
42+
}
43+
}

web/scripts/comfyspace_viewNodePackageApp.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
import { ComfyApp } from "./app.js";
3+
import { ComfySettingsDialog } from "./ui/settings.js";
4+
35
const COMFYUI_CORE_EXTENSIONS = [
46
// "/extensions/core/clipspace.js",
57
"/extensions/core/colorPalette.js",
@@ -23,7 +25,15 @@ const COMFYUI_CORE_EXTENSIONS = [
2325
"/extensions/core/uploadImage.js",
2426
"/extensions/core/widgetInputs.js",
2527
"/extensions/dp.js",
26-
]
28+
];
29+
30+
class CustomComfyUI {
31+
constructor(app) {
32+
this.app = app;
33+
this.settings = new ComfySettingsDialog(app);
34+
}
35+
}
36+
2737
export class ComfyViewNodePackageApp extends ComfyApp {
2838
/** @type {{nodeDefs:string,jsFilePaths:string}} */
2939
nodePackage = null;
@@ -64,6 +74,7 @@ export class ComfyViewNodePackageApp extends ComfyApp {
6474

6575
}
6676
async setup() {
77+
this.ui = new CustomComfyUI(this);
6778
// to disable mousewheel zooming
6879
// LGraphCanvas.prototype.processMouseWheel =()=>{}
6980
this.setupMouseWheel();

web/scripts/comfyspace_viewWorkflowApp.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
import { ComfyApp } from "./app.js";
3+
import {serverNodeDefs} from '../../serverNodeDefs.js'
4+
import { ComfySettingsDialog } from "./ui/settings.js";
35

46
const COMFYUI_CORE_EXTENSIONS = [
57
// "/extensions/core/clipspace.js",
@@ -25,12 +27,19 @@ const COMFYUI_CORE_EXTENSIONS = [
2527
"/extensions/core/widgetInputs.js",
2628
"/extensions/dp.js",
2729
]
28-
30+
class CustomComfyUI {
31+
constructor(app) {
32+
this.app = app;
33+
this.settings = new ComfySettingsDialog(app);
34+
}
35+
}
2936
export class ComfyViewWorkflowApp extends ComfyApp {
3037
#workflow = null
3138

3239
async setup() {
40+
this.ui = new CustomComfyUI(this);
3341
this.extensionFilesPath = COMFYUI_CORE_EXTENSIONS;
42+
this.nodeDefs = serverNodeDefs;
3443

3544
const queryParams = new URLSearchParams(window.location.search);
3645
const workflowVersionID = queryParams.get('workflowVersionID');
@@ -43,9 +52,15 @@ export class ComfyViewWorkflowApp extends ComfyApp {
4352
return response.json();
4453
})
4554
.then((data) => {
46-
console.log("getCloudflowVersion data", data);
4755
const workflowVer = data.data;
48-
this.nodeDefs = JSON.parse(workflowVer.nodeDefs);
56+
57+
if (workflowVer?.nodeDefs != null) {
58+
const defs = JSON.parse(workflowVer.nodeDefs);
59+
this.nodeDefs = {
60+
...this.nodeDefs,
61+
...defs,
62+
}
63+
}
4964
this.#workflow = JSON.parse(workflowVer.json);
5065
})
5166
.catch((error) => {

web/scripts/ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export class ComfyUI {
294294
this.lastQueueSize = 0;
295295
this.queue = new ComfyList("Queue");
296296
this.history = new ComfyList("History", "history", true);
297-
return;
297+
298298
api.addEventListener("status", () => {
299299
this.queue.update();
300300
this.history.update();

0 commit comments

Comments
 (0)