From 9de52bb2c3557797341e8fe62bdbc70842f4b6a1 Mon Sep 17 00:00:00 2001 From: DrJKL Date: Mon, 27 Nov 2023 18:18:44 -0800 Subject: [PATCH] Let's try this. Global LiteGraph with the wrong types. --- dist/ComfyUI-Anchors/lib/anchor.d.ts | 4 ++++ dist/comfyui-anchors.js | 29 ++++++++++++++-------------- lib/anchor.ts | 13 ++++++++----- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/dist/ComfyUI-Anchors/lib/anchor.d.ts b/dist/ComfyUI-Anchors/lib/anchor.d.ts index cb0ff5c..fe74bac 100644 --- a/dist/ComfyUI-Anchors/lib/anchor.d.ts +++ b/dist/ComfyUI-Anchors/lib/anchor.d.ts @@ -1 +1,5 @@ +declare global { + const LiteGraph: any; + const LGraphCanvas: any; +} export {}; diff --git a/dist/comfyui-anchors.js b/dist/comfyui-anchors.js index 47e54c5..fd8c8a1 100644 --- a/dist/comfyui-anchors.js +++ b/dist/comfyui-anchors.js @@ -1,24 +1,23 @@ -var c = Object.defineProperty; -var i = (r, o, t) => o in r ? c(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t; -var e = (r, o, t) => (i(r, typeof o != "symbol" ? o + "" : o, t), t); -import { LiteGraph as l, LGraphCanvas as s } from "../../../lib/litegraph.core.js"; -import { app as n } from "../../../scripts/app.js"; -import { ComfyWidgets as a } from "../../../scripts/widgets.js"; -function p() { +var s = Object.defineProperty; +var l = (r, o, t) => o in r ? s(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t; +var e = (r, o, t) => (l(r, typeof o != "symbol" ? o + "" : o, t), t); +import { app as c } from "../../../scripts/app.js"; +import { ComfyWidgets as i } from "../../../scripts/widgets.js"; +function a() { console.log("%cSetting up ComfyUI-Anchors...", "color:green"); } -n.registerExtension({ +c.registerExtension({ name: "drjkl.custom_nodes.anchors", async registerCustomNodes(r) { class o { constructor() { - e(this, "color", s.node_colors.yellow.color); - e(this, "bgcolor", s.node_colors.yellow.bgcolor); - e(this, "groupcolor", s.node_colors.yellow.groupcolor); + e(this, "color", LGraphCanvas.node_colors.yellow.color); + e(this, "bgcolor", LGraphCanvas.node_colors.yellow.bgcolor); + e(this, "groupcolor", LGraphCanvas.node_colors.yellow.groupcolor); e(this, "serialize_widgets", !0); e(this, "isVirtualNode", !0); e(this, "properties", { text: "" }); - a.STRING( + i.STRING( this, "", ["", { default: this.properties.text, multiline: !1 }], @@ -26,16 +25,16 @@ n.registerExtension({ ); } } - e(o, "category", "utils"), l.registerNodeType( + e(o, "category", "utils"), LiteGraph.registerNodeType( "Anchor", Object.assign(o, { - title_mode: l.NORMAL_TITLE, + title_mode: LiteGraph.NORMAL_TITLE, title: "⚓", collapsable: !0 }) ); }, async setup() { - p(); + a(); } }); diff --git a/lib/anchor.ts b/lib/anchor.ts index 0f4b715..d63b760 100644 --- a/lib/anchor.ts +++ b/lib/anchor.ts @@ -1,10 +1,13 @@ -import { - LGraphCanvas, - LiteGraph, -} from '../../ComfyUI/web/lib/litegraph.core.js'; import { app } from '../../ComfyUI/web/scripts/app.js'; import { ComfyWidgets } from '../../ComfyUI/web/scripts/widgets.js'; -import { ComfyExtension } from '../../ComfyUI/web/types/comfy'; +import { type ComfyExtension } from '../../ComfyUI/web/types/comfy'; + +declare global { + // TODO: Oh god... What have I gotten myself into...? + // Nah, this'll be fun. + const LiteGraph: any; + const LGraphCanvas: any; +} function setupAnchors() { console.log(`%cSetting up ComfyUI-Anchors...`, 'color:green');