From de21f5ccd348b6d5d9c647a14ab7c0ad1b7136fe Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 16 May 2025 09:16:27 +1000 Subject: [PATCH] Fix unnecessary module loading for type imports (#1053) --- src/LGraph.ts | 2 +- src/LGraphBadge.ts | 2 +- src/canvas/LinkConnector.ts | 2 +- src/litegraph.ts | 2 +- src/types/widgets.ts | 3 +-- src/widgets/BaseWidget.ts | 2 +- test/LinkConnector.integration.test.ts | 5 +---- test/LinkConnector.test.ts | 6 ++---- tsconfig.json | 1 + 9 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/LGraph.ts b/src/LGraph.ts index dbab013bc..74e857f31 100644 --- a/src/LGraph.ts +++ b/src/LGraph.ts @@ -25,7 +25,7 @@ import { LGraphNode, type NodeId } from "./LGraphNode" import { LiteGraph } from "./litegraph" import { type LinkId, LLink } from "./LLink" import { MapProxyHandler } from "./MapProxyHandler" -import { Reroute, RerouteId } from "./Reroute" +import { Reroute, type RerouteId } from "./Reroute" import { stringOrEmpty } from "./strings" import { LGraphEventMode } from "./types/globalEnums" import { getAllNestedItems } from "./utils/collections" diff --git a/src/LGraphBadge.ts b/src/LGraphBadge.ts index 0115d8dd1..48ac2a7cc 100644 --- a/src/LGraphBadge.ts +++ b/src/LGraphBadge.ts @@ -1,4 +1,4 @@ -import { LGraphIcon, LGraphIconOptions } from "./LGraphIcon" +import { LGraphIcon, type LGraphIconOptions } from "./LGraphIcon" export enum BadgePosition { TopLeft = "top-left", diff --git a/src/canvas/LinkConnector.ts b/src/canvas/LinkConnector.ts index 9e2584d71..1f11cb165 100644 --- a/src/canvas/LinkConnector.ts +++ b/src/canvas/LinkConnector.ts @@ -1,4 +1,5 @@ import type { RenderLink } from "./RenderLink" +import type { LinkConnectorEventMap } from "@/infrastructure/LinkConnectorEventMap" import type { ConnectingLink, ItemLocator, LinkNetwork, LinkSegment } from "@/interfaces" import type { INodeInputSlot, INodeOutputSlot } from "@/interfaces" import type { LGraphNode } from "@/LGraphNode" @@ -7,7 +8,6 @@ import type { CanvasPointerEvent } from "@/types/events" import type { IBaseWidget } from "@/types/widgets" import { CustomEventTarget } from "@/infrastructure/CustomEventTarget" -import { LinkConnectorEventMap } from "@/infrastructure/LinkConnectorEventMap" import { LLink } from "@/LLink" import { LinkDirection } from "@/types/globalEnums" diff --git a/src/litegraph.ts b/src/litegraph.ts index c3ec6e1da..1d2d56bfb 100644 --- a/src/litegraph.ts +++ b/src/litegraph.ts @@ -10,7 +10,7 @@ import type { CanvasEventDetail } from "./types/events" import type { RenderShape, TitleMode } from "./types/globalEnums" // Must remain above LiteGraphGlobal (circular dependency due to abstract factory behaviour in `configure`) -export type { Subgraph } from "./subgraph/Subgraph" +export { Subgraph } from "./subgraph/Subgraph" import { LiteGraphGlobal } from "./LiteGraphGlobal" import { loadPolyfills } from "./polyfills" diff --git a/src/types/widgets.ts b/src/types/widgets.ts index 90817d9f3..f2b1d472d 100644 --- a/src/types/widgets.ts +++ b/src/types/widgets.ts @@ -1,8 +1,7 @@ +import type { CanvasColour, Point, RequiredProps, Size } from "../interfaces" import type { CanvasPointer, LGraphCanvas, LGraphNode } from "../litegraph" import type { CanvasMouseEvent, CanvasPointerEvent } from "./events" -import { CanvasColour, Point, type RequiredProps, Size } from "../interfaces" - export interface IWidgetOptions { on?: string off?: string diff --git a/src/widgets/BaseWidget.ts b/src/widgets/BaseWidget.ts index eb3b374ce..f423cc642 100644 --- a/src/widgets/BaseWidget.ts +++ b/src/widgets/BaseWidget.ts @@ -1,10 +1,10 @@ +import type { Point } from "@/interfaces" import type { CanvasPointer, LGraphCanvas, LGraphNode, Size } from "@/litegraph" import type { CanvasMouseEvent, CanvasPointerEvent } from "@/types/events" import type { IBaseWidget } from "@/types/widgets" import { drawTextInArea } from "@/draw" import { Rectangle } from "@/infrastructure/Rectangle" -import { Point } from "@/interfaces" import { LiteGraph } from "@/litegraph" export interface DrawWidgetOptions { diff --git a/test/LinkConnector.integration.test.ts b/test/LinkConnector.integration.test.ts index f7ca98bb8..ecd9d481c 100644 --- a/test/LinkConnector.integration.test.ts +++ b/test/LinkConnector.integration.test.ts @@ -3,10 +3,7 @@ import type { CanvasPointerEvent } from "@/types/events" import { afterEach, describe, expect, vi } from "vitest" import { LinkConnector } from "@/canvas/LinkConnector" -import { LGraph } from "@/LGraph" -import { LGraphNode } from "@/LGraphNode" -import { LLink } from "@/LLink" -import { Reroute, type RerouteId } from "@/Reroute" +import { LGraph, LGraphNode, LLink, Reroute, type RerouteId } from "@/litegraph" import { test as baseTest } from "./testExtensions" diff --git a/test/LinkConnector.test.ts b/test/LinkConnector.test.ts index b4ac22483..31437ba1f 100644 --- a/test/LinkConnector.test.ts +++ b/test/LinkConnector.test.ts @@ -6,10 +6,7 @@ import { describe, expect, test as baseTest, vi } from "vitest" import { LinkConnector } from "@/canvas/LinkConnector" import { ToInputRenderLink } from "@/canvas/ToInputRenderLink" -import { LGraph } from "@/LGraph" -import { LGraphNode } from "@/LGraphNode" -import { LLink } from "@/LLink" -import { Reroute, type RerouteId } from "@/Reroute" +import { LGraph, LGraphNode, LLink, Reroute, type RerouteId } from "@/litegraph" import { LinkDirection } from "@/types/globalEnums" interface TestContext { @@ -30,6 +27,7 @@ const test = baseTest.extend({ links: new Map(), reroutes, floatingLinks, + getLink: graph.getLink.bind(graph), getNodeById: (id: number) => graph.getNodeById(id), addFloatingLink: (link: LLink) => { floatingLinks.set(link.id, link) diff --git a/tsconfig.json b/tsconfig.json index 32b603a7d..ef4ccc887 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,7 @@ "downlevelIteration": true, "noImplicitOverride": true, "noPropertyAccessFromIndexSignature": true, + "verbatimModuleSyntax": true, /* AllowJs during migration phase */ "allowJs": true,