@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,407 @@
1
+ import { DragAndScaleState } from './DragAndScale';
2
+ import { LGraphEventMap } from './infrastructure/LGraphEventMap';
3
+ import { Dictionary, IContextMenuValue, LinkNetwork, LinkSegment, MethodNames, OptionalProps, Point, Positionable } from './interfaces';
4
+ import { ExportedSubgraph, ISerialisedGraph, Serialisable, SerialisableGraph, SerialisableReroute } from './types/serialisation';
5
+ import { UUID } from './utils/uuid';
6
+ import { CustomEventTarget } from './infrastructure/CustomEventTarget';
7
+ import { LGraphCanvas } from './LGraphCanvas';
8
+ import { LGraphGroup } from './LGraphGroup';
9
+ import { LGraphNode, NodeId } from './LGraphNode';
10
+ import { SubgraphNode } from './litegraph';
11
+ import { LinkId, LLink } from './LLink';
12
+ import { Reroute, RerouteId } from './Reroute';
13
+ import { Subgraph } from './subgraph/Subgraph';
14
+ import { LGraphEventMode } from './types/globalEnums';
15
+ export interface LGraphState {
16
+ lastGroupId: number;
17
+ lastNodeId: number;
18
+ lastLinkId: number;
19
+ lastRerouteId: number;
20
+ }
21
+ type ParamsArray<T extends Record<any, any>, K extends MethodNames<T>> = Parameters<T[K]>[1] extends undefined ? Parameters<T[K]> | Parameters<T[K]>[0] : Parameters<T[K]>;
22
+ /** Configuration used by {@link LGraph} `config`. */
23
+ export interface LGraphConfig {
24
+ /** @deprecated Legacy config - unused */
25
+ align_to_grid?: any;
26
+ links_ontop?: any;
27
+ }
28
+ export interface LGraphExtra extends Dictionary<unknown> {
29
+ reroutes?: SerialisableReroute[];
30
+ linkExtensions?: {
31
+ id: number;
32
+ parentId: number | undefined;
33
+ }[];
34
+ ds?: DragAndScaleState;
35
+ }
36
+ export interface BaseLGraph {
37
+ /** The root graph. */
38
+ readonly rootGraph: LGraph;
39
+ }
40
+ /**
41
+ * LGraph is the class that contain a full graph. We instantiate one and add nodes to it, and then we can run the execution loop.
42
+ * supported callbacks:
43
+ * + onNodeAdded: when a new node is added to the graph
44
+ * + onNodeRemoved: when a node inside this graph is removed
45
+ */
46
+ export declare class LGraph implements LinkNetwork, BaseLGraph, Serialisable<SerialisableGraph> {
47
+ #private;
48
+ static serialisedSchemaVersion: 1;
49
+ static STATUS_STOPPED: number;
50
+ static STATUS_RUNNING: number;
51
+ /** List of LGraph properties that are manually handled by {@link LGraph.configure}. */
52
+ static readonly ConfigureProperties: Set<string>;
53
+ id: UUID;
54
+ revision: number;
55
+ _version: number;
56
+ /** The backing store for links. Keys are wrapped in String() */
57
+ _links: Map<LinkId, LLink>;
58
+ /**
59
+ * Indexed property access is deprecated.
60
+ * Backwards compatibility with a Proxy has been added, but will eventually be removed.
61
+ *
62
+ * Use {@link Map} methods:
63
+ * ```
64
+ * const linkId = 123
65
+ * const link = graph.links.get(linkId)
66
+ * // Deprecated: const link = graph.links[linkId]
67
+ * ```
68
+ */
69
+ links: Map<LinkId, LLink> & Record<LinkId, LLink>;
70
+ list_of_graphcanvas: LGraphCanvas[] | null;
71
+ status: number;
72
+ state: LGraphState;
73
+ readonly events: CustomEventTarget<LGraphEventMap, "configuring" | "configured" | "subgraph-created" | "convert-to-subgraph" | "open-subgraph">;
74
+ readonly _subgraphs: Map<UUID, Subgraph>;
75
+ _nodes: (LGraphNode | SubgraphNode)[];
76
+ _nodes_by_id: Record<NodeId, LGraphNode>;
77
+ _nodes_in_order: LGraphNode[];
78
+ _nodes_executable: LGraphNode[] | null;
79
+ _groups: LGraphGroup[];
80
+ iteration: number;
81
+ globaltime: number;
82
+ /** @deprecated Unused */
83
+ runningtime: number;
84
+ fixedtime: number;
85
+ fixedtime_lapse: number;
86
+ elapsed_time: number;
87
+ last_update_time: number;
88
+ starttime: number;
89
+ catch_errors: boolean;
90
+ execution_timer_id?: number | null;
91
+ errors_in_execution?: boolean;
92
+ /** @deprecated Unused */
93
+ execution_time: number;
94
+ _last_trigger_time?: number;
95
+ filter?: string;
96
+ /** Must contain serialisable values, e.g. primitive types */
97
+ config: LGraphConfig;
98
+ vars: Dictionary<unknown>;
99
+ nodes_executing: boolean[];
100
+ nodes_actioning: (string | boolean)[];
101
+ nodes_executedAction: string[];
102
+ extra: LGraphExtra;
103
+ /** @deprecated Deserialising a workflow sets this unused property. */
104
+ version?: number;
105
+ /** @returns Whether the graph has no items */
106
+ get empty(): boolean;
107
+ /** @returns All items on the canvas that can be selected */
108
+ positionableItems(): Generator<LGraphNode | LGraphGroup | Reroute>;
109
+ get floatingLinks(): ReadonlyMap<LinkId, LLink>;
110
+ /** All reroutes in this graph. */
111
+ get reroutes(): Map<RerouteId, Reroute>;
112
+ get rootGraph(): LGraph;
113
+ get isRootGraph(): boolean;
114
+ /** @deprecated See {@link state}.{@link LGraphState.lastNodeId lastNodeId} */
115
+ get last_node_id(): number;
116
+ set last_node_id(value: number);
117
+ /** @deprecated See {@link state}.{@link LGraphState.lastLinkId lastLinkId} */
118
+ get last_link_id(): number;
119
+ set last_link_id(value: number);
120
+ onAfterStep?(): void;
121
+ onBeforeStep?(): void;
122
+ onPlayEvent?(): void;
123
+ onStopEvent?(): void;
124
+ onAfterExecute?(): void;
125
+ onExecuteStep?(): void;
126
+ onNodeAdded?(node: LGraphNode): void;
127
+ onNodeRemoved?(node: LGraphNode): void;
128
+ onTrigger?(action: string, param: unknown): void;
129
+ onBeforeChange?(graph: LGraph, info?: LGraphNode): void;
130
+ onAfterChange?(graph: LGraph, info?: LGraphNode | null): void;
131
+ onConnectionChange?(node: LGraphNode): void;
132
+ on_change?(graph: LGraph): void;
133
+ onSerialize?(data: ISerialisedGraph | SerialisableGraph): void;
134
+ onConfigure?(data: ISerialisedGraph | SerialisableGraph): void;
135
+ onGetNodeMenuOptions?(options: (IContextMenuValue<unknown> | null)[], node: LGraphNode): void;
136
+ private _input_nodes?;
137
+ /**
138
+ * See {@link LGraph}
139
+ * @param o data from previous serialization [optional]
140
+ */
141
+ constructor(o?: ISerialisedGraph | SerialisableGraph);
142
+ /**
143
+ * Removes all nodes from this graph
144
+ */
145
+ clear(): void;
146
+ get subgraphs(): Map<UUID, Subgraph>;
147
+ get nodes(): (LGraphNode | SubgraphNode)[];
148
+ get groups(): LGraphGroup[];
149
+ /**
150
+ * Attach Canvas to this graph
151
+ */
152
+ attachCanvas(canvas: LGraphCanvas): void;
153
+ /**
154
+ * Detach Canvas from this graph
155
+ */
156
+ detachCanvas(canvas: LGraphCanvas): void;
157
+ /**
158
+ * @deprecated Will be removed in 0.9
159
+ * Starts running this graph every interval milliseconds.
160
+ * @param interval amount of milliseconds between executions, if 0 then it renders to the monitor refresh rate
161
+ */
162
+ start(interval?: number): void;
163
+ /**
164
+ * @deprecated Will be removed in 0.9
165
+ * Stops the execution loop of the graph
166
+ */
167
+ stop(): void;
168
+ /**
169
+ * Run N steps (cycles) of the graph
170
+ * @param num number of steps to run, default is 1
171
+ * @param do_not_catch_errors [optional] if you want to try/catch errors
172
+ * @param limit max number of nodes to execute (used to execute from start to a node)
173
+ */
174
+ runStep(num: number, do_not_catch_errors: boolean, limit?: number): void;
175
+ /**
176
+ * Updates the graph execution order according to relevance of the nodes (nodes with only outputs have more relevance than
177
+ * nodes with only inputs.
178
+ */
179
+ updateExecutionOrder(): void;
180
+ computeExecutionOrder(only_onExecute: boolean, set_level?: boolean): LGraphNode[];
181
+ /**
182
+ * Positions every node in a more readable manner
183
+ */
184
+ arrange(margin?: number, layout?: string): void;
185
+ /**
186
+ * Returns the amount of time the graph has been running in milliseconds
187
+ * @returns number of milliseconds the graph has been running
188
+ */
189
+ getTime(): number;
190
+ /**
191
+ * Returns the amount of time accumulated using the fixedtime_lapse var.
192
+ * This is used in context where the time increments should be constant
193
+ * @returns number of milliseconds the graph has been running
194
+ */
195
+ getFixedTime(): number;
196
+ /**
197
+ * Returns the amount of time it took to compute the latest iteration.
198
+ * Take into account that this number could be not correct
199
+ * if the nodes are using graphical actions
200
+ * @returns number of milliseconds it took the last cycle
201
+ */
202
+ getElapsedTime(): number;
203
+ /**
204
+ * @deprecated Will be removed in 0.9
205
+ * Sends an event to all the nodes, useful to trigger stuff
206
+ * @param eventname the name of the event (function to be called)
207
+ * @param params parameters in array format
208
+ */
209
+ sendEventToAllNodes(eventname: string, params?: object | object[], mode?: LGraphEventMode): void;
210
+ /**
211
+ * Runs an action on every canvas registered to this graph.
212
+ * @param action Action to run for every canvas
213
+ */
214
+ canvasAction(action: (canvas: LGraphCanvas) => void): void;
215
+ /** @deprecated See {@link LGraph.canvasAction} */
216
+ sendActionToCanvas<T extends MethodNames<LGraphCanvas>>(action: T, params?: ParamsArray<LGraphCanvas, T>): void;
217
+ /**
218
+ * Adds a new node instance to this graph
219
+ * @param node the instance of the node
220
+ */
221
+ add(node: LGraphNode | LGraphGroup, skip_compute_order?: boolean): LGraphNode | null | undefined;
222
+ /**
223
+ * Removes a node from the graph
224
+ * @param node the instance of the node
225
+ */
226
+ remove(node: LGraphNode | LGraphGroup): void;
227
+ /**
228
+ * Returns a node by its id.
229
+ */
230
+ getNodeById(id: NodeId | null | undefined): LGraphNode | null;
231
+ /**
232
+ * Returns a list of nodes that matches a class
233
+ * @param classObject the class itself (not an string)
234
+ * @returns a list with all the nodes of this type
235
+ */
236
+ findNodesByClass(classObject: Function, result?: LGraphNode[]): LGraphNode[];
237
+ /**
238
+ * Returns a list of nodes that matches a type
239
+ * @param type the name of the node type
240
+ * @returns a list with all the nodes of this type
241
+ */
242
+ findNodesByType(type: string, result: LGraphNode[]): LGraphNode[];
243
+ /**
244
+ * Returns the first node that matches a name in its title
245
+ * @param title the name of the node to search
246
+ * @returns the node or null
247
+ */
248
+ findNodeByTitle(title: string): LGraphNode | null;
249
+ /**
250
+ * Returns a list of nodes that matches a name
251
+ * @param title the name of the node to search
252
+ * @returns a list with all the nodes with this name
253
+ */
254
+ findNodesByTitle(title: string): LGraphNode[];
255
+ /**
256
+ * Returns the top-most node in this position of the canvas
257
+ * @param x the x coordinate in canvas space
258
+ * @param y the y coordinate in canvas space
259
+ * @param nodeList a list with all the nodes to search from, by default is all the nodes in the graph
260
+ * @returns the node at this position or null
261
+ */
262
+ getNodeOnPos(x: number, y: number, nodeList?: LGraphNode[]): LGraphNode | null;
263
+ /**
264
+ * Returns the top-most group in that position
265
+ * @param x The x coordinate in canvas space
266
+ * @param y The y coordinate in canvas space
267
+ * @returns The group or null
268
+ */
269
+ getGroupOnPos(x: number, y: number): LGraphGroup | undefined;
270
+ /**
271
+ * Returns the top-most group with a titlebar in the provided position.
272
+ * @param x The x coordinate in canvas space
273
+ * @param y The y coordinate in canvas space
274
+ * @returns The group or null
275
+ */
276
+ getGroupTitlebarOnPos(x: number, y: number): LGraphGroup | undefined;
277
+ /**
278
+ * Finds a reroute a the given graph point
279
+ * @param x X co-ordinate in graph space
280
+ * @param y Y co-ordinate in graph space
281
+ * @returns The first reroute under the given co-ordinates, or undefined
282
+ */
283
+ getRerouteOnPos(x: number, y: number, reroutes?: Iterable<Reroute>): Reroute | undefined;
284
+ /**
285
+ * Snaps the provided items to a grid.
286
+ *
287
+ * Item positions are reounded to the nearest multiple of {@link LiteGraph.CANVAS_GRID_SIZE}.
288
+ *
289
+ * When {@link LiteGraph.alwaysSnapToGrid} is enabled
290
+ * and the grid size is falsy, a default of 1 is used.
291
+ * @param items The items to be snapped to the grid
292
+ * @todo Currently only snaps nodes.
293
+ */
294
+ snapToGrid(items: Set<Positionable>): void;
295
+ /**
296
+ * Finds the size of the grid that items should be snapped to when moved.
297
+ * @returns The size of the grid that items should be snapped to
298
+ */
299
+ getSnapToGridSize(): number;
300
+ /**
301
+ * @deprecated Will be removed in 0.9
302
+ * Checks that the node type matches the node type registered,
303
+ * used when replacing a nodetype by a newer version during execution
304
+ * this replaces the ones using the old version with the new version
305
+ */
306
+ checkNodeTypes(): void;
307
+ trigger(action: string, param: unknown): void;
308
+ /** @todo Clean up - never implemented. */
309
+ triggerInput(name: string, value: any): void;
310
+ /** @todo Clean up - never implemented. */
311
+ setCallback(name: string, func: any): void;
312
+ beforeChange(info?: LGraphNode): void;
313
+ afterChange(info?: LGraphNode | null): void;
314
+ /**
315
+ * clears the triggered slot animation in all links (stop visual animation)
316
+ */
317
+ clearTriggeredSlots(): void;
318
+ change(): void;
319
+ setDirtyCanvas(fg: boolean, bg?: boolean): void;
320
+ addFloatingLink(link: LLink): LLink;
321
+ removeFloatingLink(link: LLink): void;
322
+ /**
323
+ * Finds the link with the provided ID.
324
+ * @param id ID of link to find
325
+ * @returns The link with the provided {@link id}, otherwise `undefined`. Always returns `undefined` if `id` is nullish.
326
+ */
327
+ getLink(id: null | undefined): undefined;
328
+ getLink(id: LinkId | null | undefined): LLink | undefined;
329
+ /**
330
+ * Finds the reroute with the provided ID.
331
+ * @param id ID of reroute to find
332
+ * @returns The reroute with the provided {@link id}, otherwise `undefined`. Always returns `undefined` if `id` is nullish.
333
+ */
334
+ getReroute(id: null | undefined): undefined;
335
+ getReroute(id: RerouteId | null | undefined): Reroute | undefined;
336
+ /**
337
+ * Configures a reroute on the graph where ID is already known (probably deserialisation).
338
+ * Creates the object if it does not exist.
339
+ * @param serialisedReroute See {@link SerialisableReroute}
340
+ */
341
+ setReroute({ id, parentId, pos, linkIds, floating }: OptionalProps<SerialisableReroute, "id">): Reroute;
342
+ /**
343
+ * Creates a new reroute and adds it to the graph.
344
+ * @param pos Position in graph space
345
+ * @param before The existing link segment (reroute, link) that will be after this reroute,
346
+ * going from the node output to input.
347
+ * @returns The newly created reroute - typically ignored.
348
+ */
349
+ createReroute(pos: Point, before: LinkSegment): Reroute;
350
+ /**
351
+ * Removes a reroute from the graph
352
+ * @param id ID of reroute to remove
353
+ */
354
+ removeReroute(id: RerouteId): void;
355
+ /**
356
+ * Destroys a link
357
+ */
358
+ removeLink(link_id: LinkId): void;
359
+ /**
360
+ * Creates a new subgraph definition, and adds it to the graph.
361
+ * @param data Exported data (typically serialised) to configure the new subgraph with
362
+ * @returns The newly created subgraph definition.
363
+ */
364
+ createSubgraph(data: ExportedSubgraph): Subgraph;
365
+ convertToSubgraph(items: Set<Positionable>): {
366
+ subgraph: Subgraph;
367
+ node: SubgraphNode;
368
+ };
369
+ /**
370
+ * Resolve a path of subgraph node IDs into a list of subgraph nodes.
371
+ * Not intended to be run from subgraphs.
372
+ * @param nodeIds An ordered list of node IDs, from the root graph to the most nested subgraph node
373
+ * @returns An ordered list of nested subgraph nodes.
374
+ */
375
+ resolveSubgraphIdPath(nodeIds: readonly NodeId[]): SubgraphNode[];
376
+ /**
377
+ * Creates a Object containing all the info about this graph, it can be serialized
378
+ * @deprecated Use {@link asSerialisable}, which returns the newer schema version.
379
+ * @returns value of the node
380
+ */
381
+ serialize(option?: {
382
+ sortNodes: boolean;
383
+ }): ISerialisedGraph;
384
+ /**
385
+ * Prepares a shallow copy of this object for immediate serialisation or structuredCloning.
386
+ * The return value should be discarded immediately.
387
+ * @param options Serialise options = currently `sortNodes: boolean`, whether to sort nodes by ID.
388
+ * @returns A shallow copy of parts of this graph, with shallow copies of its serialisable objects.
389
+ * Mutating the properties of the return object may result in changes to your graph.
390
+ * It is intended for use with {@link structuredClone} or {@link JSON.stringify}.
391
+ */
392
+ asSerialisable(options?: {
393
+ sortNodes: boolean;
394
+ }): SerialisableGraph & Required<Pick<SerialisableGraph, "nodes" | "groups" | "extra">>;
395
+ protected _configureBase(data: ISerialisedGraph | SerialisableGraph): void;
396
+ /**
397
+ * Configure a graph from a JSON string
398
+ * @param data The deserialised object to configure this graph from
399
+ * @param keep_old If `true`, the graph will not be cleared prior to
400
+ * adding the configuration.
401
+ */
402
+ configure(data: ISerialisedGraph | SerialisableGraph, keep_old?: boolean): boolean | undefined;
403
+ get primaryCanvas(): LGraphCanvas | undefined;
404
+ set primaryCanvas(canvas: LGraphCanvas);
405
+ load(url: string | Blob | URL | File, callback: () => void): void;
406
+ }
407
+ export {};
@@ -0,0 +1,33 @@
1
+ import { LGraphIcon, LGraphIconOptions } from './LGraphIcon';
2
+ export declare enum BadgePosition {
3
+ TopLeft = "top-left",
4
+ TopRight = "top-right"
5
+ }
6
+ export interface LGraphBadgeOptions {
7
+ text: string;
8
+ fgColor?: string;
9
+ bgColor?: string;
10
+ fontSize?: number;
11
+ padding?: number;
12
+ height?: number;
13
+ cornerRadius?: number;
14
+ iconOptions?: LGraphIconOptions;
15
+ xOffset?: number;
16
+ yOffset?: number;
17
+ }
18
+ export declare class LGraphBadge {
19
+ text: string;
20
+ fgColor: string;
21
+ bgColor: string;
22
+ fontSize: number;
23
+ padding: number;
24
+ height: number;
25
+ cornerRadius: number;
26
+ icon?: LGraphIcon;
27
+ xOffset: number;
28
+ yOffset: number;
29
+ constructor({ text, fgColor, bgColor, fontSize, padding, height, cornerRadius, iconOptions, xOffset, yOffset, }: LGraphBadgeOptions);
30
+ get visible(): boolean;
31
+ getWidth(ctx: CanvasRenderingContext2D): number;
32
+ draw(ctx: CanvasRenderingContext2D, x: number, y: number): void;
33
+ }
@@ -0,0 +1,27 @@
1
+ import { Rectangle } from './infrastructure/Rectangle';
2
+ import { LGraphBadge, LGraphBadgeOptions } from './LGraphBadge';
3
+ export interface LGraphButtonOptions extends LGraphBadgeOptions {
4
+ name?: string;
5
+ }
6
+ export declare class LGraphButton extends LGraphBadge {
7
+ name?: string;
8
+ _last_area: Rectangle;
9
+ constructor(options: LGraphButtonOptions);
10
+ getWidth(ctx: CanvasRenderingContext2D): number;
11
+ /**
12
+ * @internal
13
+ *
14
+ * Draws the button and updates its last rendered area for hit detection.
15
+ * @param ctx The canvas rendering context.
16
+ * @param x The x-coordinate to draw the button at.
17
+ * @param y The y-coordinate to draw the button at.
18
+ */
19
+ draw(ctx: CanvasRenderingContext2D, x: number, y: number): void;
20
+ /**
21
+ * Checks if a point is inside the button's last rendered area.
22
+ * @param x The x-coordinate of the point.
23
+ * @param y The y-coordinate of the point.
24
+ * @returns `true` if the point is inside the button, otherwise `false`.
25
+ */
26
+ isPointInside(x: number, y: number): boolean;
27
+ }