diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index b6375b664..d9c7ff1bd 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -216,8 +216,15 @@ export class LGraphCanvas implements ConnectionColorContext { static DEFAULT_BACKGROUND_IMAGE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII=" - /** Initialised from LiteGraphGlobal static block to avoid circular dependency. */ - static link_type_colors: Record + static DEFAULT_EVENT_LINK_COLOR = "#A86" + + /** Link type to colour dictionary. */ + static link_type_colors: Dictionary = { + "-1": LGraphCanvas.DEFAULT_EVENT_LINK_COLOR, + "number": "#AAA", + "node": "#DCA", + } + static gradients: Record = {} static search_limit = -1 diff --git a/src/LiteGraphGlobal.ts b/src/LiteGraphGlobal.ts index 12f8bfcd1..b6db26c13 100644 --- a/src/LiteGraphGlobal.ts +++ b/src/LiteGraphGlobal.ts @@ -66,8 +66,6 @@ export class LiteGraphGlobal { WIDGET_SECONDARY_TEXT_COLOR = "#999" LINK_COLOR = "#9A9" - // TODO: This is a workaround until LGraphCanvas.link_type_colors is no longer static. - static DEFAULT_EVENT_LINK_COLOR = "#A86" EVENT_LINK_COLOR = "#A86" CONNECTING_LINK_COLOR = "#AFA" @@ -275,15 +273,6 @@ export class LiteGraphGlobal { onNodeTypeRegistered?(type: string, base_class: typeof LGraphNode): void onNodeTypeReplaced?(type: string, base_class: typeof LGraphNode, prev: unknown): void - // Avoid circular dependency from original single-module - static { - LGraphCanvas.link_type_colors = { - "-1": LiteGraphGlobal.DEFAULT_EVENT_LINK_COLOR, - "number": "#AAA", - "node": "#DCA", - } - } - /** * Register a node class so it can be listed when the user wants to create a new one * @param type name of the node and path diff --git a/test/litegraph.test.ts b/test/litegraph.test.ts index 4513b7919..16e3b0ef2 100644 --- a/test/litegraph.test.ts +++ b/test/litegraph.test.ts @@ -27,19 +27,6 @@ describe("Import order dependency", () => { vi.resetModules() }) - // Test can be safely removed if import order requirements are resolved. - test("Throws when entry point is not imported first", async ({ expect }) => { - async function importSubmoduleFirst() { - const directImport = await import("@/LGraph") - const entryPointImport = await import("@/litegraph") - - // Unreachable. - if (directImport !== entryPointImport) return - } - - await expect(importSubmoduleFirst).rejects.toThrow("Cannot set properties of undefined (setting 'link_type_colors')") - }) - test("Imports without error when entry point is imported first", async ({ expect }) => { async function importNormally() { const entryPointImport = await import("@/litegraph")