From ee89fc575fe36c454a2ee3ec7e1adfb9ca6120df Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 2 May 2025 08:38:54 +1000 Subject: [PATCH] [Cleanup] Removes unused code (#996) - Removes unused code - Removes unnecessary globalAlpha reset when drawing reroute highlight --- src/LGraph.ts | 6 +++--- src/LGraphCanvas.ts | 7 +------ src/interfaces.ts | 6 ------ src/litegraph.ts | 1 - src/measure.ts | 12 ------------ test/measure.test.ts | 20 -------------------- 6 files changed, 4 insertions(+), 48 deletions(-) diff --git a/src/LGraph.ts b/src/LGraph.ts index f30924efd..78b59aac6 100644 --- a/src/LGraph.ts +++ b/src/LGraph.ts @@ -1189,9 +1189,9 @@ export class LGraph implements LinkNetwork, Serialisable { } /** - * Returns a reroute by ID, or `undefined` if the ID is `null` or `undefined`. - * @param id ID of reroute to return - * @returns The reroute with the provided {@link id}, otherwise `undefined`. Always returns `undefined` if `id` is `null` or `undefined`. + * Finds the reroute with the provided ID. + * @param id ID of reroute to find + * @returns The reroute with the provided {@link id}, otherwise `undefined`. Always returns `undefined` if `id` is nullish. */ getReroute(id: null | undefined): undefined getReroute(id: RerouteId | null | undefined): Reroute | undefined diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index 3355c4ddd..472c80351 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -4037,12 +4037,7 @@ export class LGraphCanvas { if (!LiteGraph.snap_highlights_node || !linkConnector.isConnecting || linkConnectorSnap) return // Reroute highlight - if (overReroute) { - const { globalAlpha } = ctx - ctx.globalAlpha = 1 - overReroute.drawHighlight(ctx, "#ffcc00aa") - ctx.globalAlpha = globalAlpha - } + overReroute?.drawHighlight(ctx, "#ffcc00aa") // Ensure we're mousing over a node and connecting a link const node = this.node_over diff --git a/src/interfaces.ts b/src/interfaces.ts index 6f615f98b..f415d5e20 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -253,12 +253,6 @@ export interface IBoundaryNodes { export type Direction = "top" | "bottom" | "left" | "right" -export interface IOptionalSlotData { - content: string - value: TSlot - className?: string -} - /** * A string that represents a specific data / slot type, e.g. `STRING`. * diff --git a/src/litegraph.ts b/src/litegraph.ts index 574464d18..f571be6ea 100644 --- a/src/litegraph.ts +++ b/src/litegraph.ts @@ -109,7 +109,6 @@ export type { INodeInputSlot, INodeOutputSlot, INodeSlot, - IOptionalSlotData, ISlotType, KeysOfType, LinkNetwork, diff --git a/src/measure.ts b/src/measure.ts index e9de55502..ee6e611df 100644 --- a/src/measure.ts +++ b/src/measure.ts @@ -115,18 +115,6 @@ export function isInsideRectangle( top + height > y } -/** - * Cheap, low accuracy check to determine if a point is roughly inside a sort-of octagon - * @param x Point x - * @param y Point y - * @param radius Radius to use as rough guide for octagon - * @returns `true` if the point is roughly inside the octagon centred on 0,0 with specified radius - */ -export function isSortaInsideOctagon(x: number, y: number, radius: number): boolean { - const sum = Math.min(radius, Math.abs(x)) + Math.min(radius, Math.abs(y)) - return sum < radius * 0.75 -} - /** * Determines if two rectangles have any overlap * @param a Rectangle A as `x, y, width, height` diff --git a/test/measure.test.ts b/test/measure.test.ts index 86ae8b776..57967d07b 100644 --- a/test/measure.test.ts +++ b/test/measure.test.ts @@ -15,7 +15,6 @@ import { isInRectangle, isInsideRectangle, isPointInRect, - isSortaInsideOctagon, overlapBounding, rotateLink, snapPoint, @@ -154,25 +153,6 @@ test("isInsideRectangle handles edge cases differently from isInRectangle", ({ e expect(isInsideRectangle(11, 5, 0, 0, 10, 10)).toBe(false) }) -test("isSortaInsideOctagon approximates octagon containment", ({ expect }) => { - const radius = 10 - - // Points clearly inside - expect(isSortaInsideOctagon(0, 0, radius)).toBe(true) - expect(isSortaInsideOctagon(3, 3, radius)).toBe(true) - - // Points on diagonal (roughly on octagon edge) - expect(isSortaInsideOctagon(7, 7, radius)).toBe(false) - - // Points clearly outside - expect(isSortaInsideOctagon(10, 10, radius)).toBe(false) - expect(isSortaInsideOctagon(-10, -10, radius)).toBe(false) - - // Points on axes - expect(isSortaInsideOctagon(radius * 0.5, 0, radius)).toBe(true) - expect(isSortaInsideOctagon(0, radius * 0.5, radius)).toBe(true) -}) - test("containsRect correctly identifies nested rectangles", ({ expect }) => { const container: Rect = [0, 0, 20, 20]