mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 07:00:23 +00:00
[TS] Clean up serialisation interfaces (#733)
Removes legacy generic & dynamic typing, and standardises TS styles.
This commit is contained in:
@@ -43,9 +43,9 @@ export interface Parent<TChild> {
|
||||
* May contain other {@link Positionable} objects.
|
||||
*/
|
||||
export interface Positionable extends Parent<Positionable> {
|
||||
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<LinkId, LLink>
|
||||
reroutes: Map<RerouteId, Reroute>
|
||||
readonly links: Map<LinkId, LLink>
|
||||
readonly reroutes: Map<RerouteId, Reroute>
|
||||
getNodeById(id: NodeId): LGraphNode | null
|
||||
}
|
||||
|
||||
|
||||
@@ -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<SerialisableObject> {
|
||||
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<LGraphNode["serialize"]>,
|
||||
TLink = ReturnType<LLink["serialize"]>,
|
||||
TGroup = ReturnType<LGraphGroup["serialize"]>,
|
||||
> = {
|
||||
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<any, any>
|
||||
extra?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/** Serialised LGraphGroup */
|
||||
|
||||
Reference in New Issue
Block a user