diff --git a/src/interfaces.ts b/src/interfaces.ts index b5c6eeae8..9fa8b4483 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -43,9 +43,9 @@ export interface Parent { * May contain other {@link Positionable} objects. */ export interface Positionable extends Parent { - id: NodeId | RerouteId | number + readonly id: NodeId | RerouteId | number /** Position in graph coordinates. Default: 0,0 */ - pos: Point + readonly pos: Point /** true if this object is part of the selection, otherwise false. */ selected?: boolean @@ -106,7 +106,7 @@ export interface IColorable { * Prevents the object being accidentally moved or resized by mouse interaction. */ export interface IPinnable { - pinned: boolean + readonly pinned: boolean pin(value?: boolean): void unpin(): void } @@ -115,8 +115,8 @@ export interface IPinnable { * Contains a list of links, reroutes, and nodes. */ export interface LinkNetwork { - links: Map - reroutes: Map + readonly links: Map + readonly reroutes: Map getNodeById(id: NodeId): LGraphNode | null } diff --git a/src/types/serialisation.ts b/src/types/serialisation.ts index 9b0a4227c..5a27258e3 100644 --- a/src/types/serialisation.ts +++ b/src/types/serialisation.ts @@ -7,11 +7,11 @@ import type { Point, Size, } from "../interfaces" -import type { LGraph, LGraphState } from "../LGraph" -import type { IGraphGroupFlags, LGraphGroup } from "../LGraphGroup" -import type { LGraphNode, NodeId, NodeProperty } from "../LGraphNode" +import type { LGraphConfig, LGraphState } from "../LGraph" +import type { IGraphGroupFlags } from "../LGraphGroup" +import type { NodeId, NodeProperty } from "../LGraphNode" import type { LiteGraph } from "../litegraph" -import type { LinkId, LLink } from "../LLink" +import type { LinkId, SerialisedLLinkArray } from "../LLink" import type { RerouteId } from "../Reroute" import type { TWidgetValue } from "../types/widgets" import type { RenderShape } from "./globalEnums" @@ -31,7 +31,7 @@ export interface Serialisable { export interface SerialisableGraph { /** Schema version. @remarks Version bump should add to const union, which is used to narrow type during deserialise. */ version: 0 | 1 - config: LGraph["config"] + config: LGraphConfig state: LGraphState groups?: ISerialisedGroup[] nodes?: ISerialisedNode[] @@ -76,19 +76,15 @@ export interface ISerialisedNode { * Original implementation from static litegraph.d.ts * Maintained for backwards compat */ -export type ISerialisedGraph< - TNode = ReturnType, - TLink = ReturnType, - TGroup = ReturnType, -> = { +export interface ISerialisedGraph { last_node_id: NodeId last_link_id: number - nodes: TNode[] - links: TLink[] - groups: TGroup[] - config: LGraph["config"] + nodes: ISerialisedNode[] + links: SerialisedLLinkArray[] + groups: ISerialisedGroup[] + config: LGraphConfig version: typeof LiteGraph.VERSION - extra?: Record + extra?: Record } /** Serialised LGraphGroup */