@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
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2013 by Javi Agenjo
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
|
|
2
|
+
# @codebolt/litegraph
|
|
3
|
+
|
|
4
|
+
This is the litegraph version used in [ComfyUI_frontend](https://github.com/Comfy-Org/ComfyUI_frontend).
|
|
5
|
+
|
|
6
|
+
It is a fork of the original `litegraph.js`. Some APIs may by unchanged, however it is largely incompatible with the original.
|
|
7
|
+
|
|
8
|
+
Some early highlights:
|
|
9
|
+
|
|
10
|
+
- Accumulated comfyUI custom changes (2024-01 ~ 2024-05) (https://github.com/Comfy-Org/litegraph.js/pull/1)
|
|
11
|
+
- Type schema change for ComfyUI_frontend TS migration (https://github.com/Comfy-Org/litegraph.js/pull/3)
|
|
12
|
+
- Zoom fix (https://github.com/Comfy-Org/litegraph.js/pull/7)
|
|
13
|
+
- Emit search box triggering custom events (<https://github.com/Comfy-Org/litegraph.js/pull/10>)
|
|
14
|
+
- Truncate overflowing combo widget text (<https://github.com/Comfy-Org/litegraph.js/pull/17>)
|
|
15
|
+
- Sort node based on ID on graph serialization (<https://github.com/Comfy-Org/litegraph.js/pull/21>)
|
|
16
|
+
- Fix empty input not used when connecting links (<https://github.com/Comfy-Org/litegraph.js/pull/24>)
|
|
17
|
+
- Batch output connection move/disconnect (<https://github.com/Comfy-Org/litegraph.js/pull/39>)
|
|
18
|
+
- And now with hundreds more...
|
|
19
|
+
|
|
20
|
+
# Install
|
|
21
|
+
|
|
22
|
+
`npm i @codebolt/litegraph`
|
|
23
|
+
|
|
24
|
+
# litegraph.js
|
|
25
|
+
|
|
26
|
+
A TypeScript library to create graphs in the browser similar to Unreal Blueprints.
|
|
27
|
+
|
|
28
|
+
<details>
|
|
29
|
+
|
|
30
|
+
<summary>Description of the original litegraph.js</summary>
|
|
31
|
+
|
|
32
|
+
A library in Javascript to create graphs in the browser similar to Unreal Blueprints. Nodes can be programmed easily and it includes an editor to construct and tests the graphs.
|
|
33
|
+
|
|
34
|
+
It can be integrated easily in any existing web applications and graphs can be run without the need of the editor.
|
|
35
|
+
|
|
36
|
+
</details>
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- Renders on Canvas2D (zoom in/out and panning, easy to render complex interfaces, can be used inside a WebGLTexture)
|
|
43
|
+
- Easy to use editor (searchbox, keyboard shortcuts, multiple selection, context menu, ...)
|
|
44
|
+
- Optimized to support hundreds of nodes per graph (on editor but also on execution)
|
|
45
|
+
- Customizable theme (colors, shapes, background)
|
|
46
|
+
- Callbacks to personalize every action/drawing/event of nodes
|
|
47
|
+
- Graphs can be executed in NodeJS
|
|
48
|
+
- Highly customizable nodes (color, shape, widgets, custom rendering)
|
|
49
|
+
- Easy to integrate in any JS application (one single file, no dependencies)
|
|
50
|
+
- Typescript support
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
You can install it using npm
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install @comfyorg/litegraph
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## How to code a new Node type
|
|
61
|
+
|
|
62
|
+
Here is an example of how to build a node that sums two inputs:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { LiteGraph, LGraphNode } from "./litegraph"
|
|
66
|
+
|
|
67
|
+
class MyAddNode extends LGraphNode {
|
|
68
|
+
// Name to show
|
|
69
|
+
title = "Sum"
|
|
70
|
+
|
|
71
|
+
constructor() {
|
|
72
|
+
this.addInput("A", "number")
|
|
73
|
+
this.addInput("B", "number")
|
|
74
|
+
this.addOutput("A+B", "number")
|
|
75
|
+
this.properties.precision = 1
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Function to call when the node is executed
|
|
79
|
+
onExecute() {
|
|
80
|
+
var A = this.getInputData(0)
|
|
81
|
+
if (A === undefined) A = 0
|
|
82
|
+
var B = this.getInputData(1)
|
|
83
|
+
if (B === undefined) B = 0
|
|
84
|
+
this.setOutputData(0, A + B)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Register the node type
|
|
89
|
+
LiteGraph.registerNodeType("basic/sum", MyAddNode)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Server side
|
|
93
|
+
|
|
94
|
+
It also works server-side using NodeJS although some nodes do not work in server (audio, graphics, input, etc).
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { LiteGraph, LGraph } from "./litegraph.js"
|
|
98
|
+
|
|
99
|
+
const graph = new LGraph()
|
|
100
|
+
|
|
101
|
+
const firstNode = LiteGraph.createNode("basic/sum")
|
|
102
|
+
graph.add(firstNode)
|
|
103
|
+
|
|
104
|
+
const secondNode = LiteGraph.createNode("basic/sum")
|
|
105
|
+
graph.add(secondNode)
|
|
106
|
+
|
|
107
|
+
firstNode.connect(0, secondNode, 1)
|
|
108
|
+
|
|
109
|
+
graph.start()
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Projects using it
|
|
113
|
+
|
|
114
|
+
### [ComfyUI](https://github.com/comfyanonymous/ComfyUI)
|
|
115
|
+
|
|
116
|
+

|
|
117
|
+
|
|
118
|
+
### Projects using the original litegraph.js
|
|
119
|
+
|
|
120
|
+
<details>
|
|
121
|
+
|
|
122
|
+
<summary>Click to expand</summary>
|
|
123
|
+
|
|
124
|
+
### [webglstudio.org](http://webglstudio.org)
|
|
125
|
+
|
|
126
|
+

|
|
127
|
+
|
|
128
|
+
### [MOI Elephant](http://moiscript.weebly.com/elephant-systegraveme-nodal.html)
|
|
129
|
+
|
|
130
|
+

|
|
131
|
+
|
|
132
|
+
### Mynodes
|
|
133
|
+
|
|
134
|
+

|
|
135
|
+
|
|
136
|
+
</details>
|
|
137
|
+
|
|
138
|
+
## Feedback
|
|
139
|
+
|
|
140
|
+
Please [open an issue](https://github.com/codebolt/litegraph.js/issues/) on the GitHub repo.
|
|
141
|
+
|
|
142
|
+
# Development
|
|
143
|
+
|
|
144
|
+
Litegraph has no runtime dependencies. The build tooling has been tested on Node.JS 20.18.x
|
|
145
|
+
|
|
146
|
+
## Releasing
|
|
147
|
+
|
|
148
|
+
Use GitHub actions to release normal versions.
|
|
149
|
+
|
|
150
|
+
1. Run the `Release a New Version` action, selecting the version incrment type
|
|
151
|
+
1. Merge the resultion PR
|
|
152
|
+
1. A GitHub release is automatically published on merge
|
|
153
|
+
|
|
154
|
+
### Pre-release
|
|
155
|
+
|
|
156
|
+
The action directly translates `Version increment type` to the npm version command. `Pre-release ID (suffix)` is the option for the `--preid` argument.
|
|
157
|
+
|
|
158
|
+
e.g. Use `prerelease` increment type to automatically bump the patch version and create a pre-release version. Subsequent runs of prerelease will update the prerelease version only.
|
|
159
|
+
Use `patch` when ready to remove the pre-release suffix.
|
|
160
|
+
|
|
161
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { CompassCorners } from './interfaces';
|
|
2
|
+
import { CanvasPointerEvent } from './types/events';
|
|
3
|
+
/**
|
|
4
|
+
* Allows click and drag actions to be declared ahead of time during a pointerdown event.
|
|
5
|
+
*
|
|
6
|
+
* By default, it retains the most recent event of each type until it is reset (on pointerup).
|
|
7
|
+
* - {@link eDown}
|
|
8
|
+
* - {@link eMove}
|
|
9
|
+
* - {@link eUp}
|
|
10
|
+
*
|
|
11
|
+
* Depending on whether the user clicks or drags the pointer, only the appropriate callbacks are called:
|
|
12
|
+
* - {@link onClick}
|
|
13
|
+
* - {@link onDoubleClick}
|
|
14
|
+
* - {@link onDragStart}
|
|
15
|
+
* - {@link onDrag}
|
|
16
|
+
* - {@link onDragEnd}
|
|
17
|
+
* - {@link finally}
|
|
18
|
+
* @see
|
|
19
|
+
* - {@link LGraphCanvas.processMouseDown}
|
|
20
|
+
* - {@link LGraphCanvas.processMouseMove}
|
|
21
|
+
* - {@link LGraphCanvas.processMouseUp}
|
|
22
|
+
*/
|
|
23
|
+
export declare class CanvasPointer {
|
|
24
|
+
#private;
|
|
25
|
+
/** Maximum time in milliseconds to ignore click drift */
|
|
26
|
+
static bufferTime: number;
|
|
27
|
+
/** Maximum gap between pointerup and pointerdown events to be considered as a double click */
|
|
28
|
+
static doubleClickTime: number;
|
|
29
|
+
/** Maximum offset from click location */
|
|
30
|
+
static get maxClickDrift(): number;
|
|
31
|
+
static set maxClickDrift(value: number);
|
|
32
|
+
/** The element this PointerState should capture input against when dragging. */
|
|
33
|
+
element: Element;
|
|
34
|
+
/** Pointer ID used by drag capture. */
|
|
35
|
+
pointerId?: number;
|
|
36
|
+
/** Set to true when if the pointer moves far enough after a down event, before the corresponding up event is fired. */
|
|
37
|
+
dragStarted: boolean;
|
|
38
|
+
/** The {@link eUp} from the last successful click */
|
|
39
|
+
eLastDown?: CanvasPointerEvent;
|
|
40
|
+
/** Used downstream for touch event support. */
|
|
41
|
+
isDouble: boolean;
|
|
42
|
+
/** Used downstream for touch event support. */
|
|
43
|
+
isDown: boolean;
|
|
44
|
+
/** The resize handle currently being hovered or dragged */
|
|
45
|
+
resizeDirection?: CompassCorners;
|
|
46
|
+
/**
|
|
47
|
+
* If `true`, {@link eDown}, {@link eMove}, and {@link eUp} will be set to
|
|
48
|
+
* `undefined` when {@link reset} is called.
|
|
49
|
+
*
|
|
50
|
+
* Default: `true`
|
|
51
|
+
*/
|
|
52
|
+
clearEventsOnReset: boolean;
|
|
53
|
+
/** The last pointerdown event for the primary button */
|
|
54
|
+
eDown?: CanvasPointerEvent;
|
|
55
|
+
/** The last pointermove event for the primary button */
|
|
56
|
+
eMove?: CanvasPointerEvent;
|
|
57
|
+
/** The last pointerup event for the primary button */
|
|
58
|
+
eUp?: CanvasPointerEvent;
|
|
59
|
+
/**
|
|
60
|
+
* If set, as soon as the mouse moves outside the click drift threshold, this action is run once.
|
|
61
|
+
* @param pointer [DEPRECATED] This parameter will be removed in a future release.
|
|
62
|
+
* @param eMove The pointermove event of this ongoing drag action.
|
|
63
|
+
*
|
|
64
|
+
* It is possible for no `pointermove` events to occur, but still be far from
|
|
65
|
+
* the original `pointerdown` event. In this case, {@link eMove} will be null, and
|
|
66
|
+
* {@link onDragEnd} will be called immediately after {@link onDragStart}.
|
|
67
|
+
*/
|
|
68
|
+
onDragStart?(pointer: this, eMove?: CanvasPointerEvent): unknown;
|
|
69
|
+
/**
|
|
70
|
+
* Called on pointermove whilst dragging.
|
|
71
|
+
* @param eMove The pointermove event of this ongoing drag action
|
|
72
|
+
*/
|
|
73
|
+
onDrag?(eMove: CanvasPointerEvent): unknown;
|
|
74
|
+
/**
|
|
75
|
+
* Called on pointerup after dragging (i.e. not called if clicked).
|
|
76
|
+
* @param upEvent The pointerup or pointermove event that triggered this callback
|
|
77
|
+
*/
|
|
78
|
+
onDragEnd?(upEvent: CanvasPointerEvent): unknown;
|
|
79
|
+
/**
|
|
80
|
+
* Callback that will be run once, the next time a pointerup event appears to be a normal click.
|
|
81
|
+
* @param upEvent The pointerup or pointermove event that triggered this callback
|
|
82
|
+
*/
|
|
83
|
+
onClick?(upEvent: CanvasPointerEvent): unknown;
|
|
84
|
+
/**
|
|
85
|
+
* Callback that will be run once, the next time a pointerup event appears to be a normal click.
|
|
86
|
+
* @param upEvent The pointerup or pointermove event that triggered this callback
|
|
87
|
+
*/
|
|
88
|
+
onDoubleClick?(upEvent: CanvasPointerEvent): unknown;
|
|
89
|
+
/**
|
|
90
|
+
* Run-once callback, called at the end of any click or drag, whether or not it was successful in any way.
|
|
91
|
+
*
|
|
92
|
+
* The setter of this callback will call the existing value before replacing it.
|
|
93
|
+
* Therefore, simply setting this value twice will execute the first callback.
|
|
94
|
+
*/
|
|
95
|
+
get finally(): (() => unknown) | undefined;
|
|
96
|
+
set finally(value: (() => unknown) | undefined);
|
|
97
|
+
constructor(element: Element);
|
|
98
|
+
/**
|
|
99
|
+
* Callback for `pointerdown` events. To be used as the event handler (or called by it).
|
|
100
|
+
* @param e The `pointerdown` event
|
|
101
|
+
*/
|
|
102
|
+
down(e: CanvasPointerEvent): void;
|
|
103
|
+
/**
|
|
104
|
+
* Callback for `pointermove` events. To be used as the event handler (or called by it).
|
|
105
|
+
* @param e The `pointermove` event
|
|
106
|
+
*/
|
|
107
|
+
move(e: CanvasPointerEvent): void;
|
|
108
|
+
/**
|
|
109
|
+
* Callback for `pointerup` events. To be used as the event handler (or called by it).
|
|
110
|
+
* @param e The `pointerup` event
|
|
111
|
+
*/
|
|
112
|
+
up(e: CanvasPointerEvent): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Resets the state of this {@link CanvasPointer} instance.
|
|
115
|
+
*
|
|
116
|
+
* The {@link finally} callback is first executed, then all callbacks and intra-click
|
|
117
|
+
* state is cleared.
|
|
118
|
+
*/
|
|
119
|
+
reset(): void;
|
|
120
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ContextMenuDivElement, IContextMenuOptions, IContextMenuValue } from './interfaces';
|
|
2
|
+
export interface ContextMenu<TValue = unknown> {
|
|
3
|
+
constructor: new (...args: ConstructorParameters<typeof ContextMenu<TValue>>) => ContextMenu<TValue>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* ContextMenu from LiteGUI
|
|
7
|
+
*/
|
|
8
|
+
export declare class ContextMenu<TValue = unknown> {
|
|
9
|
+
options: IContextMenuOptions<TValue>;
|
|
10
|
+
parentMenu?: ContextMenu<TValue>;
|
|
11
|
+
root: ContextMenuDivElement<TValue>;
|
|
12
|
+
current_submenu?: ContextMenu<TValue>;
|
|
13
|
+
lock?: boolean;
|
|
14
|
+
controller: AbortController;
|
|
15
|
+
/**
|
|
16
|
+
* @todo Interface for values requires functionality change - currently accepts
|
|
17
|
+
* an array of strings, functions, objects, nulls, or undefined.
|
|
18
|
+
* @param values (allows object { title: "Nice text", callback: function ... })
|
|
19
|
+
* @param options [optional] Some options:\
|
|
20
|
+
* - title: title to show on top of the menu
|
|
21
|
+
* - callback: function to call when an option is clicked, it receives the item information
|
|
22
|
+
* - ignore_item_callbacks: ignores the callback inside the item, it just calls the options.callback
|
|
23
|
+
* - event: you can pass a MouseEvent, this way the ContextMenu appears in that position
|
|
24
|
+
*/
|
|
25
|
+
constructor(values: readonly (string | IContextMenuValue<TValue> | null)[], options: IContextMenuOptions<TValue>);
|
|
26
|
+
/**
|
|
27
|
+
* Checks if {@link node} is inside this context menu or any of its submenus
|
|
28
|
+
* @param node The {@link Node} to check
|
|
29
|
+
* @param visited A set of visited menus to avoid circular references
|
|
30
|
+
* @returns `true` if {@link node} is inside this context menu or any of its submenus
|
|
31
|
+
*/
|
|
32
|
+
containsNode(node: Node, visited?: Set<this>): boolean;
|
|
33
|
+
addItem(name: string | null, value: string | IContextMenuValue<TValue> | null, options: IContextMenuOptions<TValue>): HTMLElement;
|
|
34
|
+
close(e?: MouseEvent, ignore_parent_menu?: boolean): void;
|
|
35
|
+
/** @deprecated Likely unused, however code search was inconclusive (too many results to check by hand). */
|
|
36
|
+
static trigger(element: HTMLDivElement, event_name: string, params: MouseEvent): CustomEvent;
|
|
37
|
+
getTopMenu(): ContextMenu<TValue>;
|
|
38
|
+
getFirstEvent(): MouseEvent | undefined;
|
|
39
|
+
/** @deprecated Unused. */
|
|
40
|
+
static isCursorOverElement(event: MouseEvent, element: HTMLDivElement): boolean;
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Point, Rect } from './interfaces';
|
|
2
|
+
import { LGraphCanvas } from './litegraph';
|
|
3
|
+
export declare class CurveEditor {
|
|
4
|
+
points: Point[];
|
|
5
|
+
selected: number;
|
|
6
|
+
nearest: number;
|
|
7
|
+
size: Rect | null;
|
|
8
|
+
must_update: boolean;
|
|
9
|
+
margin: number;
|
|
10
|
+
_nearest?: number;
|
|
11
|
+
constructor(points: Point[]);
|
|
12
|
+
static sampleCurve(f: number, points: Point[]): number | undefined;
|
|
13
|
+
draw(ctx: CanvasRenderingContext2D, size: Rect, graphcanvas?: LGraphCanvas, background_color?: string, line_color?: string, inactive?: boolean): void;
|
|
14
|
+
onMouseDown(localpos: Point, graphcanvas: LGraphCanvas): boolean | undefined;
|
|
15
|
+
onMouseMove(localpos: Point, graphcanvas: LGraphCanvas): void;
|
|
16
|
+
onMouseUp(): boolean;
|
|
17
|
+
getCloserPoint(pos: Point, max_dist: number): number;
|
|
18
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Point, ReadOnlyRect, Rect } from './interfaces';
|
|
2
|
+
import { EaseFunction, Rectangle } from './litegraph';
|
|
3
|
+
export interface DragAndScaleState {
|
|
4
|
+
/**
|
|
5
|
+
* The offset from the top-left of the current canvas viewport to `[0, 0]` in graph space.
|
|
6
|
+
* Or said another way, the inverse offset of the viewport.
|
|
7
|
+
*/
|
|
8
|
+
offset: [number, number];
|
|
9
|
+
/** The scale of the graph. */
|
|
10
|
+
scale: number;
|
|
11
|
+
}
|
|
12
|
+
export type AnimationOptions = {
|
|
13
|
+
/** Duration of the animation in milliseconds. */
|
|
14
|
+
duration?: number;
|
|
15
|
+
/** Relative target zoom level. 1 means the view is fit exactly on the bounding box. */
|
|
16
|
+
zoom?: number;
|
|
17
|
+
/** The animation easing function (curve) */
|
|
18
|
+
easing?: EaseFunction;
|
|
19
|
+
};
|
|
20
|
+
export declare class DragAndScale {
|
|
21
|
+
#private;
|
|
22
|
+
/**
|
|
23
|
+
* The state of this DragAndScale instance.
|
|
24
|
+
*
|
|
25
|
+
* Implemented as a POCO that can be proxied without side-effects.
|
|
26
|
+
*/
|
|
27
|
+
state: DragAndScaleState;
|
|
28
|
+
lastState: DragAndScaleState;
|
|
29
|
+
/** Maximum scale (zoom in) */
|
|
30
|
+
max_scale: number;
|
|
31
|
+
/** Minimum scale (zoom out) */
|
|
32
|
+
min_scale: number;
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
last_mouse: Point;
|
|
35
|
+
element: HTMLCanvasElement;
|
|
36
|
+
visible_area: Rectangle;
|
|
37
|
+
dragging?: boolean;
|
|
38
|
+
viewport?: Rect;
|
|
39
|
+
onredraw?(das: DragAndScale): void;
|
|
40
|
+
onChanged?(scale: number, offset: Point): void;
|
|
41
|
+
get offset(): [number, number];
|
|
42
|
+
set offset(value: Point);
|
|
43
|
+
get scale(): number;
|
|
44
|
+
set scale(value: number);
|
|
45
|
+
constructor(element: HTMLCanvasElement);
|
|
46
|
+
computeVisibleArea(viewport: Rect | undefined): void;
|
|
47
|
+
toCanvasContext(ctx: CanvasRenderingContext2D): void;
|
|
48
|
+
convertOffsetToCanvas(pos: Point): Point;
|
|
49
|
+
convertCanvasToOffset(pos: Point, out?: Point): Point;
|
|
50
|
+
/** @deprecated Has not been kept up to date */
|
|
51
|
+
mouseDrag(x: number, y: number): void;
|
|
52
|
+
changeScale(value: number, zooming_center?: Point, roundToScaleOne?: boolean): void;
|
|
53
|
+
changeDeltaScale(value: number, zooming_center?: Point): void;
|
|
54
|
+
/**
|
|
55
|
+
* Fits the view to the specified bounds.
|
|
56
|
+
* @param bounds The bounds to fit the view to, defined by a rectangle.
|
|
57
|
+
*/
|
|
58
|
+
fitToBounds(bounds: ReadOnlyRect, { zoom }?: {
|
|
59
|
+
zoom?: number;
|
|
60
|
+
}): void;
|
|
61
|
+
/**
|
|
62
|
+
* Starts an animation to fit the view around the specified selection of nodes.
|
|
63
|
+
* @param bounds The bounds to animate the view to, defined by a rectangle.
|
|
64
|
+
*/
|
|
65
|
+
animateToBounds(bounds: ReadOnlyRect, setDirty: () => void, { duration, zoom, easing, }?: AnimationOptions): void;
|
|
66
|
+
reset(): void;
|
|
67
|
+
}
|