Merge Task 4: LiteGraph type extraction

This commit is contained in:
Alexander Brown
2026-01-27 09:32:15 -08:00
8 changed files with 125 additions and 37 deletions

View File

@@ -18,7 +18,7 @@ import { LGraphButton } from './LGraphButton'
import type { LGraphButtonOptions } from './LGraphButton'
import { LGraphCanvas } from './LGraphCanvas'
import { LLink } from './LLink'
import type { Reroute, RerouteId } from './Reroute'
import type { Reroute } from './Reroute'
import { getNodeInputOnPos, getNodeOutputOnPos } from './canvas/measureSlots'
import type { IDrawBoundingOptions } from './draw'
import { NullGraphError } from './infrastructure/NullGraphError'
@@ -73,6 +73,7 @@ import {
RenderShape,
TitleMode
} from './types/globalEnums'
import type { NodeId, RerouteId } from './types/ids'
import type { ISerialisedNode, SubgraphIO } from './types/serialisation'
import type {
IBaseWidget,
@@ -88,9 +89,9 @@ import { BaseWidget } from './widgets/BaseWidget'
import { toConcreteWidget } from './widgets/widgetMap'
import type { WidgetTypeMap } from './widgets/widgetMap'
// #region Types
export type { NodeId } from './types/ids'
export type NodeId = number | string
// #region Types
export type NodeProperty = string | number | boolean | object

View File

@@ -7,8 +7,8 @@ import type { SubgraphOutput } from '@/lib/litegraph/src/subgraph/SubgraphOutput
import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations'
import { LayoutSource } from '@/renderer/core/layout/types'
import type { LGraphNode, NodeId } from './LGraphNode'
import type { Reroute, RerouteId } from './Reroute'
import type { LGraphNode } from './LGraphNode'
import type { Reroute } from './Reroute'
import type {
CanvasColour,
INodeInputSlot,
@@ -19,11 +19,12 @@ import type {
Point,
ReadonlyLinkNetwork
} from './interfaces'
import type { LinkId, NodeId, RerouteId } from './types/ids'
import type { Serialisable, SerialisableLLink } from './types/serialisation'
const layoutMutations = useLayoutMutations()
export type { LinkId } from './types/ids'
export type LinkId = number
const layoutMutations = useLayoutMutations()
export type SerialisedLLinkArray = [
id: LinkId,

View File

@@ -2,9 +2,8 @@ import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMuta
import { LayoutSource } from '@/renderer/core/layout/types'
import { LGraphBadge } from './LGraphBadge'
import type { LGraphNode, NodeId } from './LGraphNode'
import type { LGraphNode } from './LGraphNode'
import { LLink } from './LLink'
import type { LinkId } from './LLink'
import type {
CanvasColour,
INodeInputSlot,
@@ -17,11 +16,12 @@ import type {
ReadonlyLinkNetwork
} from './interfaces'
import { distance, isPointInRect } from './measure'
import type { LinkId, NodeId, RerouteId } from './types/ids'
import type { Serialisable, SerialisableReroute } from './types/serialisation'
const layoutMutations = useLayoutMutations()
export type { RerouteId } from './types/ids'
export type RerouteId = number
const layoutMutations = useLayoutMutations()
/** The input or output slot that an incomplete reroute link is connected to. */
export interface FloatingRerouteSlot {

View File

@@ -3,15 +3,36 @@ import type { CanvasPointerEvent } from '@/lib/litegraph/src/types/events'
import type { TWidgetValue } from '@/lib/litegraph/src/types/widgets'
import type { ContextMenu } from './ContextMenu'
import type { LGraphNode, NodeId } from './LGraphNode'
import type { LLink, LinkId } from './LLink'
import type { Reroute, RerouteId } from './Reroute'
import type { LGraphNode } from './LGraphNode'
import type { LLink } from './LLink'
import type { Reroute } from './Reroute'
import type { SubgraphInput } from './subgraph/SubgraphInput'
import type { SubgraphInputNode } from './subgraph/SubgraphInputNode'
import type { SubgraphOutputNode } from './subgraph/SubgraphOutputNode'
import type { LinkDirection, RenderShape } from './types/globalEnums'
import type {
CanvasColour,
LinkId,
NodeId,
Point,
ReadOnlyRect,
RerouteId,
Size
} from './types/index'
import type { IBaseWidget } from './types/widgets'
export type {
CanvasColour,
LinkId,
NodeId,
Point,
ReadOnlyRect,
ReadOnlyTypedArray,
Rect,
RerouteId,
Size
} from './types/index'
export type Dictionary<T> = { [key: string]: T }
/** Allows all properties to be null. The same as `Partial<T>`, but adds null instead of undefined. */
@@ -46,8 +67,6 @@ export type SharedIntersection<T1, T2> = {
[P in keyof T2 as P extends keyof T1 ? P : never]: T2[P]
}
export type CanvasColour = string | CanvasGradient | CanvasPattern
/**
* Any object that has a {@link boundingRect}.
*/
@@ -226,27 +245,6 @@ export interface IFoundSlot extends IInputOrOutput {
link_pos: Point
}
/** A point represented as `[x, y]` co-ordinates */
export type Point = [x: number, y: number]
/** A size represented as `[width, height]` */
export type Size = [width: number, height: number]
/** A rectangle starting at top-left coordinates `[x, y, width, height]` */
export type Rect =
| [x: number, y: number, width: number, height: number]
| Float64Array
/** A rectangle starting at top-left coordinates `[x, y, width, height]` that will not be modified */
export type ReadOnlyRect =
| readonly [x: number, y: number, width: number, height: number]
| ReadOnlyTypedArray<Float64Array>
export type ReadOnlyTypedArray<T extends Float64Array> = Omit<
Readonly<T>,
'fill' | 'copyWithin' | 'reverse' | 'set' | 'sort' | 'subarray'
>
/** Union of property names that are of type Match */
type KeysOfType<T, Match> = Exclude<
{ [P in keyof T]: T[P] extends Match ? P : never }[keyof T],

View File

@@ -0,0 +1,29 @@
/** A point represented as `[x, y]` co-ordinates */
export type Point = [x: number, y: number]
/** A size represented as `[width, height]` */
export type Size = [width: number, height: number]
/** A rectangle starting at top-left coordinates `[x, y, width, height]` */
export type Rect =
| [x: number, y: number, width: number, height: number]
| Float64Array
/** A rectangle starting at top-left coordinates `[x, y, width, height]` that will not be modified */
export type ReadOnlyRect =
| readonly [x: number, y: number, width: number, height: number]
| ReadOnlyTypedArray<Float64Array>
export type ReadOnlyTypedArray<T extends Float64Array> = Omit<
Readonly<T>,
'fill' | 'copyWithin' | 'reverse' | 'set' | 'sort' | 'subarray'
>
/** A 2D vector as `[x, y]` */
export type Vector2 = [x: number, y: number]
/** A 4D vector as `[x, y, z, w]` */
export type Vector4 = [x: number, y: number, z: number, w: number]
/** Margin values as `[top, right, bottom, left]` */
export type Margin = [top: number, right: number, bottom: number, left: number]

View File

@@ -0,0 +1,8 @@
/** Unique identifier for a node in the graph */
export type NodeId = number | string
/** Unique identifier for a link between nodes */
export type LinkId = number
/** Unique identifier for a reroute point on a link */
export type RerouteId = number

View File

@@ -0,0 +1,14 @@
export type {
Margin,
Point,
ReadOnlyRect,
ReadOnlyTypedArray,
Rect,
Size,
Vector2,
Vector4
} from './geometry'
export type { LinkId, NodeId, RerouteId } from './ids'
export type { CanvasColour, INodeSlotBase, ISlotType } from './slots'

View File

@@ -0,0 +1,37 @@
import type { LinkDirection, RenderShape } from './globalEnums'
import type { Point, ReadOnlyRect } from './geometry'
/** Union type for slot connection types - can be a string name or a numeric type code */
export type ISlotType = string | number
/** Colour type for canvas elements */
export type CanvasColour = string | CanvasGradient | CanvasPattern
/**
* Base interface for node slots (inputs and outputs).
* Contains common properties shared between input and output slots.
*/
export interface INodeSlotBase {
/** The unique name of the slot */
name: string
/** The type of the slot, used for connection compatibility */
type: ISlotType
/** Direction of the link connection */
dir?: LinkDirection
/** Whether the slot can be removed */
removable?: boolean
/** Visual shape of the slot */
shape?: RenderShape
/** Color when disconnected */
color_off?: CanvasColour
/** Color when connected */
color_on?: CanvasColour
/** Whether the slot is locked from modifications */
locked?: boolean
/** Whether the slot name is locked from changes */
nameLocked?: boolean
/** Position of the slot relative to the node */
pos?: Point
/** Bounding rectangle of the slot for hit detection */
boundingRect: ReadOnlyRect
}