@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.
- package/LICENSE +19 -0
- package/README.md +161 -0
- package/dist/CanvasPointer.d.ts +120 -0
- package/dist/ContextMenu.d.ts +41 -0
- package/dist/CurveEditor.d.ts +18 -0
- package/dist/DragAndScale.d.ts +67 -0
- package/dist/LGraph.d.ts +407 -0
- package/dist/LGraphBadge.d.ts +33 -0
- package/dist/LGraphButton.d.ts +27 -0
- package/dist/LGraphCanvas.d.ts +772 -0
- package/dist/LGraphGroup.d.ts +81 -0
- package/dist/LGraphIcon.d.ts +22 -0
- package/dist/LGraphNode.d.ts +883 -0
- package/dist/LLink.d.ts +194 -0
- package/dist/LiteGraphGlobal.d.ts +360 -0
- package/dist/MapProxyHandler.d.ts +13 -0
- package/dist/Reroute.d.ts +185 -0
- package/dist/canvas/FloatingRenderLink.d.ts +55 -0
- package/dist/canvas/InputIndicators.d.ts +45 -0
- package/dist/canvas/LinkConnector.d.ts +165 -0
- package/dist/canvas/MovingInputLink.d.ts +34 -0
- package/dist/canvas/MovingLinkBase.d.ts +55 -0
- package/dist/canvas/MovingOutputLink.d.ts +30 -0
- package/dist/canvas/RenderLink.d.ts +39 -0
- package/dist/canvas/ToInputFromIoNodeLink.d.ts +37 -0
- package/dist/canvas/ToInputRenderLink.d.ts +35 -0
- package/dist/canvas/ToOutputFromIoNodeLink.d.ts +33 -0
- package/dist/canvas/ToOutputFromRerouteLink.d.ts +15 -0
- package/dist/canvas/ToOutputRenderLink.d.ts +32 -0
- package/dist/canvas/measureSlots.d.ts +22 -0
- package/dist/constants.d.ts +9 -0
- package/dist/css/litegraph.css +638 -0
- package/dist/draw.d.ts +65 -0
- package/dist/infrastructure/ConstrainedSize.d.ts +27 -0
- package/dist/infrastructure/CustomEventTarget.d.ts +72 -0
- package/dist/infrastructure/InvalidLinkError.d.ts +3 -0
- package/dist/infrastructure/LGraphCanvasEventMap.d.ts +41 -0
- package/dist/infrastructure/LGraphEventMap.d.ts +43 -0
- package/dist/infrastructure/LinkConnectorEventMap.d.ts +47 -0
- package/dist/infrastructure/NullGraphError.d.ts +3 -0
- package/dist/infrastructure/Rectangle.d.ts +163 -0
- package/dist/infrastructure/RecursionError.d.ts +6 -0
- package/dist/infrastructure/SlotIndexError.d.ts +3 -0
- package/dist/infrastructure/SubgraphEventMap.d.ts +49 -0
- package/dist/infrastructure/SubgraphInputEventMap.d.ts +13 -0
- package/dist/interfaces.d.ts +388 -0
- package/dist/litegraph.d.ts +95 -0
- package/dist/litegraph.es.js +17613 -0
- package/dist/litegraph.es.js.map +1 -0
- package/dist/litegraph.umd.js +3 -0
- package/dist/litegraph.umd.js.map +1 -0
- package/dist/measure.d.ts +168 -0
- package/dist/node/NodeInputSlot.d.ts +20 -0
- package/dist/node/NodeOutputSlot.d.ts +18 -0
- package/dist/node/NodeSlot.d.ts +35 -0
- package/dist/node/SlotBase.d.ts +27 -0
- package/dist/node/slotUtils.d.ts +17 -0
- package/dist/polyfills.d.ts +1 -0
- package/dist/strings.d.ts +22 -0
- package/dist/subgraph/EmptySubgraphInput.d.ts +15 -0
- package/dist/subgraph/EmptySubgraphOutput.d.ts +15 -0
- package/dist/subgraph/ExecutableNodeDTO.d.ts +96 -0
- package/dist/subgraph/Subgraph.d.ts +65 -0
- package/dist/subgraph/SubgraphIONodeBase.d.ts +80 -0
- package/dist/subgraph/SubgraphInput.d.ts +47 -0
- package/dist/subgraph/SubgraphInputNode.d.ts +33 -0
- package/dist/subgraph/SubgraphNode.d.ts +73 -0
- package/dist/subgraph/SubgraphOutput.d.ts +30 -0
- package/dist/subgraph/SubgraphOutputNode.d.ts +31 -0
- package/dist/subgraph/SubgraphSlotBase.d.ts +61 -0
- package/dist/subgraph/subgraphUtils.d.ts +77 -0
- package/dist/types/NodeLike.d.ts +7 -0
- package/dist/types/events.d.ts +64 -0
- package/dist/types/globalEnums.d.ts +130 -0
- package/dist/types/serialisation.d.ts +198 -0
- package/dist/types/utility.d.ts +11 -0
- package/dist/types/widgets.d.ts +209 -0
- package/dist/utils/arrange.d.ts +22 -0
- package/dist/utils/collections.d.ts +38 -0
- package/dist/utils/feedback.d.ts +7 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/spaceDistribution.d.ts +11 -0
- package/dist/utils/textUtils.d.ts +9 -0
- package/dist/utils/type.d.ts +14 -0
- package/dist/utils/uuid.d.ts +13 -0
- package/dist/utils/widget.d.ts +7 -0
- package/dist/widgets/BaseSteppedWidget.d.ts +34 -0
- package/dist/widgets/BaseWidget.d.ts +125 -0
- package/dist/widgets/BooleanWidget.d.ts +9 -0
- package/dist/widgets/ButtonWidget.d.ts +16 -0
- package/dist/widgets/ComboWidget.d.ts +17 -0
- package/dist/widgets/KnobWidget.d.ts +20 -0
- package/dist/widgets/LegacyWidget.d.ts +14 -0
- package/dist/widgets/NumberWidget.d.ts +18 -0
- package/dist/widgets/SliderWidget.d.ts +20 -0
- package/dist/widgets/TextWidget.d.ts +13 -0
- package/dist/widgets/widgetMap.d.ts +50 -0
- package/package.json +76 -0
|
@@ -0,0 +1,883 @@
|
|
|
1
|
+
import { DragAndScale } from './DragAndScale';
|
|
2
|
+
import { IDrawBoundingOptions } from './draw';
|
|
3
|
+
import { ReadOnlyRectangle } from './infrastructure/Rectangle';
|
|
4
|
+
import { ColorOption, CompassCorners, DefaultConnectionColors, Dictionary, IColorable, IContextMenuValue, IFoundSlot, INodeFlags, INodeInputSlot, INodeOutputSlot, INodeSlotContextItem, IPinnable, ISlotType, Point, Positionable, ReadOnlyPoint, ReadOnlyRect, Rect, Size } from './interfaces';
|
|
5
|
+
import { LGraph } from './LGraph';
|
|
6
|
+
import { Reroute, RerouteId } from './Reroute';
|
|
7
|
+
import { SubgraphInputNode } from './subgraph/SubgraphInputNode';
|
|
8
|
+
import { SubgraphOutputNode } from './subgraph/SubgraphOutputNode';
|
|
9
|
+
import { CanvasPointerEvent } from './types/events';
|
|
10
|
+
import { NodeLike } from './types/NodeLike';
|
|
11
|
+
import { ISerialisedNode, SubgraphIO } from './types/serialisation';
|
|
12
|
+
import { IBaseWidget, IWidgetOptions, TWidgetType, TWidgetValue } from './types/widgets';
|
|
13
|
+
import { BadgePosition, LGraphBadge } from './LGraphBadge';
|
|
14
|
+
import { LGraphButton, LGraphButtonOptions } from './LGraphButton';
|
|
15
|
+
import { LGraphCanvas } from './LGraphCanvas';
|
|
16
|
+
import { LGraphNodeConstructor, Subgraph, SubgraphNode } from './litegraph';
|
|
17
|
+
import { LLink } from './LLink';
|
|
18
|
+
import { LGraphEventMode, RenderShape, TitleMode } from './types/globalEnums';
|
|
19
|
+
import { WidgetTypeMap } from './widgets/widgetMap';
|
|
20
|
+
export type NodeId = number | string;
|
|
21
|
+
export type NodeProperty = string | number | boolean | object;
|
|
22
|
+
export interface INodePropertyInfo {
|
|
23
|
+
name: string;
|
|
24
|
+
type?: string;
|
|
25
|
+
default_value: NodeProperty | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface IMouseOverData {
|
|
28
|
+
inputId?: number;
|
|
29
|
+
outputId?: number;
|
|
30
|
+
overWidget?: IBaseWidget;
|
|
31
|
+
}
|
|
32
|
+
export interface ConnectByTypeOptions {
|
|
33
|
+
/** @deprecated Events */
|
|
34
|
+
createEventInCase?: boolean;
|
|
35
|
+
/** Allow our wildcard slot to connect to typed slots on remote node. Default: true */
|
|
36
|
+
wildcardToTyped?: boolean;
|
|
37
|
+
/** Allow our typed slot to connect to wildcard slots on remote node. Default: true */
|
|
38
|
+
typedToWildcard?: boolean;
|
|
39
|
+
/** The {@link Reroute.id} that the connection is being dragged from. */
|
|
40
|
+
afterRerouteId?: RerouteId;
|
|
41
|
+
}
|
|
42
|
+
/** Internal type used for type safety when implementing generic checks for inputs & outputs */
|
|
43
|
+
export interface IGenericLinkOrLinks {
|
|
44
|
+
links?: INodeOutputSlot["links"];
|
|
45
|
+
link?: INodeInputSlot["link"];
|
|
46
|
+
}
|
|
47
|
+
export interface FindFreeSlotOptions {
|
|
48
|
+
/** Slots matching these types will be ignored. Default: [] */
|
|
49
|
+
typesNotAccepted?: ISlotType[];
|
|
50
|
+
/** If true, the slot itself is returned instead of the index. Default: false */
|
|
51
|
+
returnObj?: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface DrawSlotsOptions {
|
|
54
|
+
fromSlot?: INodeInputSlot | INodeOutputSlot;
|
|
55
|
+
colorContext: DefaultConnectionColors;
|
|
56
|
+
editorAlpha: number;
|
|
57
|
+
lowQuality: boolean;
|
|
58
|
+
}
|
|
59
|
+
interface DrawWidgetsOptions {
|
|
60
|
+
lowQuality?: boolean;
|
|
61
|
+
editorAlpha?: number;
|
|
62
|
+
}
|
|
63
|
+
interface DrawTitleOptions {
|
|
64
|
+
scale: number;
|
|
65
|
+
title_height?: number;
|
|
66
|
+
low_quality?: boolean;
|
|
67
|
+
}
|
|
68
|
+
interface DrawTitleTextOptions extends DrawTitleOptions {
|
|
69
|
+
default_title_color: string;
|
|
70
|
+
}
|
|
71
|
+
interface DrawTitleBoxOptions extends DrawTitleOptions {
|
|
72
|
+
box_size?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface LGraphNode {
|
|
75
|
+
constructor: LGraphNodeConstructor;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Base class for all nodes
|
|
79
|
+
* @param title a name for the node
|
|
80
|
+
* @param type a type for the node
|
|
81
|
+
*/
|
|
82
|
+
export declare class LGraphNode implements NodeLike, Positionable, IPinnable, IColorable {
|
|
83
|
+
#private;
|
|
84
|
+
static title?: string;
|
|
85
|
+
static MAX_CONSOLE?: number;
|
|
86
|
+
static type?: string;
|
|
87
|
+
static category?: string;
|
|
88
|
+
static filter?: string;
|
|
89
|
+
static skip_list?: boolean;
|
|
90
|
+
static resizeHandleSize: number;
|
|
91
|
+
static resizeEdgeSize: number;
|
|
92
|
+
/** Default setting for {@link LGraphNode.connectInputToOutput}. @see {@link INodeFlags.keepAllLinksOnBypass} */
|
|
93
|
+
static keepAllLinksOnBypass: boolean;
|
|
94
|
+
/** The title text of the node. */
|
|
95
|
+
title: string;
|
|
96
|
+
/**
|
|
97
|
+
* The font style used to render the node's title text.
|
|
98
|
+
*/
|
|
99
|
+
get titleFontStyle(): string;
|
|
100
|
+
get innerFontStyle(): string;
|
|
101
|
+
get displayType(): string;
|
|
102
|
+
graph: LGraph | Subgraph | null;
|
|
103
|
+
id: NodeId;
|
|
104
|
+
type: string;
|
|
105
|
+
inputs: INodeInputSlot[];
|
|
106
|
+
outputs: INodeOutputSlot[];
|
|
107
|
+
properties: Dictionary<NodeProperty | undefined>;
|
|
108
|
+
properties_info: INodePropertyInfo[];
|
|
109
|
+
flags: INodeFlags;
|
|
110
|
+
widgets?: IBaseWidget[];
|
|
111
|
+
/**
|
|
112
|
+
* The amount of space available for widgets to grow into.
|
|
113
|
+
* @see {@link layoutWidgets}
|
|
114
|
+
*/
|
|
115
|
+
freeWidgetSpace?: number;
|
|
116
|
+
locked?: boolean;
|
|
117
|
+
/** Execution order, automatically computed during run @see {@link LGraph.computeExecutionOrder} */
|
|
118
|
+
order: number;
|
|
119
|
+
mode: LGraphEventMode;
|
|
120
|
+
last_serialization?: ISerialisedNode;
|
|
121
|
+
serialize_widgets?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* The overridden fg color used to render the node.
|
|
124
|
+
* @see {@link renderingColor}
|
|
125
|
+
*/
|
|
126
|
+
color?: string;
|
|
127
|
+
/**
|
|
128
|
+
* The overridden bg color used to render the node.
|
|
129
|
+
* @see {@link renderingBgColor}
|
|
130
|
+
*/
|
|
131
|
+
bgcolor?: string;
|
|
132
|
+
/**
|
|
133
|
+
* The overridden box color used to render the node.
|
|
134
|
+
* @see {@link renderingBoxColor}
|
|
135
|
+
*/
|
|
136
|
+
boxcolor?: string;
|
|
137
|
+
/** The fg color used to render the node. */
|
|
138
|
+
get renderingColor(): string;
|
|
139
|
+
/** The bg color used to render the node. */
|
|
140
|
+
get renderingBgColor(): string;
|
|
141
|
+
/** The box color used to render the node. */
|
|
142
|
+
get renderingBoxColor(): string;
|
|
143
|
+
/** @inheritdoc {@link IColorable.setColorOption} */
|
|
144
|
+
setColorOption(colorOption: ColorOption | null): void;
|
|
145
|
+
/** @inheritdoc {@link IColorable.getColorOption} */
|
|
146
|
+
getColorOption(): ColorOption | null;
|
|
147
|
+
/**
|
|
148
|
+
* The stroke styles that should be applied to the node.
|
|
149
|
+
*/
|
|
150
|
+
strokeStyles: Record<string, (this: LGraphNode) => IDrawBoundingOptions | undefined>;
|
|
151
|
+
/**
|
|
152
|
+
* The progress of node execution. Used to render a progress bar. Value between 0 and 1.
|
|
153
|
+
*/
|
|
154
|
+
progress?: number;
|
|
155
|
+
exec_version?: number;
|
|
156
|
+
action_call?: string;
|
|
157
|
+
execute_triggered?: number;
|
|
158
|
+
action_triggered?: number;
|
|
159
|
+
widgets_up?: boolean;
|
|
160
|
+
widgets_start_y?: number;
|
|
161
|
+
lostFocusAt?: number;
|
|
162
|
+
gotFocusAt?: number;
|
|
163
|
+
badges: (LGraphBadge | (() => LGraphBadge))[];
|
|
164
|
+
title_buttons: LGraphButton[];
|
|
165
|
+
badgePosition: BadgePosition;
|
|
166
|
+
onOutputRemoved?(this: LGraphNode, slot: number): void;
|
|
167
|
+
onInputRemoved?(this: LGraphNode, slot: number, input: INodeInputSlot): void;
|
|
168
|
+
/**
|
|
169
|
+
* The width of the node when collapsed.
|
|
170
|
+
* Updated by {@link LGraphCanvas.drawNode}
|
|
171
|
+
*/
|
|
172
|
+
_collapsed_width?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Called once at the start of every frame. Caller may change the values in {@link out}, which will be reflected in {@link boundingRect}.
|
|
175
|
+
* WARNING: Making changes to boundingRect via onBounding is poorly supported, and will likely result in strange behaviour.
|
|
176
|
+
*/
|
|
177
|
+
onBounding?(this: LGraphNode, out: Rect): void;
|
|
178
|
+
console?: string[];
|
|
179
|
+
_level?: number;
|
|
180
|
+
_shape?: RenderShape;
|
|
181
|
+
mouseOver?: IMouseOverData;
|
|
182
|
+
redraw_on_mouse?: boolean;
|
|
183
|
+
resizable?: boolean;
|
|
184
|
+
clonable?: boolean;
|
|
185
|
+
_relative_id?: number;
|
|
186
|
+
clip_area?: boolean;
|
|
187
|
+
ignore_remove?: boolean;
|
|
188
|
+
has_errors?: boolean;
|
|
189
|
+
removable?: boolean;
|
|
190
|
+
block_delete?: boolean;
|
|
191
|
+
selected?: boolean;
|
|
192
|
+
showAdvanced?: boolean;
|
|
193
|
+
comfyClass?: string;
|
|
194
|
+
isVirtualNode?: boolean;
|
|
195
|
+
applyToGraph?(extraLinks?: LLink[]): void;
|
|
196
|
+
isSubgraphNode(): this is SubgraphNode;
|
|
197
|
+
/**
|
|
198
|
+
* Rect describing the node area, including shadows and any protrusions.
|
|
199
|
+
* Determines if the node is visible. Calculated once at the start of every frame.
|
|
200
|
+
*/
|
|
201
|
+
get renderArea(): ReadOnlyRect;
|
|
202
|
+
/**
|
|
203
|
+
* Cached node position & area as `x, y, width, height`. Includes changes made by {@link onBounding}, if present.
|
|
204
|
+
*
|
|
205
|
+
* Determines the node hitbox and other rendering effects. Calculated once at the start of every frame.
|
|
206
|
+
*/
|
|
207
|
+
get boundingRect(): ReadOnlyRectangle;
|
|
208
|
+
/** The offset from {@link pos} to the top-left of {@link boundingRect}. */
|
|
209
|
+
get boundingOffset(): ReadOnlyPoint;
|
|
210
|
+
/** {@link pos} and {@link size} values are backed by this {@link Rect}. */
|
|
211
|
+
_posSize: Float32Array;
|
|
212
|
+
_pos: Point;
|
|
213
|
+
_size: Size;
|
|
214
|
+
get pos(): Point;
|
|
215
|
+
/** Node position does not necessarily correlate to the top-left corner. */
|
|
216
|
+
set pos(value: Point);
|
|
217
|
+
get size(): Size;
|
|
218
|
+
set size(value: Size);
|
|
219
|
+
/**
|
|
220
|
+
* The size of the node used for rendering.
|
|
221
|
+
*/
|
|
222
|
+
get renderingSize(): Size;
|
|
223
|
+
get shape(): RenderShape | undefined;
|
|
224
|
+
set shape(v: RenderShape | "default" | "box" | "round" | "circle" | "card");
|
|
225
|
+
/**
|
|
226
|
+
* The shape of the node used for rendering. @see {@link RenderShape}
|
|
227
|
+
*/
|
|
228
|
+
get renderingShape(): RenderShape;
|
|
229
|
+
get is_selected(): boolean | undefined;
|
|
230
|
+
set is_selected(value: boolean);
|
|
231
|
+
get title_mode(): TitleMode;
|
|
232
|
+
onConnectInput?(this: LGraphNode, target_slot: number, type: unknown, output: INodeOutputSlot | SubgraphIO, node: LGraphNode | SubgraphInputNode, slot: number): boolean;
|
|
233
|
+
onConnectOutput?(this: LGraphNode, slot: number, type: unknown, input: INodeInputSlot | SubgraphIO, target_node: number | LGraphNode | SubgraphOutputNode, target_slot: number): boolean;
|
|
234
|
+
onResize?(this: LGraphNode, size: Size): void;
|
|
235
|
+
onPropertyChanged?(this: LGraphNode, name: string, value: unknown, prev_value?: unknown): boolean;
|
|
236
|
+
/** Called for each connection that is created, updated, or removed. This includes "restored" connections when deserialising. */
|
|
237
|
+
onConnectionsChange?(this: LGraphNode, type: ISlotType, index: number, isConnected: boolean, link_info: LLink | null | undefined, inputOrOutput: INodeInputSlot | INodeOutputSlot | SubgraphIO): void;
|
|
238
|
+
onInputAdded?(this: LGraphNode, input: INodeInputSlot): void;
|
|
239
|
+
onOutputAdded?(this: LGraphNode, output: INodeOutputSlot): void;
|
|
240
|
+
onConfigure?(this: LGraphNode, serialisedNode: ISerialisedNode): void;
|
|
241
|
+
onSerialize?(this: LGraphNode, serialised: ISerialisedNode): any;
|
|
242
|
+
onExecute?(this: LGraphNode, param?: unknown, options?: {
|
|
243
|
+
action_call?: any;
|
|
244
|
+
}): void;
|
|
245
|
+
onAction?(this: LGraphNode, action: string, param: unknown, options: {
|
|
246
|
+
action_call?: string;
|
|
247
|
+
}): void;
|
|
248
|
+
onDrawBackground?(this: LGraphNode, ctx: CanvasRenderingContext2D): void;
|
|
249
|
+
onNodeCreated?(this: LGraphNode): void;
|
|
250
|
+
/**
|
|
251
|
+
* Callback invoked by {@link connect} to override the target slot index.
|
|
252
|
+
* Its return value overrides the target index selection.
|
|
253
|
+
* @param target_slot The current input slot index
|
|
254
|
+
* @param requested_slot The originally requested slot index - could be negative, or if using (deprecated) name search, a string
|
|
255
|
+
* @returns {number | null} If a number is returned, the connection will be made to that input index.
|
|
256
|
+
* If an invalid index or non-number (false, null, NaN etc) is returned, the connection will be cancelled.
|
|
257
|
+
*/
|
|
258
|
+
onBeforeConnectInput?(this: LGraphNode, target_slot: number, requested_slot?: number | string): number | false | null;
|
|
259
|
+
onShowCustomPanelInfo?(this: LGraphNode, panel: any): void;
|
|
260
|
+
onAddPropertyToPanel?(this: LGraphNode, pName: string, panel: any): boolean;
|
|
261
|
+
onWidgetChanged?(this: LGraphNode, name: string, value: unknown, old_value: unknown, w: IBaseWidget): void;
|
|
262
|
+
onDeselected?(this: LGraphNode): void;
|
|
263
|
+
onKeyUp?(this: LGraphNode, e: KeyboardEvent): void;
|
|
264
|
+
onKeyDown?(this: LGraphNode, e: KeyboardEvent): void;
|
|
265
|
+
onSelected?(this: LGraphNode): void;
|
|
266
|
+
getExtraMenuOptions?(this: LGraphNode, canvas: LGraphCanvas, options: (IContextMenuValue<unknown> | null)[]): (IContextMenuValue<unknown> | null)[];
|
|
267
|
+
getMenuOptions?(this: LGraphNode, canvas: LGraphCanvas): IContextMenuValue[];
|
|
268
|
+
onAdded?(this: LGraphNode, graph: LGraph): void;
|
|
269
|
+
onDrawCollapsed?(this: LGraphNode, ctx: CanvasRenderingContext2D, cavnas: LGraphCanvas): boolean;
|
|
270
|
+
onDrawForeground?(this: LGraphNode, ctx: CanvasRenderingContext2D, canvas: LGraphCanvas, canvasElement: HTMLCanvasElement): void;
|
|
271
|
+
onMouseLeave?(this: LGraphNode, e: CanvasPointerEvent): void;
|
|
272
|
+
/**
|
|
273
|
+
* Override the default slot menu options.
|
|
274
|
+
*/
|
|
275
|
+
getSlotMenuOptions?(this: LGraphNode, slot: IFoundSlot): IContextMenuValue[];
|
|
276
|
+
/**
|
|
277
|
+
* Add extra menu options to the slot context menu.
|
|
278
|
+
*/
|
|
279
|
+
getExtraSlotMenuOptions?(this: LGraphNode, slot: IFoundSlot): IContextMenuValue[];
|
|
280
|
+
onDropItem?(this: LGraphNode, event: Event): boolean;
|
|
281
|
+
onDropData?(this: LGraphNode, data: string | ArrayBuffer, filename: any, file: any): void;
|
|
282
|
+
onDropFile?(this: LGraphNode, file: any): void;
|
|
283
|
+
onInputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void;
|
|
284
|
+
onInputDblClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void;
|
|
285
|
+
onOutputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void;
|
|
286
|
+
onOutputDblClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void;
|
|
287
|
+
onGetPropertyInfo?(this: LGraphNode, property: string): any;
|
|
288
|
+
onNodeOutputAdd?(this: LGraphNode, value: unknown): void;
|
|
289
|
+
onNodeInputAdd?(this: LGraphNode, value: unknown): void;
|
|
290
|
+
onMenuNodeInputs?(this: LGraphNode, entries: (IContextMenuValue<INodeSlotContextItem> | null)[]): (IContextMenuValue<INodeSlotContextItem> | null)[];
|
|
291
|
+
onMenuNodeOutputs?(this: LGraphNode, entries: (IContextMenuValue<INodeSlotContextItem> | null)[]): (IContextMenuValue<INodeSlotContextItem> | null)[];
|
|
292
|
+
onMouseUp?(this: LGraphNode, e: CanvasPointerEvent, pos: Point): void;
|
|
293
|
+
onMouseEnter?(this: LGraphNode, e: CanvasPointerEvent): void;
|
|
294
|
+
/** Blocks drag if return value is truthy. @param pos Offset from {@link LGraphNode.pos}. */
|
|
295
|
+
onMouseDown?(this: LGraphNode, e: CanvasPointerEvent, pos: Point, canvas: LGraphCanvas): boolean;
|
|
296
|
+
/** @param pos Offset from {@link LGraphNode.pos}. */
|
|
297
|
+
onDblClick?(this: LGraphNode, e: CanvasPointerEvent, pos: Point, canvas: LGraphCanvas): void;
|
|
298
|
+
/** @param pos Offset from {@link LGraphNode.pos}. */
|
|
299
|
+
onNodeTitleDblClick?(this: LGraphNode, e: CanvasPointerEvent, pos: Point, canvas: LGraphCanvas): void;
|
|
300
|
+
onDrawTitle?(this: LGraphNode, ctx: CanvasRenderingContext2D): void;
|
|
301
|
+
onDrawTitleText?(this: LGraphNode, ctx: CanvasRenderingContext2D, title_height: number, size: Size, scale: number, title_text_font: string, selected?: boolean): void;
|
|
302
|
+
onDrawTitleBox?(this: LGraphNode, ctx: CanvasRenderingContext2D, title_height: number, size: Size, scale: number): void;
|
|
303
|
+
onDrawTitleBar?(this: LGraphNode, ctx: CanvasRenderingContext2D, title_height: number, size: Size, scale: number, fgcolor: any): void;
|
|
304
|
+
onRemoved?(this: LGraphNode): void;
|
|
305
|
+
onMouseMove?(this: LGraphNode, e: CanvasPointerEvent, pos: Point, arg2: LGraphCanvas): void;
|
|
306
|
+
onPropertyChange?(this: LGraphNode): void;
|
|
307
|
+
updateOutputData?(this: LGraphNode, origin_slot: number): void;
|
|
308
|
+
constructor(title: string, type?: string);
|
|
309
|
+
/** Internal callback for subgraph nodes. Do not implement externally. */
|
|
310
|
+
_internalConfigureAfterSlots?(): void;
|
|
311
|
+
/**
|
|
312
|
+
* configure a node from an object containing the serialized info
|
|
313
|
+
*/
|
|
314
|
+
configure(info: ISerialisedNode): void;
|
|
315
|
+
/**
|
|
316
|
+
* serialize the content
|
|
317
|
+
*/
|
|
318
|
+
serialize(): ISerialisedNode;
|
|
319
|
+
clone(): LGraphNode | null;
|
|
320
|
+
/**
|
|
321
|
+
* serialize and stringify
|
|
322
|
+
*/
|
|
323
|
+
toString(): string;
|
|
324
|
+
/**
|
|
325
|
+
* get the title string
|
|
326
|
+
*/
|
|
327
|
+
getTitle(): string;
|
|
328
|
+
/**
|
|
329
|
+
* sets the value of a property
|
|
330
|
+
* @param name
|
|
331
|
+
* @param value
|
|
332
|
+
*/
|
|
333
|
+
setProperty(name: string, value: TWidgetValue): void;
|
|
334
|
+
/**
|
|
335
|
+
* sets the output data
|
|
336
|
+
* @param slot
|
|
337
|
+
* @param data
|
|
338
|
+
*/
|
|
339
|
+
setOutputData(slot: number, data: number | string | boolean | {
|
|
340
|
+
toToolTip?(): string;
|
|
341
|
+
}): void;
|
|
342
|
+
/**
|
|
343
|
+
* sets the output data type, useful when you want to be able to overwrite the data type
|
|
344
|
+
*/
|
|
345
|
+
setOutputDataType(slot: number, type: ISlotType): void;
|
|
346
|
+
/**
|
|
347
|
+
* Retrieves the input data (data traveling through the connection) from one slot
|
|
348
|
+
* @param slot
|
|
349
|
+
* @param force_update if set to true it will force the connected node of this slot to output data into this link
|
|
350
|
+
* @returns data or if it is not connected returns undefined
|
|
351
|
+
*/
|
|
352
|
+
getInputData(slot: number, force_update?: boolean): unknown;
|
|
353
|
+
/**
|
|
354
|
+
* Retrieves the input data type (in case this supports multiple input types)
|
|
355
|
+
* @param slot
|
|
356
|
+
* @returns datatype in string format
|
|
357
|
+
*/
|
|
358
|
+
getInputDataType(slot: number): ISlotType | null;
|
|
359
|
+
/**
|
|
360
|
+
* Retrieves the input data from one slot using its name instead of slot number
|
|
361
|
+
* @param slot_name
|
|
362
|
+
* @param force_update if set to true it will force the connected node of this slot to output data into this link
|
|
363
|
+
* @returns data or if it is not connected returns null
|
|
364
|
+
*/
|
|
365
|
+
getInputDataByName(slot_name: string, force_update: boolean): unknown;
|
|
366
|
+
/**
|
|
367
|
+
* tells you if there is a connection in one input slot
|
|
368
|
+
* @param slot The 0-based index of the input to check
|
|
369
|
+
* @returns `true` if the input slot has a link ID (does not perform validation)
|
|
370
|
+
*/
|
|
371
|
+
isInputConnected(slot: number): boolean;
|
|
372
|
+
/**
|
|
373
|
+
* tells you info about an input connection (which node, type, etc)
|
|
374
|
+
* @returns object or null { link: id, name: string, type: string or 0 }
|
|
375
|
+
*/
|
|
376
|
+
getInputInfo(slot: number): INodeInputSlot | null;
|
|
377
|
+
/**
|
|
378
|
+
* Returns the link info in the connection of an input slot
|
|
379
|
+
* @returns object or null
|
|
380
|
+
*/
|
|
381
|
+
getInputLink(slot: number): LLink | null;
|
|
382
|
+
/**
|
|
383
|
+
* returns the node connected in the input slot
|
|
384
|
+
* @returns node or null
|
|
385
|
+
*/
|
|
386
|
+
getInputNode(slot: number): LGraphNode | null;
|
|
387
|
+
/**
|
|
388
|
+
* returns the value of an input with this name, otherwise checks if there is a property with that name
|
|
389
|
+
* @returns value
|
|
390
|
+
*/
|
|
391
|
+
getInputOrProperty(name: string): unknown;
|
|
392
|
+
/**
|
|
393
|
+
* tells you the last output data that went in that slot
|
|
394
|
+
* @returns object or null
|
|
395
|
+
*/
|
|
396
|
+
getOutputData(slot: number): unknown;
|
|
397
|
+
/**
|
|
398
|
+
* tells you info about an output connection (which node, type, etc)
|
|
399
|
+
* @returns object or null { name: string, type: string, links: [ ids of links in number ] }
|
|
400
|
+
*/
|
|
401
|
+
getOutputInfo(slot: number): INodeOutputSlot | null;
|
|
402
|
+
/**
|
|
403
|
+
* tells you if there is a connection in one output slot
|
|
404
|
+
*/
|
|
405
|
+
isOutputConnected(slot: number): boolean;
|
|
406
|
+
/**
|
|
407
|
+
* tells you if there is any connection in the output slots
|
|
408
|
+
*/
|
|
409
|
+
isAnyOutputConnected(): boolean;
|
|
410
|
+
/**
|
|
411
|
+
* retrieves all the nodes connected to this output slot
|
|
412
|
+
*/
|
|
413
|
+
getOutputNodes(slot: number): LGraphNode[] | null;
|
|
414
|
+
addOnTriggerInput(): number;
|
|
415
|
+
addOnExecutedOutput(): number;
|
|
416
|
+
onAfterExecuteNode(param: unknown, options?: {
|
|
417
|
+
action_call?: any;
|
|
418
|
+
}): void;
|
|
419
|
+
changeMode(modeTo: number): boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Triggers the node code execution, place a boolean/counter to mark the node as being executed
|
|
422
|
+
*/
|
|
423
|
+
doExecute(param?: unknown, options?: {
|
|
424
|
+
action_call?: any;
|
|
425
|
+
}): void;
|
|
426
|
+
/**
|
|
427
|
+
* Triggers an action, wrapped by logics to control execution flow
|
|
428
|
+
* @param action name
|
|
429
|
+
*/
|
|
430
|
+
actionDo(action: string, param: unknown, options: {
|
|
431
|
+
action_call?: string;
|
|
432
|
+
}): void;
|
|
433
|
+
/**
|
|
434
|
+
* Triggers an event in this node, this will trigger any output with the same name
|
|
435
|
+
* @param action name ( "on_play", ... ) if action is equivalent to false then the event is send to all
|
|
436
|
+
*/
|
|
437
|
+
trigger(action: string, param: unknown, options: {
|
|
438
|
+
action_call?: any;
|
|
439
|
+
}): void;
|
|
440
|
+
/**
|
|
441
|
+
* Triggers a slot event in this node: cycle output slots and launch execute/action on connected nodes
|
|
442
|
+
* @param slot the index of the output slot
|
|
443
|
+
* @param link_id [optional] in case you want to trigger and specific output link in a slot
|
|
444
|
+
*/
|
|
445
|
+
triggerSlot(slot: number, param: unknown, link_id: number | null, options?: {
|
|
446
|
+
action_call?: any;
|
|
447
|
+
}): void;
|
|
448
|
+
/**
|
|
449
|
+
* clears the trigger slot animation
|
|
450
|
+
* @param slot the index of the output slot
|
|
451
|
+
* @param link_id [optional] in case you want to trigger and specific output link in a slot
|
|
452
|
+
*/
|
|
453
|
+
clearTriggeredSlot(slot: number, link_id: number): void;
|
|
454
|
+
/**
|
|
455
|
+
* changes node size and triggers callback
|
|
456
|
+
*/
|
|
457
|
+
setSize(size: Size): void;
|
|
458
|
+
/**
|
|
459
|
+
* Expands the node size to fit its content.
|
|
460
|
+
*/
|
|
461
|
+
expandToFitContent(): void;
|
|
462
|
+
/**
|
|
463
|
+
* add a new property to this node
|
|
464
|
+
* @param type string defining the output type ("vec3","number",...)
|
|
465
|
+
* @param extra_info this can be used to have special properties of the property (like values, etc)
|
|
466
|
+
*/
|
|
467
|
+
addProperty(name: string, default_value: NodeProperty | undefined, type?: string, extra_info?: Partial<INodePropertyInfo>): INodePropertyInfo;
|
|
468
|
+
/**
|
|
469
|
+
* add a new output slot to use in this node
|
|
470
|
+
* @param type string defining the output type ("vec3","number",...)
|
|
471
|
+
* @param extra_info this can be used to have special properties of an output (label, special color, position, etc)
|
|
472
|
+
*/
|
|
473
|
+
addOutput<TProperties extends Partial<INodeOutputSlot>>(name: string, type: ISlotType, extra_info?: TProperties): INodeOutputSlot & TProperties;
|
|
474
|
+
/**
|
|
475
|
+
* remove an existing output slot
|
|
476
|
+
*/
|
|
477
|
+
removeOutput(slot: number): void;
|
|
478
|
+
/**
|
|
479
|
+
* add a new input slot to use in this node
|
|
480
|
+
* @param type string defining the input type ("vec3","number",...), it its a generic one use 0
|
|
481
|
+
* @param extra_info this can be used to have special properties of an input (label, color, position, etc)
|
|
482
|
+
*/
|
|
483
|
+
addInput<TProperties extends Partial<INodeInputSlot>>(name: string, type: ISlotType, extra_info?: TProperties): INodeInputSlot & TProperties;
|
|
484
|
+
/**
|
|
485
|
+
* remove an existing input slot
|
|
486
|
+
*/
|
|
487
|
+
removeInput(slot: number): void;
|
|
488
|
+
/**
|
|
489
|
+
* computes the minimum size of a node according to its inputs and output slots
|
|
490
|
+
* @returns the total size
|
|
491
|
+
*/
|
|
492
|
+
computeSize(out?: Size): Size;
|
|
493
|
+
inResizeCorner(canvasX: number, canvasY: number): boolean;
|
|
494
|
+
/**
|
|
495
|
+
* Returns which resize corner the point is over, if any.
|
|
496
|
+
* @param canvasX X position in canvas coordinates
|
|
497
|
+
* @param canvasY Y position in canvas coordinates
|
|
498
|
+
* @returns The compass corner the point is in, otherwise `undefined`.
|
|
499
|
+
*/
|
|
500
|
+
findResizeDirection(canvasX: number, canvasY: number): CompassCorners | undefined;
|
|
501
|
+
/**
|
|
502
|
+
* returns all the info available about a property of this node.
|
|
503
|
+
* @param property name of the property
|
|
504
|
+
* @returns the object with all the available info
|
|
505
|
+
*/
|
|
506
|
+
getPropertyInfo(property: string): any;
|
|
507
|
+
/**
|
|
508
|
+
* Defines a widget inside the node, it will be rendered on top of the node, you can control lots of properties
|
|
509
|
+
* @param type the widget type
|
|
510
|
+
* @param name the text to show on the widget
|
|
511
|
+
* @param value the default value
|
|
512
|
+
* @param callback function to call when it changes (optionally, it can be the name of the property to modify)
|
|
513
|
+
* @param options the object that contains special properties of this widget
|
|
514
|
+
* @returns the created widget object
|
|
515
|
+
*/
|
|
516
|
+
addWidget<Type extends TWidgetType, TValue extends WidgetTypeMap[Type]["value"]>(type: Type, name: string, value: TValue, callback: IBaseWidget["callback"] | string | null, options?: IWidgetOptions | string): WidgetTypeMap[Type] | IBaseWidget;
|
|
517
|
+
addCustomWidget<TPlainWidget extends IBaseWidget>(custom_widget: TPlainWidget): TPlainWidget | WidgetTypeMap[TPlainWidget["type"]];
|
|
518
|
+
addTitleButton(options: LGraphButtonOptions): LGraphButton;
|
|
519
|
+
onTitleButtonClick(button: LGraphButton, canvas: LGraphCanvas): void;
|
|
520
|
+
removeWidgetByName(name: string): void;
|
|
521
|
+
removeWidget(widget: IBaseWidget): void;
|
|
522
|
+
ensureWidgetRemoved(widget: IBaseWidget): void;
|
|
523
|
+
move(deltaX: number, deltaY: number): void;
|
|
524
|
+
/**
|
|
525
|
+
* Internal method to measure the node for rendering. Prefer {@link boundingRect} where possible.
|
|
526
|
+
*
|
|
527
|
+
* Populates {@link out} with the results in graph space.
|
|
528
|
+
* Populates {@link _collapsed_width} with the collapsed width if the node is collapsed.
|
|
529
|
+
* Adjusts for title and collapsed status, but does not call {@link onBounding}.
|
|
530
|
+
* @param out `x, y, width, height` are written to this array.
|
|
531
|
+
* @param ctx The canvas context to use for measuring text.
|
|
532
|
+
*/
|
|
533
|
+
measure(out: Rect, ctx: CanvasRenderingContext2D): void;
|
|
534
|
+
/**
|
|
535
|
+
* returns the bounding of the object, used for rendering purposes
|
|
536
|
+
* @param out {Float32Array[4]?} [optional] a place to store the output, to free garbage
|
|
537
|
+
* @param includeExternal {boolean?} [optional] set to true to
|
|
538
|
+
* include the shadow and connection points in the bounding calculation
|
|
539
|
+
* @returns the bounding box in format of [topleft_cornerx, topleft_cornery, width, height]
|
|
540
|
+
*/
|
|
541
|
+
getBounding(out?: Rect, includeExternal?: boolean): Rect;
|
|
542
|
+
/**
|
|
543
|
+
* Calculates the render area of this node, populating both {@link boundingRect} and {@link renderArea}.
|
|
544
|
+
* Called automatically at the start of every frame.
|
|
545
|
+
*/
|
|
546
|
+
updateArea(ctx: CanvasRenderingContext2D): void;
|
|
547
|
+
/**
|
|
548
|
+
* checks if a point is inside the shape of a node
|
|
549
|
+
*/
|
|
550
|
+
isPointInside(x: number, y: number): boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Checks if the provided point is inside this node's collapse button area.
|
|
553
|
+
* @param x X co-ordinate to check
|
|
554
|
+
* @param y Y co-ordinate to check
|
|
555
|
+
* @returns true if the x,y point is in the collapse button area, otherwise false
|
|
556
|
+
*/
|
|
557
|
+
isPointInCollapse(x: number, y: number): boolean;
|
|
558
|
+
/**
|
|
559
|
+
* Returns the input slot at the given position. Uses full 20 height, and approximates the label length.
|
|
560
|
+
* @param pos The graph co-ordinates to check
|
|
561
|
+
* @returns The input slot at the given position if found, otherwise `undefined`.
|
|
562
|
+
*/
|
|
563
|
+
getInputOnPos(pos: Point): INodeInputSlot | undefined;
|
|
564
|
+
/**
|
|
565
|
+
* Returns the output slot at the given position. Uses full 20x20 box for the slot.
|
|
566
|
+
* @param pos The graph co-ordinates to check
|
|
567
|
+
* @returns The output slot at the given position if found, otherwise `undefined`.
|
|
568
|
+
*/
|
|
569
|
+
getOutputOnPos(pos: Point): INodeOutputSlot | undefined;
|
|
570
|
+
/**
|
|
571
|
+
* Returns the input or output slot at the given position.
|
|
572
|
+
*
|
|
573
|
+
* Tries {@link getNodeInputOnPos} first, then {@link getNodeOutputOnPos}.
|
|
574
|
+
* @param pos The graph co-ordinates to check
|
|
575
|
+
* @returns The input or output slot at the given position if found, otherwise `undefined`.
|
|
576
|
+
*/
|
|
577
|
+
getSlotOnPos(pos: Point): INodeInputSlot | INodeOutputSlot | undefined;
|
|
578
|
+
/**
|
|
579
|
+
* @deprecated Use {@link getSlotOnPos} instead.
|
|
580
|
+
* checks if a point is inside a node slot, and returns info about which slot
|
|
581
|
+
* @param x
|
|
582
|
+
* @param y
|
|
583
|
+
* @returns if found the object contains { input|output: slot object, slot: number, link_pos: [x,y] }
|
|
584
|
+
*/
|
|
585
|
+
getSlotInPosition(x: number, y: number): IFoundSlot | null;
|
|
586
|
+
/**
|
|
587
|
+
* Gets the widget on this node at the given co-ordinates.
|
|
588
|
+
* @param canvasX X co-ordinate in graph space
|
|
589
|
+
* @param canvasY Y co-ordinate in graph space
|
|
590
|
+
* @returns The widget found, otherwise `null`
|
|
591
|
+
*/
|
|
592
|
+
getWidgetOnPos(canvasX: number, canvasY: number, includeDisabled?: boolean): IBaseWidget | undefined;
|
|
593
|
+
/**
|
|
594
|
+
* Returns the input slot with a given name (used for dynamic slots), -1 if not found
|
|
595
|
+
* @param name the name of the slot to find
|
|
596
|
+
* @param returnObj if the obj itself wanted
|
|
597
|
+
* @returns the slot (-1 if not found)
|
|
598
|
+
*/
|
|
599
|
+
findInputSlot<TReturn extends false>(name: string, returnObj?: TReturn): number;
|
|
600
|
+
findInputSlot<TReturn extends true>(name: string, returnObj?: TReturn): INodeInputSlot;
|
|
601
|
+
/**
|
|
602
|
+
* returns the output slot with a given name (used for dynamic slots), -1 if not found
|
|
603
|
+
* @param name the name of the slot to find
|
|
604
|
+
* @param returnObj if the obj itself wanted
|
|
605
|
+
* @returns the slot (-1 if not found)
|
|
606
|
+
*/
|
|
607
|
+
findOutputSlot<TReturn extends false>(name: string, returnObj?: TReturn): number;
|
|
608
|
+
findOutputSlot<TReturn extends true>(name: string, returnObj?: TReturn): INodeOutputSlot;
|
|
609
|
+
/**
|
|
610
|
+
* Finds the first free input slot.
|
|
611
|
+
* @param optsIn
|
|
612
|
+
* @returns The index of the first matching slot, the slot itself if returnObj is true, or -1 if not found.
|
|
613
|
+
*/
|
|
614
|
+
findInputSlotFree<TReturn extends false>(optsIn?: FindFreeSlotOptions & {
|
|
615
|
+
returnObj?: TReturn;
|
|
616
|
+
}): number;
|
|
617
|
+
findInputSlotFree<TReturn extends true>(optsIn?: FindFreeSlotOptions & {
|
|
618
|
+
returnObj?: TReturn;
|
|
619
|
+
}): INodeInputSlot | -1;
|
|
620
|
+
/**
|
|
621
|
+
* Finds the first free output slot.
|
|
622
|
+
* @param optsIn
|
|
623
|
+
* @returns The index of the first matching slot, the slot itself if returnObj is true, or -1 if not found.
|
|
624
|
+
*/
|
|
625
|
+
findOutputSlotFree<TReturn extends false>(optsIn?: FindFreeSlotOptions & {
|
|
626
|
+
returnObj?: TReturn;
|
|
627
|
+
}): number;
|
|
628
|
+
findOutputSlotFree<TReturn extends true>(optsIn?: FindFreeSlotOptions & {
|
|
629
|
+
returnObj?: TReturn;
|
|
630
|
+
}): INodeOutputSlot | -1;
|
|
631
|
+
/**
|
|
632
|
+
* findSlotByType for INPUTS
|
|
633
|
+
*/
|
|
634
|
+
findInputSlotByType<TReturn extends false>(type: ISlotType, returnObj?: TReturn, preferFreeSlot?: boolean, doNotUseOccupied?: boolean): number;
|
|
635
|
+
findInputSlotByType<TReturn extends true>(type: ISlotType, returnObj?: TReturn, preferFreeSlot?: boolean, doNotUseOccupied?: boolean): INodeInputSlot;
|
|
636
|
+
/**
|
|
637
|
+
* findSlotByType for OUTPUTS
|
|
638
|
+
*/
|
|
639
|
+
findOutputSlotByType<TReturn extends false>(type: ISlotType, returnObj?: TReturn, preferFreeSlot?: boolean, doNotUseOccupied?: boolean): number;
|
|
640
|
+
findOutputSlotByType<TReturn extends true>(type: ISlotType, returnObj?: TReturn, preferFreeSlot?: boolean, doNotUseOccupied?: boolean): INodeOutputSlot;
|
|
641
|
+
/**
|
|
642
|
+
* returns the output (or input) slot with a given type, -1 if not found
|
|
643
|
+
* @param input uise inputs instead of outputs
|
|
644
|
+
* @param type the type of the slot to find
|
|
645
|
+
* @param returnObj if the obj itself wanted
|
|
646
|
+
* @param preferFreeSlot if we want a free slot (if not found, will return the first of the type anyway)
|
|
647
|
+
* @returns the slot (-1 if not found)
|
|
648
|
+
*/
|
|
649
|
+
findSlotByType<TSlot extends true | false, TReturn extends false>(input: TSlot, type: ISlotType, returnObj?: TReturn, preferFreeSlot?: boolean, doNotUseOccupied?: boolean): number;
|
|
650
|
+
findSlotByType<TSlot extends true, TReturn extends true>(input: TSlot, type: ISlotType, returnObj?: TReturn, preferFreeSlot?: boolean, doNotUseOccupied?: boolean): INodeInputSlot | -1;
|
|
651
|
+
findSlotByType<TSlot extends false, TReturn extends true>(input: TSlot, type: ISlotType, returnObj?: TReturn, preferFreeSlot?: boolean, doNotUseOccupied?: boolean): INodeOutputSlot | -1;
|
|
652
|
+
/**
|
|
653
|
+
* Determines the slot index to connect to when attempting to connect by type.
|
|
654
|
+
* @param findInputs If true, searches for an input. Otherwise, an output.
|
|
655
|
+
* @param node The node at the other end of the connection.
|
|
656
|
+
* @param slotType The type of slot at the other end of the connection.
|
|
657
|
+
* @param options Search restrictions to adhere to.
|
|
658
|
+
* @see {connectByType}
|
|
659
|
+
* @see {connectByTypeOutput}
|
|
660
|
+
*/
|
|
661
|
+
findConnectByTypeSlot(findInputs: boolean, node: LGraphNode, slotType: ISlotType, options?: ConnectByTypeOptions): number | undefined;
|
|
662
|
+
/**
|
|
663
|
+
* Finds the first free output slot with any of the comma-delimited types in {@link type}.
|
|
664
|
+
*
|
|
665
|
+
* If no slots are free, falls back in order to:
|
|
666
|
+
* - The first free wildcard slot
|
|
667
|
+
* - The first occupied slot
|
|
668
|
+
* - The first occupied wildcard slot
|
|
669
|
+
* @param type The {@link ISlotType type} of slot to find
|
|
670
|
+
* @returns The index and slot if found, otherwise `undefined`.
|
|
671
|
+
*/
|
|
672
|
+
findOutputByType(type: ISlotType): {
|
|
673
|
+
index: number;
|
|
674
|
+
slot: INodeOutputSlot;
|
|
675
|
+
} | undefined;
|
|
676
|
+
/**
|
|
677
|
+
* Finds the first free input slot with any of the comma-delimited types in {@link type}.
|
|
678
|
+
*
|
|
679
|
+
* If no slots are free, falls back in order to:
|
|
680
|
+
* - The first free wildcard slot
|
|
681
|
+
* - The first occupied slot
|
|
682
|
+
* - The first occupied wildcard slot
|
|
683
|
+
* @param type The {@link ISlotType type} of slot to find
|
|
684
|
+
* @returns The index and slot if found, otherwise `undefined`.
|
|
685
|
+
*/
|
|
686
|
+
findInputByType(type: ISlotType): {
|
|
687
|
+
index: number;
|
|
688
|
+
slot: INodeInputSlot;
|
|
689
|
+
} | undefined;
|
|
690
|
+
/**
|
|
691
|
+
* connect this node output to the input of another node BY TYPE
|
|
692
|
+
* @param slot (could be the number of the slot or the string with the name of the slot)
|
|
693
|
+
* @param target_node the target node
|
|
694
|
+
* @param target_slotType the input slot type of the target node
|
|
695
|
+
* @returns the link_info is created, otherwise null
|
|
696
|
+
*/
|
|
697
|
+
connectByType(slot: number | string, target_node: LGraphNode, target_slotType: ISlotType, optsIn?: ConnectByTypeOptions): LLink | null;
|
|
698
|
+
/**
|
|
699
|
+
* connect this node input to the output of another node BY TYPE
|
|
700
|
+
* @param slot (could be the number of the slot or the string with the name of the slot)
|
|
701
|
+
* @param source_node the target node
|
|
702
|
+
* @param source_slotType the output slot type of the target node
|
|
703
|
+
* @returns the link_info is created, otherwise null
|
|
704
|
+
*/
|
|
705
|
+
connectByTypeOutput(slot: number | string, source_node: LGraphNode, source_slotType: ISlotType, optsIn?: ConnectByTypeOptions): LLink | null;
|
|
706
|
+
canConnectTo(node: NodeLike, toSlot: INodeInputSlot | SubgraphIO, fromSlot: INodeOutputSlot | SubgraphIO): boolean;
|
|
707
|
+
/**
|
|
708
|
+
* Connect an output of this node to an input of another node
|
|
709
|
+
* @param slot (could be the number of the slot or the string with the name of the slot)
|
|
710
|
+
* @param target_node the target node
|
|
711
|
+
* @param target_slot the input slot of the target node (could be the number of the slot or the string with the name of the slot, or -1 to connect a trigger)
|
|
712
|
+
* @returns the link_info is created, otherwise null
|
|
713
|
+
*/
|
|
714
|
+
connect(slot: number | string, target_node: LGraphNode, target_slot: ISlotType, afterRerouteId?: RerouteId): LLink | null;
|
|
715
|
+
/**
|
|
716
|
+
* Connect two slots between two nodes
|
|
717
|
+
* @param output The output slot to connect
|
|
718
|
+
* @param inputNode The node that the input slot is on
|
|
719
|
+
* @param input The input slot to connect
|
|
720
|
+
* @param afterRerouteId The reroute ID to use for the link
|
|
721
|
+
* @returns The link that was created, or null if the connection was blocked
|
|
722
|
+
*/
|
|
723
|
+
connectSlots(output: INodeOutputSlot, inputNode: LGraphNode, input: INodeInputSlot, afterRerouteId: RerouteId | undefined): LLink | null | undefined;
|
|
724
|
+
connectFloatingReroute(pos: Point, slot: INodeInputSlot | INodeOutputSlot, afterRerouteId?: RerouteId): Reroute;
|
|
725
|
+
/**
|
|
726
|
+
* disconnect one output to an specific node
|
|
727
|
+
* @param slot (could be the number of the slot or the string with the name of the slot)
|
|
728
|
+
* @param target_node the target node to which this slot is connected [Optional,
|
|
729
|
+
* if not target_node is specified all nodes will be disconnected]
|
|
730
|
+
* @returns if it was disconnected successfully
|
|
731
|
+
*/
|
|
732
|
+
disconnectOutput(slot: string | number, target_node?: LGraphNode): boolean;
|
|
733
|
+
/**
|
|
734
|
+
* Disconnect one input
|
|
735
|
+
* @param slot Input slot index, or the name of the slot
|
|
736
|
+
* @param keepReroutes If `true`, reroutes will not be garbage collected.
|
|
737
|
+
* @returns true if disconnected successfully or already disconnected, otherwise false
|
|
738
|
+
*/
|
|
739
|
+
disconnectInput(slot: number | string, keepReroutes?: boolean): boolean;
|
|
740
|
+
/**
|
|
741
|
+
* @deprecated Use {@link getInputPos} or {@link getOutputPos} instead.
|
|
742
|
+
* returns the center of a connection point in canvas coords
|
|
743
|
+
* @param is_input true if if a input slot, false if it is an output
|
|
744
|
+
* @param slot_number (could be the number of the slot or the string with the name of the slot)
|
|
745
|
+
* @param out [optional] a place to store the output, to free garbage
|
|
746
|
+
* @returns the position
|
|
747
|
+
*/
|
|
748
|
+
getConnectionPos(is_input: boolean, slot_number: number, out?: Point): Point;
|
|
749
|
+
/**
|
|
750
|
+
* Gets the position of an input slot, in graph co-ordinates.
|
|
751
|
+
*
|
|
752
|
+
* This method is preferred over the legacy {@link getConnectionPos} method.
|
|
753
|
+
* @param slot Input slot index
|
|
754
|
+
* @returns Position of the input slot
|
|
755
|
+
*/
|
|
756
|
+
getInputPos(slot: number): Point;
|
|
757
|
+
/**
|
|
758
|
+
* Gets the position of an input slot, in graph co-ordinates.
|
|
759
|
+
* @param input The actual node input object
|
|
760
|
+
* @returns Position of the centre of the input slot in graph co-ordinates.
|
|
761
|
+
*/
|
|
762
|
+
getInputSlotPos(input: INodeInputSlot): Point;
|
|
763
|
+
/**
|
|
764
|
+
* Gets the position of an output slot, in graph co-ordinates.
|
|
765
|
+
*
|
|
766
|
+
* This method is preferred over the legacy {@link getConnectionPos} method.
|
|
767
|
+
* @param slot Output slot index
|
|
768
|
+
* @returns Position of the output slot
|
|
769
|
+
*/
|
|
770
|
+
getOutputPos(slot: number): Point;
|
|
771
|
+
/** @inheritdoc */
|
|
772
|
+
snapToGrid(snapTo: number): boolean;
|
|
773
|
+
/** @see {@link snapToGrid} */
|
|
774
|
+
alignToGrid(): void;
|
|
775
|
+
trace(msg: string): void;
|
|
776
|
+
setDirtyCanvas(dirty_foreground: boolean, dirty_background?: boolean): void;
|
|
777
|
+
loadImage(url: string): HTMLImageElement;
|
|
778
|
+
/**
|
|
779
|
+
* Allows to get onMouseMove and onMouseUp events even if the mouse is out of focus
|
|
780
|
+
* @deprecated Use {@link LGraphCanvas.pointer} instead.
|
|
781
|
+
*/
|
|
782
|
+
captureInput(v: boolean): void;
|
|
783
|
+
get collapsed(): boolean;
|
|
784
|
+
get collapsible(): boolean;
|
|
785
|
+
/**
|
|
786
|
+
* Toggle node collapse (makes it smaller on the canvas)
|
|
787
|
+
*/
|
|
788
|
+
collapse(force?: boolean): void;
|
|
789
|
+
/**
|
|
790
|
+
* Toggles advanced mode of the node, showing advanced widgets
|
|
791
|
+
*/
|
|
792
|
+
toggleAdvanced(): void;
|
|
793
|
+
get pinned(): boolean;
|
|
794
|
+
/**
|
|
795
|
+
* Prevents the node being accidentally moved or resized by mouse interaction.
|
|
796
|
+
* Toggles pinned state if no value is provided.
|
|
797
|
+
*/
|
|
798
|
+
pin(v?: boolean): void;
|
|
799
|
+
unpin(): void;
|
|
800
|
+
localToScreen(x: number, y: number, dragAndScale: DragAndScale): Point;
|
|
801
|
+
get width(): number;
|
|
802
|
+
/**
|
|
803
|
+
* Returns the height of the node, including the title bar.
|
|
804
|
+
*/
|
|
805
|
+
get height(): number;
|
|
806
|
+
/**
|
|
807
|
+
* Returns the height of the node, excluding the title bar.
|
|
808
|
+
*/
|
|
809
|
+
get bodyHeight(): number;
|
|
810
|
+
drawBadges(ctx: CanvasRenderingContext2D, { gap }?: {
|
|
811
|
+
gap?: number | undefined;
|
|
812
|
+
}): void;
|
|
813
|
+
/**
|
|
814
|
+
* Renders the node's title bar background
|
|
815
|
+
*/
|
|
816
|
+
drawTitleBarBackground(ctx: CanvasRenderingContext2D, { scale, title_height, low_quality, }: DrawTitleOptions): void;
|
|
817
|
+
/**
|
|
818
|
+
* Renders the node's title box, i.e. the dot in front of the title text that
|
|
819
|
+
* when clicked toggles the node's collapsed state. The term `title box` comes
|
|
820
|
+
* from the original LiteGraph implementation.
|
|
821
|
+
*/
|
|
822
|
+
drawTitleBox(ctx: CanvasRenderingContext2D, { scale, low_quality, title_height, box_size, }: DrawTitleBoxOptions): void;
|
|
823
|
+
/**
|
|
824
|
+
* Renders the node's title text.
|
|
825
|
+
*/
|
|
826
|
+
drawTitleText(ctx: CanvasRenderingContext2D, { scale, default_title_color, low_quality, title_height, }: DrawTitleTextOptions): void;
|
|
827
|
+
/**
|
|
828
|
+
* Attempts to gracefully bypass this node in all of its connections by reconnecting all links.
|
|
829
|
+
*
|
|
830
|
+
* Each input is checked against each output. This is done on a matching index basis, i.e. input 3 -> output 3.
|
|
831
|
+
* If there are any input links remaining,
|
|
832
|
+
* and {@link flags}.{@link INodeFlags.keepAllLinksOnBypass keepAllLinksOnBypass} is `true`,
|
|
833
|
+
* each input will check for outputs that match, and take the first one that matches
|
|
834
|
+
* `true`: Try the index matching first, then every input to every output.
|
|
835
|
+
* `false`: Only matches indexes, e.g. input 3 to output 3.
|
|
836
|
+
*
|
|
837
|
+
* If {@link flags}.{@link INodeFlags.keepAllLinksOnBypass keepAllLinksOnBypass} is `undefined`, it will fall back to
|
|
838
|
+
* the static {@link keepAllLinksOnBypass}.
|
|
839
|
+
* @returns `true` if any new links were established, otherwise `false`.
|
|
840
|
+
* @todo Decision: Change API to return array of new links instead?
|
|
841
|
+
*/
|
|
842
|
+
connectInputToOutput(): boolean | undefined;
|
|
843
|
+
/**
|
|
844
|
+
* Returns `true` if the widget is visible, otherwise `false`.
|
|
845
|
+
*/
|
|
846
|
+
isWidgetVisible(widget: IBaseWidget): boolean;
|
|
847
|
+
drawWidgets(ctx: CanvasRenderingContext2D, { lowQuality, editorAlpha, }: DrawWidgetsOptions): void;
|
|
848
|
+
/**
|
|
849
|
+
* When {@link LGraphNode.collapsed} is `true`, this method draws the node's collapsed slots.
|
|
850
|
+
*/
|
|
851
|
+
drawCollapsedSlots(ctx: CanvasRenderingContext2D): void;
|
|
852
|
+
get slots(): (INodeInputSlot | INodeOutputSlot)[];
|
|
853
|
+
/**
|
|
854
|
+
* Returns the input slot that is associated with the given widget.
|
|
855
|
+
*/
|
|
856
|
+
getSlotFromWidget(widget: IBaseWidget | undefined): INodeInputSlot | undefined;
|
|
857
|
+
/**
|
|
858
|
+
* Returns the widget that is associated with the given input slot.
|
|
859
|
+
*/
|
|
860
|
+
getWidgetFromSlot(slot: INodeInputSlot): IBaseWidget | undefined;
|
|
861
|
+
/**
|
|
862
|
+
* Draws the node's input and output slots.
|
|
863
|
+
*/
|
|
864
|
+
drawSlots(ctx: CanvasRenderingContext2D, { fromSlot, colorContext, editorAlpha, lowQuality, }: DrawSlotsOptions): void;
|
|
865
|
+
/**
|
|
866
|
+
* @internal Sets the internal concrete slot arrays, ensuring they are instances of
|
|
867
|
+
* {@link NodeInputSlot} or {@link NodeOutputSlot}.
|
|
868
|
+
*
|
|
869
|
+
* A temporary workaround until duck-typed inputs and outputs
|
|
870
|
+
* have been removed from the ecosystem.
|
|
871
|
+
*/
|
|
872
|
+
_setConcreteSlots(): void;
|
|
873
|
+
/**
|
|
874
|
+
* Arranges node elements in preparation for rendering (slots & widgets).
|
|
875
|
+
*/
|
|
876
|
+
arrange(): void;
|
|
877
|
+
/**
|
|
878
|
+
* Draws a progress bar on the node.
|
|
879
|
+
* @param ctx The canvas context to draw on
|
|
880
|
+
*/
|
|
881
|
+
drawProgressBar(ctx: CanvasRenderingContext2D): void;
|
|
882
|
+
}
|
|
883
|
+
export {};
|