@codebolt/litegraph 0.0.1 → 0.0.3

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 CHANGED
@@ -1,19 +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.
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 CHANGED
@@ -1,161 +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
- ![Node Graph](imgs/node_graph_example.png "Node graph example")
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
- ![ComfyUI default workflow](https://github.com/comfyanonymous/ComfyUI/blob/6efe561c2a7321501b1b27f47039c7616dda1860/comfyui_screenshot.png "ComfyUI default workflow")
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
- ![WebGLStudio](imgs/webglstudio.gif "WebGLStudio")
127
-
128
- ### [MOI Elephant](http://moiscript.weebly.com/elephant-systegraveme-nodal.html)
129
-
130
- ![MOI Elephant](imgs/elephant.gif "MOI Elephant")
131
-
132
- ### Mynodes
133
-
134
- ![MyNodes](imgs/mynodes.png "MyNodes")
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
-
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
+ ![Node Graph](imgs/node_graph_example.png "Node graph example")
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
+ ![ComfyUI default workflow](https://github.com/comfyanonymous/ComfyUI/blob/6efe561c2a7321501b1b27f47039c7616dda1860/comfyui_screenshot.png "ComfyUI default workflow")
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
+ ![WebGLStudio](imgs/webglstudio.gif "WebGLStudio")
127
+
128
+ ### [MOI Elephant](http://moiscript.weebly.com/elephant-systegraveme-nodal.html)
129
+
130
+ ![MOI Elephant](imgs/elephant.gif "MOI Elephant")
131
+
132
+ ### Mynodes
133
+
134
+ ![MyNodes](imgs/mynodes.png "MyNodes")
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
+
@@ -180,8 +180,12 @@
180
180
  .litegraph.litesearchbox {
181
181
  font-family: Tahoma, sans-serif;
182
182
  position: absolute;
183
- background-color: rgba(0, 0, 0, 0.5);
184
- padding-top: 4px;
183
+ background-color: #2e2e2e;
184
+ padding: 8px;
185
+ box-shadow: 0 0 10px black !important;
186
+ border-radius: 6px;
187
+ min-width: 300px;
188
+ z-index: 10;
185
189
  }
186
190
 
187
191
  .litegraph.litesearchbox input,
@@ -189,12 +193,20 @@
189
193
  margin-top: 3px;
190
194
  min-width: 60px;
191
195
  min-height: 1.5em;
192
- background-color: black;
193
- border: 0;
194
- color: white;
195
- padding-left: 10px;
196
+ background-color: #1a1a1a;
197
+ border: 1px solid #444;
198
+ color: #aaa;
199
+ padding: 4px 10px;
196
200
  margin-right: 5px;
197
201
  max-width: 300px;
202
+ border-radius: 4px;
203
+ outline: none;
204
+ }
205
+
206
+ .litegraph.litesearchbox input:focus,
207
+ .litegraph.litesearchbox select:focus {
208
+ border-color: #666;
209
+ color: #fff;
198
210
  }
199
211
 
200
212
  .litegraph.litesearchbox .name {
@@ -202,52 +214,86 @@
202
214
  min-width: 60px;
203
215
  min-height: 1.5em;
204
216
  padding-left: 10px;
217
+ color: #dde;
218
+ font-weight: bold;
205
219
  }
206
220
 
207
221
  .litegraph.litesearchbox .helper {
208
222
  overflow: auto;
209
223
  max-height: 200px;
210
- margin-top: 2px;
224
+ margin-top: 8px;
225
+ border-radius: 4px;
226
+ }
227
+
228
+ /* Custom scrollbar for searchbox helper */
229
+ .litegraph.litesearchbox .helper::-webkit-scrollbar {
230
+ width: 8px;
231
+ }
232
+
233
+ .litegraph.litesearchbox .helper::-webkit-scrollbar-track {
234
+ background: #1a1a1a;
235
+ border-radius: 4px;
236
+ }
237
+
238
+ .litegraph.litesearchbox .helper::-webkit-scrollbar-thumb {
239
+ background: #555;
240
+ border-radius: 4px;
241
+ }
242
+
243
+ .litegraph.litesearchbox .helper::-webkit-scrollbar-thumb:hover {
244
+ background: #666;
245
+ }
246
+
247
+ /* Firefox scrollbar styling */
248
+ .litegraph.litesearchbox .helper {
249
+ scrollbar-width: thin;
250
+ scrollbar-color: #555 #1a1a1a;
211
251
  }
212
252
 
213
253
  .litegraph.lite-search-item {
214
254
  font-family: Tahoma, sans-serif;
215
- background-color: rgba(0, 0, 0, 0.5);
216
- color: white;
217
- padding-top: 2px;
255
+ background-color: transparent;
256
+ color: #aaa;
257
+ padding: 4px 8px;
258
+ margin: 2px;
259
+ cursor: pointer;
260
+ border-radius: 4px;
261
+ font-size: 12px;
262
+ -moz-user-select: none;
263
+ -webkit-user-select: none;
264
+ user-select: none;
218
265
  }
219
266
 
220
267
  .litegraph.lite-search-item.not_in_filter {
221
- /*background-color: rgba(50, 50, 50, 0.5);*/
222
- /*color: #999;*/
223
- color: #b99;
268
+ color: #999;
224
269
  font-style: italic;
270
+ opacity: 0.7;
225
271
  }
226
272
 
227
273
  .litegraph.lite-search-item.generic_type {
228
- /*background-color: rgba(50, 50, 50, 0.5);*/
229
- /*color: #DD9;*/
230
274
  color: #999;
231
275
  font-style: italic;
276
+ opacity: 0.7;
232
277
  }
233
278
 
234
279
  .litegraph.lite-search-item:hover,
235
280
  .litegraph.lite-search-item.selected {
236
- cursor: pointer;
237
- background-color: white;
238
- color: black;
281
+ background-color: #444 !important;
282
+ color: #eee;
283
+ transition: all 0.2s;
239
284
  }
240
285
 
241
286
  .litegraph.lite-search-item-type {
242
287
  display: inline-block;
243
- background: rgba(0, 0, 0, 0.2);
288
+ background: #1a1a1a;
244
289
  margin-left: 5px;
245
- font-size: 14px;
290
+ font-size: 10px;
246
291
  padding: 2px 5px;
247
292
  position: relative;
248
- top: -2px;
293
+ top: -1px;
249
294
  opacity: 0.8;
250
- border-radius: 4px;
295
+ border-radius: 3px;
296
+ border: 1px solid #444;
251
297
  }
252
298
 
253
299
  /* DIALOGs ******/
@@ -11398,7 +11398,7 @@ class LGraphCanvas {
11398
11398
  if (this.bgcanvas == this.canvas) {
11399
11399
  this.drawBackCanvas();
11400
11400
  } else {
11401
- const scale = window.devicePixelRatio;
11401
+ const scale = 1;
11402
11402
  ctx.drawImage(
11403
11403
  this.bgcanvas,
11404
11404
  0,
@@ -11478,7 +11478,7 @@ class LGraphCanvas {
11478
11478
  ctx.strokeStyle = "#FFF";
11479
11479
  if (eDown && eMove) {
11480
11480
  const transform = ctx.getTransform();
11481
- const ratio = Math.max(1, window.devicePixelRatio);
11481
+ const ratio = 1;
11482
11482
  ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
11483
11483
  const x2 = eDown.safeOffsetX;
11484
11484
  const y = eDown.safeOffsetY;
@@ -11637,7 +11637,7 @@ class LGraphCanvas {
11637
11637
  }
11638
11638
  const bg_already_painted = this.onRenderBackground ? this.onRenderBackground(canvas2, ctx) : false;
11639
11639
  if (!this.viewport) {
11640
- const scale = window.devicePixelRatio;
11640
+ const scale = 1;
11641
11641
  ctx.restore();
11642
11642
  ctx.setTransform(scale, 0, 0, scale, 0, 0);
11643
11643
  }