@codebolt/litegraph 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +161 -0
  3. package/dist/CanvasPointer.d.ts +120 -0
  4. package/dist/ContextMenu.d.ts +41 -0
  5. package/dist/CurveEditor.d.ts +18 -0
  6. package/dist/DragAndScale.d.ts +67 -0
  7. package/dist/LGraph.d.ts +407 -0
  8. package/dist/LGraphBadge.d.ts +33 -0
  9. package/dist/LGraphButton.d.ts +27 -0
  10. package/dist/LGraphCanvas.d.ts +772 -0
  11. package/dist/LGraphGroup.d.ts +81 -0
  12. package/dist/LGraphIcon.d.ts +22 -0
  13. package/dist/LGraphNode.d.ts +883 -0
  14. package/dist/LLink.d.ts +194 -0
  15. package/dist/LiteGraphGlobal.d.ts +360 -0
  16. package/dist/MapProxyHandler.d.ts +13 -0
  17. package/dist/Reroute.d.ts +185 -0
  18. package/dist/canvas/FloatingRenderLink.d.ts +55 -0
  19. package/dist/canvas/InputIndicators.d.ts +45 -0
  20. package/dist/canvas/LinkConnector.d.ts +165 -0
  21. package/dist/canvas/MovingInputLink.d.ts +34 -0
  22. package/dist/canvas/MovingLinkBase.d.ts +55 -0
  23. package/dist/canvas/MovingOutputLink.d.ts +30 -0
  24. package/dist/canvas/RenderLink.d.ts +39 -0
  25. package/dist/canvas/ToInputFromIoNodeLink.d.ts +37 -0
  26. package/dist/canvas/ToInputRenderLink.d.ts +35 -0
  27. package/dist/canvas/ToOutputFromIoNodeLink.d.ts +33 -0
  28. package/dist/canvas/ToOutputFromRerouteLink.d.ts +15 -0
  29. package/dist/canvas/ToOutputRenderLink.d.ts +32 -0
  30. package/dist/canvas/measureSlots.d.ts +22 -0
  31. package/dist/constants.d.ts +9 -0
  32. package/dist/css/litegraph.css +638 -0
  33. package/dist/draw.d.ts +65 -0
  34. package/dist/infrastructure/ConstrainedSize.d.ts +27 -0
  35. package/dist/infrastructure/CustomEventTarget.d.ts +72 -0
  36. package/dist/infrastructure/InvalidLinkError.d.ts +3 -0
  37. package/dist/infrastructure/LGraphCanvasEventMap.d.ts +41 -0
  38. package/dist/infrastructure/LGraphEventMap.d.ts +43 -0
  39. package/dist/infrastructure/LinkConnectorEventMap.d.ts +47 -0
  40. package/dist/infrastructure/NullGraphError.d.ts +3 -0
  41. package/dist/infrastructure/Rectangle.d.ts +163 -0
  42. package/dist/infrastructure/RecursionError.d.ts +6 -0
  43. package/dist/infrastructure/SlotIndexError.d.ts +3 -0
  44. package/dist/infrastructure/SubgraphEventMap.d.ts +49 -0
  45. package/dist/infrastructure/SubgraphInputEventMap.d.ts +13 -0
  46. package/dist/interfaces.d.ts +388 -0
  47. package/dist/litegraph.d.ts +95 -0
  48. package/dist/litegraph.es.js +17613 -0
  49. package/dist/litegraph.es.js.map +1 -0
  50. package/dist/litegraph.umd.js +3 -0
  51. package/dist/litegraph.umd.js.map +1 -0
  52. package/dist/measure.d.ts +168 -0
  53. package/dist/node/NodeInputSlot.d.ts +20 -0
  54. package/dist/node/NodeOutputSlot.d.ts +18 -0
  55. package/dist/node/NodeSlot.d.ts +35 -0
  56. package/dist/node/SlotBase.d.ts +27 -0
  57. package/dist/node/slotUtils.d.ts +17 -0
  58. package/dist/polyfills.d.ts +1 -0
  59. package/dist/strings.d.ts +22 -0
  60. package/dist/subgraph/EmptySubgraphInput.d.ts +15 -0
  61. package/dist/subgraph/EmptySubgraphOutput.d.ts +15 -0
  62. package/dist/subgraph/ExecutableNodeDTO.d.ts +96 -0
  63. package/dist/subgraph/Subgraph.d.ts +65 -0
  64. package/dist/subgraph/SubgraphIONodeBase.d.ts +80 -0
  65. package/dist/subgraph/SubgraphInput.d.ts +47 -0
  66. package/dist/subgraph/SubgraphInputNode.d.ts +33 -0
  67. package/dist/subgraph/SubgraphNode.d.ts +73 -0
  68. package/dist/subgraph/SubgraphOutput.d.ts +30 -0
  69. package/dist/subgraph/SubgraphOutputNode.d.ts +31 -0
  70. package/dist/subgraph/SubgraphSlotBase.d.ts +61 -0
  71. package/dist/subgraph/subgraphUtils.d.ts +77 -0
  72. package/dist/types/NodeLike.d.ts +7 -0
  73. package/dist/types/events.d.ts +64 -0
  74. package/dist/types/globalEnums.d.ts +130 -0
  75. package/dist/types/serialisation.d.ts +198 -0
  76. package/dist/types/utility.d.ts +11 -0
  77. package/dist/types/widgets.d.ts +209 -0
  78. package/dist/utils/arrange.d.ts +22 -0
  79. package/dist/utils/collections.d.ts +38 -0
  80. package/dist/utils/feedback.d.ts +7 -0
  81. package/dist/utils/object.d.ts +1 -0
  82. package/dist/utils/spaceDistribution.d.ts +11 -0
  83. package/dist/utils/textUtils.d.ts +9 -0
  84. package/dist/utils/type.d.ts +14 -0
  85. package/dist/utils/uuid.d.ts +13 -0
  86. package/dist/utils/widget.d.ts +7 -0
  87. package/dist/widgets/BaseSteppedWidget.d.ts +34 -0
  88. package/dist/widgets/BaseWidget.d.ts +125 -0
  89. package/dist/widgets/BooleanWidget.d.ts +9 -0
  90. package/dist/widgets/ButtonWidget.d.ts +16 -0
  91. package/dist/widgets/ComboWidget.d.ts +17 -0
  92. package/dist/widgets/KnobWidget.d.ts +20 -0
  93. package/dist/widgets/LegacyWidget.d.ts +14 -0
  94. package/dist/widgets/NumberWidget.d.ts +18 -0
  95. package/dist/widgets/SliderWidget.d.ts +20 -0
  96. package/dist/widgets/TextWidget.d.ts +13 -0
  97. package/dist/widgets/widgetMap.d.ts +50 -0
  98. package/package.json +76 -0
