forked from sh570655308/ComfyUI-GigapixelAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgigapixel.js
40 lines (37 loc) · 1.46 KB
/
gigapixel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { app } from "../../scripts/app.js";
let gigapixel_setting;
const id = "comfy.gigapixel";
const ext = {
name: id,
async setup(app) {
gigapixel_setting = app.ui.settings.addSetting({
id,
name: "Gigapixel AI (gigapixel.exe)",
defaultValue: "C:\\Program Files\\Topaz Labs LLC\\Topaz Gigapixel AI\\gigapixel.exe",
type: "string",
});
},
async beforeRegisterNodeDef(nodeType, nodeData, _app) {
if (nodeData.name === 'GigapixelAI') {
const ensureGigapixel = async (node) => {
const gigapixelWidget = node.widgets.find(w => w.name === "gigapixel_exe");
if (gigapixelWidget && gigapixelWidget.value === "") {
gigapixelWidget.value = gigapixel_setting.value;
}
}
const onConfigure = nodeType.prototype.onConfigure;
nodeType.prototype.onConfigure = function () {
const r = onConfigure ? onConfigure.apply(this, arguments) : undefined;
ensureGigapixel(this);
return r;
};
const onNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
const r = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined;
ensureGigapixel(this);
return r;
};
}
},
}
app.registerExtension(ext);