Add Subgraphs (#1000)

This commit is contained in:
filtered
2025-06-28 15:21:56 -07:00
committed by GitHub
parent 3e7f9627b4
commit bcaaa00770
54 changed files with 3662 additions and 462 deletions

13
src/types/NodeLike.ts Normal file
View File

@@ -0,0 +1,13 @@
import type { INodeInputSlot, INodeOutputSlot } from "@/interfaces"
import type { NodeId } from "@/LGraphNode"
import type { SubgraphIO } from "@/types/serialisation"
export interface NodeLike {
id: NodeId
canConnectTo(
node: NodeLike,
toSlot: INodeInputSlot | SubgraphIO,
fromSlot: INodeOutputSlot | SubgraphIO,
): boolean
}

View File

@@ -36,6 +36,10 @@ export enum CanvasItem {
Link = 1 << 3,
/** A reroute slot */
RerouteSlot = 1 << 5,
/** A subgraph input or output node */
SubgraphIoNode = 1 << 6,
/** A subgraph input or output slot */
SubgraphIoSlot = 1 << 7,
}
/** The direction that a link point will flow towards - e.g. horizontal outputs are right by default */
@@ -90,3 +94,49 @@ export enum EaseFunction {
EASE_OUT_QUAD = "easeOutQuad",
EASE_IN_OUT_QUAD = "easeInOutQuad",
}
/** Bit flags used to indicate what the pointer is currently hovering over. */
export enum Alignment {
/** No items / none */
None = 0,
/** Top */
Top = 1,
/** Bottom */
Bottom = 1 << 1,
/** Vertical middle */
Middle = 1 << 2,
/** Left */
Left = 1 << 3,
/** Right */
Right = 1 << 4,
/** Horizontal centre */
Centre = 1 << 5,
/** Top left */
TopLeft = Top | Left,
/** Top side, horizontally centred */
TopCentre = Top | Centre,
/** Top right */
TopRight = Top | Right,
/** Left side, vertically centred */
MidLeft = Left | Middle,
/** Middle centre */
MidCentre = Middle | Centre,
/** Right side, vertically centred */
MidRight = Right | Middle,
/** Bottom left */
BottomLeft = Bottom | Left,
/** Bottom side, horizontally centred */
BottomCentre = Bottom | Centre,
/** Bottom right */
BottomRight = Bottom | Right,
}
/**
* Checks if the bitwise {@link flag} is set in the {@link flagSet}.
* @param flagSet The unknown set of flags - will be checked for the presence of {@link flag}
* @param flag The flag to check for
* @returns `true` if the flag is set, `false` otherwise.
*/
export function hasFlag(flagSet: number, flag: number): boolean {
return (flagSet & flag) === flag
}

View File

@@ -33,6 +33,7 @@ export interface Serialisable<SerialisableObject> {
export interface BaseExportedGraph {
/** Unique graph ID. Automatically generated if not provided. */
id: UUID
/** The revision number of this graph. Not automatically incremented; intended for use by a downstream save function. */
revision: number
config?: LGraphConfig
/** Details of the appearance and location of subgraphs shown in this graph. Similar to */
@@ -135,7 +136,7 @@ export interface ExportedSubgraph extends SerialisableGraph {
}
/** Properties shared by subgraph and node I/O slots. */
type SubgraphIOShared = Omit<INodeSlot, "nameLocked" | "locked" | "removable" | "_floatingLinks">
type SubgraphIOShared = Omit<INodeSlot, "boundingRect" | "nameLocked" | "locked" | "removable" | "_floatingLinks">
/** Subgraph I/O slots */
export interface SubgraphIO extends SubgraphIOShared {