@@ -0,0 +1,33 @@
1
+ import { SubgraphInput } from './SubgraphInput';
2
+ import { SubgraphOutput } from './SubgraphOutput';
3
+ import { LinkConnector } from '../canvas/LinkConnector';
4
+ import { CanvasPointer } from '../CanvasPointer';
5
+ import { DefaultConnectionColors, INodeInputSlot, INodeOutputSlot, ISlotType, Positionable } from '../interfaces';
6
+ import { LGraphNode, NodeId } from '../LGraphNode';
7
+ import { RerouteId } from '../Reroute';
8
+ import { CanvasPointerEvent } from '../types/events';
9
+ import { NodeLike } from '../types/NodeLike';
10
+ import { LLink } from '../LLink';
11
+ import { EmptySubgraphInput } from './EmptySubgraphInput';
12
+ import { SubgraphIONodeBase } from './SubgraphIONodeBase';
13
+ export declare class SubgraphInputNode extends SubgraphIONodeBase<SubgraphInput> implements Positionable {
14
+ readonly id: NodeId;
15
+ readonly emptySlot: EmptySubgraphInput;
16
+ get slots(): SubgraphInput[];
17
+ get allSlots(): SubgraphInput[];
18
+ get slotAnchorX(): number;
19
+ onPointerDown(e: CanvasPointerEvent, pointer: CanvasPointer, linkConnector: LinkConnector): void;
20
+ /** @inheritdoc */
21
+ renameSlot(slot: SubgraphInput, name: string): void;
22
+ /** @inheritdoc */
23
+ removeSlot(slot: SubgraphInput): void;
24
+ canConnectTo(inputNode: NodeLike, input: INodeInputSlot, fromSlot: SubgraphInput): boolean;
25
+ connectSlots(fromSlot: SubgraphInput, inputNode: LGraphNode, input: INodeInputSlot, afterRerouteId: RerouteId | undefined): LLink;
26
+ connectByType(slot: number, target_node: LGraphNode, target_slotType: ISlotType, optsIn?: {
27
+ afterRerouteId?: RerouteId;
28
+ }): LLink | undefined;
29
+ findOutputSlot(name: string): SubgraphInput | undefined;
30
+ findOutputByType(type: ISlotType): SubgraphInput | undefined;
31
+ _disconnectNodeInput(node: LGraphNode, input: INodeInputSlot, link: LLink | undefined): void;
32
+ drawProtected(ctx: CanvasRenderingContext2D, colorContext: DefaultConnectionColors, fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput, editorAlpha?: number): void;
33
+ }
@@ -0,0 +1,73 @@
1
+ import { ISubgraphInput } from '../interfaces';
2
+ import { BaseLGraph, LGraph } from '../LGraph';
3
+ import { GraphOrSubgraph, Subgraph } from './Subgraph';
4
+ import { ExportedSubgraphInstance } from '../types/serialisation';
5
+ import { IBaseWidget } from '../types/widgets';
6
+ import { UUID } from '../utils/uuid';
7
+ import { LGraphButton } from '../LGraphButton';
8
+ import { LGraphCanvas } from '../LGraphCanvas';
9
+ import { LGraphNode } from '../LGraphNode';
10
+ import { INodeInputSlot, ISlotType, NodeId } from '../litegraph';
11
+ import { LLink, ResolvedConnection } from '../LLink';
12
+ import { ExecutableLGraphNode, ExecutionId } from './ExecutableNodeDTO';
13
+ /**
14
+ * An instance of a {@link Subgraph}, displayed as a node on the containing (parent) graph.
15
+ */
16
+ export declare class SubgraphNode extends LGraphNode implements BaseLGraph {
17
+ #private;
18
+ /** The (sub)graph that contains this subgraph instance. */
19
+ readonly graph: GraphOrSubgraph;
20
+ /** The definition of this subgraph; how its nodes are configured, etc. */
21
+ readonly subgraph: Subgraph;
22
+ inputs: (INodeInputSlot & Partial<ISubgraphInput>)[];
23
+ readonly type: UUID;
24
+ readonly isVirtualNode: true;
25
+ get rootGraph(): LGraph;
26
+ get displayType(): string;
27
+ isSubgraphNode(): this is SubgraphNode;
28
+ widgets: IBaseWidget[];
29
+ constructor(
30
+ /** The (sub)graph that contains this subgraph instance. */
31
+ graph: GraphOrSubgraph,
32
+ /** The definition of this subgraph; how its nodes are configured, etc. */
33
+ subgraph: Subgraph, instanceData: ExportedSubgraphInstance);
34
+ onTitleButtonClick(button: LGraphButton, canvas: LGraphCanvas): void;
35
+ configure(info: ExportedSubgraphInstance): void;
36
+ _internalConfigureAfterSlots(): void;
37
+ /**
38
+ * Ensures the subgraph slot is in the params before adding the input as normal.
39
+ * @param name The name of the input slot.
40
+ * @param type The type of the input slot.
41
+ * @param inputProperties Properties that are directly assigned to the created input. Default: a new, empty object.
42
+ * @returns The new input slot.
43
+ * @remarks Assertion is required to instantiate empty generic POJO.
44
+ */
45
+ addInput<TInput extends Partial<ISubgraphInput>>(name: string, type: ISlotType, inputProperties?: TInput): INodeInputSlot & TInput;
46
+ getInputLink(slot: number): LLink | null;
47
+ /**
48
+ * Finds the internal links connected to the given input slot inside the subgraph, and resolves the nodes / slots.
49
+ * @param slot The slot index
50
+ * @returns The resolved connections, or undefined if no input node is found.
51
+ * @remarks This is used to resolve the input links when dragging a link from a subgraph input slot.
52
+ */
53
+ resolveSubgraphInputLinks(slot: number): ResolvedConnection[];
54
+ /**
55
+ * Finds the internal link connected to the given output slot inside the subgraph, and resolves the nodes / slots.
56
+ * @param slot The slot index
57
+ * @returns The output node if found, otherwise undefined.
58
+ */
59
+ resolveSubgraphOutputLink(slot: number): ResolvedConnection | undefined;
60
+ /** @internal Used to flatten the subgraph before execution. */
61
+ getInnerNodes(
62
+ /** The set of computed node DTOs for this execution. */
63
+ executableNodes: Map<ExecutionId, ExecutableLGraphNode>,
64
+ /** The path of subgraph node IDs. */
65
+ subgraphNodePath?: readonly NodeId[],
66
+ /** Internal recursion param. The list of nodes to add to. */
67
+ nodes?: ExecutableLGraphNode[],
68
+ /** Internal recursion param. The set of visited nodes. */
69
+ visited?: Set<SubgraphNode>): ExecutableLGraphNode[];
70
+ removeWidgetByName(name: string): void;
71
+ ensureWidgetRemoved(widget: IBaseWidget): void;
72
+ onRemoved(): void;
73
+ }
@@ -0,0 +1,30 @@
1
+ import { SubgraphInput } from './SubgraphInput';
2
+ import { SubgraphOutputNode } from './SubgraphOutputNode';
3
+ import { INodeInputSlot, INodeOutputSlot, Point, ReadOnlyRect } from '../interfaces';
4
+ import { LGraphNode } from '../LGraphNode';
5
+ import { RerouteId } from '../Reroute';
6
+ import { LLink } from '../LLink';
7
+ import { SubgraphSlot } from './SubgraphSlotBase';
8
+ /**
9
+ * An output "slot" from a subgraph to a parent graph.
10
+ *
11
+ * IMPORTANT: A subgraph "output" is both an output AND an input. It creates an extra link connection point between
12
+ * a parent graph and a subgraph, so is conceptually similar to a reroute.
13
+ *
14
+ * This can be a little confusing, but is easier to visualise when imagining editing a subgraph.
15
+ * You have "Subgraph Outputs", because they go from inside the subgraph and out, but links to them come from "node outputs".
16
+ *
17
+ * Functionally, however, when editing a subgraph, that "subgraph output" is the "target" or "input side" of a link.
18
+ */
19
+ export declare class SubgraphOutput extends SubgraphSlot {
20
+ parent: SubgraphOutputNode;
21
+ connect(slot: INodeOutputSlot, node: LGraphNode, afterRerouteId?: RerouteId): LLink | undefined;
22
+ get labelPos(): Point;
23
+ arrange(rect: ReadOnlyRect): void;
24
+ /**
25
+ * Checks if this slot is a valid target for a connection from the given slot.
26
+ * For SubgraphOutput (which acts as an input inside the subgraph),
27
+ * the fromSlot should be an output slot.
28
+ */
29
+ isValidTarget(fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput): boolean;
30
+ }
@@ -0,0 +1,31 @@
1
+ import { SubgraphInput } from './SubgraphInput';
2
+ import { SubgraphOutput } from './SubgraphOutput';
3
+ import { LinkConnector } from '../canvas/LinkConnector';
4
+ import { CanvasPointer } from '../CanvasPointer';
5
+ import { DefaultConnectionColors, INodeInputSlot, INodeOutputSlot, ISlotType, Positionable } from '../interfaces';
6
+ import { LGraphNode, NodeId } from '../LGraphNode';
7
+ import { LLink } from '../LLink';
8
+ import { RerouteId } from '../Reroute';
9
+ import { CanvasPointerEvent } from '../types/events';
10
+ import { NodeLike } from '../types/NodeLike';
11
+ import { SubgraphIO } from '../types/serialisation';
12
+ import { EmptySubgraphOutput } from './EmptySubgraphOutput';
13
+ import { SubgraphIONodeBase } from './SubgraphIONodeBase';
14
+ export declare class SubgraphOutputNode extends SubgraphIONodeBase<SubgraphOutput> implements Positionable {
15
+ readonly id: NodeId;
16
+ readonly emptySlot: EmptySubgraphOutput;
17
+ get slots(): SubgraphOutput[];
18
+ get allSlots(): SubgraphOutput[];
19
+ get slotAnchorX(): number;
20
+ onPointerDown(e: CanvasPointerEvent, pointer: CanvasPointer, linkConnector: LinkConnector): void;
21
+ /** @inheritdoc */
22
+ renameSlot(slot: SubgraphOutput, name: string): void;
23
+ /** @inheritdoc */
24
+ removeSlot(slot: SubgraphOutput): void;
25
+ canConnectTo(outputNode: NodeLike, fromSlot: SubgraphOutput, output: INodeOutputSlot | SubgraphIO): boolean;
26
+ connectByTypeOutput(slot: number, target_node: LGraphNode, target_slotType: ISlotType, optsIn?: {
27
+ afterRerouteId?: RerouteId;
28
+ }): LLink | undefined;
29
+ findInputByType(type: ISlotType): SubgraphOutput | undefined;
30
+ drawProtected(ctx: CanvasRenderingContext2D, colorContext: DefaultConnectionColors, fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput, editorAlpha?: number): void;
31
+ }
@@ -0,0 +1,61 @@
1
+ import { SubgraphInput } from './SubgraphInput';
2
+ import { SubgraphInputNode } from './SubgraphInputNode';
3
+ import { SubgraphOutput } from './SubgraphOutput';
4
+ import { SubgraphOutputNode } from './SubgraphOutputNode';
5
+ import { DefaultConnectionColors, Hoverable, INodeInputSlot, INodeOutputSlot, Point, ReadOnlyRect, ReadOnlySize } from '../interfaces';
6
+ import { LGraphNode } from '../LGraphNode';
7
+ import { LinkId, LLink } from '../LLink';
8
+ import { RerouteId } from '../Reroute';
9
+ import { CanvasPointerEvent } from '../types/events';
10
+ import { Serialisable, SubgraphIO } from '../types/serialisation';
11
+ import { ConstrainedSize } from '../infrastructure/ConstrainedSize';
12
+ import { Rectangle } from '../infrastructure/Rectangle';
13
+ import { SlotBase } from '../node/SlotBase';
14
+ import { UUID } from '../utils/uuid';
15
+ export interface SubgraphSlotDrawOptions {
16
+ ctx: CanvasRenderingContext2D;
17
+ colorContext: DefaultConnectionColors;
18
+ lowQuality?: boolean;
19
+ fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput;
20
+ editorAlpha?: number;
21
+ }
22
+ /** Shared base class for the slots used on Subgraph . */
23
+ export declare abstract class SubgraphSlot extends SlotBase implements SubgraphIO, Hoverable, Serialisable<SubgraphIO> {
24
+ #private;
25
+ static get defaultHeight(): number;
26
+ readonly measurement: ConstrainedSize;
27
+ readonly id: UUID;
28
+ readonly parent: SubgraphInputNode | SubgraphOutputNode;
29
+ type: string;
30
+ readonly linkIds: LinkId[];
31
+ readonly boundingRect: Rectangle;
32
+ get pos(): Point;
33
+ set pos(value: Point);
34
+ /** Whether this slot is connected to another slot. */
35
+ get isConnected(): boolean;
36
+ /** The display name of this slot. */
37
+ get displayName(): string;
38
+ abstract get labelPos(): Point;
39
+ constructor(slot: SubgraphIO, parent: SubgraphInputNode | SubgraphOutputNode);
40
+ isPointerOver: boolean;
41
+ containsPoint(point: Point): boolean;
42
+ onPointerMove(e: CanvasPointerEvent): void;
43
+ getLinks(): LLink[];
44
+ decrementSlots(inputsOrOutputs: "inputs" | "outputs"): void;
45
+ measure(): ReadOnlySize;
46
+ abstract arrange(rect: ReadOnlyRect): void;
47
+ abstract connect(slot: INodeInputSlot | INodeOutputSlot, node: LGraphNode, afterRerouteId?: RerouteId): LLink | undefined;
48
+ /**
49
+ * Disconnects all links connected to this slot.
50
+ */
51
+ disconnect(): void;
52
+ /**
53
+ * Checks if this slot is a valid target for a connection from the given slot.
54
+ * @param fromSlot The slot that is being dragged to connect to this slot.
55
+ * @returns true if the connection is valid, false otherwise.
56
+ */
57
+ abstract isValidTarget(fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput): boolean;
58
+ /** @remarks Leaves the context dirty. */
59
+ draw({ ctx, colorContext, lowQuality, fromSlot, editorAlpha }: SubgraphSlotDrawOptions): void;
60
+ asSerialisable(): SubgraphIO;
61
+ }
@@ -0,0 +1,77 @@
1
+ import { GraphOrSubgraph } from './Subgraph';
2
+ import { SubgraphInput } from './SubgraphInput';
3
+ import { SubgraphOutput } from './SubgraphOutput';
4
+ import { INodeInputSlot, INodeOutputSlot, Positionable } from '../interfaces';
5
+ import { LGraph } from '../LGraph';
6
+ import { ISerialisedNode, SerialisableLLink, SubgraphIO } from '../types/serialisation';
7
+ import { UUID } from '../utils/uuid';
8
+ import { LGraphGroup } from '../LGraphGroup';
9
+ import { LGraphNode } from '../LGraphNode';
10
+ import { LLink, ResolvedConnection } from '../LLink';
11
+ import { Reroute } from '../Reroute';
12
+ import { SubgraphInputNode } from './SubgraphInputNode';
13
+ import { SubgraphOutputNode } from './SubgraphOutputNode';
14
+ export interface FilteredItems {
15
+ nodes: Set<LGraphNode>;
16
+ reroutes: Set<Reroute>;
17
+ groups: Set<LGraphGroup>;
18
+ subgraphInputNodes: Set<SubgraphInputNode>;
19
+ subgraphOutputNodes: Set<SubgraphOutputNode>;
20
+ unknown: Set<Positionable>;
21
+ }
22
+ export declare function splitPositionables(items: Iterable<Positionable>): FilteredItems;
23
+ interface BoundaryLinks {
24
+ boundaryLinks: LLink[];
25
+ boundaryFloatingLinks: LLink[];
26
+ internalLinks: LLink[];
27
+ boundaryInputLinks: LLink[];
28
+ boundaryOutputLinks: LLink[];
29
+ }
30
+ export declare function getBoundaryLinks(graph: LGraph, items: Set<Positionable>): BoundaryLinks;
31
+ export declare function multiClone(nodes: Iterable<LGraphNode>): ISerialisedNode[];
32
+ /**
33
+ * Groups resolved connections by output object. If the output is nullish, the connection will be in its own group.
34
+ * @param resolvedConnections The resolved connections to group
35
+ * @returns A map of grouped connections.
36
+ */
37
+ export declare function groupResolvedByOutput(resolvedConnections: ResolvedConnection[]): Map<SubgraphIO | INodeOutputSlot | object, ResolvedConnection[]>;
38
+ export declare function mapSubgraphInputsAndLinks(resolvedInputLinks: ResolvedConnection[], links: SerialisableLLink[]): SubgraphIO[];
39
+ /**
40
+ * Clones the output slots, and updates existing links, when converting items to a subgraph.
41
+ * @param resolvedOutputLinks The resolved output links.
42
+ * @param links The links to add to the subgraph.
43
+ * @returns The subgraph output slots.
44
+ */
45
+ export declare function mapSubgraphOutputsAndLinks(resolvedOutputLinks: ResolvedConnection[], links: SerialisableLLink[]): SubgraphIO[];
46
+ /**
47
+ * Collects all subgraph IDs used directly in a single graph (non-recursive).
48
+ * @param graph The graph to check for subgraph nodes
49
+ * @returns Set of subgraph IDs used in this graph
50
+ */
51
+ export declare function getDirectSubgraphIds(graph: GraphOrSubgraph): Set<UUID>;
52
+ /**
53
+ * Collects all subgraph IDs referenced in a graph hierarchy using BFS.
54
+ * @param rootGraph The graph to start from
55
+ * @param subgraphRegistry Map of all available subgraphs
56
+ * @returns Set of all subgraph IDs found
57
+ */
58
+ export declare function findUsedSubgraphIds(rootGraph: GraphOrSubgraph, subgraphRegistry: Map<UUID, GraphOrSubgraph>): Set<UUID>;
59
+ /**
60
+ * Type guard to check if a slot is a SubgraphInput.
61
+ * @param slot The slot to check
62
+ * @returns true if the slot is a SubgraphInput
63
+ */
64
+ export declare function isSubgraphInput(slot: unknown): slot is SubgraphInput;
65
+ /**
66
+ * Type guard to check if a slot is a SubgraphOutput.
67
+ * @param slot The slot to check
68
+ * @returns true if the slot is a SubgraphOutput
69
+ */
70
+ export declare function isSubgraphOutput(slot: unknown): slot is SubgraphOutput;
71
+ /**
72
+ * Type guard to check if a slot is a regular node slot (INodeInputSlot or INodeOutputSlot).
73
+ * @param slot The slot to check
74
+ * @returns true if the slot is a regular node slot
75
+ */
76
+ export declare function isNodeSlot(slot: unknown): slot is INodeInputSlot | INodeOutputSlot;
77
+ export {};
@@ -0,0 +1,7 @@
1
+ import { INodeInputSlot, INodeOutputSlot } from '../interfaces';
2
+ import { NodeId } from '../LGraphNode';
3
+ import { SubgraphIO } from './serialisation';
4
+ export interface NodeLike {
5
+ id: NodeId;
6
+ canConnectTo(node: NodeLike, toSlot: INodeInputSlot | SubgraphIO, fromSlot: INodeOutputSlot | SubgraphIO): boolean;
7
+ }
@@ -0,0 +1,64 @@
1
+ import { LGraphGroup } from '../LGraphGroup';
2
+ import { LGraphNode } from '../LGraphNode';
3
+ import { LinkReleaseContextExtended } from '../litegraph';
4
+ /** For Canvas*Event - adds graph space co-ordinates (property names are shipped) */
5
+ export interface ICanvasPosition {
6
+ /** X co-ordinate of the event, in graph space (NOT canvas space) */
7
+ canvasX: number;
8
+ /** Y co-ordinate of the event, in graph space (NOT canvas space) */
9
+ canvasY: number;
10
+ }
11
+ /** For Canvas*Event */
12
+ export interface IDeltaPosition {
13
+ deltaX: number;
14
+ deltaY: number;
15
+ }
16
+ /**
17
+ * Workaround for Firefox returning 0 on offsetX/Y props
18
+ * See https://github.com/Comfy-Org/litegraph.js/issues/403 for details
19
+ */
20
+ export interface IOffsetWorkaround {
21
+ /** See {@link MouseEvent.offsetX}. This workaround is required (2024-12-31) to support Firefox, which always returns 0 */
22
+ safeOffsetX: number;
23
+ /** See {@link MouseEvent.offsetY}. This workaround is required (2024-12-31) to support Firefox, which always returns 0 */
24
+ safeOffsetY: number;
25
+ }
26
+ /** All properties added when converting a pointer event to a CanvasPointerEvent (via {@link LGraphCanvas.adjustMouseEvent}). */
27
+ export type CanvasPointerExtensions = ICanvasPosition & IDeltaPosition & IOffsetWorkaround;
28
+ interface LegacyMouseEvent {
29
+ /** @deprecated Part of DragAndScale mouse API - incomplete / not maintained */
30
+ dragging?: boolean;
31
+ click_time?: number;
32
+ }
33
+ /** PointerEvent with canvasX/Y and deltaX/Y properties */
34
+ export interface CanvasPointerEvent extends PointerEvent, CanvasMouseEvent {
35
+ }
36
+ /** MouseEvent with canvasX/Y and deltaX/Y properties */
37
+ export interface CanvasMouseEvent extends MouseEvent, Readonly<CanvasPointerExtensions>, LegacyMouseEvent {
38
+ }
39
+ /** DragEvent with canvasX/Y and deltaX/Y properties */
40
+ export interface CanvasDragEvent extends DragEvent, CanvasPointerExtensions {
41
+ }
42
+ export type CanvasEventDetail = GenericEventDetail | GroupDoubleClickEventDetail | NodeDoubleClickEventDetail | EmptyDoubleClickEventDetail | EmptyReleaseEventDetail;
43
+ export interface GenericEventDetail {
44
+ subType: "before-change" | "after-change";
45
+ }
46
+ export interface OriginalEvent {
47
+ originalEvent: CanvasPointerEvent;
48
+ }
49
+ export interface EmptyReleaseEventDetail extends OriginalEvent {
50
+ subType: "empty-release";
51
+ linkReleaseContext: LinkReleaseContextExtended;
52
+ }
53
+ export interface EmptyDoubleClickEventDetail extends OriginalEvent {
54
+ subType: "empty-double-click";
55
+ }
56
+ export interface GroupDoubleClickEventDetail extends OriginalEvent {
57
+ subType: "group-double-click";
58
+ group: LGraphGroup;
59
+ }
60
+ export interface NodeDoubleClickEventDetail extends OriginalEvent {
61
+ subType: "node-double-click";
62
+ node: LGraphNode;
63
+ }
64
+ export {};
@@ -0,0 +1,130 @@
1
+ /** Node slot type - input or output */
2
+ export declare enum NodeSlotType {
3
+ INPUT = 1,
4
+ OUTPUT = 2
5
+ }
6
+ /** Shape that an object will render as - used by nodes and slots */
7
+ export declare enum RenderShape {
8
+ /** Rectangle with square corners */
9
+ BOX = 1,
10
+ /** Rounded rectangle */
11
+ ROUND = 2,
12
+ /** Circle is circle */
13
+ CIRCLE = 3,
14
+ /** Two rounded corners: top left & bottom right */
15
+ CARD = 4,
16
+ /** Slot shape: Arrow */
17
+ ARROW = 5,
18
+ /** Slot shape: Grid */
19
+ GRID = 6,
20
+ /** Slot shape: Hollow circle */
21
+ HollowCircle = 7
22
+ }
23
+ /** Bit flags used to indicate what the pointer is currently hovering over. */
24
+ export declare enum CanvasItem {
25
+ /** No items / none */
26
+ Nothing = 0,
27
+ /** At least one node */
28
+ Node = 1,
29
+ /** At least one group */
30
+ Group = 2,
31
+ /** A reroute (not its path) */
32
+ Reroute = 4,
33
+ /** The path of a link */
34
+ Link = 8,
35
+ /** A reroute slot */
36
+ RerouteSlot = 32,
37
+ /** A subgraph input or output node */
38
+ SubgraphIoNode = 64,
39
+ /** A subgraph input or output slot */
40
+ SubgraphIoSlot = 128
41
+ }
42
+ /** The direction that a link point will flow towards - e.g. horizontal outputs are right by default */
43
+ export declare enum LinkDirection {
44
+ NONE = 0,
45
+ UP = 1,
46
+ DOWN = 2,
47
+ LEFT = 3,
48
+ RIGHT = 4,
49
+ CENTER = 5
50
+ }
51
+ /** The path calculation that links follow */
52
+ export declare enum LinkRenderType {
53
+ HIDDEN_LINK = -1,
54
+ /** Juts out from the input & output a little @see LinkDirection, then a straight line between them */
55
+ STRAIGHT_LINK = 0,
56
+ /** 90° angles, clean and box-like */
57
+ LINEAR_LINK = 1,
58
+ /** Smooth curved links - default */
59
+ SPLINE_LINK = 2
60
+ }
61
+ /** The marker in the middle of a link */
62
+ export declare enum LinkMarkerShape {
63
+ /** Do not display markers */
64
+ None = 0,
65
+ /** Circles (default) */
66
+ Circle = 1,
67
+ /** Directional arrows */
68
+ Arrow = 2
69
+ }
70
+ export declare enum TitleMode {
71
+ NORMAL_TITLE = 0,
72
+ NO_TITLE = 1,
73
+ TRANSPARENT_TITLE = 2,
74
+ AUTOHIDE_TITLE = 3
75
+ }
76
+ export declare enum LGraphEventMode {
77
+ ALWAYS = 0,
78
+ ON_EVENT = 1,
79
+ NEVER = 2,
80
+ ON_TRIGGER = 3,
81
+ BYPASS = 4
82
+ }
83
+ export declare enum EaseFunction {
84
+ LINEAR = "linear",
85
+ EASE_IN_QUAD = "easeInQuad",
86
+ EASE_OUT_QUAD = "easeOutQuad",
87
+ EASE_IN_OUT_QUAD = "easeInOutQuad"
88
+ }
89
+ /** Bit flags used to indicate what the pointer is currently hovering over. */
90
+ export declare enum Alignment {
91
+ /** No items / none */
92
+ None = 0,
93
+ /** Top */
94
+ Top = 1,
95
+ /** Bottom */
96
+ Bottom = 2,
97
+ /** Vertical middle */
98
+ Middle = 4,
99
+ /** Left */
100
+ Left = 8,
101
+ /** Right */
102
+ Right = 16,
103
+ /** Horizontal centre */
104
+ Centre = 32,
105
+ /** Top left */
106
+ TopLeft = 9,
107
+ /** Top side, horizontally centred */
108
+ TopCentre = 33,
109
+ /** Top right */
110
+ TopRight = 17,
111
+ /** Left side, vertically centred */
112
+ MidLeft = 12,
113
+ /** Middle centre */
114
+ MidCentre = 36,
115
+ /** Right side, vertically centred */
116
+ MidRight = 20,
117
+ /** Bottom left */
118
+ BottomLeft = 10,
119
+ /** Bottom side, horizontally centred */
120
+ BottomCentre = 34,
121
+ /** Bottom right */
122
+ BottomRight = 18
123
+ }
124
+ /**
125
+ * Checks if the bitwise {@link flag} is set in the {@link flagSet}.
126
+ * @param flagSet The unknown set of flags - will be checked for the presence of {@link flag}
127
+ * @param flag The flag to check for
128
+ * @returns `true` if the flag is set, `false` otherwise.
129
+ */
130
+ export declare function hasFlag(flagSet: number, flag: number): boolean;