From df36b23db8503f5baa9ca8b0b1f384a407a6b12b Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 14 Mar 2025 02:00:57 +1100 Subject: [PATCH] [TS] Prefer narrow interface - readonly network (#769) Uses new readonly link network interface in APIs that do not require write. --- src/LLink.ts | 5 +++-- src/Reroute.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/LLink.ts b/src/LLink.ts index 9452d268e0..0b1e555c6a 100644 --- a/src/LLink.ts +++ b/src/LLink.ts @@ -3,6 +3,7 @@ import type { ISlotType, LinkNetwork, LinkSegment, + ReadonlyLinkNetwork, } from "./interfaces" import type { NodeId } from "./LGraphNode" import type { Reroute, RerouteId } from "./Reroute" @@ -108,7 +109,7 @@ export class LLink implements LinkSegment, Serialisable { * this reroute or the reroute before it. Otherwise, an empty array. */ static getReroutes( - network: LinkNetwork, + network: ReadonlyLinkNetwork, linkSegment: LinkSegment, ): Reroute[] { if (!linkSegment.parentId) return [] @@ -133,7 +134,7 @@ export class LLink implements LinkSegment, Serialisable { * @returns The reroute that was found, `undefined` if no reroute was found, or `null` if an infinite loop was detected. */ static findNextReroute( - network: LinkNetwork, + network: Pick, linkSegment: LinkSegment, rerouteId: RerouteId, ): Reroute | null | undefined { diff --git a/src/Reroute.ts b/src/Reroute.ts index 3b355938c4..30c8acb056 100644 --- a/src/Reroute.ts +++ b/src/Reroute.ts @@ -4,6 +4,7 @@ import type { LinkSegment, Point, Positionable, + ReadonlyLinkNetwork, ReadOnlyRect, } from "./interfaces" import type { NodeId } from "./LGraphNode" @@ -252,7 +253,7 @@ export class Reroute implements Positionable, LinkSegment, Serialisable this.#lastRenderTime)) return this.#lastRenderTime = lastRenderTime